From 0c5880af59f05ab2387c6466f8a8fae2044745bc Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sat, 16 Aug 2008 22:12:17 +0000 Subject: [PATCH] * target.h (pop_all_targets): Declare. * target.c (pop_all_targets): New. * top.c (quit_target): Pop all targets instead of just closing the current. --- gdb/ChangeLog | 7 +++++++ gdb/target.c | 18 ++++++++++++++++++ gdb/target.h | 7 +++++++ gdb/top.c | 5 +++-- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6b183d33d9..df1cb37f32 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2008-08-16 Pedro Alves + + * target.h (pop_all_targets): Declare. + * target.c (pop_all_targets): New. + * top.c (quit_target): Pop all targets instead of just closing the + current. + 2008-08-16 Vladimir Prus Thiago Jung Bauermann diff --git a/gdb/target.c b/gdb/target.c index 6cda0959a6..384fa209fb 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -821,6 +821,24 @@ pop_target (void) internal_error (__FILE__, __LINE__, _("failed internal consistency check")); } +void +pop_all_targets (int quitting) +{ + while ((int) (current_target.to_stratum) > (int) dummy_stratum) + { + target_close (¤t_target, quitting); + if (!unpush_target (target_stack)) + { + fprintf_unfiltered (gdb_stderr, + "pop_all_targets couldn't find target %s\n", + current_target.to_shortname); + internal_error (__FILE__, __LINE__, + _("failed internal consistency check")); + break; + } + } +} + /* Using the objfile specified in OBJFILE, find the address for the current thread's thread-local storage with offset OFFSET. */ CORE_ADDR diff --git a/gdb/target.h b/gdb/target.h index e2425667ea..e92176f83c 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1172,6 +1172,13 @@ extern void target_preopen (int); extern void pop_target (void); +/* Does whatever cleanup is required to get rid of all pushed targets. + QUITTING is propagated to target_close; it indicates that GDB is + exiting and should not get hung on an error (otherwise it is + important to perform clean termination, even if it takes a + while). */ +extern void pop_all_targets (int quitting); + extern CORE_ADDR target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset); diff --git a/gdb/top.c b/gdb/top.c index 7f46cafb0c..0ae7ea020f 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -1222,8 +1222,9 @@ quit_target (void *arg) target_kill (); } - /* UDI wants this, to kill the TIP. */ - target_close (¤t_target, 1); + /* Give all pushed targets a chance to do minimal cleanup, and pop + them all out. */ + pop_all_targets (1); /* Save the history information if it is appropriate to do so. */ if (write_history_p && history_filename) -- 2.11.0