Skip to content

Add debug mode section for Fortran developers#7

Closed
stelais wants to merge 1 commit into
mainfrom
debug_mode
Closed

Add debug mode section for Fortran developers#7
stelais wants to merge 1 commit into
mainfrom
debug_mode

Conversation

@stelais

@stelais stelais commented Dec 17, 2025

Copy link
Copy Markdown
Collaborator

Added a section on running in debug mode with gdb, including a sample script.

Added a section on running in debug mode with gdb, including a sample script.
@golmschenk

Copy link
Copy Markdown
Owner

Hi @stelais, thanks for extra documentation. I had a few comments/questions though.

First, is there a reason you're running GDB via a script instead of interactively? I think for most people debugging something, it's probably easiest to use the debugger interactively. Usually when you're debugging something, you don't know exactly what the problem is, so you'll run new commands as needed to explore the problem and discover new things. Let me know if there's a reason you were thinking a script would be best here.

Next, I think a couple of the parts of the script are a bit odd or unnecessary. You would probably want bt full before the run call, since presumably you'd like the full backtrace from that run call. I'm pretty certain that handle SIGSEGV stop should be the default, so that is probably unnecessary. Finally, the indentation and spacing is a bit inconsistent making it a bit hard to see which parts are where. Notably the if statement indentations make it seem like more is inside the if statements than actually is.

Let me know what you think.

@stelais

stelais commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator Author

First, is there a reason you're running GDB via a script instead of interactively? I think for most people debugging something, it's probably easiest to use the debugger interactively. Usually when you're debugging something, you don't know exactly what the problem is, so you'll run new commands as needed to explore the problem and discover new things. Let me know if there's a reason you were thinking a script would be best here.

The reason I thought of running it via a script was to keep all the relevant information in one place, including the input and output filenames, to avoid any misuse. I was also trying to make sure the user understands the executable is in the build directory and that this is the version of the executable they should be using. I agree that it doesn’t have to be a script, we could also run the commands separately.

Next, I think a couple of the parts of the script are a bit odd or unnecessary. You would probably want bt full before the run call, since presumably you'd like the full backtrace from that run call.

I can be wrong. But I thought using bt full after the run was the correct way. (I saw some people using it after the run/error, like here: https://stackoverflow.com/questions/23769165/understanding-the-output-of-gdbs-bt-full-command or https://visualgdb.com/gdbreference/commands/backtrace)

I'm pretty certain that handle SIGSEGV stop should be the default, so that is probably unnecessary.

I didn't know it was the default. Sounds good to remove this line.

Finally, the indentation and spacing is a bit inconsistent making it a bit hard to see which parts are where. Notably the if statement indentations make it seem like more is inside the if statements than actually is.

I used the Code>Reformat Code from PyCharm. I agree that the ifs look odd. I can reformat it.

@golmschenk

Copy link
Copy Markdown
Owner

@stelais, Ah! Sorry, you're right about bt full. I was thinking that was an option switch, but it's a command that shows the backtrace of the already caught exception.

I do think listing the commands the user should use as a series of steps rather than writing it as a script might make more sense though, because that much more easily adapts to whatever problem the user is actually encountering.

For the formatting, I'm not sure PyCharm does much for Shell scripts. I would only be speculating on why this is, but I'm guessing this would be because Shell scripts can sometimes have structure where a formatting engine has not way to determine nesting.

@stelais

stelais commented Dec 18, 2025

Copy link
Copy Markdown
Collaborator Author

Sounds good. Let me cancel this pull request, and send another one with adjustments. I can list the commands the user should use as a series of steps. This will also eliminate the ifs , since I can explicitly tell the user to verify the executable was built correct, and ask the user to write the path to the executable.

@stelais stelais closed this Dec 18, 2025
@golmschenk

Copy link
Copy Markdown
Owner

Thanks! Sorry for the extra work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants