2002-11-07 07:00:07 +01:00
|
|
|
|
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
|
|
GNU CC 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 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
GNU CC 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 GNU CC; see the file COPYING. If not, write to
|
|
|
|
|
the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
|
|
/* As a special exception, if you link this library with other files,
|
|
|
|
|
some of which are compiled with GCC, to produce an executable,
|
|
|
|
|
this library does not by itself cause the resulting executable
|
|
|
|
|
to be covered by the GNU General Public License.
|
|
|
|
|
This exception does not however invalidate any other reasons why
|
|
|
|
|
the executable file might be covered by the GNU General Public License. */
|
|
|
|
|
|
|
|
|
|
/* Locate the FDE entry for a given address, using Darwin's keymgr support. */
|
|
|
|
|
|
|
|
|
|
#include "tconfig.h"
|
i * configure.in: Don't put ${tm_file} into host_xm_file,
build_xm_file, or xm_file. Do put tm-preds.h into tm_p_file.
Take location of tm-preds.h into account when calculating
tm_p_file_list.
* configure: Regenerate.
* mkconfig.sh: No need for separate TM_DEFINES and XM_DEFINES
arguments. Do not provide rtx, rtvec, tree, or GTY here.
Remove special case code for tm_p.h and *config.h; add new
special case code for tm.h and tconfig.h. Clean up a bit.
* Makefile.in (tm_file, tm_file_list): New variables set from
@-substitutions.
(GCONFIG_H): Deleted.
(GTM_H, TM_H): New.
(CONFIG_H): Is now just config.h $(host_xm_file_list).
(TM_P_H): Move up with the other mkconfig.sh-generated
headers; don't mention tm-preds.h explicitly.
(tm.h, cs-tm.h): New rule.
(cs-config.h, cs-hconfig.h, cs-tconfig.h, cs-tm_p.h): Adjust
invocations of mkconfig.sh for changes to that program.
(mostlyclean): Delete print-rtl1.c.
(clean): Delete tm.h.
* Makefile.in, ada/Make-lang.in, cp/Make-lang.in,
f/Make-lang.in, java/Make-lang.in, objc/Make-lang.in,
treelang/Make-lang.in: Update dependencies for the files
listed below.
* mklibgcc.in: Add 'coretypes.h $(TM_H)' to libgcc2_c_dep.
* coretypes.h: New file.
* system.h: #define malloc to xmalloc and realloc to xrealloc
when FLEX_SCANNER or YYBISON is defined, independent of the
value of GCC_VERSION.
* alias.c, attribs.c, bb-reorder.c, bitmap.c, builtins.c,
c-aux-info.c, c-common.c, c-convert.c, c-decl.c, c-dump.c,
c-errors.c, c-format.c, c-lang.c, c-lex.c, c-objc-common.c,
c-opts.c, c-parse.in, c-pragma.c, c-pretty-print.c,
c-semantics.c, c-typeck.c, caller-save.c, calls.c, cfg.c,
cfganal.c, cfgbuild.c, cfgcleanup.c, cfglayout.c, cfgloop.c,
cfgrtl.c, collect2.c, combine.c, conflict.c, convert.c,
cppdefault.c, cpperror.c, cppexp.c, cppfiles.c, cpphash.c,
cppinit.c, cpplex.c, cpplib.c, cppmacro.c, cppmain.c,
cppspec.c, cpptrad.c, crtstuff.c, cse.c, cselib.c, dbxout.c,
debug.c, df.c, diagnostic.c, doloop.c, dominance.c,
dummy-conditions.c, dwarf2asm.c, dwarf2out.c, dwarfout.c,
emit-rtl.c, errors.c, et-forest.c, except.c, explow.c,
expmed.c, expr.c, final.c, fix-header.c, flow.c, fold-const.c,
function.c, gcc.c, gccspec.c, gcov-dump.c, gcov-iov.c, gcov.c,
gcse.c, gen-protos.c, genattr.c, genattrtab.c, genautomata.c,
gencheck.c, gencodes.c, genconditions.c, genconfig.c,
genconstants.c, genemit.c, genextract.c, genflags.c,
gengenrtl.c, gengtype-lex.l, gengtype-yacc.y, gengtype.c,
genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
gensupport.c, ggc-common.c, ggc-none.c, ggc-page.c,
ggc-simple.c, global.c, graph.c, haifa-sched.c, hashtable.c,
hooks.c, ifcvt.c, integrate.c, intl.c, jump.c, langhooks.c,
lcm.c, libgcc2.c, line-map.c, lists.c, local-alloc.c, loop.c,
main.c, mbchar.c, mips-tdump.c, mips-tfile.c, mkdeps.c,
optabs.c, params.c, predict.c, prefix.c, print-rtl.c,
print-tree.c, profile.c, protoize.c, ra-build.c,
ra-colorize.c, ra-debug.c, ra-rewrite.c, ra.c, read-rtl.c,
real.c, recog.c, reg-stack.c, regclass.c, regmove.c,
regrename.c, reload.c, reload1.c, reorg.c, resource.c,
rtl-error.c, rtl.c, rtlanal.c, sbitmap.c, scan-decls.c,
scan.c, sched-deps.c, sched-ebb.c, sched-rgn.c, sched-vis.c,
sdbout.c, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c,
ssa.c, stmt.c, stor-layout.c, stringpool.c, timevar.c,
tlink.c, toplev.c, tracer.c, tree-dump.c, tree-inline.c,
tree.c, unroll.c, varasm.c, varray.c, varray.h, vmsdbgout.c,
xcoffout.c, config/darwin-c.c, config/darwin.c,
config/fp-bit.c, config/alpha/alpha.c, config/alpha/vms-cc.c,
config/alpha/vms-ld.c, config/arc/arc.c, config/arm/arm.c,
config/arm/pe.c, config/avr/avr.c, config/c4x/c4x-c.c,
config/c4x/c4x.c, config/cris/cris.c, config/d30v/d30v.c,
config/dsp16xx/dsp16xx.c, config/fr30/fr30.c,
config/frv/frv.c, config/h8300/h8300.c, config/i370/i370-c.c,
config/i370/i370.c, config/i386/i386.c, config/i386/winnt.c,
config/i960/i960-c.c, config/i960/i960.c,
config/ia64/ia64-c.c, config/ia64/ia64.c, config/ip2k/ip2k.c,
config/m32r/m32r.c, config/m68hc11/m68hc11.c,
config/m68k/m68k.c, config/m88k/m88k.c, config/mcore/mcore.c,
config/mips/irix6-libc-compat.c, config/mips/mips.c,
config/mmix/mmix.c, config/mn10200/mn10200.c,
config/mn10300/mn10300.c, config/ns32k/ns32k.c,
config/pa/pa.c, config/pdp11/pdp11.c, config/romp/romp.c,
config/rs6000/rs6000-c.c, config/rs6000/rs6000.c,
config/s390/s390.c, config/sh/sh.c, config/sparc/gmon-sol2.c,
config/sparc/sparc.c, config/stormy16/stormy16.c,
config/v850/v850-c.c, config/v850/v850.c, config/vax/vax.c,
config/xtensa/xtensa.c, objc/objc-act.c, objc/objc-lang.c:
Include coretypes.h and tm.h.
* genattrtab.c, genconditions.c, genemit.c, genextract.c,
gengenrtl.c, gengtype.c, genopinit.c, genoutput.c, genpeep.c,
genrecog.c: Include coretypes.h and tm.h from the file
generated by this program.
* unwind-dw2-fde-darwin.c, unwind-dw2-fde-glibc.c,
unwind-dw2-fde.c, unwind-dw2.c, unwind-sjlj.c: Include
coretypes.h and tm.h, and tsystem.h when not already included.
No need to include stddef.h nor stdlib.h.
* ada/cuintp.c, ada/decl.c, ada/deftarg.c, ada/misc.c,
ada/targtyps.c, ada/trans.c, ada/utils.c, ada/utils2.c:
Include coretypes.h and tm.h, and system.h when not already
included.
* cp/call.c, cp/class.c, cp/cp-lang.c, cp/cvt.c, cp/cxxfilt.c,
cp/decl.c, cp/decl2.c, cp/dump.c, cp/error.c, cp/except.c,
cp/expr.c, cp/friend.c, cp/g++spec.c, cp/init.c, cp/lex.c,
cp/mangle.c, cp/method.c, cp/optimize.c, cp/parse.y, cp/pt.c,
cp/ptree.c, cp/repo.c, cp/rtti.c, cp/search.c, cp/semantics.c,
cp/spew.c, cp/tree.c, cp/typeck.c, cp/typeck2.c:
Include coretypes.h and tm.h.
* f/proj.h, f/ansify.c, f/g77spec.c, f/intdoc.c:
Include coretypes.h and tm.h.
* fixinc/fixlib.h: Include coretypes.h and tm.h. Do not
include auto-host.h or ansidecl.h/
* fixinc/server.h: Do not include stdio.h, unistd.h, or fixlib.h.
* fixinc/procopen.c: Include server.h after fixlib.h. Do not
include auto-host.h, ansidecl.h, or system.h.
* fixinc/server.c: Likewise. Also, do not include signal.h,
and do not redefine volatile.
* java/boehm.c, java/buffer.c, java/builtins.c,
java/check-init.c, java/class.c, java/constants.c,
java/decl.c, java/except.c, java/expr.c, java/gjavah.c,
java/jcf-depend.c, java/jcf-dump.c, java/jcf-io.c,
java/jcf-parse.c, java/jcf-path.c, java/jcf-write.c,
java/jv-scan.c, java/jvgenmain.c, java/jvspec.c, java/lang.c,
java/mangle.c, java/mangle_name.c, java/parse-scan.y,
java/parse.y, java/typeck.c, java/verify.c, java/xref.c,
java/zextract.c: Include coretypes.h and tm.h.
* treelang/lex.l: Move "%{" below copyright notice; get rid of
"/*" embedded in comment. Do not #undef IN_GCC; do not
include stdio.h, memory.h, or ansidecl.h; do not include
config.h twice. Do include coretypes.h and tm.h.
* treelang/parse.y: Do not #undef IN_GCC, provide bogus
definitions of tree and rtx typedefs, or include stdio.h,
stdlib.h, string.h, or ansidecl.h. Do include coretypes.h and
tm.h.
* treelang/tree1.c: Do not include ansidecl.h, stdlib.h,
unistd.h, ctype.h, stdarg.h, string.h, or stdio.h. Do include
coretypes.h and tm.h.
* treelang/treetree.c: Do not include stdlib.h, unistd.h,
safe-ctype.h, errno.h. stdarg.h, limits.h, string.h, fcntl.h,
getopt.h. stdio.h, or ansidecl.h. Do include coretypes.h and
tm.h.
[[Split portion of a mixed commit.]]
From-SVN: r59673.2
2002-12-01 06:43:14 +01:00
|
|
|
|
#include "tsystem.h"
|
|
|
|
|
#include "coretypes.h"
|
|
|
|
|
#include "tm.h"
|
2002-11-07 07:00:07 +01:00
|
|
|
|
#include "dwarf2.h"
|
|
|
|
|
#include "unwind.h"
|
|
|
|
|
#define NO_BASE_OF_ENCODED_VALUE
|
|
|
|
|
#define DWARF2_OBJECT_END_PTR_EXTENSION
|
|
|
|
|
#include "unwind-pe.h"
|
|
|
|
|
#include "unwind-dw2-fde.h"
|
|
|
|
|
/* Carefully don't include gthr.h. */
|
|
|
|
|
|
|
|
|
|
typedef int __gthread_mutex_t;
|
|
|
|
|
#define __gthread_mutex_lock(x) (void)(x)
|
|
|
|
|
#define __gthread_mutex_unlock(x) (void)(x)
|
|
|
|
|
|
|
|
|
|
static fde * _Unwind_Find_registered_FDE (void *pc,
|
|
|
|
|
struct dwarf_eh_bases *bases);
|
|
|
|
|
|
|
|
|
|
#define _Unwind_Find_FDE _Unwind_Find_registered_FDE
|
|
|
|
|
#include "unwind-dw2-fde.c"
|
|
|
|
|
#undef _Unwind_Find_FDE
|
|
|
|
|
|
|
|
|
|
/* KeyMgr stuff. */
|
|
|
|
|
#define KEYMGR_GCC3_LIVE_IMAGE_LIST 301 /* loaded images */
|
|
|
|
|
#define KEYMGR_GCC3_DW2_OBJ_LIST 302 /* Dwarf2 object list */
|
|
|
|
|
|
|
|
|
|
extern void *_keymgr_get_and_lock_processwide_ptr (int);
|
|
|
|
|
extern void _keymgr_set_and_unlock_processwide_ptr (int, void *);
|
|
|
|
|
extern void _keymgr_unlock_processwide_ptr (int);
|
|
|
|
|
|
|
|
|
|
struct mach_header;
|
|
|
|
|
extern char *getsectdatafromheader (struct mach_header*, const char*,
|
|
|
|
|
const char *, unsigned long *);
|
|
|
|
|
|
|
|
|
|
/* This is referenced from KEYMGR_GCC3_DW2_OBJ_LIST. */
|
|
|
|
|
struct km_object_info {
|
|
|
|
|
struct object *seen_objects;
|
|
|
|
|
struct object *unseen_objects;
|
|
|
|
|
unsigned spare[2];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Node of KEYMGR_GCC3_LIVE_IMAGE_LIST. Info about each resident image. */
|
|
|
|
|
struct live_images {
|
|
|
|
|
unsigned long this_size; /* sizeof (live_images) */
|
|
|
|
|
struct mach_header *mh; /* the image info */
|
|
|
|
|
unsigned long vm_slide;
|
|
|
|
|
void (*destructor)(struct live_images *); /* destructor for this */
|
|
|
|
|
struct live_images *next;
|
|
|
|
|
unsigned int examined_p;
|
|
|
|
|
void *fde;
|
|
|
|
|
void *object_info;
|
|
|
|
|
unsigned long info[2]; /* Future use. */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Bits in the examined_p field of struct live_images. */
|
|
|
|
|
enum {
|
|
|
|
|
EXAMINED_IMAGE_MASK = 1, /* We've seen this one. */
|
|
|
|
|
ALLOCED_IMAGE_MASK = 2, /* The FDE entries were allocated by
|
|
|
|
|
malloc, and must be freed. This isn't
|
|
|
|
|
used by newer libgcc versions. */
|
|
|
|
|
IMAGE_IS_TEXT_MASK = 4 /* This image is in the TEXT segment. */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Delete any data we allocated on a live_images structure.
|
|
|
|
|
IMAGE has already been removed from the KEYMGR_GCC3_LIVE_IMAGE_LIST.
|
|
|
|
|
Called by KeyMgr (which will delete the struct after we return.) */
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
live_image_destructor (struct live_images *image)
|
|
|
|
|
{
|
|
|
|
|
if (image->object_info)
|
|
|
|
|
{
|
|
|
|
|
/* Free any sorted arrays. */
|
|
|
|
|
__deregister_frame_info_bases (image->fde);
|
|
|
|
|
|
|
|
|
|
free (image->object_info);
|
|
|
|
|
image->object_info = NULL;
|
|
|
|
|
if (image->examined_p & ALLOCED_IMAGE_MASK)
|
|
|
|
|
free (image->fde);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Run through the list of live images. If we can allocate memory,
|
|
|
|
|
give each unseen image a new `struct object'. Even if we can't,
|
|
|
|
|
check whether the PC is inside the FDE of each unseen image.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static inline fde *
|
|
|
|
|
examine_objects (void *pc, struct dwarf_eh_bases *bases, int dont_alloc)
|
|
|
|
|
{
|
|
|
|
|
fde *result = NULL;
|
|
|
|
|
struct live_images *image;
|
|
|
|
|
|
|
|
|
|
image = _keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
|
|
|
|
|
|
|
|
|
|
for (; image != NULL; image = image->next)
|
|
|
|
|
if ((image->examined_p & EXAMINED_IMAGE_MASK) == 0)
|
|
|
|
|
{
|
|
|
|
|
char *fde;
|
|
|
|
|
unsigned long sz;
|
|
|
|
|
|
|
|
|
|
fde = getsectdatafromheader (image->mh, "__DATA", "__eh_frame", &sz);
|
|
|
|
|
if (fde == NULL)
|
|
|
|
|
{
|
|
|
|
|
fde = getsectdatafromheader (image->mh, "__TEXT",
|
|
|
|
|
"__eh_frame", &sz);
|
|
|
|
|
if (fde != NULL)
|
|
|
|
|
image->examined_p |= IMAGE_IS_TEXT_MASK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If .eh_frame is empty, don't register at all. */
|
|
|
|
|
if (fde != NULL && sz > 0)
|
|
|
|
|
{
|
|
|
|
|
char *real_fde = (fde + image->vm_slide);
|
|
|
|
|
struct object *ob = NULL;
|
|
|
|
|
struct object panicob;
|
|
|
|
|
|
|
|
|
|
if (! dont_alloc)
|
|
|
|
|
ob = calloc (1, sizeof (struct object));
|
|
|
|
|
dont_alloc |= ob == NULL;
|
|
|
|
|
if (dont_alloc)
|
|
|
|
|
ob = &panicob;
|
|
|
|
|
|
|
|
|
|
ob->pc_begin = (void *)-1;
|
|
|
|
|
ob->tbase = 0;
|
|
|
|
|
ob->dbase = 0;
|
|
|
|
|
ob->u.single = (struct dwarf_fde *)real_fde;
|
|
|
|
|
ob->s.i = 0;
|
|
|
|
|
ob->s.b.encoding = DW_EH_PE_omit;
|
|
|
|
|
ob->fde_end = real_fde + sz;
|
|
|
|
|
|
|
|
|
|
if (! dont_alloc)
|
|
|
|
|
{
|
|
|
|
|
ob->next = unseen_objects;
|
|
|
|
|
unseen_objects = ob;
|
|
|
|
|
|
|
|
|
|
image->destructor = live_image_destructor;
|
|
|
|
|
image->object_info = ob;
|
|
|
|
|
|
|
|
|
|
image->examined_p |= EXAMINED_IMAGE_MASK;
|
|
|
|
|
}
|
|
|
|
|
image->fde = real_fde;
|
|
|
|
|
|
|
|
|
|
result = search_object (ob, pc);
|
|
|
|
|
if (result)
|
|
|
|
|
{
|
|
|
|
|
int encoding;
|
|
|
|
|
|
|
|
|
|
bases->tbase = ob->tbase;
|
|
|
|
|
bases->dbase = ob->dbase;
|
|
|
|
|
|
|
|
|
|
encoding = ob->s.b.encoding;
|
|
|
|
|
if (ob->s.b.mixed_encoding)
|
|
|
|
|
encoding = get_fde_encoding (result);
|
|
|
|
|
read_encoded_value_with_base (encoding,
|
|
|
|
|
base_from_object (encoding, ob),
|
|
|
|
|
result->pc_begin,
|
|
|
|
|
(_Unwind_Ptr *)&bases->func);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
image->examined_p |= EXAMINED_IMAGE_MASK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_keymgr_unlock_processwide_ptr (KEYMGR_GCC3_LIVE_IMAGE_LIST);
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fde *
|
|
|
|
|
_Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases)
|
|
|
|
|
{
|
|
|
|
|
struct km_object_info *the_obj_info;
|
|
|
|
|
fde *ret = NULL;
|
|
|
|
|
|
|
|
|
|
the_obj_info =
|
|
|
|
|
_keymgr_get_and_lock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST);
|
|
|
|
|
if (! the_obj_info)
|
|
|
|
|
the_obj_info = calloc (1, sizeof (*the_obj_info));
|
|
|
|
|
|
|
|
|
|
if (the_obj_info != NULL)
|
|
|
|
|
{
|
|
|
|
|
seen_objects = the_obj_info->seen_objects;
|
|
|
|
|
unseen_objects = the_obj_info->unseen_objects;
|
|
|
|
|
|
|
|
|
|
ret = _Unwind_Find_registered_FDE (pc, bases);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* OK, didn't find it in the list of FDEs we've seen before,
|
|
|
|
|
so go through and look at the new ones. */
|
|
|
|
|
if (ret == NULL)
|
|
|
|
|
ret = examine_objects (pc, bases, the_obj_info == NULL);
|
|
|
|
|
|
|
|
|
|
if (the_obj_info != NULL)
|
|
|
|
|
{
|
|
|
|
|
the_obj_info->seen_objects = seen_objects;
|
|
|
|
|
the_obj_info->unseen_objects = unseen_objects;
|
|
|
|
|
_keymgr_set_and_unlock_processwide_ptr (KEYMGR_GCC3_DW2_OBJ_LIST,
|
|
|
|
|
the_obj_info);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|