diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2008-05-04 14:12:34 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2008-05-04 14:12:34 +0000 |
commit | 515630c5e5a3b481867b81031930664f8d1d9b77 (patch) | |
tree | 97c8d75819dfa7fc34fe4d37b33a9986051c1bf4 | |
parent | ebd3bcc1327e6a7de6daf6536134cb20be9c2cfd (diff) | |
download | gdb-515630c5e5a3b481867b81031930664f8d1d9b77.zip gdb-515630c5e5a3b481867b81031930664f8d1d9b77.tar.gz gdb-515630c5e5a3b481867b81031930664f8d1d9b77.tar.bz2 |
* inferior.h (read_pc_pid, write_pc_pid): Remove.
* regcache.h (regcache_read_pc, regcache_write_pc): Add prototypes.
* regcache.c (read_pc_pid): Remove, replace by ...
(regcache_read_pc): ... this function.
(write_pc_pid): Remove, replace by ...
(regcache_write_pc): ... this function.
(read_pc, write_pc): Update.
* infrun.c (displaced_step_prepare): Replace read_pc_pid and
write_pc_pid by regcache_read_pc and regcache_write_pc.
(displaced_step_fixup): Likewise.
(resume): Likewise. Use regcache arch instead of current_gdbarch.
(prepare_to_proceed): Likewise.
(proceed): Likewise.
(adjust_pc_after_break): Likewise.
(handle_inferior_event): Likewise.
* linux-nat.c (cancel_breakpoint): Likewise.
* linux-thread-db.c (check_event): Likewise.
* aix-thread.c (aix_thread_wait): Likewise.
* tracepoint.c (trace_dump_command): Likewise.
-rw-r--r-- | gdb/ChangeLog | 25 | ||||
-rw-r--r-- | gdb/aix-thread.c | 15 | ||||
-rw-r--r-- | gdb/inferior.h | 4 | ||||
-rw-r--r-- | gdb/infrun.c | 102 | ||||
-rw-r--r-- | gdb/linux-nat.c | 16 | ||||
-rw-r--r-- | gdb/linux-thread-db.c | 5 | ||||
-rw-r--r-- | gdb/regcache.c | 28 | ||||
-rw-r--r-- | gdb/regcache.h | 5 | ||||
-rw-r--r-- | gdb/tracepoint.c | 9 |
9 files changed, 126 insertions, 83 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4236270..d05d6a8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,28 @@ +2008-05-04 Ulrich Weigand <uweigand@de.ibm.com> + + * inferior.h (read_pc_pid, write_pc_pid): Remove. + * regcache.h (regcache_read_pc, regcache_write_pc): Add prototypes. + + * regcache.c (read_pc_pid): Remove, replace by ... + (regcache_read_pc): ... this function. + (write_pc_pid): Remove, replace by ... + (regcache_write_pc): ... this function. + (read_pc, write_pc): Update. + + * infrun.c (displaced_step_prepare): Replace read_pc_pid and + write_pc_pid by regcache_read_pc and regcache_write_pc. + (displaced_step_fixup): Likewise. + (resume): Likewise. Use regcache arch instead of current_gdbarch. + (prepare_to_proceed): Likewise. + (proceed): Likewise. + (adjust_pc_after_break): Likewise. + (handle_inferior_event): Likewise. + + * linux-nat.c (cancel_breakpoint): Likewise. + * linux-thread-db.c (check_event): Likewise. + * aix-thread.c (aix_thread_wait): Likewise. + * tracepoint.c (trace_dump_command): Likewise. + 2008-05-04 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf2loc.c (dwarf_expr_frame_base): Error out on missing diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c index 93da34c..3377d50 100644 --- a/gdb/aix-thread.c +++ b/gdb/aix-thread.c @@ -1010,11 +1010,16 @@ aix_thread_wait (ptid_t ptid, struct target_waitstatus *status) return pid_to_ptid (-1); /* Check whether libpthdebug might be ready to be initialized. */ - if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED && - status->value.sig == TARGET_SIGNAL_TRAP - && read_pc_pid (ptid) - - gdbarch_decr_pc_after_break (current_gdbarch) == pd_brk_addr) - return pd_activate (0); + if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED + && status->value.sig == TARGET_SIGNAL_TRAP) + { + struct regcache *regcache = get_thread_regcache (ptid); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + + if (regcache_read_pc (regcache) + - gdbarch_decr_pc_after_break (gdbarch) == pd_brk_addr) + return pd_activate (0); + } return pd_update (0); } diff --git a/gdb/inferior.h b/gdb/inferior.h index 83c76fc..1dd152a 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -151,12 +151,8 @@ extern void terminal_ours (void); extern CORE_ADDR read_pc (void); -extern CORE_ADDR read_pc_pid (ptid_t); - extern void write_pc (CORE_ADDR); -extern void write_pc_pid (CORE_ADDR, ptid_t); - extern CORE_ADDR unsigned_pointer_to_address (struct type *type, const gdb_byte *buf); extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf, diff --git a/gdb/infrun.c b/gdb/infrun.c index 3944c0f..8c4c410 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -710,7 +710,7 @@ displaced_step_prepare (ptid_t ptid) displaced_step_clear (); - original = read_pc_pid (ptid); + original = regcache_read_pc (regcache); copy = gdbarch_displaced_step_location (gdbarch); len = gdbarch_max_insn_length (gdbarch); @@ -736,7 +736,7 @@ displaced_step_prepare (ptid_t ptid) make_cleanup (cleanup_displaced_step_closure, closure); /* Resume execution at the copy. */ - write_pc_pid (copy, ptid); + regcache_write_pc (regcache, copy); discard_cleanups (old_cleanups); @@ -805,9 +805,10 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal) { /* Since the instruction didn't complete, all we can do is relocate the PC. */ - CORE_ADDR pc = read_pc_pid (event_ptid); + struct regcache *regcache = get_thread_regcache (event_ptid); + CORE_ADDR pc = regcache_read_pc (regcache); pc = displaced_step_original + (pc - displaced_step_copy); - write_pc_pid (pc, event_ptid); + regcache_write_pc (regcache, pc); } do_cleanups (old_cleanups); @@ -889,7 +890,9 @@ resume (int step, enum target_signal sig) { int should_resume = 1; struct cleanup *old_cleanups = make_cleanup (resume_cleanups, 0); - CORE_ADDR pc = read_pc (); + struct regcache *regcache = get_current_regcache (); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + CORE_ADDR pc = regcache_read_pc (regcache); QUIT; if (debug_infrun) @@ -916,9 +919,8 @@ resume (int step, enum target_signal sig) breakpoints can't be removed. So we have to test for it here. */ if (breakpoint_here_p (pc) == permanent_breakpoint_here) { - if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch)) - gdbarch_skip_permanent_breakpoint (current_gdbarch, - get_current_regcache ()); + if (gdbarch_skip_permanent_breakpoint_p (gdbarch)) + gdbarch_skip_permanent_breakpoint (gdbarch, regcache); else error (_("\ The program is stopped at a permanent breakpoint, but GDB does not know\n\ @@ -933,7 +935,7 @@ a command like `return' or `jump' to continue execution.")); the comments for displaced_step_prepare explain why. The comments in the handle_inferior event for dealing with 'random signals' explain what we do instead. */ - if (use_displaced_stepping (current_gdbarch) + if (use_displaced_stepping (gdbarch) && stepping_over_breakpoint && sig == TARGET_SIGNAL_0) { @@ -944,10 +946,10 @@ a command like `return' or `jump' to continue execution.")); return; } - if (step && gdbarch_software_single_step_p (current_gdbarch)) + if (step && gdbarch_software_single_step_p (gdbarch)) { /* Do it the hard way, w/temp breakpoints */ - if (gdbarch_software_single_step (current_gdbarch, get_current_frame ())) + if (gdbarch_software_single_step (gdbarch, get_current_frame ())) { /* ...and don't ask hardware to do it. */ step = 0; @@ -1034,7 +1036,7 @@ a command like `return' or `jump' to continue execution.")); resume_ptid = inferior_ptid; } - if (gdbarch_cannot_step_breakpoint (current_gdbarch)) + if (gdbarch_cannot_step_breakpoint (gdbarch)) { /* Most targets can step a breakpoint instruction, thus executing it normally. But if this one cannot, just @@ -1044,10 +1046,11 @@ a command like `return' or `jump' to continue execution.")); } if (debug_displaced - && use_displaced_stepping (current_gdbarch) + && use_displaced_stepping (gdbarch) && stepping_over_breakpoint) { - CORE_ADDR actual_pc = read_pc_pid (resume_ptid); + struct regcache *resume_regcache = get_thread_regcache (resume_ptid); + CORE_ADDR actual_pc = regcache_read_pc (resume_regcache); gdb_byte buf[4]; fprintf_unfiltered (gdb_stdlog, "displaced: run 0x%s: ", @@ -1110,22 +1113,24 @@ prepare_to_proceed (int step) /* Switched over from WAIT_PID. */ if (!ptid_equal (wait_ptid, minus_one_ptid) - && !ptid_equal (inferior_ptid, wait_ptid) - && breakpoint_here_p (read_pc_pid (wait_ptid))) + && !ptid_equal (inferior_ptid, wait_ptid)) { - /* If stepping, remember current thread to switch back to. */ - if (step) + struct regcache *regcache = get_thread_regcache (wait_ptid); + + if (breakpoint_here_p (regcache_read_pc (regcache))) { - deferred_step_ptid = inferior_ptid; - } + /* If stepping, remember current thread to switch back to. */ + if (step) + deferred_step_ptid = inferior_ptid; - /* Switch back to WAIT_PID thread. */ - switch_to_thread (wait_ptid); + /* Switch back to WAIT_PID thread. */ + switch_to_thread (wait_ptid); - /* We return 1 to indicate that there is a breakpoint here, - so we need to step over it before continuing to avoid - hitting it straight away. */ - return 1; + /* We return 1 to indicate that there is a breakpoint here, + so we need to step over it before continuing to avoid + hitting it straight away. */ + return 1; + } } return 0; @@ -1151,31 +1156,34 @@ static CORE_ADDR prev_pc; void proceed (CORE_ADDR addr, enum target_signal siggnal, int step) { + struct regcache *regcache = get_current_regcache (); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + CORE_ADDR pc = regcache_read_pc (regcache); int oneproc = 0; if (step > 0) - step_start_function = find_pc_function (read_pc ()); + step_start_function = find_pc_function (pc); if (step < 0) stop_after_trap = 1; if (addr == (CORE_ADDR) -1) { - if (read_pc () == stop_pc && breakpoint_here_p (read_pc ())) + if (pc == stop_pc && breakpoint_here_p (pc)) /* There is a breakpoint at the address we will resume at, step one instruction before inserting breakpoints so that we do not stop right away (and report a second hit at this breakpoint). */ oneproc = 1; - else if (gdbarch_single_step_through_delay_p (current_gdbarch) - && gdbarch_single_step_through_delay (current_gdbarch, - get_current_frame ())) + else if (gdbarch_single_step_through_delay_p (gdbarch) + && gdbarch_single_step_through_delay (gdbarch, + get_current_frame ())) /* We stepped onto an instruction that needs to be stepped again before re-inserting the breakpoint, do so. */ oneproc = 1; } else { - write_pc (addr); + regcache_write_pc (regcache, addr); } if (debug_infrun) @@ -1205,14 +1213,14 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step) inserted. Otherwise we need to disable all breakpoints, step one instruction, and then re-add them when that step is finished. */ - if (!use_displaced_stepping (current_gdbarch)) + if (!use_displaced_stepping (gdbarch)) remove_breakpoints (); } /* We can insert breakpoints if we're not trying to step over one, or if we are stepping over one but we're using displaced stepping to do so. */ - if (! stepping_over_breakpoint || use_displaced_stepping (current_gdbarch)) + if (! stepping_over_breakpoint || use_displaced_stepping (gdbarch)) insert_breakpoints (); if (siggnal != TARGET_SIGNAL_DEFAULT) @@ -1247,10 +1255,10 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step) the prev_pc value before calculating the line number. This approach did not work because on platforms that use ptrace, the pc register cannot be read unless the inferior is stopped. At that point, we - are not guaranteed the inferior is stopped and so the read_pc () + are not guaranteed the inferior is stopped and so the regcache_read_pc () call can fail. Setting the prev_pc value here ensures the value is updated correctly when the inferior is stopped. */ - prev_pc = read_pc (); + prev_pc = regcache_read_pc (get_current_regcache ()); /* Resume inferior. */ resume (oneproc || step || bpstat_should_step (), stop_signal); @@ -1615,11 +1623,13 @@ context_switch (struct execution_control_state *ecs) static void adjust_pc_after_break (struct execution_control_state *ecs) { + struct regcache *regcache = get_thread_regcache (ecs->ptid); + struct gdbarch *gdbarch = get_regcache_arch (regcache); CORE_ADDR breakpoint_pc; /* If this target does not decrement the PC after breakpoints, then we have nothing to do. */ - if (gdbarch_decr_pc_after_break (current_gdbarch) == 0) + if (gdbarch_decr_pc_after_break (gdbarch) == 0) return; /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If @@ -1651,8 +1661,8 @@ adjust_pc_after_break (struct execution_control_state *ecs) /* Find the location where (if we've hit a breakpoint) the breakpoint would be. */ - breakpoint_pc = read_pc_pid (ecs->ptid) - gdbarch_decr_pc_after_break - (current_gdbarch); + breakpoint_pc = regcache_read_pc (regcache) + - gdbarch_decr_pc_after_break (gdbarch); /* Check whether there actually is a software breakpoint inserted at that location. */ @@ -1680,7 +1690,7 @@ adjust_pc_after_break (struct execution_control_state *ecs) || !ptid_equal (ecs->ptid, inferior_ptid) || !currently_stepping (ecs) || prev_pc == breakpoint_pc) - write_pc_pid (breakpoint_pc, ecs->ptid); + regcache_write_pc (regcache, breakpoint_pc); } } @@ -1918,7 +1928,7 @@ handle_inferior_event (struct execution_control_state *ecs) follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname); xfree (pending_follow.execd_pathname); - stop_pc = read_pc_pid (ecs->ptid); + stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); ecs->saved_inferior_ptid = inferior_ptid; inferior_ptid = ecs->ptid; @@ -2004,7 +2014,7 @@ handle_inferior_event (struct execution_control_state *ecs) it here, before we set stop_pc.) */ displaced_step_fixup (ecs->ptid, stop_signal); - stop_pc = read_pc_pid (ecs->ptid); + stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid)); if (debug_infrun) { @@ -2143,7 +2153,11 @@ handle_inferior_event (struct execution_control_state *ecs) when they stop, or to re-poll the remote looking for this particular thread (i.e. temporarily enable schedlock). */ - if (read_pc_pid (singlestep_ptid) != singlestep_pc) + + CORE_ADDR new_singlestep_pc + = regcache_read_pc (get_thread_regcache (singlestep_ptid)); + + if (new_singlestep_pc != singlestep_pc) { if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: unexpected thread," @@ -2154,7 +2168,7 @@ handle_inferior_event (struct execution_control_state *ecs) the context we want to use. Just fudge our state and continue. */ ecs->ptid = singlestep_ptid; - stop_pc = read_pc_pid (ecs->ptid); + stop_pc = new_singlestep_pc; } else { diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 4b6c614..5d15d42 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2157,9 +2157,12 @@ cancel_breakpoint (struct lwp_info *lp) delete or disable the breakpoint, but the LWP will have already tripped on it. */ - if (breakpoint_inserted_here_p (read_pc_pid (lp->ptid) - - gdbarch_decr_pc_after_break - (current_gdbarch))) + struct regcache *regcache = get_thread_regcache (lp->ptid); + struct gdbarch *gdbarch = get_regcache_arch (regcache); + CORE_ADDR pc; + + pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch); + if (breakpoint_inserted_here_p (pc)) { if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, @@ -2167,10 +2170,9 @@ cancel_breakpoint (struct lwp_info *lp) target_pid_to_str (lp->ptid)); /* Back up the PC if necessary. */ - if (gdbarch_decr_pc_after_break (current_gdbarch)) - write_pc_pid (read_pc_pid (lp->ptid) - gdbarch_decr_pc_after_break - (current_gdbarch), - lp->ptid); + if (gdbarch_decr_pc_after_break (gdbarch)) + regcache_write_pc (regcache, pc); + return 1; } return 0; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 83632d0..c7aaf60 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -747,6 +747,8 @@ thread_db_detach (char *args, int from_tty) static void check_event (ptid_t ptid) { + struct regcache *regcache = get_thread_regcache (ptid); + struct gdbarch *gdbarch = get_regcache_arch (regcache); td_event_msg_t msg; td_thrinfo_t ti; td_err_e err; @@ -754,7 +756,8 @@ check_event (ptid_t ptid) int loop = 0; /* Bail out early if we're not at a thread event breakpoint. */ - stop_pc = read_pc_pid (ptid) - gdbarch_decr_pc_after_break (current_gdbarch); + stop_pc = regcache_read_pc (regcache) + - gdbarch_decr_pc_after_break (gdbarch); if (stop_pc != td_create_bp_addr && stop_pc != td_death_bp_addr) return; diff --git a/gdb/regcache.c b/gdb/regcache.c index 85763c7..199b626 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -805,22 +805,11 @@ regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf) } -/* read_pc, write_pc, etc. Special handling for register PC. */ - -/* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc() and - read_sp(), will eventually be replaced by per-frame methods. - Instead of relying on the global INFERIOR_PTID, they will use the - contextual information provided by the FRAME. These functions do - not belong in the register cache. */ - -/* NOTE: cagney/2003-06-07: The functions generic_target_write_pc(), - write_pc_pid() and write_pc(), all need to be replaced by something - that does not rely on global state. But what? */ +/* Special handling for register PC. */ CORE_ADDR -read_pc_pid (ptid_t ptid) +regcache_read_pc (struct regcache *regcache) { - struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); CORE_ADDR pc_val; @@ -837,21 +826,20 @@ read_pc_pid (ptid_t ptid) pc_val = gdbarch_addr_bits_remove (gdbarch, raw_val); } else - internal_error (__FILE__, __LINE__, _("read_pc_pid: Unable to find PC")); - + internal_error (__FILE__, __LINE__, + _("regcache_read_pc: Unable to find PC")); return pc_val; } CORE_ADDR read_pc (void) { - return read_pc_pid (inferior_ptid); + return regcache_read_pc (get_current_regcache ()); } void -write_pc_pid (CORE_ADDR pc, ptid_t ptid) +regcache_write_pc (struct regcache *regcache, CORE_ADDR pc) { - struct regcache *regcache = get_thread_regcache (ptid); struct gdbarch *gdbarch = get_regcache_arch (regcache); if (gdbarch_write_pc_p (gdbarch)) @@ -861,13 +849,13 @@ write_pc_pid (CORE_ADDR pc, ptid_t ptid) gdbarch_pc_regnum (gdbarch), pc); else internal_error (__FILE__, __LINE__, - _("write_pc_pid: Unable to update PC")); + _("regcache_write_pc: Unable to update PC")); } void write_pc (CORE_ADDR pc) { - write_pc_pid (pc, inferior_ptid); + regcache_write_pc (get_current_regcache (), pc); } diff --git a/gdb/regcache.h b/gdb/regcache.h index 1e4ee86..25f4e75 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -94,6 +94,11 @@ void regcache_cooked_read_part (struct regcache *regcache, int regnum, void regcache_cooked_write_part (struct regcache *regcache, int regnum, int offset, int len, const gdb_byte *buf); +/* Special routines to read/write the PC. */ + +extern CORE_ADDR regcache_read_pc (struct regcache *regcache); +extern void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc); + /* Transfer a raw register [0..NUM_REGS) between the regcache and the target. These functions are called by the target in response to a target_fetch_registers() or target_store_registers(). */ diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index fbb1b27..40e3c0f 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2558,6 +2558,8 @@ replace_comma (void *data) static void trace_dump_command (char *args, int from_tty) { + struct regcache *regcache; + struct gdbarch *gdbarch; struct tracepoint *t; struct action_line *action; char *action_exp, *next_comma; @@ -2594,8 +2596,11 @@ trace_dump_command (char *args, int from_tty) to the tracepoint PC. If not, then the current frame was collected during single-stepping. */ - stepping_frame = (t->address != (read_pc () - gdbarch_decr_pc_after_break - (current_gdbarch))); + regcache = get_current_regcache (); + gdbarch = get_regcache_arch (regcache); + + stepping_frame = (t->address != (regcache_read_pc (regcache) + - gdbarch_decr_pc_after_break (gdbarch))); for (action = t->actions; action; action = action->next) { |