Bug 707185 - Programmatic control for eventtracer. r=ted.mielczarek

This commit is contained in:
Benoit Girard 2011-12-04 20:53:17 -05:00
parent d3a7577552
commit c7c76c3daa
5 changed files with 28 additions and 16 deletions

View File

@ -123,6 +123,7 @@ void TracerThread(void *arg)
// This is the sampling interval.
PRIntervalTime interval = PR_MillisecondsToInterval(10);
sExit = false;
FILE* log = NULL;
char* envfile = PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP_OUTPUT");
if (envfile) {
@ -193,6 +194,9 @@ namespace mozilla {
bool InitEventTracing()
{
if (sTracerThread)
return true;
// Initialize the widget backend.
if (!InitWidgetTracing())
return false;
@ -212,6 +216,9 @@ bool InitEventTracing()
void ShutdownEventTracing()
{
if (!sTracerThread)
return;
sExit = true;
// Ensure that the tracer thread doesn't hang.
SignalTracerThread();

View File

@ -75,6 +75,7 @@ endif
ifdef MOZ_INSTRUMENT_EVENT_LOOP
CPPSRCS += EventTracer.cpp
EXPORTS += EventTracer.h
endif
DEFINES += -DIMPL_XREAPI -DMOZ_APP_NAME='"$(MOZ_APP_NAME)"'
@ -90,11 +91,11 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS += nsNativeAppSupportWin.cpp
CPPSRCS += nsWindowsDllBlocklist.cpp
DEFINES += -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE
EXPORTS = nsWindowsDllInterceptor.h
EXPORTS += nsWindowsDllInterceptor.h
else
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
CMMSRCS = nsNativeAppSupportCocoa.mm
EXPORTS = MacQuirks.h
EXPORTS += MacQuirks.h
else
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += nsNativeAppSupportOS2.cpp

View File

@ -3511,9 +3511,8 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
}
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
bool event_tracing_running = false;
if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP")) {
event_tracing_running = mozilla::InitEventTracing();
if (PR_GetEnv("MOZ_INSTRUMENT_EVENT_LOOP") || SAMPLER_IS_ACTIVE()) {
mozilla::InitEventTracing();
}
#endif /* MOZ_INSTRUMENT_EVENT_LOOP */
@ -3534,8 +3533,7 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
NS_TIME_FUNCTION_MARK("appStartup->Run done");
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
if (event_tracing_running)
mozilla::ShutdownEventTracing();
mozilla::ShutdownEventTracing();
#endif
// Check for an application initiated restart. This is one that

View File

@ -35,6 +35,9 @@
* ***** END LICENSE BLOCK ***** */
#include <string>
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
#include "EventTracer.h"
#endif
#include "sampler.h"
#include "nsProfiler.h"
#include "nsMemory.h"
@ -53,6 +56,9 @@ NS_IMETHODIMP
nsProfiler::StartProfiler(PRUint32 aInterval, PRUint32 aEntries)
{
SAMPLER_START(aInterval, aEntries);
#ifdef MOZ_INSTRUMENT_EVENT_LOOP
mozilla::InitEventTracing();
#endif
return NS_OK;
}

View File

@ -49,17 +49,17 @@ extern mozilla::tls::key pkey_stack;
extern mozilla::tls::key pkey_ticker;
extern bool stack_key_initialized;
#define SAMPLER_INIT() mozilla_sampler_init();
#define SAMPLER_DEINIT() mozilla_sampler_deinit();
#define SAMPLER_START(entries, interval) mozilla_sampler_start(entries, interval);
#define SAMPLER_STOP() mozilla_sampler_stop();
#define SAMPLER_IS_ACTIVE() mozilla_sampler_is_active();
#define SAMPLER_INIT() mozilla_sampler_init()
#define SAMPLER_DEINIT() mozilla_sampler_deinit()
#define SAMPLER_START(entries, interval) mozilla_sampler_start(entries, interval)
#define SAMPLER_STOP() mozilla_sampler_stop()
#define SAMPLER_IS_ACTIVE() mozilla_sampler_is_active()
#define SAMPLER_RESPONSIVENESS(time) mozilla_sampler_responsiveness(time)
#define SAMPLER_GET_RESPONSIVENESS() mozilla_sampler_get_responsiveness()
#define SAMPLER_SAVE() mozilla_sampler_save();
#define SAMPLER_GET_PROFILE() mozilla_sampler_get_profile();
#define SAMPLE_LABEL(name_space, info) mozilla::SamplerStackFrameRAII only_one_sampleraii_per_scope(FULLFUNCTION, name_space "::" info);
#define SAMPLE_MARKER(info) mozilla_sampler_add_marker(info);
#define SAMPLER_SAVE() mozilla_sampler_save()
#define SAMPLER_GET_PROFILE() mozilla_sampler_get_profile()
#define SAMPLE_LABEL(name_space, info) mozilla::SamplerStackFrameRAII only_one_sampleraii_per_scope(FULLFUNCTION, name_space "::" info)
#define SAMPLE_MARKER(info) mozilla_sampler_add_marker(info)
/* we duplicate this code here to avoid header dependencies
* which make it more difficult to include in other places */