X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Futils%2Fparse-callstack.py;fp=tests%2Futils%2Fparse-callstack.py;h=029100b6184de3e4c61d83841e65180ef724888b;hb=16dd99389198f584be2393d1dc5e049b4ac1f8d5;hp=c3f0e2e9bc5a5d5278cb650cd09abbd5b9f8af38;hpb=fd44f4931371da6a4a995f1d0298030d65d3aeb6;p=lttng-tools.git diff --git a/tests/utils/parse-callstack.py b/tests/utils/parse-callstack.py index c3f0e2e9b..029100b61 100755 --- a/tests/utils/parse-callstack.py +++ b/tests/utils/parse-callstack.py @@ -26,14 +26,23 @@ def addr2line(executable, addr): status = subprocess.run(cmd, stdout=subprocess.PIPE, check=True) - addr2line_output = status.stdout.decode("utf-8") - - # Omit the last 2 lines as the caller of main can not be determine - fcts = [addr2line_output.split()[-2]] - - fcts = [ f for f in fcts if '??' not in f] - - return fcts + addr2line_output = status.stdout.decode("utf-8").splitlines() + # addr2line's output is made of 3-tuples: + # - address + # - function name + # - source location + if len(addr2line_output) % 3 != 0: + raise Exception('Unexpected addr2line output:\n\t{}'.format('\n\t'.join(addr2line_output))) + + function_names = [] + for address_line_number in range(0, len(addr2line_output), 3): + function_name = addr2line_output[address_line_number + 1] + + # Filter-out unresolved functions + if "??" not in function_name: + function_names.append(addr2line_output[address_line_number + 1]) + + return function_names def extract_user_func_names(executable, raw_callstack): """