Tracing shared library calls


While debugging a problem over the weekend, I needed a way to trace method calls by library. This can be accomplished on Solaris systems with Dtrace, truss, or with the less well known sotruss shell script:

$ /bin/sotruss /usr/sbin/metastat

metastat -> libc.so.1:*atexit(0xff3c0220, 0x26400, 0x0)
metastat -> libc.so.1:*atexit(0x14d94, 0xfefecbc0, 0xa7bf4)
metastat -> libc.so.1:*setlocale(0x6, 0x14fd8, 0x0)
metastat -> libc.so.1:*textdomain(0x14fdc, 0xfefcf566, 0xff3a0280)
metastat -> libmeta.so.1:*sdssc_bind_library(0x27430, 0x0, 0x5ca8c)
metastat -> libmeta.so.1:*md_init(0x1, 0xffbffb1c, 0x0)
metastat -> libc.so.1:*getopt(0x1, 0xffbffb1c, 0x14ff0)
metastat -> libmeta.so.1:*metasetname(0x26598, 0xffbffa80, 0x14ff0)
metastat -> libc_psr.so.1:*memset(0xffbff178, 0x0, 0x860)
metastat -> libmeta.so.1:*metaioctl(0x560d, 0xffbff178, 0xffbff178)
metastat -> libc.so.1:*getenv(0x150c0, 0xffbffa80, 0x14ff0)
metastat -> libmeta.so.1:*meta_check_ownership(0x27448, 0xffbff9a8, 0x0)
metastat -> libmeta.so.1:*meta_print_all(0x27448, 0x0, 0xffbff9a0)
metastat -> libmeta.so.1:*meta_getalldevs(0x27448, 0xffbff9a0, 0x0)
metastat -> libmeta.so.1:*meta_create_non_dup_list(0x28680, 0xffbff93c, 0xffbff938)
metastat -> libmeta.so.1:*meta_create_non_dup_list(0x2c118, 0xffbff93c, 0x6)
metastat -> libmeta.so.1:*meta_create_non_dup_list(0x287a0, 0xffbff93c, 0x93394)
metastat -> libmeta.so.1:*meta_create_non_dup_list(0x2b770, 0xffbff93c, 0x93394)
metastat -> libmeta.so.1:*meta_print_devid(0x27448, 0x26a18, 0x27850)
metastat -> libmeta.so.1:*Free(0x27778, 0x26a18, 0x0)
metastat -> libmeta.so.1:*Free(0x27850, 0x1084, 0x93394)
metastat -> libmeta.so.1:*Free(0x27868, 0x1084, 0x93394)
metastat -> libmeta.so.1:*Free(0x27880, 0x1084, 0x93394)
metastat -> libmeta.so.1:*md_exit(0x27448, 0x0, 0x2eec0)

This is a cool script, and makes it super easy to dig through library calls.

This article was posted by Matty on 2006-03-06 22:01:00 -0400 -0400