Flutter Engine
The Flutter Engine
ptrace_check.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_RUNTIME_PTRACE_CHECK_H_
6#define FLUTTER_RUNTIME_PTRACE_CHECK_H_
7
8#include "flutter/common/settings.h"
9#include "flutter/fml/build_config.h"
10
11namespace flutter {
12
13#define TRACING_CHECKS_NECESSARY \
14 FML_OS_IOS && !TARGET_OS_SIMULATOR && \
15 (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
16
17enum class TracingResult {
22};
23
24#if TRACING_CHECKS_NECESSARY
25bool EnableTracingIfNecessaryImpl(const Settings& vm_settings);
26TracingResult GetTracingResultImpl();
27#endif // TRACING_CHECKS_NECESSARY
28
29//------------------------------------------------------------------------------
30/// @brief Enables tracing in the process so that JIT mode VMs may be
31/// launched. Explicitly enabling tracing is not required on all
32/// platforms. On platforms where it is not required, calling this
33/// method will return true. If tracing is required but cannot be
34/// enabled, it is the responsibility of the caller to display the
35/// appropriate error message to the user as subsequent attempts to
36/// launch the VM in JIT mode will cause process termination.
37///
38/// This method may be called multiple times and will return the
39/// same result. There are no threading restrictions.
40///
41/// @param[in] vm_settings The settings used to launch the VM.
42///
43/// @return If tracing was enabled.
44///
45inline bool EnableTracingIfNecessary(const Settings& vm_settings) {
46#if TRACING_CHECKS_NECESSARY
47 return EnableTracingIfNecessaryImpl(vm_settings);
48#else // TRACING_CHECKS_NECESSARY
49 return true;
50#endif // TRACING_CHECKS_NECESSARY
51}
52
53//------------------------------------------------------------------------------
54/// @brief Returns if a tracing check has been performed and its result. To
55/// enable tracing, the Settings object used to launch the VM is
56/// required. Components may want to display messages based on the
57/// result of a previous tracing check without actually having the
58/// settings object. This accessor can be used instead.
59///
60/// @return The tracing result.
61///
63#if TRACING_CHECKS_NECESSARY
64 return GetTracingResultImpl();
65#else // TRACING_CHECKS_NECESSARY
67#endif // TRACING_CHECKS_NECESSARY
68}
69
70} // namespace flutter
71
72#endif // FLUTTER_RUNTIME_PTRACE_CHECK_H_
TracingResult GetTracingResult()
Returns if a tracing check has been performed and its result. To enable tracing, the Settings object ...
Definition: ptrace_check.h:62
bool EnableTracingIfNecessary(const Settings &vm_settings)
Enables tracing in the process so that JIT mode VMs may be launched. Explicitly enabling tracing is n...
Definition: ptrace_check.h:45