tools/lib/traceevent: Various changes in libtraceevent APIs
cover tools/lib/traceevent: Various changes in libtraceevent APIs
This patch series includes changes, related to transformation of traceevent into a library:
Renamed few libtracevent APIs.
Introduced new API: tep_get_ref()
Added support for pkg-config infrastructure
[backported from Linux kernel tree]
Tzvetomir Stoyanov (6):
tools lib traceevent: Implement new API tep_get_ref() tools lib traceevent, perf tools: Rename 'struct tep_event_format' to
'struct tep_event'
tools lib traceevent: Rename tep_free_format() to tep_free_event() tools lib traceevent: traceevent API cleanup
tools lib traceevent: Added support for pkg-config
tools lib traceevent: Install trace-seq.h API header file
Makefile | 47 ++++- include/trace-cmd/trace-cmd.h | 2 +- include/traceevent/event-parse.h | 76 +++---- kernel-shark-qt/examples/datafilter.c | 2 +- kernel-shark-qt/src/KsAdvFilteringDialog.cpp | 10 +- kernel-shark-qt/src/KsAdvFilteringDialog.hpp | 2 +- kernel-shark-qt/src/KsCaptureDialog.cpp | 4 +- kernel-shark-qt/src/KsMainWindow.cpp | 2 +- kernel-shark-qt/src/KsWidgetsLib.cpp | 2 +- kernel-shark-qt/src/libkshark-configio.c | 6 +- kernel-shark-qt/src/libkshark.c | 8 +- kernel-shark-qt/src/plugins/sched_events.c | 2 +- kernel-shark-qt/src/plugins/sched_events.h | 6 +- kernel-shark/include/trace-view-store.h | 6 +- kernel-shark/trace-capture.c | 6 +- kernel-shark/trace-dialog.c | 4 +- kernel-shark/trace-filter.c | 24 +-- kernel-shark/trace-graph.c | 8 +- kernel-shark/trace-plot-cpu.c | 4 +- kernel-shark/trace-plot-task.c | 4 +- kernel-shark/trace-view-store.c | 2 +- lib/trace-cmd/trace-blk-hack.c | 2 +- lib/trace-cmd/trace-ftrace.c | 16 +- lib/trace-cmd/trace-input.c | 14 +- lib/traceevent/event-parse-api.c | 10 +- lib/traceevent/event-parse-local.h | 13 +- lib/traceevent/event-parse.c | 206 ++++++++++--------- lib/traceevent/libtraceevent.pc.template | 10 + lib/traceevent/parse-filter.c | 42 ++-- plugins/plugin_blk.c | 4 +- plugins/plugin_function.c | 2 +- plugins/plugin_futex.c | 2 +- plugins/plugin_hrtimer.c | 4 +- plugins/plugin_kmem.c | 2 +- plugins/plugin_kvm.c | 14 +- plugins/plugin_mac80211.c | 10 +- plugins/plugin_sched_switch.c | 4 +- plugins/plugin_tlb.c | 2 +- python/ctracecmd.i | 10 +- tracecmd/trace-hist.c | 22 +- tracecmd/trace-mem.c | 18 +- tracecmd/trace-output.c | 6 +- tracecmd/trace-profile.c | 10 +- tracecmd/trace-read.c | 16 +- tracecmd/trace-record.c | 2 +- tracecmd/trace-split.c | 19 +- 46 files changed, 367 insertions(+), 320 deletions(-) create mode 100644 lib/traceevent/libtraceevent.pc.template
Signature · 1 line
2.19.2
PATCH 1/6 tools lib traceevent: Implement new API tep_get_ref()
This patch implements a new API of the tracevent library:
int tep_get_ref(struct tep_handle *tep);
The API returns the reference counter "ref_count" of the tep handler. As "struct tep_handle" is internal only, its members cannot be accessed by the library users, the API is used to get the reference counter.
--- include/traceevent/event-parse.h | 1 + lib/traceevent/event-parse.c | 7 +++++++ 2 files changed, 8 insertions(+)
include/traceevent/event-parse.h +1 -0
@@ -577,6 +577,7 @@ struct tep_handle *tep_alloc(void);void tep_free (struct tep_handle *pevent);void tep_ref (struct tep_handle *pevent);void tep_unref (struct tep_handle *pevent); +int tep_get_ref (struct tep_handle *tep);/* access to the internal parser */ void tep_buffer_init (const char *buf,unsigned long long size);
lib/traceevent/event-parse.c +7 -0
@@ -6761,6 +6761,13 @@ void tep_ref(struct tep_handle *pevent) pevent->ref_count++; } +int tep_get_ref (struct tep_handle *tep) +{ +if (tep) +return tep->ref_count; +return 0 ; +} +void tep_free_format_field (struct tep_format_field *field) {free (field->type);
Signature · 1 line
2.19.2
PATCH 2/6 tools lib traceevent, perf tools: Rename 'struct tep_event_format' to 'struct tep_event'
In reply to Tzvetomir StoyanovIn order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts.
This renames 'struct tep_event_format' to 'struct tep_event', which describes more closely the purpose of the struct.
--- include/trace-cmd/trace-cmd.h | 2 +- include/traceevent/event-parse.h | 60 +++--- kernel-shark-qt/examples/datafilter.c | 2 +- kernel-shark-qt/src/KsAdvFilteringDialog.cpp | 10 +- kernel-shark-qt/src/KsAdvFilteringDialog.hpp | 2 +- kernel-shark-qt/src/KsCaptureDialog.cpp | 4 +- kernel-shark-qt/src/KsMainWindow.cpp | 2 +- kernel-shark-qt/src/KsWidgetsLib.cpp | 2 +- kernel-shark-qt/src/libkshark-configio.c | 6 +- kernel-shark-qt/src/libkshark.c | 8 +- kernel-shark-qt/src/plugins/sched_events.c | 2 +- kernel-shark-qt/src/plugins/sched_events.h | 6 +- kernel-shark/include/trace-view-store.h | 6 +- kernel-shark/trace-capture.c | 6 +- kernel-shark/trace-dialog.c | 4 +- kernel-shark/trace-filter.c | 24 +-- kernel-shark/trace-graph.c | 8 +- kernel-shark/trace-plot-cpu.c | 4 +- kernel-shark/trace-plot-task.c | 4 +- kernel-shark/trace-view-store.c | 2 +- lib/trace-cmd/trace-blk-hack.c | 2 +- lib/trace-cmd/trace-ftrace.c | 16 +- lib/traceevent/event-parse-api.c | 4 +- lib/traceevent/event-parse-local.h | 6 +- lib/traceevent/event-parse.c | 182 +++++++++---------- lib/traceevent/parse-filter.c | 42 ++--- plugins/plugin_blk.c | 4 +- plugins/plugin_function.c | 2 +- plugins/plugin_futex.c | 2 +- plugins/plugin_hrtimer.c | 4 +- plugins/plugin_kmem.c | 2 +- plugins/plugin_kvm.c | 14 +- plugins/plugin_mac80211.c | 10 +- plugins/plugin_sched_switch.c | 4 +- plugins/plugin_tlb.c | 2 +- python/ctracecmd.i | 10 +- tracecmd/trace-hist.c | 22 +-- tracecmd/trace-mem.c | 18 +- tracecmd/trace-profile.c | 10 +- tracecmd/trace-read.c | 16 +- tracecmd/trace-record.c | 2 +- 41 files changed, 269 insertions(+), 269 deletions(-)
include/trace-cmd/trace-cmd.h +1 -1
@@ -90,7 +90,7 @@ enum {struct tracecmd_ftrace {struct tracecmd_input *handle; -struct tep_event_format *fgraph_ret_event; +struct tep_event *fgraph_ret_event;int fgraph_ret_id;int long_size; };
include/traceevent/event-parse.h +30 -30
152 lines not on this page · raw message
kernel-shark-qt/examples/datafilter.c +1 -1
@@ -19,7 +19,7 @@ int main(int argc, char **argv)struct kshark_context *kshark_ctx;struct kshark_entry **data =NULL ;struct tep_event_filter *adv_filter; -struct tep_event_format *event; +struct tep_event *event;char *entry_str;bool status;int *pids;
kernel-shark-qt/src/KsAdvFilteringDialog.cpp +5 -5
@@ -151,7 +151,7 @@ KsAdvFilteringDialog::KsAdvFilteringDialog(QWidget *parent) void KsAdvFilteringDialog::_setSystemCombo(struct kshark_context *kshark_ctx) { - tep_event_format **events; + tep_event **events; QStringList sysList; int i(0), nEvts(0);
@@ -204,7 +204,7 @@ QStringList KsAdvFilteringDialog::_operators() void KsAdvFilteringDialog::_getFilters(struct kshark_context *kshark_ctx) { - tep_event_format **events; + tep_event **events; char *str; events = tep_list_events(kshark_ctx->pevent, TEP_EVENT_SORT_SYSTEM);
@@ -275,7 +275,7 @@ void KsAdvFilteringDialog::_help() void KsAdvFilteringDialog::_systemChanged(const QString &sysName) { kshark_context *kshark_ctx(NULL); - tep_event_format **events; + tep_event **events; QStringList evtsList; int i, nEvts;
@@ -300,7 +300,7 @@ void KsAdvFilteringDialog::_systemChanged(const QString &sysName) } QStringList -KsAdvFilteringDialog::_getEventFormatFields(struct tep_event_format *event) +KsAdvFilteringDialog::_getEventFormatFields(struct tep_event *event) { tep_format_field *field, **fields = tep_event_fields(event); QStringList fieldList;
@@ -318,7 +318,7 @@ void KsAdvFilteringDialog::_eventChanged(const QString &evtName) { QString sysName = _systemComboBox.currentText(); kshark_context *kshark_ctx(NULL); - tep_event_format **events; + tep_event **events; QStringList fieldList; int nEvts;
kernel-shark-qt/src/KsAdvFilteringDialog.hpp +1 -1
@@ -78,7 +78,7 @@ private: void _makeFilterTable(struct kshark_context *kshark_ctx); - QStringList _getEventFormatFields(struct tep_event_format *event); + QStringList _getEventFormatFields(struct tep_event *event); void _setSystemCombo(struct kshark_context *kshark_ctx);
kernel-shark-qt/src/KsCaptureDialog.cpp +2 -2
@@ -149,7 +149,7 @@ QStringList KsCaptureControl::getArgs() argv << "-e" << "all"; } else { QVector<int> evtIds = _eventsWidget.getCheckedIds(); - tep_event_format *event; + tep_event *event; for (auto const &id: evtIds) { event = tep_find_event(_localTEP, id);
@@ -198,7 +198,7 @@ void KsCaptureControl::_importSettings() kshark_config_doc *conf, *jevents, *temp; QVector<bool> v(nEvts, false); tracecmd_filter_id *eventHash; - tep_event_format **events; + tep_event **events; QString fileName;
kernel-shark-qt/src/KsMainWindow.cpp +1 -1
@@ -534,7 +534,7 @@ void KsMainWindow::_showEvents() * The event filter contains IDs. Make this visible in the * CheckBox Widget. */ - tep_event_format **events = + tep_event **events = tep_list_events(_data.tep(), TEP_EVENT_SORT_SYSTEM); int nEvts = tep_get_events_count(_data.tep()); QVector<bool> v(nEvts, false);
kernel-shark-qt/src/KsWidgetsLib.cpp +1 -1
@@ -664,7 +664,7 @@ KsEventsCheckBoxWidget::KsEventsCheckBoxWidget(struct tep_handle *tep, : KsCheckBoxTreeWidget("Events", parent) { QTreeWidgetItem *sysItem, *evtItem; - tep_event_format **events(nullptr); + tep_event **events(nullptr); QString sysName, evtName; int nEvts(0), i(0);
kernel-shark-qt/src/libkshark-configio.c +3 -3
@@ -691,7 +691,7 @@ static bool kshark_event_filter_to_json(struct tep_handle *pevent, struct json_object *jobj) {json_object *jfilter_data, *jevent, *jsystem, *jname; -struct tep_event_format *event; +struct tep_event *event;int i, evt, *ids, nr_events;char *temp;
@@ -797,7 +797,7 @@ static bool kshark_event_filter_from_json(struct tep_handle *pevent, {json_object *jfilter, *jevent, *jsystem, *jname;const char *system_str, *name_str; -struct tep_event_format *event; +struct tep_event *event;int i, length;/*
@@ -1015,7 +1015,7 @@ static bool kshark_adv_filters_to_json(struct kshark_context *kshark_ctx, {struct tep_event_filter *adv_filter = kshark_ctx->advanced_event_filter;json_object *jfilter_data, *jevent, *jsystem, *jname, *jfilter; -struct tep_event_format **events; +struct tep_event **events;char *str;int i;
kernel-shark-qt/src/libkshark.c +4 -4
@@ -997,7 +997,7 @@ static const char *kshark_get_latency(struct tep_handle *pe,static const char *kshark_get_info (struct tep_handle *pe,struct tep_record *record, -struct tep_event_format *event) +struct tep_event *event) {char *pos;
@@ -1166,7 +1166,7 @@ int kshark_get_event_id_easy(struct kshark_entry *entry)const char *kshark_get_event_name_easy (struct kshark_entry *entry) {struct kshark_context *kshark_ctx =NULL ; -struct tep_event_format *event; +struct tep_event *event;int event_id =kshark_get_event_id_easy (entry);if (event_id == -EFAULT )
@@ -1205,7 +1205,7 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry)const char *kshark_get_info_easy (struct kshark_entry *entry) {struct kshark_context *kshark_ctx =NULL ; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *data;const char *info =NULL ;int event_id;
@@ -1311,7 +1311,7 @@ char* kshark_dump_entry(const struct kshark_entry *entry) task =tep_data_comm_from_pid (kshark_ctx->pevent, entry->pid);if (entry->event_id >=0 ) { -struct tep_event_format *event; +struct tep_event *event;struct tep_record *data; data =kshark_read_at (kshark_ctx, entry->offset);
kernel-shark-qt/src/plugins/sched_events.c +1 -1
@@ -26,7 +26,7 @@ struct plugin_sched_context *plugin_sched_context_handler = NULL;static bool plugin_sched_init_context (struct kshark_context *kshark_ctx) {struct plugin_sched_context *plugin_ctx; -struct tep_event_format *event; +struct tep_event *event;/* No context should exist when we initialize the plugin. */ assert (plugin_sched_context_handler ==NULL );
kernel-shark-qt/src/plugins/sched_events.h +3 -3
@@ -28,7 +28,7 @@ struct plugin_sched_context {struct tep_handle *pevent;/** Pointer to the sched_switch_event object. */ -struct tep_event_format *sched_switch_event; +struct tep_event *sched_switch_event;/** Pointer to the sched_switch_next_field format descriptor. */ struct tep_format_field *sched_switch_next_field;
@@ -40,7 +40,7 @@ struct plugin_sched_context {struct tep_format_field *sched_switch_prev_state_field;/** Pointer to the sched_wakeup_event object. */ -struct tep_event_format *sched_wakeup_event; +struct tep_event *sched_wakeup_event;/** Pointer to the sched_wakeup_pid_field format descriptor. */ struct tep_format_field *sched_wakeup_pid_field;
@@ -49,7 +49,7 @@ struct plugin_sched_context {struct tep_format_field *sched_wakeup_success_field;/** Pointer to the sched_wakeup_new_event object. */ -struct tep_event_format *sched_wakeup_new_event; +struct tep_event *sched_wakeup_new_event;/** Pointer to the sched_wakeup_new_pid_field format descriptor. */ struct tep_format_field *sched_wakeup_new_pid_field;
kernel-shark/include/trace-view-store.h +3 -3
@@ -83,11 +83,11 @@ struct trace_view_store/* Tracecmd specific info */ struct tracecmd_input *handle; -struct tep_event_format *sched_switch_event; +struct tep_event *sched_switch_event;struct tep_format_field *sched_switch_next_field; -struct tep_event_format *sched_wakeup_event; +struct tep_event *sched_wakeup_event;struct tep_format_field *sched_wakeup_pid_field; -struct tep_event_format *sched_wakeup_new_event; +struct tep_event *sched_wakeup_new_event;struct tep_format_field *sched_wakeup_new_pid_field;int cpus;
kernel-shark/trace-capture.c +3 -3
@@ -349,7 +349,7 @@ static char *find_tracecmd(void)static int add_trace_cmd_words (struct trace_capture *cap,char **args) { -struct tep_event_format *event; +struct tep_event *event;char **systems = cap->info->cap_systems;const gchar *output;int *events = cap->info->cap_events;
@@ -808,7 +808,7 @@ static int load_events(struct trace_capture *cap, {struct shark_info *info = cap->info;struct tracecmd_xml_system_node *event_node; -struct tep_event_format *event; +struct tep_event *event;struct tep_handle *pevent = cap->pevent;const char *name;int *events =NULL ;
@@ -997,7 +997,7 @@ static void save_events(struct trace_capture *cap, struct tracecmd_xml_handle *handle) {struct tep_handle *pevent = cap->pevent; -struct tep_event_format *event; +struct tep_event *event;char **systems = cap->info->cap_systems;int *events = cap->info->cap_events;int i;
kernel-shark/trace-dialog.c +2 -2
@@ -373,7 +373,7 @@ GtkResponseType trace_dialog(GtkWindow *parent, enum trace_dialog_type type, }static void read_raw_events (struct trace_seq *s, -struct tep_event_format *event, +struct tep_event *event,struct tep_record *record) {struct tep_format_field **fields;
@@ -395,7 +395,7 @@ static void read_raw_events(struct trace_seq *s,void trace_show_record_dialog (GtkWindow *parent,struct tep_handle *pevent,struct tep_record *record,gboolean raw) { -struct tep_event_format *event; +struct tep_event *event;struct trace_seq s;int type;
kernel-shark/trace-filter.c +12 -12
@@ -87,8 +87,8 @@ static GtkTreeModel *create_event_combo_model(gpointer data)GtkTreeStore *tree;GtkTreeIter sys_iter;GtkTreeIter iter; -struct tep_event_format **events; -struct tep_event_format *event; +struct tep_event **events; +struct tep_event *event;const char *last_sys =NULL ;int i;
@@ -145,7 +145,7 @@ static GtkTreeModel *create_field_combo_model(gpointer data)struct tep_handle *pevent = data;GtkListStore *list;GtkTreeIter iter; -struct tep_event_format **events; +struct tep_event **events;struct tep_format_field **fields;struct tep_format_field *field;int i;
@@ -177,8 +177,8 @@ static void update_field_combo(struct tep_handle *pevent,const char *system, const char *event_name) { - struct tep_event_format **events; -struct tep_event_format *event; + struct tep_event **events; +struct tep_event *event;struct tep_format_field **fields;struct tep_format_field *field;GtkTreeModel *model;
@@ -457,7 +457,7 @@ create_tree_filter_model(struct tep_handle *pevent, {GtkTreeStore *treestore;GtkTreeIter iter_events; -struct tep_event_format **events; +struct tep_event **events;char *str;gint i;
@@ -1063,8 +1063,8 @@ create_tree_event_model(struct tep_handle *pevent, {GtkTreeStore *treestore;GtkTreeIter iter_all, iter_sys, iter_events; -struct tep_event_format **events; -struct tep_event_format *event; +struct tep_event **events; +struct tep_event *event;char *last_system =NULL ;gboolean sysactive;gboolean active, normal;
@@ -1923,8 +1923,8 @@ void trace_filter_convert_filter_to_names(struct tep_event_filter *filter, gint **event_ids) {struct tep_handle *pevent = filter->pevent; -struct tep_event_format **events; -struct tep_event_format *event; +struct tep_event **events; +struct tep_event *event;char *last_system =NULL ;int all_selected =1 ;int start_sys =0 ;
@@ -1986,7 +1986,7 @@ void trace_filter_convert_char_to_filter(struct tep_event_filter *filter, {struct tep_handle *pevent;struct tep_event_filter *copy; -struct tep_event_format *event; +struct tep_event *event;int i; pevent = filter->pevent;
@@ -2019,7 +2019,7 @@ void trace_filter_convert_char_to_filter(struct tep_event_filter *filter,int trace_filter_save_events (struct tracecmd_xml_handle *handle,struct tep_event_filter *filter) { -struct tep_event_format *event; +struct tep_event *event;char **systems;gint *event_ids;char *str;
kernel-shark/trace-graph.c +4 -4
@@ -1007,7 +1007,7 @@ int trace_graph_check_sched_wakeup(struct graph_info *ginfo,struct tep_record *record, gint *pid) { - struct tep_event_format *event; + struct tep_event *event;unsigned long long val;gboolean found;gint id;
@@ -1074,7 +1074,7 @@ int trace_graph_check_sched_switch(struct graph_info *ginfo, gint *pid, const char **comm) {unsigned long long val; -struct tep_event_format *event; +struct tep_event *event;gint this_pid;gint id;int ret =1 ;
@@ -1153,8 +1153,8 @@ enum graph_irq_type trace_graph_check_irq(struct graph_info *ginfo, struct tep_record *record) { - struct tep_event_format *event; -struct tep_event_format **events; + struct tep_event *event; +struct tep_event **events;gint id;int i;
kernel-shark/trace-plot-cpu.c +2 -2
@@ -117,7 +117,7 @@ static int cpu_plot_display_last_event(struct graph_info *ginfo, unsigned long long time) {struct cpu_plot_info *cpu_info = plot->private; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;int cpu = cpu_info->cpu;unsigned long long offset =0 ;
@@ -353,7 +353,7 @@ int cpu_plot_display_info(struct graph_info *ginfo, unsigned long long time) {struct cpu_plot_info *cpu_info = plot->private; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;struct tep_record *next_record;struct tep_handle *pevent;
kernel-shark/trace-plot-task.c +2 -2
@@ -240,7 +240,7 @@ static int task_plot_display_last_event(struct graph_info *ginfo, unsigned long long time) {struct task_plot_info *task_info = plot->private; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;struct offset_cache *offsets;gboolean is_sched;
@@ -734,7 +734,7 @@ int task_plot_display_info(struct graph_info *ginfo, unsigned long long time) {struct task_plot_info *task_info = plot->private; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;struct tep_handle *pevent;unsigned long sec, usec;
kernel-shark/trace-view-store.c +1 -1
@@ -406,7 +406,7 @@ trace_view_store_get_value (GtkTreeModel *tree_model,TraceViewStore *trace_view_store;struct trace_seq s;struct tep_handle *pevent; -struct tep_event_format *event; +struct tep_event *event;struct tep_record *data;const gchar *comm;gchar *str;
lib/trace-cmd/trace-blk-hack.c +1 -1
@@ -32,7 +32,7 @@ static const char blk_body[] = "\n"int tracecmd_blk_hack (struct tracecmd_input *handle) {struct tep_handle *pevent; -struct tep_event_format *event; +struct tep_event *event;struct tep_format_field *field;char buf[4096 ];/* way more than enough! */ int id;
lib/trace-cmd/trace-ftrace.c +8 -8
@@ -44,7 +44,7 @@ static void find_long_size(struct tracecmd_ftrace *finfo)static int find_ret_event (struct tracecmd_ftrace *finfo,struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event;/* Store the func ret id and event for later use */ event =tep_find_event_by_name (pevent,"ftrace" ,"funcgraph_exit" );
@@ -63,7 +63,7 @@ static int find_ret_event(struct tracecmd_ftrace *finfo, struct tep_handle *peve }while (0 ) static int function_handler(struct trace_seq *s, struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_handle *pevent = event->pevent;unsigned long long function;
@@ -187,7 +187,7 @@ static void print_graph_duration(struct trace_seq *s, unsigned long long duratiostatic int print_graph_entry_leaf (struct trace_seq *s, -struct tep_event_format *event, +struct tep_event *event,struct tep_record *record,struct tep_record *ret_rec,struct tracecmd_ftrace *finfo)
@@ -237,7 +237,7 @@ print_graph_entry_leaf(struct trace_seq *s, }static int print_graph_nested (struct trace_seq *s, -struct tep_event_format *event, +struct tep_event *event,struct tep_record *record) {struct tep_handle *pevent = event->pevent;
@@ -278,7 +278,7 @@ static int print_graph_nested(struct trace_seq *s,static int fgraph_ent_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tracecmd_ftrace *finfo = context;struct tep_record *rec;
@@ -312,7 +312,7 @@ fgraph_ent_handler(struct trace_seq *s, struct tep_record *record,static int fgraph_ret_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tracecmd_ftrace *finfo = context;unsigned long long rettime, calltime;
@@ -363,7 +363,7 @@ fgraph_ret_handler(struct trace_seq *s, struct tep_record *record,static int trace_stack_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tracecmd_ftrace *finfo = context;struct tep_format_field *field;
@@ -415,7 +415,7 @@ int tracecmd_ftrace_overrides(struct tracecmd_input *handle, struct tracecmd_ftrace *finfo) {struct tep_handle *pevent; -struct tep_event_format *event; +struct tep_event *event; finfo->handle = handle;
lib/traceevent/event-parse-api.c +2 -2
@@ -16,7 +16,7 @@* This returns pointer to the element of the events array with the given index * If @tep is NULL, or @index is not in the range 0 .. nr_events, NULL is returned. */ -struct tep_event_format *tep_get_event (struct tep_handle *tep,int index) +struct tep_event *tep_get_event (struct tep_handle *tep,int index) {if (tep && tep->events && index < tep->nr_events)return tep->events[index];
@@ -31,7 +31,7 @@ struct tep_event_format *tep_get_event(struct tep_handle *tep, int index)* This returns pointer to the first element of the events array * If @tep is NULL, NULL is returned. */ -struct tep_event_format *tep_get_first_event (struct tep_handle *tep) +struct tep_event *tep_get_first_event (struct tep_handle *tep) {return tep_get_event (tep,0 ); }
lib/traceevent/event-parse-local.h +3 -3
@@ -50,9 +50,9 @@ struct tep_handle {unsigned int printk_count; -struct tep_event_format **events; +struct tep_event **events;int nr_events; -struct tep_event_format **sort_events; +struct tep_event **sort_events;enum tep_event_sort_type last_type;int type_offset;
@@ -86,7 +86,7 @@ struct tep_handle {int parsing_failures;/* cache */ -struct tep_event_format *last_event; +struct tep_event *last_event;char *trace_clock; };
lib/traceevent/event-parse.c +91 -91
660 lines not on this page · raw message
lib/traceevent/parse-filter.c +21 -21
162 lines not on this page · raw message
plugins/plugin_blk.c +2 -2
@@ -17,7 +17,7 @@struct blk_data {unsigned long long sector; -struct tep_event_format *event; +struct tep_event *event;unsigned int action;unsigned int pid;unsigned int device;
@@ -279,7 +279,7 @@ static const struct { };static int blktrace_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_format_field *field;unsigned long long val;
plugins/plugin_function.c +1 -1
@@ -129,7 +129,7 @@ static void show_function(struct trace_seq *s, struct tep_handle *pevent, }static int function_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_handle *pevent = event->pevent;unsigned long long function;
plugins/plugin_futex.c +1 -1
@@ -65,7 +65,7 @@ static void futex_print(struct trace_seq *s, const struct futex_args *args, }static int futex_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {const struct futex_op *fop;struct futex_args args;
plugins/plugin_hrtimer.c +2 -2
@@ -11,7 +11,7 @@#include "trace-seq.h" static int timer_expire_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {trace_seq_printf (s,"hrtimer=" );
@@ -28,7 +28,7 @@ static int timer_expire_handler(struct trace_seq *s, struct tep_record *record, }static int timer_start_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {trace_seq_printf (s,"hrtimer=" );
plugins/plugin_kmem.c +1 -1
@@ -10,7 +10,7 @@#include "trace-seq.h" static int call_site_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_format_field *field;unsigned long long val, addr;
plugins/plugin_kvm.c +7 -7
@@ -250,7 +250,7 @@ static const char *find_exit_reason(unsigned isa, int val) }static int print_exit_reason (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,const char *field) +struct tep_event *event,const char *field) {unsigned long long isa;unsigned long long val;
@@ -271,7 +271,7 @@ static int print_exit_reason(struct trace_seq *s, struct tep_record *record, }static int kvm_exit_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {unsigned long long info1 =0 , info2 =0 ;
@@ -293,7 +293,7 @@ static int kvm_exit_handler(struct trace_seq *s, struct tep_record *record,#define KVM_EMUL_INSN_F_CS_L (1 << 3)static int kvm_emulate_insn_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {unsigned long long rip, csbase, len, flags, failed;int llen;
@@ -333,7 +333,7 @@ static int kvm_emulate_insn_handler(struct trace_seq *s, struct tep_record *recostatic int kvm_nested_vmexit_inject_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {if (print_exit_reason (s, record, event,"exit_code" ) <0 )return -1 ;
@@ -347,7 +347,7 @@ static int kvm_nested_vmexit_inject_handler(struct trace_seq *s, struct tep_reco }static int kvm_nested_vmexit_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {tep_print_num_field (s,"rip %lx " , event,"rip" , record,1 );
@@ -370,7 +370,7 @@ union kvm_mmu_page_role { };static int kvm_mmu_print_role (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {unsigned long long val; static const char *access_str[] =
@@ -412,7 +412,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record,return 0 ; }static int kvm_mmu_get_page_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {unsigned long long val;
plugins/plugin_mac80211.c +5 -5
@@ -11,7 +11,7 @@#define INDENT 65 -static void print_string (struct trace_seq *s,struct tep_event_format *event, +static void print_string (struct trace_seq *s,struct tep_event *event,const char *name,const void *data) {struct tep_format_field *f =tep_find_field (event, name);
@@ -44,7 +44,7 @@ struct value_name {const char *name; }; -static void _print_enum (struct trace_seq *s,struct tep_event_format *event, +static void _print_enum (struct trace_seq *s,struct tep_event *event,const char *name,const void *data,const struct value_name *names,int n_names) {
@@ -77,7 +77,7 @@ static void _print_enum(struct trace_seq *s, struct tep_event_format *event,_print_enum (s, ev, name, data, __n,sizeof (__n)/sizeof (__n[0 ])); \ }) -static void _print_flag (struct trace_seq *s,struct tep_event_format *event, +static void _print_flag (struct trace_seq *s,struct tep_event *event,const char *name,const void *data,const struct value_name *names,int n_names) {
@@ -125,7 +125,7 @@ static void _print_flag(struct trace_seq *s, struct tep_event_format *event,#define SP () trace_seq_putc(s, ' ')static int drv_bss_info_changed (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {void *data = record->data;
@@ -153,7 +153,7 @@ static int drv_bss_info_changed(struct trace_seq *s, struct tep_record *record, }static int drv_config (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {void *data = record->data;
plugins/plugin_sched_switch.c +2 -2
@@ -51,7 +51,7 @@ static void write_and_save_comm(struct tep_format_field *field, }static int sched_wakeup_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_format_field *field;unsigned long long val;
@@ -79,7 +79,7 @@ static int sched_wakeup_handler(struct trace_seq *s, struct tep_record *record, }static int sched_switch_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {struct tep_format_field *field;unsigned long long val;
plugins/plugin_tlb.c +1 -1
@@ -17,7 +17,7 @@ enum tlb_flush_reason { };static int tlb_flush_handler (struct trace_seq *s,struct tep_record *record, -struct tep_event_format *event,void *context) +struct tep_event *event,void *context) {unsigned long long val;
python/ctracecmd.i +5 -5
@@ -32,7 +32,7 @@ %inline %{ static int python_callback(struct trace_seq *s, struct tep_record *record, - struct tep_event_format *event, + struct tep_event *event, void *context); static int skip_output = 0;
@@ -82,7 +82,7 @@ void py_pevent_register_event_handler(struct tep_handle *pevent, int id, static PyObject *py_field_get_stack(struct tep_handle *pevent, struct tep_record *record, - struct tep_event_format *event, + struct tep_event *event, int long_size) { PyObject *list;
@@ -169,7 +169,7 @@ static PyObject *py_field_get_str(struct tep_format_field *f, struct tep_record strnlen((char *)r->data + f->offset, f->size)); } -static PyObject *py_format_get_keys(struct tep_event_format *ef) +static PyObject *py_format_get_keys(struct tep_event *ef) { PyObject *list; struct tep_format_field *f;
@@ -191,7 +191,7 @@ static PyObject *py_format_get_keys(struct tep_event_format *ef) %wrapper %{ static int python_callback(struct trace_seq *s, struct tep_record *record, - struct tep_event_format *event, + struct tep_event *event, void *context) { PyObject *arglist, *result;
@@ -205,7 +205,7 @@ static int python_callback(struct trace_seq *s, SWIG_NewPointerObj(SWIG_as_voidptr(record), SWIGTYPE_p_tep_record, 0), SWIG_NewPointerObj(SWIG_as_voidptr(event), - SWIGTYPE_p_tep_event_format, 0)); + SWIGTYPE_p_tep_event, 0)); result = PyEval_CallObject(context, arglist); Py_XDECREF(arglist);
tracecmd/trace-hist.c +11 -11
@@ -530,7 +530,7 @@ process_sched_switch(struct tep_handle *pevent, struct tep_record *record)static void process_event (struct tep_handle *pevent,struct tep_record *record,int type) { -struct tep_event_format *event; +struct tep_event *event;const char *event_name;unsigned long long val;int pid;
@@ -592,11 +592,11 @@ process_record(struct tep_handle *pevent, struct tep_record *record)process_event (pevent, record, type); } -static struct tep_event_format * +static struct tep_event *update_event (struct tep_handle *pevent,const char *sys,const char *name,int *id) { -struct tep_event_format *event; +struct tep_event *event; event =tep_find_event_by_name (pevent, sys, name);if (!event)
@@ -609,7 +609,7 @@ update_event(struct tep_handle *pevent,static void update_sched_wakeup (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"sched" ,"sched_wakeup" , &sched_wakeup_type);if (!event)
@@ -621,7 +621,7 @@ static void update_sched_wakeup(struct tep_handle *pevent)static void update_sched_wakeup_new (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"sched" ,"sched_wakeup_new" , &sched_wakeup_new_type);if (!event)
@@ -633,7 +633,7 @@ static void update_sched_wakeup_new(struct tep_handle *pevent)static void update_sched_switch (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"sched" ,"sched_switch" , &sched_switch_type);if (!event)
@@ -647,7 +647,7 @@ static void update_sched_switch(struct tep_handle *pevent)static void update_function (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"ftrace" ,"function" , &function_type);if (!event)
@@ -659,7 +659,7 @@ static void update_function(struct tep_handle *pevent)static void update_function_graph_entry (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"ftrace" ,"funcgraph_entry" , &function_graph_entry_type);if (!event)
@@ -671,7 +671,7 @@ static void update_function_graph_entry(struct tep_handle *pevent)static void update_function_graph_exit (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"ftrace" ,"funcgraph_exit" , &function_graph_exit_type);if (!event)
@@ -686,7 +686,7 @@ static void update_function_graph_exit(struct tep_handle *pevent)static void update_kernel_stack (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"ftrace" ,"kernel_stack" , &kernel_stack_type);if (!event)
@@ -934,7 +934,7 @@ static void print_chains(struct tep_handle *pevent)static void do_trace_hist (struct tracecmd_input *handle) {struct tep_handle *pevent =tracecmd_get_pevent (handle); -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;int cpus;int cpu;
tracecmd/trace-mem.c +9 -9
@@ -61,11 +61,11 @@ static void *zalloc(size_t size)return calloc (1 , size); } -static struct tep_event_format * +static struct tep_event *update_event (struct tep_handle *pevent,const char *sys,const char *name,int *id) { -struct tep_event_format *event; +struct tep_event *event; event =tep_find_event_by_name (pevent, sys, name);if (!event)
@@ -78,7 +78,7 @@ update_event(struct tep_handle *pevent,static void update_kmalloc (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kmalloc" , &kmalloc_type);if (!event)
@@ -92,7 +92,7 @@ static void update_kmalloc(struct tep_handle *pevent)static void update_kmalloc_node (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kmalloc_node" , &kmalloc_node_type);if (!event)
@@ -106,7 +106,7 @@ static void update_kmalloc_node(struct tep_handle *pevent)static void update_kfree (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kfree" , &kfree_type);if (!event)
@@ -117,7 +117,7 @@ static void update_kfree(struct tep_handle *pevent)static void update_kmem_cache_alloc (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kmem_cache_alloc" , &kmem_cache_alloc_type);if (!event)
@@ -131,7 +131,7 @@ static void update_kmem_cache_alloc(struct tep_handle *pevent)static void update_kmem_cache_alloc_node (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kmem_cache_alloc_node" , &kmem_cache_alloc_node_type);
@@ -146,7 +146,7 @@ static void update_kmem_cache_alloc_node(struct tep_handle *pevent)static void update_kmem_cache_free (struct tep_handle *pevent) { -struct tep_event_format *event; +struct tep_event *event; event =update_event (pevent,"kmem" ,"kmem_cache_free" , &kmem_cache_free_type);if (!event)
@@ -462,7 +462,7 @@ static void print_list(void)static void do_trace_mem (struct tracecmd_input *handle) {struct tep_handle *pevent =tracecmd_get_pevent (handle); -struct tep_event_format *event; +struct tep_event *event;struct tep_record *record;int missed_events =0 ;int cpus;
tracecmd/trace-profile.c +5 -5
@@ -71,7 +71,7 @@ struct event_data {struct trace_hash_item hash;int id;int trace; -struct tep_event_format *event; +struct tep_event *event;struct event_data *end;struct event_data *start;
@@ -795,7 +795,7 @@ static struct event_data * add_event(struct handle_data *h, const char *system, const char *event_name, enum event_data_type type) { - struct tep_event_format *event; + struct tep_event *event;struct event_data *event_data; event =tep_find_event_by_name (h->pevent, system, event_name);
@@ -870,9 +870,9 @@ mate_events(struct handle_data *h, struct event_data *start,* @global: The events are global and not per task */ void tracecmd_mate_events (struct tracecmd_input *handle, -struct tep_event_format *start_event, +struct tep_event *start_event,const char *pid_field,const char *end_match_field, -struct tep_event_format *end_event, +struct tep_event *end_event,const char *start_match_field,int migrate,int global) {
@@ -1268,7 +1268,7 @@ void trace_init_profile(struct tracecmd_input *handle, struct hook_list *hook, int global) {struct tep_handle *pevent =tracecmd_get_pevent (handle); -struct tep_event_format **events; +struct tep_event **events;struct tep_format_field **fields;struct handle_data *h;struct event_data *event_data;
tracecmd/trace-read.c +8 -8
@@ -529,7 +529,7 @@ static void process_filters(struct handle_list *handles)static void init_wakeup (struct tracecmd_input *handle) { -struct tep_event_format *event; +struct tep_event *event;struct tep_handle *pevent;if (!show_wakeup)
@@ -789,7 +789,7 @@ void trace_show_data(struct tracecmd_input *handle, struct tep_record *record) } use_trace_clock =tracecmd_get_use_trace_clock (handle);if (tsdiff) { -struct tep_event_format *event; +struct tep_event *event;unsigned long long rec_ts = record->ts; event =tep_find_event_by_record (pevent, record);
@@ -927,7 +927,7 @@ test_stacktrace(struct handle_list *handles, struct tep_record *record,struct stack_info_cpu *cpu_info;struct handle_list *h;struct tracecmd_input *handle; -struct tep_event_format *event; +struct tep_event *event;struct tep_handle *pevent;static int init;int ret;
@@ -1116,7 +1116,7 @@ static void read_data_info(struct list_head *handle_list, enum output_type otypestruct handle_list *last_handle;struct tep_record *record;struct tep_record *last_record; -struct tep_event_format *event; +struct tep_event *event;struct tep_handle *pevent;int cpus;int ret;
@@ -1335,8 +1335,8 @@ static void process_plugin_option(char *option)static void set_event_flags (struct tep_handle *pevent,struct event_str *list,unsigned int flag) { -struct tep_event_format **events; -struct tep_event_format *event; +struct tep_event **events; +struct tep_event *event;struct event_str *str;regex_t regex;int ret;
@@ -1735,8 +1735,8 @@ void trace_report (int argc, char **argv) }if (show_events) { -struct tep_event_format **events; -struct tep_event_format *event; +struct tep_event **events; +struct tep_event *event;int i; events =tep_list_events (pevent,TEP_EVENT_SORT_SYSTEM );
tracecmd/trace-record.c +1 -1
@@ -3347,7 +3347,7 @@ static void add_func(struct func_list **list, const char *mod, const char *func)static unsigned long long find_ts_in_page (struct tep_handle *pevent,void *page,int size) { -struct tep_event_format *event; +struct tep_event *event;struct tep_format_field *field;struct tep_record *last_record =NULL ;struct tep_record *record;
Signature · 1 line
2.19.2
PATCH 3/6 tools lib traceevent: Rename tep_free_format() to tep_free_event()
In reply to Tzvetomir StoyanovIn order to make libtraceevent into a proper library, variables, data structures and functions require a unique prefix to prevent name space conflicts. This renames tep_free_format() to tep_free_event(), which describes more closely the purpose of the function.
--- include/traceevent/event-parse.h | 2 +- lib/traceevent/event-parse.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
include/traceevent/event-parse.h +1 -1
@@ -464,7 +464,7 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent,struct tep_event **eventp, const char *buf, unsigned long size, const char *sys); -void tep_free_format (struct tep_event *event); +void tep_free_event (struct tep_event *event);void tep_free_format_field (struct tep_format_field *field); void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event,
lib/traceevent/event-parse.c +3 -3
@@ -6156,7 +6156,7 @@ __parse_event(struct tep_handle *pevent,return 0 ; event_add_failed: -tep_free_format (event); +tep_free_event (event);return ret; }
@@ -6794,7 +6794,7 @@ static void free_formats(struct tep_format *format)free_format_fields (format->fields); } -void tep_free_format (struct tep_event *event) +void tep_free_event (struct tep_event *event) {free (event->name);free (event->system);
@@ -6880,7 +6880,7 @@ void tep_free(struct tep_handle *pevent) }for (i =0 ; i < pevent->nr_events; i++) -tep_free_format (pevent->events[i]); +tep_free_event (pevent->events[i]);while (pevent->handlers) { handle = pevent->handlers;
Signature · 1 line
2.19.2
PATCH 4/6 tools lib traceevent: traceevent API cleanup
In reply to Tzvetomir StoyanovIn order to make libtraceevent into a proper library, its API should be straightforward. This patch hides few API functions, intended for internal usage only:
tep_free_event(), tep_free_format_field(), __tep_data2host2(), __tep_data2host4() and __tep_data2host8().
The patch also alignes the libtraceevent summary man page with these API changes.
--- include/traceevent/event-parse.h | 17 ----------------- lib/trace-cmd/trace-input.c | 14 +++++++------- lib/traceevent/event-parse-api.c | 6 +++--- lib/traceevent/event-parse-local.h | 7 +++++++ lib/traceevent/event-parse.c | 13 ++++++++----- tracecmd/trace-output.c | 6 +++--- tracecmd/trace-split.c | 19 +++++++++++-------- 7 files changed, 39 insertions(+), 43 deletions(-)
include/traceevent/event-parse.h +0 -17
@@ -398,21 +398,6 @@ void tep_set_flag(struct tep_handle *tep, enum tep_flag flag);void tep_reset_flag (struct tep_handle *tep,enum tep_flag flag);int tep_check_flag (struct tep_handle *tep,enum tep_flag flag); -unsigned short __tep_data2host2 (struct tep_handle *pevent,unsigned short data); -unsigned int __tep_data2host4 (struct tep_handle *pevent,unsigned int data); -unsigned long long -__tep_data2host8 (struct tep_handle *pevent,unsigned long long data); - -#define tep_data2host2 (pevent, ptr) __tep_data2host2(pevent, *(unsigned short *)(ptr)) -#define tep_data2host4 (pevent, ptr) __tep_data2host4(pevent, *(unsigned int *)(ptr)) -#define tep_data2host8 (pevent, ptr) \ -({ \ - unsigned long long __val; \ - \ - memcpy(&__val, (ptr), sizeof(unsigned long long)); \ - __tep_data2host8(pevent, __val); \ -}) -static inline int tep_host_bigendian (void ) {unsigned char str[] = {0x1 ,0x2 ,0x3 ,0x4 };
@@ -464,8 +449,6 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent,struct tep_event **eventp, const char *buf, unsigned long size, const char *sys); -void tep_free_event (struct tep_event *event); -void tep_free_format_field (struct tep_format_field *field); void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event, const char *name, struct tep_record *record,
lib/trace-cmd/trace-input.c +7 -7
@@ -294,7 +294,7 @@ static int read4(struct tracecmd_input *handle, unsigned int *size)if (do_read_check (handle, &data,4 ))return -1 ; - *size =__tep_data2host4 (pevent, data); + *size =tep_read_number (pevent, &data,4 );return 0 ; }
@@ -306,7 +306,7 @@ static int read8(struct tracecmd_input *handle, unsigned long long *size)if (do_read_check (handle, &data,8 ))return -1 ; - *size =__tep_data2host8 (pevent, data); + *size =tep_read_number (pevent, &data,8 );return 0 ; }
@@ -2128,7 +2128,7 @@ static int handle_options(struct tracecmd_input *handle)/* next 4 bytes is the size of the option */ if (do_read_check (handle, &size,4 ))return -1 ; - size =__tep_data2host4 (handle->pevent, size); + size =tep_read_number (handle->pevent, &size,4 ); buf =malloc (size);if (!buf)return -ENOMEM ;
@@ -2184,7 +2184,7 @@ static int handle_options(struct tracecmd_input *handle)return -ENOMEM ; } offset = *(unsigned long long *)buf; - buffer->offset =__tep_data2host8 (handle->pevent, offset); + buffer->offset =tep_read_number (handle->pevent, &offset,8 );break ;case TRACECMD_OPTION_TRACECLOCK :if (!handle->ts2secs)
@@ -2200,7 +2200,7 @@ static int handle_options(struct tracecmd_input *handle)break ;case TRACECMD_OPTION_CPUCOUNT : cpus = *(int *)buf; - handle->cpus =__tep_data2host4 (handle->pevent, cpus); + handle->cpus =tep_read_number (handle->pevent, &cpus,4 );break ;default :warning ("unknown option %d" , option);
@@ -2818,7 +2818,7 @@ static int read_copy_size8(struct tracecmd_input *handle, int fd, unsigned longif (__do_write_check (fd, size,8 ))return -1 ; - *size =__tep_data2host8 (handle->pevent, *size); + *size =tep_read_number (handle->pevent, size,8 );return 0 ; }
@@ -2831,7 +2831,7 @@ static int read_copy_size4(struct tracecmd_input *handle, int fd, unsigned int *if (__do_write_check (fd, size,4 ))return -1 ; - *size =__tep_data2host4 (handle->pevent, *size); + *size =tep_read_number (handle->pevent, size,4 );return 0 ; }
lib/traceevent/event-parse-api.c +3 -3
@@ -93,7 +93,7 @@ int tep_check_flag(struct tep_handle *tep, enum tep_flag flag)return 0 ; } -unsigned short __tep_data2host2 (struct tep_handle *pevent,unsigned short data) +unsigned short tep_data2host2 (struct tep_handle *pevent,unsigned short data) {unsigned short swap;
@@ -106,7 +106,7 @@ unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)return swap; } -unsigned int __tep_data2host4 (struct tep_handle *pevent,unsigned int data) +unsigned int tep_data2host4 (struct tep_handle *pevent,unsigned int data) {unsigned int swap;
@@ -122,7 +122,7 @@ unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data) }unsigned long long -__tep_data2host8 (struct tep_handle *pevent,unsigned long long data) +tep_data2host8 (struct tep_handle *pevent,unsigned long long data) {unsigned long long swap;
lib/traceevent/event-parse-local.h +7 -0
@@ -91,4 +91,11 @@ struct tep_handle { char *trace_clock; }; +void tep_free_event (struct tep_event *event); +void tep_free_format_field (struct tep_format_field *field); + +unsigned short tep_data2host2 (struct tep_handle *pevent,unsigned short data); +unsigned int tep_data2host4 (struct tep_handle *pevent,unsigned int data); +unsigned long long tep_data2host8 (struct tep_handle *pevent,unsigned long long data); +#endif /* _PARSE_EVENTS_INT_H */
lib/traceevent/event-parse.c +8 -5
@@ -3329,15 +3329,18 @@ tep_find_any_field(struct tep_event *event, const char *name)unsigned long long tep_read_number (struct tep_handle *pevent,const void *ptr,int size) { +unsigned long long val; +switch (size) {case 1 :return *(unsigned char *)ptr;case 2 : -return tep_data2host2 (pevent, ptr); +return tep_data2host2 (pevent, *(unsigned short *)ptr);case 4 : -return tep_data2host4 (pevent, ptr); +return tep_data2host4 (pevent, *(unsigned int *)ptr);case 8 : -return tep_data2host8 (pevent, ptr); +memcpy (&val, (ptr),sizeof (unsigned long long )); +return tep_data2host8 (pevent, val);default :/* BUG! */ return 0 ;
@@ -4063,7 +4066,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, f =tep_find_any_field (event, arg->string.string); arg->string.offset = f->offset; } - str_offset =tep_data2host4 (pevent, data + arg->string.offset); + str_offset =tep_data2host4 (pevent, *(unsigned int *)(data + arg->string.offset)); str_offset &=0xffff ;print_str_to_seq (s, format, len_arg, ((char *)data) + str_offset);break ;
@@ -4081,7 +4084,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, f =tep_find_any_field (event, arg->bitmask.bitmask); arg->bitmask.offset = f->offset; } - bitmask_offset =tep_data2host4 (pevent, data + arg->bitmask.offset); + bitmask_offset =tep_data2host4 (pevent, *(unsigned int *)(data + arg->bitmask.offset)); bitmask_size = bitmask_offset >>16 ; bitmask_offset &=0xffff ; print_bitmask_to_seq(pevent, s, format, len_arg,
tracecmd/trace-output.c +3 -3
@@ -84,7 +84,7 @@ static short convert_endian_2(struct tracecmd_output *handle, short val)if (!handle->pevent)return val; -return __tep_data2host2 (handle->pevent, val); +return tep_read_number (handle->pevent, &val,2 ); }static int convert_endian_4 (struct tracecmd_output *handle,int val)
@@ -92,7 +92,7 @@ static int convert_endian_4(struct tracecmd_output *handle, int val)if (!handle->pevent)return val; -return __tep_data2host4 (handle->pevent, val); +return tep_read_number (handle->pevent, &val,4 ); } static unsigned long long convert_endian_8(struct tracecmd_output *handle,
@@ -101,7 +101,7 @@ static unsigned long long convert_endian_8(struct tracecmd_output *handle,if (!handle->pevent)return val; -return __tep_data2host8 (handle->pevent, val); +return tep_read_number (handle->pevent, &val,8 ); }void tracecmd_output_free (struct tracecmd_output *handle)
tracecmd/trace-split.c +11 -8
@@ -69,7 +69,7 @@ static int create_type_len(struct tep_handle *pevent, int time, int len)else time = (time <<5 ) | len; -return __tep_data2host4 (pevent, time); +return tep_read_number (pevent, &time,4 ); } static int write_record(struct tracecmd_input *handle,
@@ -100,7 +100,7 @@ static int write_record(struct tracecmd_input *handle, *(unsigned *)ptr = time; ptr +=4 ; time = (unsigned int )(diff >>27 ); - *(unsigned *)ptr =__tep_data2host4 (pevent, time); + *(unsigned *)ptr =tep_read_number (pevent, &time,4 ); cpu_data->ts = record->ts; cpu_data->index +=8 ;return 0 ;
@@ -122,7 +122,7 @@ static int write_record(struct tracecmd_input *handle,if (!len) { len = record->size +4 ; - *(unsigned *)ptr =__tep_data2host4 (pevent, len); + *(unsigned *)ptr =tep_read_number (pevent, &len,4 ); ptr +=4 ; index +=4 ; }
@@ -141,12 +141,15 @@ static int write_record(struct tracecmd_input *handle,static void write_page (struct tep_handle *pevent,struct cpu_data *cpu_data,int long_size) { -if (long_size ==8 ) +if (long_size ==8 ) { +unsigned long long index = cpu_data->index -16 ; *(unsigned long long *)cpu_data->commit = -__tep_data2host8 (pevent, (unsigned long long )cpu_data->index -16 ); -else +tep_read_number (pevent, &index,8 ); + }else { +unsigned int index = cpu_data->index -12 ; *(unsigned int *)cpu_data->commit = -__tep_data2host4 (pevent, cpu_data->index -12 ); +tep_read_number (pevent, &index,4 ); + }write (cpu_data->fd, cpu_data->page, page_size); }
@@ -239,7 +242,7 @@ static int parse_cpu(struct tracecmd_input *handle, ptr = cpu_data[cpu].page; *(unsigned long long *)ptr = -__tep_data2host8 (pevent, record->ts); +tep_read_number (pevent, &(record->ts),8 ); cpu_data[cpu].ts = record->ts; ptr +=8 ; cpu_data[cpu].commit = ptr;
Signature · 1 line
2.19.2
PATCH 5/6 tools lib traceevent: Added support for pkg-config
In reply to Tzvetomir StoyanovThis patch implements integration with pkg-config framework. pkg-config can be used by the library users to determine required CFLAGS and LDFLAGS in order to use the library
--- Makefile | 44 ++++++++++++++++++++---- lib/traceevent/libtraceevent.pc.template | 10 ++++++ 2 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 lib/traceevent/libtraceevent.pc.template
Makefile +38 -6
@@ -29,6 +29,7 @@ endef # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix. $(call allow-override,CC,$(CROSS_COMPILE)gcc) $(call allow-override,AR,$(CROSS_COMPILE)ar) +$(call allow-override,PKG_CONFIG,pkg-config) EXT = -std=gnu99 INSTALL = install
@@ -40,6 +41,13 @@ INSTALL = install DESTDIR ?= DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' +LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + prefix ?= /usr/local bindir_relative = bin bindir = $(prefix)/$(bindir_relative)
@@ -49,10 +57,16 @@ html_install = $(prefix)/share/kernelshark/html html_install_SQ = '$(subst ','\'',$(html_install))' img_install = $(prefix)/share/kernelshark/html/images img_install_SQ = '$(subst ','\'',$(img_install))' -libdir ?= $(prefix)/lib +libdir ?= $(prefix)/$(libdir_relative) libdir_SQ = '$(subst ','\'',$(libdir))' -includedir = $(prefix)/include/trace-cmd -includedir_SQ = '$(subst ','\'',$(includedir))' +includedir_libtrace_relative = traceevent +includedir_tc_relative = trace-cmd +includedir_tc = $(prefix)/include/$(includedir_tc_relative) +includedir_libtrace = $(prefix)/include/$(includedir_libtrace_relative) +includedir_tc_SQ = '$(subst ','\'',$(includedir_tc))' +includedir_libtrace_SQ = '$(subst ','\'',$(includedir_libtrace))' +pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \ + --variable pc_path pkg-config | tr ":" " ")) export man_dir man_dir_SQ html_install html_install_SQ INSTALL export img_install img_install_SQ
@@ -305,6 +319,20 @@ show_gui_make: PHONY += show_gui_make +PKG_CONFIG_FILE = libtraceevent.pc +define do_install_pkgconfig_file + if [ -n "${pkgconfig_dir}" ]; then \ + cp -f lib/traceevent/${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; \ + sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|LIB_VERSION|${TRACECMD_VERSION}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \ + sed -i "s|HEADER_DIR|$(includedir_libtrace)|g" ${PKG_CONFIG_FILE}; \ + $(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); \ + else \ + (echo Failed to locate pkg-config directory) 1>&2; \ + fi +endef + define find_tag_files find . -name '\.pc' -prune -o -name '*\.[ch]' -print -o -name '*\.[ch]pp' \ ! -name '\.#' -print
@@ -322,6 +350,9 @@ cscope: force $(RM) cscope* $(call find_tag_files) | cscope -b -q +install_pkgconfig: + $(Q)$(call do_install_pkgconfig_file,$(prefix)) + install_plugins: force $(Q)$(MAKE) -C $(src)/plugins $@
@@ -341,11 +372,11 @@ install: install_cmd install_gui: install_cmd gui $(Q)$(MAKE) $(S) -C $(kshark-dir)/build install -install_libs: libs +install_libs: libs install_pkgconfig $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)) $(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ)) - $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ)) - $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)) + $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_libtrace_SQ)) + $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_tc_SQ)) doc: $(MAKE) -C $(src)/Documentation all
@@ -359,6 +390,7 @@ install_doc: clean: $(RM) *.o *~ *.a *.so .*.d $(RM) tags TAGS cscope* + $(RM) -f $(PKG_CONFIG_FILE) $(MAKE) -C $(src)/lib/traceevent clean $(MAKE) -C $(src)/lib/trace-cmd clean $(MAKE) -C $(src)/kernel-shark clean
lib/traceevent/libtraceevent.pc.template new file +10 -0
@@ -0,0 +1,10 @@ +prefix=INSTALL_PREFIX +libdir=LIB_DIR +includedir=HEADER_DIR + +Name: libtraceevent +URL: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git +Description: Linux kernel trace event library +Version: LIB_VERSION +Cflags: -I${includedir} +Libs: -L${libdir} -ltraceevent
Signature · 1 line
2.19.2
Re: [PATCH 5/6] tools lib traceevent: Added support for pkg-config
Quoted 4 lines · On Wed, 5 Dec 2018 09:21:52 +0000 Tzvetomir Stoyanov <[email protected]>…
This patch implements integration with pkg-config framework. pkg-config can be used by the library users to determine required CFLAGS and LDFLAGS in order to use the library
I applied patches 1-4 in my trace-cmd repo, but I'm not going to apply this and patch 6. Although trace-cmd may hold a copy of the libtraceevent source code, I don't want it to install it. The kernel/tools/lib/traceevent is going to be the official home of the libtraceevent library, and because of that trace-cmd should not be installing it as that will lead to conflicts in the future.
I would be OK to have a pkg-config when we start to create a trace-cmd (libftrace) library. But that's going to be in the future.
Thanks!
-- Steve
PATCH 6/6 tools lib traceevent: Install trace-seq.h API header file
In reply to Tzvetomir StoyanovThis patch installs trace-seq.h header file on "make install".
--- Makefile | 1 + 1 file changed, 1 insertion(+)
Makefile +1 -0
@@ -376,6 +376,7 @@ install_libs: libs install_pkgconfig $(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ)) $(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ)) $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_libtrace_SQ)) + $(Q)$(call do_install,$(src)/include/traceevent/trace-seq.h,$(includedir_libtrace_SQ)) $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_tc_SQ)) doc:
Signature · 1 line
2.19.2