Refactor APIs for creating output handler
cover Refactor APIs for creating output handler
In the trace-cmd library there are various APIs for allocating and initializing output handler to a trace file. The existing APIs are use case oriented, with a lot of parameters. Extending them for new use cases, adding more input parameters, will make the library more complex and not easy to use.
Almost all use case oriented APIs for output handler creation are removed and replaced with new flow, which is easier to be extended with new parameters.
Removed APIs:
tracecmd_create_init_fd_msg()
tracecmd_create_init_file_glob()
tracecmd_create_init_fd_glob()
tracecmd_create_init_file_override()
New APIs:
tracecmd_output_allocate()
tracecmd_output_set_msg()
tracecmd_output_set_trace_dir()
tracecmd_output_set_kallsyms()
tracecmd_output_set_from_input()
tracecmd_output_write_init()
tracecmd_output_write_headers()
The new tracecmd_output_allocate() API allocates memory and performs minimal initialization of an output handler to a trace file. No data is written in the file.
The tracecmd_output_set_...() APIs can be used to set various parameters to the newly allocated output handler, that affect the way the data is written into the file.
When the output handler is configured for the desired use case, the tracecmd_output_write_init() is used to start writing to the file, it writes initial magic bytes.
The tracecmd_output_write_headers() API is used to write the initial headers into the file.
This patch-set depends on "[PATCH v4 0/6] trace-cmd fixes and clean-ups", should be applied on top of it:
https://lore.kernel.org/linux-trace-devel/[email protected]/
Tzvetomir Stoyanov (VMware) (10):
trace-cmd library: New API for allocating an output handler trace-cmd library: New API for setting a message context to an output
handler
trace-cmd library: New API for setting a custom trace directory to an
output handler
trace-cmd library: New API for setting a custom kallsyms to an output
handler
trace-cmd library: New API to inherit parameters from an existing
trace file
trace-cmd library: New API tracecmd_output_write_init trace-cmd library: New API to write headers of a trace file trace-cmd library: Use the new flow when creating output handler
trace-cmd: Use the new flow when creating output handler trace-cmd library: Remove deprecated APIs for creating an output
handler
.../include/private/trace-cmd-private.h | 25 +- lib/trace-cmd/trace-output.c | 397 +++++++++++------- tracecmd/trace-record.c | 55 ++- tracecmd/trace-restore.c | 32 +- 4 files changed, 347 insertions(+), 162 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/10 trace-cmd library: New API for allocating an output handler
The API only allocates a handler and performs minimal initialization. No data is written in the file.
tracecmd_output_allocate()
--- .../include/private/trace-cmd-private.h | 4 ++- lib/trace-cmd/trace-output.c | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-)
lib/trace-cmd/include/private/trace-cmd-private.h +3 -1
@@ -102,7 +102,8 @@ static inline int tracecmd_host_bigendian(void)/* --- Opening and Reading the trace.dat file --- */ enum tracecmd_file_states { -TRACECMD_FILE_INIT =1 , +TRACECMD_FILE_ALLOCATED =0 , +TRACECMD_FILE_INIT ,TRACECMD_FILE_HEADERS ,TRACECMD_FILE_FTRACE_EVENTS ,TRACECMD_FILE_ALL_EVENTS ,
@@ -268,6 +269,7 @@ struct tracecmd_event_list {struct tracecmd_option ;struct tracecmd_msg_handle ; +struct tracecmd_output *tracecmd_output_allocate (int fd);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +36 -0
@@ -59,6 +59,7 @@ struct tracecmd_output {unsigned long file_state;unsigned long file_version;size_t options_start; +bool big_endian;struct list_head options;struct tracecmd_msg_handle *msg_handle;
@@ -883,6 +884,41 @@ out_free:return ret; } +/** +* tracecmd_output_allocate - allocate new output handler to a trace file +* @handle: file descriptor to an empty file, it can be -1 if the handler +* will not write to a file +* +* This API only allocates a handler and performs minimal initialization. +* No data is written in the file. +* +* Returns pointer to a newly allocated file descriptor, that can be used +* with other library APIs. In case of an error, NULL is returned. The returned +* handler must be freed with tracecmd_output_close() or tracecmd_output_free() +*/ +struct tracecmd_output *tracecmd_output_allocate (int fd) +{ +struct tracecmd_output *handle; + + handle =calloc (1 ,sizeof (*handle)); +if (!handle) +return NULL ; + + handle->fd = fd; + + handle->file_version =FILE_VERSION ; + + handle->page_size =getpagesize (); + handle->big_endian =tracecmd_host_bigendian (); + +list_head_init (&handle->options); + + handle->file_state =TRACECMD_FILE_ALLOCATED ; + +return handle; +} + +static int select_file_version (struct tracecmd_output *handle,struct tracecmd_input *ihandle) {
Signature · 1 line
2.31.1
PATCH 2/10 trace-cmd library: New API for setting a message context to an output handler
In reply to Tzvetomir Stoyanov (VMware)The new API associates previously created handler to message context with given output handler. The message context is used by the output handler to send data over a network, instead writing to a local file.
tracecmd_output_allocate()
--- .../include/private/trace-cmd-private.h | 2 ++ lib/trace-cmd/trace-output.c | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+)
lib/trace-cmd/include/private/trace-cmd-private.h +2 -0
@@ -270,6 +270,8 @@ struct tracecmd_option;struct tracecmd_msg_handle ;struct tracecmd_output *tracecmd_output_allocate (int fd); +int tracecmd_output_set_msg (struct tracecmd_output *handler, +struct tracecmd_msg_handle *msg_handle);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +22 -0
@@ -918,6 +918,28 @@ struct tracecmd_output *tracecmd_output_allocate(int fd)return handle; } +/** +* tracecmd_output_set_msg - associated an output file handler with network message handler +* @handle: output handler to a trace file. +* @msg_handle: network handler, allocated by tracecmd_msg_handle_alloc() +* +* This API associates an output file handler with a network stream. All subsequent API calls +* with this output file handler will send data over the network using the @msg_handle, instead +* of writing to a file. +* This API must be called after the handler file version is set and before +* tracecmd_output_write_init(). +* +* Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state. +*/ +int tracecmd_output_set_msg (struct tracecmd_output *handler,struct tracecmd_msg_handle *msg_handle) +{ +if (!handler || handler->file_state !=TRACECMD_FILE_ALLOCATED ) +return -1 ; + + handler->msg_handle = msg_handle; + +return 0 ; +}static int select_file_version (struct tracecmd_output *handle,struct tracecmd_input *ihandle)
Signature · 1 line
2.31.1
PATCH 3/10 trace-cmd library: New API for setting a custom trace directory to an output handler
In reply to Tzvetomir Stoyanov (VMware)The new API associates a custom tracing directory with an output file handler. It is used when creating the trace file instead of the system default tracing directory.
tracecmd_output_set_trace_dir()
--- .../include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-output.c | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+)
lib/trace-cmd/include/private/trace-cmd-private.h +1 -0
@@ -272,6 +272,7 @@ struct tracecmd_msg_handle;struct tracecmd_output *tracecmd_output_allocate (int fd);int tracecmd_output_set_msg (struct tracecmd_output *handler,struct tracecmd_msg_handle *msg_handle); +int tracecmd_output_set_trace_dir (struct tracecmd_output *handler,const char *tracing_dir);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +27 -0
@@ -941,6 +941,33 @@ int tracecmd_output_set_msg(struct tracecmd_output *handler, struct tracecmd_msgreturn 0 ; } +/** +* tracecmd_output_set_trace_dir - Set a custom tracing dir, instead of system default +* @handle: output handler to a trace file. +* @tracing_dir: full path to a directory with tracing files +* +* This API associates an output file handler with a custom tracing directory, to be used when +* creating the trace file instead of the system default tracing directory. +* This API must be called before tracecmd_output_write_init(). +* +* Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state. +*/ +int tracecmd_output_set_trace_dir (struct tracecmd_output *handler,const char *tracing_dir) +{ +if (!handler || handler->file_state !=TRACECMD_FILE_ALLOCATED ) +return -1 ; + +free (handler->tracing_dir); +if (tracing_dir) { + handler->tracing_dir =strdup (tracing_dir); +if (!handler->tracing_dir) +return -1 ; + }else + handler->tracing_dir =NULL ; + +return 0 ; +} +static int select_file_version (struct tracecmd_output *handle,struct tracecmd_input *ihandle) {
Signature · 1 line
2.31.1
PATCH 4/10 trace-cmd library: New API for setting a custom kallsyms to an output handler
In reply to Tzvetomir Stoyanov (VMware)The new API associates an output file handler with a custom kernel symbols file. It is used when creating the trace file instead of the system default kernel symbols file.
tracecmd_output_set_kallsyms()
--- .../include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-output.c | 32 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +1 -0
@@ -273,6 +273,7 @@ struct tracecmd_output *tracecmd_output_allocate(int fd);int tracecmd_output_set_msg (struct tracecmd_output *handler,struct tracecmd_msg_handle *msg_handle);int tracecmd_output_set_trace_dir (struct tracecmd_output *handler,const char *tracing_dir); +int tracecmd_output_set_kallsyms (struct tracecmd_output *handler,const char *kallsyms);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +30 -2
@@ -54,6 +54,7 @@ struct tracecmd_output {int cpus;struct tep_handle *pevent;char *tracing_dir; +char *kallsyms;int nr_options;bool quiet;unsigned long file_state;
@@ -767,8 +768,8 @@ static int read_proc_kallsyms(struct tracecmd_output *handle,return -1 ; } -if (kallsyms) - path = kallsyms; +if (handle->kallsyms) + path = handle->kallsyms; ret =stat (path, &st);if (ret <0 ) {
@@ -968,6 +969,33 @@ int tracecmd_output_set_trace_dir(struct tracecmd_output *handler, const char *treturn 0 ; } +/** +* tracecmd_output_set_kallsyms - Set a custom kernel symbols file, instead of system default +* @handle: output handler to a trace file. +* @tracing_dir: full path to a file with kernel symbols +* +* This API associates an output file handler with a custom kernel symbols file, to be used when +* creating the trace file instead of the system default kernel symbols file. +* This API must be called before tracecmd_output_write_init(). +* +* Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state. +*/ +int tracecmd_output_set_kallsyms (struct tracecmd_output *handler,const char *kallsyms) +{ +if (!handler || handler->file_state !=TRACECMD_FILE_ALLOCATED ) +return -1 ; + +free (handler->kallsyms); +if (kallsyms) { + handler->kallsyms =strdup (kallsyms); +if (!handler->kallsyms) +return -1 ; + }else + handler->kallsyms =NULL ; + +return 0 ; +} +static int select_file_version (struct tracecmd_output *handle,struct tracecmd_input *ihandle) {
Signature · 1 line
2.31.1
PATCH 5/10 trace-cmd library: New API to inherit parameters from an existing trace file
In reply to Tzvetomir Stoyanov (VMware)The new API initializes previously allocated output handler with parameters from an input handler to a trace file.
tracecmd_output_set_from_input()
--- .../include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-output.c | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+)
lib/trace-cmd/include/private/trace-cmd-private.h +1 -0
@@ -274,6 +274,7 @@ int tracecmd_output_set_msg(struct tracecmd_output *handler, struct tracecmd_msg_handle *msg_handle);int tracecmd_output_set_trace_dir (struct tracecmd_output *handler,const char *tracing_dir);int tracecmd_output_set_kallsyms (struct tracecmd_output *handler,const char *kallsyms); +int tracecmd_output_set_from_input (struct tracecmd_output *handler,struct tracecmd_input *ihandle);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +33 -0
@@ -996,6 +996,39 @@ int tracecmd_output_set_kallsyms(struct tracecmd_output *handler, const char *kareturn 0 ; } +/** +* tracecmd_output_set_from_input - Inherit parameters from an existing trace file +* @handle: output handler to a trace file. +* @ihandle: input handler to an existing trace file. +* +* This API copies parameters from input handler @ihandle, associated with an existing trace file, +* to the output handler @handle, associated with file that is going to be created. +* These parameters are copied: +* - tep handler +* - page size +* - file endian +* - file version +* - file compression protocol +* This API must be called before tracecmd_output_write_init(). +* +* Returns 0 on success, or -1 if the output file handler is not allocated or not in expected state. +*/ +int tracecmd_output_set_from_input (struct tracecmd_output *handler,struct tracecmd_input *ihandle) +{ +if (!handler || !ihandle || handler->file_state !=TRACECMD_FILE_ALLOCATED ) +return -1 ; + +/* get endian, page size, file version and compression */ +/* Use the pevent of the ihandle for later writes */ + handler->pevent =tracecmd_get_tep (ihandle); +tep_ref (handler->pevent); + handler->page_size =tracecmd_page_size (ihandle); + handler->file_version =tracecmd_get_in_file_version (ihandle); + handler->big_endian =tep_is_file_bigendian (handler->pevent); + +return 0 ; +} +static int select_file_version (struct tracecmd_output *handle,struct tracecmd_input *ihandle) {
Signature · 1 line
2.31.1
PATCH 6/10 trace-cmd library: New API tracecmd_output_write_init
In reply to Tzvetomir Stoyanov (VMware)The API writes initial magic bits in a trace file.
tracecmd_output_write_init()
--- .../include/private/trace-cmd-private.h | 1 + lib/trace-cmd/trace-output.c | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+)
lib/trace-cmd/include/private/trace-cmd-private.h +1 -0
@@ -275,6 +275,7 @@ int tracecmd_output_set_msg(struct tracecmd_output *handler,int tracecmd_output_set_trace_dir (struct tracecmd_output *handler,const char *tracing_dir);int tracecmd_output_set_kallsyms (struct tracecmd_output *handler,const char *kallsyms);int tracecmd_output_set_from_input (struct tracecmd_output *handler,struct tracecmd_input *ihandle); +int tracecmd_output_write_init (struct tracecmd_output *handler);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +54 -0
60 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 7/10 trace-cmd library: New API to write headers of a trace file
In reply to Tzvetomir Stoyanov (VMware)The API writes metadata headers in a trace file.
tracecmd_output_write_headers()
--- .../include/private/trace-cmd-private.h | 3 ++ lib/trace-cmd/trace-output.c | 44 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +3 -0
@@ -276,6 +276,9 @@ int tracecmd_output_set_trace_dir(struct tracecmd_output *handler, const char *tint tracecmd_output_set_kallsyms (struct tracecmd_output *handler,const char *kallsyms);int tracecmd_output_set_from_input (struct tracecmd_output *handler,struct tracecmd_input *ihandle);int tracecmd_output_write_init (struct tracecmd_output *handler); +int tracecmd_output_write_headers (struct tracecmd_output *handler, +struct tracecmd_event_list *list); +struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus);struct tracecmd_output * tracecmd_create_init_file_glob(const char *output_file,
lib/trace-cmd/trace-output.c +40 -4
68 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 8/10 trace-cmd library: Use the new flow when creating output handler
In reply to Tzvetomir Stoyanov (VMware)The trace-cmd library APIs, that create a new output handler to a trace file, are converted to use the newly introduced APIs. Affected are:
tracecmd_create_file_latency()
tracecmd_create_init_fd()
tracecmd_create_init_file()
tracecmd_copy()
--- lib/trace-cmd/trace-output.c | 54 ++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-)
lib/trace-cmd/trace-output.c +48 -6
@@ -1503,11 +1503,19 @@ struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, in {struct tracecmd_output *handle;char *path; +int fd; - handle =create_file (output_file,NULL ,NULL ,NULL , &all_event_list); -if (!handle) + fd =open (output_file,O_RDWR |O_CREAT |O_TRUNC |O_LARGEFILE ,0644 ); +if (fd <0 )return NULL ; + handle =tracecmd_output_allocate (fd); +if (!handle) + goto out_free; +if (tracecmd_output_write_init (handle)) + goto out_free; +if (tracecmd_output_write_headers (handle,NULL )) + goto out_free;/* * Save the command lines; */
@@ -1801,7 +1809,20 @@ struct tracecmd_output *tracecmd_get_output_handle_fd(int fd)struct tracecmd_output *tracecmd_create_init_fd (int fd) { -return create_file_fd (fd,NULL ,NULL ,NULL , &all_event_list,NULL ); +struct tracecmd_output *out; + + out =tracecmd_output_allocate (fd); +if (!out) +return NULL ; +if (tracecmd_output_write_init (out)) + goto error; +if (tracecmd_output_write_headers (out,NULL )) + goto error; + +return out; +error: +tracecmd_output_close (out); +return NULL ; } struct tracecmd_output *
@@ -1826,7 +1847,20 @@ tracecmd_create_init_file_glob(const char *output_file,struct tracecmd_output *tracecmd_create_init_file (const char *output_file) { -return create_file (output_file,NULL ,NULL ,NULL , &all_event_list); +struct tracecmd_output *handle; +int fd; + + fd =open (output_file,O_RDWR |O_CREAT |O_TRUNC |O_LARGEFILE ,0644 ); +if (fd <0 ) +return NULL ; + handle =tracecmd_create_init_fd (fd); +if (!handle) { +close (fd); +unlink (output_file); +return NULL ; + } + +return handle; } struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
@@ -1849,11 +1883,19 @@ struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle, const char *file) {struct tracecmd_output *handle; +int fd; - handle =create_file (file, ihandle,NULL ,NULL , &all_event_list); -if (!handle) + fd =open (file,O_RDWR |O_CREAT |O_TRUNC |O_LARGEFILE ,0644 ); +if (fd <0 )return NULL ; + handle =tracecmd_output_allocate (fd); +if (!handle) + goto out_free; +if (tracecmd_output_set_from_input (handle, ihandle)) + goto out_free; +tracecmd_output_write_init (handle); +if (tracecmd_copy_headers (ihandle, handle->fd,0 ,0 ) <0 ) goto out_free;
Signature · 1 line
2.31.1
PATCH 9/10 trace-cmd: Use the new flow when creating output handler
In reply to Tzvetomir Stoyanov (VMware)The trace-cmd commands, that create a new output handler to a trace file, are converted to use the newly introduced trace-cmd APIs.
--- tracecmd/trace-record.c | 55 +++++++++++++++++++++++++++++++++++----- tracecmd/trace-restore.c | 32 +++++++++++++++++++++-- 2 files changed, 79 insertions(+), 8 deletions(-)
tracecmd/trace-record.c +49 -6
@@ -3689,6 +3689,25 @@ again:static void add_options (struct tracecmd_output *handle,struct common_record_context *ctx); +static struct tracecmd_output *create_net_output (struct common_record_context *ctx, +struct tracecmd_msg_handle *msg_handle) +{ +struct tracecmd_output *out; + + out =tracecmd_output_allocate (-1 ); +if (!out) +return NULL ; +if (tracecmd_output_set_msg (out, msg_handle)) + goto error; +if (tracecmd_output_write_headers (out, listed_events)) + goto error; + +return out; +error: +tracecmd_output_close (out); +return NULL ; +} +static struct tracecmd_msg_handle *setup_connection (struct buffer_instance *instance,struct common_record_context *ctx) {
@@ -3700,7 +3719,7 @@ setup_connection(struct buffer_instance *instance, struct common_record_context/* Now create the handle through this socket */ if (msg_handle->version ==V3_PROTOCOL ) { - network_handle =tracecmd_create_init_fd_msg (msg_handle, listed_events); + network_handle =create_net_output (ctx, msg_handle);if (!network_handle) goto error;tracecmd_set_quiet (network_handle, quiet);
@@ -3718,10 +3737,11 @@ setup_connection(struct buffer_instance *instance, struct common_record_contextif (ret) goto error; }else { - network_handle =tracecmd_create_init_fd_glob (msg_handle->fd, - listed_events); + network_handle =tracecmd_output_allocate (msg_handle->fd);if (!network_handle) goto error; +if (tracecmd_output_write_headers (network_handle, listed_events)) + goto error;tracecmd_set_quiet (network_handle, quiet); }
@@ -4067,8 +4087,7 @@ static void setup_agent(struct buffer_instance *instance, {struct tracecmd_output *network_handle; - network_handle =tracecmd_create_init_fd_msg (instance->msg_handle, - listed_events); + network_handle =create_net_output (ctx, instance->msg_handle);add_options (network_handle, ctx);tracecmd_write_cmdlines (network_handle);tracecmd_write_cpus (network_handle, instance->cpu_count);
@@ -4437,6 +4456,30 @@ static void write_guest_file(struct buffer_instance *instance)free (temp_files); } +static struct tracecmd_output *create_output (struct common_record_context *ctx) +{ +struct tracecmd_output *out; +int fd; + + fd =open (ctx->output,O_RDWR |O_CREAT |O_TRUNC |O_LARGEFILE ,0644 ); +if (fd <0 ) +return NULL ; + + out =tracecmd_output_allocate (fd); +if (!out) + goto error; +if (tracecmd_output_write_headers (out, listed_events)) + goto error; +return out; +error: +if (out) +tracecmd_output_close (out); +else +close (fd); +unlink (ctx->output); +return NULL ; +} +static void record_data (struct common_record_context *ctx) {struct tracecmd_option **buffer_options;
@@ -4491,7 +4534,7 @@ static void record_data(struct common_record_context *ctx)touch_file (temp_files[i]); } - handle =tracecmd_create_init_file_glob (ctx->output, listed_events); + handle =create_output (ctx);if (!handle)die ("Error creating output file" );tracecmd_set_quiet (handle, quiet);
tracecmd/trace-restore.c +30 -2
@@ -22,6 +22,35 @@#include "trace-local.h" +static struct tracecmd_output *create_output (const char *file, +const char *tracing_dir,const char *kallsyms) +{ +struct tracecmd_output *out; +int fd; + + fd =open (file,O_RDWR |O_CREAT |O_TRUNC |O_LARGEFILE ,0644 ); +if (fd <0 ) +return NULL ; + + out =tracecmd_output_allocate (fd); +if (!out) + goto error; +if (tracing_dir &&tracecmd_output_set_trace_dir (out, tracing_dir)) + goto error; +if (kallsyms &&tracecmd_output_set_kallsyms (out, kallsyms)) + goto error; +if (tracecmd_output_write_headers (out,NULL )) + goto error; +return out; +error: +if (out) +tracecmd_output_close (out); +else +close (fd); +unlink (file); +return NULL ; +} +void trace_restore (int argc,char **argv) {struct tracecmd_output *handle;
@@ -90,8 +119,7 @@ void trace_restore (int argc, char **argv)usage (argv); } - handle =tracecmd_create_init_file_override (output, tracing_dir, - kallsyms); + handle =create_output (output, tracing_dir, kallsyms);if (!handle)die ("Unabled to create output file %s" , output);if (tracecmd_write_cmdlines (handle) <0 )
Signature · 1 line
2.31.1
PATCH 10/10 trace-cmd library: Remove deprecated APIs for creating an output handler
In reply to Tzvetomir Stoyanov (VMware)With the introduction of the new output handler creation flow, some of the old APIs are not used any more. Removed unused APIs:
tracecmd_create_init_file_glob() tracecmd_create_init_fd_glob() tracecmd_create_init_fd_msg() tracecmd_create_init_file_override()
--- .../include/private/trace-cmd-private.h | 12 +- lib/trace-cmd/trace-output.c | 165 ------------------ 2 files changed, 1 insertion(+), 176 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +1 -11
@@ -280,19 +280,9 @@ int tracecmd_output_write_headers(struct tracecmd_output *handler, struct tracecmd_event_list *list);struct tracecmd_output *tracecmd_create_file_latency (const char *output_file,int cpus); -struct tracecmd_output * -tracecmd_create_init_file_glob (const char *output_file, -struct tracecmd_event_list *list);struct tracecmd_output *tracecmd_create_init_fd (int fd); -struct tracecmd_output * -tracecmd_create_init_fd_glob (int fd,struct tracecmd_event_list *list); -struct tracecmd_output * -tracecmd_create_init_fd_msg (struct tracecmd_msg_handle *msg_handle, -struct tracecmd_event_list *list); +struct tracecmd_output *tracecmd_create_init_file (const char *output_file); -struct tracecmd_output *tracecmd_create_init_file_override (const char *output_file, -const char *tracing_dir, -const char *kallsyms);struct tracecmd_option *tracecmd_add_option (struct tracecmd_output *handle,unsigned short id,int size,const void *data);
lib/trace-cmd/trace-output.c +0 -165
189 lines not on this page · raw message
Signature · 1 line
2.31.1