-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLDB] Add more helper functions to ValueObject class. #87197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
68cb68d
b6a1e23
145e74b
22e1b06
b8eee30
8709f70
1e41bfa
28748a9
499a097
fa25850
d4e7f69
6ca00e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -441,6 +441,19 @@ class ValueObject { | |
|
|
||
| virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = nullptr); | ||
|
|
||
| llvm::APSInt GetValueAsAPSInt(); | ||
|
|
||
| llvm::APFloat GetValueAsFloat(); | ||
|
||
|
|
||
| bool GetValueAsBool(); | ||
|
||
|
|
||
| /// Update the value of the current object to be the integer in the 'value' | ||
| /// parameter. | ||
| void UpdateIntegerValue(const llvm::APInt &value); | ||
|
||
|
|
||
| /// Assign the integer value 'new_val_sp' to the current object. | ||
| void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp); | ||
|
||
|
|
||
| virtual bool SetValueFromCString(const char *value_str, Status &error); | ||
|
|
||
| /// Return the module associated with this value object in case the value is | ||
|
|
@@ -618,6 +631,24 @@ class ValueObject { | |
| virtual lldb::ValueObjectSP CastPointerType(const char *name, | ||
| lldb::TypeSP &type_sp); | ||
|
|
||
| /// Return the target load address assocaited with this value object. | ||
cmtice marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| lldb::addr_t GetLoadAddress(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this function just a copy of the contents of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is based on SBValue::GetLoadAddress; I'll update that one to call this one. As written, it already does return LLDB_INVALID_ADDRESS in certain cases...I'm not sure what you want me to do differently (probably better to discuss this at the implementation rather than the declaration). |
||
|
|
||
| lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type, | ||
| const std::vector<uint32_t> &idx); | ||
|
||
|
|
||
| lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t offset); | ||
|
|
||
| lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status &error); | ||
|
||
|
|
||
| lldb::ValueObjectSP CastEnumToBasicType(CompilerType type); | ||
|
|
||
| lldb::ValueObjectSP CastPointerToBasicType(CompilerType type); | ||
|
||
|
|
||
| lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type); | ||
|
|
||
| lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status &error); | ||
|
||
|
|
||
| /// If this object represents a C++ class with a vtable, return an object | ||
| /// that represents the virtual function table. If the object isn't a class | ||
| /// with a vtable, return a valid ValueObject with the error set correctly. | ||
|
|
@@ -668,6 +699,32 @@ class ValueObject { | |
| CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data, | ||
| const ExecutionContext &exe_ctx, CompilerType type); | ||
|
|
||
| static lldb::ValueObjectSP | ||
|
||
| CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes, | ||
| CompilerType type); | ||
|
|
||
| static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target, | ||
|
||
| const void *bytes, | ||
| lldb::BasicType type); | ||
|
|
||
| static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto for adding a name parameter.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| const llvm::APInt &v, | ||
| CompilerType type); | ||
|
|
||
| static lldb::ValueObjectSP | ||
| CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto for adding a name parameter.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| CompilerType type); | ||
|
|
||
| static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP target, | ||
|
||
| uintptr_t addr, | ||
| CompilerType type); | ||
|
|
||
| static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name arg?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| bool value); | ||
|
|
||
| static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP target, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name arg?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
| CompilerType type); | ||
|
|
||
| lldb::ValueObjectSP Persist(); | ||
|
|
||
| /// Returns true if this is a char* or a char[] if it is a char* and | ||
|
|
@@ -719,6 +776,10 @@ class ValueObject { | |
| ClearUserVisibleData(eClearUserVisibleDataItemsSummary); | ||
| } | ||
|
|
||
| void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Synthetic child providers also have a way to provide the deref ValueObject dynamically. How do these two ways of doing that job work together?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I use the synthetic child providers way of getting the deref ValueObject to get the value I use for my call to SetDerefValobj (when I'm converting a ValueObject containing a SmartPointer into a ValueObject containing the pointer the SmartPointer was referencing). |
||
|
|
||
| ValueObject *GetDerefValobj() { return m_deref_valobj; } | ||
|
|
||
| void SetValueFormat(lldb::TypeFormatImplSP format) { | ||
| m_type_format_sp = std::move(format); | ||
| ClearUserVisibleData(eClearUserVisibleDataItemsValue); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all SBValues are representable as Int's or Floats, Bool's etc. But I don't see any way to report errors with these new API's.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if these errors matter to users then
llvm::Expected<llvm::APSInt>would be the right choice. Otherwise std::optional is the way to go.