[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)
Greg Clayton via lldb-commits
lldb-commits at lists.llvm.org
Mon May 20 15:35:07 PDT 2024
================
@@ -203,3 +208,38 @@ void AddressRange::DumpDebug(Stream *s) const {
static_cast<void *>(m_base_addr.GetSection().get()),
m_base_addr.GetOffset(), GetByteSize());
}
+
+bool AddressRange::GetDescription(Stream *s, Target *target) const {
+ const char *file_name = nullptr;
+ addr_t start_addr = LLDB_INVALID_ADDRESS;
+
+ if (target == nullptr) {
+ const auto section_sp = m_base_addr.GetSection();
+ if (section_sp) {
+ const auto object_file = section_sp->GetObjectFile();
+ if (object_file != nullptr)
+ file_name = object_file->GetFileSpec().GetFilename().AsCString();
+ }
+ start_addr = m_base_addr.GetFileAddress();
+ } else {
+ start_addr = m_base_addr.GetLoadAddress(target);
+ file_name = "";
+ }
+
+ const addr_t end_addr = (start_addr == LLDB_INVALID_ADDRESS)
+ ? LLDB_INVALID_ADDRESS
+ : start_addr + GetByteSize();
+ s->Printf("%s[0x%" PRIx64 "-0x%" PRIx64 "]", file_name, start_addr, end_addr);
----------------
clayborg wrote:
The end address isn't inclusive, so this should be:
```
s->Printf("%s[0x%" PRIx64 "-0x%" PRIx64 ")", file_name, start_addr, end_addr);
```
(change the closing brace from a `]` to a `)`)
https://github.com/llvm/llvm-project/pull/92014
More information about the lldb-commits
mailing list