Chapter 9. Debugger Command Line

You can debug programs by entering dbx-style commands at the cvd> prompt found at the bottom of the Main View window (see Figure 1-1). For more information, refer to the dbx User's Guide.

In the following text, F+C indicates that the command also applies to Fix+Continue code. In F+C code, line numbers are expressed in decimal notation (for example, 5.3 indicates that line 5 is the start of a function in the original source code and 3 is line 3 of that function in F+C). See Chapter 8, “Fix+Continue Windows” and information about Fix+Continue in the ProDev WorkShop: Debugger User's Guide for more details.


Note: Only applications compiled with -32 and -n32 options can use Fix+Continue features.


Syntax for Commands

The syntax for the debugging commands is as follows:

add_source [filename: [ line_number] [,line_number]]
 

F+C

For C and C++ only, when compiled with -o32.

Prompts you to add source code lines (for example, add_source "fmain.c":15.2). line_number must be within the body of a function. Entering a period (.) specifies the end of your input. The source lines you provide are added after the specified line. This command returns an ID existing or new, depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time. See also delete_source and replace_source.

alias [shortform command]
 

Lists all aliases without arguments. With arguments, it assigns command to shortform.

assign expression1= expression2
 

Assigns expression2 to expression1.

attach pid
 

Attaches to specified process ID (pid).

call function_name[argument, argument]
 

Executes the specified function with any arguments supplied. The syntax of the call should be that of the source language of the application in use, such as C, C++, or Fortran.

catch [signal_name | all ]
 

With no arguments, lists signals to be breakpointed. If a signal is specified, it is added to the list. If all is specified, the debuggert traps all signals.

clearcalls
 

Cancels interactive function calls that are currently active (that is, interactive function calls that are stopped on a breakpoint or watchpoint).

cont in function_name
 

Continues execution from the current line to the entry to the specified function.

cont to line_number
 

Continues execution from the current line until the specified line, if there is not an intervening breakpoint to stop execution.

continue [all]
 

Continues executing a program, or all processes, after a breakpoint. You can use both c and cont as aliases for continue.

continue [signal]
 

Sends specified signal and continues executing a program after a breakpoint.

corefile [filename]
 

With no arguments, reports whether data referencing commands reference a core file. If so, displays the current core file. With filename provided, specifies core file to be debugged.

delete [all | [bp_number] ,[bpp_number], ...]
 

Deletes all breakpoint(s). The all option deletes all breakpoints.

delete_changes [[func_spec | -all] | [-file filename]]
 

F+C

For C and C++ only when compiled with -o32.

Deletes changes corresponding to the selected functions (for example, delete_changes getNumbers -file fmain.c). Once IDs are deleted, you cannot use the IDs again because the IDs associated with the selected functions are released. The default is -all. See also save_changes.

delete_source [filename: [line_number ] [,line_number]]
 

F+C

For C and C++ only, when compiled with -o32.

Deletes the given line(s) if line_number or ,line_number (range) is within the body of a function. An example is:

delete_source "fmain.c":8.6,8.7

This command returns an ID existing or new, depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time.

delete bp_number [, bp_number, ...]
 

Deletes the specified breakpoint numbered bp_number , as obtained from the status command.

detach
 

Detaches from the current process.

disable all
 

Deactivates all traps.

disable_changes [[func_spec | -all] | [-file filename]]
 

F+C

For C and C++ only, when compiled with -o32.

