Back to index

glibc  2.9
framestate.c
Go to the documentation of this file.
00001 /* __frame_state_for unwinder helper function wrapper.
00002    Copyright (C) 2001, 2003 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Jakub Jelinek <jakub@redhat.com>, 2001.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <dlfcn.h>
00022 #include <stdlib.h>
00023 #define STATIC static
00024 #define __frame_state_for fallback_frame_state_for
00025 #include <unwind-dw2.c>
00026 #undef __frame_state_for
00027 
00028 typedef struct frame_state * (*framesf)(void *pc, struct frame_state *);
00029 struct frame_state *__frame_state_for (void *pc,
00030                                    struct frame_state *frame_state);
00031 
00032 struct frame_state *
00033 __frame_state_for (void *pc, struct frame_state *frame_state)
00034 {
00035   static framesf frame_state_for;
00036 
00037   if (frame_state_for == NULL)
00038     {
00039       void *handle = __libc_dlopen ("libgcc_s.so.1");
00040 
00041       if (handle == NULL
00042          || (frame_state_for
00043              = (framesf) __libc_dlsym (handle, "__frame_state_for")) == NULL)
00044 #ifndef __USING_SJLJ_EXCEPTIONS__
00045        frame_state_for = fallback_frame_state_for;
00046 #else
00047        frame_state_for = abort;
00048 #endif
00049     }
00050 
00051   return frame_state_for (pc, frame_state);
00052 }