Skip to content

Commit

Permalink
attach: Work around a bug in old gdb versions
Browse files Browse the repository at this point in the history
There's a bug (fixed in gdb 10.1) with how gdb parses the "commands"
command when reading from a script, which causes the commands to get
associated only with the first breakpoint rather than all of the
breakpoints we wanted them associated with.

Through sheer good luck, this bug doesn't affect the case when a range
of breakpoint numbers is given, rather than a space separated list of
breakpoint numbers, so we can switch to using a range to avoid the bug.

Signed-off-by: Matt Wozniski <[email protected]>
  • Loading branch information
godlygeek committed Feb 1, 2023
1 parent 9c23c85 commit f8073b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/310.bugfix.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Work around `a bug in GDB versions before 10.1 <https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=da1df1db9ae43050c8de62e4842428ddda7eb509>`_ that could cause ``memray attach`` to fail.
2 changes: 1 addition & 1 deletion src/memray/commands/_attach.gdb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ b PyMem_Calloc
b PyMem_Realloc
b PyMem_Free
# Apply commands to all 8 breakpoints above
commands 1 2 3 4 5 6 7 8
commands 1-8
disable breakpoints
call (void*)dlopen($libpath, $rtld_now)
p (char*)dlerror()
Expand Down

0 comments on commit f8073b4

Please sign in to comment.