Skip to content

Commit 9d60dc7

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. (cherry picked from commit c5c35e7)
1 parent c9d2fab commit 9d60dc7

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
@@ -1204,11 +1204,14 @@ class Target : public std::enable_shared_from_this<Target>,
12041204
// 2 - if there is a process, then read from memory
12051205
// 3 - if there is no process, then read from the file cache
12061206
//
1207+
// The optional did_read_live_memory parameter will be set true if live memory
1208+
// was read successfully.
1209+
//
12071210
// The method is virtual for mocking in the unit tests.
12081211
virtual size_t ReadMemory(const Address &addr, void *dst, size_t dst_len,
12091212
Status &error, bool force_live_memory = false,
1210-
lldb::addr_t *load_addr_ptr = nullptr);
1211-
1213+
lldb::addr_t *load_addr_ptr = nullptr,
1214+
bool *did_read_live_memory = nullptr);
12121215
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
12131216
Status &error, bool force_live_memory = false);
12141217

lldb/source/Target/Target.cpp

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

20262026
size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
20272027
Status &error, bool force_live_memory,
2028-
lldb::addr_t *load_addr_ptr) {
2028+
lldb::addr_t *load_addr_ptr,
2029+
bool *did_read_live_memory) {
20292030
error.Clear();
20302031

20312032
Address fixed_addr = addr;
@@ -2124,6 +2125,8 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
21242125
if (bytes_read) {
21252126
if (load_addr_ptr)
21262127
*load_addr_ptr = load_addr;
2128+
if (did_read_live_memory)
2129+
*did_read_live_memory = true;
21272130
return bytes_read;
21282131
}
21292132
}

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)