[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gdb
Subject:    Re: Problem setting a breakpoint with command in gdbinit
From:       Andrew Burgess via Gdb <gdb () sourceware ! org>
Date:       2022-02-02 17:51:27
Message-ID: 20220202175127.GA1552688 () redhat ! com
[Download RAW message or body]

* 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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic