]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/linespec.h
Add a constructor and destructor to linespec_result
[thirdparty/binutils-gdb.git] / gdb / linespec.h
CommitLineData
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
20struct symtab;
21
f8eba3c6
TT
22#include "vec.h"
23
24/* Flags to pass to decode_line_1 and decode_line_full. */
25
26enum 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
40struct 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
16e802b9
TT
48 /* Sals. The 'sals' field is destroyed by the linespec_result
49 destructor. */
f8eba3c6
TT
50 struct symtabs_and_lines sals;
51};
52
53typedef struct linespec_sals linespec_sals;
54DEF_VEC_O (linespec_sals);
55
7efd8fc2 56/* An instance of this may be filled in by decode_line_1. The caller
16e802b9 57 must make copies of any data that it needs to keep. */
7efd8fc2
TT
58
59struct linespec_result
60{
16e802b9
TT
61 linespec_result ()
62 : special_display (0),
63 pre_expanded (0),
64 location (NULL),
65 sals (NULL)
66 {
67 }
68
69 ~linespec_result ();
70
71 linespec_result (const linespec_result &) = delete;
72 linespec_result &operator= (const linespec_result &) = delete;
73
56435ebe
TT
74 /* If non-zero, the linespec should be displayed to the user. This
75 is used by "unusual" linespecs where the ordinary `info break'
76 display mechanism would do the wrong thing. */
77 int special_display;
78
f8eba3c6
TT
79 /* If non-zero, the linespec result should be considered to be a
80 "pre-expanded" multi-location linespec. A pre-expanded linespec
81 holds all matching locations in a single linespec_sals
82 object. */
83 int pre_expanded;
84
f00aae0f 85 /* If PRE_EXPANDED is non-zero, this is set to the location entered
f8eba3c6 86 by the user. This will be freed by destroy_linespec_result. */
f00aae0f 87 struct event_location *location;
f8eba3c6 88
16e802b9 89 /* The sals. The vector will be freed by the destructor. */
f8eba3c6 90 VEC (linespec_sals) *sals;
7efd8fc2
TT
91};
92
39cf75f7
DE
93/* Decode a linespec using the provided default symtab and line. */
94
c5f0f3d0 95extern struct symtabs_and_lines
f00aae0f 96 decode_line_1 (const struct event_location *location, int flags,
c2f4122d 97 struct program_space *search_pspace,
f8eba3c6
TT
98 struct symtab *default_symtab, int default_line);
99
f00aae0f 100/* Parse LOCATION and return results. This is the "full"
f8eba3c6
TT
101 interface to this module, which handles multiple results
102 properly.
103
104 For FLAGS, see decode_line_flags. DECODE_LINE_LIST_MODE is not
105 valid for this function.
106
c2f4122d
PA
107 If SEARCH_PSPACE is not NULL, symbol search is restricted to just
108 that program space.
109
f8eba3c6
TT
110 DEFAULT_SYMTAB and DEFAULT_LINE describe the default location.
111 DEFAULT_SYMTAB can be NULL, in which case the current symtab and
112 line are used.
113
114 CANONICAL is where the results are stored. It must not be NULL.
115
116 SELECT_MODE must be one of the multiple_symbols_* constants, or
117 NULL. It determines how multiple results will be handled. If
118 NULL, the appropriate CLI value will be used.
119
120 FILTER can either be NULL or a string holding a canonical name.
121 This is only valid when SELECT_MODE is multiple_symbols_all.
122
123 Multiple results are handled differently depending on the
124 arguments:
125
126 . With multiple_symbols_cancel, an exception is thrown.
127
128 . With multiple_symbols_ask, a menu is presented to the user. The
129 user may select none, in which case an exception is thrown; or all,
130 which is handled like multiple_symbols_all, below. Otherwise,
131 CANONICAL->SALS will have one entry for each name the user chose.
132
133 . With multiple_symbols_all, CANONICAL->SALS will have a single
134 entry describing all the matching locations. If FILTER is
135 non-NULL, then only locations whose canonical name is equal (in the
136 strcmp sense) to FILTER will be returned; all others will be
137 filtered out. */
138
f00aae0f 139extern void decode_line_full (const struct event_location *location, int flags,
c2f4122d 140 struct program_space *search_pspace,
f8eba3c6
TT
141 struct symtab *default_symtab, int default_line,
142 struct linespec_result *canonical,
143 const char *select_mode,
144 const char *filter);
c5f0f3d0 145
39cf75f7
DE
146/* Given a string, return the line specified by it, using the current
147 source symtab and line as defaults.
148 This is for commands like "list" and "breakpoint". */
149
150extern struct symtabs_and_lines decode_line_with_current_source (char *, int);
151
152/* Given a string, return the line specified by it, using the last displayed
153 codepoint's values as defaults, or nothing if they aren't valid. */
154
155extern struct symtabs_and_lines decode_line_with_last_displayed (char *, int);
156
0578b14e
KS
157/* Does P represent one of the keywords? If so, return
158 the keyword. If not, return NULL. */
159
160extern const char *linespec_lexer_lex_keyword (const char *p);
c7c1b3e9 161
87f0e720
KS
162/* Parse a line offset from STRING. */
163
164extern struct line_offset linespec_parse_line_offset (const char *string);
165
166/* Return the quote characters permitted by the linespec parser. */
167
168extern const char *get_gdb_linespec_parser_quote_characters (void);
169
170/* Does STRING represent an Ada operator? If so, return the length
171 of the decoded operator name. If not, return 0. */
172
173extern int is_ada_operator (const char *string);
174
175/* Find an instance of the character C in the string S that is outside
176 of all parenthesis pairs, single-quoted strings, and double-quoted
177 strings. Also, ignore the char within a template name, like a ','
178 within foo<int, int>. */
179
180extern const char *find_toplevel_char (const char *s, char c);
181
c7c1b3e9
KS
182/* Find the end of the (first) linespec pointed to by *STRINGP.
183 STRINGP will be advanced to this point. */
184
185extern void linespec_lex_to_end (char **stringp);
a06efdd6
KS
186
187/* Evaluate the expression pointed to by EXP_PTR into a CORE_ADDR,
188 advancing EXP_PTR past any parsed text. */
189
190extern CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
c5f0f3d0 191#endif /* defined (LINESPEC_H) */