Exemple #1
0
 static StackTraceElement[] backTrace2stackTrace(Object[] backtrace) {
   final VmStackFrame[] vm_trace = (VmStackFrame[]) backtrace;
   final int length = vm_trace.length;
   final StackTraceElement[] trace = new StackTraceElement[length];
   for (int i = length; i-- > 0; ) {
     final VmStackFrame frame = vm_trace[i];
     final String location = frame.getLocationInfo();
     final int lineNumber = "?".equals(location) ? -1 : Integer.parseInt(location);
     final VmMethod method = frame.getMethod();
     final VmType<?> vmClass = (method == null) ? null : method.getDeclaringClass();
     final String fname = (vmClass == null) ? null : vmClass.getSourceFile();
     final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName();
     final String mname = (method == null) ? "<unknown method>" : method.getName();
     trace[i] =
         new StackTraceElement(
             cname, mname, fname, method == null || method.isNative() ? -2 : lineNumber);
   }
   return trace;
 }
Exemple #2
0
 private static StackTraceElement getStackTraceElement(Throwable instance, int index) {
   final VmStackFrame frame =
       (VmStackFrame)
           ((Object[])
                   ObjectReference.fromObject(instance)
                       .toAddress()
                       .add(BACKTRACE_OFFSET)
                       .loadObjectReference()
                       .toObject())
               [index];
   final String location = frame.getLocationInfo();
   final int lineNumber = "?".equals(location) ? -1 : Integer.parseInt(location);
   final VmMethod method = frame.getMethod();
   final VmType<?> vmClass = (method == null) ? null : method.getDeclaringClass();
   final String fname = (vmClass == null) ? null : vmClass.getSourceFile();
   final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName();
   final String mname = (method == null) ? "<unknown method>" : method.getName();
   return new StackTraceElement(
       cname, mname, fname, method == null || method.isNative() ? -2 : lineNumber);
 }