tools/perf/util/debug.c
Source file repositories/reference/linux-study-clean/tools/perf/util/debug.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/debug.c- Extension
.c- Size
- 8267 bytes
- Lines
- 381
- 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
inttypes.hstring.hstdarg.hstdio.hstdlib.hsys/wait.hapi/debug.hlinux/kernel.hlinux/time64.hsys/time.hexecinfo.haddr_location.hcolor.hdebug.henv.hevent.hmachine.hmap.hprint_binary.hsrcline.hsymbol.hsynthetic-events.htarget.hthread.htrace-event.hui/helpline.hui/ui.hutil/parse-sublevel-options.hlinux/ctype.hevent-parse.h
Detected Declarations
function debug_set_filefunction debug_set_display_timefunction fprintf_timefunction veprintffunction eprintffunction veprintf_timefunction eprintf_timefunction pr_statfunction dump_printffunction trace_event_printerfunction trace_eventfunction perf_debug_optionfunction perf_quiet_optionfunction perf_debug_setupfunction __dump_stackfunction dump_stackfunction dump_stack
Annotated Snippet
if (use_browser >= 1 && !redirect_to_stderr) {
ui_helpline__vshow(fmt, args);
} else {
ret = fprintf_time(debug_file());
ret += vfprintf(debug_file(), fmt, args);
}
}
return ret;
}
int eprintf(int level, int var, const char *fmt, ...)
{
va_list args;
int ret;
va_start(args, fmt);
ret = veprintf(level, var, fmt, args);
va_end(args);
return ret;
}
static int veprintf_time(u64 t, const char *fmt, va_list args)
{
int ret = 0;
u64 secs, usecs, nsecs = t;
secs = nsecs / NSEC_PER_SEC;
nsecs -= secs * NSEC_PER_SEC;
usecs = nsecs / NSEC_PER_USEC;
ret = fprintf(debug_file(), "[%13" PRIu64 ".%06" PRIu64 "] ", secs, usecs);
ret += vfprintf(debug_file(), fmt, args);
return ret;
}
int eprintf_time(int level, int var, u64 t, const char *fmt, ...)
{
int ret = 0;
va_list args;
if (var >= level) {
va_start(args, fmt);
ret = veprintf_time(t, fmt, args);
va_end(args);
}
return ret;
}
/*
* Overloading libtraceevent standard info print
* function, display with -v in perf.
*/
void pr_stat(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
veprintf(1, verbose, fmt, args);
va_end(args);
eprintf(1, verbose, "\n");
}
int dump_printf(const char *fmt, ...)
{
va_list args;
int ret = 0;
if (dump_trace) {
va_start(args, fmt);
ret = vprintf(fmt, args);
va_end(args);
}
return ret;
}
static int trace_event_printer(enum binary_printer_ops op,
unsigned int val, void *extra, FILE *fp)
{
const char *color = PERF_COLOR_BLUE;
union perf_event *event = (union perf_event *)extra;
unsigned char ch = (unsigned char)val;
int printed = 0;
switch (op) {
case BINARY_PRINT_DATA_BEGIN:
printed += fprintf(fp, ".");
Annotation
- Immediate include surface: `inttypes.h`, `string.h`, `stdarg.h`, `stdio.h`, `stdlib.h`, `sys/wait.h`, `api/debug.h`, `linux/kernel.h`.
- Detected declarations: `function debug_set_file`, `function debug_set_display_time`, `function fprintf_time`, `function veprintf`, `function eprintf`, `function veprintf_time`, `function eprintf_time`, `function pr_stat`, `function dump_printf`, `function trace_event_printer`.
- 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.