[libcxxabi] [lldb] [llvm] [lldb] Add frame-format option to highlight function names in backtraces (PR #131836)
Michael Buch via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 07:55:36 PDT 2025
================
@@ -208,6 +211,71 @@ static bool PrettyPrintFunctionNameWithArgs(Stream &out_stream,
return true;
}
+static bool GetUseColor(ExecutionContextScope *exe_scope) {
+ if (!exe_scope)
+ return false;
+
+ auto target_sp = exe_scope->CalculateTarget();
+ if (!target_sp)
+ return false;
+
+ return target_sp->GetDebugger().GetUseColor();
+}
+
+static bool ShouldHighlightBasename(
+ ExecutionContextScope *exe_scope,
+ const FormatEntity::Entry::HighlightSettings &settings) {
+ if (!GetUseColor(exe_scope))
+ return false;
+
+ return settings.kind ==
+ FormatEntity::Entry::HighlightSettings::Kind::Basename;
+}
+
+/// If \c DemangledNameInfo is valid, we use it to print a function function
+/// name into \c out_stream (and if requested, highlight the basename).
+static bool PrettyPrintHighlightedBasenameWithArgs(
+ Stream &out_stream, llvm::StringRef full_name,
+ ExecutionContextScope *exe_scope, VariableList const &args,
+ const std::optional<DemangledNameInfo> &demangled_info,
+ const FormatEntity::Entry::HighlightSettings &settings) {
+ // If we didn't get sufficient information from the demangler, we fall back to
+ // parsing the and printing parts of the demangled name ourselves.
+ if (!demangled_info || !demangled_info->hasBasename())
+ return PrettyPrintFunctionNameWithArgs(out_stream, full_name, exe_scope,
----------------
Michael137 wrote:
The highlighting could even be a separate PR on top of this.
https://github.com/llvm/llvm-project/pull/131836
More information about the llvm-commits
mailing list