On-demand system call tracing for Python programs.
Project description
Ptracer is a library providing on-demand system call tracing in Python programs.
Basic Usage
import traceback
import ptracer
def callback(syscall):
print('{}({}) -> {}'.format(
syscall.name,
', '.join(repr(arg.value) for arg in syscall.args),
syscall.result.text))
print('Traceback: ')
print(''.join(traceback.format_list(syscall.traceback)))
with ptracer.context(callback):
open('/dev/null', 'wb')
Filtering
Ptracer allows elaborate syscall filtering via the filter argument:
flt = [
ptracer.SysCallPattern(
name='open',
args=[
re.compile(b'/tmp/.*'),
lambda arg: arg.value & os.O_WRONLY
],
result=lambda res: res.value > 0
)
]
with ptracer.context(callback, filter=flt):
# traced code
...
In the above example, ptracer will invoke the callback only for successful attempts to open files in the “/tmp” directory for writing.
Documentation
The documentation is available on ptracer.readthedocs.io.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ptracer-0.6.1.tar.gz.
File metadata
- Download URL: ptracer-0.6.1.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5ea2fa289d25e8c2f5e17bbfce73e83768b1cabd691691dd5c861a1a23d7370
|
|
| MD5 |
71df4db6e0cf848ca864585df8415db9
|
|
| BLAKE2b-256 |
cc501ae8d77481a026e0aaf3d2390798dc817eba0e2ffbef0dc96f3b22c0ef6d
|
File details
Details for the file ptracer-0.6.1-cp39-cp39-macosx_12_0_arm64.whl.
File metadata
- Download URL: ptracer-0.6.1-cp39-cp39-macosx_12_0_arm64.whl
- Upload date:
- Size: 39.0 kB
- Tags: CPython 3.9, macOS 12.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd71f235bb4bb842984eced02efb3baf9bf33911fadd015c13b253d407d9c725
|
|
| MD5 |
cfb9a718082d0e31b9e90c51ba662c4d
|
|
| BLAKE2b-256 |
2e479bf3edb27e36bf6aa739e98c2e8301e8c0108a4fa3bf9b211a7023f1d7af
|