[Lldb-commits] [lldb] r131376 - in /lldb/trunk: include/lldb/Core/RegisterValue.h include/lldb/Interpreter/NamedOptionValue.h include/lldb/lldb-defines.h source/Commands/CommandObjectRegister.cpp source/Core/Debugger.cpp source/Core/EmulateInstruction.cpp source/Core/RegisterValue.cpp source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp tools/debugserver/source/DNBDefs.h tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
Greg Clayton
gclayton at apple.com
Sat May 14 21:12:08 PDT 2011
Author: gclayton
Date: Sat May 14 23:12:07 2011
New Revision: 131376
URL: http://llvm.org/viewvc/llvm-project?rev=131376&view=rev
Log:
Added generic register numbers for simple ABI argument registers and defined
the appropriate registers for arm and x86_64. The register names for the
arguments that are the size of a pointer or less are all named "arg1", "arg2",
etc. This allows you to read these registers by name:
(lldb) register read arg1 arg2 arg3
...
You can also now specify you want to see alternate register names when executing
the read register command:
(lldb) register read --alternate
(lldb) register read -A
Modified:
lldb/trunk/include/lldb/Core/RegisterValue.h
lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
lldb/trunk/include/lldb/lldb-defines.h
lldb/trunk/source/Commands/CommandObjectRegister.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/EmulateInstruction.cpp
lldb/trunk/source/Core/RegisterValue.cpp
lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
lldb/trunk/tools/debugserver/source/DNBDefs.h
lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
Modified: lldb/trunk/include/lldb/Core/RegisterValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RegisterValue.h (original)
+++ lldb/trunk/include/lldb/Core/RegisterValue.h Sat May 14 23:12:07 2011
@@ -334,7 +334,8 @@
Dump (Stream *s,
const RegisterInfo *reg_info,
bool prefix_with_name,
- lldb::Format format = lldb::eFormatDefault) const;
+ bool prefix_with_alt_name,
+ lldb::Format format) const;
void *
GetBytes ();
Modified: lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h (original)
+++ lldb/trunk/include/lldb/Interpreter/NamedOptionValue.h Sat May 14 23:12:07 2011
@@ -134,6 +134,12 @@
{
return m_value_was_set;
}
+
+ void
+ SetOptionWasSet ()
+ {
+ m_value_was_set = true;
+ }
protected:
bool m_value_was_set; // This can be used to see if a value has been set
Modified: lldb/trunk/include/lldb/lldb-defines.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-defines.h?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-defines.h (original)
+++ lldb/trunk/include/lldb/lldb-defines.h Sat May 14 23:12:07 2011
@@ -56,8 +56,15 @@
#define LLDB_REGNUM_GENERIC_FP 2 // Frame Pointer
#define LLDB_REGNUM_GENERIC_RA 3 // Return Address
#define LLDB_REGNUM_GENERIC_FLAGS 4 // Processor flags register
-
-//----------------------------------------------------------------------
+#define LLDB_REGNUM_GENERIC_ARG1 5 // The register that would contain pointer size or less argument 1 (if any)
+#define LLDB_REGNUM_GENERIC_ARG2 6 // The register that would contain pointer size or less argument 2 (if any)
+#define LLDB_REGNUM_GENERIC_ARG3 7 // The register that would contain pointer size or less argument 3 (if any)
+#define LLDB_REGNUM_GENERIC_ARG4 8 // The register that would contain pointer size or less argument 4 (if any)
+#define LLDB_REGNUM_GENERIC_ARG5 9 // The register that would contain pointer size or less argument 5 (if any)
+#define LLDB_REGNUM_GENERIC_ARG6 10 // The register that would contain pointer size or less argument 6 (if any)
+#define LLDB_REGNUM_GENERIC_ARG7 11 // The register that would contain pointer size or less argument 7 (if any)
+#define LLDB_REGNUM_GENERIC_ARG8 12 // The register that would contain pointer size or less argument 8 (if any)
+//---------------------------------------------------------------------
/// Invalid value definitions
//----------------------------------------------------------------------
#define LLDB_INVALID_ADDRESS UINT64_MAX
Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Sat May 14 23:12:07 2011
@@ -89,8 +89,9 @@
else
format = m_options.format;
- bool prefix_with_name = true;
- reg_value.Dump(&strm, reg_info, prefix_with_name, m_options.format);
+ bool prefix_with_altname = m_options.alternate_name;
+ bool prefix_with_name = !prefix_with_altname;
+ reg_value.Dump(&strm, reg_info, prefix_with_name, prefix_with_altname, m_options.format);
if (((reg_info->encoding == eEncodingUint) || (reg_info->encoding == eEncodingSint)) &&
(reg_info->byte_size == reg_ctx->GetThread().GetProcess().GetAddressByteSize()))
{
@@ -245,7 +246,8 @@
CommandOptions (CommandInterpreter &interpreter) :
Options(interpreter),
set_indexes (OptionValue::ConvertTypeToMask (OptionValue::eTypeUInt64)),
- dump_all_sets (false, false) // Initial and default values are false
+ dump_all_sets (false, false), // Initial and default values are false
+ alternate_name (false, false)
{
OptionParsingStarting();
}
@@ -275,9 +277,21 @@
break;
case 'a':
- dump_all_sets.SetCurrentValue(true);
+ // When we don't use OptionValue::SetValueFromCString(const char *) to
+ // set an option value, it won't be marked as being set in the options
+ // so we make a call to let users know the value was set via option
+ dump_all_sets.SetCurrentValue (true);
+ dump_all_sets.SetOptionWasSet ();
break;
+ case 'A':
+ // When we don't use OptionValue::SetValueFromCString(const char *) to
+ // set an option value, it won't be marked as being set in the options
+ // so we make a call to let users know the value was set via option
+ alternate_name.SetCurrentValue (true);
+ dump_all_sets.SetOptionWasSet ();
+ break;
+
default:
error.SetErrorStringWithFormat("Unrecognized short option '%c'\n", short_option);
break;
@@ -291,6 +305,7 @@
format = eFormatDefault;
set_indexes.Clear();
dump_all_sets.Clear();
+ alternate_name.Clear();
}
const OptionDefinition*
@@ -307,6 +322,7 @@
lldb::Format format;
OptionValueArray set_indexes;
OptionValueBoolean dump_all_sets;
+ OptionValueBoolean alternate_name;
};
CommandOptions m_options;
@@ -315,9 +331,10 @@
OptionDefinition
CommandObjectRegisterRead::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format to use when dumping register values."},
- { LLDB_OPT_SET_1 , false, "set" , 's', required_argument, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."},
- { LLDB_OPT_SET_2 , false, "all" , 'a', no_argument , NULL, 0, eArgTypeNone , "Show all register sets."},
+ { LLDB_OPT_SET_ALL, false, "format" , 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format to use when dumping register values."},
+ { LLDB_OPT_SET_ALL, false, "alternate", 'A', no_argument , NULL, 0, eArgTypeNone , "Display register names using the alternate register name if there is one."},
+ { LLDB_OPT_SET_1 , false, "set" , 's', required_argument, NULL, 0, eArgTypeIndex , "Specify which register sets to dump by index."},
+ { LLDB_OPT_SET_2 , false, "all" , 'a', no_argument , NULL, 0, eArgTypeNone , "Show all register sets."},
{ 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
};
Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Sat May 14 23:12:07 2011
@@ -1112,7 +1112,7 @@
var_success = reg_ctx->ReadRegister (reg_info, reg_value);
if (var_success)
{
- reg_value.Dump(&s, reg_info, false);
+ reg_value.Dump(&s, reg_info, false, false, eFormatDefault);
}
}
Modified: lldb/trunk/source/Core/EmulateInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/source/Core/EmulateInstruction.cpp (original)
+++ lldb/trunk/source/Core/EmulateInstruction.cpp Sat May 14 23:12:07 2011
@@ -421,7 +421,7 @@
{
StreamFile strm (stdout, false);
strm.Printf (" Write to Register (name = %s, value = " , reg_info->name);
- reg_value.Dump(&strm, reg_info, false);
+ reg_value.Dump(&strm, reg_info, false, false, eFormatDefault);
strm.PutCString (", context = ");
context.Dump (strm, instruction);
strm.EOL();
Modified: lldb/trunk/source/Core/RegisterValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/source/Core/RegisterValue.cpp (original)
+++ lldb/trunk/source/Core/RegisterValue.cpp Sat May 14 23:12:07 2011
@@ -24,13 +24,49 @@
bool
-RegisterValue::Dump (Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, Format format) const
+RegisterValue::Dump (Stream *s,
+ const RegisterInfo *reg_info,
+ bool prefix_with_name,
+ bool prefix_with_alt_name,
+ Format format) const
{
DataExtractor data;
if (GetData (data))
{
- if (prefix_with_name && reg_info->name != NULL)
- s->Printf ("%s = ", reg_info->name);
+ bool name_printed = false;
+ if (prefix_with_name)
+ {
+ if (reg_info->name)
+ {
+ s->Printf ("%s", reg_info->name);
+ name_printed = true;
+ }
+ else if (reg_info->alt_name)
+ {
+ s->Printf ("%s", reg_info->alt_name);
+ prefix_with_alt_name = false;
+ name_printed = true;
+ }
+ }
+ if (prefix_with_alt_name)
+ {
+ if (name_printed)
+ s->PutChar ('/');
+ if (reg_info->alt_name)
+ {
+ s->Printf ("%s", reg_info->alt_name);
+ name_printed = true;
+ }
+ else if (!name_printed)
+ {
+ // No alternate name but we were asked to display a name, so show the main name
+ s->Printf ("%s", reg_info->name);
+ name_printed = true;
+ }
+ }
+ if (name_printed)
+ s->PutCString (" = ");
+
if (format == eFormatDefault)
format = reg_info->format;
Modified: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original)
+++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Sat May 14 23:12:07 2011
@@ -412,7 +412,7 @@
StreamString strm;
strm.Printf ("UnwindAssemblyInstEmulation::ReadRegister (name = \"%s\") => synthetic_value = %i, value = ", reg_info->name, synthetic);
- reg_value.Dump(&strm, reg_info, false, eFormatDefault);
+ reg_value.Dump(&strm, reg_info, false, false, eFormatDefault);
log->PutCString(strm.GetData());
}
return true;
@@ -442,7 +442,7 @@
StreamString strm;
strm.Printf ("UnwindAssemblyInstEmulation::WriteRegister (name = \"%s\", value = ", reg_info->name);
- reg_value.Dump(&strm, reg_info, false, eFormatDefault);
+ reg_value.Dump(&strm, reg_info, false, false, eFormatDefault);
strm.PutCString (", context = ");
context.Dump(strm, instruction);
log->PutCString(strm.GetData());
Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/DNBDefs.h (original)
+++ lldb/trunk/tools/debugserver/source/DNBDefs.h Sat May 14 23:12:07 2011
@@ -163,6 +163,14 @@
#define GENERIC_REGNUM_FP 2 // Frame Pointer
#define GENERIC_REGNUM_RA 3 // Return Address
#define GENERIC_REGNUM_FLAGS 4 // Processor flags register
+#define GENERIC_REGNUM_ARG1 5 // The register that would contain pointer size or less argument 1 (if any)
+#define GENERIC_REGNUM_ARG2 6 // The register that would contain pointer size or less argument 2 (if any)
+#define GENERIC_REGNUM_ARG3 7 // The register that would contain pointer size or less argument 3 (if any)
+#define GENERIC_REGNUM_ARG4 8 // The register that would contain pointer size or less argument 4 (if any)
+#define GENERIC_REGNUM_ARG5 9 // The register that would contain pointer size or less argument 5 (if any)
+#define GENERIC_REGNUM_ARG6 10 // The register that would contain pointer size or less argument 6 (if any)
+#define GENERIC_REGNUM_ARG7 11 // The register that would contain pointer size or less argument 7 (if any)
+#define GENERIC_REGNUM_ARG8 12 // The register that would contain pointer size or less argument 8 (if any)
enum DNBRegisterType
{
Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Sat May 14 23:12:07 2011
@@ -2544,10 +2544,10 @@
const DNBRegisterInfo
DNBArchMachARM::g_gpr_registers[] =
{
- DEFINE_GPR_IDX ( 0, r0, NULL, INVALID_NUB_REGNUM ),
- DEFINE_GPR_IDX ( 1, r1, NULL, INVALID_NUB_REGNUM ),
- DEFINE_GPR_IDX ( 2, r2, NULL, INVALID_NUB_REGNUM ),
- DEFINE_GPR_IDX ( 3, r3, NULL, INVALID_NUB_REGNUM ),
+ DEFINE_GPR_IDX ( 0, r0,"arg1", GENERIC_REGNUM_ARG1 ),
+ DEFINE_GPR_IDX ( 1, r1,"arg2", GENERIC_REGNUM_ARG2 ),
+ DEFINE_GPR_IDX ( 2, r2,"arg3", GENERIC_REGNUM_ARG3 ),
+ DEFINE_GPR_IDX ( 3, r3,"arg4", GENERIC_REGNUM_ARG4 ),
DEFINE_GPR_IDX ( 4, r4, NULL, INVALID_NUB_REGNUM ),
DEFINE_GPR_IDX ( 5, r5, NULL, INVALID_NUB_REGNUM ),
DEFINE_GPR_IDX ( 6, r6, NULL, INVALID_NUB_REGNUM ),
@@ -2560,7 +2560,7 @@
DEFINE_GPR_NAME (sp, "r13", GENERIC_REGNUM_SP ),
DEFINE_GPR_NAME (lr, "r14", GENERIC_REGNUM_RA ),
DEFINE_GPR_NAME (pc, "r15", GENERIC_REGNUM_PC ),
- DEFINE_GPR_NAME (cpsr, NULL, GENERIC_REGNUM_FLAGS )
+ DEFINE_GPR_NAME (cpsr, "flags", GENERIC_REGNUM_FLAGS )
};
// Floating point registers
Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=131376&r1=131375&r2=131376&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Sat May 14 23:12:07 2011
@@ -819,6 +819,7 @@
#define DEFINE_GPR(reg) { e_regSetGPR, gpr_##reg, #reg, NULL, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), gcc_dwarf_##reg, gcc_dwarf_##reg, INVALID_NUB_REGNUM, gdb_##reg }
#define DEFINE_GPR_ALT(reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), gcc_dwarf_##reg, gcc_dwarf_##reg, gen, gdb_##reg }
#define DEFINE_GPR_ALT2(reg, alt) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, gdb_##reg }
+#define DEFINE_GPR_ALT3(reg, alt, gen) { e_regSetGPR, gpr_##reg, #reg, alt, Uint, Hex, GPR_SIZE(reg), GPR_OFFSET(reg), INVALID_NUB_REGNUM, INVALID_NUB_REGNUM, gen, gdb_##reg }
// General purpose registers for 64 bit
const DNBRegisterInfo
@@ -826,22 +827,22 @@
{
DEFINE_GPR (rax),
DEFINE_GPR (rbx),
- DEFINE_GPR (rcx),
- DEFINE_GPR (rdx),
- DEFINE_GPR (rdi),
- DEFINE_GPR (rsi),
- DEFINE_GPR_ALT (rbp, "fp", GENERIC_REGNUM_FP),
- DEFINE_GPR_ALT (rsp, "sp", GENERIC_REGNUM_SP),
- DEFINE_GPR (r8),
- DEFINE_GPR (r9),
+ DEFINE_GPR_ALT (rcx , "arg4", GENERIC_REGNUM_ARG4),
+ DEFINE_GPR_ALT (rdx , "arg3", GENERIC_REGNUM_ARG3),
+ DEFINE_GPR_ALT (rdi , "arg1", GENERIC_REGNUM_ARG1),
+ DEFINE_GPR_ALT (rsi , "arg2", GENERIC_REGNUM_ARG2),
+ DEFINE_GPR_ALT (rbp , "fp" , GENERIC_REGNUM_FP),
+ DEFINE_GPR_ALT (rsp , "sp" , GENERIC_REGNUM_SP),
+ DEFINE_GPR_ALT (r8 , "arg5", GENERIC_REGNUM_ARG5),
+ DEFINE_GPR_ALT (r9 , "arg6", GENERIC_REGNUM_ARG6),
DEFINE_GPR (r10),
DEFINE_GPR (r11),
DEFINE_GPR (r12),
DEFINE_GPR (r13),
DEFINE_GPR (r14),
DEFINE_GPR (r15),
- DEFINE_GPR_ALT (rip, "pc", GENERIC_REGNUM_PC),
- DEFINE_GPR_ALT2 (rflags, "flags"),
+ DEFINE_GPR_ALT (rip , "pc", GENERIC_REGNUM_PC),
+ DEFINE_GPR_ALT3 (rflags, "flags", GENERIC_REGNUM_FLAGS),
DEFINE_GPR_ALT2 (cs, NULL),
DEFINE_GPR_ALT2 (fs, NULL),
DEFINE_GPR_ALT2 (gs, NULL),
More information about the lldb-commits
mailing list