diff options
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/backtrace.c | 15 | ||||
-rw-r--r-- | sysdeps/generic/frame.h | 24 | ||||
-rw-r--r-- | sysdeps/generic/segfault.c | 11 |
3 files changed, 35 insertions, 15 deletions
diff --git a/sysdeps/generic/backtrace.c b/sysdeps/generic/backtrace.c index 2d329e19cf..3eae3f44f7 100644 --- a/sysdeps/generic/backtrace.c +++ b/sysdeps/generic/backtrace.c @@ -19,7 +19,8 @@ Boston, MA 02111-1307, USA. */ #include <execinfo.h> - +#include <frame.h> +#include <sigcontextinfo.h> /* This is a global variable set at program start time. It marks the highest used stack address. */ @@ -49,11 +50,11 @@ extern void *__libc_stack_end; # define INNER_THAN < #endif -struct layout -{ - struct layout *next; - void *return_address; -}; +/* By default assume the `next' pointer in struct layout points to the + next struct layout. */ +#ifndef ADVANCE_STACK_FRAME +# define ADVANCE_STACK_FRAME(next) ((struct layout *) (next)) +#endif int __backtrace (array, size) @@ -81,7 +82,7 @@ __backtrace (array, size) array[cnt++] = current->return_address; - current = current->next; + current = ADVANCE_STACK_FRAME (current->next); } return cnt; diff --git a/sysdeps/generic/frame.h b/sysdeps/generic/frame.h new file mode 100644 index 0000000000..7ad7a64aab --- /dev/null +++ b/sysdeps/generic/frame.h @@ -0,0 +1,24 @@ +/* Definition of stack frame structure. Generic version. + Copyright (C) 2000 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +struct layout +{ + void *next; + void *return_address; +}; diff --git a/sysdeps/generic/segfault.c b/sysdeps/generic/segfault.c index b1bb178d7a..41e3aa54d8 100644 --- a/sysdeps/generic/segfault.c +++ b/sysdeps/generic/segfault.c @@ -28,6 +28,9 @@ #include <unistd.h> #include <stdio-common/_itoa.h> +/* Get the definition of "struct layout". */ +#include <frame.h> + /* This file defines macros to access the content of the sigcontext element passed up by the signal handler. */ #include <sigcontextinfo.h> @@ -72,14 +75,6 @@ extern void *__libc_stack_end; /* We'll use tis a lot. */ #define WRITE_STRING(s) write (fd, s, strlen (s)) - -struct layout -{ - void *next; - void *return_address; -}; - - /* Name of the output file. */ static const char *fname; |