[Lldb-commits] [lldb] [lldb] [disassembler] chore: enhance VariableAnnotator to return structured data (PR #165163)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 6 11:28:42 PST 2025
================
@@ -299,17 +299,45 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
// The goal is to give users helpful live variable hints alongside the
// disassembled instruction stream, similar to how debug information
// enhances source-level debugging.
-std::vector<std::string>
-VariableAnnotator::annotate(Instruction &inst, Target &target,
- const lldb::ModuleSP &module_sp) {
+std::vector<std::string> VariableAnnotator::Annotate(Instruction &inst,
+ Target &target,
+ lldb::ModuleSP module_sp) {
+ auto structured_annotations = AnnotateStructured(inst, target, module_sp);
+
std::vector<std::string> events;
+ events.reserve(structured_annotations.size());
+
+ for (const auto &annotation : structured_annotations) {
+ std::string display_string;
+ display_string =
+ llvm::formatv(
+ "{0} = {1}", annotation.variable_name,
+ annotation.location_description == VariableAnnotator::kUndefLocation
+ ? llvm::formatv("<{0}>", VariableAnnotator::kUndefLocation)
+ .str()
+ : annotation.location_description)
+ .str();
----------------
JDevlieghere wrote:
This seems like it could benefit from writing this as a stream:
```
std::string display_string;
llvm::raw_string_ostream os(display_string);
os << annotation.variable_name;
[...]
events.push_back(std::move(display_string));
```
https://github.com/llvm/llvm-project/pull/165163
More information about the lldb-commits
mailing list