mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 01:48:05 +00:00
Bug 1320312 - Disable Telemetry stack capturing if stack walking is not available. r=gfritzsche
MozReview-Commit-ID: AQsMm2fWWV8
This commit is contained in:
parent
2f2df764d8
commit
de2948e3f2
@ -73,11 +73,15 @@
|
||||
#include "mozilla/PoisonIOInterposer.h"
|
||||
#include "mozilla/StartupTimeline.h"
|
||||
#include "mozilla/HangMonitor.h"
|
||||
|
||||
#if defined(MOZ_ENABLE_PROFILER_SPS)
|
||||
#include "shared-libraries.h"
|
||||
#if defined(MOZ_STACKWALKING)
|
||||
#define ENABLE_STACK_CAPTURE
|
||||
#include "mozilla/StackWalk.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#endif
|
||||
#endif // MOZ_STACKWALKING
|
||||
#endif // MOZ_ENABLE_PROFILER_SPS
|
||||
|
||||
namespace {
|
||||
|
||||
@ -395,7 +399,7 @@ HangReports::GetAnnotationInfo() const {
|
||||
return mAnnotationInfo;
|
||||
}
|
||||
|
||||
#if defined(MOZ_ENABLE_PROFILER_SPS)
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
|
||||
const uint8_t kMaxKeyLength = 50;
|
||||
|
||||
@ -883,6 +887,8 @@ public:
|
||||
int32_t aSystemUptime,
|
||||
int32_t aFirefoxUptime,
|
||||
HangAnnotationsPtr aAnnotations);
|
||||
#endif
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
static void DoStackCapture(const nsACString& aKey);
|
||||
#endif
|
||||
static void RecordThreadHangStats(Telemetry::ThreadHangStats& aStats);
|
||||
@ -931,7 +937,7 @@ private:
|
||||
HangReports mHangReports;
|
||||
Mutex mHangReportsMutex;
|
||||
|
||||
#if defined(MOZ_ENABLE_PROFILER_SPS)
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
// Stores data about stacks captured on demand.
|
||||
KeyedStackCapturer mStackCapturer;
|
||||
#endif
|
||||
@ -1528,7 +1534,7 @@ TelemetryImpl::GetChromeHangs(JSContext *cx, JS::MutableHandle<JS::Value> ret)
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::SnapshotCapturedStacks(bool clear, JSContext *cx, JS::MutableHandle<JS::Value> ret)
|
||||
{
|
||||
#if defined(MOZ_ENABLE_PROFILER_SPS)
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
nsresult rv = mStackCapturer.ReflectCapturedStacks(cx, ret);
|
||||
if (clear) {
|
||||
mStackCapturer.Clear();
|
||||
@ -2461,6 +2467,7 @@ TelemetryImpl::RecordChromeHang(uint32_t aDuration,
|
||||
Move(annotations));
|
||||
}
|
||||
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
void
|
||||
TelemetryImpl::DoStackCapture(const nsACString& aKey) {
|
||||
if (Telemetry::CanRecordExtended() && XRE_IsParentProcess()) {
|
||||
@ -2468,10 +2475,11 @@ TelemetryImpl::DoStackCapture(const nsACString& aKey) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
TelemetryImpl::CaptureStack(const nsACString& aKey) {
|
||||
#if defined(MOZ_ENABLE_PROFILER_SPS)
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
TelemetryImpl::DoStackCapture(aKey);
|
||||
#endif
|
||||
return NS_OK;
|
||||
@ -3148,7 +3156,9 @@ void RecordChromeHang(uint32_t duration,
|
||||
|
||||
void CaptureStack(const nsACString& aKey)
|
||||
{
|
||||
#if defined(ENABLE_STACK_CAPTURE)
|
||||
TelemetryImpl::DoStackCapture(aKey);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -4,6 +4,10 @@
|
||||
Cu.import("resource://gre/modules/TelemetryController.jsm", this);
|
||||
Cu.import("resource://gre/modules/AppConstants.jsm", this);
|
||||
|
||||
// We need both in order to capture stacks.
|
||||
const ENABLE_TESTS = AppConstants.MOZ_ENABLE_PROFILER_SPS &&
|
||||
AppConstants.MOZ_STACKWALKING;
|
||||
|
||||
/**
|
||||
* Ensures that the sctucture of the javascript object used for capturing stacks
|
||||
* is as intended. The structure is expected to be as in this example:
|
||||
@ -66,7 +70,7 @@ const TEST_STACK_KEYS = ["TEST-KEY1", "TEST-KEY2"];
|
||||
* Ensures that captured stacks appear in pings, if any were captured.
|
||||
*/
|
||||
add_task({
|
||||
skip_if: () => !AppConstants.MOZ_ENABLE_PROFILER_SPS
|
||||
skip_if: () => !ENABLE_TESTS
|
||||
}, function* test_capturedStacksAppearInPings() {
|
||||
yield TelemetryController.testSetup();
|
||||
captureStacks("DOES-NOT-MATTER", false);
|
||||
@ -83,7 +87,7 @@ add_task({
|
||||
* of captured stacks and adds a new entry to captures.
|
||||
*/
|
||||
add_task({
|
||||
skip_if: () => !AppConstants.MOZ_ENABLE_PROFILER_SPS
|
||||
skip_if: () => !ENABLE_TESTS
|
||||
}, function* test_CaptureStacksIncreasesNumberOfCapturedStacks() {
|
||||
// Construct a unique key for this test.
|
||||
let key = TEST_STACK_KEYS[0] + "-UNIQUE-KEY-1";
|
||||
@ -111,7 +115,7 @@ add_task({
|
||||
* more than once for the key, the length of stacks does not increase.
|
||||
*/
|
||||
add_task({
|
||||
skip_if: () => !AppConstants.MOZ_ENABLE_PROFILER_SPS
|
||||
skip_if: () => !ENABLE_TESTS
|
||||
}, function* test_CaptureStacksGroupsDuplicateStacks() {
|
||||
// Make sure that there are initial captures for TEST_STACK_KEYS[0].
|
||||
let stacks = captureStacks(TEST_STACK_KEYS[0], false);
|
||||
@ -142,7 +146,7 @@ add_task({
|
||||
* for other keys.
|
||||
*/
|
||||
add_task({
|
||||
skip_if: () => !AppConstants.MOZ_ENABLE_PROFILER_SPS
|
||||
skip_if: () => !ENABLE_TESTS
|
||||
}, function* test_CaptureStacksSeparatesInformationByKeys() {
|
||||
// Make sure that there are initial captures for TEST_STACK_KEYS[0].
|
||||
let stacks = captureStacks(TEST_STACK_KEYS[0], false);
|
||||
@ -169,7 +173,7 @@ add_task({
|
||||
* Ensure that Telemetry does not allow weird keys.
|
||||
*/
|
||||
add_task({
|
||||
skip_if: () => !AppConstants.MOZ_ENABLE_PROFILER_SPS
|
||||
skip_if: () => !ENABLE_TESTS
|
||||
}, function* test_CaptureStacksDoesNotAllowBadKey() {
|
||||
for (let badKey of [null, "KEY-!@\"#$%^&*()_"]) {
|
||||
let stacks = captureStacks(badKey);
|
||||
|
@ -295,6 +295,13 @@ this.AppConstants = Object.freeze({
|
||||
false,
|
||||
#endif
|
||||
|
||||
MOZ_STACKWALKING:
|
||||
#ifdef MOZ_STACKWALKING
|
||||
true,
|
||||
#else
|
||||
false,
|
||||
#endif
|
||||
|
||||
MOZ_ANDROID_ACTIVITY_STREAM:
|
||||
#ifdef MOZ_ANDROID_ACTIVITY_STREAM
|
||||
true,
|
||||
|
Loading…
Reference in New Issue
Block a user