Skip to contentSkip to conversation

trace-cmd: Use libtraceevent for parsing tracefs files

PATCH New Steven Rostedt 1 participant 1 message Apr 8, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: Use libtraceevent for parsing tracefs files

From: "Steven Rostedt (VMware)" <[email protected]>

Now that libtraceevent has the functionality to parse and load the mappings of kallsyms, saved_cmdlines and printk_formats, use them instead of having the functionality in libtracecmd.

---
 .../include/private/trace-cmd-private.h       |  3 -
 lib/trace-cmd/trace-input.c                   |  6 +-
 lib/trace-cmd/trace-util.c                    | 91 -------------------
 tracecmd/trace-read.c                         |  5 +-
 4 files changed, 6 insertions(+), 99 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +0 -3
index 2673990a..42e739fa 100644
@@ -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);
lib/trace-cmd/trace-input.c +3 -3
index 7b25e92c..f36793e8 100644
@@ -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;
lib/trace-cmd/trace-util.c +0 -91

97 lines not on this page · raw message

tracecmd/trace-read.c +3 -2
index 1b99db1d..d962b671 100644
@@ -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);
 }
 
Signature · 1 line
2.29.2