2020#include " lldb/Utility/LLDBLog.h"
2121#include " lldb/Utility/Log.h"
2222#include " lldb/Utility/Timer.h"
23+ #include " llvm/BinaryFormat/Dwarf.h"
2324#include < cstdint>
2425#include < cstring>
25- #include < limits>
2626#include < list>
2727#include < optional>
2828
@@ -151,23 +151,19 @@ GetGNUEHPointer(const DataExtractor &DE, lldb::offset_t *offset_ptr,
151151
152152// Check if the given cie_id value indicates a CIE (Common Information Entry)
153153// as opposed to an FDE (Frame Description Entry).
154- //
155- // For eh_frame sections: CIE is marked with cie_id == 0
156- // For debug_frame sections:
157- // - DWARF32: CIE is marked with cie_id ==
158- // std::numeric_limits<uint32_t>::max()
159- // - DWARF64: CIE is marked with cie_id ==
160- // std::numeric_limits<uint64_t>::max()
161154static bool IsCIEMarker (uint64_t cie_id, bool is_64bit,
162155 DWARFCallFrameInfo::Type type) {
156+ // Check eh_frame CIE marker
163157 if (type == DWARFCallFrameInfo::EH)
164158 return cie_id == 0 ;
165159
166- // DWARF type
160+ // Check debug_frame CIE marker
161+ // DWARF64
167162 if (is_64bit)
168- return cie_id == std::numeric_limits< uint64_t >:: max () ;
163+ return cie_id == llvm::dwarf::DW64_CIE_ID ;
169164
170- return cie_id == std::numeric_limits<uint32_t >::max ();
165+ // DWARF32
166+ return cie_id == llvm::dwarf::DW_CIE_ID;
171167}
172168
173169DWARFCallFrameInfo::DWARFCallFrameInfo (ObjectFile &objfile,
@@ -306,7 +302,7 @@ DWARFCallFrameInfo::ParseCIE(const dw_offset_t cie_offset) {
306302 GetCFIData ();
307303 uint32_t length = m_cfi_data.GetU32 (&offset);
308304 dw_offset_t cie_id, end_offset;
309- bool is_64bit = (length == std::numeric_limits< uint32_t >:: max () );
305+ bool is_64bit = (length == llvm::dwarf::DW_LENGTH_DWARF64 );
310306 if (is_64bit) {
311307 length = m_cfi_data.GetU64 (&offset);
312308 cie_id = m_cfi_data.GetU64 (&offset);
@@ -494,7 +490,7 @@ void DWARFCallFrameInfo::GetFDEIndex() {
494490 const dw_offset_t current_entry = offset;
495491 dw_offset_t cie_id, next_entry, cie_offset;
496492 uint32_t len = m_cfi_data.GetU32 (&offset);
497- bool is_64bit = (len == std::numeric_limits< uint32_t >:: max () );
493+ bool is_64bit = (len == llvm::dwarf::DW_LENGTH_DWARF64 );
498494 if (is_64bit) {
499495 len = m_cfi_data.GetU64 (&offset);
500496 cie_id = m_cfi_data.GetU64 (&offset);
@@ -589,7 +585,7 @@ DWARFCallFrameInfo::ParseFDE(dw_offset_t dwarf_offset,
589585
590586 uint32_t length = m_cfi_data.GetU32 (&offset);
591587 dw_offset_t cie_offset;
592- bool is_64bit = (length == std::numeric_limits< uint32_t >:: max () );
588+ bool is_64bit = (length == llvm::dwarf::DW_LENGTH_DWARF64 );
593589 if (is_64bit) {
594590 length = m_cfi_data.GetU64 (&offset);
595591 cie_offset = m_cfi_data.GetU64 (&offset);
@@ -599,7 +595,8 @@ DWARFCallFrameInfo::ParseFDE(dw_offset_t dwarf_offset,
599595
600596 // FDE entries with zeroth cie_offset may occur for debug_frame.
601597 assert (!(m_type == EH && 0 == cie_offset) &&
602- cie_offset != std::numeric_limits<uint32_t >::max ());
598+ cie_offset !=
599+ (is_64bit ? llvm::dwarf::DW64_CIE_ID : llvm::dwarf::DW_CIE_ID));
603600
604601 // Translate the CIE_id from the eh_frame format, which is relative to the
605602 // FDE offset, into a __eh_frame section offset
0 commit comments