mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-02-07 21:50:55 +00:00
docs: Fix API reference
This commit is contained in:
@ -128,7 +128,7 @@ Decorator to mark a class as a BPF struct definition.
|
|||||||
def compile_to_ir(
|
def compile_to_ir(
|
||||||
filename: str,
|
filename: str,
|
||||||
output: str,
|
output: str,
|
||||||
loglevel=logging.INFO
|
loglevel=logging.WARNING
|
||||||
) -> None
|
) -> None
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ Compile Python source to LLVM Intermediate Representation.
|
|||||||
**Parameters:**
|
**Parameters:**
|
||||||
* `filename` (str) - Path to the Python source file
|
* `filename` (str) - Path to the Python source file
|
||||||
* `output` (str) - Path for the output LLVM IR file (.ll)
|
* `output` (str) - Path for the output LLVM IR file (.ll)
|
||||||
* `loglevel` - Logging level (default: logging.INFO)
|
* `loglevel` - Logging level (default: logging.WARNING)
|
||||||
|
|
||||||
**See also:** {doc}`../user-guide/compilation`
|
**See also:** {doc}`../user-guide/compilation`
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ Compile Python source to LLVM Intermediate Representation.
|
|||||||
def compile(
|
def compile(
|
||||||
filename: str = None,
|
filename: str = None,
|
||||||
output: str = None,
|
output: str = None,
|
||||||
loglevel=logging.INFO
|
loglevel=logging.WARNING
|
||||||
) -> None
|
) -> None
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ Compile Python source to BPF object file.
|
|||||||
**Parameters:**
|
**Parameters:**
|
||||||
* `filename` (str, optional) - Path to the Python source file (default: calling file)
|
* `filename` (str, optional) - Path to the Python source file (default: calling file)
|
||||||
* `output` (str, optional) - Path for the output object file (default: same name with .o extension)
|
* `output` (str, optional) - Path for the output object file (default: same name with .o extension)
|
||||||
* `loglevel` - Logging level (default: logging.INFO)
|
* `loglevel` - Logging level (default: logging.WARNING)
|
||||||
|
|
||||||
**See also:** {doc}`../user-guide/compilation`
|
**See also:** {doc}`../user-guide/compilation`
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ class BPF:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
filename: str = None,
|
filename: str = None,
|
||||||
loglevel=logging.INFO
|
loglevel=logging.WARNING
|
||||||
)
|
)
|
||||||
|
|
||||||
def load(self) -> BpfObject
|
def load(self) -> BpfObject
|
||||||
@ -179,7 +179,7 @@ High-level interface to compile, load, and attach BPF programs.
|
|||||||
|
|
||||||
**Parameters:**
|
**Parameters:**
|
||||||
* `filename` (str, optional) - Path to Python source file (default: calling file)
|
* `filename` (str, optional) - Path to Python source file (default: calling file)
|
||||||
* `loglevel` - Logging level (default: logging.INFO)
|
* `loglevel` - Logging level (default: logging.WARNING)
|
||||||
|
|
||||||
**Methods:**
|
**Methods:**
|
||||||
* `load()` - Load the compiled BPF program into the kernel
|
* `load()` - Load the compiled BPF program into the kernel
|
||||||
@ -255,7 +255,7 @@ class HashMap:
|
|||||||
Hash map for efficient key-value storage.
|
Hash map for efficient key-value storage.
|
||||||
|
|
||||||
**Parameters:**
|
**Parameters:**
|
||||||
* `key` - The type of the key (ctypes type)
|
* `key` - The type of the key (ctypes type or struct)
|
||||||
* `value` - The type of the value (ctypes type or struct)
|
* `value` - The type of the value (ctypes type or struct)
|
||||||
* `max_entries` (int) - Maximum number of entries
|
* `max_entries` (int) - Maximum number of entries
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ from ctypes import c_void_p, c_int64
|
|||||||
@section("tracepoint/syscalls/sys_enter_execve")
|
@section("tracepoint/syscalls/sys_enter_execve")
|
||||||
def hello(ctx: c_void_p) -> c_int64:
|
def hello(ctx: c_void_p) -> c_int64:
|
||||||
print("Hello, World!")
|
print("Hello, World!")
|
||||||
return c_int64(0)
|
return 0
|
||||||
|
|
||||||
@bpf
|
@bpf
|
||||||
@bpfglobal
|
@bpfglobal
|
||||||
@ -411,9 +411,9 @@ def count_clones(ctx: c_void_p) -> c_int64:
|
|||||||
if count:
|
if count:
|
||||||
counters.update(process_id, count + 1)
|
counters.update(process_id, count + 1)
|
||||||
else:
|
else:
|
||||||
counters.update(process_id, c_uint64(1))
|
counters.update(process_id, 1)
|
||||||
|
|
||||||
return c_int64(0)
|
return 0
|
||||||
|
|
||||||
@bpf
|
@bpf
|
||||||
@bpfglobal
|
@bpfglobal
|
||||||
@ -450,11 +450,10 @@ def track_exec(ctx: c_void_p) -> c_int64:
|
|||||||
event = Event()
|
event = Event()
|
||||||
event.timestamp = ktime()
|
event.timestamp = ktime()
|
||||||
event.pid = pid()
|
event.pid = pid()
|
||||||
# Note: comm() requires a buffer parameter
|
comm(event.comm)
|
||||||
# comm(event.comm) # Fills event.comm with process name
|
|
||||||
|
|
||||||
events.output(event)
|
events.output(event)
|
||||||
return c_int64(0)
|
return 0
|
||||||
|
|
||||||
@bpf
|
@bpf
|
||||||
@bpfglobal
|
@bpfglobal
|
||||||
|
|||||||
Reference in New Issue
Block a user