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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [include/] [java-stack.h] - Blame information for rev 791

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 757 jeremybenn
// java-stack.h - Definitions for unwinding & inspecting the call stack.
2
 
3
/* Copyright (C) 2005, 2006  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
This software is copyrighted work licensed under the terms of the
8
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9
details.  */
10
 
11
#ifndef __JV_STACKTRACE_H__
12
#define __JV_STACKTRACE_H__
13
 
14
#include <stdlib.h>
15
#include <unwind.h>
16
 
17
#include <gcj/cni.h>
18
#include <gcj/javaprims.h>
19
 
20
#include <java-interp.h>
21
 
22
#include <java/lang/Class.h>
23
#include <java/lang/StackTraceElement.h>
24
#include <java/lang/Throwable.h>
25
#include <java/lang/Thread.h>
26
#include <java/util/IdentityHashMap.h>
27
 
28
#include <gnu/gcj/runtime/NameFinder.h>
29
 
30
using namespace gnu::gcj::runtime;
31
using namespace java::lang;
32
 
33
extern "Java"
34
{
35
  namespace gnu
36
  {
37
    namespace classpath
38
    {
39
        class VMStackWalker;
40
    }
41
  }
42
}
43
 
44
#ifdef INTERPRETER
45
struct _Jv_InterpFrameInfo
46
{
47
  _Jv_InterpMethod *meth;
48
  pc_t pc;
49
};
50
#endif
51
 
52
struct _Jv_StackFrame
53
{
54
  _Jv_FrameType type;   /* Native or interpreted.  */
55
  union {
56
#ifdef INTERPRETER
57
    _Jv_InterpFrameInfo interp;
58
#endif
59
    struct {
60
      jclass proxyClass;
61
      _Jv_Method *proxyMethod;
62
    };
63
    struct {
64
      void *ip;
65
      void *start_ip;
66
    };
67
  };
68
  jclass klass;
69
  _Jv_Method *meth;
70
};
71
 
72
struct _Jv_UnwindState;
73
typedef _Unwind_Reason_Code (*_Jv_TraceFn) (_Jv_UnwindState *);
74
 
75
struct _Jv_UnwindState
76
{
77
  jint length;                   // length of FRAMES
78
  jint pos;                      // current position in FRAMES
79
  _Jv_StackFrame *frames;        // array of stack frame data to be filled.
80
#ifdef INTERPRETER
81
  _Jv_InterpFrame *interp_frame; // current frame in the interpreter stack.
82
#endif
83
  _Jv_TraceFn trace_function;    // function to call back after each frame
84
                                 // is enumerated. May be NULL.
85
  void *trace_data;              // additional state data for trace_function.
86
 
87
  _Jv_UnwindState (jint ln)
88
    {
89
      length = ln;
90
      pos = 0;
91
      frames = NULL;
92
#ifdef INTERPRETER
93
      Thread *thread = Thread::currentThread();
94
      // Check for NULL currentThread(), in case an exception is created 
95
      // very early during the runtime startup.
96
      if (thread)
97
        interp_frame = (_Jv_InterpFrame *) thread->interp_frame;
98
      else
99
        interp_frame = NULL;
100
#endif
101
      trace_function = NULL;
102
      trace_data = NULL;
103
    }
104
};
105
 
106
class _Jv_StackTrace
107
{
108
private:
109
  int length;
110
  _Jv_StackFrame frames[];
111
 
112
  static java::util::IdentityHashMap *ncodeMap;
113
  static void UpdateNCodeMap ();
114
  static jclass ClassForFrame (_Jv_StackFrame *frame);
115
  static void FillInFrameInfo (_Jv_StackFrame *frame);
116
  static void getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
117
                                    jstring *sourceFileName, jint *lineNum,
118
                                    jstring *methodName);
119
 
120
  static _Unwind_Reason_Code UnwindTraceFn (struct _Unwind_Context *context,
121
    void *state_ptr);
122
 
123
  static _Unwind_Reason_Code calling_class_trace_fn (_Jv_UnwindState *state);
124
  static _Unwind_Reason_Code non_system_trace_fn (_Jv_UnwindState *state);
125
  static _Unwind_Reason_Code accesscontrol_trace_fn (_Jv_UnwindState *state);
126
  static _Unwind_Reason_Code stackwalker_trace_fn (_Jv_UnwindState *state);
127
  static _Unwind_Reason_Code stackwalker_nnl_trace_fn (_Jv_UnwindState *state);
128
 
129
public:
130
  static _Jv_StackTrace *GetStackTrace (void);
131
  static JArray< ::java::lang::StackTraceElement *>*
132
    GetStackTraceElements (_Jv_StackTrace *trace,
133
    java::lang::Throwable *throwable);
134
  static jclass GetCallingClass (jclass);
135
  static void GetCallerInfo (jclass checkClass, jclass *, _Jv_Method **);
136
  static ClassLoader *GetFirstNonSystemClassLoader (void);
137
  static jobjectArray GetAccessControlStack ();
138
  static JArray<jclass> *GetStackWalkerStack ();
139
  static jclass GetStackWalkerCallingClass ();
140
  static ClassLoader *GetStackWalkerFirstNonNullLoader ();
141
 
142
  friend jclass _Jv_GetMethodDeclaringClass (jmethodID);
143
  friend class gnu::classpath::VMStackWalker;
144
};
145
 
146
// Information about a given address.
147
struct _Jv_AddrInfo
148
{
149
  // File name of the defining module.
150
  const char *file_name;
151
 
152
  // Base address of the loaded module.
153
  void *base;
154
 
155
  // Name of the nearest symbol.
156
  const char *sym_name;
157
 
158
  // Address of the nearest symbol.
159
  void *sym_addr;
160
 
161
  ~_Jv_AddrInfo (void)
162
    {
163
      // On systems with a real dladdr(), the file and symbol names given by
164
      // _Jv_platform_dladdr() are not dynamically allocated.  On Windows,
165
      // they are.
166
 
167
#ifdef WIN32
168
      if (file_name)
169
        free ((void *)file_name);
170
 
171
      if (sym_name)
172
        free ((void *)sym_name);
173
#endif /* WIN32 */
174
    }
175
};
176
 
177
#endif /* __JV_STACKTRACE_H__ */

powered by: WebSVN 2.1.0

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