From abef64cb07b352c8308f9c98b501a0bbbec075e3 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Wed, 26 May 2010 19:38:11 +0000 Subject: [PATCH] Make dsf-gdb test programs buildable with MinGW. MinGW gdb has problems debugging a cygwin-built executable, so we need to build the test apps with MinGW when testing that debugger. Confirmed these modified files now build with both Cygwin and MinGW. --- .../data/launch/src/BreakpointTestApp.cc | 4 +- .../data/launch/src/CatchpointTestApp.cc | 4 +- .../data/launch/src/MultiThread.cc | 63 ++++++++++++++----- .../data/launch/src/Sleep.h | 12 ++++ 4 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/Sleep.h diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/BreakpointTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/BreakpointTestApp.cc index 3129248214b..1961b6cb9a2 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/BreakpointTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/BreakpointTestApp.cc @@ -5,7 +5,7 @@ // Copyright : Ericsson AB // Description : Breakpoint test application //============================================================================ -#include +#include "Sleep.h" #include using namespace std; @@ -45,7 +45,7 @@ int main() zeroBlocks(1); loop(); setBlocks(); - sleep(1); + SLEEP(1); a++; return 0; } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/CatchpointTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/CatchpointTestApp.cc index 921f73f5418..08fd669c990 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/CatchpointTestApp.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/CatchpointTestApp.cc @@ -1,5 +1,5 @@ #include -#include +#include "Sleep.h" int g_i = 0; int main() { for (; g_i < 8; g_i++) { @@ -14,7 +14,7 @@ int main() { // For setting a catchpoint while target is running std::cout << "Sleeping..." << std::endl; - sleep(2); + SLEEP(2); std::cout << "...awake!" << std::endl; try { std::cout << "Throwing exception" << std::endl; diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc index 6b8bfb0d6c6..6bbef8af3af 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/MultiThread.cc @@ -1,29 +1,62 @@ -#include +#ifdef __MINGW32__ + #include // MinGW has no POSIX support; use MSVC runtime +#else + #include +#endif #include #include -#include +#include "Sleep.h" #define NUM_THREADS 5 +#ifdef __MINGW32__ +typedef unsigned int TID; +#else +typedef pthread_t TID; +#endif + + +#ifdef __MINGW32__ +unsigned int __stdcall PrintHello(void *threadid) +#else void *PrintHello(void *threadid) +#endif { int tid = (int)threadid; printf("Hello World! It's me, thread #%d!\n", tid); - sleep(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint + SLEEP(2); // keep this thread around for a bit; the tests will check for its existence while the main thread is stopped at a breakpoint + +#ifdef __MINGW32__ + return 0; +#else pthread_exit(NULL); +#endif } int main(int argc, char *argv[]) { - pthread_t threads[NUM_THREADS]; - int rc, t; - for(t=0;t + #define SLEEP(s) Sleep((s)*1000) // Win32's Sleep takes milliseconds +#else + #include + #define SLEEP(s) sleep(s) // POSIX sleep takes seconds +#endif + +#endif // Sleep_h