Skip to content

register ctx in the local_sym_tab with the type void * if no struct annotation is given - #94

Merged
varun-r-mallya merged 2 commits into
masterfrom
fix/probe-read-ctx-not-found
Aug 30, 2026
Merged

register ctx in the local_sym_tab with the type void * if no struct annotation is given#94
varun-r-mallya merged 2 commits into
masterfrom
fix/probe-read-ctx-not-found

Conversation

@r41k0u

@r41k0u r41k0u commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

r41k0u and others added 2 commits August 7, 2026 04:38
process_func_body only entered the context parameter into local_sym_tab
when its annotation was a vmlinux struct, so a program declared as
`def prog(ctx: c_void_p)` had no `ctx` symbol at all. Passing `ctx` to a
helper that takes a raw pointer -- probe_read(dst, size, ctx) -- failed
with "Variable 'ctx' not found in local symbol table".

Register the parameter for plain ctypes annotations too, keeping `var`
as None: that is the established sentinel meaning "this symbol is the
context parameter, read it from func.args[0]" (see
VmlinuxHandler.handle_vmlinux_struct_field). Metadata holds the
annotated Python type, mirroring the vmlinux branch.

Teach the consumer side accordingly: get_or_create_ptr_from_arg now
recognises the sentinel and hands back the function's first argument
instead of an alloca. The special case lives at the call site rather
than inside get_var_ptr_from_name so that helper stays a pure symbol
table lookup -- the call site already has `func` and `builder` in scope,
and get_var_ptr_from_name has no other callers to update.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
_allocate_for_attribute reached for `metadata.__name__` whenever the
base symbol was not a known user struct, but `metadata` is only a struct
class for struct-typed symbols. For a symbol carrying None (any plainly
typed local) or a ctypes class (a `c_void_p` context parameter), that
raised AttributeError instead of reporting the unsupported access.

Resolve the name via getattr and fall through to the existing
"struct type not found" diagnostic when there is none.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@varun-r-mallya
varun-r-mallya merged commit c4c0c58 into master Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants