OSDN Git Service

1bff9ba4a1621e4287c9e26f34706b5bc86f1722
[android-x86/system-extras.git] / perfprofd / perfprofdcore.h
1 /*
2 **
3 ** Copyright 2015, The Android Open Source Project
4 **
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
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
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.
16 */
17
18 // Semaphore file that indicates that the user is opting in
19 #define SEMAPHORE_FILENAME "perf_profile_collection_enabled.txt"
20
21 // Main routine for perfprofd daemon
22 extern int perfprofd_main(int argc, char **argv);
23
24 //
25 // This enumeration holds the results of what happened when on an
26 // attempted perf profiling run.
27 //
28 typedef enum {
29
30   // Success
31   OK_PROFILE_COLLECTION,
32
33   // Fork system call failed (lo mem?)
34   ERR_FORK_FAILED,
35
36   // Perf ran but crashed or returned a bad exit status
37   ERR_PERF_RECORD_FAILED,
38
39   // The perf.data encoding process failed somehow
40   ERR_PERF_ENCODE_FAILED,
41
42   // We tried to open the output file perf.data.encoded but the open failed
43   ERR_OPEN_ENCODED_FILE_FAILED,
44
45   // Error while writing perf.data.encoded
46   ERR_WRITE_ENCODED_FILE_FAILED
47 } PROFILE_RESULT;
48
49 //
50 // Given a full path to a perf.data file specified by "data_file_path",
51 // read/summarize/encode the contents into a new file specified
52 // by "encoded_file_path". Return status indicates whether the operation
53 // was successful (either OK_PROFILE_COLLECTION or an error of some sort).
54 //
55 PROFILE_RESULT encode_to_proto(const std::string &data_file_path,
56                                const std::string &encoded_file_path);