summaryrefslogtreecommitdiff
path: root/lldb/source/API/SBStructuredData.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2020-02-05 19:41:09 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2020-02-05 19:59:38 -0800
commit2f025bb87c33a25e3a0d226cdb663f237ccd602e (patch)
tree0fcb39e09e61df8790ddc762983dca510e88cab4 /lldb/source/API/SBStructuredData.cpp
parent25aa2eef993e17708889abf56ed1ffad5074a9f4 (diff)
[lldb/Reproducers] Implement custom replayers for (char *, size_t)
Some SB API methods returns strings through a char* and a length. This is a problem for the deserializer, which considers a single type at a time, and therefore cannot know how many bytes to allocate for the character buffer. We can solve this problem by implementing a custom replayer, which ignores the passed-in char* and allocates a buffer of the correct size itself, before invoking the original API method or function. This patch adds three new macros to register a custom replayer for methods that take a char* and a size_t. It supports arbitrary return values (some functions return a bool while others return a size_t).
Diffstat (limited to 'lldb/source/API/SBStructuredData.cpp')
-rw-r--r--lldb/source/API/SBStructuredData.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp
index c9a8e0a3e849..bc820ba7e2ef 100644
--- a/lldb/source/API/SBStructuredData.cpp
+++ b/lldb/source/API/SBStructuredData.cpp
@@ -205,11 +205,9 @@ size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
namespace lldb_private {
namespace repro {
-template <>
-void RegisterMethods<SBStructuredData>(Registry &R) {
+template <> void RegisterMethods<SBStructuredData>(Registry &R) {
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ());
- LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
- (const lldb::SBStructuredData &));
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &));
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &));
LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
(lldb_private::StructuredDataImpl *));
@@ -236,12 +234,11 @@ void RegisterMethods<SBStructuredData>(Registry &R) {
GetItemAtIndex, (size_t));
LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue,
(uint64_t));
- LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue,
- (double));
+ LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double));
LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool));
- LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
- (char *, size_t));
+ LLDB_REGISTER_CHAR_PTR_REDIRECT_CONST(size_t, SBStructuredData,
+ GetStringValue);
}
-}
-}
+} // namespace repro
+} // namespace lldb_private