Skip to content

[lldb][test] Fix TestMultipleDebuggers test on non-x86, other small issues #101169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Jul 30, 2024

This test has been flaky lately (#101162) and I disabled it everywhere initially.

I found that it always uses "x86_64" for the program architecture so the test was "passing" elsewhere but I don't think it was meant to. So I have added a define to pass on the host's architecture when compiling. This makes it work on AArch64 as well.

While I'm here I've fixed the uint64_t formatting warnings by using the defined formats that'll work everywhere.

In addition, I found that the function names include "()" on Linux, so now we check for "foo" or "foo()".

The test cpp file has never been, or was only partially formatted so I've not formatted the changes, just kept to the local style.

I've removed the Linux skip to see if any of this helps the timeouts, and to verify the build command changes. If the timeouts come back I'll disable it again.

…ssues

This test has been flaky lately (llvm#101162)
and I disabled it everywhere initially.

I found that it always uses "x86_64" for the program architecture so the test
was "passing" elsewhere but I don't think it was meant to. So I have added a define
to pass on the host's architecture when compiling. This makes it work on AArch64
as well.

While I'm here I've fixed the uint64_t formatting warnings by using the defined
formats that'll work everywhere.

In addition, I found that the function names include "()" on Linux, so now we
check for "foo" or "foo()".

The test cpp file has never been formatted so I've not done that either, just
kept to the local style.

I've removed the Linux skip to see if any of this helps the timeouts, and to
verify the build command changes. If the timeouts come back I'll disable it again.
@DavidSpickett DavidSpickett changed the title [lldb][test] Fix TestMultipleDebuggers test on non-x86, other small i… [lldb][test] Fix TestMultipleDebuggers test on non-x86, other small issues Jul 30, 2024
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 533a22941e9acee1460fbd054fbfa57b82d660e5 491bf0e33eb5ee997a05f3aa141d5e4b2f0a064c --extensions cpp -- lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
View the diff from clang-format here.
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 64728fb7c2..57a6585ee0 100644
--- a/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
+++ b/lldb/test/API/api/multiple-debuggers/multi-process-driver.cpp
@@ -13,10 +13,10 @@
 // that are hit when lldb is being used to debug multiple processes
 // simultaneously.
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <inttypes.h>
 
 #include "lldb/API/LLDB.h"
 #include "lldb/API/SBCommandInterpreter.h"
@@ -106,21 +106,24 @@ void *do_one_debugger (void *in)
     if (debugger.IsValid ())
     {
         debugger.SetAsync (true);
-        SBTarget target = debugger.CreateTargetWithFileAndArch(inferior_process_name,
-                                                               STR(LLDB_HOST_ARCH));
+        SBTarget target = debugger.CreateTargetWithFileAndArch(
+            inferior_process_name, STR(LLDB_HOST_ARCH));
         SBCommandInterpreter command_interp = debugger.GetCommandInterpreter();
         if (target.IsValid())
         {
             SBBreakpoint bar_br = target.BreakpointCreateByName ("bar", "testprog");
             if (!bar_br.IsValid())
             {
-                printf ("#%" PRIu64 ": failed to set breakpoint on bar, exiting.\n", threadnum);
-                exit (1);
+              printf("#%" PRIu64
+                     ": failed to set breakpoint on bar, exiting.\n",
+                     threadnum);
+              exit(1);
             }
             SBBreakpoint foo_br = target.BreakpointCreateByName ("foo", "testprog");
             if (!foo_br.IsValid())
             {
-                printf ("#%" PRIu64 ": Failed to set breakpoint on foo()\n", threadnum);
+              printf("#%" PRIu64 ": Failed to set breakpoint on foo()\n",
+                     threadnum);
             }
 
             SBLaunchInfo launch_info (NULL);
@@ -141,17 +144,25 @@ void *do_one_debugger (void *in)
 
                 if (!walk_stack_to_main (process.GetThreadAtIndex(0)))
                 {
-                    printf ("#%" PRIu64 ": backtrace while @ foo() failed\n", threadnum);
-                    completed_threads_array[threadnum] = true;
-                    return (void *) 1;
+                  printf("#%" PRIu64 ": backtrace while @ foo() failed\n",
+                         threadnum);
+                  completed_threads_array[threadnum] = true;
+                  return (void *)1;
                 }
 
                 // On Linux the () are included.
-                const char* hit_fn = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetFunctionName();
-                if (strcmp (hit_fn, "foo") != 0 && strcmp (hit_fn, "foo()") != 0)
-                {
+                const char *hit_fn = process.GetThreadAtIndex(0)
+                                         .GetFrameAtIndex(0)
+                                         .GetFunctionName();
+                if (strcmp(hit_fn, "foo") != 0 &&
+                    strcmp(hit_fn, "foo()") != 0) {
 #if DEBUG == 1
-                    printf ("#%" PRIu64 ": First breakpoint did not stop at foo(), instead stopped at '%s'\n", threadnum, process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetFunctionName());
+                  printf("#%" PRIu64 ": First breakpoint did not stop at "
+                                     "foo(), instead stopped at '%s'\n",
+                         threadnum,
+                         process.GetThreadAtIndex(0)
+                             .GetFrameAtIndex(0)
+                             .GetFunctionName());
 #endif
                     completed_threads_array[threadnum] = true;
                     return (void*) 1;
@@ -163,25 +174,30 @@ void *do_one_debugger (void *in)
 
                 if (process.GetState() == StateType::eStateExited)
                 {
-                    printf ("#%" PRIu64 ": Process exited\n", threadnum);
-                    completed_threads_array[threadnum] = true;
-                    return (void *) 1;
+                  printf("#%" PRIu64 ": Process exited\n", threadnum);
+                  completed_threads_array[threadnum] = true;
+                  return (void *)1;
                 }
 
 
                 if (!walk_stack_to_main (process.GetThreadAtIndex(0)))
                 {
-                    printf ("#%" PRIu64 ": backtrace while @ bar() failed\n", threadnum);
-                    completed_threads_array[threadnum] = true;
-                    return (void *) 1;
+                  printf("#%" PRIu64 ": backtrace while @ bar() failed\n",
+                         threadnum);
+                  completed_threads_array[threadnum] = true;
+                  return (void *)1;
                 }
 
-                hit_fn = process.GetThreadAtIndex(0).GetFrameAtIndex(0).GetFunctionName();
-                if (strcmp (hit_fn, "bar") != 0 && strcmp (hit_fn, "bar()") != 0)
-                {
-                    printf ("#%" PRIu64 ": First breakpoint did not stop at bar()\n", threadnum);
-                    completed_threads_array[threadnum] = true;
-                    return (void*) 1;
+                hit_fn = process.GetThreadAtIndex(0)
+                             .GetFrameAtIndex(0)
+                             .GetFunctionName();
+                if (strcmp(hit_fn, "bar") != 0 &&
+                    strcmp(hit_fn, "bar()") != 0) {
+                  printf("#%" PRIu64
+                         ": First breakpoint did not stop at bar()\n",
+                         threadnum);
+                  completed_threads_array[threadnum] = true;
+                  return (void *)1;
                 }
 
                 process.Kill();
@@ -191,7 +207,7 @@ void *do_one_debugger (void *in)
                 SBDebugger::Destroy(debugger);
 
 #if DEBUG == 1
-                printf ("#%" PRIu64 ": All good!\n", threadnum);
+                printf("#%" PRIu64 ": All good!\n", threadnum);
 #endif
                 successful_threads_array[threadnum] = true;
                 completed_threads_array[threadnum] = true;
@@ -199,26 +215,26 @@ void *do_one_debugger (void *in)
             }
             else
             {
-                printf("#%" PRIu64 ": process failed to launch\n", threadnum);
-                successful_threads_array[threadnum] = false;
-                completed_threads_array[threadnum] = true;
-                return (void*) 0;
+              printf("#%" PRIu64 ": process failed to launch\n", threadnum);
+              successful_threads_array[threadnum] = false;
+              completed_threads_array[threadnum] = true;
+              return (void *)0;
             }
         }
         else
         {
-            printf ("#%" PRIu64 ": did not get valid target\n", threadnum);
-            successful_threads_array[threadnum] = false;
-            completed_threads_array[threadnum] = true;
-            return (void*) 0;
+          printf("#%" PRIu64 ": did not get valid target\n", threadnum);
+          successful_threads_array[threadnum] = false;
+          completed_threads_array[threadnum] = true;
+          return (void *)0;
         }
     }
     else
     {
-        printf ("#%" PRIu64 ": did not get debugger\n", threadnum);
-        successful_threads_array[threadnum] = false;
-        completed_threads_array[threadnum] = true;
-        return (void*) 0;
+      printf("#%" PRIu64 ": did not get debugger\n", threadnum);
+      successful_threads_array[threadnum] = false;
+      completed_threads_array[threadnum] = true;
+      return (void *)0;
     }
     completed_threads_array[threadnum] = true;
     return (void*) 1;

Copy link
Collaborator

@jasonmolenda jasonmolenda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good cleanup.

@DavidSpickett DavidSpickett merged commit aa07282 into llvm:main Jul 31, 2024
6 of 7 checks passed
@DavidSpickett DavidSpickett deleted the lldb-multiple branch July 31, 2024 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants