diff options
| -rw-r--r-- | tools/perf/util/db-export.c | 52 | ||||
| -rw-r--r-- | tools/perf/util/db-export.h | 12 |
2 files changed, 63 insertions, 1 deletions
diff --git a/tools/perf/util/db-export.c b/tools/perf/util/db-export.c index bccb83120971..017ecbb0ec05 100644 --- a/tools/perf/util/db-export.c +++ b/tools/perf/util/db-export.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include "comm.h" | 21 | #include "comm.h" |
| 22 | #include "symbol.h" | 22 | #include "symbol.h" |
| 23 | #include "event.h" | 23 | #include "event.h" |
| 24 | #include "thread-stack.h" | ||
| 24 | #include "db-export.h" | 25 | #include "db-export.h" |
| 25 | 26 | ||
| 26 | int db_export__init(struct db_export *dbe) | 27 | int db_export__init(struct db_export *dbe) |
| @@ -29,8 +30,10 @@ int db_export__init(struct db_export *dbe) | |||
| 29 | return 0; | 30 | return 0; |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | void db_export__exit(struct db_export *dbe __maybe_unused) | 33 | void db_export__exit(struct db_export *dbe) |
| 33 | { | 34 | { |
| 35 | call_return_processor__free(dbe->crp); | ||
| 36 | dbe->crp = NULL; | ||
| 34 | } | 37 | } |
| 35 | 38 | ||
| 36 | int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel) | 39 | int db_export__evsel(struct db_export *dbe, struct perf_evsel *evsel) |
| @@ -270,6 +273,13 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, | |||
| 270 | &es.addr_sym_db_id, &es.addr_offset); | 273 | &es.addr_sym_db_id, &es.addr_offset); |
| 271 | if (err) | 274 | if (err) |
| 272 | return err; | 275 | return err; |
| 276 | if (dbe->crp) { | ||
| 277 | err = thread_stack__process(thread, comm, sample, al, | ||
| 278 | &addr_al, es.db_id, | ||
| 279 | dbe->crp); | ||
| 280 | if (err) | ||
| 281 | return err; | ||
| 282 | } | ||
| 273 | } | 283 | } |
| 274 | 284 | ||
| 275 | if (dbe->export_sample) | 285 | if (dbe->export_sample) |
| @@ -316,3 +326,43 @@ int db_export__branch_types(struct db_export *dbe) | |||
| 316 | } | 326 | } |
| 317 | return err; | 327 | return err; |
| 318 | } | 328 | } |
| 329 | |||
| 330 | int db_export__call_path(struct db_export *dbe, struct call_path *cp) | ||
| 331 | { | ||
| 332 | int err; | ||
| 333 | |||
| 334 | if (cp->db_id) | ||
| 335 | return 0; | ||
| 336 | |||
| 337 | if (cp->parent) { | ||
| 338 | err = db_export__call_path(dbe, cp->parent); | ||
| 339 | if (err) | ||
| 340 | return err; | ||
| 341 | } | ||
| 342 | |||
| 343 | cp->db_id = ++dbe->call_path_last_db_id; | ||
| 344 | |||
| 345 | if (dbe->export_call_path) | ||
| 346 | return dbe->export_call_path(dbe, cp); | ||
| 347 | |||
| 348 | return 0; | ||
| 349 | } | ||
| 350 | |||
| 351 | int db_export__call_return(struct db_export *dbe, struct call_return *cr) | ||
| 352 | { | ||
| 353 | int err; | ||
| 354 | |||
| 355 | if (cr->db_id) | ||
| 356 | return 0; | ||
| 357 | |||
| 358 | err = db_export__call_path(dbe, cr->cp); | ||
| 359 | if (err) | ||
| 360 | return err; | ||
| 361 | |||
| 362 | cr->db_id = ++dbe->call_return_last_db_id; | ||
| 363 | |||
| 364 | if (dbe->export_call_return) | ||
| 365 | return dbe->export_call_return(dbe, cr); | ||
| 366 | |||
| 367 | return 0; | ||
| 368 | } | ||
diff --git a/tools/perf/util/db-export.h b/tools/perf/util/db-export.h index e4baa45ead70..dd5ac2ae97d4 100644 --- a/tools/perf/util/db-export.h +++ b/tools/perf/util/db-export.h | |||
| @@ -25,6 +25,9 @@ struct comm; | |||
| 25 | struct dso; | 25 | struct dso; |
| 26 | struct perf_sample; | 26 | struct perf_sample; |
| 27 | struct addr_location; | 27 | struct addr_location; |
| 28 | struct call_return_processor; | ||
| 29 | struct call_path; | ||
| 30 | struct call_return; | ||
| 28 | 31 | ||
| 29 | struct export_sample { | 32 | struct export_sample { |
| 30 | union perf_event *event; | 33 | union perf_event *event; |
| @@ -57,6 +60,10 @@ struct db_export { | |||
| 57 | int (*export_branch_type)(struct db_export *dbe, u32 branch_type, | 60 | int (*export_branch_type)(struct db_export *dbe, u32 branch_type, |
| 58 | const char *name); | 61 | const char *name); |
| 59 | int (*export_sample)(struct db_export *dbe, struct export_sample *es); | 62 | int (*export_sample)(struct db_export *dbe, struct export_sample *es); |
| 63 | int (*export_call_path)(struct db_export *dbe, struct call_path *cp); | ||
| 64 | int (*export_call_return)(struct db_export *dbe, | ||
| 65 | struct call_return *cr); | ||
| 66 | struct call_return_processor *crp; | ||
| 60 | u64 evsel_last_db_id; | 67 | u64 evsel_last_db_id; |
| 61 | u64 machine_last_db_id; | 68 | u64 machine_last_db_id; |
| 62 | u64 thread_last_db_id; | 69 | u64 thread_last_db_id; |
| @@ -65,6 +72,8 @@ struct db_export { | |||
| 65 | u64 dso_last_db_id; | 72 | u64 dso_last_db_id; |
| 66 | u64 symbol_last_db_id; | 73 | u64 symbol_last_db_id; |
| 67 | u64 sample_last_db_id; | 74 | u64 sample_last_db_id; |
| 75 | u64 call_path_last_db_id; | ||
| 76 | u64 call_return_last_db_id; | ||
| 68 | }; | 77 | }; |
| 69 | 78 | ||
| 70 | int db_export__init(struct db_export *dbe); | 79 | int db_export__init(struct db_export *dbe); |
| @@ -89,4 +98,7 @@ int db_export__sample(struct db_export *dbe, union perf_event *event, | |||
| 89 | 98 | ||
| 90 | int db_export__branch_types(struct db_export *dbe); | 99 | int db_export__branch_types(struct db_export *dbe); |
| 91 | 100 | ||
| 101 | int db_export__call_path(struct db_export *dbe, struct call_path *cp); | ||
| 102 | int db_export__call_return(struct db_export *dbe, struct call_return *cr); | ||
| 103 | |||
| 92 | #endif | 104 | #endif |
