2010-06-09 00:52:24 +08:00
//===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
2012-12-05 08:20:57 +08:00
# include "lldb/lldb-python.h"
2010-06-09 00:52:24 +08:00
# include "CommandObjectProcess.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
2012-08-11 09:27:55 +08:00
# include "lldb/Breakpoint/Breakpoint.h"
# include "lldb/Breakpoint/BreakpointLocation.h"
# include "lldb/Breakpoint/BreakpointSite.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Core/State.h"
<rdar://problem/11757916>
Make breakpoint setting by file and line much more efficient by only looking for inlined breakpoint locations if we are setting a breakpoint in anything but a source implementation file. Implementing this complex for a many reasons. Turns out that parsing compile units lazily had some issues with respect to how we need to do things with DWARF in .o files. So the fixes in the checkin for this makes these changes:
- Add a new setting called "target.inline-breakpoint-strategy" which can be set to "never", "always", or "headers". "never" will never try and set any inlined breakpoints (fastest). "always" always looks for inlined breakpoint locations (slowest, but most accurate). "headers", which is the default setting, will only look for inlined breakpoint locations if the breakpoint is set in what are consudered to be header files, which is realy defined as "not in an implementation source file".
- modify the breakpoint setting by file and line to check the current "target.inline-breakpoint-strategy" setting and act accordingly
- Modify compile units to be able to get their language and other info lazily. This allows us to create compile units from the debug map and not have to fill all of the details in, and then lazily discover this information as we go on debuggging. This is needed to avoid parsing all .o files when setting breakpoints in implementation only files (no inlines). Otherwise we would need to parse the .o file, the object file (mach-o in our case) and the symbol file (DWARF in the object file) just to see what the compile unit was.
- modify the "SymbolFileDWARFDebugMap" to subclass lldb_private::Module so that the virtual "GetObjectFile()" and "GetSymbolVendor()" functions can be intercepted when the .o file contenst are later lazilly needed. Prior to this fix, when we first instantiated the "SymbolFileDWARFDebugMap" class, we would also make modules, object files and symbol files for every .o file in the debug map because we needed to fix up the sections in the .o files with information that is in the executable debug map. Now we lazily do this in the DebugMapModule::GetObjectFile()
Cleaned up header includes a bit as well.
llvm-svn: 162860
2012-08-30 05:13:06 +08:00
# include "lldb/Core/Module.h"
2014-06-13 08:54:12 +08:00
# include "lldb/Core/PluginManager.h"
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
# include "lldb/Host/Host.h"
2012-08-11 09:27:55 +08:00
# include "lldb/Interpreter/Args.h"
# include "lldb/Interpreter/Options.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Interpreter/CommandInterpreter.h"
# include "lldb/Interpreter/CommandReturnObject.h"
2011-03-09 06:40:15 +08:00
# include "lldb/Target/Platform.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Target/Process.h"
2012-08-11 09:27:55 +08:00
# include "lldb/Target/StopInfo.h"
2010-06-09 00:52:24 +08:00
# include "lldb/Target/Target.h"
# include "lldb/Target/Thread.h"
using namespace lldb ;
using namespace lldb_private ;
2013-03-29 08:56:30 +08:00
class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
{
public :
CommandObjectProcessLaunchOrAttach ( CommandInterpreter & interpreter ,
const char * name ,
const char * help ,
const char * syntax ,
uint32_t flags ,
const char * new_process_action ) :
CommandObjectParsed ( interpreter , name , help , syntax , flags ) ,
m_new_process_action ( new_process_action ) { }
virtual ~ CommandObjectProcessLaunchOrAttach ( ) { }
protected :
bool
2013-12-14 01:20:18 +08:00
StopProcessIfNecessary ( Process * process , StateType & state , CommandReturnObject & result )
2013-03-29 08:56:30 +08:00
{
state = eStateInvalid ;
if ( process )
{
state = process - > GetState ( ) ;
if ( process - > IsAlive ( ) & & state ! = eStateConnected )
{
char message [ 1024 ] ;
if ( process - > GetState ( ) = = eStateAttaching )
: : snprintf ( message , sizeof ( message ) , " There is a pending attach, abort it and %s? " , m_new_process_action . c_str ( ) ) ;
else if ( process - > GetShouldDetach ( ) )
: : snprintf ( message , sizeof ( message ) , " There is a running process, detach from it and %s? " , m_new_process_action . c_str ( ) ) ;
else
: : snprintf ( message , sizeof ( message ) , " There is a running process, kill it and %s? " , m_new_process_action . c_str ( ) ) ;
if ( ! m_interpreter . Confirm ( message , true ) )
{
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
else
{
if ( process - > GetShouldDetach ( ) )
{
2013-05-02 08:27:30 +08:00
bool keep_stopped = false ;
Error detach_error ( process - > Detach ( keep_stopped ) ) ;
2013-03-29 08:56:30 +08:00
if ( detach_error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
process = NULL ;
}
else
{
result . AppendErrorWithFormat ( " Failed to detach from process: %s \n " , detach_error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
Error destroy_error ( process - > Destroy ( ) ) ;
if ( destroy_error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
process = NULL ;
}
else
{
result . AppendErrorWithFormat ( " Failed to kill process: %s \n " , destroy_error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
}
}
}
return result . Succeeded ( ) ;
}
std : : string m_new_process_action ;
} ;
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessLaunch
//-------------------------------------------------------------------------
2012-02-16 14:50:00 +08:00
# pragma mark CommandObjectProcessLaunch
2013-03-29 08:56:30 +08:00
class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
2010-06-09 00:52:24 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessLaunch ( CommandInterpreter & interpreter ) :
2013-03-29 08:56:30 +08:00
CommandObjectProcessLaunchOrAttach ( interpreter ,
" process launch " ,
" Launch the executable in the debugger. " ,
NULL ,
eFlagRequiresTarget ,
" restart " ) ,
2011-04-08 06:46:35 +08:00
m_options ( interpreter )
2010-06-09 00:52:24 +08:00
{
2010-10-05 06:28:36 +08:00
CommandArgumentEntry arg ;
CommandArgumentData run_args_arg ;
// Define the first (and only) variant of this arg.
run_args_arg . arg_type = eArgTypeRunArgs ;
run_args_arg . arg_repetition = eArgRepeatOptional ;
// There is only one variant this argument could be; put it into the argument entry.
arg . push_back ( run_args_arg ) ;
// Push the data for the first argument into the m_arguments vector.
m_arguments . push_back ( arg ) ;
2010-06-09 00:52:24 +08:00
}
~ CommandObjectProcessLaunch ( )
{
}
2013-01-26 02:06:21 +08:00
virtual int
2012-08-11 05:48:41 +08:00
HandleArgumentCompletion ( Args & input ,
int & cursor_index ,
int & cursor_char_position ,
OptionElementVector & opt_element_vector ,
int match_start_point ,
int max_return_elements ,
bool & word_complete ,
StringList & matches )
{
std : : string completion_str ( input . GetArgumentAtIndex ( cursor_index ) ) ;
completion_str . erase ( cursor_char_position ) ;
CommandCompletions : : InvokeCommonCompletionCallbacks ( m_interpreter ,
CommandCompletions : : eDiskFileCompletion ,
completion_str . c_str ( ) ,
match_start_point ,
max_return_elements ,
NULL ,
word_complete ,
matches ) ;
return matches . GetSize ( ) ;
}
2010-06-09 00:52:24 +08:00
Options *
GetOptions ( )
{
return & m_options ;
}
2012-06-09 05:56:10 +08:00
virtual const char * GetRepeatCommand ( Args & current_command_args , uint32_t index )
{
// No repeat for "process launch"...
return " " ;
}
protected :
2010-06-09 00:52:24 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & launch_args , CommandReturnObject & result )
2010-06-09 00:52:24 +08:00
{
2011-11-08 10:43:13 +08:00
Debugger & debugger = m_interpreter . GetDebugger ( ) ;
Target * target = debugger . GetSelectedTarget ( ) . get ( ) ;
2010-06-09 00:52:24 +08:00
// If our listener is NULL, users aren't allows to launch
2013-12-14 01:20:18 +08:00
ModuleSP exe_module_sp = target - > GetExecutableModule ( ) ;
2011-02-25 06:24:29 +08:00
2013-12-14 01:20:18 +08:00
if ( exe_module_sp = = NULL )
2011-02-25 06:24:29 +08:00
{
2011-05-04 06:09:39 +08:00
result . AppendError ( " no file in target, create a debug target using the 'target create' command " ) ;
2011-02-25 06:24:29 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
StateType state = eStateInvalid ;
2013-12-14 01:20:18 +08:00
if ( ! StopProcessIfNecessary ( m_exe_ctx . GetProcessPtr ( ) , state , result ) )
2013-03-29 08:56:30 +08:00
return false ;
2010-12-10 02:58:16 +08:00
2012-10-18 06:57:12 +08:00
const char * target_settings_argv0 = target - > GetArg0 ( ) ;
2014-08-20 01:40:43 +08:00
// Determine whether we will disable ASLR or leave it in the default state (i.e. enabled if the platform supports it).
// First check if the process launch options explicitly turn on/off disabling ASLR. If so, use that setting;
// otherwise, use the 'settings target.disable-aslr' setting.
bool disable_aslr = false ;
if ( m_options . disable_aslr ! = eLazyBoolCalculate )
{
// The user specified an explicit setting on the process launch line. Use it.
disable_aslr = ( m_options . disable_aslr = = eLazyBoolYes ) ;
}
else
{
// The user did not explicitly specify whether to disable ASLR. Fall back to the target.disable-aslr setting.
disable_aslr = target - > GetDisableASLR ( ) ;
}
if ( disable_aslr )
2013-12-14 01:20:18 +08:00
m_options . launch_info . GetFlags ( ) . Set ( eLaunchFlagDisableASLR ) ;
2014-08-20 01:40:43 +08:00
else
m_options . launch_info . GetFlags ( ) . Clear ( eLaunchFlagDisableASLR ) ;
2013-12-14 01:20:18 +08:00
2014-06-25 10:32:56 +08:00
if ( target - > GetDetachOnError ( ) )
m_options . launch_info . GetFlags ( ) . Set ( eLaunchFlagDetachOnError ) ;
2013-12-14 01:20:18 +08:00
if ( target - > GetDisableSTDIO ( ) )
m_options . launch_info . GetFlags ( ) . Set ( eLaunchFlagDisableSTDIO ) ;
2012-10-18 06:57:12 +08:00
2013-12-14 01:20:18 +08:00
Args environment ;
target - > GetEnvironmentAsArgs ( environment ) ;
if ( environment . GetArgumentCount ( ) > 0 )
m_options . launch_info . GetEnvironmentEntries ( ) . AppendArguments ( environment ) ;
2012-10-18 06:57:12 +08:00
if ( target_settings_argv0 )
{
m_options . launch_info . GetArguments ( ) . AppendArgument ( target_settings_argv0 ) ;
2013-12-14 01:20:18 +08:00
m_options . launch_info . SetExecutableFile ( exe_module_sp - > GetPlatformFileSpec ( ) , false ) ;
2012-10-18 06:57:12 +08:00
}
else
{
2013-12-14 01:20:18 +08:00
m_options . launch_info . SetExecutableFile ( exe_module_sp - > GetPlatformFileSpec ( ) , true ) ;
2012-10-18 06:57:12 +08:00
}
2011-11-15 11:53:30 +08:00
if ( launch_args . GetArgumentCount ( ) = = 0 )
{
2012-08-23 01:17:09 +08:00
Args target_setting_args ;
2012-10-18 06:57:12 +08:00
if ( target - > GetRunArguments ( target_setting_args ) )
2012-08-23 01:17:09 +08:00
m_options . launch_info . GetArguments ( ) . AppendArguments ( target_setting_args ) ;
2011-11-15 11:53:30 +08:00
}
else
2010-09-04 08:03:46 +08:00
{
2012-10-18 06:57:12 +08:00
m_options . launch_info . GetArguments ( ) . AppendArguments ( launch_args ) ;
2011-11-22 05:51:18 +08:00
// Save the arguments for subsequent runs in the current target.
target - > SetRunArguments ( launch_args ) ;
2011-11-04 05:22:33 +08:00
}
2014-10-21 09:00:42 +08:00
StreamString stream ;
2014-11-18 03:39:20 +08:00
Error error = target - > Launch ( m_options . launch_info , & stream ) ;
2013-03-29 08:56:30 +08:00
2010-09-18 09:14:36 +08:00
if ( error . Success ( ) )
2010-06-09 00:52:24 +08:00
{
2013-12-14 01:20:18 +08:00
const char * archname = exe_module_sp - > GetArchitecture ( ) . GetArchitectureName ( ) ;
ProcessSP process_sp ( target - > GetProcessSP ( ) ) ;
if ( process_sp )
2010-06-09 00:52:24 +08:00
{
2014-10-21 09:00:42 +08:00
if ( stream . GetData ( ) )
result . AppendMessage ( stream . GetData ( ) ) ;
2013-12-14 01:20:18 +08:00
result . AppendMessageWithFormat ( " Process % " PRIu64 " launched: '%s' (%s) \n " , process_sp - > GetID ( ) , exe_module_sp - > GetFileSpec ( ) . GetPath ( ) . c_str ( ) , archname ) ;
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
result . SetDidChangeProcessState ( true ) ;
}
else
{
result . AppendError ( " no error returned from Target::Launch, and target has no process " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2010-06-09 00:52:24 +08:00
}
}
2011-02-16 05:59:32 +08:00
else
{
2013-12-14 01:20:18 +08:00
result . AppendError ( error . AsCString ( ) ) ;
2011-02-16 05:59:32 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
}
2010-06-09 00:52:24 +08:00
return result . Succeeded ( ) ;
}
protected :
2011-11-04 05:22:33 +08:00
ProcessLaunchCommandOptions m_options ;
2010-06-09 00:52:24 +08:00
} ;
2011-11-04 05:22:33 +08:00
//#define SET1 LLDB_OPT_SET_1
//#define SET2 LLDB_OPT_SET_2
//#define SET3 LLDB_OPT_SET_3
//
//OptionDefinition
//CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
//{
2013-09-06 00:42:23 +08:00
//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, NULL, 0, eArgTypeDirectoryName, "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
2011-11-04 05:22:33 +08:00
//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
//};
//
//#undef SET1
//#undef SET2
//#undef SET3
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessAttach
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessAttach
2013-03-29 08:56:30 +08:00
class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
2010-06-09 00:52:24 +08:00
{
public :
class CommandOptions : public Options
{
public :
2011-04-08 06:46:35 +08:00
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
2010-06-09 00:52:24 +08:00
{
2011-04-13 08:18:08 +08:00
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ( ) ;
2010-06-09 00:52:24 +08:00
}
~ CommandOptions ( )
{
}
Error
2011-04-13 08:18:08 +08:00
SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-06-09 00:52:24 +08:00
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
2010-06-09 00:52:24 +08:00
bool success = false ;
switch ( short_option )
{
2012-05-24 08:43:00 +08:00
case ' c ' :
attach_info . SetContinueOnceAttached ( true ) ;
break ;
2010-06-09 00:52:24 +08:00
case ' p ' :
{
2011-11-15 11:53:30 +08:00
lldb : : pid_t pid = Args : : StringToUInt32 ( option_arg , LLDB_INVALID_PROCESS_ID , 0 , & success ) ;
if ( ! success | | pid = = LLDB_INVALID_PROCESS_ID )
{
error . SetErrorStringWithFormat ( " invalid process ID '%s' " , option_arg ) ;
}
else
{
attach_info . SetProcessID ( pid ) ;
}
2010-06-09 00:52:24 +08:00
}
break ;
case ' P ' :
2011-11-15 11:53:30 +08:00
attach_info . SetProcessPluginName ( option_arg ) ;
2010-06-09 00:52:24 +08:00
break ;
case ' n ' :
2011-11-15 11:53:30 +08:00
attach_info . GetExecutableFile ( ) . SetFile ( option_arg , false ) ;
2010-06-09 00:52:24 +08:00
break ;
case ' w ' :
2011-11-15 11:53:30 +08:00
attach_info . SetWaitForLaunch ( true ) ;
2010-06-09 00:52:24 +08:00
break ;
2012-07-21 05:37:13 +08:00
case ' i ' :
attach_info . SetIgnoreExisting ( false ) ;
break ;
2010-06-09 00:52:24 +08:00
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid short option character '%c' " , short_option ) ;
2010-06-09 00:52:24 +08:00
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( )
2010-06-09 00:52:24 +08:00
{
2011-11-15 11:53:30 +08:00
attach_info . Clear ( ) ;
2010-06-09 00:52:24 +08:00
}
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-06-09 00:52:24 +08:00
GetDefinitions ( )
{
return g_option_table ;
}
2010-08-10 07:31:02 +08:00
virtual bool
2011-04-08 06:46:35 +08:00
HandleOptionArgumentCompletion ( Args & input ,
2010-08-10 07:31:02 +08:00
int cursor_index ,
int char_pos ,
OptionElementVector & opt_element_vector ,
int opt_element_index ,
int match_start_point ,
int max_return_elements ,
bool & word_complete ,
StringList & matches )
{
int opt_arg_pos = opt_element_vector [ opt_element_index ] . opt_arg_pos ;
int opt_defs_index = opt_element_vector [ opt_element_index ] . opt_defs_index ;
// We are only completing the name option for now...
2011-03-25 05:19:54 +08:00
const OptionDefinition * opt_defs = GetDefinitions ( ) ;
2010-08-10 07:31:02 +08:00
if ( opt_defs [ opt_defs_index ] . short_option = = ' n ' )
{
// Are we in the name?
// Look to see if there is a -P argument provided, and if so use that plugin, otherwise
// use the default plugin.
const char * partial_name = NULL ;
partial_name = input . GetArgumentAtIndex ( opt_arg_pos ) ;
2011-03-09 06:40:15 +08:00
2011-04-12 13:54:46 +08:00
PlatformSP platform_sp ( m_interpreter . GetPlatform ( true ) ) ;
2011-03-09 06:40:15 +08:00
if ( platform_sp )
2010-08-10 07:31:02 +08:00
{
2011-04-12 13:54:46 +08:00
ProcessInstanceInfoList process_infos ;
ProcessInstanceInfoMatch match_info ;
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
if ( partial_name )
{
2011-11-15 11:53:30 +08:00
match_info . GetProcessInfo ( ) . GetExecutableFile ( ) . SetFile ( partial_name , false ) ;
Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:
int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff
// Platform subclass specific code...
int result = ...
return result;
}
Added new functions to the platform:
virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);
The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.
Added the parent process ID to the ProcessInfo class.
Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.
This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:
machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver
This of course also works remotely with the lldb-platform:
machine1.foo.com % lldb-platform --listen 1234
machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.
Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:
% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out
Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.
Modified the disassembly to show the current PC value. Example output:
(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret
This can be handy when dealing with the new --line options that was recently
added:
(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.
Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:
const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;
llvm-svn: 128563
2011-03-31 02:16:51 +08:00
match_info . SetNameMatchType ( eNameMatchStartsWith ) ;
}
platform_sp - > FindProcesses ( match_info , process_infos ) ;
2013-01-26 02:06:21 +08:00
const size_t num_matches = process_infos . GetSize ( ) ;
2011-03-09 06:40:15 +08:00
if ( num_matches > 0 )
{
2013-01-26 02:06:21 +08:00
for ( size_t i = 0 ; i < num_matches ; + + i )
2011-03-09 06:40:15 +08:00
{
matches . AppendString ( process_infos . GetProcessNameAtIndex ( i ) ,
process_infos . GetProcessNameLengthAtIndex ( i ) ) ;
}
}
2010-08-10 07:31:02 +08:00
}
}
return false ;
}
2010-06-09 00:52:24 +08:00
// Options table: Required for subclasses of Options.
2011-03-25 05:19:54 +08:00
static OptionDefinition g_option_table [ ] ;
2010-06-09 00:52:24 +08:00
// Instance variables to hold the values for command options.
2011-11-15 11:53:30 +08:00
ProcessAttachInfo attach_info ;
2010-06-09 00:52:24 +08:00
} ;
2010-09-18 09:14:36 +08:00
CommandObjectProcessAttach ( CommandInterpreter & interpreter ) :
2013-03-29 08:56:30 +08:00
CommandObjectProcessLaunchOrAttach ( interpreter ,
" process attach " ,
" Attach to a process. " ,
" process attach <cmd-options> " ,
0 ,
" attach " ) ,
2011-04-08 06:46:35 +08:00
m_options ( interpreter )
2010-08-10 07:31:02 +08:00
{
}
~ CommandObjectProcessAttach ( )
{
}
2012-06-09 05:56:10 +08:00
Options *
GetOptions ( )
{
return & m_options ;
}
protected :
2010-08-10 07:31:02 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2010-08-10 07:31:02 +08:00
CommandReturnObject & result )
{
2010-09-18 09:14:36 +08:00
Target * target = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) . get ( ) ;
2011-09-15 09:08:57 +08:00
// 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
// ourselves here.
2011-01-29 09:49:25 +08:00
2011-02-25 06:24:29 +08:00
StateType state = eStateInvalid ;
2013-03-29 08:56:30 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
if ( ! StopProcessIfNecessary ( process , state , result ) )
return false ;
2010-08-10 07:31:02 +08:00
if ( target = = NULL )
{
// If there isn't a current target create one.
TargetSP new_target_sp ;
Error error ;
2010-09-18 09:14:36 +08:00
error = m_interpreter . GetDebugger ( ) . GetTargetList ( ) . CreateTarget ( m_interpreter . GetDebugger ( ) ,
2012-10-19 00:33:33 +08:00
NULL ,
2011-09-24 08:52:29 +08:00
NULL ,
2010-09-18 09:14:36 +08:00
false ,
2011-09-24 08:52:29 +08:00
NULL , // No platform options
2010-09-18 09:14:36 +08:00
new_target_sp ) ;
2010-08-10 07:31:02 +08:00
target = new_target_sp . get ( ) ;
if ( target = = NULL | | error . Fail ( ) )
{
2011-02-04 09:58:07 +08:00
result . AppendError ( error . AsCString ( " Error creating target " ) ) ;
2010-08-10 07:31:02 +08:00
return false ;
}
2010-09-18 09:14:36 +08:00
m_interpreter . GetDebugger ( ) . GetTargetList ( ) . SetSelectedTarget ( target ) ;
2010-08-10 07:31:02 +08:00
}
// Record the old executable module, we want to issue a warning if the process of attaching changed the
// current executable (like somebody said "file foo" then attached to a PID whose executable was bar.)
ModuleSP old_exec_module_sp = target - > GetExecutableModule ( ) ;
ArchSpec old_arch_spec = target - > GetArchitecture ( ) ;
if ( command . GetArgumentCount ( ) )
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " Invalid arguments for '%s'. \n Usage: %s \n " , m_cmd_name . c_str ( ) , m_cmd_syntax . c_str ( ) ) ;
2010-08-10 07:31:02 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
}
else
{
2011-02-25 06:24:29 +08:00
if ( state ! = eStateConnected )
{
2011-11-15 11:53:30 +08:00
const char * plugin_name = m_options . attach_info . GetProcessPluginName ( ) ;
2012-02-09 14:16:32 +08:00
process = target - > CreateProcess ( m_interpreter . GetDebugger ( ) . GetListener ( ) , plugin_name , NULL ) . get ( ) ;
2011-02-25 06:24:29 +08:00
}
2010-08-10 07:31:02 +08:00
if ( process )
{
Error error ;
2011-11-15 11:53:30 +08:00
// 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 ( ) )
2010-09-15 09:34:14 +08:00
{
if ( old_exec_module_sp )
2011-11-29 12:03:30 +08:00
m_options . attach_info . GetExecutableFile ( ) . GetFilename ( ) = old_exec_module_sp - > GetPlatformFileSpec ( ) . GetFilename ( ) ;
2011-11-15 11:53:30 +08:00
if ( ! m_options . attach_info . ProcessInfoSpecified ( ) )
2010-09-15 09:34:14 +08:00
{
2011-11-15 11:53:30 +08:00
error . SetErrorString ( " no process specified, create a target with a file, or specify the --pid or --name command option " ) ;
2010-09-15 09:34:14 +08:00
}
}
2011-11-15 11:53:30 +08:00
if ( error . Success ( ) )
{
2014-07-31 01:38:47 +08:00
// Update the execution context so the current target and process are now selected
// in case we interrupt
m_interpreter . UpdateExecutionContext ( NULL ) ;
2014-01-28 07:43:24 +08:00
ListenerSP listener_sp ( new Listener ( " lldb.CommandObjectProcessAttach.DoExecute.attach.hijack " ) ) ;
m_options . attach_info . SetHijackListener ( listener_sp ) ;
process - > HijackProcessEvents ( listener_sp . get ( ) ) ;
2011-11-15 11:53:30 +08:00
error = process - > Attach ( m_options . attach_info ) ;
2010-09-15 09:34:14 +08:00
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessContinuingNoResult ) ;
2014-10-21 09:00:42 +08:00
StreamString stream ;
StateType state = process - > WaitForProcessToStop ( NULL , NULL , false , listener_sp . get ( ) , & stream ) ;
2012-05-18 08:51:36 +08:00
2014-01-28 07:43:24 +08:00
process - > RestoreProcessEvents ( ) ;
result . SetDidChangeProcessState ( true ) ;
2014-10-21 09:00:42 +08:00
if ( stream . GetData ( ) )
result . AppendMessage ( stream . GetData ( ) ) ;
2014-01-28 07:43:24 +08:00
if ( state = = eStateStopped )
{
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
2014-07-31 01:38:47 +08:00
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?) " ) ;
2014-01-28 07:43:24 +08:00
process - > Destroy ( ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
2012-05-18 08:51:36 +08:00
}
else
{
2014-01-28 07:43:24 +08:00
result . AppendErrorWithFormat ( " attach failed: %s \n " , error . AsCString ( ) ) ;
2012-05-18 08:51:36 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
}
2010-08-10 07:31:02 +08:00
}
}
}
if ( result . Succeeded ( ) )
{
// Okay, we're done. Last step is to warn if the executable module has changed:
2011-01-29 15:10:55 +08:00
char new_path [ PATH_MAX ] ;
2011-08-11 10:48:45 +08:00
ModuleSP new_exec_module_sp ( target - > GetExecutableModule ( ) ) ;
2010-08-10 07:31:02 +08:00
if ( ! old_exec_module_sp )
{
2011-01-29 15:10:55 +08:00
// We might not have a module if we attached to a raw pid...
2011-08-11 10:48:45 +08:00
if ( new_exec_module_sp )
2011-01-29 15:10:55 +08:00
{
2011-08-11 10:48:45 +08:00
new_exec_module_sp - > GetFileSpec ( ) . GetPath ( new_path , PATH_MAX ) ;
2011-01-29 15:10:55 +08:00
result . AppendMessageWithFormat ( " Executable module set to \" %s \" . \n " , new_path ) ;
}
2010-08-10 07:31:02 +08:00
}
2011-08-11 10:48:45 +08:00
else if ( old_exec_module_sp - > GetFileSpec ( ) ! = new_exec_module_sp - > GetFileSpec ( ) )
2010-08-10 07:31:02 +08:00
{
2011-01-29 15:10:55 +08:00
char old_path [ PATH_MAX ] ;
2010-08-10 07:31:02 +08:00
2011-08-11 10:48:45 +08:00
old_exec_module_sp - > GetFileSpec ( ) . GetPath ( old_path , PATH_MAX ) ;
new_exec_module_sp - > GetFileSpec ( ) . GetPath ( new_path , PATH_MAX ) ;
2010-08-10 07:31:02 +08:00
result . AppendWarningWithFormat ( " Executable module changed from \" %s \" to \" %s \" . \n " ,
old_path , new_path ) ;
}
if ( ! old_arch_spec . IsValid ( ) )
{
2012-09-14 10:41:36 +08:00
result . AppendMessageWithFormat ( " Architecture set to: %s. \n " , target - > GetArchitecture ( ) . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2010-08-10 07:31:02 +08:00
}
2012-12-14 06:07:14 +08:00
else if ( ! old_arch_spec . IsExactMatch ( target - > GetArchitecture ( ) ) )
2010-08-10 07:31:02 +08:00
{
result . AppendWarningWithFormat ( " Architecture changed from %s to %s. \n " ,
2012-09-14 10:41:36 +08:00
old_arch_spec . GetTriple ( ) . getTriple ( ) . c_str ( ) ,
target - > GetArchitecture ( ) . GetTriple ( ) . getTriple ( ) . c_str ( ) ) ;
2010-08-10 07:31:02 +08:00
}
2012-05-24 08:43:00 +08:00
// This supports the use-case scenario of immediately continuing the process once attached.
if ( m_options . attach_info . GetContinueOnceAttached ( ) )
2012-05-31 09:30:08 +08:00
m_interpreter . HandleCommand ( " process continue " , eLazyBoolNo , result ) ;
2010-08-10 07:31:02 +08:00
}
return result . Succeeded ( ) ;
}
2010-06-09 00:52:24 +08:00
CommandOptions m_options ;
} ;
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-06-09 00:52:24 +08:00
CommandObjectProcessAttach : : CommandOptions : : g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_ALL , false , " continue " , ' c ' , OptionParser : : eNoArgument , NULL , NULL , 0 , eArgTypeNone , " Immediately continue the process once attached. " } ,
{ LLDB_OPT_SET_ALL , false , " plugin " , ' P ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypePlugin , " Name of the process plugin you want to use. " } ,
{ LLDB_OPT_SET_1 , false , " pid " , ' p ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypePid , " The process ID of an existing process to attach to. " } ,
{ LLDB_OPT_SET_2 , false , " name " , ' n ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeProcessName , " The name of the process to attach to. " } ,
{ LLDB_OPT_SET_2 , false , " include-existing " , ' i ' , OptionParser : : eNoArgument , NULL , NULL , 0 , eArgTypeNone , " Include existing processes when doing attach -w. " } ,
{ LLDB_OPT_SET_2 , false , " waitfor " , ' w ' , OptionParser : : eNoArgument , NULL , NULL , 0 , eArgTypeNone , " Wait for the process with <process-name> to launch. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , NULL , 0 , eArgTypeNone , NULL }
2010-06-09 00:52:24 +08:00
} ;
//-------------------------------------------------------------------------
// CommandObjectProcessContinue
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessContinue
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessContinue : public CommandObjectParsed
2010-06-09 00:52:24 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessContinue ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process continue " ,
" Continue execution of all threads in the current process. " ,
" process continue " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched |
eFlagProcessMustBePaused ) ,
2012-08-11 09:27:55 +08:00
m_options ( interpreter )
2010-06-09 00:52:24 +08:00
{
}
~ CommandObjectProcessContinue ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2012-08-11 09:27:55 +08:00
class CommandOptions : public Options
{
public :
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
{
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ( ) ;
}
~ CommandOptions ( )
{
}
Error
SetOptionValue ( uint32_t option_idx , const char * option_arg )
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
2012-08-11 09:27:55 +08:00
bool success = false ;
switch ( short_option )
{
case ' i ' :
m_ignore = Args : : StringToUInt32 ( option_arg , 0 , 0 , & success ) ;
if ( ! success )
error . SetErrorStringWithFormat ( " invalid value for ignore option: \" %s \" , should be a number. " , option_arg ) ;
break ;
default :
error . SetErrorStringWithFormat ( " invalid short option character '%c' " , short_option ) ;
break ;
}
return error ;
}
void
OptionParsingStarting ( )
{
m_ignore = 0 ;
}
const OptionDefinition *
GetDefinitions ( )
{
return g_option_table ;
}
// Options table: Required for subclasses of Options.
static OptionDefinition g_option_table [ ] ;
uint32_t m_ignore ;
} ;
2010-06-09 00:52:24 +08:00
bool
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
DoExecute ( Args & command , CommandReturnObject & result )
2010-06-09 00:52:24 +08:00
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-09-18 09:14:36 +08:00
bool synchronous_execution = m_interpreter . GetSynchronous ( ) ;
2010-06-09 00:52:24 +08:00
StateType state = process - > GetState ( ) ;
if ( state = = eStateStopped )
{
if ( command . GetArgumentCount ( ) ! = 0 )
{
result . AppendErrorWithFormat ( " The '%s' command does not take any arguments. \n " , m_cmd_name . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
2012-08-11 09:27:55 +08:00
if ( m_options . m_ignore > 0 )
{
ThreadSP sel_thread_sp ( process - > GetThreadList ( ) . GetSelectedThread ( ) ) ;
if ( sel_thread_sp )
{
StopInfoSP stop_info_sp = sel_thread_sp - > GetStopInfo ( ) ;
if ( stop_info_sp & & stop_info_sp - > GetStopReason ( ) = = eStopReasonBreakpoint )
{
2013-01-26 02:06:21 +08:00
lldb : : break_id_t bp_site_id = ( lldb : : break_id_t ) stop_info_sp - > GetValue ( ) ;
2012-08-11 09:27:55 +08:00
BreakpointSiteSP bp_site_sp ( process - > GetBreakpointSiteList ( ) . FindByID ( bp_site_id ) ) ;
if ( bp_site_sp )
{
2013-01-26 02:06:21 +08:00
const size_t num_owners = bp_site_sp - > GetNumberOfOwners ( ) ;
for ( size_t i = 0 ; i < num_owners ; i + + )
2012-08-11 09:27:55 +08:00
{
Breakpoint & bp_ref = bp_site_sp - > GetOwnerAtIndex ( i ) - > GetBreakpoint ( ) ;
if ( ! bp_ref . IsInternal ( ) )
{
bp_ref . SetIgnoreCount ( m_options . m_ignore ) ;
}
}
}
}
}
}
2012-09-11 04:50:15 +08:00
{ // Scope for thread list mutex:
Mutex : : Locker locker ( process - > GetThreadList ( ) . GetMutex ( ) ) ;
const uint32_t num_threads = process - > GetThreadList ( ) . GetSize ( ) ;
2010-06-09 00:52:24 +08:00
2012-09-11 04:50:15 +08:00
// Set the actions that the threads should each take when resuming
for ( uint32_t idx = 0 ; idx < num_threads ; + + idx )
{
2014-04-03 09:26:14 +08:00
const bool override_suspend = false ;
process - > GetThreadList ( ) . GetThreadAtIndex ( idx ) - > SetResumeState ( eStateRunning , override_suspend ) ;
2012-09-11 04:50:15 +08:00
}
2010-06-09 00:52:24 +08:00
}
2014-08-12 22:33:19 +08:00
2014-10-21 09:00:42 +08:00
StreamString stream ;
Error error ;
if ( synchronous_execution )
error = process - > ResumeSynchronous ( & stream ) ;
else
error = process - > Resume ( ) ;
2014-08-12 22:33:19 +08:00
2010-06-09 00:52:24 +08:00
if ( error . Success ( ) )
{
2014-08-12 22:33:19 +08:00
// There is a race condition where this thread will return up the call stack to the main command
// handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
// a chance to call PushProcessIOHandler().
process - > SyncIOHandler ( 2000 ) ;
2012-11-30 05:49:15 +08:00
result . AppendMessageWithFormat ( " Process % " PRIu64 " resuming \n " , process - > GetID ( ) ) ;
2010-06-09 00:52:24 +08:00
if ( synchronous_execution )
{
2014-10-21 09:00:42 +08:00
// If any state changed events had anything to say, add that to the result
if ( stream . GetData ( ) )
result . AppendMessage ( stream . GetData ( ) ) ;
2010-06-09 00:52:24 +08:00
result . SetDidChangeProcessState ( true ) ;
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
}
else
{
result . SetStatus ( eReturnStatusSuccessContinuingNoResult ) ;
}
}
else
{
result . AppendErrorWithFormat ( " Failed to resume process: %s. \n " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
result . AppendErrorWithFormat ( " Process cannot be continued from its current state (%s). \n " ,
StateAsCString ( state ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
2012-08-11 09:27:55 +08:00
Options *
GetOptions ( )
{
return & m_options ;
}
CommandOptions m_options ;
} ;
OptionDefinition
CommandObjectProcessContinue : : CommandOptions : : g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_ALL , false , " ignore-count " , ' i ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeUnsignedInteger ,
2012-08-11 09:27:55 +08:00
" Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread. " } ,
2014-07-10 00:31:49 +08:00
{ 0 , false , NULL , 0 , 0 , NULL , NULL , 0 , eArgTypeNone , NULL }
2010-06-09 00:52:24 +08:00
} ;
//-------------------------------------------------------------------------
// CommandObjectProcessDetach
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessDetach
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessDetach : public CommandObjectParsed
2010-06-09 00:52:24 +08:00
{
public :
2013-05-02 08:27:30 +08:00
class CommandOptions : public Options
{
public :
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
{
OptionParsingStarting ( ) ;
}
~ CommandOptions ( )
{
}
Error
SetOptionValue ( uint32_t option_idx , const char * option_arg )
{
Error error ;
const int short_option = m_getopt_table [ option_idx ] . val ;
switch ( short_option )
{
case ' s ' :
bool tmp_result ;
bool success ;
tmp_result = Args : : StringToBoolean ( option_arg , false , & success ) ;
if ( ! success )
error . SetErrorStringWithFormat ( " invalid boolean option: \" %s \" " , option_arg ) ;
else
{
if ( tmp_result )
m_keep_stopped = eLazyBoolYes ;
else
m_keep_stopped = eLazyBoolNo ;
}
break ;
default :
error . SetErrorStringWithFormat ( " invalid short option character '%c' " , short_option ) ;
break ;
}
return error ;
}
void
OptionParsingStarting ( )
{
m_keep_stopped = eLazyBoolCalculate ;
}
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.
LazyBool m_keep_stopped ;
} ;
2010-06-09 00:52:24 +08:00
2010-09-18 09:14:36 +08:00
CommandObjectProcessDetach ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process detach " ,
" Detach from the current process being debugged. " ,
" process detach " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
2013-05-02 08:27:30 +08:00
eFlagProcessMustBeLaunched ) ,
m_options ( interpreter )
2010-06-09 00:52:24 +08:00
{
}
~ CommandObjectProcessDetach ( )
{
}
2013-05-02 08:27:30 +08:00
Options *
GetOptions ( )
{
return & m_options ;
}
2012-06-09 05:56:10 +08:00
protected :
2010-06-09 00:52:24 +08:00
bool
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
DoExecute ( Args & command , CommandReturnObject & result )
2010-06-09 00:52:24 +08:00
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2013-05-02 08:27:30 +08:00
// FIXME: This will be a Command Option:
bool keep_stopped ;
if ( m_options . m_keep_stopped = = eLazyBoolCalculate )
{
// Check the process default:
if ( process - > GetDetachKeepsStopped ( ) )
keep_stopped = true ;
else
keep_stopped = false ;
}
else if ( m_options . m_keep_stopped = = eLazyBoolYes )
keep_stopped = true ;
else
keep_stopped = false ;
Error error ( process - > Detach ( keep_stopped ) ) ;
2010-06-09 00:52:24 +08:00
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " Detach failed: %s \n " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
return result . Succeeded ( ) ;
}
2013-05-02 08:27:30 +08:00
CommandOptions m_options ;
} ;
OptionDefinition
CommandObjectProcessDetach : : CommandOptions : : g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_1 , false , " keep-stopped " , ' s ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeBoolean , " Whether or not the process should be kept stopped on detach (if possible). " } ,
{ 0 , false , NULL , 0 , 0 , NULL , NULL , 0 , eArgTypeNone , NULL }
2010-06-09 00:52:24 +08:00
} ;
2011-02-04 09:58:07 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessConnect
//-------------------------------------------------------------------------
# pragma mark CommandObjectProcessConnect
2012-06-09 05:56:10 +08:00
class CommandObjectProcessConnect : public CommandObjectParsed
2011-02-04 09:58:07 +08:00
{
public :
class CommandOptions : public Options
{
public :
2011-04-08 06:46:35 +08:00
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
2011-02-04 09:58:07 +08:00
{
2011-04-13 08:18:08 +08:00
// Keep default values of all options in one place: OptionParsingStarting ()
OptionParsingStarting ( ) ;
2011-02-04 09:58:07 +08:00
}
~ CommandOptions ( )
{
}
Error
2011-04-13 08:18:08 +08:00
SetOptionValue ( uint32_t option_idx , const char * option_arg )
2011-02-04 09:58:07 +08:00
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
2011-02-04 09:58:07 +08:00
switch ( short_option )
{
case ' p ' :
plugin_name . assign ( option_arg ) ;
break ;
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid short option character '%c' " , short_option ) ;
2011-02-04 09:58:07 +08:00
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( )
2011-02-04 09:58:07 +08:00
{
plugin_name . clear ( ) ;
}
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2011-02-04 09:58:07 +08:00
GetDefinitions ( )
{
return g_option_table ;
}
// Options table: Required for subclasses of Options.
2011-03-25 05:19:54 +08:00
static OptionDefinition g_option_table [ ] ;
2011-02-04 09:58:07 +08:00
// Instance variables to hold the values for command options.
std : : string plugin_name ;
} ;
CommandObjectProcessConnect ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process connect " ,
" Connect to a remote debug service. " ,
" process connect <remote-url> " ,
0 ) ,
2011-04-08 06:46:35 +08:00
m_options ( interpreter )
2011-02-04 09:58:07 +08:00
{
}
~ CommandObjectProcessConnect ( )
{
}
2012-06-09 05:56:10 +08:00
Options *
GetOptions ( )
{
return & m_options ;
}
protected :
2011-02-04 09:58:07 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2011-02-04 09:58:07 +08:00
CommandReturnObject & result )
{
TargetSP target_sp ( m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) ) ;
Error error ;
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2011-02-04 09:58:07 +08:00
if ( process )
{
if ( process - > IsAlive ( ) )
{
2012-11-30 05:49:15 +08:00
result . AppendErrorWithFormat ( " Process % " PRIu64 " is currently being debugged, kill the process before connecting. \n " ,
2011-02-04 09:58:07 +08:00
process - > GetID ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
}
if ( ! target_sp )
{
// If there isn't a current target create one.
error = m_interpreter . GetDebugger ( ) . GetTargetList ( ) . CreateTarget ( m_interpreter . GetDebugger ( ) ,
2012-10-19 00:33:33 +08:00
NULL ,
2011-09-24 08:52:29 +08:00
NULL ,
2011-02-04 09:58:07 +08:00
false ,
2011-09-24 08:52:29 +08:00
NULL , // No platform options
2011-02-04 09:58:07 +08:00
target_sp ) ;
if ( ! target_sp | | error . Fail ( ) )
{
result . AppendError ( error . AsCString ( " Error creating target " ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
m_interpreter . GetDebugger ( ) . GetTargetList ( ) . SetSelectedTarget ( target_sp . get ( ) ) ;
}
if ( command . GetArgumentCount ( ) = = 1 )
{
const char * plugin_name = NULL ;
if ( ! m_options . plugin_name . empty ( ) )
plugin_name = m_options . plugin_name . c_str ( ) ;
const char * remote_url = command . GetArgumentAtIndex ( 0 ) ;
2012-02-09 14:16:32 +08:00
process = target_sp - > CreateProcess ( m_interpreter . GetDebugger ( ) . GetListener ( ) , plugin_name , NULL ) . get ( ) ;
2011-02-04 09:58:07 +08:00
if ( process )
{
2014-01-28 07:43:24 +08:00
error = process - > ConnectRemote ( process - > GetTarget ( ) . GetDebugger ( ) . GetOutputFile ( ) . get ( ) , remote_url ) ;
2011-02-04 09:58:07 +08:00
if ( error . Fail ( ) )
{
result . AppendError ( error . AsCString ( " Remote connect failed " ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
2012-03-31 08:10:30 +08:00
target_sp - > DeleteCurrentProcess ( ) ;
2011-02-04 09:58:07 +08:00
return false ;
}
}
else
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " Unable to find process plug-in for remote URL '%s'. \n Please specify a process plug-in name with the --plugin option, or specify an object file using the \" file \" command. \n " ,
2012-12-19 04:00:40 +08:00
remote_url ) ;
2011-02-04 09:58:07 +08:00
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " '%s' takes exactly one argument: \n Usage: %s \n " ,
2011-02-04 09:58:07 +08:00
m_cmd_name . c_str ( ) ,
m_cmd_syntax . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
CommandOptions m_options ;
} ;
2011-03-25 05:19:54 +08:00
OptionDefinition
2011-02-04 09:58:07 +08:00
CommandObjectProcessConnect : : CommandOptions : : g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_ALL , false , " plugin " , ' p ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypePlugin , " Name of the process plugin you want to use. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , NULL , 0 , eArgTypeNone , NULL }
2011-02-04 09:58:07 +08:00
} ;
2012-10-13 10:07:45 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessPlugin
//-------------------------------------------------------------------------
# pragma mark CommandObjectProcessPlugin
class CommandObjectProcessPlugin : public CommandObjectProxy
{
public :
CommandObjectProcessPlugin ( CommandInterpreter & interpreter ) :
CommandObjectProxy ( interpreter ,
" process plugin " ,
" Send a custom command to the current process plug-in. " ,
" process plugin <args> " ,
0 )
{
}
~ CommandObjectProcessPlugin ( )
{
}
virtual CommandObject *
GetProxyCommandObject ( )
{
2013-01-10 06:58:18 +08:00
Process * process = m_interpreter . GetExecutionContext ( ) . GetProcessPtr ( ) ;
2012-10-13 10:07:45 +08:00
if ( process )
return process - > GetPluginCommandObject ( ) ;
return NULL ;
}
} ;
2010-11-04 09:54:29 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessLoad
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessLoad
2010-11-04 09:54:29 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessLoad : public CommandObjectParsed
2010-11-04 09:54:29 +08:00
{
public :
CommandObjectProcessLoad ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process load " ,
" Load a shared library into the current process. " ,
" process load <filename> [<filename> ...] " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched |
eFlagProcessMustBePaused )
2010-11-04 09:54:29 +08:00
{
}
~ CommandObjectProcessLoad ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2010-11-04 09:54:29 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2010-11-04 09:54:29 +08:00
CommandReturnObject & result )
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-11-04 09:54:29 +08:00
2013-01-26 02:06:21 +08:00
const size_t argc = command . GetArgumentCount ( ) ;
2010-11-04 09:54:29 +08:00
for ( uint32_t i = 0 ; i < argc ; + + i )
{
Error error ;
const char * image_path = command . GetArgumentAtIndex ( i ) ;
FileSpec image_spec ( image_path , false ) ;
2011-08-12 00:25:18 +08:00
process - > GetTarget ( ) . GetPlatform ( ) - > ResolveRemotePath ( image_spec , image_spec ) ;
2010-11-04 09:54:29 +08:00
uint32_t image_token = process - > LoadImage ( image_spec , error ) ;
if ( image_token ! = LLDB_INVALID_IMAGE_TOKEN )
{
result . AppendMessageWithFormat ( " Loading \" %s \" ...ok \n Image %u loaded. \n " , image_path , image_token ) ;
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " failed to load '%s': %s " , image_path , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
return result . Succeeded ( ) ;
}
} ;
//-------------------------------------------------------------------------
// CommandObjectProcessUnload
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessUnload
2010-11-04 09:54:29 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessUnload : public CommandObjectParsed
2010-11-04 09:54:29 +08:00
{
public :
CommandObjectProcessUnload ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process unload " ,
" Unload a shared library from the current process using the index returned by a previous call to \" process load \" . " ,
" process unload <index> " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched |
eFlagProcessMustBePaused )
2010-11-04 09:54:29 +08:00
{
}
~ CommandObjectProcessUnload ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2010-11-04 09:54:29 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2010-11-04 09:54:29 +08:00
CommandReturnObject & result )
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-11-04 09:54:29 +08:00
2013-01-26 02:06:21 +08:00
const size_t argc = command . GetArgumentCount ( ) ;
2010-11-04 09:54:29 +08:00
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 ) ;
if ( image_token = = LLDB_INVALID_IMAGE_TOKEN )
{
result . AppendErrorWithFormat ( " invalid image index argument '%s' " , image_token_cstr ) ;
result . SetStatus ( eReturnStatusFailed ) ;
break ;
}
else
{
Error error ( process - > UnloadImage ( image_token ) ) ;
if ( error . Success ( ) )
{
result . AppendMessageWithFormat ( " Unloading shared library with index %u...ok \n " , image_token ) ;
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " failed to unload image: %s " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
break ;
}
}
}
return result . Succeeded ( ) ;
}
} ;
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessSignal
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessSignal
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessSignal : public CommandObjectParsed
2010-06-09 00:52:24 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessSignal ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process signal " ,
" Send a UNIX signal to the current process being debugged. " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
NULL ,
eFlagRequiresProcess | eFlagTryTargetAPILock )
2010-06-09 00:52:24 +08:00
{
2010-10-05 06:28:36 +08:00
CommandArgumentEntry arg ;
CommandArgumentData signal_arg ;
// Define the first (and only) variant of this arg.
2010-10-19 06:56:57 +08:00
signal_arg . arg_type = eArgTypeUnixSignal ;
2010-10-05 06:28:36 +08:00
signal_arg . arg_repetition = eArgRepeatPlain ;
// There is only one variant this argument could be; put it into the argument entry.
arg . push_back ( signal_arg ) ;
// Push the data for the first argument into the m_arguments vector.
m_arguments . push_back ( arg ) ;
2010-06-09 00:52:24 +08:00
}
~ CommandObjectProcessSignal ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2010-06-09 00:52:24 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2010-06-09 00:52:24 +08:00
CommandReturnObject & result )
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-06-09 00:52:24 +08:00
if ( command . GetArgumentCount ( ) = = 1 )
{
2010-10-09 09:40:57 +08:00
int signo = LLDB_INVALID_SIGNAL_NUMBER ;
const char * signal_name = command . GetArgumentAtIndex ( 0 ) ;
if ( : : isxdigit ( signal_name [ 0 ] ) )
signo = Args : : StringToSInt32 ( signal_name , LLDB_INVALID_SIGNAL_NUMBER , 0 ) ;
else
signo = process - > GetUnixSignals ( ) . GetSignalNumberFromName ( signal_name ) ;
if ( signo = = LLDB_INVALID_SIGNAL_NUMBER )
2010-06-09 00:52:24 +08:00
{
result . AppendErrorWithFormat ( " Invalid signal argument '%s'. \n " , command . GetArgumentAtIndex ( 0 ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
else
{
Error error ( process - > Signal ( signo ) ) ;
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " Failed to send signal %i: %s \n " , signo , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
}
else
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " '%s' takes exactly one signal number argument: \n Usage: %s \n " , m_cmd_name . c_str ( ) ,
2010-06-09 00:52:24 +08:00
m_cmd_syntax . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
} ;
//-------------------------------------------------------------------------
// CommandObjectProcessInterrupt
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessInterrupt
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessInterrupt : public CommandObjectParsed
2010-06-09 00:52:24 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessInterrupt ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process interrupt " ,
" Interrupt the current process being debugged. " ,
" process interrupt " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
2012-06-09 05:56:10 +08:00
eFlagProcessMustBeLaunched )
2010-06-09 00:52:24 +08:00
{
}
~ CommandObjectProcessInterrupt ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2010-06-09 00:52:24 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2013-05-11 07:48:10 +08:00
CommandReturnObject & result )
2010-06-09 00:52:24 +08:00
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-06-09 00:52:24 +08:00
if ( process = = NULL )
{
result . AppendError ( " no process to halt " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( command . GetArgumentCount ( ) = = 0 )
{
2013-05-11 07:48:10 +08:00
bool clear_thread_plans = true ;
Error error ( process - > Halt ( clear_thread_plans ) ) ;
2010-06-09 00:52:24 +08:00
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " Failed to halt process: %s \n " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " '%s' takes no arguments: \n Usage: %s \n " ,
2010-06-09 00:52:24 +08:00
m_cmd_name . c_str ( ) ,
m_cmd_syntax . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
} ;
//-------------------------------------------------------------------------
// CommandObjectProcessKill
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessKill
2010-06-09 00:52:24 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessKill : public CommandObjectParsed
2010-06-09 00:52:24 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessKill ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process kill " ,
" Terminate the current process being debugged. " ,
" process kill " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess |
eFlagTryTargetAPILock |
2012-06-09 05:56:10 +08:00
eFlagProcessMustBeLaunched )
2010-06-09 00:52:24 +08:00
{
}
~ CommandObjectProcessKill ( )
{
}
2012-06-09 05:56:10 +08:00
protected :
2010-06-09 00:52:24 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command ,
2010-06-09 00:52:24 +08:00
CommandReturnObject & result )
{
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
2010-06-09 00:52:24 +08:00
if ( process = = NULL )
{
result . AppendError ( " no process to kill " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( command . GetArgumentCount ( ) = = 0 )
{
Error error ( process - > Destroy ( ) ) ;
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " Failed to kill process: %s \n " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
2011-09-21 05:44:10 +08:00
result . AppendErrorWithFormat ( " '%s' takes no arguments: \n Usage: %s \n " ,
2010-06-09 00:52:24 +08:00
m_cmd_name . c_str ( ) ,
m_cmd_syntax . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
return result . Succeeded ( ) ;
}
} ;
2014-06-13 08:54:12 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessSaveCore
//-------------------------------------------------------------------------
# pragma mark CommandObjectProcessSaveCore
class CommandObjectProcessSaveCore : public CommandObjectParsed
{
public :
CommandObjectProcessSaveCore ( CommandInterpreter & interpreter ) :
CommandObjectParsed ( interpreter ,
" process save-core " ,
" Save the current process as a core file using an appropriate file type. " ,
" process save-core FILE " ,
eFlagRequiresProcess |
eFlagTryTargetAPILock |
eFlagProcessMustBeLaunched )
{
}
~ CommandObjectProcessSaveCore ( )
{
}
protected :
bool
DoExecute ( Args & command ,
CommandReturnObject & result )
{
ProcessSP process_sp = m_exe_ctx . GetProcessSP ( ) ;
if ( process_sp )
{
if ( command . GetArgumentCount ( ) = = 1 )
{
FileSpec output_file ( command . GetArgumentAtIndex ( 0 ) , false ) ;
Error error = PluginManager : : SaveCore ( process_sp , output_file ) ;
if ( error . Success ( ) )
{
result . SetStatus ( eReturnStatusSuccessFinishResult ) ;
}
else
{
result . AppendErrorWithFormat ( " Failed to save core file for process: %s \n " , error . AsCString ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
result . AppendErrorWithFormat ( " '%s' takes one arguments: \n Usage: %s \n " ,
m_cmd_name . c_str ( ) ,
m_cmd_syntax . c_str ( ) ) ;
result . SetStatus ( eReturnStatusFailed ) ;
}
}
else
{
result . AppendError ( " invalid process " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
return result . Succeeded ( ) ;
}
} ;
2010-06-18 09:23:09 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessStatus
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessStatus
2012-06-09 05:56:10 +08:00
class CommandObjectProcessStatus : public CommandObjectParsed
2010-06-18 09:23:09 +08:00
{
public :
2010-09-18 09:14:36 +08:00
CommandObjectProcessStatus ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process status " ,
" Show the current status and location of executing process. " ,
" process status " ,
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
eFlagRequiresProcess | eFlagTryTargetAPILock )
2010-06-18 09:23:09 +08:00
{
}
~ CommandObjectProcessStatus ( )
{
}
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & command , CommandReturnObject & result )
2010-06-18 09:23:09 +08:00
{
Centralized a lot of the status information for processes,
threads, and stack frame down in the lldb_private::Process,
lldb_private::Thread, lldb_private::StackFrameList and the
lldb_private::StackFrame classes. We had some command line
commands that had duplicate versions of the process status
output ("thread list" and "process status" for example).
Removed the "file" command and placed it where it should
have been: "target create". Made an alias for "file" to
"target create" so we stay compatible with GDB commands.
We can now have multple usable targets in lldb at the
same time. This is nice for comparing two runs of a program
or debugging more than one binary at the same time. The
new command is "target select <target-idx>" and also to see
a list of the current targets you can use the new "target list"
command. The flow in a debug session can be:
(lldb) target create /path/to/exe/a.out
(lldb) breakpoint set --name main
(lldb) run
... hit breakpoint
(lldb) target create /bin/ls
(lldb) run /tmp
Process 36001 exited with status = 0 (0x00000000)
(lldb) target list
Current targets:
target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
* target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) target select 0
Current targets:
* target #0: /tmp/args/a.out ( arch=x86_64-apple-darwin, platform=localhost, pid=35999, state=stopped )
target #1: /bin/ls ( arch=x86_64-apple-darwin, platform=localhost, pid=36001, state=exited )
(lldb) bt
* thread #1: tid = 0x2d03, 0x0000000100000b9a a.out`main + 42 at main.c:16, stop reason = breakpoint 1.1
frame #0: 0x0000000100000b9a a.out`main + 42 at main.c:16
frame #1: 0x0000000100000b64 a.out`start + 52
Above we created a target for "a.out" and ran and hit a
breakpoint at "main". Then we created a new target for /bin/ls
and ran it. Then we listed the targest and selected our original
"a.out" program, so we showed two concurent debug sessions
going on at the same time.
llvm-svn: 129695
2011-04-18 16:33:37 +08:00
Stream & strm = result . GetOutputStream ( ) ;
2010-06-18 09:23:09 +08:00
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
Expanded the flags that can be set for a command object in lldb_private::CommandObject. This list of available flags are:
enum
{
//----------------------------------------------------------------------
// eFlagRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing
// the command. If a target doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidTargetDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidTargetDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresTarget = (1u << 0),
//----------------------------------------------------------------------
// eFlagRequiresProcess
//
// Ensures a valid process is contained in m_exe_ctx prior to executing
// the command. If a process doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidProcessDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidProcessDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresProcess = (1u << 1),
//----------------------------------------------------------------------
// eFlagRequiresThread
//
// Ensures a valid thread is contained in m_exe_ctx prior to executing
// the command. If a thread doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidThreadDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidThreadDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresThread = (1u << 2),
//----------------------------------------------------------------------
// eFlagRequiresFrame
//
// Ensures a valid frame is contained in m_exe_ctx prior to executing
// the command. If a frame doesn't exist or is invalid, the command
// will fail and CommandObject::GetInvalidFrameDescription() will be
// returned as the error. CommandObject subclasses can override the
// virtual function for GetInvalidFrameDescription() to provide custom
// strings when needed.
//----------------------------------------------------------------------
eFlagRequiresFrame = (1u << 3),
//----------------------------------------------------------------------
// eFlagRequiresRegContext
//
// Ensures a valid register context (from the selected frame if there
// is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx)
// is availble from m_exe_ctx prior to executing the command. If a
// target doesn't exist or is invalid, the command will fail and
// CommandObject::GetInvalidRegContextDescription() will be returned as
// the error. CommandObject subclasses can override the virtual function
// for GetInvalidRegContextDescription() to provide custom strings when
// needed.
//----------------------------------------------------------------------
eFlagRequiresRegContext = (1u << 4),
//----------------------------------------------------------------------
// eFlagTryTargetAPILock
//
// Attempts to acquire the target lock if a target is selected in the
// command interpreter. If the command object fails to acquire the API
// lock, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagTryTargetAPILock = (1u << 5),
//----------------------------------------------------------------------
// eFlagProcessMustBeLaunched
//
// Verifies that there is a launched process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBeLaunched = (1u << 6),
//----------------------------------------------------------------------
// eFlagProcessMustBePaused
//
// Verifies that there is a paused process in m_exe_ctx, if there
// isn't, the command will fail with an appropriate error message.
//----------------------------------------------------------------------
eFlagProcessMustBePaused = (1u << 7)
};
Now each command object contains a "ExecutionContext m_exe_ctx;" member variable that gets initialized prior to running the command. The validity of the target objects in m_exe_ctx are checked to ensure that any target/process/thread/frame/reg context that are required are valid prior to executing the command. Each command object also contains a Mutex::Locker m_api_locker which gets used if eFlagTryTargetAPILock is set. This centralizes a lot of checking code that was previously and inconsistently implemented across many commands.
llvm-svn: 171990
2013-01-10 03:44:40 +08:00
// No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
Process * process = m_exe_ctx . GetProcessPtr ( ) ;
const bool only_threads_with_stop_reason = true ;
const uint32_t start_frame = 0 ;
const uint32_t num_frames = 1 ;
const uint32_t num_frames_with_source = 1 ;
process - > GetStatus ( strm ) ;
process - > GetThreadStatus ( strm ,
only_threads_with_stop_reason ,
start_frame ,
num_frames ,
num_frames_with_source ) ;
2010-06-18 09:23:09 +08:00
return result . Succeeded ( ) ;
}
} ;
2010-10-14 04:44:39 +08:00
//-------------------------------------------------------------------------
// CommandObjectProcessHandle
//-------------------------------------------------------------------------
2010-12-10 02:58:16 +08:00
# pragma mark CommandObjectProcessHandle
2010-10-14 04:44:39 +08:00
2012-06-09 05:56:10 +08:00
class CommandObjectProcessHandle : public CommandObjectParsed
2010-10-14 04:44:39 +08:00
{
public :
class CommandOptions : public Options
{
public :
2011-04-08 06:46:35 +08:00
CommandOptions ( CommandInterpreter & interpreter ) :
Options ( interpreter )
2010-10-14 04:44:39 +08:00
{
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( ) ;
2010-10-14 04:44:39 +08:00
}
~ CommandOptions ( )
{
}
Error
2011-04-13 08:18:08 +08:00
SetOptionValue ( uint32_t option_idx , const char * option_arg )
2010-10-14 04:44:39 +08:00
{
Error error ;
2012-12-04 08:32:51 +08:00
const int short_option = m_getopt_table [ option_idx ] . val ;
2010-10-14 04:44:39 +08:00
switch ( short_option )
{
case ' s ' :
stop = option_arg ;
break ;
case ' n ' :
notify = option_arg ;
break ;
case ' p ' :
pass = option_arg ;
break ;
default :
2011-10-26 08:56:27 +08:00
error . SetErrorStringWithFormat ( " invalid short option character '%c' " , short_option ) ;
2010-10-14 04:44:39 +08:00
break ;
}
return error ;
}
void
2011-04-13 08:18:08 +08:00
OptionParsingStarting ( )
2010-10-14 04:44:39 +08:00
{
stop . clear ( ) ;
notify . clear ( ) ;
pass . clear ( ) ;
}
2011-03-25 05:19:54 +08:00
const OptionDefinition *
2010-10-14 04:44:39 +08:00
GetDefinitions ( )
{
return g_option_table ;
}
// Options table: Required for subclasses of Options.
2011-03-25 05:19:54 +08:00
static OptionDefinition g_option_table [ ] ;
2010-10-14 04:44:39 +08:00
// Instance variables to hold the values for command options.
std : : string stop ;
std : : string notify ;
std : : string pass ;
} ;
CommandObjectProcessHandle ( CommandInterpreter & interpreter ) :
2012-06-09 05:56:10 +08:00
CommandObjectParsed ( interpreter ,
" process handle " ,
" Show or update what the process and debugger should do with various signals received from the OS. " ,
NULL ) ,
2011-04-08 06:46:35 +08:00
m_options ( interpreter )
2010-10-14 04:44:39 +08:00
{
2010-10-15 05:31:13 +08:00
SetHelpLong ( " If no signals are specified, update them all. If no update option is specified, list the current values. \n " ) ;
2010-10-14 04:44:39 +08:00
CommandArgumentEntry arg ;
2010-10-19 06:56:57 +08:00
CommandArgumentData signal_arg ;
2010-10-14 04:44:39 +08:00
2010-10-19 06:56:57 +08:00
signal_arg . arg_type = eArgTypeUnixSignal ;
signal_arg . arg_repetition = eArgRepeatStar ;
2010-10-14 04:44:39 +08:00
2010-10-19 06:56:57 +08:00
arg . push_back ( signal_arg ) ;
2010-10-14 04:44:39 +08:00
m_arguments . push_back ( arg ) ;
}
~ CommandObjectProcessHandle ( )
{
}
Options *
GetOptions ( )
{
return & m_options ;
}
bool
2010-10-15 05:31:13 +08:00
VerifyCommandOptionValue ( const std : : string & option , int & real_value )
2010-10-14 04:44:39 +08:00
{
bool okay = true ;
2010-10-15 05:31:13 +08:00
bool success = false ;
bool tmp_value = Args : : StringToBoolean ( option . c_str ( ) , false , & success ) ;
if ( success & & tmp_value )
real_value = 1 ;
else if ( success & & ! tmp_value )
real_value = 0 ;
2010-10-14 04:44:39 +08:00
else
{
// If the value isn't 'true' or 'false', it had better be 0 or 1.
2010-10-15 05:31:13 +08:00
real_value = Args : : StringToUInt32 ( option . c_str ( ) , 3 ) ;
if ( real_value ! = 0 & & real_value ! = 1 )
2010-10-14 04:44:39 +08:00
okay = false ;
}
return okay ;
}
2010-10-15 05:31:13 +08:00
void
PrintSignalHeader ( Stream & str )
{
str . Printf ( " NAME PASS STOP NOTIFY \n " ) ;
str . Printf ( " ========== ===== ===== ====== \n " ) ;
}
void
PrintSignal ( Stream & str , int32_t signo , const char * sig_name , UnixSignals & signals )
{
bool stop ;
bool suppress ;
bool notify ;
str . Printf ( " %-10s " , sig_name ) ;
if ( signals . GetSignalInfo ( signo , suppress , stop , notify ) )
{
bool pass = ! suppress ;
str . Printf ( " %s %s %s " ,
( pass ? " true " : " false " ) ,
( stop ? " true " : " false " ) ,
( notify ? " true " : " false " ) ) ;
}
str . Printf ( " \n " ) ;
}
void
PrintSignalInformation ( Stream & str , Args & signal_args , int num_valid_signals , UnixSignals & signals )
{
PrintSignalHeader ( str ) ;
if ( num_valid_signals > 0 )
{
size_t num_args = signal_args . GetArgumentCount ( ) ;
for ( size_t i = 0 ; i < num_args ; + + i )
{
int32_t signo = signals . GetSignalNumberFromName ( signal_args . GetArgumentAtIndex ( i ) ) ;
if ( signo ! = LLDB_INVALID_SIGNAL_NUMBER )
PrintSignal ( str , signo , signal_args . GetArgumentAtIndex ( i ) , signals ) ;
}
}
else // Print info for ALL signals
{
int32_t signo = signals . GetFirstSignalNumber ( ) ;
while ( signo ! = LLDB_INVALID_SIGNAL_NUMBER )
{
PrintSignal ( str , signo , signals . GetSignalAsCString ( signo ) , signals ) ;
signo = signals . GetNextSignalNumber ( signo ) ;
}
}
}
2012-06-09 05:56:10 +08:00
protected :
2010-10-14 04:44:39 +08:00
bool
2012-06-09 05:56:10 +08:00
DoExecute ( Args & signal_args , CommandReturnObject & result )
2010-10-14 04:44:39 +08:00
{
TargetSP target_sp = m_interpreter . GetDebugger ( ) . GetSelectedTarget ( ) ;
if ( ! target_sp )
{
result . AppendError ( " No current target; "
" cannot handle signals until you have a valid target and process. \n " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
ProcessSP process_sp = target_sp - > GetProcessSP ( ) ;
if ( ! process_sp )
{
result . AppendError ( " No current process; cannot handle signals until you have a valid process. \n " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
int stop_action = - 1 ; // -1 means leave the current setting alone
2010-10-15 05:31:13 +08:00
int pass_action = - 1 ; // -1 means leave the current setting alone
2010-10-14 04:44:39 +08:00
int notify_action = - 1 ; // -1 means leave the current setting alone
if ( ! m_options . stop . empty ( )
2010-10-15 05:31:13 +08:00
& & ! VerifyCommandOptionValue ( m_options . stop , stop_action ) )
2010-10-14 04:44:39 +08:00
{
result . AppendError ( " Invalid argument for command option --stop; must be true or false. \n " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( ! m_options . notify . empty ( )
2010-10-15 05:31:13 +08:00
& & ! VerifyCommandOptionValue ( m_options . notify , notify_action ) )
2010-10-14 04:44:39 +08:00
{
result . AppendError ( " Invalid argument for command option --notify; must be true or false. \n " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
if ( ! m_options . pass . empty ( )
2010-10-15 05:31:13 +08:00
& & ! VerifyCommandOptionValue ( m_options . pass , pass_action ) )
2010-10-14 04:44:39 +08:00
{
result . AppendError ( " Invalid argument for command option --pass; must be true or false. \n " ) ;
result . SetStatus ( eReturnStatusFailed ) ;
return false ;
}
size_t num_args = signal_args . GetArgumentCount ( ) ;
UnixSignals & signals = process_sp - > GetUnixSignals ( ) ;
int num_signals_set = 0 ;
2010-10-15 05:31:13 +08:00
if ( num_args > 0 )
2010-10-14 04:44:39 +08:00
{
2010-10-15 05:31:13 +08:00
for ( size_t i = 0 ; i < num_args ; + + i )
2010-10-14 04:44:39 +08:00
{
2010-10-15 05:31:13 +08:00
int32_t signo = signals . GetSignalNumberFromName ( signal_args . GetArgumentAtIndex ( i ) ) ;
if ( signo ! = LLDB_INVALID_SIGNAL_NUMBER )
{
// Casting the actions as bools here should be okay, because VerifyCommandOptionValue guarantees
// the value is either 0 or 1.
if ( stop_action ! = - 1 )
signals . SetShouldStop ( signo , ( bool ) stop_action ) ;
if ( pass_action ! = - 1 )
{
bool suppress = ! ( ( bool ) pass_action ) ;
signals . SetShouldSuppress ( signo , suppress ) ;
}
if ( notify_action ! = - 1 )
signals . SetShouldNotify ( signo , ( bool ) notify_action ) ;
+ + num_signals_set ;
}
else
2010-10-14 04:44:39 +08:00
{
2010-10-15 05:31:13 +08:00
result . AppendErrorWithFormat ( " Invalid signal name '%s' \n " , signal_args . GetArgumentAtIndex ( i ) ) ;
2010-10-14 04:44:39 +08:00
}
}
2010-10-15 05:31:13 +08:00
}
else
{
// No signal specified, if any command options were specified, update ALL signals.
if ( ( notify_action ! = - 1 ) | | ( stop_action ! = - 1 ) | | ( pass_action ! = - 1 ) )
2010-10-14 04:44:39 +08:00
{
2010-10-15 05:31:13 +08:00
if ( m_interpreter . Confirm ( " Do you really want to update all the signals? " , false ) )
{
int32_t signo = signals . GetFirstSignalNumber ( ) ;
while ( signo ! = LLDB_INVALID_SIGNAL_NUMBER )
{
if ( notify_action ! = - 1 )
signals . SetShouldNotify ( signo , ( bool ) notify_action ) ;
if ( stop_action ! = - 1 )
signals . SetShouldStop ( signo , ( bool ) stop_action ) ;
if ( pass_action ! = - 1 )
{
bool suppress = ! ( ( bool ) pass_action ) ;
signals . SetShouldSuppress ( signo , suppress ) ;
}
signo = signals . GetNextSignalNumber ( signo ) ;
}
}
2010-10-14 04:44:39 +08:00
}
}
2010-10-15 05:31:13 +08:00
PrintSignalInformation ( result . GetOutputStream ( ) , signal_args , num_signals_set , signals ) ;
2010-10-14 04:44:39 +08:00
if ( num_signals_set > 0 )
result . SetStatus ( eReturnStatusSuccessFinishNoResult ) ;
else
result . SetStatus ( eReturnStatusFailed ) ;
return result . Succeeded ( ) ;
}
CommandOptions m_options ;
} ;
2011-03-25 05:19:54 +08:00
OptionDefinition
2010-10-14 04:44:39 +08:00
CommandObjectProcessHandle : : CommandOptions : : g_option_table [ ] =
{
2014-07-10 00:31:49 +08:00
{ LLDB_OPT_SET_1 , false , " stop " , ' s ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeBoolean , " Whether or not the process should be stopped if the signal is received. " } ,
{ LLDB_OPT_SET_1 , false , " notify " , ' n ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeBoolean , " Whether or not the debugger should notify the user if the signal is received. " } ,
{ LLDB_OPT_SET_1 , false , " pass " , ' p ' , OptionParser : : eRequiredArgument , NULL , NULL , 0 , eArgTypeBoolean , " Whether or not the signal should be passed to the process. " } ,
{ 0 , false , NULL , 0 , 0 , NULL , NULL , 0 , eArgTypeNone , NULL }
2010-10-14 04:44:39 +08:00
} ;
2010-06-09 00:52:24 +08:00
//-------------------------------------------------------------------------
// CommandObjectMultiwordProcess
//-------------------------------------------------------------------------
2010-06-23 09:19:29 +08:00
CommandObjectMultiwordProcess : : CommandObjectMultiwordProcess ( CommandInterpreter & interpreter ) :
2010-09-18 09:14:36 +08:00
CommandObjectMultiword ( interpreter ,
" process " ,
" A set of commands for operating on a process. " ,
" process <subcommand> [<subcommand-options>] " )
2010-06-09 00:52:24 +08:00
{
2011-07-03 05:07:54 +08:00
LoadSubCommand ( " attach " , CommandObjectSP ( new CommandObjectProcessAttach ( interpreter ) ) ) ;
LoadSubCommand ( " launch " , CommandObjectSP ( new CommandObjectProcessLaunch ( interpreter ) ) ) ;
LoadSubCommand ( " continue " , CommandObjectSP ( new CommandObjectProcessContinue ( interpreter ) ) ) ;
LoadSubCommand ( " connect " , CommandObjectSP ( new CommandObjectProcessConnect ( interpreter ) ) ) ;
LoadSubCommand ( " detach " , CommandObjectSP ( new CommandObjectProcessDetach ( interpreter ) ) ) ;
LoadSubCommand ( " load " , CommandObjectSP ( new CommandObjectProcessLoad ( interpreter ) ) ) ;
LoadSubCommand ( " unload " , CommandObjectSP ( new CommandObjectProcessUnload ( interpreter ) ) ) ;
LoadSubCommand ( " signal " , CommandObjectSP ( new CommandObjectProcessSignal ( interpreter ) ) ) ;
LoadSubCommand ( " handle " , CommandObjectSP ( new CommandObjectProcessHandle ( interpreter ) ) ) ;
LoadSubCommand ( " status " , CommandObjectSP ( new CommandObjectProcessStatus ( interpreter ) ) ) ;
2010-09-18 09:14:36 +08:00
LoadSubCommand ( " interrupt " , CommandObjectSP ( new CommandObjectProcessInterrupt ( interpreter ) ) ) ;
2011-07-03 05:07:54 +08:00
LoadSubCommand ( " kill " , CommandObjectSP ( new CommandObjectProcessKill ( interpreter ) ) ) ;
2012-10-13 10:07:45 +08:00
LoadSubCommand ( " plugin " , CommandObjectSP ( new CommandObjectProcessPlugin ( interpreter ) ) ) ;
2014-06-13 08:54:12 +08:00
LoadSubCommand ( " save-core " , CommandObjectSP ( new CommandObjectProcessSaveCore ( interpreter ) ) ) ;
2010-06-09 00:52:24 +08:00
}
CommandObjectMultiwordProcess : : ~ CommandObjectMultiwordProcess ( )
{
}