Skip to content

Commit

Permalink
Bug Fix: Wrong Index If Multiples Changes
Browse files Browse the repository at this point in the history
When offmemcmp detects more than one change in a vector/matrix, it
returns the byte_offset accordingly to the pointers passed as a
parameter. It turns out that these pointers can be incremented as
new changes are found and the byte_offset alone does not match the
real byte_offset in which the change occurred.

Therefore, this commit corrects this taking into account the new
pointer address and the base address, and thus, correctly
calculating the indexes, either with one or more changes.
  • Loading branch information
Theldus committed Apr 15, 2020
1 parent 6b0d21f commit a588739
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void var_check_changes(struct breakpoint *b, struct array *vars, pid_t child, in
/* If one dimension. */
if (v->type.array.dimensions == 1)
{
index_per_dimension[0] = byte_offset / size_per_element;
index_per_dimension[0] = (cmp1 - v1) / size_per_element;

/* Output changes using the current printer. */
line_output(depth, b->line_no, v, &value1, &value2,
Expand All @@ -672,7 +672,7 @@ void var_check_changes(struct breakpoint *b, struct array *vars, pid_t child, in
int div;
int idx_dim;

div = byte_offset / size_per_element;
div = (cmp1 - v1) / size_per_element;
idx_dim = v->type.array.dimensions - 1;

/* Calculate indexes. */
Expand Down

0 comments on commit a588739

Please sign in to comment.