public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFA] "Rewrite" GetFrameCount
@ 2007-02-08  0:56 Keith Seitz
  2007-02-08  1:01 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Seitz @ 2007-02-08  0:56 UTC (permalink / raw)
  To: Java Patch List

[-- Attachment #1: Type: text/plain, Size: 792 bytes --]

Hi,

The attach patch adds the new function _Jv_Frame::depth(), which returns 
the depth of the stack at this frame. It's a little hoaky, but it should 
be sufficient, since we end up getting the top of the stack from the 
thread anyway. No need to add more storage to save this info off.

It also contains changes to _Jv_JVMTI_GetFrame to use this function. 
This patch should effectively be a nop in functionality, except that I 
can now call _Jv_Frame::depth without having to call a JVMTI function, 
which I'm going to need when I submit patches related to single stepping.

Ok?

Keith

ChangeLog
2007-02-07  Keith Seitz  <keiths@redhat.com>

         * include/java-interp.h (_Jv_Frame::depth):
         New function.
         * jvmti.cc (_Jv_JVMTI_GetFrameCount): Use _Jv_Frame::depth.

[-- Attachment #2: frame-depth.patch --]
[-- Type: text/x-patch, Size: 1244 bytes --]

Index: include/java-interp.h
===================================================================
--- include/java-interp.h	(revision 121607)
+++ include/java-interp.h	(working copy)
@@ -1,6 +1,6 @@
 // java-interp.h - Header file for the bytecode interpreter.  -*- c++ -*-
 
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006  Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -352,6 +352,16 @@
   {
     thread->frame = (gnu::gcj::RawData *) next;
   }
+
+  int depth ()
+  {
+    int depth = 0;
+    struct _Jv_Frame *f;
+    for (f = this; f != NULL; f = f->next)
+      ++depth;
+
+    return depth;
+  }
 };
 
 // An interpreted frame in the call stack
Index: jvmti.cc
===================================================================
--- jvmti.cc	(revision 121616)
+++ jvmti.cc	(working copy)
@@ -259,14 +259,7 @@
   THREAD_CHECK_IS_ALIVE (thr);
    
   _Jv_Frame *frame = reinterpret_cast<_Jv_Frame *> (thr->frame);
-  (*frame_count) = 0;
-  
-  while (frame != NULL)
-    {
-      (*frame_count)++;
-      frame = frame->next;
-    }
-  
+  (*frame_count) = frame->depth ();
   return JVMTI_ERROR_NONE;
 }
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-08  1:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-08  0:56 [RFA] "Rewrite" GetFrameCount Keith Seitz
2007-02-08  1:01 ` Tom Tromey
2007-02-08  1:55   ` Keith Seitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).