This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

backtrace() for Win32



I'm checking this in.

  - a

2002-04-23  Adam Megacz <adam@xwt.org>

        * win32.cc, include/win32.cc (backtrace): Added this function
        because Win32 does not supply it.


Index: win32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/win32.cc,v
retrieving revision 1.4.8.7
diff -u -r1.4.8.7 win32.cc
--- win32.cc    11 Apr 2002 22:23:56 -0000      1.4.8.7
+++ win32.cc    24 Apr 2002 01:02:23 -0000
@@ -195,3 +195,25 @@
         break;
     }
 }
+
+/* Store up to SIZE return address of the current program state in
+   ARRAY and return the exact number of values stored.  */
+int
+backtrace (void **__array, int __size)
+{
+  register void *_ebp __asm__ ("ebp");
+  register void *_esp __asm__ ("esp");
+  unsigned int *rfp;
+
+  int i=0;
+  for (rfp = *(unsigned int**)_ebp;
+       rfp && i < __size;
+       rfp = *(unsigned int **)rfp)
+    {
+      int diff = *rfp - (unsigned int)rfp;
+      if ((void*)rfp < _esp || diff > 4 * 1024 || diff < 0) break;
+
+    __array[i++] = (void*)(rfp[1]-4);
+  }
+  return i;
+}
Index: include/win32.h
===================================================================
RCS file: /cvs/gcc/gcc/libjava/include/win32.h,v
retrieving revision 1.3.8.4
diff -u -r1.3.8.4 win32.h
--- include/win32.h     7 Apr 2002 11:30:09 -0000       1.3.8.4
+++ include/win32.h     24 Apr 2002 01:02:23 -0000
@@ -29,4 +29,10 @@
   // Ignore.
 }
 
+#define HAVE_BACKTRACE
+
+/* Store up to SIZE return address of the current program state in
+   ARRAY and return the exact number of values stored.  */
+extern int backtrace (void **__array, int __size);
+
 #endif /* __JV_WIN32_H__ */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]