|
|
@ -0,0 +1,47 @@ |
|
|
|
|
|
/** |
|
|
|
|
|
* \file |
|
|
|
|
|
* |
|
|
|
|
|
* \author The GNU Software Foundation. |
|
|
|
|
|
* |
|
|
|
|
|
* \copyright |
|
|
|
|
|
* Copyright © 2014 The GNU Softare Foundation |
|
|
|
|
|
* |
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
|
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
|
|
|
|
* (at your option) any later version. |
|
|
|
|
|
* |
|
|
|
|
|
* This program is distributed in the hope that it will be useful, |
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
|
* GNU General Public License for more details. |
|
|
|
|
|
* |
|
|
|
|
|
* You should have received a copy of the GNU General Public License |
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <execinfo.h> |
|
|
|
|
|
#include <stdio.h> |
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
|
|
|
/* Obtain a backtrace and print it to stdout. */ |
|
|
|
|
|
void |
|
|
|
|
|
print_trace (void) |
|
|
|
|
|
{ |
|
|
|
|
|
void * array[10]; |
|
|
|
|
|
size_t size; |
|
|
|
|
|
char ** strings; |
|
|
|
|
|
size_t i; |
|
|
|
|
|
|
|
|
|
|
|
size = backtrace (array, 10); |
|
|
|
|
|
strings = backtrace_symbols (array, size); |
|
|
|
|
|
|
|
|
|
|
|
printf ("Obtained %zd stack frames.\n", size); |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++) |
|
|
|
|
|
printf ("%s\n", strings[i]); |
|
|
|
|
|
|
|
|
|
|
|
free (strings); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// vim: set ts=4 sw=4: |