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

Bug 334179

Summary: [debug view][non-stop] after thread event 'focus' on current thread is lost
Product: [Tools] CDT Reporter: dclaude <bd.claude>
Component: cdt-debug-dsf-gdbAssignee: Project Inbox <cdt-debug-dsf-gdb-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: major    
Priority: P3 CC: cdtdoug, jens.elmenthaler, me, pawel.1.piech
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
test case none

Description dclaude CLA 2011-01-12 18:22:22 EST
Build Identifier: 20100917-0705

While debugging with gdb in non-stop mode, when a thread event is sent by gdb ([New Thread], [Thread exited], ...) the focus on the current thread is lost in the 'Debug view' (threads list window).

It prevents users to do stepping (step into, step over, ...) in progams creating/closing threads very often.



Reproducible: Always

Steps to Reproduce:
1. to reproduce set a breakpoint in 'while (1)' loop of the main() function in the program below

2. when a thread event is sent by gdb the focus is lost on the main thread and it is not possible to execute one more step of the program's main thread by hitting step into (F5), step over (F6)

#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <time.h>

void * run2(void *ptr)
{
	int *i = (int *)ptr;
	struct timespec sleepTime;
	struct timespec remainingSleepTime;

	sleepTime.tv_sec = *i + 5;
	sleepTime.tv_nsec = 0;
	nanosleep(&sleepTime, &remainingSleepTime);
	return NULL;
}

void * run1(void *ptr)
{
	while (1) {
		const int nb = 2;
		pthread_t thread[nb] = { 0 };

		for (int i = 0; i < nb; ++i)
		{
			pthread_create(&thread[i], NULL, run2, &i);
		}
		for (int i = 0; i < nb; ++i)
		{
			pthread_join(thread[i], NULL);
		}
	}
	return NULL;
}

void f1()
{
	int i = 0;

	while (i < 5)
	{
		++i;
	}
}

int main()
{
	pthread_t thread = 0;

	pthread_create(&thread, NULL, run1, NULL);
	while (1) {
		f1();
	}
	pthread_join(thread, NULL);
	exit(0);
}



I tried to debug cdt code but I was not able to understand the link between the thread event handling code (MIListThreadGroups.java, MIListThreadGroupsInfo.java, GDBProcesses_7_0.java, ...) and the 'Debug view' focus update.
Comment 1 dclaude CLA 2011-01-12 18:23:39 EST
Created attachment 186691 [details]
test case
Comment 2 Jens Elmenthaler CLA 2012-10-10 03:11:25 EDT
It's not just a nuisance in non-stop mode. It also happens in all-stop mode if hovering over expressions like "it->second" which makes gdb resume its inferior in -data-evaluate-expression.
Comment 3 Jens Elmenthaler CLA 2012-10-10 03:50:40 EDT
I pushed a proposal to to gerrit: https://git.eclipse.org/r/#/c/8114/