-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Threads continue event #6160
Comments
@isidorn I couldn't figure out how to debug the C++ program. I did the following:
|
I've used this command g++ -pthread -std=c++11 -g threads.cpp to compile this program: #include <iostream>
#include <cstdlib>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
using namespace std;
#define NUM_THREADS 5
#define LOOP false
void *wait(void *t)
{
long tid = (long)t;
do {
sleep(1);
cout << "Sleeping in thread " << tid << endl;
} while(LOOP);
return NULL;
}
int main ()
{
int rc;
long i;
pthread_t threads[NUM_THREADS];
pthread_attr_t attr;
void *status;
// Initialize and set thread joinable
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
for (i= 0; i < NUM_THREADS; i++) {
char buf[20];
sprintf(buf, "Thread %d", (int)i);
rc = pthread_create(&threads[i], NULL, wait, (void*) i);
if (rc) {
cout << "Error: unable to create thread," << rc << endl;
exit(-1);
}
pthread_setname_np(threads[i], buf);
}
// free attribute and wait for the other threads
pthread_attr_destroy(&attr);
for (i= 0; i < NUM_THREADS; i++) {
rc = pthread_join(threads[i], &status);
if (rc) {
cout << "Error:unable to join," << rc << endl;
exit(-1);
}
cout << "Main: completed thread " << i << "with status " << status << endl;
}
cout << "Main: program exiting." << endl;
pthread_exit(NULL);
} Setting a breakpoint on line 18 nicely shows that all threads are stopping when the breakpoint is hit, and all continue on the 'continue' command. |
Thanks @weinand |
C++ example - https://gist.github.com/edumunoz/80275bd231abb56165eb
PHP example - any simple php script, just launch it multiple times
We have changed how the continue event behaves. Have a multi-threaded program and verify step / continue / stop behave as expected.
For PHP verify that continue only continues the selected thread, as for C++ verify that continue continues all the threads.
Also verify:
The text was updated successfully, but these errors were encountered: