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, bool will_modify,
36 Status &error) const {
37 OptionValuePropertiesSP properties_sp(GetValueProperties());
38 if (properties_sp)
39 return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
40 return lldb::OptionValueSP();
41}
42
45 llvm::StringRef path,
46 llvm::StringRef value) {
47 OptionValuePropertiesSP properties_sp(GetValueProperties());
48 if (properties_sp)
49 return properties_sp->SetSubValue(exe_ctx, op, path, value);
51 error.SetErrorString("no properties");
52 return error;
53}
54
56 Stream &strm, uint32_t dump_mask,
57 bool is_json) {
58 OptionValuePropertiesSP properties_sp(GetValueProperties());
59 if (!properties_sp)
60 return;
61
62 if (is_json) {
63 llvm::json::Value json = properties_sp->ToJSON(exe_ctx);
64 strm.Printf("%s", llvm::formatv("{0:2}", json).str().c_str());
65 } else
66 properties_sp->DumpValue(exe_ctx, strm, dump_mask);
67}
68
70 Stream &strm) const {
71 strm.PutCString("Top level variables:\n\n");
72
73 OptionValuePropertiesSP properties_sp(GetValueProperties());
74 if (properties_sp)
75 return properties_sp->DumpAllDescriptions(interpreter, strm);
76}
77
79 Stream &strm,
80 llvm::StringRef property_path,
81 uint32_t dump_mask, bool is_json) {
82 OptionValuePropertiesSP properties_sp(GetValueProperties());
83 if (properties_sp) {
84 return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
85 dump_mask, is_json);
86 }
88 error.SetErrorString("empty property list");
89 return error;
90}
91
92size_t
93Properties::Apropos(llvm::StringRef keyword,
94 std::vector<const Property *> &matching_properties) const {
95 OptionValuePropertiesSP properties_sp(GetValueProperties());
96 if (properties_sp) {
97 properties_sp->Apropos(keyword, matching_properties);
98 }
99 return matching_properties.size();
100}
101
102lldb::OptionValuePropertiesSP
104 ConstString name) {
105 OptionValuePropertiesSP properties_sp(GetValueProperties());
106 if (properties_sp)
107 return properties_sp->GetSubProperty(exe_ctx, name);
108 return lldb::OptionValuePropertiesSP();
109}
110
111const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
112
113bool Properties::IsSettingExperimental(llvm::StringRef setting) {
114 if (setting.empty())
115 return false;
116
117 llvm::StringRef experimental = GetExperimentalSettingsName();
118 size_t dot_pos = setting.find_first_of('.');
119 return setting.take_front(dot_pos) == experimental;
120}
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)
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, bool will_modify, Status &error) const
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)
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.
VarSetOperationType
Settable state variable types.
Definition: SBAddress.h:15