[debugger] Activate async message loop as default.

Enabled a flaky test about debugged jobs.

A previous change moved restarting a newly created process only if it
was launched by a filter (used for launching components). This is wrong
as it has to be done regardless. Moved restarting the process back to
the process starting event.

Added some more logging statements.

TEST=manual

Change-Id: Id59862f561b62377fc6b3d64e781eec338242980
diff --git a/garnet/bin/zxdb/client/process_impl.cc b/garnet/bin/zxdb/client/process_impl.cc
index 8979341..ec52d43 100644
--- a/garnet/bin/zxdb/client/process_impl.cc
+++ b/garnet/bin/zxdb/client/process_impl.cc
@@ -255,7 +255,6 @@
 }
 
 void ProcessImpl::OnSymbolLoadFailure(const Err& err) {
-  TIME_BLOCK();
   for (auto& observer : observers())
     observer.OnSymbolLoadFailure(this, err);
 }
diff --git a/garnet/bin/zxdb/client/session.cc b/garnet/bin/zxdb/client/session.cc
index a81d3e9..e6dd999 100644
--- a/garnet/bin/zxdb/client/session.cc
+++ b/garnet/bin/zxdb/client/session.cc
@@ -603,6 +603,9 @@
                                    std::vector<char> data) {
   debug_ipc::MessageReader reader(std::move(data));
 
+  DEBUG_LOG() << "Got " << debug_ipc::MsgHeader::TypeToString(header.type)
+              << " notification.";
+
   switch (header.type) {
     case debug_ipc::MsgHeader::Type::kNotifyProcessExiting: {
       debug_ipc::NotifyProcessExiting notify;
diff --git a/src/developer/debug/debug_agent/debug_agent.cc b/src/developer/debug/debug_agent/debug_agent.cc
index cb576b0..8d845a6 100644
--- a/src/developer/debug/debug_agent/debug_agent.cc
+++ b/src/developer/debug/debug_agent/debug_agent.cc
@@ -41,12 +41,11 @@
 
 DebugAgent::~DebugAgent() = default;
 
-void DebugAgent::OnProcessStart(const std::string& filter, zx::process process,
-                                zx::thread initial_thread) {
+void DebugAgent::OnProcessStart(const std::string& filter,
+                                zx::process process) {
   TIME_BLOCK();
   auto process_koid = KoidForObject(process);
   auto process_name = NameForObject(process);
-  auto thread_koid = KoidForObject(initial_thread);
 
   debug_ipc::NotifyProcessStarting notify;
   notify.koid = process_koid;
@@ -73,13 +72,6 @@
   create_info.handle = std::move(process);
   create_info.resume_initial_thread = false;
   AddDebuggedProcess(std::move(create_info));
-
-  // Attached to the process. At that point it will get a new thread
-  // notification for the initial thread which it can stop or continue as it
-  // desires. Therefore, we can always resume the thread in the "new process"
-  // exception.
-  debug_ipc::MessageLoopTarget::Current()->ResumeFromException(
-      thread_koid, initial_thread, 0);
 }
 
 void DebugAgent::RemoveDebuggedProcess(zx_koid_t process_koid) {
@@ -531,6 +523,8 @@
 
 void DebugAgent::LaunchProcess(const debug_ipc::LaunchRequest& request,
                                debug_ipc::LaunchReply* reply) {
+  FXL_DCHECK(!request.argv.empty());
+  DEBUG_LOG() << "Launching binary " << request.argv.front();
   Launcher launcher(services_);
   reply->inferior_type = debug_ipc::InferiorType::kBinary;
 
diff --git a/src/developer/debug/debug_agent/debug_agent.h b/src/developer/debug/debug_agent/debug_agent.h
index 48075b8..982ecec 100644
--- a/src/developer/debug/debug_agent/debug_agent.h
+++ b/src/developer/debug/debug_agent/debug_agent.h
@@ -44,8 +44,7 @@
 
   void RemoveBreakpoint(uint32_t breakpoint_id);
 
-  void OnProcessStart(const std::string& filter, zx::process,
-                      zx::thread initial_thread) override;
+  void OnProcessStart(const std::string& filter, zx::process) override;
 
   bool should_quit() const { return should_quit_; }
 
diff --git a/src/developer/debug/debug_agent/debugged_job.cc b/src/developer/debug/debug_agent/debugged_job.cc
index ca5dbde..20c2518 100644
--- a/src/developer/debug/debug_agent/debugged_job.cc
+++ b/src/developer/debug/debug_agent/debugged_job.cc
@@ -40,7 +40,7 @@
 
   zx::process process = GetProcessFromKoid(process_koid);
   auto proc_name = NameForObject(process);
-  zx::thread thread = ThreadForKoid(process.get(), thread_koid);
+  zx::thread initial_thread = ThreadForKoid(process.get(), thread_koid);
 
   // Tools like fx serve will connect every second or so to the target, spamming
   // logging for this with a lot of "/boot/bin/sh" starting.
@@ -71,9 +71,16 @@
   if (matching_filter) {
     DEBUG_LOG() << "Filter " << matching_filter->filter << " matches process "
                 << proc_name << ". Attaching.";
-    handler_->OnProcessStart(matching_filter->filter, std::move(process),
-                             std::move(thread));
+    handler_->OnProcessStart(matching_filter->filter, std::move(process));
   }
+
+  // Attached to the process. At that point it will get a new thread
+  // notification for the initial thread which it can stop or continue as it
+  // desires. Therefore, we can always resume the thread in the "new process"
+  // exception.
+  debug_ipc::MessageLoopTarget::Current()->ResumeFromException(
+      thread_koid, initial_thread, 0);
+
 }
 
 void DebuggedJob::SetFilters(std::vector<std::string> filters) {
diff --git a/src/developer/debug/debug_agent/debugged_job.h b/src/developer/debug/debug_agent/debugged_job.h
index 6c7e814..d3fca28 100644
--- a/src/developer/debug/debug_agent/debugged_job.h
+++ b/src/developer/debug/debug_agent/debugged_job.h
@@ -28,8 +28,8 @@
   //
   // The DebuggedJob matching filter passed in case the handler is tracking from
   // which this event comes from.
-  virtual void OnProcessStart(const std::string& filter, zx::process process,
-                              zx::thread thread) = 0;
+  virtual void OnProcessStart(const std::string& filter,
+                              zx::process process) = 0;
 };
 
 class DebuggedJob : public debug_ipc::ZirconExceptionWatcher {
diff --git a/src/developer/debug/debug_agent/integration_tests/debugged_job_test.cc b/src/developer/debug/debug_agent/integration_tests/debugged_job_test.cc
index a8558ab..c535421 100644
--- a/src/developer/debug/debug_agent/integration_tests/debugged_job_test.cc
+++ b/src/developer/debug/debug_agent/integration_tests/debugged_job_test.cc
@@ -205,7 +205,7 @@
 
 }  // namespace
 
-TEST(DebuggedJobIntegrationTest, DISABLED_OneProcess) {
+TEST(DebuggedJobIntegrationTest, RepresentativeScenario) {
   MessageLoopWrapper message_loop_wrapper;
   MessageLoop* message_loop = message_loop_wrapper.loop();
 
diff --git a/src/developer/debug/debug_agent/main.cc b/src/developer/debug/debug_agent/main.cc
index e3b2cce..717a2c0 100644
--- a/src/developer/debug/debug_agent/main.cc
+++ b/src/developer/debug/debug_agent/main.cc
@@ -172,8 +172,9 @@
   static std::map<std::string, std::string> options = {
       {"auwind", R"(
       [Experimental] Use the unwinder from AOSP.)"},
-      {"async-message-loop", R"(
-      [Experimental] Use async-loop backend message loop.)"},
+      {"legacy-message-loop", R"(
+      [DEPRECATED] Use the originalbackend message loop.
+                   Will be removed eventually.)"},
       {"debug-mode", R"(
       Run the agent on debug mode. This will enable conditional logging messages
       and timing profiling. Mainly useful for people developing zxdb.)"},
@@ -239,11 +240,11 @@
     debug_agent::SetUnwinderType(debug_agent::UnwinderType::kAndroid);
   }
 
-  // By default use the original agent message loop.
-  auto message_loop_type = MessageLoopTarget::Type::kZircon;
-  if (cmdline.HasOption("async-message-loop")) {
+  // By default use the async agent message loop.
+  auto message_loop_type = MessageLoopTarget::Type::kAsync;
+  if (cmdline.HasOption("legacy-message-loop")) {
     // Use new async loop.
-    message_loop_type = MessageLoopTarget::Type::kAsync;
+    message_loop_type = MessageLoopTarget::Type::kZircon;
   }
 
   if (cmdline.HasOption("debug-mode")) {