Tools: add addr2line_backtrace to extract back-trace info on Unix/Linux #111416

Manually merged
Campbell Barton merged 3 commits from ideasman42/blender:pr-addr2line_backtrace into main 2023-09-06 14:12:55 +02:00
Showing only changes of commit 44f9fb5893 - Show all commits

View File

@ -111,7 +111,7 @@ def argparse_create() -> argparse.ArgumentParser:
parser.add_argument(
"--base",
dest="base",
metavar='BASE',
metavar='BASE_PATH',
default="",
required=False,
help="Base path.",
@ -136,7 +136,7 @@ def argparse_create() -> argparse.ArgumentParser:
)
parser.add_argument(
"backtraces",
nargs='?',
nargs="*",
help="Back-trace files to scan for addresses.",
)
@ -198,10 +198,10 @@ def main() -> None:
if args.backtraces:
for backtrace_filepath in args.backtraces:
ideasman42 marked this conversation as resolved Outdated

does not work if there is only one file path given, as args.backtraces is a single string then.

does not work if there is only one file path given, as `args.backtraces` is a single string then.
try:
with open(backtrace_filepath, "utf-8", encoding="surrogateescape") as fh:
with open(backtrace_filepath, 'r', encoding="utf-8", errors="surrogateescape") as fh:
ideasman42 marked this conversation as resolved Outdated

hrrrrmmmmmm....

hrrrrmmmmmm....
bactrace_data = fh.read()
except BaseException as ex:
print("Filed to open {:r}, {:s}".format(backtrace_filepath, str(ex)))
print("Filed to open {!r}, {:s}".format(backtrace_filepath, str(ex)))
ideasman42 marked this conversation as resolved Outdated

{:r} does not exists in string format types specifiers

`{:r}` does not exists in string format [types specifiers](https://docs.python.org/3.10/library/string.html#format-string-syntax)
continue
addr2line_for_filedata(args.exe, base_path, args.time_command, jobs, bactrace_data)