From b9bddc4c7feffb49202ac9a96ae6bb550733f951 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 30 Aug 2016 21:33:47 +0000 Subject: [PATCH] Teach ValueObject::ReadPointedString how to read char[] in host memory llvm-svn: 280166 --- lldb/source/Core/ValueObject.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 3e0a318..609c518 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1224,7 +1224,8 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp, size_t cstr_len = 0; bool capped_data = false; - if (type_flags.Test (eTypeIsArray)) + const bool is_array = type_flags.Test (eTypeIsArray); + if (is_array) { // We have an array uint64_t array_size = 0; @@ -1247,10 +1248,20 @@ ValueObject::ReadPointedString (lldb::DataBufferSP& buffer_sp, if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS) { - s << ""; - error.SetErrorString("invalid address"); - CopyStringDataToBufferSP(s, buffer_sp); - return {0,was_capped}; + if (cstr_address_type == eAddressTypeHost && is_array) + { + const char* cstr = GetDataExtractor().PeekCStr(0); + buffer_sp.reset(new DataBufferHeap(cstr_len, 0)); + memcpy(buffer_sp->GetBytes(), cstr, cstr_len); + return {cstr_len,was_capped}; + } + else + { + s << ""; + error.SetErrorString("invalid address"); + CopyStringDataToBufferSP(s, buffer_sp); + return {0,was_capped}; + } } Address cstr_so_addr (cstr_address); -- 2.7.4