Manual Pages for UNIX Darwin command on man backtrace
MyWebUniversity

Manual Pages for UNIX Darwin command on man backtrace

backtrace(3) BSD Library Functions Manual backtrace(3)

NAME

bbaacckkttrraaccee, bbaacckkttrraacceessyymmbboollss, bbaacckkttrraacceessyymmbboollssffdd - call stack back-

trace and display functions

SYNOPSIS

##iinncclluuddee <>

int bbaacckkttrraaccee(void** array, int size); char** bbaacckkttrraacceessyymmbboollss(void* const* array, int size); void bbaacckkttrraacceessyymmbboollssffdd(void* const* array, int size, int fd);

DESCRIPTION

These routines provide a mechanism to examine the current thread's call stack. bbaacckkttrraaccee() writes the function return addresses of the current call

stack to the array of pointers referenced by array. At most, size point-

ers are written. The number of pointers actually written to array is returned. bbaacckkttrraacceessyymmbboollss() attempts to transform a call stack obtained by

bbaacckkttrraaccee() into an array of human-readable strings using ddllaaddddrr(). The

array of strings returned has size elements. It is allocated using mmaalllloocc() and should be released using ffrreeee(). There is no need to free the individual strings in the array. bbaacckkttrraacceessyymmbboollssffdd() performs the same operation as bbaacckkttrraacceessyymmbboollss(), but the resulting strings are immediately written to the file descriptor fd, and are not returned. EEXXAAMMPPLLEE

#include

#include

... void* callstack[128];

int i, frames = backtrace(callstack, 128);

char** strs = backtracesymbols(callstack, frames);

for (i = 0; i < frames; ++i) {

printf("%s\n", strs[i]);

} free(strs); ... HISTORY These functions first appeared in Mac OS X 10.5.

SEE ALSO

dladdr(3), malloc(3) Mac OS X February 15, 2007 Mac OS X




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™