OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [ia64/] [fde-vms.c] - Blame information for rev 734

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/* Copyright (C) 2004, 2009, 2011 Free Software Foundation, Inc.
2
   Contributed by Douglas B Rupp <rupp@gnat.com>
3
 
4
   This file is part of GCC.
5
 
6
   GCC is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
 
11
   GCC is distributed in the hope that it will be useful,
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
   GNU General Public License for more details.
15
 
16
   Under Section 7 of GPL version 3, you are granted additional
17
   permissions described in the GCC Runtime Library Exception, version
18
   3.1, as published by the Free Software Foundation.
19
 
20
   You should have received a copy of the GNU General Public License and
21
   a copy of the GCC Runtime Library Exception along with this program;
22
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
   <http://www.gnu.org/licenses/>.  */
24
 
25
/* Locate the FDE entry for a given address, using VMS Starlet routines
26
   to avoid register/deregister calls at DSO load/unload.  */
27
 
28
#include "tconfig.h"
29
#include "tsystem.h"
30
#include "coretypes.h"
31
#include "tm.h"
32
#include "libgcc_tm.h"
33
#include <stddef.h>
34
#include <stdlib.h>
35
#include <stdio.h>
36
#include "unwind-ia64.h"
37
 
38
#define __int64 long
39
#include <vms/ossddef.h>
40
#ifndef SS$_NORMAL
41
#define SS$_NORMAL 1
42
#endif
43
 
44
#define UNW_IVMS_MODE(HEADER) (((HEADER) >> 44) & 0x3L)
45
 
46
typedef struct
47
{
48
  unsigned long start_offset;
49
  unsigned long end_offset;
50
  unsigned long info_offset;
51
  unsigned long gp_value;
52
}  vms_unw_table_entry;
53
 
54
typedef unsigned long long uqword;
55
 
56
/* ENTRY is the unwind table entry found for a PC part of call chain we're
57
   unwinding through.  Return whether we should force the generic unwinder
58
   to resort to "fallback" processing.  */
59
 
60
static int
61
force_fallback_processing_for (void * pc, vms_unw_table_entry * entry)
62
{
63
  static int eh_debug = -1;
64
 
65
  uqword * unw_info_block = (uqword *)entry->info_offset;
66
  uqword header = *unw_info_block;
67
 
68
  /* We need to force fallback processing in two cases:
69
 
70
     1/ The exception dispatch frame, since only our fallback
71
        processing knows how to properly unwind through it, and
72
 
73
     2/ A bottom of stack frame, since only our fallback processing
74
        will ensure we don't try to unwind further past it, which
75
        would get us into unknown territory and likely cause a severe
76
        crash along the way.
77
 
78
     The two cases are indicated by non-default values for specific
79
     bits in the OS Specific Data (OSSD) General Information block
80
     associated with such frames.  */
81
 
82
  ossddef * ossd;
83
 
84
  if (eh_debug == -1)
85
    {
86
      char * EH_DEBUG = getenv ("EH_DEBUG");
87
      eh_debug = EH_DEBUG ? atoi (EH_DEBUG) : 0;
88
    }
89
 
90
  if (eh_debug)
91
    {
92
      printf ("pc @ 0x%p, block @ 0x%p, header = 0x%016llx\n",
93
              pc, unw_info_block, header);
94
      printf ("mode = %d, length = %ld, handler = %d\n",
95
              (int)UNW_IVMS_MODE (header), UNW_LENGTH (header),
96
              UNW_FLAG_EHANDLER (header) || UNW_FLAG_EHANDLER (header));
97
    }
98
 
99
  /* An OSSD block is there for IVMS_MODE == 3 only.  */
100
  if (UNW_IVMS_MODE (header) != 3)
101
    return 0;
102
 
103
  /* The OSSD block is found past the header, unwind descriptor area
104
     and condition handler pointer, if any.  */
105
  ossd = (ossddef *)
106
    /* Beware: uqword pointer arithmetic below.  */
107
    (unw_info_block
108
     + 1
109
     + UNW_LENGTH (header)
110
     + (UNW_FLAG_EHANDLER (header) || UNW_FLAG_EHANDLER (header)));
111
 
112
  /* "A General Information segment may be omitted if all of its fields
113
      would have their default values.  If a General Information segment
114
      is present, it must be the first in the OSSD area."  So ...  */
115
 
116
  if (eh_debug)
117
    printf ("ossd @ 0x%p\n", ossd);
118
 
119
  if (eh_debug && ossd->ossd$v_type == OSSD$K_GENERAL_INFO)
120
    printf ("exc_frame = %d - bot_frame = %d - base_frame = %d\n",
121
            ossd->ossd$v_exception_frame,
122
            ossd->ossd$v_bottom_of_stack,
123
            ossd->ossd$v_base_frame);
124
 
125
  return
126
    ossd->ossd$v_type == OSSD$K_GENERAL_INFO
127
    && (ossd->ossd$v_exception_frame
128
        || ossd->ossd$v_bottom_of_stack || ossd->ossd$v_base_frame);
129
}
130
 
131
/* Return a pointer to the unwind table entry for the function
132
   containing PC, 0 if we cannot find an entry or if the one we find
133
   calls for fallback processing.  */
134
 
135
struct unw_table_entry *
136
_Unwind_FindTableEntry (void *pc, unsigned long *segment_base,
137
                        unsigned long *gp, struct unw_table_entry *ent)
138
{
139
  vms_unw_table_entry vueblock;
140
 
141
  if (SYS$GET_UNWIND_ENTRY_INFO (pc, &vueblock, 0) != SS$_NORMAL)
142
    return 0;
143
 
144
  /* If there is no unwind information, use fallback.  */
145
  if (vueblock.info_offset == 0)
146
    return 0;
147
 
148
  /* If we need to force fallback processing, just pretend there is
149
     no entry.  */
150
  if (force_fallback_processing_for (pc, &vueblock))
151
    return 0;
152
 
153
  *segment_base = 0; /* ??? Fixme. ??? */
154
  *gp = vueblock.gp_value;
155
  ent->start_offset = vueblock.start_offset;
156
  ent->end_offset = vueblock.end_offset;
157
  ent->info_offset = vueblock.info_offset;
158
 
159
  return ent;
160
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.