forked from OSchip/llvm-project
[LLDB][NFC][Reliability] Fixes for int overflow and uninitialized state
Fixing potential int overflow and uninitialized variables. These were found by Coverity static code inspection. Differential Revision: https://reviews.llvm.org/D130795
This commit is contained in:
parent
9436a85eb6
commit
f7c961cc6b
|
@ -633,7 +633,7 @@ bool EmulateInstructionARM64::EmulateADDSUBImm(const uint32_t opcode) {
|
|||
imm = imm12;
|
||||
break;
|
||||
case 1:
|
||||
imm = imm12 << 12;
|
||||
imm = static_cast<uint64_t>(imm12) << 12;
|
||||
break;
|
||||
default:
|
||||
return false; // UNDEFINED;
|
||||
|
|
|
@ -18,7 +18,7 @@ using namespace lldb_private;
|
|||
static inline uint64_t GetStatusBit(uint32_t wp_index) {
|
||||
// DR6: ...BBBB
|
||||
// 3210 <- status bits for bp./wp. i; 1 if hit
|
||||
return 1 << wp_index;
|
||||
return 1ULL << wp_index;
|
||||
}
|
||||
|
||||
// Returns mask/value for global enable bit of wp_index in DR7
|
||||
|
@ -27,14 +27,14 @@ static inline uint64_t GetEnableBit(uint32_t wp_index) {
|
|||
// 33221100 <- global/local enable for bp./wp.; 1 if enabled
|
||||
// we use global bits because NetBSD kernel does not preserve local
|
||||
// bits reliably; Linux seems fine with either
|
||||
return 1 << (2 * wp_index + 1);
|
||||
return 1ULL << (2 * wp_index + 1);
|
||||
}
|
||||
|
||||
// Returns mask for both enable bits of wp_index in DR7
|
||||
static inline uint64_t GetBothEnableBitMask(uint32_t wp_index) {
|
||||
// DR7: ...GLGLGLGL
|
||||
// 33221100 <- global/local enable for bp./wp.; 1 if enabled
|
||||
return 3 << (2 * wp_index + 1);
|
||||
return 3ULL << (2 * wp_index + 1);
|
||||
}
|
||||
|
||||
// Returns value for type bits of wp_index in DR7
|
||||
|
@ -47,7 +47,7 @@ static inline uint64_t GetWatchTypeBits(uint32_t watch_flags,
|
|||
// wp.: 3333222211110000...
|
||||
//
|
||||
// where T - type is 01 for write, 11 for r/w
|
||||
return watch_flags << (16 + 4 * wp_index);
|
||||
return static_cast<uint64_t>(watch_flags) << (16 + 4 * wp_index);
|
||||
}
|
||||
|
||||
// Returns value for size bits of wp_index in DR7
|
||||
|
@ -63,7 +63,8 @@ static inline uint64_t GetWatchSizeBits(uint32_t size, uint32_t wp_index) {
|
|||
// 01 for 2 bytes
|
||||
// 10 for 8 bytes
|
||||
// 11 for 4 bytes
|
||||
return (size == 8 ? 0x2 : size - 1) << (18 + 4 * wp_index);
|
||||
return static_cast<uint64_t>(size == 8 ? 0x2 : size - 1)
|
||||
<< (18 + 4 * wp_index);
|
||||
}
|
||||
|
||||
// Returns bitmask for all bits controlling wp_index in DR7
|
||||
|
|
|
@ -2731,7 +2731,7 @@ void DWARFASTParserClang::ParseSingleMember(
|
|||
|
||||
uint64_t field_bit_offset = (attrs.member_byte_offset == UINT32_MAX
|
||||
? 0
|
||||
: (attrs.member_byte_offset * 8));
|
||||
: (attrs.member_byte_offset * 8ULL));
|
||||
|
||||
if (attrs.bit_size > 0) {
|
||||
FieldInfo this_field_info;
|
||||
|
|
|
@ -582,7 +582,7 @@ void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) {
|
|||
dw_addr_t DWARFUnit::ReadAddressFromDebugAddrSection(uint32_t index) const {
|
||||
uint32_t index_size = GetAddressByteSize();
|
||||
dw_offset_t addr_base = GetAddrBase();
|
||||
dw_addr_t offset = addr_base + index * index_size;
|
||||
dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
|
||||
const DWARFDataExtractor &data =
|
||||
m_dwarf.GetDWARFContext().getOrLoadAddrData();
|
||||
if (data.ValidOffsetForDataOfSize(offset, index_size))
|
||||
|
@ -1033,7 +1033,8 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
|
|||
GetAddressByteSize(), [&](uint32_t index) {
|
||||
uint32_t index_size = GetAddressByteSize();
|
||||
dw_offset_t addr_base = GetAddrBase();
|
||||
lldb::offset_t offset = addr_base + index * index_size;
|
||||
lldb::offset_t offset =
|
||||
addr_base + static_cast<lldb::offset_t>(index) * index_size;
|
||||
return llvm::object::SectionedAddress{
|
||||
m_dwarf.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
|
||||
&offset, index_size)};
|
||||
|
|
|
@ -787,14 +787,14 @@ SystemRuntimeMacOSX::GetPendingItemRefsForQueue(lldb::addr_t queue) {
|
|||
// }
|
||||
|
||||
offset_t offset = 0;
|
||||
int i = 0;
|
||||
uint64_t i = 0;
|
||||
uint32_t version = extractor.GetU32(&offset);
|
||||
if (version == 1) {
|
||||
pending_item_refs.new_style = true;
|
||||
uint32_t item_size = extractor.GetU32(&offset);
|
||||
uint32_t start_of_array_offset = offset;
|
||||
while (offset < pending_items_pointer.items_buffer_size &&
|
||||
static_cast<size_t>(i) < pending_items_pointer.count) {
|
||||
i < pending_items_pointer.count) {
|
||||
offset = start_of_array_offset + (i * item_size);
|
||||
ItemRefAndCodeAddress item;
|
||||
item.item_ref = extractor.GetAddress(&offset);
|
||||
|
@ -806,7 +806,7 @@ SystemRuntimeMacOSX::GetPendingItemRefsForQueue(lldb::addr_t queue) {
|
|||
offset = 0;
|
||||
pending_item_refs.new_style = false;
|
||||
while (offset < pending_items_pointer.items_buffer_size &&
|
||||
static_cast<size_t>(i) < pending_items_pointer.count) {
|
||||
i < pending_items_pointer.count) {
|
||||
ItemRefAndCodeAddress item;
|
||||
item.item_ref = extractor.GetAddress(&offset);
|
||||
item.code_address = LLDB_INVALID_ADDRESS;
|
||||
|
|
|
@ -966,7 +966,7 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
|
|||
// path jumps over the mid-function epilogue
|
||||
|
||||
UnwindPlan::RowSP prologue_completed_row; // copy of prologue row of CFI
|
||||
int prologue_completed_sp_bytes_offset_from_cfa; // The sp value before the
|
||||
int prologue_completed_sp_bytes_offset_from_cfa = 0; // The sp value before the
|
||||
// epilogue started executed
|
||||
bool prologue_completed_is_aligned = false;
|
||||
std::vector<bool> prologue_completed_saved_registers;
|
||||
|
|
Loading…
Reference in New Issue