[Lldb-commits] [lldb] r143015 - in /lldb/trunk: include/lldb/Interpreter/OptionGroupFormat.h include/lldb/Interpreter/OptionGroupOutputFile.h include/lldb/Interpreter/OptionGroupValueObjectDisplay.h source/Commands/CommandObjectMemory.cpp source/Interpreter/OptionGroupFormat.cpp source/Interpreter/OptionGroupValueObjectDisplay.cpp
Greg Clayton
gclayton at apple.com
Tue Oct 25 21:32:38 PDT 2011
Author: gclayton
Date: Tue Oct 25 23:32:38 2011
New Revision: 143015
URL: http://llvm.org/viewvc/llvm-project?rev=143015&view=rev
Log:
A simple fix for the GDB format strings so the byte size parameter gets
properly marked as valid.
Also modified the "memory read" command to be able to intelligently repeat
subsequent memory requests, so now you can do:
(lldb) memory read --format hex --count 32 0x1000
Then hit enter to keep viewing the memory that follows the last valid request.
Modified:
lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h
lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupFormat.h Tue Oct 25 23:32:38 2011
@@ -94,6 +94,14 @@
return m_count;
}
+
+ bool
+ AnyOptionWasSet () const
+ {
+ return m_format.OptionWasSet() ||
+ m_byte_size.OptionWasSet() ||
+ m_count.OptionWasSet();
+ }
protected:
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupOutputFile.h Tue Oct 25 23:32:38 2011
@@ -57,6 +57,12 @@
{
return m_append;
}
+
+ bool
+ AnyOptionWasSet () const
+ {
+ return m_file.OptionWasSet() || m_append.OptionWasSet();
+ }
protected:
OptionValueFileSpec m_file;
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h Tue Oct 25 23:32:38 2011
@@ -46,6 +46,21 @@
virtual void
OptionParsingStarting (CommandInterpreter &interpreter);
+ bool
+ AnyOptionWasSet () const
+ {
+ return show_types == true ||
+ no_summary_depth != 0 ||
+ show_location == true ||
+ flat_output == true ||
+ use_objc == true ||
+ max_depth != UINT32_MAX ||
+ ptr_depth != 0 ||
+ use_synth == false ||
+ be_raw == true ||
+ ignore_cap == true;
+ }
+
bool show_types;
uint32_t no_summary_depth;
bool show_location;
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Oct 25 23:32:38 2011
@@ -242,6 +242,14 @@
return error;
}
+ bool
+ AnyOptionWasSet () const
+ {
+ return m_num_per_line.OptionWasSet() ||
+ m_output_as_binary ||
+ m_view_as_type.OptionWasSet();
+ }
+
OptionValueUInt64 m_num_per_line;
bool m_output_as_binary;
OptionValueString m_view_as_type;
@@ -266,7 +274,13 @@
m_format_options (eFormatBytesWithASCII, 1, 8),
m_memory_options (),
m_outfile_options (),
- m_varobj_options()
+ m_varobj_options(),
+ m_next_addr(LLDB_INVALID_ADDRESS),
+ m_prev_byte_size(0),
+ m_prev_format_options (eFormatBytesWithASCII, 1, 8),
+ m_prev_memory_options (),
+ m_prev_outfile_options (),
+ m_prev_varobj_options()
{
CommandArgumentEntry arg1;
CommandArgumentEntry arg2;
@@ -316,6 +330,11 @@
return &m_option_group;
}
+ virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index)
+ {
+ return m_cmd_name.c_str();
+ }
+
virtual bool
Execute (Args& command,
CommandReturnObject &result)
@@ -331,7 +350,7 @@
const size_t argc = command.GetArgumentCount();
- if (argc == 0 || argc > 2)
+ if ((argc == 0 && m_next_addr == LLDB_INVALID_ADDRESS) || argc > 2)
{
result.AppendErrorWithFormat ("%s takes 1 or two args.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -486,15 +505,39 @@
return false;
}
+ lldb::addr_t addr;
+ size_t total_byte_size = 0;
+ if (argc == 0)
+ {
+ // Use the last address and byte size and all options as they were
+ // if no options have been set
+ addr = m_next_addr;
+ total_byte_size = m_prev_byte_size;
+ if (!m_format_options.AnyOptionWasSet() &&
+ !m_memory_options.AnyOptionWasSet() &&
+ !m_outfile_options.AnyOptionWasSet() &&
+ !m_varobj_options.AnyOptionWasSet())
+ {
+ m_format_options = m_prev_format_options;
+ m_memory_options = m_prev_memory_options;
+ m_outfile_options = m_prev_outfile_options;
+ m_varobj_options = m_prev_varobj_options;
+ }
+ }
+
size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
const size_t item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
const size_t num_per_line = m_memory_options.m_num_per_line.GetCurrentValue();
- size_t total_byte_size = item_count * item_byte_size;
if (total_byte_size == 0)
- total_byte_size = 32;
+ {
+ total_byte_size = item_count * item_byte_size;
+ if (total_byte_size == 0)
+ total_byte_size = 32;
+ }
- lldb::addr_t addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0);
+ if (argc > 0)
+ addr = Args::StringToUInt64(command.GetArgumentAtIndex(0), LLDB_INVALID_ADDRESS, 0);
if (addr == LLDB_INVALID_ADDRESS)
{
@@ -546,6 +589,15 @@
if (bytes_read < total_byte_size)
result.AppendWarningWithFormat("Not all bytes (%lu/%lu) were able to be read from 0x%llx.\n", bytes_read, total_byte_size, addr);
+ else
+ {
+ m_next_addr = addr + bytes_read;
+ m_prev_byte_size = bytes_read;
+ m_prev_format_options = m_format_options;
+ m_prev_memory_options = m_memory_options;
+ m_prev_outfile_options = m_outfile_options;
+ m_prev_varobj_options = m_varobj_options;
+ }
}
StreamFile outfile_stream;
@@ -674,7 +726,12 @@
OptionGroupReadMemory m_memory_options;
OptionGroupOutputFile m_outfile_options;
OptionGroupValueObjectDisplay m_varobj_options;
-
+ lldb::addr_t m_next_addr;
+ lldb::addr_t m_prev_byte_size;
+ OptionGroupFormat m_prev_format_options;
+ OptionGroupReadMemory m_prev_memory_options;
+ OptionGroupOutputFile m_prev_outfile_options;
+ OptionGroupValueObjectDisplay m_prev_varobj_options;
};
Modified: lldb/trunk/source/Interpreter/OptionGroupFormat.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupFormat.cpp?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupFormat.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupFormat.cpp Tue Oct 25 23:32:38 2011
@@ -123,7 +123,7 @@
++gdb_format_cstr;
uint32_t byte_size = SetByteSizeUsingGDBSizeLetter (gdb_format_cstr[0]);
- if (byte_size == 0)
+ if (byte_size > 0)
++gdb_format_cstr;
// We the first character of the "gdb_format_cstr" is not the
Modified: lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp?rev=143015&r1=143014&r2=143015&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionGroupValueObjectDisplay.cpp Tue Oct 25 23:32:38 2011
@@ -124,6 +124,7 @@
void
OptionGroupValueObjectDisplay::OptionParsingStarting (CommandInterpreter &interpreter)
{
+ // If these defaults change, be sure to modify AnyOptionWasSet().
show_types = false;
no_summary_depth = 0;
show_location = false;
More information about the lldb-commits
mailing list