]> Git Repo - binutils.git/blob - gdb/python/py-breakpoint.c
gdb/
[binutils.git] / gdb / python / py-breakpoint.c
1 /* Python interface to breakpoints
2
3    Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #include "defs.h"
21 #include "value.h"
22 #include "exceptions.h"
23 #include "python-internal.h"
24 #include "charset.h"
25 #include "breakpoint.h"
26 #include "gdbcmd.h"
27 #include "gdbthread.h"
28 #include "observer.h"
29 #include "cli/cli-script.h"
30 #include "ada-lang.h"
31
32 /* From breakpoint.c.  */
33 typedef struct breakpoint_object breakpoint_object;
34
35 static PyTypeObject breakpoint_object_type;
36
37 /* A dynamically allocated vector of breakpoint objects.  Each
38    breakpoint has a number.  A breakpoint is valid if its slot in this
39    vector is non-null.  When a breakpoint is deleted, we drop our
40    reference to it and zero its slot; this is how we let the Python
41    object have a lifetime which is independent from that of the gdb
42    breakpoint.  */
43 static breakpoint_object **bppy_breakpoints;
44
45 /* Number of slots in bppy_breakpoints.  */
46 static int bppy_slots;
47
48 /* Number of live breakpoints.  */
49 static int bppy_live;
50
51 /* Variables used to pass information between the Breakpoint
52    constructor and the breakpoint-created hook function.  */
53 static breakpoint_object *bppy_pending_object;
54
55 struct breakpoint_object
56 {
57   PyObject_HEAD
58
59   /* The breakpoint number according to gdb.  */
60   int number;
61
62   /* The gdb breakpoint object, or NULL if the breakpoint has been
63      deleted.  */
64   struct breakpoint *bp;
65 };
66
67 /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
68    exception if it is invalid.  */
69 #define BPPY_REQUIRE_VALID(Breakpoint)                                  \
70     do {                                                                \
71       if (! bpnum_is_valid ((Breakpoint)->number))                      \
72         return PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
73                              (Breakpoint)->number);                     \
74     } while (0)
75
76 /* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
77    exception if it is invalid.  This macro is for use in setter functions.  */
78 #define BPPY_SET_REQUIRE_VALID(Breakpoint)                              \
79     do {                                                                \
80       if (! bpnum_is_valid ((Breakpoint)->number))                      \
81         {                                                               \
82           PyErr_Format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), \
83                         (Breakpoint)->number);                          \
84           return -1;                                                    \
85         }                                                               \
86     } while (0)
87
88 /* This is used to initialize various gdb.bp_* constants.  */
89 struct pybp_code
90 {
91   /* The name.  */
92   const char *name;
93   /* The code.  */
94   enum type_code code;
95 };
96
97 /* Entries related to the type of user set breakpoints.  */
98 static struct pybp_code pybp_codes[] =
99 {
100   { "BP_NONE", bp_none},
101   { "BP_BREAKPOINT", bp_breakpoint},
102   { "BP_WATCHPOINT", bp_watchpoint},
103   { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint},
104   { "BP_READ_WATCHPOINT", bp_read_watchpoint},
105   { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint},
106   {NULL} /* Sentinel.  */
107 };
108
109 /* Entries related to the type of watchpoint.  */
110 static struct pybp_code pybp_watch_types[] =
111 {
112   { "WP_READ", hw_read},
113   { "WP_WRITE", hw_write},
114   { "WP_ACCESS", hw_access},
115   {NULL} /* Sentinel.  */
116 };
117
118 /* Evaluate to true if the breakpoint NUM is valid, false otherwise.  */
119 static int 
120 bpnum_is_valid (int num)
121 {
122   if (num >=0 
123       && num < bppy_slots 
124       && bppy_breakpoints[num] != NULL)
125     return 1;
126   
127   return 0;
128 }
129
130 /* Python function which checks the validity of a breakpoint object.  */
131 static PyObject *
132 bppy_is_valid (PyObject *self, PyObject *args)
133 {
134   breakpoint_object *self_bp = (breakpoint_object *) self;
135
136   if (self_bp->bp)
137     Py_RETURN_TRUE;
138   Py_RETURN_FALSE;
139 }
140
141 /* Python function to test whether or not the breakpoint is enabled.  */
142 static PyObject *
143 bppy_get_enabled (PyObject *self, void *closure)
144 {
145   breakpoint_object *self_bp = (breakpoint_object *) self;
146
147   BPPY_REQUIRE_VALID (self_bp);
148   if (! self_bp->bp)
149     Py_RETURN_FALSE;
150   if (self_bp->bp->enable_state == bp_enabled)
151     Py_RETURN_TRUE;
152   Py_RETURN_FALSE;
153 }
154
155 /* Python function to test whether or not the breakpoint is silent.  */
156 static PyObject *
157 bppy_get_silent (PyObject *self, void *closure)
158 {
159   breakpoint_object *self_bp = (breakpoint_object *) self;
160
161   BPPY_REQUIRE_VALID (self_bp);
162   if (self_bp->bp->silent)
163     Py_RETURN_TRUE;
164   Py_RETURN_FALSE;
165 }
166
167 /* Python function to set the enabled state of a breakpoint.  */
168 static int
169 bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
170 {
171   breakpoint_object *self_bp = (breakpoint_object *) self;
172   int cmp;
173
174   BPPY_SET_REQUIRE_VALID (self_bp);
175
176   if (newvalue == NULL)
177     {
178       PyErr_SetString (PyExc_TypeError, 
179                        _("Cannot delete `enabled' attribute."));
180
181       return -1;
182     }
183   else if (! PyBool_Check (newvalue))
184     {
185       PyErr_SetString (PyExc_TypeError,
186                        _("The value of `enabled' must be a boolean."));
187       return -1;
188     }
189
190   cmp = PyObject_IsTrue (newvalue);
191   if (cmp < 0)
192     return -1;
193   else if (cmp == 1)
194     enable_breakpoint (self_bp->bp);
195   else 
196     disable_breakpoint (self_bp->bp);
197   return 0;
198 }
199
200 /* Python function to set the 'silent' state of a breakpoint.  */
201 static int
202 bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
203 {
204   breakpoint_object *self_bp = (breakpoint_object *) self;
205   int cmp;
206
207   BPPY_SET_REQUIRE_VALID (self_bp);
208
209   if (newvalue == NULL)
210     {
211       PyErr_SetString (PyExc_TypeError, 
212                        _("Cannot delete `silent' attribute."));
213       return -1;
214     }
215   else if (! PyBool_Check (newvalue))
216     {
217       PyErr_SetString (PyExc_TypeError,
218                        _("The value of `silent' must be a boolean."));
219       return -1;
220     }
221
222   cmp = PyObject_IsTrue (newvalue);
223   if (cmp < 0)
224     return -1;
225   else
226     self_bp->bp->silent = cmp;
227
228   return 0;
229 }
230
231 /* Python function to set the thread of a breakpoint.  */
232 static int
233 bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
234 {
235   breakpoint_object *self_bp = (breakpoint_object *) self;
236   int id;
237
238   BPPY_SET_REQUIRE_VALID (self_bp);
239
240   if (newvalue == NULL)
241     {
242       PyErr_SetString (PyExc_TypeError, 
243                        _("Cannot delete `thread' attribute."));
244       return -1;
245     }
246   else if (PyInt_Check (newvalue))
247     {
248       id = (int) PyInt_AsLong (newvalue);
249       if (! valid_thread_id (id))
250         {
251           PyErr_SetString (PyExc_RuntimeError, 
252                            _("Invalid thread ID."));
253           return -1;
254         }
255     }
256   else if (newvalue == Py_None)
257     id = -1;
258   else
259     {
260       PyErr_SetString (PyExc_TypeError,
261                        _("The value of `thread' must be an integer or None."));
262       return -1;
263     }
264
265   self_bp->bp->thread = id;
266
267   return 0;
268 }
269
270 /* Python function to set the (Ada) task of a breakpoint.  */
271 static int
272 bppy_set_task (PyObject *self, PyObject *newvalue, void *closure)
273 {
274   breakpoint_object *self_bp = (breakpoint_object *) self;
275   int id;
276
277   BPPY_SET_REQUIRE_VALID (self_bp);
278
279   if (newvalue == NULL)
280     {
281       PyErr_SetString (PyExc_TypeError, 
282                        _("Cannot delete `task' attribute."));
283       return -1;
284     }
285   else if (PyInt_Check (newvalue))
286     {
287       id = (int) PyInt_AsLong (newvalue);
288       if (! valid_task_id (id))
289         {
290           PyErr_SetString (PyExc_RuntimeError, 
291                            _("Invalid task ID."));
292           return -1;
293         }
294     }
295   else if (newvalue == Py_None)
296     id = 0;
297   else
298     {
299       PyErr_SetString (PyExc_TypeError,
300                        _("The value of `task' must be an integer or None."));
301       return -1;
302     }
303
304   self_bp->bp->task = id;
305
306   return 0;
307 }
308
309
310 /* Python function to set the ignore count of a breakpoint.  */
311 static int
312 bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
313 {
314   breakpoint_object *self_bp = (breakpoint_object *) self;
315   long value;
316
317   BPPY_SET_REQUIRE_VALID (self_bp);
318
319   if (newvalue == NULL)
320     {
321       PyErr_SetString (PyExc_TypeError,
322                        _("Cannot delete `ignore_count' attribute."));
323       return -1;
324     }
325   else if (! PyInt_Check (newvalue))
326     {
327       PyErr_SetString (PyExc_TypeError,
328                        _("The value of `ignore_count' must be an integer."));
329       return -1;
330     }
331
332   value = PyInt_AsLong (newvalue);
333   if (value < 0)
334     value = 0;
335   set_ignore_count (self_bp->number, (int) value, 0);
336
337   return 0;
338 }
339
340 /* Python function to set the hit count of a breakpoint.  */
341 static int
342 bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
343 {
344   breakpoint_object *self_bp = (breakpoint_object *) self;
345
346   BPPY_SET_REQUIRE_VALID (self_bp);
347
348   if (newvalue == NULL)
349     {
350       PyErr_SetString (PyExc_TypeError, 
351                        _("Cannot delete `hit_count' attribute."));
352       return -1;
353     }
354   else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0)
355     {
356       PyErr_SetString (PyExc_AttributeError,
357                        _("The value of `hit_count' must be zero."));
358       return -1;
359     }
360
361   self_bp->bp->hit_count = 0;
362
363   return 0;
364 }
365
366 /* Python function to get the location of a breakpoint.  */
367 static PyObject *
368 bppy_get_location (PyObject *self, void *closure)
369 {
370   char *str;
371   breakpoint_object *obj = (breakpoint_object *) self;
372
373   BPPY_REQUIRE_VALID (obj);
374
375   if (obj->bp->type != bp_breakpoint)
376     Py_RETURN_NONE;
377
378   str = obj->bp->addr_string;
379
380   if (! str)
381     str = "";
382   return PyString_Decode (str, strlen (str), host_charset (), NULL);
383 }
384
385 /* Python function to get the breakpoint expression.  */
386 static PyObject *
387 bppy_get_expression (PyObject *self, void *closure)
388 {
389   char *str;
390   breakpoint_object *obj = (breakpoint_object *) self;
391
392   BPPY_REQUIRE_VALID (obj);
393
394   if (obj->bp->type != bp_watchpoint
395       && obj->bp->type != bp_hardware_watchpoint  
396       && obj->bp->type != bp_read_watchpoint
397       && obj->bp->type != bp_access_watchpoint)
398     Py_RETURN_NONE;
399
400   str = obj->bp->exp_string;
401   if (! str)
402     str = "";
403
404   return PyString_Decode (str, strlen (str), host_charset (), NULL);
405 }
406
407 /* Python function to get the condition expression of a breakpoint.  */
408 static PyObject *
409 bppy_get_condition (PyObject *self, void *closure)
410 {
411   char *str;
412   breakpoint_object *obj = (breakpoint_object *) self;
413
414   BPPY_REQUIRE_VALID (obj);
415
416   str = obj->bp->cond_string;
417   if (! str)
418     Py_RETURN_NONE;
419
420   return PyString_Decode (str, strlen (str), host_charset (), NULL);
421 }
422
423 /* Returns 0 on success.  Returns -1 on error, with a python exception set.
424    */
425
426 static int
427 bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
428 {
429   char *exp;
430   breakpoint_object *self_bp = (breakpoint_object *) self;
431   volatile struct gdb_exception except;
432
433   BPPY_SET_REQUIRE_VALID (self_bp);
434
435   if (newvalue == NULL)
436     {
437       PyErr_SetString (PyExc_TypeError, 
438                        _("Cannot delete `condition' attribute."));
439       return -1;
440     }
441   else if (newvalue == Py_None)
442     exp = "";
443   else
444     {
445       exp = python_string_to_host_string (newvalue);
446       if (exp == NULL)
447         return -1;
448     }
449
450   TRY_CATCH (except, RETURN_MASK_ALL)
451     {
452       set_breakpoint_condition (self_bp->bp, exp, 0);
453     }
454   GDB_PY_SET_HANDLE_EXCEPTION (except);
455
456   return 0;
457 }
458
459 /* Python function to get the commands attached to a breakpoint.  */
460 static PyObject *
461 bppy_get_commands (PyObject *self, void *closure)
462 {
463   breakpoint_object *self_bp = (breakpoint_object *) self;
464   struct breakpoint *bp = self_bp->bp;
465   long length;
466   volatile struct gdb_exception except;
467   struct ui_file *string_file;
468   struct cleanup *chain;
469   PyObject *result;
470   char *cmdstr;
471
472   BPPY_REQUIRE_VALID (self_bp);
473
474   if (! self_bp->bp->commands)
475     Py_RETURN_NONE;
476
477   string_file = mem_fileopen ();
478   chain = make_cleanup_ui_file_delete (string_file);
479
480   ui_out_redirect (uiout, string_file);
481   TRY_CATCH (except, RETURN_MASK_ALL)
482     {
483       print_command_lines (uiout, breakpoint_commands (bp), 0);
484     }
485   ui_out_redirect (uiout, NULL);
486   cmdstr = ui_file_xstrdup (string_file, &length);
487   GDB_PY_HANDLE_EXCEPTION (except);
488
489   result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
490   do_cleanups (chain);
491   xfree (cmdstr);
492   return result;
493 }
494
495 /* Python function to get the breakpoint type.  */
496 static PyObject *
497 bppy_get_type (PyObject *self, void *closure)
498 {
499   breakpoint_object *self_bp = (breakpoint_object *) self;
500
501   BPPY_REQUIRE_VALID (self_bp);
502
503   return PyInt_FromLong (self_bp->bp->type);
504 }
505
506 /* Python function to get the breakpoint's number.  */
507 static PyObject *
508 bppy_get_number (PyObject *self, void *closure)
509 {
510   breakpoint_object *self_bp = (breakpoint_object *) self;
511
512   BPPY_REQUIRE_VALID (self_bp);
513
514   return PyInt_FromLong (self_bp->number);
515 }
516
517 /* Python function to get the breakpoint's thread ID.  */
518 static PyObject *
519 bppy_get_thread (PyObject *self, void *closure)
520 {
521   breakpoint_object *self_bp = (breakpoint_object *) self;
522
523   BPPY_REQUIRE_VALID (self_bp);
524
525   if (self_bp->bp->thread == -1)
526     Py_RETURN_NONE;
527
528   return PyInt_FromLong (self_bp->bp->thread);
529 }
530
531 /* Python function to get the breakpoint's task ID (in Ada).  */
532 static PyObject *
533 bppy_get_task (PyObject *self, void *closure)
534 {
535   breakpoint_object *self_bp = (breakpoint_object *) self;
536
537   BPPY_REQUIRE_VALID (self_bp);
538
539   if (self_bp->bp->task == 0)
540     Py_RETURN_NONE;
541
542   return PyInt_FromLong (self_bp->bp->task);
543 }
544
545 /* Python function to get the breakpoint's hit count.  */
546 static PyObject *
547 bppy_get_hit_count (PyObject *self, void *closure)
548 {
549   breakpoint_object *self_bp = (breakpoint_object *) self;
550
551   BPPY_REQUIRE_VALID (self_bp);
552
553   return PyInt_FromLong (self_bp->bp->hit_count);
554 }
555
556 /* Python function to get the breakpoint's ignore count.  */
557 static PyObject *
558 bppy_get_ignore_count (PyObject *self, void *closure)
559 {
560   breakpoint_object *self_bp = (breakpoint_object *) self;
561
562   BPPY_REQUIRE_VALID (self_bp);
563
564   return PyInt_FromLong (self_bp->bp->ignore_count);
565 }
566
567 /* Python function to create a new breakpoint.  */
568 static PyObject *
569 bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
570 {
571   PyObject *result;
572   static char *keywords[] = { "spec", "type", "wp_class", NULL };
573   char *spec;
574   int type = bp_breakpoint;
575   int access_type = hw_write;
576   volatile struct gdb_exception except;
577
578   if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|ii", keywords,
579                                      &spec, &type, &access_type))
580     return NULL;
581
582   result = subtype->tp_alloc (subtype, 0);
583   if (! result)
584     return NULL;
585   bppy_pending_object = (breakpoint_object *) result;
586   bppy_pending_object->number = -1;
587   bppy_pending_object->bp = NULL;
588   
589   TRY_CATCH (except, RETURN_MASK_ALL)
590     {
591       switch (type)
592         {
593         case bp_breakpoint:
594           {
595             create_breakpoint (python_gdbarch,
596                                spec, NULL, -1,
597                                0,
598                                0, bp_breakpoint,
599                                0,
600                                AUTO_BOOLEAN_TRUE,
601                                NULL, 0, 1);
602             break;
603           }
604         case bp_watchpoint:
605           {
606             if (access_type == hw_write)
607               watch_command_wrapper (spec, 0);
608             else if (access_type == hw_access)
609               awatch_command_wrapper (spec, 0);
610             else if (access_type == hw_read)
611               rwatch_command_wrapper (spec, 0);
612             else
613               error(_("Cannot understand watchpoint access type."));
614             break;
615           }
616         default:
617           error(_("Do not understand breakpoint type to set."));
618         }
619     }
620   if (except.reason < 0)
621     {
622       subtype->tp_free (result);
623       return PyErr_Format (except.reason == RETURN_QUIT
624                            ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
625                            "%s", except.message);
626     }
627
628   BPPY_REQUIRE_VALID ((breakpoint_object *) result);
629   return result;
630 }
631
632 \f
633
634 /* Static function to return a tuple holding all breakpoints.  */
635
636 PyObject *
637 gdbpy_breakpoints (PyObject *self, PyObject *args)
638 {
639   PyObject *result;
640
641   if (bppy_live == 0)
642     Py_RETURN_NONE;
643
644   result = PyTuple_New (bppy_live);
645   if (result)
646     {
647       int i, out = 0;
648
649       for (i = 0; out < bppy_live; ++i)
650         {
651           if (! bppy_breakpoints[i])
652             continue;
653           Py_INCREF (bppy_breakpoints[i]);
654           PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]);
655           ++out;
656         }
657     }
658   return result;
659 }
660
661 \f
662
663 /* Event callback functions.  */
664
665 /* Callback that is used when a breakpoint is created.  This function
666    will create a new Python breakpoint object.  */
667 static void
668 gdbpy_breakpoint_created (int num)
669 {
670   breakpoint_object *newbp;
671   struct breakpoint *bp = NULL;
672   PyGILState_STATE state;
673
674   if (num < 0)
675     return;
676
677   bp = get_breakpoint (num);
678   if (! bp)
679     return;
680
681   if (bp->type != bp_breakpoint 
682       && bp->type != bp_watchpoint
683       && bp->type != bp_hardware_watchpoint  
684       && bp->type != bp_read_watchpoint
685       && bp->type != bp_access_watchpoint)
686     return;
687
688   if (num >= bppy_slots)
689     {
690       int old = bppy_slots;
691
692       bppy_slots = bppy_slots * 2 + 10;
693       bppy_breakpoints
694         = (breakpoint_object **) xrealloc (bppy_breakpoints,
695                                            (bppy_slots
696                                             * sizeof (breakpoint_object *)));
697       memset (&bppy_breakpoints[old], 0,
698               (bppy_slots - old) * sizeof (PyObject *));
699     }
700
701   ++bppy_live;
702
703   state = PyGILState_Ensure ();
704
705   if (bppy_pending_object)
706     {
707       newbp = bppy_pending_object;
708       bppy_pending_object = NULL;
709     }
710   else
711     newbp = PyObject_New (breakpoint_object, &breakpoint_object_type);
712   if (newbp)
713     {
714       newbp->number = num;
715       newbp->bp = bp;
716       bppy_breakpoints[num] = newbp;
717       Py_INCREF (newbp);
718     }
719
720   /* Just ignore errors here.  */
721   PyErr_Clear ();
722
723   PyGILState_Release (state);
724 }
725
726 /* Callback that is used when a breakpoint is deleted.  This will
727    invalidate the corresponding Python object.  */
728 static void
729 gdbpy_breakpoint_deleted (int num)
730 {
731   PyGILState_STATE state;
732
733   state = PyGILState_Ensure ();
734   if (bpnum_is_valid (num))
735     {
736       bppy_breakpoints[num]->bp = NULL;
737       Py_DECREF (bppy_breakpoints[num]);
738       bppy_breakpoints[num] = NULL;
739       --bppy_live;
740     }
741   PyGILState_Release (state);
742 }
743
744 \f
745
746 /* Initialize the Python breakpoint code.  */
747 void
748 gdbpy_initialize_breakpoints (void)
749 {
750   int i;
751
752   breakpoint_object_type.tp_new = bppy_new;
753   if (PyType_Ready (&breakpoint_object_type) < 0)
754     return;
755
756   Py_INCREF (&breakpoint_object_type);
757   PyModule_AddObject (gdb_module, "Breakpoint",
758                       (PyObject *) &breakpoint_object_type);
759
760   observer_attach_breakpoint_created (gdbpy_breakpoint_created);
761   observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
762
763   /* Add breakpoint types constants.  */
764   for (i = 0; pybp_codes[i].name; ++i)
765     {
766       if (PyModule_AddIntConstant (gdb_module,
767                                    /* Cast needed for Python 2.4.  */
768                                    (char *) pybp_codes[i].name,
769                                    pybp_codes[i].code) < 0)
770         return;
771     }
772
773   /* Add watchpoint types constants.  */
774   for (i = 0; pybp_watch_types[i].name; ++i)
775     {
776       if (PyModule_AddIntConstant (gdb_module,
777                                    /* Cast needed for Python 2.4.  */
778                                    (char *) pybp_watch_types[i].name,
779                                    pybp_watch_types[i].code) < 0)
780         return;
781     }
782
783 }
784
785 \f
786
787 static PyGetSetDef breakpoint_object_getset[] = {
788   { "enabled", bppy_get_enabled, bppy_set_enabled,
789     "Boolean telling whether the breakpoint is enabled.", NULL },
790   { "silent", bppy_get_silent, bppy_set_silent,
791     "Boolean telling whether the breakpoint is silent.", NULL },
792   { "thread", bppy_get_thread, bppy_set_thread,
793     "Thread ID for the breakpoint.\n\
794 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
795 If the value is None, then this breakpoint is not thread-specific.\n\
796 No other type of value can be used.", NULL },
797   { "task", bppy_get_task, bppy_set_task,
798     "Thread ID for the breakpoint.\n\
799 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
800 If the value is None, then this breakpoint is not task-specific.\n\
801 No other type of value can be used.", NULL },
802   { "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
803     "Number of times this breakpoint should be automatically continued.",
804     NULL },
805   { "number", bppy_get_number, NULL,
806     "Breakpoint's number assigned by GDB.", NULL },
807   { "hit_count", bppy_get_hit_count, bppy_set_hit_count,
808     "Number of times the breakpoint has been hit.\n\
809 Can be set to zero to clear the count. No other value is valid\n\
810 when setting this property.", NULL },
811   { "location", bppy_get_location, NULL,
812     "Location of the breakpoint, as specified by the user.", NULL},
813   { "expression", bppy_get_expression, NULL,
814     "Expression of the breakpoint, as specified by the user.", NULL},
815   { "condition", bppy_get_condition, bppy_set_condition,
816     "Condition of the breakpoint, as specified by the user,\
817 or None if no condition set."},
818   { "commands", bppy_get_commands, NULL,
819     "Commands of the breakpoint, as specified by the user."},
820   { "type", bppy_get_type, NULL,
821     "Type of breakpoint."},
822   { NULL }  /* Sentinel.  */
823 };
824
825 static PyMethodDef breakpoint_object_methods[] =
826 {
827   { "is_valid", bppy_is_valid, METH_NOARGS,
828     "Return true if this breakpoint is valid, false if not." },
829   { NULL } /* Sentinel.  */
830 };
831
832 static PyTypeObject breakpoint_object_type =
833 {
834   PyObject_HEAD_INIT (NULL)
835   0,                              /*ob_size*/
836   "gdb.Breakpoint",               /*tp_name*/
837   sizeof (breakpoint_object),     /*tp_basicsize*/
838   0,                              /*tp_itemsize*/
839   0,                              /*tp_dealloc*/
840   0,                              /*tp_print*/
841   0,                              /*tp_getattr*/
842   0,                              /*tp_setattr*/
843   0,                              /*tp_compare*/
844   0,                              /*tp_repr*/
845   0,                              /*tp_as_number*/
846   0,                              /*tp_as_sequence*/
847   0,                              /*tp_as_mapping*/
848   0,                              /*tp_hash */
849   0,                              /*tp_call*/
850   0,                              /*tp_str*/
851   0,                              /*tp_getattro*/
852   0,                              /*tp_setattro*/
853   0,                              /*tp_as_buffer*/
854   Py_TPFLAGS_DEFAULT,             /*tp_flags*/
855   "GDB breakpoint object",        /* tp_doc */
856   0,                              /* tp_traverse */
857   0,                              /* tp_clear */
858   0,                              /* tp_richcompare */
859   0,                              /* tp_weaklistoffset */
860   0,                              /* tp_iter */
861   0,                              /* tp_iternext */
862   breakpoint_object_methods,      /* tp_methods */
863   0,                              /* tp_members */
864   breakpoint_object_getset        /* tp_getset */
865 };
This page took 0.074836 seconds and 4 git commands to generate.