OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [ada/] [tb-gcc.c] - Blame information for rev 384

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
/****************************************************************************
2
 *                                                                          *
3
 *                         GNAT COMPILER COMPONENTS                         *
4
 *                                                                          *
5
 *                   T R A C E B A C K - G C C t a b l e s                  *
6
 *                                                                          *
7
 *                          C Implementation File                           *
8
 *                                                                          *
9
 *          Copyright (C) 2004-2009, Free Software Foundation, Inc.         *
10
 *                                                                          *
11
 * GNAT is free software;  you can  redistribute it  and/or modify it under *
12
 * terms of the  GNU General Public License as published  by the Free Soft- *
13
 * ware  Foundation;  either version 2,  or (at your option) any later ver- *
14
 * sion.  GNAT is distributed in the hope that it will be useful, but WITH- *
15
 * OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY *
16
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License *
17
 * for  more details.  You should have  received  a copy of the GNU General *
18
 * Public License  distributed with GNAT;  see file COPYING.  If not, write *
19
 * to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, *
20
 * Boston, MA 02110-1301, USA.                                              *
21
 *                                                                          *
22
 * As a  special  exception,  if you  link  this file  with other  files to *
23
 * produce an executable,  this file does not by itself cause the resulting *
24
 * executable to be covered by the GNU General Public License. This except- *
25
 * ion does not  however invalidate  any other reasons  why the  executable *
26
 * file might be covered by the  GNU Public License.                        *
27
 *                                                                          *
28
 * GNAT was originally developed  by the GNAT team at  New York University. *
29
 * Extensive contributions were provided by Ada Core Technologies Inc.      *
30
 *                                                                          *
31
 ****************************************************************************/
32
 
33
/* This is an implementation of the __gnat_backtrace routine using the
34
   underlying GCC unwinding support associated with the exception handling
35
   infrastructure.  This will only work for ZCX based applications.  */
36
 
37
#include <unwind.h>
38
 
39
/* The implementation boils down to a call to _Unwind_Backtrace with a
40
   tailored callback and carried-on data structure to keep track of the
41
   input parameters we got as well as of the basic processing state.  */
42
 
43
/******************
44
 * trace_callback *
45
 ******************/
46
 
47
#if !defined (__USING_SJLJ_EXCEPTIONS__)
48
 
49
typedef struct {
50
  void ** traceback;
51
  int max_len;
52
  void * exclude_min;
53
  void * exclude_max;
54
  int  n_frames_to_skip;
55
  int  n_frames_skipped;
56
  int  n_entries_filled;
57
} uw_data_t;
58
 
59
#if defined (__ia64__) && defined (__hpux__)
60
#include <uwx.h>
61
#endif
62
 
63
static _Unwind_Reason_Code
64
trace_callback (struct _Unwind_Context * uw_context, uw_data_t * uw_data)
65
{
66
  char * pc;
67
 
68
#if defined (__ia64__) && defined (__hpux__)
69
  /* Work around problem with _Unwind_GetIP on ia64 HP-UX. */
70
  uwx_get_reg ((struct uwx_env *) uw_context, UWX_REG_IP, (uint64_t *) &pc);
71
#else
72
  pc = (char *) _Unwind_GetIP (uw_context);
73
#endif
74
 
75
  if (uw_data->n_frames_skipped < uw_data->n_frames_to_skip)
76
    {
77
      uw_data->n_frames_skipped ++;
78
      return _URC_NO_REASON;
79
    }
80
 
81
  if (uw_data->n_entries_filled >= uw_data->max_len)
82
    return _URC_NORMAL_STOP;
83
 
84
  if (pc < (char *)uw_data->exclude_min || pc > (char *)uw_data->exclude_max)
85
    uw_data->traceback [uw_data->n_entries_filled ++] = pc + PC_ADJUST;
86
 
87
  return _URC_NO_REASON;
88
}
89
 
90
#endif
91
 
92
/********************
93
 * __gnat_backtrace *
94
 ********************/
95
 
96
int
97
__gnat_backtrace (void ** traceback __attribute__((unused)),
98
                  int max_len __attribute__((unused)),
99
                  void * exclude_min __attribute__((unused)),
100
                  void * exclude_max __attribute__((unused)),
101
                  int skip_frames __attribute__((unused)))
102
{
103
#if defined (__USING_SJLJ_EXCEPTIONS__)
104
  /* We have no unwind material (tables) at hand with sjlj eh, and no
105
     way to retrieve complete and accurate call chain information from
106
     the context stack we maintain.  */
107
  return 0;
108
#else
109
  uw_data_t uw_data;
110
  /* State carried over during the whole unwinding process.  */
111
 
112
  uw_data.traceback   = traceback;
113
  uw_data.max_len     = max_len;
114
  uw_data.exclude_min = exclude_min;
115
  uw_data.exclude_max = exclude_max;
116
 
117
  uw_data.n_frames_to_skip = skip_frames;
118
 
119
  uw_data.n_frames_skipped = 0;
120
  uw_data.n_entries_filled = 0;
121
 
122
  _Unwind_Backtrace ((_Unwind_Trace_Fn)trace_callback, &uw_data);
123
 
124
  return uw_data.n_entries_filled;
125
#endif
126
}

powered by: WebSVN 2.1.0

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