Recent

Author Topic: Suggestion - result function call  (Read 4042 times)

Borneq

  • Full Member
  • ***
  • Posts: 248
Suggestion - result function call
« on: April 13, 2013, 12:49:25 am »
Is possible to inspect not only function address but result of function call, it is generally needed to properties inspecting.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11361
  • Debugger - SynEdit - and more
    • wiki
Re: Suggestion - result function call
« Reply #1 on: April 13, 2013, 01:38:20 am »
AFAIK, unfortunately GDB does not currently support that for pascal.
That is IIRC, someone managed to have GDB call a procedure that had no (zero) parameters.

But properties are on objects., so they have (at least) the self pointer as hidden param.

Functions also must return the result. And if that is not fitting into a register, then it goes on the stack too.

Not sure, if properties can point to methods with none default calling convention (cdecl or other). If so, that needs to be detected too.

[[[
And if a string (or dyn array) is returned, it causes a memory leak. (or changes the program flow, if the app relies on the string being freed). This is unless the fpc functions for changing ref counts are compiled with debug symbols, and a way can be found to call them too.

The last paragraph can be ignored. Since it is well known to any one inspecting properties with read-via-functions that they can change the state of the app (e.g. allocate a handle)
]]]

---
If you know how to call a property from gdb let me know. Then it can be done. That must include how to get the result.

---
This has been a very long standing problem.


Borneq

  • Full Member
  • ***
  • Posts: 248
Re: Suggestion - result function call
« Reply #2 on: April 13, 2013, 09:41:53 am »
Maybe GDB need this function call extension.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11361
  • Debugger - SynEdit - and more
    • wiki
Re: Suggestion - result function call
« Reply #3 on: April 13, 2013, 02:41:10 pm »
Saw your post on the GDB list.

Some more info:

FPC does currently not add properties to debug info. [1]

I was told (I have not checked myself) that this is because dwarf 2 does not have a representation for pascal like properties.

I am not sure if dwarf3 (or 4) has. But dwarf 3 is not yet stable if used between gdb (even using the advanced archer branch) and fpc. I did tests on that, and always ended with a gdb crash.

So even if you get functions to work (I am not even sure what the state is now, I said afaik, it is a while I last looked into that), there still is a long way to go for properties.


----
[1] Except, if they read a field directly without getter function. In that case the property is added as a field, not as a property. (That affects how writing is handled, it ommits the sotter if present)

 

TinyPortal © 2005-2018