Recent

Author Topic: Array value popup display not quite right  (Read 1492 times)

440bx

  • Hero Member
  • *****
  • Posts: 1883
Array value popup display not quite right
« on: January 28, 2020, 07:50:24 pm »
Hello,

I was fiddling with bit arrays and was getting some values from GDB, I couldn't make sense of.  I wrote the following little test program to see what GDB would say:
Code: Pascal  [Select][+][-]
  1. program TestBitArray;
  2.  
  3. type
  4.   T1BIT = 0..1;
  5.  
  6. var
  7.   BitArray  : bitpacked array[0..8191] of T1BIT;
  8.   ByteArray : packed array[0..1023] of byte absolute BitArray;
  9.  
  10.   i   : integer;
  11.  
  12.   sum : qword;
  13.  
  14.  
  15. begin
  16.   sum := 0;
  17.   for i := low(BitArray) to high(BitArray) do
  18.   begin
  19.     inc(sum, BitArray[i]);
  20.   end;
  21.   writeln(Sum);
  22.  
  23.   sum := 0;
  24.   for i := low(ByteArray) to high(ByteArray) do
  25.   begin
  26.     inc(Sum, ByteArray[i]);
  27.   end;
  28.   writeln(Sum);
  29. end.
When hovering the mouse over the BitArray variable, GDB shows that some of the elements in the array are not zero (they should be - and are - zero.)  The Sum variables confirm that all elements are zero even though GDB shows some of them as not zero.

What the popup display shows is attached to this post.

I figured I'd post this as an FYI.  Also, the GDB version I'm using is 7.2, type of Debug Info is "dwarf with sets".
« Last Edit: January 28, 2020, 07:53:48 pm by 440bx »
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

julkas

  • Hero Member
  • *****
  • Posts: 601
  • KISS principle / Lazarus 2.0.6 / FPC 3.0.4
Re: Array value popup display not quite right
« Reply #1 on: January 29, 2020, 11:14:28 am »
Confirm. Same output.
If remove bitpacked or change to packed then GDB shows only zeroes.
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

 

TinyPortal © 2005-2018