* Removed all Id tags.
[cacao.git] / src / vm / jit / stacktrace.h
index 8440bda4ae1cf696d8e5b039c47a46ceb5680882..a2eddd4c4c4b7d6455e73663ec9af6cff35bd99d 100644 (file)
@@ -1,9 +1,9 @@
 /* src/vm/jit/stacktrace.h - header file for stacktrace generation
 
-   Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
-   R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
-   C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
-   Institut f. Computersprachen - TU Wien
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
 
    This file is part of CACAO.
 
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.
-
-   Contact: cacao@complang.tuwien.ac.at
-
-   Authors: Christian Thalinger
-
-   Changes:
-
-   $Id: stacktrace.h 2914 2005-07-05 13:39:44Z twisti $
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
 
 */
 
 
 /* forward typedefs ***********************************************************/
 
-typedef struct native_stackframeinfo native_stackframeinfo;
-typedef struct stackTraceBuffer stackTraceBuffer;
-typedef struct stacktraceelement stacktraceelement;
+typedef struct stackframeinfo stackframeinfo;
+typedef struct stacktracebuffer stacktracebuffer;
+typedef struct stacktrace_entry stacktrace_entry;
 
 #include "config.h"
-#include "types.h"
+#include "vm/types.h"
 
-#include "vm/method.h"
+#include "vmcore/class.h"
+#include "vmcore/method.h"
 
 
-struct native_stackframeinfo {
-       void        *oldThreadspecificHeadValue;
-       void       **addressOfThreadspecificHead;
-       methodinfo  *method;
-#if defined(__ALPHA__)
-       void        *savedpv;
-#endif
-       void        *beginOfJavaStackframe; /*only used if != 0*/ /* on i386 and x86_64 this points to the return addres stored directly below the stackframe*/
-       functionptr  returnToFromNative;
+/* stackframeinfo **************************************************************
 
-#if 0
-       void *returnFromNative;
-       void *addrReturnFromNative;
-       methodinfo *method;
-       native_stackframeinfo *next;
-       native_stackframeinfo *prev;
-#endif
+   ATTENTION: Keep the number of elements of this structure even, to
+   make sure that the stack keeps aligned (e.g. 16-bytes for x86_64).
+
+*******************************************************************************/
+
+struct stackframeinfo {
+       stackframeinfo *prev;               /* pointer to prev stackframeinfo     */
+       methodinfo     *method;             /* methodinfo of current function     */
+       u1             *pv;                 /* PV of current function             */
+       u1             *sp;                 /* SP of parent Java function         */
+       u1             *ra;                 /* RA to parent Java function         */
+       u1             *xpc;                /* XPC (for inline stubs)             */
 };
 
 
-struct stacktraceelement {
+/* stacktrace_entry ***********************************************************/
+
+struct stacktrace_entry {
 #if SIZEOF_VOID_P == 8
        u8          linenumber;
 #else
@@ -78,25 +70,78 @@ struct stacktraceelement {
 };
 
 
-struct stackTraceBuffer {
-       s4                 needsFree;
-       stacktraceelement *start;
-       s4                 size;
-       s4                 full;
+/* stacktracebuffer ***********************************************************/
+
+#define STACKTRACE_CAPACITY_DEFAULT      80
+#define STACKTRACE_CAPACITY_INCREMENT    80
+
+struct stacktracebuffer {
+       s4                capacity;         /* size of the buffer                 */
+       s4                used;             /* current entries in the buffer      */
+       stacktrace_entry *entries;          /* the actual entries                 */
 };
 
 
+/* stacktracecontainer ********************************************************
+
+   ATTENTION: Use the stacktracecontainer to place a stacktrace onto the heap
+   with stacktrace_fillInStackTrace() so that the GC does not get confused.
+
+*******************************************************************************/
+
+typedef struct stacktracecontainer {
+       java_array_t            header;     /* default array header for the GC    */
+       struct stacktracebuffer stb;        /* let entries point to data below    */
+       stacktrace_entry        data[1];    /* the actual array of entries        */
+} stacktracecontainer;
+
+
 /* function prototypes ********************************************************/
 
-void cacao_stacktrace_NormalTrace(void **target);
-java_objectarray *cacao_createClassContextArray(void);
-java_objectheader *cacao_currentClassLoader(void);
-methodinfo* cacao_callingMethod(void);
-java_objectarray *cacao_getStackForVMAccessController(void);
-void stacktrace_dump_trace(void);
+#if defined(ENABLE_INTRP)
+void stacktrace_create_stackframeinfo(stackframeinfo *sfi, u1 *pv, u1 *sp,
+                                                                         u1 *ra);
+#endif
+
+void stacktrace_create_extern_stackframeinfo(stackframeinfo *sfi, u1 *pv,
+                                                                                        u1 *sp, u1 *ra, u1 *xpc);
+
+void stacktrace_create_native_stackframeinfo(stackframeinfo *sfi, u1 *pv,
+                                                                                        u1 *sp, u1 *ra);
+
+void stacktrace_remove_stackframeinfo(stackframeinfo *sfi);
+
+
+stacktracebuffer *stacktrace_create(stackframeinfo *sfi);
+
+stacktracecontainer *stacktrace_fillInStackTrace(void);
+
+#if defined(ENABLE_JAVASE)
+java_handle_objectarray_t *stacktrace_getClassContext(void);
+classinfo                 *stacktrace_getCurrentClass(void);
+java_handle_objectarray_t *stacktrace_getStack(void);
+#endif
+
+void stacktrace_print_trace_from_buffer(stacktracebuffer *stb);
+void stacktrace_print_trace(java_handle_t *xptr);
 
 /* machine dependent functions (code in ARCH_DIR/md.c) */
-functionptr md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+
+#if defined(ENABLE_JIT)
+u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+# if defined(__SPARC_64__)
+u1 *md_get_framepointer(u1 *sp);
+u1 *md_get_pv_from_stackframe(u1 *sp);
+# endif
+#endif
+
+#if defined(ENABLE_INTRP)
+u1 *intrp_md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
+#endif
+
+#if defined(ENABLE_CYCLES_STATS)
+void stacktrace_print_cycles_stats(FILE *file);
+#endif
 
 #endif /* _STACKTRACE_H */