1 .\" Copyright (c) 2007 Apple Inc.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of Apple Inc. ("Apple") nor the names of its
13 .\" contributors may be used to endorse or promote products derived from
14 .\" this software without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY APPLE AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .Nm backtrace_symbols ,
35 .Nm backtrace_symbols_fd
36 .Nd call stack backtrace and display functions
46 .Fa "void* const* array"
50 .Fo backtrace_symbols_fd
51 .Fa "void* const* array"
56 These routines provide a mechanism to examine the current thread's call stack.
59 writes the function return addresses of the current call stack to the array of
60 pointers referenced by
64 pointers are written. The number of pointers actually written to
69 attempts to transform a call stack obtained by
71 into an array of human-readable strings using
73 The array of strings returned has
75 elements. It is allocated using
77 and should be released using
79 There is no need to free the individual strings in the array.
81 .Fn backtrace_symbols_fd
82 performs the same operation as
83 .Fn backtrace_symbols ,
84 but the resulting strings are immediately written to the file descriptor
93 int i, frames = backtrace(callstack, 128);
94 char** strs = backtrace_symbols(callstack, frames);
95 for (i = 0; i < frames; ++i) {
96 printf("%s\\n", strs[i]);
102 These functions first appeared in