public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* [python] make FrameWrapper a real wrapper
@ 2009-09-18 22:26 Tom Tromey
  2009-09-21  7:37 ` Alexander Larsson
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2009-09-18 22:26 UTC (permalink / raw)
  To: Project Archer; +Cc: Alexander Larsson

I'm checking this in on the python branch.

This changes FrameWrapper so that it never directly calls a method on
self.frame.  Instead, it relies on __getattr__ to do the right thing.

This is nice because it means you can subclass FrameWrapper and
intercept any of these calls.

I think this should eliminate one reason for monkey-patching the frame
code in the glib printers: https://bugzilla.gnome.org/show_bug.cgi?id=595619#c1
Alex, does this actually help?

Tom

2009-09-18  Tom Tromey  <tromey@redhat.com>

	* python/lib/gdb/FrameWrapper.py: Don't directly reference
	self.frame.

diff --git a/gdb/python/lib/gdb/FrameWrapper.py b/gdb/python/lib/gdb/FrameWrapper.py
index 39f8246..b790a54 100644
--- a/gdb/python/lib/gdb/FrameWrapper.py
+++ b/gdb/python/lib/gdb/FrameWrapper.py
@@ -30,7 +30,7 @@ class FrameWrapper:
 
         stream.write (sym.print_name + "=")
         try:
-            val = self.frame.read_var (sym)
+            val = self.read_var (sym)
             if val != None:
                 val = str (val)
         # FIXME: would be nice to have a more precise exception here.
@@ -75,21 +75,21 @@ class FrameWrapper:
     # FIXME: this should probably just be a method on gdb.Frame.
     # But then we need stream wrappers.
     def describe (self, stream, full):
-        if self.frame.type () == gdb.DUMMY_FRAME:
+        if self.type () == gdb.DUMMY_FRAME:
             stream.write (" <function called from gdb>\n")
-        elif self.frame.type () == gdb.SIGTRAMP_FRAME:
+        elif self.type () == gdb.SIGTRAMP_FRAME:
             stream.write (" <signal handler called>\n")
         else:
-            sal = self.frame.find_sal ()
-            pc = self.frame.pc ()
-            name = self.frame.name ()
+            sal = self.find_sal ()
+            pc = self.pc ()
+            name = self.name ()
             if not name:
                 name = "??"
             if pc != sal.pc or not sal.symtab:
                 stream.write (" 0x%08x in" % pc)
             stream.write (" " + name + " (")
 
-            func = self.frame.function ()
+            func = self.function ()
             self.print_frame_args (stream, func)
 
             stream.write (")")
@@ -98,7 +98,7 @@ class FrameWrapper:
                 stream.write (" at " + sal.symtab.filename)
                 stream.write (":" + str (sal.line))
 
-            if not self.frame.name () or (not sal.symtab or not sal.symtab.filename):
+            if not self.name () or (not sal.symtab or not sal.symtab.filename):
                 lib = gdb.solib_address (pc)
                 if lib:
                     stream.write (" from " + lib)

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

* Re: [python] make FrameWrapper a real wrapper
  2009-09-18 22:26 [python] make FrameWrapper a real wrapper Tom Tromey
@ 2009-09-21  7:37 ` Alexander Larsson
  2009-09-21 14:58   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Larsson @ 2009-09-21  7:37 UTC (permalink / raw)
  To: tromey; +Cc: Project Archer

On Fri, 2009-09-18 at 16:26 -0600, Tom Tromey wrote:
> I'm checking this in on the python branch.
> 
> This changes FrameWrapper so that it never directly calls a method on
> self.frame.  Instead, it relies on __getattr__ to do the right thing.
> 
> This is nice because it means you can subclass FrameWrapper and
> intercept any of these calls.
> 
> I think this should eliminate one reason for monkey-patching the frame
> code in the glib printers: https://bugzilla.gnome.org/show_bug.cgi?id=595619#c1
> Alex, does this actually help?

No, it doesn't. Because the backtracing code will construct FrameWrapper
objects, not my subclasses of it.

What happens is that I will create a wrapper similar to FrameWrapper
that does filtering stuff, and then the backtrace code will chain all
these toghether with FrameWrapper as the innermost wrapper of the actual
frame.

So, when something calls describe on my wrapper it will either do stuff,
or pass onto its wrapped object totally. Eventually it will reach
FrameWrapper.describe() which will call self.name() to get the name.
This "name" is looked up on the FrameWrapper, not on my filters frame
wrapper object though, so will be unaffected by whatever I do.


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

* Re: [python] make FrameWrapper a real wrapper
  2009-09-21  7:37 ` Alexander Larsson
@ 2009-09-21 14:58   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2009-09-21 14:58 UTC (permalink / raw)
  To: Alexander Larsson; +Cc: Project Archer

Alexander> No, it doesn't. Because the backtracing code will construct
Alexander> FrameWrapper objects, not my subclasses of it.

I think you should able to have a frame filter return objects of
whatever type you like.  If that doesn't work then we definitely have to
change something.

Tom

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

end of thread, other threads:[~2009-09-21 14:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-18 22:26 [python] make FrameWrapper a real wrapper Tom Tromey
2009-09-21  7:37 ` Alexander Larsson
2009-09-21 14:58   ` Tom Tromey

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).