2

I'm working on a large software project which makes use of the 'with' command and I am having difficulty with debugging.

Take the following code as an example:

with record do
begin
 record_property = 'some value'; 
end;

If I am debugging this code and I want to see the value of record_property I have to add a watch on record.record_property, even if I am paused within the 'with' block. Is there a setting or add-on for Delphi 7 which allows the scope created by a 'with' block to carry over into the watch window?

This would make my life a lot easier as there are many cases of nested 'with' blocks which make it difficult to figure out how to add watches.

4

1 回答 1

7

with语句中使用的记录指针(很可能)被加载到eax寄存器中。

在该record_property = 'some value'行命中断点后,您可以通过以下方式获取记录实例

  • 打开装配窗口 ( CtrlAltc)
  • 一步将指针加载到eax
  • 评估表达式TMyRecordType(pointer(eax)^)

或少一步(根据屏幕截图)

  • 打开装配窗口 ( CtrlAltc)
  • 评估表达式TMyRecordType(pointer(integer(ebp)-4)^)

将 TMyRecordType 替换为您的记录的实际类型


以上将是我第一次快速尝试获取您感兴趣的值。

如果这不起作用,除了打开 CPU 窗口并查看记录指针被加载的寄存器之外,我看不到任何其他选项。

在此处输入图像描述


编辑

要将监视添加到您的记录变量,您不能依赖易失性eax寄存器。您必须在手表中获取内容eax并使用它。

  • 在评估窗口中eax使用获取内容Pointer(eax)
  • 在监视表达式中使用该地址:例如。TMyRecordType(pointer($4A3DB8)^)
于 2013-10-15T10:39:15.447 回答