[PATCH 1/3] New option --cygwin-tty.

Pierre Muller pierre.muller@ics-cnrs.unistra.fr
Thu Jul 25 07:37:00 GMT 2013


  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 
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

  

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Yao Qi
> Envoyé : jeudi 25 juillet 2013 07:09
> À : gdb-patches@sourceware.org
> Objet : [PATCH 1/3] New option --cygwin-tty.
> 
> 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.
> 
> This patch was written by Pedro in 2008, and used in CS tree for a
> while.
> 
> gdb:
> 
> 2013-07-25  Pedro Alves  <pedro@codesourcery.com>
> 	    Yao Qi  <yao@codesourcery.com>
> 
> 	* 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.
> 
> gdb/testsuite:
> 
> 2013-07-25  Pedro Alves  <pedro@codesourcery.com>
> 
> 	* 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(-)
> 
> 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.
> 
> +--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.
> 
> 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;
> 
> +#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 = -1;
>  /* GDB as it has been invoked from the command line (i.e. argv[0]).  */
>  static char *gdb_program_name;
> 
> +#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 = 0;
> +#endif
> +
>  static void print_gdb_help (struct ui_file *);
> 
>  /* 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}
>      };
> 
> @@ -1123,6 +1132,13 @@ Output and user interface control:\n\n\
>    --interpreter=INTERP\n\
>                       Select a specific interpreter / user interface\n\
>    --tty=TTY          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 { } {
> 
>      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 = $GDBFLAGS" 2
> 
> +global GDB_USING_CYGWIN_TTY
> +set GDB_USING_CYGWIN_TTY "<unchecked>"
> +
>  # Make the build data directory available to tests.
>  set BUILD_DATA_DIRECTORY "[pwd]/../data-directory"
> 
> @@ -126,6 +129,31 @@ proc gdb_version { } {
>      return [default_gdb_version]
>  }
> 
> +# 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 "<unchecked>"] {
> +
> +	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 = $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]
> 
> -    verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
> +    set cygwin_tty [gdb_using_cygwin_tty]
> +    verbose "Spawning $GDB $cygwin_tty $INTERNAL_GDBFLAGS $GDBFLAGS"
> 
>      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 == "" } {
>  	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)
>      }
> 
> -    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 == "" } {
>  	perror "Spawning $GDB failed."
>  	return 1
> --
> 1.7.7.6




More information about the Gdb-patches mailing list