mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 12:34:43 +00:00
New '--binary-output' command line option, fix gdb.mi/ testing on Windows
MI testcases currently all fail on native Windows with:
Running /c/gdb/src/gdb/testsuite/gdb.mi/mi-simplerun.exp ...
ERROR: (timeout) GDB never initialized after 10 seconds.
This is because when GDB is started in MI mode, it prints info to the
terminal before -iex options are processed. I.e., before the "maint
set console-translation-mode binary" command in
gdb -nw -nx -q -iex "set height 0" -iex "set width 0" \
-iex "set interactive-mode on" \
-iex "maint set console-translation-mode binary" \
-i=mi
... is processed. This results in GDB printing early output with
\r\r\n, like can be easily seen by passing --debug to runtest:
expect: does "=thread-group-added,id="i1"\r\r\n=cmd-param-changed,param="width",value="4294967295"\r\r\n=cmd-param-changed,param="interactive-mode",value="on"\r\r\n(gdb) \r\n" (spawn_id exp10) match regular expression "~"GNU.*\r\n~".*[(]gdb[)] \r\n$"? Gate "~"GNU*\r\n~"*gdb? \r\n"? gate=no
Fix this by adding a new Windows-only --binary-output command line
option to GDB, which is processed much earlier than -iex, and making
the testsuite pass that instead of "maint set console-translation-mode
binary".
Remove "maint set console-translation-mode" completely, since the only
reason it existed was for the testsuite, and it was never included in
any release.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Tom de Vries <tdevries@suse.de>
Change-Id: I4632707bb7c8ca573cffff9641ddeb33a0e150af
This commit is contained in:
10
gdb/NEWS
10
gdb/NEWS
@@ -86,6 +86,10 @@ single-inf-arg in qSupported
|
||||
* Debugging Linux programs that use AArch64 Guarded Control Stacks is now
|
||||
supported.
|
||||
|
||||
* New "--binary-output" command line option instructs GDB to set the
|
||||
translation mode of its stdout/stderr to binary mode. This disables
|
||||
Line Feed translation. MS-Windows only.
|
||||
|
||||
* New commands
|
||||
|
||||
maintenance check psymtabs
|
||||
@@ -97,12 +101,6 @@ maintenance check symtabs
|
||||
maintenance canonicalize
|
||||
Show the canonical form of a C++ name.
|
||||
|
||||
maintenance set console-translation-mode <binary|text>
|
||||
maintenance show console-translation-mode
|
||||
Controls the translation mode of GDB stdout/stderr. MS-Windows only. In
|
||||
binary mode, no translation is done. In text mode, a Line Feed is
|
||||
translated into a Carriage Return-Line Feed combination.
|
||||
|
||||
set riscv numeric-register-names on|off
|
||||
show riscv numeric-register-names
|
||||
Controls whether GDB refers to risc-v registers by their numeric names
|
||||
|
||||
@@ -1215,6 +1215,17 @@ Run @value{GDBN} using @var{directory} as its data directory.
|
||||
The data directory is where @value{GDBN} searches for its
|
||||
auxiliary files. @xref{Data Files}.
|
||||
|
||||
@item -binary-output
|
||||
@cindex @code{--binary-output}
|
||||
|
||||
Instructs @value{GDBN} to set the translation mode of its
|
||||
@code{stdout}/@code{stderr} to binary. MS-Windows only. Useful for
|
||||
running the @value{GDBN} testsuite. By default, @value{GDBN} opens
|
||||
@code{stdout}/@code{stderr} in text mode, and translates @samp{\n}
|
||||
(LF, a single Line Feed) into @samp{\r\n} (CR-LF, a Carriage
|
||||
Return-Line Feed combination). If this option is set, no translation
|
||||
is done.
|
||||
|
||||
@item -fullname
|
||||
@itemx -f
|
||||
@cindex @code{--fullname}
|
||||
@@ -42899,22 +42910,6 @@ reports and error and the command is aborted.
|
||||
@item show watchdog
|
||||
Show the current setting of the target wait timeout.
|
||||
|
||||
@kindex maint set console-translation-mode
|
||||
@kindex maint show console-translation-mode
|
||||
@item maint set console-translation-mode @r{[}binary|text@r{]}
|
||||
@itemx maint show console-translation-mode
|
||||
Controls the translation mode of @value{GDBN} stdout/stderr. MS-Windows
|
||||
only. Useful for running the @value{GDBN} testsuite.
|
||||
|
||||
The translation mode values are as follows:
|
||||
@table @code
|
||||
@item binary
|
||||
No translation.
|
||||
@item text
|
||||
Translate @samp{\n} (LF, a single Line Feed) into @samp{\r\n} (CR-LF, a
|
||||
Carriage Return-Line Feed combination).
|
||||
@end table
|
||||
|
||||
@end table
|
||||
|
||||
@node Remote Protocol
|
||||
|
||||
22
gdb/main.c
22
gdb/main.c
@@ -59,6 +59,7 @@
|
||||
#include "serial.h"
|
||||
#include "cli-out.h"
|
||||
#include "bt-utils.h"
|
||||
#include "terminal.h"
|
||||
|
||||
/* The selected interpreter. */
|
||||
std::string interpreter_p;
|
||||
@@ -783,6 +784,9 @@ captured_main_1 (struct captured_main_args *context)
|
||||
OPT_READNEVER,
|
||||
OPT_SET_ESC_ARGS,
|
||||
OPT_SET_NO_ESC_ARGS,
|
||||
#ifdef USE_WIN32API
|
||||
OPT_BINARY_OUTPUT,
|
||||
#endif
|
||||
};
|
||||
/* This struct requires int* in the struct, but write_files is a bool.
|
||||
So use this temporary int that we write back after argument parsing. */
|
||||
@@ -859,6 +863,9 @@ captured_main_1 (struct captured_main_args *context)
|
||||
{"no-escape-args", no_argument, nullptr, OPT_SET_NO_ESC_ARGS},
|
||||
{"l", required_argument, 0, 'l'},
|
||||
{"return-child-result", no_argument, &return_child_result, 1},
|
||||
#ifdef USE_WIN32API
|
||||
{"binary-output", no_argument, 0, OPT_BINARY_OUTPUT},
|
||||
#endif
|
||||
{0, no_argument, 0, 0}
|
||||
};
|
||||
|
||||
@@ -1043,6 +1050,12 @@ captured_main_1 (struct captured_main_args *context)
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef USE_WIN32API
|
||||
case OPT_BINARY_OUTPUT:
|
||||
set_output_translation_mode_binary ();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case '?':
|
||||
error (_("Use `%s --help' for a complete list of options."),
|
||||
gdb_program_name);
|
||||
@@ -1482,8 +1495,13 @@ Remote debugging options:\n\n\
|
||||
Other options:\n\n\
|
||||
--cd=DIR Change current directory to DIR.\n\
|
||||
--data-directory=DIR, -D\n\
|
||||
Set GDB's data-directory to DIR.\n\
|
||||
"), stream);
|
||||
Set GDB's data-directory to DIR.\n"
|
||||
#ifdef USE_WIN32API
|
||||
"\
|
||||
--binary-output Set the translation mode of stdout/stderr to binary,\n\
|
||||
disabling CRLF translation.\n"
|
||||
#endif
|
||||
), stream);
|
||||
gdb_puts (_("\n\
|
||||
At startup, GDB reads the following early init files and executes their\n\
|
||||
commands:\n\
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "cli/cli-style.h"
|
||||
#include "command.h"
|
||||
#include "cli/cli-cmds.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <signal.h>
|
||||
@@ -448,61 +449,11 @@ install_sigint_handler (c_c_handler_ftype *fn)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Set stdout and stderr handles to translation mode MODE. */
|
||||
/* See terminal.h. */
|
||||
|
||||
static void
|
||||
set_console_translation_mode (int mode)
|
||||
void
|
||||
set_output_translation_mode_binary ()
|
||||
{
|
||||
setmode (fileno (stdout), mode);
|
||||
setmode (fileno (stderr), mode);
|
||||
}
|
||||
|
||||
/* Arg in "maint set console-translation-mode <arg>. */
|
||||
|
||||
static std::string maint_console_translation_mode;
|
||||
|
||||
/* Current value of "maint set/show console-translation-mode". */
|
||||
|
||||
static std::string console_translation_mode = "unknown";
|
||||
|
||||
/* Sets the console translation mode. */
|
||||
|
||||
static void
|
||||
set_maint_console_translation_mode (const char *args, int from_tty,
|
||||
struct cmd_list_element *c)
|
||||
{
|
||||
if (maint_console_translation_mode == "binary")
|
||||
set_console_translation_mode (O_BINARY);
|
||||
else if (maint_console_translation_mode == "text")
|
||||
set_console_translation_mode (O_TEXT);
|
||||
else
|
||||
error (_("Invalid console translation mode: %s"),
|
||||
maint_console_translation_mode.c_str ());
|
||||
|
||||
console_translation_mode = maint_console_translation_mode;
|
||||
}
|
||||
|
||||
/* Shows the console translation mode. */
|
||||
|
||||
static void
|
||||
show_maint_console_translation_mode (struct ui_file *file, int from_tty,
|
||||
struct cmd_list_element *c,
|
||||
const char *value)
|
||||
{
|
||||
gdb_printf (file, _("Console translation mode is %s.\n"),
|
||||
console_translation_mode.c_str ());
|
||||
}
|
||||
|
||||
INIT_GDB_FILE (mingw_hdep)
|
||||
{
|
||||
add_setshow_string_cmd ("console-translation-mode",
|
||||
class_maintenance,
|
||||
&maint_console_translation_mode, _("\
|
||||
Set the translation mode of stdout/stderr."), _("\
|
||||
Show the translation mode of stdout/stderr."), _("\
|
||||
Use \"binary\", or \"text\""),
|
||||
set_maint_console_translation_mode,
|
||||
show_maint_console_translation_mode,
|
||||
&maintenance_set_cmdlist,
|
||||
&maintenance_show_cmdlist);
|
||||
setmode (fileno (stdout), O_BINARY);
|
||||
setmode (fileno (stderr), O_BINARY);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,10 @@ public:
|
||||
private:
|
||||
serial_ttystate m_ttystate;
|
||||
};
|
||||
|
||||
#ifdef USE_WIN32API
|
||||
/* Set translation mode of stdout/stderr to binary. */
|
||||
extern void set_output_translation_mode_binary ();
|
||||
#endif
|
||||
|
||||
#endif /* GDB_TERMINAL_H */
|
||||
|
||||
@@ -276,7 +276,7 @@ if ![info exists INTERNAL_GDBFLAGS] {
|
||||
append INTERNAL_GDBFLAGS { -iex "set interactive-mode on"}
|
||||
|
||||
if { [ishost "*-*-mingw*"] } {
|
||||
append INTERNAL_GDBFLAGS { -iex "maint set console-translation-mode binary"}
|
||||
append INTERNAL_GDBFLAGS { --binary-output}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user