From f8073b41a1015f9c840e3d97b4edbf754389d66e Mon Sep 17 00:00:00 2001 From: Matt Wozniski Date: Tue, 31 Jan 2023 23:06:25 -0500 Subject: [PATCH] attach: Work around a bug in old gdb versions 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 --- news/310.bugfix.1.rst | 1 + src/memray/commands/_attach.gdb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 news/310.bugfix.1.rst diff --git a/news/310.bugfix.1.rst b/news/310.bugfix.1.rst new file mode 100644 index 0000000000..0a8c978a2d --- /dev/null +++ b/news/310.bugfix.1.rst @@ -0,0 +1 @@ +Work around `a bug in GDB versions before 10.1 `_ that could cause ``memray attach`` to fail. diff --git a/src/memray/commands/_attach.gdb b/src/memray/commands/_attach.gdb index 77749f7961..84dd9e7073 100644 --- a/src/memray/commands/_attach.gdb +++ b/src/memray/commands/_attach.gdb @@ -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()