[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / Utility / Instrumentation.cpp
blob62e377500bbb6abef3dba9f1c3402219f3367471
1 //===-- Instrumentation.cpp -----------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
8 #include "lldb/Utility/Instrumentation.h"
9 #include "lldb/Utility/LLDBLog.h"
10 #include "llvm/Support/Signposts.h"
12 #include <cstdio>
13 #include <cstdlib>
14 #include <limits>
15 #include <thread>
17 using namespace lldb_private;
18 using namespace lldb_private::instrumentation;
20 // Whether we're currently across the API boundary.
21 static thread_local bool g_global_boundary = false;
23 // Instrument SB API calls with signposts when supported.
24 static llvm::ManagedStatic<llvm::SignpostEmitter> g_api_signposts;
26 Instrumenter::Instrumenter(llvm::StringRef pretty_func,
27 std::string &&pretty_args)
28 : m_pretty_func(pretty_func) {
29 if (!g_global_boundary) {
30 g_global_boundary = true;
31 m_local_boundary = true;
32 g_api_signposts->startInterval(this, m_pretty_func);
34 LLDB_LOG(GetLog(LLDBLog::API), "[{0}] {1} ({2})",
35 m_local_boundary ? "external" : "internal", m_pretty_func,
36 pretty_args);
39 Instrumenter::~Instrumenter() {
40 if (m_local_boundary) {
41 g_global_boundary = false;
42 g_api_signposts->endInterval(this, m_pretty_func);