[Lldb-commits] [PATCH] D22294: Add functionality for rewriting symbols

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 13 13:52:01 PDT 2016


clayborg added a comment.

In http://reviews.llvm.org/D22294#483213, @sas wrote:

> @jingham, @clayborg, this is indeed a bit fragile as having to specify your rewrite maps manually when debugging is very error-prone. I have a patch that fetches the path to the rewrite map from the debug info, I'm waiting for this one to go in to upload that other diff (trying to make changes smaller so the review is easier). The way I do this is by looking at the flags that were passed to the compiler, and get the path to the rewrite map from there automatically, which then requires no user interaction for this to work.


If we have the compiler modify the DWARF by adding a linkage name to the appropriate DW_TAG_subproggram, then we won't need any rewrite file stuff at all.

In http://reviews.llvm.org/D22294#483242, @fjricci wrote:

> @clayborg: As you saw when running the test with debug info enabled, we might end up calling the non-rewritten `putchar()`, which is due to the compiler emitting debug symbols with the non-rewritten name. The `-g0` option is just a workaround until we can fix that.
>
> I suppose Adrian Prantl's idea of modifying the emitted DWARF to add a linkage name attached to the function would work. Does that mean we would only add an entry for the rewritten symbol when lldb parses the DWARF, and ignore the non-rewritten function name?


Basically the DWARF currently looks like:

  0x0000002e:     DW_TAG_subprogram [2] *
                   DW_AT_low_pc( 0x0000000000000000 )
                   DW_AT_high_pc( 0x000000000000000e )
                   DW_AT_frame_base( rbp )
                   DW_AT_name( "putchar" )
                   DW_AT_decl_file( "/Volumes/work/gclayton/Desktop/symbol_rewriter/main.c" )
                   DW_AT_decl_line( 3 )
                   DW_AT_prototyped( 0x01 )
                   DW_AT_type( {0x0000007a} ( int ) )
                   DW_AT_external( 0x01 )

And we would modify it to emit this:

  0x0000002e:     DW_TAG_subprogram [2] *
                   DW_AT_low_pc( 0x0000000000000000 )
                   DW_AT_high_pc( 0x000000000000000e )
                   DW_AT_frame_base( rbp )
                   DW_AT_name( "putchar" )
                   DW_AT_linkage_name( "__my_putchar" ) <<< Added by compiler
                   DW_AT_decl_file( "/Volumes/work/gclayton/Desktop/symbol_rewriter/main.c" )
                   DW_AT_decl_line( 3 )
                   DW_AT_prototyped( 0x01 )
                   DW_AT_type( {0x0000007a} ( int ) )
                   DW_AT_external( 0x01 )

If we do this, then we don't need any modifications for the rewrite stuff at all?


http://reviews.llvm.org/D22294





More information about the lldb-commits mailing list