public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Edgar Mobile <heideggm@hotmail.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Problem setting a breakpoint with command in gdbinit
Date: Wed, 2 Feb 2022 17:51:27 +0000	[thread overview]
Message-ID: <20220202175127.GA1552688@redhat.com> (raw)
In-Reply-To: <DM8PR16MB4357DF0A8678CD04B01BD323C7279@DM8PR16MB4357.namprd16.prod.outlook.com>

* 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


      reply	other threads:[~2022-02-02 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 16:01 Edgar Mobile
2022-02-02 17:51 ` Andrew Burgess [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220202175127.GA1552688@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=heideggm@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).