diff options
author | Markus Metzger <markus.t.metzger@intel.com> | 2013-09-10 12:27:14 +0200 |
---|---|---|
committer | Markus Metzger <markus.t.metzger@intel.com> | 2014-01-16 13:12:00 +0100 |
commit | 6e07b1d27e5d3fb20e7d13f0cadfd923243fc48d (patch) | |
tree | 9e0046ecb5176806772d54c8369024d04a6ae82d /gdb/btrace.c | |
parent | 969c39fbcd6a5675c1f4b97cd23d680e4b5b6487 (diff) | |
download | gdb-6e07b1d27e5d3fb20e7d13f0cadfd923243fc48d.zip gdb-6e07b1d27e5d3fb20e7d13f0cadfd923243fc48d.tar.gz gdb-6e07b1d27e5d3fb20e7d13f0cadfd923243fc48d.tar.bz2 |
record-btrace: show trace from enable location
The btrace record target shows the branch trace from the location of the first
branch destination. This is the first BTS records.
After adding incremental updates, we can now add a dummy record for the current
PC when we enable tracing so we show the trace from the location where branch
tracing has been enabled.
2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
* btrace.c: Include regcache.h.
(btrace_add_pc): New.
(btrace_enable): Call btrace_add_pc.
(btrace_is_empty): New.
* btrace.h (btrace_is_empty): New.
* record-btrace.c (require_btrace, record_btrace_info): Call
btrace_is_empty.
testsuite/
* gdb.btrace/Makefile.in (EXECUTABLES): Add delta.
* gdb.btrace/exception.exp: Update.
* gdb.btrace/instruction_history.exp: Update.
* gdb.btrace/record_goto.exp: Update.
* gdb.btrace/tailcall.exp: Update.
* gdb.btrace/unknown_functions.exp: Update.
* gdb.btrace/delta.exp: New.
Diffstat (limited to 'gdb/btrace.c')
-rw-r--r-- | gdb/btrace.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gdb/btrace.c b/gdb/btrace.c index 28970c3..32918ce 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -30,6 +30,7 @@ #include "source.h" #include "filenames.h" #include "xml-support.h" +#include "regcache.h" /* Print a record debug message. Use do ... while (0) to avoid ambiguities when used in if statements. */ @@ -674,6 +675,32 @@ btrace_compute_ftrace (struct btrace_thread_info *btinfo, btinfo->level = -level; } +/* Add an entry for the current PC. */ + +static void +btrace_add_pc (struct thread_info *tp) +{ + VEC (btrace_block_s) *btrace; + struct btrace_block *block; + struct regcache *regcache; + struct cleanup *cleanup; + CORE_ADDR pc; + + regcache = get_thread_regcache (tp->ptid); + pc = regcache_read_pc (regcache); + + btrace = NULL; + cleanup = make_cleanup (VEC_cleanup (btrace_block_s), &btrace); + + block = VEC_safe_push (btrace_block_s, btrace, NULL); + block->begin = pc; + block->end = pc; + + btrace_compute_ftrace (&tp->btrace, btrace); + + do_cleanups (cleanup); +} + /* See btrace.h. */ void @@ -688,6 +715,11 @@ btrace_enable (struct thread_info *tp) DEBUG ("enable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid)); tp->btrace.target = target_enable_btrace (tp->ptid); + + /* Add an entry for the current PC so we start tracing from where we + enabled it. */ + if (tp->btrace.target != NULL) + btrace_add_pc (tp); } /* See btrace.h. */ @@ -1475,3 +1507,22 @@ btrace_is_replaying (struct thread_info *tp) { return tp->btrace.replay != NULL; } + +/* See btrace.h. */ + +int +btrace_is_empty (struct thread_info *tp) +{ + struct btrace_insn_iterator begin, end; + struct btrace_thread_info *btinfo; + + btinfo = &tp->btrace; + + if (btinfo->begin == NULL) + return 1; + + btrace_insn_begin (&begin, btinfo); + btrace_insn_end (&end, btinfo); + + return btrace_insn_cmp (&begin, &end) == 0; +} |