Peter Teoh wrote: > Thank you James for the tip. > > Following your advice, and following the similar getpcstack()'s usage > as example at: > > uts/common/os/policy.c > > I coded thus: > > 23 int _init(void) > 24 { > 25 int i, depth, status; > 26 pc_t mystack[1024]; > 27 char *sym; > 28 ulong_t off; > 29 > 30 status = mod_install(&modlinkage); > 31 cmn_err(CE_NOTE,"me filed\n"); > 32 depth = getpcstack(mystack, 10); > 33 for (i = 0; i < depth; i++) { > 34 sym = kobj_getsymname((uintptr_t)mystack[i], > &off); > 35 cmn_err(CE_NOTE, "sym=%s %x %d\n", sym, > (uintptr_t) myst > ack[i], off); > 36 } > 37 return status; > 38 } > > Technically is there any problem with this piece of code?
You probably can't call this from _init, and it's possible that 'sym' might be NULL. But those are nits. The real problem is "why do you want to do this at all?" Dtrace can give you this sort of information and it doesn't require hacking around with undocumented kernel interfaces. Another -- possibly simpler -- way to do this would be to introduce an intentional error, like this: int _init(void) { *(int *)0 = 0; return 0; } That way, the system will panic, and you can explore the stack contents to your heart's content. But I think the real question is why you're attempting to do this ... without knowing that, it's hard to give useful advice. -- James Carlson 42.703N 71.076W <carls...@workingcode.com> _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code