[Lldb-commits] [lldb] r280166 - Teach ValueObject::ReadPointedString how to read char[] in host memory
Enrico Granata via lldb-commits
lldb-commits at lists.llvm.org
Tue Aug 30 14:33:48 PDT 2016
Author: enrico
Date: Tue Aug 30 16:33:47 2016
New Revision: 280166
URL: http://llvm.org/viewvc/llvm-project?rev=280166&view=rev
Log:
Teach ValueObject::ReadPointedString how to read char[] in host memory
Modified:
lldb/trunk/source/Core/ValueObject.cpp
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=280166&r1=280165&r2=280166&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Aug 30 16:33:47 2016
@@ -1224,7 +1224,8 @@ ValueObject::ReadPointedString (lldb::Da
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::Da
if (cstr_address == 0 || cstr_address == LLDB_INVALID_ADDRESS)
{
- s << "<invalid address>";
- 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 << "<invalid address>";
+ error.SetErrorString("invalid address");
+ CopyStringDataToBufferSP(s, buffer_sp);
+ return {0,was_capped};
+ }
}
Address cstr_so_addr (cstr_address);
More information about the lldb-commits
mailing list