Path: blob/main/contrib/llvm-project/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
39654 views
//===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//1//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-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H9#define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H1011#include "lldb/Target/StructuredDataPlugin.h"1213#include <mutex>1415// Forward declarations16namespace sddarwinlog_private {17class EnableCommand;18}1920namespace lldb_private {2122class StructuredDataDarwinLog : public StructuredDataPlugin {23friend sddarwinlog_private::EnableCommand;2425public:26// Public static API2728static void Initialize();2930static void Terminate();3132static llvm::StringRef GetStaticPluginName() { return "darwin-log"; }3334/// Return whether the DarwinLog functionality is enabled.35///36/// The DarwinLog functionality is enabled if the user explicitly enabled37/// it with the enable command, or if the user has the setting set38/// that controls if we always enable it for newly created/attached39/// processes.40///41/// \return42/// True if DarwinLog support is/will be enabled for existing or43/// newly launched/attached processes.44static bool IsEnabled();4546// PluginInterface API4748llvm::StringRef GetPluginName() override { return GetStaticPluginName(); }4950// StructuredDataPlugin API5152bool SupportsStructuredDataType(llvm::StringRef type_name) override;5354void HandleArrivalOfStructuredData(55Process &process, llvm::StringRef type_name,56const StructuredData::ObjectSP &object_sp) override;5758Status GetDescription(const StructuredData::ObjectSP &object_sp,59lldb_private::Stream &stream) override;6061bool GetEnabled(llvm::StringRef type_name) const override;6263void ModulesDidLoad(Process &process, ModuleList &module_list) override;6465~StructuredDataDarwinLog() override;6667private:68// Private constructors6970StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);7172// Private static methods7374static lldb::StructuredDataPluginSP CreateInstance(Process &process);7576static void DebuggerInitialize(Debugger &debugger);7778static bool InitCompletionHookCallback(void *baton,79StoppointCallbackContext *context,80lldb::user_id_t break_id,81lldb::user_id_t break_loc_id);8283static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,84Target *target);8586// Internal helper methods used by friend classes87void SetEnabled(bool enabled);8889void AddInitCompletionHook(Process &process);9091// Private methods9293void DumpTimestamp(Stream &stream, uint64_t timestamp);9495size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);9697size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,98Stream &stream);99100/// Call the enable command again, using whatever settings were initially101/// made.102103void EnableNow();104105// Private data106bool m_recorded_first_timestamp;107uint64_t m_first_timestamp_seen;108bool m_is_enabled;109std::mutex m_added_breakpoint_mutex;110bool m_added_breakpoint;111lldb::user_id_t m_breakpoint_id;112};113}114115#endif // LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H116117118