Getting started with your own CTF data

There was a <a href="http://www.opensolaris.org/jive/thread.jspa?threadID=4614&tstart=0">question</a> posed on the <a href="http://www.opensolaris.org/jive/forum.jspa?forumID=4">mdb-discuss</a> forum today, wondering how to add CTF data to kernel modules which you develop.

I gave a kinda-useless answer (basically <a href="http://cvs.opensolaris.org/source/search?q=ctfconvert">UTSL</a>;), but recalled that this question had been asked on #opensolaris a few weeks ago and I'd promised to write up a procedure.

So I found my copy of <a href="http://homepage2.nifty.com/mrym3/taiyodo/eng/index.htm">Murayama-san's</a> <tt>rh</tt> driver sourcecode, did a quick build of the <tt>fp</tt> module from the NWS consolidation, and then figured out J. Random Developer can add the CTF data in.

Firstly, grab yourself a copy of the <a href="http://www.genunix.org/mirror/SUNWonbld-20051116.i386.tar.bz2">ON build (onbld)</a> tools from <a href="http://www.genunix.org">genunix.org</a>. This package contains the utilities <tt>ctfconvert</tt> and <tt>ctfmerge</tt>. (Unfortunately they don't appear to have manpages yet).

Then with your driver, for each .o file that gets linked to make your driver, run

$ ctfconvert ---g ---l [label] objectfile.o

Then when each has been <tt>ctfconvert</tt>ed, run

$ ctfmerge ---l [label] ---o [output driver name] [list of .o files]

It's depressingly simple!


Now here's what I did for the <a href="http://homepage2.nifty.com/mrym3/taiyodo/eng/index.htm">rh</a> driver:

$ /usr/ccs/bin/make
$ cd i386
$ /ws/onnv-tools/onbld/bin/i386/ctfconvert ---g ---l RH gem.o
$ /ws/onnv-tools/onbld/bin/i386/ctfconvert ---g ---l RH rh_gem.o
$ /ws/onnv-tools/onbld/bin/i386/ctfmerge ---l RH ---o rh rh_gem.o gem.o
$ cd amd64
$ /ws/onnv-tools/onbld/bin/i386/ctfconvert ---g ---l RH gem.o
$ /ws/onnv-tools/onbld/bin/i386/ctfconvert ---g ---l RH rh_gem.o
$ /ws/onnv-tools/onbld/bin/i386/ctfmerge ---l RH ---o rh rh_gem.o gem.o

Then I did the usual <tt>make install</tt> and <tt>adddrv.sh</tt> and I could now do this in a session of <tt>mdb ---k</tt>:



> ::status
debugging live kernel (64-bit) on doppio
operating system: 5.11 onnv-gate:2005-12-11 (i86pc)
> ::modinfo ! grep rh
232 fffffffff4feed58     adf8   1 rh (via rhine nic driver v1.0.24)
> ::print ---t struct gem_stats
{
    uint32_t intr
    uint32_t crc
    uint32_t errrcv
    uint32_t overflow
    uint32_t frame
    uint32_t missed
    uint32_t runt
    uint32_t frame_too_long
    uint32_t norcvbuf
    uint32_t collisions
    uint32_t first_coll
    uint32_t multi_coll
    uint32_t excoll
    uint32_t nocarrier
    uint32_t defer
    uint32_t errxmt
    uint32_t underflow
    uint32_t xmtlatecoll
}

And even better, with a development version of Solaris CAT I can use the <tt>stype</tt> command:

SolarisCAT(live/11X)> stype gem_stats
struct gem_stats { (size: 0x48 bytes)
   typedef uint32_t = unsigned intr; (offset 0x0 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned crc; (offset 0x4 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned errrcv; (offset 0x8 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned overflow; (offset 0xc bytes, size 0x4 bytes)
   typedef uint32_t = unsigned frame; (offset 0x10 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned missed; (offset 0x14 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned runt; (offset 0x18 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned frame_too_long; (offset 0x1c bytes, size 0x4 bytes)
   typedef uint32_t = unsigned norcvbuf; (offset 0x20 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned collisions; (offset 0x24 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned first_coll; (offset 0x28 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned multi_coll; (offset 0x2c bytes, size 0x4 bytes)
   typedef uint32_t = unsigned excoll; (offset 0x30 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned nocarrier; (offset 0x34 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned defer; (offset 0x38 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned errxmt; (offset 0x3c bytes, size 0x4 bytes)
   typedef uint32_t = unsigned underflow; (offset 0x40 bytes, size 0x4 bytes)
   typedef uint32_t = unsigned xmtlatecoll; (offset 0x44 bytes, size 0x4 bytes)
} ;




Comments:

Post a Comment:
Comments are closed for this entry.
About

I work at Oracle in the Solaris group. The opinions expressed here are entirely my own, and neither Oracle nor any other party necessarily agrees with them.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today