Chris Quenelle is a tools developer at Oracle Corp. He's worked on performance and debugging tools at Sun and Oracle for over 15 years. He reads comic books and science fiction, and has more tivos than he can keep track of.

 

September 2010
S M T W T F S
« Jun    
 1234
567891011
12131415161718
19202122232425
2627282930  

Stopping right before your crash

I just got this question from Steve down the hall.  It’s so mind-bogglingly useful, that everyone who uses dbx needs to know how to do it.  The scenario goes like this. Your program crashes in strcpy sometime in the middle of the run, after about a zillion calls to strcpy.  But you want to stop on entry to the strcpy call which is going to cause the crash.  Here’s how to do it.

(dbx) stop in strcpy -count infinity
(dbx) run
[[ crash ]]
(dbx) status
 (2) stop in strcpy -count 2435/infinity
(dbx) delete all
(dbx) stop in strcpy -count 2435
(dbx) run
(dbx) where
[[ stopped right before the crash ]]

Of course, you can do the same thing in gdb, but I’ll leave that as an exercise for the reader. :-)

http://quenelle.org/unix/wp-content/plugins/sociofluid/images/digg_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/reddit_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/dzone_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/stumbleupon_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/delicious_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/furl_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/technorati_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/facebook_24.png http://quenelle.org/unix/wp-content/plugins/sociofluid/images/twitter_24.png

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>