none
How can I get a stacktrace of the call at runtime? RRS feed

  • Question

  • Hi,

    Is there any way to get the stacktrace at runtime. What I want is the call stack for the function. I had tried creating minidump. but not helping. I am getting the proper call stack from the function in which I create the minidump. I want traces of previous calls which lead to this particular function call.

    To Illustrate, there is a DLL which is used by third party application. Now DLL consist several COM objects. The problem occurs when application tries to access a particular COM object pointer. Basically it throws an exception. What I have to analyze are the traces which I had put in the DLL for debugging purpose. From traces what I can see is, the pointer to the object which third party is trying to access was deleted. This can be confirmed from the traces of FinalRelease() on that object pointer. As per my understanding FinalRelease() is called when the Release() is called on object resulting in reference count reaching zero. Now third party application is not taking the responsibility of the release() call for the pointer. And I don't see any code in implementation of the DLL, which calls Release() on that particular pointer. What I want to trace is, who called Release() which leads to the deletion of the object, resulting into FinalRelease() call. I tried to create a minidump in the FinalRelease() call, but that does not seems to help, as I indicated earlier. 

    I hope this explains the scenario..

    Dhanyawaad(Thanks)

    Tuesday, April 3, 2012 7:11 AM

Answers

  • You could always try StackWalk64. Despite the name, it does work in 32 bit code too.

    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Do you want Visual Studio 11 Express to be freely installable on Windows 7 and able to write regular C++ applications? Please vote for this.

    • Marked as answer by Helen Zhao Tuesday, April 10, 2012 2:20 AM
    Tuesday, April 3, 2012 7:58 AM
  • If you have access to the source for the DLL and are able to build it, you might be able to debug it that way.  Put breakpoints in the DLL source code at the places of interest (for instance, Release()), and then debug the DLL.  This can be done by the DLL project's Property Pages -> Configuration Properties -> Command -> <location of third party executable that dynamically links the DLL>.  This will start the thirdy party application, but allow you to step through your DLL's code when it is called by the third party application.

    • Marked as answer by Helen Zhao Tuesday, April 10, 2012 2:20 AM
    Tuesday, April 3, 2012 6:20 PM

All replies

  • You could always try StackWalk64. Despite the name, it does work in 32 bit code too.

    This is a signature

    Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    Do you want Visual Studio 11 Express to be freely installable on Windows 7 and able to write regular C++ applications? Please vote for this.

    • Marked as answer by Helen Zhao Tuesday, April 10, 2012 2:20 AM
    Tuesday, April 3, 2012 7:58 AM
  • If you have access to the source for the DLL and are able to build it, you might be able to debug it that way.  Put breakpoints in the DLL source code at the places of interest (for instance, Release()), and then debug the DLL.  This can be done by the DLL project's Property Pages -> Configuration Properties -> Command -> <location of third party executable that dynamically links the DLL>.  This will start the thirdy party application, but allow you to step through your DLL's code when it is called by the third party application.

    • Marked as answer by Helen Zhao Tuesday, April 10, 2012 2:20 AM
    Tuesday, April 3, 2012 6:20 PM