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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #elif defined(HAVE_UCONTEXT_H) | 48 #elif defined(HAVE_UCONTEXT_H) |
49 #include <ucontext.h> | 49 #include <ucontext.h> |
50 #elif defined(HAVE_CYGWIN_SIGNAL_H) | 50 #elif defined(HAVE_CYGWIN_SIGNAL_H) |
51 #include <cygwin/signal.h> | 51 #include <cygwin/signal.h> |
52 typedef ucontext ucontext_t; | 52 typedef ucontext ucontext_t; |
53 #else | 53 #else |
54 typedef int ucontext_t; // just to quiet the compiler, mostly | 54 typedef int ucontext_t; // just to quiet the compiler, mostly |
55 #endif | 55 #endif |
56 #include <sys/time.h> | 56 #include <sys/time.h> |
57 #include <string> | 57 #include <string> |
58 #include <google/profiler.h> | 58 #include <gperftools/profiler.h> |
59 #include <google/stacktrace.h> | 59 #include <gperftools/stacktrace.h> |
60 #include "base/commandlineflags.h" | 60 #include "base/commandlineflags.h" |
61 #include "base/logging.h" | 61 #include "base/logging.h" |
62 #include "base/googleinit.h" | 62 #include "base/googleinit.h" |
63 #include "base/spinlock.h" | 63 #include "base/spinlock.h" |
64 #include "base/sysinfo.h" /* for GetUniquePathFromEnv, etc */ | 64 #include "base/sysinfo.h" /* for GetUniquePathFromEnv, etc */ |
65 #include "profiledata.h" | 65 #include "profiledata.h" |
66 #include "profile-handler.h" | 66 #include "profile-handler.h" |
67 #ifdef HAVE_CONFLICT_SIGNAL_H | 67 #ifdef HAVE_CONFLICT_SIGNAL_H |
68 #include "conflict-signal.h" /* used on msvc machines */ | 68 #include "conflict-signal.h" /* used on msvc machines */ |
69 #endif | 69 #endif |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // frames, we could skip nothing, but that would increase the | 277 // frames, we could skip nothing, but that would increase the |
278 // profile size unnecessarily. | 278 // profile size unnecessarily. |
279 int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, | 279 int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, |
280 2, signal_ucontext); | 280 2, signal_ucontext); |
281 depth++; // To account for pc value in stack[0]; | 281 depth++; // To account for pc value in stack[0]; |
282 | 282 |
283 instance->collector_.Add(depth, stack); | 283 instance->collector_.Add(depth, stack); |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 #if !(defined(__CYGWIN__) || defined(__CYGWIN32__)) && !defined(__native_client_
_) | 287 #if !(defined(__CYGWIN__) || defined(__CYGWIN32__)) |
288 | 288 |
289 extern "C" PERFTOOLS_DLL_DECL void ProfilerRegisterThread() { | 289 extern "C" PERFTOOLS_DLL_DECL void ProfilerRegisterThread() { |
290 ProfileHandlerRegisterThread(); | 290 ProfileHandlerRegisterThread(); |
291 } | 291 } |
292 | 292 |
293 extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() { | 293 extern "C" PERFTOOLS_DLL_DECL void ProfilerFlush() { |
294 CpuProfiler::instance_.FlushTable(); | 294 CpuProfiler::instance_.FlushTable(); |
295 } | 295 } |
296 | 296 |
297 extern "C" PERFTOOLS_DLL_DECL int ProfilingIsEnabledForAllThreads() { | 297 extern "C" PERFTOOLS_DLL_DECL int ProfilingIsEnabledForAllThreads() { |
(...skipping 11 matching lines...) Expand all Loading... |
309 | 309 |
310 extern "C" PERFTOOLS_DLL_DECL void ProfilerStop() { | 310 extern "C" PERFTOOLS_DLL_DECL void ProfilerStop() { |
311 CpuProfiler::instance_.Stop(); | 311 CpuProfiler::instance_.Stop(); |
312 } | 312 } |
313 | 313 |
314 extern "C" PERFTOOLS_DLL_DECL void ProfilerGetCurrentState( | 314 extern "C" PERFTOOLS_DLL_DECL void ProfilerGetCurrentState( |
315 ProfilerState* state) { | 315 ProfilerState* state) { |
316 CpuProfiler::instance_.GetCurrentState(state); | 316 CpuProfiler::instance_.GetCurrentState(state); |
317 } | 317 } |
318 | 318 |
319 #else // !defined(OS_CYGWIN) && !defined(__native_client__) | 319 #else // OS_CYGWIN |
320 | 320 |
321 // ITIMER_PROF doesn't work under cygwin. ITIMER_REAL is available, but doesn't | 321 // ITIMER_PROF doesn't work under cygwin. ITIMER_REAL is available, but doesn't |
322 // work as well for profiling, and also interferes with alarm(). Because of | 322 // work as well for profiling, and also interferes with alarm(). Because of |
323 // these issues, unless a specific need is identified, profiler support is | 323 // these issues, unless a specific need is identified, profiler support is |
324 // disabled under Cygwin. | 324 // disabled under Cygwin. |
325 // | |
326 // Native Client runtime also does not have signals working. | |
327 extern "C" void ProfilerRegisterThread() { } | 325 extern "C" void ProfilerRegisterThread() { } |
328 extern "C" void ProfilerFlush() { } | 326 extern "C" void ProfilerFlush() { } |
329 extern "C" int ProfilingIsEnabledForAllThreads() { return 0; } | 327 extern "C" int ProfilingIsEnabledForAllThreads() { return 0; } |
330 extern "C" int ProfilerStart(const char* fname) { return 0; } | 328 extern "C" int ProfilerStart(const char* fname) { return 0; } |
331 extern "C" int ProfilerStartWithOptions(const char *fname, | 329 extern "C" int ProfilerStartWithOptions(const char *fname, |
332 const ProfilerOptions *options) { | 330 const ProfilerOptions *options) { |
333 return 0; | 331 return 0; |
334 } | 332 } |
335 extern "C" void ProfilerStop() { } | 333 extern "C" void ProfilerStop() { } |
336 extern "C" void ProfilerGetCurrentState(ProfilerState* state) { | 334 extern "C" void ProfilerGetCurrentState(ProfilerState* state) { |
337 memset(state, 0, sizeof(*state)); | 335 memset(state, 0, sizeof(*state)); |
338 } | 336 } |
339 | 337 |
340 #endif // !defined(OS_CYGWIN) && !defined(__native_client__) | 338 #endif // OS_CYGWIN |
341 | 339 |
342 // DEPRECATED routines | 340 // DEPRECATED routines |
343 extern "C" PERFTOOLS_DLL_DECL void ProfilerEnable() { } | 341 extern "C" PERFTOOLS_DLL_DECL void ProfilerEnable() { } |
344 extern "C" PERFTOOLS_DLL_DECL void ProfilerDisable() { } | 342 extern "C" PERFTOOLS_DLL_DECL void ProfilerDisable() { } |
OLD | NEW |