diff options
author | Tom de Vries <tdevries@suse.de> | 2025-06-28 13:03:14 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2025-06-28 13:03:14 +0200 |
commit | f9e9e263f5d8aa60f34207c056fd3c6d8bd5d8ff (patch) | |
tree | 07b57b1af87a2ed109ee40cc7732a9f15c54461a /gdb/python/py-function.c | |
parent | d62eaecf2e6fc2bce3a0d3a711666c700e79a51a (diff) | |
download | binutils-f9e9e263f5d8aa60f34207c056fd3c6d8bd5d8ff.zip binutils-f9e9e263f5d8aa60f34207c056fd3c6d8bd5d8ff.tar.gz binutils-f9e9e263f5d8aa60f34207c056fd3c6d8bd5d8ff.tar.bz2 |
[gdb/tdep] Add "maint set console-translation-mode <binary|text>" command
On MSYS2, say we record a brief gdb session using TERM=dumb script:
...
$ gdb -q
(gdb) print 1
$1 = 1
(gdb) q
...
When looking at the resulting typescript, we notice something odd:
...
$ gdb -q^M
(gdb) print 1^M
$1 = 1^M^M
(gdb) q^M
...
For some reason, we have "$1 = 1\r\r\n(gdb) ".
Looking at the documentation of _setmode [1], it mentions translation mode
_O_TEXT as a mode in which "\n" is translated into "\r\n" on output.
So, it looks like this translation happens twice.
Add a command "maint set console-translation-mode <binary|text>" command that
allows us to set the translation mode of stdout/stderr to binary, such that we
get instead:
...
$ gdb -q -ex "maint set console-translation-mode binary"^M
(gdb) print 1^M
$1 = 1^M
(gdb) q^M
...
Since we run into this in the testsuite, add
"maint set console-translation-mode binary" to INTERNAL_GDBFLAGS.
Based on "maint set testsuite-mode on/off" from these patches [2][3] by Pierre
Muller.
Compared to that proposal, I dropped the name testsuite-mode, because the
behaviour is not specific to the testsuite.
Also I chose values binary/text instead of on/off because eventually there may
be other translation mode values that we need [4].
Co-Authored-By: Pierre Muller <muller@sourceware.org>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
[1] https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode
[2] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00939.html
[3] https://sourceware.org/legacy-ml/gdb-patches/2013-09/msg00940.html
[4] https://learn.microsoft.com/en-us/cpp/c-runtime-library/translation-mode-constants
Diffstat (limited to 'gdb/python/py-function.c')
0 files changed, 0 insertions, 0 deletions