diff options
author | Jim Ingham <jingham@apple.com> | 2010-06-18 01:23:09 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2010-06-18 01:23:09 +0000 |
commit | 4b9bea87e6310d5a56e83705610e41243ddd3a17 (patch) | |
tree | 6d1cbe6cafbde4da96e4a6b72ddd09053e2e4a94 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | 23231687051add632a886b31f80271ca78e5a4ba (diff) | |
download | bcm5719-llvm-4b9bea87e6310d5a56e83705610e41243ddd3a17.tar.gz bcm5719-llvm-4b9bea87e6310d5a56e83705610e41243ddd3a17.zip |
Move the "status" command to "process status" since that's where it belongs. Also make it print "running" if invoked
when the current process is running.
llvm-svn: 106265
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 91efce47712..0a8487155d3 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/State.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "./CommandObjectThread.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -810,6 +811,83 @@ public: }; //------------------------------------------------------------------------- +// CommandObjectProcessStatus +//------------------------------------------------------------------------- +class CommandObjectProcessStatus : public CommandObject +{ +public: + CommandObjectProcessStatus () : + CommandObject ("status", + "Shows the current status and location of executing process.", + "status", + 0) + { + } + + ~CommandObjectProcessStatus() + { + } + + + bool + Execute + ( + Args& command, + CommandContext *context, + CommandInterpreter *interpreter, + CommandReturnObject &result + ) + { + StreamString &output_stream = result.GetOutputStream(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + ExecutionContext exe_ctx(context->GetExecutionContext()); + if (exe_ctx.process) + { + const StateType state = exe_ctx.process->GetState(); + if (StateIsStoppedState(state)) + { + if (state == eStateExited) + { + int exit_status = exe_ctx.process->GetExitStatus(); + const char *exit_description = exe_ctx.process->GetExitDescription(); + output_stream.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + exe_ctx.process->GetID(), + exit_status, + exit_status, + exit_description ? exit_description : ""); + } + else + { + output_stream.Printf ("Process %d %s\n", exe_ctx.process->GetID(), StateAsCString (state)); + if (exe_ctx.thread == NULL) + exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (exe_ctx.thread != NULL) + { + DisplayThreadsInfo (interpreter, &exe_ctx, result, true, true); + } + else + { + result.AppendError ("No valid thread found in current process."); + result.SetStatus (eReturnStatusFailed); + } + } + } + else + { + output_stream.Printf ("Process %d is running.\n", + exe_ctx.process->GetID()); + } + } + else + { + result.AppendError ("No current location or status available."); + result.SetStatus (eReturnStatusFailed); + } + return result.Succeeded(); + } +}; + +//------------------------------------------------------------------------- // CommandObjectMultiwordProcess //------------------------------------------------------------------------- @@ -823,6 +901,7 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter LoadSubCommand (CommandObjectSP (new CommandObjectProcessContinue ()), "continue", interpreter); LoadSubCommand (CommandObjectSP (new CommandObjectProcessDetach ()), "detach", interpreter); LoadSubCommand (CommandObjectSP (new CommandObjectProcessSignal ()), "signal", interpreter); + LoadSubCommand (CommandObjectSP (new CommandObjectProcessStatus ()), "status", interpreter); LoadSubCommand (CommandObjectSP (new CommandObjectProcessInterrupt ()), "interrupt", interpreter); LoadSubCommand (CommandObjectSP (new CommandObjectProcessKill ()), "kill", interpreter); } |