public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* backtrace() for Win32
@ 2002-04-23 18:54 Adam Megacz
  2002-04-23 20:15 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Megacz @ 2002-04-23 18:54 UTC (permalink / raw)
  To: java


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__ */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-24 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-23 18:54 backtrace() for Win32 Adam Megacz
2002-04-23 20:15 ` Tom Tromey
2002-04-24  8:55   ` Mark Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).