diff options
Diffstat (limited to 'lldb/source/Plugins/Process/Utility')
18 files changed, 293 insertions, 394 deletions
diff --git a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp index 100ab13d3b2..f9ab48e970f 100644 --- a/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp +++ b/lldb/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp @@ -74,8 +74,8 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, return 0; } - // { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, 'encoding':'uint' - // , 'format':'hex' , 'set': 0, 'ehframe' : 2, + // { 'name':'rcx' , 'bitsize' : 64, 'offset' : 16, + // 'encoding':'uint' , 'format':'hex' , 'set': 0, 'ehframe' : 2, // 'dwarf' : 2, 'generic':'arg4', 'alt-name':'arg4', }, RegisterInfo reg_info; std::vector<uint32_t> value_regs; @@ -100,14 +100,11 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict, const ByteOrder byte_order = arch.GetByteOrder(); if (reg_info.byte_offset == UINT32_MAX) { - // No offset for this register, see if the register has a value expression - // which indicates this register is part of another register. Value - // expressions - // are things like "rax[31:0]" which state that the current register's - // value - // is in a concrete register "rax" in bits 31:0. If there is a value - // expression - // we can calculate the offset + // No offset for this register, see if the register has a value + // expression which indicates this register is part of another register. + // Value expressions are things like "rax[31:0]" which state that the + // current register's value is in a concrete register "rax" in bits 31:0. + // If there is a value expression we can calculate the offset bool success = false; llvm::StringRef slice_str; if (reg_info_dict->GetValueForKeyAsString("slice", slice_str, nullptr)) { @@ -491,8 +488,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { } // sort and unique all invalidate registers and make sure each is terminated - // with - // LLDB_INVALID_REGNUM + // with LLDB_INVALID_REGNUM for (reg_to_regs_map::iterator pos = m_invalidate_regs_map.begin(), end = m_invalidate_regs_map.end(); pos != end; ++pos) { @@ -516,8 +512,8 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) { m_regs[i].invalidate_regs = NULL; } - // Check if we need to automatically set the generic registers in case - // they weren't set + // Check if we need to automatically set the generic registers in case they + // weren't set bool generic_regs_specified = false; for (const auto ® : m_regs) { if (reg.kinds[eRegisterKindGeneric] != LLDB_INVALID_REGNUM) { @@ -732,8 +728,8 @@ void DynamicRegisterInfo::Dump() const { lldb_private::RegisterInfo *DynamicRegisterInfo::GetRegisterInfo( const lldb_private::ConstString ®_name) { for (auto ®_info : m_regs) { - // We can use pointer comparison since we used a ConstString to set - // the "name" member in AddRegister() + // We can use pointer comparison since we used a ConstString to set the + // "name" member in AddRegister() if (reg_info.name == reg_name.GetCString()) { return ®_info; } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp index 64a697ff53c..b07ad7fdaba 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp @@ -968,9 +968,9 @@ const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums); const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums); //---------------------------------------------------------------------- -// Register set definitions. The first definitions at register set index -// of zero is for all registers, followed by other registers sets. The -// register information for the all register set need not be filled in. +// Register set definitions. The first definitions at register set index of +// zero is for all registers, followed by other registers sets. The register +// information for the all register set need not be filled in. //---------------------------------------------------------------------- static const RegisterSet g_reg_sets[] = { { diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp index 344c08965fa..f11cd7f5cb1 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp @@ -149,9 +149,9 @@ const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums); const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums); //---------------------------------------------------------------------- -// Register set definitions. The first definitions at register set index -// of zero is for all registers, followed by other registers sets. The -// register information for the all register set need not be filled in. +// Register set definitions. The first definitions at register set index of +// zero is for all registers, followed by other registers sets. The register +// information for the all register set need not be filled in. //---------------------------------------------------------------------- static const RegisterSet g_reg_sets[] = { { diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp index c818fad9ac0..24414211d9a 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp @@ -147,9 +147,9 @@ enum { sizeof(RegisterContextDarwin_i386::FPU)) // These macros will auto define the register name, alt name, register size, -// register offset, encoding, format and native register. This ensures that -// the register state structures are defined correctly and have the correct -// sizes and offsets. +// register offset, encoding, format and native register. This ensures that the +// register state structures are defined correctly and have the correct sizes +// and offsets. #define DEFINE_GPR(reg, alt) \ #reg, alt, sizeof(((RegisterContextDarwin_i386::GPR *) NULL)->reg), \ GPR_OFFSET(reg), eEncodingUint, eFormatHex @@ -464,9 +464,9 @@ const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums); const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums); //---------------------------------------------------------------------- -// Register set definitions. The first definitions at register set index -// of zero is for all registers, followed by other registers sets. The -// register information for the all register set need not be filled in. +// Register set definitions. The first definitions at register set index of +// zero is for all registers, followed by other registers sets. The register +// information for the all register set need not be filled in. //---------------------------------------------------------------------- static const RegisterSet g_reg_sets[] = { { @@ -680,8 +680,7 @@ bool RegisterContextDarwin_i386::ReadRegister(const RegisterInfo *reg_info, case fpu_stmm6: case fpu_stmm7: // These values don't fit into scalar types, - // RegisterContext::ReadRegisterBytes() must be used for these - // registers + // RegisterContext::ReadRegisterBytes() must be used for these registers //::memcpy (reg_value.value.vector.uint8, fpu.stmm[reg - fpu_stmm0].bytes, //10); return false; @@ -695,8 +694,7 @@ bool RegisterContextDarwin_i386::ReadRegister(const RegisterInfo *reg_info, case fpu_xmm6: case fpu_xmm7: // These values don't fit into scalar types, - // RegisterContext::ReadRegisterBytes() - // must be used for these registers + // RegisterContext::ReadRegisterBytes() must be used for these registers //::memcpy (reg_value.value.vector.uint8, fpu.xmm[reg - fpu_xmm0].bytes, //16); return false; @@ -799,8 +797,7 @@ bool RegisterContextDarwin_i386::WriteRegister(const RegisterInfo *reg_info, case fpu_stmm6: case fpu_stmm7: // These values don't fit into scalar types, - // RegisterContext::ReadRegisterBytes() - // must be used for these registers + // RegisterContext::ReadRegisterBytes() must be used for these registers ::memcpy(fpu.stmm[reg - fpu_stmm0].bytes, value.GetBytes(), value.GetByteSize()); return false; @@ -814,8 +811,7 @@ bool RegisterContextDarwin_i386::WriteRegister(const RegisterInfo *reg_info, case fpu_xmm6: case fpu_xmm7: // These values don't fit into scalar types, - // RegisterContext::ReadRegisterBytes() - // must be used for these registers + // RegisterContext::ReadRegisterBytes() must be used for these registers ::memcpy(fpu.xmm[reg - fpu_xmm0].bytes, value.GetBytes(), value.GetByteSize()); return false; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp index 50e7292f86b..ecad8240b29 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -165,9 +165,9 @@ enum ehframe_dwarf_regnums { sizeof(RegisterContextDarwin_x86_64::FPU)) // These macros will auto define the register name, alt name, register size, -// register offset, encoding, format and native register. This ensures that -// the register state structures are defined correctly and have the correct -// sizes and offsets. +// register offset, encoding, format and native register. This ensures that the +// register state structures are defined correctly and have the correct sizes +// and offsets. #define DEFINE_GPR(reg, alt) \ #reg, alt, sizeof(((RegisterContextDarwin_x86_64::GPR *) NULL)->reg), \ GPR_OFFSET(reg), eEncodingUint, eFormatHex @@ -525,9 +525,9 @@ const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums); const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums); //---------------------------------------------------------------------- -// Register set definitions. The first definitions at register set index -// of zero is for all registers, followed by other registers sets. The -// register information for the all register set need not be filled in. +// Register set definitions. The first definitions at register set index of +// zero is for all registers, followed by other registers sets. The register +// information for the all register set need not be filled in. //---------------------------------------------------------------------- static const RegisterSet g_reg_sets[] = { { diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 5435a02433a..ba9a8071bcf 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -104,8 +104,7 @@ bool RegisterContextLLDB::IsUnwindPlanValidForCurrentPC( } // Initialize a RegisterContextLLDB which is the first frame of a stack -- the -// zeroth frame or currently -// executing frame. +// zeroth frame or currently executing frame. void RegisterContextLLDB::InitializeZerothFrame() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); @@ -131,25 +130,26 @@ void RegisterContextLLDB::InitializeZerothFrame() { // Let ABIs fixup code addresses to make sure they are valid. In ARM ABIs // this will strip bit zero in case we read a PC from memory or from the LR. // (which would be a no-op in frame 0 where we get it from the register set, - // but still a good idea to make the call here for other ABIs that may exist.) + // but still a good idea to make the call here for other ABIs that may + // exist.) ABI *abi = process->GetABI().get(); if (abi) current_pc = abi->FixCodeAddress(current_pc); - // Initialize m_current_pc, an Address object, based on current_pc, an addr_t. + // Initialize m_current_pc, an Address object, based on current_pc, an + // addr_t. m_current_pc.SetLoadAddress(current_pc, &process->GetTarget()); // If we don't have a Module for some reason, we're not going to find - // symbol/function information - just - // stick in some reasonable defaults and hope we can unwind past this frame. + // symbol/function information - just stick in some reasonable defaults and + // hope we can unwind past this frame. ModuleSP pc_module_sp(m_current_pc.GetModule()); if (!m_current_pc.IsValid() || !pc_module_sp) { UnwindLogMsg("using architectural default unwind method"); } // We require either a symbol or function in the symbols context to be - // successfully - // filled in or this context is of no use to us. + // successfully filled in or this context is of no use to us. const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; if (pc_module_sp.get() && (pc_module_sp->ResolveSymbolContextForAddress( m_current_pc, resolve_scope, m_sym_ctx) & @@ -180,18 +180,17 @@ void RegisterContextLLDB::InitializeZerothFrame() { } // If we were able to find a symbol/function, set addr_range to the bounds of - // that symbol/function. - // else treat the current pc value as the start_pc and record no offset. + // that symbol/function. else treat the current pc value as the start_pc and + // record no offset. if (addr_range.GetBaseAddress().IsValid()) { m_start_pc = addr_range.GetBaseAddress(); if (m_current_pc.GetSection() == m_start_pc.GetSection()) { m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset(); } else if (m_current_pc.GetModule() == m_start_pc.GetModule()) { - // This means that whatever symbol we kicked up isn't really correct - // --- we should not cross section boundaries ... We really should NULL - // out - // the function/symbol in this case unless there is a bad assumption - // here due to inlined functions? + // This means that whatever symbol we kicked up isn't really correct --- + // we should not cross section boundaries ... We really should NULL out + // the function/symbol in this case unless there is a bad assumption here + // due to inlined functions? m_current_offset = m_current_pc.GetFileAddress() - m_start_pc.GetFileAddress(); } @@ -266,8 +265,7 @@ void RegisterContextLLDB::InitializeZerothFrame() { } // Initialize a RegisterContextLLDB for the non-zeroth frame -- rely on the -// RegisterContextLLDB "below" it -// to provide things like its current pc value. +// RegisterContextLLDB "below" it to provide things like its current pc value. void RegisterContextLLDB::InitializeNonZerothFrame() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); @@ -333,8 +331,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { m_current_pc.SetLoadAddress(pc, &process->GetTarget(), allow_section_end); // If we don't have a Module for some reason, we're not going to find - // symbol/function information - just - // stick in some reasonable defaults and hope we can unwind past this frame. + // symbol/function information - just stick in some reasonable defaults and + // hope we can unwind past this frame. ModuleSP pc_module_sp(m_current_pc.GetModule()); if (!m_current_pc.IsValid() || !pc_module_sp) { UnwindLogMsg("using architectural default unwind method"); @@ -345,12 +343,10 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { if (process->GetLoadAddressPermissions(pc, permissions) && (permissions & ePermissionsExecutable) == 0) { // If this is the second frame off the stack, we may have unwound the - // first frame - // incorrectly. But using the architecture default unwind plan may get us - // back on - // track -- albeit possibly skipping a real frame. Give this frame a - // clearly-invalid - // pc and see if we can get any further. + // first frame incorrectly. But using the architecture default unwind + // plan may get us back on track -- albeit possibly skipping a real + // frame. Give this frame a clearly-invalid pc and see if we can get any + // further. if (GetNextFrame().get() && GetNextFrame()->IsValid() && GetNextFrame()->IsFrameZero()) { UnwindLogMsg("had a pc of 0x%" PRIx64 " which is not in executable " @@ -359,8 +355,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { (uint64_t)pc); m_frame_type = eSkipFrame; } else { - // anywhere other than the second frame, a non-executable pc means we're - // off in the weeds -- stop now. + // anywhere other than the second frame, a non-executable pc means + // we're off in the weeds -- stop now. m_frame_type = eNotAValidFrame; UnwindLogMsg("pc is in a non-executable section of memory and this " "isn't the 2nd frame in the stack walk."); @@ -399,8 +395,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { } // m_cfa should point into the stack memory; if we can query memory - // region permissions, - // see if the memory is allocated & readable. + // region permissions, see if the memory is allocated & readable. if (process->GetLoadAddressPermissions(m_cfa, permissions) && (permissions & ePermissionsReadable) == 0) { m_frame_type = eNotAValidFrame; @@ -435,19 +430,18 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { bool resolve_tail_call_address = false; // m_current_pc can be one past the // address range of the function... - // If the saved pc does not point to a function/symbol because it is - // beyond the bounds of the correct function and there's no symbol there, - // we do *not* want ResolveSymbolContextForAddress to back up the pc by 1, - // because then we might not find the correct unwind information later. - // Instead, let ResolveSymbolContextForAddress fail, and handle the case - // via decr_pc_and_recompute_addr_range below. + // If the saved pc does not point to a function/symbol because it is beyond + // the bounds of the correct function and there's no symbol there, we do + // *not* want ResolveSymbolContextForAddress to back up the pc by 1, because + // then we might not find the correct unwind information later. Instead, let + // ResolveSymbolContextForAddress fail, and handle the case via + // decr_pc_and_recompute_addr_range below. const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; uint32_t resolved_scope = pc_module_sp->ResolveSymbolContextForAddress( m_current_pc, resolve_scope, m_sym_ctx, resolve_tail_call_address); // We require either a symbol or function in the symbols context to be - // successfully - // filled in or this context is of no use to us. + // successfully filled in or this context is of no use to us. if (resolve_scope & resolved_scope) { m_sym_ctx_valid = true; } @@ -476,8 +470,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { decr_pc_and_recompute_addr_range = true; // Or if we're in the middle of the stack (and not "above" an asynchronous - // event like sigtramp), - // and our "current" pc is the start of a function... + // event like sigtramp), and our "current" pc is the start of a function... if (GetNextFrame()->m_frame_type != eTrapHandlerFrame && GetNextFrame()->m_frame_type != eDebuggerFrame && (!m_sym_ctx_valid || @@ -488,9 +481,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { } // We need to back up the pc by 1 byte and re-search for the Symbol to handle - // the case where the "saved pc" - // value is pointing to the next function, e.g. if a function ends with a CALL - // instruction. + // the case where the "saved pc" value is pointing to the next function, e.g. + // if a function ends with a CALL instruction. // FIXME this may need to be an architectural-dependent behavior; if so we'll // need to add a member function // to the ABI plugin and consult that. @@ -516,9 +508,9 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { GetSymbolOrFunctionName(m_sym_ctx).AsCString("")); } - // If we were able to find a symbol/function, set addr_range_ptr to the bounds - // of that symbol/function. - // else treat the current pc value as the start_pc and record no offset. + // If we were able to find a symbol/function, set addr_range_ptr to the + // bounds of that symbol/function. else treat the current pc value as the + // start_pc and record no offset. if (addr_range.GetBaseAddress().IsValid()) { m_start_pc = addr_range.GetBaseAddress(); m_current_offset = pc - m_start_pc.GetLoadAddress(&process->GetTarget()); @@ -553,9 +545,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { RegisterKind row_register_kind = eRegisterKindGeneric; // Try to get by with just the fast UnwindPlan if possible - the full - // UnwindPlan may be expensive to get - // (e.g. if we have to parse the entire eh_frame section of an ObjectFile for - // the first time.) + // UnwindPlan may be expensive to get (e.g. if we have to parse the entire + // eh_frame section of an ObjectFile for the first time.) if (m_fast_unwind_plan_sp && m_fast_unwind_plan_sp->PlanValidAtAddress(m_current_pc)) { @@ -616,16 +607,14 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { bool RegisterContextLLDB::CheckIfLoopingStack() { // If we have a bad stack setup, we can get the same CFA value multiple times - // -- or even - // more devious, we can actually oscillate between two CFA values. Detect that - // here and - // break out to avoid a possible infinite loop in lldb trying to unwind the - // stack. - // To detect when we have the same CFA value multiple times, we compare the + // -- or even more devious, we can actually oscillate between two CFA values. + // Detect that here and break out to avoid a possible infinite loop in lldb + // trying to unwind the stack. To detect when we have the same CFA value + // multiple times, we compare the // CFA of the current // frame with the 2nd next frame because in some specail case (e.g. signal - // hanlders, hand - // written assembly without ABI compiance) we can have 2 frames with the same + // hanlders, hand written assembly without ABI compiance) we can have 2 + // frames with the same // CFA (in theory we // can have arbitrary number of frames with the same CFA, but more then 2 is // very very unlikely) @@ -734,15 +723,12 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // If we've done a jmp 0x0 / bl 0x0 (called through a null function pointer) - // so the pc is 0x0 - // in the zeroth frame, we need to use the "unwind at first instruction" arch - // default UnwindPlan - // Also, if this Process can report on memory region attributes, any - // non-executable region means - // we jumped through a bad function pointer - handle the same way as 0x0. - // Note, if we have a symbol context & a symbol, we don't want to follow this - // code path. This is - // for jumping to memory regions without any information available. + // so the pc is 0x0 in the zeroth frame, we need to use the "unwind at first + // instruction" arch default UnwindPlan Also, if this Process can report on + // memory region attributes, any non-executable region means we jumped + // through a bad function pointer - handle the same way as 0x0. Note, if we + // have a symbol context & a symbol, we don't want to follow this code path. + // This is for jumping to memory regions without any information available. if ((!m_sym_ctx_valid || (m_sym_ctx.function == NULL && m_sym_ctx.symbol == NULL)) && @@ -780,12 +766,10 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // No FuncUnwinders available for this pc (stripped function symbols, lldb - // could not augment its - // function table with another source, like LC_FUNCTION_STARTS or eh_frame in - // ObjectFileMachO). - // See if eh_frame or the .ARM.exidx tables have unwind information for this - // address, else fall - // back to the architectural default unwind. + // could not augment its function table with another source, like + // LC_FUNCTION_STARTS or eh_frame in ObjectFileMachO). See if eh_frame or the + // .ARM.exidx tables have unwind information for this address, else fall back + // to the architectural default unwind. if (!func_unwinders_sp) { m_frame_type = eNormalFrame; @@ -793,7 +777,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { !m_current_pc.IsValid()) return arch_default_unwind_plan_sp; - // Even with -fomit-frame-pointer, we can try eh_frame to get back on track. + // Even with -fomit-frame-pointer, we can try eh_frame to get back on + // track. DWARFCallFrameInfo *eh_frame = pc_module_sp->GetObjectFile()->GetUnwindTable().GetEHFrameInfo(); if (eh_frame) { @@ -819,11 +804,10 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // If we're in _sigtramp(), unwinding past this frame requires special - // knowledge. On Mac OS X this knowledge - // is properly encoded in the eh_frame section, so prefer that if available. - // On other platforms we may need to provide a platform-specific UnwindPlan - // which encodes the details of - // how to unwind out of sigtramp. + // knowledge. On Mac OS X this knowledge is properly encoded in the eh_frame + // section, so prefer that if available. On other platforms we may need to + // provide a platform-specific UnwindPlan which encodes the details of how to + // unwind out of sigtramp. if (m_frame_type == eTrapHandlerFrame && process) { m_fast_unwind_plan_sp.reset(); unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan( @@ -835,24 +819,19 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // Ask the DynamicLoader if the eh_frame CFI should be trusted in this frame - // even when it's frame zero - // This comes up if we have hand-written functions in a Module and - // hand-written eh_frame. The assembly - // instruction inspection may fail and the eh_frame CFI were probably written - // with some care to do the - // right thing. It'd be nice if there was a way to ask the eh_frame directly - // if it is asynchronous - // (can be trusted at every instruction point) or synchronous (the normal case - // - only at call sites). + // even when it's frame zero This comes up if we have hand-written functions + // in a Module and hand-written eh_frame. The assembly instruction + // inspection may fail and the eh_frame CFI were probably written with some + // care to do the right thing. It'd be nice if there was a way to ask the + // eh_frame directly if it is asynchronous (can be trusted at every + // instruction point) or synchronous (the normal case - only at call sites). // But there is not. if (process && process->GetDynamicLoader() && process->GetDynamicLoader()->AlwaysRelyOnEHUnwindInfo(m_sym_ctx)) { // We must specifically call the GetEHFrameUnwindPlan() method here -- - // normally we would - // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind - // plan sourced from - // either eh_frame (that's what we intend) or compact unwind (this won't - // work) + // normally we would call GetUnwindPlanAtCallSite() -- because CallSite may + // return an unwind plan sourced from either eh_frame (that's what we + // intend) or compact unwind (this won't work) unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan( process->GetTarget(), m_current_offset_backed_up_one); if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) { @@ -871,22 +850,16 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) { if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) { // We probably have an UnwindPlan created by inspecting assembly - // instructions. The - // assembly profilers work really well with compiler-generated functions - // but hand- - // written assembly can be problematic. We set the eh_frame based unwind - // plan as our - // fallback unwind plan if instruction emulation doesn't work out even - // for non call - // sites if it is available and use the architecture default unwind plan - // if it is + // instructions. The assembly profilers work really well with compiler- + // generated functions but hand- written assembly can be problematic. + // We set the eh_frame based unwind plan as our fallback unwind plan if + // instruction emulation doesn't work out even for non call sites if it + // is available and use the architecture default unwind plan if it is // not available. The eh_frame unwind plan is more reliable even on non - // call sites - // then the architecture default plan and for hand written assembly code - // it is often - // written in a way that it valid at all location what helps in the most - // common - // cases when the instruction emulation fails. + // call sites then the architecture default plan and for hand written + // assembly code it is often written in a way that it valid at all + // location what helps in the most common cases when the instruction + // emulation fails. UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite( process->GetTarget(), m_current_offset_backed_up_one); @@ -919,9 +892,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // We'd prefer to use an UnwindPlan intended for call sites when we're at a - // call site but if we've - // struck out on that, fall back to using the non-call-site assembly - // inspection UnwindPlan if possible. + // call site but if we've struck out on that, fall back to using the non- + // call-site assembly inspection UnwindPlan if possible. if (process) { unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite( process->GetTarget(), m_thread, m_current_offset_backed_up_one); @@ -929,19 +901,14 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { if (unwind_plan_sp && unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) { // We probably have an UnwindPlan created by inspecting assembly - // instructions. The assembly - // profilers work really well with compiler-generated functions but hand- - // written assembly - // can be problematic. We set the eh_frame based unwind plan as our fallback - // unwind plan if + // instructions. The assembly profilers work really well with compiler- + // generated functions but hand- written assembly can be problematic. We + // set the eh_frame based unwind plan as our fallback unwind plan if // instruction emulation doesn't work out even for non call sites if it is - // available and use - // the architecture default unwind plan if it is not available. The eh_frame - // unwind plan is - // more reliable even on non call sites then the architecture default plan - // and for hand - // written assembly code it is often written in a way that it valid at all - // location what + // available and use the architecture default unwind plan if it is not + // available. The eh_frame unwind plan is more reliable even on non call + // sites then the architecture default plan and for hand written assembly + // code it is often written in a way that it valid at all location what // helps in the most common cases when the instruction emulation fails. UnwindPlanSP call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite( @@ -963,8 +930,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() { } // If we're on the first instruction of a function, and we have an - // architectural default UnwindPlan - // for the initial instruction of a function, use that. + // architectural default UnwindPlan for the initial instruction of a + // function, use that. if (m_current_offset_backed_up_one == 0) { unwind_plan_sp = func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry( @@ -1115,12 +1082,10 @@ bool RegisterContextLLDB::IsValid() const { } // After the final stack frame in a stack walk we'll get one invalid -// (eNotAValidFrame) stack frame -- -// one past the end of the stack walk. But higher-level code will need to tell -// the differnece between -// "the unwind plan below this frame failed" versus "we successfully completed -// the stack walk" so -// this method helps to disambiguate that. +// (eNotAValidFrame) stack frame -- one past the end of the stack walk. But +// higher-level code will need to tell the differnece between "the unwind plan +// below this frame failed" versus "we successfully completed the stack walk" +// so this method helps to disambiguate that. bool RegisterContextLLDB::IsTrapHandlerFrame() const { return m_frame_type == eTrapHandlerFrame; @@ -1129,12 +1094,10 @@ bool RegisterContextLLDB::IsTrapHandlerFrame() const { // A skip frame is a bogus frame on the stack -- but one where we're likely to // find a real frame farther // up the stack if we keep looking. It's always the second frame in an unwind -// (i.e. the first frame after -// frame zero) where unwinding can be the trickiest. Ideally we'll mark up this -// frame in some way so the -// user knows we're displaying bad data and we may have skipped one frame of -// their real program in the -// process of getting back on track. +// (i.e. the first frame after frame zero) where unwinding can be the +// trickiest. Ideally we'll mark up this frame in some way so the user knows +// we're displaying bad data and we may have skipped one frame of their real +// program in the process of getting back on track. bool RegisterContextLLDB::IsSkipFrame() const { return m_frame_type == eSkipFrame; @@ -1231,8 +1194,8 @@ RegisterContextLLDB::SavedLocationForRegister( RegisterNumber return_address_reg; // If we're fetching the saved pc and this UnwindPlan defines a - // ReturnAddress register (e.g. lr on arm), - // look for the return address register number in the UnwindPlan's row. + // ReturnAddress register (e.g. lr on arm), look for the return address + // register number in the UnwindPlan's row. if (pc_regnum.IsValid() && pc_regnum == regnum && m_full_unwind_plan_sp->GetReturnAddressRegister() != LLDB_INVALID_REGNUM) { @@ -1272,10 +1235,8 @@ RegisterContextLLDB::SavedLocationForRegister( } // This is frame 0 and we're retrieving the PC and it's saved in a Return - // Address register and - // it hasn't been saved anywhere yet -- that is, it's still live in the - // actual register. - // Handle this specially. + // Address register and it hasn't been saved anywhere yet -- that is, + // it's still live in the actual register. Handle this specially. if (have_unwindplan_regloc == false && return_address_reg.IsValid() && IsFrameZero()) { @@ -1298,22 +1259,18 @@ RegisterContextLLDB::SavedLocationForRegister( } // If this architecture stores the return address in a register (it - // defines a Return Address register) - // and we're on a non-zero stack frame and the Full UnwindPlan says that - // the pc is stored in the + // defines a Return Address register) and we're on a non-zero stack frame + // and the Full UnwindPlan says that the pc is stored in the // RA registers (e.g. lr on arm), then we know that the full unwindplan is // not trustworthy -- this // is an impossible situation and the instruction emulation code has - // likely been misled. - // If this stack frame meets those criteria, we need to throw away the - // Full UnwindPlan that the - // instruction emulation came up with and fall back to the architecture's - // Default UnwindPlan so - // the stack walk can get past this point. + // likely been misled. If this stack frame meets those criteria, we need + // to throw away the Full UnwindPlan that the instruction emulation came + // up with and fall back to the architecture's Default UnwindPlan so the + // stack walk can get past this point. // Special note: If the Full UnwindPlan was generated from the compiler, - // don't second-guess it - // when we're at a call site location. + // don't second-guess it when we're at a call site location. // arch_default_ra_regnum is the return address register # in the Full // UnwindPlan register numbering @@ -1376,11 +1333,10 @@ RegisterContextLLDB::SavedLocationForRegister( ExecutionContext exe_ctx(m_thread.shared_from_this()); Process *process = exe_ctx.GetProcessPtr(); if (have_unwindplan_regloc == false) { - // If the UnwindPlan failed to give us an unwind location for this register, - // we may be able to fall back - // to some ABI-defined default. For example, some ABIs allow to determine - // the caller's SP via the CFA. - // Also, the ABI may set volatile registers to the undefined state. + // If the UnwindPlan failed to give us an unwind location for this + // register, we may be able to fall back to some ABI-defined default. For + // example, some ABIs allow to determine the caller's SP via the CFA. Also, + // the ABI may set volatile registers to the undefined state. ABI *abi = process ? process->GetABI().get() : NULL; if (abi) { const RegisterInfo *reg_info = @@ -1558,24 +1514,19 @@ RegisterContextLLDB::SavedLocationForRegister( // TryFallbackUnwindPlan() -- this method is a little tricky. // // When this is called, the frame above -- the caller frame, the "previous" -// frame -- -// is invalid or bad. +// frame -- is invalid or bad. // -// Instead of stopping the stack walk here, we'll try a different UnwindPlan and -// see -// if we can get a valid frame above us. +// Instead of stopping the stack walk here, we'll try a different UnwindPlan +// and see if we can get a valid frame above us. // // This most often happens when an unwind plan based on assembly instruction -// inspection -// is not correct -- mostly with hand-written assembly functions or functions -// where the -// stack frame is set up "out of band", e.g. the kernel saved the register -// context and -// then called an asynchronous trap handler like _sigtramp. +// inspection is not correct -- mostly with hand-written assembly functions or +// functions where the stack frame is set up "out of band", e.g. the kernel +// saved the register context and then called an asynchronous trap handler like +// _sigtramp. // // Often in these cases, if we just do a dumb stack walk we'll get past this -// tricky -// frame and our usual techniques can continue to be used. +// tricky frame and our usual techniques can continue to be used. bool RegisterContextLLDB::TryFallbackUnwindPlan() { if (m_fallback_unwind_plan_sp.get() == nullptr) @@ -1591,15 +1542,13 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { } // If a compiler generated unwind plan failed, trying the arch default - // unwindplan - // isn't going to do any better. + // unwindplan isn't going to do any better. if (m_full_unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes) return false; - // Get the caller's pc value and our own CFA value. - // Swap in the fallback unwind plan, re-fetch the caller's pc value and CFA - // value. - // If they're the same, then the fallback unwind plan provides no benefit. + // Get the caller's pc value and our own CFA value. Swap in the fallback + // unwind plan, re-fetch the caller's pc value and CFA value. If they're the + // same, then the fallback unwind plan provides no benefit. RegisterNumber pc_regnum(m_thread, eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); @@ -1622,23 +1571,18 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() { } // This is a tricky wrinkle! If SavedLocationForRegister() detects a really - // impossible - // register location for the full unwind plan, it may call - // ForceSwitchToFallbackUnwindPlan() - // which in turn replaces the full unwindplan with the fallback... in short, - // we're done, - // we're using the fallback UnwindPlan. - // We checked if m_fallback_unwind_plan_sp was nullptr at the top -- the only - // way it - // became nullptr since then is via SavedLocationForRegister(). + // impossible register location for the full unwind plan, it may call + // ForceSwitchToFallbackUnwindPlan() which in turn replaces the full + // unwindplan with the fallback... in short, we're done, we're using the + // fallback UnwindPlan. We checked if m_fallback_unwind_plan_sp was nullptr + // at the top -- the only way it became nullptr since then is via + // SavedLocationForRegister(). if (m_fallback_unwind_plan_sp.get() == nullptr) return true; // Switch the full UnwindPlan to be the fallback UnwindPlan. If we decide - // this isn't - // working, we need to restore. - // We'll also need to save & restore the value of the m_cfa ivar. Save is - // down below a bit in 'old_cfa'. + // this isn't working, we need to restore. We'll also need to save & restore + // the value of the m_cfa ivar. Save is down below a bit in 'old_cfa'. UnwindPlanSP original_full_unwind_plan_sp = m_full_unwind_plan_sp; addr_t old_cfa = m_cfa; @@ -2049,10 +1993,9 @@ bool RegisterContextLLDB::ReadPC(addr_t &pc) { // A pc value of 0 or 1 is impossible in the middle of the stack -- it // indicates the end of a stack walk. // On the currently executing frame (or such a frame interrupted - // asynchronously by sigtramp et al) this may - // occur if code has jumped through a NULL pointer -- we want to be able to - // unwind past that frame to help - // find the bug. + // asynchronously by sigtramp et al) this may occur if code has jumped + // through a NULL pointer -- we want to be able to unwind past that frame + // to help find the bug. ProcessSP process_sp (m_thread.GetProcess()); if (process_sp) diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp index bc84b4af364..77c1bea3485 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp @@ -139,8 +139,8 @@ bool RegisterContextMacOSXFrameBackchain::ReadRegister( bool RegisterContextMacOSXFrameBackchain::WriteRegister( const RegisterInfo *reg_info, const RegisterValue &value) { - // Not supported yet. We could easily add support for this by remembering - // the address of each entry (it would need to be part of the cursor) + // Not supported yet. We could easily add support for this by remembering the + // address of each entry (it would need to be part of the cursor) return false; } @@ -154,10 +154,10 @@ bool RegisterContextMacOSXFrameBackchain::ReadAllRegisterValues( bool RegisterContextMacOSXFrameBackchain::WriteAllRegisterValues( const lldb::DataBufferSP &data_sp) { - // Since this class doesn't respond to "ReadAllRegisterValues()", it must - // not have been the one that saved all the register values. So we just let - // the thread's register context (the register context for frame zero) do - // the writing. + // Since this class doesn't respond to "ReadAllRegisterValues()", it must not + // have been the one that saved all the register values. So we just let the + // thread's register context (the register context for frame zero) do the + // writing. return m_thread.GetRegisterContext()->WriteAllRegisterValues(data_sp); } diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp index 8f0dfd2a5b5..76189ea781d 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextMemory.cpp @@ -32,9 +32,9 @@ RegisterContextMemory::RegisterContextMemory(Thread &thread, addr_t reg_data_addr) : RegisterContext(thread, concrete_frame_idx), m_reg_infos(reg_infos), m_reg_valid(), m_reg_data(), m_reg_data_addr(reg_data_addr) { - // Resize our vector of bools to contain one bool for every register. - // We will use these boolean values to know when a register value - // is valid in m_reg_data. + // Resize our vector of bools to contain one bool for every register. We will + // use these boolean values to know when a register value is valid in + // m_reg_data. const size_t num_regs = reg_infos.GetNumRegisters(); assert(num_regs > 0); m_reg_valid.resize(num_regs); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp index bb3509330ee..c3fa8316895 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp @@ -142,8 +142,8 @@ size_t RegisterContextPOSIX_arm::GetGPRSize() { const lldb_private::RegisterInfo *RegisterContextPOSIX_arm::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -199,8 +199,8 @@ bool RegisterContextPOSIX_arm::IsRegisterSetAvailable(size_t set_index) { return set_index < k_num_register_sets; } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_arm::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp index 89384c8f519..192f06c3aa0 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp @@ -162,8 +162,8 @@ size_t RegisterContextPOSIX_arm64::GetGPRSize() { const lldb_private::RegisterInfo * RegisterContextPOSIX_arm64::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -219,8 +219,8 @@ bool RegisterContextPOSIX_arm64::IsRegisterSetAvailable(size_t set_index) { return set_index < k_num_register_sets; } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_arm64::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp index 6a55947ba5c..039ca028123 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -92,8 +92,8 @@ size_t RegisterContextPOSIX_mips64::GetGPRSize() { const RegisterInfo *RegisterContextPOSIX_mips64::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -172,8 +172,8 @@ bool RegisterContextPOSIX_mips64::IsRegisterSetAvailable(size_t set_index) { return (set_index < num_sets); } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_mips64::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = m_num_registers; diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp index c2b73e22616..ad52a4d309f 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp @@ -129,8 +129,8 @@ size_t RegisterContextPOSIX_powerpc::GetGPRSize() { const RegisterInfo *RegisterContextPOSIX_powerpc::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -181,8 +181,8 @@ bool RegisterContextPOSIX_powerpc::IsRegisterSetAvailable(size_t set_index) { return (set_index < num_sets); } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_powerpc::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp index de410f063b5..44578d7c584 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp @@ -146,8 +146,8 @@ size_t RegisterContextPOSIX_ppc64le::GetGPRSize() { const RegisterInfo *RegisterContextPOSIX_ppc64le::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -198,8 +198,8 @@ bool RegisterContextPOSIX_ppc64le::IsRegisterSetAvailable(size_t set_index) { return (set_index < num_sets); } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_ppc64le::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp index b3365ee2f09..662ac38405e 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp @@ -174,8 +174,8 @@ lldb::ByteOrder RegisterContextPOSIX_s390x::GetByteOrder() { return byte_order; } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_s390x::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp index 41cec8add98..d2a06e1b789 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -414,8 +414,8 @@ size_t RegisterContextPOSIX_x86::GetFXSAVEOffset() { const RegisterInfo *RegisterContextPOSIX_x86::GetRegisterInfo() { // Commonly, this method is overridden and g_register_infos is copied and - // specialized. - // So, use GetRegisterInfo() rather than g_register_infos in this scope. + // specialized. So, use GetRegisterInfo() rather than g_register_infos in + // this scope. return m_register_info_ap->GetRegisterInfo(); } @@ -531,8 +531,8 @@ bool RegisterContextPOSIX_x86::IsRegisterSetAvailable(size_t set_index) { return (set_index < num_sets); } -// Used when parsing DWARF and EH frame information and any other -// object file sections that contain register numbers in them. +// Used when parsing DWARF and EH frame information and any other object file +// sections that contain register numbers in them. uint32_t RegisterContextPOSIX_x86::ConvertRegisterKindToRegisterNumber( lldb::RegisterKind kind, uint32_t num) { const uint32_t num_regs = GetRegisterCount(); diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 3e860874183..3dbfe611e71 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -356,8 +356,8 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( if (exc_code == 0x10003) // EXC_SOFT_SIGNAL { if (exc_sub_code == 5) { - // On MacOSX, a SIGTRAP can signify that a process has called - // exec, so we should check with our dynamic loader to verify. + // On MacOSX, a SIGTRAP can signify that a process has called exec, + // so we should check with our dynamic loader to verify. ProcessSP process_sp(thread.GetProcess()); if (process_sp) { DynamicLoader *dynamic_loader = process_sp->GetDynamicLoader(); @@ -403,10 +403,8 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( if (!exc_sub_code) { // This looks like a plain trap. // Have to check if there is a breakpoint here as well. When you - // single-step onto a trap, - // the single step stops you not to trap. Since we also do that - // check below, let's just use - // that logic. + // single-step onto a trap, the single step stops you not to trap. + // Since we also do that check below, let's just use that logic. is_actual_breakpoint = true; is_trace_if_actual_breakpoint_missing = true; } else { @@ -419,8 +417,8 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( (lldb::addr_t)exc_sub_code); if (wp_sp && wp_sp->IsEnabled()) { // Debugserver may piggyback the hardware index of the fired - // watchpoint in the exception data. - // Set the hardware index if that's the case. + // watchpoint in the exception data. Set the hardware index if + // that's the case. if (exc_data_count >= 3) wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); return StopInfo::CreateStopReasonWithWatchpointID(thread, @@ -450,16 +448,15 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( if (exc_code == 0x102) // EXC_ARM_DA_DEBUG { // It's a watchpoint, then, if the exc_sub_code indicates a - // known/enabled - // data break address from our watchpoint list. + // known/enabled data break address from our watchpoint list. lldb::WatchpointSP wp_sp; if (target) wp_sp = target->GetWatchpointList().FindByAddress( (lldb::addr_t)exc_sub_code); if (wp_sp && wp_sp->IsEnabled()) { // Debugserver may piggyback the hardware index of the fired - // watchpoint in the exception data. - // Set the hardware index if that's the case. + // watchpoint in the exception data. Set the hardware index if + // that's the case. if (exc_data_count >= 3) wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); return StopInfo::CreateStopReasonWithWatchpointID(thread, @@ -473,9 +470,9 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( is_actual_breakpoint = true; is_trace_if_actual_breakpoint_missing = true; } else if (exc_code == 0) // FIXME not EXC_ARM_BREAKPOINT but a kernel - // is currently returning this so accept it as - // indicating a breakpoint until the kernel is - // fixed + // is currently returning this so accept it + // as indicating a breakpoint until the + // kernel is fixed { is_actual_breakpoint = true; is_trace_if_actual_breakpoint_missing = true; @@ -493,16 +490,15 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( if (exc_code == 0x102) // EXC_ARM_DA_DEBUG { // It's a watchpoint, then, if the exc_sub_code indicates a - // known/enabled - // data break address from our watchpoint list. + // known/enabled data break address from our watchpoint list. lldb::WatchpointSP wp_sp; if (target) wp_sp = target->GetWatchpointList().FindByAddress( (lldb::addr_t)exc_sub_code); if (wp_sp && wp_sp->IsEnabled()) { // Debugserver may piggyback the hardware index of the fired - // watchpoint in the exception data. - // Set the hardware index if that's the case. + // watchpoint in the exception data. Set the hardware index if + // that's the case. if (exc_data_count >= 3) wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); return StopInfo::CreateStopReasonWithWatchpointID(thread, @@ -514,8 +510,7 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( return StopInfo::CreateStopReasonToTrace(thread); } // It looks like exc_sub_code has the 4 bytes of the instruction that - // triggered the - // exception, i.e. our breakpoint opcode + // triggered the exception, i.e. our breakpoint opcode is_actual_breakpoint = exc_code == 1; break; } @@ -534,23 +529,21 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException( if (process_sp) bp_site_sp = process_sp->GetBreakpointSiteList().FindByAddress(pc); if (bp_site_sp && bp_site_sp->IsEnabled()) { - // Update the PC if we were asked to do so, but only do - // so if we find a breakpoint that we know about cause - // this could be a trap instruction in the code + // Update the PC if we were asked to do so, but only do so if we find + // a breakpoint that we know about cause this could be a trap + // instruction in the code if (pc_decrement > 0 && adjust_pc_if_needed) reg_ctx_sp->SetPC(pc); // If the breakpoint is for this thread, then we'll report the hit, - // but if it is for another thread, - // we can just report no reason. We don't need to worry about - // stepping over the breakpoint here, that + // but if it is for another thread, we can just report no reason. We + // don't need to worry about stepping over the breakpoint here, that // will be taken care of when the thread resumes and notices that - // there's a breakpoint under the pc. - // If we have an operating system plug-in, we might have set a thread - // specific breakpoint using the + // there's a breakpoint under the pc. If we have an operating system + // plug-in, we might have set a thread specific breakpoint using the // operating system thread ID, so we can't make any assumptions about - // the thread ID so we must always - // report the breakpoint regardless of the thread. + // the thread ID so we must always report the breakpoint regardless + // of the thread. if (bp_site_sp->ValidForThisThread(&thread) || thread.GetProcess()->GetOperatingSystem() != NULL) return StopInfo::CreateStopReasonWithBreakpointSiteID( diff --git a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp index 2b34bddd90b..55559f07f1e 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -132,16 +132,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { // We want to detect an unwind that cycles erroneously and stop backtracing. // Don't want this maximum unwind limit to be too low -- if you have a - // backtrace - // with an "infinitely recursing" bug, it will crash when the stack blows out - // and the first 35,000 frames are uninteresting - it's the top most 5 frames - // that - // you actually care about. So you can't just cap the unwind at 10,000 or - // something. - // Realistically anything over around 200,000 is going to blow out the stack - // space. - // If we're still unwinding at that point, we're probably never going to - // finish. + // backtrace with an "infinitely recursing" bug, it will crash when the stack + // blows out and the first 35,000 frames are uninteresting - it's the top + // most 5 frames that you actually care about. So you can't just cap the + // unwind at 10,000 or something. Realistically anything over around 200,000 + // is going to blow out the stack space. If we're still unwinding at that + // point, we're probably never going to finish. if (cur_idx > 300000) { if (log) log->Printf("%*sFrame %d unwound too many frames, assuming unwind has " @@ -152,13 +148,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { if (reg_ctx_sp.get() == NULL) { // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to - // that and return - // true. Subsequent calls to TryFallbackUnwindPlan() will return false. + // that and return true. Subsequent calls to TryFallbackUnwindPlan() will + // return false. if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be updated. - // Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of prev_frame + // still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -172,15 +167,13 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { } if (!reg_ctx_sp->IsValid()) { - // We failed to get a valid RegisterContext. - // See if the regctx below this on the stack has a fallback unwind plan it - // can use. - // Subsequent calls to TryFallbackUnwindPlan() will return false. + // We failed to get a valid RegisterContext. See if the regctx below this + // on the stack has a fallback unwind plan it can use. Subsequent calls to + // TryFallbackUnwindPlan() will return false. if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be updated. - // Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of prev_frame + // still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -195,13 +188,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { } if (!reg_ctx_sp->GetCFA(cursor_sp->cfa)) { // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to - // that and return - // true. Subsequent calls to TryFallbackUnwindPlan() will return false. + // that and return true. Subsequent calls to TryFallbackUnwindPlan() will + // return false. if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be updated. - // Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of prev_frame + // still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -216,27 +208,21 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { } if (abi && !abi->CallFrameAddressIsValid(cursor_sp->cfa)) { // On Mac OS X, the _sigtramp asynchronous signal trampoline frame may not - // have - // its (constructed) CFA aligned correctly -- don't do the abi alignment - // check for - // these. + // have its (constructed) CFA aligned correctly -- don't do the abi + // alignment check for these. if (reg_ctx_sp->IsTrapHandlerFrame() == false) { // See if we can find a fallback unwind plan for THIS frame. It may be // that the UnwindPlan we're using for THIS frame was bad and gave us a - // bad CFA. - // If that's not it, then see if we can change the UnwindPlan for the - // frame - // below us ("NEXT") -- see if using that other UnwindPlan gets us a - // better - // unwind state. + // bad CFA. If that's not it, then see if we can change the UnwindPlan + // for the frame below us ("NEXT") -- see if using that other UnwindPlan + // gets us a better unwind state. if (reg_ctx_sp->TryFallbackUnwindPlan() == false || reg_ctx_sp->GetCFA(cursor_sp->cfa) == false || abi->CallFrameAddressIsValid(cursor_sp->cfa) == false) { if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be - // updated. Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of + // prev_frame still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -259,13 +245,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { } if (!reg_ctx_sp->ReadPC(cursor_sp->start_pc)) { // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to - // that and return - // true. Subsequent calls to TryFallbackUnwindPlan() will return false. + // that and return true. Subsequent calls to TryFallbackUnwindPlan() will + // return false. if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be updated. - // Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of prev_frame + // still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -280,13 +265,12 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) { } if (abi && !abi->CodeAddressIsValid(cursor_sp->start_pc)) { // If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to - // that and return - // true. Subsequent calls to TryFallbackUnwindPlan() will return false. + // that and return true. Subsequent calls to TryFallbackUnwindPlan() will + // return false. if (prev_frame->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // TryFallbackUnwindPlan for prev_frame succeeded and updated - // reg_ctx_lldb_sp field of - // prev_frame. However, cfa field of prev_frame still needs to be updated. - // Hence updating it. + // reg_ctx_lldb_sp field of prev_frame. However, cfa field of prev_frame + // still needs to be updated. Hence updating it. if (!(prev_frame->reg_ctx_lldb_sp->GetCFA(prev_frame->cfa))) return nullptr; @@ -320,13 +304,12 @@ void UnwindLLDB::UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi) { CursorSP old_m_candidate_frame = m_candidate_frame; // Try to unwind 2 more frames using the Unwinder. It uses Full UnwindPlan - // and if Full UnwindPlan fails, then uses FallBack UnwindPlan. Also - // update the cfa of Frame 0 (if required). + // and if Full UnwindPlan fails, then uses FallBack UnwindPlan. Also update + // the cfa of Frame 0 (if required). AddOneMoreFrame(abi); - // Remove all the frames added by above function as the purpose of - // using above function was just to check whether Unwinder of Frame 0 - // works or not. + // Remove all the frames added by above function as the purpose of using + // above function was just to check whether Unwinder of Frame 0 works or not. for (uint32_t i = 1; i < m_frames.size(); i++) m_frames.pop_back(); @@ -362,51 +345,44 @@ bool UnwindLLDB::AddOneMoreFrame(ABI *abi) { m_frames.push_back(new_frame); - // If we can get one more frame further then accept that we get back a correct - // frame. + // If we can get one more frame further then accept that we get back a + // correct frame. m_candidate_frame = GetOneMoreFrame(abi); if (m_candidate_frame) return true; // We can't go further from the frame returned by GetOneMore frame. Lets try - // to get a - // different frame with using the fallback unwind plan. + // to get a different frame with using the fallback unwind plan. if (!m_frames[m_frames.size() - 2] ->reg_ctx_lldb_sp->TryFallbackUnwindPlan()) { // We don't have a valid fallback unwind plan. Accept the frame as it is. - // This is a - // valid situation when we are at the bottom of the stack. + // This is a valid situation when we are at the bottom of the stack. return true; } // Remove the possibly incorrect frame from the frame list and try to add a - // different one with - // the newly selected fallback unwind plan. + // different one with the newly selected fallback unwind plan. m_frames.pop_back(); CursorSP new_frame_v2 = GetOneMoreFrame(abi); if (new_frame_v2 == nullptr) { // We haven't got a new frame from the fallback unwind plan. Accept the - // frame from the - // original unwind plan. This is a valid situation when we are at the bottom - // of the stack. + // frame from the original unwind plan. This is a valid situation when we + // are at the bottom of the stack. m_frames.push_back(new_frame); return true; } // Push the new frame to the list and try to continue from this frame. If we - // can get a new frame - // then accept it as the correct one. + // can get a new frame then accept it as the correct one. m_frames.push_back(new_frame_v2); m_candidate_frame = GetOneMoreFrame(abi); if (m_candidate_frame) { // If control reached here then TryFallbackUnwindPlan had succeeded for - // Cursor::m_frames[m_frames.size() - 2]. - // It also succeeded to Unwind next 2 frames i.e. m_frames[m_frames.size() - - // 1] and a frame after that. - // For Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was - // already updated during TryFallbackUnwindPlan - // call above. However, cfa field still needs to be updated. Hence updating - // it here and then returning. + // Cursor::m_frames[m_frames.size() - 2]. It also succeeded to Unwind next + // 2 frames i.e. m_frames[m_frames.size() - 1] and a frame after that. For + // Cursor::m_frames[m_frames.size() - 2], reg_ctx_lldb_sp field was already + // updated during TryFallbackUnwindPlan call above. However, cfa field + // still needs to be updated. Hence updating it here and then returning. if (!(m_frames[m_frames.size() - 2]->reg_ctx_lldb_sp->GetCFA( m_frames[m_frames.size() - 2]->cfa))) return false; @@ -414,8 +390,7 @@ bool UnwindLLDB::AddOneMoreFrame(ABI *abi) { } // The new frame hasn't helped in unwinding. Fall back to the original one as - // the default unwind - // plan is usually more reliable then the fallback one. + // the default unwind plan is usually more reliable then the fallback one. m_frames.pop_back(); m_frames.push_back(new_frame); return true; @@ -486,10 +461,9 @@ bool UnwindLLDB::SearchForSavedLocationForRegister( if (static_cast<size_t>(frame_num) >= m_frames.size()) return false; - // Never interrogate more than one level while looking for the saved pc value. - // If the value - // isn't saved by frame_num, none of the frames lower on the stack will have a - // useful value. + // Never interrogate more than one level while looking for the saved pc + // value. If the value isn't saved by frame_num, none of the frames lower on + // the stack will have a useful value. if (pc_reg) { UnwindLLDB::RegisterSearchResult result; result = m_frames[frame_num]->reg_ctx_lldb_sp->SavedLocationForRegister( @@ -505,8 +479,7 @@ bool UnwindLLDB::SearchForSavedLocationForRegister( lldb_regnum, regloc); // We descended down to the live register context aka stack frame 0 and are - // reading the value - // out of a live register. + // reading the value out of a live register. if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound && regloc.type == UnwindLLDB::RegisterLocation::eRegisterInLiveRegisterContext) { @@ -514,11 +487,9 @@ bool UnwindLLDB::SearchForSavedLocationForRegister( } // If we have unwind instructions saying that register N is saved in - // register M in the middle of - // the stack (and N can equal M here, meaning the register was not used in - // this function), then - // change the register number we're looking for to M and keep looking for a - // concrete location + // register M in the middle of the stack (and N can equal M here, meaning + // the register was not used in this function), then change the register + // number we're looking for to M and keep looking for a concrete location // down the stack, or an actual value from a live RegisterContext at frame // 0. if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound && diff --git a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp index d831011cb66..2115b4e179c 100644 --- a/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp +++ b/lldb/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp @@ -133,8 +133,8 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386( if (addr_range_ptr) { if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress()) { - // We are at the first instruction, so we can recover the - // previous PC by dereferencing the SP + // We are at the first instruction, so we can recover the previous PC + // by dereferencing the SP lldb::addr_t first_frame_sp = reg_ctx->GetSP(0); // Read the real second frame return address into frame.pc if (first_frame_sp && @@ -224,8 +224,8 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64( if (addr_range_ptr) { if (first_frame->GetFrameCodeAddress() == addr_range_ptr->GetBaseAddress()) { - // We are at the first instruction, so we can recover the - // previous PC by dereferencing the SP + // We are at the first instruction, so we can recover the previous PC + // by dereferencing the SP lldb::addr_t first_frame_sp = reg_ctx->GetSP(0); // Read the real second frame return address into frame.pc if (process->ReadMemory(first_frame_sp, &frame.pc, sizeof(frame.pc), |