Skip to content

Commit b854d8d

Browse files
committed
[lldb][debugserver] Check if Rosetta debugserver exists (llvm#110943)
If lldb tries to attach to a process that is marked 'Translated' with debugserver, it will exec the Rosetta debugserver to handle the debug session without checking if it is present. If there is a configuration that is somehow missing this, it will fail poorly. rdar://135641680 (cherry picked from commit c20b90a)
1 parent d93fb41 commit b854d8d

File tree

1 file changed

+11
-3
lines changed
  • lldb/tools/debugserver/source

1 file changed

+11
-3
lines changed

lldb/tools/debugserver/source/DNB.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,17 @@ nub_process_t DNBProcessAttach(nub_process_t attach_pid,
475475
extern int communication_fd;
476476

477477
if (communication_fd == -1) {
478-
fprintf(stderr, "Trying to attach to a translated process with the "
479-
"native debugserver, exiting...\n");
480-
exit(1);
478+
DNBLogError("Trying to attach to a translated process with the "
479+
"native debugserver, exiting...\n");
480+
return INVALID_NUB_PROCESS_ARCH;
481+
}
482+
483+
struct stat st;
484+
if (::stat(translated_debugserver, &st) != 0) {
485+
DNBLogError("Translated inferior process but Rosetta debugserver not "
486+
"found at %s",
487+
translated_debugserver);
488+
return INVALID_NUB_PROCESS_ARCH;
481489
}
482490

483491
snprintf(fdstr, sizeof(fdstr), "--fd=%d", communication_fd);

0 commit comments

Comments
 (0)