Disables specified changes for selected functions (for example, disable_changes getNumbers -file fmain.c. Nothing happens if the selected function is already disabled. The compiled definition of the function is executed on its next entry. You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set.

disable bp_number [, bp_number, ...]
 

Deactivates the specified breakpoint numbered bp_number, as obtained from the status command.

display [expression, ... ]
 

With expression, adds expression to the list of expressions displayed whenever the process stops. With no arguments, lists all expressions. See undisplay to delete an expression.

down [number]
 

Moves down the specified number of frames in the call stack. down moves away from the direction of the caller toward the most deeply nested function called..

dump
 

Prints local variable values in the visible scopes in the currently active function..

enable all
 

Reactivates all inactive breakpoints.

enable_changes [func_spec | -all] | [-file filename]
 

F+C

For C and C++ only when compiled with -o32.

Enables specified changes for selected functions (for example, enable_changes getNumbers -file fmain.c). Nothing happens if the selected function is already enabled. The latest accepted definition of the function is redefined on its next entry. You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set.

enable bp_number [[ ,bp_number, ...]
 

Reactivates the specified breakpoint numbered bp_number, as shown by the status command.

expression/[count] [ format] or expression, [ count] / [format]
 

Prints the contents of the memory address specified by expression, according to the specified format. count represents the number of formatted items. The following format options are available:

d 

Prints a 16-bit word in decimal.

D 

Prints a 32-bit word in decimal.

o 

Prints a 16-bit word in octal.

O 

Prints a 32-bit word in octal.

x 

Prints a 16-bit word in hexadecimal.

X 

Prints a 32-bit word in hexadecimal.

b 

Prints a byte in octal.

c 

Prints a byte as a character.

s 

Prints a string of characters that ends in a null byte.

f 

Prints a single-precision real number (32-bit floating point).

g 

Prints a double-precision real number (64-bit floating point).

file [filename]
 

Displays the name of the current or specified file ( filename). If a file is specified, it becomes the current file.

func [func_name]
 

Moves to the source code corresponding to the specified frame in the call stack or to the function in the executable if not on the stack.

givenfile [filename]
 

With no arguments, displays name of current object file. With filename, specifies the executable to be debugged.

goto linenumber
 

Skips over lines going directly to the specified line number in the current routine. Unlike dbx(1), cvd(1) does not begin execution at the specified line.

help
 

Displays syntax information for the cvd command.

ignore[signal_name | all ]
 

With no arguments, lists those signals not to be breakpointed/trapped. If a signal is specified, this command removes it from the list of signals to be breakpointed/trapped. If all is specified, ignores all signals.

kill[pid | all]
 

Kills the specified process currently controlled by the Debugger or kills all processes.

list [from-line[ :line_count]][, to_line]|[function_name]
 

Lists source lines beginning at line number from-line. If no additional argument is specified, the default for line_count is 10. If line_count is specified, a total of line_count lines are listed. If function_name is specified, the lines from the given function are listed.

list_changes [func_spec | -all] | [-file filename]
 

F+C

Lists one or more lines using the following syntax:

change_id isEnabled filename function_spec 

For example:

4 enabled foo.c foo
8 disabled A.c++ A::bingo

The default is list_changes -all.

next [int]
 

Steps over the specified number of source lines. This command does not step into procedures. The default is one line.

nexti [int]
 

Steps over the specified number of machine instructions. This command does not step into procedures. The default is one instruction.

print expression [, expression, ...]
 

Prints the value of the specified expression(s). If the expression is a character pointer or array, both the string and address print. Uuse p as an alias.

printd expression [, expression, ...]
 

Prints the value of the specified expression(s) in decimal format. Use pd as an alias.

printf string [, expression1 [, expression2, ]... ]
 

Prints the value(s) of the specified expression(s) in the format specified by the string string. The printf command supports all formats of the IRIX printf command except %s. For a list of formats, see the printf(1) man page.

printo expression [, expression, ...]
 

Prints the value of the specified expression(s) in octal format. You can use po as an alias.

printregs
 

Prints the contents of all of the registers.

printx expression [, expression, ...]
 

Prints the value of the specified expression(s) in hexadecimal format. Use px as an alias.

privateProject
 

Used when running multiple cvd sessions simultaneously. This prevents one cvd session from being confused with anotoher cvd session.

pwd
 

Displays the current directory.

quit
 

Exits the debugging session.

redefine [func_spec [ -edit | -read] filename [ line_number,line_number]]
 

F+C

For C and C++ only.

Specifies a new body for a function. The new definition is checked, and errors (if any) are printed. The new function body is redefined on the next function entry. Breakpoints (if set) on the old definition are put on the new definition based on their relative line number position from the beginning of the function definition. (Note that some breakpoints may not make it to the new definition.) You can invoke this command when the process is stopped or on a running process when a function entry breakpoint is set. There are three ways to provide a new definition:

  • -edit pops up an editor of your choice containing the current definition of the function. The specification of the new definition is complete when you exit the editor. You may not leave the editor open.

  • -read takes the contents of the file specified (within the line numbers if given) as the new function definition.

  • No option allows you to type in replacement code from the next line. A period in the first column on a fresh line terminates the definition. For example:

    redefine getNums
    "/usr/fmain.c”:8.1> {
    "/usr/fmain.c”:8.2> printf(“In getNums.\n”);
    "/usr/fmain.c”:8.3> }
    "/usr/fmain.c”:8.4> .

replace_source [filename: [ line_number] [,line_number]]
 

F+C

For C and C++ only when compiled with -o32.)

Prompts you to type in replacement source if line_number or ,line_number (range) is within the body of a function. The source lines you provide replace the specified line(s). An example is: replace_source "fmain.c":12. This command returns an existing or new id depending on whether the function affected has already been changed or not. The resulting new definition of the function is executed on its entry next time. See also add_source and delete_source.

rerun
 

Runs the program again using the same arguments.

return
 

Continues executing the current procedure and returns to the next sequential line in the calling function.

run [[all] | argument_list ]
 

Runs the program(s). If an argument_list is specified, it is used as the arguments to be supplied to the program.

runtime_check func_spec [ -options key [key,... ]]
 

F+C

For C and C++ only when compiled with -o32.

Enables all run-time checking options by default. If -options is specified, then run-time checking is restricted to the keys. The result of the runtime checks are printed the next time the specified function (func_spec) is entered. You can invoke this command on a stopped or a running process.

save_changes {func_spec| {-file filename}} [-[w|a]] filename_to_save
 

F+C

For C and C++ only when compiled with -o32.

Saves (enabled or disabled) function redefinitions or an entire file to another file (filename_to_save). The following example shows how to save a function definition:

save_changes getNumbers getNumbersFunc   

If you specify the -file option, then before saving to filename_to_save, all function changes are applied to the compiled source of the file (with the condition that the file has had only its functions redefined, and has not been edited since the last build). An example of saving an entire file is the following:

save_changes -file fmain.c fmain.c

The -w option replaces the filename_to_save . The -a option appends to the filename_to_save. An example of adding a function to a file is the following:

save_changes -file fmain.c -a fmain.c

See also delete_changes.

setbuildenv [filename] compiler-flag-list
 

F+C

For C and C++ only, when compiled with -o32.

Overrides default build environment flags (compiler options). Without filename, the flags are passed along with -c -g flags to the compiler for any function in any file except those set separately with setbuildenv. An example is the following:

setbuildenv -DnameA -Idir

If filename is given, this command sets separate flags specifically for that file. For example, consider the following:

setbuildenv "fermat.c" -DnameB -Ianotherdir

See also unsetbuildenv.

sh [shell_command]
 

Calls a shell if no arguments; otherwise, executes the specified shell command.

showbuildenv [filename]
 

F+C

For C and C++ only, when compiled with -o32.

Lists all the build environment flags set. showbuildenv with a filename lists any build environment specifications that have been set separately with setbuildenv "filename".

show_changes [func_spec | -all |[-file filename]]
 

F+C

For C and C++ only, when compiled with -o32.

Prints the code of all enabled redefinitions of the specified function(s). The default is show_changes -all. See also enable_changes and disable_changes.

show_diff [func_spec | [ -file filename]]
 

F+C

For C and C++ only, when compiled with -o32.

Launches a xdiff comparing the compiled source and its latest redefinition for the specified function. If -file filename is specified, xdiff shows the difference between the compiled file and the file with all redefinitions applied to the compiled source of the file (with the condition that the file has had only its functions redefined, and has not been edited since the last build).

showthread [full] [thread] [ number | all]
 

Shows brief status information about threads. If full is specified, prints full status information. You can request status information for a specific thread by number or you can request information for all threads. The thread qualifier does not affect command output. It is effectively a 'noise' word here, though allowed for consistency with other commands where the thread qualifier is needed to specify a particiular thread.

source filename
 

Executes commands in the specified file as if those commands were typed on the command line..

status
 

Displays a list of currently set breakpoints and traces.

step [int]
 

Steps the specified number of source lines. This command steps into procedures. The default is one line.

stepi [int]
 

Steps the specified number of machine instructions. This command steps into procedures. The default is one instruction.

stop [all | pgrp] in [ filename]
 

If set to all, stops all members of the specified process group whenever the trap is encountered. If set to pgrp, all members of the process group apply the trap.

stop at [file] [ filename] [line] [ line_number] [if expression ]
 

Sets a breakpoint at the specified line in the specified file. If the if option is used, the breakpoint fires only if expression is true. If specified, the file name must be enclosed in double-quotation marks. As an example, to specify a stop at line 5 in myfile.c, the syntax is:

stop at "myfile.c":5

stop exception [all | item]}
 

