aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp31
1 files changed, 12 insertions, 19 deletions
diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index f7f52de..ec2aebc 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -246,25 +246,20 @@ NativeProcessLinux::Factory::Launch(ProcessLaunchInfo &launch_info,
}
LLDB_LOG(log, "inferior started, now in stopped state");
- ProcessInstanceInfo Info;
- if (!Host::GetProcessInfo(pid, Info)) {
- return llvm::make_error<StringError>("Cannot get process architecture",
- llvm::inconvertibleErrorCode());
- }
-
- // Set the architecture to the exe architecture.
- LLDB_LOG(log, "pid = {0:x}, detected architecture {1}", pid,
- Info.GetArchitecture().GetArchitectureName());
-
status = SetDefaultPtraceOpts(pid);
if (status.Fail()) {
LLDB_LOG(log, "failed to set default ptrace options: {0}", status);
return status.ToError();
}
+ llvm::Expected<ArchSpec> arch_or =
+ NativeRegisterContextLinux::DetermineArchitecture(pid);
+ if (!arch_or)
+ return arch_or.takeError();
+
return std::unique_ptr<NativeProcessLinux>(new NativeProcessLinux(
pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), native_delegate,
- Info.GetArchitecture(), mainloop, {pid}));
+ *arch_or, mainloop, {pid}));
}
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
@@ -274,19 +269,17 @@ NativeProcessLinux::Factory::Attach(
Log *log = GetLog(POSIXLog::Process);
LLDB_LOG(log, "pid = {0:x}", pid);
- // Retrieve the architecture for the running process.
- ProcessInstanceInfo Info;
- if (!Host::GetProcessInfo(pid, Info)) {
- return llvm::make_error<StringError>("Cannot get process architecture",
- llvm::inconvertibleErrorCode());
- }
-
auto tids_or = NativeProcessLinux::Attach(pid);
if (!tids_or)
return tids_or.takeError();
+ ArrayRef<::pid_t> tids = *tids_or;
+ llvm::Expected<ArchSpec> arch_or =
+ NativeRegisterContextLinux::DetermineArchitecture(tids[0]);
+ if (!arch_or)
+ return arch_or.takeError();
return std::unique_ptr<NativeProcessLinux>(new NativeProcessLinux(
- pid, -1, native_delegate, Info.GetArchitecture(), mainloop, *tids_or));
+ pid, -1, native_delegate, *arch_or, mainloop, tids));
}
NativeProcessLinux::Extension