[lldb-dev] Help with C++ API

jingham at apple.com jingham at apple.com
Tue Aug 27 19:31:11 PDT 2013


Enrico answered questions 1 & 3.  

For question 2, that's really a bit of missing API.  There's an SBValue::CreateValueFromAddress which takes one SBValue an address, and an SBType to make a new value object that is just tied to that address and type.  That was an SBValue method because that's what was convenient to implement the Synthetic types. But since all that it uses from the original SBValue is the process, it really should just be a method on SBProcess.  That would be perfect for you.  It would be pretty easy to add that API, if you want to give it a try.

Otherwise, you can cons up a new expression from the type and address of the original SBValue, and use SBTarget::EvaluateExpression to make a free-standing SBValue from that.

Jim

On Aug 27, 2013, at 6:23 PM, Jakob Leben <jakob.leben at gmail.com> wrote:

> Hello,
> 
> I have got some questions regarding the LLDB C++ API which I haven't
> found answers to in the documentation or by investigating the source
> code so far. If there is a better place than this mailing list to
> direct this kind of questions to, please let me know!
> 
> All the questions below are related to using the API to debug a
> program compiled from C++ source.
> 
> 1. When trying to read data from a dynamically allocated array of
> "doubles" I fail to get all the data correctly by using
> SBValue::GetPointeeData() and then SBData::ReadRawData(), despite the
> fact that no call reports any error, and all the involved SBxxx
> objects as valid. However, if I use SBValue::GetChildAtIndex for each
> array member, each member is read correctly. What's the difference? I
> guess this has to do something with data caching (or lack thereof)?
> 
> 2. When reading data from a dynamically allocated data structure by
> using SBValue::GetChildMemberWithName() etc. on a SBValue representing
> a pointer to the (complex) object, and obtained in a *different*
> breakpoint callback then the current one, again reading does not fail
> in any way, but the read data of any field will be equivalent to
> whatever was last read in the *originating* breakpoint callback.
> Probably again, only data cached when reading with the SBValue in
> scope is returned. I understand that a SBValue is meant to represent a
> value a particular execution context, and as such does not need to
> support reading data outside of that context. But it there any other
> API that would facilitate reading fields of a complex-type object on
> the heap at any point in program execution, regardless of the current
> execution context? It seems logical that this should be possible.
> 
> 3. Despite reading the source code, I have not managed to grasp the
> exact meaning of the words "dynamic" and "synthetic", whenever they
> occur in the API. For example, what precisely do the
> lldb::DynamicValueType flags mean? Is this related to dynamically
> typed languages, or does it have to do something with caching of data
> exchanged between debugger and debugee? What exactly does it imply if
> I set a SBValue's "preference" to use dynamic or synthetic value?
> 
> Thank you for any answers, or directions that would help me find the
> answers myself.
> 
> Best regards,
> Jakob Leben
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev




More information about the lldb-dev mailing list