Skip to content

Commit 5503b03

Browse files
[lldb][nfc] Add helper function for logging in UnwindAssemblyInstruction (llvm#167914)
(cherry picked from commit b27681f)
1 parent 9fd17ae commit 5503b03

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ static void DumpUnwindRowsToLog(Log *log, AddressRange range,
6262
log->PutString(strm.GetString());
6363
}
6464

65+
static void DumpInstToLog(Log *log, Instruction &inst,
66+
InstructionList inst_list) {
67+
if (!log || !log->GetVerbose())
68+
return;
69+
const bool show_address = true;
70+
const bool show_bytes = true;
71+
const bool show_control_flow_kind = false;
72+
StreamString strm;
73+
lldb_private::FormatEntity::Entry format;
74+
FormatEntity::Parse("${frame.pc}: ", format);
75+
inst.Dump(&strm, inst_list.GetMaxOpcocdeByteSize(), show_address, show_bytes,
76+
show_control_flow_kind, nullptr, nullptr, nullptr, &format, 0);
77+
log->PutString(strm.GetString());
78+
}
79+
6580
bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
6681
AddressRange &range, uint8_t *opcode_data, size_t opcode_size,
6782
UnwindPlan &unwind_plan) {
@@ -95,9 +110,6 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
95110
m_unwind_plan_ptr = &unwind_plan;
96111

97112
const uint32_t addr_byte_size = m_arch.GetAddressByteSize();
98-
const bool show_address = true;
99-
const bool show_bytes = true;
100-
const bool show_control_flow_kind = false;
101113

102114
m_state.cfa_reg_info = *m_inst_emulator_up->GetRegisterInfo(
103115
unwind_plan.GetRegisterKind(), unwind_plan.GetInitialCFARegister());
@@ -152,6 +164,7 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
152164
inst = inst_list.GetInstructionAtIndex(idx).get();
153165
if (!inst)
154166
continue;
167+
DumpInstToLog(log, *inst, inst_list);
155168

156169
lldb::addr_t current_offset =
157170
inst->GetAddress().GetFileAddress() - base_addr;
@@ -185,16 +198,6 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
185198
condition_block_start_state = it;
186199
}
187200

188-
if (log && log->GetVerbose()) {
189-
StreamString strm;
190-
lldb_private::FormatEntity::Entry format;
191-
FormatEntity::Parse("${frame.pc}: ", format);
192-
inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize(), show_address,
193-
show_bytes, show_control_flow_kind, nullptr, nullptr, nullptr,
194-
&format, 0);
195-
log->PutString(strm.GetString());
196-
}
197-
198201
last_condition = m_inst_emulator_up->GetInstructionCondition();
199202

200203
m_inst_emulator_up->EvaluateInstruction(

0 commit comments

Comments
 (0)