r218129 - Omit DW_TAG_subprograms for subprograms without inlined subroutines when producing -gmlt data

David Blaikie dblaikie at gmail.com
Thu Sep 25 10:51:00 PDT 2014


On Wed, Sep 24, 2014 at 12:27 PM, Kuba Brecka <kuba.brecka at gmail.com> wrote:

> Sure. It works with my system's clang, but when using my just-built
> ./bin/clang, the symbolizer doesn't give me any line information.
>
> $ cat a.c
> #include <stdio.h>
>
> int f() {
>         printf("X");
>         return 0;
> }
>
> int main() {
>         printf("1");
>         printf("2");
>         printf("3");
> }
> $ clang a.c -o a.out -gline-tables-only
>

A -cc1 command line would be helpful, not sure which -target I should use,
etc.


> $ nm a.out
> 0000000100000000 T __mh_execute_header
> 0000000100000f00 T _f
> 0000000100000f30 T _main
>                  U _printf
>                  U dyld_stub_binder
> $ echo "a.out 0x0000000100000f00" | ./bin/llvm-symbolizer
> f
> /Users/kuba/llvm-tot-cmake-release/a.c:3:0
> $ echo "a.out 0x0000000100000f18" | ./bin/llvm-symbolizer
> f
> /Users/kuba/llvm-tot-cmake-release/a.c:5:2
> $ ./bin/llvm-dwarfdump -debug-dump=line
> a.out.dSYM/Contents/Resources/DWARF/a.out
>

The full dwarfdump, not just the line table, is probably necessary to
investigate this - my change didn't modify the line table, it modified the
compile units in the debug_info section (and added ranges back into the
debug_ranges section).


