From c2a6704f600a3227e7bcc1d2a4ecbafb2c08086c Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Wed, 24 Apr 2002 01:33:19 +0000 Subject: [PATCH] win32.cc, win32.cc (backtrace): Added this function because Win32 does not supply it. 2002-04-23 Adam Megacz * win32.cc, include/win32.cc (backtrace): Added this function because Win32 does not supply it. From-SVN: r52701 --- libjava/ChangeLog | 5 +++++ libjava/include/win32.h | 6 ++++++ libjava/win32.cc | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3f08237361d..d084656e02e 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2002-04-23 Adam Megacz + + * win32.cc, include/win32.cc (backtrace): Added this function + because Win32 does not supply it. + 2002-04-21 David S. Miller * include/dwarf2-signal.h (MAKE_THROW_FRAME, sparc32): Document diff --git a/libjava/include/win32.h b/libjava/include/win32.h index 9a8a7690914..8fbe39335d0 100644 --- a/libjava/include/win32.h +++ b/libjava/include/win32.h @@ -29,4 +29,10 @@ _Jv_platform_close_on_exec (jint) // 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__ */ diff --git a/libjava/win32.cc b/libjava/win32.cc index c5f434029e0..af1163fbfa9 100644 --- a/libjava/win32.cc +++ b/libjava/win32.cc @@ -195,3 +195,25 @@ _Jv_platform_initProperties (java::util::Properties* newprops) 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; +} -- 2.30.2