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.Breakpoint getter methods.


Most breakpoint properties can change (condition, commands, thread,
is_valid, is_enabled, is_silent, hit_count, ignore_count), so I kept
them as methods, just removing the get_ prefix.

But perhaps number and location (can it ever change?) could be changed
to attributes? 


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

	Rename gdb.Breakpoint getter methods.
	* python/lib/gdb/command/save_breakpoints.py: Adjust to
	new gdb.Breakpoint getter method names.
	* python/python-breakpoint.c (bppy_get_location): Rename to ...
	(bppy_location): ... this.
	(bppy_get_condition): Rename to ...
	(bppy_condition): ... this.
	(bppy_get_commands): Rename to ...
	(bppy_commands): ... this.
	(bppy_get_number): Rename to ...
	(bppy_number): ... this.
	(bppy_get_thread): Rename to ...
	(bppy_thread): ... this.
	(bppy_get_hit_count): Rename to ...
	(bppy_hit_count): ... this.
	(bppy_get_ignore_count): Rename to ...
	(bppy_ignore_count): ... this.
	(gdbpy_get_breakpoints): Rename to ...
	(gdbpy_breakpoints): ... this.
	(breakpoint_object_methods): Rename getter methods.
	* python/python-internal.h (gdbpy_get_breakpoints): Rename prototype
	to ...
	(gdbpy_breakpoints): ... this.
	* python/python.c (GdbMethods): Rename `get_breakpoints' entry to
	`breakpoints'.

