This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to ignore errors in user defined commands?


>>>>> "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 ()


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]