GDB (xrefs)

scm-breakpoint.c
Go to the documentation of this file.
1 /* Scheme interface to breakpoints.
2
3 Copyright (C) 2008-2018 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 /* See README file in this directory for implementation notes, coding
21 conventions, et.al. */
22
23 #include "defs.h"
24 #include "value.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 #include "arch-utils.h"
32 #include "language.h"
33 #include "guile-internal.h"
34 #include "location.h"
35
36 /* The <gdb:breakpoint> smob.
37 N.B.: The name of this struct is known to breakpoint.h.
38
39 Note: Breakpoints are added to gdb using a two step process:
40 1) Call make-breakpoint to create a <gdb:breakpoint> object.
41 2) Call register-breakpoint! to add the breakpoint to gdb.
42 It is done this way so that the constructor, make-breakpoint, doesn't have
43 any side-effects. This means that the smob needs to store everything
44 that was passed to make-breakpoint. */
45
46 typedef struct gdbscm_breakpoint_object
47 {
48 /* This always appears first. */
49 gdb_smob base;
50
51 /* Non-zero if this breakpoint was created with make-breakpoint. */
52 int is_scheme_bkpt;
53
54 /* For breakpoints created with make-breakpoint, these are the parameters
55 that were passed to make-breakpoint. These values are not used except
56 to register the breakpoint with GDB. */
57 struct
58 {
59 /* The string representation of the breakpoint.
60 Space for this lives in GC space. */
61 char *location;
62
63 /* The kind of breakpoint.
64 At the moment this can only be one of bp_breakpoint, bp_watchpoint. */
65 enum bptype type;
66
67 /* If a watchpoint, the kind of watchpoint. */
68 enum target_hw_bp_type access_type;
69
70 /* Non-zero if the breakpoint is an "internal" breakpoint. */
71 int is_internal;
72 } spec;
73
74 /* The breakpoint number according to gdb.
75 For breakpoints created from Scheme, this has the value -1 until the
76 breakpoint is registered with gdb.
77 This is recorded here because BP will be NULL when deleted. */
78 int number;
79
80 /* The gdb breakpoint object, or NULL if the breakpoint has not been
81 registered yet, or has been deleted. */
82 struct breakpoint *bp;
83
84 /* Backlink to our containing <gdb:breakpoint> smob.
85 This is needed when we are deleted, we need to unprotect the object
86 from GC. */
87 SCM containing_scm;
88
89 /* A stop condition or #f. */
90 SCM stop;
91 } breakpoint_smob;
92
93 static const char breakpoint_smob_name[] = "gdb:breakpoint";
94
95 /* The tag Guile knows the breakpoint smob by. */
96 static scm_t_bits breakpoint_smob_tag;
97
98 /* Variables used to pass information between the breakpoint_smob
99 constructor and the breakpoint-created hook function. */
100 static SCM pending_breakpoint_scm = SCM_BOOL_F;
101
102 /* Keywords used by create-breakpoint!. */
103 static SCM type_keyword;
104 static SCM wp_class_keyword;
105 static SCM internal_keyword;
106
107 /* Administrivia for breakpoint smobs. */
108
109 /* The smob "free" function for <gdb:breakpoint>. */
110
111 static size_t
112 bpscm_free_breakpoint_smob (SCM self)
113 {
114 breakpoint_smob *bp_smob = (breakpoint_smob *) SCM_SMOB_DATA (self);
115
116 if (bp_smob->bp)
117 bp_smob->bp->scm_bp_object = NULL;
118
119 /* Not necessary, done to catch bugs. */
120 bp_smob->bp = NULL;
121 bp_smob->containing_scm = SCM_UNDEFINED;
122 bp_smob->stop = SCM_UNDEFINED;
123
124 return 0;
125 }
126
127 /* Return the name of TYPE.
128 This doesn't handle all types, just the ones we export. */
129
130 static const char *
131 bpscm_type_to_string (enum bptype type)
132 {
133 switch (type)
134 {
135 case bp_none: return "BP_NONE";
136 case bp_breakpoint: return "BP_BREAKPOINT";
137 case bp_watchpoint: return "BP_WATCHPOINT";
138 case bp_hardware_watchpoint: return "BP_HARDWARE_WATCHPOINT";
139 case bp_read_watchpoint: return "BP_READ_WATCHPOINT";
140 case bp_access_watchpoint: return "BP_ACCESS_WATCHPOINT";
141 default: return "internal/other";
142 }
143 }
144
145 /* Return the name of ENABLE_STATE. */
146
147 static const char *
148 bpscm_enable_state_to_string (enum enable_state enable_state)
149 {
150 switch (enable_state)
151 {
152 case bp_disabled: return "disabled";
153 case bp_enabled: return "enabled";
154 case bp_call_disabled: return "call_disabled";
155 default: return "unknown";
156 }
157 }
158
159 /* The smob "print" function for <gdb:breakpoint>. */
160
161 static int
162 bpscm_print_breakpoint_smob (SCM self, SCM port, scm_print_state *pstate)
163 {
164 breakpoint_smob *bp_smob = (breakpoint_smob *) SCM_SMOB_DATA (self);
165 struct breakpoint *b = bp_smob->bp;
166
167 gdbscm_printf (port, "#<%s", breakpoint_smob_name);
168
169 /* Only print what we export to the user.
170 The rest are possibly internal implementation details. */
171
172 gdbscm_printf (port, " #%d", bp_smob->number);
173
174 /* Careful, the breakpoint may be invalid. */
175 if (b != NULL)
176 {
177 const char *str;
178
179 gdbscm_printf (port, " %s %s %s",
180 bpscm_type_to_string (b->type),
181 bpscm_enable_state_to_string (b->enable_state),
182 b->silent ? "silent" : "noisy");
183
184 gdbscm_printf (port, " hit:%d", b->hit_count);
185 gdbscm_printf (port, " ignore:%d", b->ignore_count);
186
187 str = event_location_to_string (b->location.get ());
188 if (str != NULL)
189 gdbscm_printf (port, " @%s", str);
190 }
191
192 scm_puts (">", port);
193
194 scm_remember_upto_here_1 (self);
195
196 /* Non-zero means success. */
197 return 1;
198 }
199
200 /* Low level routine to create a <gdb:breakpoint> object. */
201
202 static SCM
203 bpscm_make_breakpoint_smob (void)
204 {
205 breakpoint_smob *bp_smob = (breakpoint_smob *)
206 scm_gc_malloc (sizeof (breakpoint_smob), breakpoint_smob_name);
207 SCM bp_scm;
208
209 memset (bp_smob, 0, sizeof (*bp_smob));
210 bp_smob->number = -1;
211 bp_smob->stop = SCM_BOOL_F;
212 bp_scm = scm_new_smob (breakpoint_smob_tag, (scm_t_bits) bp_smob);
213 bp_smob->containing_scm = bp_scm;
214 gdbscm_init_gsmob (&bp_smob->base);
215
216 return bp_scm;
217 }
218
219 /* Return non-zero if we want a Scheme wrapper for breakpoint B.
220 If FROM_SCHEME is non-zero,this is called for a breakpoint created
221 by the user from Scheme. Otherwise it is zero. */
222
223 static int
224 bpscm_want_scm_wrapper_p (struct breakpoint *bp, int from_scheme)
225 {
226 /* Don't create <gdb:breakpoint> objects for internal GDB breakpoints. */
227 if (bp->number < 0 && !from_scheme)
228 return 0;
229
230 /* The others are not supported. */
231 if (bp->type != bp_breakpoint
232 && bp->type != bp_watchpoint
233 && bp->type != bp_hardware_watchpoint
234 && bp->type != bp_read_watchpoint
235 && bp->type != bp_access_watchpoint)
236 return 0;
237
238 return 1;
239 }
240
241 /* Install the Scheme side of a breakpoint, CONTAINING_SCM, in
242 the gdb side BP. */
243
244 static void
245 bpscm_attach_scm_to_breakpoint (struct breakpoint *bp, SCM containing_scm)
246 {
247 breakpoint_smob *bp_smob;
248
249 bp_smob = (breakpoint_smob *) SCM_SMOB_DATA (containing_scm);
250 bp_smob->number = bp->number;
251 bp_smob->bp = bp;
252 bp_smob->containing_scm = containing_scm;
253 bp_smob->bp->scm_bp_object = bp_smob;
254
255 /* The owner of this breakpoint is not in GC-controlled memory, so we need
256 to protect it from GC until the breakpoint is deleted. */
257 scm_gc_protect_object (containing_scm);
258 }
259
260 /* Return non-zero if SCM is a breakpoint smob. */
261
262 static int
263 bpscm_is_breakpoint (SCM scm)
264 {
265 return SCM_SMOB_PREDICATE (breakpoint_smob_tag, scm);
266 }
267
268 /* (breakpoint? scm) -> boolean */
269
270 static SCM
271 gdbscm_breakpoint_p (SCM scm)
272 {
273 return scm_from_bool (bpscm_is_breakpoint (scm));
274 }
275
276 /* Returns the <gdb:breakpoint> object in SELF.
277 Throws an exception if SELF is not a <gdb:breakpoint> object. */
278
279 static SCM
280 bpscm_get_breakpoint_arg_unsafe (SCM self, int arg_pos, const char *func_name)
281 {
282 SCM_ASSERT_TYPE (bpscm_is_breakpoint (self), self, arg_pos, func_name,
283 breakpoint_smob_name);
284
285 return self;
286 }
287
288 /* Returns a pointer to the breakpoint smob of SELF.
289 Throws an exception if SELF is not a <gdb:breakpoint> object. */
290
291 static breakpoint_smob *
292 bpscm_get_breakpoint_smob_arg_unsafe (SCM self, int arg_pos,
293 const char *func_name)
294 {
295 SCM bp_scm = bpscm_get_breakpoint_arg_unsafe (self, arg_pos, func_name);
296 breakpoint_smob *bp_smob = (breakpoint_smob *) SCM_SMOB_DATA (bp_scm);
297
298 return bp_smob;
299 }
300
301 /* Return non-zero if breakpoint BP_SMOB is valid. */
302
303 static int
304 bpscm_is_valid (breakpoint_smob *bp_smob)
305 {
306 return bp_smob->bp != NULL;
307 }
308
309 /* Returns the breakpoint smob in SELF, verifying it's valid.
310 Throws an exception if SELF is not a <gdb:breakpoint> object,
311 or is invalid. */
312
313 static breakpoint_smob *
314 bpscm_get_valid_breakpoint_smob_arg_unsafe (SCM self, int arg_pos,
315 const char *func_name)
316 {
317 breakpoint_smob *bp_smob
318 = bpscm_get_breakpoint_smob_arg_unsafe (self, arg_pos, func_name);
319
320 if (!bpscm_is_valid (bp_smob))
321 {
322 gdbscm_invalid_object_error (func_name, arg_pos, self,
323 _("<gdb:breakpoint>"));
324 }
325
326 return bp_smob;
327 }
328
329 /* Breakpoint methods. */
330
331 /* (make-breakpoint string [#:type integer] [#:wp-class integer]
332 [#:internal boolean) -> <gdb:breakpoint>
333
334 The result is the <gdb:breakpoint> Scheme object.
335 The breakpoint is not available to be used yet, however.
336 It must still be added to gdb with register-breakpoint!. */
337
338 static SCM
339 gdbscm_make_breakpoint (SCM location_scm, SCM rest)
340 {
341 const SCM keywords[] = {
342 type_keyword, wp_class_keyword, internal_keyword, SCM_BOOL_F
343 };
344 char *s;
345 char *location;
346 int type_arg_pos = -1, access_type_arg_pos = -1, internal_arg_pos = -1;
347 enum bptype type = bp_breakpoint;
348 enum target_hw_bp_type access_type = hw_write;
349 int internal = 0;
350 SCM result;
351 breakpoint_smob *bp_smob;
352
353 gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#iit",
354 location_scm, &location, rest,
355 &type_arg_pos, &type,
356 &access_type_arg_pos, &access_type,
357 &internal_arg_pos, &internal);
358
359 result = bpscm_make_breakpoint_smob ();
360 bp_smob = (breakpoint_smob *) SCM_SMOB_DATA (result);
361
362 s = location;
363 location = gdbscm_gc_xstrdup (s);
364 xfree (s);
365
366 switch (type)
367 {
368 case bp_breakpoint:
369 if (access_type_arg_pos > 0)
370 {
371 gdbscm_misc_error (FUNC_NAME, access_type_arg_pos,
372 scm_from_int (access_type),
373 _("access type with breakpoint is not allowed"));
374 }
375 break;
376 case bp_watchpoint:
377 switch (access_type)
378 {
379 case hw_write:
380 case hw_access:
381 case hw_read:
382 break;
383 default:
384 gdbscm_out_of_range_error (FUNC_NAME, access_type_arg_pos,
385 scm_from_int (access_type),
386 _("invalid watchpoint class"));
387 }
388 break;
389 default:
390 gdbscm_out_of_range_error (FUNC_NAME, access_type_arg_pos,
391 scm_from_int (type),
392 _("invalid breakpoint type"));
393 }
394
395 bp_smob->is_scheme_bkpt = 1;
396 bp_smob->spec.location = location;
397 bp_smob->spec.type = type;
398 bp_smob->spec.access_type = access_type;
399 bp_smob->spec.is_internal = internal;
400
401 return result;
402 }
403
404 /* (register-breakpoint! <gdb:breakpoint>) -> unspecified
405
406 It is an error to register a breakpoint created outside of Guile,
407 or an already-registered breakpoint. */
408
409 static SCM
410 gdbscm_register_breakpoint_x (SCM self)
411 {
412 breakpoint_smob *bp_smob
413 = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
414 struct gdb_exception except = exception_none;
415 const char *location, *copy;
416
417 /* We only support registering breakpoints created with make-breakpoint. */
418 if (!bp_smob->is_scheme_bkpt)
419 scm_misc_error (FUNC_NAME, _("not a Scheme breakpoint"), SCM_EOL);
420
421 if (bpscm_is_valid (bp_smob))
422 scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL);
423
424 pending_breakpoint_scm = self;
425 location = bp_smob->spec.location;
426 copy = skip_spaces (location);
427 event_location_up eloc
428 = string_to_event_location_basic (&copy,
429 current_language,
430 symbol_name_match_type::WILD);
431
432 TRY
433 {
434 int internal = bp_smob->spec.is_internal;
435
436 switch (bp_smob->spec.type)
437 {
438 case bp_breakpoint:
439 {
440 create_breakpoint (get_current_arch (),
441 eloc.get (), NULL, -1, NULL,
442 0,
443 0, bp_breakpoint,
444 0,
445 AUTO_BOOLEAN_TRUE,
446 &bkpt_breakpoint_ops,
447 0, 1, internal, 0);
448 break;
449 }
450 case bp_watchpoint:
451 {
452 enum target_hw_bp_type access_type = bp_smob->spec.access_type;
453
454 if (access_type == hw_write)
455 watch_command_wrapper (location, 0, internal);
456 else if (access_type == hw_access)
457 awatch_command_wrapper (location, 0, internal);
458 else if (access_type == hw_read)
459 rwatch_command_wrapper (location, 0, internal);
460 else
461 gdb_assert_not_reached ("invalid access type");
462 break;
463 }
464 default:
465 gdb_assert_not_reached ("invalid breakpoint type");
466 }
467 }
468 CATCH (ex, RETURN_MASK_ALL)
469 {
470 except = ex;
471 }
472 END_CATCH
473
474 /* Ensure this gets reset, even if there's an error. */
475 pending_breakpoint_scm = SCM_BOOL_F;
476 GDBSCM_HANDLE_GDB_EXCEPTION (except);
477
478 return SCM_UNSPECIFIED;
479 }
480
481 /* (delete-breakpoint! <gdb:breakpoint>) -> unspecified
482 Scheme function which deletes (removes) the underlying GDB breakpoint
483 from GDB's list of breakpoints. This triggers the breakpoint_deleted
484 observer which will call gdbscm_breakpoint_deleted; that function cleans
485 up the Scheme bits. */
486
487 static SCM
488 gdbscm_delete_breakpoint_x (SCM self)
489 {
490 breakpoint_smob *bp_smob
491 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
492
493 TRY
494 {
495 delete_breakpoint (bp_smob->bp);
496 }
497 CATCH (except, RETURN_MASK_ALL)
498 {
499 GDBSCM_HANDLE_GDB_EXCEPTION (except);
500 }
501 END_CATCH
502
503 return SCM_UNSPECIFIED;
504 }
505
506 /* iterate_over_breakpoints function for gdbscm_breakpoints. */
507
508 static int
509 bpscm_build_bp_list (struct breakpoint *bp, void *arg)
510 {
511 SCM *list = (SCM *) arg;
512 breakpoint_smob *bp_smob = bp->scm_bp_object;
513
514 /* Lazily create wrappers for breakpoints created outside Scheme. */
515
516 if (bp_smob == NULL)
517 {
518 if (bpscm_want_scm_wrapper_p (bp, 0))
519 {
520 SCM bp_scm;
521
522 bp_scm = bpscm_make_breakpoint_smob ();
523 bpscm_attach_scm_to_breakpoint (bp, bp_scm);
524 /* Refetch it. */
525 bp_smob = bp->scm_bp_object;
526 }
527 }
528
529 /* Not all breakpoints will have a companion Scheme object.
530 Only breakpoints that trigger the created_breakpoint observer call,
531 and satisfy certain conditions (see bpscm_want_scm_wrapper_p),
532 get a companion object (this includes Scheme-created breakpoints). */
533
534 if (bp_smob != NULL)
535 *list = scm_cons (bp_smob->containing_scm, *list);
536
537 return 0;
538 }
539
540 /* (breakpoints) -> list
541 Return a list of all breakpoints. */
542
543 static SCM
544 gdbscm_breakpoints (void)
545 {
546 SCM list = SCM_EOL;
547
548 /* If iterate_over_breakpoints returns non-NULL it means the iteration
549 terminated early.
550 In that case abandon building the list and return #f. */
551 if (iterate_over_breakpoints (bpscm_build_bp_list, &list) != NULL)
552 return SCM_BOOL_F;
553
554 return scm_reverse_x (list, SCM_EOL);
555 }
556
557 /* (breakpoint-valid? <gdb:breakpoint>) -> boolean
558 Returns #t if SELF is still valid. */
559
560 static SCM
561 gdbscm_breakpoint_valid_p (SCM self)
562 {
563 breakpoint_smob *bp_smob
564 = bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
565
566 return scm_from_bool (bpscm_is_valid (bp_smob));
567 }
568
569 /* (breakpoint-enabled? <gdb:breakpoint>) -> boolean */
570
571 static SCM
572 gdbscm_breakpoint_enabled_p (SCM self)
573 {
574 breakpoint_smob *bp_smob
575 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
576
577 return scm_from_bool (bp_smob->bp->enable_state == bp_enabled);
578 }
579
580 /* (set-breakpoint-enabled? <gdb:breakpoint> boolean) -> unspecified */
581
582 static SCM
583 gdbscm_set_breakpoint_enabled_x (SCM self, SCM newvalue)
584 {
585 breakpoint_smob *bp_smob
586 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
587
588 SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME,
589 _("boolean"));
590
591 TRY
592 {
593 if (gdbscm_is_true (newvalue))
594 enable_breakpoint (bp_smob->bp);
595 else
596 disable_breakpoint (bp_smob->bp);
597 }
598 CATCH (except, RETURN_MASK_ALL)
599 {
600 GDBSCM_HANDLE_GDB_EXCEPTION (except);
601 }
602 END_CATCH
603
604 return SCM_UNSPECIFIED;
605 }
606
607 /* (breakpoint-silent? <gdb:breakpoint>) -> boolean */
608
609 static SCM
610 gdbscm_breakpoint_silent_p (SCM self)
611 {
612 breakpoint_smob *bp_smob
613 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
614
615 return scm_from_bool (bp_smob->bp->silent);
616 }
617
618 /* (set-breakpoint-silent?! <gdb:breakpoint> boolean) -> unspecified */
619
620 static SCM
621 gdbscm_set_breakpoint_silent_x (SCM self, SCM newvalue)
622 {
623 breakpoint_smob *bp_smob
624 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
625
626 SCM_ASSERT_TYPE (gdbscm_is_bool (newvalue), newvalue, SCM_ARG2, FUNC_NAME,
627 _("boolean"));
628
629 TRY
630 {
631 breakpoint_set_silent (bp_smob->bp, gdbscm_is_true (newvalue));
632 }
633 CATCH (except, RETURN_MASK_ALL)
634 {
635 GDBSCM_HANDLE_GDB_EXCEPTION (except);
636 }
637 END_CATCH
638
639 return SCM_UNSPECIFIED;
640 }
641
642 /* (breakpoint-ignore-count <gdb:breakpoint>) -> integer */
643
644 static SCM
645 gdbscm_breakpoint_ignore_count (SCM self)
646 {
647 breakpoint_smob *bp_smob
648 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
649
650 return scm_from_long (bp_smob->bp->ignore_count);
651 }
652
653 /* (set-breakpoint-ignore-count! <gdb:breakpoint> integer)
654 -> unspecified */
655
656 static SCM
657 gdbscm_set_breakpoint_ignore_count_x (SCM self, SCM newvalue)
658 {
659 breakpoint_smob *bp_smob
660 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
661 long value;
662
663 SCM_ASSERT_TYPE (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX),
664 newvalue, SCM_ARG2, FUNC_NAME, _("integer"));
665
666 value = scm_to_long (newvalue);
667 if (value < 0)
668 value = 0;
669
670 TRY
671 {
672 set_ignore_count (bp_smob->number, (int) value, 0);
673 }
674 CATCH (except, RETURN_MASK_ALL)
675 {
676 GDBSCM_HANDLE_GDB_EXCEPTION (except);
677 }
678 END_CATCH
679
680 return SCM_UNSPECIFIED;
681 }
682
683 /* (breakpoint-hit-count <gdb:breakpoint>) -> integer */
684
685 static SCM
686 gdbscm_breakpoint_hit_count (SCM self)
687 {
688 breakpoint_smob *bp_smob
689 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
690
691 return scm_from_long (bp_smob->bp->hit_count);
692 }
693
694 /* (set-breakpoint-hit-count! <gdb:breakpoint> integer) -> unspecified */
695
696 static SCM
697 gdbscm_set_breakpoint_hit_count_x (SCM self, SCM newvalue)
698 {
699 breakpoint_smob *bp_smob
700 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
701 long value;
702
703 SCM_ASSERT_TYPE (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX),
704 newvalue, SCM_ARG2, FUNC_NAME, _("integer"));
705
706 value = scm_to_long (newvalue);
707 if (value < 0)
708 value = 0;
709
710 if (value != 0)
711 {
712 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG2, newvalue,
713 _("hit-count must be zero"));
714 }
715
716 bp_smob->bp->hit_count = 0;
717
718 return SCM_UNSPECIFIED;
719 }
720
721 /* (breakpoint-thread <gdb:breakpoint>) -> integer */
722
723 static SCM
724 gdbscm_breakpoint_thread (SCM self)
725 {
726 breakpoint_smob *bp_smob
727 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
728
729 if (bp_smob->bp->thread == -1)
730 return SCM_BOOL_F;
731
732 return scm_from_long (bp_smob->bp->thread);
733 }
734
735 /* (set-breakpoint-thread! <gdb:breakpoint> integer) -> unspecified */
736
737 static SCM
738 gdbscm_set_breakpoint_thread_x (SCM self, SCM newvalue)
739 {
740 breakpoint_smob *bp_smob
741 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
742 long id;
743
744 if (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX))
745 {
746 id = scm_to_long (newvalue);
747 if (!valid_global_thread_id (id))
748 {
749 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG2, newvalue,
750 _("invalid thread id"));
751 }
752 }
753 else if (gdbscm_is_false (newvalue))
754 id = -1;
755 else
756 SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f"));
757
758 breakpoint_set_thread (bp_smob->bp, id);
759
760 return SCM_UNSPECIFIED;
761 }
762
763 /* (breakpoint-task <gdb:breakpoint>) -> integer */
764
765 static SCM
766 gdbscm_breakpoint_task (SCM self)
767 {
768 breakpoint_smob *bp_smob
769 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
770
771 if (bp_smob->bp->task == 0)
772 return SCM_BOOL_F;
773
774 return scm_from_long (bp_smob->bp->task);
775 }
776
777 /* (set-breakpoint-task! <gdb:breakpoint> integer) -> unspecified */
778
779 static SCM
780 gdbscm_set_breakpoint_task_x (SCM self, SCM newvalue)
781 {
782 breakpoint_smob *bp_smob
783 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
784 long id;
785 int valid_id = 0;
786
787 if (scm_is_signed_integer (newvalue, LONG_MIN, LONG_MAX))
788 {
789 id = scm_to_long (newvalue);
790
791 TRY
792 {
793 valid_id = valid_task_id (id);
794 }
795 CATCH (except, RETURN_MASK_ALL)
796 {
797 GDBSCM_HANDLE_GDB_EXCEPTION (except);
798 }
799 END_CATCH
800
801 if (! valid_id)
802 {
803 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG2, newvalue,
804 _("invalid task id"));
805 }
806 }
807 else if (gdbscm_is_false (newvalue))
808 id = 0;
809 else
810 SCM_ASSERT_TYPE (0, newvalue, SCM_ARG2, FUNC_NAME, _("integer or #f"));
811
812 TRY
813 {
814 breakpoint_set_task (bp_smob->bp, id);
815 }
816 CATCH (except, RETURN_MASK_ALL)
817 {
818 GDBSCM_HANDLE_GDB_EXCEPTION (except);
819 }
820 END_CATCH
821
822 return SCM_UNSPECIFIED;
823 }
824
825 /* (breakpoint-location <gdb:breakpoint>) -> string */
826
827 static SCM
828 gdbscm_breakpoint_location (SCM self)
829 {
830 breakpoint_smob *bp_smob
831 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
832 const char *str;
833
834 if (bp_smob->bp->type != bp_breakpoint)
835 return SCM_BOOL_F;
836
837 str = event_location_to_string (bp_smob->bp->location.get ());
838 if (! str)
839 str = "";
840
841 return gdbscm_scm_from_c_string (str);
842 }
843
844 /* (breakpoint-expression <gdb:breakpoint>) -> string
845 This is only valid for watchpoints.
846 Returns #f for non-watchpoints. */
847
848 static SCM
849 gdbscm_breakpoint_expression (SCM self)
850 {
851 breakpoint_smob *bp_smob
852 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
853 struct watchpoint *wp;
854
855 if (!is_watchpoint (bp_smob->bp))
856 return SCM_BOOL_F;
857
858 wp = (struct watchpoint *) bp_smob->bp;
859
860 const char *str = wp->exp_string;
861 if (! str)
862 str = "";
863
864 return gdbscm_scm_from_c_string (str);
865 }
866
867 /* (breakpoint-condition <gdb:breakpoint>) -> string */
868
869 static SCM
870 gdbscm_breakpoint_condition (SCM self)
871 {
872 breakpoint_smob *bp_smob
873 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
874 char *str;
875
876 str = bp_smob->bp->cond_string;
877 if (! str)
878 return SCM_BOOL_F;
879
880 return gdbscm_scm_from_c_string (str);
881 }
882
883 /* (set-breakpoint-condition! <gdb:breakpoint> string|#f)
884 -> unspecified */
885
886 static SCM
887 gdbscm_set_breakpoint_condition_x (SCM self, SCM newvalue)
888 {
889 breakpoint_smob *bp_smob
890 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
891 char *exp;
892 struct gdb_exception except = exception_none;
893
894 SCM_ASSERT_TYPE (scm_is_string (newvalue) || gdbscm_is_false (newvalue),
895 newvalue, SCM_ARG2, FUNC_NAME,
896 _("string or #f"));
897
898 if (gdbscm_is_false (newvalue))
899 exp = NULL;
900 else
901 exp = gdbscm_scm_to_c_string (newvalue);
902
903 TRY
904 {
905 set_breakpoint_condition (bp_smob->bp, exp ? exp : "", 0);
906 }
907 CATCH (ex, RETURN_MASK_ALL)
908 {
909 except = ex;
910 }
911 END_CATCH
912
913 xfree (exp);
914 GDBSCM_HANDLE_GDB_EXCEPTION (except);
915
916 return SCM_UNSPECIFIED;
917 }
918
919 /* (breakpoint-stop <gdb:breakpoint>) -> procedure or #f */
920
921 static SCM
922 gdbscm_breakpoint_stop (SCM self)
923 {
924 breakpoint_smob *bp_smob
925 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
926
927 return bp_smob->stop;
928 }
929
930 /* (set-breakpoint-stop! <gdb:breakpoint> procedure|#f)
931 -> unspecified */
932
933 static SCM
934 gdbscm_set_breakpoint_stop_x (SCM self, SCM newvalue)
935 {
936 breakpoint_smob *bp_smob
937 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
938 const struct extension_language_defn *extlang = NULL;
939
940 SCM_ASSERT_TYPE (gdbscm_is_procedure (newvalue)
941 || gdbscm_is_false (newvalue),
942 newvalue, SCM_ARG2, FUNC_NAME,
943 _("procedure or #f"));
944
945 if (bp_smob->bp->cond_string != NULL)
946 extlang = get_ext_lang_defn (EXT_LANG_GDB);
947 if (extlang == NULL)
948 extlang = get_breakpoint_cond_ext_lang (bp_smob->bp, EXT_LANG_GUILE);
949 if (extlang != NULL)
950 {
951 char *error_text
952 = xstrprintf (_("Only one stop condition allowed. There is"
953 " currently a %s stop condition defined for"
954 " this breakpoint."),
955 ext_lang_capitalized_name (extlang));
956
957 scm_dynwind_begin ((scm_t_dynwind_flags) 0);
958 gdbscm_dynwind_xfree (error_text);
959 gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self, error_text);
960 /* The following line, while unnecessary, is present for completeness
961 sake. */
962 scm_dynwind_end ();
963 }
964
965 bp_smob->stop = newvalue;
966
967 return SCM_UNSPECIFIED;
968 }
969
970 /* (breakpoint-commands <gdb:breakpoint>) -> string */
971
972 static SCM
973 gdbscm_breakpoint_commands (SCM self)
974 {
975 breakpoint_smob *bp_smob
976 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
977 struct breakpoint *bp;
978 SCM result;
979
980 bp = bp_smob->bp;
981
982 if (bp->commands == NULL)
983 return SCM_BOOL_F;
984
985 string_file buf;
986
987 current_uiout->redirect (&buf);
988 TRY
989 {
990 print_command_lines (current_uiout, breakpoint_commands (bp), 0);
991 }
992 CATCH (except, RETURN_MASK_ALL)
993 {
994 current_uiout->redirect (NULL);
995 gdbscm_throw_gdb_exception (except);
996 }
997 END_CATCH
998
999 current_uiout->redirect (NULL);
1000 result = gdbscm_scm_from_c_string (buf.c_str ());
1001
1002 return result;
1003 }
1004
1005 /* (breakpoint-type <gdb:breakpoint>) -> integer */
1006
1007 static SCM
1008 gdbscm_breakpoint_type (SCM self)
1009 {
1010 breakpoint_smob *bp_smob
1011 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1012
1013 return scm_from_long (bp_smob->bp->type);
1014 }
1015
1016 /* (breakpoint-visible? <gdb:breakpoint>) -> boolean */
1017
1018 static SCM
1019 gdbscm_breakpoint_visible (SCM self)
1020 {
1021 breakpoint_smob *bp_smob
1022 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1023
1024 return scm_from_bool (bp_smob->bp->number >= 0);
1025 }
1026
1027 /* (breakpoint-number <gdb:breakpoint>) -> integer */
1028
1029 static SCM
1030 gdbscm_breakpoint_number (SCM self)
1031 {
1032 breakpoint_smob *bp_smob
1033 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
1034
1035 return scm_from_long (bp_smob->number);
1036 }
1037
1038 /* Return TRUE if "stop" has been set for this breakpoint.
1039
1040 This is the extension_language_ops.breakpoint_has_cond "method". */
1041
1042 int
1043 gdbscm_breakpoint_has_cond (const struct extension_language_defn *extlang,
1044 struct breakpoint *b)
1045 {
1046 breakpoint_smob *bp_smob = b->scm_bp_object;
1047
1048 if (bp_smob == NULL)
1049 return 0;
1050
1051 return gdbscm_is_procedure (bp_smob->stop);
1052 }
1053
1054 /* Call the "stop" method in the breakpoint class.
1055 This must only be called if gdbscm_breakpoint_has_cond returns true.
1056 If the stop method returns #t, the inferior will be stopped at the
1057 breakpoint. Otherwise the inferior will be allowed to continue
1058 (assuming other conditions don't indicate "stop").
1059
1060 This is the extension_language_ops.breakpoint_cond_says_stop "method". */
1061
1062 enum ext_lang_bp_stop
1063 gdbscm_breakpoint_cond_says_stop
1064 (const struct extension_language_defn *extlang, struct breakpoint *b)
1065 {
1066 breakpoint_smob *bp_smob = b->scm_bp_object;
1067 SCM predicate_result;
1068 int stop;
1069
1070 if (bp_smob == NULL)
1071 return EXT_LANG_BP_STOP_UNSET;
1072 if (!gdbscm_is_procedure (bp_smob->stop))
1073 return EXT_LANG_BP_STOP_UNSET;
1074
1075 stop = 1;
1076
1077 predicate_result
1078 = gdbscm_safe_call_1 (bp_smob->stop, bp_smob->containing_scm, NULL);
1079
1080 if (gdbscm_is_exception (predicate_result))
1081 ; /* Exception already printed. */
1082 /* If the "stop" function returns #f that means
1083 the Scheme breakpoint wants GDB to continue. */
1084 else if (gdbscm_is_false (predicate_result))
1085 stop = 0;
1086
1087 return stop ? EXT_LANG_BP_STOP_YES : EXT_LANG_BP_STOP_NO;
1088 }
1089
1090 /* Event callback functions. */
1091
1092 /* Callback that is used when a breakpoint is created.
1093 For breakpoints created by Scheme, i.e., gdbscm_create_breakpoint_x, finish
1094 object creation by connecting the Scheme wrapper to the gdb object.
1095 We ignore breakpoints created from gdb or python here, we create the
1096 Scheme wrapper for those when there's a need to, e.g.,
1097 gdbscm_breakpoints. */
1098
1099 static void
1100 bpscm_breakpoint_created (struct breakpoint *bp)
1101 {
1102 SCM bp_scm;
1103
1104 if (gdbscm_is_false (pending_breakpoint_scm))
1105 return;
1106
1107 /* Verify our caller error checked the user's request. */
1108 gdb_assert (bpscm_want_scm_wrapper_p (bp, 1));
1109
1110 bp_scm = pending_breakpoint_scm;
1111 pending_breakpoint_scm = SCM_BOOL_F;
1112
1113 bpscm_attach_scm_to_breakpoint (bp, bp_scm);
1114 }
1115
1116 /* Callback that is used when a breakpoint is deleted. This will
1117 invalidate the corresponding Scheme object. */
1118
1119 static void
1120 bpscm_breakpoint_deleted (struct breakpoint *b)
1121 {
1122 int num = b->number;
1123 struct breakpoint *bp;
1124
1125 /* TODO: Why the lookup? We have B. */
1126
1127 bp = get_breakpoint (num);
1128 if (bp)
1129 {
1130 breakpoint_smob *bp_smob = bp->scm_bp_object;
1131
1132 if (bp_smob)
1133 {
1134 bp_smob->bp = NULL;
1135 bp_smob->number = -1;
1136 bp_smob->stop = SCM_BOOL_F;
1137 scm_gc_unprotect_object (bp_smob->containing_scm);
1138 }
1139 }
1140 }
1141
1142 /* Initialize the Scheme breakpoint code. */
1143
1144 static const scheme_integer_constant breakpoint_integer_constants[] =
1145 {
1146 { "BP_NONE", bp_none },
1147 { "BP_BREAKPOINT", bp_breakpoint },
1148 { "BP_WATCHPOINT", bp_watchpoint },
1149 { "BP_HARDWARE_WATCHPOINT", bp_hardware_watchpoint },
1150 { "BP_READ_WATCHPOINT", bp_read_watchpoint },
1151 { "BP_ACCESS_WATCHPOINT", bp_access_watchpoint },
1152
1153 { "WP_READ", hw_read },
1154 { "WP_WRITE", hw_write },
1155 { "WP_ACCESS", hw_access },
1156
1157 END_INTEGER_CONSTANTS
1158 };
1159
1160 static const scheme_function breakpoint_functions[] =
1161 {
1162 { "make-breakpoint", 1, 0, 1, as_a_scm_t_subr (gdbscm_make_breakpoint),
1163 "\
1164 Create a GDB breakpoint object.\n\
1165 \n\
1166 Arguments:\n\
1167 location [#:type <type>] [#:wp-class <wp-class>] [#:internal <bool>]\n\
1168 Returns:\n\
1169 <gdb:breakpoint object" },
1170
1171 { "register-breakpoint!", 1, 0, 0,
1172 as_a_scm_t_subr (gdbscm_register_breakpoint_x),
1173 "\
1174 Register a <gdb:breakpoint> object with GDB." },
1175
1176 { "delete-breakpoint!", 1, 0, 0, as_a_scm_t_subr (gdbscm_delete_breakpoint_x),
1177 "\
1178 Delete the breakpoint from GDB." },
1179
1180 { "breakpoints", 0, 0, 0, as_a_scm_t_subr (gdbscm_breakpoints),
1181 "\
1182 Return a list of all GDB breakpoints.\n\
1183 \n\
1184 Arguments: none" },
1185
1186 { "breakpoint?", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_p),
1187 "\
1188 Return #t if the object is a <gdb:breakpoint> object." },
1189
1190 { "breakpoint-valid?", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_valid_p),
1191 "\
1192 Return #t if the breakpoint has not been deleted from GDB." },
1193
1194 { "breakpoint-number", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_number),
1195 "\
1196 Return the breakpoint's number." },
1197
1198 { "breakpoint-type", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_type),
1199 "\
1200 Return the type of the breakpoint." },
1201
1202 { "breakpoint-visible?", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_visible),
1203 "\
1204 Return #t if the breakpoint is visible to the user." },
1205
1206 { "breakpoint-location", 1, 0, 0,
1207 as_a_scm_t_subr (gdbscm_breakpoint_location),
1208 "\
1209 Return the location of the breakpoint as specified by the user." },
1210
1211 { "breakpoint-expression", 1, 0, 0,
1212 as_a_scm_t_subr (gdbscm_breakpoint_expression),
1213 "\
1214 Return the expression of the breakpoint as specified by the user.\n\
1215 Valid for watchpoints only, returns #f for non-watchpoints." },
1216
1217 { "breakpoint-enabled?", 1, 0, 0,
1218 as_a_scm_t_subr (gdbscm_breakpoint_enabled_p),
1219 "\
1220 Return #t if the breakpoint is enabled." },
1221
1222 { "set-breakpoint-enabled!", 2, 0, 0,
1223 as_a_scm_t_subr (gdbscm_set_breakpoint_enabled_x),
1224 "\
1225 Set the breakpoint's enabled state.\n\
1226 \n\
1227 Arguments: <gdb:breakpoint> boolean" },
1228
1229 { "breakpoint-silent?", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_silent_p),
1230 "\
1231 Return #t if the breakpoint is silent." },
1232
1233 { "set-breakpoint-silent!", 2, 0, 0,
1234 as_a_scm_t_subr (gdbscm_set_breakpoint_silent_x),
1235 "\
1236 Set the breakpoint's silent state.\n\
1237 \n\
1238 Arguments: <gdb:breakpoint> boolean" },
1239
1240 { "breakpoint-ignore-count", 1, 0, 0,
1241 as_a_scm_t_subr (gdbscm_breakpoint_ignore_count),
1242 "\
1243 Return the breakpoint's \"ignore\" count." },
1244
1245 { "set-breakpoint-ignore-count!", 2, 0, 0,
1246 as_a_scm_t_subr (gdbscm_set_breakpoint_ignore_count_x),
1247 "\
1248 Set the breakpoint's \"ignore\" count.\n\
1249 \n\
1250 Arguments: <gdb:breakpoint> count" },
1251
1252 { "breakpoint-hit-count", 1, 0, 0,
1253 as_a_scm_t_subr (gdbscm_breakpoint_hit_count),
1254 "\
1255 Return the breakpoint's \"hit\" count." },
1256
1257 { "set-breakpoint-hit-count!", 2, 0, 0,
1258 as_a_scm_t_subr (gdbscm_set_breakpoint_hit_count_x),
1259 "\
1260 Set the breakpoint's \"hit\" count. The value must be zero.\n\
1261 \n\
1262 Arguments: <gdb:breakpoint> 0" },
1263
1264 { "breakpoint-thread", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_thread),
1265 "\
1266 Return the breakpoint's global thread id or #f if there isn't one." },
1267
1268 { "set-breakpoint-thread!", 2, 0, 0,
1269 as_a_scm_t_subr (gdbscm_set_breakpoint_thread_x),
1270 "\
1271 Set the global thread id for this breakpoint.\n\
1272 \n\
1273 Arguments: <gdb:breakpoint> global-thread-id" },
1274
1275 { "breakpoint-task", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_task),
1276 "\
1277 Return the breakpoint's Ada task-id or #f if there isn't one." },
1278
1279 { "set-breakpoint-task!", 2, 0, 0,
1280 as_a_scm_t_subr (gdbscm_set_breakpoint_task_x),
1281 "\
1282 Set the breakpoint's Ada task-id.\n\
1283 \n\
1284 Arguments: <gdb:breakpoint> task-id" },
1285
1286 { "breakpoint-condition", 1, 0, 0,
1287 as_a_scm_t_subr (gdbscm_breakpoint_condition),
1288 "\
1289 Return the breakpoint's condition as specified by the user.\n\
1290 Return #f if there isn't one." },
1291
1292 { "set-breakpoint-condition!", 2, 0, 0,
1293 as_a_scm_t_subr (gdbscm_set_breakpoint_condition_x),
1294 "\
1295 Set the breakpoint's condition.\n\
1296 \n\
1297 Arguments: <gdb:breakpoint> condition\n\
1298 condition: a string" },
1299
1300 { "breakpoint-stop", 1, 0, 0, as_a_scm_t_subr (gdbscm_breakpoint_stop),
1301 "\
1302 Return the breakpoint's stop predicate.\n\
1303 Return #f if there isn't one." },
1304
1305 { "set-breakpoint-stop!", 2, 0, 0,
1306 as_a_scm_t_subr (gdbscm_set_breakpoint_stop_x),
1307 "\
1308 Set the breakpoint's stop predicate.\n\
1309 \n\
1310 Arguments: <gdb:breakpoint> procedure\n\
1311 procedure: A procedure of one argument, the breakpoint.\n\
1312 Its result is true if program execution should stop." },
1313
1314 { "breakpoint-commands", 1, 0, 0,
1315 as_a_scm_t_subr (gdbscm_breakpoint_commands),
1316 "\
1317 Return the breakpoint's commands." },
1318
1319 END_FUNCTIONS
1320 };
1321
1322 void
1323 gdbscm_initialize_breakpoints (void)
1324 {
1325 breakpoint_smob_tag
1326 = gdbscm_make_smob_type (breakpoint_smob_name, sizeof (breakpoint_smob));
1327 scm_set_smob_free (breakpoint_smob_tag, bpscm_free_breakpoint_smob);
1328 scm_set_smob_print (breakpoint_smob_tag, bpscm_print_breakpoint_smob);
1329
1330 observer_attach_breakpoint_created (bpscm_breakpoint_created);
1331 observer_attach_breakpoint_deleted (bpscm_breakpoint_deleted);
1332
1333 gdbscm_define_integer_constants (breakpoint_integer_constants, 1);
1334 gdbscm_define_functions (breakpoint_functions, 1);
1335
1336 type_keyword = scm_from_latin1_keyword ("type");
1337 wp_class_keyword = scm_from_latin1_keyword ("wp-class");
1338 internal_keyword = scm_from_latin1_keyword ("internal");
1339 }
gdbscm_breakpoint_has_cond
int gdbscm_breakpoint_has_cond(const struct extension_language_defn *extlang, struct breakpoint *b)
Definition: scm-breakpoint.c:1043
as_a_scm_t_subr
static scm_t_subr as_a_scm_t_subr(SCM(*func)(void))
Definition: guile-internal.h:66
breakpoint_commands
struct command_line * breakpoint_commands(struct breakpoint *b)
Definition: breakpoint.c:303
observer_attach_breakpoint_deleted
struct observer * observer_attach_breakpoint_deleted(observer_breakpoint_deleted_ftype *f)
scm_new_smob
static SCM scm_new_smob(scm_t_bits tc, scm_t_bits data)
Definition: guile-internal.h:141
set_ignore_count
void set_ignore_count(int bptnum, int count, int from_tty)
Definition: breakpoint.c:14018
bp_enabled
Definition: breakpoint.h:202
gdbscm_breakpoint_object::is_internal
int is_internal
Definition: scm-breakpoint.c:71
bpscm_make_breakpoint_smob
static SCM bpscm_make_breakpoint_smob(void)
Definition: scm-breakpoint.c:203
gdbscm_define_functions
void gdbscm_define_functions(const scheme_function *, int is_public)
Definition: scm-utils.c:44
type_keyword
static SCM type_keyword
Definition: scm-breakpoint.c:103
RETURN_MASK_ALL
Definition: common-exceptions.h:44
bp_breakpoint
Definition: breakpoint.h:70
ext_lang_bp_stop
ext_lang_bp_stop
Definition: extension.h:129
xfree
void xfree(void *)
gdbscm_breakpoint_expression
static SCM gdbscm_breakpoint_expression(SCM self)
Definition: scm-breakpoint.c:849
if
if(!(yy_init))
Definition: ada-lex.c:1075
gdbscm_breakpoint_location
static SCM gdbscm_breakpoint_location(SCM self)
Definition: scm-breakpoint.c:828
ada-lang.h
gdbscm_scm_to_c_string
char * gdbscm_scm_to_c_string(SCM string)
Definition: scm-string.c:55
breakpoint_smob_name
static const char breakpoint_smob_name[]
Definition: scm-breakpoint.c:93
gdbscm_breakpoint_object::is_scheme_bkpt
int is_scheme_bkpt
Definition: scm-breakpoint.c:52
gdbscm_breakpoint_object::spec
struct gdbscm_breakpoint_object::@73 spec
breakpoint::number
int number
Definition: breakpoint.h:699
gdbscm_breakpoint_ignore_count
static SCM gdbscm_breakpoint_ignore_count(SCM self)
Definition: scm-breakpoint.c:645
memset
void * memset(T *s, int c, size_t n)=delete
valid_global_thread_id
int valid_global_thread_id(int global_id)
Definition: thread.c:593
breakpoint::silent
bool silent
Definition: breakpoint.h:706
awatch_command_wrapper
void awatch_command_wrapper(const char *arg, int from_tty, int internal)
Definition: breakpoint.c:11052
FUNC_NAME
#define FUNC_NAME
Definition: guile-internal.h:153
guile-internal.h
gdbscm_breakpoint_commands
static SCM gdbscm_breakpoint_commands(SCM self)
Definition: scm-breakpoint.c:973
gdbscm_breakpoint_stop
static SCM gdbscm_breakpoint_stop(SCM self)
Definition: scm-breakpoint.c:922
exception_none
const struct gdb_exception exception_none
Definition: common-exceptions.c:23
bp_watchpoint
Definition: breakpoint.h:75
gdbscm_make_smob_type
scm_t_bits gdbscm_make_smob_type(const char *name, size_t size)
Definition: scm-gsmob.c:102
gdbscm_is_bool
#define gdbscm_is_bool(scm)
Definition: guile-internal.h:131
skip_spaces
char * skip_spaces(char *chp)
Definition: common-utils.c:337
gdbscm_set_breakpoint_ignore_count_x
static SCM gdbscm_set_breakpoint_ignore_count_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:657
bpscm_build_bp_list
static int bpscm_build_bp_list(struct breakpoint *bp, void *arg)
Definition: scm-breakpoint.c:509
_
#define _(String)
Definition: gdb_locale.h:35
EXT_LANG_GDB
Definition: extension.h:62
gdbscm_breakpoint_object::containing_scm
SCM containing_scm
Definition: scm-breakpoint.c:87
gdbscm_register_breakpoint_x
static SCM gdbscm_register_breakpoint_x(SCM self)
Definition: scm-breakpoint.c:410
bpscm_type_to_string
static const char * bpscm_type_to_string(enum bptype type)
Definition: scm-breakpoint.c:131
defs.h
gdbscm_breakpoint_object::bp
struct breakpoint * bp
Definition: scm-breakpoint.c:82
END_CATCH
#define END_CATCH
Definition: common-exceptions.h:259
gdbscm_set_breakpoint_stop_x
static SCM gdbscm_set_breakpoint_stop_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:934
gdbscm_breakpoint_condition
static SCM gdbscm_breakpoint_condition(SCM self)
Definition: scm-breakpoint.c:870
gdbscm_is_exception
int gdbscm_is_exception(SCM scm)
Definition: scm-exception.c:147
enable_breakpoint
void enable_breakpoint(struct breakpoint *bpt)
Definition: breakpoint.c:14485
string_to_event_location_basic
event_location_up string_to_event_location_basic(const char **stringp, const struct language_defn *language, symbol_name_match_type match_type)
Definition: location.c:877
bpscm_print_breakpoint_smob
static int bpscm_print_breakpoint_smob(SCM self, SCM port, scm_print_state *pstate)
Definition: scm-breakpoint.c:162
gdbscm_is_true
#define gdbscm_is_true(scm)
Definition: guile-internal.h:134
watchpoint::exp_string
char * exp_string
Definition: breakpoint.h:799
hw_write
Definition: break-common.h:24
breakpoint_set_task
void breakpoint_set_task(struct breakpoint *b, int task)
Definition: breakpoint.c:1209
arch-utils.h
gdbscm_breakpoint_object::access_type
enum target_hw_bp_type access_type
Definition: scm-breakpoint.c:68
gdbscm_breakpoints
static SCM gdbscm_breakpoints(void)
Definition: scm-breakpoint.c:544
observer.h
breakpoint::hit_count
int hit_count
Definition: breakpoint.h:773
internal_keyword
static SCM internal_keyword
Definition: scm-breakpoint.c:105
TRY
#define TRY
Definition: common-exceptions.h:246
gdbscm_dynwind_xfree
void gdbscm_dynwind_xfree(void *ptr)
Definition: scm-utils.c:571
gdbscm_breakpoint_object
Definition: scm-breakpoint.c:46
extract_bp_kind::bp
gdbscm_set_breakpoint_thread_x
static SCM gdbscm_set_breakpoint_thread_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:738
gdbscm_breakpoint_visible
static SCM gdbscm_breakpoint_visible(SCM self)
Definition: scm-breakpoint.c:1019
gdbscm_init_gsmob
void gdbscm_init_gsmob(gdb_smob *base)
Definition: scm-gsmob.c:113
CATCH
#define CATCH(EXCEPTION, MASK)
Definition: common-exceptions.h:254
bpscm_attach_scm_to_breakpoint
static void bpscm_attach_scm_to_breakpoint(struct breakpoint *bp, SCM containing_scm)
Definition: scm-breakpoint.c:245
gdbscm_breakpoint_object::base
gdb_smob base
Definition: scm-breakpoint.c:49
breakpoint::type
bptype type
Definition: breakpoint.h:693
pstate
static struct parser_state * pstate
Definition: ada-exp.c:98
gdbscm_set_breakpoint_condition_x
static SCM gdbscm_set_breakpoint_condition_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:887
gdbscm_scm_from_c_string
SCM gdbscm_scm_from_c_string(const char *string)
Definition: scm-string.c:44
LONG_MAX
#define LONG_MAX
Definition: defs.h:489
iterate_over_breakpoints
struct breakpoint * iterate_over_breakpoints(int(*callback)(struct breakpoint *, void *), void *data)
Definition: breakpoint.c:15347
gdbscm_is_false
#define gdbscm_is_false(scm)
Definition: guile-internal.h:133
EXT_LANG_BP_STOP_YES
Definition: extension.h:138
is_watchpoint
int is_watchpoint(const struct breakpoint *bpt)
Definition: breakpoint.c:1533
breakpoint::cond_string
char * cond_string
Definition: breakpoint.h:749
gdbscm_set_breakpoint_task_x
static SCM gdbscm_set_breakpoint_task_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:780
observer_attach_breakpoint_created
struct observer * observer_attach_breakpoint_created(observer_breakpoint_created_ftype *f)
gdb_assert_not_reached
#define gdb_assert_not_reached(message)
Definition: gdb_assert.h:55
gdbscm_set_breakpoint_enabled_x
static SCM gdbscm_set_breakpoint_enabled_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:583
gdbscm_set_breakpoint_silent_x
static SCM gdbscm_set_breakpoint_silent_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:621
gdbthread.h
current_uiout
#define current_uiout
Definition: ui-out.h:39
breakpoint
Definition: breakpoint.h:684
valid_task_id
int valid_task_id(int)
Definition: ada-tasks.c:337
bpscm_get_breakpoint_smob_arg_unsafe
static breakpoint_smob * bpscm_get_breakpoint_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition: scm-breakpoint.c:292
cli-script.h
disable_breakpoint
void disable_breakpoint(struct breakpoint *bpt)
Definition: breakpoint.c:14330
hw_read
Definition: break-common.h:25
bp_call_disabled
Definition: breakpoint.h:204
type
Definition: gdbtypes.h:749
language.h
gdb_smob
Definition: guile-internal.h:241
gdbscm_breakpoint_thread
static SCM gdbscm_breakpoint_thread(SCM self)
Definition: scm-breakpoint.c:724
scheme_function
Definition: guile-internal.h:91
get_current_arch
struct gdbarch * get_current_arch(void)
Definition: arch-utils.c:798
gdbscm_breakpoint_silent_p
static SCM gdbscm_breakpoint_silent_p(SCM self)
Definition: scm-breakpoint.c:610
type
static const char * type
Definition: language.c:113
get_breakpoint
struct breakpoint * get_breakpoint(int num)
Definition: breakpoint.c:652
bpscm_free_breakpoint_smob
static size_t bpscm_free_breakpoint_smob(SCM self)
Definition: scm-breakpoint.c:112
EXT_LANG_GUILE
Definition: extension.h:64
event_location_up
std::unique_ptr< event_location, event_location_deleter > event_location_up
Definition: location.h:140
event_location_to_string
const char * event_location_to_string(struct event_location *location)
Definition: location.c:397
gdbscm_breakpoint_valid_p
static SCM gdbscm_breakpoint_valid_p(SCM self)
Definition: scm-breakpoint.c:561
gdbscm_breakpoint_object::type
enum bptype type
Definition: scm-breakpoint.c:65
xstrprintf
char * xstrprintf(const char *format,...)
Definition: common-utils.c:107
breakpoint.h
breakpoint_smob
struct gdbscm_breakpoint_object breakpoint_smob
print_command_lines
void print_command_lines(struct ui_out *uiout, struct command_line *cmd, unsigned int depth)
Definition: cli-script.c:189
gdbscm_breakpoint_task
static SCM gdbscm_breakpoint_task(SCM self)
Definition: scm-breakpoint.c:766
bpscm_is_valid
static int bpscm_is_valid(breakpoint_smob *bp_smob)
Definition: scm-breakpoint.c:304
extension_language_defn
Definition: extension-priv.h:53
bp_read_watchpoint
Definition: breakpoint.h:77
watchpoint
Definition: breakpoint.h:793
bkpt_breakpoint_ops
struct breakpoint_ops bkpt_breakpoint_ops
Definition: breakpoint.c:255
watchpoint::exp
expression_up exp
Definition: breakpoint.h:804
wp_class_keyword
static SCM wp_class_keyword
Definition: scm-breakpoint.c:104
bptype
bptype
Definition: breakpoint.h:67
gdbscm_printf
void gdbscm_printf(SCM port, const char *format,...) ATTRIBUTE_PRINTF(2
watch_command_wrapper
void watch_command_wrapper(const char *arg, int from_tty, int internal)
Definition: breakpoint.c:11009
get_ext_lang_defn
const struct extension_language_defn * get_ext_lang_defn(enum extension_language lang)
Definition: extension.c:116
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
gdbscm_breakpoint_object::stop
SCM stop
Definition: scm-breakpoint.c:90
breakpoint_smob_tag
static scm_t_bits breakpoint_smob_tag
Definition: scm-breakpoint.c:96
value
Definition: value.c:169
gdbscm_delete_breakpoint_x
static SCM gdbscm_delete_breakpoint_x(SCM self)
Definition: scm-breakpoint.c:488
gdbscm_initialize_breakpoints
void gdbscm_initialize_breakpoints(void)
Definition: scm-breakpoint.c:1323
bp_none
Definition: breakpoint.h:69
gdbscm_safe_call_1
SCM gdbscm_safe_call_1(SCM proc, SCM arg0, excp_matcher_func *ok_excps)
Definition: scm-safe-call.c:257
gdbscm_breakpoint_enabled_p
static SCM gdbscm_breakpoint_enabled_p(SCM self)
Definition: scm-breakpoint.c:572
gdbscm_breakpoint_number
static SCM gdbscm_breakpoint_number(SCM self)
Definition: scm-breakpoint.c:1030
gdbscm_define_integer_constants
void gdbscm_define_integer_constants(const scheme_integer_constant *, int is_public)
Definition: scm-utils.c:63
get_breakpoint_cond_ext_lang
const struct extension_language_defn * get_breakpoint_cond_ext_lang(struct breakpoint *b, enum extension_language skip_lang)
Definition: extension.c:614
bpscm_get_breakpoint_arg_unsafe
static SCM bpscm_get_breakpoint_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition: scm-breakpoint.c:280
END_FUNCTIONS
#define END_FUNCTIONS
Definition: guile-internal.h:103
bpscm_want_scm_wrapper_p
static int bpscm_want_scm_wrapper_p(struct breakpoint *bp, int from_scheme)
Definition: scm-breakpoint.c:224
current_language
const struct language_defn * current_language
Definition: language.c:81
gdbscm_invalid_object_error
void gdbscm_invalid_object_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
Definition: scm-exception.c:325
enable_state
enable_state
Definition: breakpoint.h:198
breakpoint::thread
int thread
Definition: breakpoint.h:763
bpscm_breakpoint_created
static void bpscm_breakpoint_created(struct breakpoint *bp)
Definition: scm-breakpoint.c:1100
breakpoint_integer_constants
static const scheme_integer_constant breakpoint_integer_constants[]
Definition: scm-breakpoint.c:1144
ext_lang_capitalized_name
const char * ext_lang_capitalized_name(const struct extension_language_defn *extlang)
Definition: extension.c:235
gdbscm_set_breakpoint_hit_count_x
static SCM gdbscm_set_breakpoint_hit_count_x(SCM self, SCM newvalue)
Definition: scm-breakpoint.c:697
pending_breakpoint_scm
static SCM pending_breakpoint_scm
Definition: scm-breakpoint.c:100
breakpoint::location
event_location_up location
Definition: breakpoint.h:730
gdbscm_misc_error
void gdbscm_misc_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
Definition: scm-exception.c:371
string_file::c_str
const char * c_str() const
Definition: ui-file.h:137
gdbscm_out_of_range_error
void gdbscm_out_of_range_error(const char *subr, int arg_pos, SCM bad_value, const char *error) ATTRIBUTE_NORETURN
Definition: scm-exception.c:349
create_breakpoint
int create_breakpoint(struct gdbarch *gdbarch, const struct event_location *location, const char *cond_string, int thread, const char *extra_string, int parse_extra, int tempflag, enum bptype type_wanted, int ignore_count, enum auto_boolean pending_break_support, const struct breakpoint_ops *ops, int from_tty, int enabled, int internal, unsigned flags)
Definition: breakpoint.c:9325
gdbscm_throw_gdb_exception
void gdbscm_throw_gdb_exception(struct gdb_exception exception) ATTRIBUTE_NORETURN
Definition: scm-exception.c:457
AUTO_BOOLEAN_TRUE
Definition: defs.h:239
gdbscm_breakpoint_type
static SCM gdbscm_breakpoint_type(SCM self)
Definition: scm-breakpoint.c:1008
gdbscm_breakpoint_object::number
int number
Definition: scm-breakpoint.c:78
bp_disabled
Definition: breakpoint.h:200
gdbscm_parse_function_args
void gdbscm_parse_function_args(const char *function_name, int beginning_arg_pos, const SCM *keywords, const char *format,...)
Definition: scm-utils.c:377
value.h
location.h
target_hw_bp_type
target_hw_bp_type
Definition: break-common.h:22
breakpoint_set_silent
void breakpoint_set_silent(struct breakpoint *b, int silent)
Definition: breakpoint.c:1183
EXT_LANG_BP_STOP_UNSET
Definition: extension.h:132
breakpoint_set_thread
void breakpoint_set_thread(struct breakpoint *b, int thread)
Definition: breakpoint.c:1196
gdb_exception
Definition: common-exceptions.h:111
GDBSCM_HANDLE_GDB_EXCEPTION
#define GDBSCM_HANDLE_GDB_EXCEPTION(exception)
Definition: guile-internal.h:643
breakpoint::ignore_count
int ignore_count
Definition: breakpoint.h:711
bp_hardware_watchpoint
Definition: breakpoint.h:76
hw_access
Definition: break-common.h:26
bpscm_breakpoint_deleted
static void bpscm_breakpoint_deleted(struct breakpoint *b)
Definition: scm-breakpoint.c:1120
breakpoint::scm_bp_object
gdbscm_breakpoint_object * scm_bp_object
Definition: breakpoint.h:788
gdbscm_make_breakpoint
static SCM gdbscm_make_breakpoint(SCM location_scm, SCM rest)
Definition: scm-breakpoint.c:339
scheme_integer_constant
Definition: guile-internal.h:107
bpscm_get_valid_breakpoint_smob_arg_unsafe
static breakpoint_smob * bpscm_get_valid_breakpoint_smob_arg_unsafe(SCM self, int arg_pos, const char *func_name)
Definition: scm-breakpoint.c:314
breakpoint::enable_state
enum enable_state enable_state
Definition: breakpoint.h:695
gdbscm_breakpoint_object::location
char * location
Definition: scm-breakpoint.c:61
EXT_LANG_BP_STOP_NO
Definition: extension.h:135
bpscm_enable_state_to_string
static const char * bpscm_enable_state_to_string(enum enable_state enable_state)
Definition: scm-breakpoint.c:148
bpscm_is_breakpoint
static int bpscm_is_breakpoint(SCM scm)
Definition: scm-breakpoint.c:263
gdbscm_breakpoint_hit_count
static SCM gdbscm_breakpoint_hit_count(SCM self)
Definition: scm-breakpoint.c:686
rwatch_command_wrapper
void rwatch_command_wrapper(const char *arg, int from_tty, int internal)
Definition: breakpoint.c:11040
gdbscm_is_procedure
int gdbscm_is_procedure(SCM proc)
Definition: scm-utils.c:579
gdbcmd.h
delete_breakpoint
void delete_breakpoint(struct breakpoint *bpt)
Definition: breakpoint.c:13226
breakpoint::task
int task
Definition: breakpoint.h:767
bp_access_watchpoint
Definition: breakpoint.h:78
set_breakpoint_condition
void set_breakpoint_condition(struct breakpoint *b, const char *exp, int from_tty)
Definition: breakpoint.c:838
symbol_name_match_type::WILD
gdbscm_gc_xstrdup
char * gdbscm_gc_xstrdup(const char *)
Definition: scm-utils.c:587
gdbscm_breakpoint_cond_says_stop
enum ext_lang_bp_stop gdbscm_breakpoint_cond_says_stop(const struct extension_language_defn *extlang, struct breakpoint *b)
Definition: scm-breakpoint.c:1064
gdbscm_breakpoint_p
static SCM gdbscm_breakpoint_p(SCM scm)
Definition: scm-breakpoint.c:271
breakpoint_functions
static const scheme_function breakpoint_functions[]
Definition: scm-breakpoint.c:1160
END_INTEGER_CONSTANTS
#define END_INTEGER_CONSTANTS
Definition: guile-internal.h:113
string_file
Definition: ui-file.h:106