diff options
Diffstat (limited to 'source/Commands/CommandObjectMemory.cpp')
-rw-r--r-- | source/Commands/CommandObjectMemory.cpp | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp index dac6dd8..d589800 100644 --- a/source/Commands/CommandObjectMemory.cpp +++ b/source/Commands/CommandObjectMemory.cpp @@ -7,8 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-python.h" - #include "CommandObjectMemory.h" // C Includes @@ -16,6 +14,7 @@ // C++ Includes // Other libraries and framework includes +#include "clang/AST/Decl.h" // Project includes #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" @@ -24,6 +23,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" +#include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -95,7 +95,7 @@ public: switch (short_option) { case 'l': - error = m_num_per_line.SetValueFromCString (option_arg); + error = m_num_per_line.SetValueFromString (option_arg); if (m_num_per_line.GetCurrentValue() == 0) error.SetErrorStringWithFormat("invalid value for --num-per-line option '%s'", option_arg); break; @@ -105,7 +105,7 @@ public: break; case 't': - error = m_view_as_type.SetValueFromCString (option_arg); + error = m_view_as_type.SetValueFromString (option_arg); break; case 'r': @@ -313,7 +313,7 @@ public: "memory read", "Read from the memory of the process being debugged.", NULL, - eFlagRequiresTarget | eFlagProcessMustBePaused), + eCommandRequiresTarget | eCommandProcessMustBePaused), m_option_group (interpreter), m_format_options (eFormatBytesWithASCII, 1, 8), m_memory_options (), @@ -386,7 +386,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "target" for validity as eFlagRequiresTarget ensures it is valid + // No need to check "target" for validity as eCommandRequiresTarget ensures it is valid Target *target = m_exe_ctx.GetTargetPtr(); const size_t argc = command.GetArgumentCount(); @@ -532,7 +532,7 @@ protected: clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name)); if (tdecl) { - clang_ast_type.SetClangType(&tdecl->getASTContext(),(lldb::clang_type_t)tdecl->getTypeForDecl()); + clang_ast_type.SetClangType(&tdecl->getASTContext(),(const lldb::clang_type_t)tdecl->getTypeForDecl()); } } @@ -742,6 +742,7 @@ protected: auto data_addr = addr; auto count = item_count; item_count = 0; + bool break_on_no_NULL = false; while (item_count < count) { std::string buffer; @@ -754,17 +755,24 @@ protected: result.SetStatus(eReturnStatusFailed); return false; } + if (item_byte_size == read) { result.AppendWarningWithFormat("unable to find a NULL terminated string at 0x%" PRIx64 ".Consider increasing the maximum read length.\n", data_addr); - break; + --read; + break_on_no_NULL = true; } - read+=1; // account for final NULL byte + else + ++read; // account for final NULL byte + memcpy(data_ptr, &buffer[0], read); data_ptr += read; data_addr += read; bytes_read += read; item_count++; // if we break early we know we only read item_count strings + + if (break_on_no_NULL) + break; } data_sp.reset(new DataBufferHeap(data_sp->GetBytes(),bytes_read+1)); } @@ -981,20 +989,20 @@ public: switch (short_option) { case 'e': - m_expr.SetValueFromCString(option_arg); + m_expr.SetValueFromString(option_arg); break; case 's': - m_string.SetValueFromCString(option_arg); + m_string.SetValueFromString(option_arg); break; case 'c': - if (m_count.SetValueFromCString(option_arg).Fail()) + if (m_count.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for count"); break; case 'o': - if (m_offset.SetValueFromCString(option_arg).Fail()) + if (m_offset.SetValueFromString(option_arg).Fail()) error.SetErrorString("unrecognized value for dump-offset"); break; @@ -1024,7 +1032,7 @@ public: "memory find", "Find a value in the memory of the process being debugged.", NULL, - eFlagRequiresProcess | eFlagProcessMustBeLaunched), + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_memory_options () { @@ -1070,7 +1078,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid + // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); @@ -1325,7 +1333,7 @@ public: "memory write", "Write to the memory of the process being debugged.", NULL, - eFlagRequiresProcess | eFlagProcessMustBeLaunched), + eCommandRequiresProcess | eCommandProcessMustBeLaunched), m_option_group (interpreter), m_format_options (eFormatBytes, 1, UINT64_MAX), m_memory_options () @@ -1402,7 +1410,7 @@ protected: virtual bool DoExecute (Args& command, CommandReturnObject &result) { - // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid + // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); @@ -1692,7 +1700,7 @@ public: "memory history", "Prints out the recorded stack traces for allocation/deallocation of a memory address.", NULL, - eFlagRequiresTarget | eFlagRequiresProcess | eFlagProcessMustBePaused | eFlagProcessMustBeLaunched) + eCommandRequiresTarget | eCommandRequiresProcess | eCommandProcessMustBePaused | eCommandProcessMustBeLaunched) { CommandArgumentEntry arg1; CommandArgumentData addr_arg; |