#include <inttypes.h>
#include <ctype.h>
+#include <algorithm>
/* Command lists for btrace maintenance commands. */
static struct cmd_list_element *maint_btrace_cmdlist;
We start at the preceding function's level in case this has
already been a return for which we have not seen the call.
We start at level 0 otherwise, to handle tail calls correctly. */
- bfun->level = min (0, prev->level) - 1;
+ bfun->level = std::min (0, prev->level) - 1;
/* Fix up the call stack for PREV. */
ftrace_fixup_caller (prev, bfun, BFUN_UP_LINKS_TO_RET);
/* Maintain the function level offset.
For all but the last block, we do it here. */
if (blk != 0)
- level = min (level, end->level);
+ level = std::min (level, end->level);
size = 0;
TRY
and is not really part of the execution history, it shouldn't
affect the level. */
if (blk == 0)
- level = min (level, end->level);
+ level = std::min (level, end->level);
}
}
/* Return the btrace instruction flags for INSN. */
-static enum btrace_insn_flag
+static btrace_insn_flags
pt_btrace_insn_flags (const struct pt_insn *insn)
{
- enum btrace_insn_flag flags = 0;
+ btrace_insn_flags flags = 0;
if (insn->speculative)
flags |= BTRACE_INSN_FLAG_SPECULATIVE;
if (errcode < 0)
{
if (errcode != -pte_eos)
- warning (_("Failed to synchronize onto the Intel(R) Processor "
+ warning (_("Failed to synchronize onto the Intel Processor "
"Trace stream: %s."), pt_errstr (pt_errcode (errcode)));
break;
}
}
/* Maintain the function level offset. */
- *plevel = min (*plevel, end->level);
+ *plevel = std::min (*plevel, end->level);
btinsn.pc = (CORE_ADDR) insn.ip;
btinsn.size = (gdb_byte) insn.size;
pt_insn_get_offset (decoder, &offset);
- warning (_("Failed to decode Intel(R) Processor Trace near trace "
+ warning (_("Failed to decode Intel Processor Trace near trace "
"offset 0x%" PRIx64 " near recorded PC 0x%" PRIx64 ": %s."),
offset, insn.ip, pt_errstr (pt_errcode (errcode)));
const struct pt_asid *asid, uint64_t pc,
void *context)
{
- int errcode;
+ int result, errcode;
+ result = (int) size;
TRY
{
errcode = target_read_code ((CORE_ADDR) pc, buffer, size);
if (errcode != 0)
- return -pte_nomap;
+ result = -pte_nomap;
}
CATCH (error, RETURN_MASK_ERROR)
{
- return -pte_nomap;
+ result = -pte_nomap;
}
END_CATCH
- return size;
+ return result;
}
/* Translate the vendor from one enum to another. */
btrace_add_pc (tp);
}
-/* Compute the function branch trace from Intel(R) Processor Trace. */
+/* Compute the function branch trace from Intel Processor Trace
+ format. */
static void
btrace_compute_ftrace_pt (struct thread_info *tp,
errcode = pt_cpu_errata (&config.errata, &config.cpu);
if (errcode < 0)
- error (_("Failed to configure the Intel(R) Processor Trace decoder: %s."),
+ error (_("Failed to configure the Intel Processor Trace decoder: %s."),
pt_errstr (pt_errcode (errcode)));
decoder = pt_insn_alloc_decoder (&config);
if (decoder == NULL)
- error (_("Failed to allocate the Intel(R) Processor Trace decoder."));
+ error (_("Failed to allocate the Intel Processor Trace decoder."));
TRY
{
image = pt_insn_get_image(decoder);
if (image == NULL)
- error (_("Failed to configure the Intel(R) Processor Trace decoder."));
+ error (_("Failed to configure the Intel Processor Trace decoder."));
errcode = pt_image_set_callback(image, btrace_pt_readmem_callback, NULL);
if (errcode < 0)
- error (_("Failed to configure the Intel(R) Processor Trace decoder: "
+ error (_("Failed to configure the Intel Processor Trace decoder: "
"%s."), pt_errstr (pt_errcode (errcode)));
ftrace_add_pt (decoder, &btinfo->begin, &btinfo->end, &level,
#if !defined (HAVE_LIBIPT)
if (conf->format == BTRACE_FORMAT_PT)
- error (_("GDB does not support Intel(R) Processor Trace."));
+ error (_("GDB does not support Intel Processor Trace."));
#endif /* !defined (HAVE_LIBIPT) */
if (!target_supports_btrace (conf->format))
error (_("Target does not support branch tracing."));
- DEBUG ("enable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
+ DEBUG ("enable thread %s (%s)", print_thread_id (tp),
+ target_pid_to_str (tp->ptid));
tp->btrace.target = target_enable_btrace (tp->ptid, conf);
if (btp->target == NULL)
return;
- DEBUG ("disable thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
+ DEBUG ("disable thread %s (%s)", print_thread_id (tp),
+ target_pid_to_str (tp->ptid));
target_disable_btrace (btp->target);
btp->target = NULL;
if (btp->target == NULL)
return;
- DEBUG ("teardown thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
+ DEBUG ("teardown thread %s (%s)", print_thread_id (tp),
+ target_pid_to_str (tp->ptid));
target_teardown_btrace (btp->target);
btp->target = NULL;
struct cleanup *cleanup;
int errcode;
- DEBUG ("fetch thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
+ DEBUG ("fetch thread %s (%s)", print_thread_id (tp),
+ target_pid_to_str (tp->ptid));
btinfo = &tp->btrace;
tinfo = btinfo->target;
struct btrace_thread_info *btinfo;
struct btrace_function *it, *trash;
- DEBUG ("clear thread %d (%s)", tp->num, target_pid_to_str (tp->ptid));
+ DEBUG ("clear thread %s (%s)", print_thread_id (tp),
+ target_pid_to_str (tp->ptid));
/* Make sure btrace frames that may hold a pointer into the branch
trace data are destroyed. */
space = end - index;
/* Advance the iterator as far as possible within this segment. */
- adv = min (space, stride);
+ adv = std::min (space, stride);
stride -= adv;
index += adv;
steps += adv;
}
/* Advance the iterator as far as possible within this segment. */
- adv = min (index, stride);
+ adv = std::min (index, stride);
stride -= adv;
index -= adv;
}
if (errcode != -pte_eos)
- warning (_("Failed to synchronize onto the Intel(R) Processor Trace "
+ warning (_("Failed to synchronize onto the Intel Processor Trace "
"stream: %s."), pt_errstr (pt_errcode (errcode)));
}
errcode = pt_cpu_errata (&config.errata, &config.cpu);
if (errcode < 0)
- error (_("Failed to configure the Intel(R) Processor Trace decoder: %s."),
+ error (_("Failed to configure the Intel Processor Trace decoder: %s."),
pt_errstr (pt_errcode (errcode)));
decoder = pt_pkt_alloc_decoder (&config);
if (decoder == NULL)
- error (_("Failed to allocate the Intel(R) Processor Trace decoder."));
+ error (_("Failed to allocate the Intel Processor Trace decoder."));
TRY
{
0, &maintenance_set_cmdlist);
add_prefix_cmd ("pt", class_maintenance, maint_btrace_pt_set_cmd, _("\
-Set Intel(R) Processor Trace specific variables."),
+Set Intel Processor Trace specific variables."),
&maint_btrace_pt_set_cmdlist, "maintenance set btrace pt ",
0, &maint_btrace_set_cmdlist);
0, &maintenance_show_cmdlist);
add_prefix_cmd ("pt", class_maintenance, maint_btrace_pt_show_cmd, _("\
-Show Intel(R) Processor Trace specific variables."),
+Show Intel Processor Trace specific variables."),
&maint_btrace_pt_show_cmdlist, "maintenance show btrace pt ",
0, &maint_btrace_show_cmdlist);