]> Git Repo - binutils.git/blob - gdb/python/py-breakpoint.c
24eebb7759da8fde8fb8a722f36a4920cf26358c
[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 static int
424 bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
425 {
426   char *exp;
427   breakpoint_object *self_bp = (breakpoint_object *) self;
428   volatile struct gdb_exception except;
429
430   BPPY_SET_REQUIRE_VALID (self_bp);
431
432   if (newvalue == NULL)
433     {
434       PyErr_SetString (PyExc_TypeError, 
435                        _("Cannot delete `condition' attribute."));
436       return -1;
437     }
438   else if (newvalue == Py_None)
439     exp = "";
440   else
441     {
442       exp = python_string_to_host_string (newvalue);
443       if (exp == NULL)
444         return -1;
445     }
446
447   TRY_CATCH (except, RETURN_MASK_ALL)
448     {
449       set_breakpoint_condition (self_bp->bp, exp, 0);
450     }
451   GDB_PY_SET_HANDLE_EXCEPTION (except);
452
453   return 0;
454 }
455
456 /* Python function to get the commands attached to a breakpoint.  */
457 static PyObject *
458 bppy_get_commands (PyObject *self, void *closure)
459 {
460   breakpoint_object *self_bp = (breakpoint_object *) self;
461   struct breakpoint *bp = self_bp->bp;
462   long length;
463   volatile struct gdb_exception except;
464   struct ui_file *string_file;
465   struct cleanup *chain;
466   PyObject *result;
467   char *cmdstr;
468
469   BPPY_REQUIRE_VALID (self_bp);
470
471   if (! self_bp->bp->commands)
472     Py_RETURN_NONE;
473
474   string_file = mem_fileopen ();
475   chain = make_cleanup_ui_file_delete (string_file);
476
477   TRY_CATCH (except, RETURN_MASK_ALL)
478     {
479       ui_out_redirect (uiout, string_file);
480       print_command_lines (uiout, breakpoint_commands (bp), 0);
481       ui_out_redirect (uiout, NULL);
482     }
483   cmdstr = ui_file_xstrdup (string_file, &length);
484   GDB_PY_HANDLE_EXCEPTION (except);
485
486   result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
487   do_cleanups (chain);
488   xfree (cmdstr);
489   return result;
490 }
491
492 /* Python function to get the breakpoint type.  */
493 static PyObject *
494 bppy_get_type (PyObject *self, void *closure)
495 {
496   breakpoint_object *self_bp = (breakpoint_object *) self;
497
498   BPPY_REQUIRE_VALID (self_bp);
499
500   return PyInt_FromLong (self_bp->bp->type);
501 }
502
503 /* Python function to get the breakpoint's number.  */
504 static PyObject *
505 bppy_get_number (PyObject *self, void *closure)
506 {
507   breakpoint_object *self_bp = (breakpoint_object *) self;
508
509   BPPY_REQUIRE_VALID (self_bp);
510
511   return PyInt_FromLong (self_bp->number);
512 }
513
514 /* Python function to get the breakpoint's thread ID.  */
515 static PyObject *
516 bppy_get_thread (PyObject *self, void *closure)
517 {
518   breakpoint_object *self_bp = (breakpoint_object *) self;
519
520   BPPY_REQUIRE_VALID (self_bp);
521
522   if (self_bp->bp->thread == -1)
523     Py_RETURN_NONE;
524
525   return PyInt_FromLong (self_bp->bp->thread);
526 }
527
528 /* Python function to get the breakpoint's task ID (in Ada).  */
529 static PyObject *
530 bppy_get_task (PyObject *self, void *closure)
531 {
532   breakpoint_object *self_bp = (breakpoint_object *) self;
533
534   BPPY_REQUIRE_VALID (self_bp);
535
536   if (self_bp->bp->task == 0)
537     Py_RETURN_NONE;
538
539   return PyInt_FromLong (self_bp->bp->task);
540 }
541
542 /* Python function to get the breakpoint's hit count.  */
543 static PyObject *
544 bppy_get_hit_count (PyObject *self, void *closure)
545 {
546   breakpoint_object *self_bp = (breakpoint_object *) self;
547
548   BPPY_REQUIRE_VALID (self_bp);
549
550   return PyInt_FromLong (self_bp->bp->hit_count);
551 }
552
553 /* Python function to get the breakpoint's ignore count.  */
554 static PyObject *
555 bppy_get_ignore_count (PyObject *self, void *closure)
556 {
557   breakpoint_object *self_bp = (breakpoint_object *) self;
558
559   BPPY_REQUIRE_VALID (self_bp);
560
561   return PyInt_FromLong (self_bp->bp->ignore_count);
562 }
563
564 /* Python function to create a new breakpoint.  */
565 static PyObject *
566 bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
567 {
568   PyObject *result;
569   static char *keywords[] = { "spec", "type", "wp_class", NULL };
570   char *spec;
571   int type = bp_breakpoint;
572   int access_type = hw_write;
573   volatile struct gdb_exception except;
574
575   if (! PyArg_ParseTupleAndKeywords (args, kwargs, "s|ii", keywords,
576                                      &spec, &type, &access_type))
577     return NULL;
578
579   result = subtype->tp_alloc (subtype, 0);
580   if (! result)
581     return NULL;
582   bppy_pending_object = (breakpoint_object *) result;
583   bppy_pending_object->number = -1;
584   bppy_pending_object->bp = NULL;
585   
586   TRY_CATCH (except, RETURN_MASK_ALL)
587     {
588       switch (type)
589         {
590         case bp_breakpoint:
591           {
592             create_breakpoint (python_gdbarch,
593                                spec, NULL, -1,
594                                0,
595                                0, 0, 0,
596                                0,
597                                AUTO_BOOLEAN_TRUE,
598                                NULL, 0, 1);
599             break;
600           }
601         case bp_watchpoint:
602           {
603             if (access_type == hw_write)
604               watch_command_wrapper (spec, 0);
605             else if (access_type == hw_access)
606               awatch_command_wrapper (spec, 0);
607             else if (access_type == hw_read)
608               rwatch_command_wrapper (spec, 0);
609             else
610               error(_("Cannot understand watchpoint access type."));
611             break;
612           }
613         default:
614           error(_("Do not understand breakpoint type to set."));
615         }
616     }
617   if (except.reason < 0)
618     {
619       subtype->tp_free (result);
620       return PyErr_Format (except.reason == RETURN_QUIT
621                            ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
622                            "%s", except.message);
623     }
624
625   BPPY_REQUIRE_VALID ((breakpoint_object *) result);
626   return result;
627 }
628
629 \f
630
631 /* Static function to return a tuple holding all breakpoints.  */
632
633 PyObject *
634 gdbpy_breakpoints (PyObject *self, PyObject *args)
635 {
636   PyObject *result;
637
638   if (bppy_live == 0)
639     Py_RETURN_NONE;
640
641   result = PyTuple_New (bppy_live);
642   if (result)
643     {
644       int i, out = 0;
645       for (i = 0; out < bppy_live; ++i)
646         {
647           if (! bppy_breakpoints[i])
648             continue;
649           Py_INCREF (bppy_breakpoints[i]);
650           PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]);
651           ++out;
652         }
653     }
654   return result;
655 }
656
657 \f
658
659 /* Event callback functions.  */
660
661 /* Callback that is used when a breakpoint is created.  This function
662    will create a new Python breakpoint object.  */
663 static void
664 gdbpy_breakpoint_created (int num)
665 {
666   breakpoint_object *newbp;
667   struct breakpoint *bp = NULL;
668   PyGILState_STATE state;
669
670   if (num < 0)
671     return;
672
673   bp = get_breakpoint (num);
674   if (! bp)
675     return;
676
677   if (bp->type != bp_breakpoint 
678       && bp->type != bp_watchpoint
679       && bp->type != bp_hardware_watchpoint  
680       && bp->type != bp_read_watchpoint
681       && bp->type != bp_access_watchpoint)
682     return;
683
684   if (num >= bppy_slots)
685     {
686       int old = bppy_slots;
687       bppy_slots = bppy_slots * 2 + 10;
688       bppy_breakpoints
689         = (breakpoint_object **) xrealloc (bppy_breakpoints,
690                                            (bppy_slots
691                                             * sizeof (breakpoint_object *)));
692       memset (&bppy_breakpoints[old], 0,
693               (bppy_slots - old) * sizeof (PyObject *));
694     }
695
696   ++bppy_live;
697
698   state = PyGILState_Ensure ();
699
700   if (bppy_pending_object)
701     {
702       newbp = bppy_pending_object;
703       bppy_pending_object = NULL;
704     }
705   else
706     newbp = PyObject_New (breakpoint_object, &breakpoint_object_type);
707   if (newbp)
708     {
709       newbp->number = num;
710       newbp->bp = bp;
711       bppy_breakpoints[num] = newbp;
712       Py_INCREF (newbp);
713     }
714
715   /* Just ignore errors here.  */
716   PyErr_Clear ();
717
718   PyGILState_Release (state);
719 }
720
721 /* Callback that is used when a breakpoint is deleted.  This will
722    invalidate the corresponding Python object.  */
723 static void
724 gdbpy_breakpoint_deleted (int num)
725 {
726   PyGILState_STATE state;
727
728   state = PyGILState_Ensure ();
729   if (bpnum_is_valid (num))
730     {
731       bppy_breakpoints[num]->bp = NULL;
732       Py_DECREF (bppy_breakpoints[num]);
733       bppy_breakpoints[num] = NULL;
734       --bppy_live;
735     }
736   PyGILState_Release (state);
737 }
738
739 \f
740
741 /* Initialize the Python breakpoint code.  */
742 void
743 gdbpy_initialize_breakpoints (void)
744 {
745   int i;
746
747   breakpoint_object_type.tp_new = bppy_new;
748   if (PyType_Ready (&breakpoint_object_type) < 0)
749     return;
750
751   Py_INCREF (&breakpoint_object_type);
752   PyModule_AddObject (gdb_module, "Breakpoint",
753                       (PyObject *) &breakpoint_object_type);
754
755   observer_attach_breakpoint_created (gdbpy_breakpoint_created);
756   observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
757
758   /* Add breakpoint types constants.  */
759   for (i = 0; pybp_codes[i].name; ++i)
760     {
761       if (PyModule_AddIntConstant (gdb_module,
762                                    /* Cast needed for Python 2.4.  */
763                                    (char *) pybp_codes[i].name,
764                                    pybp_codes[i].code) < 0)
765         return;
766     }
767
768   /* Add watchpoint types constants.  */
769   for (i = 0; pybp_watch_types[i].name; ++i)
770     {
771       if (PyModule_AddIntConstant (gdb_module,
772                                    /* Cast needed for Python 2.4.  */
773                                    (char *) pybp_watch_types[i].name,
774                                    pybp_watch_types[i].code) < 0)
775         return;
776     }
777
778 }
779
780 \f
781
782 static PyGetSetDef breakpoint_object_getset[] = {
783   { "enabled", bppy_get_enabled, bppy_set_enabled,
784     "Boolean telling whether the breakpoint is enabled.", NULL },
785   { "silent", bppy_get_silent, bppy_set_silent,
786     "Boolean telling whether the breakpoint is silent.", NULL },
787   { "thread", bppy_get_thread, bppy_set_thread,
788     "Thread ID for the breakpoint.\n\
789 If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
790 If the value is None, then this breakpoint is not thread-specific.\n\
791 No other type of value can be used.", NULL },
792   { "task", bppy_get_task, bppy_set_task,
793     "Thread ID for the breakpoint.\n\
794 If the value is a task ID (integer), then this is an Ada task-specific breakpoint.\n\
795 If the value is None, then this breakpoint is not task-specific.\n\
796 No other type of value can be used.", NULL },
797   { "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
798     "Number of times this breakpoint should be automatically continued.",
799     NULL },
800   { "number", bppy_get_number, NULL,
801     "Breakpoint's number assigned by GDB.", NULL },
802   { "hit_count", bppy_get_hit_count, bppy_set_hit_count,
803     "Number of times the breakpoint has been hit.\n\
804 Can be set to zero to clear the count. No other value is valid\n\
805 when setting this property.", NULL },
806   { "location", bppy_get_location, NULL,
807     "Location of the breakpoint, as specified by the user.", NULL},
808   { "expression", bppy_get_expression, NULL,
809     "Expression of the breakpoint, as specified by the user.", NULL},
810   { "condition", bppy_get_condition, bppy_set_condition,
811     "Condition of the breakpoint, as specified by the user,\
812 or None if no condition set."},
813   { "commands", bppy_get_commands, NULL,
814     "Commands of the breakpoint, as specified by the user."},
815   { "type", bppy_get_type, NULL,
816     "Type of breakpoint."},
817   { NULL }  /* Sentinel.  */
818 };
819
820 static PyMethodDef breakpoint_object_methods[] =
821 {
822   { "is_valid", bppy_is_valid, METH_NOARGS,
823     "Return true if this breakpoint is valid, false if not." },
824   { NULL } /* Sentinel.  */
825 };
826
827 static PyTypeObject breakpoint_object_type =
828 {
829   PyObject_HEAD_INIT (NULL)
830   0,                              /*ob_size*/
831   "gdb.Breakpoint",               /*tp_name*/
832   sizeof (breakpoint_object),     /*tp_basicsize*/
833   0,                              /*tp_itemsize*/
834   0,                              /*tp_dealloc*/
835   0,                              /*tp_print*/
836   0,                              /*tp_getattr*/
837   0,                              /*tp_setattr*/
838   0,                              /*tp_compare*/
839   0,                              /*tp_repr*/
840   0,                              /*tp_as_number*/
841   0,                              /*tp_as_sequence*/
842   0,                              /*tp_as_mapping*/
843   0,                              /*tp_hash */
844   0,                              /*tp_call*/
845   0,                              /*tp_str*/
846   0,                              /*tp_getattro*/
847   0,                              /*tp_setattro*/
848   0,                              /*tp_as_buffer*/
849   Py_TPFLAGS_DEFAULT,             /*tp_flags*/
850   "GDB breakpoint object",        /* tp_doc */
851   0,                              /* tp_traverse */
852   0,                              /* tp_clear */
853   0,                              /* tp_richcompare */
854   0,                              /* tp_weaklistoffset */
855   0,                              /* tp_iter */
856   0,                              /* tp_iternext */
857   breakpoint_object_methods,      /* tp_methods */
858   0,                              /* tp_members */
859   breakpoint_object_getset        /* tp_getset */
860 };
This page took 0.064074 seconds and 2 git commands to generate.