1libtraceevent(3) 2================ 3 4NAME 5---- 6tep_parse_saved_cmdlines, tep_parse_printk_formats, tep_parse_kallsyms 7- Parsing functions to load mappings 8 9SYNOPSIS 10-------- 11[verse] 12-- 13*#include <event-parse.h>* 14 15int *tep_parse_saved_cmdlines*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 16int *tep_parse_printk_formats*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 17int *tep_parse_kallsyms*(struct tep_handle pass:[*]_tep_, const char pass:[*]_buf_); 18-- 19 20DESCRIPTION 21----------- 22*tep_parse_saved_cmdlines()* is a helper function to parse content in the tracefs 23file system of the "saved_cmdlines" file (stored in a string buffer passed in by _buf_) 24and loads the mapping of the process IDs (pid) to the comm names in the 25_tep_ handler. The events store the pid and this is used to be able to show the 26process names associated to those process ids. It parses the string _buf_ that 27holds the content of saved_cmdlines and ends with a nul character ('\0'). 28 29*tep_parse_printk_formats()* is a helper function to parse content in the tracefs 30file system of the "printk_formats" file (stored in a string buffer passed in by _buf_) 31and loads the mapping of addresses of strings that may be referenced by events. 32Events only store the address of constant strings in the kernel, and the mapping 33of their address to the string is exported to user space in the printk_formats 34file. It parses the string _buf_ that holds the content of printk_formats and 35ends with a nul character ('\0'). 36 37*tep_parse_kallsyms()* is a helper function to parse the Linux kernel /proc/kallsyms format 38(stored in a string buffer passed in by _buf_) and load the functions into the 39_tep_ handler such that function IP addresses can be mapped to their name when 40parsing events with %pS in the print format field. It parses the string _buf_ that 41holds the content of /proc/kallsyms and ends with a nul character ('\0'). 42 43RETURN VALUE 44------------ 45The *tep_parse_saved_cmdlines*() function returns 0 in case of success, or -1 46in case of an error. 47 48The *tep_parse_printk_formats*() function returns 0 in case of success, or -1 49in case of an error. 50 51The *tep_parse_kallsyms*() function returns 0 in case of success, or -1 52in case of an error. 53 54EXAMPLE 55------- 56[source,c] 57-- 58... 59#include <event-parse.h> 60#include <tracefs.h> 61#include <stdlib.h> 62 63int load_cmdlines(struct tep_handle *tep) 64{ 65 char *buf = NULL; 66 int r; 67 68 buf = tracefs_instance_file_read(NULL, "saved_cmdlines", NULL); 69 if (!buf) 70 return -1; 71 r = tep_parse_saved_cmdlines(tep, buf); 72 free(buf); 73 return r; 74} 75 76int load_print_strings(struct tep_handle *tep) 77{ 78 char *buf = NULL; 79 int r; 80 81 buf = tracefs_instance_file_read(NULL, "printk_formats", NULL); 82 if (!buf) 83 return -1; 84 r = tep_parse_printk_formats(tep, buf); 85 free(buf); 86 return r; 87} 88 89int load_kallsyms(struct tep_handle *tep) 90{ 91 char *line = NULL; 92 char *buf = NULL; 93 size_t sz = 0; 94 FILE *fp; 95 int len = 0; 96 int r; 97 98 fp = fopen("/proc/kallsyms", "r"); 99 while ((r = getline(&line, &sz, fp)) >= 0) { 100 buf = realloc(buf, len + r + 1); 101 memcpy(buf + len, line, r); 102 len += r; 103 } 104 free(line); 105 fclose(fp); 106 if (!buf) 107 return -1; 108 buf[len] = 0; 109 110 r = tep_parse_kallsyms(tep, buf); 111 free(buf); 112 return r; 113} 114... 115-- 116 117FILES 118----- 119[verse] 120-- 121*event-parse.h* 122 Header file to include in order to have access to the library APIs. 123*-ltraceevent* 124 Linker switch to add when building a program that uses the library. 125-- 126 127SEE ALSO 128-------- 129*libtraceevent*(3), *trace-cmd*(1), *tep_register_comm*(3), *tep_register_function*(3), 130*tep_register_print_string*(3) 131 132AUTHOR 133------ 134[verse] 135-- 136*Steven Rostedt* <[email protected]>, author of *libtraceevent*. 137*Tzvetomir Stoyanov* <[email protected]>, coauthor of *libtraceevent*. 138-- 139REPORTING BUGS 140-------------- 141Report bugs to <[email protected]> 142 143LICENSE 144------- 145libtraceevent is Free Software licensed under the GNU LGPL 2.1 146 147RESOURCES 148--------- 149https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/ 150