Back to index

glibc  2.9
Defines | Functions | Variables
tst-backtrace1.c File Reference
#include <execinfo.h>
#include <pthread.h>
#include <stdio.h>
#include "../test-skeleton.c"

Go to the source code of this file.

Defines

#define BT_SIZE   64
#define TEST_FUNCTION   do_test ()

Functions

int do_bt (void)
int call_do_bt (void)
void * tf (void *arg)
int do_test (void)

Variables

void * bt_array [BT_SIZE]
int bt_cnt

Define Documentation

#define BT_SIZE   64

Definition at line 24 of file tst-backtrace1.c.

#define TEST_FUNCTION   do_test ()

Definition at line 85 of file tst-backtrace1.c.


Function Documentation

int call_do_bt ( void  )

Definition at line 36 of file tst-backtrace1.c.

{
  return do_bt () + 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int do_bt ( void  )

Definition at line 29 of file tst-backtrace1.c.

{
  bt_cnt = backtrace (bt_array, BT_SIZE);
  return 56;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int do_test ( void  )

Definition at line 50 of file tst-backtrace1.c.

{
  pthread_t th;
  if (pthread_create (&th, NULL, tf, NULL))
    {
      puts ("create failed");
      return 1;
    }

  void *res;
  if (pthread_join (th, &res))
    {
      puts ("join failed");
      return 1;
    }

  if (res != NULL)
    {
      puts ("thread failed");
      return 1;
    }

  char **text = backtrace_symbols (bt_array, bt_cnt);
  if (text == NULL)
    {
      puts ("backtrace_symbols failed");
      return 1;
    }

  for (int i = 0; i < bt_cnt; ++i)
    puts (text[i]);

  return 0;
}

Here is the call graph for this function:

void* tf ( void *  arg)

Definition at line 42 of file tst-backtrace1.c.

{
  if (call_do_bt () != 57)
    return (void *) 1L;
  return NULL;
}

Here is the call graph for this function:


Variable Documentation

void* bt_array[BT_SIZE]

Definition at line 25 of file tst-backtrace1.c.

Definition at line 26 of file tst-backtrace1.c.