lkml.org 
[lkml]   [2017]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] trace-cmd: replace show_file() -> show_instance_file()
Date
show_file(name) and show_instance_file(&top_instance, name) are
equivalent.

Remove the show_file() function in order to have a single function for
this task.

Signed-off-by: Federico Vaga <federico.vaga@vaga.pv.it>
---
trace-list.c | 21 ++++++---------------
trace-local.h | 2 --
trace-show.c | 18 ++----------------
trace-snapshot.c | 2 +-
4 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/trace-list.c b/trace-list.c
index 32b19bc..933397f 100644
--- a/trace-list.c
+++ b/trace-list.c
@@ -59,15 +59,6 @@ enum {
};


-void show_file(const char *name)
-{
- char *path;
-
- path = tracecmd_get_tracing_file(name);
- dump_file_content(path);
- tracecmd_put_tracing_file(path);
-}
-
typedef int (*process_file_func)(char *buf, int len);

static void process_file_re(process_file_func func,
@@ -83,7 +74,7 @@ static void process_file_re(process_file_func func,

/* Just in case :-p */
if (!re || l == 0) {
- show_file(name);
+ show_instance_file( &top_instance, name);
return;
}

@@ -258,25 +249,25 @@ static void show_events(const char *eventre, int flags)
else
show_file_re("available_events", eventre);
} else
- show_file("available_events");
+ show_instance_file(&top_instance, "available_events");
}


static void show_tracers(void)
{
- show_file("available_tracers");
+ show_instance_file(&top_instance, "available_tracers");
}


static void show_options(void)
{
- show_file("trace_options");
+ show_instance_file(&top_instance, "trace_options");
}


static void show_clocks(void)
{
- show_file("trace_clock");
+ show_instance_file(&top_instance, "trace_clock");
}


@@ -285,7 +276,7 @@ static void show_functions(const char *funcre)
if (funcre)
show_file_re("available_filter_functions", funcre);
else
- show_file("available_filter_functions");
+ show_instance_file(&top_instance, "available_filter_functions");
}


diff --git a/trace-local.h b/trace-local.h
index fa987bc..0e4ce61 100644
--- a/trace-local.h
+++ b/trace-local.h
@@ -50,8 +50,6 @@ struct pid_record_data {
struct pevent_record *record;
};

-void show_file(const char *name);
-
struct tracecmd_input *read_trace_header(const char *file);
int read_trace_files(void);

diff --git a/trace-show.c b/trace-show.c
index f13db31..7d5a805 100644
--- a/trace-show.c
+++ b/trace-show.c
@@ -38,12 +38,10 @@ enum {

void trace_show(int argc, char **argv)
{
- const char *buffer = NULL;
const char *file = "trace";
const char *cpu = NULL;
struct buffer_instance *instance = &top_instance;
char cpu_path[128];
- char *path;
int snap = 0;
int pipe = 0;
int show_name = 0;
@@ -72,9 +70,8 @@ void trace_show(int argc, char **argv)
usage(argv);
break;
case 'B':
- if (buffer)
+ if (instance != &top_instance)
die("Can only show one buffer at a time");
- buffer = optarg;
instance = create_instance(optarg);
if (!instance)
die("Failed to create instance");
@@ -153,24 +150,13 @@ void trace_show(int argc, char **argv)
file = cpu_path;
}

- if (buffer) {
- int ret;
-
- ret = asprintf(&path, "instances/%s/%s", buffer, file);
- if (ret < 0)
- die("Failed to allocate instance path %s", file);
- file = path;
- }
-
if (show_name) {
char *name;
name = tracecmd_get_tracing_file(file);
printf("%s\n", name);
tracecmd_put_tracing_file(name);
}
- show_file(file);
- if (buffer)
- free(path);
+ show_instance_file(instance, file);

return;
}
diff --git a/trace-snapshot.c b/trace-snapshot.c
index 771b065..1e11438 100644
--- a/trace-snapshot.c
+++ b/trace-snapshot.c
@@ -113,7 +113,7 @@ void trace_snapshot (int argc, char **argv)
tracecmd_put_tracing_file(name);

if (!reset_snap && !take_snap && !free_snap) {
- show_file(file);
+ show_instance_file(&top_instance, file);
exit(0);
}

--
2.9.4
\
 
 \ /
  Last update: 2017-06-05 11:39    [W:0.083 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site