Skip to content
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

Closed
2 tasks done
isidorn opened this issue May 6, 2016 · 3 comments
Closed
2 tasks done

Threads continue event #6160

isidorn opened this issue May 6, 2016 · 3 comments
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues testplan-item
Milestone

Comments

@isidorn
Copy link
Contributor

isidorn commented May 6, 2016

  • win - PHP (isidor has a vm where PHP is setup) - @bpasero
  • linux - C++ (very easy to setup) - @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:

  • Newly created threads are reflected in the callStack view
  • One thread resuming execution does not affect other stopped threads
  • A thread that exits should disappear from the call stack view
@isidorn isidorn added debug Debug viewlet, configurations, breakpoints, adapter issues testplan-item labels May 6, 2016
@isidorn isidorn added this to the May 2016 milestone May 6, 2016
@isidorn isidorn changed the title Threads context menu actions Threads continue event May 19, 2016
@egamma egamma mentioned this issue May 23, 2016
87 tasks
@Tyriar
Copy link
Member

Tyriar commented May 24, 2016

@isidorn I couldn't figure out how to debug the C++ program. I did the following:

  • Install cpptools

  • Create vscode-repro.cpp

  • Tried to debug, I need to compile first

  • After some experimenting I landed on this to compile: g++ -Wall -Wextra -Werror -std=c++11 -c vscode-repro.cpp -o vscode-repro.out

  • Tried to debug, hit this:

    image

    image

  • Because of the permission error I thought I'd add +x to the .out file but it didn't work.

@isidorn isidorn removed their assignment May 25, 2016
@weinand
Copy link
Contributor

weinand commented May 25, 2016

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.

@weinand weinand closed this as completed May 25, 2016
@Tyriar
Copy link
Member

Tyriar commented May 25, 2016

Thanks @weinand

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues testplan-item
Projects
None yet
Development

No branches or pull requests

3 participants