-
Hi All, I am one of the devs for the Modern Fortran extension and the accompanying language server fortls. I was wondering if you could shed some light with regards to your implementation of the Debug Adapter Protocol (DAP). Because Fortran in UNIX platforms can use GDB for debugging (for both GCC and Intel compilers), I opted a few years ago to piggyback on your extension's implementation of DAP which has worked out amazingly well. The only small problem is that hovering over a member object while debugging in Fortran produces no output. The only way to navigate into the value of an object is by starting from the very top one I suspect this has something to do with the fact that GDB output of Fortran objects and only Fortran objects use parentheses instead of curly braces (functions and subroutines seem to use curly braces like in C/C++) Fortran (GDB)$1 = ( b = ( a = ( var = 10 ), r = 0.100000001 ), dp = 0.20000000298023224 ) C++ (GDB)$1 = {b = {a = {var = 10}, r = 0.100000001}, dp = 0.20000000000000001} Strangely enough, Fortran arrays also use Do you know what is going on? And more importantly, if the solution is something as trivial as parsing the GDB output with a different regex, would you consider adding that functionality to the extension (hidden behind a flag or something) so we could then set it in our As always, any and all help would be greatly appreciated. P.S. hover and completion requests to our Language Server work as expected, so I don't think this is caused by using a different Steps to replicate & MWEmodule c_mod
implicit none
private
public :: type_c, temp
type, public :: type_a
integer :: var = 10
end type type_a
type, public :: type_b
type(type_a) :: a
real :: r = 0.1
end type type_b
type, public :: type_c
type(type_b) :: b
double precision :: dp = 0.2
end type type_c
contains
real function temp() result(val)
val = 10.0
end function temp
end module c_mod
program overloads
use c_mod
implicit none
type(type_c) :: c; integer :: a(10) = 1
print*, c%b%a%var
print*, a
end program overloads
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
Hi guys, any thoughts on this? Any and all input would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
The issue stems from the type information that GDB is returning to the debug adapter. Hovering over:Fortran
C++:
Within the locals window:Fortran
C++
In C++ it gives us the exact C++ class where during Fortran debugging it seems to provide definitions based on Fortran. Here is a reference to where the debug adapter recieved the variable information from GDB and tries to visualize it https://github.com/microsoft/MIEngine/blob/8456c49b4731971b885c2909f9feaac4bdcd494d/src/MIDebugEngine/Natvis.Impl/Natvis.cs#L915-L947 As the debug type Ideally the debug type would be different (e.g. MIEngine is under the MIT License so your extension can build and ship a version targeted for Fortran. |
Beta Was this translation helpful? Give feedback.
-
... or, as you don't want to use the rest of cpptools here (only the debugger) you may also try a different one that does not target C/C++ but GDB: https://github.com/WebFreak001/code-debug. Note: if your language server did not included it before, consider to register an // Match any character except a set of characters which often break interesting sub-expressions
let expression: RegExp = /([^()\[\]{}<>\s+\-/%~#^;=|,`!]|\->)+/g; and that may not match Fortran best. For more details see Debug hover API, which allows you to say about what expressions are seen under your cursor. |
Beta Was this translation helpful? Give feedback.
-
@gnikit To clarify your question, is this only about hover? In other words, if you type in the expression you are trying to hover over (I think If yes, then @GitMensch's reply from yesterday is the answer. |
Beta Was this translation helpful? Give feedback.
... or, as you don't want to use the rest of cpptools here (only the debugger) you may also try a different one that does not target C/C++ but GDB: https://github.com/WebFreak001/code-debug.
Note: if your language server did not included it before, consider to register an
EvaluatableExpressionProvider
- allowing to split (or combine) by Fortran specific expressions. Background: The vscode debug browser ui used to split words by the following: