2003/02/25 22:09:41
[org.ibex.core.git] / README
1 ==============================================================================
2 XWT README
3       
4 ______________________________________________________________________________
5 Documentation
6
7 If you're new to XWT, you should read the documentation in the order
8 presented below:
9
10 - README [this file]
11
12       Start here. Includes a map of all other documentation and a
13       description of the directory strucure
14
15 - The XWT home page [http://www.xwt.org/]
16
17 - The XWT tutorial [http://www.xwt.org/tutorial.html]
18
19       Gentle introduction to what XWT is, and how to write
20       .xwt's. Good for anybody who wants to write XWT applications.
21
22 - The XWT reference [http://www.xwt.org/reference.html]
23
24       Precise, technical spec of exactly how XWT works. Assumes
25       familiarity with XWT (ie, you've read the tutorial). This is the
26       authoritative source for how an XWT engine should
27       behave.
28
29
30 ______________________________________________________________________________
31 Directory Structure
32
33 /
34    AUTHORS                - people involved in developing XWT
35    README                 - this file
36    COPYING                - copyright information for all files in this distro
37    TM                     - trademark information for XWT
38    Makefile               - build file for gcc 3.3
39    bin/                   - all binary stuff generated by xwt builds
40    gcc/                   - build area for a custom copy of gcc3.3 and binutils2.13
41        Makefile           - will download, configure, compile, and private-install gcc3.3/binutils2.13
42    lib/                   - any third-party binary stuff needed during the build process
43        javago             - a copy of the javago post-compilation bytecode inliner
44        netscape.jar       - minimal set of classes required for compiling against Netcape's Applet interfaces
45        msjvm.jar          - minimal set of classes required for compiling against Microsoft's Applet interfaces
46        jump.jar           - the jump2 bytecode-to-palmos translator
47        libgcj-minimal.jar - a tiny portion of libgcj.jar; allows java->bytecode compilation without gcj
48    src/                   - all java source files and xwt sources go here
49        org/
50            bouncycastle/  - the BouncyCastle Crypto Library
51            mozilla/       - a copy of Rhino, the Mozilla JavaScript interpreter
52            xwt/builtin/   - .xwt's and .png's that are essential to bootstrapping the engine
53            xwt/plat/      - platform-specific code
54
55 ______________________________________________________________________________
56 Build Targets and Requirements
57
58 Build requirements:
59 - jdk 1.4+
60 - jikes (warning: Jikes 1.16 has a fatal bug; use 1.15)
61 - gcj 3.3+
62 - binutils 2.13+
63 - fastjar
64
65 If you already have a suitably configured gcj 3.3 and binutils 2.13+
66 you can set "gcc_path" to point at its installation location;
67 otherwise the Makefile will download, configure, compile, and install
68 gcc and binutils.
69
70 Public build targets:
71
72     compile       - compiles all .java files into bin/*.class
73     Win32         - Win95 or later (bin-Win32/xwt.exe)
74     Linux         - Linux 2.2 or later (bin-Linux/xwt.linux)
75     Java2         - Any Java 1.2+ compliant JVM
76     clean         - cleanup
77
78
79 ______________________________________________________________________________
80 inet_addr patch
81
82 Index: java/net/natInetAddress.cc
83 ===================================================================
84 RCS file: /cvs/gcc/gcc/libjava/java/net/natInetAddress.cc,v
85 retrieving revision 1.18.18.1
86 diff -u -r1.18.18.1 natInetAddress.cc
87 --- java/net/natInetAddress.cc  4 Mar 2002 20:02:19 -0000       1.18.18.1
88 +++ java/net/natInetAddress.cc  27 May 2002 22:54:40 -0000
89 @@ -9,6 +9,7 @@
90  details.  */
91
92  #include <config.h>
93 +#include <platform.h>
94
95  #ifdef WIN32
96
97 Index: include/win32.h
98 ===================================================================
99 RCS file: /cvs/gcc/gcc/libjava/include/win32.h,v
100 retrieving revision 1.3.8.5
101 diff -u -r1.3.8.5 win32.h
102 --- include/win32.h     24 Apr 2002 01:04:45 -0000      1.3.8.5
103 +++ include/win32.h     27 May 2002 22:54:40 -0000
104 @@ -35,4 +35,8 @@
105     ARRAY and return the exact number of values stored.  */
106  extern int backtrace (void **__array, int __size);
107
108 +// configure cannot correctly detect inet_addr due to Win32's
109 +// oddball header naming scheme
110 +#define HAVE_INET_ADDR
111 +
112  #endif /* __JV_WIN32_H__ */
113
114
115
116 ______________________________________________________________________________
117 Throwable.printStackTrace() patch
118
119 Index: Class.h
120 ===================================================================
121 RCS file: /cvs/gcc/gcc/libjava/java/lang/Class.h,v
122 retrieving revision 1.43
123 diff -u -r1.43 Class.h
124 --- Class.h     21 Dec 2001 19:47:50 -0000      1.43
125 +++ Class.h     24 Apr 2002 03:06:14 -0000
126 @@ -308,6 +308,7 @@
127    friend void _Jv_LayoutVTableMethods (jclass klass);
128    friend void _Jv_SetVTableEntries (jclass, _Jv_VTable *);
129    friend void _Jv_MakeVTable (jclass);
130 +  friend JArray<java::lang::reflect::Method*>* _Jv_GetAllMethods();
131  
132    // Return array class corresponding to element type KLASS, creating it if
133    // necessary.
134 Index: ClassLoader.java
135 ===================================================================
136 RCS file: /cvs/gcc/gcc/libjava/java/lang/ClassLoader.java,v
137 retrieving revision 1.16
138 diff -u -r1.16 ClassLoader.java
139 --- ClassLoader.java    7 Dec 2001 23:34:12 -0000       1.16
140 +++ ClassLoader.java    24 Apr 2002 03:06:14 -0000
141 @@ -577,4 +577,8 @@
142      // Default to returning null.  Derived classes implement this.
143      return null;
144    }
145 +
146 +  static native java.lang.reflect.Method[] getAllMethods();
147 +  static native long[] getAllMethodAddrs();
148 +
149  }
150 Index: Throwable.java
151 ===================================================================
152 RCS file: /cvs/gcc/gcc/libjava/java/lang/Throwable.java,v
153 retrieving revision 1.10
154 diff -u -r1.10 Throwable.java
155 --- Throwable.java      24 Feb 2001 03:52:49 -0000      1.10
156 +++ Throwable.java      24 Apr 2002 03:06:14 -0000
157 @@ -123,21 +123,64 @@
158      printStackTrace (writer);
159    }
160  
161 +  private native static long longFromStackTraceBytes(byte[] stackTrace, int i);
162 +
163    public void printStackTrace (PrintWriter wr)
164    {
165 -    try
166 -      {
167 -       CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
168 -       PrintWriter writer = new PrintWriter (cPlusPlusFilter);
169 -       printRawStackTrace (writer);    
170 -       writer.close ();
171 -       if (cPlusPlusFilter.written == 0) // The demangler has failed...
172 -         printRawStackTrace (wr);
173 +      try
174 +          {
175 +              CPlusPlusDemangler cPlusPlusFilter = new CPlusPlusDemangler (wr);
176 +              PrintWriter writer = new PrintWriter (cPlusPlusFilter);
177 +              printRawStackTrace (writer);     
178 +              writer.close ();
179 +              if (cPlusPlusFilter.written > 0) return;
180 +          }
181 +      catch (Exception e1)
182 +          {
183 +          }
184 +
185 +      wr.println(toString());
186 +      if (stackTrace == null) {
187 +          wr.flush();
188 +          return;
189        }
190 -    catch (Exception e1)
191 -      {
192 -       printRawStackTrace (wr);
193 +      
194 +      long[] allAddrs = ClassLoader.getAllMethodAddrs();
195 +      java.lang.reflect.Method[] meths = ClassLoader.getAllMethods();
196 +      
197 +      // FIXME: assumes little endian
198 +      for(int i=0; i<stackTrace.length; i++) {
199 +          long addr = longFromStackTraceBytes(stackTrace, i);
200 +          if (addr == 0) break;
201 +          
202 +          int whichMethod = -1;
203 +          for(int j=0; j<allAddrs.length; j++) {
204 +              if (allAddrs[j] <= addr &&
205 +                  (whichMethod == -1 || allAddrs[whichMethod] < allAddrs[j])) {
206 +                  whichMethod = j;
207 +              }
208 +          }
209 +          
210 +          if (whichMethod == -1) {
211 +              wr.println("[" + Long.toString(addr, 16) + "]  " + "??");
212 +              continue;
213 +          }
214 +          
215 +          if (meths[whichMethod].getDeclaringClass().getName().equals("gnu.gcj.runtime.FirstThread") &&
216 +              meths[whichMethod].getName().equals("call_main"))
217 +              break;
218 +          
219 +          wr.println("    [" + Long.toString(addr, 16) + "] " +
220 +                     meths[whichMethod].getDeclaringClass().getName() + "." +
221 +                     meths[whichMethod].getName() + "() " +
222 +                     "+" + (addr - allAddrs[whichMethod])
223 +                     );
224 +          
225 +          if (java.lang.Thread.class.isAssignableFrom(meths[whichMethod].getDeclaringClass()) &&
226 +              meths[whichMethod].getName().equals("run"))
227 +              break;
228        }
229 +      wr.flush();
230    }
231  
232    public Throwable ()
233 Index: natClassLoader.cc
234 ===================================================================
235 RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
236 retrieving revision 1.47.8.1
237 diff -u -r1.47.8.1 natClassLoader.cc
238 --- natClassLoader.cc   2 Apr 2002 22:19:55 -0000       1.47.8.1
239 +++ natClassLoader.cc   24 Apr 2002 03:06:14 -0000
240 @@ -40,6 +40,10 @@
241  #include <java/lang/StringBuffer.h>
242  #include <java/io/Serializable.h>
243  #include <java/lang/Cloneable.h>
244 +#include <java/lang/reflect/Method.h>
245 +
246 +#include<java/lang/reflect/Constructor.h>
247 +#include<gcj/method.h>
248  
249  // FIXME: remove these.
250  #define CloneableClass java::lang::Cloneable::class$
251 @@ -347,6 +351,50 @@
252  static jclass loaded_classes[HASH_LEN];
253  
254  // This is the root of a linked list of classes
255 +
256 +JArray<java::lang::reflect::Method*>*
257 +java::lang::ClassLoader::getAllMethods()
258 +{
259 +    return _Jv_GetAllMethods();
260 +}
261 +
262 +JArray<jlong>*
263 +java::lang::ClassLoader::getAllMethodAddrs()
264 +{
265 +    JArray<java::lang::reflect::Method*>* arr = _Jv_GetAllMethods();
266 +    java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(arr);
267 +    JArray<jlong>* ret = JvNewLongArray(arr->length);
268 +    jlong* retel = (jlong*)elements(ret);
269 +    for(int i=0; i<arr->length; i++)
270 +        retel[i] = (jlong)((unsigned int)(_Jv_FromReflectedMethod (el[i])->ncode));
271 +    return ret;
272 +}
273 +
274 +JArray<java::lang::reflect::Method*>*
275 +_Jv_GetAllMethods()
276 +{
277 +  int numMethods = 0;
278 +
279 +  for(int i=0; i<HASH_LEN; i++)
280 +      for(jclass c = loaded_classes[i]; c; c = c->next)
281 +          numMethods += c->getDeclaredMethods()->length;
282 +
283 +  JArray<java::lang::reflect::Method*>* ret =
284 +    (JArray<java::lang::reflect::Method*>*)
285 +    JvNewObjectArray(numMethods, &java::lang::reflect::Method::class$, NULL);
286 +
287 +  java::lang::reflect::Method** el = (java::lang::reflect::Method**)elements(ret);
288 +
289 +  for(int i=0; i<HASH_LEN; i++)
290 +      for(jclass c = loaded_classes[i]; c; c = c->next) {
291 +          JArray<java::lang::reflect::Method*>* methods = c->getDeclaredMethods();
292 +          jint len = methods->length;
293 +          java::lang::reflect::Method** meths = (java::lang::reflect::Method**)elements(methods);
294 +          for(int j=0; j<len; j++) el[--numMethods] = meths[j];
295 +      }
296 +
297 +  return ret;
298 +}
299  
300  \f
301  
302 Index: natThrowable.cc
303 ===================================================================
304 RCS file: /cvs/gcc/gcc/libjava/java/lang/natThrowable.cc,v
305 retrieving revision 1.11
306 diff -u -r1.11 natThrowable.cc
307 --- natThrowable.cc     7 Feb 2002 19:26:06 -0000       1.11
308 +++ natThrowable.cc     24 Apr 2002 03:06:14 -0000
309 @@ -32,6 +32,7 @@
310  #include <stdio.h>
311  
312  #include <unistd.h>
313 +#include <platform.h>
314  
315  #ifdef HAVE_EXECINFO_H
316  #include <execinfo.h>
317 @@ -102,3 +103,18 @@
318  #endif /* HAVE_BACKTRACE */
319    wr->flush ();
320  }
321 +
322 +// Returns the i^th call address in the stackTrace member, or 0 if i
323 +// is beyond the end of the trace. This has to be done in C++ because
324 +// the addresses in stackTrace are the same width as the platform's
325 +// pointers (which is unknown to Java code), and stackTrace is a
326 +// byte[] using the platform's endianness (which is unknown to Java
327 +// code).
328 +jlong
329 +java::lang::Throwable::longFromStackTraceBytes(jbyteArray stackArr, jint i)
330 +{
331 +    if (i * sizeof(void*) > stackArr->length) return 0;
332 +    unsigned int* stack = (unsigned int*)elements(stackArr);
333 +    return (jlong)stack[i];
334 +}
335 +
336
337
338
339
340