You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "defs.h"
#include "btrace.h"
#include "gdbthread.h"
-#include "exceptions.h"
#include "inferior.h"
#include "target.h"
#include "record.h"
#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. */
return SYMBOL_PRINT_NAME (sym);
if (msym != NULL)
- return SYMBOL_PRINT_NAME (msym);
+ return MSYMBOL_PRINT_NAME (msym);
return "<unknown>";
}
/* If the minimal symbol changed, we certainly switched functions. */
if (mfun != NULL && msym != NULL
- && strcmp (SYMBOL_LINKAGE_NAME (mfun), SYMBOL_LINKAGE_NAME (msym)) != 0)
+ && strcmp (MSYMBOL_LINKAGE_NAME (mfun), MSYMBOL_LINKAGE_NAME (msym)) != 0)
return 1;
/* If the symbol changed, we certainly switched functions. */
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
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. */
DEBUG ("free objfile");
- ALL_THREADS (tp)
+ ALL_NON_EXITED_THREADS (tp)
btrace_clear (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;
+}