gdb arbitrarily starting threads
Sat Jun 20 18:47:00 GMT 2015
On Jun 20 09:29, William M. (Mike) Miller wrote:
> I have a single-threaded executable that has a number of debug-print
> routines that can be called interactively in the debugger to display
> data structures to stderr. Something has changed in gdb/gcc/Cygwin
> during the last year or so (I don't update my installation very often)
> so that when I call one of these functions, _sometimes_ gdb will start
> a new thread and put my current thread into "running" status, so that
> I can't step, etc. (although the thread isn't actually running).
> Here's the scenario:
> 1) I say "gdb xxx.exe", set a breakpoint, and run. When I hit the
> breakpoint, "info threads" shows me two threads, one for my executable
> and one with some _cygtls/cygthread/ntdll frames; both are stopped.
> 2) I say "up" a couple of times, then "p db_foo(p)" (where db_foo is
> one of these debug-print routines that displays to stderr the data
> structure pointed to by "p"). Sometimes, but not always, gdb will
> respond with
> [New Thread 1436.0x1f00]
You don't have this under control. Nor does Cygwin, most of the time.
E.g, a debugged Windows executable has always at least two threads, one
is your process thread, one is the thread created by the OS when the
debugger attaches to a process.
Every Cygwin process has at least two threads, your process thread, as
well as a so-called "signal thread", the thread handling POSIX signals,
created at every process startup by the Cygwin DLL.
Certain Windows system calls create threads in your process to perform
tasks "under the hood".
Cygwin is doing the same, for instance to implement interruptible system
calls where the underlying OS call is non-interuptible. select(2) may
start multiple threads at once. Etc.
There's no way around that. Windows process handling is centered around
cheap thread creation and termination. Have a look into the "Details"
view in Windows Task Manager. Activate the "Threads" column. Note that
almost all processes are running with more than one thread. Just don't
worry about it, it's kind of system inherent.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 819 bytes
Desc: not available
More information about the Cygwin