• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_SERVERS_CAMERA_TRACES_H_
18 #define ANDROID_SERVERS_CAMERA_TRACES_H_
19 
20 #include <utils/Errors.h>
21 #include <utils/Vector.h>
22 
23 namespace android {
24 namespace camera3 {
25 
26 struct CameraTracesImpl;
27 
28 // Collect a list of the process's stack traces
29 class CameraTraces {
30 public:
31     /**
32      * Save the current stack trace for each thread in the process. At most
33      * MAX_TRACES will be saved, after which the oldest traces will be discarded.
34      *
35      * <p>Use CameraTraces::dump to print out the traces.</p>
36      */
37     static void     saveTrace();
38 
39     /**
40      * Prints all saved traces to the specified file descriptor.
41      *
42      * <p>Each line is indented by DUMP_INDENT spaces.</p>
43      */
44     static status_t dump(int fd);
45 
46 private:
47     enum {
48         // Don't collect more than 100 traces. Discard oldest.
49         MAX_TRACES = 100,
50 
51         // Insert 2 spaces when dumping the traces
52         DUMP_INDENT = 2,
53     };
54 
55     CameraTraces();
56     ~CameraTraces();
57     CameraTraces(CameraTraces& rhs);
58 
59     static CameraTracesImpl& sImpl;
60 }; // class CameraTraces
61 
62 }; // namespace camera3
63 }; // namespace android
64 
65 #endif // ANDROID_SERVERS_CAMERA_TRACES_H_
66