Go to main content
Oracle® Developer Studio 12.6: Debugging a Program with dbx

Exit Print View

Updated: June 2017
 
 

trace Command

The trace command shows executed source lines, function calls, or variable changes.

The speed of a trace is set using the dbx trace_speed environment variable.

If dbx is in Java mode and you want to set a trace breakpoint in native code, switch to Native mode using the joff command or prefix the trace command with native.

If dbx is in JNI mode and you want to set a trace breakpoint in Java code, prefix the trace command with java.

Syntax

The trace command has the following general syntax:

trace event-specification [modifier]

When the specified event occurs, a trace is printed.

Native Mode Syntax

The following specific syntaxes are valid in native mode:

trace -file filename

Direct all trace output to the specified file name. To revert trace output to standard output use - for filename. Trace output is always appended to filename. It is flushed whenever dbx prompts and when the application has exited. The file is always re-opened on a new run or resumption after an attach.

trace step

Trace each source line, function call, and return.

trace next -in function

Trace each source line while in the specified function.

trace at line-number

Trace given source line.

trace in function

Trace calls to and returns from the specified function.

trace infile filename

Trace calls to and returns from any function in filename.

trace inmember function

Trace calls to any member function named function.

trace infunction function

Trace when any function named function is called.

trace inclass class

Trace calls to any member function of class.

trace change variable

Trace changes to the variable.

where:

filename is the name of the file to which you want trace output sent.

function is the name of a function.

line-number is the number of a source code line.

class is the name of a class.

variable is the name of a variable.

The following modifiers are valid in native mode.

–if condition-expression

The specified event occurs only when condition-expression evaluates to true.

–in function

Execution stops only if the specified event occurs in function.

–count number

Starting at 0, each time the event occurs, the counter is incremented. When number is reached, execution stops and the counter is reset to 0.

–count infinity

Starting at 0, each time the event occurs, the counter is incremented. Execution is not stopped.

–temp

Create a temporary breakpoint that is deleted when the event occurs.

–disable

Create the breakpoint in a disabled state.

–instr

Do instruction-level variation. For example, step becomes instruction-level stepping, and at takes a text address for an argument instead of a line number.

–perm

Make this event permanent across debug. Certain events like breakpoints are not appropriate to be made permanent. delete all will not delete permanent handlers. To delete permanent handlers, use delete hid.

–hidden

Hide the event from the status command. Some import modules might choose to use this. Use status -h to see them.

–lwp lwp-ID

Execution stops only if the specified event occurs in the given LWP.

–thread thread-ID

Execution stops only if the specified event occurs in the given thread.

Java Mode Syntax

The following specific syntaxes are valid in Java mode.

trace -file filename

Direct all trace output to the specified filename. To revert trace output to standard output use - for filename. Trace output is always appended to filename. It is flushed whenever dbxprompts and when the application has exited. The file is always re-opened on a new run or resumption after an attach.

trace at line-number

Trace line-number.

trace at filename.line-number

Trace specified source filename.line-number.

trace in class-name.method-name

Trace calls to and returns from class-name. method-name.

trace in class-name.method-name([parameters]).

Trace calls to and returns from class-name.method-name([parameters]).

trace inmethod class-name.method-name

Trace when any method named class-name.method-name is called.

trace inmethod class-name.method-name[(parameters)]

Trace when any method named class-name.method-name [(parameters)] is called.

where:

class_name is the name of a Java class. You can use either of the following:

  • The package path using a period (.) as a qualifier; for example, test1.extra.T1.Inner

  • The full path name preceded by a pound sign (#) and using slash (/) and dollar sign ($) as qualifiers. For example, #test1/extra/T1$Inner. Enclose class-name in quotation marks if you use the $ qualifier.

filename is the name of a file.

line-number is the number of a source code line.

method-name is the name of a Java method.

parameters are the method’s parameters

The following modifiers are valid in Java mode.

–if condition-expression

The specified event occurs and the trace is printed only when condition-expression evaluates to true.

–count number

Starting at 0, each time the event occurs, the counter is incremented. When number is reached, the trace is printed and the counter is reset to 0.

–count infinity

Starting at 0, each time the event occurs, the counter is incremented. Execution is not stopped.

–temp

Create a temporary breakpoint that is deleted when the event occurs and the trace is printed. If -temp is used with -count, the breakpoint is deleted only when the counter is reset to 0.

–disable

Create the breakpoint in a disabled state.

For a list and the syntax of all events see Setting Event Specifications.