From 006631931599a9f7d47553e4c63c93f29208f821 Mon Sep 17 00:00:00 2001 From: palves Date: Mon, 18 Aug 2008 23:12:39 +0000 Subject: [PATCH] * corelow.c (core_open): Assume there was no upper layer left behind from a previous inferior. * target.c (pop_all_targets): Rename to ... (pop_all_targets_above): ... this. Add a target stratum parameter. Use it instead of hardcoding the dummy_stratum. (pop_all_targets): New, defer to pop_all_targets_above. (target_preopen): Use pop_all_targets_above. * target.h (pop_all_targets_above): Declare. --- gdb/ChangeLog | 11 +++++++++++ gdb/corelow.c | 22 ++++++---------------- gdb/target.c | 16 +++++++++++----- gdb/target.h | 4 ++++ 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e02205bc8e..91bc692d93 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ 2008-08-18 Pedro Alves + * corelow.c (core_open): Assume there was no upper layer left + behind from a previous inferior. + * target.c (pop_all_targets): Rename to ... + (pop_all_targets_above): ... this. Add a target stratum + parameter. Use it instead of hardcoding the dummy_stratum. + (pop_all_targets): New, defer to pop_all_targets_above. + (target_preopen): Use pop_all_targets_above. + * target.h (pop_all_targets_above): Declare. + +2008-08-18 Pedro Alves + * gdbthread.h (thread_change_ptid): Declare. * infrun.c (infrun_thread_ptid_changed): New. (_initialize_infrun): Attach infrun_thread_ptid_changed to the diff --git a/gdb/corelow.c b/gdb/corelow.c index 7c3a398427..ce8d6285a1 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -258,7 +258,6 @@ core_open (char *filename, int from_tty) struct cleanup *old_chain; char *temp; bfd *temp_bfd; - int ontop; int scratch_chan; int flags; @@ -341,7 +340,7 @@ core_open (char *filename, int from_tty) if (!exec_bfd) set_gdbarch_from_file (core_bfd); - ontop = !push_target (&core_ops); + push_target (&core_ops); discard_cleanups (old_chain); /* This is done first, before anything has a chance to query the @@ -368,21 +367,12 @@ core_open (char *filename, int from_tty) bfd_map_over_sections (core_bfd, add_to_thread_list, bfd_get_section_by_name (core_bfd, ".reg")); - if (ontop) - { - /* Fetch all registers from core file. */ - target_fetch_registers (get_current_regcache (), -1); + /* Fetch all registers from core file. */ + target_fetch_registers (get_current_regcache (), -1); - /* Now, set up the frame cache, and print the top of stack. */ - reinit_frame_cache (); - print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); - } - else - { - warning ( - "you won't be able to access this core file until you terminate\n\ -your %s; do ``info files''", target_longname); - } + /* Now, set up the frame cache, and print the top of stack. */ + reinit_frame_cache (); + print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC); } static void diff --git a/gdb/target.c b/gdb/target.c index 384fa209fb..681043eb76 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -822,9 +822,9 @@ pop_target (void) } void -pop_all_targets (int quitting) +pop_all_targets_above (enum strata above_stratum, int quitting) { - while ((int) (current_target.to_stratum) > (int) dummy_stratum) + while ((int) (current_target.to_stratum) > (int) above_stratum) { target_close (¤t_target, quitting); if (!unpush_target (target_stack)) @@ -839,6 +839,12 @@ pop_all_targets (int quitting) } } +void +pop_all_targets (int quitting) +{ + pop_all_targets_above (dummy_stratum, quitting); +} + /* Using the objfile specified in OBJFILE, find the address for the current thread's thread-local storage with offset OFFSET. */ CORE_ADDR @@ -1778,9 +1784,9 @@ target_preopen (int from_tty) /* Calling target_kill may remove the target from the stack. But if it doesn't (which seems like a win for UDI), remove it now. */ - - if (target_has_execution) - pop_target (); + /* Leave the exec target, though. The user may be switching from a + live process to a core of the same program. */ + pop_all_targets_above (file_stratum, 0); target_pre_inferior (from_tty); } diff --git a/gdb/target.h b/gdb/target.h index e92176f83c..ded91a2b91 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -1179,6 +1179,10 @@ extern void pop_target (void); while). */ extern void pop_all_targets (int quitting); +/* Like pop_all_targets, but pops only targets whose stratum is + strictly above ABOVE_STRATUM. */ +extern void pop_all_targets_above (enum strata above_stratum, int quitting); + extern CORE_ADDR target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset); -- 2.11.0