question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Continuing in breakpoint commands hangs gdb if dashboard is enabled

See original GitHub issue

Continuing in breakpoint commands hangs gdb if dashboard is enabled. You can verify this by doing the following in gdb on a sample program:

b main
commands
cont
end
run

The error that gets raised is gdb.error: Selected thread is running. and then gdb will be unresponsive. Maybe this is a duplicate of old issue #27 Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
cyrus-andcommented, Apr 4, 2021

@algrebe OK it works, thanks!

So apparently scheduling a continuation command avoids the hanging. I also noticed that rendering the dashboard in a gdb.post_event handler also works but it messes with the prompt.

It’s still suboptimal as the dashboard shouldn’t be rendered in such conditions (hardly noticeable if the scrollback is discarded, default) but at least it doesn’t force the users to kill their debugging session. Anyway since this is something that requires user intervention anyway, I prefer to document this in the wiki for now and suggest to define a custom command to be used when continuing within a breakpoint’s command list:

define continue-breakpoint
python gdb.post_event(lambda: gdb.execute('continue'))
end

The usage is the following:

b main
commands
echo from breakpoint
continue-breakpoint
end

See the corresponding wiki page.

0reactions
algrebecommented, Apr 4, 2021

@cyrus-and Thank you for your response. Yes, it does happen too late. So I took another approach this time - rather than having cont in the command, I ask the dashboard to issue the cont. This seems to work well. It probably isn’t a fix to handling cont from commands but it’s a good workaround for those who use the dashboard.

b foo
commands
dashboard -cont # <--- instead of using cont, use dashboard -cont
end
diff --git a/.gdbinit b/.gdbinit
index 8c3db0a..db5050b 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -400,6 +400,7 @@ class Dashboard(gdb.Command):
         Dashboard.OutputCommand(self)
         Dashboard.EnabledCommand(self)
         Dashboard.LayoutCommand(self)
+        Dashboard.ContinueCommand()
         # setup style commands
         Dashboard.StyleCommand(self, 'dashboard', R, R.attributes())
         # main terminal
@@ -824,6 +825,13 @@ configuration files must be placed.'''
             if output:
                 fs.write('{} -output {}\n'.format(prefix, output))
 
+    class ContinueCommand(gdb.Command):
+        def __init__(self):
+            gdb.Command.__init__(self, 'dashboard -cont', gdb.COMMAND_USER)
+
+        def invoke(self, arg, from_tty):
+            gdb.post_event(lambda: gdb.execute("cont"))
+
     class OutputCommand(gdb.Command):
         '''Set the output file/TTY for the whole dashboard or single modules.
 

Read more comments on GitHub >

github_iconTop Results From Across the Web

1176227 – gdb "run" command hangs - Red Hat Bugzilla
Description of problem: The gdb "run" command hangs if it's invoked before the user has issued any resume-execution commands ("step", "continue", "stepi", ...
Read more >
Pleasant debugging with GDB and DDD - begriffs.com
Set a breakpoint on the return 0 line. Select GDB console from the View menu (or press Alt-1). Run start in the GDB...
Read more >
Hacked GDB Dashboard Puts It All On Display - Hackaday
Normally, the dashboard shows when the program stops. For example, on each breakpoint. However, gdb has a hook system that allows you to...
Read more >
Continuing and Stepping (Debugging with GDB)
Continue running as in step , but do so count times. If a breakpoint is reached, or a signal not related to stepping...
Read more >
Debug it - Discovery - Embedded Rust documentation
Also, as mentioned above if you were to execute the step command GDB gets stuck because it is executing a branch instruction to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found