summaryrefslogtreecommitdiffstats
path: root/source/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'source/Commands')
-rw-r--r--source/Commands/CommandObjectBreakpoint.cpp20
-rw-r--r--source/Commands/CommandObjectDisassemble.cpp6
-rw-r--r--source/Commands/CommandObjectExpression.cpp4
-rw-r--r--source/Commands/CommandObjectFrame.cpp5
-rw-r--r--source/Commands/CommandObjectGUI.cpp20
-rw-r--r--source/Commands/CommandObjectHelp.cpp20
-rw-r--r--source/Commands/CommandObjectHelp.h11
-rw-r--r--source/Commands/CommandObjectLog.cpp3
-rw-r--r--source/Commands/CommandObjectMemory.cpp21
-rw-r--r--source/Commands/CommandObjectPlatform.cpp42
-rw-r--r--source/Commands/CommandObjectProcess.cpp201
-rw-r--r--source/Commands/CommandObjectSource.cpp8
-rw-r--r--source/Commands/CommandObjectTarget.cpp141
-rw-r--r--source/Commands/CommandObjectThread.cpp113
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp3
15 files changed, 352 insertions, 266 deletions
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 3d4b3af..025524b 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -19,6 +19,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/OptionValueUInt64.h"
@@ -140,7 +141,7 @@ public:
break;
case 'C':
- m_column = Args::StringToUInt32 (option_arg, 0);
+ m_column = StringConvert::ToUInt32 (option_arg, 0);
break;
case 'c':
@@ -166,6 +167,7 @@ public:
case eLanguageTypeC_plus_plus:
case eLanguageTypeC_plus_plus_03:
case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
m_language = eLanguageTypeC_plus_plus;
break;
case eLanguageTypeObjC:
@@ -207,7 +209,7 @@ public:
case 'i':
{
- m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
break;
@@ -229,7 +231,7 @@ public:
break;
case 'l':
- m_line_num = Args::StringToUInt32 (option_arg, 0);
+ m_line_num = StringConvert::ToUInt32 (option_arg, 0);
break;
case 'M':
@@ -276,7 +278,7 @@ public:
case 't' :
{
- m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
+ m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
}
@@ -297,7 +299,7 @@ public:
case 'x':
{
- m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
@@ -838,7 +840,7 @@ public:
break;
case 'i':
{
- m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
}
@@ -865,7 +867,7 @@ public:
}
else
{
- m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
+ m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
else
@@ -896,7 +898,7 @@ public:
}
else
{
- m_thread_index = Args::StringToUInt32 (option_arg, UINT32_MAX, 0);
+ m_thread_index = StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
else
@@ -1555,7 +1557,7 @@ public:
break;
case 'l':
- m_line_num = Args::StringToUInt32 (option_arg, 0);
+ m_line_num = StringConvert::ToUInt32 (option_arg, 0);
break;
default:
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index 8124ce1..2ba47be 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -19,7 +19,7 @@
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/SourceManager.h"
-#include "lldb/Interpreter/Args.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandCompletions.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -76,13 +76,13 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (uint32_t option_idx, c
break;
case 'C':
- num_lines_context = Args::StringToUInt32(option_arg, 0, 0, &success);
+ num_lines_context = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid num context lines string: \"%s\"", option_arg);
break;
case 'c':
- num_instructions = Args::StringToUInt32(option_arg, 0, 0, &success);
+ num_instructions = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid num of instructions string: \"%s\"", option_arg);
break;
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index b4c559c..e87399f 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -15,7 +15,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
@@ -24,6 +23,7 @@
#include "lldb/Expression/ClangFunction.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -119,7 +119,7 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int
{
bool success;
uint32_t result;
- result = Args::StringToUInt32(option_arg, 0, 0, &success);
+ result = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (success)
timeout = result;
else
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index ce540a5..4458a69 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -27,6 +27,7 @@
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -119,7 +120,7 @@ public:
switch (short_option)
{
case 'r':
- relative_frame_offset = Args::StringToSInt32 (option_arg, INT32_MIN, 0, &success);
+ relative_frame_offset = StringConvert::ToSInt32 (option_arg, INT32_MIN, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid frame offset argument '%s'", option_arg);
break;
@@ -246,7 +247,7 @@ protected:
{
const char *frame_idx_cstr = command.GetArgumentAtIndex(0);
bool success = false;
- frame_idx = Args::StringToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success);
+ frame_idx = StringConvert::ToUInt32 (frame_idx_cstr, UINT32_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid frame index argument '%s'", frame_idx_cstr);
diff --git a/source/Commands/CommandObjectGUI.cpp b/source/Commands/CommandObjectGUI.cpp
index 3d05335..359d6d2 100644
--- a/source/Commands/CommandObjectGUI.cpp
+++ b/source/Commands/CommandObjectGUI.cpp
@@ -42,10 +42,22 @@ CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
if (args.GetArgumentCount() == 0)
{
Debugger &debugger = m_interpreter.GetDebugger();
- IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
- if (io_handler_sp)
- debugger.PushIOHandler(io_handler_sp);
- result.SetStatus (eReturnStatusSuccessFinishResult);
+
+ lldb::StreamFileSP input_sp = debugger.GetInputFile();
+ if (input_sp &&
+ input_sp->GetFile().GetIsRealTerminal() &&
+ input_sp->GetFile().GetIsInteractive())
+ {
+ IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
+ if (io_handler_sp)
+ debugger.PushIOHandler(io_handler_sp);
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendError("the gui command requires an interactive terminal.");
+ result.SetStatus (eReturnStatusFailed);
+ }
}
else
{
diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp
index f73d9d2..b02515e 100644
--- a/source/Commands/CommandObjectHelp.cpp
+++ b/source/Commands/CommandObjectHelp.cpp
@@ -54,9 +54,10 @@ CommandObjectHelp::~CommandObjectHelp()
OptionDefinition
CommandObjectHelp::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "show-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Show aliases in the command list."},
+ { LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide aliases in the command list."},
{ LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Hide user-defined commands from the list."},
- { 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
+ { LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
+ { 0, false, NULL, 0, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
bool
@@ -75,6 +76,8 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
cmd_types |= CommandInterpreter::eCommandTypesAliases;
if (m_options.m_show_user_defined)
cmd_types |= CommandInterpreter::eCommandTypesUserDef;
+ if (m_options.m_show_hidden)
+ cmd_types |= CommandInterpreter::eCommandTypesHidden;
result.SetStatus (eReturnStatusSuccessFinishNoResult);
m_interpreter.GetHelp (result, cmd_types); // General help
@@ -136,17 +139,19 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
else if (!sub_cmd_obj)
{
result.AppendErrorWithFormat("'%s' is not a known command.\n"
- "Try 'help' to see a current list of commands.\n",
- cmd_string.c_str());
+ "Try '%shelp' to see a current list of commands.\n",
+ cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix());
result.SetStatus (eReturnStatusFailed);
return false;
}
else
{
result.GetOutputStream().Printf("'%s' is not a known command.\n"
- "Try 'help' to see a current list of commands.\n"
+ "Try '%shelp' to see a current list of commands.\n"
"The closest match is '%s'. Help on it follows.\n\n",
cmd_string.c_str(),
+ m_interpreter.GetCommandPrefix(),
sub_cmd_obj->GetCommandName());
}
}
@@ -183,8 +188,9 @@ CommandObjectHelp::DoExecute (Args& command, CommandReturnObject &result)
else
{
result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
- command.GetArgumentAtIndex(0));
+ ("'%s' is not a known command.\nTry '%shelp' to see a current list of commands.\n",
+ command.GetArgumentAtIndex(0),
+ m_interpreter.GetCommandPrefix());
result.SetStatus (eReturnStatusFailed);
}
}
diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h
index 6e8f9d4..7db659c 100644
--- a/source/Commands/CommandObjectHelp.h
+++ b/source/Commands/CommandObjectHelp.h
@@ -62,11 +62,14 @@ public:
switch (short_option)
{
case 'a':
- m_show_aliases = true;
+ m_show_aliases = false;
break;
case 'u':
m_show_user_defined = false;
break;
+ case 'h':
+ m_show_hidden = true;
+ break;
default:
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
break;
@@ -78,8 +81,9 @@ public:
void
OptionParsingStarting ()
{
- m_show_aliases = false;
+ m_show_aliases = true;
m_show_user_defined = true;
+ m_show_hidden = false;
}
const OptionDefinition*
@@ -95,7 +99,8 @@ public:
// Instance variables to hold the values for command options.
bool m_show_aliases;
- bool m_show_user_defined;
+ bool m_show_user_defined;
+ bool m_show_hidden;
};
virtual Options *
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index 7d32cc6..aa09f53 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -29,6 +29,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/Debugger.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -444,7 +445,7 @@ protected:
if (strcasecmp(sub_command, "enable") == 0)
{
bool success;
- uint32_t depth = Args::StringToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success);
+ uint32_t depth = StringConvert::ToUInt32(args.GetArgumentAtIndex(1), 0, 0, &success);
if (success)
{
Timer::SetDisplayDepth (depth);
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index 6c06ec8..dac6dd8 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -24,6 +24,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -566,7 +567,7 @@ protected:
--pointer_count;
}
- m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize();
+ m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize(nullptr);
if (m_format_options.GetByteSizeValue() == 0)
{
@@ -689,7 +690,7 @@ protected:
if (m_format_options.GetFormatValue().OptionWasSet() == false)
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
- bytes_read = clang_ast_type.GetByteSize() * m_format_options.GetCountValue().GetCurrentValue();
+ bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
}
else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
{
@@ -1113,7 +1114,7 @@ protected:
if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get())
{
uint64_t value = result_sp->GetValueAsUnsigned(0);
- switch (result_sp->GetClangType().GetByteSize())
+ switch (result_sp->GetClangType().GetByteSize(nullptr))
{
case 1: {
uint8_t byte = (uint8_t)value;
@@ -1293,7 +1294,7 @@ public:
case 'o':
{
bool success;
- m_infile_offset = Args::StringToUInt64(option_arg, 0, 0, &success);
+ m_infile_offset = StringConvert::ToUInt64(option_arg, 0, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat("invalid offset string '%s'", option_arg);
@@ -1446,7 +1447,7 @@ protected:
if (m_memory_options.m_infile)
{
size_t length = SIZE_MAX;
- if (item_byte_size > 0)
+ if (item_byte_size > 1)
length = item_byte_size;
lldb::DataBufferSP data_sp (m_memory_options.m_infile.ReadFileContents (m_memory_options.m_infile_offset, length));
if (data_sp)
@@ -1539,7 +1540,7 @@ protected:
case eFormatPointer:
// Decode hex bytes
- uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 16, &success);
+ uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid hex string value.\n", value_str);
@@ -1567,7 +1568,7 @@ protected:
break;
case eFormatBinary:
- uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 2, &success);
+ uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 2, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid binary string value.\n", value_str);
@@ -1607,7 +1608,7 @@ protected:
break;
case eFormatDecimal:
- sval64 = Args::StringToSInt64(value_str, INT64_MAX, 0, &success);
+ sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid signed decimal value.\n", value_str);
@@ -1624,7 +1625,7 @@ protected:
break;
case eFormatUnsigned:
- uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 0, &success);
+ uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid unsigned decimal string value.\n", value_str);
@@ -1641,7 +1642,7 @@ protected:
break;
case eFormatOctal:
- uval64 = Args::StringToUInt64(value_str, UINT64_MAX, 8, &success);
+ uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 8, &success);
if (!success)
{
result.AppendErrorWithFormat ("'%s' is not a valid octal string value.\n", value_str);
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index d176d52..959c5cd 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandOptionValidators.h"
@@ -104,7 +105,7 @@ public:
case 'v':
{
bool ok;
- uint32_t perms = Args::StringToUInt32(option_arg, 777, 8, &ok);
+ uint32_t perms = StringConvert::ToUInt32(option_arg, 777, 8, &ok);
if (!ok)
error.SetErrorStringWithFormat("invalid value for permissions: %s", option_arg);
else
@@ -248,6 +249,8 @@ protected:
PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, ArchSpec(), select, error, platform_arch));
if (platform_sp)
{
+ m_interpreter.GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp);
+
platform_sp->GetStatus (result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@@ -613,7 +616,7 @@ public:
std::string cmd_line;
args.GetCommandString(cmd_line);
uint32_t mode;
- const OptionPermissions* options_permissions = (OptionPermissions*)m_options.GetGroupWithOption('r');
+ const OptionPermissions* options_permissions = (const OptionPermissions*)m_options.GetGroupWithOption('r');
if (options_permissions)
mode = options_permissions->m_permissions;
else
@@ -682,7 +685,7 @@ public:
std::string cmd_line;
args.GetCommandString(cmd_line);
mode_t perms;
- const OptionPermissions* options_permissions = (OptionPermissions*)m_options.GetGroupWithOption('r');
+ const OptionPermissions* options_permissions = (const OptionPermissions*)m_options.GetGroupWithOption('r');
if (options_permissions)
perms = options_permissions->m_permissions;
else
@@ -751,7 +754,7 @@ public:
{
std::string cmd_line;
args.GetCommandString(cmd_line);
- const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
+ const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
Error error;
bool success = platform_sp->CloseFile(fd, error);
if (success)
@@ -803,7 +806,7 @@ public:
{
std::string cmd_line;
args.GetCommandString(cmd_line);
- const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
+ const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
std::string buffer(m_options.m_count,0);
Error error;
uint32_t retcode = platform_sp->ReadFile(fd, m_options.m_offset, &buffer[0], m_options.m_count, error);
@@ -849,12 +852,12 @@ protected:
switch (short_option)
{
case 'o':
- m_offset = Args::StringToUInt32(option_arg, 0, 0, &success);
+ m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
case 'c':
- m_count = Args::StringToUInt32(option_arg, 0, 0, &success);
+ m_count = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
@@ -930,7 +933,7 @@ public:
std::string cmd_line;
args.GetCommandString(cmd_line);
Error error;
- const lldb::user_id_t fd = Args::StringToUInt64(cmd_line.c_str(), UINT64_MAX);
+ const lldb::user_id_t fd = StringConvert::ToUInt64(cmd_line.c_str(), UINT64_MAX);
uint32_t retcode = platform_sp->WriteFile (fd,
m_options.m_offset,
&m_options.m_data[0],
@@ -977,7 +980,7 @@ protected:
switch (short_option)
{
case 'o':
- m_offset = Args::StringToUInt32(option_arg, 0, 0, &success);
+ m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
break;
@@ -1537,37 +1540,37 @@ protected:
switch (short_option)
{
case 'p':
- match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
+ match_info.GetProcessInfo().SetProcessID (StringConvert::ToUInt32 (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));
+ match_info.GetProcessInfo().SetParentProcessID (StringConvert::ToUInt32 (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().SetUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ match_info.GetProcessInfo().SetUserID (StringConvert::ToUInt32 (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));
+ match_info.GetProcessInfo().SetEffectiveUserID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid effective user ID string: '%s'", option_arg);
break;
case 'g':
- match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
+ match_info.GetProcessInfo().SetGroupID (StringConvert::ToUInt32 (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));
+ match_info.GetProcessInfo().SetEffectiveGroupID (StringConvert::ToUInt32 (option_arg, UINT32_MAX, 0, &success));
if (!success)
error.SetErrorStringWithFormat("invalid effective group ID string: '%s'", option_arg);
break;
@@ -1730,7 +1733,7 @@ protected:
for (size_t i=0; i<argc; ++ i)
{
const char *arg = args.GetArgumentAtIndex(i);
- lldb::pid_t pid = Args::StringToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success);
+ lldb::pid_t pid = StringConvert::ToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (success)
{
ProcessInstanceInfo proc_info;
@@ -1805,7 +1808,7 @@ public:
{
case 'p':
{
- lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
+ lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID)
{
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
@@ -2055,7 +2058,7 @@ public:
case 't':
{
bool success;
- timeout = Args::StringToUInt32(option_value, 10, 10, &success);
+ timeout = StringConvert::ToUInt32(option_value, 10, 10, &success);
if (!success)
error.SetErrorStringWithFormat("could not convert \"%s\" to a numeric value.", option_value);
break;
@@ -2278,19 +2281,16 @@ CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect (interpreter)));
LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect (interpreter)));
LoadSubCommand ("settings", CommandObjectSP (new CommandObjectPlatformSettings (interpreter)));
-#ifdef LLDB_CONFIGURATION_DEBUG
LoadSubCommand ("mkdir", CommandObjectSP (new CommandObjectPlatformMkDir (interpreter)));
LoadSubCommand ("file", CommandObjectSP (new CommandObjectPlatformFile (interpreter)));
LoadSubCommand ("get-file", CommandObjectSP (new CommandObjectPlatformGetFile (interpreter)));
LoadSubCommand ("get-size", CommandObjectSP (new CommandObjectPlatformGetSize (interpreter)));
LoadSubCommand ("put-file", CommandObjectSP (new CommandObjectPlatformPutFile (interpreter)));
-#endif
LoadSubCommand ("process", CommandObjectSP (new CommandObjectPlatformProcess (interpreter)));
LoadSubCommand ("shell", CommandObjectSP (new CommandObjectPlatformShell (interpreter)));
LoadSubCommand ("target-install", CommandObjectSP (new CommandObjectPlatformInstall (interpreter)));
}
-
//----------------------------------------------------------------------
// Destructor
//----------------------------------------------------------------------
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index ec7b478..d47311e 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -22,6 +22,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -353,7 +354,7 @@ public:
case 'p':
{
- lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
+ lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID)
{
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
@@ -488,6 +489,8 @@ protected:
DoExecute (Args& command,
CommandReturnObject &result)
{
+ PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
// N.B. The attach should be synchronous. It doesn't help much to get the prompt back between initiating the attach
// and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
@@ -526,122 +529,130 @@ protected:
ModuleSP old_exec_module_sp = target->GetExecutableModule();
ArchSpec old_arch_spec = target->GetArchitecture();
+ ProcessSP process_sp;
+ Error error;
if (command.GetArgumentCount())
{
result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str());
result.SetStatus (eReturnStatusFailed);
+ return false;
}
- else
+
+ m_interpreter.UpdateExecutionContext(nullptr);
+ ListenerSP listener_sp (new Listener("lldb.CommandObjectProcessAttach.DoExecute.attach.hijack"));
+ m_options.attach_info.SetHijackListener(listener_sp);
+
+ // If no process info was specified, then use the target executable
+ // name as the process to attach to by default
+ if (!m_options.attach_info.ProcessInfoSpecified ())
{
- if (state != eStateConnected)
+ if (old_exec_module_sp)
+ m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename();
+
+ if (!m_options.attach_info.ProcessInfoSpecified ())
{
- const char *plugin_name = m_options.attach_info.GetProcessPluginName();
- process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
+ error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option");
}
+ }
- if (process)
+ if (error.Success())
+ {
+ if (state != eStateConnected && platform_sp != nullptr && platform_sp->CanDebugProcess())
+ {
+ target->SetPlatform(platform_sp);
+ process = platform_sp->Attach(m_options.attach_info, m_interpreter.GetDebugger(), target, error).get();
+ }
+ else
{
- Error error;
- // If no process info was specified, then use the target executable
- // name as the process to attach to by default
- if (!m_options.attach_info.ProcessInfoSpecified ())
+ if (state != eStateConnected)
{
- if (old_exec_module_sp)
- m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename();
-
- if (!m_options.attach_info.ProcessInfoSpecified ())
- {
- error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option");
- }
+ const char *plugin_name = m_options.attach_info.GetProcessPluginName();
+ process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, nullptr).get();
+ if (process == nullptr)
+ error.SetErrorStringWithFormat("failed to create process using plugin %s", plugin_name);
}
-
- if (error.Success())
+ if (process)
{
- // Update the execution context so the current target and process are now selected
- // in case we interrupt
- m_interpreter.UpdateExecutionContext(NULL);
- ListenerSP listener_sp (new Listener("lldb.CommandObjectProcessAttach.DoExecute.attach.hijack"));
- m_options.attach_info.SetHijackListener(listener_sp);
process->HijackProcessEvents(listener_sp.get());
- error = process->Attach (m_options.attach_info);
-
- if (error.Success())
- {
- result.SetStatus (eReturnStatusSuccessContinuingNoResult);
- StreamString stream;
- StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get(), &stream);
-
- process->RestoreProcessEvents();
-
- result.SetDidChangeProcessState (true);
-
- if (stream.GetData())
- result.AppendMessage(stream.GetData());
-
- if (state == eStateStopped)
- {
- result.SetStatus (eReturnStatusSuccessFinishNoResult);
- }
- else
- {
- const char *exit_desc = process->GetExitDescription();
- if (exit_desc)
- result.AppendErrorWithFormat ("attach failed: %s", exit_desc);
- else
- result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
- process->Destroy();
- result.SetStatus (eReturnStatusFailed);
- }
- }
- else
- {
- result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
- result.SetStatus (eReturnStatusFailed);
- }
+ error = process->Attach(m_options.attach_info);
}
}
}
-
- if (result.Succeeded())
+
+ if (error.Success() && process != nullptr)
{
- // Okay, we're done. Last step is to warn if the executable module has changed:
- char new_path[PATH_MAX];
- ModuleSP new_exec_module_sp (target->GetExecutableModule());
- if (!old_exec_module_sp)
+ result.SetStatus (eReturnStatusSuccessContinuingNoResult);
+ StreamString stream;
+ StateType state = process->WaitForProcessToStop (nullptr, nullptr, false, listener_sp.get(), &stream);
+
+ process->RestoreProcessEvents();
+ result.SetDidChangeProcessState (true);
+
+ if (stream.GetData())
+ result.AppendMessage(stream.GetData());
+
+ if (state == eStateStopped)
{
- // We might not have a module if we attached to a raw pid...
- if (new_exec_module_sp)
- {
- new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
- result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
- }
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
- else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
- {
- char old_path[PATH_MAX];
-
- old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
- new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
-
- result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
- old_path, new_path);
- }
-
- if (!old_arch_spec.IsValid())
+ else
{
- result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
+ const char *exit_desc = process->GetExitDescription();
+ if (exit_desc)
+ result.AppendErrorWithFormat ("attach failed: %s", exit_desc);
+ else
+ result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
+ process->Destroy();
+ result.SetStatus (eReturnStatusFailed);
}
- else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ }
+
+ if (!result.Succeeded())
+ return false;
+
+ // Okay, we're done. Last step is to warn if the executable module has changed:
+ char new_path[PATH_MAX];
+ ModuleSP new_exec_module_sp (target->GetExecutableModule());
+ if (!old_exec_module_sp)
+ {
+ // We might not have a module if we attached to a raw pid...
+ if (new_exec_module_sp)
{
- result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
- old_arch_spec.GetTriple().getTriple().c_str(),
- target->GetArchitecture().GetTriple().getTriple().c_str());
+ new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
+ result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
}
+ }
+ else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
+ {
+ char old_path[PATH_MAX];
- // This supports the use-case scenario of immediately continuing the process once attached.
- if (m_options.attach_info.GetContinueOnceAttached())
- m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
+ old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
+ new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
+
+ result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
+ old_path, new_path);
+ }
+
+ if (!old_arch_spec.IsValid())
+ {
+ result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
}
+ else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
+ {
+ result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
+ old_arch_spec.GetTriple().getTriple().c_str(),
+ target->GetArchitecture().GetTriple().getTriple().c_str());
+ }
+
+ // This supports the use-case scenario of immediately continuing the process once attached.
+ if (m_options.attach_info.GetContinueOnceAttached())
+ m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
+
return result.Succeeded();
}
@@ -714,7 +725,7 @@ protected:
switch (short_option)
{
case 'i':
- m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ m_ignore = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
break;
@@ -1297,7 +1308,7 @@ protected:
for (uint32_t i=0; i<argc; ++i)
{
const char *image_token_cstr = command.GetArgumentAtIndex(i);
- uint32_t image_token = Args::StringToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
+ uint32_t image_token = StringConvert::ToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
if (image_token == LLDB_INVALID_IMAGE_TOKEN)
{
result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
@@ -1371,7 +1382,7 @@ protected:
const char *signal_name = command.GetArgumentAtIndex(0);
if (::isxdigit (signal_name[0]))
- signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
+ signo = StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
else
signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
@@ -1754,7 +1765,7 @@ public:
else
{
// If the value isn't 'true' or 'false', it had better be 0 or 1.
- real_value = Args::StringToUInt32 (option.c_str(), 3);
+ real_value = StringConvert::ToUInt32 (option.c_str(), 3);
if (real_value != 0 && real_value != 1)
okay = false;
}
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index 8fb03e6..a88a9b1 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -15,7 +15,6 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
-#include "lldb/Interpreter/Args.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/FileLineResolver.h"
#include "lldb/Core/Module.h"
@@ -24,6 +23,7 @@
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
@@ -63,7 +63,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed
switch (short_option)
{
case 'l':
- start_line = Args::StringToUInt32 (option_arg, 0);
+ start_line = StringConvert::ToUInt32 (option_arg, 0);
if (start_line == 0)
error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
break;
@@ -171,13 +171,13 @@ class CommandObjectSourceList : public CommandObjectParsed
switch (short_option)
{
case 'l':
- start_line = Args::StringToUInt32 (option_arg, 0);
+ start_line = StringConvert::ToUInt32 (option_arg, 0);
if (start_line == 0)
error.SetErrorStringWithFormat("invalid line number: '%s'", option_arg);
break;
case 'c':
- num_lines = Args::StringToUInt32 (option_arg, 0);
+ num_lines = StringConvert::ToUInt32 (option_arg, 0);
if (num_lines == 0)
error.SetErrorStringWithFormat("invalid line count: '%s'", option_arg);
break;
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 0d9ffda..9188283 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -27,6 +27,7 @@
#include "lldb/Core/Timer.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -159,7 +160,6 @@ public:
NULL),
m_option_group (interpreter),
m_arch_option (),
- m_platform_options(true), // Do include the "--platform" option in the platform settings by passing true
m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypeFilename, "Fullpath to a core file to use for this target."),
m_platform_path (LLDB_OPT_SET_1, false, "platform-path", 'P', 0, eArgTypePath, "Path to the remote file to use for this target."),
m_symbol_file (LLDB_OPT_SET_1, false, "symfile", 's', 0, eArgTypeFilename, "Fullpath to a stand alone debug symbols file for when debug symbols are not in the executable."),
@@ -180,7 +180,6 @@ public:
m_arguments.push_back (arg);
m_option_group.Append (&m_arch_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
- m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_core_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_platform_path, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append (&m_symbol_file, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
@@ -282,70 +281,83 @@ protected:
bool must_set_platform_path = false;
Debugger &debugger = m_interpreter.GetDebugger();
- PlatformSP platform_sp(debugger.GetPlatformList().GetSelectedPlatform ());
- if (remote_file)
+ TargetSP target_sp;
+ const char *arch_cstr = m_arch_option.GetArchitectureName();
+ const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
+ Error error (debugger.GetTargetList().CreateTarget (debugger,
+ file_path,
+ arch_cstr,
+ get_dependent_files,
+ NULL,
+ target_sp));
+
+ if (target_sp)
{
- // I have a remote file.. two possible cases
- if (file_spec && file_spec.Exists())
+ // Only get the platform after we create the target because we might have
+ // switched platforms depending on what the arguments were to CreateTarget()
+ // we can't rely on the selected platform.
+
+ PlatformSP platform_sp = target_sp->GetPlatform();
+
+ if (remote_file)
{
- // if the remote file does not exist, push it there
- if (!platform_sp->GetFileExists (remote_file))
+ if (platform_sp)
{
- Error err = platform_sp->PutFile(file_spec, remote_file);
- if (err.Fail())
+ // I have a remote file.. two possible cases
+ if (file_spec && file_spec.Exists())
{
- result.AppendError(err.AsCString());
- result.SetStatus (eReturnStatusFailed);
- return false;
+ // if the remote file does not exist, push it there
+ if (!platform_sp->GetFileExists (remote_file))
+ {
+ Error err = platform_sp->PutFile(file_spec, remote_file);
+ if (err.Fail())
+ {
+ result.AppendError(err.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
}
- }
- }
- else
- {
- // there is no local file and we need one
- // in order to make the remote ---> local transfer we need a platform
- // TODO: if the user has passed in a --platform argument, use it to fetch the right platform
- if (!platform_sp)
- {
- result.AppendError("unable to perform remote debugging without a platform");
- result.SetStatus (eReturnStatusFailed);
- return false;
- }
- if (file_path)
- {
- // copy the remote file to the local file
- Error err = platform_sp->GetFile(remote_file, file_spec);
- if (err.Fail())
+ else
{
- result.AppendError(err.AsCString());
- result.SetStatus (eReturnStatusFailed);
- return false;
+ // there is no local file and we need one
+ // in order to make the remote ---> local transfer we need a platform
+ // TODO: if the user has passed in a --platform argument, use it to fetch the right platform
+ if (!platform_sp)
+ {
+ result.AppendError("unable to perform remote debugging without a platform");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ if (file_path)
+ {
+ // copy the remote file to the local file
+ Error err = platform_sp->GetFile(remote_file, file_spec);
+ if (err.Fail())
+ {
+ result.AppendError(err.AsCString());
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ }
+ else
+ {
+ // make up a local file
+ result.AppendError("remote --> local transfer without local path is not implemented yet");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
}
}
else
{
- // make up a local file
- result.AppendError("remote --> local transfer without local path is not implemented yet");
+ result.AppendError("no platform found for target");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
- }
- TargetSP target_sp;
- const char *arch_cstr = m_arch_option.GetArchitectureName();
- const bool get_dependent_files = m_add_dependents.GetOptionValue().GetCurrentValue();
- Error error (debugger.GetTargetList().CreateTarget (debugger,
-// remote_file ? remote_file : file_spec,
- file_path,
- arch_cstr,
- get_dependent_files,
- &m_platform_options,
- target_sp));
-
- if (target_sp)
- {
if (symfile || remote_file)
{
ModuleSP module_sp (target_sp->GetExecutableModule());
@@ -426,7 +438,7 @@ protected:
}
else
{
- result.AppendErrorWithFormat("'%s' takes exactly one executable path argument, or use the --core-file option.\n", m_cmd_name.c_str());
+ result.AppendErrorWithFormat("'%s' takes exactly one executable path argument, or use the --core option.\n", m_cmd_name.c_str());
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
@@ -435,7 +447,6 @@ protected:
private:
OptionGroupOptions m_option_group;
OptionGroupArchitecture m_arch_option;
- OptionGroupPlatform m_platform_options;
OptionGroupFile m_core_file;
OptionGroupFile m_platform_path;
OptionGroupFile m_symbol_file;
@@ -522,7 +533,7 @@ protected:
{
bool success = false;
const char *target_idx_arg = args.GetArgumentAtIndex(0);
- uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
+ uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
if (success)
{
TargetList &target_list = m_interpreter.GetDebugger().GetTargetList();
@@ -629,7 +640,7 @@ protected:
for (uint32_t arg_idx = 0; success && arg_idx < argc; ++arg_idx)
{
const char *target_idx_arg = args.GetArgumentAtIndex(arg_idx);
- uint32_t target_idx = Args::StringToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
+ uint32_t target_idx = StringConvert::ToUInt32 (target_idx_arg, UINT32_MAX, 0, &success);
if (success)
{
if (target_idx < num_targets)
@@ -1260,7 +1271,7 @@ protected:
{
bool success = false;
- uint32_t insert_idx = Args::StringToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success);
+ uint32_t insert_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), UINT32_MAX, 0, &success);
if (!success)
{
@@ -2963,7 +2974,7 @@ protected:
{
ConstString const_sect_name(sect_name);
bool success = false;
- addr_t load_addr = Args::StringToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success);
+ addr_t load_addr = StringConvert::ToUInt64(load_addr_cstr, LLDB_INVALID_ADDRESS, 0, &success);
if (success)
{
SectionSP section_sp (section_list->FindSectionByName(const_sect_name));
@@ -3890,7 +3901,7 @@ public:
break;
case 'o':
- m_offset = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
+ m_offset = StringConvert::ToUInt64(option_arg, LLDB_INVALID_ADDRESS);
if (m_offset == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat ("invalid offset string '%s'", option_arg);
break;
@@ -3910,7 +3921,7 @@ public:
break;
case 'l':
- m_line_number = Args::StringToUInt32(option_arg, UINT32_MAX);
+ m_line_number = StringConvert::ToUInt32(option_arg, UINT32_MAX);
if (m_line_number == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid line number string '%s'", option_arg);
else if (m_line_number == 0)
@@ -4078,7 +4089,7 @@ public:
if (LookupAddressInModule (m_interpreter,
result.GetOutputStream(),
module,
- eSymbolContextEverything,
+ eSymbolContextEverything | (m_options.m_verbose ? eSymbolContextVariable : 0),
m_options.m_addr,
m_options.m_offset,
m_options.m_verbose))
@@ -4873,7 +4884,7 @@ public:
break;
case 'e':
- m_line_end = Args::StringToUInt32 (option_arg, UINT_MAX, 0, &success);
+ m_line_end = StringConvert::ToUInt32 (option_arg, UINT_MAX, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat ("invalid end line number: \"%s\"", option_arg);
@@ -4883,7 +4894,7 @@ public:
break;
case 'l':
- m_line_start = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ m_line_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
{
error.SetErrorStringWithFormat ("invalid start line number: \"%s\"", option_arg);
@@ -4912,7 +4923,7 @@ public:
break;
case 't' :
{
- m_thread_id = Args::StringToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
+ m_thread_id = StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
error.SetErrorStringWithFormat ("invalid thread id string '%s'", option_arg);
m_thread_specified = true;
@@ -4928,7 +4939,7 @@ public:
break;
case 'x':
{
- m_thread_index = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid thread index string '%s'", option_arg);
m_thread_specified = true;
@@ -5233,7 +5244,7 @@ protected:
bool success;
for (size_t i = 0; i < num_args; i++)
{
- lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
+ lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i));
@@ -5302,7 +5313,7 @@ protected:
{
for (size_t i = 0; i < num_args; i++)
{
- lldb::user_id_t user_id = Args::StringToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
+ lldb::user_id_t user_id = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid stop hook id: \"%s\".\n", command.GetArgumentAtIndex(i));
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index bace4e5..199d16b8 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -19,6 +19,7 @@
#include "lldb/Core/State.h"
#include "lldb/Core/SourceManager.h"
#include "lldb/Host/Host.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/Options.h"
@@ -95,7 +96,7 @@ public:
{
bool success;
- uint32_t thread_idx = Args::StringToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success);
+ uint32_t thread_idx = StringConvert::ToUInt32(command.GetArgumentAtIndex(i), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat ("invalid thread specification: \"%s\"\n", command.GetArgumentAtIndex(i));
@@ -178,7 +179,7 @@ public:
case 'c':
{
bool success;
- int32_t input_count = Args::StringToSInt32 (option_arg, -1, 0, &success);
+ int32_t input_count = StringConvert::ToSInt32 (option_arg, -1, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
if (input_count < -1)
@@ -190,7 +191,7 @@ public:
case 's':
{
bool success;
- m_start = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ m_start = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid integer value for option '%c'", short_option);
}
@@ -384,7 +385,7 @@ public:
case 'c':
{
- m_step_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_step_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
break;
@@ -522,7 +523,7 @@ protected:
else
{
const char *thread_idx_cstr = command.GetArgumentAtIndex(0);
- uint32_t step_thread_idx = Args::StringToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
+ uint32_t step_thread_idx = StringConvert::ToUInt32 (thread_idx_cstr, LLDB_INVALID_INDEX32);
if (step_thread_idx == LLDB_INVALID_INDEX32)
{
result.AppendErrorWithFormat ("invalid thread index '%s'.\n", thread_idx_cstr);
@@ -812,7 +813,7 @@ public:
{
bool success;
const int base = 0;
- uint32_t thread_idx = Args::StringToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success);
+ uint32_t thread_idx = StringConvert::ToUInt32 (command.GetArgumentAtIndex(i), LLDB_INVALID_INDEX32, base, &success);
if (success)
{
Thread *thread = process->GetThreadList().FindThreadByIndexID(thread_idx).get();
@@ -984,9 +985,17 @@ public:
switch (short_option)
{
+ case 'a':
+ {
+ ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
+ lldb::addr_t tmp_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
+ if (error.Success())
+ m_until_addrs.push_back(tmp_addr);
+ }
+ break;
case 't':
{
- m_thread_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_INDEX32);
+ m_thread_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_INDEX32);
if (m_thread_idx == LLDB_INVALID_INDEX32)
{
error.SetErrorStringWithFormat ("invalid thread index '%s'", option_arg);
@@ -995,7 +1004,7 @@ public:
break;
case 'f':
{
- m_frame_idx = Args::StringToUInt32 (option_arg, LLDB_INVALID_FRAME_ID);
+ m_frame_idx = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_FRAME_ID);
if (m_frame_idx == LLDB_INVALID_FRAME_ID)
{
error.SetErrorStringWithFormat ("invalid frame index '%s'", option_arg);
@@ -1030,6 +1039,7 @@ public:
m_thread_idx = LLDB_INVALID_THREAD_ID;
m_frame_idx = 0;
m_stop_others = false;
+ m_until_addrs.clear();
}
const OptionDefinition*
@@ -1040,6 +1050,7 @@ public:
uint32_t m_step_thread_idx;
bool m_stop_others;
+ std::vector<lldb::addr_t> m_until_addrs;
// Options table: Required for subclasses of Options.
@@ -1051,7 +1062,7 @@ public:
CommandObjectThreadUntil (CommandInterpreter &interpreter) :
CommandObjectParsed (interpreter,
"thread until",
- "Run the current or specified thread until it reaches a given line number or leaves the current function.",
+ "Run the current or specified thread until it reaches a given line number or address or leaves the current function.",
NULL,
eFlagRequiresThread |
eFlagTryTargetAPILock |
@@ -1110,23 +1121,33 @@ protected:
else
{
Thread *thread = NULL;
- uint32_t line_number;
+ std::vector<uint32_t> line_numbers;
- if (command.GetArgumentCount() != 1)
+ if (command.GetArgumentCount() >= 1)
{
- result.AppendErrorWithFormat ("No line number provided:\n%s", GetSyntax());
- result.SetStatus (eReturnStatusFailed);
- return false;
+ size_t num_args = command.GetArgumentCount();
+ for (size_t i = 0; i < num_args; i++)
+ {
+ uint32_t line_number;
+ line_number = StringConvert::ToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX);
+ if (line_number == UINT32_MAX)
+ {
+ result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0));
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ else
+ line_numbers.push_back(line_number);
+ }
}
-
- line_number = Args::StringToUInt32 (command.GetArgumentAtIndex(0), UINT32_MAX);
- if (line_number == UINT32_MAX)
+ else if (m_options.m_until_addrs.empty())
{
- result.AppendErrorWithFormat ("invalid line number: '%s'.\n", command.GetArgumentAtIndex(0));
+ result.AppendErrorWithFormat ("No line number or address provided:\n%s", GetSyntax());
result.SetStatus (eReturnStatusFailed);
return false;
}
+
if (m_options.m_thread_idx == LLDB_INVALID_THREAD_ID)
{
thread = process->GetThreadList().GetSelectedThread().get();
@@ -1188,27 +1209,40 @@ protected:
Address fun_end_addr(fun_start_addr.GetSection(),
fun_start_addr.GetOffset() + fun_addr_range.GetByteSize());
- line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr);
bool all_in_function = true;
-
- while (index_ptr <= end_ptr)
+
+ line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr);
+
+ for (uint32_t line_number : line_numbers)
{
- LineEntry line_entry;
- const bool exact = false;
- index_ptr = sc.comp_unit->FindLineEntry(index_ptr, line_number, sc.comp_unit, exact, &line_entry);
- if (index_ptr == UINT32_MAX)
- break;
-
- addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target);
- if (address != LLDB_INVALID_ADDRESS)
+ uint32_t start_idx_ptr = index_ptr;
+ while (start_idx_ptr <= end_ptr)
{
- if (fun_addr_range.ContainsLoadAddress (address, target))
- address_list.push_back (address);
- else
- all_in_function = false;
+ LineEntry line_entry;
+ const bool exact = false;
+ start_idx_ptr = sc.comp_unit->FindLineEntry(start_idx_ptr, line_number, sc.comp_unit, exact, &line_entry);
+ if (start_idx_ptr == UINT32_MAX)
+ break;
+
+ addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target);
+ if (address != LLDB_INVALID_ADDRESS)
+ {
+ if (fun_addr_range.ContainsLoadAddress (address, target))
+ address_list.push_back (address);
+ else
+ all_in_function = false;
+ }
+ start_idx_ptr++;
}
- index_ptr++;
+ }
+
+ for (lldb::addr_t address : m_options.m_until_addrs)
+ {
+ if (fun_addr_range.ContainsLoadAddress (address, target))
+ address_list.push_back (address);
+ else
+ all_in_function = false;
}
if (address_list.size() == 0)
@@ -1290,7 +1324,8 @@ CommandObjectThreadUntil::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0"},
{ LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation"},
-{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode,"Determine how to run other threads while stepping this one"},
+{ LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, NULL, g_duo_running_mode, 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one"},
+{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times."},
{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
};
@@ -1351,7 +1386,7 @@ protected:
return false;
}
- uint32_t index_id = Args::StringToUInt32(command.GetArgumentAtIndex(0), 0, 0);
+ uint32_t index_id = StringConvert::ToUInt32(command.GetArgumentAtIndex(0), 0, 0);
Thread *new_thread = process->GetThreadList().FindThreadByIndexID(index_id).get();
if (new_thread == NULL)
@@ -1796,12 +1831,12 @@ public:
return Error("only one source file expected.");
break;
case 'l':
- m_line_num = Args::StringToUInt32 (option_arg, 0, 0, &success);
+ m_line_num = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
if (!success || m_line_num == 0)
return Error("invalid line number: '%s'.", option_arg);
break;
case 'b':
- m_line_offset = Args::StringToSInt32 (option_arg, 0, 0, &success);
+ m_line_offset = StringConvert::ToSInt32 (option_arg, 0, 0, &success);
if (!success)
return Error("invalid line offset: '%s'.", option_arg);
break;
@@ -2120,7 +2155,7 @@ public:
}
bool success;
- uint32_t thread_plan_idx = Args::StringToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
+ uint32_t thread_plan_idx = StringConvert::ToUInt32(args.GetArgumentAtIndex(0), 0, 0, &success);
if (!success)
{
result.AppendErrorWithFormat("Invalid thread index: \"%s\" - should be unsigned int.",
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index ca5fe98..bef59ca 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -21,6 +21,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Host/StringConvert.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/CommandCompletions.h"
@@ -639,7 +640,7 @@ public:
{
case 'i':
{
- m_ignore_count = Args::StringToUInt32(option_arg, UINT32_MAX, 0);
+ m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
error.SetErrorStringWithFormat ("invalid ignore count '%s'", option_arg);
}
OpenPOWER on IntegriCloud