*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / breakpoint.c
1 /* Everything about breakpoints, for GDB.
2 Copyright (C) 1986, 1987, 1989, 1990 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 GDB is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 1, or (at your option)
9 any later version.
10
11 GDB is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GDB; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include <stdio.h>
21 #include <ctype.h>
22 #include "defs.h"
23 #include "param.h"
24 #include "symtab.h"
25 #include "frame.h"
26 #include "breakpoint.h"
27 #include "expression.h"
28 #include "gdbcore.h"
29 #include "gdbcmd.h"
30 #include "value.h"
31 #include "ctype.h"
32 #include "command.h"
33 #include "inferior.h"
34 #include "target.h"
35 #include <string.h>
36
37 extern int addressprint; /* Print machine addresses? */
38 extern int demangle; /* Print de-mangled symbol names? */
39
40 extern int catch_errors ();
41 extern void set_next_address (); /* ...for x/ command */
42
43 /* Are we executing breakpoint commands? */
44 static int executing_breakpoint_commands;
45
46 /* States of enablement of breakpoint.
47 `temporary' means disable when hit.
48 `delete' means delete when hit. */
49
50 enum enable { disabled, enabled, temporary, delete};
51
52 /* Not that the ->silent field is not currently used by any commands
53 (though the code is in there if it was to be, and set_raw_breakpoint
54 does set it to 0). I implemented it because I thought it would be
55 useful for a hack I had to put in; I'm going to leave it in because
56 I can see how there might be times when it would indeed be useful */
57
58 /* This is for a breakpoint or a watchpoint. */
59
60 struct breakpoint
61 {
62 struct breakpoint *next;
63 /* Number assigned to distinguish breakpoints. */
64 int number;
65 /* Address to break at, or NULL if not a breakpoint. */
66 CORE_ADDR address;
67 /* Line number of this address. Redundant. Only matters if address
68 is non-NULL. */
69 int line_number;
70 /* Symtab of file of this address. Redundant. Only matters if address
71 is non-NULL. */
72 struct symtab *symtab;
73 /* Zero means disabled; remember the info but don't break here. */
74 enum enable enable;
75 /* Non-zero means a silent breakpoint (don't print frame info
76 if we stop here). */
77 unsigned char silent;
78 /* Number of stops at this breakpoint that should
79 be continued automatically before really stopping. */
80 int ignore_count;
81 /* "Real" contents of byte where breakpoint has been inserted.
82 Valid only when breakpoints are in the program. Under the complete
83 control of the target insert_breakpoint and remove_breakpoint routines.
84 No other code should assume anything about the value(s) here. */
85 char shadow_contents[BREAKPOINT_MAX];
86 /* Nonzero if this breakpoint is now inserted. Only matters if address
87 is non-NULL. */
88 char inserted;
89 /* Nonzero if this is not the first breakpoint in the list
90 for the given address. Only matters if address is non-NULL. */
91 char duplicate;
92 /* Chain of command lines to execute when this breakpoint is hit. */
93 struct command_line *commands;
94 /* Stack depth (address of frame). If nonzero, break only if fp
95 equals this. */
96 FRAME_ADDR frame;
97 /* Conditional. Break only if this expression's value is nonzero. */
98 struct expression *cond;
99
100 /* String we used to set the breakpoint (malloc'd). Only matters if
101 address is non-NULL. */
102 char *addr_string;
103 /* String form of the breakpoint condition (malloc'd), or NULL if there
104 is no condition. */
105 char *cond_string;
106
107 /* The expression we are watching, or NULL if not a watchpoint. */
108 struct expression *exp;
109 /* The largest block within which it is valid, or NULL if it is
110 valid anywhere (e.g. consists just of global symbols). */
111 struct block *exp_valid_block;
112 /* Value of the watchpoint the last time we checked it. */
113 value val;
114 };
115
116 #define ALL_BREAKPOINTS(b) for (b = breakpoint_chain; b; b = b->next)
117
118 /* Chain of all breakpoints defined. */
119
120 struct breakpoint *breakpoint_chain;
121
122 /* Number of last breakpoint made. */
123
124 static int breakpoint_count;
125
126 /* Set breakpoint count to NUM. */
127 static void
128 set_breakpoint_count (num)
129 int num;
130 {
131 breakpoint_count = num;
132 set_internalvar (lookup_internalvar ("bpnum"),
133 value_from_long (builtin_type_int, (LONGEST) num));
134 }
135
136 /* Default address, symtab and line to put a breakpoint at
137 for "break" command with no arg.
138 if default_breakpoint_valid is zero, the other three are
139 not valid, and "break" with no arg is an error.
140
141 This set by print_stack_frame, which calls set_default_breakpoint. */
142
143 int default_breakpoint_valid;
144 CORE_ADDR default_breakpoint_address;
145 struct symtab *default_breakpoint_symtab;
146 int default_breakpoint_line;
147
148 static void delete_breakpoint ();
149 void breakpoint_auto_delete ();
150
151 /* Flag indicating extra verbosity for xgdb. */
152 extern int xgdb_verbose;
153 \f
154 /* *PP is a string denoting a breakpoint. Get the number of the breakpoint.
155 Advance *PP after the string and any trailing whitespace.
156
157 Currently the string can either be a number or "$" followed by the name
158 of a convenience variable. Making it an expression wouldn't work well
159 for map_breakpoint_numbers (e.g. "4 + 5 + 6"). */
160 static int
161 get_number (pp)
162 char **pp;
163 {
164 int retval;
165 char *p = *pp;
166
167 if (p == NULL)
168 /* Empty line means refer to the last breakpoint. */
169 return breakpoint_count;
170 else if (*p == '$')
171 {
172 /* Make a copy of the name, so we can null-terminate it
173 to pass to lookup_internalvar(). */
174 char *varname;
175 char *start = ++p;
176 value val;
177
178 while (isalnum (*p) || *p == '_')
179 p++;
180 varname = (char *) alloca (p - start + 1);
181 strncpy (varname, start, p - start);
182 varname[p - start] = '\0';
183 val = value_of_internalvar (lookup_internalvar (varname));
184 if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT)
185 error (
186 "Convenience variables used to specify breakpoints must have integer values."
187 );
188 retval = (int) value_as_long (val);
189 }
190 else
191 {
192 while (*p >= '0' && *p <= '9')
193 ++p;
194 if (p == *pp)
195 /* There is no number here. (e.g. "cond a == b"). */
196 error_no_arg ("breakpoint number");
197 retval = atoi (*pp);
198 }
199 if (!(isspace (*p) || *p == '\0'))
200 error ("breakpoint number expected");
201 while (isspace (*p))
202 p++;
203 *pp = p;
204 return retval;
205 }
206 \f
207 /* condition N EXP -- set break condition of breakpoint N to EXP. */
208
209 static void
210 condition_command (arg, from_tty)
211 char *arg;
212 int from_tty;
213 {
214 register struct breakpoint *b;
215 char *p;
216 register int bnum;
217
218 if (arg == 0)
219 error_no_arg ("breakpoint number");
220
221 p = arg;
222 bnum = get_number (&p);
223
224 ALL_BREAKPOINTS (b)
225 if (b->number == bnum)
226 {
227 if (b->cond)
228 {
229 free (b->cond);
230 b->cond = 0;
231 }
232 if (b->cond_string != NULL)
233 free (b->cond_string);
234
235 if (*p == 0)
236 {
237 b->cond = 0;
238 b->cond_string = NULL;
239 if (from_tty)
240 printf ("Breakpoint %d now unconditional.\n", bnum);
241 }
242 else
243 {
244 arg = p;
245 /* I don't know if it matters whether this is the string the user
246 typed in or the decompiled expression. */
247 b->cond_string = savestring (arg, strlen (arg));
248 b->cond = parse_c_1 (&arg, block_for_pc (b->address), 0);
249 if (*arg)
250 error ("Junk at end of expression");
251 }
252 return;
253 }
254
255 error ("No breakpoint number %d.", bnum);
256 }
257
258 static void
259 commands_command (arg, from_tty)
260 char *arg;
261 int from_tty;
262 {
263 register struct breakpoint *b;
264 char *p;
265 register int bnum;
266 struct command_line *l;
267
268 /* If we allowed this, we would have problems with when to
269 free the storage, if we change the commands currently
270 being read from. */
271
272 if (executing_breakpoint_commands)
273 error ("Can't use the \"commands\" command among a breakpoint's commands.");
274
275 p = arg;
276 bnum = get_number (&p);
277 if (p && *p)
278 error ("Unexpected extra arguments following breakpoint number.");
279
280 ALL_BREAKPOINTS (b)
281 if (b->number == bnum)
282 {
283 if (input_from_terminal_p ())
284 {
285 printf ("Type commands for when breakpoint %d is hit, one per line.\n\
286 End with a line saying just \"end\".\n", bnum);
287 fflush (stdout);
288 }
289 l = read_command_lines ();
290 free_command_lines (&b->commands);
291 b->commands = l;
292 return;
293 }
294 error ("No breakpoint number %d.", bnum);
295 }
296 \f
297 extern int memory_breakpoint_size; /* from mem-break.c */
298
299 /* Like target_read_memory() but if breakpoints are inserted, return
300 the shadow contents instead of the breakpoints themselves. */
301 int
302 read_memory_nobpt (memaddr, myaddr, len)
303 CORE_ADDR memaddr;
304 char *myaddr;
305 unsigned len;
306 {
307 int status;
308 struct breakpoint *b;
309
310 if (memory_breakpoint_size < 0)
311 /* No breakpoints on this machine. */
312 return target_read_memory (memaddr, myaddr, len);
313
314 ALL_BREAKPOINTS (b)
315 {
316 if (b->address == NULL || !b->inserted)
317 continue;
318 else if (b->address + memory_breakpoint_size <= memaddr)
319 /* The breakpoint is entirely before the chunk of memory
320 we are reading. */
321 continue;
322 else if (b->address >= memaddr + len)
323 /* The breakpoint is entirely after the chunk of memory we
324 are reading. */
325 continue;
326 else
327 {
328 /* Copy the breakpoint from the shadow contents, and recurse
329 for the things before and after. */
330
331 /* Addresses and length of the part of the breakpoint that
332 we need to copy. */
333 CORE_ADDR membpt = b->address;
334 unsigned int bptlen = memory_breakpoint_size;
335 /* Offset within shadow_contents. */
336 int bptoffset = 0;
337
338 if (membpt < memaddr)
339 {
340 /* Only copy the second part of the breakpoint. */
341 bptlen -= memaddr - membpt;
342 bptoffset = memaddr - membpt;
343 membpt = memaddr;
344 }
345
346 if (membpt + bptlen > memaddr + len)
347 {
348 /* Only copy the first part of the breakpoint. */
349 bptlen -= (membpt + bptlen) - (memaddr + len);
350 }
351
352 bcopy (b->shadow_contents + bptoffset,
353 myaddr + membpt - memaddr, bptlen);
354
355 if (membpt > memaddr)
356 {
357 /* Copy the section of memory before the breakpoint. */
358 status = read_memory_nobpt (memaddr, myaddr, membpt - memaddr);
359 if (status != 0)
360 return status;
361 }
362
363 if (membpt + bptlen < memaddr + len)
364 {
365 /* Copy the section of memory after the breakpoint. */
366 status = read_memory_nobpt
367 (membpt + bptlen,
368 myaddr + membpt + bptlen - memaddr,
369 memaddr + len - (membpt + bptlen));
370 if (status != 0)
371 return status;
372 }
373 return 0;
374 }
375 }
376 /* Nothing overlaps. Just call read_memory_noerr. */
377 return target_read_memory (memaddr, myaddr, len);
378 }
379 \f
380 /* insert_breakpoints is used when starting or continuing the program.
381 remove_breakpoints is used when the program stops.
382 Both return zero if successful,
383 or an `errno' value if could not write the inferior. */
384
385 int
386 insert_breakpoints ()
387 {
388 register struct breakpoint *b;
389 int val = 0;
390 int disabled_breaks = 0;
391
392 ALL_BREAKPOINTS (b)
393 if (b->address != NULL
394 && b->enable != disabled
395 && ! b->inserted
396 && ! b->duplicate)
397 {
398 val = target_insert_breakpoint(b->address, b->shadow_contents);
399 if (val)
400 {
401 /* Can't set the breakpoint. */
402 #if defined (DISABLE_UNSETTABLE_BREAK)
403 if (DISABLE_UNSETTABLE_BREAK (b->address))
404 {
405 val = 0;
406 b->enable = disabled;
407 if (!disabled_breaks)
408 {
409 fprintf (stderr,
410 "Cannot insert breakpoint %d:\n", b->number);
411 printf_filtered ("Disabling shared library breakpoints:\n");
412 }
413 disabled_breaks = 1;
414 printf_filtered ("%d ", b->number);
415 }
416 else
417 #endif
418 {
419 fprintf (stderr, "Cannot insert breakpoint %d:\n", b->number);
420 memory_error (val, b->address); /* which bombs us out */
421 }
422 }
423 else
424 b->inserted = 1;
425 }
426 if (disabled_breaks)
427 printf_filtered ("\n");
428 return val;
429 }
430
431 int
432 remove_breakpoints ()
433 {
434 register struct breakpoint *b;
435 int val;
436
437 #ifdef BREAKPOINT_DEBUG
438 printf ("Removing breakpoints.\n");
439 #endif /* BREAKPOINT_DEBUG */
440
441 ALL_BREAKPOINTS (b)
442 if (b->address != NULL && b->inserted)
443 {
444 val = target_remove_breakpoint(b->address, b->shadow_contents);
445 if (val)
446 return val;
447 b->inserted = 0;
448 #ifdef BREAKPOINT_DEBUG
449 printf ("Removed breakpoint at 0x%x, shadow 0x%x, 0x%x.\n",
450 b->address, b->shadow_contents[0], b->shadow_contents[1]);
451 #endif /* BREAKPOINT_DEBUG */
452 }
453
454 return 0;
455 }
456
457 /* Clear the "inserted" flag in all breakpoints.
458 This is done when the inferior is loaded. */
459
460 void
461 mark_breakpoints_out ()
462 {
463 register struct breakpoint *b;
464
465 ALL_BREAKPOINTS (b)
466 b->inserted = 0;
467 }
468
469 /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC.
470 When continuing from a location with a breakpoint,
471 we actually single step once before calling insert_breakpoints. */
472
473 int
474 breakpoint_here_p (pc)
475 CORE_ADDR pc;
476 {
477 register struct breakpoint *b;
478
479 ALL_BREAKPOINTS (b)
480 if (b->enable != disabled && b->address == pc)
481 return 1;
482
483 return 0;
484 }
485 \f
486 /* bpstat stuff. External routines' interfaces are documented
487 in breakpoint.h. */
488 void
489 bpstat_clear (bsp)
490 bpstat *bsp;
491 {
492 bpstat p;
493 bpstat q;
494
495 if (bsp == 0)
496 return;
497 p = *bsp;
498 while (p != NULL)
499 {
500 q = p->next;
501 if (p->old_val != NULL)
502 value_free (p->old_val);
503 free (p);
504 p = q;
505 }
506 *bsp = NULL;
507 }
508
509 bpstat
510 bpstat_copy (bs)
511 bpstat bs;
512 {
513 bpstat p = NULL;
514 bpstat tmp;
515 bpstat retval;
516
517 if (bs == NULL)
518 return bs;
519
520 for (; bs != NULL; bs = bs->next)
521 {
522 tmp = (bpstat) xmalloc (sizeof (*tmp));
523 bcopy (bs, tmp, sizeof (*tmp));
524 if (p == NULL)
525 /* This is the first thing in the chain. */
526 retval = tmp;
527 else
528 p->next = tmp;
529 p = tmp;
530 }
531 p->next = NULL;
532 return retval;
533 }
534
535 int
536 bpstat_num (bsp)
537 bpstat *bsp;
538 {
539 struct breakpoint *b;
540
541 if ((*bsp) == NULL)
542 return 0; /* No more breakpoint values */
543 else
544 {
545 b = (*bsp)->breakpoint_at;
546 *bsp = (*bsp)->next;
547 if (b == NULL)
548 return -1; /* breakpoint that's been deleted since */
549 else
550 return b->number; /* We have its number */
551 }
552 }
553
554 void
555 bpstat_clear_actions (bs)
556 bpstat bs;
557 {
558 for (; bs != NULL; bs = bs->next)
559 {
560 bs->commands = NULL;
561 if (bs->old_val != NULL)
562 {
563 value_free (bs->old_val);
564 bs->old_val = NULL;
565 }
566 }
567 }
568
569 /* Execute all the commands associated with all the breakpoints at this
570 location. Any of these commands could cause the process to proceed
571 beyond this point, etc. We look out for such changes by checking
572 the global "breakpoint_proceeded" after each command. */
573 void
574 bpstat_do_actions (bsp)
575 bpstat *bsp;
576 {
577 bpstat bs;
578
579 top:
580 bs = *bsp;
581
582 executing_breakpoint_commands = 1;
583 breakpoint_proceeded = 0;
584 for (; bs != NULL; bs = bs->next)
585 {
586 while (bs->commands)
587 {
588 char *line = bs->commands->line;
589 bs->commands = bs->commands->next;
590 execute_command (line, 0);
591 /* If the inferior is proceeded by the command, bomb out now.
592 The bpstat chain has been blown away by wait_for_inferior.
593 But since execution has stopped again, there is a new bpstat
594 to look at, so start over. */
595 if (breakpoint_proceeded)
596 goto top;
597 }
598 }
599 clear_momentary_breakpoints ();
600
601 executing_breakpoint_commands = 0;
602 }
603
604 int
605 bpstat_print (bs)
606 bpstat bs;
607 {
608 /* bs->breakpoint_at can be NULL if it was a momentary breakpoint
609 which has since been deleted. */
610 if (bs == NULL || bs->breakpoint_at == NULL)
611 return 0;
612
613 /* If bpstat_stop_status says don't print, OK, we won't. An example
614 circumstance is when we single-stepped for both a watchpoint and
615 for a "stepi" instruction. The bpstat says that the watchpoint
616 explains the stop, but we shouldn't print because the watchpoint's
617 value didn't change -- and the real reason we are stopping here
618 rather than continuing to step (as the watchpoint would've had us do)
619 is because of the "stepi". */
620 if (!bs->print)
621 return 0;
622
623 if (bs->breakpoint_at->address != NULL)
624 {
625 /* I think the user probably only wants to see one breakpoint
626 number, not all of them. */
627 printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number);
628 return 0;
629 }
630
631 if (bs->old_val != NULL)
632 {
633 printf_filtered ("\nWatchpoint %d, ", bs->breakpoint_at->number);
634 print_expression (bs->breakpoint_at->exp, stdout);
635 printf_filtered ("\nOld value = ");
636 value_print (bs->old_val, stdout, 0, Val_pretty_default);
637 printf_filtered ("\nNew value = ");
638 value_print (bs->breakpoint_at->val, stdout, 0,
639 Val_pretty_default);
640 printf_filtered ("\n");
641 value_free (bs->old_val);
642 bs->old_val = NULL;
643 return 1;
644 }
645
646 fprintf_filtered (stderr, "gdb internal error: in bpstat_print\n");
647 return 0;
648 }
649
650 /* Evaluate the expression EXP and return 1 if value is zero.
651 This is used inside a catch_errors to evaluate the breakpoint condition.
652 The argument is a "struct expression *" that has been cast to int to
653 make it pass through catch_errors. */
654
655 static int
656 breakpoint_cond_eval (exp)
657 int exp;
658 {
659 return value_zerop (evaluate_expression ((struct expression *)exp));
660 }
661
662 /* Allocate a new bpstat and chain it to the current one. */
663
664 static bpstat
665 bpstat_alloc (b, cbs)
666 register struct breakpoint *b;
667 bpstat cbs; /* Current "bs" value */
668 {
669 bpstat bs;
670
671 bs = (bpstat) xmalloc (sizeof (*bs));
672 cbs->next = bs;
673 bs->breakpoint_at = b;
674 /* If the condition is false, etc., don't do the commands. */
675 bs->commands = NULL;
676 bs->momentary = b->number == -3;
677 bs->old_val = NULL;
678 return bs;
679 }
680
681 /* Determine whether we stopped at a breakpoint, etc, or whether we
682 don't understand this stop. Result is a chain of bpstat's such that:
683
684 if we don't understand the stop, the result is a null pointer.
685
686 if we understand why we stopped, the result is not null, and
687 the first element of the chain contains summary "stop" and
688 "print" flags for the whole chain.
689
690 Each element of the chain refers to a particular breakpoint or
691 watchpoint at which we have stopped. (We may have stopped for
692 several reasons.)
693
694 Each element of the chain has valid next, breakpoint_at,
695 commands, FIXME??? fields.
696
697 */
698
699
700 bpstat
701 bpstat_stop_status (pc, frame_address)
702 CORE_ADDR *pc;
703 FRAME_ADDR frame_address;
704 {
705 register struct breakpoint *b;
706 int stop = 0;
707 int print = 0;
708 CORE_ADDR bp_addr;
709 /* True if we've hit a breakpoint (as opposed to a watchpoint). */
710 int real_breakpoint = 0;
711 /* Root of the chain of bpstat's */
712 struct bpstat__struct root_bs[1];
713 /* Pointer to the last thing in the chain currently. */
714 bpstat bs = root_bs;
715
716 /* Get the address where the breakpoint would have been. */
717 bp_addr = *pc - DECR_PC_AFTER_BREAK;
718
719 ALL_BREAKPOINTS (b)
720 {
721 int this_bp_stop;
722 int this_bp_print;
723
724 if (b->enable == disabled)
725 continue;
726 if (b->address != NULL && b->address != bp_addr)
727 continue;
728
729 bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */
730
731 this_bp_stop = 1;
732 this_bp_print = 1;
733
734 if (b->exp != NULL) /* Watchpoint */
735 {
736 int within_current_scope;
737 if (b->exp_valid_block != NULL)
738 within_current_scope =
739 contained_in (get_selected_block (), b->exp_valid_block);
740 else
741 within_current_scope = 1;
742
743 if (within_current_scope)
744 {
745 value new_val = evaluate_expression (b->exp);
746 release_value (new_val);
747 if (!value_equal (b->val, new_val))
748 {
749 bs->old_val = b->val;
750 b->val = new_val;
751 /* We will stop here */
752 }
753 else
754 {
755 /* Nothing changed, don't do anything. */
756 value_free (new_val);
757 continue;
758 /* We won't stop here */
759 }
760 }
761 else
762 {
763 /* This seems like the only logical thing to do because
764 if we temporarily ignored the watchpoint, then when
765 we reenter the block in which it is valid it contains
766 garbage (in the case of a function, it may have two
767 garbage values, one before and one after the prologue).
768 So we can't even detect the first assignment to it and
769 watch after that (since the garbage may or may not equal
770 the first value assigned). */
771 b->enable = disabled;
772 printf_filtered ("\
773 Watchpoint %d disabled because the program has left the block in\n\
774 which its expression is valid.\n", b->number);
775 /* We won't stop here */
776 /* FIXME, maybe we should stop here!!! */
777 continue;
778 }
779 }
780 else
781 real_breakpoint = 1;
782
783 if (b->frame && b->frame != frame_address)
784 this_bp_stop = 0;
785 else
786 {
787 int value_zero;
788
789 if (b->cond)
790 {
791 /* Need to select the frame, with all that implies
792 so that the conditions will have the right context. */
793 select_frame (get_current_frame (), 0);
794 value_zero
795 = catch_errors (breakpoint_cond_eval, (int)(b->cond),
796 "Error occurred in testing breakpoint condition.");
797 free_all_values ();
798 }
799 if (b->cond && value_zero)
800 {
801 this_bp_stop = 0;
802 }
803 else if (b->ignore_count > 0)
804 {
805 b->ignore_count--;
806 this_bp_stop = 0;
807 }
808 else
809 {
810 /* We will stop here */
811 if (b->enable == temporary)
812 b->enable = disabled;
813 bs->commands = b->commands;
814 if (b->silent)
815 this_bp_print = 0;
816 if (bs->commands && !strcmp ("silent", bs->commands->line))
817 {
818 bs->commands = bs->commands->next;
819 this_bp_print = 0;
820 }
821 }
822 }
823 if (this_bp_stop)
824 stop = 1;
825 if (this_bp_print)
826 print = 1;
827 }
828
829 bs->next = NULL; /* Terminate the chain */
830 bs = root_bs->next; /* Re-grab the head of the chain */
831 if (bs)
832 {
833 bs->stop = stop;
834 bs->print = print;
835 #if DECR_PC_AFTER_BREAK != 0 || defined (SHIFT_INST_REGS)
836 if (real_breakpoint)
837 {
838 *pc = bp_addr;
839 #if defined (SHIFT_INST_REGS)
840 {
841 CORE_ADDR pc = read_register (PC_REGNUM);
842 CORE_ADDR npc = read_register (NPC_REGNUM);
843 if (pc != npc)
844 {
845 write_register (NNPC_REGNUM, npc);
846 write_register (NPC_REGNUM, pc);
847 }
848 }
849 #else /* No SHIFT_INST_REGS. */
850 write_pc (bp_addr);
851 #endif /* No SHIFT_INST_REGS. */
852 }
853 #endif /* DECR_PC_AFTER_BREAK != 0. */
854 }
855 return bs;
856 }
857
858 int
859 bpstat_should_step ()
860 {
861 struct breakpoint *b;
862 ALL_BREAKPOINTS (b)
863 if (b->enable != disabled && b->exp != NULL)
864 return 1;
865 return 0;
866 }
867 \f
868 /* Print information on breakpoint number BNUM, or -1 if all.
869 If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS
870 is nonzero, process only watchpoints. */
871
872 static void
873 breakpoint_1 (bnum, watchpoints)
874 int bnum;
875 int watchpoints;
876 {
877 register struct breakpoint *b;
878 register struct command_line *l;
879 register struct symbol *sym;
880 CORE_ADDR last_addr = (CORE_ADDR)-1;
881 int header_printed = 0;
882
883 ALL_BREAKPOINTS (b)
884 if (bnum == -1 || bnum == b->number)
885 {
886 if (b->address == NULL && !watchpoints)
887 {
888 if (bnum == -1)
889 continue;
890 error ("That is a watchpoint, not a breakpoint.");
891 }
892 if (b->address != NULL && watchpoints)
893 {
894 if (bnum == -1)
895 continue;
896 error ("That is a breakpoint, not a watchpoint.");
897 }
898
899 if (!header_printed)
900 {
901 if (watchpoints)
902 printf_filtered (" Enb Expression\n");
903 else if (addressprint)
904 printf_filtered (" Enb Address Where\n");
905 else
906 printf_filtered (" Enb Where\n");
907 header_printed = 1;
908 }
909
910 printf_filtered ("#%-3d %c ", b->number, "nyod"[(int) b->enable]);
911 if (b->address == NULL) {
912 printf_filtered (" ");
913 print_expression (b->exp, stdout);
914 } else {
915 if (addressprint)
916 printf_filtered (" 0x%08x ", b->address);
917
918 last_addr = b->address;
919 if (b->symtab)
920 {
921 sym = find_pc_function (b->address);
922 if (sym)
923 {
924 fputs_filtered (" in ", stdout);
925 fputs_demangled (SYMBOL_NAME (sym), stdout, 1);
926 fputs_filtered (" at ", stdout);
927 }
928 fputs_filtered (b->symtab->filename, stdout);
929 printf_filtered (":%d", b->line_number);
930 }
931 else
932 print_address_symbolic (b->address, stdout, demangle);
933 }
934
935 printf_filtered ("\n");
936
937 if (b->frame)
938 printf_filtered ("\tstop only in stack frame at 0x%x\n", b->frame);
939 if (b->cond)
940 {
941 printf_filtered ("\tstop only if ");
942 print_expression (b->cond, stdout);
943 printf_filtered ("\n");
944 }
945 if (b->ignore_count)
946 printf_filtered ("\tignore next %d hits\n", b->ignore_count);
947 if ((l = b->commands))
948 while (l)
949 {
950 fputs_filtered ("\t", stdout);
951 fputs_filtered (l->line, stdout);
952 fputs_filtered ("\n", stdout);
953 l = l->next;
954 }
955 }
956
957 if (!header_printed)
958 {
959 char *which = watchpoints ? "watch" : "break";
960 if (bnum == -1)
961 printf_filtered ("No %spoints.\n", which);
962 else
963 printf_filtered ("No %spoint numbered %d.\n", which, bnum);
964 }
965
966 /* Compare against (CORE_ADDR)-1 in case some compiler decides
967 that a comparison of an unsigned with -1 is always false. */
968 if (last_addr != (CORE_ADDR)-1)
969 set_next_address (last_addr);
970 }
971
972 static void
973 breakpoints_info (bnum_exp, from_tty)
974 char *bnum_exp;
975 int from_tty;
976 {
977 int bnum = -1;
978
979 if (bnum_exp)
980 bnum = parse_and_eval_address (bnum_exp);
981
982 breakpoint_1 (bnum, 0);
983 }
984
985 static void
986 watchpoints_info (bnum_exp, from_tty)
987 char *bnum_exp;
988 int from_tty;
989 {
990 int bnum = -1;
991
992 if (bnum_exp)
993 bnum = parse_and_eval_address (bnum_exp);
994
995 breakpoint_1 (bnum, 1);
996 }
997
998 /* Print a message describing any breakpoints set at PC. */
999
1000 static void
1001 describe_other_breakpoints (pc)
1002 register CORE_ADDR pc;
1003 {
1004 register int others = 0;
1005 register struct breakpoint *b;
1006
1007 ALL_BREAKPOINTS (b)
1008 if (b->address == pc)
1009 others++;
1010 if (others > 0)
1011 {
1012 printf ("Note: breakpoint%s ", (others > 1) ? "s" : "");
1013 ALL_BREAKPOINTS (b)
1014 if (b->address == pc)
1015 {
1016 others--;
1017 printf ("%d%s%s ",
1018 b->number,
1019 (b->enable == disabled) ? " (disabled)" : "",
1020 (others > 1) ? "," : ((others == 1) ? " and" : ""));
1021 }
1022 printf ("also set at pc 0x%x.\n", pc);
1023 }
1024 }
1025 \f
1026 /* Set the default place to put a breakpoint
1027 for the `break' command with no arguments. */
1028
1029 void
1030 set_default_breakpoint (valid, addr, symtab, line)
1031 int valid;
1032 CORE_ADDR addr;
1033 struct symtab *symtab;
1034 int line;
1035 {
1036 default_breakpoint_valid = valid;
1037 default_breakpoint_address = addr;
1038 default_breakpoint_symtab = symtab;
1039 default_breakpoint_line = line;
1040 }
1041
1042 /* Rescan breakpoints at address ADDRESS,
1043 marking the first one as "first" and any others as "duplicates".
1044 This is so that the bpt instruction is only inserted once. */
1045
1046 static void
1047 check_duplicates (address)
1048 CORE_ADDR address;
1049 {
1050 register struct breakpoint *b;
1051 register int count = 0;
1052
1053 if (address == NULL) /* Watchpoints are uninteresting */
1054 return;
1055
1056 ALL_BREAKPOINTS (b)
1057 if (b->enable != disabled && b->address == address)
1058 {
1059 count++;
1060 b->duplicate = count > 1;
1061 }
1062 }
1063
1064 /* Low level routine to set a breakpoint.
1065 Takes as args the three things that every breakpoint must have.
1066 Returns the breakpoint object so caller can set other things.
1067 Does not set the breakpoint number!
1068 Does not print anything.
1069
1070 ==> This routine should not be called if there is a chance of later
1071 error(); otherwise it leaves a bogus breakpoint on the chain. Validate
1072 your arguments BEFORE calling this routine! */
1073
1074 static struct breakpoint *
1075 set_raw_breakpoint (sal)
1076 struct symtab_and_line sal;
1077 {
1078 register struct breakpoint *b, *b1;
1079
1080 b = (struct breakpoint *) xmalloc (sizeof (struct breakpoint));
1081 bzero (b, sizeof *b);
1082 b->address = sal.pc;
1083 b->symtab = sal.symtab;
1084 b->line_number = sal.line;
1085 b->enable = enabled;
1086 b->next = 0;
1087 b->silent = 0;
1088 b->ignore_count = 0;
1089 b->commands = NULL;
1090 b->frame = NULL;
1091
1092 /* Add this breakpoint to the end of the chain
1093 so that a list of breakpoints will come out in order
1094 of increasing numbers. */
1095
1096 b1 = breakpoint_chain;
1097 if (b1 == 0)
1098 breakpoint_chain = b;
1099 else
1100 {
1101 while (b1->next)
1102 b1 = b1->next;
1103 b1->next = b;
1104 }
1105
1106 check_duplicates (sal.pc);
1107
1108 return b;
1109 }
1110
1111 /* Set a breakpoint that will evaporate an end of command
1112 at address specified by SAL.
1113 Restrict it to frame FRAME if FRAME is nonzero. */
1114
1115 void
1116 set_momentary_breakpoint (sal, frame)
1117 struct symtab_and_line sal;
1118 FRAME frame;
1119 {
1120 register struct breakpoint *b;
1121 b = set_raw_breakpoint (sal);
1122 b->number = -3;
1123 b->enable = delete;
1124 b->frame = (frame ? FRAME_FP (frame) : 0);
1125 }
1126
1127 void
1128 clear_momentary_breakpoints ()
1129 {
1130 register struct breakpoint *b;
1131 ALL_BREAKPOINTS (b)
1132 if (b->number == -3)
1133 {
1134 delete_breakpoint (b);
1135 break;
1136 }
1137 }
1138 \f
1139 /* Tell the user we have just set a breakpoint B. */
1140 static void
1141 mention (b)
1142 struct breakpoint *b;
1143 {
1144 if (b->exp)
1145 {
1146 printf_filtered ("Watchpoint %d: ", b->number);
1147 print_expression (b->exp, stdout);
1148 }
1149 else
1150 {
1151 printf_filtered ("Breakpoint %d at 0x%x", b->number, b->address);
1152 if (b->symtab)
1153 printf_filtered (": file %s, line %d.",
1154 b->symtab->filename, b->line_number);
1155 }
1156 printf_filtered ("\n");
1157 }
1158
1159 #if 0
1160 /* Nobody calls this currently. */
1161 /* Set a breakpoint from a symtab and line.
1162 If TEMPFLAG is nonzero, it is a temporary breakpoint.
1163 ADDR_STRING is a malloc'd string holding the name of where we are
1164 setting the breakpoint. This is used later to re-set it after the
1165 program is relinked and symbols are reloaded.
1166 Print the same confirmation messages that the breakpoint command prints. */
1167
1168 void
1169 set_breakpoint (s, line, tempflag, addr_string)
1170 struct symtab *s;
1171 int line;
1172 int tempflag;
1173 char *addr_string;
1174 {
1175 register struct breakpoint *b;
1176 struct symtab_and_line sal;
1177
1178 sal.symtab = s;
1179 sal.line = line;
1180 sal.pc = find_line_pc (sal.symtab, sal.line);
1181 if (sal.pc == 0)
1182 error ("No line %d in file \"%s\".\n", sal.line, sal.symtab->filename);
1183 else
1184 {
1185 describe_other_breakpoints (sal.pc);
1186
1187 b = set_raw_breakpoint (sal);
1188 set_breakpoint_count (breakpoint_count + 1);
1189 b->number = breakpoint_count;
1190 b->cond = 0;
1191 b->addr_string = addr_string;
1192 if (tempflag)
1193 b->enable = temporary;
1194
1195 mention (b);
1196 }
1197 }
1198 #endif
1199 \f
1200 /* Set a breakpoint according to ARG (function, linenum or *address)
1201 and make it temporary if TEMPFLAG is nonzero. */
1202
1203 static void
1204 break_command_1 (arg, tempflag, from_tty)
1205 char *arg;
1206 int tempflag, from_tty;
1207 {
1208 struct symtabs_and_lines sals;
1209 struct symtab_and_line sal;
1210 register struct expression *cond = 0;
1211 register struct breakpoint *b;
1212
1213 /* Pointers in arg to the start, and one past the end, of the condition. */
1214 char *cond_start = NULL;
1215 char *cond_end;
1216 /* Pointers in arg to the start, and one past the end,
1217 of the address part. */
1218 char *addr_start = NULL;
1219 char *addr_end;
1220
1221 int i;
1222 CORE_ADDR pc;
1223
1224 sals.sals = NULL;
1225 sals.nelts = 0;
1226
1227 sal.line = sal.pc = sal.end = 0;
1228 sal.symtab = 0;
1229
1230 /* If no arg given, or if first arg is 'if ', use the default breakpoint. */
1231
1232 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1233 && (arg[2] == ' ' || arg[2] == '\t')))
1234 {
1235 if (default_breakpoint_valid)
1236 {
1237 sals.sals = (struct symtab_and_line *)
1238 xmalloc (sizeof (struct symtab_and_line));
1239 sal.pc = default_breakpoint_address;
1240 sal.line = default_breakpoint_line;
1241 sal.symtab = default_breakpoint_symtab;
1242 sals.sals[0] = sal;
1243 sals.nelts = 1;
1244 }
1245 else
1246 error ("No default breakpoint address now.");
1247 }
1248 else
1249 {
1250 addr_start = arg;
1251
1252 /* Force almost all breakpoints to be in terms of the
1253 current_source_symtab (which is decode_line_1's default). This
1254 should produce the results we want almost all of the time while
1255 leaving default_breakpoint_* alone. */
1256 if (default_breakpoint_valid
1257 && (!current_source_symtab
1258 || (arg && (*arg == '+' || *arg == '-'))))
1259 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1260 default_breakpoint_line);
1261 else
1262 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1263
1264 addr_end = arg;
1265 }
1266
1267 if (! sals.nelts)
1268 return;
1269
1270 for (i = 0; i < sals.nelts; i++)
1271 {
1272 sal = sals.sals[i];
1273 if (sal.pc == 0 && sal.symtab != 0)
1274 {
1275 pc = find_line_pc (sal.symtab, sal.line);
1276 if (pc == 0)
1277 error ("No line %d in file \"%s\".",
1278 sal.line, sal.symtab->filename);
1279 }
1280 else
1281 pc = sal.pc;
1282
1283 while (arg && *arg)
1284 {
1285 if (arg[0] == 'i' && arg[1] == 'f'
1286 && (arg[2] == ' ' || arg[2] == '\t'))
1287 {
1288 arg += 2;
1289 cond_start = arg;
1290 cond = parse_c_1 (&arg, block_for_pc (pc), 0);
1291 cond_end = arg;
1292 }
1293 else
1294 error ("Junk at end of arguments.");
1295 }
1296 sals.sals[i].pc = pc;
1297 }
1298
1299 for (i = 0; i < sals.nelts; i++)
1300 {
1301 sal = sals.sals[i];
1302
1303 if (from_tty)
1304 describe_other_breakpoints (sal.pc);
1305
1306 b = set_raw_breakpoint (sal);
1307 set_breakpoint_count (breakpoint_count + 1);
1308 b->number = breakpoint_count;
1309 b->cond = cond;
1310
1311 if (addr_start)
1312 b->addr_string = savestring (addr_start, addr_end - addr_start);
1313 if (cond_start)
1314 b->cond_string = savestring (cond_start, cond_end - cond_start);
1315
1316 if (tempflag)
1317 b->enable = temporary;
1318
1319 mention (b);
1320 }
1321
1322 if (sals.nelts > 1)
1323 {
1324 printf ("Multiple breakpoints were set.\n");
1325 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1326 }
1327 free (sals.sals);
1328 }
1329
1330 void
1331 break_command (arg, from_tty)
1332 char *arg;
1333 int from_tty;
1334 {
1335 break_command_1 (arg, 0, from_tty);
1336 }
1337
1338 static void
1339 tbreak_command (arg, from_tty)
1340 char *arg;
1341 int from_tty;
1342 {
1343 break_command_1 (arg, 1, from_tty);
1344 }
1345
1346 static void
1347 watch_command (arg, from_tty)
1348 char *arg;
1349 int from_tty;
1350 {
1351 struct breakpoint *b;
1352 struct symtab_and_line sal;
1353 struct expression *exp;
1354 struct block *exp_valid_block;
1355 struct value *val;
1356
1357 sal.pc = NULL;
1358 sal.symtab = NULL;
1359 sal.line = 0;
1360
1361 /* Parse arguments. */
1362 innermost_block = NULL;
1363 exp = parse_c_expression (arg);
1364 exp_valid_block = innermost_block;
1365 val = evaluate_expression (exp);
1366 release_value (val);
1367
1368 /* Now set up the breakpoint. */
1369 b = set_raw_breakpoint (sal);
1370 set_breakpoint_count (breakpoint_count + 1);
1371 b->number = breakpoint_count;
1372 b->exp = exp;
1373 b->exp_valid_block = exp_valid_block;
1374 b->val = val;
1375 b->cond = 0;
1376 b->cond_string = NULL;
1377 mention (b);
1378 }
1379 \f
1380 /*
1381 * Helper routine for the until_command routine in infcmd.c. Here
1382 * because it uses the mechanisms of breakpoints.
1383 */
1384 void
1385 until_break_command (arg, from_tty)
1386 char *arg;
1387 int from_tty;
1388 {
1389 struct symtabs_and_lines sals;
1390 struct symtab_and_line sal;
1391 FRAME prev_frame = get_prev_frame (selected_frame);
1392
1393 clear_proceed_status ();
1394
1395 /* Set a breakpoint where the user wants it and at return from
1396 this function */
1397
1398 if (default_breakpoint_valid)
1399 sals = decode_line_1 (&arg, 1, default_breakpoint_symtab,
1400 default_breakpoint_line);
1401 else
1402 sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0);
1403
1404 if (sals.nelts != 1)
1405 error ("Couldn't get information on specified line.");
1406
1407 sal = sals.sals[0];
1408 free (sals.sals); /* malloc'd, so freed */
1409
1410 if (*arg)
1411 error ("Junk at end of arguments.");
1412
1413 if (sal.pc == 0 && sal.symtab != 0)
1414 sal.pc = find_line_pc (sal.symtab, sal.line);
1415
1416 if (sal.pc == 0)
1417 error ("No line %d in file \"%s\".", sal.line, sal.symtab->filename);
1418
1419 set_momentary_breakpoint (sal, selected_frame);
1420
1421 /* Keep within the current frame */
1422
1423 if (prev_frame)
1424 {
1425 struct frame_info *fi;
1426
1427 fi = get_frame_info (prev_frame);
1428 sal = find_pc_line (fi->pc, 0);
1429 sal.pc = fi->pc;
1430 set_momentary_breakpoint (sal, prev_frame);
1431 }
1432
1433 proceed (-1, -1, 0);
1434 }
1435 \f
1436 /* Set a breakpoint at the catch clause for NAME. */
1437 static int
1438 catch_breakpoint (name)
1439 char *name;
1440 {
1441 }
1442
1443 static int
1444 disable_catch_breakpoint ()
1445 {
1446 }
1447
1448 static int
1449 delete_catch_breakpoint ()
1450 {
1451 }
1452
1453 static int
1454 enable_catch_breakpoint ()
1455 {
1456 }
1457
1458 struct sal_chain
1459 {
1460 struct sal_chain *next;
1461 struct symtab_and_line sal;
1462 };
1463
1464 /* For each catch clause identified in ARGS, run FUNCTION
1465 with that clause as an argument. */
1466 static struct symtabs_and_lines
1467 map_catch_names (args, function)
1468 char *args;
1469 int (*function)();
1470 {
1471 register char *p = args;
1472 register char *p1;
1473 struct symtabs_and_lines sals;
1474 struct sal_chain *sal_chain = 0;
1475
1476 if (p == 0)
1477 error_no_arg ("one or more catch names");
1478
1479 sals.nelts = 0;
1480 sals.sals = NULL;
1481
1482 while (*p)
1483 {
1484 p1 = p;
1485 /* Don't swallow conditional part. */
1486 if (p1[0] == 'i' && p1[1] == 'f'
1487 && (p1[2] == ' ' || p1[2] == '\t'))
1488 break;
1489
1490 if (isalpha (*p1))
1491 {
1492 p1++;
1493 while (isalnum (*p1) || *p1 == '_' || *p1 == '$')
1494 p1++;
1495 }
1496
1497 if (*p1 && *p1 != ' ' && *p1 != '\t')
1498 error ("Arguments must be catch names.");
1499
1500 *p1 = 0;
1501 #if 0
1502 if (function (p))
1503 {
1504 struct sal_chain *next
1505 = (struct sal_chain *)alloca (sizeof (struct sal_chain));
1506 next->next = sal_chain;
1507 next->sal = get_catch_sal (p);
1508 sal_chain = next;
1509 goto win;
1510 }
1511 #endif
1512 printf ("No catch clause for exception %s.\n", p);
1513 win:
1514 p = p1;
1515 while (*p == ' ' || *p == '\t') p++;
1516 }
1517 }
1518
1519 /* This shares a lot of code with `print_frame_label_vars' from stack.c. */
1520
1521 static struct symtabs_and_lines
1522 get_catch_sals (this_level_only)
1523 int this_level_only;
1524 {
1525 extern struct blockvector *blockvector_for_pc ();
1526 register struct blockvector *bl;
1527 register struct block *block = get_frame_block (selected_frame);
1528 int index, have_default = 0;
1529 struct frame_info *fi = get_frame_info (selected_frame);
1530 CORE_ADDR pc = fi->pc;
1531 struct symtabs_and_lines sals;
1532 struct sal_chain *sal_chain = 0;
1533 char *blocks_searched;
1534
1535 sals.nelts = 0;
1536 sals.sals = NULL;
1537
1538 if (block == 0)
1539 error ("No symbol table info available.\n");
1540
1541 bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
1542 blocks_searched = (char *) alloca (BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1543 bzero (blocks_searched, BLOCKVECTOR_NBLOCKS (bl) * sizeof (char));
1544
1545 while (block != 0)
1546 {
1547 CORE_ADDR end = BLOCK_END (block) - 4;
1548 int last_index;
1549
1550 if (bl != blockvector_for_pc (end, &index))
1551 error ("blockvector blotch");
1552 if (BLOCKVECTOR_BLOCK (bl, index) != block)
1553 error ("blockvector botch");
1554 last_index = BLOCKVECTOR_NBLOCKS (bl);
1555 index += 1;
1556
1557 /* Don't print out blocks that have gone by. */
1558 while (index < last_index
1559 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < pc)
1560 index++;
1561
1562 while (index < last_index
1563 && BLOCK_END (BLOCKVECTOR_BLOCK (bl, index)) < end)
1564 {
1565 if (blocks_searched[index] == 0)
1566 {
1567 struct block *b = BLOCKVECTOR_BLOCK (bl, index);
1568 int nsyms;
1569 register int i;
1570 register struct symbol *sym;
1571
1572 nsyms = BLOCK_NSYMS (b);
1573
1574 for (i = 0; i < nsyms; i++)
1575 {
1576 sym = BLOCK_SYM (b, i);
1577 if (! strcmp (SYMBOL_NAME (sym), "default"))
1578 {
1579 if (have_default)
1580 continue;
1581 have_default = 1;
1582 }
1583 if (SYMBOL_CLASS (sym) == LOC_LABEL)
1584 {
1585 struct sal_chain *next = (struct sal_chain *)
1586 alloca (sizeof (struct sal_chain));
1587 next->next = sal_chain;
1588 next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
1589 sal_chain = next;
1590 }
1591 }
1592 blocks_searched[index] = 1;
1593 }
1594 index++;
1595 }
1596 if (have_default)
1597 break;
1598 if (sal_chain && this_level_only)
1599 break;
1600
1601 /* After handling the function's top-level block, stop.
1602 Don't continue to its superblock, the block of
1603 per-file symbols. */
1604 if (BLOCK_FUNCTION (block))
1605 break;
1606 block = BLOCK_SUPERBLOCK (block);
1607 }
1608
1609 if (sal_chain)
1610 {
1611 struct sal_chain *tmp_chain;
1612
1613 /* Count the number of entries. */
1614 for (index = 0, tmp_chain = sal_chain; tmp_chain;
1615 tmp_chain = tmp_chain->next)
1616 index++;
1617
1618 sals.nelts = index;
1619 sals.sals = (struct symtab_and_line *)
1620 xmalloc (index * sizeof (struct symtab_and_line));
1621 for (index = 0; sal_chain; sal_chain = sal_chain->next, index++)
1622 sals.sals[index] = sal_chain->sal;
1623 }
1624
1625 return sals;
1626 }
1627
1628 /* Commands to deal with catching exceptions. */
1629
1630 void
1631 catch_command_1 (arg, tempflag, from_tty)
1632 char *arg;
1633 int tempflag;
1634 int from_tty;
1635 {
1636 /* First, translate ARG into something we can deal with in terms
1637 of breakpoints. */
1638
1639 struct symtabs_and_lines sals;
1640 struct symtab_and_line sal;
1641 register struct expression *cond = 0;
1642 register struct breakpoint *b;
1643 char *save_arg;
1644 int i;
1645 CORE_ADDR pc;
1646
1647 sal.line = sal.pc = sal.end = 0;
1648 sal.symtab = 0;
1649
1650 /* If no arg given, or if first arg is 'if ', all active catch clauses
1651 are breakpointed. */
1652
1653 if (!arg || (arg[0] == 'i' && arg[1] == 'f'
1654 && (arg[2] == ' ' || arg[2] == '\t')))
1655 {
1656 /* Grab all active catch clauses. */
1657 sals = get_catch_sals (0);
1658 }
1659 else
1660 {
1661 /* Grab selected catch clauses. */
1662 error ("catch NAME not implemeneted");
1663 sals = map_catch_names (arg, catch_breakpoint);
1664 }
1665
1666 if (! sals.nelts)
1667 return;
1668
1669 save_arg = arg;
1670 for (i = 0; i < sals.nelts; i++)
1671 {
1672 sal = sals.sals[i];
1673 if (sal.pc == 0 && sal.symtab != 0)
1674 {
1675 pc = find_line_pc (sal.symtab, sal.line);
1676 if (pc == 0)
1677 error ("No line %d in file \"%s\".",
1678 sal.line, sal.symtab->filename);
1679 }
1680 else
1681 pc = sal.pc;
1682
1683 while (arg && *arg)
1684 {
1685 if (arg[0] == 'i' && arg[1] == 'f'
1686 && (arg[2] == ' ' || arg[2] == '\t'))
1687 cond = (struct expression *) parse_c_1 ((arg += 2, &arg),
1688 block_for_pc (pc), 0);
1689 else
1690 error ("Junk at end of arguments.");
1691 }
1692 arg = save_arg;
1693 sals.sals[i].pc = pc;
1694 }
1695
1696 for (i = 0; i < sals.nelts; i++)
1697 {
1698 sal = sals.sals[i];
1699
1700 if (from_tty)
1701 describe_other_breakpoints (sal.pc);
1702
1703 b = set_raw_breakpoint (sal);
1704 b->number = ++breakpoint_count;
1705 b->cond = cond;
1706 if (tempflag)
1707 b->enable = temporary;
1708
1709 printf ("Breakpoint %d at 0x%x", b->number, b->address);
1710 if (b->symtab)
1711 printf (": file %s, line %d.", b->symtab->filename, b->line_number);
1712 printf ("\n");
1713 }
1714
1715 if (sals.nelts > 1)
1716 {
1717 printf ("Multiple breakpoints were set.\n");
1718 printf ("Use the \"delete\" command to delete unwanted breakpoints.\n");
1719 }
1720 free (sals.sals);
1721 }
1722
1723 /* Disable breakpoints on all catch clauses described in ARGS. */
1724 static void
1725 disable_catch (args)
1726 char *args;
1727 {
1728 /* Map the disable command to catch clauses described in ARGS. */
1729 }
1730
1731 /* Enable breakpoints on all catch clauses described in ARGS. */
1732 static void
1733 enable_catch (args)
1734 char *args;
1735 {
1736 /* Map the disable command to catch clauses described in ARGS. */
1737 }
1738
1739 /* Delete breakpoints on all catch clauses in the active scope. */
1740 static void
1741 delete_catch (args)
1742 char *args;
1743 {
1744 /* Map the delete command to catch clauses described in ARGS. */
1745 }
1746
1747 static void
1748 catch_command (arg, from_tty)
1749 char *arg;
1750 int from_tty;
1751 {
1752 catch_command_1 (arg, 0, from_tty);
1753 }
1754 \f
1755 static void
1756 clear_command (arg, from_tty)
1757 char *arg;
1758 int from_tty;
1759 {
1760 register struct breakpoint *b, *b1;
1761 struct symtabs_and_lines sals;
1762 struct symtab_and_line sal;
1763 register struct breakpoint *found;
1764 int i;
1765
1766 if (arg)
1767 {
1768 sals = decode_line_spec (arg, 1);
1769 }
1770 else
1771 {
1772 sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line));
1773 sal.line = default_breakpoint_line;
1774 sal.symtab = default_breakpoint_symtab;
1775 sal.pc = 0;
1776 if (sal.symtab == 0)
1777 error ("No source file specified.");
1778
1779 sals.sals[0] = sal;
1780 sals.nelts = 1;
1781 }
1782
1783 for (i = 0; i < sals.nelts; i++)
1784 {
1785 /* If exact pc given, clear bpts at that pc.
1786 But if sal.pc is zero, clear all bpts on specified line. */
1787 sal = sals.sals[i];
1788 found = (struct breakpoint *) 0;
1789 while (breakpoint_chain
1790 && (sal.pc ? breakpoint_chain->address == sal.pc
1791 : (breakpoint_chain->symtab == sal.symtab
1792 && breakpoint_chain->line_number == sal.line)))
1793 {
1794 b1 = breakpoint_chain;
1795 breakpoint_chain = b1->next;
1796 b1->next = found;
1797 found = b1;
1798 }
1799
1800 ALL_BREAKPOINTS (b)
1801 while (b->next
1802 && b->next->address != NULL
1803 && (sal.pc ? b->next->address == sal.pc
1804 : (b->next->symtab == sal.symtab
1805 && b->next->line_number == sal.line)))
1806 {
1807 b1 = b->next;
1808 b->next = b1->next;
1809 b1->next = found;
1810 found = b1;
1811 }
1812
1813 if (found == 0)
1814 {
1815 if (arg)
1816 error ("No breakpoint at %s.", arg);
1817 else
1818 error ("No breakpoint at this line.");
1819 }
1820
1821 if (found->next) from_tty = 1; /* Always report if deleted more than one */
1822 if (from_tty) printf ("Deleted breakpoint%s ", found->next ? "s" : "");
1823 while (found)
1824 {
1825 if (from_tty) printf ("%d ", found->number);
1826 b1 = found->next;
1827 delete_breakpoint (found);
1828 found = b1;
1829 }
1830 if (from_tty) putchar ('\n');
1831 }
1832 free (sals.sals);
1833 }
1834 \f
1835 /* Delete breakpoint in BS if they are `delete' breakpoints.
1836 This is called after any breakpoint is hit, or after errors. */
1837
1838 void
1839 breakpoint_auto_delete (bs)
1840 bpstat bs;
1841 {
1842 for (; bs; bs = bs->next)
1843 if (bs->breakpoint_at && bs->breakpoint_at->enable == delete)
1844 delete_breakpoint (bs->breakpoint_at);
1845 }
1846
1847 /* Delete a breakpoint and clean up all traces of it in the data structures. */
1848
1849 static void
1850 delete_breakpoint (bpt)
1851 struct breakpoint *bpt;
1852 {
1853 register struct breakpoint *b;
1854 register bpstat bs;
1855
1856 if (bpt->inserted)
1857 target_remove_breakpoint(bpt->address, bpt->shadow_contents);
1858
1859 if (breakpoint_chain == bpt)
1860 breakpoint_chain = bpt->next;
1861
1862 ALL_BREAKPOINTS (b)
1863 if (b->next == bpt)
1864 {
1865 b->next = bpt->next;
1866 break;
1867 }
1868
1869 check_duplicates (bpt->address);
1870
1871 free_command_lines (&bpt->commands);
1872 if (bpt->cond)
1873 free (bpt->cond);
1874 if (bpt->cond_string != NULL)
1875 free (bpt->cond_string);
1876 if (bpt->addr_string != NULL)
1877 free (bpt->addr_string);
1878
1879 if (xgdb_verbose && bpt->number >=0)
1880 printf ("breakpoint #%d deleted\n", bpt->number);
1881
1882 /* Be sure no bpstat's are pointing at it after it's been freed. */
1883 /* FIXME, how can we find all bpstat's? We just check stop_bpstat for now. */
1884 for (bs = stop_bpstat; bs; bs = bs->next)
1885 if (bs->breakpoint_at == bpt)
1886 bs->breakpoint_at = NULL;
1887 free (bpt);
1888 }
1889
1890 static void map_breakpoint_numbers ();
1891
1892 static void
1893 delete_command (arg, from_tty)
1894 char *arg;
1895 int from_tty;
1896 {
1897
1898 if (arg == 0)
1899 {
1900 /* Ask user only if there are some breakpoints to delete. */
1901 if (!from_tty
1902 || (breakpoint_chain && query ("Delete all breakpoints? ", 0, 0)))
1903 {
1904 /* No arg; clear all breakpoints. */
1905 while (breakpoint_chain)
1906 delete_breakpoint (breakpoint_chain);
1907 }
1908 }
1909 else
1910 map_breakpoint_numbers (arg, delete_breakpoint);
1911 }
1912
1913 static void
1914 breakpoint_re_set_one (bint)
1915 int bint;
1916 {
1917 struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */
1918 int i;
1919 struct symtabs_and_lines sals;
1920 struct symtab_and_line sal;
1921 char *s;
1922
1923 if (b->address != NULL && b->addr_string != NULL)
1924 {
1925 s = b->addr_string;
1926 sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0);
1927 for (i = 0; i < sals.nelts; i++)
1928 {
1929 sal = sals.sals[i];
1930
1931 b->symtab = sal.symtab;
1932 b->line_number = sal.line;
1933 if (sal.pc == 0 && sal.symtab != 0)
1934 {
1935 sal.pc = find_line_pc (sal.symtab, sal.line);
1936 if (sal.pc == 0)
1937 error ("No line %d in file \"%s\".",
1938 sal.line, sal.symtab->filename);
1939 }
1940 b->address = sal.pc;
1941
1942 if (b->cond_string != NULL)
1943 {
1944 s = b->cond_string;
1945 b->cond = parse_c_1 (&s, block_for_pc (sal.pc), 0);
1946 }
1947
1948 check_duplicates (b->address);
1949
1950 mention (b);
1951 }
1952 free (sals.sals);
1953 }
1954 else
1955 {
1956 /* Anything without a string can't be re-set. */
1957 delete_breakpoint (b);
1958 }
1959 }
1960
1961 /* Re-set all breakpoints after symbols have been re-loaded. */
1962 void
1963 breakpoint_re_set ()
1964 {
1965 struct breakpoint *b;
1966
1967 ALL_BREAKPOINTS (b)
1968 {
1969 b->symtab = 0; /* Be sure we don't point to old dead symtab */
1970 (void) catch_errors (breakpoint_re_set_one, (int) b,
1971 "Error in re-setting breakpoint");
1972 }
1973
1974 /* Blank line to finish off all those mention() messages we just printed. */
1975 printf_filtered ("\n");
1976 }
1977 \f
1978 /* Set ignore-count of breakpoint number BPTNUM to COUNT.
1979 If from_tty is nonzero, it prints a message to that effect,
1980 which ends with a period (no newline). */
1981
1982 void
1983 set_ignore_count (bptnum, count, from_tty)
1984 int bptnum, count, from_tty;
1985 {
1986 register struct breakpoint *b;
1987
1988 if (count < 0)
1989 count = 0;
1990
1991 ALL_BREAKPOINTS (b)
1992 if (b->number == bptnum)
1993 {
1994 b->ignore_count = count;
1995 if (!from_tty)
1996 return;
1997 else if (count == 0)
1998 printf ("Will stop next time breakpoint %d is reached.", bptnum);
1999 else if (count == 1)
2000 printf ("Will ignore next crossing of breakpoint %d.", bptnum);
2001 else
2002 printf ("Will ignore next %d crossings of breakpoint %d.",
2003 count, bptnum);
2004 return;
2005 }
2006
2007 error ("No breakpoint number %d.", bptnum);
2008 }
2009
2010 /* Clear the ignore counts of all breakpoints. */
2011 void
2012 breakpoint_clear_ignore_counts ()
2013 {
2014 struct breakpoint *b;
2015
2016 ALL_BREAKPOINTS (b)
2017 b->ignore_count = 0;
2018 }
2019
2020 /* Command to set ignore-count of breakpoint N to COUNT. */
2021
2022 static void
2023 ignore_command (args, from_tty)
2024 char *args;
2025 int from_tty;
2026 {
2027 char *p = args;
2028 register int num;
2029
2030 if (p == 0)
2031 error_no_arg ("a breakpoint number");
2032
2033 num = get_number (&p);
2034
2035 if (*p == 0)
2036 error ("Second argument (specified ignore-count) is missing.");
2037
2038 set_ignore_count (num, parse_and_eval_address (p), from_tty);
2039 printf ("\n");
2040 }
2041 \f
2042 /* Call FUNCTION on each of the breakpoints
2043 whose numbers are given in ARGS. */
2044
2045 static void
2046 map_breakpoint_numbers (args, function)
2047 char *args;
2048 void (*function) ();
2049 {
2050 register char *p = args;
2051 char *p1;
2052 register int num;
2053 register struct breakpoint *b;
2054
2055 if (p == 0)
2056 error_no_arg ("one or more breakpoint numbers");
2057
2058 while (*p)
2059 {
2060 p1 = p;
2061
2062 num = get_number (&p1);
2063
2064 ALL_BREAKPOINTS (b)
2065 if (b->number == num)
2066 {
2067 function (b);
2068 goto win;
2069 }
2070 printf ("No breakpoint number %d.\n", num);
2071 win:
2072 p = p1;
2073 }
2074 }
2075
2076 static void
2077 enable_breakpoint (bpt)
2078 struct breakpoint *bpt;
2079 {
2080 bpt->enable = enabled;
2081
2082 if (xgdb_verbose && bpt->number >= 0)
2083 printf ("breakpoint #%d enabled\n", bpt->number);
2084
2085 check_duplicates (bpt->address);
2086 if (bpt->val != NULL)
2087 {
2088 if (bpt->exp_valid_block != NULL
2089 && !contained_in (get_selected_block (), bpt->exp_valid_block))
2090 {
2091 printf_filtered ("\
2092 Cannot enable watchpoint %d because the block in which its expression\n\
2093 is valid is not currently in scope.\n", bpt->number);
2094 return;
2095 }
2096
2097 value_free (bpt->val);
2098
2099 bpt->val = evaluate_expression (bpt->exp);
2100 release_value (bpt->val);
2101 }
2102 }
2103
2104 static void
2105 enable_command (args, from_tty)
2106 char *args;
2107 int from_tty;
2108 {
2109 struct breakpoint *bpt;
2110 if (args == 0)
2111 ALL_BREAKPOINTS (bpt)
2112 enable_breakpoint (bpt);
2113 else
2114 map_breakpoint_numbers (args, enable_breakpoint);
2115 }
2116
2117 static void
2118 disable_breakpoint (bpt)
2119 struct breakpoint *bpt;
2120 {
2121 bpt->enable = disabled;
2122
2123 if (xgdb_verbose && bpt->number >= 0)
2124 printf ("breakpoint #%d disabled\n", bpt->number);
2125
2126 check_duplicates (bpt->address);
2127 }
2128
2129 static void
2130 disable_command (args, from_tty)
2131 char *args;
2132 int from_tty;
2133 {
2134 register struct breakpoint *bpt;
2135 if (args == 0)
2136 ALL_BREAKPOINTS (bpt)
2137 disable_breakpoint (bpt);
2138 else
2139 map_breakpoint_numbers (args, disable_breakpoint);
2140 }
2141
2142 static void
2143 enable_once_breakpoint (bpt)
2144 struct breakpoint *bpt;
2145 {
2146 bpt->enable = temporary;
2147
2148 check_duplicates (bpt->address);
2149 }
2150
2151 static void
2152 enable_once_command (args, from_tty)
2153 char *args;
2154 int from_tty;
2155 {
2156 map_breakpoint_numbers (args, enable_once_breakpoint);
2157 }
2158
2159 static void
2160 enable_delete_breakpoint (bpt)
2161 struct breakpoint *bpt;
2162 {
2163 bpt->enable = delete;
2164
2165 check_duplicates (bpt->address);
2166 }
2167
2168 static void
2169 enable_delete_command (args, from_tty)
2170 char *args;
2171 int from_tty;
2172 {
2173 map_breakpoint_numbers (args, enable_delete_breakpoint);
2174 }
2175 \f
2176 /*
2177 * Use default_breakpoint_'s, or nothing if they aren't valid.
2178 */
2179 struct symtabs_and_lines
2180 decode_line_spec_1 (string, funfirstline)
2181 char *string;
2182 int funfirstline;
2183 {
2184 struct symtabs_and_lines sals;
2185 if (string == 0)
2186 error ("Empty line specification.");
2187 if (default_breakpoint_valid)
2188 sals = decode_line_1 (&string, funfirstline,
2189 default_breakpoint_symtab, default_breakpoint_line);
2190 else
2191 sals = decode_line_1 (&string, funfirstline, (struct symtab *)NULL, 0);
2192 if (*string)
2193 error ("Junk at end of line specification: %s", string);
2194 return sals;
2195 }
2196 \f
2197
2198 /* Chain containing all defined enable commands. */
2199
2200 extern struct cmd_list_element
2201 *enablelist, *disablelist,
2202 *deletelist, *enablebreaklist;
2203
2204 extern struct cmd_list_element *cmdlist;
2205
2206 void
2207 _initialize_breakpoint ()
2208 {
2209 breakpoint_chain = 0;
2210 /* Don't bother to call set_breakpoint_count. $bpnum isn't useful
2211 before a breakpoint is set. */
2212 breakpoint_count = 0;
2213
2214 add_com ("ignore", class_breakpoint, ignore_command,
2215 "Set ignore-count of breakpoint number N to COUNT.");
2216
2217 add_com ("commands", class_breakpoint, commands_command,
2218 "Set commands to be executed when a breakpoint is hit.\n\
2219 Give breakpoint number as argument after \"commands\".\n\
2220 With no argument, the targeted breakpoint is the last one set.\n\
2221 The commands themselves follow starting on the next line.\n\
2222 Type a line containing \"end\" to indicate the end of them.\n\
2223 Give \"silent\" as the first line to make the breakpoint silent;\n\
2224 then no output is printed when it is hit, except what the commands print.");
2225
2226 add_com ("condition", class_breakpoint, condition_command,
2227 "Specify breakpoint number N to break only if COND is true.\n\
2228 N is an integer; COND is a C expression to be evaluated whenever\n\
2229 breakpoint N is reached. Actually break only when COND is nonzero.");
2230
2231 add_com ("tbreak", class_breakpoint, tbreak_command,
2232 "Set a temporary breakpoint. Args like \"break\" command.\n\
2233 Like \"break\" except the breakpoint is only enabled temporarily,\n\
2234 so it will be disabled when hit. Equivalent to \"break\" followed\n\
2235 by using \"enable once\" on the breakpoint number.");
2236
2237 add_prefix_cmd ("enable", class_breakpoint, enable_command,
2238 "Enable some breakpoints.\n\
2239 Give breakpoint numbers (separated by spaces) as arguments.\n\
2240 With no subcommand, breakpoints are enabled until you command otherwise.\n\
2241 This is used to cancel the effect of the \"disable\" command.\n\
2242 With a subcommand you can enable temporarily.",
2243 &enablelist, "enable ", 1, &cmdlist);
2244
2245 add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command,
2246 "Enable some breakpoints.\n\
2247 Give breakpoint numbers (separated by spaces) as arguments.\n\
2248 This is used to cancel the effect of the \"disable\" command.\n\
2249 May be abbreviated to simply \"enable\".\n",
2250 &enablebreaklist, "enable breakpoints ", 1, &enablelist);
2251
2252 add_cmd ("once", no_class, enable_once_command,
2253 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2254 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2255 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2256 &enablebreaklist);
2257
2258 add_cmd ("delete", no_class, enable_delete_command,
2259 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2260 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2261 &enablebreaklist);
2262
2263 add_cmd ("delete", no_class, enable_delete_command,
2264 "Enable breakpoints and delete when hit. Give breakpoint numbers.\n\
2265 If a breakpoint is hit while enabled in this fashion, it is deleted.",
2266 &enablelist);
2267
2268 add_cmd ("once", no_class, enable_once_command,
2269 "Enable breakpoints for one hit. Give breakpoint numbers.\n\
2270 If a breakpoint is hit while enabled in this fashion, it becomes disabled.\n\
2271 See the \"tbreak\" command which sets a breakpoint and enables it once.",
2272 &enablelist);
2273
2274 add_prefix_cmd ("disable", class_breakpoint, disable_command,
2275 "Disable some breakpoints.\n\
2276 Arguments are breakpoint numbers with spaces in between.\n\
2277 To disable all breakpoints, give no argument.\n\
2278 A disabled breakpoint is not forgotten, but has no effect until reenabled.",
2279 &disablelist, "disable ", 1, &cmdlist);
2280 add_com_alias ("dis", "disable", class_breakpoint, 1);
2281 add_com_alias ("disa", "disable", class_breakpoint, 1);
2282
2283 add_cmd ("breakpoints", class_alias, disable_command,
2284 "Disable some breakpoints.\n\
2285 Arguments are breakpoint numbers with spaces in between.\n\
2286 To disable all breakpoints, give no argument.\n\
2287 A disabled breakpoint is not forgotten, but has no effect until reenabled.\n\
2288 This command may be abbreviated \"disable\".",
2289 &disablelist);
2290
2291 add_prefix_cmd ("delete", class_breakpoint, delete_command,
2292 "Delete some breakpoints or auto-display expressions.\n\
2293 Arguments are breakpoint numbers with spaces in between.\n\
2294 To delete all breakpoints, give no argument.\n\
2295 \n\
2296 Also a prefix command for deletion of other GDB objects.\n\
2297 The \"unset\" command is also an alias for \"delete\".",
2298 &deletelist, "delete ", 1, &cmdlist);
2299 add_com_alias ("d", "delete", class_breakpoint, 1);
2300
2301 add_cmd ("breakpoints", class_alias, delete_command,
2302 "Delete some breakpoints or auto-display expressions.\n\
2303 Arguments are breakpoint numbers with spaces in between.\n\
2304 To delete all breakpoints, give no argument.\n\
2305 This command may be abbreviated \"delete\".",
2306 &deletelist);
2307
2308 add_com ("clear", class_breakpoint, clear_command,
2309 "Clear breakpoint at specified line or function.\n\
2310 Argument may be line number, function name, or \"*\" and an address.\n\
2311 If line number is specified, all breakpoints in that line are cleared.\n\
2312 If function is specified, breakpoints at beginning of function are cleared.\n\
2313 If an address is specified, breakpoints at that address are cleared.\n\n\
2314 With no argument, clears all breakpoints in the line that the selected frame\n\
2315 is executing in.\n\
2316 \n\
2317 See also the \"delete\" command which clears breakpoints by number.");
2318
2319 add_com ("break", class_breakpoint, break_command,
2320 "Set breakpoint at specified line or function.\n\
2321 Argument may be line number, function name, or \"*\" and an address.\n\
2322 If line number is specified, break at start of code for that line.\n\
2323 If function is specified, break at start of code for that function.\n\
2324 If an address is specified, break at that exact address.\n\
2325 With no arg, uses current execution address of selected stack frame.\n\
2326 This is useful for breaking on return to a stack frame.\n\
2327 \n\
2328 Multiple breakpoints at one place are permitted, and useful if conditional.\n\
2329 \n\
2330 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2331 add_com_alias ("b", "break", class_run, 1);
2332 add_com_alias ("br", "break", class_run, 1);
2333 add_com_alias ("bre", "break", class_run, 1);
2334 add_com_alias ("brea", "break", class_run, 1);
2335
2336 add_info ("breakpoints", breakpoints_info,
2337 "Status of all breakpoints, or breakpoint number NUMBER.\n\
2338 Second column is \"y\" for enabled breakpoint, \"n\" for disabled,\n\
2339 \"o\" for enabled once (disable when hit), \"d\" for enable but delete when hit.\n\
2340 Then come the address and the file/line number.\n\n\
2341 Convenience variable \"$_\" and default examine address for \"x\"\n\
2342 are set to the address of the last breakpoint listed.\n\n\
2343 Convenience variable \"$bpnum\" contains the number of the last\n\
2344 breakpoint set.");
2345
2346 add_com ("catch", class_breakpoint, catch_command,
2347 "Set breakpoints to catch exceptions that are raised.\n\
2348 Argument may be a single exception to catch, multiple exceptions\n\
2349 to catch, or the default exception \"default\". If no arguments\n\
2350 are given, breakpoints are set at all exception handlers catch clauses\n\
2351 within the current scope.\n\
2352 \n\
2353 A condition specified for the catch applies to all breakpoints set\n\
2354 with this command\n\
2355 \n\
2356 Do \"help breakpoints\" for info on other commands dealing with breakpoints.");
2357
2358 add_com ("watch", class_breakpoint, watch_command,
2359 "Set a watchpoint for an expression.\n\
2360 A watchpoint stops execution of your program whenever the value of\n\
2361 an expression changes.");
2362
2363 add_info ("watchpoints", watchpoints_info,
2364 "Status of all watchpoints, or watchpoint number NUMBER.\n\
2365 Second column is \"y\" for enabled watchpoints, \"n\" for disabled.");
2366 }
This page took 0.12696 seconds and 5 git commands to generate.