analyzer: give a dispatch site to the nearest function around it - #78
Open
kuba-moo wants to merge 1 commit into
Open
analyzer: give a dispatch site to the nearest function around it#78kuba-moo wants to merge 1 commit into
kuba-moo wants to merge 1 commit into
Conversation
const char *netdev_cmd_to_name(enum netdev_cmd cmd)
{
#define N(val) \
case NETDEV_##val: \
return "NETDEV_" __stringify(val);
switch (cmd) {
N(UP) N(DOWN) N(REBOOT) N(CHANGE) N(REGISTER) ...
net/core/dev.c ends at line 13325 and netdev_cmd_to_name ends at 1881, but
the database recorded that function as lines 1860 - 13325. A switch whose
case labels arrive from a macro invoked inside the body is one tree-sitter
cannot close, so the node runs to the end of the file and encloses every
function below it.
Sites and registrations were claimed while walking the file, first span to
cover one taking it, so that single body took all 49 dispatch sites in the
11,400 lines after it. can_rcv is registered in packet_type::func and
dispatched from deliver_skb and dev_queue_xmit_nit; asking who reaches it
answered netdev_cmd_to_name, a function that only stringifies notifier
commands, and the three real answers were not in the output at all.
Collect each function's extent instead and attribute afterwards, letting
the narrowest enclosing span claim the site. An unclosed body no longer
outranks the real function, and still answers where nothing narrower
encloses the site, which is what it should do for the sites genuinely
inside it. The receiver-type scope lookup chose among candidates the same
way and is fixed with it.
An empty caller name still means no function encloses the site, so a
file-scope ops table, a Python module-level call and a static initializer
are recorded as they were.
Indexing net/core/dev.c before and after: 55 dispatch sites and 174
registrations either way, with the ones in dev.c moving off
netdev_cmd_to_name onto deliver_skb, dev_queue_xmit_nit and
__netif_receive_skb_list_ptype.
Assisted-by: claw:claude-opus-5
Signed-off-by: Jakub Kicinski <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
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.
net/core/dev.c ends at line 13325 and netdev_cmd_to_name ends at 1881, but the database recorded that function as lines 1860 - 13325. A switch whose case labels arrive from a macro invoked inside the body is one tree-sitter cannot close, so the node runs to the end of the file and encloses every function below it.
Sites and registrations were claimed while walking the file, first span to cover one taking it, so that single body took all 49 dispatch sites in the 11,400 lines after it. can_rcv is registered in packet_type::func and dispatched from deliver_skb and dev_queue_xmit_nit; asking who reaches it answered netdev_cmd_to_name, a function that only stringifies notifier commands, and the three real answers were not in the output at all.
Collect each function's extent instead and attribute afterwards, letting the narrowest enclosing span claim the site. An unclosed body no longer outranks the real function, and still answers where nothing narrower encloses the site, which is what it should do for the sites genuinely inside it. The receiver-type scope lookup chose among candidates the same way and is fixed with it.
An empty caller name still means no function encloses the site, so a file-scope ops table, a Python module-level call and a static initializer are recorded as they were.
Indexing net/core/dev.c before and after: 55 dispatch sites and 174 registrations either way, with the ones in dev.c moving off netdev_cmd_to_name onto deliver_skb, dev_queue_xmit_nit and __netif_receive_skb_list_ptype.
Assisted-by: claw:claude-opus-5