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