Tools: add addr2line_backtrace to extract back-trace info on Unix/Linux #111416
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111416
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ideasman42/blender:pr-addr2line_backtrace"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Since hiding symbols on Linux, in many cases only addresses are printed.
This utility can run run on the back-trace to replace addresses
with line & function information.
See:
./tools/utils/addr2line_backtrace.py --help
for usage information.Note that some examples online run
addr2line
directly and use the output in the stack-trace,while convenient and acceptable in some cases, in my tests addr2line can take over 20 seconds to complete for a single address.
Implement this as a post-process instead. Multi-processing to prevent this taking too long (around ~23 seconds on my system).
Example input, output:
./tools/utils/addr2line_backtrace --exe=./blender.bin trace.txt
fa4859f355
to92750af7ac
Unless there is some smart trick we can quickly do to make
BLI_system_backtrace
work better I think it is fine to have such script.I don't think I can test the patch as there seems to be no
addr2line
available on macOS. From reading the code I did not spot anything obviously wrong.Here's diff of changes I had to do to get it working:
Further more, with a debug + ASAN build, the default jobs value is unusable on my 16 cores, 64GB machine - it eats the available 48+GB of RAM in no time and then jobs start being killed by the OS. 4 jobs are already using over 30GB of RAM... So think we should default to 1 or 2 jobs max?
In fact, did a check here, running a certain 28 addresses stack (with a lot of addresses in Python itself and not Blender) through this script took over 1h30 mins, while a single direct call to
addr2lines
with all 28 addresses took about 35mins. So think would be worth it to:addr2lines
as possible?@ -0,0 +196,4 @@
base_path = base_path.rstrip(os.sep) + os.sep
if args.backtraces:
for backtrace_filepath in args.backtraces:
does not work if there is only one file path given, as
args.backtraces
is a single string then.@ -0,0 +198,4 @@
if args.backtraces:
for backtrace_filepath in args.backtraces:
try:
with open(backtrace_filepath, "utf-8", encoding="surrogateescape") as fh:
hrrrrmmmmmm....
@ -0,0 +201,4 @@
with open(backtrace_filepath, "utf-8", encoding="surrogateescape") as fh:
bactrace_data = fh.read()
except BaseException as ex:
print("Filed to open {:r}, {:s}".format(backtrace_filepath, str(ex)))
{:r}
does not exists in string format types specifiers8b7379dca8
to49cbd4c3b1
@ideasman42 I think there's been a problem with your merge or rebase?
I think we can pass
-rdynamic
to the linker to get the symbols again in backtraces:https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-rdynamic
But as before, there are not going to be line numbers. So this is still useful.
49cbd4c3b1
to76fdef4bcf
I would still rather pack several addresses within a single call to
addr2line
, especially with debug builds this tools is extremely greedy with memory, so it's way better to e.g. split 32+ addresses between 4 processes, rather than calling the tool 32+ times individually, making it reload and reparse the whole binary every time.Otherwise LGTM now.
@brecht I tried using this
-dynamic
flag before, for me it still only gives me pure addresses backtrace, without any kind of symbol resolution...@ -0,0 +65,4 @@
(exe, base_path, time_command) = shared_args
cmd = (
"addr2line",
addr,
This can be a list of several addresses instead of a single one.
@ -0,0 +162,4 @@
addr_len = len(addr_set)
with multiprocessing.Pool(jobs) as pool:
for i, (addr, result) in enumerate(pool.imap_unordered(addr2line_fn, addr2line_args), 1):
Should be packed so that each submissions contains as many addresses as possible
76fdef4bcf
tob40dbe74dc
Updated to default to 4 cores to avoid using too much memory.
Details:
b40dbe74dc
tobab94c6385
Works great now, thanks!