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