aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-script.c
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
commit17d92a02195a3dc9d3d3b6d46b22cb187eeccd19 (patch)
treebbcbf99ae0d66e7176859a9ba9efa697c53f4b82 /gdb/cli/cli-script.c
parentae03635710dcd5a17dbe0fbf3971d079281eeede (diff)
downloadgdb-17d92a02195a3dc9d3d3b6d46b22cb187eeccd19.zip
gdb-17d92a02195a3dc9d3d3b6d46b22cb187eeccd19.tar.gz
gdb-17d92a02195a3dc9d3d3b6d46b22cb187eeccd19.tar.bz2
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/cli-script.c')
-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 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);
}