@@ -27,9 +27,6 @@
#define TSCNSEC_CLOCK "tsc2nsec"
-void tracecmd_parse_cmdlines(struct tep_handle *pevent, char *file, int size);
-void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
-void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep, int flags);
int *tracecmd_add_id(int *list, int id, int len);
@@ -743,7 +743,7 @@ static int read_proc_kallsyms(struct tracecmd_input *handle)
}
buf[size] = 0;
- tracecmd_parse_proc_kallsyms(pevent, buf, size);
+ tep_parse_kallsyms(pevent, buf);
free(buf);
@@ -775,7 +775,7 @@ static int read_ftrace_printk(struct tracecmd_input *handle)
buf[size] = 0;
- tracecmd_parse_ftrace_printk(handle->pevent, buf, size);
+ tep_parse_printk_formats(handle->pevent, buf);
free(buf);
@@ -2970,7 +2970,7 @@ static int read_and_parse_cmdlines(struct tracecmd_input *handle)
if (read_data_and_size(handle, &cmdlines, &size) < 0)
return -1;
cmdlines[size] = 0;
- tracecmd_parse_cmdlines(pevent, cmdlines, size);
+ tep_parse_saved_cmdlines(pevent, cmdlines);
free(cmdlines);
handle->file_state = TRACECMD_FILE_CMD_LINES;
@@ -103,97 +103,6 @@ bool tracecmd_get_debug(void)
return debug;
}
-void tracecmd_parse_cmdlines(struct tep_handle *pevent,
- char *file, int size __maybe_unused)
-{
- char *comm;
- char *line;
- char *next = NULL;
- int pid;
-
- line = strtok_r(file, "\n", &next);
- while (line) {
- sscanf(line, "%d %m[^\n]s", &pid, &comm);
- tep_register_comm(pevent, comm, pid);
- free(comm);
- line = strtok_r(NULL, "\n", &next);
- }
-}
-
-void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent,
- char *file, unsigned int size __maybe_unused)
-{
- unsigned long long addr;
- char *func;
- char *line;
- char *next = NULL;
- char *mod;
- char ch;
-
- line = strtok_r(file, "\n", &next);
- while (line) {
- int func_start, func_end = 0;
- int mod_start, mod_end = 0;
- int n;
-
- mod = NULL;
- errno = 0;
- n = sscanf(line, "%16llx %c %n%*s%n%*1[\t][%n%*s%n",
- &addr, &ch, &func_start, &func_end, &mod_start, &mod_end);
- if (errno) {
- perror("sscanf");
- return;
- }
-
- if (n != 2 || !func_end)
- return;
-
- func = line + func_start;
- /*
- * Hacks for
- * - arm arch that adds a lot of bogus '$a' functions
- * - x86-64 that reports per-cpu variable offsets as absolute
- */
- if (func[0] != '$' && ch != 'A' && ch != 'a') {
- line[func_end] = 0;
- if (mod_end) {
- mod = line + mod_start;
- /* truncate the extra ']' */
- line[mod_end - 1] = 0;
- }
- tep_register_function(pevent, func, addr, mod);
- }
-
- line = strtok_r(NULL, "\n", &next);
- }
-}
-
-void tracecmd_parse_ftrace_printk(struct tep_handle *pevent,
- char *file, unsigned int size __maybe_unused)
-{
- unsigned long long addr;
- char *printk;
- char *line;
- char *next = NULL;
- char *addr_str;
- char *fmt;
-
- line = strtok_r(file, "\n", &next);
- while (line) {
- addr_str = strtok_r(line, ":", &fmt);
- if (!addr_str) {
- warning("printk format with empty entry");
- break;
- }
- addr = strtoull(addr_str, NULL, 16);
- /* fmt still has a space, skip it */
- printk = strdup(fmt+1);
- line = strtok_r(NULL, "\n", &next);
- tep_register_print_string(pevent, printk, addr);
- free(printk);
- }
-}
-
/**
* tracecmd_add_id - add an int to the event id list
* @list: list to add the id to
@@ -1413,12 +1413,13 @@ static void add_functions(struct tep_handle *pevent, const char *file)
if (ret < 0)
die("Can't stat file %s", file);
- buf = malloc(st.st_size);
+ buf = malloc(st.st_size + 1);
if (!buf)
die("Failed to allocate for function buffer");
read_file_fd(fd, buf, st.st_size);
+ buf[st.st_size] = '\0';
close(fd);
- tracecmd_parse_proc_kallsyms(pevent, buf, st.st_size);
+ tep_parse_kallsyms(pevent, buf);
free(buf);
}