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][rfc] Rename gdb.Frame getters.


Frame properties don't change, but they are either non-trivial to
compute (like name), or may trigger unwinding of other frames. I kept
them all as methods. 


2008-12-04  Thiago Jung Bauermann  <bauerman@br.ibm.com>

	* python/python-frame.c (frapy_get_name): Rename to ...
	(frapy_name): ... this.
	(frapy_get_type): Rename to ...
	(frapy_type): ... this.
	(frapy_get_unwind_stop_reason): Rename to ...
	(frapy_unwind_stop_reason): ... this.
	(frapy_get_pc): Rename to ...
	(frapy_pc): ... this.
	(frapy_get_address_in_block): Rename to ...
	(frapy_address_in_block): ... this.
	(frapy_get_prev): Rename to ...
	(frapy_prev): ... this.
	(frapy_get_next): Rename to ...
	(frapy_next): ... this.
	(gdbpy_get_frames): Rename to ...
	(gdbpy_frames): ... this.
	(gdbpy_get_current_frame): Rename to ...
	(gdbpy_current_frame): ... this.
	(gdbpy_get_selected_frame): Rename to ...
	(gdbpy_selected_frame): ... this.
	(frame_object_methods): Rename getter methods.
	* python/python-internal.h (gdbpy_get_frames): Rename prototype to ...
	(gdbpy_frames): ... this.
	(gdbpy_get_current_frame): Rename prototype to ...
	(gdbpy_current_frame): ... this.
	(gdbpy_get_selected_frame): Rename prototype to ...
	(gdbpy_selected_frame): ... this.
	* python/python.c (GdbMethods): Rename `get_frames' entry to `frames',
	`get_current_frame' to `current_frame' and `get_selected_frame' to
	`selected_frame'.
	* python/lib/gdb/FrameIterator.py: Adapt to renamed gdb.Frame getters.
	* python/lib/gdb/command/backtrace.py: Likewise.
	* python/lib/gdb/function/caller_is.py: Likewise.
	* python/lib/gdb/function/in_scope.py: Likewise.

diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
index c842504..5cf7824 100644
--- a/gdb/python/lib/gdb/FrameIterator.py
+++ b/gdb/python/lib/gdb/FrameIterator.py
@@ -29,5 +29,5 @@ class FrameIterator:
         result = self.frame
         if result == None:
             raise StopIteration
-        self.frame = result.get_prev()
+        self.frame = result.prev()
         return result
diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py
index 9e37cef..916a039 100644
--- a/gdb/python/lib/gdb/command/backtrace.py
+++ b/gdb/python/lib/gdb/command/backtrace.py
@@ -78,21 +78,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.get_type () == gdb.DUMMY_FRAME:
+        if self.frame.type () == gdb.DUMMY_FRAME:
             stream.write (" <function called from gdb>\n")
-        elif self.frame.get_type () == gdb.SIGTRAMP_FRAME:
+        elif self.frame.type () == gdb.SIGTRAMP_FRAME:
             stream.write (" <signal handler called>\n")
         else:
             sal = self.frame.find_sal ()
-            pc = self.frame.get_pc ()
-            name = self.frame.get_name ()
+            pc = self.frame.pc ()
+            name = self.frame.name ()
             if not name:
                 name = "??"
             if pc != sal.get_pc () or not sal.symtab:
                 stream.write (" 0x%08x in" % pc)
             stream.write (" " + name + " (")
 
-            func = gdb.find_pc_function (self.frame.get_address_in_block ())
+            func = gdb.find_pc_function (self.frame.address_in_block ())
             self.print_frame_args (stream, func)
 
             stream.write (")")
@@ -101,7 +101,7 @@ class FrameWrapper:
                 stream.write (" at " + sal.symtab.get_filename ())
                 stream.write (":" + str (sal.get_line ()))
 
-            if not self.frame.get_name () or (not sal.symtab or not sal.symtab.get_filename ()):
+            if not self.frame.name () or (not sal.symtab or not sal.symtab.get_filename ()):
                 lib = gdb.solib_address (pc)
                 if lib:
                     stream.write (" from " + lib)
@@ -175,7 +175,7 @@ Use of the 'raw' qualifier avoids any filtering by loadable modules.
         # FIXME: provide option to start at selected frame
         # However, should still number as if starting from current
         iter = itertools.imap (FrameWrapper,
-                               FrameIterator (gdb.get_current_frame ()))
+                               FrameIterator (gdb.current_frame ()))
         if filter:
             iter = gdb.backtrace.create_frame_filter (iter)
 
diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py
index 8afa721..dee6b47 100644
--- a/gdb/python/lib/gdb/function/caller_is.py
+++ b/gdb/python/lib/gdb/function/caller_is.py
@@ -30,11 +30,11 @@ to traverse to find the calling function.  The default is 1."""
         super (CallerIs, self).__init__ ("caller_is")
 
     def invoke (self, name, nframes = 1):
-        frame = gdb.get_current_frame ()
+        frame = gdb.current_frame ()
         while nframes > 0:
-            frame = frame.get_prev ()
+            frame = frame.prev ()
             nframes = nframes - 1
-        return frame.get_name () == name.string ()
+        return frame.name () == name.string ()
 
 class CallerMatches (gdb.Function):
     """Return True if the calling function's name matches a string.
@@ -48,11 +48,11 @@ to traverse to find the calling function.  The default is 1."""
         super (CallerMatches, self).__init__ ("caller_matches")
 
     def invoke (self, name, nframes = 1):
-        frame = gdb.get_current_frame ()
+        frame = gdb.current_frame ()
         while nframes > 0:
-            frame = frame.get_prev ()
+            frame = frame.prev ()
             nframes = nframes - 1
-        return re.match (name.string (), frame.get_name ()) is not None
+        return re.match (name.string (), frame.name ()) is not None
 
 CallerIs()
 CallerMatches()
diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py
index 56b1562..3ad0d40 100644
--- a/gdb/python/lib/gdb/function/in_scope.py
+++ b/gdb/python/lib/gdb/function/in_scope.py
@@ -27,7 +27,7 @@ Receives as argument a list of names separated by whitespace."""
     def invoke (self, var):
 	vars = set (var.string().split())
 	found = set ()
-	block = gdb.block_for_pc (gdb.get_selected_frame ().get_pc ())
+	block = gdb.block_for_pc (gdb.selected_frame ().pc ())
 	while block:
 	    for sym in block:
 		if (sym.is_argument () or sym.is_constant ()
diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c
index 75e7654..f5fc432 100644
--- a/gdb/python/python-frame.c
+++ b/gdb/python/python-frame.c
@@ -123,7 +123,7 @@ frapy_equal_p (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_name (PyObject *self, PyObject *args)
+frapy_name (PyObject *self, PyObject *args)
 {
   struct frame_info *frame;
   char *name;
@@ -151,7 +151,7 @@ frapy_get_name (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_type (PyObject *self, PyObject *args)
+frapy_type (PyObject *self, PyObject *args)
 {
   struct frame_info *frame;
   enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning.  */
@@ -169,7 +169,7 @@ frapy_get_type (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_unwind_stop_reason (PyObject *self, PyObject *args)
+frapy_unwind_stop_reason (PyObject *self, PyObject *args)
 {
   struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
   volatile struct gdb_exception except;
@@ -187,7 +187,7 @@ frapy_get_unwind_stop_reason (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_pc (PyObject *self, PyObject *args)
+frapy_pc (PyObject *self, PyObject *args)
 {
   CORE_ADDR pc = 0;	      /* Initialize to appease gcc warning.  */
   struct frame_info *frame;
@@ -205,7 +205,7 @@ frapy_get_pc (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_address_in_block (PyObject *self, PyObject *args)
+frapy_address_in_block (PyObject *self, PyObject *args)
 {
   CORE_ADDR pc = 0;	      /* Initialize to appease gcc warning.  */
   struct frame_info *frame;
@@ -256,7 +256,7 @@ frame_info_to_frame_object (struct frame_info *frame)
 }
 
 static PyObject *
-frapy_get_prev (PyObject *self, PyObject *args)
+frapy_prev (PyObject *self, PyObject *args)
 {
   struct frame_info *frame, *prev;
   volatile struct gdb_exception except;
@@ -281,7 +281,7 @@ frapy_get_prev (PyObject *self, PyObject *args)
 }
 
 static PyObject *
-frapy_get_next (PyObject *self, PyObject *args)
+frapy_next (PyObject *self, PyObject *args)
 {
   struct frame_info *frame, *next;
   volatile struct gdb_exception except;
@@ -359,7 +359,7 @@ frapy_read_var_value (PyObject *self, PyObject *args)
 }
 
 PyObject *
-gdbpy_get_frames (PyObject *self, PyObject *args)
+gdbpy_frames (PyObject *self, PyObject *args)
 {
   int result = 0;
   struct frame_info *frame;
@@ -403,7 +403,7 @@ gdbpy_get_frames (PyObject *self, PyObject *args)
 }
 
 PyObject *
-gdbpy_get_current_frame (PyObject *self, PyObject *args)
+gdbpy_current_frame (PyObject *self, PyObject *args)
 {
   struct frame_info *frame;
   frame_object *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
@@ -422,7 +422,7 @@ gdbpy_get_current_frame (PyObject *self, PyObject *args)
 }
 
 PyObject *
-gdbpy_get_selected_frame (PyObject *self, PyObject *args)
+gdbpy_selected_frame (PyObject *self, PyObject *args)
 {
   struct frame_info *frame;
   frame_object *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
@@ -496,17 +496,16 @@ static PyMethodDef frame_object_methods[] = {
   { "equals", frapy_equal_p, METH_VARARGS, "Compare frames." },
   { "is_valid", frapy_is_valid, METH_NOARGS,
     "Return true if this frame is valid, false if not." },
-  { "get_name", frapy_get_name, METH_NOARGS,
+  { "name", frapy_name, METH_NOARGS,
     "Return the function name of the frame." },
-  { "get_type", frapy_get_type, METH_NOARGS, "Return the type of the frame." },
-  { "get_unwind_stop_reason", frapy_get_unwind_stop_reason,
-    METH_NOARGS, "Return the function name of the frame." },
-  { "get_pc", frapy_get_pc, METH_NOARGS, "Return the frame's resume address." },
-  { "get_address_in_block", frapy_get_address_in_block, METH_NOARGS,
+  { "type", frapy_type, METH_NOARGS, "Return the type of the frame." },
+  { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
+    "Return the function name of the frame." },
+  { "pc", frapy_pc, METH_NOARGS, "Return the frame's resume address." },
+  { "address_in_block", frapy_address_in_block, METH_NOARGS,
     "Return an address which falls within the frame's code block." },
-  { "get_prev", frapy_get_prev, METH_NOARGS,
-    "Return the previous (outer) frame." },
-  { "get_next", frapy_get_next, METH_NOARGS, "Return the next (inner) frame." },
+  { "prev", frapy_prev, METH_NOARGS, "Return the previous (outer) frame." },
+  { "next", frapy_next, METH_NOARGS, "Return the next (inner) frame." },
   { "find_sal", frapy_find_sal, METH_NOARGS,
     "Return the frame's symtab and line." },
   { "read_var_value", frapy_read_var_value, METH_VARARGS,
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 3ab34b1..0c6ce9b 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -71,11 +71,11 @@ extern PyTypeObject symbol_object_type;
 
 PyObject *gdbpy_history (PyObject *self, PyObject *args);
 PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
-PyObject *gdbpy_get_frames (PyObject *, PyObject *);
-PyObject *gdbpy_get_current_frame (PyObject *, PyObject *);
+PyObject *gdbpy_frames (PyObject *, PyObject *);
+PyObject *gdbpy_current_frame (PyObject *, PyObject *);
 PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
 PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args);
-PyObject *gdbpy_get_selected_frame (PyObject *self, PyObject *args);
+PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
 PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args);
 
 PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 6076bdc..dde2789 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1362,11 +1362,11 @@ static PyMethodDef GdbMethods[] =
   { "get_objfiles", gdbpy_get_objfiles, METH_NOARGS,
     "Return a sequence of all loaded objfiles." },
 
-  { "get_frames", gdbpy_get_frames, METH_NOARGS,
+  { "frames", gdbpy_frames, METH_NOARGS,
     "Return a tuple of all frame objects" },
-  { "get_current_frame", gdbpy_get_current_frame, METH_NOARGS,
+  { "current_frame", gdbpy_current_frame, METH_NOARGS,
     "Return the current frame object" },
-  { "get_selected_frame", gdbpy_get_selected_frame, METH_NOARGS,
+  { "selected_frame", gdbpy_selected_frame, METH_NOARGS,
     "Return the selected frame object" },
   { "frame_stop_reason_string", gdbpy_frame_stop_reason_string,
     METH_VARARGS, "Return a string explaining unwind stop reason" },
-- 
1.5.6.3



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