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