| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEBUG_H__ | 5 #ifndef DEBUG_H__ |
| 6 #define DEBUG_H__ | 6 #define DEBUG_H__ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if defined(__x86_64__) | 24 #if defined(__x86_64__) |
| 25 __attribute__((visibility("internal"))) | 25 __attribute__((visibility("internal"))) |
| 26 #endif | 26 #endif |
| 27 ; | 27 ; |
| 28 #else | 28 #else |
| 29 { } | 29 { } |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 // If debugging is enabled, write the name of the syscall and an optional | 32 // If debugging is enabled, write the name of the syscall and an optional |
| 33 // message to stderr. | 33 // message to stderr. |
| 34 static void syscall(int sysnum, const char* msg, int call = -1) | 34 static void syscall(long long* tm, int sysnum, |
| 35 const char* msg, int call = -1) |
| 35 #ifndef NDEBUG | 36 #ifndef NDEBUG |
| 36 ; | 37 ; |
| 37 #else | 38 #else |
| 38 { } | 39 { } |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 42 // Print how much wall-time has elapsed since the last call to syscall() |
| 43 static void elapsed(long long tm, int sysnum, int call = -1) |
| 44 #ifndef NDEBUG |
| 45 ; |
| 46 #else |
| 47 { |
| 48 } |
| 49 #endif |
| 50 |
| 41 // Check whether debugging is enabled. | 51 // Check whether debugging is enabled. |
| 42 static bool isEnabled() { | 52 static bool isEnabled() { |
| 43 #ifndef NDEBUG | 53 #ifndef NDEBUG |
| 44 return enabled_; | 54 return enabled_; |
| 45 #else | 55 #else |
| 46 return false; | 56 return false; |
| 47 #endif | 57 #endif |
| 48 } | 58 } |
| 49 | 59 |
| 50 private: | 60 private: |
| 51 #ifndef NDEBUG | 61 #ifndef NDEBUG |
| 52 Debug(); | 62 Debug(); |
| 63 static bool enter(); |
| 64 static bool leave(); |
| 65 static void _message(const char* msg); |
| 66 static void gettimeofday(long long* tm); |
| 53 static char* itoa(char* s, int n); | 67 static char* itoa(char* s, int n); |
| 54 | 68 |
| 55 static Debug debug_; | 69 static Debug debug_; |
| 56 | 70 |
| 57 static bool enabled_; | 71 static bool enabled_; |
| 58 static int numSyscallNames_; | 72 static int numSyscallNames_; |
| 59 static const char **syscallNames_; | 73 static const char **syscallNames_; |
| 60 static std::map<int, std::string> syscallNamesMap_; | 74 static std::map<int, std::string> syscallNamesMap_; |
| 61 #endif | 75 #endif |
| 62 }; | 76 }; |
| 63 | 77 |
| 64 } // namespace | 78 } // namespace |
| 65 | 79 |
| 66 #endif // DEBUG_H__ | 80 #endif // DEBUG_H__ |
| OLD | NEW |