Skip to content

Commit

Permalink
Fix debugger output parsing in attach command
Browse files Browse the repository at this point in the history
When using lldb in macOS, the output of lldb is slighly different and we
are not properly matching that is what we expect. To avoid having to
rely on weird hacks to not detect the actual command we issue, filter
the output to not contain the lines that have the debugger promt to only
check against the actual debugger output. This simplifies the check and
provides an easier way to do assert that we are in the situation we
expect.
  • Loading branch information
pablogsal committed Nov 3, 2023
1 parent 27c1f73 commit 76edcb5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/memray/commands/attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ def inject(debugger: str, pid: int, port: int, verbose: bool) -> str | None:
print(f"debugger return code: {returncode}")
print(f"debugger output:\n{output}")

if returncode == 0 and ' = "SUCCESS"' in output:
command_output_lines = (
line for line in output.splitlines() if not line.startswith(f"({debugger})")
)
if returncode == 0 and any(' "SUCCESSS"' in line for line in command_output_lines):
return None

# An error occurred. Give the best message we can. This is hacky; we don't
Expand Down

0 comments on commit 76edcb5

Please sign in to comment.