...
#include <event-parse.h>
#include <tracefs.h>
#include <stdlib.h>
int load_cmdlines(struct tep_handle *tep)
{
char *buf = NULL;
int r;
buf = tracefs_instance_file_read(NULL, "saved_cmdlines", NULL);
if (!buf)
return -1;
r = tep_parse_saved_cmdlines(tep, buf);
free(buf);
return r;
}
int load_print_strings(struct tep_handle *tep)
{
char *buf = NULL;
int r;
buf = tracefs_instance_file_read(NULL, "printk_formats", NULL);
if (!buf)
return -1;
r = tep_parse_printk_formats(tep, buf);
free(buf);
return r;
}
int load_kallsyms(struct tep_handle *tep)
{
char *line = NULL;
char *buf = NULL;
size_t sz = 0;
FILE *fp;
int len = 0;
int r;
fp = fopen("/proc/kallsyms", "r");
while ((r = getline(&line, &sz, fp)) >= 0) {
buf = realloc(buf, len + r + 1);
memcpy(buf + len, line, r);
len += r;
}
free(line);
fclose(fp);
if (!buf)
return -1;
buf[len] = 0;
r = tep_parse_kallsyms(tep, buf);
free(buf);
return r;
}
...