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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [gnu/] [gcj/] [util/] [natDebug.cc] - Blame information for rev 22

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

Line No. Rev Author Line
1 14 jlechner
// natDebug -- C++ side of Debug
2
 
3
/* Copyright (C) 2004  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
#include <config.h>
12
#include <stddef.h>
13
#include <gcj/cni.h>
14
#include <gcj/field.h>
15
#include <gcj/javaprims.h>
16
#include <java/lang/reflect/Field.h>
17
#include <java/lang/Class.h>
18
#include <java/lang/Byte.h>
19
#include <java/lang/Short.h>
20
#include <java/lang/Integer.h>
21
#include <java/lang/Long.h>
22
#include <java/lang/Float.h>
23
#include <java/lang/Double.h>
24
#include <java/lang/Boolean.h>
25
#include <java/lang/Character.h>
26
#include <java/lang/IllegalArgumentException.h>
27
 
28
#include <gnu/gcj/util/Debug.h>
29
 
30
jlong
31
gnu::gcj::util::Debug::getAddr (::java::lang::Object *o)
32
{
33
  return (jlong)(size_t)o;
34
}
35
 
36
JArray< ::java::lang::reflect::Field *> *
37
gnu::gcj::util::Debug::getDeclaredFields (::java::lang::Class *c)
38
{
39
  return c->getDeclaredFields (false);
40
}
41
 
42
static void *
43
getField (::java::lang::Object *obj,
44
          ::java::lang::reflect::Field *field)
45
{
46
  using namespace java::lang::reflect;
47
 
48
  jfieldID fld = _Jv_FromReflectedField (field);
49
  _Jv_ushort flags = fld->getModifiers();
50
 
51
  if (flags & Modifier::STATIC)
52
    {
53
      jclass fldClass = field->getDeclaringClass ();
54
      JvInitClass(fldClass);
55
      return (void*) fld->u.addr;
56
    }
57
  else
58
    {
59
      return (void*) ((char*) obj + fld->getOffset ());
60
    }
61
}
62
 
63
::java::lang::Object *
64
gnu::gcj::util::Debug::getField (::java::lang::Object *o,
65
                                   ::java::lang::reflect::Field *field)
66
{
67
  void *addr = ::getField (o, field);
68
 
69
  jclass type = field->getType();
70
  if (! type->isPrimitive ())
71
    return * (jobject*) addr;
72
  if (type == JvPrimClass (double))
73
    return new java::lang::Double (* (jdouble*) addr);
74
  if (type == JvPrimClass (float))
75
    return new java::lang::Float (* (jfloat*) addr);
76
  if (type == JvPrimClass (long))
77
    return new java::lang::Long (* (jlong*) addr);
78
  if (type == JvPrimClass (int))
79
    return new java::lang::Integer (* (jint*) addr);
80
  if (type == JvPrimClass (short))
81
    return new java::lang::Short (* (jshort*) addr);
82
  if (type == JvPrimClass (byte))
83
    return new java::lang::Byte (* (jbyte*) addr);
84
  if (type == JvPrimClass (char))
85
    return new java::lang::Character (* (jchar*) addr);
86
  if (type == JvPrimClass (boolean))
87
    {
88
      _Jv_InitClass (&java::lang::Boolean::class$);
89
      if (* (jboolean*) addr)
90
        return java::lang::Boolean::TRUE;
91
      else
92
        return java::lang::Boolean::FALSE;
93
    }
94
  throw new java::lang::IllegalArgumentException;
95
}
96
 
97
/* A simple method of printing an object that can be called from a
98
   debugger.  */
99
extern "C"
100
void
101
_Jv_Debug (void *p)
102
{
103
  (new ::gnu::gcj::util::Debug ())->write ((jobject)p);
104
}
105
 
106
extern "C"
107
void
108
_Jv_DeepDebug (void *p, int depth)
109
{
110
  (new ::gnu::gcj::util::Debug (depth))->write ((jobject)p);
111
}
112
 
113
extern "C"
114
void
115
_Jv_StaticDeepDebug (void *p, int depth)
116
{
117
  (new ::gnu::gcj::util::Debug (depth, true))->write ((jobject)p);
118
}

powered by: WebSVN 2.1.0

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