<p></p>
<p>I am not sure where I should open this issue, here or in geany-plugins.</p>
<p>I need to debug a multithreaded app with Geany with debugger plugin (gdb) but Geany hangs inside the thread.<br>
I have been using Geany for a long time but I can't find a way to debug a thread.</p>
<p>To reproduce the problem, build and debug the sample thread.c, setting a break-point at the line <em>22</em> and <em>34</em> and then <strong>run</strong></p>
<ul>
<li>
<p>Build</p>
<pre><code> gcc -g -O0 -o thread thread.c -lpthread  
</code></pre>
</li>
<li>
<p>thread.c</p>
</li>
</ul>
<pre><code>#include<stdio.h>
#include<string.h>
#include<pthread.h>
#include<stdlib.h>
#include<unistd.h>

/*
 * Build with:
 *
 * gcc -g -O0 -o thread thread.c -lpthread
 *
*/

pthread_t tid[2];

void* doSomeThing(void *arg)
{
    unsigned long x = 0;
    int j = 0;
    int i = (int)arg;

    pthread_t id = pthread_self();

    printf("Thread %d processing...\n", i);
    if(pthread_equal(id,tid[0])) {
        printf("Inside First thread\n");
    } else  {
        printf("Inside Second thread\n");
    }

    for(x=0; x<(0xFFFFFFFF);x++) {
        j++;
    }
    printf("Thread %d: 0x%lx [ x = 0x%X ]\n",i, id, j);

    return NULL;
}

int main(void)
{
    int i = 0;
    int err;

    while (i < 2) {
        err = pthread_create(&(tid[i]), NULL, &doSomeThing, (void*)i);
        if (err != 0)
            printf("can't create thread :[%s]", strerror(err));
        else
            printf("Thread %d created successfully\n", i);
        i++;
    }

    sleep(10);
    return 0;
}

</code></pre>
<p>Geany correctly stops at the first break-point, but If i click "Step over", Geany switches to the second thread, hitting "Step over" again hangs Geany. And eventually, a crash occurs if you try to close Geany.</p>
<p>The correct behavior should be to stay in the same thread and walk through the code while "Step over" is hit, line by line.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/2756">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAIOWJ6OYK5H5ABDSNHCQB3TBW3GNANCNFSM4YQOMW6Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AAIOWJ57CLQDNFVM3KL7PSTTBW3GNA5CNFSM4YQOMW62YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4MHKUJRQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/2756",
"url": "https://github.com/geany/geany/issues/2756",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>