2009/7/20 Vegard Nossum <vegard.nos...@gmail.com>: > Cc: Tomek Grabiec <tgrab...@gmail.com> > Signed-off-by: Vegard Nossum <vegard.nos...@gmail.com> > --- > arch/x86/backtrace.c | 35 +++++++++++++++++++++++++++++++++++ > 1 files changed, 35 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/backtrace.c b/arch/x86/backtrace.c > index 6b2dde4..1651aa3 100644 > --- a/arch/x86/backtrace.c > +++ b/arch/x86/backtrace.c > @@ -24,7 +24,12 @@ > * Please refer to the file LICENSE for details. > */ > > +#include "jit/bc-offset-mapping.h" > +#include "jit/compilation-unit.h" > +#include "jit/cu-mapping.h" > #include "vm/backtrace.h" > +#include "vm/class.h" > +#include "vm/method.h" > > #include <bfd.h> > #include <execinfo.h> > @@ -121,10 +126,40 @@ failed: > goto out; > } > > +static bool show_jit_function(void *addr) > +{ > + struct compilation_unit *cu; > + long bytecode_offset; > + struct vm_method *vmm; > + struct vm_class *vmc; > + int line_number; > + > + cu = jit_lookup_cu((unsigned long) addr); > + if (!cu) > + return false; > + > + bytecode_offset = native_ptr_to_bytecode_offset(cu, addr); > + > + vmm = cu->method; > + vmc = vmm->class; > + > + line_number = bytecode_offset_to_line_no(vmm, bytecode_offset); > + > + printf(" [<%08lx> %s.%s%s+%lx %s:%d]\n", (unsigned long) addr, > + vmc->name, vmm->name, vmm->type, > + vm_method_is_native(vmm) > + ? 0 : native_ptr_to_bytecode_offset(cu, addr), > + vmc->source_file_name, line_number >= 1 > + ? line_number : 0); > + return true; > +} > + > static void show_function(void *addr) > { > if (show_exe_function(addr)) > return; > + if (show_jit_function(addr)) > + return; > > printf(" [<%08lx> <unknown>]\n", (unsigned long) addr); > }
The show_jit_function() might not always work as it should. That's because jit_lookup_cu() returns the nearest preceeding complation unit for given address. Therefore we should use it only when we're sure that the address is within some JIT method, JNI method or VM native method. I think that the proper solution would be to use the stack walker functionality which is currently used to construct the java stack traces. -- Tomek Grabiec ------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge _______________________________________________ Jatovm-devel mailing list Jatovm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jatovm-devel