DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
adb: absolute debugger

An example: simple formatting

The following example illustrates how to combine formats in ? or / commands to display different types of values when stored together in the same program. This program has the following source statements:

   char	str1[ ]	= "This is a character string" ;
   int	one	 	= 1 ;
   int	number	= 456 ;
   long	lnum		= 1234 ;
   float	fpt		= 1.25 ;
   char	str2[ ]	= "This is the second character string" ;
   

main() { one = 2; }

The program is compiled and stored in a file named sample. To start the session, type:
   adb sample -
To display the value of each individual variable by specifying its name and corresponding format in a / command. For example:
   str1/s
displays the contents of str1 as a string:
   str1:	This is a character string
The following command:
   number/d
displays the contents of number as a decimal integer:
   number:	456.
You can choose to view a variable in a variety of formats. For example, you can display the long variable lnum as a 4-byte decimal, octal, and hexadecimal number by typing the following:
   lnum/D
   lnum:	1234
   lnum/O
   lnum:	02322
   lnum/X
   lnum:	0x4d2
You can also examine all variables as a whole. For example, if you wish to see them all in hexadecimal, type:
   str1,5/8x
This command displays eight hexadecimal values on a line, and continues for five lines.

Since the data contains a combination of numeric and string values, it is worthwhile to display each value as both a number and a character to see where the actual strings are located. You can do this with one command by typing:

   str1,5/4x4^8Cn
In this case, the command displays four values in hexadecimal, then the same values as eight ASCII characters. The caret (^) is used four times, immediately before displaying the characters to set the current address back to the starting address for that line.

To make the display easier to read, insert a tab between the values and characters, and give an address for each line, for example:

   str1,5/4x4^8t8Cna

Next topic: Debugging program execution
Previous topic: Using the ? and / commands

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