public inbox for bunsen@sourceware.org
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: bunsen@sourceware.org
Subject: [PATCH] Use binary mode to read .log/.sum
Date: Wed, 23 Sep 2020 14:06:45 -0700	[thread overview]
Message-ID: <20200923210645.1472242-1-keiths@redhat.com> (raw)

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
problem.

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/parse_dejagnu.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts-master/gdb/parse_dejagnu.py b/scripts-master/gdb/parse_dejagnu.py
index 5218e9a..c9f30ac 100755
--- a/scripts-master/gdb/parse_dejagnu.py
+++ b/scripts-master/gdb/parse_dejagnu.py
@@ -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 lzma.open(path+'.xz', mode='rt')
-    return open(path, mode='rt') # XXX trigger default error
+        return lzma.open(path+'.xz', mode='rb')
+    return open(path, mode='rb') # XXX trigger default error
 
 def parse_README(testrun, READMEfile):
     if testrun is None: return None
-- 
2.26.2


                 reply	other threads:[~2020-09-23 21:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200923210645.1472242-1-keiths@redhat.com \
    --to=keiths@redhat.com \
    --cc=bunsen@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).