tools/perf/scripts/python/Perf-Trace-Util/Context.c
Source file repositories/reference/linux-study-clean/tools/perf/scripts/python/Perf-Trace-Util/Context.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/scripts/python/Perf-Trace-Util/Context.c- Extension
.c- Size
- 5832 bytes
- Lines
- 226
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
Python.h../../../util/config.h../../../util/trace-event.h../../../util/event.h../../../util/symbol.h../../../util/thread.h../../../util/map.h../../../util/maps.h../../../util/auxtrace.h../../../util/session.h../../../util/srcline.h../../../util/srccode.h
Detected Declarations
function PyInit_perf_trace_context
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Context.c. Python interfaces for perf script.
*
* Copyright (C) 2010 Tom Zanussi <tzanussi@gmail.com>
*/
/*
* Use Py_ssize_t for '#' formats to avoid DeprecationWarning: PY_SSIZE_T_CLEAN
* will be required for '#' formats.
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "../../../util/config.h"
#include "../../../util/trace-event.h"
#include "../../../util/event.h"
#include "../../../util/symbol.h"
#include "../../../util/thread.h"
#include "../../../util/map.h"
#include "../../../util/maps.h"
#include "../../../util/auxtrace.h"
#include "../../../util/session.h"
#include "../../../util/srcline.h"
#include "../../../util/srccode.h"
#define _PyCapsule_GetPointer(arg1, arg2) \
PyCapsule_GetPointer((arg1), (arg2))
#define _PyBytes_FromStringAndSize(arg1, arg2) \
PyBytes_FromStringAndSize((arg1), (arg2))
#define _PyUnicode_AsUTF8(arg) \
PyUnicode_AsUTF8(arg)
PyMODINIT_FUNC PyInit_perf_trace_context(void);
static struct scripting_context *get_args(PyObject *args, const char *name, PyObject **arg2)
{
int cnt = 1 + !!arg2;
PyObject *context;
if (!PyArg_UnpackTuple(args, name, 1, cnt, &context, arg2))
return NULL;
return _PyCapsule_GetPointer(context, NULL);
}
static struct scripting_context *get_scripting_context(PyObject *args)
{
return get_args(args, "context", NULL);
}
#ifdef HAVE_LIBTRACEEVENT
static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
{
struct scripting_context *c = get_scripting_context(args);
if (!c)
return NULL;
return Py_BuildValue("i", common_pc(c));
}
static PyObject *perf_trace_context_common_flags(PyObject *obj,
PyObject *args)
{
struct scripting_context *c = get_scripting_context(args);
if (!c)
return NULL;
return Py_BuildValue("i", common_flags(c));
}
static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
PyObject *args)
{
struct scripting_context *c = get_scripting_context(args);
if (!c)
return NULL;
return Py_BuildValue("i", common_lock_depth(c));
}
#endif
static PyObject *perf_sample_insn(PyObject *obj, PyObject *args)
{
struct scripting_context *c = get_scripting_context(args);
if (!c)
Annotation
- Immediate include surface: `Python.h`, `../../../util/config.h`, `../../../util/trace-event.h`, `../../../util/event.h`, `../../../util/symbol.h`, `../../../util/thread.h`, `../../../util/map.h`, `../../../util/maps.h`.
- Detected declarations: `function PyInit_perf_trace_context`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.