Re: [lldb-dev] get function name from dwarf info

2016-10-13 Thread Carlo Kok via lldb-dev



On 2016-10-12 19:10, Greg Clayton wrote:



We would also need to add a way to get the class type from the member function:

lldb::SBType lldb::SBTypeMemberFunction::GetContainingType();

This would return the class/struct that owns the member function.


So if we just add:

  lldb::SBTypeMemberFunction lldb::SBType::GetMemberFunction();
  lldb::SBType lldb::SBTypeMemberFunction::GetContainingType();

Then you should be able to do what you want. Let me know if you need help with 
this.


Shouldn't that be SBFunction::GetMemberFunction() ?

If you can hint at where this info is stored that would be great. I 
looked at Function but couldn't figure it out.



Besides that, happen to know how I can get the dw_at_name from dwarf 
function to SBFunction? Atm it seems to go through the demangler in 
Function, which fails (there isn't one) and just returns the symbol name 
even though the info is there.

--
Carlo Kok
RemObjects Software
___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] get function name from dwarf info

2016-10-12 Thread Greg Clayton via lldb-dev

> On Oct 7, 2016, at 7:32 AM, Carlo Kok via lldb-dev  
> wrote:
> 
> 
>>> How do I get the dw_at_name field? I don't need lldb to decypher the
>>> mangling I use, I just want access to the linkage name and real encoded
>>> name?
>>> 
>>> Also how do I get the type this is contained in (presuming there is one
>>> ofc)?
>> I am not sure what you are trying to do. Can you elaborate a little.
> 
> I have a custom language where it's ~ equivalent to the c++ class:
> 
> class TEST{
>private:
>int INSTANCEFIELD;
>static int STATICFIELD;
>public:
>void INSTANCEMETHOD() {
>INSTANCEFIELD++;
>}
>static void STATICMETHOD() {
>STATICFIELD++;
>}
> };
> 
> the name "STATICMETHOD" is properly encoded in the dwarf debug info (where 
> linkage name is the mangled name). I want "STATICMETHOD" back as it would be 
> encoded in DW_AT_NAME.
> 
> I also want to get the SBType for "TEST" when I have the SBFunction for 
> INSTANCEMETHOD/STATICMETHOD.
> 
> Both things are properly encoded in dwarf (as matching the c++ output), 
> however I can't seem to find the right SB method to get it.

We currently have a way for you to find the SBType for "TEST" and then ask that 
type for its member functions:



SBType test_type = module.FindFirstType("TEST");
const uint32_t num_member_functions = test_type.GetNumberOfMemberFunctions();
for (uint32_t i=0; i 
> 
>> 
>>> 
>>> Lastly: How do I encode if a method is static or not, I couldn't find
>>> any difference in what C++ does for instance vs static.

You can already ask a member function for its kind:

  lldb::MemberFunctionKind lldb::SBTypeMemberFunction::GetKind();

This should help for member functions.

>> 
>> There is  "DW_AT_object_pointer". Debuggers can also make that decision
>> based on presence of "this" parameter.
>> 


The member function type should be correctly encoded and can be accessed by 
lldb::SBTypeMemberFunction::GetKind(). 

> 
> Thanks.
> 
> -- 
> Carlo Kok
> RemObjects Software
> ___
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev

___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev


Re: [lldb-dev] get function name from dwarf info

2016-10-07 Thread Abid, Hafiz via lldb-dev


> -Original Message-
> From: lldb-dev [mailto:lldb-dev-boun...@lists.llvm.org] On Behalf Of Carlo
> Kok via lldb-dev
> Sent: 07 October 2016 14:29
> To: lldb-dev@lists.llvm.org
> Subject: [lldb-dev] get function name from dwarf info
> 
> Hi,
> 
> I have a piece of debuginfo containing this subfunction :
> 
> DW_TAG_subprogram [6] *
>DW_AT_low_pc [DW_FORM_addr]   (0x00437020)
>DW_AT_high_pc [DW_FORM_data4] (0x001e)
>DW_AT_frame_base [DW_FORM_exprloc](<0x1> 55 )
>DW_AT_linkage_name [DW_FORM_strp] ( .debug_str[0x00ae] =
> "mi_t11_issudebugtest.ABC2_AA")
>DW_AT_name [DW_FORM_strp] ( .debug_str[0x00cb] = "AA")
>DW_AT_decl_line [DW_FORM_data1]   (16)
> DW_AT_external [DW_FORM_flag_present] (true)
> 
> 
> It's part (a member) of this type:
> DW_TAG_structure_type [2] *
>DW_AT_name [DW_FORM_strp] ( .debug_str[0x0065] =
> "issudebugtest.ABC")
>   DW_AT_byte_size [DW_FORM_data1] (0x08)
> 
> How do I get the dw_at_name field? I don't need lldb to decypher the
> mangling I use, I just want access to the linkage name and real encoded
> name?
> 
> Also how do I get the type this is contained in (presuming there is one
> ofc)?
I am not sure what you are trying to do. Can you elaborate a little.

> 
> Lastly: How do I encode if a method is static or not, I couldn't find
> any difference in what C++ does for instance vs static.

There is  "DW_AT_object_pointer". Debuggers can also make that decision
based on presence of "this" parameter.
 
Regards,
Abid

> 
> --
> Carlo Kok
> RemObjects Software
> ___
> lldb-dev mailing list
> lldb-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev
___
lldb-dev mailing list
lldb-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev