DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
dbXtra and dbxtra

Monitoring the contents of variables

The dbxtra commands when, trace, and stop monitor the contents of a program's variables. The trace and stop commands are not as robust as the when command. For further details see ``Events menu: managing execution time events''.

In our Bridge example, the variable cardsleft is passed to the function Deal(). It may be a good idea to have the value of cardsleft printed out every time the call to Deal(), at line 49, is made. To do this use the when command. At the (dbxtra) prompt, enter:

   (dbxtra) when at 49 {print "at 49: cardsleft = ", cardsleft;}
   [1] when at "deal.c":49 { print "at 49: cardsleft = ",
   deal.deal_hands.cardsleft;}
dbxtra acknowledges your command, and automatically prepends the names of the blocks containing the variable to the variable name and the filename to the line number. Notice the W beside line 49; this indicates a when has been issued for this function.

To verify how a variable is monitored, use the status command:

   (dbxtra) status
   [1] when at "deal.c":49 { print "at 49: cardsleft = ",
   deal.deal_hands.cardsleft;}
There are two things to note here: Now let's run a.out to see what happens:
   (dbxtra) run
   Dealing 1 hands...
   at 49: cardsleft = 52
   at 49: cardsleft = 39
   at 49: cardsleft = 26
   at 49: cardsleft = 13
   at 49: cardsleft = 0
   Floating point exception in Deal at line 66 in file "deal.c"

Next topic: Analyzing the results
Previous topic: Traversing the call stack

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003