Debugging K42/Mambo

Debugging K42 user processes

  1. Log into K42
    ssh leon@mambo1
  2. 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
  3. 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
  4. 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

  5. Attach debugger to machine:port
    (gdb) mambo-debug s3:44911

    See definition of mambo-debug in .gdbinit file

  6. Set breakpoints
  7. Continue execution and start debugging the program :-D
    (gdb) cont

Debugging Mambo

  • On the target machine (where mambo is running):
    1. Find mambo's pid:
      ps -fea | grep systemsim
    2. Run gdbserver:
      gdbserver :<port> --attach <mambo_pid>
      # Example: 
      gdbserver :45000 --attach 13217
  • On the client machine (where I want to run gdb):
    1. Run gdb
      gdb systemsim
    2. 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
 
/var/www/ssl/data/pages/k42/debugging_in_k42.txt · Last modified: 2008/07/24 14:58 by leon     Back to top