Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
sakhnik committed Oct 15, 2024
2 parents 5619e1b + 952f0b4 commit 27304e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions lib/gdb_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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 = {}

Expand Down Expand Up @@ -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()
Expand Down
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 27304e9

Please sign in to comment.