Tighten regexp of lib/completion-support.exp:test_gdb_complete_tab_multiple
[deliverable/binutils-gdb.git] / gdb / location.h
CommitLineData
c7c1b3e9 1/* Data structures and API for event locations in GDB.
61baf725 2 Copyright (C) 2013-2017 Free Software Foundation, Inc.
c7c1b3e9
KS
3
4 This file is part of GDB.
5
6 This program 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 3 of the License, or
9 (at your option) any later version.
10
11 This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#ifndef LOCATIONS_H
20#define LOCATIONS_H 1
21
22struct language_defn;
23struct event_location;
24
00e52e53
KS
25/* An enumeration of possible signs for a line offset. */
26
27enum offset_relative_sign
28{
29 /* No sign */
30 LINE_OFFSET_NONE,
31
32 /* A plus sign ("+") */
33 LINE_OFFSET_PLUS,
34
35 /* A minus sign ("-") */
36 LINE_OFFSET_MINUS,
37
38 /* A special "sign" for unspecified offset. */
39 LINE_OFFSET_UNKNOWN
40};
41
42/* A line offset in a location. */
43
44struct line_offset
45{
46 /* Line offset and any specified sign. */
47 int offset;
48 enum offset_relative_sign sign;
49};
50
c7c1b3e9
KS
51/* An enumeration of the various ways to specify a stop event
52 location (used with create_breakpoint). */
53
54enum event_location_type
55{
56 /* A traditional linespec. */
a06efdd6
KS
57 LINESPEC_LOCATION,
58
59 /* An address in the inferior. */
5b56227b
KS
60 ADDRESS_LOCATION,
61
00e52e53
KS
62 /* An explicit location. */
63 EXPLICIT_LOCATION,
64
5b56227b
KS
65 /* A probe location. */
66 PROBE_LOCATION
c7c1b3e9
KS
67};
68
a20714ff
PA
69/* A traditional linespec. */
70
71struct linespec_location
72{
73 /* Whether the function name is fully-qualified or not. */
74 symbol_name_match_type match_type;
75
76 /* The linespec. */
77 char *spec_string;
78};
79
00e52e53
KS
80/* An explicit location. This structure is used to bypass the
81 parsing done on linespecs. It still has the same requirements
82 as linespecs, though. For example, source_filename requires
83 at least one other field. */
84
85struct explicit_location
86{
87 /* The source filename. Malloc'd. */
88 char *source_filename;
89
90 /* The function name. Malloc'd. */
91 char *function_name;
92
a20714ff
PA
93 /* Whether the function name is fully-qualified or not. */
94 symbol_name_match_type func_name_match_type;
95
00e52e53
KS
96 /* The name of a label. Malloc'd. */
97 char *label_name;
98
99 /* A line offset relative to the start of the symbol
100 identified by the above fields or the current symtab
101 if the other fields are NULL. */
102 struct line_offset line_offset;
103};
104
c7c1b3e9
KS
105/* Return the type of the given event location. */
106
107extern enum event_location_type
108 event_location_type (const struct event_location *);
109
00e52e53
KS
110/* Return a malloc'd explicit string representation of the given
111 explicit location. The location must already be canonicalized/valid. */
112
113extern char *
67994074 114 explicit_location_to_string (const struct explicit_location *explicit_loc);
00e52e53
KS
115
116/* Return a malloc'd linespec string representation of the given
117 explicit location. The location must already be canonicalized/valid. */
118
119extern char *
67994074 120 explicit_location_to_linespec (const struct explicit_location *explicit_loc);
00e52e53 121
c7c1b3e9
KS
122/* Return a string representation of the LOCATION.
123 This function may return NULL for unspecified linespecs,
a20714ff 124 e.g, LINESPEC_LOCATION and spec_string is NULL.
c7c1b3e9
KS
125
126 The result is cached in LOCATION. */
127
128extern const char *
129 event_location_to_string (struct event_location *location);
130
ffc2605c
TT
131/* A deleter for a struct event_location. */
132
133struct event_location_deleter
134{
8e9e35b1 135 void operator() (event_location *location) const;
ffc2605c
TT
136};
137
138/* A unique pointer for event_location. */
139typedef std::unique_ptr<event_location, event_location_deleter>
140 event_location_up;
141
142/* Create a new linespec location. */
c7c1b3e9 143
a20714ff
PA
144extern event_location_up new_linespec_location
145 (const char **linespec, symbol_name_match_type match_type);
c7c1b3e9 146
a20714ff
PA
147/* Return the linespec location of the given event_location (which
148 must be of type LINESPEC_LOCATION). */
c7c1b3e9 149
a20714ff 150extern const linespec_location *
c7c1b3e9
KS
151 get_linespec_location (const struct event_location *location);
152
305e13e6
JB
153/* Create a new address location.
154 ADDR is the address corresponding to this event_location.
155 ADDR_STRING, a string of ADDR_STRING_LEN characters, is
156 the expression that was parsed to determine the address ADDR. */
a06efdd6 157
ffc2605c
TT
158extern event_location_up new_address_location (CORE_ADDR addr,
159 const char *addr_string,
160 int addr_string_len);
a06efdd6
KS
161
162/* Return the address location (a CORE_ADDR) of the given event_location
163 (which must be of type ADDRESS_LOCATION). */
164
165extern CORE_ADDR
166 get_address_location (const struct event_location *location);
167
305e13e6
JB
168/* Return the expression (a string) that was used to compute the address
169 of the given event_location (which must be of type ADDRESS_LOCATION). */
170
171extern const char *
172 get_address_string_location (const struct event_location *location);
173
ffc2605c 174/* Create a new probe location. */
5b56227b 175
ffc2605c 176extern event_location_up new_probe_location (const char *probe);
5b56227b
KS
177
178/* Return the probe location (a string) of the given event_location
179 (which must be of type PROBE_LOCATION). */
180
181extern const char *
182 get_probe_location (const struct event_location *location);
183
00e52e53
KS
184/* Initialize the given explicit location. */
185
67994074
KS
186extern void
187 initialize_explicit_location (struct explicit_location *explicit_loc);
00e52e53
KS
188
189/* Create a new explicit location. If not NULL, EXPLICIT is checked for
ffc2605c 190 validity. If invalid, an exception is thrown. */
00e52e53 191
ffc2605c 192extern event_location_up
67994074 193 new_explicit_location (const struct explicit_location *explicit_loc);
00e52e53
KS
194
195/* Return the explicit location of the given event_location
196 (which must be of type EXPLICIT_LOCATION). */
197
198extern struct explicit_location *
199 get_explicit_location (struct event_location *location);
200
201/* A const version of the above. */
202
203extern const struct explicit_location *
204 get_explicit_location_const (const struct event_location *location);
205
c7c1b3e9
KS
206/* Return a copy of the given SRC location. */
207
ffc2605c 208extern event_location_up
c7c1b3e9
KS
209 copy_event_location (const struct event_location *src);
210
211/* Attempt to convert the input string in *ARGP into an event_location.
212 ARGP is advanced past any processed input. Returns an event_location
213 (malloc'd) if an event location was successfully found in *ARGP,
214 NULL otherwise.
215
216 This function may call error() if *ARGP looks like properly formed,
217 but invalid, input, e.g., if it is called with missing argument parameters
218 or invalid options.
219
eeb1af43
KS
220 This function is intended to be used by CLI commands and will parse
221 explicit locations in a CLI-centric way. Other interfaces should use
222 string_to_event_location_basic if they want to maintain support for
223 legacy specifications of probe, address, and linespec locations. */
c7c1b3e9 224
ffc2605c 225extern event_location_up
f2fc3015 226 string_to_event_location (const char **argp,
c7c1b3e9
KS
227 const struct language_defn *langauge);
228
a20714ff
PA
229/* Like string_to_event_location, but does not attempt to parse
230 explicit locations. MATCH_TYPE indicates how function names should
231 be matched. */
eeb1af43 232
ffc2605c 233extern event_location_up
f2fc3015 234 string_to_event_location_basic (const char **argp,
a20714ff
PA
235 const struct language_defn *language,
236 symbol_name_match_type match_type);
eeb1af43 237
c6756f62
PA
238/* Structure filled in by string_to_explicit_location to aid the
239 completer. */
240struct explicit_completion_info
241{
242 /* Pointer to the last option found. E.g., in "b -sou src.c -fun
243 func", LAST_OPTION is left pointing at "-fun func". */
244 const char *last_option = NULL;
245
246 /* These point to the start and end of a quoted argument, iff the
247 last argument was quoted. If parsing finds an incomplete quoted
248 string (e.g., "break -function 'fun"), then QUOTED_ARG_START is
249 set to point to the opening \', and QUOTED_ARG_END is left NULL.
250 If the last option is not quoted, then both are set to NULL. */
251 const char *quoted_arg_start = NULL;
252 const char *quoted_arg_end = NULL;
a20714ff
PA
253
254 /* True if we saw an explicit location option, as opposed to only
255 flags that affect both explicit locations and linespecs, like
256 "-qualified". */
257 bool saw_explicit_location_option = false;
c6756f62
PA
258};
259
87f0e720
KS
260/* Attempt to convert the input string in *ARGP into an explicit location.
261 ARGP is advanced past any processed input. Returns an event_location
262 (malloc'd) if an explicit location was successfully found in *ARGP,
263 NULL otherwise.
264
c6756f62
PA
265 If COMPLETION_INFO is NULL, this function may call error() if *ARGP
266 looks like improperly formed input, e.g., if it is called with
267 missing argument parameters or invalid options. If COMPLETION_INFO
268 is not NULL, this function will not throw any exceptions. */
87f0e720 269
ffc2605c 270extern event_location_up
87f0e720 271 string_to_explicit_location (const char **argp,
c6756f62
PA
272 const struct language_defn *language,
273 explicit_completion_info *completion_info);
87f0e720 274
c7c1b3e9
KS
275/* A convenience function for testing for unset locations. */
276
277extern int event_location_empty_p (const struct event_location *location);
278
279/* Set the location's string representation. If STRING is NULL, clear
280 the string representation. */
281
282extern void
283 set_event_location_string (struct event_location *location,
284 const char *string);
285#endif /* LOCATIONS_H */
This page took 0.232841 seconds and 4 git commands to generate.