mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
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.
This commit is contained in:
parent
29f2c9bf4f
commit
abef64cb07
4 changed files with 64 additions and 19 deletions
|
@ -5,7 +5,7 @@
|
|||
// Copyright : Ericsson AB
|
||||
// Description : Breakpoint test application
|
||||
//============================================================================
|
||||
#include <unistd.h>
|
||||
#include "Sleep.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
@ -45,7 +45,7 @@ int main()
|
|||
zeroBlocks(1);
|
||||
loop();
|
||||
setBlocks();
|
||||
sleep(1);
|
||||
SLEEP(1);
|
||||
a++;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#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;
|
||||
|
|
|
@ -1,29 +1,62 @@
|
|||
#include <pthread.h>
|
||||
#ifdef __MINGW32__
|
||||
#include <process.h> // MinGW has no POSIX support; use MSVC runtime
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#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<NUM_THREADS;t++){
|
||||
printf("In main: creating thread %d\n", t);
|
||||
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
|
||||
if (rc){
|
||||
printf("ERROR; return code from pthread_create() is %d\n", rc);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
TID threads[NUM_THREADS];
|
||||
int t;
|
||||
for(t=0; t < NUM_THREADS; t++)
|
||||
{
|
||||
printf("In main: creating thread %d\n", t);
|
||||
#ifdef __MINGW32__
|
||||
{
|
||||
uintptr_t rc = _beginthreadex(NULL, 0, PrintHello, (void*)t, 0, &threads[t]);
|
||||
if (rc == 0)
|
||||
{
|
||||
printf("ERROR; _beginthreadex() failed. errno = %d\n", errno);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#else
|
||||
{
|
||||
int rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
|
||||
if (rc)
|
||||
{
|
||||
printf("ERROR; return code from pthread_create() is %d\n", rc);
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#ifndef Sleep_h
|
||||
#define Sleep_h
|
||||
|
||||
#ifdef __MINGW32__ // MinGW has no POSIX support; use Win32 API
|
||||
#include <windows.h>
|
||||
#define SLEEP(s) Sleep((s)*1000) // Win32's Sleep takes milliseconds
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#define SLEEP(s) sleep(s) // POSIX sleep takes seconds
|
||||
#endif
|
||||
|
||||
#endif // Sleep_h
|
Loading…
Add table
Reference in a new issue