Skip to content

Commit ecd3b66

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

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
@@ -1067,10 +1067,11 @@ class Target : public std::enable_shared_from_this<Target>,
10671067
lldb::addr_t *load_addr_ptr = nullptr);
10681068

10691069
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
1070-
Status &error);
1070+
Status &error, bool force_live_memory = false);
10711071

10721072
size_t ReadCStringFromMemory(const Address &addr, char *dst,
1073-
size_t dst_max_len, Status &result_error);
1073+
size_t dst_max_len, Status &result_error,
1074+
bool force_live_memory = false);
10741075

10751076
size_t ReadScalarIntegerFromMemory(const Address &addr, uint32_t byte_size,
10761077
bool is_signed, Scalar &scalar,

lldb/source/Target/Target.cpp

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

18751875
size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
1876-
Status &error) {
1876+
Status &error, bool force_live_memory) {
18771877
char buf[256];
18781878
out_str.clear();
18791879
addr_t curr_addr = addr.GetLoadAddress(this);
18801880
Address address(addr);
18811881
while (true) {
1882-
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
1882+
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error,
1883+
force_live_memory);
18831884
if (length == 0)
18841885
break;
18851886
out_str.append(buf, length);
@@ -1895,7 +1896,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
18951896
}
18961897

18971898
size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
1898-
size_t dst_max_len, Status &result_error) {
1899+
size_t dst_max_len, Status &result_error,
1900+
bool force_live_memory) {
18991901
size_t total_cstr_len = 0;
19001902
if (dst && dst_max_len) {
19011903
result_error.Clear();
@@ -1918,8 +1920,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
19181920
cache_line_size - (curr_addr % cache_line_size);
19191921
addr_t bytes_to_read =
19201922
std::min<addr_t>(bytes_left, cache_line_bytes_left);
1921-
size_t bytes_read =
1922-
ReadMemory(address, curr_dst, bytes_to_read, error, true);
1923+
size_t bytes_read = ReadMemory(address, curr_dst, bytes_to_read, error,
1924+
force_live_memory);
19231925

19241926
if (bytes_read == 0) {
19251927
result_error = error;

0 commit comments

Comments
 (0)