brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 5b9abf3 Raw
117 lines · c
1//===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H10#define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H11 12#include "lldb/Target/StructuredDataPlugin.h"13 14#include <mutex>15 16// Forward declarations17namespace sddarwinlog_private {18class EnableCommand;19}20 21namespace lldb_private {22 23class StructuredDataDarwinLog : public StructuredDataPlugin {24  friend sddarwinlog_private::EnableCommand;25 26public:27  // Public static API28 29  static void Initialize();30 31  static void Terminate();32 33  static llvm::StringRef GetStaticPluginName() { return "darwin-log"; }34 35  /// Return whether the DarwinLog functionality is enabled.36  ///37  /// The DarwinLog functionality is enabled if the user explicitly enabled38  /// it with the enable command, or if the user has the setting set39  /// that controls if we always enable it for newly created/attached40  /// processes.41  ///42  /// \return43  ///      True if DarwinLog support is/will be enabled for existing or44  ///      newly launched/attached processes.45  static bool IsEnabled();46 47  // PluginInterface API48 49  llvm::StringRef GetPluginName() override { return GetStaticPluginName(); }50 51  // StructuredDataPlugin API52 53  bool SupportsStructuredDataType(llvm::StringRef type_name) override;54 55  void HandleArrivalOfStructuredData(56      Process &process, llvm::StringRef type_name,57      const StructuredData::ObjectSP &object_sp) override;58 59  Status GetDescription(const StructuredData::ObjectSP &object_sp,60                        lldb_private::Stream &stream) override;61 62  bool GetEnabled(llvm::StringRef type_name) const override;63 64  void ModulesDidLoad(Process &process, ModuleList &module_list) override;65 66  ~StructuredDataDarwinLog() override;67 68private:69  // Private constructors70 71  StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);72 73  // Private static methods74 75  static lldb::StructuredDataPluginSP CreateInstance(Process &process);76 77  static void DebuggerInitialize(Debugger &debugger);78 79  static bool InitCompletionHookCallback(void *baton,80                                         StoppointCallbackContext *context,81                                         lldb::user_id_t break_id,82                                         lldb::user_id_t break_loc_id);83 84  static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,85                                 Target *target);86 87  // Internal helper methods used by friend classes88  void SetEnabled(bool enabled);89 90  void AddInitCompletionHook(Process &process);91 92  // Private methods93 94  void DumpTimestamp(Stream &stream, uint64_t timestamp);95 96  size_t DumpHeader(Stream &stream, const StructuredData::Dictionary &event);97 98  size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,99                              Stream &stream);100 101  /// Call the enable command again, using whatever settings were initially102  /// made.103 104  void EnableNow();105 106  // Private data107  bool m_recorded_first_timestamp;108  uint64_t m_first_timestamp_seen;109  bool m_is_enabled;110  std::mutex m_added_breakpoint_mutex;111  bool m_added_breakpoint;112  lldb::user_id_t m_breakpoint_id;113};114}115 116#endif // LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H117