Path: blob/main/contrib/llvm-project/lldb/source/Utility/Instrumentation.cpp
39587 views
//===-- Instrumentation.cpp -----------------------------------------------===//1// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.2// See https://llvm.org/LICENSE.txt for license information.3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception4//5//===----------------------------------------------------------------------===//67#include "lldb/Utility/Instrumentation.h"8#include "lldb/Utility/LLDBLog.h"9#include "llvm/Support/Signposts.h"1011#include <cstdio>12#include <cstdlib>13#include <limits>14#include <thread>1516using namespace lldb_private;17using namespace lldb_private::instrumentation;1819// Whether we're currently across the API boundary.20static thread_local bool g_global_boundary = false;2122// Instrument SB API calls with singposts when supported.23static llvm::ManagedStatic<llvm::SignpostEmitter> g_api_signposts;2425Instrumenter::Instrumenter(llvm::StringRef pretty_func,26std::string &&pretty_args)27: m_pretty_func(pretty_func) {28if (!g_global_boundary) {29g_global_boundary = true;30m_local_boundary = true;31g_api_signposts->startInterval(this, m_pretty_func);32}33LLDB_LOG(GetLog(LLDBLog::API), "[{0}] {1} ({2})",34m_local_boundary ? "external" : "internal", m_pretty_func,35pretty_args);36}3738Instrumenter::~Instrumenter() {39if (m_local_boundary) {40g_global_boundary = false;41g_api_signposts->endInterval(this, m_pretty_func);42}43}444546