From: Markus Metzger <markus.t.metzger@intel.com>
To: jan.kratochvil@redhat.com, palves@redhat.com
Cc: gdb-patches@sourceware.org
Subject: [PATCH v9 28/29] target: allow decr_pc_after_break to be defined by the target
Date: Thu, 19 Dec 2013 16:45:00 -0000 [thread overview]
Message-ID: <1387471499-29444-29-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1387471499-29444-1-git-send-email-markus.t.metzger@intel.com>
Allow the target to define which value to use in decr_pc_after_break.
It defaults to gdbarch_decr_pc_after_break (GDBARCH).
2013-12-19 Markus Metzger <markus.t.metzger@intel.com>
* target.h (struct target_ops) <to_decr_pc_after_break>: New.
(forward_target_decr_pc_after_break)
(target_decr_pc_after_break): New.
* target.c (forward_target_decr_pc_after_break)
(target_decr_pc_after_break): New.
* aix-thread.c (aix_thread_wait): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* darwin-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* infrun.c (adjust_pc_after_break): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* linux-nat.c (cancel_breakpoint): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* linux-thread-db.c (check_event): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
* record-full.c (record_full_wait_1): Call target_decr_pc_after_break
instead of gdbarch_decr_pc_after_break.
---
gdb/aix-thread.c | 2 +-
gdb/darwin-nat.c | 4 ++--
gdb/infrun.c | 9 +++++----
gdb/linux-nat.c | 4 ++--
gdb/linux-thread-db.c | 2 +-
gdb/record-full.c | 6 +++---
gdb/target.c | 21 +++++++++++++++++++++
gdb/target.h | 13 +++++++++++++
8 files changed, 48 insertions(+), 13 deletions(-)
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index df21a99..48b38de 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1044,7 +1044,7 @@ aix_thread_wait (struct target_ops *ops,
struct gdbarch *gdbarch = get_regcache_arch (regcache);
if (regcache_read_pc (regcache)
- - gdbarch_decr_pc_after_break (gdbarch) == pd_brk_addr)
+ - target_decr_pc_after_break (gdbarch) == pd_brk_addr)
return pd_activate (0);
}
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index f0f938d..aaf9f73 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1011,14 +1011,14 @@ cancel_breakpoint (ptid_t ptid)
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR pc;
- pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch);
+ pc = regcache_read_pc (regcache) - target_decr_pc_after_break (gdbarch);
if (breakpoint_inserted_here_p (get_regcache_aspace (regcache), pc))
{
inferior_debug (4, "cancel_breakpoint for thread 0x%x\n",
ptid_get_tid (ptid));
/* Back up the PC if necessary. */
- if (gdbarch_decr_pc_after_break (gdbarch))
+ if (target_decr_pc_after_break (gdbarch))
regcache_write_pc (regcache, pc);
return 1;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index d8f9787..debd0c8 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2963,7 +2963,7 @@ adjust_pc_after_break (struct execution_control_state *ecs)
struct regcache *regcache;
struct gdbarch *gdbarch;
struct address_space *aspace;
- CORE_ADDR breakpoint_pc;
+ CORE_ADDR breakpoint_pc, decr_pc;
/* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP. If
we aren't, just return.
@@ -3025,15 +3025,16 @@ adjust_pc_after_break (struct execution_control_state *ecs)
we have nothing to do. */
regcache = get_thread_regcache (ecs->ptid);
gdbarch = get_regcache_arch (regcache);
- if (gdbarch_decr_pc_after_break (gdbarch) == 0)
+
+ decr_pc = target_decr_pc_after_break (gdbarch);
+ if (decr_pc == 0)
return;
aspace = get_regcache_aspace (regcache);
/* Find the location where (if we've hit a breakpoint) the
breakpoint would be. */
- breakpoint_pc = regcache_read_pc (regcache)
- - gdbarch_decr_pc_after_break (gdbarch);
+ breakpoint_pc = regcache_read_pc (regcache) - decr_pc;
/* Check whether there actually is a software breakpoint inserted at
that location.
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 88af3b5..17a07e9 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2738,7 +2738,7 @@ cancel_breakpoint (struct lwp_info *lp)
struct gdbarch *gdbarch = get_regcache_arch (regcache);
CORE_ADDR pc;
- pc = regcache_read_pc (regcache) - gdbarch_decr_pc_after_break (gdbarch);
+ pc = regcache_read_pc (regcache) - target_decr_pc_after_break (gdbarch);
if (breakpoint_inserted_here_p (get_regcache_aspace (regcache), pc))
{
if (debug_linux_nat)
@@ -2747,7 +2747,7 @@ cancel_breakpoint (struct lwp_info *lp)
target_pid_to_str (lp->ptid));
/* Back up the PC if necessary. */
- if (gdbarch_decr_pc_after_break (gdbarch))
+ if (target_decr_pc_after_break (gdbarch))
regcache_write_pc (regcache, pc);
return 1;
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 4cc3a4c..b81a074 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1394,7 +1394,7 @@ check_event (ptid_t ptid)
/* Bail out early if we're not at a thread event breakpoint. */
stop_pc = regcache_read_pc (regcache)
- - gdbarch_decr_pc_after_break (gdbarch);
+ - target_decr_pc_after_break (gdbarch);
if (stop_pc != info->td_create_bp_addr
&& stop_pc != info->td_death_bp_addr)
return;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index b54314d..c68a000 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -1259,7 +1259,7 @@ record_full_wait_1 (struct target_ops *ops,
struct gdbarch *gdbarch
= get_regcache_arch (regcache);
CORE_ADDR decr_pc_after_break
- = gdbarch_decr_pc_after_break (gdbarch);
+ = target_decr_pc_after_break (gdbarch);
if (decr_pc_after_break)
regcache_write_pc (regcache,
tmp_pc + decr_pc_after_break);
@@ -1332,7 +1332,7 @@ record_full_wait_1 (struct target_ops *ops,
tmp_pc = regcache_read_pc (regcache);
if (breakpoint_inserted_here_p (aspace, tmp_pc))
{
- int decr_pc_after_break = gdbarch_decr_pc_after_break (gdbarch);
+ int decr_pc_after_break = target_decr_pc_after_break (gdbarch);
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
@@ -1414,7 +1414,7 @@ record_full_wait_1 (struct target_ops *ops,
if (breakpoint_inserted_here_p (aspace, tmp_pc))
{
int decr_pc_after_break
- = gdbarch_decr_pc_after_break (gdbarch);
+ = target_decr_pc_after_break (gdbarch);
if (record_debug)
fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/target.c b/gdb/target.c
index 45261ef..2a81360 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -4526,6 +4526,27 @@ target_get_tailcall_unwinder (void)
return NULL;
}
+/* See target.h. */
+
+CORE_ADDR
+forward_target_decr_pc_after_break (struct target_ops *ops,
+ struct gdbarch *gdbarch)
+{
+ for (; ops != NULL; ops = ops->beneath)
+ if (ops->to_decr_pc_after_break != NULL)
+ return ops->to_decr_pc_after_break (ops, gdbarch);
+
+ return gdbarch_decr_pc_after_break (gdbarch);
+}
+
+/* See target.h. */
+
+CORE_ADDR
+target_decr_pc_after_break (struct gdbarch *gdbarch)
+{
+ return forward_target_decr_pc_after_break (current_target.beneath, gdbarch);
+}
+
static int
deprecated_debug_xfer_memory (CORE_ADDR memaddr, bfd_byte *myaddr, int len,
int write, struct mem_attrib *attrib,
diff --git a/gdb/target.h b/gdb/target.h
index 231a435..1c82c44 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -906,6 +906,12 @@ struct target_ops
const struct frame_unwind *to_get_unwinder;
const struct frame_unwind *to_get_tailcall_unwinder;
+ /* Return the number of bytes by which the PC needs to be decremented
+ after executing a breakpoint instruction.
+ Defaults to gdbarch_decr_pc_after_break (GDBARCH). */
+ CORE_ADDR (*to_decr_pc_after_break) (struct target_ops *ops,
+ struct gdbarch *gdbarch);
+
int to_magic;
/* Need sub-structure for target machine related rather than comm related?
*/
@@ -2036,4 +2042,11 @@ extern void target_call_history_from (ULONGEST begin, int size, int flags);
/* See to_call_history_range. */
extern void target_call_history_range (ULONGEST begin, ULONGEST end, int flags);
+/* See to_decr_pc_after_break. Start searching for the target at OPS. */
+extern CORE_ADDR forward_target_decr_pc_after_break (struct target_ops *ops,
+ struct gdbarch *gdbarch);
+
+/* See to_decr_pc_after_break. */
+extern CORE_ADDR target_decr_pc_after_break (struct gdbarch *gdbarch);
+
#endif /* !defined (TARGET_H) */
--
1.8.3.1
next prev parent reply other threads:[~2013-12-19 16:45 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 16:45 [PATCH v9 00/29] record-btrace: reverse Markus Metzger
2013-12-19 16:45 ` [PATCH v9 07/29] btrace: change branch trace data structure Markus Metzger
2013-12-19 16:45 ` [PATCH v9 26/29] btrace, gdbserver: read branch trace incrementally Markus Metzger
2013-12-19 16:45 ` [PATCH v9 20/29] target, breakpoint: allow insert/remove breakpoint to be forwarded Markus Metzger
2013-12-19 19:08 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 15/29] record-btrace: supply register target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 19/29] record-btrace, frame: supply target-specific unwinder Markus Metzger
2013-12-19 16:45 ` [PATCH v9 17/29] frame, cfa: check unwind stop reason first Markus Metzger
2013-12-19 16:45 ` [PATCH v9 14/29] target: add ops parameter to to_prepare_to_store method Markus Metzger
2013-12-19 18:30 ` Pedro Alves
2013-12-19 21:13 ` Tom Tromey
2013-12-20 13:07 ` Metzger, Markus T
2013-12-20 15:13 ` Tom Tromey
2013-12-20 17:23 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 06/29] frame: add frame_id_build_unavailable_stack_special Markus Metzger
2013-12-19 18:12 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 02/29] btrace, linux: fix memory leak when reading branch trace Markus Metzger
2013-12-19 16:45 ` [PATCH v9 27/29] record-btrace: show trace from enable location Markus Metzger
2013-12-19 16:45 ` [PATCH v9 01/29] btrace, test: fix multi-line btrace tests Markus Metzger
2013-12-19 18:01 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 18/29] frame: do not assume unwinding will succeed Markus Metzger
2013-12-19 16:45 ` [PATCH v9 05/29] frame: add frame_is_tailcall function Markus Metzger
2013-12-19 20:19 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 09/29] record-btrace: start counting at one Markus Metzger
2013-12-19 17:27 ` Eli Zaretskii
2013-12-19 16:45 ` [PATCH v9 08/29] record-btrace: fix insn range in function call history Markus Metzger
2013-12-19 16:45 ` [PATCH v9 16/29] frame, backtrace: allow targets to supply a frame unwinder Markus Metzger
2013-12-19 18:41 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 12/29] record-btrace: make ranges include begin and end Markus Metzger
2013-12-19 17:29 ` Eli Zaretskii
2013-12-19 16:45 ` [PATCH v9 11/29] record-btrace: optionally indent function call history Markus Metzger
2013-12-19 18:23 ` Pedro Alves
2013-12-20 12:54 ` Metzger, Markus T
2013-12-20 16:47 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 03/29] btrace: uppercase btrace_read_type Markus Metzger
2013-12-19 16:45 ` Markus Metzger [this message]
2013-12-19 19:51 ` [PATCH v9 28/29] target: allow decr_pc_after_break to be defined by the target Pedro Alves
2013-12-19 16:45 ` [PATCH v9 04/29] gdbarch: add instruction predicate methods Markus Metzger
2013-12-19 20:19 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 21/29] record-btrace: provide xfer_partial target method Markus Metzger
2013-12-19 19:13 ` Pedro Alves
2013-12-20 13:37 ` Metzger, Markus T
2013-12-20 13:54 ` Metzger, Markus T
2013-12-20 15:56 ` Pedro Alves
2013-12-20 16:02 ` Pedro Alves
2014-01-13 17:11 ` Pedro Alves
2014-01-13 12:36 ` Metzger, Markus T
2014-01-13 16:47 ` Pedro Alves
2013-12-19 19:26 ` Pedro Alves
2013-12-20 13:32 ` Metzger, Markus T
2013-12-20 15:36 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 22/29] record-btrace: add to_wait and to_resume target methods Markus Metzger
2013-12-19 16:45 ` [PATCH v9 25/29] record-btrace: extend unwinder Markus Metzger
2013-12-19 16:45 ` [PATCH v9 29/29] record-btrace: add (reverse-)stepping support Markus Metzger
2013-12-19 17:31 ` Eli Zaretskii
2013-12-19 20:10 ` Pedro Alves
2013-12-20 14:37 ` Metzger, Markus T
2013-12-20 14:47 ` Metzger, Markus T
2013-12-20 16:31 ` Pedro Alves
2013-12-20 16:07 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 13/29] btrace: add replay position to btrace thread info Markus Metzger
2013-12-19 16:45 ` [PATCH v9 23/29] record-btrace: provide target_find_new_threads method Markus Metzger
2013-12-19 19:32 ` Pedro Alves
2013-12-19 16:45 ` [PATCH v9 10/29] btrace: increase buffer size Markus Metzger
2013-12-19 16:45 ` [PATCH v9 24/29] record-btrace: add record goto target methods Markus Metzger
2013-12-19 20:23 ` [PATCH v9 00/29] record-btrace: reverse Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387471499-29444-29-git-send-email-markus.t.metzger@intel.com \
--to=markus.t.metzger@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=palves@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).