Sets a breakpoint on all C++ exceptions or exceptions that throw the base type item. Do not include complex expressions using operators such as * and & in your type specification for an exception breakpoint.

stop exception [all | [item] [ , item]]
 

Sets a breakpoint on all C++ exceptions or exceptions that either have no handler or are caught by an unexpected handler. If you specify item, stops on exceptions that throw the base type item . Do not include complex expressions using operators such as * and & in your type specification for an exception breakpoint.

stop in [filename:] function_name [if expression]
 

Sets a breakpoint at the entry to the specified function. If the if option is used, then the breakpoint fires only if expression is true. If the filename is given, the function is assumed to be in that file's scope. If specified, the filename must be enclosed in double-quotation marks. As an example, to specify a stop in function func1 in myfile.f only if n is 20, the syntax is:

stop in "myfile.f":func1 if n .eq. 20

syscall [catch | ignore] [call | return] [sys_call_name | all ]
 

The catch option adds a system call to the list of system calls to be breakpointed. The ignore option removes a system call from the system call breakpoint list. The call option specifies the entry to the system call and return signifies the return from the call.

trace [[[variable] at filename] | line_number | function_name] [ if expression]
 

Traces the specified variable. You can specify a file and/or test condition. You can also specify a line number or a function where the trace is to take place. If expression is allowed, only a variable, line number, or function name is typed (that is, trace if ==3 is not allowed).

