Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attach: Add breakpoints for more safe entry points
`memray attach` needs to inject some custom code into the process it has attached to. It does this by using `dlopen` and then calling a function we control, but that can't be done just anywhere: we need to ensure we're not currently in the middle of a call to `dlopen`, or in the middle of a call to `malloc`, etc. To work around this, we set a handful of breakpoints for known safe (probably) places to call into our custom code, and load and call it only when the breakpoint is hit. Add 2 new breakpoints to our gdb script, on `PyCallable_Check` and `PyError_CheckSignals`. Also, use `Py_AddPendingCall` to schedule a call to `PyCallable_Check` on the main thread, in the hopes of triggering one of our breakpoints to happen sooner. For now, apply this only to our gdb script, and not to our lldb script. Making the analogous changes to the lldb script results in lldb on Linux stopping at an already-deleted breakpoint, and I haven't figured out a workaround or fix for that yet. Signed-off-by: Matt Wozniski <[email protected]>
- Loading branch information