-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugger: Fix debugging of multi-threaded programs #1170
Conversation
40b78a6
to
292e4c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiled and tested with Geany 1.37 (git >= 5cc69b3d)
@elextr Anyone to review this to get it merged? I don't think it's being maintained by anyone current, so I worded in much detail in the commit message to explain both the cause and the fix. |
@nomadbyte yeah, its over 10 years since the maintainer listed contributed. We don't usually summarily remove maintainers, but since there are no contact details in the file to check if they are still interested I think the plugin could be marked orphaned so someone else can take over, if nobody objects (and someone reminds me) in a couple of weeks I'll do that @frlan @eht16 @b4n |
I'd look at who committed recently and ask whether they'd be willing to maintain it, but as far as removing maintainership information I really it's fine 10 years later :) |
Just for the record, a comment about the fix to @nomadbyte , i have been using the debugger with very good results with Geany 1.37 (git >= 5cc69b3d) . I don't know if anyone else tested this fix with newer Geany. I was more interested in debugging multi-threaded applications but recently i had to debug minicom to mimic some of its features in one local application here and depending on where i set the breakpoint (in minicom), the next [Step over] closes Geany. minicom is a terminal program generally used to communicate with some hardware via Serial/USB interface (most common use). If you are interested in knowing more about the issue, please let me know. Or if someone would like to find more, a tip to debug minicom is to comment the setjmp() code and then you are able to set breakpoints anywhere. Maybe the interrupts set by minicom are the main cause. BR. |
@avafinger, you could try to see if the same steps work properly in command-line GDB without Geany. If the issue is persistent in Geany, then you may describe it in a new issue against the Debugger plugin. |
292e4c7
to
0abd437
Compare
@nomadbyte By the way, your patch cannot be applied over the last one, i had to manually change the code. It works as expected. ;) |
@nomadbyte, Below is the error: sudo gdb --args ./minicom -D /dev/ttyUSB1
I know i have to install libc6 sym, but can't remember how... |
@avafinger |
Yes, but the breakpoint is not in tcgetattr(). The s (Step into) wants the source.
|
The missing source is ok, in above you stepped into |
You are right, n can step over without throwing an error. |
I doubt the source will make it work any better, thats only displayed for the human, GDB doesn't use it. :-) |
@avafinger, If the minicom-bound issue is not directly related to this multi-threaded debugging issue, I'd rather see this topic discussed in a separate issue for clarity and completeness. The current "patch" should be functionally equivalent to my original fix; this just addresses the comments raised by @b4n . Thus, any Debugger issues possibly exposed by debugging the minicom code should be summarized in a new issue. |
Looking back, this may also fix the symptoms in #309 (Error 'Can't find a source file') |
Sorry, i didn't want to flood the thread. |
@nomadbyte and others, I opened a new issue to discuss the [Can't find a source file and no directory or file]. Please, make your considerations there. |
@elextr I wonder if this PR is ready for the merge? |
- By original design, the debugger allows thread context switching only interactively, while in the Call Stack pane (in Stopped mode). This is being handled directly through GtkTreeView::cursor-changed event. - However, this event was also getting triggered when clearing the latest thread's Call Stack after continuing the execution (Running mode). - This behavior does not seem to have being intended, and it lead to a number of issues: stepping hangs, corruption of GDB output processing, unnecessary attempts at opening of source files corresponding to thread's call-stack frames. - To avoid all of these issues, GtkTreeView::cursor-changed event is left unhandled while clearing the frames. Also the handler for thread-context switching is allowed processing only in debugger's Stopped mode to enforce the intended behavior.
0abd437
to
aa40d7c
Compare
@nomadbyte I guess its waiting for "somebody" to review and test, IIRC @avafinger applied changes manually, it would be nice for someone to test the PR explicitly. LGB(very cursory)I |
Sure. However, as you probably could see, the changes are very much limited, so applying manually should be just as effective. Of course, I did the testing of the issue, as I described above. It's been almost a year since this issue is in DONE state. Is there something that I could do to get this finally merged? |
I just tried this using #1069 test case, and it's clearly better. The second example program (more reasonable) seems to work OK. With the first example it gets confused and state desynchronizes (the plugin doesn't notice the program stopped), leading to the plugin giving weird-looking errors (though they aren't). I got fairly random results though, and believe once I had a hang, but it's a bit too random to tell. Anyway, I guess the issue here is that the threads are dying and thus just vanish, and something isn't coping well with that. Admittedly, an interactive GDB session is a bit confusing and random as well, but makes sense. So there's something to improve here, but it does help quite a bit indeed 👍 |
@nomadbyte thanks (and thanks for good commit messages) |
interactively, while in the Call Stack pane (in Stopped mode). This is
being handled directly through GtkTreeView::cursor-changed event.
thread's Call Stack after continuing the execution (Running mode).
number of issues: stepping hangs, corruption of GDB output processing,
unnecessary attempts at opening of source files corresponding to thread's
call-stack frames.
unhandled while clearing the frames. Also the handler for thread-context
switching is allowed processing only in debugger's Stopped mode to enforce
the intended behavior.
Fixes #1069