meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
gdb [2016/12/07 08:05] – [breakpoints] niziakgdb [2025/05/28 07:16] (current) – [stepping] niziak
Line 1: Line 1:
 +====== GDB ======
 +
 ====== Starting  ====== ====== Starting  ======
 <code> <code>
Line 6: Line 8:
 </code> </code>
  
 +====== Symbols and paths =====
 +
 +Add symbols:
 +<code>
 +symbol-file /mnt/nfs/binary-with-symbols.elf
 +dir /mnt/nfs/src
 +</code>
  
 ====== Using ====== ====== Using ======
  
 ==== getting info ==== ==== getting info ====
 +set print pretty on
   * p[rint] <name> - print value   * p[rint] <name> - print value
     * p * <name> - print what is pointed by     * p * <name> - print what is pointed by
Line 15: Line 25:
     * p <name> @<n> print <n> values starting at <name>     * p <name> @<n> print <n> values starting at <name>
     * p <chars> <TAB> - List all variables starting with <chars>     * p <chars> <TAB> - List all variables starting with <chars>
 +    * 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 39: Line 50:
   * cond[ition] 1 <expr> - stop at breakpoint 1 only if <expr> is true   * cond[ition] 1 <expr> - stop at breakpoint 1 only if <expr> is true
   * cond 1 - Remove condition from breakpoint 1   * cond 1 - Remove condition from breakpoint 1
 +
 +Add to C code to catch timing critical issues:
 +<code c>
 +if (p_queue->p_cb->locked) {
 +  __BKPT(8);
 +}
 +</code>
  
 ==== stepping ==== ==== stepping ====
-  * s [tep] 
-  * c [ontinue] <num_to_ignore> 
-  * 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] <num_to_ignore>
 +  * **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:
 +<code>
 +tbreak +1
 +jump +1
 +</code>
 ==== infos ==== ==== infos ====
   * show debug-file-directory   * show debug-file-directory
Line 54: Line 78:
   * thread 4 - switch to thread 4   * thread 4 - switch to thread 4
   * print mutex   * 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
 +
 +<code>
 +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
 +</code>
  
 ===== gdbcommands file ===== ===== gdbcommands file =====
Line 95: Line 135:
 </file> </file>
  
 +<file>
 +# 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 = &exception_table
 +  # Set SP/PC to the values from the actual vector table
 +  set $sp = *(int*)&exception_table
 +  set $pc = *((int*)(&exception_table)+1)
 +end
 +</file>
 ==== symbols ==== ==== symbols ====
   * set symbol-reloading on   * set symbol-reloading on
   * add-symbol-file ~/mymodule.o 0xd8be4000   * add-symbol-file ~/mymodule.o 0xd8be4000
   * add-symbol-file ~/myanother.o 0x12341234   * add-symbol-file ~/myanother.o 0x12341234
 +
 +  * set debug-file-directory <directory> - set directory contain symbol file
 +  * show debug-file-directory
  
 ==== file paths and libraries ==== ==== file paths and libraries ====