OSDN Git Service

Mark ChangeLog
[pf3gnuchains/gcc-fork.git] / libjava / stacktrace.cc
index 6423bbd..d8d1f38 100644 (file)
@@ -9,24 +9,27 @@ Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
 details.  */
 
 #include <config.h>
+#include <platform.h>
 
 #include <jvm.h>
 #include <gcj/cni.h>
 #include <java-interp.h>
 #include <java-stack.h>
 
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
 #include <stdio.h>
 
+#include <java/lang/Boolean.h>
 #include <java/lang/Class.h>
 #include <java/lang/Long.h>
+#include <java/lang/reflect/Method.h>
+#include <java/security/AccessController.h>
 #include <java/util/ArrayList.h>
 #include <java/util/IdentityHashMap.h>
+#include <gnu/classpath/jdwp/Jdwp.h>
+#include <gnu/classpath/VMStackWalker.h>
 #include <gnu/java/lang/MainThread.h>
 #include <gnu/gcj/runtime/NameFinder.h>
+#include <gnu/gcj/runtime/StringBuffer.h>
 
 #include <sysdep/backtrace.h>
 #include <sysdep/descriptor.h>
@@ -36,11 +39,15 @@ using namespace java::lang::reflect;
 using namespace java::util;
 using namespace gnu::gcj::runtime;
 
+#ifdef __ARM_EABI_UNWINDER__
+#define _URC_NORMAL_STOP _URC_FAILURE
+#endif
+
 // Maps ncode values to their containing native class.
 // NOTE: Currently this Map contradicts class GC for native classes. This map
 // (and the "new class stack") will need to use WeakReferences in order to 
 // enable native class GC.
-static java::util::IdentityHashMap *ncodeMap;
+java::util::IdentityHashMap *_Jv_StackTrace::ncodeMap;
 
 // Check the "class stack" for any classes initialized since we were last 
 // called, and add them to ncodeMap.
@@ -55,21 +62,20 @@ _Jv_StackTrace::UpdateNCodeMap ()
   
   jclass klass;
   while ((klass = _Jv_PopClass ()))
-    if (!_Jv_IsInterpretedClass (klass))
-      {
-       //printf ("got %s\n", klass->name->data);
-       for (int i = 0; i < klass->method_count; i++)
-         {
-           _Jv_Method *method = &klass->methods[i];
-           void *ncode = method->ncode;
-           // Add non-abstract methods to ncodeMap.
-           if (ncode)
-             {
-               ncode = UNWRAP_FUNCTION_DESCRIPTOR (ncode);
-               ncodeMap->put ((java::lang::Object *) ncode, klass);
-             }
-         }
-      }
+    {
+      //printf ("got %s\n", klass->name->data);
+      for (int i = 0; i < klass->method_count; i++)
+       {
+         _Jv_Method *method = &klass->methods[i];
+         void *ncode = method->ncode;
+         // Add non-abstract methods to ncodeMap.
+         if (ncode)
+           {
+             ncode = UNWRAP_FUNCTION_DESCRIPTOR (ncode);
+             ncodeMap->put ((java::lang::Object *) ncode, klass);
+           }
+       }
+    }
 }
 
 // Given a native frame, return the class which this code belongs 
@@ -81,12 +87,16 @@ _Jv_StackTrace::ClassForFrame (_Jv_StackFrame *frame)
 {
   JvAssert (frame->type == frame_native);
   jclass klass = NULL;
-  // use _Unwind_FindEnclosingFunction to find start of method
-  //void *entryPoint = _Unwind_FindEnclosingFunction (ip);
 
   // look it up in ncodeMap
   if (frame->start_ip)
-    klass = (jclass) ncodeMap->get ((jobject) frame->start_ip);
+    {
+      klass = (jclass) ncodeMap->get ((jobject) frame->start_ip);
+
+      // Exclude interpreted classes
+      if (klass != NULL && _Jv_IsInterpretedClass (klass))
+       klass = NULL;
+    }
 
   return klass;
 }
@@ -115,24 +125,53 @@ _Jv_StackTrace::UnwindTraceFn (struct _Unwind_Context *context, void *state_ptr)
   // correspondance between call frames in the interpreted stack and occurances
   // of _Jv_InterpMethod::run() on the native stack.
 #ifdef INTERPRETER
