public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [RFC][gdb/cli] Ignore error in gdb command script
@ 2021-05-18  9:59 Tom de Vries
  2021-05-18 11:12 ` Marco Barisione
  0 siblings, 1 reply; 15+ messages in thread
From: Tom de Vries @ 2021-05-18  9:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Hi,

While trying to reproduce a failing test-case from the testsuite on the
command line using a gdb command script, I ran into the problem that a command
failed which stopped script execution.

I could work around this by splitting the script at each error, but I realized
it would be nice if I could tell gdb to ignore the error.

Inspired by make, I chose the '-' prefix.

This demonstator works for my use case, but also has effect on the gdb
prompt, which is strictly speaking not necessary.

Another way to do this is to use a python workaround ignore-errors mentioned
here ( https://sourceware.org/legacy-ml/gdb/2010-06/msg00100.html ).  This
also mentions a bugzilla entry that adds "exception handling to the gdb
command language" but I was not able to find that.

This though:
...
$ cat script.gdb
-run
echo here
...
doesn't work very well:
...
$ gdb -q -batch -x script.gdb
here
<HANGS>
...

While this:
...
$ cat script.gdb
source ignore-errors.py
ignore-errors run
echo HERE
...
works fine:
...
$ gdb -q -batch -x script.gdb
HERE$
...

Any comments?

Thanks,
- Tom

[gdb/cli] Ignore error in gdb command script

---
 gdb/event-top.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gdb/event-top.c b/gdb/event-top.c
index 002a7dc95e0..e7dd5e1319e 100644
--- a/gdb/event-top.c
+++ b/gdb/event-top.c
@@ -585,7 +585,19 @@ command_handler (const char *command)
     ;
   if (c[0] != '#')
     {
-      execute_command (command, ui->instream == ui->stdin_stream);
+      if (*c == '-')
+	{
+	  c++;
+	  try
+	    {
+	      execute_command (c, ui->instream == ui->stdin_stream);
+	    }
+	  catch (const gdb_exception_error &ex)
+	    {
+	    }
+	}
+      else
+	execute_command (c, ui->instream == ui->stdin_stream);
 
       /* Do any commands attached to breakpoint we stopped at.  */
       bpstat_do_actions ();

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

end of thread, other threads:[~2021-05-20 15:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18  9:59 [RFC][gdb/cli] Ignore error in gdb command script Tom de Vries
2021-05-18 11:12 ` Marco Barisione
2021-05-18 13:57   ` Tom de Vries
2021-05-18 14:10     ` Simon Marchi
2021-05-18 14:42       ` Tom Tromey
2021-05-18 15:16         ` Tom de Vries
2021-05-18 15:32           ` Tom Tromey
2021-05-19  6:25             ` [PATCH][gdb/cli] Add ignore-errors command Tom de Vries
2021-05-19  7:32               ` Andreas Schwab
2021-05-19  7:36                 ` Tom de Vries
2021-05-18 19:16           ` [RFC][gdb/cli] Ignore error in gdb command script Philippe Waroquiers
2021-05-18 21:59             ` Tom de Vries
2021-05-20  8:02               ` Philippe Waroquiers
2021-05-20 15:01                 ` Simon Marchi
2021-05-18 14:23     ` 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).