Skip to contentSkip to conversation

trace-cmd: libtracecmd: Rename private functions to fix static building

PATCH New Metin Kaya 1 participant 1 message Nov 26, 2024

lore
Share & tools
lore

Metin Kaya

author
#0 lore raw

PATCH v3 1/1 trace-cmd: libtracecmd: Rename private functions to fix static building

Building trace-cmd statically fails because of duplicated symbols for strstrip() function which is also implemented in libtracefs. The __hidden attribute does not resolve these conflicts for static builds due to the lack of namespacing support in C. Refer to the associated Bugzilla page for further details.

Although only strstrip() breaks the static build as of now, we should fix the underlying issue comprehensively across the libtraceevent, libtracefs, and trace-cmd packages. The recommendation is prepending "tcmd_" to private functions (tagged with __hidden attribute).

Thus:
1. Do not touch private functions which start with "tracecmd_" if they are referenced under tracecmd/ directory.
2. If a private function starts with "trace_", then just change its prefix to "tcmd_".
3. Prepend "tcmd_" prefix to all remaining private functions.

Future __hidden functions should follow this prefixing schemed to avoid new naming conflicts.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217768

---
Changes since v2: https://lore.kernel.org/linux-trace-devel/[email protected]

- Revert naming changes for the functions which start with "tracecmd_" and referenced under tracecmd/ directory. Apparently tracecmd_tsync_get_proto() is the only function that satisfies this criterion.
- Revert buggy renaming of TRACECMD_FILTER_MATCH.

Changes since v1: https://lore.kernel.org/linux-trace-devel/[email protected]

- Use "tcmd_" prefix instead of "tracecmd_".

 .../include/private/trace-cmd-private.h       |  20 +-
 lib/trace-cmd/include/private/trace-hash.h    |  10 +-
 lib/trace-cmd/include/private/trace-rbtree.h  |   6 +-
 lib/trace-cmd/include/trace-cmd-local.h       |  81 ++--
 lib/trace-cmd/trace-filter.c                  |  10 +-
 lib/trace-cmd/trace-hash.c                    |  13 +-
 lib/trace-cmd/trace-input.c                   | 228 ++++++------
 lib/trace-cmd/trace-maps.c                    |  20 +-
 lib/trace-cmd/trace-msg.c                     |   6 +-
 lib/trace-cmd/trace-output.c                  | 346 +++++++++---------
 lib/trace-cmd/trace-perf.c                    |  22 +-
 lib/trace-cmd/trace-rbtree.c                  |   9 +-
 lib/trace-cmd/trace-timesync.c                |   5 +-
 lib/trace-cmd/trace-util.c                    |  18 +-
 tracecmd/include/trace-local.h                |  24 +-
 tracecmd/trace-agent.c                        |  12 +-
 tracecmd/trace-check-events.c                 |   2 +-
 tracecmd/trace-list.c                         |   4 +-
 tracecmd/trace-listen.c                       |   6 +-
 tracecmd/trace-profile.c                      |  59 ++-
 tracecmd/trace-read.c                         |  10 +-
 tracecmd/trace-record.c                       |  28 +-
 tracecmd/trace-vm.c                           |   2 +-
 tracecmd/trace-vsock.c                        |  14 +-
 24 files changed, 480 insertions(+), 475 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +10 -10
index e2f22315..809e244b 100644
@@ -28,7 +28,7 @@
 
 #define TSCNSEC_CLOCK	"tsc2nsec"
 
-struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep, int flags);
+struct tep_plugin_list *tcmd_load_plugins(struct tep_handle *tep, int flags);
 
 int *tracecmd_add_id(int *list, int id, int len);
 
@@ -204,8 +204,8 @@ int tracecmd_copy_buffer_descr(struct tracecmd_input *in_handle,
 			       struct tracecmd_output *out_handle);
 int tracecmd_copy_options(struct tracecmd_input *in_handle,
 			  struct tracecmd_output *out_handle);
-int tracecmd_copy_trace_data(struct tracecmd_input *in_handle,
-			     struct tracecmd_output *out_handle);
+int tcmd_copy_trace_data(struct tracecmd_input *in_handle,
+			 struct tracecmd_output *out_handle);
 void tracecmd_set_flag(struct tracecmd_input *handle, int flag);
 void tracecmd_clear_flag(struct tracecmd_input *handle, int flag);
 unsigned long tracecmd_get_flags(struct tracecmd_input *handle);
@@ -504,7 +504,7 @@ enum tracecmd_time_sync_role {
 
 void tracecmd_tsync_init(void);
 int tracecmd_tsync_proto_getall(struct tracecmd_tsync_protos **protos, const char *clock, int role);
-bool tsync_proto_is_supported(const char *proto_name);
+bool tcmd_tsync_proto_is_supported(const char *proto_name);
 struct tracecmd_time_sync *
 tracecmd_tsync_with_host(int fd, const char *proto, const char *clock,
 			 int remote_id, int local_id);
@@ -518,7 +518,7 @@ int tracecmd_tsync_get_offsets(struct tracecmd_time_sync *tsync, int cpu,
 			       int *count, long long **ts,
 			       long long **offsets, long long **scalings, long long **frac);
 const char *tracecmd_tsync_get_proto(const struct tracecmd_tsync_protos *protos,
-			 const char *clock, enum tracecmd_time_sync_role role);
+				     const char *clock, enum tracecmd_time_sync_role role);
 void tracecmd_tsync_free(struct tracecmd_time_sync *tsync);
 int tracecmd_write_guest_time_shift(struct tracecmd_output *handle,
 				    struct tracecmd_time_sync *tsync);
