Debian Codegraph @

libdebugger/command/break.c

raw symbols SCIP
1 /*
2 Copyright (C) 2004-2005, 2007-2009, 2011, 2020 R. Bernstein
3 <[email protected]>
4 This file is part of GNU Make (remake variant).
5
6 GNU Make 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 2, or (at your option)
9 any later version.
10
11 GNU Make 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 GNU Make; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /** \file libdebugger/command/break.c
22 *
23 * \brief Debugger `break` command.
24 *
25 * Debugger command to set a breakpoint.
26 * With a target name, set a break before running commands of that target.
27 * Without an argument, list all breaks.
28 */
29
30 #include "../../src/makeint.h"
31 #include "../../src/debug.h"
32 #include "../../src/expand.h"
33 #include "../../src/filedef.h"
34 #include "../../src/trace.h"
35
36 #include "../break.h"
37 #include "../cmd.h"
38 #include "../file2line.h"
39 #include "../fns.h"
40 #include "../msg.h"
41 #include "../stack.h"
42
43 extern debug_return_t
44 dbg_cmd_break (char *psz_args)
45 {
46 if (!psz_args || !*psz_args) {
47 list_breakpoints();
48 return debug_readloop;
49 } else {
50 char *psz_target = get_word(&psz_args);
51 char *psz_break_type;
52 file_t *p_target;
53 unsigned int i_brkpt_mask = BRK_NONE;
54
55 /** FIXME: DRY with code in continue.h **/
56 if (p_stack && p_stack->p_target) {
57 unsigned int u_lineno=0;
58 f2l_entry_t entry_type;
59 if (get_uint(psz_target, &u_lineno, false)) {
60 p_target = target_for_file_and_line(p_stack->p_target->floc.filenm,
61 u_lineno, &entry_type);
62 if (F2L_TARGET == entry_type) {
63 if (!p_target) {
64 dbg_errmsg("Can't find target or pattern on line %s.\n"
65 "Use 'info lines' to get a list of breakpoint lines.",
66 psz_target);
67 return debug_cmd_error;
68 }
69 } else {
70 dbg_errmsg("No support of breakpoints on target patterns yet.");
71 return debug_cmd_error;
72 }
73 } else
74 p_target =
75 lookup_file(variable_expand_set(psz_target,
76 p_stack->p_target->variables));
77 } else {
78 p_target = lookup_file(psz_target);
79 }
80
81 if (!p_target) {
82 dbg_errmsg("Can't find target %s; breakpoint not set.", psz_target);
83 return debug_cmd_error;
84 }
85
86 /* FIXME: Combine with code in continue. */
87 if (!(psz_args && *psz_args))
88 i_brkpt_mask = BRK_ALL;
89 else {
90 while ((psz_break_type = get_word(&psz_args))) {
91 if (!(psz_break_type && *psz_break_type)) break;
92 i_brkpt_mask |= get_brkpt_option(psz_break_type) ;
93 }
94 }
95 add_breakpoint(p_target, i_brkpt_mask);
96 }
97
98 return debug_readloop;
99 };
100
101 /*
102 * Local variables:
103 * eval: (c-set-style "gnu")
104 * indent-tabs-mode: nil
105 * End:
106 */