How to visualize the value of a pointer while debugging in Delphi?
Asked Answered
B

3

7

So, I have a variable buffPtr: TPointer It has a size of 16 and contains a series of numbers, mostly starting with 0, say something like 013854351387365. I'm sure it contains values, because the application does what it does fine.

I want to see this value while I'm debugging.

If I add "PAnsiChar(buffPtr)^" to the watches I only see the first byte.

Billon answered 8/1, 2013 at 16:47 Comment(1)
Did you tried to put PAnsiChar(BufPtr) (without the ^)?Nadenenader
B
9

I added a watch to PAnsiChar(buffPtr)^

with the Watch Properties as

Repeat Count = 16 Decimal

enter image description here

Billon answered 8/1, 2013 at 17:26 Comment(2)
I don't understand the question or the answer. Could you elaborate?Tad
It would be nice if you also included a picture of the output from this configuration, instead of just the input of the dialog.Connatural
G
11

Just type in the watch expression PAnsiChar(buffPtr)^,16 or PByte(buffPtr)^,16 if you want the ordinal/byte values.

The trick here is to add the number of pattern repeat after a comma, like ,16.

It is IMHO more convenient than changing the Watch Properties, and it works with the F7 evaluation command of the IDE.

Gilud answered 8/1, 2013 at 18:4 Comment(0)
B
9

I added a watch to PAnsiChar(buffPtr)^

with the Watch Properties as

Repeat Count = 16 Decimal

enter image description here

Billon answered 8/1, 2013 at 17:26 Comment(2)
I don't understand the question or the answer. Could you elaborate?Tad
It would be nice if you also included a picture of the output from this configuration, instead of just the input of the dialog.Connatural
M
3

Did you set the watch do dump a region of memory? For some structures that helps.

If you can recompile your application, then define this:

type
  T16Values = array[0..15] of Byte;
  P16Values = ^T16Values;

Then cast your pointer into a P16Values, and view that.

If it is another data type than Byte, change the above code accordingly.

Madeira answered 8/1, 2013 at 17:26 Comment(3)
IMHO you don't need that, since the debugger handle custom repetition directly.Gilud
Sometimes it is more convenient to do this at code time, as saving debugger settings requires you to save the whole .DSK, which often results in pain.Madeira
... or just add ,16 to the expression. No need to change the settings. ;)Gilud

© 2022 - 2024 — McMap. All rights reserved.