Bug 106282 - cannot debug multithreaded application
Summary: cannot debug multithreaded application
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: CPP Debugger (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-25 18:07 UTC by Eddy Hahn
Modified: 2007-01-10 18:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eddy Hahn 2005-05-25 18:07:04 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    SuSE RPMs
Compiler:          gcc 3.3.5  
OS:                Linux

If the application is multithreaded a set breakpoint in the thread never get caught.  Also, if it is in the bad mood the debugger gets into a wierd state and you won't be able to start new debugging without restarting the IDE.

In the Project Options I have the folowing addition flags:
LDFLAGS:  -lpthread
CXXFLAGS: -pthread

I've tried all combination of the above flags with no luck.

Here is a simple example just put a break point on the printf in the thread code. Then execute it and you will see it will not break.  Also, if you catch it in the right moment it will render debugger useless.

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <iostream>
#include <cstdlib>
#include <pthread.h>


using namespace std;

//void *(*__start_routine) (void *)
void* thread(void* pData)
{
	while(1)
	{
		printf("Worker has started...\r\n");
		sleep(1);
	}
}


int main(int argc, char *argv[])
{
  printf("Starting main...\r\n");

  pthread_t id;
  
  pthread_create( &id, NULL, thread, NULL);

  while( true )
	sleep(1);

  return EXIT_SUCCESS;
}
Comment 1 Stephan Diederich 2006-11-26 17:41:11 UTC
I cannot reproduce this here with your code snippet.
(current svn of KDevelop and gdb 6.4 as well as with gdb 6.5)
Breakpoints can be set into thread as well as the main and debugger interrupts if they are reached.
Comment 2 Jens Dagerbo 2007-01-10 18:14:31 UTC
Works here too. Assuming fixed.