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, `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. Signed-off-by: Matt Wozniski <[email protected]>
- Loading branch information