public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Problem setting a breakpoint with command in gdbinit
@ 2022-02-02 16:01 Edgar Mobile
  2022-02-02 17:51 ` Andrew Burgess
  0 siblings, 1 reply; 2+ messages in thread
From: Edgar Mobile @ 2022-02-02 16:01 UTC (permalink / raw)
  To: gdb

Greetings,

I try to set a silent breakpoint with commands via .gdbinit like this:


define breakXOpenDisplayRun
set pagination off
break XOpenDisplay
commands
  silent
  info locals
  bt full
  cont
end
run
end

Then I call my application like this:


gdb -q -ex breakXOpenDisplayRun ./myapp

The breakpoint is set and the application starts. However, when it encounters the breakpoint the first time it doesn't execute the command silently but stops there. Entering "continue" will continue with debugging and after that point it works.
If I start up GDB manually, then execute breakXOpenDisplayRun and run manually everything works fine.

What can I do?

GDB Version is 8.1.0.20180409-git for Ubuntu Linux 18.04   AMD64.

Regards

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Problem setting a breakpoint with command in gdbinit
  2022-02-02 16:01 Problem setting a breakpoint with command in gdbinit Edgar Mobile
@ 2022-02-02 17:51 ` Andrew Burgess
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2022-02-02 17:51 UTC (permalink / raw)
  To: Edgar Mobile; +Cc: gdb

* Edgar Mobile via Gdb <gdb@sourceware.org> [2022-02-02 16:01:11 +0000]:

> Greetings,
> 
> I try to set a silent breakpoint with commands via .gdbinit like this:
> 
> 
> define breakXOpenDisplayRun
> set pagination off
> break XOpenDisplay
> commands
>   silent
>   info locals
>   bt full
>   cont
> end
> run
> end
> 
> Then I call my application like this:
> 
> 
> gdb -q -ex breakXOpenDisplayRun ./myapp
> 
> The breakpoint is set and the application starts. However, when it encounters the breakpoint the first time it doesn't execute the command silently but stops there. Entering "continue" will continue with debugging and after that point it works.
> If I start up GDB manually, then execute breakXOpenDisplayRun and run manually everything works fine.
> 
> What can I do?
> 
> GDB Version is 8.1.0.20180409-git for Ubuntu Linux 18.04   AMD64.

If possible, update your version of gdb.

This issue was fixed in this commit:

  commit 21e051b3d666bcd614391142a936a8a8cccfa3cb
  Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
  Date:   Mon Dec 7 09:03:24 2020 +0100

      gdb/main: execute breakpoint commands for '-iex' and '-ex' commands

Basically, the breakpoint commands are not being executed when gdb is
set running as a result of an -ex command line flag.

Your example works fine with GDB 11.

If you can't update gdb for whatever reason, then you might be able to
work around this issue by placing the call to breakXOpenDisplayRun in
a file, and sourcing that, so

 $ cat breakXOpenDisplayRun.gdb
 breakXOpenDisplayRun
 $ gdb -q -ex 'source breakXOpenDisplayRun.gdb' ./myapp

this seemed to work for me, though clearly not ideal.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-02 17:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-02 16:01 Problem setting a breakpoint with command in gdbinit Edgar Mobile
2022-02-02 17:51 ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).