Coverage Report

Created: 2022-01-25 06:29

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Core/UserSettingsController.cpp
Line
Count
Source (jump to first uncovered line)
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
9
#include "lldb/Core/UserSettingsController.h"
10
11
#include "lldb/Interpreter/OptionValueProperties.h"
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
34
Properties::GetPropertyValue(const ExecutionContext *exe_ctx,
35
                             llvm::StringRef path, bool will_modify,
36
3
                             Status &error) const {
37
3
  OptionValuePropertiesSP properties_sp(GetValueProperties());
38
3
  if (properties_sp)
39
3
    return properties_sp->GetSubValue(exe_ctx, path, will_modify, error);
40
0
  return lldb::OptionValueSP();
41
3
}
42
43
Status Properties::SetPropertyValue(const ExecutionContext *exe_ctx,
44
                                    VarSetOperationType op,
45
                                    llvm::StringRef path,
46
31.2k
                                    llvm::StringRef value) {
47
31.2k
  OptionValuePropertiesSP properties_sp(GetValueProperties());
48
31.2k
  if (properties_sp)
49
31.2k
    return properties_sp->SetSubValue(exe_ctx, op, path, value);
50
0
  Status error;
51
0
  error.SetErrorString("no properties");
52
0
  return error;
53
31.2k
}
54
55
void Properties::DumpAllPropertyValues(const ExecutionContext *exe_ctx,
56
5
                                       Stream &strm, uint32_t dump_mask) {
57
5
  OptionValuePropertiesSP properties_sp(GetValueProperties());
58
5
  if (properties_sp)
59
5
    return properties_sp->DumpValue(exe_ctx, strm, dump_mask);
60
5
}
61
62
void Properties::DumpAllDescriptions(CommandInterpreter &interpreter,
63
1
                                     Stream &strm) const {
64
1
  strm.PutCString("Top level variables:\n\n");
65
66
1
  OptionValuePropertiesSP properties_sp(GetValueProperties());
67
1
  if (properties_sp)
68
1
    return properties_sp->DumpAllDescriptions(interpreter, strm);
69
1
}
70
71
Status Properties::DumpPropertyValue(const ExecutionContext *exe_ctx,
72
                                     Stream &strm,
73
                                     llvm::StringRef property_path,
74
94
                                     uint32_t dump_mask) {
75
94
  OptionValuePropertiesSP properties_sp(GetValueProperties());
76
94
  if (properties_sp) {
77
94
    return properties_sp->DumpPropertyValue(exe_ctx, strm, property_path,
78
94
                                            dump_mask);
79
94
  }
80
0
  Status error;
81
0
  error.SetErrorString("empty property list");
82
0
  return error;
83
94
}
84
85
size_t
86
Properties::Apropos(llvm::StringRef keyword,
87
7
                    std::vector<const Property *> &matching_properties) const {
88
7
  OptionValuePropertiesSP properties_sp(GetValueProperties());
89
7
  if (properties_sp) {
90
7
    properties_sp->Apropos(keyword, matching_properties);
91
7
  }
92
7
  return matching_properties.size();
93
7
}
94
95
lldb::OptionValuePropertiesSP
96
Properties::GetSubProperty(const ExecutionContext *exe_ctx,
97
0
                           ConstString name) {
98
0
  OptionValuePropertiesSP properties_sp(GetValueProperties());
99
0
  if (properties_sp)
100
0
    return properties_sp->GetSubProperty(exe_ctx, name);
101
0
  return lldb::OptionValuePropertiesSP();
102
0
}
103
104
104k
const char *Properties::GetExperimentalSettingsName() { return "experimental"; }
105
106
66.7k
bool Properties::IsSettingExperimental(llvm::StringRef setting) {
107
66.7k
  if (setting.empty())
108
0
    return false;
109
110
66.7k
  llvm::StringRef experimental = GetExperimentalSettingsName();
111
66.7k
  size_t dot_pos = setting.find_first_of('.');
112
66.7k
  return setting.take_front(dot_pos) == experimental;
113
66.7k
}