mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
Fix debugserver translation check
Currently, debugserver has a test to check if it was launched in translation. The intent was to cover the case where an x86_64 debugserver attempts to control an arm64/arm64e process, returning an error. However, this check also covers the case where users are attaching to an x86_64 process, exiting out before attempting to hand off control to the translated debugserver at `/Library/Apple/usr/libexec/oah/debugserver`. This diff delays the debugserver translation check until after determining whether to hand off control to `/Library/Apple/usr/libexec/oah/debugserver`. Only when the process is not translated and thus has not been handed off do we check if the debugserver is translated, erroring out in that case. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D124814
This commit is contained in:
@@ -477,6 +477,10 @@ nub_process_t DNBProcessAttach(nub_process_t attach_pid,
|
||||
}
|
||||
}
|
||||
|
||||
if (DNBDebugserverIsTranslated()) {
|
||||
return INVALID_NUB_PROCESS_ARCH;
|
||||
}
|
||||
|
||||
pid_t pid = INVALID_NUB_PROCESS;
|
||||
MachProcessSP processSP(new MachProcess);
|
||||
if (processSP.get()) {
|
||||
|
||||
@@ -54,6 +54,7 @@ typedef uint32_t nub_event_t;
|
||||
typedef uint32_t nub_bool_t;
|
||||
|
||||
#define INVALID_NUB_PROCESS ((nub_process_t)0)
|
||||
#define INVALID_NUB_PROCESS_ARCH ((nub_process_t)-1)
|
||||
#define INVALID_NUB_THREAD ((nub_thread_t)0)
|
||||
#define INVALID_NUB_WATCH_ID ((nub_watch_t)0)
|
||||
#define INVALID_NUB_HW_INDEX UINT32_MAX
|
||||
|
||||
@@ -3753,17 +3753,6 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) {
|
||||
char err_str[1024] = {'\0'};
|
||||
std::string attach_name;
|
||||
|
||||
if (DNBDebugserverIsTranslated()) {
|
||||
DNBLogError("debugserver is x86_64 binary running in translation, attach "
|
||||
"failed.");
|
||||
std::string return_message = "E96;";
|
||||
return_message +=
|
||||
cstring_to_asciihex_string("debugserver is x86_64 binary running in "
|
||||
"translation, attached failed.");
|
||||
SendPacket(return_message);
|
||||
return rnb_err;
|
||||
}
|
||||
|
||||
if (strstr(p, "vAttachWait;") == p) {
|
||||
p += strlen("vAttachWait;");
|
||||
if (!GetProcessNameFrom_vAttach(p, attach_name)) {
|
||||
@@ -3823,6 +3812,17 @@ rnb_err_t RNBRemote::HandlePacket_v(const char *p) {
|
||||
return HandlePacket_UNIMPLEMENTED(p);
|
||||
}
|
||||
|
||||
if (attach_pid == INVALID_NUB_PROCESS_ARCH) {
|
||||
DNBLogError("debugserver is x86_64 binary running in translation, attach "
|
||||
"failed.");
|
||||
std::string return_message = "E96;";
|
||||
return_message +=
|
||||
cstring_to_asciihex_string("debugserver is x86_64 binary running in "
|
||||
"translation, attach failed.");
|
||||
SendPacket(return_message.c_str());
|
||||
return rnb_err;
|
||||
}
|
||||
|
||||
if (attach_pid != INVALID_NUB_PROCESS) {
|
||||
if (m_ctx.ProcessID() != attach_pid)
|
||||
m_ctx.SetProcessID(attach_pid);
|
||||
|
||||
Reference in New Issue
Block a user