Skip to content

Commit f2bff00

Browse files
ahunter6acmel
authored andcommitted
perf tools: Add branch type to db export
Add the ability to export branch types through the database export facility. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1414678188-14946-3-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 92a9e4f commit f2bff00

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

‎tools/perf/util/db-export.c‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,15 @@ static int db_ids_from_al(struct db_export *dbe, struct addr_location *al,
208208
return 0;
209209
}
210210

211+
int db_export__branch_type(struct db_export *dbe, u32 branch_type,
212+
const char *name)
213+
{
214+
if (dbe->export_branch_type)
215+
return dbe->export_branch_type(dbe, branch_type, name);
216+
217+
return 0;
218+
}
219+
211220
int db_export__sample(struct db_export *dbe, union perf_event *event,
212221
struct perf_sample *sample, struct perf_evsel *evsel,
213222
struct thread *thread, struct addr_location *al)
@@ -268,3 +277,42 @@ int db_export__sample(struct db_export *dbe, union perf_event *event,
268277

269278
return 0;
270279
}
280+
281+
static struct {
282+
u32 branch_type;
283+
const char *name;
284+
} branch_types[] = {
285+
{0, "no branch"},
286+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"},
287+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"},
288+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "conditional jump"},
289+
{PERF_IP_FLAG_BRANCH, "unconditional jump"},
290+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT,
291+
"software interrupt"},
292+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT,
293+
"return from interrupt"},
294+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET,
295+
"system call"},
296+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET,
297+
"return from system call"},
298+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "asynchronous branch"},
299+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_ASYNC |
300+
PERF_IP_FLAG_INTERRUPT, "hardware interrupt"},
301+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "transaction abort"},
302+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "trace begin"},
303+
{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "trace end"},
304+
{0, NULL}
305+
};
306+
307+
int db_export__branch_types(struct db_export *dbe)
308+
{
309+
int i, err = 0;
310+
311+
for (i = 0; branch_types[i].name ; i++) {
312+
err = db_export__branch_type(dbe, branch_types[i].branch_type,
313+
branch_types[i].name);
314+
if (err)
315+
break;
316+
}
317+
return err;
318+
}

‎tools/perf/util/db-export.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct db_export {
5454
struct machine *machine);
5555
int (*export_symbol)(struct db_export *dbe, struct symbol *sym,
5656
struct dso *dso);
57+
int (*export_branch_type)(struct db_export *dbe, u32 branch_type,
58+
const char *name);
5759
int (*export_sample)(struct db_export *dbe, struct export_sample *es);
5860
u64 evsel_last_db_id;
5961
u64 machine_last_db_id;
@@ -79,8 +81,12 @@ int db_export__dso(struct db_export *dbe, struct dso *dso,
7981
struct machine *machine);
8082
int db_export__symbol(struct db_export *dbe, struct symbol *sym,
8183
struct dso *dso);
84+
int db_export__branch_type(struct db_export *dbe, u32 branch_type,
85+
const char *name);
8286
int db_export__sample(struct db_export *dbe, union perf_event *event,
8387
struct perf_sample *sample, struct perf_evsel *evsel,
8488
struct thread *thread, struct addr_location *al);
8589

90+
int db_export__branch_types(struct db_export *dbe);
91+
8692
#endif

0 commit comments

Comments
 (0)