Recent

Author Topic: Short call stack inside DLL execution  (Read 8110 times)

Chronos

  • Sr. Member
  • ****
  • Posts: 250
    • PascalClassLibrary
Short call stack inside DLL execution
« on: February 01, 2011, 08:01:36 am »
It is possible to get full call stack if application is paused inside execution of DLL?

Example code:
Code: [Select]
Sleep(1000000);
If program is manually paused during execution of Sleep than Call Stack window show only few lines:
Code: [Select]
#0 ntdll!LdrAccessResource at :0
#1 ntdll!ZwDelayExecution at :0
#2 SleepEx at :0
#3 ?? at :0

There are no information about real placement of original Sleep function calling in own source code.

Same apply to other blocking functions as
 
Code: [Select]
Event.WaitFor(1000000);
pausing shows only

Code: [Select]
#0 ntdll!LdrAccessResource at :0
#1 ntdll!ZwWaitForSingleObject at :0
#2 WaitForSingleObjectEx at :0
#3 ?? at :0
#4 ?? at :0

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12142
  • FPC developer.
Re: Short call stack inside DLL execution
« Reply #1 on: February 01, 2011, 09:35:26 am »
(afaik this also happens in Delphi btw, so might be systematic)

Chronos

  • Sr. Member
  • ****
  • Posts: 250
    • PascalClassLibrary
Re: Short call stack inside DLL execution
« Reply #2 on: February 02, 2011, 08:54:01 am »
Unfortunately stepping through assembler code doesn't always work. But if it does then program continue inside DLL to something like ReleaseMutex where then context is switched to main thread and call stack will show proper information. So solution would be implementing something like "Thread status" window, where all threads will be listed with their id and running status similarly to Delphi. Ability to show call stack for every thread will be useful too.

Chronos

  • Sr. Member
  • ****
  • Posts: 250
    • PascalClassLibrary
Re: Short call stack inside DLL execution
« Reply #3 on: February 10, 2011, 07:52:55 am »
I found out that short call stack is result of not storing compatible stack frame to the stack. It occurs inside function with incompatible stack frame or simply by stepping through assembler on instruction which push or pop something to the stack and thus affect stack frame chain.

Then solution should be to make more intelligent stack passing with ability to do alignment of rest of call stack. But as debugger is not native so far and call stack is read from GDB. So where is no way to do that now. We have to wait for native debugger.


Another problem is assembler stepping. If program is stopped inside Sleep procedure then call stack is not completely visible and stepping is not always successful. Interesting difference is that if Sleep is called from main thread then stepping doesn't work. But if Sleep is called form other thread stepping works and I am able to move forward by few lines where call stack is displayed properly.

This issue need more investigation.

 

TinyPortal © 2005-2018