remake  4.3+dbg-1.5
debugger/command/print.h
Go to the documentation of this file.
1 /* Show a variable definition. */
2 /*
3 Copyright (C) 2004-2005, 2007-2009, 2011, 2020 R. Bernstein
4 <rocky@gnu.org>
5 This file is part of GNU Make (remake variant).
6 
7 GNU Make is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11 
12 GNU Make is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with GNU Make; see the file COPYING. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21 static debug_return_t
22 dbg_cmd_print(char *psz_args)
23 {
24  char *psz_name;
25  static char *psz_last_name = NULL;
26 
27  if (!psz_args || 0==strlen(psz_args)) {
28  /* Use last value */
29  if (psz_last_name)
30  psz_name = psz_last_name;
31  else {
32  printf("No current variable - must supply something to print\n");
33  return debug_readloop;
34  }
35  } else {
36  psz_name = get_word(&psz_args);
37  }
38 
39  if (dbg_cmd_show_exp(psz_name, false)) {
40  if (psz_last_name) free(psz_last_name);
41  psz_last_name = strdup(psz_name);
42  }
43 
44  return debug_readloop;
45 }
46 
47 static void
48 dbg_cmd_print_init(unsigned int c)
49 {
50  short_command[c].func = &dbg_cmd_print;
51  short_command[c].use = _("print {VARIABLE [attrs...]}");
52 }
53 
54 /*
55  * Local variables:
56  * c-file-style: "gnu"
57  * indent-tabs-mode: nil
58  * End:
59  */
debug_return_t
Definition: trace.h:32
bool dbg_cmd_show_exp(char *psz_arg, bool expand)
#define _(msgid)
Definition: make.h:293
Definition: trace.h:40
char * get_word(char **ppsz_str)