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/String16.h> 22 #include <utils/Vector.h> 23 24 namespace android { 25 namespace camera3 { 26 27 class CameraTracesImpl; 28 29 // Collect a list of the process's stack traces 30 class CameraTraces { 31 public: 32 /** 33 * Save the current stack trace for each thread in the process. At most 34 * MAX_TRACES will be saved, after which the oldest traces will be discarded. 35 * 36 * <p>Use CameraTraces::dump to print out the traces.</p> 37 */ 38 static void saveTrace(); 39 40 /** 41 * Prints all saved traces to the specified file descriptor. 42 * 43 * <p>Each line is indented by DUMP_INDENT spaces.</p> 44 */ 45 static status_t dump(int fd, const Vector<String16>& args); 46 47 private: 48 enum { 49 // Don't collect more than 100 traces. Discard oldest. 50 MAX_TRACES = 100, 51 52 // Insert 2 spaces when dumping the traces 53 DUMP_INDENT = 2, 54 }; 55 56 CameraTraces(); 57 ~CameraTraces(); 58 CameraTraces(CameraTraces& rhs); 59 60 static CameraTracesImpl& sImpl; 61 }; // class CameraTraces 62 63 }; // namespace camera3 64 }; // namespace android 65 66 #endif // ANDROID_SERVERS_CAMERA_TRACES_H_ 67