This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[python] make FrameWrapper a real wrapper


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)


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