blob: 19620dd7a5d1472b5a7541cb54c50c0b1df05a16 [file] [log] [blame]
Primiano Tucci9564d912019-05-21 23:53:18 +01001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Primiano Tucci2c5488f2019-06-01 03:27:28 +010017#include "perfetto/tracing/internal/tracing_tls.h"
18#include "perfetto/tracing/tracing.h"
19#include "perfetto/tracing/tracing_backend.h"
Primiano Tucci9564d912019-05-21 23:53:18 +010020
21// This translation unit contains the definitions for the destructor of pure
22// virtual interfaces for the src/public:public target. The alternative would be
23// introducing a one-liner .cc file for each pure virtual interface, which is
24// overkill. This is for compliance with -Wweak-vtables.
25
26namespace perfetto {
27namespace internal {
28
Sami Kyostila2d790202021-05-08 01:47:55 +000029TracingTLS::~TracingTLS() {
30 // Avoid entering trace points while the thread is being torn down.
Primiano Tucciad111e42021-05-19 21:34:12 +010031 // This is the problem: when a thread exits, the at-thread-exit destroys the
32 // TracingTLS. As part of that the various TraceWriter for the active data
33 // sources are destroyd. A TraceWriter dtor will issue a PostTask on the IPC
34 // thread to issue a final flush and unregister its ID with the service.
35 // The PostTask, in chromium, might have a trace event that will try to
36 // re-enter the tracing system.
37 // We fix this by resetting the TLS key to the TracingTLS object that is
38 // being destroyed in the platform impl (platform_posix.cc,
39 // platform_windows.cc, chromium's platform.cc). We carefully rely on the fact
40 // that all the tracing path that will be invoked during thread exit will
41 // early out if |is_in_trace_point| == true and will not depend on the other
42 // TLS state that has been destroyed.
Sami Kyostila2d790202021-05-08 01:47:55 +000043 is_in_trace_point = true;
44}
Primiano Tucci9564d912019-05-21 23:53:18 +010045
46} // namespace internal
47
Daniele Di Proietto3faa5fd2023-02-16 17:36:01 +000048TracingProducerBackend::~TracingProducerBackend() = default;
49TracingConsumerBackend::~TracingConsumerBackend() = default;
Primiano Tucci9564d912019-05-21 23:53:18 +010050TracingBackend::~TracingBackend() = default;
Primiano Tucci9564d912019-05-21 23:53:18 +010051
52} // namespace perfetto