[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon May 13 15:36:09 PDT 2024


================
@@ -0,0 +1,63 @@
+//===-- SBAddressRange.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBADDRESSRANGE_H
+#define LLDB_API_SBADDRESSRANGE_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+class LLDB_API SBAddressRange {
+public:
+  SBAddressRange();
+
+  SBAddressRange(const lldb::SBAddressRange &rhs);
+
+  SBAddressRange(lldb::addr_t file_addr, lldb::addr_t byte_size);
----------------
clayborg wrote:

If you actually want to resolve a `file_addr` then you must supply a `lldb::SBModule` which can be used to resolve it:
```
SBAddressRange(lldb::addr_t file_addr, ldb::SBModule module, lldb::addr_t byte_size);
``` 
That being said, I don't know if we want this constructor. We probably want:
```
SBAddressRange(SBAddress base_addr, lldb::addr_t byte_size);
```
You might want this API because you want to just make a list of load address ranges. I would suggest that you would use either of these `SBAddress` constructors:
```
  SBAddress(lldb::SBSection section, lldb::addr_t offset);
  SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target);
```
So if you want to make a `SBAddress` using a "load_addr", you would do:
```
SBAddress(load_addr, target);
```
If `load_addr` resolved to a section that is loaded, then the resulting `SBAddress` will contain a valid section. If the `load_addr` is somewhere in the process, but not in a section the resulting `SBAddress` will have no section and the offset will be set to `load_addr`

So change this to be:
```
SBAddressRange(SBAddress base_addr, lldb::addr_t byte_size);
```


https://github.com/llvm/llvm-project/pull/92014


More information about the lldb-commits mailing list