whitespace fixes in milenage_test.ok
[osmocom-bb.git] / src / backtrace.c
blob023671c2ceda31dfaa55c1b90efbe73e684da690
1 /*
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>
7 * All Rights Reserved
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.
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.
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.
25 /*! \file backtrace.c
26 * \brief Routines realted to generating call back traces
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <osmocom/core/utils.h>
32 #include "config.h"
34 #ifdef HAVE_EXECINFO_H
35 #include <execinfo.h>
37 /*! \brief Generate and print a call back-trace
39 * This function will generate a function call back-trace of the
40 * current process and print it to stdout
42 void osmo_generate_backtrace(void)
44 int i, nptrs;
45 void *buffer[100];
46 char **strings;
48 nptrs = backtrace(buffer, ARRAY_SIZE(buffer));
49 printf("backtrace() returned %d addresses\n", nptrs);
51 strings = backtrace_symbols(buffer, nptrs);
52 if (!strings)
53 return;
55 for (i = 1; i < nptrs; i++)
56 printf("%s\n", strings[i]);
58 free(strings);
60 #else
61 void osmo_generate_backtrace(void)
64 #endif