meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| gdb [2016/06/17 09:33] – niziak | gdb [2025/05/28 07:16] (current) – [stepping] niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== GDB ====== | ||
| + | |||
| ====== Starting | ====== Starting | ||
| < | < | ||
| gdb < | gdb < | ||
| gdb --args < | gdb --args < | ||
| + | gdb -x gdbcommands --init-commands=gdb-openocd.cfg | ||
| + | </ | ||
| + | |||
| + | ====== Symbols and paths ===== | ||
| + | |||
| + | Add symbols: | ||
| + | < | ||
| + | symbol-file / | ||
| + | dir / | ||
| </ | </ | ||
| + | ====== Using ====== | ||
| ==== getting info ==== | ==== getting info ==== | ||
| - | | + | set print pretty on |
| + | | ||
| + | * p * < | ||
| + | * p/x < | ||
| + | * p < | ||
| + | * p < | ||
| + | * p ((sturct dummy*)variable)[0] - Dump structure members | ||
| * ptype var | * ptype var | ||
| * x /100bx m - eXamine memory located by variable m, print 100 bytes in hex format | * x /100bx m - eXamine memory located by variable m, print 100 bytes in hex format | ||
| Line 20: | Line 38: | ||
| ==== breakpoints ==== | ==== breakpoints ==== | ||
| - | * break malloc | + | * b[reak] |
| + | * b mall <TAB> - List all starting with mall | ||
| * clear malloc | * clear malloc | ||
| + | * info break | ||
| + | * i[nfo] b | ||
| + | * dis[able] 1 - disable brakpoint 1 | ||
| + | * en[able] 1 | ||
| + | * d[elete] 1 | ||
| + | * d 1 2 | ||
| + | * d - delete all breakpoints | ||
| + | * cond[ition] 1 < | ||
| + | * cond 1 - Remove condition from breakpoint 1 | ||
| + | |||
| + | Add to C code to catch timing critical issues: | ||
| + | <code c> | ||
| + | if (p_queue-> | ||
| + | __BKPT(8); | ||
| + | } | ||
| + | </ | ||
| ==== stepping ==== | ==== stepping ==== | ||
| - | * s [tep] | ||
| - | * c [ontinue] < | ||
| - | * n [ext] - to next line | ||
| - | * fin [ish] - execute until stack frame returns | ||
| - | * u [ntil] <line number> - execute to line (to avoid loops) | ||
| + | * **s** [tep] - step to next **source** line | ||
| + | * **c** [ontinue] < | ||
| + | * **n** [ext] - step (do not enter to subroutines) | ||
| + | * **fin** [ish] - execute until stack frame returns | ||
| + | * **u** [ntil] <line number> - execute to line (to avoid loops) | ||
| + | | ||
| + | Skip current command: | ||
| + | < | ||
| + | tbreak +1 | ||
| + | jump +1 | ||
| + | </ | ||
| + | ==== infos ==== | ||
| + | * show debug-file-directory | ||
| + | |||
| + | ==== threads ==== | ||
| + | * info threads - show info about threads | ||
| + | * thread 4 - switch to thread 4 | ||
| + | * print mutex | ||
| + | * info line - print current code line | ||
| + | * frame - print current execution position and code | ||
| + | |||
| + | ==== OpenOCD ==== | ||
| + | Disable Cortex M0 interrupts | ||
| + | * mon cortex_m maskisr on | ||
| + | |||
| + | < | ||
| + | set remote hardware-breakpoint-limit 4 | ||
| + | set remote hardware-watchpoint-limit 2 | ||
| + | define hook-step | ||
| + | mon cortex_m maskisr on | ||
| + | end | ||
| + | define hookpost-step | ||
| + | mon cortex_m maskisr off | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | ===== gdbcommands file ===== | ||
| + | <file | gdbcommands> | ||
| + | set verbose on | ||
| + | set auto-load safe-path / | ||
| + | set debug auto-load on | ||
| + | |||
| + | set sysroot / | ||
| + | |||
| + | source ../ | ||
| + | |||
| + | set substitute-path / | ||
| + | |||
| + | add-symbol-file / | ||
| + | |||
| + | dir ../ | ||
| + | dir ../ | ||
| + | dir ../ | ||
| + | |||
| + | set substitute-path /usr/lib ../ | ||
| + | |||
| + | set args -m 0 -c / | ||
| + | |||
| + | # | ||
| + | |||
| + | #target extended-remote 192.168.1.62: | ||
| + | |||
| + | break myFunction | ||
| + | </ | ||
| + | |||
| + | <file | gdb-openocd.cfg> | ||
| + | target extended-remote localhost: | ||
| + | #monitor reset | ||
| + | monitor halt | ||
| + | |||
| + | # Setup GDB FOR FASTER DOWNLOADS | ||
| + | #set remote memory-write-packet-size 1024 | ||
| + | #set remote memory-write-packet-size fixed | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | # Add GDB access to mem range where VTOR is located | ||
| + | mem 0xE0000000 0xE00FFFFF | ||
| + | |||
| + | define bootapp | ||
| + | monitor reset halt | ||
| + | # Adjust VTOR (Vector table offset register) | ||
| + | set {int}0xE000ED08 = & | ||
| + | # Set SP/PC to the values from the actual vector table | ||
| + | set $sp = *(int*)& | ||
| + | set $pc = *((int*)(& | ||
| + | end | ||
| + | </ | ||
| ==== symbols ==== | ==== symbols ==== | ||
| * set symbol-reloading on | * set symbol-reloading on | ||
| * add-symbol-file ~/ | * add-symbol-file ~/ | ||
| + | * add-symbol-file ~/ | ||
| + | |||
| + | * set debug-file-directory < | ||
| + | * show debug-file-directory | ||
| ==== file paths and libraries ==== | ==== file paths and libraries ==== | ||
| Line 40: | Line 162: | ||
| * set sysroot / | * set sysroot / | ||
| - | === source paths === | + | ==== source paths ==== |
| Search paths (prefixes): | Search paths (prefixes): | ||
| * dir / | * dir / | ||
| Line 48: | Line 170: | ||
| * set substitute-path /usr/lib ../ | * set substitute-path /usr/lib ../ | ||
| - | ==== infos ==== | ||
| - | * show debug-file-directory | ||
| - | |||
| - | ==== threads ==== | ||
| - | * info threads - show info about threads | ||
| - | * thread 4 - switch to thread 4 | ||
| - | * print mutex | ||
| - | ==== Kernel OOPS ==== | + | ====== Kernel OOPS ====== |
| === Reading === | === Reading === | ||
| < | < | ||
| Line 73: | Line 188: | ||
| and look into generated code. | and look into generated code. | ||
| - | ==== Python ==== | + | ====== Python ====== |
| <code bash> | <code bash> | ||
| <code bash>gdb python < | <code bash>gdb python < | ||
| - | ===== DRAFTS ===== | + | |
| + | ====== DRAFTS | ||
| call raise(kernel-thread-id, | call raise(kernel-thread-id, | ||