blob: 108498977e8370ea11a8df080969bd345c6594a3 [file] [log] [blame]
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/developer/debug/zxdb/client/target.h"
#include "src/developer/debug/zxdb/client/setting_schema_definition.h"
#include "src/developer/debug/zxdb/client/system.h"
namespace zxdb {
// Schema Definition -----------------------------------------------------------
static const char kShowStdoutDescription[] =
R"( Whether this process should pipe its stdout/stderr to zxdb.
If not set for a particular process, it will default to the system-wide
setting.)";
const char* ClientSettings::Target::kStoreBacktraces = "x-store-backtraces";
static const char kStoreBacktracesDescription[] =
R"( [EXPERIMENTAL] Store exceptional backtraces. Do not use.)";
namespace {
fxl::RefPtr<SettingSchema> CreateSchema() {
auto schema = fxl::MakeRefCounted<SettingSchema>();
schema->AddBool(ClientSettings::System::kShowStdout, kShowStdoutDescription,
true);
schema->AddBool(ClientSettings::Target::kStoreBacktraces,
kStoreBacktracesDescription, false);
return schema;
}
} // namespace
// Target Implementation -------------------------------------------------------
Target::Target(Session* session)
: ClientObject(session),
// Implementations can set up fallbacks if needed.
settings_(GetSchema(), nullptr),
weak_factory_(this) {}
Target::~Target() = default;
void Target::AddObserver(TargetObserver* observer) {
observers_.AddObserver(observer);
}
void Target::RemoveObserver(TargetObserver* observer) {
observers_.RemoveObserver(observer);
}
fxl::WeakPtr<Target> Target::GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
fxl::RefPtr<SettingSchema> Target::GetSchema() {
// Will only run initialization once.
InitializeSchemas();
static fxl::RefPtr<SettingSchema> schema = CreateSchema();
return schema;
}
} // namespace zxdb