> a.out.dSYM/Contents/Resources/DWARF/a.out:      file format Mach-O 64-bit
> x86-64
> .debug_line contents:
> Line table prologue:
>     total_length: 0x00000052
>          version: 2
>  prologue_length: 0x0000001a
>  min_inst_length: 1
>  default_is_stmt: 1
>        line_base: -5
>       line_range: 14
>      opcode_base: 13
> standard_opcode_lengths[DW_LNS_copy] = 0
> standard_opcode_lengths[DW_LNS_advance_pc] = 1
> standard_opcode_lengths[DW_LNS_advance_line] = 1
> standard_opcode_lengths[DW_LNS_set_file] = 1
> standard_opcode_lengths[DW_LNS_set_column] = 1
> standard_opcode_lengths[DW_LNS_negate_stmt] = 0
> standard_opcode_lengths[DW_LNS_set_basic_block] = 0
> standard_opcode_lengths[DW_LNS_const_add_pc] = 0
> standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
> standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
> standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
> standard_opcode_lengths[DW_LNS_set_isa] = 1
>                 Dir  Mod Time   File Len   File Name
>                 ---- ---------- ---------- ---------------------------
> file_names[  1]    0 0x00000000 0x00000000 a.c
> Address            Line   Column File   ISA Discriminator Flags
> ------------------ ------ ------ ------ --- ------------- -------------
> 0x0000000100000f00      3      0      1   0             0  is_stmt
> 0x0000000100000f0f      4      2      1   0             0  is_stmt
> prologue_end
> 0x0000000100000f18      5      2      1   0             0  is_stmt
> 0x0000000100000f23      5      2      1   0             0  is_stmt
> end_sequence
> 0x0000000100000f30      8      0      1   0             0  is_stmt
> 0x0000000100000f3f      9      2      1   0             0  is_stmt
> prologue_end
> 0x0000000100000f4d     10      2      1   0             0  is_stmt
> 0x0000000100000f5e     11      2      1   0             0  is_stmt
> 0x0000000100000f6a     12      1      1   0             0  is_stmt
> 0x0000000100000f75     12      1      1   0             0  is_stmt
> end_sequence
>
> $ ./bin/clang a.c -o a.out -gline-tables-only
> warning: no debug symbols in executable (-arch x86_64)
> $ echo "a.out 0x0000000100000f00" | ./bin/llvm-symbolizer
> f
> ??:0:0
> $ echo "a.out 0x0000000100000f18" | ./bin/llvm-symbolizer
> f
> ??:0:0
> $ ./bin/llvm-dwarfdump -debug-dump=line
> a.out.dSYM/Contents/Resources/DWARF/a.out
> a.out.dSYM/Contents/Resources/DWARF/a.out:      file format Mach-O 64-bit
> x86-64
>
>
> .debug_line contents:
> $
>
> Kuba
>
>
> On Wed, Sep 24, 2014 at 12:10 PM, David Blaikie <dblaikie at gmail.com>
> wrote:
>
>>
>>
>> On Wed, Sep 24, 2014 at 12:08 PM, Kuba Brecka <kuba.brecka at gmail.com>
>> wrote:
>>
>>> I'm getting test failures for compiler-rt asan tests after this patch.
>>> It seems the symbolizer stops working with -gline-tables-only on OS X:
>>>
>>
>> Could you provide a simple reproduction? (a clang command line with a
>> -target and an llvm-symbolizer invocation that should symbolize a
>> particular instruction/offset in the binary, etc) and/or llvm-dwarfdump of
>> a simple binary that fails symbolication when it shouldn't.
>>
>>
>>>
>>> FAIL: AddressSanitizer32 :: TestCases/use-after-free.cc (222 of 460)
>>> ******************** TEST 'AddressSanitizer32 ::
>>> TestCases/use-after-free.cc' FAILED ********************
>>> Script:
>>> --
>>> /Users/kuba/llvm-tot-cmake-release/./bin/clang --driver-mode=g++
>>> -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer
>>> -fno-optimize-sibling-calls -gline-tables-only -m32 -O0
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> -o
>>> /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> && not
>>>  /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> 2>&1 | FileCheck
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> --check-prefix=CHECK-Darwin --check-prefix=CHECK
>>> /Users/kuba/llvm-tot-cmake-release/./bin/clang --driver-mode=g++
>>> -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer
>>> -fno-optimize-sibling-calls -gline-tables-only -m32 -O1
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> -o
>>> /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> && not
>>>  /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> 2>&1 | FileCheck
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> --check-prefix=CHECK-Darwin --check-prefix=CHECK
>>> /Users/kuba/llvm-tot-cmake-release/./bin/clang --driver-mode=g++
>>> -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer
>>> -fno-optimize-sibling-calls -gline-tables-only -m32 -O2
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> -o
>>> /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> && not
>>>  /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> 2>&1 | FileCheck
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> --check-prefix=CHECK-Darwin --check-prefix=CHECK
>>> /Users/kuba/llvm-tot-cmake-release/./bin/clang --driver-mode=g++
>>> -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer
>>> -fno-optimize-sibling-calls -gline-tables-only -m32 -O3
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> -o
>>> /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> && not
>>>  /Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp
>>> 2>&1 | FileCheck
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc
>>> --check-prefix=CHECK-Darwin --check-prefix=CHECK
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stdout):
>>> --
>>> warning: no debug symbols in executable (-arch i386)
>>>
>>> --
>>> Command Output (stderr):
>>> --
>>> /Users/kuba/llvm-tot/projects/compiler-rt/test/asan/TestCases/use-after-free.cc:15:12:
>>> error: expected string not found in input
>>>  // CHECK: {{ #0 0x.* in main .*use-after-free.cc:}}[[@LINE-4]]
>>>            ^
>>> <stdin>:4:2: note: scanning from here
>>>  #0 0x75e5f in main
>>> (/Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp+0x1e5f)
>>>  ^
>>> <stdin>:4:2: note: with expression "@LINE-4" equal to "11"
>>>  #0 0x75e5f in main
>>> (/Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp+0x1e5f)
>>>  ^
>>> <stdin>:4:97: note: possible intended match here
>>>  #0 0x75e5f in main
>>> (/Users/kuba/llvm-tot-cmake-release/projects/compiler-rt/test/asan/32bitConfig/TestCases/Output/use-after-free.cc.tmp+0x1e5f)
>>>
>>>
>>> Kuba
>>>
>>> Author: dblaikie
>>>> Date: Fri Sep 19 12:03:16 2014
>>>> New Revision: 218129
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=218129&view=rev
>>>> Log:
>>>> Omit DW_TAG_subprograms for subprograms without inlined subroutines
>>>> when producing -gmlt data
>>>> To reduce the size of -gmlt data, skip the subprograms without any
>>>> inlined subroutines. Since we've now got the ability to make these
>>>> determinations in the backend (funnily enough - we added the flag so we
>>>> wouldn't produce ranges under -gmlt, but with this change we use the
>>>> flag, but go back to producing ranges under -gmlt).
>>>> Instead, just produce CU ranges to inform the consumer which parts of
>>>> the code are described by this CU's line table. Tools could inspect the
>>>> line table directly to compute the range, but the CU ranges only seem to
>>>> be about 0.5% of object/executable size, so I'm not too worried about
>>>> teaching llvm-symbolizer that trick just yet - it's certainly a possible
>>>> piece of future work.
>>>> Update an llvm-symbolizer test just to demonstrate that this schema is
>>>> acceptable there (if it wasn't, the compiler-rt tests would catch this,
>>>> but good to have an in-llvm-tree test for llvm-symbolizer's behavior
>>>> here)
>>>> Building the clang binary with -gmlt with this patch reduces the total
>>>> size of object files by 5.1% (5.56% without ranges) without compression
>>>> and the executable by 4.37% (4.75% without ranges).
>>>> Modified:
>>>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>>>>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>>>>     llvm/trunk/test/DebugInfo/Inputs/dwarfdump-inl-test.elf-x86-64
>>>>     llvm/trunk/test/DebugInfo/gmlt.ll
>>>>     llvm/trunk/test/DebugInfo/llvm-symbolizer.test
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140925/2a1cc1c5/attachment.html>


More information about the llvm-commits mailing list