aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.xml
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-12-10 11:44:36 -0700
committerTom Tromey <tromey@adacore.com>2019-12-19 10:00:05 -0700
commitf69656d00fe3154519ea21668d964bf8cc50c01b (patch)
treee07fe31898f35e94c42ff5e8e185488e7a26f845 /gdb/testsuite/gdb.xml
parent228c8f4be0c428369ec6b68e25696863d1e62ed7 (diff)
downloadfsf-binutils-gdb-f69656d00fe3154519ea21668d964bf8cc50c01b.zip
fsf-binutils-gdb-f69656d00fe3154519ea21668d964bf8cc50c01b.tar.gz
fsf-binutils-gdb-f69656d00fe3154519ea21668d964bf8cc50c01b.tar.bz2
Handle CRLF when reading XML on Windows
xml-support.c uses FOPEN_RT, but then reads the entire contents of the file and verifies that the number of bytes read matches the length. This can fail on Windows, where the read will translate line terminators. This patch fixes the bug by changing xml-support.c to use FOPEN_RB. This works because expat correctly handles \r\n line terminators. gdb/ChangeLog 2019-12-11 Tom Tromey <tromey@adacore.com> * xml-support.c (xml_fetch_content_from_file): Use FOPEN_RB. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey <tromey@adacore.com> * gdb.xml/tdesc-arch.exp (set_arch): Add "trans_mode" parameter. Add crlf test. Change-Id: I548438f33eed284dde1de8babf755eaa1a40319d
Diffstat (limited to 'gdb/testsuite/gdb.xml')
-rw-r--r--gdb/testsuite/gdb.xml/tdesc-arch.exp14
1 files changed, 11 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.xml/tdesc-arch.exp b/gdb/testsuite/gdb.xml/tdesc-arch.exp
index 617ab06..d98e50e 100644
--- a/gdb/testsuite/gdb.xml/tdesc-arch.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-arch.exp
@@ -55,13 +55,16 @@ if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
# Run these tests twice, once for $arch1 and once for $arch2, to
# make sure that the tdesc file overrides the global default.
+# TRANS_MODE indicates how newlines should be represented; it should
+# be one of the values supported by "fconfigure -translation".
-proc set_arch { arch which } {
+proc set_arch { arch which trans_mode } {
global gdb_prompt
global subdir
set filename [standard_output_file tdesc-arch.xml]
set fd [open $filename w]
+ fconfigure $fd -translation $trans_mode
puts $fd \
"<target>
<architecture>$arch</architecture>
@@ -92,8 +95,13 @@ proc set_arch { arch which } {
remote_file host delete $filename
}
-set_arch $arch1 first
-set_arch $arch2 second
+set_arch $arch1 first lf
+set_arch $arch2 second lf
+
+with_test_prefix crlf {
+ set_arch $arch1 first crlf
+ set_arch $arch2 second crlf
+}
# Check an invalid architecture setting.
set filename [standard_output_file tdesc-arch.xml]