diff options
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 15 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectProcess.cpp | 124 |
2 files changed, 124 insertions, 15 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 7f7c780978a..2045c59d058 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -218,21 +218,6 @@ CommandObjectExpression::EvaluateExpression return false; } - if (!m_exe_ctx.process->GetDynamicCheckers()) - { - DynamicCheckerFunctions *dynamic_checkers = new DynamicCheckerFunctions(); - - StreamString install_errors; - - if (!dynamic_checkers->Install(install_errors, m_exe_ctx)) - { - error_stream.Printf("Couldn't install dynamic checkers into the execution context: %s\n", install_errors.GetData()); - return false; - } - - m_exe_ctx.process->SetDynamicCheckers(dynamic_checkers); - } - const char *prefix = NULL; if (m_exe_ctx.target) diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 8c4ffdd96bb..88fdca3086b 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -853,6 +853,128 @@ public: }; //------------------------------------------------------------------------- +// CommandObjectProcessLoad +//------------------------------------------------------------------------- + +class CommandObjectProcessLoad : public CommandObject +{ +public: + + CommandObjectProcessLoad (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process load", + "Load a shared library into the current process.", + "process load <filename> [<filename> ...]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + { + } + + ~CommandObjectProcessLoad () + { + } + + bool + Execute (Args& command, + CommandReturnObject &result) + { + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + if (process == NULL) + { + result.AppendError ("must have a valid process in order to load a shared library"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const uint32_t argc = command.GetArgumentCount(); + + for (uint32_t i=0; i<argc; ++i) + { + Error error; + const char *image_path = command.GetArgumentAtIndex(i); + FileSpec image_spec (image_path, false); + uint32_t image_token = process->LoadImage(image_spec, error); + if (image_token != LLDB_INVALID_IMAGE_TOKEN) + { + result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %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 +//------------------------------------------------------------------------- + +class CommandObjectProcessUnload : public CommandObject +{ +public: + + CommandObjectProcessUnload (CommandInterpreter &interpreter) : + CommandObject (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>", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + { + } + + ~CommandObjectProcessUnload () + { + } + + bool + Execute (Args& command, + CommandReturnObject &result) + { + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + if (process == NULL) + { + result.AppendError ("must have a valid process in order to load a shared library"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const uint32_t argc = command.GetArgumentCount(); + + 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(); + } +}; + +//------------------------------------------------------------------------- // CommandObjectProcessSignal //------------------------------------------------------------------------- @@ -1450,6 +1572,8 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter))); LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (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))); |