remake  4.3+dbg-1.5
list.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2020 R. Bernstein <rocky@gnu.org>
3 
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 /* List target. */
21 
22 #define DEPENDS_COMMANDS " depends commands"
23 static debug_return_t
24 dbg_cmd_list(char *psz_arg)
25 {
26  const char *psz_target = NULL;
27  char *target_cmd = NULL;
28  file_t *p_target;
29 
30  if (psz_arg && 0 == strcmp(psz_arg, "-")) {
31  /* Show info for parent target. */
32  if (p_stack_top) {
33  /* We have a target stack */
35 
36  if (!p) {
37  dbg_errmsg(_("We don't seem to have a target to get parent of."));
38  return debug_cmd_error;
39  }
40 
41  p = p->p_parent;
42  if (!p) {
43  dbg_errmsg(_("We don't seem to have a parent target."));
44  return debug_cmd_error;
45  }
46  p_target = p->p_target;
47  psz_target = p_target->name;
48  } else {
49  dbg_errmsg(_("We don't seem to have a target stack to get parent of."));
50  return debug_cmd_error;
51  }
52  } else {
53  unsigned int u_lineno=0;
54  f2l_entry_t entry_type;
55  if (get_uint(psz_arg, &u_lineno, false)) {
56  if (p_stack) {
58  u_lineno, &entry_type);
59  if (!p_target) {
60  dbg_errmsg("Can't find target or pattern on line %s.\n"
61  "Use 'info lines' to get a list of and pattern lines.",
62  psz_arg);
63  return debug_cmd_error;
64  }
65  psz_target = p_target->name;
66  } else {
67  dbg_errmsg(_("We don't seem to have a target stack to get parent of."));
68  return debug_cmd_error;
69  }
70  } else
71  p_target = get_target(&psz_arg, &psz_target);
72  }
73 
74  if (!p_target) {
75  dbg_errmsg(_("Trouble getting a target name for %s."), psz_target);
76  return debug_cmd_error;
77  }
78  print_floc_prefix(&p_target->floc);
79  if (p_target->description) printf("\n");
80  target_cmd = CALLOC(char, strlen(psz_target) + 1 + strlen(DEPENDS_COMMANDS));
81  sprintf(target_cmd, "%s%s", psz_target, DEPENDS_COMMANDS);
82  return dbg_cmd_target(target_cmd);
83 }
84 
85 static void
86 dbg_cmd_list_init(unsigned int c)
87 {
88  short_command[c].func = &dbg_cmd_list;
89  short_command[c].use = _("list [TARGET|LINE-NUMBER]");
90 }
91 
92 
93 /*
94  * Local variables:
95  * eval: (c-set-style "gnu")
96  * indent-tabs-mode: nil
97  * End:
98  */
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)
const char * name
Definition: filedef.h:36
bool get_uint(const char *psz_arg, unsigned int *pi_result, bool b_warn)
#define CALLOC(t, n)
Definition: types.h:83
gmk_floc floc
Definition: filedef.h:39
void dbg_errmsg()
target_stack_node_t * p_stack
debug_return_t
Definition: trace.h:32
f2l_entry_t
Definition: file2line.h:24
#define DEPENDS_COMMANDS
Definition: list.h:22
#define _(msgid)
Definition: make.h:293
file_t * get_target(char **ppsz_args, const char **ppsz_target)
Node for an item in the target call stack.
Definition: trace.h:79
const char * filenm
Definition: gnuremake.h:25
Definition: trace.h:42
struct target_stack_node * p_parent
Definition: trace.h:83
target_stack_node_t * p_stack_top
const char * description
Definition: filedef.h:43
debug_return_t dbg_cmd_target(char *psz_args)
Definition: target.h:21
Definition: filedef.h:34