-  void *interp_run = (void *) &_Jv_InterpMethod::run;
+  void *interp_run = NULL;
+  
+  if (::gnu::classpath::jdwp::Jdwp::isDebugging)
+       interp_run = (void *) &_Jv_InterpMethod::run_debug;
+  else
+    interp_run = (void *) &_Jv_InterpMethod::run;
+       
   if (func_addr == UNWRAP_FUNCTION_DESCRIPTOR (interp_run))
     {
       state->frames[pos].type = frame_interpreter;
-      state->frames[pos].interp.meth = state->interp_frame->self;
+      _Jv_Frame *frame = static_cast<_Jv_Frame *> (state->interp_frame);
+      state->frames[pos].interp.meth 
+        = static_cast<_Jv_InterpMethod *> (frame->self);
       state->frames[pos].interp.pc = state->interp_frame->pc;
-      state->interp_frame = state->interp_frame->next;
+      state->interp_frame = state->interp_frame->next_interp;
     }
-  else
+  else 
+  // We handle proxies in the same way as interpreted classes
+  if (_Jv_is_proxy (func_addr))
+    {
+      state->frames[pos].type = frame_proxy;
+      state->frames[pos].proxyClass = state->interp_frame->proxyClass;
+      state->frames[pos].proxyMethod = state->interp_frame->proxyMethod;
+      state->interp_frame = state->interp_frame->next_interp;
+    }
+  else 
 #endif
     {
+#ifdef HAVE_GETIPINFO
+      _Unwind_Ptr ip;
+      int ip_before_insn = 0;
+      ip = _Unwind_GetIPInfo (context, &ip_before_insn);
+
+      // If the unwinder gave us a 'return' address, roll it back a little
+      // to ensure we get the correct line number for the call itself.
+      if (! ip_before_insn)
+       --ip;
+#endif
       state->frames[pos].type = frame_native;
+#ifdef HAVE_GETIPINFO
+      state->frames[pos].ip = (void *) ip;
+#else
       state->frames[pos].ip = (void *) _Unwind_GetIP (context);
+#endif
       state->frames[pos].start_ip = func_addr;
     }
 
-  //printf ("unwind ip: %p\n", _Unwind_GetIP (context));
-
   _Unwind_Reason_Code result = _URC_NO_REASON;
   if (state->trace_function != NULL)
     result = (state->trace_function) (state);
@@ -150,13 +189,7 @@ _Jv_StackTrace::GetStackTrace(void)
   _Jv_UnwindState state (trace_size);
   state.frames = (_Jv_StackFrame *) &frames;
 
-#ifdef SJLJ_EXCEPTIONS
-  // The Unwind interface doesn't work with the SJLJ exception model.
-  // Fall back to a platform-specific unwinder.
-  fallback_backtrace (&state);
-#else /* SJLJ_EXCEPTIONS */  
   _Unwind_Backtrace (UnwindTraceFn, &state);
-#endif /* SJLJ_EXCEPTIONS */
   
   // Copy the trace and return it.
   int traceSize = sizeof (_Jv_StackTrace) + 
@@ -179,50 +212,66 @@ _Jv_StackTrace::getLineNumberForFrame(_Jv_StackFrame *frame, NameFinder *finder,
       _Jv_InterpClass *interp_class = 
         (_Jv_InterpClass *) interp_meth->defining_class->aux_info;
       *sourceFileName = interp_class->source_file_name;
-      *lineNum = interp_meth->get_source_line(frame->interp.pc);
+      // The interpreter advances the PC before executing an instruction,
+      // so roll-back 1 byte to ensure the line number is accurate.
+      *lineNum = interp_meth->get_source_line(frame->interp.pc - 1);
       return;
     }
 #endif
-  // Use dladdr() to determine in which binary the address IP resides.
-#if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
-  Dl_info info;
+
+  if (frame->type == frame_proxy)
+    {
+      *sourceFileName = NULL;
+      *lineNum = 0;
+      return;
+    }
+
+  // Use _Jv_platform_dladdr() to determine in which binary the address IP
+  // resides.
+  _Jv_AddrInfo info;
   jstring binaryName = NULL;
   const char *argv0 = _Jv_GetSafeArg(0);
 
   void *ip = frame->ip;
   _Unwind_Ptr offset = 0;
 
