diff options
| author | Zachary Turner <zturner@google.com> | 2014-07-28 16:45:18 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2014-07-28 16:45:18 +0000 |
| commit | 35ed13262d1f9a6434dab9f00e7abf011f854bdc (patch) | |
| tree | 3373e37d8d0c23cdfbe04055723526fdfb6f4aad /lldb/source/Plugins/Process/Windows/ProcessWindows.cpp | |
| parent | 9e757b7ebe5c3e1a07d4e3f5757f2dd19a78a8a1 (diff) | |
| download | bcm5719-llvm-35ed13262d1f9a6434dab9f00e7abf011f854bdc.tar.gz bcm5719-llvm-35ed13262d1f9a6434dab9f00e7abf011f854bdc.zip | |
Teach LLDB about Windows processes.
This patch creates a simple ProcessWindows process plugin.
The only thing it knows how to do currently is create processes.
Differential Revision: http://reviews.llvm.org/D4681
llvm-svn: 214094
Diffstat (limited to 'lldb/source/Plugins/Process/Windows/ProcessWindows.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Windows/ProcessWindows.cpp | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp new file mode 100644 index 00000000000..8aeed4b8252 --- /dev/null +++ b/lldb/source/Plugins/Process/Windows/ProcessWindows.cpp @@ -0,0 +1,203 @@ +//===-- ProcessWindows.cpp --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Windows includes +#include "lldb/Host/windows/windows.h" + +// C++ Includes +// Other libraries and framework includes +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/State.h" +#include "lldb/Host/Host.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/DynamicLoader.h" +#include "lldb/Target/Target.h" + +#include "ProcessWindows.h" + +using namespace lldb; +using namespace lldb_private; + +//------------------------------------------------------------------------------ +// Static functions. + +ProcessSP +ProcessWindows::CreateInstance(Target &target, Listener &listener, const FileSpec *) +{ + return ProcessSP(new ProcessWindows(target, listener)); +} + +void +ProcessWindows::Initialize() +{ + static bool g_initialized = false; + + if (!g_initialized) + { + g_initialized = true; + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); + } +} + +//------------------------------------------------------------------------------ +// Constructors and destructors. + +ProcessWindows::ProcessWindows(Target& target, Listener &listener) + : lldb_private::Process(target, listener) +{ +} + +void +ProcessWindows::Terminate() +{ +} + +lldb_private::ConstString +ProcessWindows::GetPluginNameStatic() +{ + static ConstString g_name("windows"); + return g_name; +} + +const char * +ProcessWindows::GetPluginDescriptionStatic() +{ + return "Process plugin for Windows"; +} + + +bool +ProcessWindows::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) +{ + new_thread_list = old_thread_list; + return new_thread_list.GetSize(false) > 0; +} + +Error +ProcessWindows::DoLaunch(Module *exe_module, + ProcessLaunchInfo &launch_info) +{ + std::string executable; + std::string commandLine; + std::vector<char> environment; + STARTUPINFO startupinfo = {0}; + PROCESS_INFORMATION pi = {0}; + startupinfo.cb = sizeof(startupinfo); + + executable = launch_info.GetExecutableFile().GetPath(); + launch_info.GetArguments().GetQuotedCommandString(commandLine); + BOOL result = ::CreateProcessA(executable.c_str(), + const_cast<char*>(commandLine.c_str()), + NULL, + NULL, + FALSE, + CREATE_NEW_CONSOLE, + NULL, + launch_info.GetWorkingDirectory(), + &startupinfo, + &pi); + Error error; + if (!result) + error.SetErrorToErrno(); + return error; +} + +Error +ProcessWindows::DoResume() +{ + Error error; + return error; +} + + +//------------------------------------------------------------------------------ +// ProcessInterface protocol. + +lldb_private::ConstString +ProcessWindows::GetPluginName() +{ + return GetPluginNameStatic(); +} + +uint32_t +ProcessWindows::GetPluginVersion() +{ + return 1; +} + +void +ProcessWindows::GetPluginCommandHelp(const char *command, Stream *strm) +{ +} + +Error +ProcessWindows::ExecutePluginCommand(Args &command, Stream *strm) +{ + return Error(1, eErrorTypeGeneric); +} + +Log * +ProcessWindows::EnablePluginLogging(Stream *strm, Args &command) +{ + return NULL; +} + +Error +ProcessWindows::DoDetach(bool keep_stopped) +{ + Error error; + error.SetErrorString("Detaching from processes is not currently supported on Windows."); + return error; +} + +Error +ProcessWindows::DoDestroy() +{ + Error error; + error.SetErrorString("Destroying processes is not currently supported on Windows."); + return error; +} + +void +ProcessWindows::RefreshStateAfterStop() +{ +} + +bool +ProcessWindows::IsAlive() +{ + return false; +} + +size_t +ProcessWindows::DoReadMemory(lldb::addr_t vm_addr, + void *buf, + size_t size, + Error &error) +{ + return 0; +} + + +bool +ProcessWindows::CanDebug(Target &target, bool plugin_specified_by_name) +{ + if (plugin_specified_by_name) + return true; + + // For now we are just making sure the file exists for a given module + ModuleSP exe_module_sp(target.GetExecutableModule()); + if (exe_module_sp.get()) + return exe_module_sp->GetFileSpec().Exists(); + return false; +} + |

