Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314350 - [debug view] Multi-threaded programs can cause the opening of useless and empty editors
Summary: [debug view] Multi-threaded programs can cause the opening of useless and emp...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Ken Ryall CLA
QA Contact: Pawel Piech CLA
URL:
Whiteboard:
Keywords:
: 322311 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-25 15:58 EDT by Marc Khouzam CLA
Modified: 2010-09-23 10:58 EDT (History)
3 users (show)

See Also:
ken.ryall: review? (marc.khouzam)


Attachments
Screenshot of useless and empty editors (110.49 KB, image/png)
2010-05-25 15:58 EDT, Marc Khouzam CLA
no flags Details
prevent multiple source not found editors (2.29 KB, patch)
2010-09-17 17:36 EDT, Ken Ryall CLA
ken.ryall: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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?