summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/NativeProcessProtocol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Host/common/NativeProcessProtocol.cpp')
-rw-r--r--lldb/source/Host/common/NativeProcessProtocol.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/lldb/source/Host/common/NativeProcessProtocol.cpp b/lldb/source/Host/common/NativeProcessProtocol.cpp
index dfac0cb5645..bdc58fb8b43 100644
--- a/lldb/source/Host/common/NativeProcessProtocol.cpp
+++ b/lldb/source/Host/common/NativeProcessProtocol.cpp
@@ -12,12 +12,15 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/Log.h"
+#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/State.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/common/NativeRegisterContext.h"
-
#include "lldb/Host/common/NativeThreadProtocol.h"
#include "lldb/Host/common/SoftwareBreakpoint.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Utility/LLDBAssert.h"
using namespace lldb;
using namespace lldb_private;
@@ -436,6 +439,29 @@ NativeProcessProtocol::DoStopIDBumped (uint32_t /* newBumpId */)
// Default implementation does nothing.
}
+Error
+NativeProcessProtocol::ResolveProcessArchitecture(lldb::pid_t pid,
+ ArchSpec &arch)
+{
+ // Grab process info for the running process.
+ ProcessInstanceInfo process_info;
+ if (!Host::GetProcessInfo(pid, process_info))
+ return Error("failed to get process info");
+
+ // Resolve the executable module.
+ ModuleSpecList module_specs;
+ if (!ObjectFile::GetModuleSpecifications(process_info.GetExecutableFile(),
+ 0, 0, module_specs))
+ return Error("failed to get module specifications");
+ lldbassert(module_specs.GetSize() == 1);
+
+ arch = module_specs.GetModuleSpecRefAtIndex(0).GetArchitecture();
+ if (arch.IsValid())
+ return Error();
+ else
+ return Error("failed to retrieve a valid architecture from the exe module");
+}
+
#ifndef __linux__
// These need to be implemented to support lldb-gdb-server on a given platform. Stubs are
// provided to make the rest of the code link on non-supported platforms.
OpenPOWER on IntegriCloud