From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26803 invoked by alias); 25 Jul 2013 07:37:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26793 invoked by uid 89); 25 Jul 2013 07:37:53 -0000 X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_50,KHOP_THREADED,MSGID_MULTIPLE_AT,RDNS_NONE,TW_DB,TW_GJ autolearn=no version=3.3.1 Received: from Unknown (HELO mailhost.u-strasbg.fr) (130.79.201.45) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Jul 2013 07:37:52 +0000 Received: from md16.u-strasbg.fr (md16.u-strasbg.fr [130.79.200.206]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r6P7be8X079337 ; Thu, 25 Jul 2013 09:37:40 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from ms15.u-strasbg.fr (ms15.u-strasbg.fr [130.79.204.115]) by md16.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r6P7bevU021800 ; Thu, 25 Jul 2013 09:37:40 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (Authenticated sender: mullerp) by ms15.u-strasbg.fr (Postfix) with ESMTPSA id F24921FD88; Thu, 25 Jul 2013 09:37:38 +0200 (CEST) From: "Pierre Muller" To: "'Yao Qi'" , References: <1374728963-25187-1-git-send-email-yao@codesourcery.com> <1374728963-25187-2-git-send-email-yao@codesourcery.com> In-Reply-To: <1374728963-25187-2-git-send-email-yao@codesourcery.com> Subject: RE: [PATCH 1/3] New option --cygwin-tty. Date: Thu, 25 Jul 2013 07:37:00 -0000 Message-ID: <000901ce8909$dd069470$9713bd50$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2013-07/txt/msg00600.txt.bz2 Hi again, Instead of adding a new command line option, we might change this into a new command call set windows-os-tty on/off In the testsuite, this could be=20 automated by adding "-ex {set windows-os-tty on}" to INTERNAL_GDBFLAGS. This is what I do to run the testsuite on msys for the "set interactive-mode on" command that I added a while ago to resolve a similar problem. This would avoid adding a target specific command line option and allow to move most of the code to mingw-hdep.c source where it belongs as it really is mingw specific, no? Pierre Muller =20=20 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Yao Qi > Envoy=E9=A0: jeudi 25 juillet 2013 07:09 > =C0=A0: gdb-patches@sourceware.org > Objet=A0: [PATCH 1/3] New option --cygwin-tty. >=20 > Hi, > This patch is to add a new GDB option '--cygwin-tty', which is useful > when running/testing mingw32 native GDB in cygwin. Due the odd TTY > in Cygwin, the output of mingw32 native GDB behaves differently, > which causes the testsuite result unusable. I tried different > approaches to detect whether GDB is running in cygwin tty, but failed. > Finally, we decide to add this option in GDB, and let the testsuite > to launch GDB with this option if GDB is running cygwin. >=20 > This patch was written by Pedro in 2008, and used in CS tree for a > while. >=20 > gdb: >=20 > 2013-07-25 Pedro Alves > Yao Qi >=20 > * NEWS: Mention new option '--cygwin-tty'. > * defs.h [__MINGW32__] (cygwin_tty): Declare. > * main.c [__MINGW32__] (cygwin_tty): New global variable. > (long_options) [__MINGW32__]: Add an element for "cygwin-tty". > (print_gdb_help) [__MINGW32__]: Print "--cygwin-tty" in help. >=20 > gdb/testsuite: >=20 > 2013-07-25 Pedro Alves >=20 > * lib/gdb.exp (GDB_USING_CYGWIN_TTY): New global. > (gdb_using_cygwin_tty): New proc. > (default_gdb_start): Use gdb_using_cygwin_tty. > * lib/mi-support.exp (mi_gdb_start): Use gdb_using_cygwin_tty. > * gdb.base/dbx.exp (dbx_gdb_start): Use gdb_using_cygwin_tty. > --- > gdb/NEWS | 4 ++++ > gdb/defs.h | 4 ++++ > gdb/main.c | 16 ++++++++++++++++ > gdb/testsuite/gdb.base/dbx.exp | 3 ++- > gdb/testsuite/lib/gdb.exp | 35 +++++++++++++++++++++++++++++++++-- > gdb/testsuite/lib/mi-support.exp | 3 ++- > 6 files changed, 61 insertions(+), 4 deletions(-) >=20 > diff --git a/gdb/NEWS b/gdb/NEWS > index a4238d0..407b715 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -61,6 +61,10 @@ show range-stepping > --configuration > Display the details of GDB configure-time options. >=20 > +--cygwin-tty > + Tells GDB that it is running in Cygwin's TTY. This is mostly for > + testing purposes. > + > * The command 'tsave' can now support new option '-ctf' to save trace > buffer in Common Trace Format. >=20 > diff --git a/gdb/defs.h b/gdb/defs.h > index 014d7d4..90bfe0f 100644 > --- a/gdb/defs.h > +++ b/gdb/defs.h > @@ -156,6 +156,10 @@ extern char *python_libdir; > /* Search path for separate debug files. */ > extern char *debug_file_directory; >=20 > +#ifdef __MINGW32__ > +extern int cygwin_tty; > +#endif > + > /* GDB has two methods for handling SIGINT. When immediate_quit is > nonzero, a SIGINT results in an immediate longjmp out of the signal > handler. Otherwise, SIGINT simply sets a flag; code that might > diff --git a/gdb/main.c b/gdb/main.c > index 440094e..029f365 100644 > --- a/gdb/main.c > +++ b/gdb/main.c > @@ -98,6 +98,12 @@ int return_child_result_value =3D -1; > /* GDB as it has been invoked from the command line (i.e. argv[0]). */ > static char *gdb_program_name; >=20 > +#ifdef __MINGW32__ > +/* Support for --cygwin-tty. If non-zero, pipes seen on > + std{in,out,err} are understood as being Cygwin ttys. */ > +int cygwin_tty =3D 0; > +#endif > + > static void print_gdb_help (struct ui_file *); >=20 > /* Relocate a file or directory. PROGNAME is the name by which gdb > @@ -517,6 +523,9 @@ captured_main (void *data) > {"args", no_argument, &set_args, 1}, > {"l", required_argument, 0, 'l'}, > {"return-child-result", no_argument, &return_child_result, 1}, > +#ifdef __MINGW32__ > + {"cygwin-tty", no_argument, &cygwin_tty, 1}, > +#endif > {0, no_argument, 0, 0} > }; >=20 > @@ -1123,6 +1132,13 @@ Output and user interface control:\n\n\ > --interpreter=3DINTERP\n\ > Select a specific interpreter / user interface\n\ > --tty=3DTTY Use TTY for input/output by the program being > debugged.\n\ > +"), stream); > +#ifdef __MINGW32__ > + fputs_unfiltered (_("\ > + --cygwin-tty Tells GDB that it is running in Cygwin's TTY.\n\ > +"), stream); > +#endif > + fputs_unfiltered (_("\ > -w Use the GUI interface.\n\ > --nw Do not use the GUI interface.\n\ > "), stream); > diff --git a/gdb/testsuite/gdb.base/dbx.exp b/gdb/testsuite/gdb.base/dbx.exp > index 7d89b81..a460971 100644 > --- a/gdb/testsuite/gdb.base/dbx.exp > +++ b/gdb/testsuite/gdb.base/dbx.exp > @@ -41,7 +41,8 @@ proc dbx_gdb_start { } { >=20 > set oldtimeout $timeout > set timeout [expr "$timeout + 60"] > - eval "spawn $GDB -dbx $INTERNAL_GDBFLAGS $GDBFLAGS" > + set cygwin_tty [gdb_using_cygwin_tty]; > + eval "spawn $GDB -dbx $cygwin_tty $INTERNAL_GDBFLAGS $GDBFLAGS" > gdb_expect { > -re ".*\r\n$gdb_prompt $" { > verbose "GDB initialized." > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 77fa359..e769b7f 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -52,6 +52,9 @@ if ![info exists GDBFLAGS] { > } > verbose "using GDBFLAGS =3D $GDBFLAGS" 2 >=20 > +global GDB_USING_CYGWIN_TTY > +set GDB_USING_CYGWIN_TTY "" > + > # Make the build data directory available to tests. > set BUILD_DATA_DIRECTORY "[pwd]/../data-directory" >=20 > @@ -126,6 +129,31 @@ proc gdb_version { } { > return [default_gdb_version] > } >=20 > +# Return "--cygwin-tty" and save it in $GDB_USING_CYGWIN_TTY if GDB is > +# running in cygwin. > + > +proc gdb_using_cygwin_tty { } { > + global GDB_USING_CYGWIN_TTY > + > + if ![string compare $GDB_USING_CYGWIN_TTY ""] { > + > + set GDB_USING_CYGWIN_TTY "" > + if { [ishost "*-*-mingw*"] } { > + set output [remote_exec host "uname -o"] > + set osname [lindex $output 1]; > + verbose "Remote host OS name: $osname" 2 > + if [string match "Cygwin*" $osname] { > + # Tell GDB that the pipes seen attached to > + # std{in|out|err} are really Cygwin TTYs. > + set GDB_USING_CYGWIN_TTY "--cygwin-tty" > + } > + } > + > + verbose "using GDB_USING_CYGWIN_TTY =3D $GDB_USING_CYGWIN_TTY" 2 > + } > + return $GDB_USING_CYGWIN_TTY > +} > + > # > # gdb_unload -- unload a file if one is loaded > # Return 0 on success, -1 on error. > @@ -1415,7 +1443,8 @@ proc default_gdb_start { } { > # a specific different target protocol itself. > set use_gdb_stub [target_info exists use_gdb_stub] >=20 > - verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS" > + set cygwin_tty [gdb_using_cygwin_tty] > + verbose "Spawning $GDB $cygwin_tty $INTERNAL_GDBFLAGS $GDBFLAGS" >=20 > if [info exists gdb_spawn_id] { > return 0 > @@ -1427,7 +1456,9 @@ proc default_gdb_start { } { > exit 1 > } > } > - set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS > [host_info gdb_opts]"] > + > + set res [remote_spawn host \ > + "$GDB $cygwin_tty $INTERNAL_GDBFLAGS $GDBFLAGS [host_info > gdb_opts]"] > if { $res < 0 || $res =3D=3D "" } { > perror "Spawning $GDB failed." > return 1 > diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi- > support.exp > index 86a0fd6..061735d 100644 > --- a/gdb/testsuite/lib/mi-support.exp > +++ b/gdb/testsuite/lib/mi-support.exp > @@ -145,7 +145,8 @@ proc default_mi_gdb_start { args } { > set mi_inferior_tty_name $spawn_out(slave,name) > } >=20 > - set res [remote_spawn host "$GDB $INTERNAL_GDBFLAGS $GDBFLAGS $MIFLAGS > [host_info gdb_opts]"] > + set cygwin_tty [gdb_using_cygwin_tty]; > + set res [remote_spawn host "$GDB $cygwin_tty $INTERNAL_GDBFLAGS > $GDBFLAGS $MIFLAGS [host_info gdb_opts]"] > if { $res < 0 || $res =3D=3D "" } { > perror "Spawning $GDB failed." > return 1 > -- > 1.7.7.6