[Lldb-commits] [lldb] 3da7dcf - [lldb/Reproducers] Serialize empty string for char* methods.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 5 21:55:49 PST 2020


Author: Jonas Devlieghere
Date: 2020-02-05T21:55:36-08:00
New Revision: 3da7dcf38a96b7ba8ba0cb61be40210ace3fd91f

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

LOG: [lldb/Reproducers] Serialize empty string for char* methods.

For the methods taking a char* and a length that have a custom replayer,
ignore the incoming string in the instrumentation macro. This prevents
potentially reading garbage and blowing up the SB API log.

Added: 
    

Modified: 
    lldb/source/API/SBFileSpec.cpp
    lldb/source/API/SBProcess.cpp
    lldb/source/API/SBStructuredData.cpp
    lldb/source/API/SBThread.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a9b3c0f99f9d..3c3ea32a455d 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -143,8 +143,8 @@ void SBFileSpec::SetDirectory(const char *directory) {
 }
 
 uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
-  LLDB_RECORD_DUMMY(uint32_t, SBFileSpec, GetPath, (char *, size_t),
-                           dst_path, dst_len);
+  LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t), "",
+                           dst_len);
 
   uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
 

diff  --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp
index ffb5a3fa8569..425ebf63ba17 100644
--- a/lldb/source/API/SBProcess.cpp
+++ b/lldb/source/API/SBProcess.cpp
@@ -270,7 +270,7 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
 }
 
 size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
-  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
+  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), "",
                            dst_len);
 
   size_t bytes_read = 0;
@@ -284,7 +284,7 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
 }
 
 size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
-  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
+  LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), "",
                            dst_len);
 
   size_t bytes_read = 0;
@@ -299,7 +299,7 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
 
 size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
   LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
-                           (char *, size_t), dst, dst_len);
+                           (char *, size_t), "", dst_len);
 
   size_t bytes_read = 0;
   ProcessSP process_sp(GetSP());

diff  --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp
index bc820ba7e2ef..7d1b6bf78504 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/lldb/source/API/SBStructuredData.cpp
@@ -126,10 +126,10 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
 
   if (!m_impl_up)
     return false;
-  
+
   if (GetType() != eStructuredDataTypeDictionary)
     return false;
-  
+
   StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP();
   if (!obj_sp)
     return false;
@@ -141,7 +141,7 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
   StructuredData::ObjectSP array_sp = dict->GetKeys();
   StructuredData::Array *key_arr = array_sp->GetAsArray();
   assert(key_arr);
-  
+
   key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool {
     llvm::StringRef key = object->GetStringValue("");
     keys.AppendString(key.str().c_str());
@@ -197,7 +197,7 @@ bool SBStructuredData::GetBooleanValue(bool fail_value) const {
 
 size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
   LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
-                           (char *, size_t), dst, dst_len);
+                           (char *, size_t), "", dst_len);
 
   return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
 }

diff  --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index ff1a428b83cd..69342b972a2c 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -313,8 +313,8 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
 }
 
 size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
-  LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
-                     dst, dst_len);
+  LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t), "",
+                     dst_len);
 
   std::unique_lock<std::recursive_mutex> lock;
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -970,23 +970,20 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
                                             bool resume_immediately) {
   LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
-                     (const char *, bool), script_class_name, 
+                     (const char *, bool), script_class_name,
                      resume_immediately);
 
   lldb::SBStructuredData no_data;
-  return LLDB_RECORD_RESULT(
-      StepUsingScriptedThreadPlan(script_class_name, 
-                                  no_data, 
-                                  resume_immediately));
+  return LLDB_RECORD_RESULT(StepUsingScriptedThreadPlan(
+      script_class_name, no_data, resume_immediately));
 }
 
 SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
                                               SBStructuredData &args_data,
                                               bool resume_immediately) {
   LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
-                     (const char *, lldb::SBStructuredData &, bool), 
-                     script_class_name, args_data,
-                     resume_immediately);
+                     (const char *, lldb::SBStructuredData &, bool),
+                     script_class_name, args_data, resume_immediately);
 
   SBError error;
 


        


More information about the lldb-commits mailing list