Skip to content

Commit b784868

Browse files
Formatting changes.
1 parent 10fddc4 commit b784868

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

lldb/source/Core/Disassembler.cpp

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,16 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
397397
// enhances source-level debugging.
398398

399399
struct VarState {
400-
std::string name; // display name
401-
std::string last_loc; // last printed location (empty means <undef>)
400+
std::string name; // display name
401+
std::string last_loc; // last printed location (empty means <undef>)
402402
bool seen_this_inst = false;
403403
};
404404

405405
// Track live variables across instructions (keyed by stable LLDB user_id_t)
406406
std::unordered_map<lldb::user_id_t, VarState> live_vars;
407407

408-
// Stateful annotator: updates live_vars and returns only what should be printed for THIS instruction.
408+
// Stateful annotator: updates live_vars and returns only what should be
409+
// printed for THIS instruction.
409410
auto annotate_variables = [&](Instruction &inst) -> std::vector<std::string> {
410411
std::vector<std::string> events;
411412

@@ -420,16 +421,18 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
420421
kv.second.seen_this_inst = false;
421422

422423
addr_t current_pc = inst.GetAddress().GetLoadAddress(target_sp.get());
423-
addr_t original_pc = frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get());
424+
addr_t original_pc =
425+
frame->GetFrameCodeAddress().GetLoadAddress(target_sp.get());
424426

425-
// We temporarily move the frame PC so variable locations resolve at this inst
427+
// We temporarily move the frame PC so variable locations resolve at this
428+
// inst
426429
if (!frame->ChangePC(current_pc))
427430
return events;
428431

429432
VariableListSP var_list_sp = frame->GetInScopeVariableList(true);
430433
if (!var_list_sp) {
431434
// No variables in scope: everything previously live becomes <undef>
432-
for (auto it = live_vars.begin(); it != live_vars.end(); ) {
435+
for (auto it = live_vars.begin(); it != live_vars.end();) {
433436
events.push_back(llvm::formatv("{0} = <undef>", it->second.name).str());
434437
it = live_vars.erase(it);
435438
}
@@ -438,16 +441,16 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
438441
}
439442

440443
SymbolContext sc = frame->GetSymbolContext(eSymbolContextFunction);
441-
addr_t func_load_addr = sc.function
442-
? sc.function->GetAddress().GetLoadAddress(target_sp.get())
443-
: LLDB_INVALID_ADDRESS;
444+
addr_t func_load_addr =
445+
sc.function ? sc.function->GetAddress().GetLoadAddress(target_sp.get())
446+
: LLDB_INVALID_ADDRESS;
444447

445448
// Walk all in-scope variables and try to resolve a location
446449
for (const VariableSP &var_sp : *var_list_sp) {
447450
if (!var_sp)
448451
continue;
449452

450-
const auto var_id = var_sp->GetID(); // lldb::user_id_t – stable key
453+
const auto var_id = var_sp->GetID(); // lldb::user_id_t – stable key
451454
const char *name_cstr = var_sp->GetName().AsCString();
452455
llvm::StringRef name = name_cstr ? name_cstr : "<anon>";
453456

@@ -456,7 +459,8 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
456459
continue;
457460

458461
// Try to get the expression entry for this PC
459-
auto entry_or_err = expr_list.GetExpressionEntryAtAddress(func_load_addr, current_pc);
462+
auto entry_or_err =
463+
expr_list.GetExpressionEntryAtAddress(func_load_addr, current_pc);
460464
if (!entry_or_err)
461465
continue;
462466

@@ -484,19 +488,22 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
484488
auto it = live_vars.find(var_id);
485489
if (it == live_vars.end()) {
486490
// New var → print
487-
live_vars.emplace(var_id, VarState{std::string(name), loc_clean.str(), true});
491+
live_vars.emplace(var_id,
492+
VarState{std::string(name), loc_clean.str(), true});
488493
events.push_back(llvm::formatv("{0} = {1}", name, loc_clean).str());
489494
} else {
490495
it->second.seen_this_inst = true;
491496
if (it->second.last_loc != loc_clean) {
492497
it->second.last_loc = loc_clean.str();
493-
events.push_back(llvm::formatv("{0} = {1}", it->second.name, loc_clean).str());
498+
events.push_back(
499+
llvm::formatv("{0} = {1}", it->second.name, loc_clean).str());
494500
}
495501
}
496502
}
497503

498-
// Anything previously live that we didn't see a location for at this inst is now <undef>
499-
for (auto it = live_vars.begin(); it != live_vars.end(); ) {
504+
// Anything previously live that we didn't see a location for at this inst
505+
// is now <undef>
506+
for (auto it = live_vars.begin(); it != live_vars.end();) {
500507
if (!it->second.seen_this_inst) {
501508
events.push_back(llvm::formatv("{0} = <undef>", it->second.name).str());
502509
it = live_vars.erase(it);
@@ -678,10 +685,10 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
678685
StreamString inst_line;
679686

680687
inst->Dump(&inst_line, max_opcode_byte_size, true, show_bytes,
681-
show_control_flow_kind, &exe_ctx, &sc, &prev_sc, nullptr,
682-
address_text_size);
688+
show_control_flow_kind, &exe_ctx, &sc, &prev_sc, nullptr,
689+
address_text_size);
683690

684-
if (enable_rich_annotations){
691+
if (enable_rich_annotations) {
685692
std::vector<std::string> annotations = annotate_variables(*inst);
686693
if (!annotations.empty()) {
687694
const size_t annotation_column = 100;
@@ -694,7 +701,6 @@ void Disassembler::PrintInstructions(Debugger &debugger, const ArchSpec &arch,
694701
strm.PutCString(inst_line.GetString());
695702
strm.EOL();
696703

697-
698704
} else {
699705
break;
700706
}

0 commit comments

Comments
 (0)