tools/perf/util/annotate-arch/annotate-x86.c
Source file repositories/reference/linux-study-clean/tools/perf/util/annotate-arch/annotate-x86.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/annotate-arch/annotate-x86.c- Extension
.c- Size
- 25474 bytes
- Lines
- 853
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
string.hlinux/compiler.hlinux/zalloc.hassert.hinttypes.h../annotate-data.h../debug.h../disasm.h../dso.h../map.h../string2.h../symbol.h
Detected Declarations
function amd__ins_is_fusedfunction strstartsfunction intel__ins_is_fusedfunction x86__cpuid_parsefunction invalidate_reg_statefunction update_insn_state_x86function dwarf_tag
Annotated Snippet
strstarts(ins1, "or") || strstarts(ins1, "xor"))) {
return true;
}
return false;
}
static bool intel__ins_is_fused(const struct arch *arch, const char *ins1,
const char *ins2)
{
if (arch->family != 6 || arch->model < 0x1e || strstr(ins2, "jmp"))
return false;
if (arch->model == 0x1e) {
/* Nehalem */
if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
strstr(ins1, "test")) {
return true;
}
} else {
/* Newer platform */
if ((strstr(ins1, "cmp") && !strstr(ins1, "xchg")) ||
strstr(ins1, "test") ||
strstr(ins1, "add") ||
strstr(ins1, "sub") ||
strstr(ins1, "and") ||
strstr(ins1, "inc") ||
strstr(ins1, "dec")) {
return true;
}
}
return false;
}
static int x86__cpuid_parse(struct arch *arch, const char *cpuid)
{
unsigned int family, model, stepping;
int ret;
/*
* cpuid = "GenuineIntel,family,model,stepping"
*/
ret = sscanf(cpuid, "%*[^,],%u,%u,%u", &family, &model, &stepping);
if (ret == 3) {
arch->family = family;
arch->model = model;
arch->ins_is_fused = strstarts(cpuid, "AuthenticAMD") ?
amd__ins_is_fused :
intel__ins_is_fused;
return 0;
}
return -1;
}
#ifdef HAVE_LIBDW_SUPPORT
static void invalidate_reg_state(struct type_state_reg *reg)
{
reg->kind = TSR_KIND_INVALID;
reg->ok = false;
reg->lifetime_active = false;
reg->lifetime_end = 0;
reg->copied_from = -1;
}
static void update_insn_state_x86(struct type_state *state,
struct data_loc_info *dloc, Dwarf_Die *cu_die,
struct disasm_line *dl)
{
struct annotated_insn_loc loc;
struct annotated_op_loc *src = &loc.ops[INSN_OP_SOURCE];
struct annotated_op_loc *dst = &loc.ops[INSN_OP_TARGET];
struct type_state_reg *tsr;
Dwarf_Die type_die;
u32 insn_offset = dl->al.offset;
int fbreg = dloc->fbreg;
int fboff = 0;
if (annotate_get_insn_location(dloc->arch, dl, &loc) < 0)
return;
if (ins__is_call(&dl->ins)) {
struct symbol *func = dl->ops.target.sym;
const char *call_name;
u64 call_addr;
/* Try to resolve the call target name */
if (func)
call_name = func->name;
Annotation
- Immediate include surface: `string.h`, `linux/compiler.h`, `linux/zalloc.h`, `assert.h`, `inttypes.h`, `../annotate-data.h`, `../debug.h`, `../disasm.h`.
- Detected declarations: `function amd__ins_is_fused`, `function strstarts`, `function intel__ins_is_fused`, `function x86__cpuid_parse`, `function invalidate_reg_state`, `function update_insn_state_x86`, `function dwarf_tag`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.