Back to index

glibc  2.9
Classes | Functions
backtrace.c File Reference
#include <execinfo.h>
#include <stddef.h>
#include <bp-checks.h>

Go to the source code of this file.


struct  layout


int __backtrace (void **array, int size)

Class Documentation

struct layout

Definition at line 21 of file frame.h.

Collaboration diagram for layout:
Class Members
int back_chain
long back_chain
long condition_register
struct layout * ebp
long empty
int empty
long end_of_stack
int end_of_stack
int glue
unsigned long ins
unsigned long locals
void *__unbounded next
struct layout *__unbounded next
void * next
unsigned long next
void * ret
void *__unbounded return_address
void * return_address
long save_fp
int save_fp
long save_grps
int save_grps
long scratch
int scratch
void *__unbounded sp

Function Documentation

int __backtrace ( void **  array,
int  size 

Definition at line 44 of file backtrace.c.

  struct layout *current;
  int count;

  /* Force gcc to spill LR.  */
  asm volatile ("" : "=l"(current));

  /* Get the address on top-of-stack.  */
  asm volatile ("ld %0,0(1)" : "=r"(current));
  current = BOUNDED_1 (current);

  for (                            count = 0;
       current != NULL &&   count < size;
       current = BOUNDED_1 (current->next), count++)
    array[count] = current->return_address;

  /* It's possible the second-last stack frame can't return
     (that is, it's __libc_start_main), in which case
     the CRT startup code will have set its LR to 'NULL'.  */
  if (count > 0 && array[count-1] == NULL)

  return count;