[llvm-dev] Dwarf - 5 features in clang and llvm

Sourabh Singh Tomar via llvm-dev llvm-dev at lists.llvm.org
Wed Sep 11 06:06:04 PDT 2019


Hi Djordje,

> The 'func()' gets inlined, so according to the DWARF standard the
call-site debug info should not be created for calls to inlined functions

Thanks for sharing this, Now the real problem is getting values of this
optimized parameter "ptr" since func is inlined, variable ptr has location
in debug_loc section {assuming DWARF-4}.
but for CLANG compiled binaries, gdb is reporting  optimized out.

Reading symbols from test1_clang_O2...
(gdb) b func(int*)
Breakpoint 1 at 0x2010f4: func(int*). (2 locations)
(gdb) r
Starting program: /doc/test1_clang_O2

Breakpoint 1, func (ptr=<optimized out>) at test1.cpp:4
4               std::cout << *ptr;
(gdb) print *ptr
value has been optimized out

For GCC-9.2 compiled binaries, I'm able to print this optimized out the
value of optimized out "ptr" variable.
Please note that GCC-9.2 is also emitting an extra
DW_OP_GNU_implicit_poitner along with DW_OP_GNU_entry_value,
DW_OP_stack_value. DW_OP_GNU_implicit_pointer is not emitted by CLANG.

>> The new work is also implemented on the MIR level.
Thanks for clarifying this.

Thanks!
Sourabh.

On Wed, Sep 11, 2019 at 5:16 PM Djordje Todorovic <
djordje.todorovic at rt-rk.com> wrote:

> Hi Sourabh,
>
> > #include <iostream>
> > int func(int* ptr){
> >         std::cout << *ptr;
> >         return *ptr + 5;
> > }
> > int main(int argc, char** argv){
> >         int a = 4;
> >         int* ptr_a = &a;
> >         int b = func(ptr_a);
> >         return 0;
> > }
>
> The 'func()' gets inlined, so according to the DWARF standard the
> call-site debug info should not be created for calls to inlined functions.
>
> >@Djorde DW_TAG_call_site are supported using late MIR approach, are the
> new Call Site related development will be supported via MIR. or their will
> be a frontend level debug metadata support will be added.
>
> The new work is also implemented on the MIR level.
>
> Best,
> Djordje
>
> On 11.9.19. 13:07, Sourabh Singh Tomar wrote:
> > Hello Djordje, Vedant,
> >
> > Thanks a lot for sharing information.
> >
> > I have a doubt, please consider the following simple test case-
> > #include <iostream>
> > int func(int* ptr){
> >         std::cout << *ptr;
> >         return *ptr + 5;
> > }
> > int main(int argc, char** argv){
> >         int a = 4;
> >         int* ptr_a = &a;
> >         int b = func(ptr_a);
> >         return 0;
> > }
> > commandline used --
> > bash$ clang++ -Xclang -femit-debug-entry-values -O2 -ggdb test.cpp
> >
> > For this case-- these Tags are not emitted
> > DW_TAG_call_site, DW_TAG_call_site_paramter ..
> > only DW_AT_GNU_all_call_sites attribute is present.
> >
> > + @Djorde DW_TAG_call_site are supported using late MIR approach, are
> the new Call Site related development will be supported via MIR. or their
> will be a frontend level debug metadata support will be added.
> >
> > Thanks!
> > Sourabh.
> >
> >
> >
> > On Wed, Sep 11, 2019 at 12:02 PM Djordje Todorovic <
> djordje.todorovic at rt-rk.com <mailto:djordje.todorovic at rt-rk.com>> wrote:
> >
> >     Great to see this! :)
> >
> >     Best,
> >     Djordje
> >
> >     On 10.9.19. 21:16, Vedant Kumar wrote:
> >     >
> >     >
> >     >> On Sep 10, 2019, at 6:15 AM, Djordje Todorovic via llvm-dev <
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> <mailto:
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>>> wrote:
> >     >>
> >     >> Hi Sourabh,
> >     >>
> >     >> Support for call-site related DWARF 5 tag/attributes is
> implemented very late, in the LLVM middle-end.
> >     >> Please note that there is also the IR-level flag
> (DIFlagAllCallsDescribed) that lowers to
> >     >> the DW_AT_call_all_calls.
> >     >>
> >     >> There is also support for call-site-parameter
> (DW_TAG_call_site_parameter) and the debug entry values
> >     >> (DW_OP_entry_value) related DWARF 5 symbols, but it is restricted
> by the CC1 option ‘-femit-debug-entry-values’,
> >     >> since the LLDB is still missing support for that.
> >     >
> >     > Not for too long ;)
> >     >
> >     > See https://reviews.llvm.org/D67410 &
> https://reviews.llvm.org/D67376
> >     >
> >     > best,
> >     > vedant
> >     >
> >     >>
> >     >> Best regards,
> >     >> Djordje
> >     >>
> >     >> On 10.9.19. 13:58, Sourabh Singh Tomar via llvm-dev wrote:
> >     >>> Hello All,
> >     >>>
> >     >>> I was working on some dwarf-5 features and debugging optimized
> code support in clang and llvm.
> >     >>>
> >     >>> Noticed that, DW_TAG_call_site is supported in llvm middle-end.
> but clang is not emitting these.
> >     >>>
> >     >>> I was hoping, if someone could provide current status of these
> features and current status of dwarf-5 features in clang and llvm.
> >     >>> That will be immensely helpful.
> >     >>>
> >     >>> Thanks!
> >     >>> Sourabh.
> >     >>>
> >     >>> _______________________________________________
> >     >>> LLVM Developers mailing list
> >     >>> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> <mailto:llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>>
> >     >>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >     >>>
> >     >> _______________________________________________
> >     >> LLVM Developers mailing list
> >     >> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> <mailto:
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>>
> >     >> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >     >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190911/456600bc/attachment-0001.html>


More information about the llvm-dev mailing list