-  if (dladdr (ip, &info))
+  if (_Jv_platform_dladdr (ip, &info))
     {
-      if (info.dli_fname)
-       binaryName = JvNewStringUTF (info.dli_fname);
+      if (info.file_name)
+       binaryName = JvNewStringUTF (info.file_name);
       else
         return;
 
-      if (*methodName == NULL && info.dli_sname)
-       *methodName = JvNewStringUTF (info.dli_sname);
+      if (*methodName == NULL && info.sym_name)
+       *methodName = JvNewStringUTF (info.sym_name);
 
       // addr2line expects relative addresses for shared libraries.
-      if (strcmp (info.dli_fname, argv0) == 0)
+      if (strcmp (info.file_name, argv0) == 0)
         offset = (_Unwind_Ptr) ip;
       else
-        offset = (_Unwind_Ptr) ip - (_Unwind_Ptr) info.dli_fbase;
+        offset = (_Unwind_Ptr) ip - (_Unwind_Ptr) info.base;
 
-      //printf ("linenum ip: %p\n", ip);
-      //printf ("%s: 0x%x\n", info.dli_fname, offset);
-      //offset -= sizeof(void *);
-      
+#ifndef HAVE_GETIPINFO
       // The unwinder gives us the return address. In order to get the right
       // line number for the stack trace, roll it back a little.
       offset -= 1;
+#endif
 
-      // printf ("%s: 0x%x\n", info.dli_fname, offset);
-      
       finder->lookup (binaryName, (jlong) offset);
       *sourceFileName = finder->getSourceFile();
       *lineNum = finder->getLineNum();
+      if (*lineNum == -1 && NameFinder::showRaw())
+        {
+          gnu::gcj::runtime::StringBuffer *t =
+            new gnu::gcj::runtime::StringBuffer(binaryName);
+          t->append ((jchar)' ');
+          t->append ((jchar)'[');
+          // + 1 to compensate for the - 1 adjustment above;
+          t->append (Long::toHexString (offset + 1));
+          t->append ((jchar)']');
+          *sourceFileName = t->toString();
+        }
     }
-#endif
 }
 
 // Look up class and method info for the given stack frame, setting 
@@ -249,6 +298,11 @@ _Jv_StackTrace::FillInFrameInfo (_Jv_StackFrame *frame)
              }
          }
     }
