0001-trace-cmd-libtracecmd-API-cleanup.patch 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. From 4b6e124d8b5a0dfd21aedf21d2c347fc5f0705a2 Mon Sep 17 00:00:00 2001
  2. From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
  3. Date: Thu, 12 Nov 2020 13:52:08 +0200
  4. Subject: [PATCH] trace-cmd: libtracecmd API cleanup
  5. The tracecmd library is used by trace-cmd and KernelShark applications.
  6. All APIs, that are not used by KernelShark are removed from trace-cmd.h.
  7. This is the first step to cleanup the library APIs and dependencies.
  8. Link: https://lore.kernel.org/linux-trace-devel/20201112115208.1250789-3-tz.stoyanov@gmail.com
  9. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
  10. Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  11. [Retrieved from:
  12. https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/commit/?id=4b6e124d8b5a0dfd21aedf21d2c347fc5f0705a2]
  13. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  14. ---
  15. Makefile | 2 +-
  16. include/trace-cmd/trace-cmd.h | 488 +-----------------
  17. include/trace-cmd/trace-filter-hash.h | 64 ---
  18. include/trace-cmd/trace-hash.h | 55 --
  19. include/trace-cmd/trace-msg.h | 15 -
  20. .../include/private/trace-cmd-private.h | 480 +++++++++++++++++
  21. .../include/private/trace-filter-hash.h | 64 +++
  22. lib/trace-cmd/include/private/trace-hash.h | 55 ++
  23. lib/trace-cmd/include/private/trace-msg.h | 15 +
  24. lib/trace-cmd/include/trace-cmd-local.h | 2 +
  25. lib/trace-cmd/trace-ftrace.c | 2 +-
  26. lib/trace-cmd/trace-hooks.c | 2 +-
  27. lib/trace-cmd/trace-recorder.c | 2 +-
  28. lib/trace-cmd/trace-timesync.c | 2 +-
  29. lib/trace-cmd/trace-util.c | 2 +-
  30. lib/traceevent/plugins/plugin_python_loader.c | 3 +-
  31. python/ctracecmd.i | 1 +
  32. tracecmd/include/trace-local.h | 2 +-
  33. 18 files changed, 637 insertions(+), 619 deletions(-)
  34. delete mode 100644 include/trace-cmd/trace-filter-hash.h
  35. delete mode 100644 include/trace-cmd/trace-hash.h
  36. delete mode 100644 include/trace-cmd/trace-msg.h
  37. create mode 100644 lib/trace-cmd/include/private/trace-cmd-private.h
  38. create mode 100644 lib/trace-cmd/include/private/trace-filter-hash.h
  39. create mode 100644 lib/trace-cmd/include/private/trace-hash.h
  40. create mode 100644 lib/trace-cmd/include/private/trace-msg.h
  41. diff --git a/Makefile b/Makefile
  42. index b034042..6ef6936 100644
  43. --- a/Makefile
  44. +++ b/Makefile
  45. @@ -224,6 +224,7 @@ INCLUDES += -I$(src)/include/trace-cmd
  46. INCLUDES += -I$(src)/include/tracefs
  47. INCLUDES += -I$(src)/lib/traceevent/include
  48. INCLUDES += -I$(src)/lib/trace-cmd/include
  49. +INCLUDES += -I$(src)/lib/trace-cmd/include/private
  50. INCLUDES += -I$(src)/lib/tracefs/include
  51. INCLUDES += -I$(src)/tracecmd/include
  52. INCLUDES += -I$(obj)/tracecmd/include
  53. @@ -417,7 +418,6 @@ install_libs: libs
  54. $(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ)/traceevent)
  55. $(Q)$(call do_install,$(src)/include/traceevent/trace-seq.h,$(includedir_SQ)/traceevent)
  56. $(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ)/trace-cmd)
  57. - $(Q)$(call do_install,$(src)/include/trace-cmd/trace-filter-hash.h,$(includedir_SQ)/trace-cmd)
  58. $(Q)$(call do_install,$(src)/include/tracefs/tracefs.h,$(includedir_SQ)/tracefs)
  59. $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/trace-cmd)
  60. $(Q)$(call do_install_ld,$(TRACE_LD_FILE),$(LD_SO_CONF_DIR),$(libdir_SQ)/traceevent)
  61. diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h
  62. index 3c2b474..9751ac3 100644
  63. --- a/include/trace-cmd/trace-cmd.h
  64. +++ b/include/trace-cmd/trace-cmd.h
  65. @@ -9,497 +9,31 @@
  66. #include "traceevent/event-parse.h"
  67. #include "tracefs/tracefs.h"
  68. -#define TRACECMD_MAGIC { 23, 8, 68 }
  69. -
  70. -#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
  71. -#define __weak __attribute__((weak))
  72. -#define __noreturn __attribute__((noreturn))
  73. -
  74. -#define TRACECMD_ERR_MSK ((unsigned long)(-1) & ~((1UL << 14) - 1))
  75. -#define TRACECMD_ISERR(ptr) ((unsigned long)(ptr) > TRACECMD_ERR_MSK)
  76. -#define TRACECMD_ERROR(ret) ((void *)((unsigned long)(ret) | TRACECMD_ERR_MSK))
  77. -#define TRACECMD_PTR2ERR(ptr) ((unisgned long)(ptr) & ~TRACECMD_ERR_MSK)
  78. -
  79. -void tracecmd_parse_cmdlines(struct tep_handle *pevent, char *file, int size);
  80. -void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
  81. -void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
  82. -struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep);
  83. -
  84. -int *tracecmd_add_id(int *list, int id, int len);
  85. -
  86. -enum {
  87. - RINGBUF_TYPE_PADDING = 29,
  88. - RINGBUF_TYPE_TIME_EXTEND = 30,
  89. - RINGBUF_TYPE_TIME_STAMP = 31,
  90. -};
  91. -
  92. -void tracecmd_record_ref(struct tep_record *record);
  93. -void free_record(struct tep_record *record);
  94. -
  95. -void tracecmd_set_debug(bool set_debug);
  96. -bool tracecmd_get_debug(void);
  97. -
  98. struct tracecmd_input;
  99. -struct tracecmd_output;
  100. -struct tracecmd_recorder;
  101. -struct hook_list;
  102. -
  103. -/* --- tracecmd plugins --- */
  104. -
  105. -extern int tracecmd_disable_sys_plugins;
  106. -extern int tracecmd_disable_plugins;
  107. -
  108. -enum tracecmd_context {
  109. - TRACECMD_INPUT,
  110. - TRACECMD_OUTPUT,
  111. -};
  112. -
  113. -enum tracecmd_plugin_flag {
  114. - TRACECMD_DISABLE_SYS_PLUGINS = 1,
  115. - TRACECMD_DISABLE_PLUGINS = 1 << 1,
  116. -};
  117. -
  118. -struct trace_plugin_context;
  119. -
  120. -struct trace_plugin_context *
  121. -tracecmd_plugin_context_create(enum tracecmd_context context, void *data);
  122. -
  123. -void tracecmd_plugin_set_flag(struct trace_plugin_context *context,
  124. - enum tracecmd_plugin_flag flag);
  125. -
  126. -#define TRACECMD_PLUGIN_LOADER tracecmd_plugin_loader
  127. -#define TRACECMD_PLUGIN_UNLOADER tracecmd_plugin_unloader
  128. -#define TRACECMD_PLUGIN_ALIAS tracecmd_plugin_alias
  129. -#define _MAKE_STR(x) #x
  130. -#define MAKE_STR(x) _MAKE_STR(x)
  131. -#define TRACECMD_PLUGIN_LOADER_NAME MAKE_STR(TRACECMD_PLUGIN_LOADER)
  132. -#define TRACECMD_PLUGIN_UNLOADER_NAME MAKE_STR(TRACECMD_PLUGIN_UNLOADER)
  133. -#define TRACECMD_PLUGIN_ALIAS_NAME MAKE_STR(TRACECMD_PLUGIN_ALIAS)
  134. -
  135. -typedef int (*tracecmd_plugin_load_func)(struct trace_plugin_context *trace);
  136. -typedef int (*tracecmd_plugin_unload_func)(struct trace_plugin_context *trace);
  137. -
  138. -struct tracecmd_input *
  139. -tracecmd_plugin_context_input(struct trace_plugin_context *trace_context);
  140. -struct tracecmd_output *
  141. -tracecmd_plugin_context_output(struct trace_plugin_context *trace_context);
  142. -
  143. -void tracecmd_set_quiet(struct tracecmd_output *handle, bool set_quiet);
  144. -bool tracecmd_get_quiet(struct tracecmd_output *handle);
  145. -
  146. -static inline int tracecmd_host_bigendian(void)
  147. -{
  148. - unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
  149. - unsigned int *ptr;
  150. -
  151. - ptr = (unsigned int *)str;
  152. - return *ptr == 0x01020304;
  153. -}
  154. -
  155. -/* --- Opening and Reading the trace.dat file --- */
  156. -
  157. -enum {
  158. - TRACECMD_OPTION_DONE,
  159. - TRACECMD_OPTION_DATE,
  160. - TRACECMD_OPTION_CPUSTAT,
  161. - TRACECMD_OPTION_BUFFER,
  162. - TRACECMD_OPTION_TRACECLOCK,
  163. - TRACECMD_OPTION_UNAME,
  164. - TRACECMD_OPTION_HOOK,
  165. - TRACECMD_OPTION_OFFSET,
  166. - TRACECMD_OPTION_CPUCOUNT,
  167. - TRACECMD_OPTION_VERSION,
  168. - TRACECMD_OPTION_PROCMAPS,
  169. - TRACECMD_OPTION_TRACEID,
  170. - TRACECMD_OPTION_TIME_SHIFT,
  171. - TRACECMD_OPTION_GUEST,
  172. -};
  173. -
  174. -enum {
  175. - TRACECMD_FL_IGNORE_DATE = (1 << 0),
  176. - TRACECMD_FL_BUFFER_INSTANCE = (1 << 1),
  177. - TRACECMD_FL_LATENCY = (1 << 2),
  178. - TRACECMD_FL_IN_USECS = (1 << 3),
  179. - TRACECMD_FL_FLYRECORD = (1 << 4),
  180. -};
  181. -
  182. -struct tracecmd_ftrace {
  183. - struct tracecmd_input *handle;
  184. - struct tep_event *fgraph_ret_event;
  185. - int fgraph_ret_id;
  186. - int long_size;
  187. -};
  188. -
  189. -struct tracecmd_proc_addr_map {
  190. - unsigned long long start;
  191. - unsigned long long end;
  192. - char *lib_name;
  193. -};
  194. -
  195. -typedef void (*tracecmd_show_data_func)(struct tracecmd_input *handle,
  196. - struct tep_record *record);
  197. -typedef void (*tracecmd_handle_init_func)(struct tracecmd_input *handle,
  198. - struct hook_list *hook, int global);
  199. -struct tracecmd_input *tracecmd_alloc(const char *file);
  200. -struct tracecmd_input *tracecmd_alloc_fd(int fd);
  201. -struct tracecmd_input *tracecmd_open(const char *file);
  202. struct tracecmd_input *tracecmd_open_head(const char *file);
  203. -struct tracecmd_input *tracecmd_open_fd(int fd);
  204. +void tracecmd_close(struct tracecmd_input *handle);
  205. int tracecmd_pair_peer(struct tracecmd_input *handle,
  206. struct tracecmd_input *peer);
  207. -void tracecmd_unpair_peer(struct tracecmd_input *handle);
  208. -void tracecmd_ref(struct tracecmd_input *handle);
  209. -void tracecmd_close(struct tracecmd_input *handle);
  210. -int tracecmd_read_headers(struct tracecmd_input *handle);
  211. -int tracecmd_get_parsing_failures(struct tracecmd_input *handle);
  212. -int tracecmd_long_size(struct tracecmd_input *handle);
  213. -int tracecmd_page_size(struct tracecmd_input *handle);
  214. -int tracecmd_cpus(struct tracecmd_input *handle);
  215. -int tracecmd_copy_headers(struct tracecmd_input *handle, int fd);
  216. -void tracecmd_set_flag(struct tracecmd_input *handle, int flag);
  217. -void tracecmd_clear_flag(struct tracecmd_input *handle, int flag);
  218. -unsigned long tracecmd_get_flags(struct tracecmd_input *handle);
  219. -unsigned long long tracecmd_get_traceid(struct tracecmd_input *handle);
  220. -int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
  221. - unsigned long long trace_id,
  222. - const char **name,
  223. - int *vcpu_count, const int **cpu_pid);
  224. -unsigned long long tracecmd_get_tsync_peer(struct tracecmd_input *handle);
  225. -int tracecmd_enable_tsync(struct tracecmd_input *handle, bool enable);
  226. -
  227. -void tracecmd_parse_trace_clock(struct tracecmd_input *handle, char *file, int size);
  228. -
  229. -int tracecmd_make_pipe(struct tracecmd_input *handle, int cpu, int fd, int cpus);
  230. -
  231. -int tracecmd_buffer_instances(struct tracecmd_input *handle);
  232. -const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx);
  233. -struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
  234. -int tracecmd_is_buffer_instance(struct tracecmd_input *handle);
  235. -
  236. -void tracecmd_set_ts_offset(struct tracecmd_input *handle, long long offset);
  237. -void tracecmd_set_ts2secs(struct tracecmd_input *handle, unsigned long long hz);
  238. -
  239. -void tracecmd_print_events(struct tracecmd_input *handle, const char *regex);
  240. -
  241. -struct hook_list *tracecmd_hooks(struct tracecmd_input *handle);
  242. int tracecmd_init_data(struct tracecmd_input *handle);
  243. -
  244. -void tracecmd_print_stats(struct tracecmd_input *handle);
  245. -void tracecmd_print_uname(struct tracecmd_input *handle);
  246. -void tracecmd_print_version(struct tracecmd_input *handle);
  247. -
  248. struct tep_record *
  249. -tracecmd_peek_data(struct tracecmd_input *handle, int cpu);
  250. -
  251. -static inline struct tep_record *
  252. -tracecmd_peek_data_ref(struct tracecmd_input *handle, int cpu)
  253. -{
  254. - struct tep_record *rec = tracecmd_peek_data(handle, cpu);
  255. - if (rec)
  256. - rec->ref_count++;
  257. - return rec;
  258. -}
  259. -
  260. +tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu);
  261. struct tep_record *
  262. tracecmd_read_data(struct tracecmd_input *handle, int cpu);
  263. -
  264. -struct tep_record *
  265. -tracecmd_read_prev(struct tracecmd_input *handle, struct tep_record *record);
  266. -
  267. -struct tep_record *
  268. -tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu);
  269. -
  270. -struct tep_record *
  271. -tracecmd_peek_next_data(struct tracecmd_input *handle, int *rec_cpu);
  272. -
  273. struct tep_record *
  274. tracecmd_read_at(struct tracecmd_input *handle, unsigned long long offset,
  275. int *cpu);
  276. -struct tep_record *
  277. -tracecmd_translate_data(struct tracecmd_input *handle,
  278. - void *ptr, int size);
  279. -struct tep_record *
  280. -tracecmd_read_cpu_first(struct tracecmd_input *handle, int cpu);
  281. -struct tep_record *
  282. -tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu);
  283. -int tracecmd_refresh_record(struct tracecmd_input *handle,
  284. - struct tep_record *record);
  285. -
  286. -int tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle,
  287. - int cpu, unsigned long long ts);
  288. -void
  289. -tracecmd_set_all_cpus_to_timestamp(struct tracecmd_input *handle,
  290. - unsigned long long time);
  291. -
  292. -int tracecmd_set_cursor(struct tracecmd_input *handle,
  293. - int cpu, unsigned long long offset);
  294. -unsigned long long
  295. -tracecmd_get_cursor(struct tracecmd_input *handle, int cpu);
  296. +void free_record(struct tep_record *record);
  297. -int tracecmd_ftrace_overrides(struct tracecmd_input *handle, struct tracecmd_ftrace *finfo);
  298. struct tep_handle *tracecmd_get_pevent(struct tracecmd_input *handle);
  299. -bool tracecmd_get_use_trace_clock(struct tracecmd_input *handle);
  300. -tracecmd_show_data_func
  301. -tracecmd_get_show_data_func(struct tracecmd_input *handle);
  302. -void tracecmd_set_show_data_func(struct tracecmd_input *handle,
  303. - tracecmd_show_data_func func);
  304. -
  305. -int tracecmd_record_at_buffer_start(struct tracecmd_input *handle, struct tep_record *record);
  306. -unsigned long long tracecmd_page_ts(struct tracecmd_input *handle,
  307. - struct tep_record *record);
  308. -unsigned int tracecmd_record_ts_delta(struct tracecmd_input *handle,
  309. - struct tep_record *record);
  310. -
  311. -struct tracecmd_proc_addr_map *
  312. -tracecmd_search_task_map(struct tracecmd_input *handle,
  313. - int pid, unsigned long long addr);
  314. -#ifndef SWIG
  315. -/* hack for function graph work around */
  316. -extern __thread struct tracecmd_input *tracecmd_curr_thread_handle;
  317. -#endif
  318. -
  319. -
  320. -/* --- Creating and Writing the trace.dat file --- */
  321. -
  322. -struct tracecmd_event_list {
  323. - struct tracecmd_event_list *next;
  324. - const char *glob;
  325. -};
  326. -
  327. -struct tracecmd_option;
  328. -struct tracecmd_msg_handle;
  329. -
  330. -struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus);
  331. -struct tracecmd_output *tracecmd_create_file(const char *output_file,
  332. - int cpus, char * const *cpu_data_files);
  333. -struct tracecmd_output *
  334. -tracecmd_create_file_glob(const char *output_file,
  335. - int cpus, char * const *cpu_data_files,
  336. - struct tracecmd_event_list *event_globs);
  337. -struct tracecmd_output *
  338. -tracecmd_create_init_file_glob(const char *output_file,
  339. - struct tracecmd_event_list *list);
  340. -struct tracecmd_output *tracecmd_create_init_fd(int fd);
  341. -struct tracecmd_output *
  342. -tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list);
  343. -struct tracecmd_output *
  344. -tracecmd_create_init_fd_msg(struct tracecmd_msg_handle *msg_handle,
  345. - struct tracecmd_event_list *list);
  346. -struct tracecmd_output *tracecmd_create_init_file(const char *output_file);
  347. -struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
  348. - const char *tracing_dir,
  349. - const char *kallsyms);
  350. -struct tracecmd_option *tracecmd_add_option(struct tracecmd_output *handle,
  351. - unsigned short id, int size,
  352. - const void *data);
  353. -struct tracecmd_option *
  354. -tracecmd_add_option_v(struct tracecmd_output *handle,
  355. - unsigned short id, const struct iovec *vector, int count);
  356. -
  357. -struct tracecmd_option *tracecmd_add_buffer_option(struct tracecmd_output *handle,
  358. - const char *name, int cpus);
  359. -
  360. -int tracecmd_write_cpus(struct tracecmd_output *handle, int cpus);
  361. -int tracecmd_write_options(struct tracecmd_output *handle);
  362. -int tracecmd_append_options(struct tracecmd_output *handle);
  363. -int tracecmd_update_option(struct tracecmd_output *handle,
  364. - struct tracecmd_option *option, int size,
  365. - const void *data);
  366. -void tracecmd_output_close(struct tracecmd_output *handle);
  367. -void tracecmd_output_free(struct tracecmd_output *handle);
  368. -struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
  369. - const char *file);
  370. -
  371. -int tracecmd_write_cpu_data(struct tracecmd_output *handle,
  372. - int cpus, char * const *cpu_data_files);
  373. -int tracecmd_append_cpu_data(struct tracecmd_output *handle,
  374. - int cpus, char * const *cpu_data_files);
  375. -int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
  376. - struct tracecmd_option *option,
  377. - int cpus, char * const *cpu_data_files);
  378. -
  379. -struct tracecmd_output *tracecmd_get_output_handle_fd(int fd);
  380. -
  381. -/* --- Reading the Fly Recorder Trace --- */
  382. -
  383. -enum {
  384. - TRACECMD_RECORD_NOSPLICE = (1 << 0), /* Use read instead of splice */
  385. - TRACECMD_RECORD_SNAPSHOT = (1 << 1), /* Extract from snapshot */
  386. - TRACECMD_RECORD_BLOCK = (1 << 2), /* Block on splice write */
  387. - TRACECMD_RECORD_NOBRASS = (1 << 3), /* Splice directly without a brass pipe */
  388. -};
  389. -
  390. -void tracecmd_free_recorder(struct tracecmd_recorder *recorder);
  391. -struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu, unsigned flags);
  392. -struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu, unsigned flags);
  393. -struct tracecmd_recorder *tracecmd_create_recorder_virt(const char *file, int cpu, unsigned flags, int trace_fd);
  394. -struct tracecmd_recorder *tracecmd_create_recorder_maxkb(const char *file, int cpu, unsigned flags, int maxkb);
  395. -struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd(int fd, int cpu, unsigned flags, const char *buffer);
  396. -struct tracecmd_recorder *tracecmd_create_buffer_recorder(const char *file, int cpu, unsigned flags, const char *buffer);
  397. -struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb(const char *file, int cpu, unsigned flags, const char *buffer, int maxkb);
  398. -
  399. -int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long sleep);
  400. -void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
  401. -long tracecmd_flush_recording(struct tracecmd_recorder *recorder);
  402. -
  403. -enum tracecmd_msg_flags {
  404. - TRACECMD_MSG_FL_USE_TCP = 1 << 0,
  405. -};
  406. -
  407. -/* for both client and server */
  408. -struct tracecmd_msg_handle {
  409. - int fd;
  410. - short cpu_count;
  411. - short version; /* Current protocol version */
  412. - unsigned long flags;
  413. - bool done;
  414. -};
  415. -
  416. -struct tracecmd_msg_handle *
  417. - tracecmd_msg_handle_alloc(int fd, unsigned long flags);
  418. -
  419. -/* Closes the socket and frees the handle */
  420. -void tracecmd_msg_handle_close(struct tracecmd_msg_handle *msg_handle);
  421. -
  422. -/* for clients */
  423. -int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
  424. - unsigned int **client_ports);
  425. -int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
  426. - const char *buf, int size);
  427. -int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle);
  428. -int tracecmd_msg_send_close_msg(struct tracecmd_msg_handle *msg_handle);
  429. -int tracecmd_msg_send_close_resp_msg(struct tracecmd_msg_handle *msg_handle);
  430. -int tracecmd_msg_wait_close(struct tracecmd_msg_handle *msg_handle);
  431. -int tracecmd_msg_wait_close_resp(struct tracecmd_msg_handle *msg_handle);
  432. -
  433. -/* for server */
  434. -int tracecmd_msg_initial_setting(struct tracecmd_msg_handle *msg_handle);
  435. -int tracecmd_msg_send_port_array(struct tracecmd_msg_handle *msg_handle,
  436. - unsigned *ports);
  437. -int tracecmd_msg_read_data(struct tracecmd_msg_handle *msg_handle, int ofd);
  438. -int tracecmd_msg_collect_data(struct tracecmd_msg_handle *msg_handle, int ofd);
  439. -bool tracecmd_msg_done(struct tracecmd_msg_handle *msg_handle);
  440. -void tracecmd_msg_set_done(struct tracecmd_msg_handle *msg_handle);
  441. -
  442. -int tracecmd_msg_send_trace_req(struct tracecmd_msg_handle *msg_handle,
  443. - int argc, char **argv, bool use_fifos,
  444. - unsigned long long trace_id,
  445. - char *tsync_protos,
  446. - int tsync_protos_size);
  447. -int tracecmd_msg_recv_trace_req(struct tracecmd_msg_handle *msg_handle,
  448. - int *argc, char ***argv, bool *use_fifos,
  449. - unsigned long long *trace_id,
  450. - char **tsync_protos,
  451. - unsigned int *tsync_protos_size);
  452. -
  453. -int tracecmd_msg_send_trace_resp(struct tracecmd_msg_handle *msg_handle,
  454. - int nr_cpus, int page_size,
  455. - unsigned int *ports, bool use_fifos,
  456. - unsigned long long trace_id,
  457. - unsigned int tsync_proto,
  458. - unsigned int tsync_port);
  459. -int tracecmd_msg_recv_trace_resp(struct tracecmd_msg_handle *msg_handle,
  460. - int *nr_cpus, int *page_size,
  461. - unsigned int **ports, bool *use_fifos,
  462. - unsigned long long *trace_id,
  463. - unsigned int *tsync_proto,
  464. - unsigned int *tsync_port);
  465. -
  466. -int tracecmd_msg_send_time_sync(struct tracecmd_msg_handle *msg_handle,
  467. - unsigned int sync_protocol,
  468. - unsigned int sync_msg_id,
  469. - unsigned int payload_size, char *payload);
  470. -int tracecmd_msg_recv_time_sync(struct tracecmd_msg_handle *msg_handle,
  471. - unsigned int *sync_protocol,
  472. - unsigned int *sync_msg_id,
  473. - unsigned int *payload_size, char **payload);
  474. -
  475. -/* --- Timestamp synchronization --- */
  476. -
  477. -enum{
  478. - TRACECMD_TIME_SYNC_PROTO_NONE = 0,
  479. -};
  480. -enum{
  481. - TRACECMD_TIME_SYNC_CMD_PROBE = 1,
  482. - TRACECMD_TIME_SYNC_CMD_STOP = 2,
  483. -};
  484. -
  485. -#define TRACECMD_TIME_SYNC_PROTO_PTP_WEIGHT 10
  486. -
  487. -struct tracecmd_time_sync {
  488. - unsigned int sync_proto;
  489. - int loop_interval;
  490. - pthread_mutex_t lock;
  491. - pthread_cond_t cond;
  492. - char *clock_str;
  493. - struct tracecmd_msg_handle *msg_handle;
  494. - void *context;
  495. -};
  496. -
  497. -void tracecmd_tsync_init(void);
  498. -int tracecmd_tsync_proto_getall(char **proto_mask, int *words);
  499. -unsigned int tracecmd_tsync_proto_select(char *proto_mask, int words);
  500. -bool tsync_proto_is_supported(unsigned int proto_id);
  501. -void tracecmd_tsync_with_host(struct tracecmd_time_sync *tsync);
  502. -void tracecmd_tsync_with_guest(struct tracecmd_time_sync *tsync);
  503. -int tracecmd_tsync_get_offsets(struct tracecmd_time_sync *tsync,
  504. - int *count,
  505. - long long **ts, long long **offsets);
  506. -void tracecmd_tsync_free(struct tracecmd_time_sync *tsync);
  507. -
  508. -/* --- Plugin handling --- */
  509. -extern struct tep_plugin_option trace_ftrace_options[];
  510. -
  511. -char **trace_util_find_plugin_files(const char *suffix);
  512. -void trace_util_free_plugin_files(char **files);
  513. -
  514. -/* Used for trace-cmd list */
  515. -void tracecmd_ftrace_load_options(void);
  516. -
  517. -/* event hooks */
  518. -
  519. -struct hook_list {
  520. - struct hook_list *next;
  521. - struct buffer_instance *instance;
  522. - const char *hook;
  523. - char *str;
  524. - char *start_system;
  525. - char *start_event;
  526. - char *start_match;
  527. - char *end_system;
  528. - char *end_event;
  529. - char *end_match;
  530. - char *pid;
  531. - int migrate;
  532. - int global;
  533. - int stack;
  534. -};
  535. -
  536. -struct hook_list *tracecmd_create_event_hook(const char *arg);
  537. -void tracecmd_free_hooks(struct hook_list *hooks);
  538. -
  539. -void tracecmd_plog(const char *fmt, ...);
  540. -void tracecmd_plog_error(const char *fmt, ...);
  541. -int tracecmd_set_logfile(char *logfile);
  542. -
  543. -/* --- System --- */
  544. -unsigned long long tracecmd_generate_traceid(void);
  545. -int tracecmd_count_cpus(void);
  546. -
  547. -/* --- Hack! --- */
  548. -int tracecmd_blk_hack(struct tracecmd_input *handle);
  549. -
  550. -/* --- Stack tracer functions --- */
  551. -int tracecmd_stack_tracer_status(int *status);
  552. -
  553. -/* --- Debugging --- */
  554. -struct kbuffer *tracecmd_record_kbuf(struct tracecmd_input *handle,
  555. - struct tep_record *record);
  556. -void *tracecmd_record_page(struct tracecmd_input *handle,
  557. - struct tep_record *record);
  558. -void *tracecmd_record_offset(struct tracecmd_input *handle,
  559. - struct tep_record *record);
  560. +unsigned long long tracecmd_get_traceid(struct tracecmd_input *handle);
  561. +int tracecmd_get_guest_cpumap(struct tracecmd_input *handle,
  562. + unsigned long long trace_id,
  563. + const char **name,
  564. + int *vcpu_count, const int **cpu_pid);
  565. +int tracecmd_buffer_instances(struct tracecmd_input *handle);
  566. +const char *tracecmd_buffer_instance_name(struct tracecmd_input *handle, int indx);
  567. +struct tracecmd_input *tracecmd_buffer_instance_handle(struct tracecmd_input *handle, int indx);
  568. #endif /* _TRACE_CMD_H */
  569. diff --git a/include/trace-cmd/trace-filter-hash.h b/include/trace-cmd/trace-filter-hash.h
  570. deleted file mode 100644
  571. index 4111c41..0000000
  572. --- a/include/trace-cmd/trace-filter-hash.h
  573. +++ /dev/null
  574. @@ -1,64 +0,0 @@
  575. -/* SPDX-License-Identifier: LGPL-2.1 */
  576. -/*
  577. - * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  578. - * Copyright (C) 2018 VMware Inc, Steven Rostedt <rostedt@goodmis.org>
  579. - *
  580. - */
  581. -#ifndef _TRACE_FILTER_HASH_H
  582. -#define _TRACE_FILTER_HASH_H
  583. -
  584. -#include <stdint.h>
  585. -
  586. -struct tracecmd_filter_id_item {
  587. - struct tracecmd_filter_id_item *next;
  588. - int id;
  589. -};
  590. -
  591. -struct tracecmd_filter_id {
  592. - struct tracecmd_filter_id_item **hash;
  593. - int count;
  594. -};
  595. -
  596. -/**
  597. - * tracecmd_quick_hash - A quick (non secured) hash alogirthm
  598. - * @val: The value to perform the hash on
  599. - * @bits: The size in bits you need to return
  600. - *
  601. - * This is a quick hashing function adapted from Donald E. Knuth's 32
  602. - * bit multiplicative hash. See The Art of Computer Programming (TAOCP).
  603. - * Multiplication by the Prime number, closest to the golden ratio of
  604. - * 2^32.
  605. - *
  606. - * @bits is used to max the result for use cases that require
  607. - * a power of 2 return value that is less than 32 bits. Any value
  608. - * of @bits greater than 31 (or zero), will simply return the full hash on @val.
  609. - */
  610. -static inline uint32_t tracecmd_quick_hash(uint32_t val, unsigned int bits)
  611. -{
  612. - val *= UINT32_C(2654435761);
  613. -
  614. - if (!bits || bits > 31)
  615. - return val;
  616. -
  617. - return val & ((1 << bits) - 1);
  618. -}
  619. -
  620. -struct tracecmd_filter_id_item *
  621. - tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id);
  622. -void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id);
  623. -void tracecmd_filter_id_remove(struct tracecmd_filter_id *hash, int id);
  624. -void tracecmd_filter_id_clear(struct tracecmd_filter_id *hash);
  625. -struct tracecmd_filter_id *tracecmd_filter_id_hash_alloc(void);
  626. -void tracecmd_filter_id_hash_free(struct tracecmd_filter_id *hash);
  627. -struct tracecmd_filter_id *
  628. - tracecmd_filter_id_hash_copy(struct tracecmd_filter_id *hash);
  629. -int *tracecmd_filter_ids(struct tracecmd_filter_id *hash);
  630. -int tracecmd_filter_id_compare(struct tracecmd_filter_id *hash1,
  631. - struct tracecmd_filter_id *hash2);
  632. -
  633. -static inline int tracecmd_filter_task_count(struct tracecmd_filter_id *hash)
  634. -{
  635. - return hash->count;
  636. -}
  637. -
  638. -#endif /* _TRACE_FILTER_HASH_H */
  639. diff --git a/include/trace-cmd/trace-hash.h b/include/trace-cmd/trace-hash.h
  640. deleted file mode 100644
  641. index aa92cdf..0000000
  642. --- a/include/trace-cmd/trace-hash.h
  643. +++ /dev/null
  644. @@ -1,55 +0,0 @@
  645. -/* SPDX-License-Identifier: GPL-2.0 */
  646. -/*
  647. - * Copyright (C) 2014 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  648. - *
  649. - */
  650. -#ifndef _TRACE_HASH_H
  651. -#define _TRACE_HASH_H
  652. -
  653. -struct trace_hash_item {
  654. - struct trace_hash_item *next;
  655. - struct trace_hash_item *prev;
  656. - unsigned long long key;
  657. -};
  658. -
  659. -struct trace_hash {
  660. - struct trace_hash_item **buckets;
  661. - int nr_buckets;
  662. - int power;
  663. -};
  664. -
  665. -int trace_hash_init(struct trace_hash *hash, int buckets);
  666. -void trace_hash_free(struct trace_hash *hash);
  667. -int trace_hash_add(struct trace_hash *hash, struct trace_hash_item *item);
  668. -int trace_hash_empty(struct trace_hash *hash);
  669. -
  670. -static inline void trace_hash_del(struct trace_hash_item *item)
  671. -{
  672. - struct trace_hash_item *prev = item->prev;
  673. -
  674. - prev->next = item->next;
  675. - if (item->next)
  676. - item->next->prev = prev;
  677. -}
  678. -
  679. -#define trace_hash_for_each_bucket(bucket, hash) \
  680. - for (bucket = (hash)->buckets; \
  681. - (bucket) < (hash)->buckets + (hash)->nr_buckets; (bucket)++)
  682. -
  683. -#define trace_hash_for_each_item(item, bucket) \
  684. - for ((item = *(bucket)); item; item = (item)->next)
  685. -
  686. -#define trace_hash_for_each_item_safe(item, n, bucket) \
  687. - for ((item = *(bucket)), n = item ? item->next : NULL; item; \
  688. - item = n, n = item ? (item)->next : NULL)
  689. -
  690. -#define trace_hash_while_item(item, bucket) \
  691. - while ((item = *(bucket)))
  692. -
  693. -typedef int (*trace_hash_func)(struct trace_hash_item *item, void *data);
  694. -
  695. -struct trace_hash_item *
  696. -trace_hash_find(struct trace_hash *hash, unsigned long long key,
  697. - trace_hash_func match, void *data);
  698. -
  699. -#endif /* _TRACE_HASH_H */
  700. diff --git a/include/trace-cmd/trace-msg.h b/include/trace-cmd/trace-msg.h
  701. deleted file mode 100644
  702. index aab8a69..0000000
  703. --- a/include/trace-cmd/trace-msg.h
  704. +++ /dev/null
  705. @@ -1,15 +0,0 @@
  706. -#ifndef _TRACE_MSG_H_
  707. -#define _TRACE_MSG_H_
  708. -
  709. -#include <stdbool.h>
  710. -
  711. -#define UDP_MAX_PACKET (65536 - 20)
  712. -#define V3_MAGIC "766679\0"
  713. -#define V3_CPU "-1V3"
  714. -
  715. -#define V1_PROTOCOL 1
  716. -#define V3_PROTOCOL 3
  717. -
  718. -extern unsigned int page_size;
  719. -
  720. -#endif /* _TRACE_MSG_H_ */
  721. diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
  722. new file mode 100644
  723. index 0000000..458760e
  724. --- /dev/null
  725. +++ b/lib/trace-cmd/include/private/trace-cmd-private.h
  726. @@ -0,0 +1,480 @@
  727. +/* SPDX-License-Identifier: LGPL-2.1 */
  728. +/*
  729. + * Copyright (C) 2008, 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  730. + *
  731. + */
  732. +#ifndef _TRACE_CMD_PRIVATE_H
  733. +#define _TRACE_CMD_PRIVATE_H
  734. +
  735. +#include "traceevent/event-parse.h"
  736. +#include "trace-cmd/trace-cmd.h"
  737. +
  738. +#define TRACECMD_MAGIC { 23, 8, 68 }
  739. +
  740. +#define ARRAY_SIZE(_a) (sizeof(_a) / sizeof((_a)[0]))
  741. +#define __weak __attribute__((weak))
  742. +#define __noreturn __attribute__((noreturn))
  743. +
  744. +#define TRACECMD_ERR_MSK ((unsigned long)(-1) & ~((1UL << 14) - 1))
  745. +#define TRACECMD_ISERR(ptr) ((unsigned long)(ptr) > TRACECMD_ERR_MSK)
  746. +#define TRACECMD_ERROR(ret) ((void *)((unsigned long)(ret) | TRACECMD_ERR_MSK))
  747. +#define TRACECMD_PTR2ERR(ptr) ((unisgned long)(ptr) & ~TRACECMD_ERR_MSK)
  748. +
  749. +void tracecmd_parse_cmdlines(struct tep_handle *pevent, char *file, int size);
  750. +void tracecmd_parse_proc_kallsyms(struct tep_handle *pevent, char *file, unsigned int size);
  751. +void tracecmd_parse_ftrace_printk(struct tep_handle *pevent, char *file, unsigned int size);
  752. +struct tep_plugin_list *trace_load_plugins(struct tep_handle *tep);
  753. +
  754. +int *tracecmd_add_id(int *list, int id, int len);
  755. +
  756. +enum {
  757. + RINGBUF_TYPE_PADDING = 29,
  758. + RINGBUF_TYPE_TIME_EXTEND = 30,
  759. + RINGBUF_TYPE_TIME_STAMP = 31,
  760. +};
  761. +
  762. +void tracecmd_record_ref(struct tep_record *record);
  763. +
  764. +void tracecmd_set_debug(bool set_debug);
  765. +bool tracecmd_get_debug(void);
  766. +
  767. +struct tracecmd_output;
  768. +struct tracecmd_recorder;
  769. +struct hook_list;
  770. +
  771. +/* --- tracecmd plugins --- */
  772. +
  773. +extern int tracecmd_disable_sys_plugins;
  774. +extern int tracecmd_disable_plugins;
  775. +
  776. +enum tracecmd_context {
  777. + TRACECMD_INPUT,
  778. + TRACECMD_OUTPUT,
  779. +};
  780. +
  781. +enum tracecmd_plugin_flag {
  782. + TRACECMD_DISABLE_SYS_PLUGINS = 1,
  783. + TRACECMD_DISABLE_PLUGINS = 1 << 1,
  784. +};
  785. +
  786. +struct trace_plugin_context;
  787. +
  788. +struct trace_plugin_context *
  789. +tracecmd_plugin_context_create(enum tracecmd_context context, void *data);
  790. +
  791. +void tracecmd_plugin_set_flag(struct trace_plugin_context *context,
  792. + enum tracecmd_plugin_flag flag);
  793. +
  794. +#define TRACECMD_PLUGIN_LOADER tracecmd_plugin_loader
  795. +#define TRACECMD_PLUGIN_UNLOADER tracecmd_plugin_unloader
  796. +#define TRACECMD_PLUGIN_ALIAS tracecmd_plugin_alias
  797. +#define _MAKE_STR(x) #x
  798. +#define MAKE_STR(x) _MAKE_STR(x)
  799. +#define TRACECMD_PLUGIN_LOADER_NAME MAKE_STR(TRACECMD_PLUGIN_LOADER)
  800. +#define TRACECMD_PLUGIN_UNLOADER_NAME MAKE_STR(TRACECMD_PLUGIN_UNLOADER)
  801. +#define TRACECMD_PLUGIN_ALIAS_NAME MAKE_STR(TRACECMD_PLUGIN_ALIAS)
  802. +
  803. +typedef int (*tracecmd_plugin_load_func)(struct trace_plugin_context *trace);
  804. +typedef int (*tracecmd_plugin_unload_func)(struct trace_plugin_context *trace);
  805. +
  806. +struct tracecmd_input *
  807. +tracecmd_plugin_context_input(struct trace_plugin_context *trace_context);
  808. +struct tracecmd_output *
  809. +tracecmd_plugin_context_output(struct trace_plugin_context *trace_context);
  810. +
  811. +void tracecmd_set_quiet(struct tracecmd_output *handle, bool set_quiet);
  812. +bool tracecmd_get_quiet(struct tracecmd_output *handle);
  813. +
  814. +static inline int tracecmd_host_bigendian(void)
  815. +{
  816. + unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
  817. + unsigned int *ptr;
  818. +
  819. + ptr = (unsigned int *)str;
  820. + return *ptr == 0x01020304;
  821. +}
  822. +
  823. +/* --- Opening and Reading the trace.dat file --- */
  824. +
  825. +enum {
  826. + TRACECMD_OPTION_DONE,
  827. + TRACECMD_OPTION_DATE,
  828. + TRACECMD_OPTION_CPUSTAT,
  829. + TRACECMD_OPTION_BUFFER,
  830. + TRACECMD_OPTION_TRACECLOCK,
  831. + TRACECMD_OPTION_UNAME,
  832. + TRACECMD_OPTION_HOOK,
  833. + TRACECMD_OPTION_OFFSET,
  834. + TRACECMD_OPTION_CPUCOUNT,
  835. + TRACECMD_OPTION_VERSION,
  836. + TRACECMD_OPTION_PROCMAPS,
  837. + TRACECMD_OPTION_TRACEID,
  838. + TRACECMD_OPTION_TIME_SHIFT,
  839. + TRACECMD_OPTION_GUEST,
  840. +};
  841. +
  842. +enum {
  843. + TRACECMD_FL_IGNORE_DATE = (1 << 0),
  844. + TRACECMD_FL_BUFFER_INSTANCE = (1 << 1),
  845. + TRACECMD_FL_LATENCY = (1 << 2),
  846. + TRACECMD_FL_IN_USECS = (1 << 3),
  847. + TRACECMD_FL_FLYRECORD = (1 << 4),
  848. +};
  849. +
  850. +struct tracecmd_ftrace {
  851. + struct tracecmd_input *handle;
  852. + struct tep_event *fgraph_ret_event;
  853. + int fgraph_ret_id;
  854. + int long_size;
  855. +};
  856. +
  857. +struct tracecmd_proc_addr_map {
  858. + unsigned long long start;
  859. + unsigned long long end;
  860. + char *lib_name;
  861. +};
  862. +
  863. +typedef void (*tracecmd_show_data_func)(struct tracecmd_input *handle,
  864. + struct tep_record *record);
  865. +typedef void (*tracecmd_handle_init_func)(struct tracecmd_input *handle,
  866. + struct hook_list *hook, int global);
  867. +
  868. +struct tracecmd_input *tracecmd_alloc(const char *file);
  869. +struct tracecmd_input *tracecmd_alloc_fd(int fd);
  870. +struct tracecmd_input *tracecmd_open(const char *file);
  871. +struct tracecmd_input *tracecmd_open_fd(int fd);
  872. +void tracecmd_unpair_peer(struct tracecmd_input *handle);
  873. +void tracecmd_ref(struct tracecmd_input *handle);
  874. +int tracecmd_read_headers(struct tracecmd_input *handle);
  875. +int tracecmd_get_parsing_failures(struct tracecmd_input *handle);
  876. +int tracecmd_long_size(struct tracecmd_input *handle);
  877. +int tracecmd_page_size(struct tracecmd_input *handle);
  878. +int tracecmd_cpus(struct tracecmd_input *handle);
  879. +int tracecmd_copy_headers(struct tracecmd_input *handle, int fd);
  880. +void tracecmd_set_flag(struct tracecmd_input *handle, int flag);
  881. +void tracecmd_clear_flag(struct tracecmd_input *handle, int flag);
  882. +unsigned long tracecmd_get_flags(struct tracecmd_input *handle);
  883. +unsigned long long tracecmd_get_tsync_peer(struct tracecmd_input *handle);
  884. +int tracecmd_enable_tsync(struct tracecmd_input *handle, bool enable);
  885. +
  886. +void tracecmd_parse_trace_clock(struct tracecmd_input *handle, char *file, int size);
  887. +
  888. +int tracecmd_make_pipe(struct tracecmd_input *handle, int cpu, int fd, int cpus);
  889. +
  890. +int tracecmd_is_buffer_instance(struct tracecmd_input *handle);
  891. +
  892. +void tracecmd_set_ts_offset(struct tracecmd_input *handle, long long offset);
  893. +void tracecmd_set_ts2secs(struct tracecmd_input *handle, unsigned long long hz);
  894. +
  895. +void tracecmd_print_events(struct tracecmd_input *handle, const char *regex);
  896. +
  897. +struct hook_list *tracecmd_hooks(struct tracecmd_input *handle);
  898. +
  899. +void tracecmd_print_stats(struct tracecmd_input *handle);
  900. +void tracecmd_print_uname(struct tracecmd_input *handle);
  901. +void tracecmd_print_version(struct tracecmd_input *handle);
  902. +
  903. +struct tep_record *
  904. +tracecmd_peek_data(struct tracecmd_input *handle, int cpu);
  905. +
  906. +static inline struct tep_record *
  907. +tracecmd_peek_data_ref(struct tracecmd_input *handle, int cpu)
  908. +{
  909. + struct tep_record *rec = tracecmd_peek_data(handle, cpu);
  910. + if (rec)
  911. + rec->ref_count++;
  912. + return rec;
  913. +}
  914. +
  915. +struct tep_record *
  916. +tracecmd_read_prev(struct tracecmd_input *handle, struct tep_record *record);
  917. +
  918. +struct tep_record *
  919. +tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu);
  920. +
  921. +struct tep_record *
  922. +tracecmd_peek_next_data(struct tracecmd_input *handle, int *rec_cpu);
  923. +
  924. +struct tep_record *
  925. +tracecmd_translate_data(struct tracecmd_input *handle,
  926. + void *ptr, int size);
  927. +struct tep_record *
  928. +tracecmd_read_cpu_last(struct tracecmd_input *handle, int cpu);
  929. +int tracecmd_refresh_record(struct tracecmd_input *handle,
  930. + struct tep_record *record);
  931. +
  932. +int tracecmd_set_cpu_to_timestamp(struct tracecmd_input *handle,
  933. + int cpu, unsigned long long ts);
  934. +void
  935. +tracecmd_set_all_cpus_to_timestamp(struct tracecmd_input *handle,
  936. + unsigned long long time);
  937. +
  938. +int tracecmd_set_cursor(struct tracecmd_input *handle,
  939. + int cpu, unsigned long long offset);
  940. +unsigned long long
  941. +tracecmd_get_cursor(struct tracecmd_input *handle, int cpu);
  942. +
  943. +int tracecmd_ftrace_overrides(struct tracecmd_input *handle, struct tracecmd_ftrace *finfo);
  944. +bool tracecmd_get_use_trace_clock(struct tracecmd_input *handle);
  945. +tracecmd_show_data_func
  946. +tracecmd_get_show_data_func(struct tracecmd_input *handle);
  947. +void tracecmd_set_show_data_func(struct tracecmd_input *handle,
  948. + tracecmd_show_data_func func);
  949. +
  950. +int tracecmd_record_at_buffer_start(struct tracecmd_input *handle, struct tep_record *record);
  951. +unsigned long long tracecmd_page_ts(struct tracecmd_input *handle,
  952. + struct tep_record *record);
  953. +unsigned int tracecmd_record_ts_delta(struct tracecmd_input *handle,
  954. + struct tep_record *record);
  955. +
  956. +struct tracecmd_proc_addr_map *
  957. +tracecmd_search_task_map(struct tracecmd_input *handle,
  958. + int pid, unsigned long long addr);
  959. +#ifndef SWIG
  960. +/* hack for function graph work around */
  961. +extern __thread struct tracecmd_input *tracecmd_curr_thread_handle;
  962. +#endif
  963. +
  964. +
  965. +/* --- Creating and Writing the trace.dat file --- */
  966. +
  967. +struct tracecmd_event_list {
  968. + struct tracecmd_event_list *next;
  969. + const char *glob;
  970. +};
  971. +
  972. +struct tracecmd_option;
  973. +struct tracecmd_msg_handle;
  974. +
  975. +struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus);
  976. +struct tracecmd_output *tracecmd_create_file(const char *output_file,
  977. + int cpus, char * const *cpu_data_files);
  978. +struct tracecmd_output *
  979. +tracecmd_create_file_glob(const char *output_file,
  980. + int cpus, char * const *cpu_data_files,
  981. + struct tracecmd_event_list *event_globs);
  982. +struct tracecmd_output *
  983. +tracecmd_create_init_file_glob(const char *output_file,
  984. + struct tracecmd_event_list *list);
  985. +struct tracecmd_output *tracecmd_create_init_fd(int fd);
  986. +struct tracecmd_output *
  987. +tracecmd_create_init_fd_glob(int fd, struct tracecmd_event_list *list);
  988. +struct tracecmd_output *
  989. +tracecmd_create_init_fd_msg(struct tracecmd_msg_handle *msg_handle,
  990. + struct tracecmd_event_list *list);
  991. +struct tracecmd_output *tracecmd_create_init_file(const char *output_file);
  992. +struct tracecmd_output *tracecmd_create_init_file_override(const char *output_file,
  993. + const char *tracing_dir,
  994. + const char *kallsyms);
  995. +struct tracecmd_option *tracecmd_add_option(struct tracecmd_output *handle,
  996. + unsigned short id, int size,
  997. + const void *data);
  998. +struct tracecmd_option *
  999. +tracecmd_add_option_v(struct tracecmd_output *handle,
  1000. + unsigned short id, const struct iovec *vector, int count);
  1001. +
  1002. +struct tracecmd_option *tracecmd_add_buffer_option(struct tracecmd_output *handle,
  1003. + const char *name, int cpus);
  1004. +
  1005. +int tracecmd_write_cpus(struct tracecmd_output *handle, int cpus);
  1006. +int tracecmd_write_options(struct tracecmd_output *handle);
  1007. +int tracecmd_append_options(struct tracecmd_output *handle);
  1008. +int tracecmd_update_option(struct tracecmd_output *handle,
  1009. + struct tracecmd_option *option, int size,
  1010. + const void *data);
  1011. +void tracecmd_output_close(struct tracecmd_output *handle);
  1012. +void tracecmd_output_free(struct tracecmd_output *handle);
  1013. +struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
  1014. + const char *file);
  1015. +
  1016. +int tracecmd_write_cpu_data(struct tracecmd_output *handle,
  1017. + int cpus, char * const *cpu_data_files);
  1018. +int tracecmd_append_cpu_data(struct tracecmd_output *handle,
  1019. + int cpus, char * const *cpu_data_files);
  1020. +int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
  1021. + struct tracecmd_option *option,
  1022. + int cpus, char * const *cpu_data_files);
  1023. +
  1024. +struct tracecmd_output *tracecmd_get_output_handle_fd(int fd);
  1025. +
  1026. +/* --- Reading the Fly Recorder Trace --- */
  1027. +
  1028. +enum {
  1029. + TRACECMD_RECORD_NOSPLICE = (1 << 0), /* Use read instead of splice */
  1030. + TRACECMD_RECORD_SNAPSHOT = (1 << 1), /* Extract from snapshot */
  1031. + TRACECMD_RECORD_BLOCK = (1 << 2), /* Block on splice write */
  1032. + TRACECMD_RECORD_NOBRASS = (1 << 3), /* Splice directly without a brass pipe */
  1033. +};
  1034. +
  1035. +void tracecmd_free_recorder(struct tracecmd_recorder *recorder);
  1036. +struct tracecmd_recorder *tracecmd_create_recorder(const char *file, int cpu, unsigned flags);
  1037. +struct tracecmd_recorder *tracecmd_create_recorder_fd(int fd, int cpu, unsigned flags);
  1038. +struct tracecmd_recorder *tracecmd_create_recorder_virt(const char *file, int cpu, unsigned flags, int trace_fd);
  1039. +struct tracecmd_recorder *tracecmd_create_recorder_maxkb(const char *file, int cpu, unsigned flags, int maxkb);
  1040. +struct tracecmd_recorder *tracecmd_create_buffer_recorder_fd(int fd, int cpu, unsigned flags, const char *buffer);
  1041. +struct tracecmd_recorder *tracecmd_create_buffer_recorder(const char *file, int cpu, unsigned flags, const char *buffer);
  1042. +struct tracecmd_recorder *tracecmd_create_buffer_recorder_maxkb(const char *file, int cpu, unsigned flags, const char *buffer, int maxkb);
  1043. +
  1044. +int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long sleep);
  1045. +void tracecmd_stop_recording(struct tracecmd_recorder *recorder);
  1046. +long tracecmd_flush_recording(struct tracecmd_recorder *recorder);
  1047. +
  1048. +enum tracecmd_msg_flags {
  1049. + TRACECMD_MSG_FL_USE_TCP = 1 << 0,
  1050. +};
  1051. +
  1052. +/* for both client and server */
  1053. +struct tracecmd_msg_handle {
  1054. + int fd;
  1055. + short cpu_count;
  1056. + short version; /* Current protocol version */
  1057. + unsigned long flags;
  1058. + bool done;
  1059. +};
  1060. +
  1061. +struct tracecmd_msg_handle *
  1062. +tracecmd_msg_handle_alloc(int fd, unsigned long flags);
  1063. +
  1064. +/* Closes the socket and frees the handle */
  1065. +void tracecmd_msg_handle_close(struct tracecmd_msg_handle *msg_handle);
  1066. +
  1067. +/* for clients */
  1068. +int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
  1069. + unsigned int **client_ports);
  1070. +int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
  1071. + const char *buf, int size);
  1072. +int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle);
  1073. +int tracecmd_msg_send_close_msg(struct tracecmd_msg_handle *msg_handle);
  1074. +int tracecmd_msg_send_close_resp_msg(struct tracecmd_msg_handle *msg_handle);
  1075. +int tracecmd_msg_wait_close(struct tracecmd_msg_handle *msg_handle);
  1076. +int tracecmd_msg_wait_close_resp(struct tracecmd_msg_handle *msg_handle);
  1077. +
  1078. +/* for server */
  1079. +int tracecmd_msg_initial_setting(struct tracecmd_msg_handle *msg_handle);
  1080. +int tracecmd_msg_send_port_array(struct tracecmd_msg_handle *msg_handle,
  1081. + unsigned *ports);
  1082. +int tracecmd_msg_read_data(struct tracecmd_msg_handle *msg_handle, int ofd);
  1083. +int tracecmd_msg_collect_data(struct tracecmd_msg_handle *msg_handle, int ofd);
  1084. +bool tracecmd_msg_done(struct tracecmd_msg_handle *msg_handle);
  1085. +void tracecmd_msg_set_done(struct tracecmd_msg_handle *msg_handle);
  1086. +
  1087. +int tracecmd_msg_send_trace_req(struct tracecmd_msg_handle *msg_handle,
  1088. + int argc, char **argv, bool use_fifos,
  1089. + unsigned long long trace_id,
  1090. + char *tsync_protos,
  1091. + int tsync_protos_size);
  1092. +int tracecmd_msg_recv_trace_req(struct tracecmd_msg_handle *msg_handle,
  1093. + int *argc, char ***argv, bool *use_fifos,
  1094. + unsigned long long *trace_id,
  1095. + char **tsync_protos,
  1096. + unsigned int *tsync_protos_size);
  1097. +
  1098. +int tracecmd_msg_send_trace_resp(struct tracecmd_msg_handle *msg_handle,
  1099. + int nr_cpus, int page_size,
  1100. + unsigned int *ports, bool use_fifos,
  1101. + unsigned long long trace_id,
  1102. + unsigned int tsync_proto,
  1103. + unsigned int tsync_port);
  1104. +int tracecmd_msg_recv_trace_resp(struct tracecmd_msg_handle *msg_handle,
  1105. + int *nr_cpus, int *page_size,
  1106. + unsigned int **ports, bool *use_fifos,
  1107. + unsigned long long *trace_id,
  1108. + unsigned int *tsync_proto,
  1109. + unsigned int *tsync_port);
  1110. +
  1111. +int tracecmd_msg_send_time_sync(struct tracecmd_msg_handle *msg_handle,
  1112. + unsigned int sync_protocol,
  1113. + unsigned int sync_msg_id,
  1114. + unsigned int payload_size, char *payload);
  1115. +int tracecmd_msg_recv_time_sync(struct tracecmd_msg_handle *msg_handle,
  1116. + unsigned int *sync_protocol,
  1117. + unsigned int *sync_msg_id,
  1118. + unsigned int *payload_size, char **payload);
  1119. +
  1120. +/* --- Timestamp synchronization --- */
  1121. +
  1122. +enum{
  1123. + TRACECMD_TIME_SYNC_PROTO_NONE = 0,
  1124. +};
  1125. +enum{
  1126. + TRACECMD_TIME_SYNC_CMD_PROBE = 1,
  1127. + TRACECMD_TIME_SYNC_CMD_STOP = 2,
  1128. +};
  1129. +
  1130. +#define TRACECMD_TIME_SYNC_PROTO_PTP_WEIGHT 10
  1131. +
  1132. +struct tracecmd_time_sync {
  1133. + unsigned int sync_proto;
  1134. + int loop_interval;
  1135. + pthread_mutex_t lock;
  1136. + pthread_cond_t cond;
  1137. + char *clock_str;
  1138. + struct tracecmd_msg_handle *msg_handle;
  1139. + void *context;
  1140. +};
  1141. +
  1142. +void tracecmd_tsync_init(void);
  1143. +int tracecmd_tsync_proto_getall(char **proto_mask, int *words);
  1144. +unsigned int tracecmd_tsync_proto_select(char *proto_mask, int words);
  1145. +bool tsync_proto_is_supported(unsigned int proto_id);
  1146. +void tracecmd_tsync_with_host(struct tracecmd_time_sync *tsync);
  1147. +void tracecmd_tsync_with_guest(struct tracecmd_time_sync *tsync);
  1148. +int tracecmd_tsync_get_offsets(struct tracecmd_time_sync *tsync,
  1149. + int *count,
  1150. + long long **ts, long long **offsets);
  1151. +void tracecmd_tsync_free(struct tracecmd_time_sync *tsync);
  1152. +
  1153. +/* --- Plugin handling --- */
  1154. +extern struct tep_plugin_option trace_ftrace_options[];
  1155. +
  1156. +char **trace_util_find_plugin_files(const char *suffix);
  1157. +void trace_util_free_plugin_files(char **files);
  1158. +
  1159. +/* Used for trace-cmd list */
  1160. +void tracecmd_ftrace_load_options(void);
  1161. +
  1162. +/* event hooks */
  1163. +
  1164. +struct hook_list {
  1165. + struct hook_list *next;
  1166. + struct buffer_instance *instance;
  1167. + const char *hook;
  1168. + char *str;
  1169. + char *start_system;
  1170. + char *start_event;
  1171. + char *start_match;
  1172. + char *end_system;
  1173. + char *end_event;
  1174. + char *end_match;
  1175. + char *pid;
  1176. + int migrate;
  1177. + int global;
  1178. + int stack;
  1179. +};
  1180. +
  1181. +struct hook_list *tracecmd_create_event_hook(const char *arg);
  1182. +void tracecmd_free_hooks(struct hook_list *hooks);
  1183. +
  1184. +void tracecmd_plog(const char *fmt, ...);
  1185. +void tracecmd_plog_error(const char *fmt, ...);
  1186. +int tracecmd_set_logfile(char *logfile);
  1187. +
  1188. +/* --- System --- */
  1189. +unsigned long long tracecmd_generate_traceid(void);
  1190. +int tracecmd_count_cpus(void);
  1191. +
  1192. +/* --- Hack! --- */
  1193. +int tracecmd_blk_hack(struct tracecmd_input *handle);
  1194. +
  1195. +/* --- Stack tracer functions --- */
  1196. +int tracecmd_stack_tracer_status(int *status);
  1197. +
  1198. +/* --- Debugging --- */
  1199. +struct kbuffer *tracecmd_record_kbuf(struct tracecmd_input *handle,
  1200. + struct tep_record *record);
  1201. +void *tracecmd_record_page(struct tracecmd_input *handle,
  1202. + struct tep_record *record);
  1203. +void *tracecmd_record_offset(struct tracecmd_input *handle,
  1204. + struct tep_record *record);
  1205. +
  1206. +#endif /* _TRACE_CMD_PRIVATE_H */
  1207. diff --git a/lib/trace-cmd/include/private/trace-filter-hash.h b/lib/trace-cmd/include/private/trace-filter-hash.h
  1208. new file mode 100644
  1209. index 0000000..4111c41
  1210. --- /dev/null
  1211. +++ b/lib/trace-cmd/include/private/trace-filter-hash.h
  1212. @@ -0,0 +1,64 @@
  1213. +/* SPDX-License-Identifier: LGPL-2.1 */
  1214. +/*
  1215. + * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  1216. + * Copyright (C) 2018 VMware Inc, Steven Rostedt <rostedt@goodmis.org>
  1217. + *
  1218. + */
  1219. +#ifndef _TRACE_FILTER_HASH_H
  1220. +#define _TRACE_FILTER_HASH_H
  1221. +
  1222. +#include <stdint.h>
  1223. +
  1224. +struct tracecmd_filter_id_item {
  1225. + struct tracecmd_filter_id_item *next;
  1226. + int id;
  1227. +};
  1228. +
  1229. +struct tracecmd_filter_id {
  1230. + struct tracecmd_filter_id_item **hash;
  1231. + int count;
  1232. +};
  1233. +
  1234. +/**
  1235. + * tracecmd_quick_hash - A quick (non secured) hash alogirthm
  1236. + * @val: The value to perform the hash on
  1237. + * @bits: The size in bits you need to return
  1238. + *
  1239. + * This is a quick hashing function adapted from Donald E. Knuth's 32
  1240. + * bit multiplicative hash. See The Art of Computer Programming (TAOCP).
  1241. + * Multiplication by the Prime number, closest to the golden ratio of
  1242. + * 2^32.
  1243. + *
  1244. + * @bits is used to max the result for use cases that require
  1245. + * a power of 2 return value that is less than 32 bits. Any value
  1246. + * of @bits greater than 31 (or zero), will simply return the full hash on @val.
  1247. + */
  1248. +static inline uint32_t tracecmd_quick_hash(uint32_t val, unsigned int bits)
  1249. +{
  1250. + val *= UINT32_C(2654435761);
  1251. +
  1252. + if (!bits || bits > 31)
  1253. + return val;
  1254. +
  1255. + return val & ((1 << bits) - 1);
  1256. +}
  1257. +
  1258. +struct tracecmd_filter_id_item *
  1259. + tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id);
  1260. +void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id);
  1261. +void tracecmd_filter_id_remove(struct tracecmd_filter_id *hash, int id);
  1262. +void tracecmd_filter_id_clear(struct tracecmd_filter_id *hash);
  1263. +struct tracecmd_filter_id *tracecmd_filter_id_hash_alloc(void);
  1264. +void tracecmd_filter_id_hash_free(struct tracecmd_filter_id *hash);
  1265. +struct tracecmd_filter_id *
  1266. + tracecmd_filter_id_hash_copy(struct tracecmd_filter_id *hash);
  1267. +int *tracecmd_filter_ids(struct tracecmd_filter_id *hash);
  1268. +int tracecmd_filter_id_compare(struct tracecmd_filter_id *hash1,
  1269. + struct tracecmd_filter_id *hash2);
  1270. +
  1271. +static inline int tracecmd_filter_task_count(struct tracecmd_filter_id *hash)
  1272. +{
  1273. + return hash->count;
  1274. +}
  1275. +
  1276. +#endif /* _TRACE_FILTER_HASH_H */
  1277. diff --git a/lib/trace-cmd/include/private/trace-hash.h b/lib/trace-cmd/include/private/trace-hash.h
  1278. new file mode 100644
  1279. index 0000000..aa92cdf
  1280. --- /dev/null
  1281. +++ b/lib/trace-cmd/include/private/trace-hash.h
  1282. @@ -0,0 +1,55 @@
  1283. +/* SPDX-License-Identifier: GPL-2.0 */
  1284. +/*
  1285. + * Copyright (C) 2014 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
  1286. + *
  1287. + */
  1288. +#ifndef _TRACE_HASH_H
  1289. +#define _TRACE_HASH_H
  1290. +
  1291. +struct trace_hash_item {
  1292. + struct trace_hash_item *next;
  1293. + struct trace_hash_item *prev;
  1294. + unsigned long long key;
  1295. +};
  1296. +
  1297. +struct trace_hash {
  1298. + struct trace_hash_item **buckets;
  1299. + int nr_buckets;
  1300. + int power;
  1301. +};
  1302. +
  1303. +int trace_hash_init(struct trace_hash *hash, int buckets);
  1304. +void trace_hash_free(struct trace_hash *hash);
  1305. +int trace_hash_add(struct trace_hash *hash, struct trace_hash_item *item);
  1306. +int trace_hash_empty(struct trace_hash *hash);
  1307. +
  1308. +static inline void trace_hash_del(struct trace_hash_item *item)
  1309. +{
  1310. + struct trace_hash_item *prev = item->prev;
  1311. +
  1312. + prev->next = item->next;
  1313. + if (item->next)
  1314. + item->next->prev = prev;
  1315. +}
  1316. +
  1317. +#define trace_hash_for_each_bucket(bucket, hash) \
  1318. + for (bucket = (hash)->buckets; \
  1319. + (bucket) < (hash)->buckets + (hash)->nr_buckets; (bucket)++)
  1320. +
  1321. +#define trace_hash_for_each_item(item, bucket) \
  1322. + for ((item = *(bucket)); item; item = (item)->next)
  1323. +
  1324. +#define trace_hash_for_each_item_safe(item, n, bucket) \
  1325. + for ((item = *(bucket)), n = item ? item->next : NULL; item; \
  1326. + item = n, n = item ? (item)->next : NULL)
  1327. +
  1328. +#define trace_hash_while_item(item, bucket) \
  1329. + while ((item = *(bucket)))
  1330. +
  1331. +typedef int (*trace_hash_func)(struct trace_hash_item *item, void *data);
  1332. +
  1333. +struct trace_hash_item *
  1334. +trace_hash_find(struct trace_hash *hash, unsigned long long key,
  1335. + trace_hash_func match, void *data);
  1336. +
  1337. +#endif /* _TRACE_HASH_H */
  1338. diff --git a/lib/trace-cmd/include/private/trace-msg.h b/lib/trace-cmd/include/private/trace-msg.h
  1339. new file mode 100644
  1340. index 0000000..aab8a69
  1341. --- /dev/null
  1342. +++ b/lib/trace-cmd/include/private/trace-msg.h
  1343. @@ -0,0 +1,15 @@
  1344. +#ifndef _TRACE_MSG_H_
  1345. +#define _TRACE_MSG_H_
  1346. +
  1347. +#include <stdbool.h>
  1348. +
  1349. +#define UDP_MAX_PACKET (65536 - 20)
  1350. +#define V3_MAGIC "766679\0"
  1351. +#define V3_CPU "-1V3"
  1352. +
  1353. +#define V1_PROTOCOL 1
  1354. +#define V3_PROTOCOL 3
  1355. +
  1356. +extern unsigned int page_size;
  1357. +
  1358. +#endif /* _TRACE_MSG_H_ */
  1359. diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h
  1360. index 95dce66..d0a7365 100644
  1361. --- a/lib/trace-cmd/include/trace-cmd-local.h
  1362. +++ b/lib/trace-cmd/include/trace-cmd-local.h
  1363. @@ -6,6 +6,8 @@
  1364. #ifndef _TRACE_CMD_LOCAL_H
  1365. #define _TRACE_CMD_LOCAL_H
  1366. +#include "trace-cmd-private.h"
  1367. +
  1368. /* Can be overridden */
  1369. void warning(const char *fmt, ...);
  1370. diff --git a/lib/trace-cmd/trace-ftrace.c b/lib/trace-cmd/trace-ftrace.c
  1371. index 20bf71f..df7335f 100644
  1372. --- a/lib/trace-cmd/trace-ftrace.c
  1373. +++ b/lib/trace-cmd/trace-ftrace.c
  1374. @@ -8,7 +8,7 @@
  1375. #include <string.h>
  1376. #include <sys/param.h>
  1377. -#include "trace-cmd.h"
  1378. +#include "trace-cmd-private.h"
  1379. struct tep_plugin_option trace_ftrace_options[] = {
  1380. {
  1381. diff --git a/lib/trace-cmd/trace-hooks.c b/lib/trace-cmd/trace-hooks.c
  1382. index 8c969a6..2dadf61 100644
  1383. --- a/lib/trace-cmd/trace-hooks.c
  1384. +++ b/lib/trace-cmd/trace-hooks.c
  1385. @@ -8,7 +8,7 @@
  1386. #include <stdlib.h>
  1387. #include <ctype.h>
  1388. -#include "trace-cmd.h"
  1389. +#include "trace-cmd-private.h"
  1390. #include "event-utils.h"
  1391. struct hook_list *tracecmd_create_event_hook(const char *arg)
  1392. diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
  1393. index 2a6e2b6..6b647d6 100644
  1394. --- a/lib/trace-cmd/trace-recorder.c
  1395. +++ b/lib/trace-cmd/trace-recorder.c
  1396. @@ -13,7 +13,7 @@
  1397. #include <errno.h>
  1398. #include "tracefs.h"
  1399. -#include "trace-cmd.h"
  1400. +#include "trace-cmd-private.h"
  1401. #include "event-utils.h"
  1402. /* F_GETPIPE_SZ was introduced in 2.6.35, older systems don't have it */
  1403. diff --git a/lib/trace-cmd/trace-timesync.c b/lib/trace-cmd/trace-timesync.c
  1404. index 7a6a7eb..390e9d9 100644
  1405. --- a/lib/trace-cmd/trace-timesync.c
  1406. +++ b/lib/trace-cmd/trace-timesync.c
  1407. @@ -17,7 +17,7 @@
  1408. #include <errno.h>
  1409. #include <pthread.h>
  1410. -#include "trace-cmd.h"
  1411. +#include "trace-cmd-private.h"
  1412. #include "tracefs.h"
  1413. #include "event-utils.h"
  1414. #include "trace-tsync-local.h"
  1415. diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c
  1416. index 0ead96e..6b5d872 100644
  1417. --- a/lib/trace-cmd/trace-util.c
  1418. +++ b/lib/trace-cmd/trace-util.c
  1419. @@ -21,7 +21,7 @@
  1420. #include <sys/sysinfo.h>
  1421. #include <time.h>
  1422. -#include "trace-cmd.h"
  1423. +#include "trace-cmd-private.h"
  1424. #include "event-utils.h"
  1425. #define LOCAL_PLUGIN_DIR ".trace-cmd/plugins"
  1426. diff --git a/lib/traceevent/plugins/plugin_python_loader.c b/lib/traceevent/plugins/plugin_python_loader.c
  1427. index 776bf12..01bdfad 100644
  1428. --- a/lib/traceevent/plugins/plugin_python_loader.c
  1429. +++ b/lib/traceevent/plugins/plugin_python_loader.c
  1430. @@ -1,6 +1,7 @@
  1431. #include <Python.h>
  1432. #include <stdio.h>
  1433. -#include "trace-cmd.h"
  1434. +#include "event-parse.h"
  1435. +#include "trace-cmd-private.h"
  1436. #ifndef PYTHON_DIR
  1437. #define PYTHON_DIR "."
  1438. diff --git a/python/ctracecmd.i b/python/ctracecmd.i
  1439. index 01cd0d5..5f7181c 100644
  1440. --- a/python/ctracecmd.i
  1441. +++ b/python/ctracecmd.i
  1442. @@ -15,6 +15,7 @@
  1443. %{
  1444. #include "trace-cmd.h"
  1445. +#include "event-parse.h"
  1446. #include "event-utils.h"
  1447. #include <Python.h>
  1448. %}
  1449. diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
  1450. index 207aa68..28d1b4e 100644
  1451. --- a/tracecmd/include/trace-local.h
  1452. +++ b/tracecmd/include/trace-local.h
  1453. @@ -9,7 +9,7 @@
  1454. #include <sys/types.h>
  1455. #include <dirent.h> /* for DIR */
  1456. -#include "trace-cmd.h"
  1457. +#include "trace-cmd-private.h"
  1458. #include "event-utils.h"
  1459. #define TRACE_AGENT_DEFAULT_PORT 823
  1460. --
  1461. 2.29.2