Debian Codegraph @

libdebugger/command/list.c

raw symbols SCIP
1 /*
2 Copyright (C) 2020 R. Bernstein <[email protected]>
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
21 /** \file libdebugger/command/list.c
22 *
23 * \brief Debugger command to list Makefile target information
24 */
25
26 #include "../../src/trace.h"
27 #include "../../src/print.h"
28 #include "../file2line.h"
29 #include "../cmd.h"
30 #include "../fns.h"
31 #include "../msg.h"
32 #include "../stack.h"
33
34 #define DEPENDS_COMMANDS " depends commands"
35 extern debug_return_t
36 dbg_cmd_list(char *psz_arg)
37 {
38 const char *psz_target = NULL;
39 char *target_cmd = NULL;
40 file_t *p_target;
41
42 if (psz_arg && 0 == strcmp(psz_arg, "-")) {
43 /* Show info for parent target. */
44 if (p_stack_top) {
45 /* We have a target stack */
46 target_stack_node_t *p=p_stack;
47
48 if (!p) {
49 dbg_errmsg(_("We don't seem to have a target to get parent of."));
50 return debug_cmd_error;
51 }
52
53 p = p->p_parent;
54 if (!p) {
55 dbg_errmsg(_("We don't seem to have a parent target."));
56 return debug_cmd_error;
57 }
58 p_target = p->p_target;
59 psz_target = p_target->name;
60 } else {
61 dbg_errmsg(_("We don't seem to have a target stack to get parent of."));
62 return debug_cmd_error;
63 }
64 } else {
65 unsigned int u_lineno=0;
66 f2l_entry_t entry_type;
67 if (get_uint(psz_arg, &u_lineno, false)) {
68 if (p_stack) {
69 p_target = target_for_file_and_line(p_stack->p_target->floc.filenm,
70 u_lineno, &entry_type);
71 if (!p_target) {
72 dbg_errmsg("Can't find target or pattern on line %s.\n"
73 "Use 'info lines' to get a list of and pattern lines.",
74 psz_arg);
75 return debug_cmd_error;
76 }
77 psz_target = p_target->name;
78 } else {
79 dbg_errmsg(_("We don't seem to have a target stack to get parent of."));
80 return debug_cmd_error;
81 }
82 } else
83 p_target = get_target(&psz_arg, &psz_target);
84 }
85
86 if (!p_target) {
87 dbg_errmsg(_("Trouble getting a target name for %s."), psz_target);
88 return debug_cmd_error;
89 }
90 print_floc_prefix(&p_target->floc);
91 if (p_target->description) printf("\n");
92 target_cmd = CALLOC(char, strlen(psz_target) + 1 + strlen(DEPENDS_COMMANDS));
93 sprintf(target_cmd, "%s%s", psz_target, DEPENDS_COMMANDS);
94 return dbg_cmd_target(target_cmd);
95 }
96
97
98 /*
99 * Local variables:
100 * eval: (c-set-style "gnu")
101 * indent-tabs-mode: nil
102 * End:
103 */