summaryrefslogtreecommitdiffstats
path: root/documentation/GDB commands
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/GDB commands')
-rw-r--r--documentation/GDB commands139
1 files changed, 139 insertions, 0 deletions
diff --git a/documentation/GDB commands b/documentation/GDB commands
new file mode 100644
index 0000000..8411f19
--- /dev/null
+++ b/documentation/GDB commands
@@ -0,0 +1,139 @@
+###################################################################
+###################### #############################
+### GDB COMMANDS ###
+###################### #############################
+###################################################################
+
+QEMU CONFIGURATION
+
+ qemu must be started with "-s" option
+ (shorthand for "-gdb tcp::1234")
+
+#
+# GDB PART
+#
+
+SYMBOL FILES
+ add-symbol-file /path/to/Hello.debug 0x... -s .data 0x...
+
+
+CONNECTION
+ - source gdbscript
+ (if a gdbscript is created, which contains
+ add-symbol-file commandos)
+
+ - target remote localhost:1234
+
+DISCONNECTION
+ - detach
+ break connection with target, target resumes execution
+ GDB Target
+ (RSP Client) (RSP Server)
+ D
+ O------------------------------>O
+ O RSP exchange
+ O<------------------------------O
+ OK
+ -disconnect
+ Simply break connection. Target stays at the point where execution terminated previously
+ Reconnection(target remote): resume debugging at the point where the previous connection was broken
+
+BREAKPOINTS
+
+ - b CoreHandleProtocol || or OutputString
+ - break *0x65fe447 || set breakpoint at address
+ - delete 2 || delete breakpoint no 2
+ - break sampleApp.c:nn=LineNumber
+
+
+INFORMATION
+
+ - info
+ address SYM || Get address for symbol SYM
+ symbol ADDR || Show symbol at specified address
+
+ all-registers || all registers & their contents
+
+ breakpoints
+
+ files || get Entry point + sections
+ files || Names of targets & files being debugged
+
+ functions || all function names in Program
+ functions UefiMain || show where this function occurs
+
+ line
+
+ types [regex] || list all types or with regex
+
+ args || Argument variables of current stack frame
+ locals || local variables of current stack frame
+ variables || all gloabl & static variables
+
+
+CONTROL FLOW
+
+ - c || continue
+ - next || move only one step forward
+ - bt || print back_trace of all stack frames
+ - stop || stop program until it reaches a different source line
+
+FILES (perhaps not applicable when debugging with QEMU)
+
+ - file MemtestEfi.efi || load file ...no debugging symbols found...done
+ - file || unload files
+
+LIST
+
+ - list || list specified function or line
+
+gdb --tui
+ - layout asm
+ - layout reg
+ - layout src
+
+ - tui enable
+ - tui disable
+
+ - next
+
+ - ctrl+x o || change active window
+
+ - ctrl+x 1 || use TUI layout with one window
+ - ctrl+x 2 || use TUI layout with two windows
+
+ - PgUp || scroll the active window one page up
+ - PgDn || scroll the active window one page down
+
+ - Up || scroll the active window one line up
+ - Down || scroll the active window one lin down
+ - Right
+ - Left
+
+ - C+L || refresh the screen
+
+VARIABLES
+ info locals
+ info variables
+ info args
+
+ || Set is the same as print except that the expression's value is not printed
+ || and is not put in the value history.
+ || if your program has a variable width, you get an error if you try to set
+ || a new value with just ‘set width=13’, because GDB has the command set width
+ || To avoid to set silently general variables to invalid values, ALWAYS use
+ || set var x=4
+ print x=4
+ set x=4 or set variable x=4
+ whatis x -> type = double
+
+DISSASEMBLE BINARIES
+ gdb -batch -ex 'file /bin/ls' -ex 'disassemble main'
+ Also, -ex 'set disassembly-flavor intel' before other -exs will result in Intel assembly syntax
+
+ gcc -O0 -ggdb3 -std=c99 -Wall -Wextra -pedantic -o main.out main.c
+ gdb -batch -ex "disassemble/rs myfunc" main.out
+
+
+
+