aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/unwind.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/unwind.c')
-rw-r--r--tools/perf/util/unwind.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/tools/perf/util/unwind.c b/tools/perf/util/unwind.c
index 3b7018102dfb..720a4cae6004 100644
--- a/tools/perf/util/unwind.c
+++ b/tools/perf/util/unwind.c
@@ -86,7 +86,6 @@ struct unwind_info {
86 struct perf_sample *sample; 86 struct perf_sample *sample;
87 struct machine *machine; 87 struct machine *machine;
88 struct thread *thread; 88 struct thread *thread;
89 u64 sample_uregs;
90}; 89};
91 90
92#define dw_read(ptr, type, end) ({ \ 91#define dw_read(ptr, type, end) ({ \
@@ -391,16 +390,16 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr,
391 return !(size == sizeof(*data)); 390 return !(size == sizeof(*data));
392} 391}
393 392
394static int reg_value(unw_word_t *valp, struct regs_dump *regs, int id, 393static int reg_value(unw_word_t *valp, struct regs_dump *regs, int id)
395 u64 sample_regs)
396{ 394{
397 int i, idx = 0; 395 int i, idx = 0;
396 u64 mask = regs->mask;
398 397
399 if (!(sample_regs & (1 << id))) 398 if (!(mask & (1 << id)))
400 return -EINVAL; 399 return -EINVAL;
401 400
402 for (i = 0; i < id; i++) { 401 for (i = 0; i < id; i++) {
403 if (sample_regs & (1 << i)) 402 if (mask & (1 << i))
404 idx++; 403 idx++;
405 } 404 }
406 405
@@ -424,8 +423,7 @@ static int access_mem(unw_addr_space_t __maybe_unused as,
424 return 0; 423 return 0;
425 } 424 }
426 425
427 ret = reg_value(&start, &ui->sample->user_regs, PERF_REG_SP, 426 ret = reg_value(&start, &ui->sample->user_regs, PERF_REG_SP);
428 ui->sample_uregs);
429 if (ret) 427 if (ret)
430 return ret; 428 return ret;
431 429
@@ -475,7 +473,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
475 if (id < 0) 473 if (id < 0)
476 return -EINVAL; 474 return -EINVAL;
477 475
478 ret = reg_value(valp, &ui->sample->user_regs, id, ui->sample_uregs); 476 ret = reg_value(valp, &ui->sample->user_regs, id);
479 if (ret) { 477 if (ret) {
480 pr_err("unwind: can't read reg %d\n", regnum); 478 pr_err("unwind: can't read reg %d\n", regnum);
481 return ret; 479 return ret;
@@ -572,13 +570,11 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
572 570
573int unwind__get_entries(unwind_entry_cb_t cb, void *arg, 571int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
574 struct machine *machine, struct thread *thread, 572 struct machine *machine, struct thread *thread,
575 u64 sample_uregs, struct perf_sample *data, 573 struct perf_sample *data, int max_stack)
576 int max_stack)
577{ 574{
578 unw_word_t ip; 575 unw_word_t ip;
579 struct unwind_info ui = { 576 struct unwind_info ui = {
580 .sample = data, 577 .sample = data,
581 .sample_uregs = sample_uregs,
582 .thread = thread, 578 .thread = thread,
583 .machine = machine, 579 .machine = machine,
584 }; 580 };
@@ -587,7 +583,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
587 if (!data->user_regs.regs) 583 if (!data->user_regs.regs)
588 return -EINVAL; 584 return -EINVAL;
589 585
590 ret = reg_value(&ip, &data->user_regs, PERF_REG_IP, sample_uregs); 586 ret = reg_value(&ip, &data->user_regs, PERF_REG_IP);
591 if (ret) 587 if (ret)
592 return ret; 588 return ret;
593 589