diff options
Diffstat (limited to 'man3/backtrace.3')
-rw-r--r-- | man3/backtrace.3 | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/man3/backtrace.3 b/man3/backtrace.3 index 157fca076..a0fb7cf34 100644 --- a/man3/backtrace.3 +++ b/man3/backtrace.3 @@ -221,40 +221,40 @@ backtrace() returned 8 addresses #include <stdio.h> #include <stdlib.h> #include <unistd.h> - +\& #define BT_BUF_SIZE 100 - +\& void myfunc3(void) { int nptrs; void *buffer[BT_BUF_SIZE]; char **strings; - +\& nptrs = backtrace(buffer, BT_BUF_SIZE); printf("backtrace() returned %d addresses\en", nptrs); - +\& /* The call backtrace_symbols_fd(buffer, nptrs, STDOUT_FILENO) would produce similar output to the following: */ - +\& strings = backtrace_symbols(buffer, nptrs); if (strings == NULL) { perror("backtrace_symbols"); exit(EXIT_FAILURE); } - +\& for (size_t j = 0; j < nptrs; j++) printf("%s\en", strings[j]); - +\& free(strings); } - +\& static void /* "static" means don\[aq]t export the symbol... */ myfunc2(void) { myfunc3(); } - +\& void myfunc(int ncalls) { @@ -263,7 +263,7 @@ myfunc(int ncalls) else myfunc2(); } - +\& int main(int argc, char *argv[]) { @@ -271,7 +271,7 @@ main(int argc, char *argv[]) fprintf(stderr, "%s num\-calls\en", argv[0]); exit(EXIT_FAILURE); } - +\& myfunc(atoi(argv[1])); exit(EXIT_SUCCESS); } |