================ @@ -702,6 +705,78 @@ void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size, ss.FillLastLineToColumn(opcode_pos + opcode_column_width, ' '); ss.PutCString(mnemonics); + const size_t annotation_column = 150; + + if (exe_ctx && exe_ctx->GetFramePtr()) { + StackFrame *frame = exe_ctx->GetFramePtr(); + TargetSP target_sp = exe_ctx->GetTargetSP(); + if (frame && target_sp) { + addr_t current_pc = m_address.GetLoadAddress(target_sp.get()); + addr_t original_pc = frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get()); + if (frame->ChangePC(current_pc)) { + VariableListSP var_list_sp = frame->GetInScopeVariableList(true); + SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction); + addr_t func_load_addr = LLDB_INVALID_ADDRESS; + if (sc.function) + func_load_addr = sc.function->GetAddress().GetLoadAddress(target_sp.get()); + + + if(ss.GetSizeOfLastLine() < annotation_column) { + + std::vector<std::string> annotations; + + if (var_list_sp) { + for (size_t i = 0; i < var_list_sp->GetSize(); ++i) { + VariableSP var_sp = var_list_sp->GetVariableAtIndex(i); + if (!var_sp) + continue; + + const char *name = var_sp->GetName().AsCString(); + auto &expr_list = var_sp->LocationExpressionList(); + if (!expr_list.IsValid()) + continue; + // Handle std::optional<DWARFExpressionEntry>. + if (auto entryOrErr = expr_list.GetExpressionEntryAtAddress(func_load_addr, current_pc)) { + auto entry = *entryOrErr; + + // Check if entry has a file_range, and filter on address if so. + if (!entry.file_range || entry.file_range->ContainsFileAddress( + (current_pc - func_load_addr) + expr_list.GetFuncFileAddress())) { + + StreamString loc_str; + ABI *abi = exe_ctx->GetProcessPtr()->GetABI().get(); + llvm::DIDumpOptions opts; + opts.ShowAddresses = false; + opts.PrintRegisterOnly = true; // <-- important: suppress DW_OP_... annotations, etc. + + entry.expr->DumpLocationWithOptions(&loc_str, eDescriptionLevelBrief, abi, opts); + + // Only include if not empty + llvm::StringRef loc_clean = llvm::StringRef(loc_str.GetString()).trim(); + if (!loc_clean.empty()) { + annotations.push_back(llvm::formatv("{0} = {1}", name, loc_clean)); + } + } + } + } + + if (!annotations.empty()) { + ss.FillLastLineToColumn(annotation_column, ' '); + ss.PutCString(" ; "); + for (size_t i = 0; i < annotations.size(); ++i) { ---------------- adrian-prantl wrote:
- range-based for - there is also a helper in LLVM to join a list with a separator (https://llvm.org/doxygen/StringExtras_8h_source.html) https://github.com/llvm/llvm-project/pull/147460 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits