diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2016-11-18 18:06:43 -0500 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2017-04-26 10:35:12 -0400 |
commit | ac2faf23be3d7a87d131f7e7d3fe972676be333e (patch) | |
tree | 0a07c2ec92205ab5906b3594e2266aead868e3d1 | |
parent | f556063e3bee11c8bbbc02209c42669607711385 (diff) | |
download | trace-cmd-ac2faf23be3d7a87d131f7e7d3fe972676be333e.tar.gz |
trace-cmd: Move die() and friends out of event-utils.h and parse-utils.c
As event-utils.h and parse-utils.c are copies of the same files from the
Linux kernel source tree, move the die() funtions out of them as they no
longer exist in the kernel source.
Move the functions into trace-local.h. We need to update usage() of
kernel-shark because its prototype conflicts with the usage in
trace-local.h.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | event-utils.h | 5 | ||||
-rw-r--r-- | kernel-shark.c | 9 | ||||
-rw-r--r-- | parse-utils.c | 44 | ||||
-rw-r--r-- | trace-capture.c | 1 | ||||
-rw-r--r-- | trace-dialog.c | 1 | ||||
-rw-r--r-- | trace-input.c | 1 | ||||
-rw-r--r-- | trace-local.h | 6 | ||||
-rw-r--r-- | trace-plot-cpu.c | 1 | ||||
-rw-r--r-- | trace-plot-task.c | 1 | ||||
-rw-r--r-- | trace-plot.c | 1 | ||||
-rw-r--r-- | trace-util.c | 46 | ||||
-rw-r--r-- | trace-view.c | 1 | ||||
-rw-r--r-- | trace-xml.c | 1 |
13 files changed, 66 insertions, 52 deletions
diff --git a/event-utils.h b/event-utils.h index d7ea2cab..a8c8b6bc 100644 --- a/event-utils.h +++ b/event-utils.h @@ -22,21 +22,16 @@ #include <string.h> #include <ctype.h> -#include <stdarg.h> /* Can be overridden */ -void die(const char *fmt, ...); -void *malloc_or_die(unsigned int size); void warning(const char *fmt, ...); void pr_stat(const char *fmt, ...); void vpr_stat(const char *fmt, va_list ap); /* Always available */ -void __die(const char *fmt, ...); void __warning(const char *fmt, ...); void __pr_stat(const char *fmt, ...); -void __vdie(const char *fmt, ...); void __vwarning(const char *fmt, ...); void __vpr_stat(const char *fmt, ...); diff --git a/kernel-shark.c b/kernel-shark.c index a7a75a80..2198d204 100644 --- a/kernel-shark.c +++ b/kernel-shark.c @@ -34,6 +34,7 @@ #include "trace-compat.h" #include "trace-capture.h" #include "trace-cmd.h" +#include "trace-local.h" #include "trace-gui.h" #include "kernel-shark.h" #include "kshark-plugin.h" @@ -60,8 +61,10 @@ #define default_input_file "trace.dat" static char *input_file; -void usage(char *prog) +void usage(char **argv) { + char *prog = basename(argv[0]); + printf("Usage: %s\n", prog); printf(" -h Display this help message\n"); printf(" -v Display version and exit\n"); @@ -1891,7 +1894,7 @@ void kernel_shark(int argc, char **argv) while ((c = getopt(argc, argv, "hvi:p:")) != -1) { switch(c) { case 'h': - usage(basename(argv[0])); + usage(argv); return; case 'v': printf("%s - %s\n", @@ -1912,7 +1915,7 @@ void kernel_shark(int argc, char **argv) if ((argc - optind) >= 1) { if (input_file) - usage(basename(argv[0])); + usage(argv); input_file = argv[optind]; } diff --git a/parse-utils.c b/parse-utils.c index 90693915..844fda1c 100644 --- a/parse-utils.c +++ b/parse-utils.c @@ -6,40 +6,6 @@ #define __weak __attribute__((weak)) -void __vdie(const char *fmt, va_list ap) -{ - int ret = errno; - - if (errno) - perror("trace-cmd"); - else - ret = -1; - - fprintf(stderr, " "); - vfprintf(stderr, fmt, ap); - - fprintf(stderr, "\n"); - exit(ret); -} - -void __die(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - __vdie(fmt, ap); - va_end(ap); -} - -void __weak die(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - __vdie(fmt, ap); - va_end(ap); -} - void __vwarning(const char *fmt, va_list ap) { if (errno) @@ -93,13 +59,3 @@ void __weak pr_stat(const char *fmt, ...) __vpr_stat(fmt, ap); va_end(ap); } - -void __weak *malloc_or_die(unsigned int size) -{ - void *data; - - data = malloc(size); - if (!data) - die("malloc"); - return data; -} diff --git a/trace-capture.c b/trace-capture.c index 004f1d61..ced0e30d 100644 --- a/trace-capture.c +++ b/trace-capture.c @@ -37,6 +37,7 @@ #include "trace-cmd.h" #include "trace-gui.h" +#include "trace-local.h" #include "kernel-shark.h" #include "version.h" diff --git a/trace-dialog.c b/trace-dialog.c index 5447e767..5d3aabe9 100644 --- a/trace-dialog.c +++ b/trace-dialog.c @@ -28,6 +28,7 @@ #include "trace-compat.h" #include "trace-cmd.h" #include "trace-gui.h" +#include "trace-local.h" #define DIALOG_WIDTH 500 #define DIALOG_HEIGHT 550 diff --git a/trace-input.c b/trace-input.c index 6d7f62e7..eee581f3 100644 --- a/trace-input.c +++ b/trace-input.c @@ -37,6 +37,7 @@ #include <errno.h> #include "trace-cmd-local.h" +#include "trace-local.h" #include "kbuffer.h" #include "list.h" diff --git a/trace-local.h b/trace-local.h index a97dca6e..13d23a2c 100644 --- a/trace-local.h +++ b/trace-local.h @@ -187,4 +187,10 @@ void update_first_instance(struct buffer_instance *instance, int topt); void show_instance_file(struct buffer_instance *instance, const char *name); int count_cpus(void); +/* No longer in event-utils.h */ +void die(const char *fmt, ...); /* Can be overriden */ +void *malloc_or_die(unsigned int size); /* Can be overridden */ +void __die(const char *fmt, ...); +void __vdie(const char *fmt, ...); + #endif /* __TRACE_LOCAL_H */ diff --git a/trace-plot-cpu.c b/trace-plot-cpu.c index d83b595b..2a7d1a86 100644 --- a/trace-plot-cpu.c +++ b/trace-plot-cpu.c @@ -20,6 +20,7 @@ #include <string.h> #include "trace-graph.h" +#include "trace-local.h" #include "cpu.h" struct cpu_plot_info { diff --git a/trace-plot-task.c b/trace-plot-task.c index d810ebba..b333ce58 100644 --- a/trace-plot-task.c +++ b/trace-plot-task.c @@ -21,6 +21,7 @@ #include "trace-graph.h" #include "trace-filter.h" +#include "trace-local.h" #define RED 0xff #define GREEN (0xff<<16) diff --git a/trace-plot.c b/trace-plot.c index ac8cffd1..85a7a775 100644 --- a/trace-plot.c +++ b/trace-plot.c @@ -19,6 +19,7 @@ */ #include <string.h> #include "trace-graph.h" +#include "trace-local.h" void trace_graph_plot_free(struct graph_info *ginfo) { diff --git a/trace-util.c b/trace-util.c index 6a0818d3..40d0c295 100644 --- a/trace-util.c +++ b/trace-util.c @@ -1624,3 +1624,49 @@ void tracecmd_put_tracing_file(char *name) { free(name); } + +void __vdie(const char *fmt, va_list ap) +{ + int ret = errno; + + if (errno) + perror("trace-cmd"); + else + ret = -1; + + fprintf(stderr, " "); + vfprintf(stderr, fmt, ap); + + fprintf(stderr, "\n"); + exit(ret); +} + +void __die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + __vdie(fmt, ap); + va_end(ap); +} + +#define __weak __attribute__((weak)) + +void __weak die(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + __vdie(fmt, ap); + va_end(ap); +} + +void __weak *malloc_or_die(unsigned int size) +{ + void *data; + + data = malloc(size); + if (!data) + die("malloc"); + return data; +} diff --git a/trace-view.c b/trace-view.c index 2a5b1ad5..544698f0 100644 --- a/trace-view.c +++ b/trace-view.c @@ -30,6 +30,7 @@ #include "trace-compat.h" #include "cpu.h" #include "event-utils.h" +#include "trace-local.h" enum { COL_INDEX, diff --git a/trace-xml.c b/trace-xml.c index 6be53373..b11126a4 100644 --- a/trace-xml.c +++ b/trace-xml.c @@ -28,6 +28,7 @@ #include "trace-cmd.h" #include "trace-xml.h" +#include "trace-local.h" struct tracecmd_xml_handle { xmlTextWriterPtr writer; |