blob: ecd6b9c5dc04c1f3993b7ce5ec68dab969d118da [file] [log] [blame]
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +01001/*
2 * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de>
3 * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
5 * (C) 2010 by Nico Golde <nico@ngolde.de>
6 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
Pablo Neira Ayuso83419342011-03-22 16:36:13 +010027#include <osmocom/core/utils.h>
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +010028#include "config.h"
29
30#ifdef HAVE_EXECINFO_H
31#include <execinfo.h>
32void generate_backtrace()
33{
34 int i, nptrs;
35 void *buffer[100];
36 char **strings;
37
38 nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
39 printf("backtrace() returned %d addresses\n", nptrs);
40
41 strings = backtrace_symbols(buffer, nptrs);
42 if (!strings)
43 return;
44
45 for (i = 1; i < nptrs; i++)
46 printf("%s\n", strings[i]);
47
48 free(strings);
49}
50#endif