[Lldb-commits] [lldb] 6dccad7 - [lldb/Reproducers] (De)serialize char* like const char*

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 5 14:52:14 PST 2020


Author: Jonas Devlieghere
Date: 2020-02-05T14:52:08-08:00
New Revision: 6dccad7517f83a069d9bfbf761b648b0e50870c2

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

LOG: [lldb/Reproducers] (De)serialize char* like const char*

The current implementation has a discrepancy between how char pointers
are serialized and deserialized. The latter treats it like a const char*
while the former serializes it as a pointer to a basic type.

Both are potentially wrong, as char pointers are mostly used in
combination with a size, and nothing guarantees that the string's length
(its first null byte to be more precise) is greater or equal to its
size. The real solution is to have a custom (de)serializer that uses
both pieces of infromation.

However, the implementation should be consistent between serialization
and deserialization and I believe treating char* as const char* is the
better alternative.

Added: 
    

Modified: 
    lldb/include/lldb/Utility/ReproducerInstrumentation.h

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index 9039a7f1d162..bc28999221db 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -621,6 +621,8 @@ class Serializer {
     }
   }
 
+  void Serialize(char *t) { Serialize(static_cast<const char *>(t)); }
+
   void Serialize(const char **t) {
     size_t size = 0;
     if (!t) {


        


More information about the lldb-commits mailing list