* cli/cli-script.c: Include "exceptions.h".
(struct wrapped_read_command_file_args): Define.
(wrapped_read_command_file): New function.
(script_from_file): Replace direct call to read_command_file by
one wrapped by an exception handler.
* exceptions.c (throw_it): Free the old message after creating the
new.
* Makefile.in: Update dependencies.
Index: testsuite/ChangeLog
2005-01-16 Andrew Cagney <cagney@gnu.org>
* gdb.base/source.exp: Delete KFAIL gdb/1846, simplify.
+2005-01-16 Andrew Cagney <cagney@gnu.org>
+
+ * cli/cli-script.c: Include "exceptions.h".
+ (struct wrapped_read_command_file_args): Define.
+ (wrapped_read_command_file): New function.
+ (script_from_file): Replace direct call to read_command_file by
+ one wrapped by an exception handler.
+ * exceptions.c (throw_it): Free the old message after creating the
+ new.
+ * Makefile.in: Update dependencies.
+
2005-01-16 Mark Kettenis <kettenis@gnu.org>
* sparc64fbsd-tdep.c: Update copyright year.
$(gdbcore_h) $(inferior_h) $(language_h) $(regcache_h) $(value_h) \
$(gdb_assert_h) $(gdb_string_h) $(i386_tdep_h) $(i387_tdep_h)
ia64-linux-nat.o: ia64-linux-nat.c $(defs_h) $(gdb_string_h) $(inferior_h) \
- $(target_h) $(gdbcore_h) $(regcache_h) $(gdb_wait_h) $(gregset_h)
+ $(target_h) $(gdbcore_h) $(regcache_h) $(ia64_tdep_h) $(gdb_wait_h) \
+ $(gregset_h)
ia64-linux-tdep.o: ia64-linux-tdep.c $(defs_h) $(ia64_tdep_h) \
$(arch_utils_h) $(gdbcore_h) $(regcache_h) $(osabi_h)
ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(gdbcore_h) \
linespec.o: linespec.c $(defs_h) $(symtab_h) $(frame_h) $(command_h) \
$(symfile_h) $(objfiles_h) $(source_h) $(demangle_h) $(value_h) \
$(completer_h) $(cp_abi_h) $(parser_defs_h) $(block_h) \
- $(objc_lang_h) $(linespec_h)
+ $(objc_lang_h) $(linespec_h) $(exceptions_h)
linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_string_h) \
$(gdb_wait_h) $(gdb_assert_h) $(linux_nat_h) $(gdbthread_h) \
$(gdbcmd_h) $(regcache_h) $(elf_bfd_h) $(gregset_h) $(gdbcore_h) \
$(gdb_string_h) $(gdb_stat_h) $(gdbcore_h) $(gdb_regex_h) \
$(symfile_h) $(objfiles_h) $(annotate_h) $(gdbtypes_h) $(linespec_h) \
$(filenames_h) $(completer_h) $(ui_out_h) $(readline_h)
-sparc64fbsd-nat.o: sparc64fbsd-nat.c $(defs_h) $(target_h) \
- $(fbsd_nat_h) $(sparc64_tdep_h) $(sparc_nat_h)
+sparc64fbsd-nat.o: sparc64fbsd-nat.c $(defs_h) $(target_h) $(fbsd_nat_h) \
+ $(sparc64_tdep_h) $(sparc_nat_h)
sparc64fbsd-tdep.o: sparc64fbsd-tdep.c $(defs_h) $(frame_h) \
$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
$(target_h) $(trad_frame_h) $(gdb_assert_h) $(gdb_string_h) \
$(gdb_string_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-logging.c
cli-script.o: $(srcdir)/cli/cli-script.c $(defs_h) $(value_h) $(language_h) \
- $(ui_out_h) $(gdb_string_h) $(top_h) $(cli_cmds_h) $(cli_decode_h) \
- $(cli_script_h)
+ $(ui_out_h) $(gdb_string_h) $(exceptions_h) $(top_h) $(cli_cmds_h) \
+ $(cli_decode_h) $(cli_script_h)
$(CC) -c $(INTERNAL_CFLAGS) $(srcdir)/cli/cli-script.c
cli-setshow.o: $(srcdir)/cli/cli-setshow.c $(defs_h) $(readline_tilde_h) \
$(value_h) $(gdb_string_h) $(ui_out_h) $(cli_decode_h) $(cli_cmds_h) \
/* GDB CLI command scripting.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software
- Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free
+ Software Foundation, Inc.
This file is part of GDB.
#include "ui-out.h"
#include "gdb_string.h"
-
+#include "exceptions.h"
#include "top.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
fclose (stream);
}
+struct wrapped_read_command_file_args
+{
+ FILE *stream;
+};
+
+static void
+wrapped_read_command_file (struct ui_out *uiout, void *data)
+{
+ struct wrapped_read_command_file_args *args = data;
+ read_command_file (args->stream);
+}
+
/* Used to implement source_command */
void
source_error = xrealloc (source_error, source_error_allocated);
}
- read_command_file (stream);
+ {
+ struct exception e;
+ struct wrapped_read_command_file_args args;
+ args.stream = stream;
+ e = catch_exception (uiout, wrapped_read_command_file, &args,
+ RETURN_MASK_ERROR);
+ switch (e.reason)
+ {
+ case 0:
+ break;
+ case RETURN_ERROR:
+ /* Re-throw the error, but with the file name information
+ prepended. */
+ throw_error (e.error, "%s%s:%d: Error in sourced command file:\n%s",
+ source_pre_error, source_file_name,
+ source_line_number,
+ e.message);
+ default:
+ internal_error (__FILE__, __LINE__, "bad reason");
+ }
+ }
do_cleanups (old_cleanups);
}
va_list ap)
{
struct exception e;
+ char *new_message;
- /* Save the message. */
+ /* 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);
xfree (last_message);
- last_message = xstrvprintf (fmt, ap);
+ last_message = new_message;
/* Create the exception. */
e.reason = reason;
2005-01-16 Andrew Cagney <cagney@gnu.org>
+ * gdb.base/source.exp: Delete KFAIL gdb/1846, simplify.
+
* gdb.base/source-error.gdb, gdb.base/source.exp: New files.
2005-01-14 Andrew Cagney <cagney@gnu.org>
gdb_start
-set test "script contains error"
-gdb_test_multiple "source ${srcdir}/${subdir}/source-error.gdb" $test {
- -re "source-error.gdb:22: Error in sourced command file:\[\r\n\]*Cannot access memory at address 0x0.*$gdb_prompt " {
- pass $test
- }
- -re "0x0:\[ \t\]+Cannot access memory at address 0x0.*$gdb_prompt " {
- kfail gdb/1846 $test
- }
-}
+gdb_test "source ${srcdir}/${subdir}/source-error.gdb" \
+ "source-error.gdb:22: Error in sourced command file:\[\r\n\]*Cannot access memory at address 0x0.*" \
+ "script contains error"
gdb_exit