The SAS/C Debugger — Command and Built-in Function Reference

cdbg's command-line interface follows a GDB-influenced style, extended with AREXX built-in functions for scripting. Vol 2 Ch.9 is the canonical reference. This article summarizes the commands most useful in everyday debugging; the full reference is in the manual.

Command syntax

(cdbg) [count] command [args...]

A count repeats the command: 3 step is equivalent to three step commands. Commands may be abbreviated to their shortest unambiguous prefix: b = break, c = continue, p = print.

Command output goes to the command window. Output redirection:

(cdbg) set logging file session.log
(cdbg) set logging on
(cdbg) print big_struct
(cdbg) set logging off

Execution control

Command Args Effect
step [count] Single-step into function calls
next [count] Single-step over function calls (don't enter callees)
finish Run until current function returns
until line Run until source line
continue [count] Resume execution; with count, ignore next N breakpoint hits
stop Halt the running program (sends SIGBREAKF_CTRL_C)
run [args...] Restart the program from the beginning
kill Terminate the program (without exiting cdbg)
quit Exit cdbg

continue is the most-used command — c is the standard abbreviation.

Breakpoints and watchpoints

Command Args Effect
break function Break at function entry
break file:line Break at source line
break *address Break at absolute address
break cond Break on condition (e.g., break Open if argc > 1)
tbreak same as break Temporary breakpoint (deleted after first hit)
delete [N] Delete breakpoint N (or all if N omitted)
disable [N] Disable breakpoint N (keep but don't trigger)
enable [N] Enable a previously disabled breakpoint
condition N expr Add/modify condition on breakpoint N
ignore N count Skip the next count hits of breakpoint N
commands N Run a list of commands when breakpoint N hits
watch expr Break on write to expression
rwatch expr Break on read of expression
awatch expr Break on either read or write
info breakpoints List all breakpoints

Inspection

Command Args Effect
print expr Evaluate and print expression (alias: p)
whatis name Show the type of name
info subcommand Generic info (see below)
list [line \| func] Show source code around line or function
disassemble [addr] Disassemble from address
x [/fmt] addr Examine memory at address (e.g., x/16xb 0x1000)
set var=expr Modify a variable in the program
call func(args) Call a function in the program (use with care)
return expr Force the current function to return expr

info subcommands:

Subcommand Reports
info registers CPU registers (D0–D7, A0–A7, SR, PC)
info breakpoints All breakpoints
info locals Local variables of current frame
info args Arguments of current function
info tasks All known tasks (multitasking)
info task Details of one task
info threads Alias for info tasks
info sharedlibrary Loaded shared libraries
info source Current source file and line
info sources All source files loaded
info functions All known functions
info variables All known variables
info address Address of a symbol
info symbol Symbol at an address

Stack

Command Effect
backtrace Show call stack (alias: bt)
frame N Select frame N (default 0 = innermost)
up Move to caller's frame
down Move to called frame
info frame Details of current frame
info args Arguments of current frame
info locals Local variables of current frame

Memory examination

x is the most flexible inspection command. Format specs follow GDB conventions:

(cdbg) x/16xb 0x1000          # 16 bytes in hex at 0x1000
(cdbg) x/8xw 0x2000           # 8 words (16-bit) in hex
(cdbg) x/4xw ptr              # 4 words starting at address stored in ptr
(cdbg) x/1xg &big_struct      # 1 giant (8-byte) word — useful for 64-bit values

Format letters:

Letter Unit Print as
b byte hex
h halfword (2 bytes) hex
w word (4 bytes) hex
g giant word (8 bytes) hex
d unit decimal
i unit instruction (disassembly)
s null-terminated string ASCII

Multitasking

Command Effect
task [N] Switch to task N (current task is implicit in subsequent commands)
info tasks List all tasks and their state
signal tid sigmask Send signal to task
stop tid Stop a specific task (others continue)
continue tid Resume a specific task

AREXX built-in functions

These are invoked from an AREXX script (address CDBG) or from a cdbg macro file:

Function Returns Description
BREAK(loc) rc Set breakpoint at loc (function, file:line, or address)
CLEAR(N) rc Delete breakpoint N
CONTINUE() rc Resume execution
EVALUATE(expr) result string Evaluate expression, return as string
PRINT(expr) rc Print expression to log
SET(var, value) rc Set debugger variable
STEP(N) rc Step N times
WAITFORSTOP(timeout) rc Block up to timeout seconds for the program to stop; rc=0 on stop
QUIT() — Exit cdbg

A typical regression test pattern (ARexx):

ADDRESS CDBG
'BREAK main'
'CONTINUE'
rc = WAITFORSTOP(30)
if rc \= 0 then call err 'no stop in main'
'STEP 5'
'PRINT result'
expected = EVALUATE('result')
if expected \= '42' then call err 'wrong result'
'CONTINUE'
rc = WAITFORSTOP(60)
'QUIT'
return 0

err: say 'FAIL:' arg(1); exit 10

Custom commands

cdbg supports user-defined commands via the define directive (Vol 2 Ch.9):

(cdbg) define mycmd
> print *ptr
> print i
> continue
> end
(cdbg) mycmd

The define block runs as a macro whenever the command name is invoked. document adds a help string:

(cdbg) document mycmd
> Prints *ptr and i, then continues.
> end

Configuration files

cdbg reads S:cdbg.config at startup (or the file named in CDBG_CONFIG). The config file is a sequence of cdbg commands:

set listsize 10
set print elements 20
set print pretty on
set logging file cdbg.log
define reload source myfile.c
end

A project's Makefile/smakefile can call cdbg with -x cdbg.init to load a project-specific config.

See Also


Sources: SAS Institute Inc., "SAS/C Development System User's Guide, Volume 2" Ch.9, Version 6.50 (1993), pp. 105–206. Raw: raw/sasc/sasc-debugger-commands-extract.md Updated: 2026-10-02