tools/perf/builtin-help.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-help.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-help.c- Extension
.c- Size
- 14054 bytes
- Lines
- 541
- 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
util/cache.hutil/config.hutil/strbuf.hbuiltin.hsubcmd/exec-cmd.hsubcmd/parse-options.hsubcmd/run-command.hsubcmd/help.hutil/debug.hutil/util.hlinux/kernel.hlinux/string.hlinux/zalloc.herrno.hlimits.hstdio.hstdlib.hstring.hsys/types.hsys/stat.hunistd.h
Detected Declarations
enum help_formatfunction parse_help_formatfunction check_emacsclient_versionfunction exec_failedfunction exec_woman_emacsfunction exec_man_konquerorfunction exec_man_manfunction exec_man_cmdfunction add_man_viewerfunction supported_man_viewerfunction do_add_man_viewer_infofunction unsupported_man_viewerfunction add_man_viewer_pathfunction add_man_viewer_cmdfunction add_man_viewer_infofunction perf_help_configfunction list_common_cmds_helpfunction setup_man_pathfunction exec_viewerfunction show_man_pagefunction show_info_pagefunction get_html_page_pathfunction open_htmlfunction show_html_pagefunction cmd_help
Annotated Snippet
if (asprintf(&man_page, "(woman \"%s\")", page) > 0) {
execlp(path, "emacsclient", "-e", man_page, NULL);
free(man_page);
}
exec_failed(path);
}
}
static void exec_man_konqueror(const char *path, const char *page)
{
const char *display = getenv("DISPLAY");
if (display && *display) {
char *man_page;
const char *filename = "kfmclient";
/* It's simpler to launch konqueror using kfmclient. */
if (path) {
const char *file = strrchr(path, '/');
if (file && !strcmp(file + 1, "konqueror")) {
char *new = strdup(path);
char *dest = strrchr(new, '/');
/* strlen("konqueror") == strlen("kfmclient") */
strcpy(dest + 1, "kfmclient");
path = new;
}
if (file)
filename = file;
} else
path = "kfmclient";
if (asprintf(&man_page, "man:%s(1)", page) > 0) {
execlp(path, filename, "newTab", man_page, NULL);
free(man_page);
}
exec_failed(path);
}
}
static void exec_man_man(const char *path, const char *page)
{
if (!path)
path = "man";
execlp(path, "man", page, NULL);
exec_failed(path);
}
static void exec_man_cmd(const char *cmd, const char *page)
{
char *shell_cmd;
if (asprintf(&shell_cmd, "%s %s", cmd, page) > 0) {
execl("/bin/sh", "sh", "-c", shell_cmd, NULL);
free(shell_cmd);
}
exec_failed(cmd);
}
static void add_man_viewer(const char *name)
{
struct man_viewer_list **p = &man_viewer_list;
size_t len = strlen(name);
while (*p)
p = &((*p)->next);
*p = zalloc(sizeof(**p) + len + 1);
strcpy((*p)->name, name);
}
static int supported_man_viewer(const char *name, size_t len)
{
return (!strncasecmp("man", name, len) ||
!strncasecmp("woman", name, len) ||
!strncasecmp("konqueror", name, len));
}
static void do_add_man_viewer_info(const char *name,
size_t len,
const char *value)
{
struct man_viewer_info_list *new = zalloc(sizeof(*new) + len + 1);
strncpy(new->name, name, len);
new->info = strdup(value);
new->next = man_viewer_info_list;
man_viewer_info_list = new;
}
static void unsupported_man_viewer(const char *name, const char *var)
{
Annotation
- Immediate include surface: `util/cache.h`, `util/config.h`, `util/strbuf.h`, `builtin.h`, `subcmd/exec-cmd.h`, `subcmd/parse-options.h`, `subcmd/run-command.h`, `subcmd/help.h`.
- Detected declarations: `enum help_format`, `function parse_help_format`, `function check_emacsclient_version`, `function exec_failed`, `function exec_woman_emacs`, `function exec_man_konqueror`, `function exec_man_man`, `function exec_man_cmd`, `function add_man_viewer`, `function supported_man_viewer`.
- 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.