From c727fe695d28799acb499e9961f11ec07d4f9fe2 Mon Sep 17 00:00:00 2001 From: emaste Date: Wed, 6 Nov 2013 16:48:53 +0000 Subject: Import lldb as of SVN r194122 Sponsored by: DARPA, AFRL --- source/Commands/CommandObjectMemory.cpp | 65 ++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 26 deletions(-) (limited to 'source/Commands/CommandObjectMemory.cpp') diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp index 4725a4d..2ee275e 100644 --- a/source/Commands/CommandObjectMemory.cpp +++ b/source/Commands/CommandObjectMemory.cpp @@ -12,6 +12,8 @@ #include "CommandObjectMemory.h" // C Includes +#include + // C++ Includes // Other libraries and framework includes // Project includes @@ -21,6 +23,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectMemory.h" +#include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -39,12 +42,12 @@ using namespace lldb_private; static OptionDefinition g_option_table[] = { - { LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, - { LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, - { LLDB_OPT_SET_3, true , "type" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, + { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, + { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, + { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, { LLDB_OPT_SET_1| LLDB_OPT_SET_2| - LLDB_OPT_SET_3, false, "force" ,'r', no_argument, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."}, + LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."}, }; @@ -648,7 +651,7 @@ protected: } else if (m_format_options.GetCountValue().OptionWasSet()) { - result.AppendErrorWithFormat("specify either the end address (0x%" PRIx64 ") or the count (--count %lu), not both.\n", end_addr, item_count); + result.AppendErrorWithFormat("specify either the end address (0x%" PRIx64 ") or the count (--count %zu), not both.\n", end_addr, item_count); result.SetStatus(eReturnStatusFailed); return false; } @@ -705,7 +708,7 @@ protected: } if (bytes_read < total_byte_size) - result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%" PRIx64 ".\n", bytes_read, total_byte_size, addr); + result.AppendWarningWithFormat("Not all bytes (%zu/%zu) were able to be read from 0x%" PRIx64 ".\n", bytes_read, total_byte_size, addr); } else { @@ -834,11 +837,9 @@ protected: if (format != eFormatDefault) valobj_sp->SetFormat (format); - ValueObject::DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(false,format)); + DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(eLanguageRuntimeDescriptionDisplayVerbosityFull,format)); - ValueObject::DumpValueObject (*output_stream, - valobj_sp.get(), - options); + valobj_sp->Dump(*output_stream,options); } else { @@ -859,16 +860,28 @@ protected: Format format = m_format_options.GetFormat(); if ( ( (format == eFormatChar) || (format == eFormatCharPrintable) ) - && (item_byte_size != 1) - && (item_count == 1)) + && (item_byte_size != 1)) { - // this turns requests such as - // memory read -fc -s10 -c1 *charPtrPtr - // which make no sense (what is a char of size 10?) - // into a request for fetching 10 chars of size 1 from the same memory location - format = eFormatCharArray; - item_count = item_byte_size; - item_byte_size = 1; + // if a count was not passed, or it is 1 + if (m_format_options.GetCountValue().OptionWasSet() == false || item_count == 1) + { + // this turns requests such as + // memory read -fc -s10 -c1 *charPtrPtr + // which make no sense (what is a char of size 10?) + // into a request for fetching 10 chars of size 1 from the same memory location + format = eFormatCharArray; + item_count = item_byte_size; + item_byte_size = 1; + } + else + { + // here we passed a count, and it was not 1 + // so we have a byte_size and a count + // we could well multiply those, but instead let's just fail + result.AppendErrorWithFormat("reading memory as characters of size %zu is not supported", item_byte_size); + result.SetStatus(eReturnStatusFailed); + return false; + } } assert (output_stream); @@ -905,8 +918,8 @@ protected: OptionDefinition g_memory_write_option_table[] = { -{ LLDB_OPT_SET_1, true, "infile", 'i', required_argument, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."}, -{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "Start writng bytes from an offset within the input file."}, +{ LLDB_OPT_SET_1, true, "infile", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeFilename, "Write memory using the contents of a file."}, +{ LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeOffset, "Start writng bytes from an offset within the input file."}, }; @@ -1219,7 +1232,7 @@ protected: } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %zu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1247,7 +1260,7 @@ protected: } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value 0x%" PRIx64 " is too large to fit in a %zu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1287,7 +1300,7 @@ protected: } else if (!SIntValueIsValidForSize (sval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %" PRIi64 " is too large or small to fit in a %lu byte signed integer value.\n", sval64, item_byte_size); + result.AppendErrorWithFormat ("Value %" PRIi64 " is too large or small to fit in a %zu byte signed integer value.\n", sval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1304,7 +1317,7 @@ protected: } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %" PRIu64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value %" PRIu64 " is too large to fit in a %zu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } @@ -1321,7 +1334,7 @@ protected: } else if (!UIntValueIsValidForSize (uval64, item_byte_size)) { - result.AppendErrorWithFormat ("Value %" PRIo64 " is too large to fit in a %lu byte unsigned integer value.\n", uval64, item_byte_size); + result.AppendErrorWithFormat ("Value %" PRIo64 " is too large to fit in a %zu byte unsigned integer value.\n", uval64, item_byte_size); result.SetStatus(eReturnStatusFailed); return false; } -- cgit v1.1