remake  4.3+dbg-1.5
command/break.h
Go to the documentation of this file.
1 /*
2 Set a breakpoint at a target. With a target name, set a break before
3 running commands of that target. Without argument, list all breaks.
4 */
5 /*
6 Copyright (C) 2004-2005, 2007-2009, 2011, 2020 R. Bernstein
7 <rocky@gnu.org>
8 This file is part of GNU Make (remake variant).
9 
10 GNU Make is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14 
15 GNU Make is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with GNU Make; see the file COPYING. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24 
25 static debug_return_t
26 dbg_cmd_break (char *psz_args)
27 {
28  if (!psz_args || !*psz_args) {
30  return debug_readloop;
31  } else {
32  char *psz_target = get_word(&psz_args);
33  char *psz_break_type;
34  file_t *p_target;
35  unsigned int i_brkpt_mask = BRK_NONE;
36 
38  if (p_stack && p_stack->p_target) {
39  unsigned int u_lineno=0;
40  f2l_entry_t entry_type;
41  if (get_uint(psz_target, &u_lineno, false)) {
43  u_lineno, &entry_type);
44  if (F2L_TARGET == entry_type) {
45  if (!p_target) {
46  dbg_errmsg("Can't find target or pattern on line %s.\n"
47  "Use 'info lines' to get a list of breakpoint lines.",
48  psz_target);
49  return debug_cmd_error;
50  }
51  } else {
52  dbg_errmsg("No support of breakpoints on target patterns yet.");
53  return debug_cmd_error;
54  }
55  } else
56  p_target =
59  } else {
60  p_target = lookup_file(psz_target);
61  }
62 
63  if (!p_target) {
64  dbg_errmsg("Can't find target %s; breakpoint not set.", psz_target);
65  return debug_cmd_error;
66  }
67 
68  /* FIXME: Combine with code in continue. */
69  if (!(psz_args && *psz_args))
70  i_brkpt_mask = BRK_ALL;
71  else {
72  while ((psz_break_type = get_word(&psz_args))) {
73  if (!(psz_break_type && *psz_break_type)) break;
74  i_brkpt_mask |= get_brkpt_option(psz_break_type) ;
75  }
76  }
77  add_breakpoint(p_target, i_brkpt_mask);
78  }
79 
80  return debug_readloop;
81 };
82 
83 static void
84 dbg_cmd_break_init(unsigned int c)
85 {
86  short_command[c].func = &dbg_cmd_break;
87  short_command[c].use = _("break [TARGET|LINENUM] [all|run|prereq|end]*");
88 }
89 
90 /*
91  * Local variables:
92  * eval: (c-set-style "gnu")
93  * indent-tabs-mode: nil
94  * End:
95  */
file_t * p_target
Definition: trace.h:81
file_t * target_for_file_and_line(const char *psz_filename, unsigned int lineno, f2l_entry_t *entry_type)
bool get_uint(const char *psz_arg, unsigned int *pi_result, bool b_warn)
bool add_breakpoint(file_t *p_target, unsigned int brkp_mask)
gmk_floc floc
Definition: filedef.h:39
Definition: types.h:60
void dbg_errmsg()
target_stack_node_t * p_stack
debug_return_t
Definition: trace.h:32
void list_breakpoints(void)
f2l_entry_t
Definition: file2line.h:24
#define _(msgid)
Definition: make.h:293
Definition: file2line.h:25
Definition: trace.h:40
file_t * lookup_file(const char *name)
char * variable_expand_set(char *psz_line, variable_set_list_t *p_file_set)
struct variable_set_list * variables
Definition: filedef.h:60
char * get_word(char **ppsz_str)
const char * filenm
Definition: gnuremake.h:25
Definition: trace.h:42
Definition: types.h:56
brkpt_mask_t get_brkpt_option(const char *psz_break_type)
Definition: filedef.h:34