LLDB mainline
UserSettingsController.cpp
Go to the documentation of this file.
1//===-- UserSettingsController.cpp ----------------------------------------===//
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
10
12#include "lldb/Utility/Status.h"
13#include "lldb/Utility/Stream.h"
14
15#include <memory>
16
17namespace lldb_private {
19}
20namespace lldb_private {
21class ConstString;
22}
23namespace lldb_private {
25}
26namespace lldb_private {
27class Property;
28}
29
30using namespace lldb;
31using namespace lldb_private;
32
33lldb::OptionValueSP
35 llvm::StringRef path, Status &error) const {
36 OptionValuePropertiesSP properties_sp(GetValueProperties());
37 if (properties_sp)
38 return properties_sp->GetSubValue(exe_ctx, path, error);
39 return lldb::OptionValueSP();
40}
41
44 llvm::StringRef path,
45 llvm::StringRef value) {
46 OptionValuePropertiesSP properties_sp(GetValueProperties());
47 if (properties_sp)
48 return properties_sp->SetSubValue(exe_ctx, op, path, value);
50 error.SetErrorString("no properties");
51 return error;
52}
53
55 Stream &strm, uint32_t dump_mask,
56 bool is_json) {
57 OptionValuePropertiesSP properties_sp(GetValueProperties());
58 if (!properties_sp)
59 return;
60
61 if (is_json) {
62 llvm::json::Value json = properties_sp->ToJSON(exe_ctx);
63 strm.Printf("%s", llvm::formatv("{0:2}", json).str().c_str());
64 } else
65 properties_sp->DumpValue(exe_ctx, strm, dump_mask);
66}
67
69 Stream &strm) const {
70 strm.PutCString("Top level variables:\n\n");
71
72 OptionValuePropertiesSP properties_sp(GetValueProperties());
73 if (properties_sp)
74 return properties_sp->DumpAllDescriptions(interpreter, strm);
75}
76
78 Stream &strm,
79 llvm::StringRef property_path,
80 uint32_t dump_mask, bool is_json) {
81 OptionValuePropertiesSP properties_sp(GetValueProperties());
82 if (properties_sp) {
83 return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
84 dump_mask, is_json);
85 }
87 error.SetErrorString("empty property list");
88 return error;
89}
90
91size_t
92Properties::Apropos(llvm::StringRef keyword,
93 std::vector<const Property *> &matching_properties) const {
94 OptionValuePropertiesSP properties_sp(GetValueProperties());
95 if (properties_sp) {
96 properties_sp->Apropos(keyword, matching_properties);
97 }
98 return matching_properties.size();
99}
100
101lldb::OptionValuePropertiesSP
103 ConstString name) {
104 OptionValuePropertiesSP properties_sp(GetValueProperties());
105 if (properties_sp)
106 return properties_sp->GetSubProperty(exe_ctx, name);
107 return lldb::OptionValuePropertiesSP();
108}
109
110const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
111
112bool Properties::IsSettingExperimental(llvm::StringRef setting) {
113 if (setting.empty())
114 return false;
115
116 llvm::StringRef experimental = GetExperimentalSettingsName();
117 size_t dot_pos = setting.find_first_of('.');
118 return setting.take_front(dot_pos) == experimental;
119}
static llvm::raw_ostream & error(Stream &strm)
A uniqued constant string class.
Definition: ConstString.h:39
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask, bool is_json=false)
virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask, bool is_json=false)
size_t Apropos(llvm::StringRef keyword, std::vector< const Property * > &matching_properties) const
virtual Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value)
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, Status &error) const
static bool IsSettingExperimental(llvm::StringRef setting)
virtual lldb::OptionValuePropertiesSP GetValueProperties() const
static const char * GetExperimentalSettingsName()
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
VarSetOperationType
Settable state variable types.
Definition: SBAddress.h:15