3 ** Copyright 2015, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 #ifndef PERF_INTERNALS_H
19 #define PERF_INTERNALS_H
21 #include <linux/perf_event.h>
22 #include "kernel-headers/tools/perf/util/types.h"
23 #include "kernel-headers/tools/perf/util/include/linux/bitops.h"
24 #include "kernel-headers/tools/perf/util/include/linux/types.h"
25 #include "kernel-headers/tools/perf/util/build-id.h"
26 #include "kernel-headers/tools/perf/util/include/linux/kernel/kernel.h"
27 #include "kernel-headers/tools/perf/util/header.h"
28 #include "kernel-headers/tools/perf/util/event.h"
29 #include "kernel-headers/tools/perf/util/target.h"
30 #include "kernel-headers/tools/perf/perf.h"
32 // The first 64 bits of the perf header, used as a perf data file ID tag.
33 const uint64_t kPerfMagic = 0x32454c4946524550LL; // "PERFILE2" little-endian
39 // Wrapper class to manage creation/deletion of storage associated
40 // with perf_sample structs.
42 class PerfSampleCustodian {
44 explicit PerfSampleCustodian(struct perf_sample& sample)
46 sample.raw_data = NULL;
47 sample.callchain = NULL;
48 sample.branch_stack = NULL;
50 ~PerfSampleCustodian() {
51 if (sample_.callchain)
52 delete [] sample_.callchain;
53 if (sample_.branch_stack)
54 delete [] sample_.branch_stack;
55 if (sample_.branch_stack)
56 delete [] reinterpret_cast<char*>(sample_.raw_data);
59 struct perf_sample& sample_;
62 typedef perf_event event_t;