backtrace_symbols - Linux
Overview
backtrace_symbols generates a stack backtrace from a memory dump or core file and resolves the addresses in it to symbols. It is primarily used for debugging and analyzing crashes.
Syntax
backtrace_symbols [-j [<threads...>] [-d <directories>]] [-s <symbols>] [-a <offset>]
[-p <process name>] [-A] [-D] [-r <limit>] [-l <limit>]
[-e <elf-file>] [-m <map-file>] [-c <compact-file>]
[-i <ignore-list>] [-I <ignore-file>] [-f <filter>]
[-F <filter-file>] [-P <demangle-filter>] [-C <column>]
[-t <type>] [-w <width>] [-S <style>] [-n <max-name-len>]
[-R] [-M] [-E] [-O <options>] [-h] [-H] [-v] [-V]
[<file>]
Options/Flags
- -d
Specify directories to search for symbols. - -s
Specify a symbol file to use. - -a
Specify the offset of the backtrace within the specified file. - -p
Filter backtraces by process name. - -A Display all backtraces.
- -D Display only DWARF-based backtraces.
- -r
Limit the number of backtraces displayed. - -l
Limit the number of lines per backtrace. - -e
Use an ELF file instead of a core file. - -m
Use a map file to resolve addresses. - -c
Use a compact file to resolve addresses. - -i
Ignore addresses in the specified file. - -I
Ignore addresses in the specified file. - -f
Filter backtraces based on a regular expression. - -F
Read filter from a file. - -P
Filter demangled symbols based on a regular expression. - -C
Specify the column to print the backtraces in. - -t
Specify the type of backtrace to display (e.g., "full", "brief"). - -w
Specify the width of the backtrace display. - -S
Specify the style of the backtrace display (e.g., "default", "bt2"). - -n
Specify the maximum length of symbol names. - -R Resolve relative addresses.
- -M Resolve mangled symbols.
- -E Resolve embedded addresses.
- -O
Set additional options (e.g., "-O warnings=no"). - -h Display help information.
- -H Display advanced help information.
- -v Display version information.
- -V Display extended version information.
Examples
- Display all backtraces:
backtrace_symbols -A <file>
- Filter backtraces by process name:
backtrace_symbols -p <process name> <file>
- Resolve mangled symbols:
backtrace_symbols -M <file>
- Specify a custom symbol file:
backtrace_symbols -s <symbol file> <file>
Common Issues
- Missing symbols: Ensure you have the correct symbols for the core file or ELF file.
- Unresolved addresses: Try specifying additional search directories for symbols (-d) or using a map file (-m) to resolve addresses.
- Confusing output: Adjust the display type (-t), width (-w), or style (-S) to improve readability.
Integration
- Backtrace symbols can be used in conjunction with
gdb
for advanced debugging. - It can be integrated into scripts to automate crash analysis and debugging.
- It can be used in combination with tools like
readelf
to extract ELF information for symbol resolution.
Related Commands
- gdb
- addr2line
- readelf