1 /* Data structures and API for event locations in GDB.
2 Copyright (C) 2013-2016 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
23 struct event_location
;
25 /* An enumeration of possible signs for a line offset. */
27 enum offset_relative_sign
32 /* A plus sign ("+") */
35 /* A minus sign ("-") */
38 /* A special "sign" for unspecified offset. */
42 /* A line offset in a location. */
46 /* Line offset and any specified sign. */
48 enum offset_relative_sign sign
;
51 /* An enumeration of the various ways to specify a stop event
52 location (used with create_breakpoint). */
54 enum event_location_type
56 /* A traditional linespec. */
59 /* An address in the inferior. */
62 /* An explicit location. */
65 /* A probe location. */
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. */
74 struct explicit_location
76 /* The source filename. Malloc'd. */
77 char *source_filename
;
79 /* The function name. Malloc'd. */
82 /* The name of a label. Malloc'd. */
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
;
91 /* Return the type of the given event location. */
93 extern enum event_location_type
94 event_location_type (const struct event_location
*);
96 /* Return a malloc'd explicit string representation of the given
97 explicit location. The location must already be canonicalized/valid. */
100 explicit_location_to_string (const struct explicit_location
*explicit_loc
);
102 /* Return a malloc'd linespec string representation of the given
103 explicit location. The location must already be canonicalized/valid. */
106 explicit_location_to_linespec (const struct explicit_location
*explicit_loc
);
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.
112 The result is cached in LOCATION. */
115 event_location_to_string (struct event_location
*location
);
117 /* Create a new linespec location. The return result is malloc'd
118 and should be freed with delete_event_location. */
120 extern struct event_location
*
121 new_linespec_location (char **linespec
);
123 /* Return the linespec location (a string) of the given event_location
124 (which must be of type LINESPEC_LOCATION). */
127 get_linespec_location (const struct event_location
*location
);
129 /* Create a new address location. The return result is malloc'd
130 and should be freed with delete_event_location. */
132 extern struct event_location
*
133 new_address_location (CORE_ADDR addr
);
135 /* Return the address location (a CORE_ADDR) of the given event_location
136 (which must be of type ADDRESS_LOCATION). */
139 get_address_location (const struct event_location
*location
);
141 /* Create a new probe location. The return result is malloc'd
142 and should be freed with delete_event_location. */
144 extern struct event_location
*
145 new_probe_location (const char *probe
);
147 /* Return the probe location (a string) of the given event_location
148 (which must be of type PROBE_LOCATION). */
151 get_probe_location (const struct event_location
*location
);
153 /* Initialize the given explicit location. */
156 initialize_explicit_location (struct explicit_location
*explicit_loc
);
158 /* Create a new explicit location. If not NULL, EXPLICIT is checked for
159 validity. If invalid, an exception is thrown.
161 The return result is malloc'd and should be freed with
162 delete_event_location. */
164 extern struct event_location
*
165 new_explicit_location (const struct explicit_location
*explicit_loc
);
167 /* Return the explicit location of the given event_location
168 (which must be of type EXPLICIT_LOCATION). */
170 extern struct explicit_location
*
171 get_explicit_location (struct event_location
*location
);
173 /* A const version of the above. */
175 extern const struct explicit_location
*
176 get_explicit_location_const (const struct event_location
*location
);
178 /* Free an event location and any associated data. */
180 extern void delete_event_location (struct event_location
*location
);
182 /* Make a cleanup to free LOCATION. */
184 extern struct cleanup
*
185 make_cleanup_delete_event_location (struct event_location
*location
);
187 /* Return a copy of the given SRC location. */
189 extern struct event_location
*
190 copy_event_location (const struct event_location
*src
);
192 /* Attempt to convert the input string in *ARGP into an event_location.
193 ARGP is advanced past any processed input. Returns an event_location
194 (malloc'd) if an event location was successfully found in *ARGP,
197 This function may call error() if *ARGP looks like properly formed,
198 but invalid, input, e.g., if it is called with missing argument parameters
201 The return result must be freed with delete_event_location. */
203 extern struct event_location
*
204 string_to_event_location (char **argp
,
205 const struct language_defn
*langauge
);
207 /* Attempt to convert the input string in *ARGP into an explicit location.
208 ARGP is advanced past any processed input. Returns an event_location
209 (malloc'd) if an explicit location was successfully found in *ARGP,
212 IF !DONT_THROW, this function may call error() if *ARGP looks like
213 properly formed input, e.g., if it is called with missing argument
214 parameters or invalid options. If DONT_THROW is non-zero, this function
215 will not throw any exceptions. */
217 extern struct event_location
*
218 string_to_explicit_location (const char **argp
,
219 const struct language_defn
*langauge
,
222 /* A convenience function for testing for unset locations. */
224 extern int event_location_empty_p (const struct event_location
*location
);
226 /* Set the location's string representation. If STRING is NULL, clear
227 the string representation. */
230 set_event_location_string (struct event_location
*location
,
232 #endif /* LOCATIONS_H */