summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/NamedOptionValue.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-04-22 03:55:06 +0000
committerGreg Clayton <gclayton@apple.com>2011-04-22 03:55:06 +0000
commit385aa28cf6bb57d54e76e4e7c0c224b9fc7eb370 (patch)
tree86cc2c99275c79ca1be6d16c06412452a73af402 /lldb/source/Interpreter/NamedOptionValue.cpp
parentbafb9347ddfe01a8ee669e77d6e6c4dbe00be62f (diff)
downloadbcm5719-llvm-385aa28cf6bb57d54e76e4e7c0c224b9fc7eb370.tar.gz
bcm5719-llvm-385aa28cf6bb57d54e76e4e7c0c224b9fc7eb370.zip
Did some work on the "register read" command to only show the first register
set by default when dumping registers. If you want to see all of the register sets you can use the "--all" option: (lldb) register read --all If you want to just see some register sets, you can currently specify them by index: (lldb) register read --set 0 --set 2 We need to get shorter register set names soon so we can specify the register sets by name without having to type too much. I will make this change soon. You can also have any integer encoded registers resolve the address values back to any code or data from the object files using the "--lookup" option. Below is sample output when stopped in the libc function "puts" with some const strings in registers: Process 8973 stopped * thread #1: tid = 0x2c03, 0x00007fff828fa30f libSystem.B.dylib`puts + 1, stop reason = instruction step into frame #0: 0x00007fff828fa30f libSystem.B.dylib`puts + 1 (lldb) register read --lookup General Purpose Registers: rax = 0x0000000100000e98 "----------------------------------------------------------------------" rbx = 0x0000000000000000 rcx = 0x0000000000000001 rdx = 0x0000000000000000 rdi = 0x0000000100000e98 "----------------------------------------------------------------------" rsi = 0x0000000100800000 rbp = 0x00007fff5fbff710 rsp = 0x00007fff5fbff280 r8 = 0x0000000000000040 r9 = 0x0000000000000000 r10 = 0x0000000000000000 r11 = 0x0000000000000246 r12 = 0x0000000000000000 r13 = 0x0000000000000000 r14 = 0x0000000000000000 r15 = 0x0000000000000000 rip = 0x00007fff828fa30f libSystem.B.dylib`puts + 1 rflags = 0x0000000000000246 cs = 0x0000000000000027 fs = 0x0000000000000000 gs = 0x0000000000000000 As we can see, we see two constant strings and the PC (register "rip") is showing the code it resolves to. I fixed the register "--format" option to work as expected. Added a setting to disable skipping the function prologue when setting breakpoints as a target settings variable: (lldb) settings set target.skip-prologue false Updated the user settings controller boolean value handler funciton to be able to take the default value so it can correctly respond to the eVarSetOperationClear operation. Did some usability work on the OptionValue classes. Fixed the "image lookup" command to correctly respond to the "--verbose" option and display the detailed symbol context information when looking up line table entries and functions by name. This previously was only working for address lookups. llvm-svn: 129977
Diffstat (limited to 'lldb/source/Interpreter/NamedOptionValue.cpp')
-rw-r--r--lldb/source/Interpreter/NamedOptionValue.cpp104
1 files changed, 85 insertions, 19 deletions
diff --git a/lldb/source/Interpreter/NamedOptionValue.cpp b/lldb/source/Interpreter/NamedOptionValue.cpp
index 987ab472aaa..7c1284f8067 100644
--- a/lldb/source/Interpreter/NamedOptionValue.cpp
+++ b/lldb/source/Interpreter/NamedOptionValue.cpp
@@ -23,6 +23,29 @@ using namespace lldb_private;
//-------------------------------------------------------------------------
// OptionValue
//-------------------------------------------------------------------------
+
+// Get this value as a uint64_t value if it is encoded as a boolean,
+// uint64_t or int64_t. Other types will cause "fail_value" to be
+// returned
+uint64_t
+OptionValue::GetUInt64Value (uint64_t fail_value, bool *success_ptr)
+{
+ if (success_ptr)
+ *success_ptr = true;
+ switch (GetType())
+ {
+ case OptionValue::eTypeBoolean: return static_cast<OptionValueBoolean *>(this)->GetCurrentValue();
+ case OptionValue::eTypeSInt64: return static_cast<OptionValueSInt64 *>(this)->GetCurrentValue();
+ case OptionValue::eTypeUInt64: return static_cast<OptionValueUInt64 *>(this)->GetCurrentValue();
+ default:
+ break;
+ }
+ if (success_ptr)
+ *success_ptr = false;
+ return fail_value;
+}
+
+
OptionValueBoolean *
OptionValue::GetAsBooleanValue ()
{
@@ -105,17 +128,22 @@ OptionValueBoolean::DumpValue (Stream &strm)
strm.PutCString (m_current_value ? "true" : "false");
}
-bool
+Error
OptionValueBoolean::SetValueFromCString (const char *value_cstr)
{
+ Error error;
bool success = false;
bool value = Args::StringToBoolean(value_cstr, false, &success);
if (success)
{
+ m_value_was_set = true;
m_current_value = value;
- return true;
}
- return false;
+ else
+ {
+ error.SetErrorStringWithFormat ("invalid boolean string value: '%s'\n", value_cstr);
+ }
+ return error;
}
//-------------------------------------------------------------------------
@@ -127,39 +155,62 @@ OptionValueSInt64::DumpValue (Stream &strm)
strm.Printf ("%lli", m_current_value);
}
-bool
+Error
OptionValueSInt64::SetValueFromCString (const char *value_cstr)
{
+
+ Error error;
bool success = false;
int64_t value = Args::StringToSInt64 (value_cstr, 0, 0, &success);
if (success)
{
+ m_value_was_set = true;
m_current_value = value;
- return true;
}
- return false;
+ else
+ {
+ error.SetErrorStringWithFormat ("invalid int64_t string value: '%s'\n", value_cstr);
+ }
+ return error;
}
//-------------------------------------------------------------------------
// OptionValueUInt64
//-------------------------------------------------------------------------
+
+lldb::OptionValueSP
+OptionValueUInt64::Create (const char *value_cstr, Error &error)
+{
+ lldb::OptionValueSP value_sp (new OptionValueUInt64());
+ error = value_sp->SetValueFromCString (value_cstr);
+ if (error.Fail())
+ value_sp.reset();
+ return value_sp;
+}
+
+
void
OptionValueUInt64::DumpValue (Stream &strm)
{
strm.Printf ("0x%llx", m_current_value);
}
-bool
+Error
OptionValueUInt64::SetValueFromCString (const char *value_cstr)
{
+ Error error;
bool success = false;
uint64_t value = Args::StringToUInt64 (value_cstr, 0, 0, &success);
if (success)
{
+ m_value_was_set = true;
m_current_value = value;
- return true;
}
- return false;
+ else
+ {
+ error.SetErrorStringWithFormat ("invalid uint64_t string value: '%s'\n", value_cstr);
+ }
+ return error;
}
//-------------------------------------------------------------------------
@@ -171,11 +222,12 @@ OptionValueString::DumpValue (Stream &strm)
strm.Printf ("\"%s\"", m_current_value.c_str());
}
-bool
+Error
OptionValueString::SetValueFromCString (const char *value_cstr)
{
+ m_value_was_set = true;
SetCurrentValue (value_cstr);
- return true;
+ return Error ();
}
@@ -202,14 +254,15 @@ OptionValueFileSpec::DumpValue (Stream &strm)
}
}
-bool
+Error
OptionValueFileSpec::SetValueFromCString (const char *value_cstr)
{
if (value_cstr && value_cstr[0])
m_current_value.SetFile(value_cstr, false);
else
m_current_value.Clear();
- return true;
+ m_value_was_set = true;
+ return Error();
}
@@ -227,13 +280,25 @@ OptionValueArray::DumpValue (Stream &strm)
}
}
-bool
+Error
OptionValueArray::SetValueFromCString (const char *value_cstr)
{
- // We must be able to set this using the array specific functions
- return false;
+ Error error;
+ error.SetErrorStringWithFormat ("array option values don't yet support being set by string: '%s'\n", value_cstr);
+ return error;
}
+
+uint64_t
+OptionValueArray::GetUInt64ValueAtIndex (uint32_t idx, uint64_t fail_value, bool *success_ptr) const
+{
+ if (idx < m_values.size())
+ return m_values[idx]->GetUInt64Value (fail_value, success_ptr);
+ return fail_value;
+}
+
+
+
//-------------------------------------------------------------------------
// OptionValueDictionary
//-------------------------------------------------------------------------
@@ -249,11 +314,12 @@ OptionValueDictionary::DumpValue (Stream &strm)
}
}
-bool
+Error
OptionValueDictionary::SetValueFromCString (const char *value_cstr)
{
- // We must be able to set this using the array specific functions
- return false;
+ Error error;
+ error.SetErrorStringWithFormat ("dictionary option values don't yet support being set by string: '%s'\n", value_cstr);
+ return error;
}
lldb::OptionValueSP
OpenPOWER on IntegriCloud