[Lldb-commits] [PATCH] D94357: [NFC] Add some additional, unconditional, logging to debugserver mostly related to app launching/attaching

2021-01-11 Thread Jason Molenda via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedde2eb1d209: Add unconditional logging to debugserver for 
launch/attach processes (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94357/new/

https://reviews.llvm.org/D94357

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/tools/debugserver/source/MacOSX/MachTask.mm
  lldb/tools/debugserver/source/RNBRemote.cpp
  lldb/tools/debugserver/source/debugserver.cpp

Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -583,29 +583,34 @@
   }
 
   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 @@
   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 @@
 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 @@
 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, 

[Lldb-commits] [PATCH] D94357: [NFC] Add some additional, unconditional, logging to debugserver mostly related to app launching/attaching

2021-01-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94357/new/

https://reviews.llvm.org/D94357

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D94357: [NFC] Add some additional, unconditional, logging to debugserver mostly related to app launching/attaching

2021-01-09 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

It can be tricky to find the important error messages when debugserver tries to 
launch or attach to a process in the system console log.  Add some new logging 
messages to give us clear before/after logging around the critical areas, so we 
can search other subsystems that might issue a console message about why the 
app launch failed.  These new logging messages are only intended to go to the 
system console, not stdout when running debugserver from the command line, 
unless logging is redirected somewhere else.

rdar://problem/67220442


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94357

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm
  lldb/tools/debugserver/source/MacOSX/MachTask.mm
  lldb/tools/debugserver/source/RNBRemote.cpp
  lldb/tools/debugserver/source/debugserver.cpp

Index: lldb/tools/debugserver/source/debugserver.cpp
===
--- lldb/tools/debugserver/source/debugserver.cpp
+++ lldb/tools/debugserver/source/debugserver.cpp
@@ -583,29 +583,34 @@
   }
 
   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 @@
   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 @@
 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 =