aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Metzger <markus.t.metzger@intel.com>2015-08-25 10:49:11 +0200
committerMarkus Metzger <markus.t.metzger@intel.com>2015-09-18 14:20:44 +0200
commit3c615f99d3923df7dfa94c6587733c682efbbc78 (patch)
tree2c9f7250c68a97e2b84a7ec39702a11abdf45668
parent987e68b1a38ad9116f309bff006e794c7e6f85e8 (diff)
downloadbinutils-3c615f99d3923df7dfa94c6587733c682efbbc78.zip
binutils-3c615f99d3923df7dfa94c6587733c682efbbc78.tar.gz
binutils-3c615f99d3923df7dfa94c6587733c682efbbc78.tar.bz2
btrace: extract the breakpoint check from record_btrace_step_thread
There are two places where record_btrace_step_thread checks for a breakpoint at the current replay position. Move this code into its own function. gdb/ * record-btrace.c (record_btrace_replay_at_breakpoint): New. (record_btrace_step_thread): Call record_btrace_replay_at_breakpoint.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/record-btrace.c42
2 files changed, 35 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 098f732..e56028a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
+ * record-btrace.c (record_btrace_replay_at_breakpoint): New.
+ (record_btrace_step_thread): Call record_btrace_replay_at_breakpoint.
+
+2015-09-18 Markus Metzger <markus.t.metzger@intel.com>
+
* record-btrace.c (btrace_thread_flag_to_str)
(record_btrace_cancel_resume): New.
(record_btrace_step_thread): Call btrace_thread_flag_to_str.
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 7ee681c..77494ba 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1983,6 +1983,34 @@ record_btrace_clear_histories (struct btrace_thread_info *btinfo)
btinfo->call_history = NULL;
}
+/* Check whether TP's current replay position is at a breakpoint. */
+
+static int
+record_btrace_replay_at_breakpoint (struct thread_info *tp)
+{
+ struct btrace_insn_iterator *replay;
+ struct btrace_thread_info *btinfo;
+ const struct btrace_insn *insn;
+ struct inferior *inf;
+
+ btinfo = &tp->btrace;
+ replay = btinfo->replay;
+
+ if (replay == NULL)
+ return 0;
+
+ insn = btrace_insn_get (replay);
+ if (insn == NULL)
+ return 0;
+
+ inf = find_inferior_ptid (tp->ptid);
+ if (inf == NULL)
+ return 0;
+
+ return record_check_stopped_by_breakpoint (inf->aspace, insn->pc,
+ &btinfo->stop_reason);
+}
+
/* Step a single thread. */
static struct target_waitstatus
@@ -1990,8 +2018,6 @@ record_btrace_step_thread (struct thread_info *tp)
{
struct btrace_insn_iterator *replay, end;
struct btrace_thread_info *btinfo;
- struct address_space *aspace;
- struct inferior *inf;
enum btrace_thread_flag flags;
unsigned int steps;
@@ -2067,9 +2093,6 @@ record_btrace_step_thread (struct thread_info *tp)
if (replay == NULL)
return btrace_step_no_history ();
- inf = find_inferior_ptid (tp->ptid);
- aspace = inf->aspace;
-
/* Determine the end of the instruction trace. */
btrace_insn_end (&end, btinfo);
@@ -2102,8 +2125,7 @@ record_btrace_step_thread (struct thread_info *tp)
target_pid_to_str (tp->ptid),
core_addr_to_string_nz (insn->pc));
- if (record_check_stopped_by_breakpoint (aspace, insn->pc,
- &btinfo->stop_reason))
+ if (record_btrace_replay_at_breakpoint (tp))
return btrace_step_stopped ();
}
@@ -2112,9 +2134,6 @@ record_btrace_step_thread (struct thread_info *tp)
if (replay == NULL)
replay = record_btrace_start_replaying (tp);
- inf = find_inferior_ptid (tp->ptid);
- aspace = inf->aspace;
-
for (;;)
{
const struct btrace_insn *insn;
@@ -2135,8 +2154,7 @@ record_btrace_step_thread (struct thread_info *tp)
target_pid_to_str (tp->ptid),
core_addr_to_string_nz (insn->pc));
- if (record_check_stopped_by_breakpoint (aspace, insn->pc,
- &btinfo->stop_reason))
+ if (record_btrace_replay_at_breakpoint (tp))
return btrace_step_stopped ();
}
}