aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-08-04 18:19:27 +0000
committerPedro Alves <palves@redhat.com>2011-08-04 18:19:27 +0000
commitf9679975a3374a650ce5ffc8a512b85d662bfcbf (patch)
treedcae2ee7ee8e1f89c9f3ee86d72978e328ddef8e
parenta1e28cb2af1ec61d0dea8c9280e52e7153df2df8 (diff)
downloadgdb-f9679975a3374a650ce5ffc8a512b85d662bfcbf.zip
gdb-f9679975a3374a650ce5ffc8a512b85d662bfcbf.tar.gz
gdb-f9679975a3374a650ce5ffc8a512b85d662bfcbf.tar.bz2
2011-08-04 Pedro Alves <pedro@codesourcery.com>
* exceptions.c (struct catcher): Remove saved_uiout field. (exceptions_state_mc_init): Remove the `func_uiout' parameter, and no longer save/resvore the global ui_out builder. (catch_exceptions_with_msg): Save/override/restore the global ui_out builder manually instead of relying on TRY_CATCH to do it. (catch_errors): Save/restore the global ui_out builder manually instead of relying on TRY_CATCH to do it. * exceptions.h (exceptions_state_mc_init): Remove the `func_uiout' parameter. (TRY_CATCH): Adjust. * cli/cli-interp.c (safe_execute_command): Save/override/restore the global ui_out builder manually instead of relying on TRY_CATCH to do it.
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/cli/cli-interp.c11
-rw-r--r--gdb/exceptions.c47
-rw-r--r--gdb/exceptions.h5
4 files changed, 63 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 358f515..570fca8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,19 @@
+2011-08-04 Pedro Alves <pedro@codesourcery.com>
+
+ * exceptions.c (struct catcher): Remove saved_uiout field.
+ (exceptions_state_mc_init): Remove the `func_uiout' parameter, and
+ no longer save/resvore the global ui_out builder.
+ (catch_exceptions_with_msg): Save/override/restore the global
+ ui_out builder manually instead of relying on TRY_CATCH to do it.
+ (catch_errors): Save/restore the global ui_out builder manually
+ instead of relying on TRY_CATCH to do it.
+ * exceptions.h (exceptions_state_mc_init): Remove the `func_uiout'
+ parameter.
+ (TRY_CATCH): Adjust.
+ * cli/cli-interp.c (safe_execute_command): Save/override/restore
+ the global ui_out builder manually instead of relying on TRY_CATCH
+ to do it.
+
2011-08-03 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* breakpoint.c (update_global_location_list): Ensure
diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c
index 88a570c..32883cf 100644
--- a/gdb/cli/cli-interp.c
+++ b/gdb/cli/cli-interp.c
@@ -112,14 +112,23 @@ cli_interpreter_exec (void *data, const char *command_str)
}
static struct gdb_exception
-safe_execute_command (struct ui_out *uiout, char *command, int from_tty)
+safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty)
{
volatile struct gdb_exception e;
+ struct ui_out *saved_uiout;
+
+ /* Save and override the global ``struct ui_out'' builder. */
+ saved_uiout = uiout;
+ uiout = command_uiout;
TRY_CATCH (e, RETURN_MASK_ALL)
{
execute_command (command, from_tty);
}
+
+ /* Restore the global builder. */
+ uiout = saved_uiout;
+
/* FIXME: cagney/2005-01-13: This shouldn't be needed. Instead the
caller should print the exception. */
exception_print (gdb_stderr, e);
diff --git a/gdb/exceptions.c b/gdb/exceptions.c
index ce86f48..6704f93 100644
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -60,7 +60,6 @@ struct catcher
volatile struct gdb_exception *exception;
/* Saved/current state. */
int mask;
- struct ui_out *saved_uiout;
struct cleanup *saved_cleanup_chain;
/* Back link. */
struct catcher *prev;
@@ -70,8 +69,7 @@ struct catcher
static struct catcher *current_catcher;
EXCEPTIONS_SIGJMP_BUF *
-exceptions_state_mc_init (struct ui_out *func_uiout,
- volatile struct gdb_exception *exception,
+exceptions_state_mc_init (volatile struct gdb_exception *exception,
return_mask mask)
{
struct catcher *new_catcher = XZALLOC (struct catcher);
@@ -84,10 +82,6 @@ exceptions_state_mc_init (struct ui_out *func_uiout,
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 ();
@@ -112,8 +106,6 @@ catcher_pop (void)
restore_cleanups (old_catcher->saved_cleanup_chain);
- uiout = old_catcher->saved_uiout;
-
xfree (old_catcher);
}
@@ -459,7 +451,7 @@ catch_exceptions (struct ui_out *uiout,
}
int
-catch_exceptions_with_msg (struct ui_out *uiout,
+catch_exceptions_with_msg (struct ui_out *func_uiout,
catch_exceptions_ftype *func,
void *func_args,
char **gdberrmsg,
@@ -467,11 +459,27 @@ catch_exceptions_with_msg (struct ui_out *uiout,
{
volatile struct gdb_exception exception;
volatile int val = 0;
+ struct ui_out *saved_uiout;
- TRY_CATCH (exception, mask)
+ /* Save and override the global ``struct ui_out'' builder. */
+ saved_uiout = uiout;
+ uiout = func_uiout;
+
+ TRY_CATCH (exception, RETURN_MASK_ALL)
{
val = (*func) (uiout, func_args);
}
+
+ /* Restore the global builder. */
+ uiout = saved_uiout;
+
+ if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
+ {
+ /* The caller didn't request that the event be caught.
+ Rethrow. */
+ throw_exception (exception);
+ }
+
print_any_exception (gdb_stderr, NULL, exception);
gdb_assert (val >= 0);
gdb_assert (exception.reason <= 0);
@@ -500,11 +508,26 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
{
volatile int val = 0;
volatile struct gdb_exception exception;
+ struct ui_out *saved_uiout;
- TRY_CATCH (exception, mask)
+ /* Save the global ``struct ui_out'' builder. */
+ saved_uiout = uiout;
+
+ TRY_CATCH (exception, RETURN_MASK_ALL)
{
val = func (func_args);
}
+
+ /* Restore the global builder. */
+ uiout = saved_uiout;
+
+ if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
+ {
+ /* The caller didn't request that the event be caught.
+ Rethrow. */
+ throw_exception (exception);
+ }
+
print_any_exception (gdb_stderr, errstring, exception);
if (exception.reason != 0)
return 0;
diff --git a/gdb/exceptions.h b/gdb/exceptions.h
index c1bc605..9e306e4 100644
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -114,8 +114,7 @@ extern const struct gdb_exception exception_none;
/* Functions to drive the exceptions state m/c (internal to
exceptions). */
-EXCEPTIONS_SIGJMP_BUF *exceptions_state_mc_init (struct ui_out *func_uiout,
- volatile struct
+EXCEPTIONS_SIGJMP_BUF *exceptions_state_mc_init (volatile struct
gdb_exception *exception,
return_mask mask);
int exceptions_state_mc_action_iter (void);
@@ -146,7 +145,7 @@ int exceptions_state_mc_action_iter_1 (void);
#define TRY_CATCH(EXCEPTION,MASK) \
{ \
EXCEPTIONS_SIGJMP_BUF *buf = \
- exceptions_state_mc_init (uiout, &(EXCEPTION), (MASK)); \
+ exceptions_state_mc_init (&(EXCEPTION), (MASK)); \
EXCEPTIONS_SIGSETJMP (*buf); \
} \
while (exceptions_state_mc_action_iter ()) \