Alien-LibJIT
view release on metacpan or search on metacpan
libjit/jit/jit-unwind.c view on Meta::CPAN
/*
* jit-unwind.c - Routines for performing stack unwinding.
*
* Copyright (C) 2008 Southern Storm Software, Pty Ltd.
*
* This file is part of the libjit library.
*
* The libjit library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 2.1 of
* the License, or (at your option) any later version.
*
* The libjit library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the libjit library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "jit-internal.h"
#include "jit-rules.h"
#include "jit-apply-rules.h"
#include <jit/jit-unwind.h>
#include <jit/jit-walk.h>
int
jit_unwind_init(jit_unwind_context_t *unwind, jit_context_t context)
{
#if defined(JIT_BACKEND_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
jit_thread_control_t control;
control = _jit_thread_get_control();
if(!control)
{
return 0;
}
unwind->frame = control->backtrace_head;
#elif JIT_FAST_GET_CURRENT_FRAME != 0
unwind->frame = jit_get_next_frame_address(jit_get_current_frame());
#else
unwind->frame = jit_get_frame_address(1);
#endif
unwind->context = context;
unwind->cache = 0;
#ifdef _JIT_ARCH_UNWIND_INIT
_JIT_ARCH_UNWIND_INIT(unwind);
#endif
return (unwind->frame != 0);
}
void
jit_unwind_free(jit_unwind_context_t *unwind)
{
#ifdef _JIT_ARCH_UNWIND_FREE
_JIT_ARCH_UNWIND_FREE(unwind);
#endif
}
int
jit_unwind_next(jit_unwind_context_t *unwind)
{
#if defined(_JIT_ARCH_UNWIND_NEXT) || defined(_JIT_ARCH_UNWIND_NEXT_PRE)
jit_function_t func;
#endif
if(!unwind || !unwind->frame)
{
return 0;
}
unwind->cache = 0;
#if defined(JIT_BACKEND_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
unwind->frame = ((jit_backtrace_t) unwind->frame)->parent;
return (unwind->frame != 0);
#else
#ifdef _JIT_ARCH_UNWIND_NEXT_PRE
func = jit_unwind_get_function(unwind);
if(func)
{
_JIT_ARCH_UNWIND_NEXT_PRE(unwind, func);
}
#endif
unwind->frame = jit_get_next_frame_address(unwind->frame);
if(!unwind->frame)
{
( run in 0.766 second using v1.01-cache-2.11-cpan-97f6503c9c8 )