Back to index

glibc  2.9
Defines | Functions
backtrace.c File Reference
#include <execinfo.h>
#include <signal.h>
#include <frame.h>
#include <sigcontextinfo.h>
#include <bp-checks.h>
#include <ldsodefs.h>

Go to the source code of this file.


#define CURRENT_STACK_FRAME   ({ char __csf; &__csf; })
#define INNER_THAN   <
#define ADVANCE_STACK_FRAME(next)   BOUNDED_1 ((struct layout *) (next))
#define FIRST_FRAME_POINTER   __builtin_frame_address (0)


int __backtrace (void **array, int size)

Define Documentation

#define ADVANCE_STACK_FRAME (   next)    BOUNDED_1 ((struct layout *) (next))

Definition at line 54 of file backtrace.c.

#define CURRENT_STACK_FRAME   ({ char __csf; &__csf; })

Definition at line 43 of file backtrace.c.

#define FIRST_FRAME_POINTER   __builtin_frame_address (0)

Definition at line 59 of file backtrace.c.

#define INNER_THAN   <

Definition at line 48 of file backtrace.c.

Function Documentation

int __backtrace ( void **  array,
int  size 

Definition at line 63 of file backtrace.c.

  struct layout *current;
  void *__unbounded top_frame;
  void *__unbounded top_stack;
  int cnt = 0;

  top_frame = FIRST_FRAME_POINTER;
  top_stack = CURRENT_STACK_FRAME;

  /* We skip the call to this function, it makes no sense to record it.  */
  current = BOUNDED_1 ((struct layout *) top_frame);
  while (cnt < size)
      if ((void *) current INNER_THAN top_stack
         || !((void *) current INNER_THAN __libc_stack_end))
       /* This means the address is out of range.  Note that for the
         toplevel we see a frame pointer with value NULL which clearly is
         out of range.  */

      array[cnt++] = current->return_address;

      current = ADVANCE_STACK_FRAME (current->next);

  return cnt;

Here is the caller graph for this function: