* [PATCH 1/3] New option --cygwin-tty.
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
2013-07-25 5:10 ` [PATCH 3/3] native mingw32 gdb, eol format Yao Qi
2013-07-25 5:10 ` [PATCH 2/3] Unbuffer stdout and stderr on windows Yao Qi
@ 2013-07-25 5:10 ` Yao Qi
2013-07-25 7:34 ` Corinna Vinschen
2013-07-25 7:37 ` Pierre Muller
2013-07-25 7:31 ` [PATCH 0/3] Test mingw32 GDB in cygwin Pierre Muller
3 siblings, 2 replies; 15+ messages in thread
From: Yao Qi @ 2013-07-25 5:10 UTC (permalink / raw)
To: gdb-patches
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/3] native mingw32 gdb, eol format
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
@ 2013-07-25 5:10 ` Yao Qi
2013-07-25 5:10 ` [PATCH 2/3] Unbuffer stdout and stderr on windows Yao Qi
` (2 subsequent siblings)
3 siblings, 0 replies; 15+ messages in thread
From: Yao Qi @ 2013-07-25 5:10 UTC (permalink / raw)
To: gdb-patches
Hello,
I see the following fail on a remote windows host,
info tracepoints^M
Num Type Disp Enb Address What^M^M
1 tracepoint keep y 0x0040143f in gdb_c_test at actions.c:74^M^M
not installed on target^M^M
2 tracepoint keep y 0x00401687 in gdb_asm_test at actions.c:121^M^M
not installed on target^M^M
3 tracepoint keep y 0x004013d2 in gdb_recursion_test at actions.c:61^M^M
not installed on target^M^M
(gdb) FAIL: gdb.trace/deltrace.exp: 3.1a: set three tracepoints
this fail is caused by an extra '\r' at end of each line.
on Windows, when a file is opened in text mode, a "\n" is always
expanded to "\r\n", so gdb on Windows is outputting "\r\n", and when
that goes throught the PTY, the '\n' is being expanded to "\r\n",
hence "\r\r\n".
This patch is to force stdin/stdout/stderr to binary mode prevents that
expansion.
gdb:
2013-07-25 Pedro Alves <pedro@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* main.c [__MINGW32__]: Include fcntl.h and windows.h.
(captured_main) [__MINGW32__]: If stdout, stdin and stderr
are pipes, set them to binary mode.
---
gdb/main.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index 4777286..3b871ee 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -47,6 +47,11 @@
#include "filenames.h"
#include "filestuff.h"
+#ifdef __MINGW32__
+#include <fcntl.h>
+#include <windows.h>
+#endif
+
/* The selected interpreter. This will be used as a set command
variable, so it should always be malloc'ed - since
do_setshow_command will free it. */
@@ -753,12 +758,33 @@ captured_main (void *data)
#ifdef __MINGW32__
if (cygwin_tty)
{
+ int in = fileno (stdin);
+ int out = fileno (stdout);
+ int err = fileno (stderr);
+ HANDLE hin = (HANDLE) _get_osfhandle (in);
+ HANDLE hout = (HANDLE) _get_osfhandle (out);
+ HANDLE herr = (HANDLE) _get_osfhandle (err);
+
/* A Cygwin session may not look like a terminal to the Windows
runtime; ensure unbuffered output. Note that setvbuf may be
used after the file is opened but before any other operation
is performed. */
setvbuf (stdout, NULL, _IONBF, BUFSIZ);
setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+
+ /* In textmode, a '\n' is automatically expanded into "\r\n". When
+ driving the testsuite from a linux host, the '\n' is also
+ expanded into "\r\n". This results in expect seeing "\r\r\n".
+ The tests aren't prepared currently for other forms of eol. As a
+ workaround, we force the output to binary mode. Do this only if
+ the files are pipes (cygwin ttys are Windows pipes behind the
+ scenes). */
+ if (GetFileType (hin) == FILE_TYPE_PIPE)
+ setmode (in, O_BINARY);
+ if (GetFileType (hout) == FILE_TYPE_PIPE)
+ setmode (out, O_BINARY);
+ if (GetFileType (herr) == FILE_TYPE_PIPE)
+ setmode (err, O_BINARY);
}
#endif
--
1.7.7.6
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 0/3] Test mingw32 GDB in cygwin
@ 2013-07-25 5:10 Yao Qi
2013-07-25 5:10 ` [PATCH 3/3] native mingw32 gdb, eol format Yao Qi
` (3 more replies)
0 siblings, 4 replies; 15+ messages in thread
From: Yao Qi @ 2013-07-25 5:10 UTC (permalink / raw)
To: gdb-patches
Hi,
This patch series try to fix the problems we've seen on running
mingw32 native for testing in cygwin tty. Patch 2/3 unbuffer the
stdout and stderr, so that dejagnu/expect can match the output in
the right order. Likewise, patch 3/3 sets stdin/stdout/stderr into
binary mode, so that dejagnu/expects can match the eol correctly
too.
Patch 2/3 and 3/3 was posted last week,
http://sourceware.org/ml/gdb-patches/2013-07/msg00481.html
http://sourceware.org/ml/gdb-patches/2013-07/msg00358.html
and one review comment is that these changes affect the behavior of
mingw32 GDB as a typical native win32 application. In order to
remove this side effect, a new option '--cyginw-tty' is added in
patch 1/3, which tells GDB that it is running in Cygwin TTY.
The whole series are tested on native mingw32 GDB running in cygwin.
Test results are improved dramatically.
*** BLURB HERE ***
Yao Qi (3):
New option --cygwin-tty.
Unbuffer stdout and stderr on windows
native mingw32 gdb, eol format
gdb/NEWS | 4 +++
gdb/defs.h | 4 +++
gdb/main.c | 54 ++++++++++++++++++++++++++++++++++++++
gdb/testsuite/gdb.base/dbx.exp | 3 +-
gdb/testsuite/lib/gdb.exp | 35 +++++++++++++++++++++++-
gdb/testsuite/lib/mi-support.exp | 3 +-
6 files changed, 99 insertions(+), 4 deletions(-)
--
1.7.7.6
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/3] Unbuffer stdout and stderr on windows
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
2013-07-25 5:10 ` [PATCH 3/3] native mingw32 gdb, eol format Yao Qi
@ 2013-07-25 5:10 ` Yao Qi
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
2013-07-25 7:31 ` [PATCH 0/3] Test mingw32 GDB in cygwin Pierre Muller
3 siblings, 0 replies; 15+ messages in thread
From: Yao Qi @ 2013-07-25 5:10 UTC (permalink / raw)
To: gdb-patches
This is the V2. We have some changes in V2:
- Replace '_WIN32' with '__MINGW32__'.
- Check flag 'cygwin_tty'.
- Postpone setting stdout/stderr until the option is parsed.
---------------------------------------------------------------
Hi,
This patch is to disable the buffering on windows host, because the
error message and gdb prompt come out in different orders, which
causes a lot of test fails.
We call setvbuf this place, because it is a place "before any other
operation is performed". See the doc below:
"The setvbuf() function may be used after the stream pointed to by
stream is associated with an open file but before any other operation
(other than an unsuccessful call to setvbuf()) is performed on the
stream."
It is not the first time this patch show up here. Daniel posted it
http://sourceware.org/ml/gdb-patches/2009-06/msg00433.html and Joel
preferred it as the exact same piece of code is in their tree as well
http://sourceware.org/ml/gdb-patches/2009-06/msg00434.html
Eli wanted to check this patch didn't interfere with Emacs 23 GDB
interface on Windows, which is probably the last question to this
patch. The discussion stopped there. I build native mingw32 gdb
with buffering disabled, and use it with Emacs 24.3 in Windows
cmd.exe. Emacs+GDB behave correctly.
gdb:
2013-07-25 Joseph Myers <joseph@codesourcery.com>
* main.c (captured_main) [__MINGW32__]: Set stdout and stderr
unbuffered on Windows.
---
gdb/main.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/gdb/main.c b/gdb/main.c
index 029f365..4777286 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -750,6 +750,18 @@ captured_main (void *data)
quiet = 1;
}
+#ifdef __MINGW32__
+ if (cygwin_tty)
+ {
+ /* A Cygwin session may not look like a terminal to the Windows
+ runtime; ensure unbuffered output. Note that setvbuf may be
+ used after the file is opened but before any other operation
+ is performed. */
+ setvbuf (stdout, NULL, _IONBF, BUFSIZ);
+ setvbuf (stderr, NULL, _IONBF, BUFSIZ);
+ }
+#endif
+
/* Initialize all files. Give the interpreter a chance to take
control of the console via the deprecated_init_ui_hook (). */
gdb_init (gdb_program_name);
--
1.7.7.6
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 0/3] Test mingw32 GDB in cygwin
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
` (2 preceding siblings ...)
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
@ 2013-07-25 7:31 ` Pierre Muller
3 siblings, 0 replies; 15+ messages in thread
From: Pierre Muller @ 2013-07-25 7:31 UTC (permalink / raw)
To: 'Yao Qi', gdb-patches
Hi all,
while I find that this patch series is really a big improvement
towards getting usable results for Windows OS native GDB,
I must say that I do not like at all the name of the new
command line option.
Indeed, I tested your previous patches on a current trunk CVS
source compiled on msys system configured as i686-pc-mingw32.
I am using an old dejagnu port for msys
which basically suffers the problems a you describe for mingw32 GDB
on a cygwin tty.
But to me it seems rather odd that we should use --cygwin-tty
option on an msys terminal.
Maybe --windows-so-tty would be more appropriate?
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 0/3] Test mingw32 GDB in cygwin
>
> Hi,
> This patch series try to fix the problems we've seen on running
> mingw32 native for testing in cygwin tty. Patch 2/3 unbuffer the
> stdout and stderr, so that dejagnu/expect can match the output in
> the right order. Likewise, patch 3/3 sets stdin/stdout/stderr into
> binary mode, so that dejagnu/expects can match the eol correctly
> too.
>
> Patch 2/3 and 3/3 was posted last week,
>
> http://sourceware.org/ml/gdb-patches/2013-07/msg00481.html
> http://sourceware.org/ml/gdb-patches/2013-07/msg00358.html
>
> and one review comment is that these changes affect the behavior of
> mingw32 GDB as a typical native win32 application. In order to
> remove this side effect, a new option '--cyginw-tty' is added in
> patch 1/3, which tells GDB that it is running in Cygwin TTY.
>
> The whole series are tested on native mingw32 GDB running in cygwin.
> Test results are improved dramatically.
>
> *** BLURB HERE ***
>
> Yao Qi (3):
> New option --cygwin-tty.
> Unbuffer stdout and stderr on windows
> native mingw32 gdb, eol format
>
> gdb/NEWS | 4 +++
> gdb/defs.h | 4 +++
> gdb/main.c | 54
> ++++++++++++++++++++++++++++++++++++++
> gdb/testsuite/gdb.base/dbx.exp | 3 +-
> gdb/testsuite/lib/gdb.exp | 35 +++++++++++++++++++++++-
> gdb/testsuite/lib/mi-support.exp | 3 +-
> 6 files changed, 99 insertions(+), 4 deletions(-)
>
> --
> 1.7.7.6
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
@ 2013-07-25 7:34 ` Corinna Vinschen
2013-07-25 7:37 ` Pierre Muller
1 sibling, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2013-07-25 7:34 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 786 bytes --]
On Jul 25 13:09, Yao Qi wrote:
> 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.
Ptys in Cygwin are implemented as named pipes. Therefore the native
MSVCRT _isatty() call returns 0 when called on a stream connected to a
pty.
Last year I created an isatty replacement implementation for non-Cygwin
applications for demonstration. It should work with Mingw-w64 as well
as VC++. I attached it to this mail, maybe it helps.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: isatty-for-native-apps.c --]
[-- Type: text/plain, Size: 3010 bytes --]
#include <stdio.h>
#include <io.h>
#include <errno.h>
#include <wchar.h>
#include <windows.h>
#include <winternl.h>
#ifndef __MINGW64_VERSION_MAJOR
/* MS winternl.h defines FILE_INFORMATION_CLASS, but with only a
different single member. */
enum FILE_INFORMATION_CLASSX
{
FileNameInformation = 9
};
typedef struct _FILE_NAME_INFORMATION
{
ULONG FileNameLength;
WCHAR FileName[1];
} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION;
NTSTATUS (NTAPI *pNtQueryInformationFile) (HANDLE, PIO_STATUS_BLOCK, PVOID,
ULONG, FILE_INFORMATION_CLASSX);
#else
NTSTATUS (NTAPI *pNtQueryInformationFile) (HANDLE, PIO_STATUS_BLOCK, PVOID,
ULONG, FILE_INFORMATION_CLASS);
#endif
int
isatty (int fd)
{
HANDLE fh;
NTSTATUS status;
IO_STATUS_BLOCK io;
long buf[66]; /* NAME_MAX + 1 + sizeof ULONG */
PFILE_NAME_INFORMATION pfni = (PFILE_NAME_INFORMATION) buf;
PWCHAR cp;
/* First check using _isatty.
Note that this returns the wrong result for NUL, for instance!
Workaround is not to use _isatty at all, but rather GetFileType
plus object name checking. */
if (_isatty (fd))
return 1;
/* Now fetch the underlying HANDLE. */
fh = (HANDLE) _get_osfhandle (fd);
if (!fh || fh == INVALID_HANDLE_VALUE)
{
errno = EBADF;
return 0;
}
/* Must be a pipe. */
if (GetFileType (fh) != FILE_TYPE_PIPE)
goto no_tty;
/* Calling the native NT function NtQueryInformationFile is required to
support pre-Vista systems. If that's of no concern, Vista introduced
the GetFileInformationByHandleEx call with the FileNameInfo info class,
which can be used instead. */
if (!pNtQueryInformationFile)
{
pNtQueryInformationFile = (NTSTATUS (NTAPI *)(HANDLE, PIO_STATUS_BLOCK,
PVOID, ULONG, FILE_INFORMATION_CLASS))
GetProcAddress (GetModuleHandle ("ntdll.dll"),
"NtQueryInformationFile");
if (!pNtQueryInformationFile)
goto no_tty;
}
if (!NT_SUCCESS (pNtQueryInformationFile (fh, &io, pfni, sizeof buf,
FileNameInformation)))
goto no_tty;
/* The filename is not guaranteed to be NUL-terminated. */
pfni->FileName[pfni->FileNameLength / sizeof (WCHAR)] = L'\0';
/* Now check the name pattern. The filename of a Cygwin pseudo tty pipe
looks like this:
\cygwin-%16llx-pty%d-{to,from}-master
%16llx is the hash of the Cygwin installation, (to support multiple
parallel installations), %d id the pseudo tty number, "to" or "from"
differs the pipe direction. "from" is a stdin, "to" a stdout-like
pipe. */
cp = pfni->FileName;
if (!wcsncmp (cp, L"\\cygwin-", 8)
&& !wcsncmp (cp + 24, L"-pty", 4))
{
cp = wcschr (cp + 28, '-');
if (!cp)
goto no_tty;
if (!wcscmp (cp, L"-from-master") || !wcscmp (cp, L"-to-master"))
return 1;
}
no_tty:
errno = EINVAL;
return 0;
}
int
main ()
{
if (isatty(0))
printf("tty\n");
else
printf("not a tty\n");
return 0;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
2013-07-25 7:34 ` Corinna Vinschen
@ 2013-07-25 7:37 ` Pierre Muller
2013-07-25 7:55 ` Yao Qi
1 sibling, 1 reply; 15+ messages in thread
From: Pierre Muller @ 2013-07-25 7:37 UTC (permalink / raw)
To: 'Yao Qi', gdb-patches
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
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 7:37 ` Pierre Muller
@ 2013-07-25 7:55 ` Yao Qi
2013-07-25 8:18 ` Corinna Vinschen
2013-07-26 19:40 ` Doug Evans
0 siblings, 2 replies; 15+ messages in thread
From: Yao Qi @ 2013-07-25 7:55 UTC (permalink / raw)
To: Pierre Muller; +Cc: gdb-patches
On 07/25/2013 03:37 PM, Pierre Muller wrote:
> 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?
Yeah, I agree, but I am worried that stdio handlers (such as stdout)
should be set before any writes to them, so we should set the flag
(cygwin_tty) at the early stage of GDB start up (before command 'set
windows-os-tty on' is processed). If it is not a problem, I am fine.
I am looking at Corinna's example to see how to detect GDB is running in
Cygwin's TTY. If it works, probably we can get rid of this new GDB
option completely.
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 7:55 ` Yao Qi
@ 2013-07-25 8:18 ` Corinna Vinschen
2013-07-25 8:26 ` Corinna Vinschen
2013-07-25 9:05 ` Yao Qi
2013-07-26 19:40 ` Doug Evans
1 sibling, 2 replies; 15+ messages in thread
From: Corinna Vinschen @ 2013-07-25 8:18 UTC (permalink / raw)
To: gdb-patches
On Jul 25 15:54, Yao Qi wrote:
> On 07/25/2013 03:37 PM, Pierre Muller wrote:
> > 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?
>
> Yeah, I agree, but I am worried that stdio handlers (such as stdout)
> should be set before any writes to them, so we should set the flag
> (cygwin_tty) at the early stage of GDB start up (before command 'set
> windows-os-tty on' is processed). If it is not a problem, I am
> fine.
You can use the _setmode() call at any time to switch text/binary mode
on the descriptors.
> I am looking at Corinna's example to see how to detect GDB is
> running in Cygwin's TTY. If it works, probably we can get rid of
> this new GDB option completely.
It has been tested under Mingw-w64 and VC++. If you're using Mingw.Org,
it probably needs some tweaking.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 8:18 ` Corinna Vinschen
@ 2013-07-25 8:26 ` Corinna Vinschen
2013-07-25 9:05 ` Yao Qi
1 sibling, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2013-07-25 8:26 UTC (permalink / raw)
To: gdb-patches
On Jul 25 10:18, Corinna Vinschen wrote:
> On Jul 25 15:54, Yao Qi wrote:
> > On 07/25/2013 03:37 PM, Pierre Muller wrote:
> > > 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?
> >
> > Yeah, I agree, but I am worried that stdio handlers (such as stdout)
> > should be set before any writes to them, so we should set the flag
> > (cygwin_tty) at the early stage of GDB start up (before command 'set
> > windows-os-tty on' is processed). If it is not a problem, I am
> > fine.
>
> You can use the _setmode() call at any time to switch text/binary mode
> on the descriptors.
>
> > I am looking at Corinna's example to see how to detect GDB is
> > running in Cygwin's TTY. If it works, probably we can get rid of
> > this new GDB option completely.
>
> It has been tested under Mingw-w64 and VC++. If you're using Mingw.Org,
> it probably needs some tweaking.
...in terms of using different header files and the definitions at the
start of the example code. The source itself should then work unchanged.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 8:18 ` Corinna Vinschen
2013-07-25 8:26 ` Corinna Vinschen
@ 2013-07-25 9:05 ` Yao Qi
2013-07-25 10:20 ` Corinna Vinschen
1 sibling, 1 reply; 15+ messages in thread
From: Yao Qi @ 2013-07-25 9:05 UTC (permalink / raw)
To: gdb-patches
On 07/25/2013 04:18 PM, Corinna Vinschen wrote:
>> Yeah, I agree, but I am worried that stdio handlers (such as stdout)
>> >should be set before any writes to them, so we should set the flag
>> >(cygwin_tty) at the early stage of GDB start up (before command 'set
>> >windows-os-tty on' is processed). If it is not a problem, I am
>> >fine.
> You can use the _setmode() call at any time to switch text/binary mode
> on the descriptors.
>
The doc on _setmode on MSDN says _setmode () should be called before any
input or output operations.
http://msdn.microsoft.com/en-us/library/tw4k6df8.aspx
"_setmode is typically used to modify the default translation mode of
stdin and stdout, but you can use it on any file. If you apply _setmode
to the file descriptor for a stream, call _setmode before you perform
any input or output operations on the stream."
Beside setmode, we also need setvbuf to disable buffering. It should be
called before any input or output on the stream.
>> >I am looking at Corinna's example to see how to detect GDB is
>> >running in Cygwin's TTY. If it works, probably we can get rid of
>> >this new GDB option completely.
> It has been tested under Mingw-w64 and VC++. If you're using Mingw.Org,
> it probably needs some tweaking.
Right, it needs some tweaks on headers files for Mingw.Org.
What is the minimum version of cygwin required for this example? In
cygwin 1.7.20, the file name is
"\cygwin-8c26184c318518a4-pty0-from-master", while in 1.7.9, it is
"\cygwin-c5e39b7a9d22bafb-tty0-from-master".
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 9:05 ` Yao Qi
@ 2013-07-25 10:20 ` Corinna Vinschen
2013-07-25 12:08 ` Yao Qi
0 siblings, 1 reply; 15+ messages in thread
From: Corinna Vinschen @ 2013-07-25 10:20 UTC (permalink / raw)
To: gdb-patches
On Jul 25 17:04, Yao Qi wrote:
> On 07/25/2013 04:18 PM, Corinna Vinschen wrote:
> >>Yeah, I agree, but I am worried that stdio handlers (such as stdout)
> >>>should be set before any writes to them, so we should set the flag
> >>>(cygwin_tty) at the early stage of GDB start up (before command 'set
> >>>windows-os-tty on' is processed). If it is not a problem, I am
> >>>fine.
> >You can use the _setmode() call at any time to switch text/binary mode
> >on the descriptors.
> >
>
> The doc on _setmode on MSDN says _setmode () should be called before
> any input or output operations.
>
> http://msdn.microsoft.com/en-us/library/tw4k6df8.aspx
>
> "_setmode is typically used to modify the default translation mode
> of stdin and stdout, but you can use it on any file. If you apply
> _setmode to the file descriptor for a stream, call _setmode before
> you perform any input or output operations on the stream."
>
> Beside setmode, we also need setvbuf to disable buffering. It
> should be called before any input or output on the stream.
>
> >>>I am looking at Corinna's example to see how to detect GDB is
> >>>running in Cygwin's TTY. If it works, probably we can get rid of
> >>>this new GDB option completely.
> >It has been tested under Mingw-w64 and VC++. If you're using Mingw.Org,
> >it probably needs some tweaking.
>
> Right, it needs some tweaks on headers files for Mingw.Org.
>
> What is the minimum version of cygwin required for this example? In
> cygwin 1.7.20, the file name is
> "\cygwin-8c26184c318518a4-pty0-from-master", while in 1.7.9, it is
> "\cygwin-c5e39b7a9d22bafb-tty0-from-master".
Read the source code comments. The hex number is a per-installation
hash value which does not tell anything about the Cygwin version. The
earliest supported Cygwin version is 1.7.0, so the answer is "all of
them" for all practical purposes.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 10:20 ` Corinna Vinschen
@ 2013-07-25 12:08 ` Yao Qi
2013-07-25 15:21 ` Corinna Vinschen
0 siblings, 1 reply; 15+ messages in thread
From: Yao Qi @ 2013-07-25 12:08 UTC (permalink / raw)
To: gdb-patches
On 07/25/2013 06:19 PM, Corinna Vinschen wrote:
>> What is the minimum version of cygwin required for this example? In
>> >cygwin 1.7.20, the file name is
>> >"\cygwin-8c26184c318518a4-pty0-from-master", while in 1.7.9, it is
>> >"\cygwin-c5e39b7a9d22bafb-tty0-from-master".
> Read the source code comments. The hex number is a per-installation
> hash value which does not tell anything about the Cygwin version. The
> earliest supported Cygwin version is 1.7.0, so the answer is "all of
> them" for all practical purposes.
My point was about the "pty0" vs "tty0" difference in the file name. If
the difference is expected, I'll update the name pattern in the code.
Your example expects to see "pty".
--
Yao (é½å°§)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 12:08 ` Yao Qi
@ 2013-07-25 15:21 ` Corinna Vinschen
0 siblings, 0 replies; 15+ messages in thread
From: Corinna Vinschen @ 2013-07-25 15:21 UTC (permalink / raw)
To: gdb-patches
On Jul 25 20:07, Yao Qi wrote:
> On 07/25/2013 06:19 PM, Corinna Vinschen wrote:
> >>What is the minimum version of cygwin required for this example? In
> >>>cygwin 1.7.20, the file name is
> >>>"\cygwin-8c26184c318518a4-pty0-from-master", while in 1.7.9, it is
> >>>"\cygwin-c5e39b7a9d22bafb-tty0-from-master".
> >Read the source code comments. The hex number is a per-installation
> >hash value which does not tell anything about the Cygwin version. The
> >earliest supported Cygwin version is 1.7.0, so the answer is "all of
> >them" for all practical purposes.
>
> My point was about the "pty0" vs "tty0" difference in the file name.
> If the difference is expected, I'll update the name pattern in the
> code. Your example expects to see "pty".
Oh, ok, I missed that. Just tweak the code to check for both if you
want to support old Cygwin versions. But this isn't necessary IMO.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] New option --cygwin-tty.
2013-07-25 7:55 ` Yao Qi
2013-07-25 8:18 ` Corinna Vinschen
@ 2013-07-26 19:40 ` Doug Evans
1 sibling, 0 replies; 15+ messages in thread
From: Doug Evans @ 2013-07-26 19:40 UTC (permalink / raw)
To: Yao Qi; +Cc: Pierre Muller, gdb-patches
On Thu, Jul 25, 2013 at 12:54 AM, Yao Qi <yao@codesourcery.com> wrote:
> On 07/25/2013 03:37 PM, Pierre Muller wrote:
>>
>> 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?
>
>
> Yeah, I agree, but I am worried that stdio handlers (such as stdout) should
> be set before any writes to them, so we should set the flag (cygwin_tty) at
> the early stage of GDB start up (before command 'set windows-os-tty on' is
> processed). If it is not a problem, I am fine.
>
> I am looking at Corinna's example to see how to detect GDB is running in
> Cygwin's TTY. If it works, probably we can get rid of this new GDB option
> completely.
As a data point, and I agree that avoiding any new option would be preferable,
in addition to -ex there is also -iex which is performed earlier in
the gdb startup process
(before symbol files are read, for example).
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-07-26 19:40 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 5:10 [PATCH 0/3] Test mingw32 GDB in cygwin Yao Qi
2013-07-25 5:10 ` [PATCH 3/3] native mingw32 gdb, eol format Yao Qi
2013-07-25 5:10 ` [PATCH 2/3] Unbuffer stdout and stderr on windows Yao Qi
2013-07-25 5:10 ` [PATCH 1/3] New option --cygwin-tty Yao Qi
2013-07-25 7:34 ` Corinna Vinschen
2013-07-25 7:37 ` Pierre Muller
2013-07-25 7:55 ` Yao Qi
2013-07-25 8:18 ` Corinna Vinschen
2013-07-25 8:26 ` Corinna Vinschen
2013-07-25 9:05 ` Yao Qi
2013-07-25 10:20 ` Corinna Vinschen
2013-07-25 12:08 ` Yao Qi
2013-07-25 15:21 ` Corinna Vinschen
2013-07-26 19:40 ` Doug Evans
2013-07-25 7:31 ` [PATCH 0/3] Test mingw32 GDB in cygwin Pierre Muller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox