From: Adam Megacz Date: Wed, 24 Apr 2002 01:33:19 +0000 (+0000) Subject: win32.cc, win32.cc (backtrace): Added this function because Win32 does not supply it. X-Git-Tag: releases/gcc-3.3.0~5506 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c2a6704f600a3227e7bcc1d2a4ecbafb2c08086c;p=thirdparty%2Fgcc.git 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 --- diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 3f08237361d2..d084656e02ef 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 9a8a76909144..8fbe39335d0a 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 c5f434029e03..af1163fbfa9e 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; +}