summaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2005-01-16 21:20:06 +0000
committerAndrew Cagney <cagney@redhat.com>2005-01-16 21:20:06 +0000
commit80dfa7e61a021cbed533f7f1263c6e54d290aa22 (patch)
tree8f55dae9b8efc8e0d68699d3c9d5e41f40eac559 /gdb/cli
parentd938bcea6b78ed30832307500ad5b078ecb035e8 (diff)
downloadgdb-80dfa7e61a021cbed533f7f1263c6e54d290aa22.tar.gz
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. Index: testsuite/ChangeLog 2005-01-16 Andrew Cagney <cagney@gnu.org> * gdb.base/source.exp: Delete KFAIL gdb/1846, simplify.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-script.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 1f1cf1df0c3..2bac862e720 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);
}