Skip to content

Commit b414954

Browse files
committed
[lldb] Make ReadCStringFromMemory default to read from the file-cache.
Differential Revision: https://reviews.llvm.org/D118265
1 parent a9d5bb9 commit b414954

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,11 @@ class Target : public std::enable_shared_from_this<Target>,
10191019
lldb::addr_t *load_addr_ptr = nullptr);
10201020

10211021
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1022-
Status &error);
1022+
Status &error, bool force_live_memory = false);
10231023

10241024
size_t ReadCStringFromMemory(const Address &addr, char *dst,
1025-
size_t dst_max_len, Status &result_error);
1025+
size_t dst_max_len, Status &result_error,
1026+
bool force_live_memory = false);
10261027

10271028
/// Read a NULL terminated string from memory
10281029
///

lldb/source/Target/Target.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,13 +1829,14 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
18291829
}
18301830

18311831
size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
1832-
Status &error) {
1832+
Status &error, bool force_live_memory) {
18331833
char buf[256];
18341834
out_str.clear();
18351835
addr_t curr_addr = addr.GetLoadAddress(this);
18361836
Address address(addr);
18371837
while (true) {
1838-
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
1838+
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error,
1839+
force_live_memory);
18391840
if (length == 0)
18401841
break;
18411842
out_str.append(buf, length);
@@ -1851,7 +1852,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
18511852
}
18521853

18531854
size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
1854-
size_t dst_max_len, Status &result_error) {
1855+
size_t dst_max_len, Status &result_error,
1856+
bool force_live_memory) {
18551857
size_t total_cstr_len = 0;
18561858
if (dst && dst_max_len) {
18571859
result_error.Clear();
@@ -1874,8 +1876,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
18741876
cache_line_size - (curr_addr % cache_line_size);
18751877
addr_t bytes_to_read =
18761878
std::min<addr_t>(bytes_left, cache_line_bytes_left);
1877-
size_t bytes_read =
1878-
ReadMemory(address, curr_dst, bytes_to_read, error, true);
1879+
size_t bytes_read = ReadMemory(address, curr_dst, bytes_to_read, error,
1880+
force_live_memory);
18791881

18801882
if (bytes_read == 0) {
18811883
result_error = error;

0 commit comments

Comments
 (0)