db-export.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * db-export.h: Support for exporting data suitable for import to a database
  3. * Copyright (c) 2014, Intel Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. */
  15. #ifndef __PERF_DB_EXPORT_H
  16. #define __PERF_DB_EXPORT_H
  17. #include <linux/types.h>
  18. #include <linux/list.h>
  19. struct perf_evsel;
  20. struct machine;
  21. struct thread;
  22. struct comm;
  23. struct dso;
  24. struct perf_sample;
  25. struct addr_location;
  26. struct call_return_processor;
  27. struct call_path;
  28. struct call_return;
  29. struct export_sample {
  30. union perf_event *event;
  31. struct perf_sample *sample;
  32. struct perf_evsel *evsel;
  33. struct thread *thread;
  34. struct addr_location *al;
  35. u64 db_id;
  36. u64 comm_db_id;
  37. u64 dso_db_id;
  38. u64 sym_db_id;
  39. u64 offset; /* ip offset from symbol start */
  40. u64 addr_dso_db_id;
  41. u64 addr_sym_db_id;
  42. u64 addr_offset; /* addr offset from symbol start */
  43. };
  44. struct db_export {
  45. int (*export_evsel)(struct db_export *dbe, struct perf_evsel *evsel);
  46. int (*export_machine)(struct db_export *dbe, struct machine *machine);
  47. int (*export_thread)(struct db_export *dbe, struct thread *thread,
  48. u64 main_thread_db_id, struct machine *machine);
  49. int (*export_comm)(struct db_export *dbe, struct comm *comm);
  50. int (*export_comm_thread)(struct db_export *dbe, u64 db_id,
  51. struct comm *comm, struct thread *thread);
  52. int (*export_dso)(struct db_export *dbe, struct dso *dso,
  53. struct machine *machine);
  54. int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
  55. struct dso *dso);
  56. int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
  57. const char *name);
  58. int (*export_sample)(struct db_export *dbe, struct export_sample *es);
  59. int (*export_call_path)(struct db_export *dbe, struct call_path *cp);
  60. int (*export_call_return)(struct db_export *dbe,
  61. struct call_return *cr);
  62. struct call_return_processor *crp;
  63. u64 evsel_last_db_id;
  64. u64 machine_last_db_id;
  65. u64 thread_last_db_id;
  66. u64 comm_last_db_id;
  67. u64 comm_thread_last_db_id;
  68. u64 dso_last_db_id;
  69. u64 symbol_last_db_id;
  70. u64 sample_last_db_id;
  71. u64 call_path_last_db_id;
  72. u64 call_return_last_db_id;
  73. struct list_head deferred;
  74. };
  75. int db_export__init(struct db_export *dbe);
  76. int db_export__flush(struct db_export *dbe);
  77. void db_export__exit(struct db_export *dbe);
  78. int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel);
  79. int db_export__machine(struct db_export *dbe, struct machine *machine);
  80. int db_export__thread(struct db_export *dbe, struct thread *thread,
  81. struct machine *machine, struct comm *comm);
  82. int db_export__comm(struct db_export *dbe, struct comm *comm,
  83. struct thread *main_thread);
  84. int db_export__comm_thread(struct db_export *dbe, struct comm *comm,
  85. struct thread *thread);
  86. int db_export__dso(struct db_export *dbe, struct dso *dso,
  87. struct machine *machine);
  88. int db_export__symbol(struct db_export *dbe, struct symbol *sym,
  89. struct dso *dso);
  90. int db_export__branch_type(struct db_export *dbe, u32 branch_type,
  91. const char *name);
  92. int db_export__sample(struct db_export *dbe, union perf_event *event,
  93. struct perf_sample *sample, struct perf_evsel *evsel,
  94. struct thread *thread, struct addr_location *al);
  95. int db_export__branch_types(struct db_export *dbe);
  96. int db_export__call_path(struct db_export *dbe, struct call_path *cp);
  97. int db_export__call_return(struct db_export *dbe, struct call_return *cr);
  98. #endif