Simplifying debugging

One thing that makes debugging really difficult in imperative languages like C++, Java, C#, etc, is the use of state. If I'm in the debugger and I notice that a variable has the wrong value, it can sometimes be very difficult to figure out where that value came from. For local variables, this isn't usually much of a problem -- I can just page up and see where the variable got assigned. But for global variables, or even for class member variables, it can be a real pain.

It occurs to me that it would be useful if my debugger could let me time-warp back to the place and time where any given variable was assigned. To do this, it would have to store a stack trace with each and every non-local variable. For languages that already store activation records on the heap (e.g. to support closures and continuations), this should be almost trivial. It would increase memory usage quite a bit, but when I'm debugging the cost would be well worth it.

It would be an interesting project to try to hack something like this into Python or Ruby (I hear Perl internals are a mess, so I wouldn't even consider trying it with Perl).

Followups to Simplifying debugging:

Posted on July 23, 2003 02:19 PM
More programming articles

Comments

Been there, done that.

I worked on the design of a single board computer that enabled this. It used the debugging ports in Xilink to dump the bitwise state even! Down side, drowns the user in more debugging info that maybe they should have.

Posted by: BPolant at July 23, 2003 04:38 PM

Surely you jest. This is just a trace/tie
and caller fn. Very easy in perl or tcl, but hard
in C (I would think it woudn't be too hard
in JAVA). I don't know enough to comment on
RUBY or Python.

Posted by: Kris at July 23, 2003 11:38 PM

Kris, the point would be to have the debugger do this without requiring the source to be modified. It sounds like your solution would require a code hack for each variable you want to trace, right? That would take so much time that it would make the technique only useful as a last resort for really difficult problems. I'd rather use it as a routine debugging technique that lets me avoid having to think about state at all. Kind of like using etags to jump to a function definition -- sure I could use grep instead, but if it's just a simple keystroke, it makes it qualitatively nicer and much easier on the brain. I'm all about making things easier on my brain these days -- I simply don't have enough motivation to pay attention to stuff that bores me.

Posted by: kim at July 24, 2003 10:42 AM

The ocaml programming language comes with a time-travelling debugger. You can run your program until you find the problem, then go back in time to see what caused it. I think it works behind-the-scenes by fork()ing the process, and assuming that copy-on-write keep the memory usage tolerable.

Posted by: Andrew Birkett at July 24, 2003 12:46 PM

There was a discussion on Lambda The Ultimate about this very topic a while ago. It was inspired by my finding this tool which provides the exact functionality you were talking about.

Posted by: ade at July 26, 2003 06:23 AM

Watching the history of the state is a good idea I think (via extensive "flight recorder" tracing) and integration with the debugger.

Check out http://blog.monstuff.com/archives/000035.html.

Java has such debuggers, as a reader commented already. They also will be possible in .NET, because similar instrumentation is possible, as my experiments show (see http://blog.monstuff.com/archives/000058.html and following posts).

Posted by: Dumky at July 28, 2003 06:06 PM

Zstep sounds like yet another solution. You could take a look at http://web.media.mit.edu/~lieber/Lieberary/ZStep/ZStep-SoftViz/ZStep-SoftViz.html

Posted by: ryan at August 24, 2003 08:30 AM

mec-replay also is intended for time-travel debugging.

Posted by: Kragen Sitaker at April 13, 2005 08:05 PM

People all over the world know the abercrombie and fitch,but not everyone really knows how fashion the abercrombie is,hollister is the Legend maker. Everybody wears the hollister clothing would be the abercrombie mensand the abercrombie womens, if you want know you can search the Ruehl No.925 or abercrombie outlet in the www.google.com .

Posted by: anf at November 13, 2009 12:34 AM

Louis Vuitton , commonly referred to as LV Comes First In 2009 World's Top Ten Brands and Mother Shopping With LV Bag!, or sometimes shortened to Journey On LV has become one of the most Sofia Coppola Design Louis Vuitton Bags Agendas luxurybrands Louis Vuitton Flagship Store Opened In California.

Posted by: 1 at November 17, 2009 01:23 AM

UGG Bailey Button bootsis a new style in 2009.The classic cardy uggs boots is another hot boots that worth of buying.And the classic tall ugg boots will make your winter amusing.And now uggs on sale,if you are looking for such a boot,the ugg boots is good choice this year.

Posted by: uggs on sale at November 17, 2009 08:30 PM

Uggs on sale now.Classic cardy boots ugg is a special boot that makes you different from the other girls.And the Bailey Button UGGs is hot in 2009.If you want to get a warm shoe in cold winter,I think ugg classic tall boots is a good choice for you.

Posted by: ugg classic cardy boots at November 17, 2009 09:00 PM

We are the best online sales for the china wholesale . Here you can have a large of choices of kinds Ugg Boots,Converse Shoes,Timberland Boots,puma shoes,Nike Shox Shoes ,Nike Dunk SB Shoes,Nike Air Max,Links Of London,Tiffany Jewelry,Dior Handbags?,jimmy choo handbags ,Cartier Watches, 8GB Mp4 Players,Bluetooth Car DVDs. All our cheap online cheap goods are high quality and original packages, and best service. We offer our customers the best service, 7 days arrive at your door.Enjoy your easy and happy shopping with us.

Posted by: cheap goods sale. at November 20, 2009 01:52 AM

Laptop Battery Laptop Battery Laptop Batteries
Laptop Batteries discount laptop battery
discount laptop battery
notebook battery notebook battery
computer battery computer battery
replacement laptop battery replacement laptop battery
notebook batteries notebook batteries

Posted by: Laptop Battery at November 23, 2009 09:56 PM

We are the best online sales for the china wholesale . Here you can have a large of choices of kinds cheap ugg classic tall boots on sale, tiffany & co jewelry,tiffany and co silver earrings,tiffany cheap silver rings,mbt shoes on sale.All our cheap online cheap goods are high quality and original packages, and best service. We offer our customers the best service, 7 days arrive at your door.Enjoy your easy and happy shopping with us.

Posted by: China Wholesale at November 27, 2009 04:24 AM

Just wanted to say great job with the blog, today is my first visit here and I’ve enjoyed reading your posts so far
ugg bailey button
Wow, my ugg classic mini will not be coming off now! I’ve had them on for 12hrs strait and I do not want to take them off. Thanks for everything, well worth the wait.

Posted by: ugg bailey button boots at November 30, 2009 06:33 AM

Now more and more young people love to wear puma running shoes,due to the puma shoes make you feel more comfortable and more fashionable,buy cheap puma shoes online that you could go to www.ilovepuma.com the puma store to buy
Puma Future Cat,
fluxion ii
or cat puma shoes,high quality and best sprice with free shipping.

Posted by: puma running shoes at November 30, 2009 12:38 PM

Spring is near,every girl wants to be the bride in the special season.They are eager to put on beautiful Wedding Dresses or the Bridal gowns.During the day the Wedding gowns is the good choose,and the night,if you want radiant,you need the Evening gowns.
About the bridesmaid,they have to wear Bridesmaid Dresses in order to avoid grab limelight with the bride.And the Flower Girl has the Flower Girl Dresses,too.In the wedding,the Cocktail Dresses and the Evening Dresses is necessary,too!And remember,the Wedding Dress of the Bridal Dress must be the most glaring!

Posted by: weddingdressclub at December 1, 2009 12:15 AM
Post a comment









Remember info?




Prove you're human. Type "human":