This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/JDWP] Implement VMVM:getFrames


Keith Seitz wrote:
Tom Tromey wrote:

If this approach is ok with Keith, it is ok with me.

Having seen the alternative, yeah, I'm fine with this.
Good stuff. I made some small changes, so I thought I would send in a patch so everyone can have a chance to see what I am going to commit. I basically changed up the way that start and length are dealt with.

Comments, or is this ok to go in?

- Kyle

Index: libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc
===================================================================
--- libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc	(revision 121957)
+++ libjava/gnu/classpath/jdwp/natVMVirtualMachine.cc	(working copy)
@@ -486,11 +486,49 @@
 }
 
 java::util::ArrayList *
-gnu::classpath::jdwp::VMVirtualMachine::getFrames (MAYBE_UNUSED Thread *thread,
-						   MAYBE_UNUSED jint start,
-						   MAYBE_UNUSED jint length)
+gnu::classpath::jdwp::VMVirtualMachine::getFrames (Thread *thread, jint start,
+                                                   jint length)
 {
-  return NULL;
+  jint frame_count = getFrameCount (thread);
+  ::java::util::ArrayList *frame_list;
+  
+  // Calculate the max number of frames to be returned.
+  jint num_frames = frame_count - start;
+  
+  // Check if num_frames is valid.
+  if (num_frames < 0)
+    num_frames = 0;
+  
+  // Check if there are more than length frames left after start.
+  // If length is -1 return all remaining frames.
+  if (length != -1 && num_frames > length)
+    num_frames = length;
+     
+  frame_list = new ::java::util::ArrayList (num_frames);
+  
+  _Jv_Frame *vm_frame = reinterpret_cast<_Jv_Frame *> (thread->frame);
+  
+  // Take start frames off the top of the stack
+  while (vm_frame != NULL && start > 0)
+    {
+      start--;
+      vm_frame = vm_frame->next;
+    }
+  
+  // Use as a counter for the number of frames returned.
+  num_frames = 0;
+  
+  while (vm_frame != NULL && (num_frames < length || length == -1))
+    {  
+      jlong frameId = reinterpret_cast<jlong> (vm_frame);
+      
+      VMFrame *frame = getFrame (thread, frameId);
+      frame_list->add (frame);
+      vm_frame = vm_frame->next;
+      num_frames++;
+    }
+  
+  return frame_list;
 }
 
 gnu::classpath::jdwp::VMFrame *

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]