[Lldb-commits] [PATCH] D109591: [lldb] [test] Synchronize before the breakpoint in fork tests

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 10 04:06:23 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcaf508d71243: [lldb] [test] Synchronize before the breakpoint in fork tests (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109591

Files:
  lldb/test/Shell/Subprocess/Inputs/fork.cpp


Index: lldb/test/Shell/Subprocess/Inputs/fork.cpp
===================================================================
--- lldb/test/Shell/Subprocess/Inputs/fork.cpp
+++ lldb/test/Shell/Subprocess/Inputs/fork.cpp
@@ -28,9 +28,24 @@
   assert(ret == 0);
 }
 
-int child_func(void *argv0_ptr) {
+// This is the function we set breakpoint on.
+int child_func(const char *argv0) {
+  // we need to avoid memory modifications for vfork(), yet we want
+  // to be able to test watchpoints, so do the next best thing
+  // and restore the original value
+  g_val = 2;
+  g_val = 0;
+  execl(argv0, argv0, parent_done_str, NULL);
+  assert(0 && "this should not be reached");
+  return 1;
+}
+
+int child_top_func(void *argv0_ptr) {
   const char *argv0 = static_cast<char*>(argv0_ptr);
 
+  int ret = close(parent_done[1]);
+  assert(ret == 0);
+
   // NB: when using vfork(), the parent may be suspended while running
   // this function, so do not rely on any synchronization until we exec
 #if defined(TEST_FORK)
@@ -38,17 +53,7 @@
 #endif
     wait_for_parent();
 
-  int ret = close(parent_done[1]);
-  assert(ret == 0);
-
-  // we need to avoid memory modifications for vfork(), yet we want
-  // to be able to test watchpoints, so do the next best thing
-  // and restore the original value
-  g_val = 2;
-  g_val = 0;
-  execl(argv0, argv0, parent_done_str, NULL);
-  assert(0 && "this should not be reached");
-  return 1;
+  return child_func(argv0);
 }
 
 int main(int argc, char* argv[]) {
@@ -77,12 +82,12 @@
   assert(ret != -1);
 
 #if defined(TEST_CLONE)
-  pid_t pid = clone(child_func, &stack[sizeof(stack)], 0, argv[0]);
+  pid_t pid = clone(child_top_func, &stack[sizeof(stack)], 0, argv[0]);
 #elif defined(TEST_FORK)
   pid_t pid = TEST_FORK();
   // NB: this must be equivalent to the clone() call above
   if (pid == 0)
-    _exit(child_func(argv[0]));
+    _exit(child_top_func(argv[0]));
 #endif
   assert(pid != -1);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109591.371868.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210910/fc95491b/attachment.bin>


More information about the lldb-commits mailing list