Skip to content

Commit 711ecc2

Browse files
fixup! use language-based setting
1 parent 0c8e475 commit 711ecc2

File tree

7 files changed

+55
-18
lines changed

7 files changed

+55
-18
lines changed

lldb/include/lldb/Target/Language.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@
2626

2727
namespace lldb_private {
2828

29-
class Language : public PluginInterface {
29+
class LanguageProperties : public Properties {
30+
public:
31+
LanguageProperties();
32+
33+
static llvm::StringRef GetSettingName();
34+
35+
bool GetEnableFilterForLineBreakpoints() const;
36+
};
37+
38+
class Language : public PluginInterface, public LanguageProperties {
3039
public:
3140
class TypeScavenger {
3241
public:
@@ -324,6 +333,8 @@ class Language : public PluginInterface {
324333
static LanguageSet GetLanguagesSupportingTypeSystemsForExpressions();
325334
static LanguageSet GetLanguagesSupportingREPLs();
326335

336+
static LanguageProperties &GetGlobalLanguageProperties();
337+
327338
// Given a mangled function name, calculates some alternative manglings since
328339
// the compiler mangling may not line up with the symbol we are expecting.
329340
virtual std::vector<ConstString>

lldb/include/lldb/Target/Target.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ class TargetProperties : public Properties {
258258

259259
bool GetDebugUtilityExpression() const;
260260

261-
bool GetEnableLanguageFilterForLineBreakpoints() const;
262-
263261
private:
264262
// Callbacks for m_launch_info.
265263
void Arg0ValueChangedCallback();

lldb/source/Breakpoint/BreakpointResolver.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,12 @@ void BreakpointResolver::SetSCMatchesByLine(
204204
SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue,
205205
llvm::StringRef log_ident, uint32_t line, std::optional<uint16_t> column) {
206206
llvm::SmallVector<SymbolContext, 16> all_scs;
207-
const bool ShouldQueryLanguageFilter =
208-
GetBreakpoint()->GetTarget().GetEnableLanguageFilterForLineBreakpoints();
209207

210208
for (const auto &sc : sc_list) {
211-
if (ShouldQueryLanguageFilter)
212-
if (Language *lang = Language::FindPlugin(sc.GetLanguage());
213-
lang && lang->IgnoreForLineBreakpoints(sc))
214-
continue;
209+
if (Language *lang = Language::FindPlugin(sc.GetLanguage());
210+
lang && lang->GetEnableFilterForLineBreakpoints() &&
211+
lang->IgnoreForLineBreakpoints(sc))
212+
continue;
215213
all_scs.push_back(sc);
216214
}
217215

lldb/source/Core/Debugger.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
860860
m_collection_sp->AppendProperty(
861861
"symbols", "Symbol lookup and cache settings.", true,
862862
ModuleList::GetGlobalModuleListProperties().GetValueProperties());
863+
m_collection_sp->AppendProperty(
864+
LanguageProperties::GetSettingName(), "Language settings.", true,
865+
Language::GetGlobalLanguageProperties().GetValueProperties());
863866
if (m_command_interpreter_up) {
864867
m_collection_sp->AppendProperty(
865868
"interpreter",

lldb/source/Target/Language.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "lldb/Target/Language.h"
1414

1515
#include "lldb/Core/PluginManager.h"
16+
#include "lldb/Interpreter/OptionValueProperties.h"
1617
#include "lldb/Symbol/SymbolFile.h"
1718
#include "lldb/Symbol/TypeList.h"
1819
#include "lldb/Target/Target.h"
@@ -27,6 +28,35 @@ using namespace lldb_private::formatters;
2728
typedef std::unique_ptr<Language> LanguageUP;
2829
typedef std::map<lldb::LanguageType, LanguageUP> LanguagesMap;
2930

31+
#define LLDB_PROPERTIES_language
32+
#include "TargetProperties.inc"
33+
34+
enum {
35+
#define LLDB_PROPERTIES_language
36+
#include "TargetPropertiesEnum.inc"
37+
};
38+
39+
LanguageProperties &Language::GetGlobalLanguageProperties() {
40+
static LanguageProperties g_settings;
41+
return g_settings;
42+
}
43+
44+
llvm::StringRef LanguageProperties::GetSettingName() {
45+
static constexpr llvm::StringLiteral g_setting_name("language");
46+
return g_setting_name;
47+
}
48+
49+
LanguageProperties::LanguageProperties() {
50+
m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
51+
m_collection_sp->Initialize(g_language_properties);
52+
}
53+
54+
bool LanguageProperties::GetEnableFilterForLineBreakpoints() const {
55+
const uint32_t idx = ePropertyEnableFilterForLineBreakpoints;
56+
return GetPropertyAtIndexAs<bool>(
57+
idx, g_language_properties[idx].default_uint_value != 0);
58+
}
59+
3060
static LanguagesMap &GetLanguagesMap() {
3161
static LanguagesMap *g_map = nullptr;
3262
static llvm::once_flag g_initialize;

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4896,12 +4896,6 @@ void TargetProperties::SetDebugUtilityExpression(bool debug) {
48964896
SetPropertyAtIndex(idx, debug);
48974897
}
48984898

4899-
bool TargetProperties::GetEnableLanguageFilterForLineBreakpoints() const {
4900-
const uint32_t idx = ePropertyEnableLanguageFilterForLineBreakpoints;
4901-
return GetPropertyAtIndexAs<bool>(
4902-
idx, g_target_properties[idx].default_uint_value != 0);
4903-
}
4904-
49054899
// Target::TargetEventData
49064900

49074901
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)

lldb/source/Target/TargetProperties.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,6 @@ let Definition = "target" in {
104104
def BreakpointUseAvoidList: Property<"breakpoints-use-platform-avoid-list", "Boolean">,
105105
DefaultTrue,
106106
Desc<"Consult the platform module avoid list when setting non-module specific breakpoints.">;
107-
def EnableLanguageFilterForLineBreakpoints: Property<"enable-language-filter-for-line-breakpoints", "Boolean">,
108-
DefaultTrue,
109-
Desc<"If true, allow Language plugins to filter locations when setting breakpoints by line number or regex.">;
110107
def Arg0: Property<"arg0", "String">,
111108
DefaultStringValue<"">,
112109
Desc<"The first argument passed to the program in the argument array which can be different from the executable itself.">;
@@ -314,3 +311,9 @@ let Definition = "thread" in {
314311
DefaultUnsignedValue<600000>,
315312
Desc<"Maximum number of frames to backtrace.">;
316313
}
314+
315+
let Definition = "language" in {
316+
def EnableFilterForLineBreakpoints: Property<"enable-filter-for-line-breakpoints", "Boolean">,
317+
DefaultTrue,
318+
Desc<"If true, allow Language plugins to filter locations when setting breakpoints by line number or regex.">;
319+
}

0 commit comments

Comments
 (0)