Explicit locations: introduce explicit locations
[deliverable/binutils-gdb.git] / gdb / location.h
CommitLineData
c7c1b3e9
KS
1/* Data structures and API for event locations in GDB.
2 Copyright (C) 2013-2015 Free Software Foundation, Inc.
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
00e52e53
KS
69/* An explicit location. This structure is used to bypass the
70 parsing done on linespecs. It still has the same requirements
71 as linespecs, though. For example, source_filename requires
72 at least one other field. */
73
74struct explicit_location
75{
76 /* The source filename. Malloc'd. */
77 char *source_filename;
78
79 /* The function name. Malloc'd. */
80 char *function_name;
81
82 /* The name of a label. Malloc'd. */
83 char *label_name;
84
85 /* A line offset relative to the start of the symbol
86 identified by the above fields or the current symtab
87 if the other fields are NULL. */
88 struct line_offset line_offset;
89};
90
c7c1b3e9
KS
91/* Return the type of the given event location. */
92
93extern enum event_location_type
94 event_location_type (const struct event_location *);
95
00e52e53
KS
96/* Return a malloc'd explicit string representation of the given
97 explicit location. The location must already be canonicalized/valid. */
98
99extern char *
100 explicit_location_to_string (const struct explicit_location *explicit);
101
102/* Return a malloc'd linespec string representation of the given
103 explicit location. The location must already be canonicalized/valid. */
104
105extern char *
106 explicit_location_to_linespec (const struct explicit_location *explicit);
107
c7c1b3e9
KS
108/* Return a string representation of the LOCATION.
109 This function may return NULL for unspecified linespecs,
110 e.g, LOCATION_LINESPEC and addr_string is NULL.
111
112 The result is cached in LOCATION. */
113
114extern const char *
115 event_location_to_string (struct event_location *location);
116
117/* Create a new linespec location. The return result is malloc'd
118 and should be freed with delete_event_location. */
119
120extern struct event_location *
121 new_linespec_location (char **linespec);
122
123/* Return the linespec location (a string) of the given event_location
124 (which must be of type LINESPEC_LOCATION). */
125
126extern const char *
127 get_linespec_location (const struct event_location *location);
128
a06efdd6
KS
129/* Create a new address location. The return result is malloc'd
130 and should be freed with delete_event_location. */
131
132extern struct event_location *
133 new_address_location (CORE_ADDR addr);
134
135/* Return the address location (a CORE_ADDR) of the given event_location
136 (which must be of type ADDRESS_LOCATION). */
137
138extern CORE_ADDR
139 get_address_location (const struct event_location *location);
140
5b56227b
KS
141/* Create a new probe location. The return result is malloc'd
142 and should be freed with delete_event_location. */
143
144extern struct event_location *
145 new_probe_location (const char *probe);
146
147/* Return the probe location (a string) of the given event_location
148 (which must be of type PROBE_LOCATION). */
149
150extern const char *
151 get_probe_location (const struct event_location *location);
152
00e52e53
KS
153/* Initialize the given explicit location. */
154
155extern void initialize_explicit_location (struct explicit_location *explicit);
156
157/* Create a new explicit location. If not NULL, EXPLICIT is checked for
158 validity. If invalid, an exception is thrown.
159
160 The return result is malloc'd and should be freed with
161 delete_event_location. */
162
163extern struct event_location *
164 new_explicit_location (const struct explicit_location *explicit);
165
166/* Return the explicit location of the given event_location
167 (which must be of type EXPLICIT_LOCATION). */
168
169extern struct explicit_location *
170 get_explicit_location (struct event_location *location);
171
172/* A const version of the above. */
173
174extern const struct explicit_location *
175 get_explicit_location_const (const struct event_location *location);
176
c7c1b3e9
KS
177/* Free an event location and any associated data. */
178
179extern void delete_event_location (struct event_location *location);
180
181/* Make a cleanup to free LOCATION. */
182
183extern struct cleanup *
184 make_cleanup_delete_event_location (struct event_location *location);
185
186/* Return a copy of the given SRC location. */
187
188extern struct event_location *
189 copy_event_location (const struct event_location *src);
190
191/* Attempt to convert the input string in *ARGP into an event_location.
192 ARGP is advanced past any processed input. Returns an event_location
193 (malloc'd) if an event location was successfully found in *ARGP,
194 NULL otherwise.
195
196 This function may call error() if *ARGP looks like properly formed,
197 but invalid, input, e.g., if it is called with missing argument parameters
198 or invalid options.
199
200 The return result must be freed with delete_event_location. */
201
202extern struct event_location *
203 string_to_event_location (char **argp,
204 const struct language_defn *langauge);
205
206/* A convenience function for testing for unset locations. */
207
208extern int event_location_empty_p (const struct event_location *location);
209
210/* Set the location's string representation. If STRING is NULL, clear
211 the string representation. */
212
213extern void
214 set_event_location_string (struct event_location *location,
215 const char *string);
216#endif /* LOCATIONS_H */
This page took 0.0313 seconds and 4 git commands to generate.