aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/Makefile.in13
-rw-r--r--gdb/cli/cli-script.c40
-rw-r--r--gdb/exceptions.c7
-rw-r--r--gdb/testsuite/ChangeLog2
-rw-r--r--gdb/testsuite/gdb.base/source.exp12
6 files changed, 64 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ed79ba9..a9d35b1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+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.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 567732d..d80091b 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -2066,7 +2066,8 @@ i387-tdep.o: i387-tdep.c $(defs_h) $(doublest_h) $(floatformat_h) $(frame_h) \
$(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) \
@@ -2140,7 +2141,7 @@ libunwind-frame.o: libunwind-frame.c $(defs_h) $(inferior_h) $(frame_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) \
@@ -2532,8 +2533,8 @@ source.o: source.c $(defs_h) $(symtab_h) $(expression_h) $(language_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) \
@@ -2748,8 +2749,8 @@ cli-logging.o: $(srcdir)/cli/cli-logging.c $(defs_h) $(gdbcmd_h) $(ui_out_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) \
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 1f1cf1d..2bac862 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -1,8 +1,8 @@
/* 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.
@@ -28,7 +28,7 @@
#include "ui-out.h"
#include "gdb_string.h"
-
+#include "exceptions.h"
#include "top.h"
#include "cli/cli-cmds.h"
#include "cli/cli-decode.h"
@@ -1251,6 +1251,18 @@ do_fclose_cleanup (void *stream)
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
@@ -1293,7 +1305,27 @@ script_from_file (FILE *stream, char *file)
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);
}
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index d95c58a..e640b5f 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -360,10 +360,13 @@ throw_it (enum return_reason reason, enum errors error, const char *fmt,
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;
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 5268537..bc352ab 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,7 @@
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>
diff --git a/gdb/testsuite/gdb.base/source.exp b/gdb/testsuite/gdb.base/source.exp
index 81496d9..a17b314 100644
--- a/gdb/testsuite/gdb.base/source.exp
+++ b/gdb/testsuite/gdb.base/source.exp
@@ -35,14 +35,8 @@ set binfile ${objdir}/${subdir}/${testfile}
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