@@ -571,8 +571,8 @@ int tracecmd_load_chunks_info(struct tracecmd_compression *handle,
 /* --- Plugin handling --- */
 extern struct tep_plugin_option trace_ftrace_options[];
 
-char **trace_util_find_plugin_files(const char *suffix);
-void trace_util_free_plugin_files(char **files);
+char **tcmd_util_find_plugin_files(const char *suffix);
+void tcmd_util_free_plugin_files(char **files);
 
 /* Used for trace-cmd list */
 void tracecmd_ftrace_load_options(void);
@@ -633,9 +633,9 @@ struct trace_perf {
 	struct perf_event_attr pe;
 	struct perf_event_mmap_page *mmap;
 };
-int trace_perf_init(struct trace_perf *perf, int pages, int cpu, int pid);
-int trace_perf_open(struct trace_perf *perf);
-void trace_perf_close(struct trace_perf *perf);
+int tcmd_perf_init(struct trace_perf *perf, int pages, int cpu, int pid);
+int tcmd_perf_open(struct trace_perf *perf);
+void tcmd_perf_close(struct trace_perf *perf);
 #endif
 
 #endif /* _TRACE_CMD_PRIVATE_H */
lib/trace-cmd/include/private/trace-hash.h +5 -5
index aa92cdfe..16ad44a5 100644
@@ -18,10 +18,10 @@ struct trace_hash {
 	int			power;
 };
 
-int trace_hash_init(struct trace_hash *hash, int buckets);
-void trace_hash_free(struct trace_hash *hash);
-int trace_hash_add(struct trace_hash *hash, struct trace_hash_item *item);
-int trace_hash_empty(struct trace_hash *hash);
+int tcmd_hash_init(struct trace_hash *hash, int buckets);
+void tcmd_hash_free(struct trace_hash *hash);
+int tcmd_hash_add(struct trace_hash *hash, struct trace_hash_item *item);
+int tcmd_hash_empty(struct trace_hash *hash);
 
 static inline void trace_hash_del(struct trace_hash_item *item)
 {
@@ -49,7 +49,7 @@ static inline void trace_hash_del(struct trace_hash_item *item)
 typedef int (*trace_hash_func)(struct trace_hash_item *item, void *data);
 
 struct trace_hash_item *
-trace_hash_find(struct trace_hash *hash, unsigned long long key,
+tcmd_hash_find(struct trace_hash *hash, unsigned long long key,
 		trace_hash_func match, void *data);
 
 #endif /* _TRACE_HASH_H */
lib/trace-cmd/include/private/trace-rbtree.h +3 -3
index 82211199..7b70f699 100644
@@ -24,11 +24,11 @@ struct trace_rbtree {
 	size_t				nr_nodes;
 };
 
-void trace_rbtree_init(struct trace_rbtree *tree, trace_rbtree_cmp_fn cmp_fn,
-		       trace_rbtree_search_fn search_fn);
+void tcmd_rbtree_init(struct trace_rbtree *tree, trace_rbtree_cmp_fn cmp_fn,
+		      trace_rbtree_search_fn search_fn);
 struct trace_rbtree_node *trace_rbtree_find(struct trace_rbtree *tree, const void *data);
 void trace_rbtree_delete(struct trace_rbtree *tree, struct trace_rbtree_node *node);
-int trace_rbtree_insert(struct trace_rbtree *tree, struct trace_rbtree_node *node);
+int tcmd_rbtree_insert(struct trace_rbtree *tree, struct trace_rbtree_node *node);
 struct trace_rbtree_node *trace_rbtree_pop_nobalance(struct trace_rbtree *tree);
 
 #endif /* _TRACE_RBTREE_H */
lib/trace-cmd/include/trace-cmd-local.h +41 -40

106 lines not on this page · raw message

lib/trace-cmd/trace-filter.c +5 -5
index 99423223..4ec822db 100644
@@ -44,8 +44,8 @@ static bool test_stacktraces(struct tracecmd_filter *filter, struct tep_record *
 		test_stacktrace(filter, record, filter->user_stacktrace_id);
 }
 
-__hidden enum tracecmd_filters tracecmd_filter_match(struct tracecmd_filter *filter,
-						     struct tep_record *record)
+__hidden enum tracecmd_filters
+tcmd_filter_match(struct tracecmd_filter *filter, struct tep_record *record)
 {
 	bool is_stack = false;
 	bool found = false;
@@ -135,12 +135,12 @@ struct tracecmd_filter *tracecmd_filter_add(struct tracecmd_input *handle,
 
 	tep = tracecmd_get_tep(handle);
 
-	trace_filter = tracecmd_filter_get(handle);
+	trace_filter = tcmd_filter_get(handle);
 	if (!trace_filter) {
 		trace_filter = calloc(1, sizeof(*trace_filter));
 		if (!trace_filter)
 			goto fail;
-		tracecmd_filter_set(handle, trace_filter);
+		tcmd_filter_set(handle, trace_filter);
 		trace_filter->tep = tep;
 	}
 
@@ -188,7 +188,7 @@ static void free_filters (struct filter **filter, int nr)
 	free(filter);
 }
 
-__hidden void tracecmd_filter_free(struct tracecmd_filter *trace_filter)
+__hidden void tcmd_filter_free(struct tracecmd_filter *trace_filter)
 {
 	if (!trace_filter)
 		return;
lib/trace-cmd/trace-hash.c +7 -6
index bed97323..2ee668ed 100644
@@ -12,7 +12,7 @@
 #include "trace-cmd-private.h"
 #include "trace-hash.h"
 
-int __hidden trace_hash_init(struct trace_hash *hash, int buckets)
+int __hidden tcmd_hash_init(struct trace_hash *hash, int buckets)
 {
 	memset(hash, 0, sizeof(*hash));
 
@@ -28,12 +28,12 @@ int __hidden trace_hash_init(struct trace_hash *hash, int buckets)
 	return 0;
 }
 
-void __hidden trace_hash_free(struct trace_hash *hash)
+void __hidden tcmd_hash_free(struct trace_hash *hash)
 {
 	free(hash->buckets);
 }
 
-int __hidden trace_hash_empty(struct trace_hash *hash)
+int __hidden tcmd_hash_empty(struct trace_hash *hash)
 {
 	struct trace_hash_item **bucket;
 
@@ -43,7 +43,7 @@ int __hidden trace_hash_empty(struct trace_hash *hash)
 	return 1;
 }
 
-int __hidden trace_hash_add(struct trace_hash *hash, struct trace_hash_item *item)
+int __hidden tcmd_hash_add(struct trace_hash *hash, struct trace_hash_item *item)
 {
 	struct trace_hash_item *next;
 	int bucket = hash->power ? item->key & hash->power :
@@ -64,8 +64,9 @@ int __hidden trace_hash_add(struct trace_hash *hash, struct trace_hash_item *ite
 }
 
  __hidden struct trace_hash_item *
-trace_hash_find(struct trace_hash *hash, unsigned long long key,
-		trace_hash_func match, void *data)
+tcmd_hash_find(struct trace_hash *hash,
+	       unsigned long long key,
+	       trace_hash_func match, void *data)
 {
 	struct trace_hash_item *item;
 	int bucket = hash->power ? key & hash->power :
lib/trace-cmd/trace-input.c +114 -114

719 lines not on this page · raw message

lib/trace-cmd/trace-maps.c +10 -10
index bd16486f..d445ffea 100644
@@ -74,8 +74,8 @@ int tracecmd_map_vcpus(struct tracecmd_input **handles, int nr_handles)
 			gmap[k].self = &gmap[k];
 		}
 
-		trace_set_guest_map(handles[i], gmap);
-		trace_set_guest_map_cnt(handles[i], vcpu_count);
+		tcmd_set_guest_map(handles[i], gmap);
+		tcmd_set_guest_map_cnt(handles[i], vcpu_count);
 
 		/* Update the host mapping of all guests to the host */
 		map = realloc(vcpu_maps, sizeof(*map) * (nr_vcpu_maps + vcpu_count));
@@ -96,8 +96,8 @@ int tracecmd_map_vcpus(struct tracecmd_input **handles, int nr_handles)
 	/* We want to do a binary search via host_pid to find these mappings */
 	qsort(vcpu_maps, nr_vcpu_maps, sizeof(*map), cmp_map);
 
-	trace_set_guest_map(handles[0], vcpu_maps);
-	trace_set_guest_map_cnt(handles[0], nr_vcpu_maps);
+	tcmd_set_guest_map(handles[0], vcpu_maps);
+	tcmd_set_guest_map_cnt(handles[0], nr_vcpu_maps);
 
 	return mappings;
 
@@ -106,7 +106,7 @@ int tracecmd_map_vcpus(struct tracecmd_input **handles, int nr_handles)
 	return -1;
 }
 
-__hidden void trace_guest_map_free(struct tracecmd_cpu_map *map)
+__hidden void tcmd_guest_map_free(struct tracecmd_cpu_map *map)
 {
 	free(map);
 }
@@ -118,7 +118,7 @@ struct tracecmd_cpu_map *tracecmd_map_find_by_host_pid(struct tracecmd_input *ha
 	struct tracecmd_cpu_map key;
 	int nr_maps;
 
-	map = trace_get_guest_map(handle);
+	map = tcmd_get_guest_map(handle);
 	if (!map)
 		return NULL;
 
@@ -126,11 +126,11 @@ struct tracecmd_cpu_map *tracecmd_map_find_by_host_pid(struct tracecmd_input *ha
 	handle = map->host_handle;
 
 	/* And again, get the mapping of the host, as it has all the mappings */
-	map = trace_get_guest_map(handle);
+	map = tcmd_get_guest_map(handle);
 	if (!map)
 		return NULL;
 
-	nr_maps = trace_get_guest_map_cnt(handle);
+	nr_maps = tcmd_get_guest_map_cnt(handle);
 
 	key.host_pid = host_pid;
 
@@ -168,10 +168,10 @@ struct tracecmd_cpu_map *tracecmd_get_cpu_map(struct tracecmd_input *handle, int
 	struct tracecmd_cpu_map *map;
 	int cnt;
 
-	map = trace_get_guest_map(handle);
+	map = tcmd_get_guest_map(handle);
 	/* Make sure it's for the guest handle, as this could be a host handle */
 	map = map->self;
-	cnt = trace_get_guest_map_cnt(map->guest_handle);
+	cnt = tcmd_get_guest_map_cnt(map->guest_handle);
 	if (cnt <= cpu)
 		return NULL;
 
lib/trace-cmd/trace-msg.c +3 -3
index f5c604f1..c2b14db9 100644
@@ -183,7 +183,7 @@ static int __msg_write(int fd, struct tracecmd_msg *msg, bool network)
 	return __do_write_check(fd, msg->buf, data_size);
 }
 
-__hidden off_t msg_lseek(struct tracecmd_msg_handle *msg_handle, off_t offset, int whence)
+__hidden off_t tcmd_msg_lseek(struct tracecmd_msg_handle *msg_handle, off_t offset, int whence)
 {
 	off_t cache_offset = msg_handle->cache_start_offset;
 	off_t ret;
@@ -855,7 +855,7 @@ int tracecmd_msg_send_options(struct tracecmd_msg_handle *msg_handle,
 	void *buf;
 	int ret;
 
-	buf = trace_get_options(handle, &len);
+	buf = tcmd_get_options(handle, &len);
 	if (!buf)
 		return -1;
 
@@ -963,7 +963,7 @@ int tracecmd_msg_read_options(struct tracecmd_msg_handle *msg_handle,
 	}
 	msg_free(&msg);
 
-	ret = trace_append_options(handle, buf, len);
+	ret = tcmd_append_options(handle, buf, len);
 	free(buf);
 
 	return ret;
lib/trace-cmd/trace-output.c +174 -172

1,048 lines not on this page · raw message

lib/trace-cmd/trace-perf.c +11 -11
index a10da55d..f0f8ae32 100644
@@ -31,7 +31,7 @@ static void default_perf_init_pe(struct perf_event_attr *pe)
 }
 
 /**
- * trace_perf_init - Initialize perf context
+ * tcmd_perf_init - Initialize perf context
  *
  * @perf: structure, representing perf context, that will be initialized.
  * @pages: Number of perf memory mapped pages.
@@ -39,12 +39,12 @@ static void default_perf_init_pe(struct perf_event_attr *pe)
  * @pid: PID, associated with this perf context.
  *
  * The perf context in initialized with default values. The caller can set
- * custom perf parameters in perf->pe, before calling trace_perf_open() API.
+ * custom perf parameters in perf->pe, before calling tcmd_perf_open() API.
  *
  * Returns 0 on success, or -1 in case of an error.
  *
  */
-int __hidden trace_perf_init(struct trace_perf *perf, int pages, int cpu, int pid)
+int __hidden tcmd_perf_init(struct trace_perf *perf, int pages, int cpu, int pid)
 {
 	if (!perf)
 		return -1;
@@ -60,13 +60,13 @@ int __hidden trace_perf_init(struct trace_perf *perf, int pages, int cpu, int pi
 }
 
 /**
- * trace_perf_close - Close perf session
+ * tcmd_perf_close - Close perf session
  *
  * @perf: structure, representing context of a running perf session, opened
- *	  with trace_perf_open()
+ *	  with tcmd_perf_open()
  *
  */
-void __hidden trace_perf_close(struct trace_perf *perf)
+void __hidden tcmd_perf_close(struct trace_perf *perf)
 {
 	if (perf->fd >= 0)
 		close(perf->fd);
@@ -77,15 +77,15 @@ void __hidden trace_perf_close(struct trace_perf *perf)
 }
 
 /**
- * trace_perf_open - Open perf session
+ * tcmd_perf_open - Open perf session
  *
  * @perf: structure, representing perf context that will be opened. It must be
- *	  initialized with trace_perf_init().
+ *	  initialized with tcmd_perf_init().
  *
  * Returns 0 on success, or -1 in case of an error. In case of success, the
- * session must be closed with trace_perf_close()
+ * session must be closed with tcmd_perf_close()
  */
-int __hidden trace_perf_open(struct trace_perf *perf)
+int __hidden tcmd_perf_open(struct trace_perf *perf)
 {
 	perf->fd = syscall(__NR_perf_event_open, &perf->pe, perf->pid, perf->cpu, -1, 0);
 	if (perf->fd < 0)
@@ -100,6 +100,6 @@ int __hidden trace_perf_open(struct trace_perf *perf)
 	return 0;
 
 error:
-	trace_perf_close(perf);
+	tcmd_perf_close(perf);
 	return -1;
 }
lib/trace-cmd/trace-rbtree.c +5 -4
index 90671819..e1890bfa 100644
@@ -13,7 +13,7 @@ enum {
 	BLACK,
 };
 
-void __hidden trace_rbtree_init(struct trace_rbtree *tree, trace_rbtree_cmp_fn cmp_fn,
+void __hidden tcmd_rbtree_init(struct trace_rbtree *tree, trace_rbtree_cmp_fn cmp_fn,
 				trace_rbtree_search_fn search_fn)
 {
 	memset(tree, 0, sizeof(*tree));
@@ -163,7 +163,7 @@ static void check_tree(struct trace_rbtree *tree)
 static inline void check_tree(struct trace_rbtree *tree) { }
 #endif
 
-int __hidden trace_rbtree_insert(struct trace_rbtree *tree,
+int __hidden tcmd_rbtree_insert(struct trace_rbtree *tree,
 				 struct trace_rbtree_node *node)
 {
 	struct trace_rbtree_node *uncle;
@@ -371,8 +371,9 @@ void trace_rbtree_delete(struct trace_rbtree *tree, struct trace_rbtree_node *no
 	check_tree(tree);
 }
 
-__hidden struct trace_rbtree_node *trace_rbtree_next(struct trace_rbtree *tree,
-						     struct trace_rbtree_node *node)
+__hidden struct trace_rbtree_node *
+tcmd_rbtree_next(struct trace_rbtree *tree,
+		 struct trace_rbtree_node *node)
 {
 	check_tree(tree);
 	/*
lib/trace-cmd/trace-timesync.c +3 -2
index 6ee4e643..1dd4881c 100644
@@ -116,7 +116,7 @@ int tracecmd_tsync_proto_unregister(char *proto_name)
 	return -1;
 }
 
-bool __hidden tsync_proto_is_supported(const char *proto_name)
+bool __hidden tcmd_tsync_proto_is_supported(const char *proto_name)
 {
 	if (tsync_proto_find(proto_name))
 		return true;
@@ -250,7 +250,8 @@ tsync_proto_select(const struct tracecmd_tsync_protos *protos,
  */
 __hidden const char *
 tracecmd_tsync_get_proto(const struct tracecmd_tsync_protos *protos,
-			 const char *clock, enum tracecmd_time_sync_role role)
+			 const char *clock,
+			 enum tracecmd_time_sync_role role)
 {
 	return tsync_proto_select(protos, clock, role);
 }
lib/trace-cmd/trace-util.c +9 -9
index 37caab45..14975d32 100644
@@ -280,7 +280,7 @@ static void add_plugin_file(struct tep_handle *pevent, const char *path,
 }
 
 /**
- * trace_util_find_plugin_files - find list of possible plugin files
+ * tcmd_util_find_plugin_files - find list of possible plugin files
  * @suffix: The suffix of the plugin files to find
  *
  * Searches the plugin directory for files that end in @suffix, and
@@ -291,9 +291,9 @@ static void add_plugin_file(struct tep_handle *pevent, const char *path,
  * the errno will be returned with the TRACECMD_ERR_MSK to denote
  * such an error occurred.
  *
- * Use trace_util_free_plugin_files() to free the result.
+ * Use tcmd_util_free_plugin_files() to free the result.
  */
-__hidden char **trace_util_find_plugin_files(const char *suffix)
+__hidden char **tcmd_util_find_plugin_files(const char *suffix)
 {
 	struct add_plugin_data pdata;
 
@@ -308,12 +308,12 @@ __hidden char **trace_util_find_plugin_files(const char *suffix)
 }
 
 /**
- * trace_util_free_plugin_files - free the result of trace_util_find_plugin_files()
- * @files: The result from trace_util_find_plugin_files()
+ * tcmd_util_free_plugin_files - free the result of tcmd_util_find_plugin_files()
+ * @files: The result from tcmd_util_find_plugin_files()
  *
- * Frees the contents that were allocated by trace_util_find_plugin_files().
+ * Frees the contents that were allocated by tcmd_util_find_plugin_files().
  */
-void __hidden trace_util_free_plugin_files(char **files)
+void __hidden tcmd_util_free_plugin_files(char **files)
 {
 	int i;
 
@@ -349,7 +349,7 @@ static char *get_source_plugins_dir(void)
 }
 
 __hidden struct tep_plugin_list *
-trace_load_plugins(struct tep_handle *tep, int flags)
+tcmd_load_plugins(struct tep_handle *tep, int flags)
 {
 	struct tep_plugin_list *list;
 	char *path;
@@ -659,7 +659,7 @@ static void __attribute__((destructor)) tracecmd_lib_free(void)
 	tracecmd_compress_free();
 }
 
-__hidden bool check_file_state(unsigned long file_version, int current_state, int new_state)
+__hidden bool tcmd_check_file_state(unsigned long file_version, int current_state, int new_state)
 {
 	if (file_version >= FILE_VERSION_SECTIONS) {
 		if (current_state < TRACECMD_FILE_INIT)
tracecmd/include/trace-local.h +12 -12
index 1515fbbe..54a1b51e 100644
@@ -399,27 +399,27 @@ int get_local_cid(unsigned int *cid);
 char *trace_get_guest_file(const char *file, const char *guest);
 
 #ifdef VSOCK
-int trace_vsock_open(unsigned int cid, unsigned int port);
-int trace_vsock_make(unsigned int port);
-int trace_vsock_make_any(void);
+int tcmd_vsock_open(unsigned int cid, unsigned int port);
+int tcmd_vsock_make(unsigned int port);
+int tcmd_vsock_make_any(void);
 int get_vsocket_params(int fd, unsigned int *lcid, unsigned int *rcid);
-int trace_vsock_get_port(int sd, unsigned int *port);
-bool trace_vsock_can_splice_read(void);
-int trace_vsock_local_cid(void);
+int tcmd_vsock_get_port(int sd, unsigned int *port);
+bool tcmd_vsock_can_splice_read(void);
+int tcmd_vsock_local_cid(void);
 int trace_vsock_print_connection(int fd);
 #else
-static inline int trace_vsock_open(unsigned int cid, unsigned int port)
+static inline int tcmd_vsock_open(unsigned int cid, unsigned int port)
 {
 	return -ENOTSUP;
 }
 
-static inline int trace_vsock_make(unsigned int port)
+static inline int tcmd_vsock_make(unsigned int port)
 {
 	return -ENOTSUP;
 
 }
 
-static inline int trace_vsock_make_any(void)
+static inline int tcmd_vsock_make_any(void)
 {
 	return -ENOTSUP;
 
@@ -430,17 +430,17 @@ static inline int get_vsocket_params(int fd, unsigned int *lcid, unsigned int *r
 	return -ENOTSUP;
 }
 
-static inline int trace_vsock_get_port(int sd, unsigned int *port)
+static inline int tcmd_vsock_get_port(int sd, unsigned int *port)
 {
 	return -ENOTSUP;
 }
 
-static inline bool trace_vsock_can_splice_read(void)
+static inline bool tcmd_vsock_can_splice_read(void)
 {
 	return false;
 }
 
-static inline int trace_vsock_local_cid(void)
+static inline int tcmd_vsock_local_cid(void)
 {
 	return -ENOTSUP;
 }
tracecmd/trace-agent.c +6 -6
index b6b44f58..10a10464 100644
@@ -32,11 +32,11 @@ static void make_vsocks(int nr, int *fds, unsigned int *ports)
 	int i, fd, ret;
 
 	for (i = 0; i < nr; i++) {
-		fd = trace_vsock_make_any();
+		fd = tcmd_vsock_make_any();
 		if (fd < 0)
 			die("Failed to open vsocket");
 
-		ret = trace_vsock_get_port(fd, &port);
+		ret = tcmd_vsock_get_port(fd, &port);
 		if (ret < 0)
 			die("Failed to get vsocket address");
 
@@ -223,9 +223,9 @@ static void agent_handle(int sd, int nr_cpus, int page_size,
 				remote_id = -1;
 				local_id = -2;
 			}
-			fd = trace_vsock_make_any();
+			fd = tcmd_vsock_make_any();
 			if (fd >= 0 &&
-			    trace_vsock_get_port(fd, &tsync_port) < 0) {
+			    tcmd_vsock_get_port(fd, &tsync_port) < 0) {
 				close(fd);
 				fd = -1;
 			}
@@ -327,13 +327,13 @@ static void agent_serve(unsigned int port, bool do_daemon, int proxy_id,
 		if (listen(sd, 5) < 0)
 			die("Failed to listen on %d\n", port);
 	} else
-		sd = trace_vsock_make(port);
+		sd = tcmd_vsock_make(port);
 	if (sd < 0)
 		die("Failed to open socket");
 	tracecmd_tsync_init();
 
 	if (!network) {
-		cid = trace_vsock_local_cid();
+		cid = tcmd_vsock_local_cid();
 		if (cid >= 0)
 			printf("listening on @%u:%u\n", cid, port);
 	}
tracecmd/trace-check-events.c +1 -1
index 46f57e17..e0b2fed7 100644
@@ -59,7 +59,7 @@ void trace_check_events(int argc, char **argv)
 	if (!pevent)
 		exit(EINVAL);
 
-	list = trace_load_plugins(pevent, open_flags);
+	list = tcmd_load_plugins(pevent, open_flags);
 	ret = tracefs_fill_local_events(tracing, pevent, &parsing_failures);
 	if (ret || parsing_failures)
 		ret = EINVAL;
tracecmd/trace-list.c +2 -2
index 8badd1f2..b2bbf280 100644
@@ -551,7 +551,7 @@ static void show_plugin_options(void)
 
 	trace_seq_init(&s);
 
-	list = trace_load_plugins(pevent, 0);
+	list = tcmd_load_plugins(pevent, 0);
 	tep_plugin_print_options(&s);
 	trace_seq_do_printf(&s);
 	tep_unload_plugins(list, pevent);
@@ -577,7 +577,7 @@ static void show_plugins(void)
 
 	trace_seq_init(&s);
 
-	list = trace_load_plugins(pevent, 0);
+	list = tcmd_load_plugins(pevent, 0);
 	tep_print_plugins(&s, "  ", "\n", list);
 
 	trace_seq_do_printf(&s);
tracecmd/trace-listen.c +3 -3
index e11bca03..2f505b73 100644
@@ -225,7 +225,7 @@ static int setup_vsock_port(int start_port, int *sfd)
 {
 	int sd;
 
-	sd = trace_vsock_make(start_port);
+	sd = tcmd_vsock_make(start_port);
 	if (sd < 0)
 		return -errno;
 	*sfd = sd;
@@ -1022,11 +1022,11 @@ static int get_vsock(const char *port)
 	unsigned int cid;
 	int sd;
 
-	sd = trace_vsock_make(atoi(port));
+	sd = tcmd_vsock_make(atoi(port));
 	if (sd < 0)
 		return sd;
 
-	cid = trace_vsock_local_cid();
+	cid = tcmd_vsock_local_cid();
 	if (cid >= 0)
 		printf("listening on @%u:%s\n", cid, port);
 
tracecmd/trace-profile.c +29 -30

195 lines not on this page · raw message

tracecmd/trace-read.c +5 -5
index a5a0e10a..355ee0f4 100644
@@ -609,7 +609,7 @@ static void init_wakeup(struct tracecmd_input *handle)
 
 	pevent = tracecmd_get_tep(handle);
 
-	trace_hash_init(&wakeup_hash, WAKEUP_HASH_SIZE);
+	tcmd_hash_init(&wakeup_hash, WAKEUP_HASH_SIZE);
 
 	event = tep_find_event_by_name(pevent, "sched", "sched_wakeup");
 	if (!event)
@@ -657,7 +657,7 @@ static void add_wakeup(unsigned int val, unsigned long long start)
 	struct wakeup_info *info;
 	struct trace_hash_item *item;
 
-	item = trace_hash_find(&wakeup_hash, key, NULL, NULL);
+	item = tcmd_hash_find(&wakeup_hash, key, NULL, NULL);
 	if (item) {
 		info = container_of(item, struct wakeup_info, hash);
 		/* Hmm, double wakeup? */
@@ -670,7 +670,7 @@ static void add_wakeup(unsigned int val, unsigned long long start)
 		die("Failed to allocate wakeup info");
 	info->hash.key = key;
 	info->start = start;
-	trace_hash_add(&wakeup_hash, &info->hash);
+	tcmd_hash_add(&wakeup_hash, &info->hash);
 }
 
 static unsigned long long max_lat = 0;
@@ -690,7 +690,7 @@ static void add_sched(unsigned int val, unsigned long long end, int rt)
 	struct wakeup_info *info;
 	unsigned long long cal;
 
-	item = trace_hash_find(&wakeup_hash, key, NULL, NULL);
+	item = tcmd_hash_find(&wakeup_hash, key, NULL, NULL);
 	if (!item)
 		return;
 
@@ -817,7 +817,7 @@ static void finish_wakeup(void)
 		}
 	}
 
-	trace_hash_free(&wakeup_hash);
+	tcmd_hash_free(&wakeup_hash);
 }
 
 void trace_show_data(struct tracecmd_input *handle, struct tep_record *record)
tracecmd/trace-record.c +14 -14
index 6e9b4535..f3b152e9 100644
@@ -3439,7 +3439,7 @@ static int connect_port(const char *host, unsigned int port, enum port_type type
 	int sfd;
 
 	if (type == USE_VSOCK)
-		return trace_vsock_open(atoi(host), port);
+		return tcmd_vsock_open(atoi(host), port);
 
 	results = do_getaddrinfo(host, port, type);
 
@@ -3580,14 +3580,14 @@ create_recorder_instance(struct buffer_instance *instance, const char *file, int
 			fd = connect_addr(result);
 			freeaddrinfo(result);
 		} else
-			fd = trace_vsock_open(instance->cid, instance->client_ports[cpu]);
+			fd = tcmd_vsock_open(instance->cid, instance->client_ports[cpu]);
 		if (fd < 0)
 			die("Failed to connect to agent");
 
 		flags = recorder_flags;
 		if (instance->use_fifos)
 			flags |= TRACECMD_RECORD_NOBRASS;
-		else if (!trace_vsock_can_splice_read())
+		else if (!tcmd_vsock_can_splice_read())
 			flags |= TRACECMD_RECORD_NOSPLICE;
 		return tracecmd_create_recorder_virt(file, cpu, flags, fd, max_kb);
 	}
@@ -3843,7 +3843,7 @@ static int connect_vsock(char *vhost)
 	if (!port)
 		die("vsocket must have format of 'CID:PORT'");
 
-	sd = trace_vsock_open(atoi(cid), atoi(port));
+	sd = tcmd_vsock_open(atoi(cid), atoi(port));
 
 	return sd;
 }
@@ -4105,7 +4105,7 @@ static int host_tsync(struct common_record_context *ctx,
 				  instance->port_type);
 	} else {
 		guest_id = instance->cid;
-		fd = trace_vsock_open(instance->cid, tsync_port);
+		fd = tcmd_vsock_open(instance->cid, tsync_port);
 	}
 
 	if (is_proxy(instance)) {
@@ -4151,7 +4151,7 @@ static void connect_to_agent(struct common_record_context *ctx,
 			role = TRACECMD_TIME_SYNC_ROLE_GUEST;
 		else
 			role = TRACECMD_TIME_SYNC_ROLE_HOST;
-		sd = trace_vsock_open(instance->cid, instance->port);
+		sd = tcmd_vsock_open(instance->cid, instance->port);
 		if (sd < 0)
 			die("Failed to connect to vsocket @%u:%u",
 			    instance->cid, instance->port);
@@ -4192,7 +4192,7 @@ static void connect_to_agent(struct common_record_context *ctx,
 	if (ret < 0)
 		die("Failed to receive trace response %d", ret);
 	if (tsync_protos_reply && tsync_protos_reply[0]) {
-		if (tsync_proto_is_supported(tsync_protos_reply)) {
+		if (tcmd_tsync_proto_is_supported(tsync_protos_reply)) {
 			printf("Negotiated %s time sync protocol with guest %s\n",
 				tsync_protos_reply,
 				instance->name);
@@ -6325,17 +6325,17 @@ static int get_tsc_nsec(int *shift, int *mult)
 		goto out;
 
 	supported = -1;
-	if (trace_perf_init(&perf, 1, 0, getpid()))
+	if (tcmd_perf_init(&perf, 1, 0, getpid()))
 		return -1;
-	if (trace_perf_open(&perf))
+	if (tcmd_perf_open(&perf))
 		return -1;
 	cpu_shift = perf.mmap->time_shift;
 	cpu_mult = perf.mmap->time_mult;
 	for (i = 1; i < cpus; i++) {
-		trace_perf_close(&perf);
-		if (trace_perf_init(&perf, 1, i, getpid()))
+		tcmd_perf_close(&perf);
+		if (tcmd_perf_init(&perf, 1, i, getpid()))
 			break;
-		if (trace_perf_open(&perf))
+		if (tcmd_perf_open(&perf))
 			break;
 		if (perf.mmap->time_shift != cpu_shift ||
 		    perf.mmap->time_mult != cpu_mult) {
@@ -6344,7 +6344,7 @@ static int get_tsc_nsec(int *shift, int *mult)
 			break;
 		}
 	}
-	trace_perf_close(&perf);
+	tcmd_perf_close(&perf);
 	if (i < cpus)
 		return -1;
 
@@ -7107,7 +7107,7 @@ static void set_tsync_params(struct common_record_context *ctx)
 	 * force using the x86-tsc clock for this host-guest tracing session
 	 * and store TSC to nsec multiplier and shift.
 	 */
-		if (tsync_proto_is_supported("kvm") &&
+		if (tcmd_tsync_proto_is_supported("kvm") &&
 		    trace_have_guests_pid() &&
 		    clock_is_supported(NULL, TSC_CLOCK) &&
 		    !get_tsc_nsec(&shift, &mult) && mult) {
tracecmd/trace-vm.c +1 -1
index 960ed5d5..94489d50 100644
@@ -325,7 +325,7 @@ static void find_pid_by_cid(struct trace_guest *guest)
 	int fd;
 
 	instance = start_trace_connect();
-	fd = trace_vsock_open(guest->cid, -1);
+	fd = tcmd_vsock_open(guest->cid, -1);
 	guest->pid = stop_trace_connect(instance);
 	/* Just in case! */
 	if (fd >= 0)
tracecmd/trace-vsock.c +7 -7
index df1a9800..ae93fa12 100644
@@ -6,7 +6,7 @@
 
 #include "trace-cmd-private.h"
 
-int __hidden trace_vsock_open(unsigned int cid, unsigned int port)
+int __hidden tcmd_vsock_open(unsigned int cid, unsigned int port)
 {
 	struct sockaddr_vm addr = {
 		.svm_family = AF_VSOCK,
@@ -27,7 +27,7 @@ int __hidden trace_vsock_open(unsigned int cid, unsigned int port)
 	return sd;
 }
 
-int __hidden trace_vsock_make(unsigned int port)
+int __hidden tcmd_vsock_make(unsigned int port)
 {
 	struct sockaddr_vm addr = {
 		.svm_family = AF_VSOCK,
@@ -55,12 +55,12 @@ error:
 	return -errno;
 }
 
-int __hidden trace_vsock_make_any(void)
+int __hidden tcmd_vsock_make_any(void)
 {
-	return trace_vsock_make(VMADDR_PORT_ANY);
+	return tcmd_vsock_make(VMADDR_PORT_ANY);
 }
 
-int __hidden trace_vsock_get_port(int sd, unsigned int *port)
+int __hidden tcmd_vsock_get_port(int sd, unsigned int *port)
 {
 	struct sockaddr_vm addr;
 	socklen_t addr_len = sizeof(addr);
@@ -155,7 +155,7 @@ out_close_sd:
 	return ret;
 }
 
-bool __hidden trace_vsock_can_splice_read(void)
+bool __hidden tcmd_vsock_can_splice_read(void)
 {
 	static bool initialized, res;
 
@@ -169,7 +169,7 @@ bool __hidden trace_vsock_can_splice_read(void)
 
 #define GET_LOCAL_CID	0x7b9
 
-int __hidden trace_vsock_local_cid(void)
+int __hidden tcmd_vsock_local_cid(void)
 {
 	int cid;
 	int fd;

base-commit: 201f95fdbe7c344a5875e5d78362bfdded74c2a9

Signature · 1 line
2.34.1