diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-04-12 05:54:46 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-04-12 05:54:46 +0000 |
| commit | 8b82f087a0499319640f5d06498f965fa0214c72 (patch) | |
| tree | 561c493dbe3e1a176d4c1b4ddd0c0afb396d3bea /lldb/source/Commands | |
| parent | f52718899fa93f19403336355bca8117321ee834 (diff) | |
| download | bcm5719-llvm-8b82f087a0499319640f5d06498f965fa0214c72.tar.gz bcm5719-llvm-8b82f087a0499319640f5d06498f965fa0214c72.zip | |
Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.
Make sure that Modules can track their object file offsets correctly to
allow opening of sub object files (like the "__commpage" on darwin).
Modified the Platforms to be able to launch processes. The first part of this
move is the platform soon will become the entity that launches your program
and when it does, it uses a new ProcessLaunchInfo class which encapsulates
all process launching settings. This simplifies the internal APIs needed for
launching. I want to slowly phase out process launching from the process
classes, so for now we can still launch just as we used to, but eventually
the platform is the object that should do the launching.
Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able
to launch processes with all of the new eLaunchFlag settings. Modified any
code that was manually launching processes to use the Host::LaunchProcess
functions.
Fixed an issue where lldb_private::Args had implicitly defined copy
constructors that could do the wrong thing. This has now been fixed by adding
an appropriate copy constructor and assignment operator.
Make sure we don't add empty ModuleSP entries to a module list.
Fixed the commpage module creation on MacOSX, but we still need to train
the MacOSX dynamic loader to not get rid of it when it doesn't have an entry
in the all image infos.
Abstracted many more calls from in ProcessGDBRemote down into the
GDBRemoteCommunicationClient subclass to make the classes cleaner and more
efficient.
Fixed the default iOS ARM register context to be correct and also added support
for targets that don't support the qThreadStopInfo packet by selecting the
current thread (only if needed) and then sending a stop reply packet.
Debugserver can now start up with a --unix-socket (-u for short) and can
then bind to port zero and send the port it bound to to a listening process
on the other end. This allows the GDB remote platform to spawn new GDB server
instances (debugserver) to allow platform debugging.
llvm-svn: 129351
Diffstat (limited to 'lldb/source/Commands')
| -rw-r--r-- | lldb/source/Commands/CommandObjectArgs.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectBreakpoint.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectDisassemble.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectFile.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectFrame.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectImage.cpp | 54 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectMemory.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 262 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 104 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectRegister.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 16 |
13 files changed, 297 insertions, 171 deletions
diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index 6064ec8dbc6..0ed4a06e564 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -105,7 +105,7 @@ CommandObjectArgs::Execute ConstString target_triple; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -131,7 +131,7 @@ CommandObjectArgs::Execute return false; } - Thread *thread = m_interpreter.GetDebugger().GetExecutionContext ().thread; + Thread *thread = m_interpreter.GetExecutionContext ().thread; if (!thread) { diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index c8287015643..d5a4345ba2e 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -322,7 +322,7 @@ CommandObjectBreakpointSet::Execute FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; + StackFrame *cur_frame = m_interpreter.GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 1301fd9f4da..dea764074e1 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -128,7 +128,7 @@ CommandObjectDisassemble::CommandOptions::SetOptionValue (int option_idx, const break; case 'a': - arch.SetTriple (option_arg, m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform().get()); + arch.SetTriple (option_arg, m_interpreter.GetPlatform (true).get()); break; default: @@ -257,7 +257,7 @@ CommandObjectDisassemble::Execute if (m_options.show_mixed && m_options.num_lines_context == 0) m_options.num_lines_context = 1; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (!m_options.func_name.empty()) { diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 31ecaf106d2..c96b247ce12 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -295,7 +295,7 @@ CommandObjectExpression::ExecuteRawCommandString CommandReturnObject &result ) { - m_exe_ctx = m_interpreter.GetDebugger().GetExecutionContext(); + m_exe_ctx = m_interpreter.GetExecutionContext(); m_options.Reset(); diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp index e0c81bbf983..1177f5aafbc 100644 --- a/lldb/source/Commands/CommandObjectFile.cpp +++ b/lldb/source/Commands/CommandObjectFile.cpp @@ -58,7 +58,7 @@ CommandObjectFile::CommandOptions::SetOptionValue (int option_idx, const char *o { case 'a': { - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + PlatformSP platform_sp (m_interpreter.GetPlatform (false)); ArchSpec option_arch (option_arg, platform_sp.get()); if (option_arch.IsValid()) m_arch = option_arch; diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index aaaee06c4be..57286ac3014 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -69,7 +69,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream()); @@ -188,7 +188,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx (m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { const uint32_t num_frames = exe_ctx.thread->GetStackFrameCount(); @@ -445,7 +445,7 @@ public: CommandReturnObject &result ) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("you must be stopped in a valid stack frame to view frame variables."); diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp index 3d005a80526..ca109d59576 100644 --- a/lldb/source/Commands/CommandObjectImage.cpp +++ b/lldb/source/Commands/CommandObjectImage.cpp @@ -87,7 +87,7 @@ DumpCompileUnitLineTable LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) line_table->GetDescription (&strm, - interpreter.GetDebugger().GetExecutionContext().target, + interpreter.GetExecutionContext().target, lldb::eDescriptionLevelBrief); else strm << "No line table"; @@ -165,7 +165,7 @@ DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module, { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, sort_order); + symtab->Dump(&strm, interpreter.GetExecutionContext().target, sort_order); } } } @@ -183,9 +183,11 @@ DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *modul { strm.PutCString ("Sections for '"); strm << module->GetFileSpec(); + if (module->GetObjectName()) + strm << '(' << module->GetObjectName() << ')'; strm.Printf ("' (%s):\n", module->GetArchitecture().GetArchitectureName()); strm.IndentMore(); - section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true, UINT32_MAX); + section_list->Dump(&strm, interpreter.GetExecutionContext().target, true, UINT32_MAX); strm.IndentLess(); } } @@ -224,7 +226,7 @@ LookupAddressInModule lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Target *target = interpreter.GetDebugger().GetExecutionContext().target; + Target *target = interpreter.GetExecutionContext().target; if (target && !target->GetSectionLoadList().IsEmpty()) { if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr)) @@ -242,7 +244,7 @@ LookupAddressInModule if (offset) strm.Printf("File Address: 0x%llx\n", addr); - ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = interpreter.GetExecutionContext().GetBestExecutionContextScope(); strm.IndentMore(); strm.Indent (" Address: "); so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset); @@ -309,7 +311,7 @@ LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *mod { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().target, i); + symbol->Dump (&strm, interpreter.GetExecutionContext().target, i); } strm.IndentLess (); return num_matches; @@ -338,9 +340,9 @@ DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolCont { if (sc.line_entry.range.GetBaseAddress().IsValid()) { - lldb::addr_t vm_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().target); + lldb::addr_t vm_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetExecutionContext().target); int addr_size = sizeof (addr_t); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = interpreter.GetExecutionContext().process; if (process) addr_size = process->GetTarget().GetArchitecture().GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) @@ -351,7 +353,7 @@ DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolCont strm.PutCString(" in "); } } - sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, true, false); + sc.DumpStopContext(&strm, interpreter.GetExecutionContext().process, sc.line_entry.range.GetBaseAddress(), true, true, false); } } strm.IndentLess (); @@ -1050,7 +1052,7 @@ public: } else { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -1233,9 +1235,11 @@ public: Module *module = target->GetImages().GetModulePointerAtIndex(image_idx); strm.Printf("[%3u] ", image_idx); + bool dump_object_name = false; if (m_options.m_format_array.empty()) { DumpFullpath(strm, &module->GetFileSpec(), 0); + dump_object_name = true; } else { @@ -1254,6 +1258,7 @@ public: case 'f': DumpFullpath (strm, &module->GetFileSpec(), width); + dump_object_name = true; break; case 'd': @@ -1262,6 +1267,7 @@ public: case 'b': DumpBasename (strm, &module->GetFileSpec(), width); + dump_object_name = true; break; case 's': @@ -1277,6 +1283,7 @@ public: DumpBasename(strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); else DumpFullpath (strm, &symbol_file->GetObjectFile()->GetFileSpec(), width); + dump_object_name = true; break; } } @@ -1291,8 +1298,15 @@ public: default: break; } + } } + if (dump_object_name) + { + const char *object_name = module->GetObjectName().GetCString(); + if (object_name) + strm.Printf ("(%s)", object_name); + } strm.EOL(); } result.SetStatus (eReturnStatusSuccessFinishResult); @@ -1682,16 +1696,16 @@ protected: OptionDefinition CommandObjectImageLookup::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more executable images."}, -{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract <offset> from any addresses before doing the lookup."}, -{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more executable images."}, -{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeNone, "The <name> argument for name lookups are regular expressions."}, -{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more executable images."}, -{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, eArgTypeNone, "Check inline line entries (must be used in conjunction with --file)."}, -{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more executable images."}, -{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose lookup information."}, +{ LLDB_OPT_SET_1, true, "address", 'a', required_argument, NULL, 0, eArgTypeAddress, "Lookup an address in one or more executable images."}, +{ LLDB_OPT_SET_1, false, "offset", 'o', required_argument, NULL, 0, eArgTypeOffset, "When looking up an address subtract <offset> from any addresses before doing the lookup."}, +{ LLDB_OPT_SET_2, true, "symbol", 's', required_argument, NULL, 0, eArgTypeSymbol, "Lookup a symbol by name in the symbol tables in one or more executable images."}, +{ LLDB_OPT_SET_2, false, "regex", 'r', no_argument, NULL, 0, eArgTypeNone, "The <name> argument for name lookups are regular expressions."}, +{ LLDB_OPT_SET_3, true, "file", 'f', required_argument, NULL, 0, eArgTypeFilename, "Lookup a file by fullpath or basename in one or more executable images."}, +{ LLDB_OPT_SET_3, false, "line", 'l', required_argument, NULL, 0, eArgTypeLineNum, "Lookup a line number in a file (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_3, false, "no-inlines", 'i', no_argument, NULL, 0, eArgTypeNone, "Check inline line entries (must be used in conjunction with --file)."}, +{ LLDB_OPT_SET_4, true, "function", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_5, true, "type", 't', required_argument, NULL, 0, eArgTypeName, "Lookup a type by name in the debug symbols in one or more executable images."}, +{ LLDB_OPT_SET_ALL, false, "verbose", 'v', no_argument, NULL, 0, eArgTypeNone, "Enable verbose lookup information."}, { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } }; diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index c731c61836c..7993f5462eb 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -240,7 +240,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -415,7 +415,7 @@ CommandObjectMemoryRead::CommandOptions::g_option_table[] = { SET1 , false, "format", 'f', required_argument, NULL, 0, eArgTypeFormat, "The format that will be used to display the memory. Defaults to bytes with ASCII (--format=Y)."}, { SET1 , false, "size", 's', required_argument, NULL, 0, eArgTypeByteSize, "The size in bytes to use when displaying with the selected format."}, { SET1 , false, "num-per-line", 'l', required_argument, NULL, 0, eArgTypeNumberPerLine,"The number of items per line to display."}, -{ SET1 , false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, +{ SET1 | SET2, false, "count", 'c', required_argument, NULL, 0, eArgTypeCount, "The number of total items to display."}, { SET1 | SET2, false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename, "Dump memory read results into a file."}, { SET1 | SET2, false, "append", 'a', no_argument, NULL, 0, eArgTypeNone, "Append memory read results to 'outfile'."}, { SET2, false, "binary", 'b', no_argument, NULL, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, @@ -591,7 +591,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index a72b0db4d14..730a1b3dd01 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -413,6 +413,134 @@ public: return result.Succeeded(); } }; +//---------------------------------------------------------------------- +// "platform process launch" +//---------------------------------------------------------------------- +class CommandObjectPlatformProcessLaunch : public CommandObject +{ +public: + CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "platform process launch", + "Launch a new process on a remote platform.", + "platform process launch program", + 0), + m_options (interpreter) + { + } + + virtual + ~CommandObjectPlatformProcessLaunch () + { + } + + virtual bool + Execute (Args& args, CommandReturnObject &result) + { + PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + + if (platform_sp) + { + Error error; + const uint32_t argc = args.GetArgumentCount(); + Target *target = m_interpreter.GetExecutionContext().target; + ModuleSP exe_module_sp; + if (target) + { + exe_module_sp = target->GetExecutableModule(); + if (exe_module_sp) + { + m_options.launch_info.GetExecutableFile () = exe_module_sp->GetFileSpec(); + char exe_path[PATH_MAX]; + if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path))) + m_options.launch_info.GetArguments().AppendArgument (exe_path); + m_options.launch_info.GetArchitecture() = exe_module_sp->GetArchitecture(); + } + } + + if (argc > 0) + { + if (m_options.launch_info.GetExecutableFile ()) + { + // We already have an executable file, so we will use this + // and all arguments to this function are extra arguments + m_options.launch_info.GetArguments().AppendArguments (args); + } + else + { + // We don't have any file yet, so the first argument is our + // executable, and the rest are program arguments + const bool first_arg_is_executable = true; + m_options.launch_info.SetArgumentsFromArgs (args, + first_arg_is_executable, + first_arg_is_executable); + } + } + + if (m_options.launch_info.GetExecutableFile ()) + { + Debugger &debugger = m_interpreter.GetDebugger(); + + if (argc == 0) + { + lldb::UserSettingsControllerSP process_usc_sp (Process::GetSettingsController ()); + if (process_usc_sp) + { + SettableVariableType type; + StringList settings_args (process_usc_sp->GetVariable ("process.run-args", + type, + m_interpreter.GetDebugger().GetInstanceName().GetCString(), + error)); + if (error.Success()) + { + const size_t num_settings_args = settings_args.GetSize(); + for (size_t i=0; i<num_settings_args; ++i) + m_options.launch_info.GetArguments().AppendArgument (settings_args.GetStringAtIndex(i)); + } + } + } + + ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info, + debugger, + target, + debugger.GetListener(), + error)); + if (process_sp && process_sp->IsAlive()) + { + result.SetStatus (eReturnStatusSuccessFinishNoResult); + return true; + } + + if (error.Success()) + result.AppendError ("process launch failed"); + else + result.AppendError (error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } + else + { + result.AppendError ("'platform process launch' uses the current target file and arguments, or the executable and its arguments can be specified in this command"); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + else + { + result.AppendError ("no platform is selected\n"); + } + return result.Succeeded(); + } + + virtual Options * + GetOptions () + { + return &m_options; + } + +protected: + ProcessLaunchCommandOptions m_options; +}; + //---------------------------------------------------------------------- @@ -454,11 +582,11 @@ public: lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID(); if (pid != LLDB_INVALID_PROCESS_ID) { - ProcessInfo proc_info; + ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo (pid, proc_info)) { - ProcessInfo::DumpTableHeader (ostrm, platform_sp.get()); - proc_info.DumpAsTableRow(ostrm, platform_sp.get()); + ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); + proc_info.DumpAsTableRow(ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); result.SetStatus (eReturnStatusSuccessFinishResult); } else @@ -469,24 +597,25 @@ public: } else { - ProcessInfoList proc_infos; + ProcessInstanceInfoList proc_infos; const uint32_t matches = platform_sp->FindProcesses (m_options.match_info, proc_infos); - if (matches == 0) + const char *match_desc = NULL; + const char *match_name = m_options.match_info.GetProcessInfo().GetName(); + if (match_name && match_name[0]) { - const char *match_desc = NULL; - const char *match_name = m_options.match_info.GetProcessInfo().GetName(); - if (match_name && match_name[0]) + switch (m_options.match_info.GetNameMatchType()) { - switch (m_options.match_info.GetNameMatchType()) - { - case eNameMatchIgnore: break; - case eNameMatchEquals: match_desc = "match"; break; - case eNameMatchContains: match_desc = "contains"; break; - case eNameMatchStartsWith: match_desc = "starts with"; break; - case eNameMatchEndsWith: match_desc = "end with"; break; - case eNameMatchRegularExpression: match_desc = "match the regular expression"; break; - } + case eNameMatchIgnore: break; + case eNameMatchEquals: match_desc = "matched"; break; + case eNameMatchContains: match_desc = "contained"; break; + case eNameMatchStartsWith: match_desc = "started with"; break; + case eNameMatchEndsWith: match_desc = "ended with"; break; + case eNameMatchRegularExpression: match_desc = "matched the regular expression"; break; } + } + + if (matches == 0) + { if (match_desc) result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n", match_desc, @@ -498,11 +627,19 @@ public: } else { - - ProcessInfo::DumpTableHeader (ostrm, platform_sp.get()); + result.AppendMessageWithFormat ("%u matching process%s found on \"%s\"", + matches, + matches > 1 ? "es were" : " was", + platform_sp->GetName()); + if (match_desc) + result.AppendMessageWithFormat (" whose name %s \"%s\"", + match_desc, + match_name); + result.AppendMessageWithFormat ("\n"); + ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); for (uint32_t i=0; i<matches; ++i) { - proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(ostrm, platform_sp.get()); + proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(ostrm, platform_sp.get(), m_options.show_args, m_options.verbose); } } } @@ -567,7 +704,7 @@ protected: break; case 'u': - match_info.GetProcessInfo().SetRealUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid user ID string: '%s'", option_arg); break; @@ -579,7 +716,7 @@ protected: break; case 'g': - match_info.GetProcessInfo().SetRealGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); + match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success)); if (!success) error.SetErrorStringWithFormat("invalid group ID string: '%s'", option_arg); break; @@ -596,26 +733,37 @@ protected: case 'n': match_info.GetProcessInfo().SetName (option_arg); - if (match_info.GetNameMatchType() == eNameMatchIgnore) - match_info.SetNameMatchType (eNameMatchEquals); + match_info.SetNameMatchType (eNameMatchEquals); break; case 'e': + match_info.GetProcessInfo().SetName (option_arg); match_info.SetNameMatchType (eNameMatchEndsWith); break; case 's': + match_info.GetProcessInfo().SetName (option_arg); match_info.SetNameMatchType (eNameMatchStartsWith); break; case 'c': + match_info.GetProcessInfo().SetName (option_arg); match_info.SetNameMatchType (eNameMatchContains); break; case 'r': + match_info.GetProcessInfo().SetName (option_arg); match_info.SetNameMatchType (eNameMatchRegularExpression); break; + case 'A': + show_args = true; + break; + + case 'v': + verbose = true; + break; + default: error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); break; @@ -628,6 +776,8 @@ protected: ResetOptionValues () { match_info.Clear(); + show_args = false; + verbose = false; } const OptionDefinition* @@ -642,7 +792,9 @@ protected: // Instance variables to hold the values for command options. - ProcessInfoMatch match_info; + ProcessInstanceInfoMatch match_info; + bool show_args; + bool verbose; }; CommandOptions m_options; }; @@ -650,49 +802,23 @@ protected: OptionDefinition CommandObjectPlatformProcessList::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "pid" , 'p', required_argument, NULL, 0, eArgTypePid , "List the process info for a specific process ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5, true , "name" , 'n', required_argument, NULL, 0, eArgTypeProcessName , "Find processes that match the supplied name." }, -{ LLDB_OPT_SET_2, false, "ends-with" , 'e', no_argument , NULL, 0, eArgTypeNone , "Process names must end with the name supplied with the --name option." }, -{ LLDB_OPT_SET_3, false, "starts-with" , 's', no_argument , NULL, 0, eArgTypeNone , "Process names must start with the name supplied with the --name option." }, -{ LLDB_OPT_SET_4, false, "contains" , 'c', no_argument , NULL, 0, eArgTypeNone , "Process names must contain the name supplied with the --name option." }, -{ LLDB_OPT_SET_5, false, "regex" , 'r', no_argument , NULL, 0, eArgTypeNone , "Process names must match name supplied with the --name option as a regular expression." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "parent" , 'P', required_argument, NULL, 0, eArgTypePid , "Find processes that have a matching parent process ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "uid" , 'u', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching user ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "euid" , 'U', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective user ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "gid" , 'g', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching group ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "egid" , 'G', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective group ID." }, -{ LLDB_OPT_SET_2| - LLDB_OPT_SET_3| - LLDB_OPT_SET_4| - LLDB_OPT_SET_5| - LLDB_OPT_SET_6, false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." }, -{ 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone , NULL } +{ LLDB_OPT_SET_1, false, "pid" , 'p', required_argument, NULL, 0, eArgTypePid , "List the process info for a specific process ID." }, +{ LLDB_OPT_SET_2, true , "name" , 'n', required_argument, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that match a string." }, +{ LLDB_OPT_SET_3, true , "ends-with" , 'e', required_argument, NULL, 0, eArgTypeNone , "Find processes with executable basenames that end with a string." }, +{ LLDB_OPT_SET_4, true , "starts-with" , 's', required_argument, NULL, 0, eArgTypeNone , "Find processes with executable basenames that start with a string." }, +{ LLDB_OPT_SET_5, true , "contains" , 'c', required_argument, NULL, 0, eArgTypeNone , "Find processes with executable basenames that contain a string." }, +{ LLDB_OPT_SET_6, true , "regex" , 'r', required_argument, NULL, 0, eArgTypeNone , "Find processes with executable basenames that match a regular expression." }, +{ ~LLDB_OPT_SET_1, false, "parent" , 'P', required_argument, NULL, 0, eArgTypePid , "Find processes that have a matching parent process ID." }, +{ ~LLDB_OPT_SET_1, false, "uid" , 'u', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching user ID." }, +{ ~LLDB_OPT_SET_1, false, "euid" , 'U', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective user ID." }, +{ ~LLDB_OPT_SET_1, false, "gid" , 'g', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching group ID." }, +{ ~LLDB_OPT_SET_1, false, "egid" , 'G', required_argument, NULL, 0, eArgTypeNone , "Find processes that have a matching effective group ID." }, +{ ~LLDB_OPT_SET_1, false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." }, +{ LLDB_OPT_SET_ALL, false, "show-args" , 'A', no_argument , NULL, 0, eArgTypeNone , "Show process arguments instead of the process executable basename." }, +{ LLDB_OPT_SET_ALL, false, "verbose" , 'v', no_argument , NULL, 0, eArgTypeNone , "Enable verbose output." }, +{ 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone , NULL } }; - //---------------------------------------------------------------------- // "platform process info" //---------------------------------------------------------------------- @@ -746,7 +872,7 @@ public: lldb::pid_t pid = Args::StringToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success); if (success) { - ProcessInfo proc_info; + ProcessInstanceInfo proc_info; if (platform_sp->GetProcessInfo (pid, proc_info)) { ostrm.Printf ("Process information for process %i:\n", pid); @@ -805,7 +931,7 @@ public: "platform process [attach|launch|list] ...") { // LoadSubCommand ("attach", CommandObjectSP (new CommandObjectPlatformProcessAttach (interpreter))); -// LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter))); + LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter))); LoadSubCommand ("info" , CommandObjectSP (new CommandObjectPlatformProcessInfo (interpreter))); LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformProcessList (interpreter))); diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 116309d94d5..1fc573b9266 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -175,7 +175,7 @@ public: exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); StateType state = eStateInvalid; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process) { state = process->GetState(); @@ -266,7 +266,10 @@ public: if (process->GetDisableASLR()) launch_flags |= eLaunchFlagDisableASLR; - + + if (m_options.in_new_tty) + launch_flags |= eLaunchFlagLaunchInTTY; + if (m_options.no_stdio) launch_flags |= eLaunchFlagDisableSTDIO; else if (!m_options.in_new_tty @@ -287,52 +290,35 @@ public: if (!m_options.working_dir.empty()) working_dir = m_options.working_dir.c_str(); - if (m_options.in_new_tty) + const char * stdin_path = NULL; + const char * stdout_path = NULL; + const char * stderr_path = NULL; + + // Were any standard input/output/error paths given on the command line? + if (m_options.stdin_path.empty() && + m_options.stdout_path.empty() && + m_options.stderr_path.empty()) { - - lldb::pid_t pid = Host::LaunchInNewTerminal (m_options.tty_name.c_str(), - inferior_argv, - inferior_envp, - working_dir, - &exe_module->GetArchitecture(), - true, - process->GetDisableASLR()); - - if (pid != LLDB_INVALID_PROCESS_ID) - error = process->Attach (pid); + // No standard file handles were given on the command line, check + // with the process object in case they were give using "set settings" + stdin_path = process->GetStandardInputPath(); + stdout_path = process->GetStandardOutputPath(); + stderr_path = process->GetStandardErrorPath(); } else { - const char * stdin_path = NULL; - const char * stdout_path = NULL; - const char * stderr_path = NULL; - - // Were any standard input/output/error paths given on the command line? - if (m_options.stdin_path.empty() && - m_options.stdout_path.empty() && - m_options.stderr_path.empty()) - { - // No standard file handles were given on the command line, check - // with the process object in case they were give using "set settings" - stdin_path = process->GetStandardInputPath(); - stdout_path = process->GetStandardOutputPath(); - stderr_path = process->GetStandardErrorPath(); - } - else - { - stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); - stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); - stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); - } - - error = process->Launch (inferior_argv, - inferior_envp, - launch_flags, - stdin_path, - stdout_path, - stderr_path, - working_dir); + stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); + stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); + stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); } + + error = process->Launch (inferior_argv, + inferior_envp, + launch_flags, + stdin_path, + stdout_path, + stderr_path, + working_dir); if (error.Success()) { @@ -521,11 +507,11 @@ public: const char *partial_name = NULL; partial_name = input.GetArgumentAtIndex(opt_arg_pos); - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ()); + PlatformSP platform_sp (m_interpreter.GetPlatform (true)); if (platform_sp) { - ProcessInfoList process_infos; - ProcessInfoMatch match_info; + ProcessInstanceInfoList process_infos; + ProcessInstanceInfoMatch match_info; if (partial_name) { match_info.GetProcessInfo().SetName(partial_name); @@ -579,7 +565,7 @@ public: Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); bool synchronous_execution = m_interpreter.GetSynchronous (); - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; StateType state = eStateInvalid; if (process) { @@ -707,11 +693,11 @@ public: if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL) { - ProcessInfoList process_infos; - PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ()); + ProcessInstanceInfoList process_infos; + PlatformSP platform_sp (m_interpreter.GetPlatform (true)); if (platform_sp) { - ProcessInfoMatch match_info (wait_name, eNameMatchEquals); + ProcessInstanceInfoMatch match_info (wait_name, eNameMatchEquals); platform_sp->FindProcesses (match_info, process_infos); } if (process_infos.GetSize() > 1) @@ -860,7 +846,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; bool synchronous_execution = m_interpreter.GetSynchronous (); if (process == NULL) @@ -947,7 +933,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -1057,7 +1043,7 @@ public: TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget()); Error error; - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -1172,7 +1158,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1230,7 +1216,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to load a shared library"); @@ -1307,7 +1293,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -1382,7 +1368,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -1444,7 +1430,7 @@ public: Execute (Args& command, CommandReturnObject &result) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -1507,7 +1493,7 @@ public: { Stream &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index d50d7d71ecf..2607854ed2e 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -75,7 +75,7 @@ public: { Stream &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -274,7 +274,7 @@ public: ) { DataExtractor reg_data; - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 9fbf6024a39..29b17dc1d42 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -272,7 +272,7 @@ public: result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (!m_options.symbol_name.empty()) { diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index abb6f5f1cef..f321000768d 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -362,7 +362,7 @@ public: if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { if (DisplayFramesForExecutionContext (exe_ctx.thread, @@ -386,7 +386,7 @@ public: } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; uint32_t num_threads = process->GetThreadList().GetSize(); for (uint32_t i = 0; i < num_threads; i++) { @@ -412,7 +412,7 @@ public: else { uint32_t num_args = command.GetArgumentCount(); - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; std::vector<ThreadSP> thread_sps; for (uint32_t i = 0; i < num_args; i++) @@ -610,7 +610,7 @@ public: CommandReturnObject &result ) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; bool synchronous_execution = m_interpreter.GetSynchronous(); if (process == NULL) @@ -851,7 +851,7 @@ public: return false; } - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -1115,7 +1115,7 @@ public: return false; } - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1308,7 +1308,7 @@ public: CommandReturnObject &result ) { - Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1378,7 +1378,7 @@ public: { Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); |

