[Lldb-commits] [lldb] b414954 - [lldb] Make ReadCStringFromMemory default to read from the file-cache.

Augusto Noronha via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 28 08:09:37 PST 2022


Author: Augusto Noronha
Date: 2022-01-28T13:08:30-03:00
New Revision: b414954a5f1c2f8f6adecf20e5a433dfbc320cc2

URL: https://github.com/llvm/llvm-project/commit/b414954a5f1c2f8f6adecf20e5a433dfbc320cc2
DIFF: https://github.com/llvm/llvm-project/commit/b414954a5f1c2f8f6adecf20e5a433dfbc320cc2.diff

LOG: [lldb] Make ReadCStringFromMemory default to read from the file-cache.

Differential Revision: https://reviews.llvm.org/D118265

Added: 
    

Modified: 
    lldb/include/lldb/Target/Target.h
    lldb/source/Target/Target.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 2c8b36d1e3d9c..42a641f6d52ab 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1019,10 +1019,11 @@ class Target : public std::enable_shared_from_this<Target>,
                     lldb::addr_t *load_addr_ptr = nullptr);
 
   size_t ReadCStringFromMemory(const Address &addr, std::string &out_str,
-                               Status &error);
+                               Status &error, bool force_live_memory = false);
 
   size_t ReadCStringFromMemory(const Address &addr, char *dst,
-                               size_t dst_max_len, Status &result_error);
+                               size_t dst_max_len, Status &result_error,
+                               bool force_live_memory = false);
 
   /// Read a NULL terminated string from memory
   ///

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 01e51c0577aae..6d33db6554d2e 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -1829,13 +1829,14 @@ size_t Target::ReadMemory(const Address &addr, void *dst, size_t dst_len,
 }
 
 size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
-                                     Status &error) {
+                                     Status &error, bool force_live_memory) {
   char buf[256];
   out_str.clear();
   addr_t curr_addr = addr.GetLoadAddress(this);
   Address address(addr);
   while (true) {
-    size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
+    size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error,
+                                          force_live_memory);
     if (length == 0)
       break;
     out_str.append(buf, length);
@@ -1851,7 +1852,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
 }
 
 size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
-                                     size_t dst_max_len, Status &result_error) {
+                                     size_t dst_max_len, Status &result_error,
+                                     bool force_live_memory) {
   size_t total_cstr_len = 0;
   if (dst && dst_max_len) {
     result_error.Clear();
@@ -1874,8 +1876,8 @@ size_t Target::ReadCStringFromMemory(const Address &addr, char *dst,
           cache_line_size - (curr_addr % cache_line_size);
       addr_t bytes_to_read =
           std::min<addr_t>(bytes_left, cache_line_bytes_left);
-      size_t bytes_read =
-          ReadMemory(address, curr_dst, bytes_to_read, error, true);
+      size_t bytes_read = ReadMemory(address, curr_dst, bytes_to_read, error,
+                                     force_live_memory);
 
       if (bytes_read == 0) {
         result_error = error;


        


More information about the lldb-commits mailing list