I'd like to trace some code in GIMP and therefore need GIMP with debug symbols enabled. I don't remember whether I have enabled them during compilation. How to check that without recompiling the program?
2 Answers
You can use file
and objdump
on Linux. In particular, you can look at whether file says "stripped" or "not stripped" (under my Ubuntu 20.04.1 LTS
, whether an executable is compiled with -g
or not shows not stripped
with file
command. But the one with -g
, shows with debug_info,
in addition to that), and whether objdump --syms
outputs anything useful (for me, it says "no symbols" for a regular build).

- 7,007
- 2
- 49
- 79

- 278,309
- 50
- 514
- 539
-
13Stripped means no symbols, right? – Lukasz Czerwinski Jul 25 '10 at 13:57
-
28the equivalent for OS X is `otool -Iv`. – rich.e Oct 09 '11 at 23:17
-
10what to look for in the output of otool -Iv? – Nitish Upreti Apr 17 '15 at 01:39
-
For OS X, this might be helpful: http://stackoverflow.com/a/18497811/246776 – eonil Jun 03 '15 at 03:58
-
14Stripped or not has little to do with if it is built in debug or release. You can have a debug build that is stripped or a release build that is not stripped. – Ronny Andersson Sep 22 '15 at 17:27
-
Can you please add a command line example? – Dean Jan 06 '16 at 10:16
-
At least on Debian Jessie, `file` reports both if the file was stripped (`stripped` or `not stripped`) and if it contains debug information (`with debug_info`). – x-yuri Jan 23 '18 at 12:47
-
3Well, that must have been Debian Stretch after all. `with debug_info` appeared in [`file-5.30`](https://github.com/file/file/blob/FILE5_30/src/readelf.c#L1379), which comes with Stretch. So another option would be to look for `.debug_info` section (`objdump -h a.out | grep .debug_info`). – x-yuri Feb 15 '18 at 19:39
-
1`file my_binary` and `file my_binary_debug` show the same info, both `not stripped`. – mrgloom Jul 03 '18 at 09:49
-
As others have hinted at but not really explicitly said, this is quite wrong. If you make a short C program and build it without `-g`, `file` will show "not stripped" and `objdump` will show an intact symbol table, but that doesn't mean the program has debug information – Michael Mrozek Jul 26 '18 at 22:04
-
@NitishUpreti After some experimentation it seems `_objc_msgSend` in `__TEXT,__stubs` is an indication of debug. In release binaries, it is only in `__DATA,__got`. This may vary based on compiler, OS version, and language though (I tested obj-c) – 1110101001 Aug 25 '21 at 08:50
-
On Linux, you can also do: `readelf -S
| grep .debug` – Maximilian Mordig Aug 22 '22 at 09:02
When running the objdump --syms
command, I see much more than "no symbols" in the output (at least, for kernel objects).
To check if there's debug info inside the kernel object, you can add the following at the end of the objdump
command: | grep debug
.
If this string is found, you know the kernel object contains debug information. If not, then it's a "clean" kernel object.
Example of a kernel module I've compiled without debug information:
geertvc@jimi:~/mystuff/kernels/linux-3.12.6$ objdump --syms ./modules/lib/modules/3.12.6/kernel/drivers/i2c/busses/i2c-at91.ko | grep debug
Example of that same kernel module I've compiled with debug information:
geertvc@jimi:~/mystuff/kernels/linux-3.12.6$ objdump --syms ./modules/lib/modules/3.12.6/kernel/drivers/i2c/busses/i2c-at91.ko | grep debug
00000000 l d .debug_frame 00000000 .debug_frame
00000000 l d .debug_info 00000000 .debug_info
00000000 l d .debug_abbrev 00000000 .debug_abbrev
00000000 l d .debug_loc 00000000 .debug_loc
00000000 l d .debug_aranges 00000000 .debug_aranges
00000000 l d .debug_ranges 00000000 .debug_ranges
00000000 l d .debug_line 00000000 .debug_line
00000000 l d .debug_str 00000000 .debug_str
00000010 l .debug_frame 00000000 $d
As you can see, the first output returns nothing, while the second output returns lines with debug
in it.
Note: in my case, the file
command returned me "not stripped" in both debug and non-debug case. However, the difference in size of the kernel object was remarkable:
- approx. 16k without debug information
- approx. 137k with debug information
Clearly, the latter version had debug information inside.
My question: is the file
command reliable in such cases?
From what I've experienced, I rely on the objdump --syms ... | grep debug
command.

- 1,914
- 17
- 22
-
I too had the same issue with `file`. For me, `objdump --syms` without the `grep` bit yields many results even on the non-debug build, but the `grep` helps call out the specific debug-only symbols, so that works for me. – pattivacek Mar 03 '14 at 17:19
-
5
-
2On my Ubuntu 19 system, `file` says "with debug_info, not stripped" or just "stripped". – Nagev Mar 11 '20 at 11:02