Print a warning when stopped in a frame LLDB has no plugin for.
This patchs adds an optional warning that is printed when stopped at a
frame that was compiled in a source language that LLDB has no plugin
for.
The motivational use-case is debugging Swift code on Linux. When the
user accidentally invokes the system LLDB that was built without the
Swift plugin, it is very much non-obvious why debugging doesnt
work. This warning makes it easy to figure out what went wrong.
<rdar://problem/56986569>
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 0eb9866..25a940b 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -258,6 +258,12 @@
nullptr, idx, g_process_properties[idx].default_uint_value != 0);
}
+bool ProcessProperties::GetWarningsUnsupportedLanguage() const {
+ const uint32_t idx = ePropertyWarningUnsupportedLanguage;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_process_properties[idx].default_uint_value != 0);
+}
+
bool ProcessProperties::GetStopOnExec() const {
const uint32_t idx = ePropertyStopOnExec;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -5779,9 +5785,6 @@
StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream();
if (!stream_sp)
return;
- if (warning_type == eWarningsOptimization && !GetWarningsOptimization()) {
- return;
- }
if (repeat_key != nullptr) {
WarningsCollection::iterator it = m_warnings_issued.find(warning_type);
@@ -5806,8 +5809,11 @@
}
void Process::PrintWarningOptimization(const SymbolContext &sc) {
- if (GetWarningsOptimization() && sc.module_sp &&
- !sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
+ if (!GetWarningsOptimization())
+ return;
+ if (!sc.module_sp)
+ return;
+ if (!sc.module_sp->GetFileSpec().GetFilename().IsEmpty() && sc.function &&
sc.function->GetIsOptimized()) {
PrintWarning(Process::Warnings::eWarningsOptimization, sc.module_sp.get(),
"%s was compiled with optimization - stepping may behave "
@@ -5816,6 +5822,25 @@
}
}
+void Process::PrintWarningUnsupportedLanguage(const SymbolContext &sc) {
+ if (!GetWarningsUnsupportedLanguage())
+ return;
+ if (!sc.module_sp)
+ return;
+ LanguageType language = sc.GetLanguage();
+ if (language == eLanguageTypeUnknown)
+ return;
+ auto type_system_or_err = sc.module_sp->GetTypeSystemForLanguage(language);
+ if (auto err = type_system_or_err.takeError()) {
+ llvm::consumeError(std::move(err));
+ PrintWarning(Process::Warnings::eWarningsUnsupportedLanguage,
+ sc.module_sp.get(),
+ "This version of LLDB has no plugin for the %s language. "
+ "Inspection of frame variables will be limited.\n",
+ Language::GetNameForLanguageType(language));
+ }
+}
+
bool Process::GetProcessInfo(ProcessInstanceInfo &info) {
info.Clear();