Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
Line
Count
Source (jump to first uncovered line)
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-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
10
#define LLDB_SOURCE_PLUGINS_STRUCTUREDDATA_DARWINLOG_STRUCTUREDDATADARWINLOG_H
11
12
#include "lldb/Target/StructuredDataPlugin.h"
13
14
#include <mutex>
15
16
// Forward declarations
17
namespace sddarwinlog_private {
18
class EnableCommand;
19
}
20
21
namespace lldb_private {
22
23
class StructuredDataDarwinLog : public StructuredDataPlugin {
24
  friend sddarwinlog_private::EnableCommand;
25
26
public:
27
  // Public static API
28
29
  static void Initialize();
30
31
  static void Terminate();
32
33
3.44k
  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 enabled
38
  /// it with the enable command, or if the user has the setting set
39
  /// that controls if we always enable it for newly created/attached
40
  /// processes.
41
  ///
42
  /// \return
43
  ///      True if DarwinLog support is/will be enabled for existing or
44
  ///      newly launched/attached processes.
45
  static bool IsEnabled();
46
47
  // PluginInterface API
48
49
0
  llvm::StringRef GetPluginName() override { return GetStaticPluginName(); }
50
51
  // StructuredDataPlugin API
52
53
  bool SupportsStructuredDataType(ConstString type_name) override;
54
55
  void HandleArrivalOfStructuredData(
56
      Process &process, ConstString 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(ConstString type_name) const override;
63
64
  void ModulesDidLoad(Process &process, ModuleList &module_list) override;
65
66
  ~StructuredDataDarwinLog() override;
67
68
private:
69
  // Private constructors
70
71
  StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
72
73
  // Private static methods
74
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 classes
88
  void SetEnabled(bool enabled);
89
90
  void AddInitCompletionHook(Process &process);
91
92
  // Private methods
93
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 initially
102
  /// made.
103
104
  void EnableNow();
105
106
  // Private data
107
  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_H