+  else if (frame->type == frame_proxy)
+    {
+      klass = frame->proxyClass;
+      meth = frame->proxyMethod;
+    }
 #ifdef INTERPRETER
   else if (frame->type == frame_interpreter)
     {
@@ -271,7 +325,7 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
 {
   ArrayList *list = new ArrayList ();
 
-#ifdef SJLJ_EXCEPTIONS
+#if defined (SJLJ_EXCEPTIONS) && ! defined (WIN32)
   // We can't use the nCodeMap without unwinder support. Instead,
   // fake the method name by giving the IP in hex - better than nothing.  
   jstring hex = JvNewStringUTF ("0x");
@@ -290,7 +344,7 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
       list->add (element);
     }
 
-#else /* SJLJ_EXCEPTIONS */
+#else /* SJLJ_EXCEPTIONS && !WIN32 */
 
   //JvSynchronized (ncodeMap);
   UpdateNCodeMap ();
@@ -358,7 +412,7 @@ _Jv_StackTrace::GetStackTraceElements (_Jv_StackTrace *trace,
     }
   
   finder->close();
-#endif /* SJLJ_EXCEPTIONS */
+#endif /* SJLJ_EXCEPTIONS && !WIN32 */
 
   JArray<Object *> *array = JvNewObjectArray (list->size (), 
     &StackTraceElement::class$, NULL);
@@ -417,7 +471,6 @@ void
 _Jv_StackTrace::GetCallerInfo (jclass checkClass, jclass *caller_class,
   _Jv_Method **caller_meth)
 {
-#ifndef SJLJ_EXCEPTIONS
   int trace_size = 20;
   _Jv_StackFrame frames[trace_size];
   _Jv_UnwindState state (trace_size);
@@ -441,100 +494,335 @@ _Jv_StackTrace::GetCallerInfo (jclass checkClass, jclass *caller_class,
     *caller_class = trace_data.foundClass;
   if (caller_meth)
     *caller_meth = trace_data.foundMeth;
-#else
-  return;
-#endif
 }
 
-// Return a java array containing the Java classes on the stack above CHECKCLASS.
-JArray<jclass> *
-_Jv_StackTrace::GetClassContext (jclass checkClass)
+_Unwind_Reason_Code
+_Jv_StackTrace::non_system_trace_fn (_Jv_UnwindState *state)
 {
-  JArray<jclass> *result = NULL;
+  _Jv_StackFrame *frame = &state->frames[state->pos];
+  FillInFrameInfo (frame);
+  
+  ClassLoader *classLoader = NULL;
 
-  int trace_size = 100;
+  if (frame->klass)
+    {
+      classLoader = frame->klass->getClassLoaderInternal();
+#ifdef INTERPRETER
+      if (classLoader != NULL)
+        {
+          state->trace_data = (void *) classLoader;
+         return _URC_NORMAL_STOP;
+       }
+#endif
+    }
+
+  return _URC_NO_REASON;
+}
+
+ClassLoader *
+_Jv_StackTrace::GetFirstNonSystemClassLoader ()
+{
+  int trace_size = 32;
   _Jv_StackFrame frames[trace_size];
   _Jv_UnwindState state (trace_size);
   state.frames = (_Jv_StackFrame *) &frames;
+  state.trace_function = non_system_trace_fn;
+  state.trace_data = NULL;
 
   //JvSynchronized (ncodeMap);
   UpdateNCodeMap ();
+  
+  _Unwind_Backtrace (UnwindTraceFn, &state);
 
+  if (state.trace_data)
+    return (ClassLoader *) state.trace_data;
+  
+  return NULL;
+}
+
+struct AccessControlTraceData
+{
+  jint length;
+  jboolean privileged;
+};
+
+_Unwind_Reason_Code
+_Jv_StackTrace::accesscontrol_trace_fn (_Jv_UnwindState *state)
+{
+  AccessControlTraceData *trace_data = (AccessControlTraceData *)
+    state->trace_data;
+  _Jv_StackFrame *frame = &state->frames[state->pos];
+  FillInFrameInfo (frame);
+
+  if (!(frame->klass && frame->meth))
+    return _URC_NO_REASON;
+
+  trace_data->length++;
+
+  // If the previous frame was a call to doPrivileged, then this is
+  // the last frame we look at.
+  if (trace_data->privileged)
+    return _URC_NORMAL_STOP;
+  
+  if (frame->klass == &::java::security::AccessController::class$
+      && strcmp (frame->meth->name->chars(), "doPrivileged") == 0)
+    trace_data->privileged = true;
+
+  return _URC_NO_REASON;
+}
+
+jobjectArray
+_Jv_StackTrace::GetAccessControlStack (void)
+{
+  int trace_size = 100;
+  _Jv_StackFrame frames[trace_size];
+  _Jv_UnwindState state (trace_size);
+  state.frames = (_Jv_StackFrame *) &frames;
+
+  AccessControlTraceData trace_data;
+  trace_data.length = 0;
+  trace_data.privileged = false;
+  
+  state.trace_function = accesscontrol_trace_fn;
+  state.trace_data = (void *) &trace_data;
+
+  UpdateNCodeMap();
   _Unwind_Backtrace (UnwindTraceFn, &state);
 
-  // Count the number of Java frames on the stack.
-  int jframe_count = 0;
-  bool seen_checkClass = false;
-  int start_pos = -1;
+  JArray<jclass> *classes = (JArray<jclass> *)
+    _Jv_NewObjectArray (trace_data.length, &::java::lang::Class::class$, NULL);
+  jclass *c = elements (classes);
+
+  for (int i = 0, j = 0; i < state.pos; i++)
+    {
+      _Jv_StackFrame *frame = &state.frames[i];
+      if (!frame->klass || !frame->meth)
+       continue;
+      c[j] = frame->klass;
+      j++;
+    }
+
+  jobjectArray result =
+    (jobjectArray) _Jv_NewObjectArray (2, &::java::lang::Object::class$,
+                                        NULL);
+  jobject *r = elements (result);
+  r[0] = (jobject) classes;
+  r[1] = (jobject) new Boolean (trace_data.privileged);
+  
+  return result;
+}
+
+JArray<jclass> *
+_Jv_StackTrace::GetStackWalkerStack ()
+{
+  int trace_size = 100;
+  _Jv_StackFrame frames[trace_size];
+  _Jv_UnwindState state (trace_size);
+  state.frames = (_Jv_StackFrame *) &frames;
+
+  UpdateNCodeMap ();
+  _Unwind_Backtrace (UnwindTraceFn, &state);
+
+  int num_frames = 0, start_frame = -1;
+  enum
+    {
+      VMSW_GETCLASSCONTEXT,
+      JLRM_INVOKE_OR_USER_FN,
+      USER_FN
+    }
+  expect = VMSW_GETCLASSCONTEXT;
   for (int i = 0; i < state.pos; i++)
     {
       _Jv_StackFrame *frame = &state.frames[i];
       FillInFrameInfo (frame);
-      
-      if (seen_checkClass)
+      if (!frame->klass || !frame->meth)
+       continue;
+
+      switch (expect)
        {
-         if (frame->klass)
-           {
-             jframe_count++;
-             if (start_pos == -1)
-               start_pos = i;
-           }
+       case VMSW_GETCLASSCONTEXT:
+         JvAssert (
+           frame->klass == &::gnu::classpath::VMStackWalker::class$
+           && strcmp (frame->meth->name->chars(), "getClassContext") == 0);
+         expect = JLRM_INVOKE_OR_USER_FN;
+         break;
+
+       case JLRM_INVOKE_OR_USER_FN:
+         if (frame->klass != &::java::lang::reflect::Method::class$
+             || strcmp (frame->meth->name->chars(), "invoke") != 0)
+           start_frame = i;
+         expect = USER_FN;
+         break;
+
+       case USER_FN:
+         if (start_frame == -1)
+           start_frame = i;
+         break;
+       }
+
+      if (start_frame != -1)
+       {
+         if (frame->klass == &::gnu::java::lang::MainThread::class$)
+           break;
+         num_frames++;
        }
-      else
-       seen_checkClass = frame->klass == checkClass;
     }
-  result = (JArray<jclass> *) _Jv_NewObjectArray (jframe_count, &Class::class$, NULL);
-  int pos = 0;
-  
-  for (int i = start_pos; i < state.pos; i++)
+  JvAssert (num_frames > 0 && start_frame > 0);
+
+  JArray<jclass> *result = (JArray<jclass> *)
+    _Jv_NewObjectArray (num_frames, &::java::lang::Class::class$, NULL);
+  jclass *c = elements (result);
+
+  for (int i = start_frame, j = 0; i < state.pos && j < num_frames; i++)
     {
       _Jv_StackFrame *frame = &state.frames[i];
-      if (frame->klass)
-        elements(result)[pos++] = frame->klass;
+      if (!frame->klass || !frame->meth)
+       continue;
+      c[j] = frame->klass;
+      j++;
     }
   return result;
 }
 
+typedef enum
+  {
+    VMSW_GET_CALLING_ITEM,
+    JLRM_INVOKE_OR_CALLER,
+    CALLER,
+    CALLER_OF_CALLER
+  } gswcc_expect;
+
+struct StackWalkerTraceData
+{
+  gswcc_expect expect;
+  jclass result;
+};
+
 _Unwind_Reason_Code
-_Jv_StackTrace::non_system_trace_fn (_Jv_UnwindState *state)
+_Jv_StackTrace::stackwalker_trace_fn (_Jv_UnwindState *state)
 {
+  StackWalkerTraceData *trace_data = (StackWalkerTraceData *)
+    state->trace_data;
   _Jv_StackFrame *frame = &state->frames[state->pos];
   FillInFrameInfo (frame);
+
+  if (!(frame->klass && frame->meth))
+    return _URC_NO_REASON;
+
+  switch (trace_data->expect)
+    {
+    case VMSW_GET_CALLING_ITEM:
+      JvAssert (frame->klass == &::gnu::classpath::VMStackWalker::class$);
+      trace_data->expect = JLRM_INVOKE_OR_CALLER;
+      break;
+
+    case JLRM_INVOKE_OR_CALLER:
+      if (frame->klass == &::java::lang::reflect::Method::class$
+         && strcmp (frame->meth->name->chars(), "invoke") == 0)
+       trace_data->expect = CALLER;
+      else
+       trace_data->expect = CALLER_OF_CALLER;
+      break;
+
+    case CALLER:
+      trace_data->expect = CALLER_OF_CALLER;
+      break;
+
+    case CALLER_OF_CALLER:
+      trace_data->result = frame->klass;
+      return _URC_NORMAL_STOP;
+    }
+
+  return _URC_NO_REASON;
+}
+
+jclass
+_Jv_StackTrace::GetStackWalkerCallingClass (void)
+{
+  int trace_size = 100;
+  _Jv_StackFrame frames[trace_size];
+  _Jv_UnwindState state (trace_size);
+  state.frames = (_Jv_StackFrame *) &frames;
+
+  StackWalkerTraceData trace_data;
+  trace_data.expect = VMSW_GET_CALLING_ITEM;
+  trace_data.result = NULL;
   
-  ClassLoader *classLoader = NULL;
+  state.trace_function = stackwalker_trace_fn;
+  state.trace_data = (void *) &trace_data;
 
-  if (frame->klass)
+  UpdateNCodeMap();
+  _Unwind_Backtrace (UnwindTraceFn, &state);
+
+  return trace_data.result;
+}
+
+struct StackWalkerNNLTraceData
+{
+  gswcc_expect expect;
+  ClassLoader *result;
+};
+
+_Unwind_Reason_Code
+_Jv_StackTrace::stackwalker_nnl_trace_fn (_Jv_UnwindState *state)
+{
+  StackWalkerNNLTraceData *trace_data = (StackWalkerNNLTraceData *)
+    state->trace_data;
+  _Jv_StackFrame *frame = &state->frames[state->pos];
+  FillInFrameInfo (frame);
+
+  if (!(frame->klass && frame->meth))
+    return _URC_NO_REASON;
+
+  switch (trace_data->expect)
     {
-      classLoader = frame->klass->getClassLoaderInternal();
-#ifdef INTERPRETER
-      if (classLoader != NULL)
-        {
-          state->trace_data = (void *) classLoader;
+    case VMSW_GET_CALLING_ITEM:
+      JvAssert (frame->klass == &::gnu::classpath::VMStackWalker::class$);
+      trace_data->expect = JLRM_INVOKE_OR_CALLER;
+      break;
+
+    case JLRM_INVOKE_OR_CALLER:
+      if (frame->klass == &::java::lang::reflect::Method::class$
+         && strcmp (frame->meth->name->chars(), "invoke") == 0)
+       trace_data->expect = CALLER;
+      else
+       trace_data->expect = CALLER_OF_CALLER;
+      break;
+
+    case CALLER:
+      trace_data->expect = CALLER_OF_CALLER;
+      break;
+
+    case CALLER_OF_CALLER:
+      ClassLoader *cl = frame->klass->getClassLoaderInternal ();
+      if (cl != NULL)
+       {
+         trace_data->result = cl;
          return _URC_NORMAL_STOP;
        }
-#endif
     }
 
   return _URC_NO_REASON;
 }
 
 ClassLoader *
-_Jv_StackTrace::GetFirstNonSystemClassLoader ()
+_Jv_StackTrace::GetStackWalkerFirstNonNullLoader (void)
 {
-  int trace_size = 32;
+  int trace_size = 100;
   _Jv_StackFrame frames[trace_size];
   _Jv_UnwindState state (trace_size);
   state.frames = (_Jv_StackFrame *) &frames;
-  state.trace_function = non_system_trace_fn;
-  state.trace_data = NULL;
 
-  //JvSynchronized (ncodeMap);
-  UpdateNCodeMap ();
+  StackWalkerNNLTraceData trace_data;
+  trace_data.expect = VMSW_GET_CALLING_ITEM;
+  trace_data.result = NULL;
   
+  state.trace_function = stackwalker_nnl_trace_fn;
+  state.trace_data = (void *) &trace_data;
+
+  UpdateNCodeMap();
   _Unwind_Backtrace (UnwindTraceFn, &state);
 
-  if (state.trace_data)
-    return (ClassLoader *) state.trace_data;
-  
-  return NULL;
+  return trace_data.result;
 }