public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "eager at eagercon dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/17198] Batch cmd file abandoned when breakpoint hit
Date: Thu, 24 Jul 2014 18:58:00 -0000	[thread overview]
Message-ID: <bug-17198-4717-X5OxtUaOom@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-17198-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=17198

--- Comment #1 from eager at eagercon dot com ---
I noticed some unexpected behavior with a batch command file which calls a
target function and encounters a breakpoint.  The batch command file is
abandoned, rather than continuing to be executed following the breakpoint.

$ cat t.c
#include <stdio.h>
void foo (int a)  {
  printf ("a = %d\n", a);
}
void main (void) {
  foo (123);
}

$cat gdb.cmd
b main
b foo
run
call foo(234)
p a
c

$ gdb -x gdb.cmd t
...
Breakpoint 1 at 0x400551: file t.c, line 7.
Breakpoint 2 at 0x400537: file t.c, line 3.

Breakpoint 1, main () at t.c:7
7         foo (123);

Breakpoint 2, foo (a=234) at t.c:3
3         printf ("a = %d\n", a);
gdb.cmd:4: Error in sourced command file:
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(foo) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb)

The breakpoint during the target function call apparently causes gdb to decide
that there is an error in the batch file which it abandons.  Subsequent
commands in the batch file are ignored.  It doesn't seem to matter whether the
target generates an interrupt from a breakpoint or a SEGV.

If run with --batch --command instead of -x, gdb terminates rather than
generating the CLI prompt, but does not execute the remaining commands.

Being able to include commands in a batch command file which are executed after
a brakepoint is hit is useful in a couple cases.  The first is to create a
script which demonstrates a gdb bug.  Second is for automated testing.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  reply	other threads:[~2014-07-24 18:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24 18:49 [Bug gdb/17198] New: " eager at eagercon dot com
2014-07-24 18:58 ` eager at eagercon dot com [this message]
2014-07-24 20:53 ` [Bug gdb/17198] " msebor at gmail dot com
2024-01-02 16:32 ` ssbssa at sourceware dot org

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=bug-17198-4717-X5OxtUaOom@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).