diff --git a/gdb/python/lib/gdb/command/save_breakpoints.py b/gdb/python/lib/gdb/command/save_breakpoints.py
index eeeb5dd..5b8ee3c 100644
--- a/gdb/python/lib/gdb/command/save_breakpoints.py
+++ b/gdb/python/lib/gdb/command/save_breakpoints.py
@@ -38,22 +38,22 @@ The breakpoints can be restored using the 'source' command."""
 
     def invoke (self, arg, from_tty):
         self.dont_repeat ()
-        bps = gdb.get_breakpoints ()
+        bps = gdb.breakpoints ()
         if bps is None:
             raise RuntimeError, 'No breakpoints to save'
         with open (arg.strip (), 'w') as f:
             for bp in bps:
-                print >> f, "break", bp.get_location (),
-                if bp.get_thread () is not None:
-                    print >> f, " thread", bp.get_thread (),
-                if bp.get_condition () is not None:
-                    print >> f, " if", bp.get_condition (),
+                print >> f, "break", bp.location (),
+                if bp.thread () is not None:
+                    print >> f, " thread", bp.thread (),
+                if bp.condition () is not None:
+                    print >> f, " if", bp.condition (),
                 print >> f
                 if not bp.is_enabled ():
                     print >> f, "disable $bpnum"
                 # Note: we don't save the ignore count; there doesn't
                 # seem to be much point.
-                commands = bp.get_commands ()
+                commands = bp.commands ()
                 if commands is not None:
                     print >> f, "commands"
                     # Note that COMMANDS has a trailing newline.
diff --git a/gdb/python/python-breakpoint.c b/gdb/python/python-breakpoint.c
index 0dfeb28..52cf938 100644
--- a/gdb/python/python-breakpoint.c
+++ b/gdb/python/python-breakpoint.c
@@ -204,7 +204,7 @@ bppy_clear_hit_count (PyObject *self, PyObject *newvalue)
 
 /* Python function to get the location of a breakpoint.  */
 static PyObject *
-bppy_get_location (PyObject *self, PyObject *args)
+bppy_location (PyObject *self, PyObject *args)
 {
   char *str;
 
@@ -218,7 +218,7 @@ bppy_get_location (PyObject *self, PyObject *args)
 
 /* Python function to get the condition expression of a breakpoint.  */
 static PyObject *
-bppy_get_condition (PyObject *self, PyObject *args)
+bppy_condition (PyObject *self, PyObject *args)
 {
   char *str;
   BPPY_REQUIRE_VALID ((breakpoint_object *) self);
@@ -231,7 +231,7 @@ bppy_get_condition (PyObject *self, PyObject *args)
 
 /* Python function to get the commands attached to a breakpoint.  */
 static PyObject *
-bppy_get_commands (PyObject *self, PyObject *args)
+bppy_commands (PyObject *self, PyObject *args)
 {
   breakpoint_object *self_bp = (breakpoint_object *) self;
   long length;
@@ -268,7 +268,7 @@ bppy_get_commands (PyObject *self, PyObject *args)
 
 /* Python function to get the breakpoint's number.  */
 static PyObject *
-bppy_get_number (PyObject *self, PyObject *args)
+bppy_number (PyObject *self, PyObject *args)
 {
   breakpoint_object *self_bp = (breakpoint_object *) self;
 
@@ -279,7 +279,7 @@ bppy_get_number (PyObject *self, PyObject *args)
 
 /* Python function to get the breakpoint's thread ID.  */
 static PyObject *
-bppy_get_thread (PyObject *self, PyObject *args)
+bppy_thread (PyObject *self, PyObject *args)
 {
   breakpoint_object *self_bp = (breakpoint_object *) self;
 
@@ -292,7 +292,7 @@ bppy_get_thread (PyObject *self, PyObject *args)
 
 /* Python function to get the breakpoint's hit count.  */
 static PyObject *
-bppy_get_hit_count (PyObject *self, PyObject *args)
+bppy_hit_count (PyObject *self, PyObject *args)
 {
   breakpoint_object *self_bp = (breakpoint_object *) self;
 
@@ -303,7 +303,7 @@ bppy_get_hit_count (PyObject *self, PyObject *args)
 
 /* Python function to get the breakpoint's ignore count.  */
 static PyObject *
-bppy_get_ignore_count (PyObject *self, PyObject *args)
+bppy_ignore_count (PyObject *self, PyObject *args)
 {
   breakpoint_object *self_bp = (breakpoint_object *) self;
 
@@ -351,7 +351,7 @@ bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
 /* Static function to return a tuple holding all breakpoints.  */
 
 PyObject *
-gdbpy_get_breakpoints (PyObject *self, PyObject *args)
+gdbpy_breakpoints (PyObject *self, PyObject *args)
 {
   PyObject *result;
 
@@ -507,21 +507,21 @@ Any other argument is an error." },
   { "clear_hit_count", bppy_set_ignore_count, METH_NOARGS,
     "Set the hit count for this breakpoint to zero" },
 
-  { "get_location", bppy_get_location, METH_NOARGS,
+  { "location", bppy_location, METH_NOARGS,
     "Return the location of this breakpoint, as specified by the user"},
-  { "get_condition", bppy_get_condition, METH_NOARGS,
+  { "condition", bppy_condition, METH_NOARGS,
     "Return the condition of this breakpoint, as specified by the user.\n\
 Returns None if no condition set."},
-  { "get_commands", bppy_get_commands, METH_NOARGS,
+  { "commands", bppy_commands, METH_NOARGS,
     "Return the commands of this breakpoint, as specified by the user"},
-  { "get_number", bppy_get_number, METH_NOARGS,
+  { "number", bppy_number, METH_NOARGS,
     "Return this breakpoint's number." },
-  { "get_thread", bppy_get_thread, METH_NOARGS,
+  { "thread", bppy_thread, METH_NOARGS,
     "For a thread-specific breakpoint, return the thread ID.\n\
 Otherwise, return None." },
-  { "get_hit_count", bppy_get_hit_count, METH_NOARGS,
+  { "hit_count", bppy_hit_count, METH_NOARGS,
     "Return the number of times this breakpoint has been hit." },
-  { "get_ignore_count", bppy_get_ignore_count, METH_NOARGS,
+  { "ignore_count", bppy_ignore_count, METH_NOARGS,
     "Return the number of times this breakpoint should be automatically continued." },
 
   { 0 }
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index ab73f71..3ab34b1 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -70,7 +70,7 @@ extern PyTypeObject value_object_type;
 extern PyTypeObject symbol_object_type;
 
 PyObject *gdbpy_history (PyObject *self, PyObject *args);
-PyObject *gdbpy_get_breakpoints (PyObject *, PyObject *);
+PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
 PyObject *gdbpy_get_frames (PyObject *, PyObject *);
 PyObject *gdbpy_get_current_frame (PyObject *, PyObject *);
 PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index ddcd378..6076bdc 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1351,7 +1351,7 @@ static PyMethodDef GdbMethods[] =
   { "get_parameter", get_parameter, METH_VARARGS,
     "Return a gdb parameter's value" },
 
-  { "get_breakpoints", gdbpy_get_breakpoints, METH_NOARGS,
+  { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
     "Return a tuple of all breakpoint objects" },
 
   { "get_default_visualizer", gdbpy_get_default_visualizer, METH_VARARGS,
-- 
1.5.6.3



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