[Lldb-commits] [lldb] [llvm] Stateful variable-location annotations in Disassembler::PrintInstructions() (follow-up to #147460) (PR #152887)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 28 13:04:13 PDT 2025
================
@@ -376,6 +382,147 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
}
}
+ // Add variable location annotations to the disassembly output.
+ //
+ // For each instruction, this block attempts to resolve in-scope variables
+ // and determine if the current PC falls within their
+ // DWARF location entry. If so, it prints a simplified annotation using the
+ // variable name and its resolved location (e.g., "var = reg; " ).
+ //
+ // Annotations are only included if the variable has a valid DWARF location
+ // entry, and the location string is non-empty after filtering. Decoding
+ // errors and DWARF opcodes are intentionally omitted to keep the output
+ // concise and user-friendly.
+ //
+ // The goal is to give users helpful live variable hints alongside the
+ // disassembled instruction stream, similar to how debug information
+ // enhances source-level debugging.
+
+ struct VarState {
+ std::string name; ///< Display name.
+ std::string last_loc; ///< Last printed location (empty means <undef>).
+ bool seen_this_inst = false;
+ };
----------------
JDevlieghere wrote:
Let's define this as a private class type, or at least outside the function. Given our column limit, we also prefer the comments to come before the member to avoid wrapping.
```suggestion
struct VarState {
/// Display name.
std::string name;
/// Last printed location (empty means <undef>).
std::string last_loc;
bool seen_this_inst = false;
};
```
https://github.com/llvm/llvm-project/pull/152887
More information about the lldb-commits
mailing list