Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: John Cortell <rat042@freescale.com>
To: Dave Korn <dave.korn.cygwin@googlemail.com>
Cc: Pedro Alves <pedro@codesourcery.com>,
	gdb@sourceware.org,
	        Joel Brobecker <brobecker@adacore.com>
Subject: Re: sending CTRL-C to Cygwin gdb 6.8 has no effect
Date: Sun, 25 Apr 2010 14:10:00 -0000	[thread overview]
Message-ID: <201004251418.o3PEIBMG000580@az33smr01.freescale.net> (raw)
In-Reply-To: <4BD389B3.2030409@gmail.com>

At 07:15 PM 4/24/2010, Dave Korn wrote:
>On 24/04/2010 23:29, John Cortell wrote:
>
> > Great. That makes perfect sense now. So, given the behavior I'm seeing,
> > it would seem the gdb that CDT launches is NOT sharing the console with
> > the inferior. What is left for me to answer is "why?", since that's not
> > what I expect. CDT, through an intermediary launcher process, does a
> > Win32 CreateProcess call to launch gdb. The call specifies whether to
> > launch it attached or not, and if attached, whether to share the
> > console. Fine, but that is between CDT's launcher process and gdb, not
> > gdb and the inferior. The console relationship between gdb and the
> > inferior seems out of the hands of CDT. That is, once we establish an mi
> > connection with gdb, we till it to load aprogram.exe and run it. We
> > don't specify whether gdb should share the console with it. So what's
> > the expected behavior? Again, I would expect the two to share the
> > console. After all, they apparently do when I carry out the same thing
> > from a Windows command shell session. There too, I don't tell gdb to
> > share a console with the inferior or not, and apparently it does.
>
>   What's probably getting in the way here is Cygwin's POSIX tty emulation,
>which has to interact with the Windows console in bizarre and sometimes
>unexpected ways.  A Cygwin process launched from a standard Windows console -
>whether cmd.exe or bash doesn't matter - comes with its stdio handles attached
>to the console.
>
>   However, a Cygwin process launched either from a shell running in 
> one of the
>GUI consoles like xterm/rxvt, or if launched with CYGWIN=tty set in the
>environment, gets connected to a pty, which is implemented in windows terms as
>the ends of a pair of (iirc) named pipes.  In that case, no console is created
>nor attached to the process, to avoid the "flashing black window" syndrome
>caused by a console appearing briefly even if you hide it.
>
>   I haven't checked what the code in gdb exactly tries to do when it launches
>a process, but I'd infer from your observations that when the gdb itself is
>running attached to a console it launches the inferior sharing the console,
>and when not it may well let the new process create its own console.
>
>   I quickly searched for "console" in the gdb info page, and discovered a
>couple of useful-sounding options:
>
> > `set new-console MODE'
> >      If MODE is `on' the debuggee will be started in a new console on
> >      next start.  If MODE is `off'i, the debuggee will be started in
> >      the same console as the debugger.
> >
> > `show new-console'
> >      Displays whether a new console is used when the debuggee is
> >      started.
> >
> > `set new-group MODE'
> >      This boolean value controls whether the debuggee should start a
> >      new group or stay in the same group as the debugger.  This affects
> >      the way the Windows OS handles `Ctrl-C'.
> >
> > `show new-group'
> >      Displays current value of new-group boolean.
>
>   Those sound like they ought to be of some use to you in this situation :)


Dave, that all got me pretty optimistic our problems would soon be 
over :-). Unfortunately, none of it panned out.

1. I ruled out POSIX emulation in the inferior being a factor by 
debugging a MinGW-built program. No change in behavior.CTRL-C to gdb 
programatically has no effect.
2. I added 'set new-console off' in the .gdbinit file (and confirmed 
it took effect with a 'show new-console' at debug time). No change in behavior.
3. I added 'set new-group on' in the .gdbinit file (and confirmed it 
took effect with a 'show new-group' at debug time). The default is 
on, btw. No change in behavior.

So, I decided to look at how we send the CTRL-C to gdb. If the 
program spawned by our launcher is using the cygwin runtime dll, we 
run  a 'kill -SIGINT <PID>'. In this case, the launched program is 
cygwin's gdb, which does use the cygwin runtime, so that's what we 
end up doing. And for sure, this command isn't interrupting either 
gdb or the inferior. So what I'll do tomorrow is see if we have more 
luck using the Win32 call GenerateConsoleCtrlEvent(CTRL_C_EVENT , 
0)...that's what we use when the launched program is not using the 
cygwin runtime.

Anyone know of a way to tell whether two running processes on Windows 
are sharing a console...perhaps via some utility? Process Explorer 
doesn't seem to reveal that information.

Again, I appreciate the insight.
John 



  reply	other threads:[~2010-04-25 14:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23 19:33 John Cortell
2010-04-23 19:44 ` Joel Brobecker
2010-04-23 19:57   ` John Cortell
2010-04-23 20:11     ` Joel Brobecker
2010-04-23 20:27       ` John Cortell
2010-04-24  1:10         ` Pedro Alves
2010-04-24  1:58           ` John Cortell
2010-04-24  2:13             ` Pedro Alves
2010-04-24 22:30               ` John Cortell
2010-04-24 23:56                 ` Dave Korn
2010-04-25 14:10                   ` John Cortell [this message]
2010-04-25 21:25                     ` Pedro Alves
2010-04-26  6:22                       ` Christopher Faylor
2010-04-26 11:38                         ` Pierre Muller
2010-04-26 14:30                           ` Christopher Faylor
     [not found]                       ` <201004261330.o3QDUfph028936@az33smr01.freescale.net>
2010-04-26 13:37                         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201004251418.o3PEIBMG000580@az33smr01.freescale.net \
    --to=rat042@freescale.com \
    --cc=brobecker@adacore.com \
    --cc=dave.korn.cygwin@googlemail.com \
    --cc=gdb@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox