OLD | NEW |
1 /* Copyright (c) 2009, Google Inc. | 1 /* Copyright (c) 2009, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 /* | 96 /* |
97 * Registers a new thread with profile handler and should be called only once | 97 * Registers a new thread with profile handler and should be called only once |
98 * per thread. The main thread is registered at program startup. This routine | 98 * per thread. The main thread is registered at program startup. This routine |
99 * is called by the Thread module in google3/thread whenever a new thread is | 99 * is called by the Thread module in google3/thread whenever a new thread is |
100 * created. This function is not async-signal-safe. | 100 * created. This function is not async-signal-safe. |
101 */ | 101 */ |
102 void ProfileHandlerRegisterThread(); | 102 void ProfileHandlerRegisterThread(); |
103 | 103 |
104 /* | 104 /* |
| 105 * Unregisters a thread before exiting. This is not strictly necessary in most |
| 106 * cases, because the pthread library will detect that previously-valid thread |
| 107 * identifiers have become invalid. For dead-thread detection to work, pthread |
| 108 * identifiers are accessed even after the thread has been destroyed, which may |
| 109 * fail in some edge cases (thread ID recycling) and even crash in exotic cases |
| 110 * (for example, when using user-allocated stacks with NPTL and unmapping the |
| 111 * memory after the thread terminates). Thus, it is generally good practice to |
| 112 * call ProfileHandlerUnregisterThread() just before exiting the thread. |
| 113 */ |
| 114 void ProfileHandlerUnregisterThread(); |
| 115 |
| 116 /* |
105 * Registers a callback routine. This callback function will be called in the | 117 * Registers a callback routine. This callback function will be called in the |
106 * context of SIGPROF handler, so must be async-signal-safe. The returned token | 118 * context of SIGPROF handler, so must be async-signal-safe. The returned token |
107 * is to be used when unregistering this callback via | 119 * is to be used when unregistering this callback via |
108 * ProfileHandlerUnregisterCallback. Registering the first callback enables | 120 * ProfileHandlerUnregisterCallback. Registering the first callback enables |
109 * the SIGPROF signal handler. Caller must not free the returned token. This | 121 * the SIGPROF signal handler. Caller must not free the returned token. This |
110 * function is not async-signal-safe. | 122 * function is not async-signal-safe. |
111 */ | 123 */ |
112 ProfileHandlerToken* ProfileHandlerRegisterCallback( | 124 ProfileHandlerToken* ProfileHandlerRegisterCallback( |
113 ProfileHandlerCallback callback, void* callback_arg); | 125 ProfileHandlerCallback callback, void* callback_arg); |
114 | 126 |
(...skipping 24 matching lines...) Expand all Loading... |
139 int64 interrupts; /* Number of interrupts received */ | 151 int64 interrupts; /* Number of interrupts received */ |
140 bool allowed; /* Profiling is allowed */ | 152 bool allowed; /* Profiling is allowed */ |
141 }; | 153 }; |
142 void ProfileHandlerGetState(struct ProfileHandlerState* state); | 154 void ProfileHandlerGetState(struct ProfileHandlerState* state); |
143 | 155 |
144 #ifdef __cplusplus | 156 #ifdef __cplusplus |
145 } /* extern "C" */ | 157 } /* extern "C" */ |
146 #endif | 158 #endif |
147 | 159 |
148 #endif /* BASE_PROFILE_HANDLER_H_ */ | 160 #endif /* BASE_PROFILE_HANDLER_H_ */ |
OLD | NEW |