Page 1 of 1

[PB4.30 x86] Debugger can't handle Interfaces

Posted: Mon May 04, 2009 9:12 pm
by Deeem2031
This is a small example of Interfaces:

Code: Select all

Interface tmpI
  p1()
  p2()
  p3()
  p4()
EndInterface

Procedure Dummy()
  Static c
  c + 1
  Debug Str(c)+"!"
EndProcedure



*VarI = AllocateMemory(SizeOf(tmpI))
PokeI(*VarI + OffsetOf(tmpI\p1()), @Dummy())
PokeI(*VarI + OffsetOf(tmpI\p2()), @Dummy())
PokeI(*VarI + OffsetOf(tmpI\p3()), @Dummy())
PokeI(*VarI + OffsetOf(tmpI\p4()), @Dummy())
*pVarI.tmpI = @*VarI

*pVarI\p1()
*pVarI\p2()
*pVarI\p3()
*pVarI\p4()
CallDebugger
It works fine, but the debugger can't read the procedure addresses inside the Interface.
I mean the values given when you stop the mouse over *pVarI.
They are something like p1 = 26783256, p2 = 407603, p3 = 4, p4 = 1 but they should be all the same because they all point to Dummy().
The problem is that the debugger has no information about if "tmpI" is a structure or an interface but structure fields are saved directly at the pointed memory - pointer to interfaces point to an pointer which points to the procedureaddresses.

Posted: Tue May 05, 2009 12:51 am
by Demivec
Confirmed.

Also noted is that the debugger actually can't display any interface information. The information it displays in the code above is because it thinks of *pVariI.tmpI as a pointer to a structure. It displays the wrong values because of this (as noted previously). If the "*" is removed from the variable name the debugger can't identify it at all (even though the code executes properly) and will display a message to that effect when it is highlighted.

Since an interface contains a procedure address, and a procedure's address isn't shown either when you point to it in the debugger it doesn't seem to be logical or implied that the address of the procedure in an interface should be displayed either.

This would probably fall under the category of a feature request. I would still consider it as a bug, the misinterpretation of an interface that uses "*" in its name as a pointer to a structure.