From fe757123184e947b95519883f324e8211d834a21 Mon Sep 17 00:00:00 2001 From: tearandfix <79838675+tearandfix@users.noreply.github.com> Date: Sat, 5 Oct 2024 10:18:26 +0300 Subject: [PATCH 1/3] Support older gdb versions which use python2.7 --- lib/gdb_commands.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/gdb_commands.py b/lib/gdb_commands.py index 04803d8..f4cfee7 100644 --- a/lib/gdb_commands.py +++ b/lib/gdb_commands.py @@ -45,13 +45,13 @@ def invoke(self, arg, from_tty): self.thrd.daemon = True self.thrd.start() - def _server(self, server_address: str): + def _server(self, server_address): sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.bind(('127.0.0.1', 0)) sock.settimeout(0.25) _, port = sock.getsockname() with open(server_address, 'w') as f: - f.write(f"{port}") + f.write(str(port)) logger.info("Start listening for commands at port %d", port) try: while not self.quit: @@ -129,7 +129,7 @@ def _get_current_frame_location(self): line = symtab_and_line.line return [filename, line] except gdb.error: - ... + pass return [] def _get_breaks_provider(self): @@ -139,7 +139,7 @@ def _get_breaks_provider(self): return self._enum_breaks() return self._enum_breaks_fallback() - def _get_breaks(self, fname: str): + def _get_breaks(self, fname): """Get list of enabled breakpoints for a given source file.""" breaks = {} @@ -226,7 +226,7 @@ def _get_all_breaks(self): breaks = [] try: for path, line, bid in self._get_breaks_provider(): - breaks.append(f"{path}:{line} breakpoint {bid}") + breaks.append(str(path) + ':' + str(line) + ' breakpoint ' + str(bid)) except AttributeError: self.fallback_to_parsing = True return self._get_all_breaks() From 2004f039e64f4bd6df32450ff7251f07819ce7ff Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Sun, 13 Oct 2024 20:21:39 -0300 Subject: [PATCH 2/3] Fix GdbStartRR Now it works with rr version 5.8.0 --- lib/rr-replay.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rr-replay.py b/lib/rr-replay.py index 811e38f..047b1a2 100755 --- a/lib/rr-replay.py +++ b/lib/rr-replay.py @@ -3,19 +3,18 @@ import asyncio import pipes import sys +import shlex # rr replay refuses to run outside of a pty. But it allows # attaching a gdb remotely. async def run_gdb(cmd): - args = [f'"{pipes.quote(a)}"' for a in sys.argv[1:]] - parts = cmd.split() + parts = shlex.split(cmd) gdb_idx = parts.index('gdb') if gdb_idx != -1: - parts = parts[:gdb_idx+1] + args + parts[gdb_idx+1:] - cmd = " ".join(parts) - gdb_proc = await asyncio.create_subprocess_shell(cmd) + parts = parts[:gdb_idx+1] + sys.argv[1:] + parts[gdb_idx+1:] + gdb_proc = await asyncio.create_subprocess_exec(*parts) await gdb_proc.communicate() return gdb_proc.returncode @@ -36,7 +35,7 @@ async def run(cmd): # Check it launched header = await rr_proc.stderr.readline() - if header != b'Launch gdb with\n': + if header != b'Launch debugger with\n': rest = await rr_proc.stderr.read() raise RuntimeError(f"Unexpected: {header.decode()}{rest.decode()}") From 41f0598e4ad0d10d56a0df1971954868ae371c3d Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Mon, 14 Oct 2024 18:41:33 -0300 Subject: [PATCH 3/3] Fix rr-replay to work with previous versions of rr --- lib/rr-replay.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rr-replay.py b/lib/rr-replay.py index 047b1a2..68f1630 100755 --- a/lib/rr-replay.py +++ b/lib/rr-replay.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 import asyncio -import pipes import sys import shlex +import re # rr replay refuses to run outside of a pty. But it allows # attaching a gdb remotely. @@ -33,9 +33,11 @@ async def run(cmd): cmd, stderr=asyncio.subprocess.PIPE) + header_regex = re.compile(b'Launch \\w+ with$') + # Check it launched header = await rr_proc.stderr.readline() - if header != b'Launch debugger with\n': + if not header_regex.match(header): rest = await rr_proc.stderr.read() raise RuntimeError(f"Unexpected: {header.decode()}{rest.decode()}")