../

Links:
pi pico getting started
gdb docs
openocd debugging commands(!!)
pi pico C sdk DOCS
pi pico C sdk REFERENCE
rp2040 datasheet

quick setup:
- start openocd with openocd -f interface/raspberrypi-swd.cfg -f target/rp2040.cfg from any directory
- forward openocd with ~C to open inband ssh shell, -L3333:localhost:3333, -L4444:localhost:4444 for gdb and telnet respectively
- start gdb with gdb -q -se "FILE.elf" -ex "target remote localhost:3333" -ex "load" -ex "monitor reset init" -ex "break main" -ex "continue"
- watchexec gdb with watchexec --force-poll 500 -r --signal SIGHUP
- gdb starts in emacs mode, M-C-j (Ctrl-Alt-j on my machine) switches to vi mode
- quickly run a shell command with shell command string
- gdb file is a shortcut for the gdb command file file
- connect to openocd with target remote localhost:3333 (with a ssh forward -L3333:localhost:3333 wherever openocd is running)
- gdb load flashes the pico with the loaded file
- gdb monitor args sends an openocd command
- openocd reset then command performs a hard reset on the pico and then does then:
	- run: run the pico after the reset (default)
	- halt: halt the pico after the reset
	- init: halt the pico and put it into a known init state (entry of main())
- common gdb commands:
	- c(ontinue): lets the program start going
	- c(ontinue) ignore-count: lets the program start going, skipping a given number of lines
	- b(reak) at sets a breakpoint at the given function, linenum, filename:linenum, +/-lineoffset, filename:function,
	- clear at remove breakpoint
	- delete breakpoint-id remove breakpoint by number
	- info stack/registers/b(reakpoints)
	- n(ext) next line
	- s(tep) step in
	- f(inish) step out
	- bt backtrace
	- p var print variable value
	- l(ist) var show source at the given line, function, start,end
- put the following into ~/.gdbinit for skipl to skip a line(note, doesnt actually work ;-;)
    define skipl
    tbreak +1
    jump +1
end
- my init script for pico programming follows:
    target remote localhost:3333
load
monitor reset init
break main
continue
  this will leave you paused at the entry to int main()
  startup commands can be provided to gdb with gdb -ex "target remote localhost" -ex "load" -ex "monitor reset init" etc