From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5989 invoked by alias); 24 Apr 2002 01:04:48 -0000 Mailing-List: contact java-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: java-owner@gcc.gnu.org Received: (qmail 5925 invoked from network); 24 Apr 2002 01:04:46 -0000 Received: from unknown (HELO alonzo.megacz.com) (64.23.37.80) by sources.redhat.com with SMTP; 24 Apr 2002 01:04:46 -0000 Received: from megacz by alonzo.megacz.com with local (Exim 3.12 #1 (Debian)) id 170B9H-0004IT-00 for ; Tue, 23 Apr 2002 18:00:43 -0700 To: java@gcc.gnu.org Subject: backtrace() for Win32 From: Adam Megacz X-Home-Page: http://www.megacz.com/adam Organization: Myself Date: Tue, 23 Apr 2002 18:54:00 -0000 Message-ID: <86ofg9lxl0.fsf@megacz.com> User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-04/txt/msg00332.txt.bz2 I'm checking this in. - a 2002-04-23 Adam Megacz * 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__ */