[lldb] [Process/FreeBSDRemote] Handle exec() from inferior
authorMichał Górny <mgorny@moritz.systems>
Fri, 6 Nov 2020 14:32:43 +0000 (15:32 +0100)
committerMichał Górny <mgorny@moritz.systems>
Mon, 9 Nov 2020 10:35:11 +0000 (11:35 +0100)
Differential Revision: https://reviews.llvm.org/D90938

lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
lldb/test/API/functionalities/exec/TestExec.py

index d132e37..5c10c9c 100644 (file)
@@ -211,6 +211,22 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
     return;
   }
 
+  if (info.pl_flags & PL_FLAG_EXEC) {
+    Status error = ReinitializeThreads();
+    if (error.Fail()) {
+      SetState(StateType::eStateInvalid);
+      return;
+    }
+
+    // Let our delegate know we have just exec'd.
+    NotifyDidExec();
+
+    for (const auto &thread : m_threads)
+      static_cast<NativeThreadFreeBSD &>(*thread).SetStoppedByExec();
+    SetState(StateType::eStateStopped, true);
+    return;
+  }
+
   if (info.pl_lwpid > 0) {
     for (const auto &t : m_threads) {
       if (t->GetID() == static_cast<lldb::tid_t>(info.pl_lwpid))
index 89ee640..019df21 100644 (file)
@@ -20,7 +20,6 @@ class ExecTestCase(TestBase):
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
     @expectedFailureNetBSD
     @skipIfAsan # rdar://problem/43756823
-    @skipIfFreeBSD  # hangs
     @skipIfWindows
     def test_hitting_exec (self):
         self.do_test(False)
@@ -29,7 +28,6 @@ class ExecTestCase(TestBase):
     @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
     @expectedFailureNetBSD
     @skipIfAsan # rdar://problem/43756823
-    @skipIfFreeBSD  # hangs
     @skipIfWindows
     def test_skipping_exec (self):
         self.do_test(True)