On 08/03/07 07:49, Aubrey Li wrote:
On 8/3/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Once you have the address (from the driver cmn_err() call), you could just open /dev/kmem, lseek to the address, and print the contents of the structure, something like: fd = open("/dev/kmem", O_RDONLY); lseek(fd, kernel_address, SEEK_SET); read(fd, &global_structure, sizeof(global_structure)); printf("xxx = %x\n", global_structure.xxx); printf("yyy = %x\n", global_structure.yyy);
The kvm library does all this a bit more compactly for you,
with kvm_open to open the devices for you and
kvm_read to read at a given virtual address - no lseek.
The mdb API is more elegant. Once a target is opened (eg
you ran mdb -k to run against the current kernel) you can
use mdb_vread() to read from the a given virtual address
and you have mdb_lookup_by_{name,obj,addr} for address
lookup.
Yes, mdb can dump the root node of the structure, while the whole structure is a tree, I need the info of every nodes. So, mdb is not enough.
On the contrary, mdb may be exactly what you need! You can write an mdb walker to traverse your tree, dumping every member. If you happen to have reused the avl tree stuff included in Solaris then the 'avl' walker is already available to you. If not then walkers are not difficult to write - find a simple walker implementation and emulate it. They work in three stages: initialization, which often involves looking up the beginning of the pertinent structure and perhaps reading one or more structures; step iteration, which is called repeatedly until it indicates it is done - on each call it supplies the "next" object; and finishing or deconstruction, typically used to free memory etc. So once you have written your new walker it will be able to walk the addresses of all structures in your tree (or however you define it to behave). Now use a mdb pipeline to ::print them: ::walk mytreewalker | ::print my_tree_node_t For extra points, present your tree using ASCII art :-)
Firstly, The command "global_struct=X" can print the address of this variable. I think that means is already loaded. Then I run "add_drv" command to add my driver. It still reports "undefined symbol".
That mdb can see a symbol does not mean your driver can - mdb is grokking around via global mechanisms such as /dev/ksyms and is working outside of the environment imposed ny the kernel runtime linker which is policing your driver. You likely need to link as Max suggests.
you build the driver, use: $ ld -r -dy -N drv/foo mydriver.o -o mydriver
Gavin
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
