Skip to content

GDB commands

Daniele Lombardi edited this page Aug 17, 2024 · 6 revisions

Most commands have been designed with the same syntax of original gdb commands, so if you are familiar with gdb it will be extremely easy for you to start.

advance

advance *ip|linenumber
Continue the execution of the active thread until it reaches the given instruction address or line number.

backtrace, bt, where

backtrace
Print all frames (call stack) in the active thread.

backtrace n
Print all frames between current and current+n.

break, b

break
Set breakpoint at next instruction.

break [file:]line [thread threadId] [if expr]
Set breakpoint at line number. A breakpoint can be enabled for a specific thread ID, and may have a condition.

call

call script_name [arg0,...,argN]
Call a CHL script with optional parameters. The game will continue running until the given script ends. You can also pause the script execution, but you cannot call another script until the previous one ends.

catch

catch syscall native_name
Pause the execution whenever the given native function name is called. To find out the native function name for a given CHL statement, please refer to this page.

catch call script_name
Pause the execution whenever the given script name is called synchronous.

catch run script_name
Pause the execution whenever the given script name is started in background.

Catching a script call/run pauses the debugger on the caller. If you want to pause the debugger on the called script, don't use catch, but set a breakpoint on the first instruction within the script.

clear

clear
Delete breakpoints at next instruction.

clear *ip|[file:]linenumber
Delete breakpoints at given instruction address or line number.

commands

commands [breakpoint]
Define a list of gdb commands to be executed when the specified breakpoint is hit. If you omit the breakpoint ID, the command list will be attached to the last breakpoint set. Each command must be entered on a separate line; to end the list, enter end.

compile

compile code [-raw] -- [expression]
Compile and execute expression. If expression is not provided on the same line, you will be prompted for multiple lines of code; to terminate the code block enter end.

compile file [-raw] filename
Compile and execute the code from the provided file.

The code will be wrapped in a temporary script named _gdb_expr_. If you need to declare local variables, you must set the -raw flag and provide the full script definition.

condition, cond

condition n expression
Set a condition on breakpoint n. The breakpoint will pause the execution only if the given condition is true.

condition n
Remove the condition from breakpoint n.

continue, c

Resume script execution.

define

define cmdname
Create a user defined command. You will be prompted for multiple lines of gdb commands; to terminate the code block enter end.
To run a previously defined custom command, just type its name. If you give a custom command the same name of a built-in command, you won't be able to execute the custom one, because built-in commands will mask any user defined command with the same name.

delete, d

delete
Delete all breakpoints. You will be asked for confirmation.

delete n
Delete breakpoint n.

delete display n
Delete the global display n.

directory

directory dir1 ... dirN
Add directory names to front of source path.

directory
Clear source path.

disassemble, disas

disassemble [/m|/s]
Show ASM code around the current instruction.

disassemble [/m|/s] [from,to]
Show ASM code between from and to. An instruction address can be absolute or relative to the current address; to use relative address simply prepend a + or a - to the offset.

The options /m and /s (they are equivalent) can be used to display original source lines, if available.

disable

disable
Disable all breakpoints.

disable n
Disable breakpoint n.

disable display n
Disable the global display n.

display

display
List the global displays.

display [/f|/d|/d] expression
Add a global display expression.

Global display expressions are evaluated and shown everytime the execution is paused. They are useful to check the game state without having to type a number of print statements everytime.

down

down [n]
Move the active frame down by n, then display the active frame. If n is not specified, it defaults to 1.

down-silently

down-silently [n]
Move the active frame down by n without any display. If n is not specified, it defaults to 1.

echo

echo string1 ... stringN
Print one or more strings to the console without appending a newline. You may add more strings on subsequent lines by ending the previous line with a \. Newline and tab can be coded as \n and t.

enable

enable
Enable all breakpoints.

enable [once] [del] n
Enable breakpoint n. If you specify once the breakpoint will be disabled after it hits. If you specify del the breakpoint is deleted after it hits.

enable display n
Enable the global display n.

end (block only)

end
Ends a command block or a code block.

eval

eval format[,expressions]
Construct and executes a command from the given format and expressions. The format string supports the same placeholders of printf.

fg

fg
Alias of continue.

finish

finish
Continue the execution of the current thread until it ends.

frame, f

frame
Print the current frame.

frame n
Set the current frame. Use the backtrace command to find out the IDs of each frame in the active thread.

help

Print gdb help - Not implemented yet.

if (script only)

if condition
	commands
[else
	commands]
end

ignore

info

jump, j

kill

list

loop_break (script only)

loop_continue (script only)

make

next, n

nexti, ni

output

print, p

printf

quit, q

return, ret

run, r

select-frame

set

shell, !

show

source

step, s

stepi, si

tbreak

thread

undisplay

until, u

up

updatechl (custom)

watch

whatis

while (script only)

x