register ctx in the local_sym_tab with the type void * if no struct annotation is given - #94
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.