Home | History | Annotate | Download | only in x86
      1 /* libunwind - a platform-independent unwind library
      2    Copyright (c) 2003, 2005 Hewlett-Packard Development Company, L.P.
      3 	Contributed by David Mosberger-Tang <davidm (at) hpl.hp.com>
      4 
      5 This file is part of libunwind.
      6 
      7 Permission is hereby granted, free of charge, to any person obtaining
      8 a copy of this software and associated documentation files (the
      9 "Software"), to deal in the Software without restriction, including
     10 without limitation the rights to use, copy, modify, merge, publish,
     11 distribute, sublicense, and/or sell copies of the Software, and to
     12 permit persons to whom the Software is furnished to do so, subject to
     13 the following conditions:
     14 
     15 The above copyright notice and this permission notice shall be
     16 included in all copies or substantial portions of the Software.
     17 
     18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
     25 
     26 #include "unwind_i.h"
     27 #include "dwarf_i.h"
     28 
     29 HIDDEN define_lock (x86_lock);
     30 HIDDEN int tdep_init_done;
     31 
     32 /* See comments for svr4_dbx_register_map[] in gcc/config/i386/i386.c.  */
     33 
     34 HIDDEN const uint8_t dwarf_to_unw_regnum_map[19] =
     35   {
     36     UNW_X86_EAX, UNW_X86_ECX, UNW_X86_EDX, UNW_X86_EBX,
     37     UNW_X86_ESP, UNW_X86_EBP, UNW_X86_ESI, UNW_X86_EDI,
     38     UNW_X86_EIP, UNW_X86_EFLAGS, UNW_X86_TRAPNO,
     39     UNW_X86_ST0, UNW_X86_ST1, UNW_X86_ST2, UNW_X86_ST3,
     40     UNW_X86_ST4, UNW_X86_ST5, UNW_X86_ST6, UNW_X86_ST7
     41   };
     42 
     43 HIDDEN void
     44 tdep_init (void)
     45 {
     46   intrmask_t saved_mask;
     47 
     48   sigfillset (&unwi_full_mask);
     49 
     50   lock_acquire (&x86_lock, saved_mask);
     51   {
     52     if (tdep_init_done)
     53       /* another thread else beat us to it... */
     54       goto out;
     55 
     56     mi_init ();
     57 
     58     dwarf_init ();
     59 
     60 #ifndef UNW_REMOTE_ONLY
     61     x86_local_addr_space_init ();
     62 #endif
     63     tdep_init_done = 1;	/* signal that we're initialized... */
     64   }
     65  out:
     66   lock_release (&x86_lock, saved_mask);
     67 }
     68