LLDB  mainline
UserSettingsController.cpp
Go to the documentation of this file.
1 //====-- UserSettingsController.cpp ------------------------------*- 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 
10 
12 #include "lldb/Utility/Status.h"
13 #include "lldb/Utility/Stream.h"
14 
15 #include <memory>
16 
17 namespace lldb_private {
18 class CommandInterpreter;
19 }
20 namespace lldb_private {
21 class ConstString;
22 }
23 namespace lldb_private {
24 class ExecutionContext;
25 }
26 namespace lldb_private {
27 class Property;
28 }
29 
30 using namespace lldb;
31 using namespace lldb_private;
32 
33 lldb::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);
50  Status error;
51  error.SetErrorString("no properties");
52  return error;
53 }
54 
56  Stream &strm, uint32_t dump_mask) {
57  OptionValuePropertiesSP properties_sp(GetValueProperties());
58  if (properties_sp)
59  return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
60 }
61 
63  Stream &strm) const {
64  strm.PutCString("Top level variables:\n\n");
65 
66  OptionValuePropertiesSP properties_sp(GetValueProperties());
67  if (properties_sp)
68  return properties_sp->DumpAllDescriptions(interpreter, strm);
69 }
70 
72  Stream &strm,
73  llvm::StringRef property_path,
74  uint32_t dump_mask) {
75  OptionValuePropertiesSP properties_sp(GetValueProperties());
76  if (properties_sp) {
77  return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
78  dump_mask);
79  }
80  Status error;
81  error.SetErrorString("empty property list");
82  return error;
83 }
84 
85 size_t
86 Properties::Apropos(llvm::StringRef keyword,
87  std::vector<const Property *> &matching_properties) const {
88  OptionValuePropertiesSP properties_sp(GetValueProperties());
89  if (properties_sp) {
90  properties_sp->Apropos(keyword, matching_properties);
91  }
92  return matching_properties.size();
93 }
94 
95 lldb::OptionValuePropertiesSP
97  ConstString name) {
98  OptionValuePropertiesSP properties_sp(GetValueProperties());
99  if (properties_sp)
100  return properties_sp->GetSubProperty(exe_ctx, name);
101  return lldb::OptionValuePropertiesSP();
102 }
103 
104 const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
105 
106 bool Properties::IsSettingExperimental(llvm::StringRef setting) {
107  if (setting.empty())
108  return false;
109 
110  llvm::StringRef experimental = GetExperimentalSettingsName();
111  size_t dot_pos = setting.find_first_of('.');
112  return setting.take_front(dot_pos) == experimental;
113 }
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx, ConstString name)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
size_t Apropos(llvm::StringRef keyword, std::vector< const Property *> &matching_properties) const
static bool IsSettingExperimental(llvm::StringRef setting)
virtual lldb::OptionValueSP GetPropertyValue(const ExecutionContext *exe_ctx, llvm::StringRef property_path, bool will_modify, Status &error) const
static const char * GetExperimentalSettingsName()
VarSetOperationType
Settable state variable types.
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
virtual Status SetPropertyValue(const ExecutionContext *exe_ctx, VarSetOperationType op, llvm::StringRef property_path, llvm::StringRef value)
virtual void DumpAllDescriptions(CommandInterpreter &interpreter, Stream &strm) const
virtual void DumpAllPropertyValues(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask)
A uniqued constant string class.
Definition: ConstString.h:38
Definition: SBAddress.h:15
An error handling class.
Definition: Status.h:44
virtual Status DumpPropertyValue(const ExecutionContext *exe_ctx, Stream &strm, llvm::StringRef property_path, uint32_t dump_mask)