tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
Source file repositories/reference/linux-study-clean/tools/perf/util/arm-spe-decoder/arm-spe-decoder.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/arm-spe-decoder/arm-spe-decoder.c- Extension
.c- Size
- 8571 bytes
- Lines
- 302
- 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
errno.hinttypes.hstdbool.hstring.hstdint.hstdlib.hlinux/bitops.hlinux/compiler.hlinux/zalloc.h../auxtrace.h../debug.h../util.harm-spe-decoder.h
Detected Declarations
function arm_spe_calc_ipfunction arm_spe_decoder_freefunction arm_spe_get_datafunction arm_spe_get_next_packetfunction arm_spe_read_recordfunction arm_spe_decode
Annotated Snippet
if (!(seen_idx & BIT(index))) {
seen_idx |= BIT(index);
pr_warning("ignoring unsupported address packet index: 0x%x\n", index);
}
}
return payload;
}
struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params)
{
struct arm_spe_decoder *decoder;
if (!params->get_trace)
return NULL;
decoder = zalloc(sizeof(struct arm_spe_decoder));
if (!decoder)
return NULL;
decoder->get_trace = params->get_trace;
decoder->data = params->data;
return decoder;
}
void arm_spe_decoder_free(struct arm_spe_decoder *decoder)
{
free(decoder);
}
static int arm_spe_get_data(struct arm_spe_decoder *decoder)
{
struct arm_spe_buffer buffer = { .buf = 0, };
int ret;
pr_debug("Getting more data\n");
ret = decoder->get_trace(&buffer, decoder->data);
if (ret < 0)
return ret;
decoder->buf = buffer.buf;
decoder->len = buffer.len;
if (!decoder->len)
pr_debug("No more data\n");
return decoder->len;
}
static int arm_spe_get_next_packet(struct arm_spe_decoder *decoder)
{
int ret;
do {
if (!decoder->len) {
ret = arm_spe_get_data(decoder);
/* Failed to read out trace data */
if (ret <= 0)
return ret;
}
ret = arm_spe_get_packet(decoder->buf, decoder->len,
&decoder->packet);
if (ret <= 0) {
/* Move forward for 1 byte */
decoder->buf += 1;
decoder->len -= 1;
return -EBADMSG;
}
decoder->buf += ret;
decoder->len -= ret;
} while (decoder->packet.type == ARM_SPE_PAD);
return 1;
}
static int arm_spe_read_record(struct arm_spe_decoder *decoder)
{
int err;
int idx;
u64 payload, ip;
memset(&decoder->record, 0x0, sizeof(decoder->record));
decoder->record.context_id = (u64)-1;
while (1) {
err = arm_spe_get_next_packet(decoder);
Annotation
- Immediate include surface: `errno.h`, `inttypes.h`, `stdbool.h`, `string.h`, `stdint.h`, `stdlib.h`, `linux/bitops.h`, `linux/compiler.h`.
- Detected declarations: `function arm_spe_calc_ip`, `function arm_spe_decoder_free`, `function arm_spe_get_data`, `function arm_spe_get_next_packet`, `function arm_spe_read_record`, `function arm_spe_decode`.
- 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.