[lldb/Reproducers] Include string length in string (de)serialization.
This allows us to differentiate between an empty string and a nullptr.
(cherry picked from commit 53e206284fa715886020d6a5553bf791582850a3)
diff --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index e91eb7f..b0424e4 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -602,8 +602,12 @@
}
void Serialize(const char *t) {
- m_stream << t;
- m_stream.write(0x0);
+ const size_t size = t ? strlen(t) : std::numeric_limits<size_t>::max();
+ Serialize(size);
+ if (t) {
+ m_stream << t;
+ m_stream.write(0x0);
+ }
}
void Serialize(const char **t) {
@@ -620,11 +624,8 @@
Serialize(size);
// Serialize the content of the array.
- while (*t) {
- m_stream << *t;
- m_stream.write(0x0);
- ++t;
- }
+ while (*t)
+ Serialize(*t++);
}
/// Serialization stream.