public inbox for
 help / color / mirror / Atom feed
* [PATCH] Use binary mode to read .log/.sum
@ 2020-09-23 21:06 Keith Seitz
  0 siblings, 0 replies; only message in thread
From: Keith Seitz @ 2020-09-23 21:06 UTC (permalink / raw)
  To: bunsen

There's no guarantee that gdb.{log,sum} will not contain non-UTF-8
encoded characters.  This can happen, for example, when either gdb or
the inferior outputs uninitialized data (either intentionally or as a
result of some bug). gdb.fortran/function-calls.exp is a common

Since Cursor will decode lines using UTF-8, nothing is really sacrificed.
However, this does fix several import problems I've encountered where
stray/garbage bytes have caused the import to abort prematurely.
 scripts-master/gdb/ | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts-master/gdb/ b/scripts-master/gdb/
index 5218e9a..c9f30ac 100755
--- a/scripts-master/gdb/
+++ b/scripts-master/gdb/
@@ -65,11 +65,14 @@ def get_outcome_line(testcase):
 datestamp_format = '%a %b %d %H:%M:%S %Y'
 def openfile_or_xz(path):
+    # Read in bary mode to suppress encoding problems that might occur
+    # from reading gdb.{log,sum}. Sometimes inferiors or gdb can just output
+    # garbage bytes.
     if os.path.isfile(path):
-        return open(path, mode='rt')
+        return open(path, mode='rb')
     elif os.path.isfile(path+'.xz'):
-        return'.xz', mode='rt')
-    return open(path, mode='rt') # XXX trigger default error
+        return'.xz', mode='rb')
+    return open(path, mode='rb') # XXX trigger default error
 def parse_README(testrun, READMEfile):
     if testrun is None: return None

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-23 21:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-23 21:06 [PATCH] Use binary mode to read .log/.sum Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).