Skip to content

Commit

Permalink
[lldb][debugserver] Check if Rosetta debugserver exists (#110943)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jasonmolenda authored Oct 3, 2024
1 parent b977ec6 commit c20b90a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lldb/tools/debugserver/source/DNB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,9 +475,17 @@ nub_process_t DNBProcessAttach(nub_process_t attach_pid,
extern int communication_fd;

if (communication_fd == -1) {
fprintf(stderr, "Trying to attach to a translated process with the "
"native debugserver, exiting...\n");
exit(1);
DNBLogError("Trying to attach to a translated process with the "
"native debugserver, exiting...\n");
return INVALID_NUB_PROCESS_ARCH;
}

struct stat st;
if (::stat(translated_debugserver, &st) != 0) {
DNBLogError("Translated inferior process but Rosetta debugserver not "
"found at %s",
translated_debugserver);
return INVALID_NUB_PROCESS_ARCH;
}

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

0 comments on commit c20b90a

Please sign in to comment.