find_data_type(9)
π find_data_type(9) β from the Kernel API Manual, bestie
Okay so real talk, this one's from the kernel API manual and it's genuinely iconic: find_data_type is the function that β¨findsβ¨ the data type sitting at a location. That's it. That's the whole vibe. Let's get into it π«Ά
πΈ NAME πΈ
find_data_type β returns a data type at the location π
β¨ SYNOPSIS β¨
struct annotated_data_type * find_data_type (struct data_loc_info *dloc );
That's the whole signature, no cap. Returns a struct annotated_data_type *, takes one struct data_loc_info * called dloc. Slay.
π ARGUMENTS π
dlocβ the data location, periodt. That's what you're passing in, and that's what it's gonna go dig through π
π¦ DESCRIPTION π¦
Okay so the way this works is so cute: the function goes searching through the debug information of the binary to figure out the data type it accesses. Like it's literally snooping through the debug info to find your type. Obsessed.
Now, how the location gets expressed depends on what you're pointing at:
- For pointer variables, the exact location is expressed by
(ip, reg, offset)β yes, all three, in that order π― - For global variables, it's expressed by
(ip, addr)β just the two, way simpler π
Heads up bestie: global variables might update dloc->type_offset after it finds the start of the variable. So like, don't be surprised if that field comes back with a lil glow-up π
And if it can't find a global variable by address? It'll try to find a declaration of the variable using var_name instead β main character problem-solving energy fr fr. In that case, dloc->offset won't be updated. Not a bug, just how it is π
It returns NULL if not found. That's the signal that it came up empty π
π₯ SEE ALSO π₯
- The kernel file
./tools/perf/util/annotate-data.cβ that's the source, go read it iykyk π update_var_state(9)update_insn_state(9)annotated_data_type__update_samples(9)
π that's the whole page, you ate it π
Cute lil sign-off: this one lives over in ./tools/perf/util, and it's dated October 2026. Bye bestie ππ¦β
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms