-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb] Add DWARFExpressionEntry and GetExpressionEntryAtAddress() to … #144238
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
8ed8c54
1db5002
a26010b
72237b7
94e4951
e8142da
7e8741e
c4cd77f
62c02a9
d015971
60898ea
3462165
c01a747
ec3ac93
38baa90
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 |
|---|---|---|
|
|
@@ -59,6 +59,18 @@ class DWARFExpressionList { | |
|
|
||
| lldb::addr_t GetFuncFileAddress() { return m_func_file_addr; } | ||
|
|
||
| /// Represents an entry in the DWARFExpressionList with all needed metadata | ||
| struct DWARFExpressionEntry { | ||
| lldb::addr_t base; | ||
| lldb::addr_t end; | ||
|
||
| const DWARFExpression *expr; | ||
| }; | ||
|
|
||
| /// Returns the entry (base, end, data) for a given PC address | ||
UltimateForce21 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| llvm::Expected<DWARFExpressionEntry> | ||
| GetExpressionEntryAtAddress(lldb::addr_t func_load_addr, | ||
| lldb::addr_t load_addr) const; | ||
|
|
||
| const DWARFExpression *GetExpressionAtAddress(lldb::addr_t func_load_addr, | ||
| lldb::addr_t load_addr) const; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,27 @@ bool DWARFExpressionList::ContainsAddress(lldb::addr_t func_load_addr, | |
| return GetExpressionAtAddress(func_load_addr, addr) != nullptr; | ||
| } | ||
|
|
||
| llvm::Expected<DWARFExpressionList::DWARFExpressionEntry> | ||
| DWARFExpressionList::GetExpressionEntryAtAddress(lldb::addr_t func_load_addr, | ||
| lldb::addr_t load_addr) const { | ||
| if (const DWARFExpression *expr = GetAlwaysValidExpr()) { | ||
| return DWARFExpressionEntry{0, LLDB_INVALID_ADDRESS, expr}; | ||
| } | ||
UltimateForce21 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (func_load_addr == LLDB_INVALID_ADDRESS) | ||
| func_load_addr = m_func_file_addr; | ||
|
|
||
| addr_t addr = load_addr - func_load_addr + m_func_file_addr; | ||
| uint32_t index = m_exprs.FindEntryIndexThatContains(addr); | ||
| if (index == UINT32_MAX) { | ||
| return llvm::createStringError(llvm::inconvertibleErrorCode(), | ||
| "No DWARF expression found for address 0x%llx", addr); | ||
|
||
| } | ||
|
|
||
| const Entry &entry = *m_exprs.GetEntryAtIndex(index); | ||
| return DWARFExpressionEntry{entry.base, entry.GetRangeEnd(), &entry.data}; | ||
| } | ||
|
|
||
| const DWARFExpression * | ||
| DWARFExpressionList::GetExpressionAtAddress(lldb::addr_t func_load_addr, | ||
|
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. Out of curiosity: Do we still need this API, or is it just a subset of the function above?
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. As you know the new function GetExpressionEntryAtAddress, does almost exact same thing as this one. I don't see this function being used anywhere else in the lldb code base, so maybe it can be removed, but to be safe I did not want to alter it. But from what I can tell, it should be okay to remove it. We can also choose to keep it and maybe refactor it to just call the GetExpressionEntryAtAddress and just return the
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. If it's completely unused, and there is no indication that was added in support of any downstream clients (either as a comment or in the commit message) we could consider deleting it in a separate PR. Not urgent. |
||
| lldb::addr_t load_addr) const { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.