Skip to content

Commit 6638d59

Browse files
[lldb][NFC] Rename forward_branch_offset to branch_offset in UnwindAssemblyInstEmulation (#169631)
This will reduce the diff in subsequent patches Part of a sequence of PRs: [lldb][NFCI] Rewrite UnwindAssemblyInstEmulation in terms of a CFG visit #169630 [lldb][NFC] Rename forward_branch_offset to branch_offset in UnwindAssemblyInstEmulation #169631 [lldb] Add DisassemblerLLVMC::IsBarrier API #169632 [lldb] Handle backwards branches in UnwindAssemblyInstEmulation #169633 commit-id:5e758a22
1 parent c5ecdec commit 6638d59

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
166166
DumpInstToLog(log, inst, inst_list);
167167

168168
m_curr_row_modified = false;
169-
m_forward_branch_offset = 0;
169+
m_branch_offset = 0;
170170

171171
lldb::addr_t current_offset =
172172
inst.GetAddress().GetFileAddress() - base_addr;
@@ -211,13 +211,13 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
211211
// If the current instruction is a branch forward then save the current
212212
// CFI information for the offset where we are branching.
213213
Address branch_address = inst.GetAddress();
214-
branch_address.Slide(m_forward_branch_offset);
215-
if (m_forward_branch_offset != 0 &&
214+
branch_address.Slide(m_branch_offset);
215+
if (m_branch_offset != 0 &&
216216
range.ContainsFileAddress(branch_address.GetFileAddress())) {
217217
if (auto [it, inserted] = saved_unwind_states.emplace(
218-
current_offset + m_forward_branch_offset, m_state);
218+
current_offset + m_branch_offset, m_state);
219219
inserted) {
220-
it->second.row.SetOffset(current_offset + m_forward_branch_offset);
220+
it->second.row.SetOffset(current_offset + m_branch_offset);
221221
if (std::size_t dest_instr_index =
222222
inst_list.GetIndexOfInstructionAtAddress(branch_address);
223223
dest_instr_index < inst_list.GetSize()) {
@@ -531,20 +531,19 @@ bool UnwindAssemblyInstEmulation::WriteRegister(
531531
case EmulateInstruction::eContextRelativeBranchImmediate: {
532532
if (context.GetInfoType() == EmulateInstruction::eInfoTypeISAAndImmediate &&
533533
context.info.ISAAndImmediate.unsigned_data32 > 0) {
534-
m_forward_branch_offset = context.info.ISAAndImmediate.unsigned_data32;
534+
m_branch_offset = context.info.ISAAndImmediate.unsigned_data32;
535535
} else if (context.GetInfoType() ==
536536
EmulateInstruction::eInfoTypeISAAndImmediateSigned &&
537537
context.info.ISAAndImmediateSigned.signed_data32 > 0) {
538-
m_forward_branch_offset =
539-
context.info.ISAAndImmediateSigned.signed_data32;
538+
m_branch_offset = context.info.ISAAndImmediateSigned.signed_data32;
540539
} else if (context.GetInfoType() ==
541540
EmulateInstruction::eInfoTypeImmediate &&
542541
context.info.unsigned_immediate > 0) {
543-
m_forward_branch_offset = context.info.unsigned_immediate;
542+
m_branch_offset = context.info.unsigned_immediate;
544543
} else if (context.GetInfoType() ==
545544
EmulateInstruction::eInfoTypeImmediateSigned &&
546545
context.info.signed_immediate > 0) {
547-
m_forward_branch_offset = context.info.signed_immediate;
546+
m_branch_offset = context.info.signed_immediate;
548547
}
549548
} break;
550549

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly {
6464
lldb_private::EmulateInstruction *inst_emulator)
6565
: UnwindAssembly(arch), m_inst_emulator_up(inst_emulator),
6666
m_range_ptr(nullptr), m_unwind_plan_ptr(nullptr),
67-
m_curr_row_modified(false), m_forward_branch_offset(0) {
67+
m_curr_row_modified(false) {
6868
if (m_inst_emulator_up) {
6969
m_inst_emulator_up->SetBaton(this);
7070
m_inst_emulator_up->SetCallbacks(ReadMemory, WriteMemory, ReadRegister,
@@ -152,7 +152,7 @@ class UnwindAssemblyInstEmulation : public lldb_private::UnwindAssembly {
152152
bool m_curr_row_modified;
153153
// The instruction is branching forward with the given offset. 0 value means
154154
// no branching.
155-
uint32_t m_forward_branch_offset;
155+
uint32_t m_branch_offset = 0;
156156
};
157157

158158
#endif // LLDB_SOURCE_PLUGINS_UNWINDASSEMBLY_INSTEMULATION_UNWINDASSEMBLYINSTEMULATION_H

0 commit comments

Comments
 (0)