Commit | Line | Data |
---|---|---|
c5f0f3d0 | 1 | /* Header for GDB line completion. |
61baf725 | 2 | Copyright (C) 2000-2017 Free Software Foundation, Inc. |
c5f0f3d0 FN |
3 | |
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 6 | the Free Software Foundation; either version 3 of the License, or |
c5f0f3d0 FN |
7 | (at your option) any later version. |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c5f0f3d0 FN |
16 | |
17 | #if !defined (LINESPEC_H) | |
18 | #define LINESPEC_H 1 | |
19 | ||
da3331ec AC |
20 | struct symtab; |
21 | ||
8e9e35b1 | 22 | #include "location.h" |
f8eba3c6 TT |
23 | #include "vec.h" |
24 | ||
25 | /* Flags to pass to decode_line_1 and decode_line_full. */ | |
26 | ||
27 | enum decode_line_flags | |
28 | { | |
29 | /* Set this flag if you want the resulting SALs to describe the | |
30 | first line of indicated functions. */ | |
31 | DECODE_LINE_FUNFIRSTLINE = 1, | |
32 | ||
33 | /* Set this flag if you want "list mode". In this mode, a | |
34 | FILE:LINE linespec will always return a result, and such | |
35 | linespecs will not be expanded to all matches. */ | |
36 | DECODE_LINE_LIST_MODE = 2 | |
37 | }; | |
38 | ||
39 | /* decode_line_full returns a vector of these. */ | |
40 | ||
41 | struct linespec_sals | |
42 | { | |
f00aae0f | 43 | /* This is the location corresponding to the sals contained in this |
f8eba3c6 | 44 | object. It can be passed as the FILTER argument to future calls |
16e802b9 TT |
45 | to decode_line_full. This is freed by the linespec_result |
46 | destructor. */ | |
f8eba3c6 TT |
47 | char *canonical; |
48 | ||
6c5b2ebe PA |
49 | /* Sals. */ |
50 | std::vector<symtab_and_line> sals; | |
f8eba3c6 TT |
51 | }; |
52 | ||
7efd8fc2 | 53 | /* An instance of this may be filled in by decode_line_1. The caller |
16e802b9 | 54 | must make copies of any data that it needs to keep. */ |
7efd8fc2 TT |
55 | |
56 | struct linespec_result | |
57 | { | |
6c5b2ebe | 58 | linespec_result () = default; |
16e802b9 TT |
59 | ~linespec_result (); |
60 | ||
d6541620 | 61 | DISABLE_COPY_AND_ASSIGN (linespec_result); |
16e802b9 | 62 | |
6c5b2ebe | 63 | /* If true, the linespec should be displayed to the user. This |
56435ebe TT |
64 | is used by "unusual" linespecs where the ordinary `info break' |
65 | display mechanism would do the wrong thing. */ | |
6c5b2ebe | 66 | bool special_display = false; |
56435ebe | 67 | |
6c5b2ebe | 68 | /* If true, the linespec result should be considered to be a |
f8eba3c6 TT |
69 | "pre-expanded" multi-location linespec. A pre-expanded linespec |
70 | holds all matching locations in a single linespec_sals | |
71 | object. */ | |
6c5b2ebe | 72 | bool pre_expanded = false; |
f8eba3c6 | 73 | |
f00aae0f | 74 | /* If PRE_EXPANDED is non-zero, this is set to the location entered |
8e9e35b1 TT |
75 | by the user. */ |
76 | event_location_up location; | |
f8eba3c6 | 77 | |
16e802b9 | 78 | /* The sals. The vector will be freed by the destructor. */ |
6c5b2ebe | 79 | std::vector<linespec_sals> lsals; |
7efd8fc2 TT |
80 | }; |
81 | ||
39cf75f7 DE |
82 | /* Decode a linespec using the provided default symtab and line. */ |
83 | ||
6c5b2ebe | 84 | extern std::vector<symtab_and_line> |
f00aae0f | 85 | decode_line_1 (const struct event_location *location, int flags, |
c2f4122d | 86 | struct program_space *search_pspace, |
f8eba3c6 TT |
87 | struct symtab *default_symtab, int default_line); |
88 | ||
f00aae0f | 89 | /* Parse LOCATION and return results. This is the "full" |
f8eba3c6 TT |
90 | interface to this module, which handles multiple results |
91 | properly. | |
92 | ||
93 | For FLAGS, see decode_line_flags. DECODE_LINE_LIST_MODE is not | |
94 | valid for this function. | |
95 | ||
c2f4122d PA |
96 | If SEARCH_PSPACE is not NULL, symbol search is restricted to just |
97 | that program space. | |
98 | ||
f8eba3c6 TT |
99 | DEFAULT_SYMTAB and DEFAULT_LINE describe the default location. |
100 | DEFAULT_SYMTAB can be NULL, in which case the current symtab and | |
101 | line are used. | |
102 | ||
103 | CANONICAL is where the results are stored. It must not be NULL. | |
104 | ||
105 | SELECT_MODE must be one of the multiple_symbols_* constants, or | |
106 | NULL. It determines how multiple results will be handled. If | |
107 | NULL, the appropriate CLI value will be used. | |
108 | ||
109 | FILTER can either be NULL or a string holding a canonical name. | |
110 | This is only valid when SELECT_MODE is multiple_symbols_all. | |
111 | ||
112 | Multiple results are handled differently depending on the | |
113 | arguments: | |
114 | ||
115 | . With multiple_symbols_cancel, an exception is thrown. | |
116 | ||
117 | . With multiple_symbols_ask, a menu is presented to the user. The | |
118 | user may select none, in which case an exception is thrown; or all, | |
119 | which is handled like multiple_symbols_all, below. Otherwise, | |
120 | CANONICAL->SALS will have one entry for each name the user chose. | |
121 | ||
122 | . With multiple_symbols_all, CANONICAL->SALS will have a single | |
123 | entry describing all the matching locations. If FILTER is | |
124 | non-NULL, then only locations whose canonical name is equal (in the | |
125 | strcmp sense) to FILTER will be returned; all others will be | |
126 | filtered out. */ | |
127 | ||
f00aae0f | 128 | extern void decode_line_full (const struct event_location *location, int flags, |
c2f4122d | 129 | struct program_space *search_pspace, |
f8eba3c6 TT |
130 | struct symtab *default_symtab, int default_line, |
131 | struct linespec_result *canonical, | |
132 | const char *select_mode, | |
133 | const char *filter); | |
c5f0f3d0 | 134 | |
39cf75f7 DE |
135 | /* Given a string, return the line specified by it, using the current |
136 | source symtab and line as defaults. | |
137 | This is for commands like "list" and "breakpoint". */ | |
138 | ||
f2fc3015 TT |
139 | extern std::vector<symtab_and_line> decode_line_with_current_source |
140 | (const char *, int); | |
39cf75f7 DE |
141 | |
142 | /* Given a string, return the line specified by it, using the last displayed | |
143 | codepoint's values as defaults, or nothing if they aren't valid. */ | |
144 | ||
f2fc3015 TT |
145 | extern std::vector<symtab_and_line> decode_line_with_last_displayed |
146 | (const char *, int); | |
39cf75f7 | 147 | |
0578b14e KS |
148 | /* Does P represent one of the keywords? If so, return |
149 | the keyword. If not, return NULL. */ | |
150 | ||
151 | extern const char *linespec_lexer_lex_keyword (const char *p); | |
c7c1b3e9 | 152 | |
87f0e720 KS |
153 | /* Parse a line offset from STRING. */ |
154 | ||
155 | extern struct line_offset linespec_parse_line_offset (const char *string); | |
156 | ||
157 | /* Return the quote characters permitted by the linespec parser. */ | |
158 | ||
159 | extern const char *get_gdb_linespec_parser_quote_characters (void); | |
160 | ||
161 | /* Does STRING represent an Ada operator? If so, return the length | |
162 | of the decoded operator name. If not, return 0. */ | |
163 | ||
164 | extern int is_ada_operator (const char *string); | |
165 | ||
166 | /* Find an instance of the character C in the string S that is outside | |
167 | of all parenthesis pairs, single-quoted strings, and double-quoted | |
168 | strings. Also, ignore the char within a template name, like a ',' | |
169 | within foo<int, int>. */ | |
170 | ||
171 | extern const char *find_toplevel_char (const char *s, char c); | |
172 | ||
c7c1b3e9 KS |
173 | /* Find the end of the (first) linespec pointed to by *STRINGP. |
174 | STRINGP will be advanced to this point. */ | |
175 | ||
f2fc3015 | 176 | extern void linespec_lex_to_end (const char **stringp); |
a06efdd6 | 177 | |
c6756f62 PA |
178 | extern const char * const linespec_keywords[]; |
179 | ||
c45ec17c PA |
180 | /* Complete a linespec. */ |
181 | ||
182 | extern void linespec_complete (completion_tracker &tracker, | |
183 | const char *text); | |
184 | ||
c6756f62 PA |
185 | /* Complete a function symbol, in linespec mode. If SOURCE_FILENAME |
186 | is non-NULL, limits completion to the list of functions defined in | |
187 | source files that match SOURCE_FILENAME. */ | |
188 | ||
189 | extern void linespec_complete_function (completion_tracker &tracker, | |
190 | const char *function, | |
191 | const char *source_filename); | |
192 | ||
a2459270 PA |
193 | /* Complete a label symbol, in linespec mode. Only labels of |
194 | functions named FUNCTION_NAME are considered. If SOURCE_FILENAME | |
195 | is non-NULL, limits completion to labels of functions defined in | |
196 | source files that match SOURCE_FILENAME. */ | |
197 | ||
198 | extern void linespec_complete_label (completion_tracker &tracker, | |
199 | const struct language_defn *language, | |
200 | const char *source_filename, | |
201 | const char *function_name, | |
202 | const char *label_name); | |
203 | ||
a06efdd6 KS |
204 | /* Evaluate the expression pointed to by EXP_PTR into a CORE_ADDR, |
205 | advancing EXP_PTR past any parsed text. */ | |
206 | ||
207 | extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr); | |
c5f0f3d0 | 208 | #endif /* defined (LINESPEC_H) */ |