Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "ProfilerBacktrace.h"
8 :
9 : #include "ProfileJSONWriter.h"
10 : #include "ThreadInfo.h"
11 :
12 0 : ProfilerBacktrace::ProfilerBacktrace(const char* aName, int aThreadId,
13 0 : UniquePtr<ProfileBuffer> aBuffer)
14 : : mName(strdup(aName))
15 : , mThreadId(aThreadId)
16 0 : , mBuffer(Move(aBuffer))
17 : {
18 0 : MOZ_COUNT_CTOR(ProfilerBacktrace);
19 0 : }
20 :
21 0 : ProfilerBacktrace::~ProfilerBacktrace()
22 : {
23 0 : MOZ_COUNT_DTOR(ProfilerBacktrace);
24 0 : }
25 :
26 : void
27 0 : ProfilerBacktrace::StreamJSON(SpliceableJSONWriter& aWriter,
28 : const TimeStamp& aProcessStartTime,
29 : UniqueStacks& aUniqueStacks)
30 : {
31 : // This call to StreamSamplesAndMarkers() can safely pass in a non-null
32 : // JSContext. That's because StreamSamplesAndMarkers() only accesses the
33 : // JSContext when streaming JitReturnAddress entries, and such entries
34 : // never appear in synchronous samples.
35 0 : StreamSamplesAndMarkers(mName.get(), mThreadId,
36 0 : *mBuffer.get(), aWriter, aProcessStartTime,
37 : /* aSinceTime */ 0, /* aContext */ nullptr,
38 : /* aSavedStreamedSamples */ nullptr,
39 : /* aSavedStreamedMarkers */ nullptr,
40 0 : aUniqueStacks);
41 0 : }
|