Skip to content

Commit c7a0023

Browse files
captain5050acmel
authored andcommitted
perf srcline: Make addr2line configuration failure more verbose
To aid debugging why it fails. Also, combine the loops for reading a line for the llvm/binutils cases. Signed-off-by: Ian Rogers <[email protected]> Tested-by: Changbin Du <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Nathan Chancellor <[email protected]> Cc: Nick Desaulniers <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Tom Rix <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d436373 commit c7a0023

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

tools/perf/util/srcline.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ enum a2l_style {
443443
LLVM,
444444
};
445445

446-
static enum a2l_style addr2line_configure(struct child_process *a2l)
446+
static enum a2l_style addr2line_configure(struct child_process *a2l, const char *dso_name)
447447
{
448448
static bool cached;
449449
static enum a2l_style style;
@@ -452,6 +452,7 @@ static enum a2l_style addr2line_configure(struct child_process *a2l)
452452
char buf[128];
453453
struct io io;
454454
int ch;
455+
int lines;
455456

456457
if (write(a2l->in, ",\n", 2) != 2)
457458
return BROKEN;
@@ -461,19 +462,29 @@ static enum a2l_style addr2line_configure(struct child_process *a2l)
461462
if (ch == ',') {
462463
style = LLVM;
463464
cached = true;
465+
lines = 1;
464466
} else if (ch == '?') {
465467
style = GNU_BINUTILS;
466468
cached = true;
469+
lines = 2;
467470
} else {
468-
style = BROKEN;
471+
if (!symbol_conf.disable_add2line_warn) {
472+
char *output = NULL;
473+
size_t output_len;
474+
475+
io__getline(&io, &output, &output_len);
476+
pr_warning("%s %s: addr2line configuration failed\n",
477+
__func__, dso_name);
478+
pr_warning("\t%c%s", ch, output);
479+
}
480+
return BROKEN;
469481
}
470-
do {
482+
while (lines) {
471483
ch = io__get_char(&io);
472-
} while (ch > 0 && ch != '\n');
473-
if (style == GNU_BINUTILS) {
474-
do {
475-
ch = io__get_char(&io);
476-
} while (ch > 0 && ch != '\n');
484+
if (ch <= 0)
485+
break;
486+
if (ch == '\n')
487+
lines--;
477488
}
478489
/* Ignore SIGPIPE in the event addr2line exits. */
479490
signal(SIGPIPE, SIG_IGN);
@@ -593,12 +604,9 @@ static int addr2line(const char *dso_name, u64 addr,
593604
pr_warning("%s %s: addr2line_subprocess_init failed\n", __func__, dso_name);
594605
goto out;
595606
}
596-
a2l_style = addr2line_configure(a2l);
597-
if (a2l_style == BROKEN) {
598-
if (!symbol_conf.disable_add2line_warn)
599-
pr_warning("%s: addr2line configuration failed\n", __func__);
607+
a2l_style = addr2line_configure(a2l, dso_name);
608+
if (a2l_style == BROKEN)
600609
goto out;
601-
}
602610

603611
/*
604612
* Send our request and then *deliberately* send something that can't be interpreted as

0 commit comments

Comments
 (0)