From 81409635e0e766371baeea7da805ff73c6c922df Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sat, 15 Dec 2012 01:44:51 +0000 Subject: [PATCH] x/a print wouldn't always reset the word size to the size of a pointer if a previous memory read using x/ had been used that set it to another width. llvm-svn: 170264 --- lldb/include/lldb/Interpreter/OptionGroupFormat.h | 5 ++++- lldb/source/Interpreter/OptionGroupFormat.cpp | 22 +++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lldb/include/lldb/Interpreter/OptionGroupFormat.h b/lldb/include/lldb/Interpreter/OptionGroupFormat.h index 234b38c..b721644 100644 --- a/lldb/include/lldb/Interpreter/OptionGroupFormat.h +++ b/lldb/include/lldb/Interpreter/OptionGroupFormat.h @@ -109,7 +109,10 @@ public: protected: bool - ParserGDBFormatLetter (char format_letter, lldb::Format &format, uint32_t &byte_size); + ParserGDBFormatLetter (CommandInterpreter &interpreter, + char format_letter, + lldb::Format &format, + uint32_t &byte_size); OptionValueFormat m_format; OptionValueUInt64 m_byte_size; diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp index 795fb03..226f5a1 100644 --- a/lldb/source/Interpreter/OptionGroupFormat.cpp +++ b/lldb/source/Interpreter/OptionGroupFormat.cpp @@ -13,6 +13,10 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/ArchSpec.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Target.h" #include "lldb/Utility/Utils.h" using namespace lldb; @@ -119,7 +123,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, Format format = eFormatDefault; uint32_t byte_size = 0; - while (ParserGDBFormatLetter (gdb_format_cstr[0], format, byte_size)) + while (ParserGDBFormatLetter (interpreter, gdb_format_cstr[0], format, byte_size)) { ++gdb_format_cstr; } @@ -139,7 +143,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, // Anything that wasn't set correctly should be set to the // previous default if (format == eFormatInvalid) - ParserGDBFormatLetter (m_prev_gdb_format, format, byte_size); + ParserGDBFormatLetter (interpreter, m_prev_gdb_format, format, byte_size); const bool byte_size_enabled = m_byte_size.GetDefaultValue() < UINT64_MAX; const bool count_enabled = m_count.GetDefaultValue() < UINT64_MAX; @@ -147,7 +151,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, { // Byte size is enabled if (byte_size == 0) - ParserGDBFormatLetter (m_prev_gdb_size, format, byte_size); + ParserGDBFormatLetter (interpreter, m_prev_gdb_size, format, byte_size); } else { @@ -199,7 +203,7 @@ OptionGroupFormat::SetOptionValue (CommandInterpreter &interpreter, } bool -OptionGroupFormat::ParserGDBFormatLetter (char format_letter, Format &format, uint32_t &byte_size) +OptionGroupFormat::ParserGDBFormatLetter (CommandInterpreter &interpreter, char format_letter, Format &format, uint32_t &byte_size) { switch (format_letter) { @@ -209,7 +213,15 @@ OptionGroupFormat::ParserGDBFormatLetter (char format_letter, Format &format, ui case 'u': format = eFormatUnsigned; m_prev_gdb_format = format_letter; return true; case 't': format = eFormatBinary; m_prev_gdb_format = format_letter; return true; case 'f': format = eFormatFloat; m_prev_gdb_format = format_letter; return true; - case 'a': format = eFormatAddressInfo; m_prev_gdb_format = format_letter; return true; + case 'a': format = eFormatAddressInfo; + { + ExecutionContext exe_ctx(interpreter.GetExecutionContext()); + Target *target = exe_ctx.GetTargetPtr(); + if (target) + byte_size = target->GetArchitecture().GetAddressByteSize(); + m_prev_gdb_format = format_letter; + return true; + } case 'i': format = eFormatInstruction; m_prev_gdb_format = format_letter; return true; case 'c': format = eFormatChar; m_prev_gdb_format = format_letter; return true; case 's': format = eFormatCString; m_prev_gdb_format = format_letter; return true; -- 2.7.4