Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
whocalls [-l wholib] [-s] funcname executable [arguments]...
whocalls is a simple example of a utility based on the Link-Auditing functionality of ld.so.1(1) that permits the tracking of a given function call. See the Linker and Libraries Guide for a detailed description of the Link-Auditing mechanism. The executable is run as normal with any associated arguments. Each time the procedure funcname is called, both the arguments to that procedure and a stack trace are displayed on standard output.
The following options are supported: -l wholib
Specifies an alternate who.so Link-Auditing library to use.
When available, examines and uses the .symtab symbol table for local symbols. This is a little more expensive than using the .dynsym symbol table, but can produce more detailed stack trace information.
Example 1 Tracking Function Calls
The following example tracks the calls to printf() made by a simple helloworld program:
example% whocalls printf helloworld
printf(0x106e4, 0xef625310, 0xef621ba8)
helloworld:main+0x10
helloworld:_start+0x5c
Hello World
ld.so.1(1), sotruss(1), attributes(5)
Linker and Libraries Guide