tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
Source file repositories/reference/linux-study-clean/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c- Extension
.c- Size
- 18703 bytes
- Lines
- 792
- 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
stdio.hstring.hendian.hbyteswap.hlinux/kernel.hlinux/compiler.hlinux/unaligned.hintel-pt-pkt-decoder.h
Detected Declarations
function intel_pt_get_long_tntfunction intel_pt_get_pipfunction intel_pt_get_tracestopfunction intel_pt_get_cbrfunction intel_pt_get_vmcsfunction intel_pt_get_ovffunction intel_pt_get_psbfunction intel_pt_get_psbendfunction intel_pt_get_tmafunction intel_pt_get_padfunction intel_pt_get_mntfunction intel_pt_get_3bytefunction intel_pt_get_ptwritefunction intel_pt_get_exstopfunction intel_pt_get_exstop_ipfunction intel_pt_get_mwaitfunction intel_pt_get_pwrefunction intel_pt_get_pwrxfunction intel_pt_get_bbpfunction intel_pt_get_bip_4function intel_pt_get_bip_8function intel_pt_get_bepfunction intel_pt_get_bep_ipfunction intel_pt_get_cfefunction intel_pt_get_evdfunction intel_pt_get_extfunction intel_pt_get_short_tntfunction intel_pt_get_cycfunction intel_pt_get_ipfunction intel_pt_get_modefunction intel_pt_get_tscfunction intel_pt_get_mtcfunction intel_pt_do_get_packetfunction intel_pt_upd_pkt_ctxfunction intel_pt_get_packetfunction intel_pt_pkt_desc
Annotated Snippet
switch (buf[1] & 3) {
case 0:
packet->payload = 16;
break;
case 1:
packet->payload = 64;
break;
case 2:
packet->payload = 32;
break;
default:
return INTEL_PT_BAD_PACKET;
}
break;
case 1:
packet->type = INTEL_PT_MODE_TSX;
if ((buf[1] & 3) == 3)
return INTEL_PT_BAD_PACKET;
packet->payload = buf[1] & 3;
break;
default:
return INTEL_PT_BAD_PACKET;
}
return 2;
}
static int intel_pt_get_tsc(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 8)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_TSC;
memcpy_le64(&packet->payload, buf + 1, 7);
return 8;
}
static int intel_pt_get_mtc(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet)
{
if (len < 2)
return INTEL_PT_NEED_MORE_BYTES;
packet->type = INTEL_PT_MTC;
packet->payload = buf[1];
return 2;
}
static int intel_pt_do_get_packet(const unsigned char *buf, size_t len,
struct intel_pt_pkt *packet,
enum intel_pt_pkt_ctx ctx)
{
unsigned int byte;
memset(packet, 0, sizeof(struct intel_pt_pkt));
if (!len)
return INTEL_PT_NEED_MORE_BYTES;
byte = buf[0];
switch (ctx) {
case INTEL_PT_NO_CTX:
break;
case INTEL_PT_BLK_4_CTX:
if ((byte & 0x7) == 4)
return intel_pt_get_bip_4(buf, len, packet);
break;
case INTEL_PT_BLK_8_CTX:
if ((byte & 0x7) == 4)
return intel_pt_get_bip_8(buf, len, packet);
break;
default:
break;
}
if (!(byte & BIT(0))) {
if (byte == 0)
return intel_pt_get_pad(packet);
if (byte == 2)
return intel_pt_get_ext(buf, len, packet);
return intel_pt_get_short_tnt(byte, packet);
}
if ((byte & 2))
return intel_pt_get_cyc(byte, buf, len, packet);
switch (byte & 0x1f) {
case 0x0D:
return intel_pt_get_ip(INTEL_PT_TIP, byte, buf, len, packet);
case 0x11:
Annotation
- Immediate include surface: `stdio.h`, `string.h`, `endian.h`, `byteswap.h`, `linux/kernel.h`, `linux/compiler.h`, `linux/unaligned.h`, `intel-pt-pkt-decoder.h`.
- Detected declarations: `function intel_pt_get_long_tnt`, `function intel_pt_get_pip`, `function intel_pt_get_tracestop`, `function intel_pt_get_cbr`, `function intel_pt_get_vmcs`, `function intel_pt_get_ovf`, `function intel_pt_get_psb`, `function intel_pt_get_psbend`, `function intel_pt_get_tma`, `function intel_pt_get_pad`.
- 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.