blob: f3b1717f30374ce892bf53f297a5d0c24d967f12 [file] [log] [blame]
Than McIntosh7e2f4e92015-03-05 11:05:02 -05001/*
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
Dehao Chen5c415622015-05-07 13:16:35 -070021// File containing a list of sequence numbers corresponding to profiles
22// that have been processed/uploaded. Written by the GmsCore uploader,
23// within the GmsCore files directory.
24#define PROCESSED_FILENAME "perfprofd_processed.txt"
25
26// File containing a list of sequence numbers corresponding to profiles
27// that have been created by the perfprofd but not yet uploaded. Written
28// by perfprofd within the destination directory; consumed by GmsCore.
29#define PRODUCED_FILENAME "perfprofd_produced.txt"
30
31// Maximum number of encoded perf.data files stored in destination dir
32#define MAX_UNPROCESSED_FILE 10
33
Than McIntosh7e2f4e92015-03-05 11:05:02 -050034// Main routine for perfprofd daemon
35extern int perfprofd_main(int argc, char **argv);
36
37//
38// This enumeration holds the results of what happened when on an
39// attempted perf profiling run.
40//
41typedef enum {
42
43 // Success
44 OK_PROFILE_COLLECTION,
45
46 // Fork system call failed (lo mem?)
47 ERR_FORK_FAILED,
48
49 // Perf ran but crashed or returned a bad exit status
50 ERR_PERF_RECORD_FAILED,
51
52 // The perf.data encoding process failed somehow
53 ERR_PERF_ENCODE_FAILED,
54
55 // We tried to open the output file perf.data.encoded but the open failed
56 ERR_OPEN_ENCODED_FILE_FAILED,
57
58 // Error while writing perf.data.encoded
59 ERR_WRITE_ENCODED_FILE_FAILED
60} PROFILE_RESULT;
61
62//
63// Given a full path to a perf.data file specified by "data_file_path",
64// read/summarize/encode the contents into a new file specified
65// by "encoded_file_path". Return status indicates whether the operation
66// was successful (either OK_PROFILE_COLLECTION or an error of some sort).
67//
68PROFILE_RESULT encode_to_proto(const std::string &data_file_path,
Dehao Chen5c415622015-05-07 13:16:35 -070069 const char *encoded_file_path);