2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
/* Exception (throw catch) mechanism, for GDB, the GNU debugger.
|
|
|
|
|
|
|
|
Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
|
2005-01-15 04:24:20 +08:00
|
|
|
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
|
|
|
|
Software Foundation, Inc.
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "exceptions.h"
|
|
|
|
#include "breakpoint.h"
|
|
|
|
#include "target.h"
|
|
|
|
#include "inferior.h"
|
|
|
|
#include "annotate.h"
|
|
|
|
#include "ui-out.h"
|
|
|
|
#include "gdb_assert.h"
|
2005-01-13 03:12:29 +08:00
|
|
|
#include "gdb_string.h"
|
2005-01-20 06:54:56 +08:00
|
|
|
#include "serial.h"
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
|
2005-04-26 13:03:41 +08:00
|
|
|
const struct gdb_exception exception_none = { 0, NO_ERROR, NULL };
|
2005-01-13 10:35:39 +08:00
|
|
|
|
2005-01-13 03:12:29 +08:00
|
|
|
/* Possible catcher states. */
|
|
|
|
enum catcher_state {
|
|
|
|
/* Initial state, a new catcher has just been created. */
|
|
|
|
CATCHER_CREATED,
|
|
|
|
/* The catch code is running. */
|
|
|
|
CATCHER_RUNNING,
|
|
|
|
CATCHER_RUNNING_1,
|
|
|
|
/* The catch code threw an exception. */
|
|
|
|
CATCHER_ABORTING
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Possible catcher actions. */
|
|
|
|
enum catcher_action {
|
|
|
|
CATCH_ITER,
|
|
|
|
CATCH_ITER_1,
|
|
|
|
CATCH_THROWING
|
|
|
|
};
|
|
|
|
|
|
|
|
struct catcher
|
|
|
|
{
|
|
|
|
enum catcher_state state;
|
2005-01-13 08:12:50 +08:00
|
|
|
/* Jump buffer pointing back at the exception handler. */
|
2005-02-09 07:44:06 +08:00
|
|
|
EXCEPTIONS_SIGJMP_BUF buf;
|
2005-01-15 02:55:33 +08:00
|
|
|
/* Status buffer belonging to the exception handler. */
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception *exception;
|
2005-01-13 03:12:29 +08:00
|
|
|
/* Saved/current state. */
|
|
|
|
int mask;
|
|
|
|
struct ui_out *saved_uiout;
|
|
|
|
struct cleanup *saved_cleanup_chain;
|
|
|
|
/* Back link. */
|
|
|
|
struct catcher *prev;
|
|
|
|
};
|
|
|
|
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
/* Where to go for throw_exception(). */
|
2005-01-13 03:12:29 +08:00
|
|
|
static struct catcher *current_catcher;
|
|
|
|
|
2005-02-09 07:44:06 +08:00
|
|
|
EXCEPTIONS_SIGJMP_BUF *
|
|
|
|
exceptions_state_mc_init (struct ui_out *func_uiout,
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception *exception,
|
2005-02-09 07:44:06 +08:00
|
|
|
return_mask mask)
|
2005-01-13 03:12:29 +08:00
|
|
|
{
|
|
|
|
struct catcher *new_catcher = XZALLOC (struct catcher);
|
|
|
|
|
2005-01-13 08:12:50 +08:00
|
|
|
/* Start with no exception, save it's address. */
|
|
|
|
exception->reason = 0;
|
|
|
|
exception->error = NO_ERROR;
|
|
|
|
exception->message = NULL;
|
|
|
|
new_catcher->exception = exception;
|
|
|
|
|
2005-01-13 03:12:29 +08:00
|
|
|
new_catcher->mask = mask;
|
|
|
|
|
|
|
|
/* Override the global ``struct ui_out'' builder. */
|
|
|
|
new_catcher->saved_uiout = uiout;
|
|
|
|
uiout = func_uiout;
|
|
|
|
|
|
|
|
/* Prevent error/quit during FUNC from calling cleanups established
|
|
|
|
prior to here. */
|
|
|
|
new_catcher->saved_cleanup_chain = save_cleanups ();
|
|
|
|
|
|
|
|
/* Push this new catcher on the top. */
|
|
|
|
new_catcher->prev = current_catcher;
|
|
|
|
current_catcher = new_catcher;
|
|
|
|
new_catcher->state = CATCHER_CREATED;
|
|
|
|
|
|
|
|
return &new_catcher->buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
catcher_pop (void)
|
|
|
|
{
|
|
|
|
struct catcher *old_catcher = current_catcher;
|
|
|
|
current_catcher = old_catcher->prev;
|
|
|
|
|
|
|
|
/* Restore the cleanup chain, the error/quit messages, and the uiout
|
|
|
|
builder, to their original states. */
|
|
|
|
|
|
|
|
restore_cleanups (old_catcher->saved_cleanup_chain);
|
|
|
|
|
|
|
|
uiout = old_catcher->saved_uiout;
|
|
|
|
|
|
|
|
xfree (old_catcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Catcher state machine. Returns non-zero if the m/c should be run
|
|
|
|
again, zero if it should abort. */
|
|
|
|
|
2005-02-09 07:44:06 +08:00
|
|
|
static int
|
|
|
|
exceptions_state_mc (enum catcher_action action)
|
2005-01-13 03:12:29 +08:00
|
|
|
{
|
|
|
|
switch (current_catcher->state)
|
|
|
|
{
|
|
|
|
case CATCHER_CREATED:
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case CATCH_ITER:
|
|
|
|
/* Allow the code to run the catcher. */
|
|
|
|
current_catcher->state = CATCHER_RUNNING;
|
|
|
|
return 1;
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad state"));
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
case CATCHER_RUNNING:
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case CATCH_ITER:
|
|
|
|
/* No error/quit has occured. Just clean up. */
|
|
|
|
catcher_pop ();
|
|
|
|
return 0;
|
|
|
|
case CATCH_ITER_1:
|
|
|
|
current_catcher->state = CATCHER_RUNNING_1;
|
|
|
|
return 1;
|
|
|
|
case CATCH_THROWING:
|
|
|
|
current_catcher->state = CATCHER_ABORTING;
|
|
|
|
/* See also throw_exception. */
|
|
|
|
return 1;
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad switch"));
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
case CATCHER_RUNNING_1:
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case CATCH_ITER:
|
|
|
|
/* The did a "break" from the inner while loop. */
|
|
|
|
catcher_pop ();
|
|
|
|
return 0;
|
|
|
|
case CATCH_ITER_1:
|
|
|
|
current_catcher->state = CATCHER_RUNNING;
|
|
|
|
return 0;
|
|
|
|
case CATCH_THROWING:
|
|
|
|
current_catcher->state = CATCHER_ABORTING;
|
|
|
|
/* See also throw_exception. */
|
|
|
|
return 1;
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad switch"));
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
case CATCHER_ABORTING:
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case CATCH_ITER:
|
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
struct gdb_exception exception = *current_catcher->exception;
|
2005-01-13 08:12:50 +08:00
|
|
|
if (current_catcher->mask & RETURN_MASK (exception.reason))
|
2005-01-13 03:12:29 +08:00
|
|
|
{
|
|
|
|
/* Exit normally if this catcher can handle this
|
|
|
|
exception. The caller analyses the func return
|
|
|
|
values. */
|
|
|
|
catcher_pop ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* The caller didn't request that the event be caught,
|
|
|
|
relay the event to the next containing
|
|
|
|
catch_errors(). */
|
|
|
|
catcher_pop ();
|
2005-01-13 08:12:50 +08:00
|
|
|
throw_exception (exception);
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad state"));
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad switch"));
|
2005-01-13 03:12:29 +08:00
|
|
|
}
|
|
|
|
}
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
|
2005-02-09 07:44:06 +08:00
|
|
|
int
|
|
|
|
exceptions_state_mc_action_iter (void)
|
|
|
|
{
|
|
|
|
return exceptions_state_mc (CATCH_ITER);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
exceptions_state_mc_action_iter_1 (void)
|
|
|
|
{
|
|
|
|
return exceptions_state_mc (CATCH_ITER_1);
|
|
|
|
}
|
|
|
|
|
2005-01-13 08:12:50 +08:00
|
|
|
/* Return EXCEPTION to the nearest containing catch_errors(). */
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
|
|
|
|
NORETURN void
|
2005-04-26 13:03:41 +08:00
|
|
|
throw_exception (struct gdb_exception exception)
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
{
|
|
|
|
quit_flag = 0;
|
|
|
|
immediate_quit = 0;
|
|
|
|
|
|
|
|
/* Perhaps it would be cleaner to do this via the cleanup chain (not sure
|
|
|
|
I can think of a reason why that is vital, though). */
|
|
|
|
bpstat_clear_actions (stop_bpstat); /* Clear queued breakpoint commands */
|
|
|
|
|
|
|
|
disable_current_display ();
|
|
|
|
do_cleanups (ALL_CLEANUPS);
|
|
|
|
if (target_can_async_p () && !target_executing)
|
|
|
|
do_exec_cleanups (ALL_CLEANUPS);
|
|
|
|
if (sync_execution)
|
|
|
|
do_exec_error_cleanups (ALL_CLEANUPS);
|
|
|
|
|
|
|
|
/* Jump to the containing catch_errors() call, communicating REASON
|
|
|
|
to that call via setjmp's return value. Note that REASON can't
|
|
|
|
be zero, by definition in defs.h. */
|
2005-02-09 07:44:06 +08:00
|
|
|
exceptions_state_mc (CATCH_THROWING);
|
2005-01-13 08:12:50 +08:00
|
|
|
*current_catcher->exception = exception;
|
2005-02-09 07:44:06 +08:00
|
|
|
EXCEPTIONS_SIGLONGJMP (current_catcher->buf, exception.reason);
|
2005-01-13 08:12:50 +08:00
|
|
|
}
|
|
|
|
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
static char *last_message;
|
|
|
|
|
2005-01-13 08:12:50 +08:00
|
|
|
NORETURN void
|
2005-01-20 05:15:44 +08:00
|
|
|
deprecated_throw_reason (enum return_reason reason)
|
2005-01-13 08:12:50 +08:00
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
struct gdb_exception exception;
|
2005-01-13 08:12:50 +08:00
|
|
|
memset (&exception, 0, sizeof exception);
|
|
|
|
|
|
|
|
exception.reason = reason;
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case RETURN_QUIT:
|
|
|
|
break;
|
|
|
|
case RETURN_ERROR:
|
|
|
|
exception.error = GENERIC_ERROR;
|
|
|
|
break;
|
|
|
|
default:
|
2005-02-11 Andrew Cagney <cagney@gnu.org>
Mark up error_no_arg, query, perror_with_name, complaint, and
internal_error.
* breakpoint.c, cp-abi.c, cp-namespace.c, cp-support.c: Update.
* cris-tdep.c, dbxread.c, dictionary.c, dsrec.c: Update.
* dummy-frame.c, dve3900-rom.c, dwarf2-frame.c, dwarf2expr.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, event-loop.c: Update.
* exceptions.c, exec.c, f-lang.c, findvar.c, fork-child.c: Update.
* frame-unwind.c, frame.c, frv-linux-tdep.c, frv-tdep.c: Update.
* gdb_assert.h, gdbarch.c, gdbtypes.c, gnu-nat.c: Update.
* go32-nat.c, hppa-tdep.c, hppabsd-nat.c, hpread.c: Update.
* i386-linux-nat.c, i386-nat.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386fbsd-nat.c, inf-ptrace.c, inf-ttrace.c, infcall.c: Update.
* infcmd.c, inflow.c, infptrace.c, infrun.c, inftarg.c: Update.
* interps.c, language.c, linespec.c, linux-nat.c: Update.
* m32r-linux-nat.c, m68k-tdep.c, m68kbsd-nat.c: Update.
* m68klinux-nat.c, m88kbsd-nat.c, macroexp.c, macroscope.c: Update.
* macrotab.c, maint.c, mdebugread.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mips64obsd-nat.c: Update.
* mipsnbsd-nat.c, mn10300-tdep.c, monitor.c, nto-procfs.c: Update.
* objc-lang.c, objfiles.c, objfiles.h, ocd.c, osabi.c: Update.
* parse.c, ppc-bdm.c, ppc-linux-nat.c, ppc-sysv-tdep.c: Update.
* ppcnbsd-nat.c, ppcobsd-nat.c, printcmd.c, procfs.c: Update.
* regcache.c, reggroups.c, remote-e7000.c, remote-mips.c: Update.
* remote-rdp.c, remote-sds.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote.c, rs6000-nat.c, rs6000-tdep.c: Update.
* s390-nat.c, s390-tdep.c, sentinel-frame.c, serial.c: Update.
* sh-tdep.c, sh3-rom.c, sh64-tdep.c, shnbsd-nat.c: Update.
* solib-aix5.c, solib-svr4.c, solib.c, source.c: Update.
* sparc-nat.c, stabsread.c, stack.c, symfile.c, symtab.c: Update.
* symtab.h, target.c, tracepoint.c, ui-file.c, ui-out.c: Update.
* utils.c, valops.c, valprint.c, vax-nat.c, vaxbsd-nat.c: Update.
* win32-nat.c, xcoffread.c, xstormy16-tdep.c: Update.
* cli/cli-cmds.c, cli/cli-logging.c, cli/cli-script.c: Update.
* cli/cli-setshow.c, mi/mi-cmd-break.c, mi/mi-cmds.c: Update.
* mi/mi-console.c, mi/mi-getopt.c, mi/mi-out.c: Update.
* tui/tui-file.c, tui/tui-interp.c: Update.
2005-02-12 02:13:55 +08:00
|
|
|
internal_error (__FILE__, __LINE__, _("bad switch"));
|
2005-01-13 08:12:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
throw_exception (exception);
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
}
|
|
|
|
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
static void
|
2005-01-15 12:31:10 +08:00
|
|
|
print_flush (void)
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
{
|
2005-01-20 06:54:56 +08:00
|
|
|
struct serial *gdb_stdout_serial;
|
|
|
|
|
2005-01-15 12:31:10 +08:00
|
|
|
if (deprecated_error_begin_hook)
|
|
|
|
deprecated_error_begin_hook ();
|
|
|
|
target_terminal_ours ();
|
2005-01-20 06:54:56 +08:00
|
|
|
|
|
|
|
/* We want all output to appear now, before we print the error. We
|
|
|
|
have 3 levels of buffering we have to flush (it's possible that
|
|
|
|
some of these should be changed to flush the lower-level ones
|
|
|
|
too): */
|
|
|
|
|
|
|
|
/* 1. The _filtered buffer. */
|
|
|
|
wrap_here ("");
|
|
|
|
|
|
|
|
/* 2. The stdio buffer. */
|
2005-01-15 12:31:10 +08:00
|
|
|
gdb_flush (gdb_stdout);
|
2005-01-20 06:54:56 +08:00
|
|
|
gdb_flush (gdb_stderr);
|
|
|
|
|
|
|
|
/* 3. The system-level buffer. */
|
|
|
|
gdb_stdout_serial = serial_fdopen (1);
|
2005-04-28 22:07:54 +08:00
|
|
|
if (gdb_stdout_serial)
|
|
|
|
{
|
|
|
|
serial_drain_output (gdb_stdout_serial);
|
|
|
|
serial_un_fdopen (gdb_stdout_serial);
|
|
|
|
}
|
2005-01-20 06:54:56 +08:00
|
|
|
|
2005-01-15 12:31:10 +08:00
|
|
|
annotate_error_begin ();
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
}
|
|
|
|
|
2005-01-15 06:59:36 +08:00
|
|
|
static void
|
2005-04-26 13:03:41 +08:00
|
|
|
print_exception (struct ui_file *file, struct gdb_exception e)
|
2005-01-15 06:59:36 +08:00
|
|
|
{
|
|
|
|
/* KLUGE: cagney/2005-01-13: Write the string out one line at a time
|
|
|
|
as that way the MI's behavior is preserved. */
|
|
|
|
const char *start;
|
|
|
|
const char *end;
|
|
|
|
for (start = e.message; start != NULL; start = end)
|
|
|
|
{
|
|
|
|
end = strchr (start, '\n');
|
|
|
|
if (end == NULL)
|
|
|
|
fputs_filtered (start, file);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
end++;
|
|
|
|
ui_file_write (file, start, end - start);
|
|
|
|
}
|
|
|
|
}
|
2005-01-15 12:31:10 +08:00
|
|
|
fprintf_filtered (file, "\n");
|
2005-01-15 13:16:15 +08:00
|
|
|
|
|
|
|
/* Now append the annotation. */
|
|
|
|
switch (e.reason)
|
|
|
|
{
|
|
|
|
case RETURN_QUIT:
|
|
|
|
annotate_quit ();
|
|
|
|
break;
|
|
|
|
case RETURN_ERROR:
|
|
|
|
/* Assume that these are all errors. */
|
|
|
|
annotate_error ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
internal_error (__FILE__, __LINE__, _("Bad switch."));
|
|
|
|
}
|
2005-01-15 06:59:36 +08:00
|
|
|
}
|
|
|
|
|
2005-01-15 02:55:33 +08:00
|
|
|
void
|
2005-04-26 13:03:41 +08:00
|
|
|
exception_print (struct ui_file *file, struct gdb_exception e)
|
2005-01-15 02:55:33 +08:00
|
|
|
{
|
|
|
|
if (e.reason < 0 && e.message != NULL)
|
|
|
|
{
|
2005-01-15 12:31:10 +08:00
|
|
|
print_flush ();
|
2005-01-15 06:59:36 +08:00
|
|
|
print_exception (file, e);
|
|
|
|
}
|
|
|
|
}
|
2005-01-15 02:55:33 +08:00
|
|
|
|
2005-01-15 06:59:36 +08:00
|
|
|
void
|
2005-04-26 13:03:41 +08:00
|
|
|
exception_fprintf (struct ui_file *file, struct gdb_exception e,
|
2005-01-15 06:59:36 +08:00
|
|
|
const char *prefix, ...)
|
|
|
|
{
|
|
|
|
if (e.reason < 0 && e.message != NULL)
|
|
|
|
{
|
|
|
|
va_list args;
|
2005-01-15 12:31:10 +08:00
|
|
|
|
|
|
|
print_flush ();
|
2005-01-15 06:59:36 +08:00
|
|
|
|
|
|
|
/* Print the prefix. */
|
|
|
|
va_start (args, prefix);
|
|
|
|
vfprintf_filtered (file, prefix, args);
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
print_exception (file, e);
|
2005-01-15 02:55:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-15 13:16:15 +08:00
|
|
|
void
|
|
|
|
print_any_exception (struct ui_file *file, const char *prefix,
|
2005-04-26 13:03:41 +08:00
|
|
|
struct gdb_exception e)
|
2005-01-15 13:16:15 +08:00
|
|
|
{
|
|
|
|
if (e.reason < 0 && e.message != NULL)
|
|
|
|
{
|
|
|
|
target_terminal_ours ();
|
|
|
|
wrap_here (""); /* Force out any buffered output */
|
|
|
|
gdb_flush (gdb_stdout);
|
|
|
|
annotate_error_begin ();
|
|
|
|
|
|
|
|
/* Print the prefix. */
|
|
|
|
if (prefix != NULL && prefix[0] != '\0')
|
|
|
|
fputs_filtered (prefix, file);
|
|
|
|
print_exception (file, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
From Kaveh R. Ghazi <ghazi@caip.rutgers.edu>:
gdb/
* cli-out.c (cli_field_fmt, cli_message, out_field_fmt): Add
ATTR_FORMAT or ATTRIBUTE_FPTR_PRINTF.
* complaints.c (vcomplaint): Likewise.
* defs.h (xvasprintf, xstrvprintf, verror, vfatal)
(internal_verror, internal_vwarning, vwarning)
(deprecated_query_hook, deprecated_warning_hook)
(deprecated_readline_begin_hook): Likewise.
* disasm.c (fprintf_disasm): Likewise.
* exceptions.c (throw_it): Likewise.
* exceptions.h (throw_verror, throw_vfatal): Likewise.
* mi/mi-interp.c (mi_interp_query_hook): Likewise.
* mi/mi-out.c (mi_field_fmt, mi_message): Likewise.
* tui/tui-hooks.c (tui_query_hook): Likewise.
* tui/tui-out.c (tui_field_fmt, tui_message, out_field_fmt):
Likewise.
* ui-out.c (default_field_fmt, default_message, uo_field_fmt)
(uo_message): Likewise.
* ui-out.h (ui_out_field_fmt, ui_out_message, field_fmt_ftype)
(message_ftype): Likewise.
* utils.c (vfprintf_maybe_filtered, internal_vproblem)
(defaulted_query, printchar): Likewise.
gdb/gdbserver/
* server.h (error, fatal, warning): Add ATTR_FORMAT.
2005-08-01 04:56:26 +08:00
|
|
|
NORETURN static void ATTR_NORETURN ATTR_FORMAT (printf, 3, 0)
|
2005-01-15 14:03:34 +08:00
|
|
|
throw_it (enum return_reason reason, enum errors error, const char *fmt,
|
|
|
|
va_list ap)
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
struct gdb_exception e;
|
2005-01-17 05:20:06 +08:00
|
|
|
char *new_message;
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
|
2005-01-17 05:20:06 +08:00
|
|
|
/* Save the message. Create the new message before deleting the
|
|
|
|
old, the new message may include the old message text. */
|
|
|
|
new_message = xstrvprintf (fmt, ap);
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
xfree (last_message);
|
2005-01-17 05:20:06 +08:00
|
|
|
last_message = new_message;
|
2005-01-15 12:31:10 +08:00
|
|
|
|
|
|
|
/* Create the exception. */
|
|
|
|
e.reason = reason;
|
|
|
|
e.error = error;
|
|
|
|
e.message = last_message;
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
|
|
|
|
/* Throw the exception. */
|
|
|
|
throw_exception (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void
|
|
|
|
throw_verror (enum errors error, const char *fmt, va_list ap)
|
|
|
|
{
|
2005-01-15 14:03:34 +08:00
|
|
|
throw_it (RETURN_ERROR, error, fmt, ap);
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void
|
|
|
|
throw_vfatal (const char *fmt, va_list ap)
|
|
|
|
{
|
2005-01-15 14:03:34 +08:00
|
|
|
throw_it (RETURN_QUIT, NO_ERROR, fmt, ap);
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
NORETURN void
|
2005-01-15 04:24:20 +08:00
|
|
|
throw_error (enum errors error, const char *fmt, ...)
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
{
|
2005-01-15 04:24:20 +08:00
|
|
|
va_list args;
|
|
|
|
va_start (args, fmt);
|
2005-01-15 14:03:34 +08:00
|
|
|
throw_it (RETURN_ERROR, error, fmt, args);
|
2005-01-15 04:24:20 +08:00
|
|
|
va_end (args);
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
}
|
|
|
|
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
/* Call FUNC() with args FUNC_UIOUT and FUNC_ARGS, catching any
|
|
|
|
errors. Set FUNC_CAUGHT to an ``enum return_reason'' if the
|
|
|
|
function is aborted (using throw_exception() or zero if the
|
|
|
|
function returns normally. Set FUNC_VAL to the value returned by
|
|
|
|
the function or 0 if the function was aborted.
|
|
|
|
|
|
|
|
Must not be called with immediate_quit in effect (bad things might
|
|
|
|
happen, say we got a signal in the middle of a memcpy to quit_return).
|
|
|
|
This is an OK restriction; with very few exceptions immediate_quit can
|
|
|
|
be replaced by judicious use of QUIT.
|
|
|
|
|
|
|
|
MASK specifies what to catch; it is normally set to
|
|
|
|
RETURN_MASK_ALL, if for no other reason than that the code which
|
|
|
|
calls catch_errors might not be set up to deal with a quit which
|
|
|
|
isn't caught. But if the code can deal with it, it generally
|
|
|
|
should be RETURN_MASK_ERROR, unless for some reason it is more
|
|
|
|
useful to abort only the portion of the operation inside the
|
|
|
|
catch_errors. Note that quit should return to the command line
|
|
|
|
fairly quickly, even if some further processing is being done. */
|
|
|
|
|
|
|
|
/* MAYBE: cagney/1999-11-05: catch_errors() in conjunction with
|
|
|
|
error() et.al. could maintain a set of flags that indicate the the
|
|
|
|
current state of each of the longjmp buffers. This would give the
|
|
|
|
longjmp code the chance to detect a longjmp botch (before it gets
|
|
|
|
to longjmperror()). Prior to 1999-11-05 this wasn't possible as
|
|
|
|
code also randomly used a SET_TOP_LEVEL macro that directly
|
|
|
|
initialize the longjmp buffers. */
|
|
|
|
|
|
|
|
/* MAYBE: cagney/1999-11-05: Should the catch_errors and cleanups code
|
|
|
|
be consolidated into a single file instead of being distributed
|
|
|
|
between utils.c and top.c? */
|
|
|
|
|
|
|
|
int
|
|
|
|
catch_exceptions (struct ui_out *uiout,
|
|
|
|
catch_exceptions_ftype *func,
|
|
|
|
void *func_args,
|
|
|
|
return_mask mask)
|
|
|
|
{
|
2005-01-15 07:27:14 +08:00
|
|
|
return catch_exceptions_with_msg (uiout, func, func_args, NULL, mask);
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
}
|
|
|
|
|
2005-04-26 13:03:41 +08:00
|
|
|
struct gdb_exception
|
2005-01-13 08:12:50 +08:00
|
|
|
catch_exception (struct ui_out *uiout,
|
|
|
|
catch_exception_ftype *func,
|
|
|
|
void *func_args,
|
|
|
|
return_mask mask)
|
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception exception;
|
2005-02-09 07:44:06 +08:00
|
|
|
TRY_CATCH (exception, mask)
|
|
|
|
{
|
|
|
|
(*func) (uiout, func_args);
|
|
|
|
}
|
2005-01-13 08:12:50 +08:00
|
|
|
return exception;
|
|
|
|
}
|
|
|
|
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
int
|
|
|
|
catch_exceptions_with_msg (struct ui_out *uiout,
|
|
|
|
catch_exceptions_ftype *func,
|
|
|
|
void *func_args,
|
|
|
|
char **gdberrmsg,
|
|
|
|
return_mask mask)
|
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception exception;
|
2005-01-13 08:12:50 +08:00
|
|
|
volatile int val = 0;
|
2005-02-09 07:44:06 +08:00
|
|
|
TRY_CATCH (exception, mask)
|
|
|
|
{
|
|
|
|
val = (*func) (uiout, func_args);
|
|
|
|
}
|
2005-01-15 13:16:15 +08:00
|
|
|
print_any_exception (gdb_stderr, NULL, exception);
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
gdb_assert (val >= 0);
|
2005-01-13 08:12:50 +08:00
|
|
|
gdb_assert (exception.reason <= 0);
|
|
|
|
if (exception.reason < 0)
|
|
|
|
{
|
|
|
|
/* If caller wants a copy of the low-level error message, make
|
|
|
|
one. This is used in the case of a silent error whereby the
|
|
|
|
caller may optionally want to issue the message. */
|
|
|
|
if (gdberrmsg != NULL)
|
2005-01-13 Andrew Cagney <cagney@gnu.org>
* defs.h (error_last_message, error_init): Delete declaration.
* utils.c (fatal, vfatal): Call throw_vfatal.
(error, verror): Call throw_verror;
(do_write, error_stream_1): Delete function.
(error_stream): Simplify, call error.
(error_last_message, error_init, gdb_lasterr): Delete.
(error_silent): Simplify, call throw_vsilent.
* mi/mi-interp.c (mi_cmd_interpreter_exec): Dup the message.
* main.c (captured_main): Delete call to error_init.
* exceptions.c (throw_verror, throw_verror)
(throw_vsilent): New functions.
(do_write, print_and_throw): New functions.
(last_message): New global.
(throw_reason): Replace error_last_message with last_message.
(catch_exceptions_with_msg): Dup the message.
* exceptions.h (throw_verror, throw_vfatal, throw_vsilent):
Declare.
2005-01-14 09:20:38 +08:00
|
|
|
{
|
|
|
|
if (exception.message != NULL)
|
|
|
|
*gdberrmsg = xstrdup (exception.message);
|
|
|
|
else
|
|
|
|
*gdberrmsg = NULL;
|
|
|
|
}
|
2005-01-13 08:12:50 +08:00
|
|
|
return exception.reason;
|
|
|
|
}
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
|
|
|
|
return_mask mask)
|
|
|
|
{
|
2005-01-13 08:12:50 +08:00
|
|
|
volatile int val = 0;
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception exception;
|
2005-02-09 07:44:06 +08:00
|
|
|
TRY_CATCH (exception, mask)
|
|
|
|
{
|
|
|
|
val = func (func_args);
|
|
|
|
}
|
2005-01-15 13:16:15 +08:00
|
|
|
print_any_exception (gdb_stderr, errstring, exception);
|
2005-01-13 08:12:50 +08:00
|
|
|
if (exception.reason != 0)
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
return 0;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
catch_command_errors (catch_command_errors_ftype * command,
|
|
|
|
char *arg, int from_tty, return_mask mask)
|
|
|
|
{
|
2005-04-26 13:03:41 +08:00
|
|
|
volatile struct gdb_exception e;
|
2005-02-09 07:44:06 +08:00
|
|
|
TRY_CATCH (e, mask)
|
|
|
|
{
|
|
|
|
command (arg, from_tty);
|
|
|
|
}
|
2005-01-16 02:59:43 +08:00
|
|
|
print_any_exception (gdb_stderr, NULL, e);
|
|
|
|
if (e.reason < 0)
|
|
|
|
return 0;
|
|
|
|
return 1;
|
2005-01-12 Andrew Cagney <cagney@gnu.org>
* exceptions.h (enum return_reason, RETURN_MASK)
(RETURN_MASK_QUIT, RETURN_MASK_ERROR, RETURN_MASK_ALL)
(return_mask, throw_exception, catch_exceptions_ftype)
(catch_exceptions_with_msg, catch_errors_ftype, catch_errors)
(catch_command_errors_ftype, catch_command_errors): Move to
exceptions.h.
* exceptions.c, exceptions.h: New files.
* top.c: Do not include <setjmp.h>.
(SIGJMP_BUF, SIGSETJMP, SIGLONGJMP, catch_return)
(throw_exception, catcher, catch_exceptions)
(catch_exceptions_with_msg, struct catch_errors_args)
(do_catch_errors, catch_errors, struct captured_command_args)
(do_captured_command, catch_command_errors): Move to exceptions.c.
* wrapper.c, wince.c, win32-nat.c, utils.c: Include "exceptions.h".
* tui/tui-interp.c, top.c, thread.c, symmisc.c: Ditto.
* symfile-mem.c, stack.c, solib.c, rs6000-nat.c: Ditto.
* remote-sds.c, remote-mips.c, remote-fileio.c: Ditto.
* remote-e7000.c, objc-lang.c, ocd.c: Ditto.
* remote.c, nto-procfs.c, monitor.c, mi/mi-main.c: Ditto.
* main.c, m32r-rom.c, infrun.c, inf-loop.c: Ditto.
* hppa-hpux-tdep.c, frame.c, event-top.c, event-loop.c: Ditto.
* corelow.c, corefile.c, cli/cli-interp.c, breakpoint.c: Ditto.
* ada-valprint.c, ada-lang.c: Ditto.
* Makefile.in (HFILES_NO_SRCDIR, COMMON_OBS): Add exceptions.h and
exceptions.o. Update all dependencies.
2005-01-13 02:31:35 +08:00
|
|
|
}
|