1 // natVMThrowable.cc - native helper methods for Throwable
3 /* Copyright (C) 2000, 2002 Free Software Foundation, Inc
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
12 * @author Andrew Haley <aph@cygnus.com>
13 * @author Mark Wielaard <mark@klomp.org>
15 * Native helper methods for VM specific Throwable support.
24 #include <gnu/gcj/RawData.h>
25 #include <java/lang/Object.h>
26 #include <java-threads.h>
27 #include <java/lang/Throwable.h>
28 #include <java/lang/VMThrowable.h>
30 #include <sys/types.h>
36 #ifdef HAVE_EXECINFO_H
40 /* FIXME: size of the stack trace is limited to 128 elements. It's
41 undoubtedly sensible to limit the stack trace, but 128 is rather
42 arbitrary. It may be better to configure this. */
44 java::lang::VMThrowable *
45 java::lang::VMThrowable::fillInStackTrace (java::lang::Throwable* t)
49 #if defined (HAVE_BACKTRACE)
50 VMThrowable* state = new VMThrowable;
53 // We subtract 1 from the number of elements because we don't want
54 // to include the calls to fillInStackTrace in the trace.
55 int n = backtrace (p, 128) - 1;
61 addrs = (void **) _Jv_Malloc (n * sizeof p[0]);
68 state->stackTraceAddrs = reinterpret_cast<gnu::gcj::RawData *> (addrs);