Skip to content

Commit

Permalink
fix for Fjalar issue #66 (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
markro49 authored May 28, 2024
1 parent 81f8a30 commit a4a6d75
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions valgrind/fjalar/generate_fjalar_entries.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ void repCheckAllEntries(void) {
VarNode* n;
unsigned int numMemberVars = 0;
unsigned int prev_data_member_location = 0;
unsigned int prev_data_member_size = 0;
unsigned int prev_data_member_bit_size = 0;

SimpleNode* memberFunctionNode;
SimpleNode* superclassNode;
Expand Down Expand Up @@ -758,19 +760,21 @@ void repCheckAllEntries(void) {
tl_assert(0 == curMember->byteOffset);

// For a struct, check that data_member_location is greater
// than the one of the previous member variable. Notice that
// data_member_location can be 0.
// than or equal to that of the previous member variable.
// Don't do this check for bitfields.
if (D_STRUCT_CLASS == t->decType) {
// We don't check bit-fields as the compiler may
// allocate them to a previous location.
// (We currently don't support bit-fields.)
// FJALAR_DPRINTF("addr: %lx, bitfield?: %d %d %d\n", curMember->memberVar->data_member_location,
// curMember->memberVar->internalByteSize,
// curMember->memberVar->internalBitOffset,
// curMember->memberVar->internalBitSize);
if ((curMember->memberVar->internalByteSize == 0) && (curMember->memberVar->data_member_location != 0))
tl_assert(curMember->memberVar->data_member_location > prev_data_member_location);
FJALAR_DPRINTF("addr: %lx, bitfield?: %d %d %d\n", curMember->memberVar->data_member_location,
curMember->memberVar->internalByteSize,
curMember->memberVar->internalBitOffset,
curMember->memberVar->internalBitSize);
if ((curMember->memberVar->internalBitSize == 0) && (prev_data_member_bit_size == 0))
tl_assert(curMember->memberVar->data_member_location >= prev_data_member_location + prev_data_member_size);
prev_data_member_location = curMember->memberVar->data_member_location;
prev_data_member_size = curMember->memberVar->internalByteSize;
prev_data_member_bit_size = curMember->memberVar->internalBitSize;
}
// For a union, all offsets should be 0
else if (D_UNION == t->decType) {
Expand Down

0 comments on commit a4a6d75

Please sign in to comment.