OLD | NEW |
1 /* Interface to C preprocessor macro tables for GDB. | 1 /* Interface to C preprocessor macro tables for GDB. |
2 Copyright (C) 2002, 2007-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2002, 2007-2012 Free Software Foundation, Inc. |
3 Contributed by Red Hat, Inc. | 3 Contributed by Red Hat, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 the same structure we created last time. | 205 the same structure we created last time. |
206 | 206 |
207 The first line of the source file has a line number of 1, not 0. | 207 The first line of the source file has a line number of 1, not 0. |
208 | 208 |
209 The macro table makes its own copy of INCLUDED; the caller is | 209 The macro table makes its own copy of INCLUDED; the caller is |
210 responsible for freeing INCLUDED when it is no longer needed. */ | 210 responsible for freeing INCLUDED when it is no longer needed. */ |
211 struct macro_source_file *macro_include (struct macro_source_file *source, | 211 struct macro_source_file *macro_include (struct macro_source_file *source, |
212 int line, | 212 int line, |
213 const char *included); | 213 const char *included); |
214 | 214 |
| 215 /* Define any special macros, like __FILE__ or __LINE__. This should |
| 216 be called once, on the main source file. */ |
| 217 |
| 218 void macro_define_special (struct macro_table *table); |
215 | 219 |
216 /* Find any source file structure for a file named NAME, either | 220 /* Find any source file structure for a file named NAME, either |
217 included into SOURCE, or SOURCE itself. Return zero if we have | 221 included into SOURCE, or SOURCE itself. Return zero if we have |
218 none. NAME is only the final portion of the filename, not the full | 222 none. NAME is only the final portion of the filename, not the full |
219 path. e.g., `stdio.h', not `/usr/include/stdio.h'. If NAME | 223 path. e.g., `stdio.h', not `/usr/include/stdio.h'. If NAME |
220 appears more than once in the inclusion tree, return the | 224 appears more than once in the inclusion tree, return the |
221 least-nested inclusion --- the one closest to the main source file. */ | 225 least-nested inclusion --- the one closest to the main source file. */ |
222 struct macro_source_file *(macro_lookup_inclusion | 226 struct macro_source_file *(macro_lookup_inclusion |
223 (struct macro_source_file *source, | 227 (struct macro_source_file *source, |
224 const char *name)); | 228 const char *name)); |
(...skipping 29 matching lines...) Expand all Loading... |
254 void macro_undef (struct macro_source_file *source, int line, | 258 void macro_undef (struct macro_source_file *source, int line, |
255 const char *name); | 259 const char *name); |
256 | 260 |
257 /* Different kinds of macro definitions. */ | 261 /* Different kinds of macro definitions. */ |
258 enum macro_kind | 262 enum macro_kind |
259 { | 263 { |
260 macro_object_like, | 264 macro_object_like, |
261 macro_function_like | 265 macro_function_like |
262 }; | 266 }; |
263 | 267 |
| 268 /* Different kinds of special macros. */ |
| 269 |
| 270 enum macro_special_kind |
| 271 { |
| 272 /* Ordinary. */ |
| 273 macro_ordinary, |
| 274 /* The special macro __FILE__. */ |
| 275 macro_FILE, |
| 276 /* The special macro __LINE__. */ |
| 277 macro_LINE |
| 278 }; |
264 | 279 |
265 /* A preprocessor symbol definition. */ | 280 /* A preprocessor symbol definition. */ |
266 struct macro_definition | 281 struct macro_definition |
267 { | 282 { |
268 /* The table this definition lives in. */ | 283 /* The table this definition lives in. */ |
269 struct macro_table *table; | 284 struct macro_table *table; |
270 | 285 |
271 /* What kind of macro it is. */ | 286 /* What kind of macro it is. */ |
272 ENUM_BITFIELD (macro_kind) kind : 1; | 287 ENUM_BITFIELD (macro_kind) kind : 1; |
273 | 288 |
274 /* If `kind' is `macro_function_like', the number of arguments it | 289 /* If `kind' is `macro_function_like', the number of arguments it |
275 takes, and their names. The names, and the array of pointers to | 290 takes, and their names. The names, and the array of pointers to |
276 them, are in the table's bcache, if it has one. */ | 291 them, are in the table's bcache, if it has one. If `kind' is |
277 int argc : 31; | 292 `macro_object_like', then this is actually a `macro_special_kind' |
| 293 describing the macro. */ |
| 294 int argc : 30; |
278 const char * const *argv; | 295 const char * const *argv; |
279 | 296 |
280 /* The replacement string (body) of the macro. This is in the | 297 /* The replacement string (body) of the macro. For ordinary macros, |
281 table's bcache, if it has one. */ | 298 this is in the table's bcache, if it has one. For special macros |
| 299 like __FILE__, this value is only valid until the next use of any |
| 300 special macro definition; that is, it is reset each time any |
| 301 special macro is looked up or iterated over. */ |
282 const char *replacement; | 302 const char *replacement; |
283 }; | 303 }; |
284 | 304 |
285 | 305 |
286 /* Return a pointer to the macro definition for NAME in scope at line | 306 /* Return a pointer to the macro definition for NAME in scope at line |
287 number LINE of SOURCE. If LINE is -1, return the definition in | 307 number LINE of SOURCE. If LINE is -1, return the definition in |
288 effect at the end of the file. The macro table owns the structure; | 308 effect at the end of the file. The macro table owns the structure; |
289 the caller need not free it. Return zero if NAME is not #defined | 309 the caller need not free it. Return zero if NAME is not #defined |
290 at that point. */ | 310 at that point. */ |
291 struct macro_definition *(macro_lookup_definition | 311 struct macro_definition *(macro_lookup_definition |
(...skipping 30 matching lines...) Expand all Loading... |
322 | 342 |
323 /* Call the function FN for each macro that is visible in a given | 343 /* Call the function FN for each macro that is visible in a given |
324 scope. The scope is represented by FILE and LINE. USER_DATA is | 344 scope. The scope is represented by FILE and LINE. USER_DATA is |
325 passed, untranslated, to FN. */ | 345 passed, untranslated, to FN. */ |
326 void macro_for_each_in_scope (struct macro_source_file *file, int line, | 346 void macro_for_each_in_scope (struct macro_source_file *file, int line, |
327 macro_callback_fn fn, | 347 macro_callback_fn fn, |
328 void *user_data); | 348 void *user_data); |
329 | 349 |
330 | 350 |
331 #endif /* MACROTAB_H */ | 351 #endif /* MACROTAB_H */ |
OLD | NEW |