[Lldb-commits] [lldb] r161993 - in /lldb/trunk: source/Commands/CommandObjectTarget.cpp test/functionalities/completion/TestCompletion.py tools/driver/Driver.cpp tools/driver/Driver.h
Johnny Chen
johnny.chen at apple.com
Wed Aug 15 15:10:42 PDT 2012
Author: johnny
Date: Wed Aug 15 17:10:42 2012
New Revision: 161993
URL: http://llvm.org/viewvc/llvm-project?rev=161993&view=rev
Log:
rdar://problem/12096295
Add an lldb command line option to specify a core file: --core/-c.
For consistency, change the "target create" command to also use --core.
Modified:
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/test/functionalities/completion/TestCompletion.py
lldb/trunk/tools/driver/Driver.cpp
lldb/trunk/tools/driver/Driver.h
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=161993&r1=161992&r2=161993&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Aug 15 17:10:42 2012
@@ -151,7 +151,7 @@
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-file", 'c', 0, eArgTypePath, "Fullpath to a core file to use for this target.")
+ m_core_file (LLDB_OPT_SET_1, false, "core", 'c', 0, eArgTypePath, "Fullpath to a core file to use for this target.")
{
CommandArgumentEntry arg;
CommandArgumentData file_arg;
Modified: lldb/trunk/test/functionalities/completion/TestCompletion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/completion/TestCompletion.py?rev=161993&r1=161992&r2=161993&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/completion/TestCompletion.py (original)
+++ lldb/trunk/test/functionalities/completion/TestCompletion.py Wed Aug 15 17:10:42 2012
@@ -131,6 +131,10 @@
['Available completions:', 'create', 'delete', 'list',
'modules', 'select', 'stop-hook', 'variable'])
+ def test_target_create_dash_co(self):
+ """Test that 'target create --co' completes to 'target variable --core '."""
+ self.complete_from_to('target create --co', 'target create --core ')
+
def test_target_va(self):
"""Test that 'target va' completes to 'target variable '."""
self.complete_from_to('target va', 'target variable ')
Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=161993&r1=161992&r2=161993&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Wed Aug 15 17:10:42 2012
@@ -84,6 +84,8 @@
"be one of the architectures for which the program was compiled." },
{ LLDB_OPT_SET_3, true , "file" , 'f', required_argument, NULL, eArgTypeFilename,
"Tells the debugger to use the file <filename> as the program to be debugged." },
+ { LLDB_OPT_SET_3, false, "core" , 'c', required_argument, NULL, eArgTypePath,
+ "Tells the debugger to use the fullpath to <path> as the core file." },
{ LLDB_OPT_SET_4, true , "attach-name" , 'n', required_argument, NULL, eArgTypeProcessName,
"Tells the debugger to attach to a process with the given name." },
{ LLDB_OPT_SET_4, true , "wait-for" , 'w', no_argument , NULL, eArgTypeNone,
@@ -379,6 +381,7 @@
Driver::OptionData::OptionData () :
m_args(),
m_script_lang (lldb::eScriptLanguageDefault),
+ m_core_file (),
m_crash_log (),
m_source_command_files (),
m_debug_mode (false),
@@ -587,9 +590,17 @@
break;
case 'c':
- m_option_data.m_crash_log = optarg;
+ {
+ SBFileSpec file(optarg);
+ if (file.Exists())
+ {
+ m_option_data.m_core_file = optarg;
+ }
+ else
+ error.SetErrorStringWithFormat("file specified in --core (-c) option doesn't exist: '%s'", optarg);
+ }
break;
-
+
case 'e':
m_option_data.m_use_external_editor = true;
break;
@@ -691,10 +702,6 @@
::fprintf (out_fh, "%s\n", m_debugger.GetVersionString());
exit = true;
}
- else if (! m_option_data.m_crash_log.empty())
- {
- // Handle crash log stuff here.
- }
else if (m_option_data.m_process_name.empty() && m_option_data.m_process_pid == LLDB_INVALID_PROCESS_ID)
{
// Any arguments that are left over after option parsing are for
@@ -1311,6 +1318,11 @@
}
}
+ // Was there a core file specified?
+ std::string core_file_spec("");
+ if (!m_option_data.m_core_file.empty())
+ core_file_spec.append("--core ").append(m_option_data.m_core_file);
+
const size_t num_args = m_option_data.m_args.size();
if (num_args > 0)
{
@@ -1318,13 +1330,15 @@
if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name)))
::snprintf (command_string,
sizeof (command_string),
- "target create --arch=%s \"%s\"",
+ "target create --arch=%s %s \"%s\"",
arch_name,
+ core_file_spec.c_str(),
m_option_data.m_args[0].c_str());
else
::snprintf (command_string,
sizeof(command_string),
- "target create \"%s\"",
+ "target create %s \"%s\"",
+ core_file_spec.c_str(),
m_option_data.m_args[0].c_str());
m_debugger.HandleCommand (command_string);
@@ -1343,6 +1357,14 @@
}
}
}
+ else if (!core_file_spec.empty())
+ {
+ ::snprintf (command_string,
+ sizeof(command_string),
+ "target create %s",
+ core_file_spec.c_str());
+ m_debugger.HandleCommand (command_string);;
+ }
// Now that all option parsing is done, we try and parse the .lldbinit
// file in the current working directory
Modified: lldb/trunk/tools/driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=161993&r1=161992&r2=161993&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.h (original)
+++ lldb/trunk/tools/driver/Driver.h Wed Aug 15 17:10:42 2012
@@ -103,6 +103,7 @@
std::vector<std::string> m_args;
lldb::ScriptLanguage m_script_lang;
+ std::string m_core_file;
std::string m_crash_log;
std::vector<std::string> m_source_command_files;
bool m_debug_mode;
More information about the lldb-commits
mailing list