[PATCH] D46628: [ELF] Add --strip-debug-non-line option
Lucian Adrian Grijincu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 25 12:47:59 PDT 2019
luciang added a comment.
GCC with `-g1` produces extra information not necessary for stacktrace + file:line info production:
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
> Level 1 produces minimal information, enough for making backtraces in parts of the program that you don’t plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
Using GCC 7: note the generation of `DW_TAG_subprogram` -- so `--strip-debug-non-line` is still useful in reducing that info
$ echo "int foo() { return 0; } int bar() { return foo(); }" | g++ -g1 -S -x c - -o - > /tmp/test/gcc.s
$ llvm-mc -filetype=obj -triple=x86_64-unknown-linux /tmp/test/gcc.s -o /tmp/test/gcc.o
$ llvm-dwarfdump --debug-info /tmp/test/gcc.o
/tmp/test/gcc.o: file format ELF64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x0000005a version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000005e)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("GNU C17 7.x 20190403 (Facebook) 8.x -mtune=generic -march=x86-64 -g1")
DW_AT_language (DW_LANG_C99)
DW_AT_comp_dir ("/tmp/test")
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x000000000000001b)
DW_AT_stmt_list (0x00000000)
0x00000029: DW_TAG_subprogram
DW_AT_external (true)
DW_AT_name ("bar")
DW_AT_decl_file ("/tmp/test/<stdin>")
DW_AT_decl_line (1)
DW_AT_decl_column (0x1d)
DW_AT_low_pc (0x000000000000000b)
DW_AT_high_pc (0x000000000000001b)
DW_AT_frame_base (DW_OP_call_frame_cfa)
DW_AT_unknown_2116 (true)
0x00000043: DW_TAG_subprogram
DW_AT_external (true)
DW_AT_name ("foo")
DW_AT_decl_file ("/tmp/test/<stdin>")
DW_AT_decl_line (1)
DW_AT_decl_column (0x05)
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x000000000000000b)
DW_AT_frame_base (DW_OP_call_frame_cfa)
DW_AT_GNU_all_call_sites (true)
0x0000005d: NULL
`clang` does better (I tried clang-7, clang-8) and only produces `DW_TAG_compile_unit`:
$ echo "int foo() { return 0; } int bar() { return foo(); }" | clang++ -Os -g1 -S -x c - -Xclang -fdebug-compilation-dir -Xclang . -o - > /tmp/test/clang.s
$ llvm-mc -filetype=obj -triple=x86_64-unknown-linux /tmp/test/clang.s -o /tmp/test/clang.o
$ llvm-dwarfdump --debug-info /tmp/test/clang.o
/tmp/test/clang.o: file format ELF64-x86-64
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000026 version = 0x0004 abbr_offset = 0x0000 addr_size = 0x08 (next unit at 0x0000002a)
0x0000000b: DW_TAG_compile_unit
DW_AT_producer ("clang version 8.0.20181009 ")
DW_AT_language (DW_LANG_C99)
DW_AT_name ("-")
DW_AT_stmt_list (0x00000000)
DW_AT_comp_dir (".")
DW_AT_low_pc (0x0000000000000000)
DW_AT_high_pc (0x0000000000000006)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D46628/new/
https://reviews.llvm.org/D46628
More information about the llvm-commits
mailing list