Debugging K42/Mambo
Debugging K42 user processes
- Log into K42
ssh leon@mambo1
- Define environment variables accordingly
- TRACEPROC=<process>
Print the syscalls (with arguments and return values) that <process> invokes to Mambo console - DEBUGPROC=<process>
Break <process> immediately after exec()leon@mambo1> export DEBUGPROC=/knfs/tests/native/testIOMapping
- Run the program to debug
leon@mambo1> /knfs/tests/native/testIOMapping
The mambo console shows:
Re-Mapping program /knfs/tests/native/testIOMapping (/knfs/tests/nati ), k42 pid 0x25 linux pid 0x14e. 18:01:16: 78790277912: (1765712825): breakpoint pid 0x25, progName -bash WARNING: 78790283561: Static breakpoint at 0x00001000702BFFE0; waiting for gdb WARNING: 78790283561: MCM 0 waiting for GDB to attach on port 44911
- Start the debugger on .dbg program file
powerpc64-linux-gdb powerpc/partDeb/usr/testIOMapping.dbg
powerpc64-linux-gdb is provided with the k42 devkit debian package
If you like xemacs, use my custom.el file and type ESC-x ppc-gdb - Attach debugger to machine:port
(gdb) mambo-debug s3:44911
See definition of mambo-debug in .gdbinit file
- Set breakpoints
- Continue execution and start debugging the program
(gdb) cont
Debugging Mambo
- On the target machine (where mambo is running):
- Find mambo's pid:
ps -fea | grep systemsim
- Run gdbserver:
gdbserver :<port> --attach <mambo_pid> # Example: gdbserver :45000 --attach 13217
- On the client machine (where I want to run gdb):
- Run gdb
gdb systemsim
- Attach to remote machine
gdb> target remote <target_host>:<port> # Example: target remote s1:45000
Files
- Xemacs init file (~/.xemacs/custom.el)
(defun ppc-gdb (path) (interactive "fRun mambo-gdb on file: ") (let (gdb-command-name) (setq gdb-command-name "powerpc64-linux-gdb") (gdb (if (string-match "XEmacs\\|Lucid" emacs-version) path (concat gdb-command-name " " path)))))
- Gdb init file (~/.gdbinit)
# # mambo stuff # define mambo-debug set architecture powerpc:a35 set single-step-mode 1 target remote $arg0 end document mambo-debug Attach to mambo simulator to debug a program. Specify communication method via socket ([host]:<port>) or TTY. end define libexec add-symbol k42.29/powerpc/partDeb/lib/exec.so.dbg end define libk42sys add-symbol k42.29/powerpc/partDeb/lib/libk42sys.so.1.dbg end define z stepi x/i $pc end define zn nexti x/i $pc end set radix 10