I'm debugging Fortran code in Mac OSX 11.4 using Visual Studio Code using GDB C++ debugger and Fortran Breakpoint Support in Visual Studio Code. In launch.json
, I have the following code:
{
"version": "0.2.0",
"configurations": [
{
"name": "Run GDB",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"externalConsole": false,
"MIMode": "gdb",
"preLaunchTask": "make"
},
]
}
In tasks.json
, I have the following code:
{
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "make",
"options": {
"cwd": "${workspaceRoot}"
}
}
]
}
In my Makefile
I have:
# variables
FC=gfortran
SRC=Parameters.f90 Globals.f90 Procedures.f90 random.f90 SimulateEarnings.f90 Grids.f90 ValueFunctions.f90 Simulations.f90 RunSimulations.f90
OBJ=${SRC:.f90=.o}
# convert all .f90 files into .o files
%.o: %.f90
$(FC) -c -g $<
# create executable
a.out: ${OBJ}
$(FC) ${OBJ}
# clean
clean:
rm *.o a.out
# execute
run:
make
./a.out
I can run make
and make run
in the terminal with no issues. In Visual Studio Code, I then place a breakpoint using F9 at a place in my code and press F5 to begin debugging. When doing so, three issues arise:
- The code does not always stop at my breakpoint and the only way I can get it to eventually stop is to repeatedly restart debugging until it finally stops.
- Once it does finally stop, the values of all variables are not displayed. The only way I can find them is by manually adding variables to "WATCH".
- The values of some of the variables in "WATCH" are incorrect. If I set a breakpoint on the line of code at which I print a variable to the console, the value printed to the console doesn't match what is displayed in "WATCH".
Thanks in advance for the help and sorry for the long question!
Aucun commentaire:
Enregistrer un commentaire