1 /*
2 Copyright (C) 2005, 2008, 2011 R. Bernstein <rocky@gnu.org>
3 This file is part of GNU Make (remake variant).
4 
5 GNU Make is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9 
10 GNU Make is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with GNU Make; see the file COPYING.  If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.  */
19 
20 /** \file dbg_fns.h
21  *
22  *  \brief debugger helper functions.
23 */
24 
25 #ifndef DBG_FNS_H
26 #define DBG_FNS_H
27 
28 #include "debug.h"
29 #include "filedef.h"
30 #include "trace.h"
31 #include "rule.h"
32 
33 extern gmk_floc *p_target_loc;
34 extern char   *psz_target_name;
35 
36 /*! We use the if when we fake a line number because
37    a real one hasn't been recorded on the stack. */
38 extern gmk_floc  fake_floc;
39 
40 brkpt_mask_t get_brkpt_option(const char *psz_break_type);
41 const gmk_floc *get_current_floc(void);
42 
43 /*!
44   Return the current target from the stack or NULL
45   if none set.
46  */
47 const file_t * get_current_target(void);
48 
49 /*! Parse psz_arg for a signed integer. The value is returned in
50     *pi_result. If warn is true, then we'll give a warning if no
51     integer found. The return value is true if parsing succeeded in
52     any event..
53  */
54 extern bool get_int(const char *psz_arg, /*out*/ int *pi_result,
55 		    bool b_warn);
56 
57 /*! Parse psz_arg for a unsigned integer. The value is returned in
58     *pi_result. The retun value is true if parsing succeeded.
59  */
60 extern bool get_uint(const char *psz_arg, /*out*/ unsigned int *pi_result,
61     bool b_warn);
62 
63 /*! Find the next "word" - skip leading blanks and the "word" is the
64    largest non-blank characters after that. ppsz_str is modified to
65    point after the portion returned and also the region initially
66    pointed to by ppsz_str is modified so that word is zero-byte
67    termintated.
68  */
69 extern char *get_word(char **ppsz_str);
70 
71 /*! Find the target in first word of psz_args or use $@ (the current
72     stack) if none.  We also allow $@ or @ explicitly as a target name
73     to mean the current target on the stack. NULL is returned if a lookup
74     of the target name was not found. ppsz_target is to the name
75     looked up.
76  */
77 file_t *
78 get_target(/*in/out*/ char **ppsz_args, /*out*/ const char **ppsz_target);
79 
80 /*! Return true if psz_substr is an initial prefix (abbreviation) of
81     psz_word. The empty string is not a valid abbreviation. */
82 extern bool is_abbrev_of(const char *psz_substr,
83 			 const char *psz_word, unsigned int i_min);
84 /*! toggle var on or on or off depending on psz_onoff */
85 extern void on_off_toggle(const char *psz_onoff, int *var) ;
86 
87 /** Print where we are in the Makefile. */
88 extern void print_debugger_location(const file_t *p_target,
89 				    debug_enter_reason_t reason,
90 				    const floc_stack_node_t *p_stack_floc);
91 
92 /** Strip whitespace from the start and end of STRING.  Return a pointer
93    into STRING. */
94 extern char *stripwhite (char *string);
95 
96 /*! Show if i_bool is "on" or "off" */
97 extern const char *var_to_on_off(int i_bool);
98 
99 /*! Show a expression. Set "expand" to 1 if you want variable
100    definitions inside the displayed value expanded.
101 */
102 extern bool dbg_cmd_show_exp(char *psz_arg, bool expand);
103 
104 /*! Print an interpretation of the debug level mask. */
105 extern void print_db_level(debug_level_mask_t e_debug_level);
106 
107 /*! See if psz_varname is $varname or $(varname) */
108 extern variable_t *try_without_dollar(const char *psz_varname);
109 
110 extern void dbg_print_invocation(void);
111 
112 extern rule_t *find_rule (const char *psz_name);
113 extern void shell_rc_status(int rc);
114 
115 extern void chomp(char * line);
116 
117 #endif /* DBG_FNS_H*/
118