unalias aliasname
 

Cancels the alias specified as aliasname.

undisplay [[displaynumber, ...]
 

Stops display of expression with specified displaynumber when the process stops. Removes the expression from the display list.

unsetbuildenv[filename]
 

F+C

For C and C++ only, when compiled with -o32.

Disregards the default build environment flags if specified earlier. For all functions in files that don't have an overriding build environment, unsetbuildenv passes only the -c and -g flags.

If filename is given, this command disregards the build environment flags specified for the file earlier. Further redefinition of the functions in the file use the default build environment flags, if set. See also setbuildenv.

up [number]
 

Moves up the specified number of frames in the call stack. up moves in the direction of the caller.

use [path]
 

Uses the specified path to search for source files.

watch identifier [write | read]
 

Causes program to stop when the identifier is written or read, depending on whether write or read is specified. If neither is specified, the default is write.

whatis identifier
 

Displays the type information of the specified variable or function.

when at [filename] [ line_number] [command] [ command] ...
 

When your program reaches the specified line_number , the commands specified are executed (the program resumes execution automatically).

when in [filename] function_name [command] [ command] ...
 

When your program enters the specified function, the commands specified are executed before the program resumes execution.

which [identifier]
 

Displays the qualification of the specified variable.

where [thread | thread-id] [n]
 

Performs a stack trace showing the activation levels of a program or, optionally, of the specified thread. You can obtain thread-ids from the first column of output of the showthread command. n is the number of levels for the output.