public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to ignore errors in user defined commands?
@ 2010-06-22 15:05 Steffen Dettmer
  2010-06-22 16:12 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Steffen Dettmer @ 2010-06-22 15:05 UTC (permalink / raw)
  To: gdb

Hi,

when an error occures, the execution of a user define command
stops. How can I avoid this?

Background:
I use arm-elf-gdb-6.8 to debug my remote target. On some errors,
such as a crash of the target device, the remote protocol seems
to get out of sync and does not recover (I just get remote
protocol errors). When I try to reconnect via "target remote
<IP>" this fails with remote errors.

I just noticed while writing this mail that I'm unable to
reproduce it (in my tests now it recovers always).

However, when it does not recover an easy workaround is "tar re /x",
which leads to a "no such file or directory" and aborts. After
this, "target remote <IP>" works in any case.

The issue with that state is that here not everyone knows and
remembers this workaround, so I would like to automate that.

Since target remote is called by a user defined command (which
for example disables all breakpoints, otherwise my connect
attempts fail), I wanted to do:

defined trc
  target remote /x
  target remote $IP
  continue
end

but this already stops at the (intended) error at first
statement.

oki,

Steffen

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

* Re: How to ignore errors in user defined commands?
  2010-06-22 15:05 How to ignore errors in user defined commands? Steffen Dettmer
@ 2010-06-22 16:12 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2010-06-22 16:12 UTC (permalink / raw)
  To: Steffen Dettmer; +Cc: gdb

>>>>> "Steffen" == Steffen Dettmer <steffen.dettmer@googlemail.com> writes:

Steffen> when an error occures, the execution of a user define command
Steffen> stops. How can I avoid this?

Steffen> I use arm-elf-gdb-6.8 to debug my remote target.

With 6.8, I think there is no way.

A long time ago there was a patch to add exception handling to the gdb
command language.  This is still in bugzilla somewhere.  I don't know
why it was never applied.

With a Python-enabled gdb you can write a command like the appended.
Then you can "ignore-errors do something".

Tom

class IgnoreErrorsCommand (gdb.Command):
    """Execute a single command, ignoring all errors.
Only one-line commands are supported.
This is primarily useful in scripts."""

    def __init__ (self):
        super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
                                                    gdb.COMMAND_OBSCURE,
                                                    # FIXME...
                                                    gdb.COMPLETE_COMMAND)

    def invoke (self, arg, from_tty):
        try:
            gdb.execute (arg, from_tty)
        except:
            pass

IgnoreErrorsCommand ()

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

end of thread, other threads:[~2010-06-22 16:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-22 15:05 How to ignore errors in user defined commands? Steffen Dettmer
2010-06-22 16:12 ` Tom Tromey

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).