dumpstate.h revision 71ca15eadd3da0c102a8539f7a88294a94456623
1f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* 2f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * Copyright (C) 2008 The Android Open Source Project 3f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * 4f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * Licensed under the Apache License, Version 2.0 (the "License"); 5f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * you may not use this file except in compliance with the License. 6f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * You may obtain a copy of the License at 7f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * 8f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * http://www.apache.org/licenses/LICENSE-2.0 9f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * 10f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * Unless required by applicable law or agreed to in writing, software 11f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * distributed under the License is distributed on an "AS IS" BASIS, 12f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * See the License for the specific language governing permissions and 14f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross * limitations under the License. 15f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross */ 16f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 17f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#ifndef _DUMPSTATE_H_ 18f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#define _DUMPSTATE_H_ 19f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 2093d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme/* When defined, skips the real dumps and just print the section headers. 2193d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme Useful when debugging dumpstate itself. */ 2293d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme//#define _DUMPSTATE_DRY_RUN_ 2393d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme 2493d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme#ifdef _DUMPSTATE_DRY_RUN_ 2593d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme#define ON_DRY_RUN_RETURN(X) return X 26ed24d2ae2cd6e8b0afb86efa555f18bcfaf74a64Christopher Ferris#define ON_DRY_RUN(code) code 27ed24d2ae2cd6e8b0afb86efa555f18bcfaf74a64Christopher Ferris#else 2893d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme#define ON_DRY_RUN_RETURN(X) 29ed24d2ae2cd6e8b0afb86efa555f18bcfaf74a64Christopher Ferris#define ON_DRY_RUN(code) 3093d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme#endif 3193d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme 32cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#ifndef MYLOGD 3360869c9e1e91170d487715fc30b795d786630c54Felipe Leme#define MYLOGD(...) fprintf(stderr, __VA_ARGS__); ALOGD(__VA_ARGS__); 34cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#endif 35cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme 36cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#ifndef MYLOGI 3760869c9e1e91170d487715fc30b795d786630c54Felipe Leme#define MYLOGI(...) fprintf(stderr, __VA_ARGS__); ALOGI(__VA_ARGS__); 38cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#endif 39cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme 40cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#ifndef MYLOGE 4160869c9e1e91170d487715fc30b795d786630c54Felipe Leme#define MYLOGE(...) fprintf(stderr, __VA_ARGS__); ALOGE(__VA_ARGS__); 42cbce55d4fdbdd2e5a5515054c48d2116c5db2712Felipe Leme#endif 4393d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme 44f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#include <time.h> 45f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#include <unistd.h> 460c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Cross#include <stdbool.h> 47f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#include <stdio.h> 4836b3f6ff17e456dea81501006e33d5fdd1d3b480Felipe Leme#include <vector> 49f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 50f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#define SU_PATH "/system/xbin/su" 51f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 528620bb4118a68721d10c29529dc6978847d08d00Felipe Leme#ifdef __cplusplus 538620bb4118a68721d10c29529dc6978847d08d00Felipe Lemeextern "C" { 548620bb4118a68721d10c29529dc6978847d08d00Felipe Leme#endif 558620bb4118a68721d10c29529dc6978847d08d00Felipe Leme 560c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Crosstypedef void (for_each_pid_func)(int, const char *); 570c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Crosstypedef void (for_each_tid_func)(int, int, const char *); 580c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Cross 5971bbfc57974331dce79242ce806d92035fce06baFelipe Leme/* Estimated total weight of bugreport generation. 6071bbfc57974331dce79242ce806d92035fce06baFelipe Leme * 6171bbfc57974331dce79242ce806d92035fce06baFelipe Leme * Each section contributes to the total weight by an individual weight, so the overall progress 6271bbfc57974331dce79242ce806d92035fce06baFelipe Leme * can be calculated by dividing the all completed weight by the total weight. 6371bbfc57974331dce79242ce806d92035fce06baFelipe Leme * 6471bbfc57974331dce79242ce806d92035fce06baFelipe Leme * This value is defined empirically and it need to be adjusted as more sections are added. 65ad5f6c475934ac6a658a203069a9f055540946e7Felipe Leme * 66ad5f6c475934ac6a658a203069a9f055540946e7Felipe Leme * It does not need to match the exact sum of all sections, but ideally it should to be slight more 67ad5f6c475934ac6a658a203069a9f055540946e7Felipe Leme * than such sum: a value too high will cause the bugreport to finish before the user expected (for 68faf67e3fe2451e75d0369906a579d3e1386a5064Felipe Leme * example, jumping from 70% to 100%), while a value too low will cause the progress to get stuck 69faf67e3fe2451e75d0369906a579d3e1386a5064Felipe Leme * at an almost-finished value (like 99%) for a while. 7071bbfc57974331dce79242ce806d92035fce06baFelipe Leme */ 71faf67e3fe2451e75d0369906a579d3e1386a5064Felipe Lemestatic const int WEIGHT_TOTAL = 6500; 7271bbfc57974331dce79242ce806d92035fce06baFelipe Leme 7371bbfc57974331dce79242ce806d92035fce06baFelipe Leme/* Most simple commands have 10 as timeout, so 5 is a good estimate */ 7471bbfc57974331dce79242ce806d92035fce06baFelipe Lemestatic const int WEIGHT_FILE = 5; 7571bbfc57974331dce79242ce806d92035fce06baFelipe Leme 7671bbfc57974331dce79242ce806d92035fce06baFelipe Leme/* 770c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme * TODO: the dumpstate internal state is getting fragile; for example, this variable is defined 7871bbfc57974331dce79242ce806d92035fce06baFelipe Leme * here, declared at utils.cpp, and used on utils.cpp and dumpstate.cpp. 7971bbfc57974331dce79242ce806d92035fce06baFelipe Leme * It would be better to take advantage of the C++ migration and encapsulate the state in an object, 8071bbfc57974331dce79242ce806d92035fce06baFelipe Leme * but that will be better handled in a major C++ refactoring, which would also get rid of other C 8171bbfc57974331dce79242ce806d92035fce06baFelipe Leme * idioms (like using std::string instead of char*, removing varargs, etc...) */ 82e338bf60701e5b955ab0a097f2631f2190218894Felipe Lemeextern int do_update_progress, progress, weight_total; 8371bbfc57974331dce79242ce806d92035fce06baFelipe Leme 8471ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme/* full path of the directory where the bugreport files will be written */ 8571ca15eadd3da0c102a8539f7a88294a94456623Felipe Lemeextern std::string bugreport_dir; 8671ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme 8771ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme/* root dir for all files copied as-is into the bugreport. */ 8871ca15eadd3da0c102a8539f7a88294a94456623Felipe Lemeextern const std::string ZIP_ROOT_DIR; 8971ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme 9071ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme/* adds a new entry to the existing zip file. */ 9171ca15eadd3da0c102a8539f7a88294a94456623Felipe Lemebool add_zip_entry(const std::string& entry_name, const std::string& entry_path); 9271ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme 9371ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme/* adds a new entry to the existing zip file. */ 9471ca15eadd3da0c102a8539f7a88294a94456623Felipe Lemebool add_zip_entry_from_fd(const std::string& entry_name, int fd); 9571ca15eadd3da0c102a8539f7a88294a94456623Felipe Leme 96f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* prints the contents of a file */ 971fe6107b66516b225e0843836d60a69b1b57f3c3Christopher Ferrisint dump_file(const char *title, const char *path); 981fe6107b66516b225e0843836d60a69b1b57f3c3Christopher Ferris 9971a74ac75c8687195d27642fa0db31a796102c59Felipe Leme/* saves the the contents of a file as a long */ 10071a74ac75c8687195d27642fa0db31a796102c59Felipe Lemeint read_file_as_long(const char *path, long int *output); 10171a74ac75c8687195d27642fa0db31a796102c59Felipe Leme 10254bcc5ffd5a79f4f194089c58d3de571532bf39bChristopher Ferris/* prints the contents of the fd 10354bcc5ffd5a79f4f194089c58d3de571532bf39bChristopher Ferris * fd must have been opened with the flag O_NONBLOCK. 10454bcc5ffd5a79f4f194089c58d3de571532bf39bChristopher Ferris */ 1051fe6107b66516b225e0843836d60a69b1b57f3c3Christopher Ferrisint dump_file_from_fd(const char *title, const char *path, int fd); 106f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 107326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn/* calls skip to gate calling dump_from_fd recursively 108326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn * in the specified directory. dump_from_fd defaults to 109326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn * dump_file_from_fd above when set to NULL. skip defaults 110326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn * to false when set to NULL. dump_from_fd will always be 111326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn * called with title NULL. 112326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn */ 113326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzynint dump_files(const char *title, const char *dir, 114326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn bool (*skip)(const char *path), 115326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn int (*dump_from_fd)(const char *title, const char *path, int fd)); 116326842fca4883f1256aa9ed019bb3206ee76fca7Mark Salyzyn 117cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Leme// TODO: need to refactor all those run_command variations; there shold be just one, receiving an 118cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Leme// optional CommandOptions objects with values such as run_always, drop_root, etc... 119cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Leme 120f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* forks a command and waits for it to finish -- terminate args with NULL */ 121cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Lemeint run_command_as_shell(const char *title, int timeout_seconds, const char *command, ...); 122f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossint run_command(const char *title, int timeout_seconds, const char *command, ...); 123f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 12429c39715b8a45ca2e97aecd8ebb63183f63da72bFelipe Lemeenum RootMode { DROP_ROOT, DONT_DROP_ROOT }; 12529c39715b8a45ca2e97aecd8ebb63183f63da72bFelipe Lemeenum StdoutMode { NORMAL_STDOUT, REDIRECT_TO_STDERR }; 12629c39715b8a45ca2e97aecd8ebb63183f63da72bFelipe Leme 12793d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme/* forks a command and waits for it to finish 12893d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme first element of args is the command, and last must be NULL. 12993d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme command is always ran, even when _DUMPSTATE_DRY_RUN_ is defined. */ 13029c39715b8a45ca2e97aecd8ebb63183f63da72bFelipe Lemeint run_command_always(const char *title, RootMode root_mode, StdoutMode stdout_mode, 13129c39715b8a45ca2e97aecd8ebb63183f63da72bFelipe Leme int timeout_seconds, const char *args[]); 132cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Leme 133cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Leme/* switch to non-root user and group */ 134cf6a8b47dc04f1c33ddc337b5e21f2c5b7354cb5Felipe Lemebool drop_root_user(); 13593d705b6d742e8f00167ff2384e35c2205a6f9daFelipe Leme 13636b3f6ff17e456dea81501006e33d5fdd1d3b480Felipe Leme/* sends a broadcast using Activity Manager */ 13736b3f6ff17e456dea81501006e33d5fdd1d3b480Felipe Lemevoid send_broadcast(const std::string& action, const std::vector<std::string>& args); 13836b3f6ff17e456dea81501006e33d5fdd1d3b480Felipe Leme 13971bbfc57974331dce79242ce806d92035fce06baFelipe Leme/* updates the overall progress of dumpstate by the given weight increment */ 14071bbfc57974331dce79242ce806d92035fce06baFelipe Lemevoid update_progress(int weight); 14171bbfc57974331dce79242ce806d92035fce06baFelipe Leme 142f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* prints all the system properties */ 143f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossvoid print_properties(); 144f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 1452628e9e939fda323fa44c5cb743f4a77b12a312aFelipe Leme/** opens a socket and returns its file descriptor */ 1462628e9e939fda323fa44c5cb743f4a77b12a312aFelipe Lemeint open_socket(const char *service); 1472628e9e939fda323fa44c5cb743f4a77b12a312aFelipe Leme 148f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* redirect output to a service control socket */ 149f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossvoid redirect_to_socket(FILE *redirect, const char *service); 150f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 151ff4a4dc7e6e3ead12020b4dc17548d767a419ddeChristopher Ferris/* redirect output to a file */ 152ff4a4dc7e6e3ead12020b4dc17548d767a419ddeChristopher Ferrisvoid redirect_to_file(FILE *redirect, char *path); 153f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 154111b9d06cc0fc72438782c9234f28675e5077ef4Felipe Leme/* create leading directories, if necessary */ 155111b9d06cc0fc72438782c9234f28675e5077ef4Felipe Lemevoid create_parent_dirs(const char *path); 156111b9d06cc0fc72438782c9234f28675e5077ef4Felipe Leme 157bf7f49238d0af497d4300f7e611cf831854d6434Jeff Brown/* dump Dalvik and native stack traces, return the trace file location (NULL if none) */ 158bf7f49238d0af497d4300f7e611cf831854d6434Jeff Brownconst char *dump_traces(); 159f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 160f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* for each process in the system, run the specified function */ 1610c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Crossvoid for_each_pid(for_each_pid_func func, const char *header); 1620c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Cross 1630c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Cross/* for each thread in the system, run the specified function */ 1640c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Crossvoid for_each_tid(for_each_tid_func func, const char *header); 165f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 166f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* Displays a blocked processes in-kernel wait channel */ 1670c22e8b31651caf12a2b4d4acef5bc65d486e570Colin Crossvoid show_wchan(int pid, int tid, const char *name); 168f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 169a297c3258f6f7ea52cc2dcc42d62f85fda12a163Mark Salyzyn/* Displays a processes times */ 170a297c3258f6f7ea52cc2dcc42d62f85fda12a163Mark Salyzynvoid show_showtime(int pid, const char *name); 171a297c3258f6f7ea52cc2dcc42d62f85fda12a163Mark Salyzyn 172f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* Runs "showmap" for a process */ 173f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossvoid do_showmap(int pid, const char *name); 174f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 175f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* Gets the dmesg output for the kernel */ 176f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossvoid do_dmesg(); 177f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 1782b3bba34aec65b612be8d1f52cd124d9c30955f9Sreeram Ramachandran/* Prints the contents of all the routing tables, both IPv4 and IPv6. */ 1792b3bba34aec65b612be8d1f52cd124d9c30955f9Sreeram Ramachandranvoid dump_route_tables(); 1802b3bba34aec65b612be8d1f52cd124d9c30955f9Sreeram Ramachandran 181f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* Play a sound via Stagefright */ 1821fe6107b66516b225e0843836d60a69b1b57f3c3Christopher Ferrisvoid play_sound(const char *path); 183f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 184f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross/* Implemented by libdumpstate_board to dump board-specific info */ 185f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Crossvoid dumpstate_board(); 186f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross 187e338bf60701e5b955ab0a097f2631f2190218894Felipe Leme/* Takes a screenshot and save it to the given file */ 1883634a1e3459cb609da709646107e246cafbc01f9Felipe Lemevoid take_screenshot(const std::string& path); 189e338bf60701e5b955ab0a097f2631f2190218894Felipe Leme 1900c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme/* Vibrates for a given durating (in milliseconds). */ 1910c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Lemevoid vibrate(FILE* vibrator, int ms); 1920c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme 1930c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme/* Checks if a given path is a directory. */ 1940c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Lemebool is_dir(const char* pathname); 1950c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme 1960c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme/** Gets the last modification time of a file, or default time if file is not found. */ 1970c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Lemetime_t get_mtime(int fd, time_t default_mtime); 1980c80cf0caaf5dce5ef4d0265b249bd1ec680cca1Felipe Leme 19978f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme/* dump eMMC Extended CSD data */ 20078f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Lemevoid dump_emmc_ecsd(const char *ext_csd_path); 20178f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme 202a34efb7ae17a7ea1078cce75be634120bd72a421Felipe Leme/** gets command-line arguments */ 203a34efb7ae17a7ea1078cce75be634120bd72a421Felipe Lemevoid format_args(int argc, const char *argv[], std::string *args); 20488c7933df551f6dadd8cc931d104b01d6d1609e4Felipe Leme 20578f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme/* 20678f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * Helper class used to report how long it takes for a section to finish. 20778f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * 20878f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * Typical usage: 20978f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * 21078f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * DurationReporter duration_reporter(title); 21178f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme * 21278f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme */ 21378f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Lemeclass DurationReporter { 21478f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Lemepublic: 21578f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme DurationReporter(const char *title); 216608385dd151e36a93f3e3f4a7514b1e720d20ae9Felipe Leme DurationReporter(const char *title, FILE* out); 21778f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme 21878f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme ~DurationReporter(); 21978f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme 22078f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme static uint64_t nanotime(); 22178f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme 22278f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Lemeprivate: 22378f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme const char* title_; 224608385dd151e36a93f3e3f4a7514b1e720d20ae9Felipe Leme FILE* out_; 22578f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme uint64_t started_; 22678f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme}; 22778f2c86235d5882a8dc84c85a1c1864062e5f3afFelipe Leme 2288620bb4118a68721d10c29529dc6978847d08d00Felipe Leme#ifdef __cplusplus 2298620bb4118a68721d10c29529dc6978847d08d00Felipe Leme} 2308620bb4118a68721d10c29529dc6978847d08d00Felipe Leme#endif 2318620bb4118a68721d10c29529dc6978847d08d00Felipe Leme 232f45fa6b2853cc32385375a0b63ee39ad6a968869Colin Cross#endif /* _DUMPSTATE_H_ */ 233