#include "StructuredDataDarwinLog.h"
#include <cstring>
#include <memory>
#include <sstream>
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallOnFunctionExit.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/StringMap.h"
#define DARWIN_LOG_TYPE_VALUE …
usingnamespacelldb;
usingnamespacelldb_private;
LLDB_PLUGIN_DEFINE(…)
#pragma mark -
#pragma mark Anonymous Namespace
namespace sddarwinlog_private {
const uint64_t NANOS_PER_MICRO = …;
const uint64_t NANOS_PER_MILLI = …;
const uint64_t NANOS_PER_SECOND = …;
const uint64_t NANOS_PER_MINUTE = …;
const uint64_t NANOS_PER_HOUR = …;
static bool DEFAULT_FILTER_FALLTHROUGH_ACCEPTS = …;
static bool s_is_explicitly_enabled;
class EnableOptions;
EnableOptionsSP;
OptionsMap;
static OptionsMap &GetGlobalOptionsMap() { … }
static std::mutex &GetGlobalOptionsMapLock() { … }
EnableOptionsSP GetGlobalEnableOptions(const DebuggerSP &debugger_sp) { … }
void SetGlobalEnableOptions(const DebuggerSP &debugger_sp,
const EnableOptionsSP &options_sp) { … }
#pragma mark -
#pragma mark Settings Handling
#define LLDB_PROPERTIES_darwinlog
#include "StructuredDataDarwinLogProperties.inc"
enum { … };
class StructuredDataDarwinLogProperties : public Properties { … };
static StructuredDataDarwinLogProperties &GetGlobalProperties() { … }
const char *const s_filter_attributes[] = …;
static llvm::StringRef GetDarwinLogTypeName() { … }
static llvm::StringRef GetLogEventType() { … }
class FilterRule;
FilterRuleSP;
class FilterRule { … };
FilterRules;
class RegexFilterRule : public FilterRule { … };
class ExactMatchFilterRule : public FilterRule { … };
static void RegisterFilterOperations() { … }
static constexpr OptionDefinition g_enable_option_table[] = …;
class EnableOptions : public Options { … };
class EnableCommand : public CommandObjectParsed { … };
class StatusCommand : public CommandObjectParsed { … };
class BaseCommand : public CommandObjectMultiword { … };
EnableOptionsSP ParseAutoEnableOptions(Status &error, Debugger &debugger) { … }
bool RunEnableCommand(CommandInterpreter &interpreter) { … }
}
usingnamespacesddarwinlog_private;
#pragma mark -
#pragma mark Public static API
void StructuredDataDarwinLog::Initialize() { … }
void StructuredDataDarwinLog::Terminate() { … }
#pragma mark -
#pragma mark StructuredDataPlugin API
bool StructuredDataDarwinLog::SupportsStructuredDataType(
llvm::StringRef type_name) { … }
void StructuredDataDarwinLog::HandleArrivalOfStructuredData(
Process &process, llvm::StringRef type_name,
const StructuredData::ObjectSP &object_sp) { … }
static void SetErrorWithJSON(Status &error, const char *message,
StructuredData::Object &object) { … }
Status StructuredDataDarwinLog::GetDescription(
const StructuredData::ObjectSP &object_sp, lldb_private::Stream &stream) { … }
bool StructuredDataDarwinLog::GetEnabled(llvm::StringRef type_name) const { … }
void StructuredDataDarwinLog::SetEnabled(bool enabled) { … }
void StructuredDataDarwinLog::ModulesDidLoad(Process &process,
ModuleList &module_list) { … }
StructuredDataDarwinLog::~StructuredDataDarwinLog() { … }
#pragma mark -
#pragma mark Private instance methods
StructuredDataDarwinLog::StructuredDataDarwinLog(const ProcessWP &process_wp)
: … { … }
StructuredDataPluginSP
StructuredDataDarwinLog::CreateInstance(Process &process) { … }
void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) { … }
Status StructuredDataDarwinLog::FilterLaunchInfo(ProcessLaunchInfo &launch_info,
Target *target) { … }
bool StructuredDataDarwinLog::InitCompletionHookCallback(
void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id,
lldb::user_id_t break_loc_id) { … }
void StructuredDataDarwinLog::AddInitCompletionHook(Process &process) { … }
void StructuredDataDarwinLog::DumpTimestamp(Stream &stream,
uint64_t timestamp) { … }
size_t
StructuredDataDarwinLog::DumpHeader(Stream &output_stream,
const StructuredData::Dictionary &event) { … }
size_t StructuredDataDarwinLog::HandleDisplayOfEvent(
const StructuredData::Dictionary &event, Stream &stream) { … }
void StructuredDataDarwinLog::EnableNow() { … }