Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314350

Summary: [debug view] Multi-threaded programs can cause the opening of useless and empty editors
Product: [Tools] CDT Reporter: Marc Khouzam <marc.khouzam>
Component: cdt-debug-dsfAssignee: Ken Ryall <ken.ryall>
Status: RESOLVED FIXED QA Contact: Pawel Piech <pawel.1.piech>
Severity: normal    
Priority: P3 CC: dalexiev, kirk.beitz, pawel.1.piech
Version: 7.0Flags: ken.ryall: review? (marc.khouzam)
Target Milestone: 8.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Screenshot of useless and empty editors
none
prevent multiple source not found editors ken.ryall: iplog-

Description Marc Khouzam CLA 2010-05-25 15:58:13 EDT
Created attachment 169891 [details]
Screenshot of useless and empty editors

This bug happens after the fix to bug 308835.

We basically seen useless and empty editor being opened during multi-threaded all-stop programs with DSF-GDB.  

To reproduce, use the below program and set a breakpoint at the printf as indicated in the program.  After the program stops at main, every time we press 'continue', an editor will be opened for the new value of the old selection, before the new selection is activated.  E.g., if thread1.frame0 is selected and we continue, once the program stops, a new editor for the new thread1.frame0  will be opened, and right after, the editor for the new selection (where the program actually stopped) say thread2.frame0 will be opened.  This happens over and over with each 'continue' and leaves all these editors opened.

Please see screenshot.

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <unistd.h>

/* Infinite prints.  The parameter is unused.  Does not return.  */
void *my_func(void *unused)
{
    int j;
    struct timespec t;
    while (1) {
        j = sched_rr_get_interval(getpid(), &t);
        if (j != 0) {
            printf("Error: %d\n", errno);
        } else {
            printf("%d: %ld\n", (int)unused, t.tv_nsec); // add break here
            sleep(1);
        }
    }
    return NULL;
}

/* The main program.  */
int main()
{
    pthread_t *t_id;
    pthread_attr_t attr;
    int j = 0;

    for (j = 0; j < 75; j++) {
        pthread_attr_init(&attr);

        /* Create a new thread.  The new thread will run the print_xs
           function.  */
        t_id = (pthread_t *) malloc(sizeof(pthread_t));
        printf("Creating %d\n", j);
        pthread_create(t_id, &attr, &my_func, (void *)j);
    }

    while (1) {
        printf("In main()\n");
    }

    return 0;
}
Comment 1 Ken Ryall CLA 2010-09-17 17:32:20 EDT
*** Bug 322311 has been marked as a duplicate of this bug. ***
Comment 2 Ken Ryall CLA 2010-09-17 17:36:46 EDT
Created attachment 179154 [details]
prevent multiple source not found editors

The attached patch will prevent multiple source not found editors from opening.
Comment 3 Ken Ryall CLA 2010-09-17 17:37:24 EDT
Committed to HEAD.
Comment 4 CDT Genie CLA 2010-09-17 18:23:04 EDT
*** cdt cvs genie on behalf of kryall ***
Bug 314350 -  [debug view] Multi-threaded programs can cause the opening of useless and empty editors

[*] DsfSourceDisplayAdapter.java 1.18 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java?root=Tools_Project&r1=1.17&r2=1.18
Comment 5 Dobrin Alexiev CLA 2010-09-23 10:58:08 EDT
Can we have the patch in CDT 7.0.2?