home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / aix / 8987 < prev    next >
Encoding:
Text File  |  1992-08-21  |  5.9 KB  |  157 lines

  1. Newsgroups: comp.unix.aix
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!mips!darwin.sura.net!sgiblab!ultra!marc
  3. From: marc@mercutio.ultra.com (Marc Kwiatkowski {Host Software-AIX})
  4. Subject: Re: Anyone debugged AIX before?
  5. In-Reply-To: sangster@news.ans.net's message of Fri, 21 Aug 1992 14:44:48 GMT
  6. Message-ID: <1992Aug21.182033.5718@ultra.com>
  7. Sender: marc@ultra.com (Marc Kwiatkowski {Host Software-AIX})
  8. Organization: Ultra Network Technologies
  9. References: <qb4mqj9#@aix01.rz.fht-mannheim.de> <1992Aug21.144448.64350@ans.net>
  10. Date: Fri, 21 Aug 92 18:20:33 GMT
  11. Lines: 144
  12.  
  13. In article <1992Aug21.144448.64350@ans.net> sangster@news.ans.net (Paul Sangster) writes:
  14.  
  15.  
  16. >   Greetings,
  17. >
  18. >   I am trying to do alittle kernel hacking on the TCP/IP
  19. >   component of AIX.  My question is of someone who had done
  20. >   this ... how did you getting debugging info printed out
  21. >   on the console?  I see lots of printfs floating around in
  22. >   the code, but they don't seem to do anything when compiled
  23. >   into the netinet.  Is their a special kernel library
  24. >   with its own printf (or does it just use libc)?
  25. >
  26. >   Please direct follow ups via e-mail.
  27. >
  28. >   Thanx,
  29. >
  30.  
  31. Below is a copy of my cheat sheet for kernel debugging.  Everything
  32. you need to know is in InfoExplorer databases, but it's hard to find
  33. it.  If someone wants to stick this into an FAQ, feel free.
  34.  
  35. ================================================================================
  36.  
  37. Installing the AIXv3.2 kernel debugger.
  38.  
  39. To configure your AIXv3.2 kernel for debugging, run the following
  40. command.
  41.  
  42.  $ bosboot -a -D -d <boot-device>
  43.  
  44. Where boot device is the hard-disk you boot off of, typically, hdisk0.
  45.  
  46. Configure tty0 for 9600 baud, 8 bit, no-parity, 1 stop-bit.  Connect serial port
  47. S1 (ie tty0)  from your machine to a dumb terminal capable of supporting 
  48. the above line mode.  If you have another Unix workstation you can connect to 
  49. its serial port with tip or cu.
  50.  
  51. Reboot your machine.  To enter the debugger, strike the following
  52. keys on the console keyboard simultaneously.
  53.  
  54.   Cntl-Alt-<Numeric-key-pad 4>
  55.  
  56. That is, the number 4 on the numeric keypad as opposed to the number
  57. 4 above the E and R key.  You should see a register dump displayed
  58. on your dumb terminal.  Entering "go" or "quit" will allow the kernel
  59. to resume execution.  See the InfoExplorer on-line documentation for
  60. more on the kernel debugger commands.
  61.  
  62. Kernel Printfs
  63.  
  64. Kernel printfs are only displayed to the debug terminal.  If you do
  65. not have the kernel debugger configured or you don't have your terminal
  66. hooked up you will not see kernel printfs, period.
  67.  
  68. Whe your kernel is configured with debugging on, all kernel printfs
  69. will go to your kernel-debug dumb terminal.  Note that there is
  70. no way to get around the 9600 baud rate, so too many printfs and
  71. printfs in time-critical areas will significantly alter the behaviour
  72. of your kernel.
  73.  
  74. Panics
  75.  
  76. When your kernel is configured with debugging on, any panic will trap
  77. into the debugger.  When this happens look to see if any error messages 
  78. have been displayed to the dumb terminal.
  79.  
  80. Stack traces.
  81.  
  82. When your machine has panicked, you may want to trace the thread of
  83. exuction by examining the stack.  Because the AIXv3 kernel debugger
  84. doesn't maintain a full-blown symbol table, traces are a little painful
  85. but can be done.  The current stack pointer is always stored in register
  86. 1, and so one can display the current stack by entering the following
  87. in the debugger dumb terminal.
  88.  
  89. > d r1
  90. 001F1CCC   001F1D1C 00000010 013DB7C0 20202072   |.........=..   r|
  91.            ^^^^^^^^          ^^^^^^^^
  92.            Previous          Calling
  93.            Stack             Function
  94.            Pointer           Return
  95.                              Address
  96.  
  97. This shows the first 16 bytes of the stack.  The first four bytes
  98. are the address of the previous stack-pointer, and the third
  99. four bytes are the return address of the calling function.  Thus
  100. by first displaying r1, and then dumping the first four bytes of
  101. each successive output one can get a quick complete dump.
  102.  
  103. For example:
  104. > d r1
  105. 001F1CCC   001F1D1C 00000010 013DB7C0 20202072   |.........=..   r|
  106. > d r1
  107. 001F1CCC   001F1D1C 00000010 013DB7C0 20202072   |.........=..   r|
  108. > d 001F1D1C
  109. 001F1D1C   001F1D8C 01484238 013B1ECC 009AB300   |.....HB8.;......|
  110. > d 001F1D8C
  111. 001F1D8C   001F1DCC 0000608C 013B172C 70000000   |......`..;.,p...|
  112. > d 01F1DCC
  113. 001F1DCC   001F1EAC 007FFFFF 013B1240 00000002   |.........;.@....|
  114. > d 01F1EAC
  115. 001F1EAC   001F1F2C 24000024 0001C21C 001F2F64   |...,$..$....../d|
  116. > d 1F1F2C
  117. 001F1F2C   00000000 48002084 00004498 00000000   |....H. ...D.....|
  118.  
  119. Converting addresses to symbol names
  120.  
  121. The AIXv3 kernel debugger provides minimal symbol table support.
  122. The map command can be used to locate the address of global
  123. symbols (ie those that are exported by their module) and nothing
  124. else.  
  125.  
  126. To figure out what each function is, a quick and dirty trick is
  127. to dump the return address in the stack or the current IAR (pc).  
  128. The name of each function is encoded
  129. as an ASCII string at the end of each function, so if you dump
  130. enough you will eventually see it.  Note:  this doesn't always
  131. work.  Low-level and/or hardware panics may leave current registers
  132. in a meaningless state, thus attempts to dump stacks and return 
  133. addresses are useless.
  134.  
  135.  
  136. > d 013DB7C0 200
  137. .
  138. .
  139. .
  140. .
  141. 013DB890   81810098 30210090 7D8803A6 BB61FFEC   |....0!..}....a..|
  142. 013DB8A0   4E800020 00000000 00002041 80050300   |N.. ...... A....|
  143. 013DB8B0   00000000 00000218 000D656E 745F786D   |..........ent_xm|
  144. 013DB8C0   69745F64 6F6E6500 7C0802A6 BF81FFF0   |it_done.|.......|
  145. .
  146. .
  147.  
  148. Note the ent_xmt_done in the ASCII output column.  That is the name
  149. of the last calling function.
  150. ================================================================================
  151. -- 
  152. Marc P. Kwiatkowski                  /|/|            Ultra Network Technologies
  153. internet: marc@ultra.com     \______/ | | W.A.S.T.E. 101 Daggett Drive
  154. uucp: ...!ames!ultra!marc    / (__) \ | |            San Jose, CA 95134 USA
  155. voice: 408 922 0100 x249             \|\|
  156.