By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,538 Members | 875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,538 IT Pros & Developers. It's quick & easy.

how to add a debug hook - via trampoline or direct VTABLE access?

P: n/a
Hi *,

I'm debugging a crash in a very big and complex server application.

This server run's fine for days and hours and suddenly crashes. I've
spent 2 weeks of time now, but cannot find the problem.

I believe that there is a method call with an already deleted objects
causing the crash, something like

SomeClass *obj = new SomeClass();
...
delete obj;
...
obj->somefunction() // infrequently crashed here

The idea I now have is to "catch" access to every method call in a
"debug hook" function.

In this "debug hook" I check the object, and dispatch to the original
method call if the object is valid. If it is not valid, than I have a
breakpoint hit and can do a stacktrace.

Currently I'm using MS Visualt Studio 6, but it is multiple platform
project and it compiles with g++ under Linux too. Thus a solution does
not have to be portable - it is only for debugging purposes.

I have looked around the web and found something called a 'trampoline'
technique used by g++ compilers. That sounds like I need for this
debugging purpose. But I couldn't find/did not understand how to use it.

Another idea I had was to manipulate the VTABLE entry of the base class
and modify it to jump to the "debug hook" function. This should work
because nearly every methods in our classes are virtual methods.

Does anyone have a tip for me? Or other ideas?

thanks a lot for your help, -Hans
Jul 22 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.