Back to index

glibc  2.9
Classes | Defines | Functions
backtrace.c File Reference
#include <bits/libc-lock.h>
#include <dlfcn.h>
#include <execinfo.h>
#include <stdlib.h>
#include <unwind.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


struct  trace_arg


#define unwind_backtrace   _Unwind_Backtrace
#define unwind_getip   _Unwind_GetIP


static _Unwind_Reason_Code backtrace_helper (struct _Unwind_Context *ctx, void *a)
int __backtrace (void **array, int size)

Class Documentation

struct trace_arg

Definition at line 27 of file backtrace.c.

Class Members
void ** array
int cnt
void * lastebp
void * lastesp
int size

Define Documentation

Definition at line 52 of file backtrace.c.

Definition at line 53 of file backtrace.c.

Function Documentation

int __backtrace ( void **  array,
int  size 

Definition at line 71 of file backtrace.c.

  struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
#ifdef SHARED
  __libc_once_define (static, once);

  __libc_once (once, init);
  if (unwind_backtrace == NULL)
    return 0;

  if (size >= 1)
    unwind_backtrace (backtrace_helper, &arg);

  /* _Unwind_Backtrace on IA-64 seems to put NULL address above
     _start.  Fix it up here.  */
  if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
  return arg.cnt != -1 ? arg.cnt : 0;

Here is the call graph for this function:

static _Unwind_Reason_Code backtrace_helper ( struct _Unwind_Context ctx,
void *  a 
) [static]

Definition at line 57 of file backtrace.c.

  struct trace_arg *arg = a;

  /* We are first called with address in the __backtrace function.
     Skip it.  */
  if (arg->cnt != -1)
    arg->array[arg->cnt] = (void *) unwind_getip (ctx);
  if (++arg->cnt == arg->size)
    return _URC_END_OF_STACK;
  return _URC_NO_REASON;

Here is the caller graph for this function: