================
@@ -300,16 +303,43 @@ bool Disassembler::ElideMixedSourceAndDisassemblyLine(
// disassembled instruction stream, similar to how debug information
// enhances source-level debugging.
std::vector<std::string> VariableAnnotator::Annotate(Instruction &inst) {
+ std::vector<VariableAnnotation> structured_annotations =
+ AnnotateStructured(inst);
+
std::vector<std::string> events;
+ events.reserve(structured_annotations.size());
+
+ for (const auto &annotation : structured_annotations) {
+ const llvm::StringRef location =
+ (annotation.location_description == kUndefLocation
+ ? llvm::StringRef(kUndefLocationFormatted)
+ : llvm::StringRef(annotation.location_description));
+
+ const auto display_string =
+ llvm::formatv("{0} = {1}", annotation.variable_name, location).str();
+
+ events.push_back(std::move(display_string));
+ }
+
+ return events;
+}
+
+std::vector<VariableAnnotation>
+VariableAnnotator::AnnotateStructured(Instruction &inst) {
+ std::vector<VariableAnnotation> annotations;
auto module_sp = inst.GetAddress().GetModule();
- // If we lost module context, everything becomes <undef>.
+ // If we lost module context, mark all live variables as UndefLocation.
if (!module_sp) {
- for (const auto &KV : m_live_vars)
- events.emplace_back(llvm::formatv("{0} = <undef>",
KV.second.name).str());
+ for (const auto &KV : m_live_vars) {
+ VariableAnnotation annotation_entity = KV.second;
+ annotation_entity.is_live = false;
+ annotation_entity.location_description = kUndefLocation;
+ annotations.push_back(std::move(annotation_entity));
+ }
----------------
JDevlieghere wrote:
The same code is duplicated below on line 352 and 456. Seems like it could be
extracted into a helper?
https://github.com/llvm/llvm-project/pull/169408
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits