return 0;
}
-static int perf_sample__fprintf_regs(struct regs_dump *regs, uint64_t mask, uint16_t e_machine,
+static int perf_sample__fprintf_regs(struct regs_dump *regs, uint64_t mask,
+ uint16_t e_machine, uint32_t e_flags,
FILE *fp)
{
unsigned i = 0, r;
for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
u64 val = regs->regs[i++];
- printed += fprintf(fp, "%5s:0x%"PRIx64" ", perf_reg_name(r, e_machine), val);
+ printed += fprintf(fp, "%5s:0x%"PRIx64" ",
+ perf_reg_name(r, e_machine, e_flags),
+ val);
}
return printed;
}
static int perf_sample__fprintf_iregs(struct perf_sample *sample,
- struct perf_event_attr *attr, uint16_t e_machine, FILE *fp)
+ struct perf_event_attr *attr,
+ uint16_t e_machine,
+ uint32_t e_flags,
+ FILE *fp)
{
if (!sample->intr_regs)
return 0;
return perf_sample__fprintf_regs(perf_sample__intr_regs(sample),
- attr->sample_regs_intr, e_machine, fp);
+ attr->sample_regs_intr, e_machine, e_flags, fp);
}
static int perf_sample__fprintf_uregs(struct perf_sample *sample,
- struct perf_event_attr *attr, uint16_t e_machine, FILE *fp)
+ struct perf_event_attr *attr,
+ uint16_t e_machine,
+ uint32_t e_flags,
+ FILE *fp)
{
if (!sample->user_regs)
return 0;
return perf_sample__fprintf_regs(perf_sample__user_regs(sample),
- attr->sample_regs_user, e_machine, fp);
+ attr->sample_regs_user, e_machine, e_flags, fp);
}
static int perf_sample__fprintf_start(struct perf_script *script,
struct evsel_script *es = evsel->priv;
FILE *fp = es->fp;
char str[PAGE_SIZE_NAME_LEN];
+ uint32_t e_flags;
if (output[type].fields == 0)
return;
if (PRINT_FIELD(IREGS)) {
perf_sample__fprintf_iregs(sample, attr,
- thread__e_machine(thread, machine, /*e_flags=*/NULL),
+ thread__e_machine(thread, machine, &e_flags),
+ e_flags,
fp);
}
if (PRINT_FIELD(UREGS)) {
perf_sample__fprintf_uregs(sample, attr,
- thread__e_machine(thread, machine, /*e_flags=*/NULL),
+ thread__e_machine(thread, machine, &e_flags),
+ e_flags,
fp);
}
if (((1ULL << reg) & mask) == 0)
continue;
- name = perf_reg_name(reg, EM_HOST);
+ name = perf_reg_name(reg, EM_HOST, EF_HOST);
if (name && (!last_name || strcmp(last_name, name)))
fprintf(fp, "%s%s", reg > 0 ? " " : "", name);
last_name = name;
if (((1ULL << reg) & mask) == 0)
continue;
- name = perf_reg_name(reg, EM_HOST);
+ name = perf_reg_name(reg, EM_HOST, EF_HOST);
if (!name)
continue;
// SPDX-License-Identifier: GPL-2.0
-
+#include <elf.h>
+#ifndef EF_CSKY_ABIMASK
+#define EF_CSKY_ABIMASK 0XF0000000
+#endif
+#ifndef EF_CSKY_ABIV2
+#define EF_CSKY_ABIV2 0X20000000
+#endif
#include "../perf_regs.h"
+#undef __CSKYABIV2__
+#define __CSKYABIV2__ 1 // Always want the V2 register definitions.
#include "../../arch/csky/include/uapi/asm/perf_regs.h"
-const char *__perf_reg_name_csky(int id)
+const char *__perf_reg_name_csky(int id, uint32_t e_flags)
{
+ if (id >= PERF_REG_CSKY_EXREGS0 && (e_flags & EF_CSKY_ABIMASK) == EF_CSKY_ABIV2)
+ return NULL;
+
switch (id) {
case PERF_REG_CSKY_A0:
return "a0";
return "lr";
case PERF_REG_CSKY_PC:
return "pc";
-#if defined(__CSKYABIV2__)
case PERF_REG_CSKY_EXREGS0:
return "exregs0";
case PERF_REG_CSKY_EXREGS1:
return "hi";
case PERF_REG_CSKY_LO:
return "lo";
-#endif
default:
return NULL;
}
-
- return NULL;
}
uint64_t __perf_reg_ip_csky(void)
return 0;
}
-const char *perf_reg_name(int id, uint16_t e_machine)
+const char *perf_reg_name(int id, uint16_t e_machine, uint32_t e_flags)
{
const char *reg_name = NULL;
reg_name = __perf_reg_name_arm64(id);
break;
case EM_CSKY:
- reg_name = __perf_reg_name_csky(id);
+ reg_name = __perf_reg_name_csky(id, e_flags);
break;
case EM_LOONGARCH:
reg_name = __perf_reg_name_loongarch(id);
uint64_t arch__intr_reg_mask(void);
uint64_t arch__user_reg_mask(void);
-const char *perf_reg_name(int id, uint16_t e_machine);
+const char *perf_reg_name(int id, uint16_t e_machine, uint32_t e_flags);
int perf_reg_value(u64 *valp, struct regs_dump *regs, int id);
uint64_t perf_arch_reg_ip(uint16_t e_machine);
uint64_t perf_arch_reg_sp(uint16_t e_machine);
const char *__perf_reg_name_arm(int id);
uint64_t __perf_reg_ip_arm(void);
uint64_t __perf_reg_sp_arm(void);
-const char *__perf_reg_name_csky(int id);
+const char *__perf_reg_name_csky(int id, uint32_t e_flags);
uint64_t __perf_reg_ip_csky(void);
uint64_t __perf_reg_sp_csky(void);
const char *__perf_reg_name_loongarch(int id);
_PyUnicode_FromString(decode));
}
-static void regs_map(struct regs_dump *regs, uint64_t mask, uint16_t e_machine, char *bf, int size)
+static void regs_map(struct regs_dump *regs, uint64_t mask, uint16_t e_machine, uint32_t e_flags,
+ char *bf, int size)
{
unsigned int i = 0, r;
int printed = 0;
printed += scnprintf(bf + printed, size - printed,
"%5s:0x%" PRIx64 " ",
- perf_reg_name(r, e_machine), val);
+ perf_reg_name(r, e_machine, e_flags), val);
}
}
static int set_regs_in_dict(PyObject *dict,
struct perf_sample *sample,
struct evsel *evsel,
- uint16_t e_machine)
+ uint16_t e_machine,
+ uint32_t e_flags)
{
struct perf_event_attr *attr = &evsel->core.attr;
if (!bf)
return -1;
- regs_map(sample->intr_regs, attr->sample_regs_intr, e_machine, bf, size);
+ regs_map(sample->intr_regs, attr->sample_regs_intr, e_machine, e_flags, bf, size);
pydict_set_item_string_decref(dict, "iregs",
_PyUnicode_FromString(bf));
if (!bf)
return -1;
}
- regs_map(sample->user_regs, attr->sample_regs_user, e_machine, bf, size);
+ regs_map(sample->user_regs, attr->sample_regs_user, e_machine, e_flags, bf, size);
pydict_set_item_string_decref(dict, "uregs",
_PyUnicode_FromString(bf));
PyObject *dict, *dict_sample, *brstack, *brstacksym;
struct machine *machine;
uint16_t e_machine = EM_HOST;
+ uint32_t e_flags = EF_HOST;
dict = PyDict_New();
if (!dict)
if (al->thread) {
machine = maps__machine(thread__maps(al->thread));
- e_machine = thread__e_machine(al->thread, machine, /*e_flags=*/NULL);
+ e_machine = thread__e_machine(al->thread, machine, &e_flags);
}
- if (set_regs_in_dict(dict, sample, evsel, e_machine))
+ if (set_regs_in_dict(dict, sample, evsel, e_machine, e_flags))
Py_FatalError("Failed to setting regs in dict");
return dict;
}
}
-static void regs_dump__printf(u64 mask, u64 *regs, uint16_t e_machine)
+static void regs_dump__printf(u64 mask, u64 *regs, uint16_t e_machine, uint32_t e_flags)
{
unsigned rid, i = 0;
u64 val = regs[i++];
printf(".... %-5s 0x%016" PRIx64 "\n",
- perf_reg_name(rid, e_machine), val);
+ perf_reg_name(rid, e_machine, e_flags), val);
}
}
return regs_abi[d->abi];
}
-static void regs__printf(const char *type, struct regs_dump *regs, uint16_t e_machine)
+static void regs__printf(const char *type, struct regs_dump *regs,
+ uint16_t e_machine, uint32_t e_flags)
{
u64 mask = regs->mask;
mask,
regs_dump_abi(regs));
- regs_dump__printf(mask, regs->regs, e_machine);
+ regs_dump__printf(mask, regs->regs, e_machine, e_flags);
}
-static void regs_user__printf(struct perf_sample *sample, uint16_t e_machine)
+static void regs_user__printf(struct perf_sample *sample, uint16_t e_machine, uint32_t e_flags)
{
struct regs_dump *user_regs;
user_regs = perf_sample__user_regs(sample);
if (user_regs->regs)
- regs__printf("user", user_regs, e_machine);
+ regs__printf("user", user_regs, e_machine, e_flags);
}
-static void regs_intr__printf(struct perf_sample *sample, uint16_t e_machine)
+static void regs_intr__printf(struct perf_sample *sample, uint16_t e_machine, uint32_t e_flags)
{
struct regs_dump *intr_regs;
intr_regs = perf_sample__intr_regs(sample);
if (intr_regs->regs)
- regs__printf("intr", intr_regs, e_machine);
+ regs__printf("intr", intr_regs, e_machine, e_flags);
}
static void stack_user__printf(struct stack_dump *dump)
u64 sample_type;
char str[PAGE_SIZE_NAME_LEN];
uint16_t e_machine = EM_NONE;
+ uint32_t e_flags = 0;
if (!dump_trace)
return;
if (sample_type & (PERF_SAMPLE_REGS_USER | PERF_SAMPLE_REGS_INTR)) {
struct thread *thread = machine__find_thread(machine, sample->pid, sample->pid);
- e_machine = thread__e_machine(thread, machine, /*e_flags=*/NULL);
+ e_machine = thread__e_machine(thread, machine, &e_flags);
}
printf("(IP, 0x%x): %d/%d: %#" PRIx64 " period: %" PRIu64 " addr: %#" PRIx64 "\n",
branch_stack__printf(sample, evsel);
if (sample_type & PERF_SAMPLE_REGS_USER)
- regs_user__printf(sample, e_machine);
+ regs_user__printf(sample, e_machine, e_flags);
if (sample_type & PERF_SAMPLE_REGS_INTR)
- regs_intr__printf(sample, e_machine);
+ regs_intr__printf(sample, e_machine, e_flags);
if (sample_type & PERF_SAMPLE_STACK_USER)
stack_user__printf(&sample->user_stack);