aboutsummaryrefslogtreecommitdiff
path: root/lldb/tools/debugserver/source/debugserver.cpp
diff options
context:
space:
mode:
authorJason Molenda <jason@molenda.com>2021-01-11 22:17:10 -0800
committerJason Molenda <jason@molenda.com>2021-01-11 22:17:10 -0800
commitedde2eb1d2093905a2cb6166e6a60f9cc04c2bbc (patch)
tree7ba3ccfbe4ee2c223729655aa78eb0e9dc03cc09 /lldb/tools/debugserver/source/debugserver.cpp
parentb1c304c4946506c0d00532829fb2f91276dde0c8 (diff)
downloadllvm-edde2eb1d2093905a2cb6166e6a60f9cc04c2bbc.zip
llvm-edde2eb1d2093905a2cb6166e6a60f9cc04c2bbc.tar.gz
llvm-edde2eb1d2093905a2cb6166e6a60f9cc04c2bbc.tar.bz2
Add unconditional logging to debugserver for launch/attach processes
Debugging app launch/attach failures can be difficult because of all of the messages logged to the console on a darwin system; emitting specific messages around critical API calls can make it easier to narrow the search for the console messages related to the failure. <rdar://problem/67220442> Differential revision: https://reviews.llvm.org/D94357
Diffstat (limited to 'lldb/tools/debugserver/source/debugserver.cpp')
-rw-r--r--lldb/tools/debugserver/source/debugserver.cpp46
1 files changed, 32 insertions, 14 deletions
diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp
index fed24fe..d76f4f0 100644
--- a/lldb/tools/debugserver/source/debugserver.cpp
+++ b/lldb/tools/debugserver/source/debugserver.cpp
@@ -583,29 +583,34 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemote *remote) {
}
if (set_events & RNBContext::event_proc_thread_exiting) {
+ DNBLog("debugserver's process monitoring thread has exited.");
mode = eRNBRunLoopModeExit;
}
if (set_events & RNBContext::event_read_thread_exiting) {
// Out remote packet receiving thread exited, exit for now.
+ DNBLog(
+ "debugserver's packet communication to lldb has been shut down.");
if (ctx.HasValidProcessID()) {
+ nub_process_t pid = ctx.ProcessID();
// TODO: We should add code that will leave the current process
// in its current state and listen for another connection...
if (ctx.ProcessStateRunning()) {
if (ctx.GetDetachOnError()) {
- DNBLog("debugserver's event read thread is exiting, detaching "
- "from the inferior process.");
- DNBProcessDetach(ctx.ProcessID());
+ DNBLog("debugserver has a valid PID %d, it is still running. "
+ "detaching from the inferior process.",
+ pid);
+ DNBProcessDetach(pid);
} else {
- DNBLog("debugserver's event read thread is exiting, killing the "
- "inferior process.");
- DNBProcessKill(ctx.ProcessID());
+ DNBLog("debugserver killing the inferior process, pid %d.", pid);
+ DNBProcessKill(pid);
}
} else {
if (ctx.GetDetachOnError()) {
- DNBLog("debugserver's event read thread is exiting, detaching "
- "from the inferior process.");
- DNBProcessDetach(ctx.ProcessID());
+ DNBLog("debugserver has a valid PID %d but it may no longer "
+ "be running, detaching from the inferior process.",
+ pid);
+ DNBProcessDetach(pid);
}
}
}
@@ -1104,21 +1109,30 @@ int main(int argc, char *argv[]) {
if (optarg && optarg[0]) {
if (strcasecmp(optarg, "auto") == 0)
g_launch_flavor = eLaunchFlavorDefault;
- else if (strcasestr(optarg, "posix") == optarg)
+ else if (strcasestr(optarg, "posix") == optarg) {
+ DNBLog(
+ "[LaunchAttach] launch flavor is posix_spawn via cmdline option");
g_launch_flavor = eLaunchFlavorPosixSpawn;
- else if (strcasestr(optarg, "fork") == optarg)
+ } else if (strcasestr(optarg, "fork") == optarg)
g_launch_flavor = eLaunchFlavorForkExec;
#ifdef WITH_SPRINGBOARD
- else if (strcasestr(optarg, "spring") == optarg)
+ else if (strcasestr(optarg, "spring") == optarg) {
+ DNBLog(
+ "[LaunchAttach] launch flavor is SpringBoard via cmdline option");
g_launch_flavor = eLaunchFlavorSpringBoard;
+ }
#endif
#ifdef WITH_BKS
- else if (strcasestr(optarg, "backboard") == optarg)
+ else if (strcasestr(optarg, "backboard") == optarg) {
+ DNBLog("[LaunchAttach] launch flavor is BKS via cmdline option");
g_launch_flavor = eLaunchFlavorBKS;
+ }
#endif
#ifdef WITH_FBS
- else if (strcasestr(optarg, "frontboard") == optarg)
+ else if (strcasestr(optarg, "frontboard") == optarg) {
+ DNBLog("[LaunchAttach] launch flavor is FBS via cmdline option");
g_launch_flavor = eLaunchFlavorFBS;
+ }
#endif
else {
@@ -1398,6 +1412,7 @@ int main(int argc, char *argv[]) {
dup2(null, STDOUT_FILENO);
dup2(null, STDERR_FILENO);
} else if (g_applist_opt != 0) {
+ DNBLog("debugserver running in --applist mode");
// List all applications we are able to see
std::string applist_plist;
int err = ListApplications(applist_plist, false, false);
@@ -1455,6 +1470,7 @@ int main(int argc, char *argv[]) {
mode = eRNBRunLoopModeExit;
} else if (g_applist_opt != 0) {
// List all applications we are able to see
+ DNBLog("debugserver running in applist mode under lockdown");
std::string applist_plist;
if (ListApplications(applist_plist, false, false) == 0) {
DNBLogDebug("Task list: %s", applist_plist.c_str());
@@ -1631,6 +1647,8 @@ int main(int argc, char *argv[]) {
const char *proc_name = "<unknown>";
if (ctx.ArgumentCount() > 0)
proc_name = ctx.ArgumentAtIndex(0);
+ DNBLog("[LaunchAttach] Successfully launched %s (pid = %d).\n",
+ proc_name, ctx.ProcessID());
RNBLogSTDOUT("Got a connection, launched process %s (pid = %d).\n",
proc_name, ctx.ProcessID());
}