On 11/24/21 22:37, Steven Rostedt wrote: > On Fri, 29 Oct 2021 21:26:05 +0200 > Daniel Bristot de Oliveira <bristot@xxxxxxxxxx> wrote: > >> +/* >> + * enable_tracer_by_name - enable a tracer on the given instance >> + */ >> +int enable_tracer_by_name(struct tracefs_instance *inst, const char *tracer) >> +{ >> + enum tracefs_tracers t; >> + int retval; >> + >> + t = TRACEFS_TRACER_CUSTOM; >> + >> + debug_msg("enabling %s tracer\n", tracer); >> + >> + retval = tracefs_tracer_set(inst, t, tracer); > > Interesting. We had discussions about having the custom option (which I > fought for, for this very reason). > >> + if (retval < 0) { >> + if (errno == ENODEV) >> + err_msg("tracer %s not found!\n", tracer); >> + >> + err_msg("failed to enable the tracer %s\n", tracer); >> + return -1; >> + } >> + >> + return 0; >> +} >> + >> +/* >> + * disable_tracer - set nop tracer to the insta >> + */ >> +void disable_tracer(struct tracefs_instance *inst) >> +{ >> + enum tracefs_tracers t = TRACEFS_TRACER_NOP; >> + int retval; >> + >> + retval = tracefs_tracer_set(inst, t); >> + if (retval < 0) >> + err_msg("oops, error disabling tracer\n"); >> +} >> + >> +/* >> + * create_instance - create a trace instance with *instance_name >> + */ >> +struct tracefs_instance *create_instance(char *instance_name) >> +{ >> + return tracefs_instance_create(instance_name); >> +} >> + >> +/* >> + * destroy_instance - remove a trace instance and free the data >> + */ >> +void destroy_instance(struct tracefs_instance *inst) >> +{ >> + tracefs_instance_destroy(inst); >> + tracefs_instance_free(inst); >> +} >> + >> +/* >> + * save_trace_to_file - save the trace output of the instance to the file >> + */ >> +int save_trace_to_file(struct tracefs_instance *inst, const char *filename) >> +{ >> + const char *file = "trace"; >> + mode_t mode = 0644; >> + char *buffer[4096]; > > Did you really mean to have buffer be 4096 strings? > > Or did you mean: > > char buffer[4096]; I should be "char buffer[4096];" I will fix that. (The * is probably a left over from the idea of using a malloc(4096)...) -- Daniel > (i.e. a single string of 4096 size)? > > -- Steve >