diff options
author | Greg Clayton <gclayton@apple.com> | 2014-06-13 00:54:12 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2014-06-13 00:54:12 +0000 |
commit | a2715cf108d1fc433ffd76102998dbc470720103 (patch) | |
tree | 07af7321b88e0be9ca48eaa51a2d47aed7485ac9 /lldb/source/Commands/CommandObjectProcess.cpp | |
parent | 454d374e37ebebf7a2746093d8543197516b95d0 (diff) | |
download | bcm5719-llvm-a2715cf108d1fc433ffd76102998dbc470720103.tar.gz bcm5719-llvm-a2715cf108d1fc433ffd76102998dbc470720103.zip |
Added the ability to save core files:
(lldb) file /bin/ls
(lldb) b malloc
(lldb) run
(lldb) process save-core /tmp/ls.core
Each ObjectFile plug-in now has the option to save core files by registering a new static callback.
llvm-svn: 210864
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 27c1109571e..92735ecee19 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -20,6 +20,7 @@ #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/State.h" #include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" @@ -1483,6 +1484,71 @@ protected: }; //------------------------------------------------------------------------- +// 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:\nUsage: %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(); + } +}; + +//------------------------------------------------------------------------- // CommandObjectProcessStatus //------------------------------------------------------------------------- #pragma mark CommandObjectProcessStatus @@ -1853,6 +1919,7 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter))); LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter))); LoadSubCommand ("plugin", CommandObjectSP (new CommandObjectProcessPlugin (interpreter))); + LoadSubCommand ("save-core", CommandObjectSP (new CommandObjectProcessSaveCore (interpreter))); } CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () |