From e02bc4cc30e0425abebd623e4decd1bf37b9e3da Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 6 Apr 2001 17:53:39 +0000 Subject: 2001-04-06 David Smith * arch-utils.c (default_prepare_to_proceed) (generic_prepare_to_proceed): Added new functions. * arch-utils.h: New function declarations for default_prepare_to_proceed() and generic_prepare_to_proceed(). * gdbarch.sh: Added PREPARE_TO_PROCEED. * gdbarch.c: Regenerated. * gdbarch.h: Regenerated. * inferior.h: Added get_last_target_status() declaration. * infrun.c (get_last_target_status): Added new function. (handle_inferior_event): Saves last pid and waitstatus, which will get returned by get_last_target_status(). * hppa-tdep.c (prepare_to_proceed): Added comment stating that prepare_to_proceed() is potentially redundant since default_prepare_to_proceed() has been added. * linux-thread.c (prepare_to_proceed): Ditto. * lin-lwp.c (prepare_to_proceed): Ditto. * m3-nat.c (prepare_to_proceed): Ditto. --- gdb/arch-utils.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'gdb/arch-utils.c') diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 004d3ae..10f0fc5 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -239,6 +239,61 @@ default_frame_address (struct frame_info *fi) return fi->frame; } +/* Default prepare_to_procced(). */ +int +default_prepare_to_proceed (int select_it) +{ + return 0; +} + +/* Generic prepare_to_proceed(). This one should be suitable for most + targets that support threads. */ +int +generic_prepare_to_proceed (int select_it) +{ + int wait_pid; + struct target_waitstatus wait_status; + + /* Get the last target status returned by target_wait(). */ + get_last_target_status (&wait_pid, &wait_status); + + /* Make sure we were stopped at a breakpoint. */ + if (wait_status.kind != TARGET_WAITKIND_STOPPED + || wait_status.value.sig != TARGET_SIGNAL_TRAP) + { + return 0; + } + + if (wait_pid != -1 && inferior_pid != wait_pid) + { + /* Switched over from WAIT_PID. */ + CORE_ADDR wait_pc = read_pc_pid (wait_pid); + + /* Avoid switching where it wouldn't do any good, i.e. if both + threads are at the same breakpoint. */ + if (wait_pc != read_pc () && breakpoint_here_p (wait_pc)) + { + if (select_it) + { + /* User hasn't deleted the breakpoint. Switch back to + WAIT_PID and return non-zero. */ + inferior_pid = wait_pid; + + /* FIXME: This stuff came from switch_to_thread() in + thread.c (which should probably be a public function). */ + flush_cached_frames (); + registers_changed (); + stop_pc = wait_pc; + select_frame (get_current_frame (), 0); + } + + return 1; + } + } + return 0; + +} + /* Functions to manipulate the endianness of the target. */ #ifdef TARGET_BYTE_ORDER_SELECTABLE -- cgit v1.1