-
Notifications
You must be signed in to change notification settings - Fork 0
Home
William Cazorla edited this page Feb 26, 2022
·
7 revisions
-
r
: run or relaunch execution.
-
n
: step over the next line -
s
: step into the next line, dive into a function call. -
c
: continue execution until next breakpoint or regular interruption.
-
b
: set a breakpoint to the line you are on. -
b [func_name]
: set a breakpoint to that function first line. -
b [source_file_name:line_number]
: set a breakpoint to that source file line.
-
p [variable]
: prints a variable once. The C syntax fully applies so you can cast and dereference those, as well as try some dereferencing syntax. Great to fix, understand and test your pointers on pointers ! -
disp [variable]
: keeps printing a variable throughout a function exec, even when you come back to this function. -
bt
: Backtrace, shows and numbers the stack frames. Allowing you to navigate in or out function calls / down or up the stack. Makes fixing segfaults a breeze ! -
f [stack number]
: allows you to dive into any stack frame / function call.
- Launch gdb with your program :
gdb ./minishell
set follow-fork-mode child
- Set a breakpoint in a function inside the child :
b child_proc
- Open the text user interface :
tui e
- Tui display may get scrambled when your program outputs on stdout, don't panic and just refresh your display by scrolling inside the code preview window a bit.
- Run
r
- When gdb meets a fork its sends a SIGTRAP signal, continue to resume execution :
c