User`s guide
Tracing Program Execution
67
and watch until it changes. If expression1 is not of type
pointer, look at the 32 bits at that address (assume the
expression evaluates to an address).
To examine the parameters passed to and values returned from a function,
you can trace that function. For example, if the function name is foo, set the
trace by entering:
(dbx) trace foo
When you execute your program, dbx prints the values of the parameters
passed to foo whenever your program calls it. Upon return from foo, dbx
prints the return value:
(dbx) run
[3] calling foo(text = 0x10000484 = "Processing...\n", i =
4) from function main
[4] foo returning -1 from foo
In the example shown above, foo receives two parameters: a character string
variable named text containing the value “Processing...\n” and an integer
variable named i containing the value 4. The trace also indicates that foo
returns a value of -1.
You can also examine a variable as it changes values. For example, you can
monitor the value of a string variable named curarg as you use it to process
an argument list. To set the trace, enter:
(dbx) trace curarg
Process 2395: [6] trace .test.main.curarg in main
When you set a trace on a variable, examine the confirmation that dbx prints.
If you use the same variable name in multiple functions in your program,
dbx may not set the trace on the variable that you want. If dbx sets the trace
on an incorrect variable, delete the trace and set a new trace using a qualified
variable format as described in “Qualifying Variable Names” on page 39.
For more information on deleting traces, see “Deleting Breakpoints, Traces,
and Conditional Commands” on page 73.
So, in this example, if you use the variable curarg in both main and a function
called arg_process, and you want to trace the curarg in arg_process, first
delete this trace and then set a new trace:
(dbx) delete 6