OLD | NEW |
1 // Copyright (c) 2005, Google Inc. | 1 // Copyright (c) 2005, 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext, | 263 void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext, |
264 void* cpu_profiler) { | 264 void* cpu_profiler) { |
265 CpuProfiler* instance = static_cast<CpuProfiler*>(cpu_profiler); | 265 CpuProfiler* instance = static_cast<CpuProfiler*>(cpu_profiler); |
266 | 266 |
267 if (instance->filter_ == NULL || | 267 if (instance->filter_ == NULL || |
268 (*instance->filter_)(instance->filter_arg_)) { | 268 (*instance->filter_)(instance->filter_arg_)) { |
269 void* stack[ProfileData::kMaxStackDepth]; | 269 void* stack[ProfileData::kMaxStackDepth]; |
270 | 270 |
271 // The top-most active routine doesn't show up as a normal | 271 // The top-most active routine doesn't show up as a normal |
272 // frame, but as the "pc" value in the signal handler context. | 272 // frame, but as the "pc" value in the signal handler context. |
| 273 #if defined(__ANDROID__) |
| 274 stack[0] = GetPC(*reinterpret_cast<tcmalloc::ucontext_t*>(signal_ucontext)); |
| 275 #else |
273 stack[0] = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext)); | 276 stack[0] = GetPC(*reinterpret_cast<ucontext_t*>(signal_ucontext)); |
| 277 #endif |
274 | 278 |
275 // We skip the top two stack trace entries (this function and one | 279 // We skip the top two stack trace entries (this function and one |
276 // signal handler frame) since they are artifacts of profiling and | 280 // signal handler frame) since they are artifacts of profiling and |
277 // should not be measured. Other profiling related frames may be | 281 // should not be measured. Other profiling related frames may be |
278 // removed by "pprof" at analysis time. Instead of skipping the top | 282 // removed by "pprof" at analysis time. Instead of skipping the top |
279 // frames, we could skip nothing, but that would increase the | 283 // frames, we could skip nothing, but that would increase the |
280 // profile size unnecessarily. | 284 // profile size unnecessarily. |
281 int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, | 285 int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, |
282 2, signal_ucontext); | 286 2, signal_ucontext); |
283 depth++; // To account for pc value in stack[0]; | 287 depth++; // To account for pc value in stack[0]; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 extern "C" void ProfilerStop() { } | 339 extern "C" void ProfilerStop() { } |
336 extern "C" void ProfilerGetCurrentState(ProfilerState* state) { | 340 extern "C" void ProfilerGetCurrentState(ProfilerState* state) { |
337 memset(state, 0, sizeof(*state)); | 341 memset(state, 0, sizeof(*state)); |
338 } | 342 } |
339 | 343 |
340 #endif // OS_CYGWIN | 344 #endif // OS_CYGWIN |
341 | 345 |
342 // DEPRECATED routines | 346 // DEPRECATED routines |
343 extern "C" PERFTOOLS_DLL_DECL void ProfilerEnable() { } | 347 extern "C" PERFTOOLS_DLL_DECL void ProfilerEnable() { } |
344 extern "C" PERFTOOLS_DLL_DECL void ProfilerDisable() { } | 348 extern "C" PERFTOOLS_DLL_DECL void ProfilerDisable() { } |
OLD | NEW |