Skip to main content

ptracer – a library for ptrace-based tracing of Python programs

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.

Metadata

Release files for ptracer 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ptracer 0.6.1
File Size Uploaded Provenance
ptracer-0.6.1.tar.gz 33.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ptracer 0.6.1
File Interpreter ABI Platform
ptracer-0.6.1-cp39-cp39-macosx_12_0_arm64.whl CPython 3.9 CPython 3.9 macOS 12.0+ ARM64 Details

Total release size: 72.5 kB

Release files / ptracer-0.6.1.tar.gz

Download URL ptracer-0.6.1.tar.gz
Size 33.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c5ea2fa289d25e8c2f5e17bbfce73e83768b1cabd691691dd5c861a1a23d7370
BLAKE2b-256 checksum
How to use checksums
cc501ae8d77481a026e0aaf3d2390798dc817eba0e2ffbef0dc96f3b22c0ef6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / ptracer-0.6.1-cp39-cp39-macosx_12_0_arm64.whl

Download URL ptracer-0.6.1-cp39-cp39-macosx_12_0_arm64.whl
Size 39.0 kB
Tags CPython 3.9 macOS 12.0+ ARM64
SHA-256 checksum
How to use checksums
bd71f235bb4bb842984eced02efb3baf9bf33911fadd015c13b253d407d9c725
BLAKE2b-256 checksum
How to use checksums
2e479bf3edb27e36bf6aa739e98c2e8301e8c0108a4fa3bf9b211a7023f1d7af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for ptracer 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page