I have a static library I'm building in debug mode, but when I step into it I still get disassembly. I want to know how to use nm or another tool to ensure that the debug symbols are not being stripped.
-
1`man nm` might be a start. – Brett Hale Dec 20 '12 at 06:12
-
Since you are sure that you are building your static lib with debug symbols, I believe your program is not linked with the latest static lib. It has been compiled/linked on other machine or you have not recompiled/linked it on this machine. – ernesto Apr 29 '14 at 06:00
4 Answers
You might use nm
's option --debug-syms
, to let nm
also list debugger symbols (if any) for the object packed into a library.
For debugger symbols the second column indicates N
.
Example (assumes the object example.o to be in the library)
nm --debug-syms libexample.a
Output (excerpt):
example.o:
0000000000000000 b .bss
0000000000000000 n .comment
0000000000000000 d .data
0000000000000000 N .debug_abbrev
0000000000000000 N .debug_aranges
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 N .debug_loc
0000000000000000 N .debug_pubnames
0000000000000000 N .debug_str
0000000000000000 r .eh_frame
0000000000000000 n .note.GNU-stack
0000000000000000 r .rodata
0000000000000000 t .text
...
For more on this please see man nm
.

- 69,737
- 10
- 105
- 255
-
As of today, 2015-09-24, and on Mac, the 'file' command doesn't have --debug-syms. I know it once had a while ago. So, it must have been changed. ( The trios, i.e. nm, otool, and files are kept being changed drastically from time to time. ) However, the functionality is still there. ('file' version : 5.04) -D option : e.g. file -D myGreadLibrary.a D Print debugging messages. – JongAm Park Sep 24 '15 at 22:24
You can use the file command, available for many OSes, including Windows via Cygwin.
If it says 'not stripped' it means it has the debug info present.
As a side note, for static libs use ar to extract the .o
files & use file
on them directly.

- 8,994
- 2
- 34
- 51
-
1`file` is fine for this case, although it's worth noting that in the general case, it's possible to have an unstripped binary without debug information. – Nick Mar 25 '13 at 16:10
You can use strip -S libXX.a
to check if your static library size has been reduce. The static library size will not change if it's not include debugging symbols.
It is works on Mac OS to check static library generated by Xcode.

- 2,854
- 3
- 16
- 18
Download Dependencywalker for your OS
It will detect if your dll has debug symbols. If you see "Invalid" under "Symbols", it means debug symbols have been stripped off. Valid values are : PDB, CV, DBG, etc.

- 1,246
- 9
- 18
-
6Dependencywalker only support dynamical library, not for static library. – Yigang Wu Dec 20 '12 at 06:07