[Lldb-commits] [lldb] [lldb][test] Fix undefined behaviour in multi process driver (PR #226949)

via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 28 03:36:12 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp b/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
index 8af3695db..30e477681 100644
--- a/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
+++ b/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
@@ -88,11 +88,10 @@ walk_stack_to_main (SBThread thread)
     while (!found_main && curr_frame < framecount)
     {
         SBFrame frame = thread.GetFrameAtIndex (curr_frame);
-        const char* function_name = frame.GetFunctionName();
-        if (function_name && strcmp (function_name, "main") == 0)
-        {
-            found_main = true;
-            break;
+        const char *function_name = frame.GetFunctionName();
+        if (function_name && strcmp(function_name, "main") == 0) {
+          found_main = true;
+          break;
         }
         curr_frame += 1;
     }
@@ -159,15 +158,19 @@ void *do_one_debugger (void *in)
                 }
 
                 // On Linux the () are included.
-                const char* hit_fn_name = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetFunctionName();
-                if (!hit_fn_name || (strcmp (hit_fn_name, "foo") != 0 && strcmp (hit_fn_name, "foo()") != 0))
-                {
+                const char *hit_fn_name = process.GetThreadAtIndex(0)
+                                              .GetFrameAtIndex(0)
+                                              .GetFunctionName();
+                if (!hit_fn_name || (strcmp(hit_fn_name, "foo") != 0 &&
+                                     strcmp(hit_fn_name, "foo()") != 0)) {
 #if DEBUG == 1
-                    printf ("#%" PRIu64 ": First breakpoint did not stop at foo(), instead stopped at ", threadnum);
-                    if (hit_fn_name)
-                        printf ("'%s'\n", hit_fn_name);
-                    else
-                        printf ("an unnamed function\n");
+                  printf("#%" PRIu64 ": First breakpoint did not stop at "
+                                     "foo(), instead stopped at ",
+                         threadnum);
+                  if (hit_fn_name)
+                    printf("'%s'\n", hit_fn_name);
+                  else
+                    printf("an unnamed function\n");
 #endif
                     completed_threads_array[threadnum] = true;
                     return (void*) 1;
@@ -192,12 +195,16 @@ void *do_one_debugger (void *in)
                     return (void *) 1;
                 }
 
-                hit_fn_name = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetFunctionName();
-                if (!hit_fn_name || (strcmp (hit_fn_name, "bar") != 0 && strcmp (hit_fn_name, "bar()") != 0))
-                {
-                    printf ("#%" PRIu64 ": First breakpoint did not stop at bar()\n", threadnum);
-                    completed_threads_array[threadnum] = true;
-                    return (void*) 1;
+                hit_fn_name = process.GetThreadAtIndex(0)
+                                  .GetFrameAtIndex(0)
+                                  .GetFunctionName();
+                if (!hit_fn_name || (strcmp(hit_fn_name, "bar") != 0 &&
+                                     strcmp(hit_fn_name, "bar()") != 0)) {
+                  printf("#%" PRIu64
+                         ": First breakpoint did not stop at bar()\n",
+                         threadnum);
+                  completed_threads_array[threadnum] = true;
+                  return (void *)1;
                 }
 
                 process.Kill();

``````````

</details>


https://github.com/llvm/llvm-project/pull/226949


More information about the lldb-commits mailing list