Rewrite init_attach_ctx_from_handlers, so we can use a more robust method to instantiate handlers. In the new implementation, we scan all allocated handlers from index zero, instantiate all handlers that we meet. If we encounter a bpf_link_handler, we just recursively instantiate its program and perf event
Instantiation of a bpf program is to setup the virtual machine; Instantiation of a perf event is to setup the private data of the corresponding attach type; Instantiation of a bpf link is to invoke the corresponding attach implementation and create the attach.
Use bpf_link_handler to record all attaches. Public APIs are kept untouched. After this, it would be more convenient to manage attach-related data, such as attach cookie, since we could store it in the bpf_link_handler
Adapt unit tests & bpftime_shm_json for bpf_link_handler. In the previous implementation they store perf event fds in prog_handler.
Update the structure of bpf_perf_event_handler, use variant to store data of different perf event types. After this, more memory could be saved, and it make the structure of bpf_perf_event_handler more clear, since there will only be one type of data stored in the same perf event handler.
Remove the dependency to attach parts for runtime. In the previous implementation, runtime depends on frida attach impl to resolve function address. Now, such process were moved to frida_attach_private_data, and expose a general string-based interface to solve the problem Where to attach?
Allow attach impl to register bpf helpers, so that frida uprobe impl could register helpers like bpf_get_retval which requires frida
This PR doesn't include:
Full support for dynamically registered attach impls. We need to find out a suitable way to collect attach-specified arguments (e.g If we have a Nginx url handler attach impl, the argument could be which urls should be filtered out) from the user. We need a way to collect such arguments from user, and pass them to the instantiation of bpf links. Other things for dynamically registered attach impls are already done.
Closes #234 Closes #230
This PR includes:
init_attach_ctx_from_handlers
, so we can use a more robust method to instantiate handlers. In the new implementation, we scan all allocated handlers from index zero, instantiate all handlers that we meet. If we encounter a bpf_link_handler, we just recursively instantiate its program and perf eventWhere to attach?
bpf_get_retval
which requires fridaThis PR doesn't include: