summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Molenda <jmolenda@apple.com>2014-07-10 10:23:01 +0000
committerJason Molenda <jmolenda@apple.com>2014-07-10 10:23:01 +0000
commit3b9a93498bd67a92e669da0ee11f6af2ac32f85e (patch)
treec4fef2d70fcf68e1541e74afdd8aac60a7d6b9da
parentcbd44c591d0ff434be4c9dbdd194ae0e1b186e3e (diff)
downloadbcm5719-llvm-3b9a93498bd67a92e669da0ee11f6af2ac32f85e.tar.gz
bcm5719-llvm-3b9a93498bd67a92e669da0ee11f6af2ac32f85e.zip
Get the inferior binary's name via the command line argument instead
of hardcoding it. llvm-svn: 212698
-rw-r--r--lldb/test/api/multiple-debuggers/multi-process-driver.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/lldb/test/api/multiple-debuggers/multi-process-driver.cpp b/lldb/test/api/multiple-debuggers/multi-process-driver.cpp
index 87b3ffff639..dac9a7e2fa5 100644
--- a/lldb/test/api/multiple-debuggers/multi-process-driver.cpp
+++ b/lldb/test/api/multiple-debuggers/multi-process-driver.cpp
@@ -1,3 +1,18 @@
+
+// This program creates NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS of pthreads,
+// creates an lldb Debugger on each thread, creates targets, inserts two
+// breakpoints, runs to the first breakpoint, backtraces, runs to the second
+// breakpoint, backtraces, kills the inferior process, closes down the
+// debugger.
+
+// The main thread keeps track of which pthreads have completed and which
+// pthreads have completed successfully, and exits when all pthreads have
+// completed successfully, or our time limit has been exceeded.
+
+// This test file helps to uncover race conditions and locking mistakes
+// that are hit when lldb is being used to debug multiple processes
+// simultaneously.
+
#include <stdio.h>
#include <stdlib.h>
@@ -23,6 +38,8 @@ using namespace lldb;
bool *completed_threads_array = 0;
bool *successful_threads_array = 0;
+const char *inferior_process_name = "testprog";
+
bool
wait_for_stop_event (SBProcess process, SBListener listener)
{
@@ -88,7 +105,7 @@ void *do_one_debugger (void *in)
if (debugger.IsValid ())
{
debugger.SetAsync (true);
- SBTarget target = debugger.CreateTargetWithFileAndArch("testprog", "x86_64");
+ SBTarget target = debugger.CreateTargetWithFileAndArch(inferior_process_name, "x86_64");
SBCommandInterpreter command_interp = debugger.GetCommandInterpreter();
if (target.IsValid())
{
@@ -202,7 +219,7 @@ void *do_one_debugger (void *in)
return (void*) 1;
}
-int main ()
+int main (int argc, char **argv)
{
SBDebugger::Initialize();
@@ -211,6 +228,11 @@ int main ()
successful_threads_array = (bool *) malloc (sizeof (bool) * NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
memset (successful_threads_array, 0, sizeof (bool) * NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS);
+ if (argc > 1 && argv[1] != NULL)
+ {
+ inferior_process_name = argv[1];
+ }
+
for (uint64_t i = 0; i< NUMBER_OF_SIMULTANEOUS_DEBUG_SESSIONS; i++)
{
pthread_t thread;
OpenPOWER on IntegriCloud