Skip to content

Commit 8652cd1

Browse files
committed
[lldb] Add an extra optional did_read_live_memory to Target::ReadMemory
Target::ReadMemory may or may not read live memory, but whether it did read from live memory or from the filecache is opaque to callers. Add an extra out parameter to indicate whether live memory was read or not.
1 parent 0bbdf73 commit 8652cd1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,11 +1193,14 @@ class Target : public std::enable_shared_from_this<Target>,
11931193
// 2 - if there is a process, then read from memory
11941194
// 3 - if there is no process, then read from the file cache
11951195
//
1196+
// The optional did_read_live_memory parameter will be set true if live memory
1197+
// was read successfully.
1198+
//
11961199
// The method is virtual for mocking in the unit tests.
11971200
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
11981201
Status &error, bool force_live_memory = false,
1199-
lldb::addr_t *load_addr_ptr = nullptr);
1200-
1202+
lldb::addr_t *load_addr_ptr = nullptr,
1203+
bool *did_read_live_memory = nullptr);
12011204
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
12021205
Status &error, bool force_live_memory = false);
12031206

lldb/source/Target/Target.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ size_t Target::ReadMemoryFromFileCache(const Address &addr, void *dst,
19211921

19221922
size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
19231923
Status &error, bool force_live_memory,
1924-
lldb::addr_t *load_addr_ptr) {
1924+
lldb::addr_t *load_addr_ptr,
1925+
bool *did_read_live_memory) {
19251926
error.Clear();
19261927

19271928
Address fixed_addr = addr;
@@ -2020,6 +2021,8 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
20202021
if (bytes_read) {
20212022
if (load_addr_ptr)
20222023
*load_addr_ptr = load_addr;
2024+
if (did_read_live_memory)
2025+
*did_read_live_memory = true;
20232026
return bytes_read;
20242027
}
20252028
}

lldb/unittests/Expression/DWARFExpressionTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class MockTarget : public Target {
111111

112112
size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
113113
Status &error, bool force_live_memory = false,
114-
lldb::addr_t *load_addr_ptr = nullptr) /*override*/ {
114+
lldb::addr_t *load_addr_ptr = nullptr,
115+
bool *did_read_live_memory = nullptr) /*override*/ {
115116
auto expected_memory = this->ReadMemory(addr.GetOffset(), dst_len);
116117
if (!expected_memory) {
117118
llvm::consumeError(expected_memory.takeError());

0 commit comments

Comments
 (0)