From 9c963737626c7f658eb36773c5f8e6096297f4a3 Mon Sep 17 00:00:00 2001 From: YenHaoChen Date: Tue, 4 Oct 2022 15:34:11 +0800 Subject: Update testlib.py; remove ANSI escape sequences The control sequences (^[[?2004h and ^[[?2004l) occur after the gdb.command, which results in Exception fault. This commit removes the control sequences and strips out the blank lines (^M). --- debug/testlib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'debug') diff --git a/debug/testlib.py b/debug/testlib.py index 1f023f0..bbca9fe 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -692,7 +692,8 @@ class Gdb: self.active_child.sendline(command) self.active_child.expect("\n", timeout=timeout) self.active_child.expect(r"\(gdb\)", timeout=timeout) - return self.active_child.before.strip().decode("utf-8", errors="ignore") + ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') + return ansi_escape.sub('', self.active_child.before.strip().decode("utf-8", errors="ignore")).strip() def interact(self): """Call this from a test at a point where you just want to interact with -- cgit v1.1