summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectArgs.cpp1
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp8
-rw-r--r--lldb/source/Commands/CommandObjectBreakpointCommand.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp6
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.cpp166
-rw-r--r--lldb/source/Commands/CommandObjectDisassemble.h17
-rw-r--r--lldb/source/Commands/CommandObjectExpression.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectFile.cpp1
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectImage.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectLog.cpp1
-rw-r--r--lldb/source/Commands/CommandObjectMemory.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp305
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp15
-rw-r--r--lldb/source/Commands/CommandObjectRegister.cpp75
-rw-r--r--lldb/source/Commands/CommandObjectSettings.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp4
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp3
18 files changed, 493 insertions, 124 deletions
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp
index 6810b45300c..f75ac0b17ab 100644
--- a/lldb/source/Commands/CommandObjectArgs.cpp
+++ b/lldb/source/Commands/CommandObjectArgs.cpp
@@ -68,7 +68,6 @@ CommandObjectArgs::CommandOptions::SetOptionValue (int option_idx, const char *o
void
CommandObjectArgs::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
}
const OptionDefinition*
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index 6bf408b2460..8208ea8123c 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -235,8 +235,6 @@ CommandObjectBreakpointSet::CommandOptions::SetOptionValue (int option_idx, cons
void
CommandObjectBreakpointSet::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_filename.clear();
m_line_num = 0;
m_column = 0;
@@ -706,8 +704,6 @@ CommandObjectBreakpointList::CommandOptions::SetOptionValue (int option_idx, con
void
CommandObjectBreakpointList::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_level = lldb::eDescriptionLevelBrief;
m_internal = false;
}
@@ -1105,8 +1101,6 @@ CommandObjectBreakpointClear::CommandOptions::SetOptionValue (int option_idx, co
void
CommandObjectBreakpointClear::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_filename.clear();
m_line_num = 0;
}
@@ -1485,8 +1479,6 @@ CommandObjectBreakpointModify::CommandOptions::SetOptionValue (int option_idx, c
void
CommandObjectBreakpointModify::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_ignore_count = 0;
m_thread_id = LLDB_INVALID_THREAD_ID;
m_thread_id_passed = false;
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 3af812c2d91..c3d50ea0209 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -135,8 +135,6 @@ CommandObjectBreakpointCommandAdd::CommandOptions::SetOptionValue
void
CommandObjectBreakpointCommandAdd::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_use_commands = true;
m_use_script_language = false;
m_script_language = eScriptLanguageNone;
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 49fc0222bbd..b3a974b538e 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -69,8 +69,6 @@ private:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
-
m_stop_on_error = true;
m_stop_on_continue = true;
}
@@ -358,7 +356,7 @@ public:
if (options)
{
// See if any options were specified as part of the alias; if so, handle them appropriately
- options->ResetOptionValues ();
+ options->Reset ();
Args tmp_args (raw_command_string.c_str());
args.Unshift ("dummy_arg");
args.ParseAliasOptions (*options, result, option_arg_vector, raw_command_string);
@@ -489,7 +487,7 @@ public:
options = sub_cmd_obj->GetOptions();
else
options = cmd_obj->GetOptions();
- options->ResetOptionValues ();
+ options->Reset ();
std::string empty_string;
args.Unshift ("dummy_arg");
args.ParseAliasOptions (*options, result, option_arg_vector, empty_string);
diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp
index 74c27e39090..6567a0896a9 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.cpp
+++ b/lldb/source/Commands/CommandObjectDisassemble.cpp
@@ -36,12 +36,13 @@ CommandObjectDisassemble::CommandOptions::CommandOptions () :
Options(),
num_lines_context(0),
num_instructions (0),
- m_func_name(),
- m_start_addr(),
- m_end_addr (),
- m_at_pc (false),
- m_plugin_name (),
- m_arch()
+ func_name(),
+ start_addr(),
+ end_addr (),
+ at_pc (false),
+ frame_line (false),
+ plugin_name (),
+ arch()
{
ResetOptionValues();
}
@@ -82,32 +83,39 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const
break;
case 's':
- m_start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
- if (m_start_addr == LLDB_INVALID_ADDRESS)
- m_start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
+ start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
+ if (start_addr == LLDB_INVALID_ADDRESS)
+ start_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
- if (m_start_addr == LLDB_INVALID_ADDRESS)
+ if (start_addr == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat ("Invalid start address string '%s'.\n", option_arg);
break;
case 'e':
- m_end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
- if (m_end_addr == LLDB_INVALID_ADDRESS)
- m_end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
+ end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 0);
+ if (end_addr == LLDB_INVALID_ADDRESS)
+ end_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS, 16);
- if (m_end_addr == LLDB_INVALID_ADDRESS)
+ if (end_addr == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat ("Invalid end address string '%s'.\n", option_arg);
break;
case 'n':
- m_func_name.assign (option_arg);
+ func_name.assign (option_arg);
break;
case 'p':
- m_at_pc = true;
+ at_pc = true;
+ break;
+
+ case 'l':
+ frame_line = true;
+ // Disassemble the current source line kind of implies showing mixed
+ // source code context.
+ show_mixed = true;
break;
case 'P':
- m_plugin_name.assign (option_arg);
+ plugin_name.assign (option_arg);
break;
case 'r':
@@ -120,7 +128,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const
break;
case 'a':
- m_arch.SetTriple (option_arg);
+ arch.SetTriple (option_arg);
break;
default:
@@ -134,18 +142,18 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const
void
CommandObjectDisassemble::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
show_mixed = false;
show_bytes = false;
num_lines_context = 0;
num_instructions = 0;
- m_func_name.clear();
- m_at_pc = false;
- m_start_addr = LLDB_INVALID_ADDRESS;
- m_end_addr = LLDB_INVALID_ADDRESS;
+ func_name.clear();
+ at_pc = false;
+ frame_line = false;
+ start_addr = LLDB_INVALID_ADDRESS;
+ end_addr = LLDB_INVALID_ADDRESS;
raw = false;
- m_plugin_name.clear();
- m_arch.Clear();
+ plugin_name.clear();
+ arch.Clear();
}
const OptionDefinition*
@@ -172,7 +180,8 @@ CommandObjectDisassemble::CommandOptions::g_option_table[] =
LLDB_OPT_SET_5 , false , "count", 'c', required_argument , NULL, 0, eArgTypeNumLines, "Number of instructions to display."},
{ LLDB_OPT_SET_3 , true , "name", 'n', required_argument , NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Disassemble entire contents of the given function name."},
{ LLDB_OPT_SET_4 , true , "frame", 'f', no_argument , NULL, 0, eArgTypeNone, "Disassemble from the start of the current frame's function."},
-{ LLDB_OPT_SET_5 , true , "pc", 'p', no_argument , NULL, 0, eArgTypeNone, "Disassemble from the current pc."},
+{ LLDB_OPT_SET_5 , true , "pc", 'p', no_argument , NULL, 0, eArgTypeNone, "Disassemble around the current pc."},
+{ LLDB_OPT_SET_6 , true , "line", 'l', no_argument , NULL, 0, eArgTypeNone, "Disassemble the current frame's current source line instructions if there debug line table information, else disasemble around the pc."},
{ 0 , false , NULL, 0, 0 , NULL, 0, eArgTypeNone, NULL }
};
@@ -208,10 +217,10 @@ CommandObjectDisassemble::Execute
result.SetStatus (eReturnStatusFailed);
return false;
}
- if (!m_options.m_arch.IsValid())
- m_options.m_arch = target->GetArchitecture();
+ if (!m_options.arch.IsValid())
+ m_options.arch = target->GetArchitecture();
- if (!m_options.m_arch.IsValid())
+ if (!m_options.arch.IsValid())
{
result.AppendError ("use the --arch option or set the target architecure to disassemble");
result.SetStatus (eReturnStatusFailed);
@@ -219,17 +228,17 @@ CommandObjectDisassemble::Execute
}
const char *plugin_name = m_options.GetPluginName ();
- Disassembler *disassembler = Disassembler::FindPlugin(m_options.m_arch, plugin_name);
+ Disassembler *disassembler = Disassembler::FindPlugin(m_options.arch, plugin_name);
if (disassembler == NULL)
{
if (plugin_name)
result.AppendErrorWithFormat ("Unable to find Disassembler plug-in named '%s' that supports the '%s' architecture.\n",
plugin_name,
- m_options.m_arch.GetArchitectureName());
+ m_options.arch.GetArchitectureName());
else
result.AppendErrorWithFormat ("Unable to find Disassembler plug-in for the '%s' architecture.\n",
- m_options.m_arch.GetArchitectureName());
+ m_options.arch.GetArchitectureName());
result.SetStatus (eReturnStatusFailed);
return false;
}
@@ -252,12 +261,12 @@ CommandObjectDisassemble::Execute
ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
- if (!m_options.m_func_name.empty())
+ if (!m_options.func_name.empty())
{
- ConstString name(m_options.m_func_name.c_str());
+ ConstString name(m_options.func_name.c_str());
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
- m_options.m_arch,
+ m_options.arch,
plugin_name,
exe_ctx,
name,
@@ -278,59 +287,76 @@ CommandObjectDisassemble::Execute
}
else
{
- Address start_addr;
- lldb::addr_t range_byte_size = DEFAULT_DISASM_BYTE_SIZE;
-
- if (m_options.m_at_pc)
+ AddressRange range;
+ if (m_options.frame_line)
{
- if (exe_ctx.frame == NULL)
+ LineEntry pc_line_entry (exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
+ if (pc_line_entry.IsValid())
{
- result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n");
- result.SetStatus (eReturnStatusFailed);
- return false;
+ range = pc_line_entry.range;
}
- start_addr = exe_ctx.frame->GetFrameCodeAddress();
- if (m_options.num_instructions == 0)
+ else
{
- // Disassembling at the PC always disassembles some number of instructions (not the whole function).
- m_options.num_instructions = DEFAULT_DISASM_NUM_INS;
+ m_options.at_pc = true; // No line entry, so just disassemble around the current pc
+ m_options.show_mixed = false;
}
}
- else
+
+ // Did the "m_options.frame_line" find a valid range already? If so
+ // skip the rest...
+ if (range.GetByteSize() == 0)
{
- start_addr.SetOffset (m_options.m_start_addr);
- if (start_addr.IsValid())
+ if (m_options.at_pc)
{
- if (m_options.m_end_addr != LLDB_INVALID_ADDRESS)
+ if (exe_ctx.frame == NULL)
{
- if (m_options.m_end_addr < m_options.m_start_addr)
+ result.AppendError ("Cannot disassemble around the current PC without a selected frame.\n");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
+ if (m_options.num_instructions == 0)
+ {
+ // Disassembling at the PC always disassembles some number of instructions (not the whole function).
+ m_options.num_instructions = DEFAULT_DISASM_NUM_INS;
+ }
+ }
+ else
+ {
+ range.GetBaseAddress().SetOffset (m_options.start_addr);
+ if (range.GetBaseAddress().IsValid())
+ {
+ if (m_options.end_addr != LLDB_INVALID_ADDRESS)
{
- result.AppendErrorWithFormat ("End address before start address.\n");
- result.SetStatus (eReturnStatusFailed);
- return false;
+ if (m_options.end_addr <= m_options.start_addr)
+ {
+ result.AppendErrorWithFormat ("End address before start address.\n");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ range.SetByteSize (m_options.end_addr - m_options.start_addr);
}
- range_byte_size = m_options.m_end_addr - m_options.m_start_addr;
}
}
}
if (m_options.num_instructions != 0)
{
- if (!start_addr.IsValid())
+ if (!range.GetBaseAddress().IsValid())
{
// The default action is to disassemble the current frame function.
if (exe_ctx.frame)
{
SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol));
if (sc.function)
- start_addr = sc.function->GetAddressRange().GetBaseAddress();
+ range.GetBaseAddress() = sc.function->GetAddressRange().GetBaseAddress();
else if (sc.symbol && sc.symbol->GetAddressRangePtr())
- start_addr = sc.symbol->GetAddressRangePtr()->GetBaseAddress();
+ range.GetBaseAddress() = sc.symbol->GetAddressRangePtr()->GetBaseAddress();
else
- start_addr = exe_ctx.frame->GetFrameCodeAddress();
+ range.GetBaseAddress() = exe_ctx.frame->GetFrameCodeAddress();
}
- if (!start_addr.IsValid())
+ if (!range.GetBaseAddress().IsValid())
{
result.AppendError ("invalid frame");
result.SetStatus (eReturnStatusFailed);
@@ -339,10 +365,10 @@ CommandObjectDisassemble::Execute
}
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
- m_options.m_arch,
+ m_options.arch,
plugin_name,
exe_ctx,
- start_addr,
+ range.GetBaseAddress(),
m_options.num_instructions,
m_options.show_mixed ? m_options.num_lines_context : 0,
m_options.show_bytes,
@@ -353,19 +379,13 @@ CommandObjectDisassemble::Execute
}
else
{
- result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.m_start_addr);
+ result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.start_addr);
result.SetStatus (eReturnStatusFailed);
}
}
else
{
- AddressRange range;
- if (start_addr.IsValid())
- {
- range.GetBaseAddress() = start_addr;
- range.SetByteSize (range_byte_size);
- }
- else
+ if (!range.GetBaseAddress().IsValid())
{
// The default action is to disassemble the current frame function.
if (exe_ctx.frame)
@@ -389,7 +409,7 @@ CommandObjectDisassemble::Execute
range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
if (Disassembler::Disassemble (m_interpreter.GetDebugger(),
- m_options.m_arch,
+ m_options.arch,
plugin_name,
exe_ctx,
range,
@@ -403,7 +423,7 @@ CommandObjectDisassemble::Execute
}
else
{
- result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.m_start_addr);
+ result.AppendErrorWithFormat ("Failed to disassemble memory at 0x%8.8llx.\n", m_options.start_addr);
result.SetStatus (eReturnStatusFailed);
}
}
diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h
index 42ede79787d..46b4bacfccd 100644
--- a/lldb/source/Commands/CommandObjectDisassemble.h
+++ b/lldb/source/Commands/CommandObjectDisassemble.h
@@ -47,9 +47,9 @@ public:
const char *
GetPluginName ()
{
- if (m_plugin_name.empty())
+ if (plugin_name.empty())
return NULL;
- return m_plugin_name.c_str();
+ return plugin_name.c_str();
}
@@ -58,12 +58,13 @@ public:
uint32_t num_lines_context;
uint32_t num_instructions;
bool raw;
- std::string m_func_name;
- lldb::addr_t m_start_addr;
- lldb::addr_t m_end_addr;
- bool m_at_pc;
- std::string m_plugin_name;
- ArchSpec m_arch;
+ std::string func_name;
+ lldb::addr_t start_addr;
+ lldb::addr_t end_addr;
+ bool at_pc;
+ bool frame_line;
+ std::string plugin_name;
+ ArchSpec arch;
static OptionDefinition g_option_table[];
};
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp
index e7b11837c8e..fd9271b3b5e 100644
--- a/lldb/source/Commands/CommandObjectExpression.cpp
+++ b/lldb/source/Commands/CommandObjectExpression.cpp
@@ -95,7 +95,6 @@ CommandObjectExpression::CommandOptions::SetOptionValue (int option_idx, const c
void
CommandObjectExpression::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
//language.Clear();
debug = false;
format = eFormatDefault;
@@ -298,7 +297,7 @@ CommandObjectExpression::ExecuteRawCommandString
{
m_exe_ctx = m_interpreter.GetDebugger().GetExecutionContext();
- m_options.ResetOptionValues();
+ m_options.Reset();
const char * expr = NULL;
diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp
index 7d17af9f004..6f1267ebf1d 100644
--- a/lldb/source/Commands/CommandObjectFile.cpp
+++ b/lldb/source/Commands/CommandObjectFile.cpp
@@ -77,7 +77,6 @@ CommandObjectFile::CommandOptions::SetOptionValue (int option_idx, const char *o
void
CommandObjectFile::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues();
m_arch.Clear();
}
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 8efb1649bf3..25f7638ef7d 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -135,7 +135,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
relative_frame_offset = INT32_MIN;
}
@@ -352,8 +351,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
-
use_objc = false;
use_regex = false;
show_args = true;
diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp
index ed196475a0b..d684bb2df98 100644
--- a/lldb/source/Commands/CommandObjectImage.cpp
+++ b/lldb/source/Commands/CommandObjectImage.cpp
@@ -763,7 +763,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_sort_order = eSortOrderNone;
}
@@ -1167,7 +1166,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_format_array.clear();
}
@@ -1429,7 +1427,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_type = eLookupTypeInvalid;
m_str.clear();
m_file.Clear();
diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp
index d49485a2d16..383e29974f8 100644
--- a/lldb/source/Commands/CommandObjectLog.cpp
+++ b/lldb/source/Commands/CommandObjectLog.cpp
@@ -208,7 +208,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
log_file.clear();
log_options = 0;
}
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp
index 4225f860b61..f63848c0a65 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -164,7 +164,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_format = eFormatBytesWithASCII;
m_byte_size = 0;
m_count = 0;
@@ -493,7 +492,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_format = eFormatBytes;
m_byte_size = 1;
m_infile.Clear();
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 0e321d035b9..b57a51be5eb 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -68,7 +68,7 @@ public:
}
else
{
- result.AppendError ("command not implemented\n");
+ result.AppendError ("platform create takes a platform name as an argument\n");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
@@ -409,6 +409,308 @@ public:
};
+//----------------------------------------------------------------------
+// "platform process list"
+//----------------------------------------------------------------------
+class CommandObjectPlatformProcessList : public CommandObject
+{
+public:
+ CommandObjectPlatformProcessList (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "platform process list",
+ "List processes on a remote platform by name, pid, or many other matching attributes.",
+ "platform process list",
+ 0)
+ {
+ }
+
+ virtual
+ ~CommandObjectPlatformProcessList ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args, CommandReturnObject &result)
+ {
+ PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+
+ if (platform_sp)
+ {
+ Error error;
+ if (args.GetArgumentCount() == 0)
+ {
+
+ if (platform_sp)
+ {
+ lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID();
+ if (pid != LLDB_INVALID_PROCESS_ID)
+ {
+ ProcessInfo proc_info;
+ if (platform_sp->GetProcessInfo (pid, proc_info))
+ {
+ proc_info.Dump (result.GetOutputStream(), platform_sp.get());
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("no process found with pid = %i\n", pid);
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ ProcessInfoList proc_infos;
+ const uint32_t matches = platform_sp->FindProcesses (m_options.match_info, proc_infos);
+ if (matches == 0)
+ {
+ const char *match_desc = NULL;
+ const char *match_name = m_options.match_info.GetProcessInfo().GetName();
+ if (match_name && match_name[0])
+ {
+ switch (m_options.match_info.GetNameMatchType())
+ {
+ case eNameMatchIgnore: break;
+ case eNameMatchEquals: match_desc = "match"; break;
+ case eNameMatchContains: match_desc = "contains"; break;
+ case eNameMatchStartsWith: match_desc = "starts with"; break;
+ case eNameMatchEndsWith: match_desc = "end with"; break;
+ case eNameMatchRegularExpression: match_desc = "match the regular expression"; break;
+ }
+ }
+ if (match_desc)
+ result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n",
+ match_desc,
+ match_name,
+ platform_sp->GetShortPluginName());
+ else
+ result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetShortPluginName());
+ result.SetStatus (eReturnStatusFailed);
+ }
+ else
+ {
+ Stream &ostrm = result.GetOutputStream();
+
+ ProcessInfo::DumpTableHeader (ostrm, platform_sp.get());
+ for (uint32_t i=0; i<matches; ++i)
+ {
+ proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(ostrm, platform_sp.get());
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ result.AppendError ("invalid args: process list takes only options\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ }
+ else
+ {
+ result.AppendError ("no platform is selected\n");
+ result.SetStatus (eReturnStatusFailed);
+ }
+ return result.Succeeded();
+ }
+
+ virtual Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
+protected:
+
+ class CommandOptions : public Options
+ {
+ public:
+
+ CommandOptions () :
+ match_info ()
+ {
+ }
+
+ virtual
+ ~CommandOptions ()
+ {
+ }
+
+ virtual Error
+ SetOptionValue (int option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+ bool success = false;
+
+ switch (short_option)
+ {
+ case 'p':
+ match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid process ID string: '%s'", option_arg);
+ break;
+
+ case 'P':
+ match_info.GetProcessInfo().SetParentProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid parent process ID string: '%s'", option_arg);
+ break;
+
+ case 'u':
+ match_info.GetProcessInfo().SetRealUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid user ID string: '%s'", option_arg);
+ break;
+
+ case 'U':
+ match_info.GetProcessInfo().SetEffectiveUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid effective user ID string: '%s'", option_arg);
+ break;
+
+ case 'g':
+ match_info.GetProcessInfo().SetRealGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid group ID string: '%s'", option_arg);
+ break;
+
+ case 'G':
+ match_info.GetProcessInfo().SetEffectiveGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ if (!success)
+ error.SetErrorStringWithFormat("invalid effective group ID string: '%s'", option_arg);
+ break;
+
+ case 'a':
+ match_info.GetProcessInfo().GetArchitecture().SetTriple (option_arg);
+ break;
+
+ case 'n':
+ match_info.GetProcessInfo().SetName (option_arg);
+ if (match_info.GetNameMatchType() == eNameMatchIgnore)
+ match_info.SetNameMatchType (eNameMatchEquals);
+ break;
+
+ case 'e':
+ match_info.SetNameMatchType (eNameMatchEndsWith);
+ break;
+
+ case 's':
+ match_info.SetNameMatchType (eNameMatchStartsWith);
+ break;
+
+ case 'c':
+ match_info.SetNameMatchType (eNameMatchContains);
+ break;
+
+ case 'r':
+ match_info.SetNameMatchType (eNameMatchRegularExpression);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
+ break;
+ }
+
+ return error;
+ }
+
+ void
+ ResetOptionValues ()
+ {
+ match_info.Clear();
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+
+ ProcessInfoMatch match_info;
+ };
+ CommandOptions m_options;
+};
+
+OptionDefinition
+CommandObjectPlatformProcessList::CommandOptions::g_option_table[] =
+{
+{ LLDB_OPT_SET_1, false, "pid" , 'p', required_argument, NULL, 0, eArgTypePid , "List the process info for a specific process ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5, true , "name" , 'n', required_argument, NULL, 0, eArgTypeProcessName , "Find processes that match the supplied name." },
+{ LLDB_OPT_SET_2, false, "ends-with" , 'e', no_argument , NULL, 0, eArgTypeNone , "Process names must end with the name supplied with the --name option." },
+{ LLDB_OPT_SET_3, false, "starts-with" , 's', no_argument , NULL, 0, eArgTypeNone , "Process names must start with the name supplied with the --name option." },
+{ LLDB_OPT_SET_4, false, "contains" , 'c', no_argument , NULL, 0, eArgTypeNone , "Process names must contain the name supplied with the --name option." },
+{ LLDB_OPT_SET_5, false, "regex" , 'r', no_argument , NULL, 0, eArgTypeNone , "Process names must match name supplied with the --name option as a regular expression." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "parent" , 'P', required_argument, NULL, 0, eArgTypePid , "Find processes that have a matching parent process ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "uid" , 'u', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching user ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "euid" , 'U', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective user ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "gid" , 'g', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching group ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "egid" , 'G', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective group ID." },
+{ LLDB_OPT_SET_2|
+ LLDB_OPT_SET_3|
+ LLDB_OPT_SET_4|
+ LLDB_OPT_SET_5|
+ LLDB_OPT_SET_6, false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." },
+{ 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone , NULL }
+};
+
+class CommandObjectPlatformProcess : public CommandObjectMultiword
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CommandObjectPlatformProcess (CommandInterpreter &interpreter) :
+ CommandObjectMultiword (interpreter,
+ "platform process",
+ "A set of commands to query, launch and attach to platform processes",
+ "platform process [attach|launch|list] ...")
+ {
+// LoadSubCommand ("attach", CommandObjectSP (new CommandObjectPlatformProcessAttach (interpreter)));
+// LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter)));
+ LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformProcessList (interpreter)));
+
+ }
+
+ virtual
+ ~CommandObjectPlatformProcess ()
+ {
+ }
+
+private:
+ //------------------------------------------------------------------
+ // For CommandObjectPlatform only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatformProcess);
+};
//----------------------------------------------------------------------
// CommandObjectPlatform constructor
@@ -425,6 +727,7 @@ CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus (interpreter)));
LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect (interpreter)));
LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect (interpreter)));
+ LoadSubCommand ("process", CommandObjectSP (new CommandObjectPlatformProcess (interpreter)));
}
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 7eb7c4a16ff..8287481eec2 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -82,7 +82,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
stop_at_entry = false;
in_new_tty = false;
tty_name.clear();
@@ -483,7 +482,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
pid = LLDB_INVALID_PROCESS_ID;
name.clear();
waitfor = false;
@@ -527,7 +525,13 @@ public:
if (platform_sp)
{
ProcessInfoList process_infos;
- platform_sp->FindProcessesByName (partial_name, partial_name ? eNameMatchStartsWith : eNameMatchIgnore, process_infos);
+ ProcessInfoMatch match_info;
+ if (partial_name)
+ {
+ match_info.GetProcessInfo().SetName(partial_name);
+ match_info.SetNameMatchType(eNameMatchStartsWith);
+ }
+ platform_sp->FindProcesses (match_info, process_infos);
const uint32_t num_matches = process_infos.GetSize();
if (num_matches > 0)
{
@@ -706,7 +710,8 @@ public:
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
if (platform_sp)
{
- platform_sp->FindProcessesByName (wait_name, eNameMatchEquals, process_infos);
+ ProcessInfoMatch match_info (wait_name, eNameMatchEquals);
+ platform_sp->FindProcesses (match_info, process_infos);
}
if (process_infos.GetSize() > 1)
{
@@ -1011,7 +1016,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
plugin_name.clear();
}
@@ -1601,7 +1605,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
stop.clear();
notify.clear();
pass.clear();
diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp
index d9cb5de6fe6..55a4782c822 100644
--- a/lldb/source/Commands/CommandObjectRegister.cpp
+++ b/lldb/source/Commands/CommandObjectRegister.cpp
@@ -58,6 +58,12 @@ public:
{
}
+ Options *
+ GetOptions ()
+ {
+ return &m_options;
+ }
+
virtual bool
Execute
(
@@ -143,8 +149,77 @@ public:
}
return result.Succeeded();
}
+
+protected:
+ class CommandOptions : public Options
+ {
+ public:
+ CommandOptions () :
+ Options()
+ {
+ ResetOptionValues();
+ }
+
+ virtual
+ ~CommandOptions ()
+ {
+ }
+
+ virtual Error
+ SetOptionValue (int option_idx, const char *option_arg)
+ {
+ Error error;
+ char short_option = (char) m_getopt_table[option_idx].val;
+ switch (short_option)
+ {
+ case 'f':
+ error = Args::StringToFormat (option_arg, m_format);
+ break;
+
+ default:
+ error.SetErrorStringWithFormat("Unrecognized short option '%c'\n", short_option);
+ break;
+ }
+ return error;
+ }
+
+ void
+ ResetOptionValues ()
+ {
+ m_format = eFormatBytes;
+ }
+
+ const OptionDefinition*
+ GetDefinitions ()
+ {
+ return g_option_table;
+ }
+
+ // Options table: Required for subclasses of Options.
+
+ static OptionDefinition g_option_table[];
+
+ // Instance variables to hold the values for command options.
+ lldb::Format m_format;
+ };
+
+ CommandOptions m_options;
};
+OptionDefinition
+CommandObjectRegisterRead::CommandOptions::g_option_table[] =
+{
+ //{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
+ //{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."},
+ { LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, eArgTypeExprFormat, "Specify the format that the expression output should use."},
+ { LLDB_OPT_SET_2, false, "object-description", 'o', no_argument, NULL, 0, eArgTypeNone, "Print the object description of the value resulting from the expression."},
+ { LLDB_OPT_SET_ALL, false, "unwind-on-error", 'u', required_argument, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, breakpoint hit or signal."},
+ { LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, eArgTypeNone, "Enable verbose debug logging of the expression parsing and evaluation."},
+ { LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, eArgTypeNone, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."},
+ { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
+};
+
+
//----------------------------------------------------------------------
// "register write"
diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp
index 348885d4dfc..82a49299cbe 100644
--- a/lldb/source/Commands/CommandObjectSettings.cpp
+++ b/lldb/source/Commands/CommandObjectSettings.cpp
@@ -287,8 +287,6 @@ CommandObjectSettingsSet::CommandOptions::SetOptionValue (int option_idx, const
void
CommandObjectSettingsSet::CommandOptions::ResetOptionValues ()
{
- Options::ResetOptionValues ();
-
m_override = true;
m_reset = false;
}
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 2c7fb33a763..7435b855a93 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -74,8 +74,6 @@ class CommandObjectSourceInfo : public CommandObject
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
-
file_spec.Clear();
file_name.clear();
start_line = 0;
@@ -200,8 +198,6 @@ class CommandObjectSourceList : public CommandObject
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
-
file_spec.Clear();
file_name.clear();
symbol_name.clear();
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 977f63fee35..d5da8807ae6 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -300,7 +300,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_count = -1;
m_start = 0;
}
@@ -545,7 +544,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_avoid_no_debug = true;
m_run_mode = eOnlyDuringStepping;
m_avoid_regexp.clear();
@@ -1044,7 +1042,6 @@ public:
void
ResetOptionValues ()
{
- Options::ResetOptionValues();
m_thread_idx = LLDB_INVALID_THREAD_ID;
m_frame_idx = 0;
m_stop_others = false;
OpenPOWER on IntegriCloud