Skip to content

Commit

Permalink
Merge pull request #210 from Rodrigodd/fix-rr
Browse files Browse the repository at this point in the history
Update rr-replay.py to work with rr 5.8.0
  • Loading branch information
sakhnik authored Oct 15, 2024
2 parents 769ae42 + 41f0598 commit 952f0b4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/rr-replay.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/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.


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

Expand All @@ -34,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 gdb with\n':
if not header_regex.match(header):
rest = await rr_proc.stderr.read()
raise RuntimeError(f"Unexpected: {header.decode()}{rest.decode()}")

Expand Down

0 comments on commit 952f0b4

Please sign in to comment.