GDB (xrefs)

Classes | Functions
/tmp/gdb-8.1/gdb/macroexp.c File Reference
`#include "defs.h"`
`#include "gdb_obstack.h"`
`#include "bcache.h"`
`#include "macrotab.h"`
`#include "macroexp.h"`
`#include "c-lang.h"`

Go to the source code of this file.

## Classes
struct | macro_buffer
struct | macro_name_list

## Functions
static void | init_buffer (struct macro_buffer *b, int n)
static void | init_shared_buffer (struct macro_buffer *buf, const char *addr, int len)
static void | free_buffer (struct macro_buffer *b)
static char * | free_buffer_return_text (struct macro_buffer *b)
static void | cleanup_macro_buffer (void *untyped_buf)
static void | resize_buffer (struct macro_buffer *b, int n)
static void | appendc (struct macro_buffer *b, int c)
static void | appendmem (struct macro_buffer *b, const char *addr, int len)
int | macro_is_whitespace (int c)
int | macro_is_digit (int c)
int | macro_is_identifier_nondigit (int c)
static void | set_token (struct macro_buffer *tok, char *start, char *end)
static int | get_comment (struct macro_buffer *tok, char *p, char *end)
static int | get_identifier (struct macro_buffer *tok, char *p, char *end)
static int | get_pp_number (struct macro_buffer *tok, char *p, char *end)
static int | get_character_constant (struct macro_buffer *tok, char *p, char *end)
static int | get_string_literal (struct macro_buffer *tok, char *p, char *end)
static int | get_punctuator (struct macro_buffer *tok, char *p, char *end)
static int | get_token (struct macro_buffer *tok, struct macro_buffer *src)
static void | append_tokens_without_splicing (struct macro_buffer *dest, struct macro_buffer *src)
static void | stringify (struct macro_buffer *dest, const char *arg, int len)
char * | macro_stringify (const char *str)
static int | currently_rescanning (struct macro_name_list *list, const char *name)
static struct macro_buffer * | gather_arguments (const char *name, struct macro_buffer *src, int nargs, int *argc_p)
static void | scan (struct macro_buffer *dest, struct macro_buffer *src, struct macro_name_list *no_loop, macro_lookup_ftype *lookup_func, void *lookup_baton)
static int | find_parameter (const struct macro_buffer *tok, int is_varargs, const struct macro_buffer *va_arg_name, int argc, const char *const *argv)
static void | get_next_token_for_substitution (struct macro_buffer *replacement_list, struct macro_buffer *token, char **start, struct macro_buffer *lookahead, char **lookahead_start, int *lookahead_valid, bool *keep_going)
static void | substitute_args (struct macro_buffer *dest, struct macro_definition *def, int is_varargs, const struct macro_buffer *va_arg_name, int argc, struct macro_buffer *argv, struct macro_name_list *no_loop, macro_lookup_ftype *lookup_func, void *lookup_baton)
static int | expand (const char *id, struct macro_definition *def, struct macro_buffer *dest, struct macro_buffer *src, struct macro_name_list *no_loop, macro_lookup_ftype *lookup_func, void *lookup_baton)
static int | maybe_expand (struct macro_buffer *dest, struct macro_buffer *src_first, struct macro_buffer *src_rest, struct macro_name_list *no_loop, macro_lookup_ftype *lookup_func, void *lookup_baton)
char * | macro_expand (const char *source, macro_lookup_ftype *lookup_func, void *lookup_func_baton)
char * | macro_expand_once (const char *source, macro_lookup_ftype *lookup_func, void *lookup_func_baton)
char * | macro_expand_next (const char **lexptr, macro_lookup_ftype *lookup_func, void *lookup_baton)

## Function Documentation

## ◆ append_tokens_without_splicing()

static void append_tokens_without_splicing | ( | struct macro_buffer * | dest,
|  | struct macro_buffer * | src
| ) |  |
| static

Definition at line 588 of file macroexp.c.

References _, appendc(), appendmem(), gdb_assert, get_token(), init_shared_buffer(), internal_error(), macro_buffer::last_token, macro_buffer::len, and macro_buffer::text.

Referenced by scan(), and substitute_args().

## ◆ appendc()

static void appendc | ( | struct macro_buffer * | b,
|  | int | c
| ) |  |
| static

Definition at line 159 of file macroexp.c.

References macro_buffer::len, resize_buffer(), macro_buffer::size, and macro_buffer::text.

Referenced by append_tokens_without_splicing(), macro_expand(), macro_expand_next(), macro_stringify(), and stringify().

## ◆ appendmem()

static void appendmem | ( | struct macro_buffer * | b,
|  | const char * | addr,
|  | int | len
| ) |  |
| static

Definition at line 173 of file macroexp.c.

References macro_buffer::len, resize_buffer(), macro_buffer::size, and macro_buffer::text.

Referenced by append_tokens_without_splicing(), scan(), and substitute_args().

## ◆ cleanup_macro_buffer()

static void cleanup_macro_buffer | ( | void * | untyped_buf | ) |
| static

Definition at line 133 of file macroexp.c.

References free_buffer().

Referenced by expand(), macro_expand(), and macro_expand_next().

## ◆ currently_rescanning()

static int currently_rescanning | ( | struct macro_name_list * | list,
|  | const char * | name
| ) |  |
| static

Definition at line 741 of file macroexp.c.

References name, macro_name_list::name, and macro_name_list::next.

Referenced by maybe_expand().

## ◆ expand()

static int expand | ( | const char * | id,
|  | struct macro_definition * | def,
|  | struct macro_buffer * | dest,
|  | struct macro_buffer * | src,
|  | struct macro_name_list * | no_loop,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_baton
| ) |  |
| static

Definition at line 1257 of file macroexp.c.

References _, macro_definition::argc, gdb::argv, macro_definition::argv, cleanup_macro_buffer(), do_cleanups(), error(), free_current_contents(), gather_arguments(), init_buffer(), init_shared_buffer(), internal_error(), macro_definition::kind, macro_buffer::len, macro_function_like, macro_object_like, make_cleanup(), macro_name_list::name, macro_name_list::next, null_cleanup(), macro_definition::replacement, scan(), substitute_args(), and macro_buffer::text.

Referenced by maybe_expand().

## ◆ find_parameter()

static int find_parameter | ( | const struct macro_buffer * | tok,
|  | int | is_varargs,
|  | const struct macro_buffer * | va_arg_name,
|  | int | argc,
|  | const char *const * | argv
| ) |  |
| static

Definition at line 928 of file macroexp.c.

References gdb::argv, macro_buffer::is_identifier, macro_buffer::len, and macro_buffer::text.

Referenced by substitute_args().

## ◆ free_buffer()

static void free_buffer | ( | struct macro_buffer * | b | ) |
| static

Definition at line 112 of file macroexp.c.

References gdb_assert, macro_buffer::shared, macro_buffer::size, macro_buffer::text, and xfree().

Referenced by cleanup_macro_buffer().

## ◆ free_buffer_return_text()

static char* free_buffer_return_text | ( | struct macro_buffer * | b | ) |
| static

Definition at line 123 of file macroexp.c.

References gdb_assert, macro_buffer::shared, macro_buffer::size, and macro_buffer::text.

Referenced by macro_stringify().

## ◆ gather_arguments()

static struct macro_buffer* gather_arguments | ( | const char * | name,
|  | struct macro_buffer * | src,
|  | int | nargs,
|  | int * | argc_p
| ) |  |
| static

Definition at line 791 of file macroexp.c.

References _, discard_cleanups(), error(), free_current_contents(), get_token(), init_shared_buffer(), macro_buffer::last_token, macro_buffer::len, make_cleanup(), name, set_token(), macro_buffer::text, XNEWVEC, and XRESIZEVEC.

Referenced by expand().

## ◆ get_character_constant()

static int get_character_constant | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 331 of file macroexp.c.

References _, c_parse_escape(), error(), gdb_assert_not_reached, and set_token().

Referenced by get_token().

## ◆ get_comment()

static int get_comment | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 228 of file macroexp.c.

References _, error(), and set_token().

Referenced by get_token().

## ◆ get_identifier()

static int get_identifier | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 270 of file macroexp.c.

References macro_buffer::is_identifier, macro_is_digit(), macro_is_identifier_nondigit(), and set_token().

Referenced by get_token().

## ◆ get_next_token_for_substitution()

static void get_next_token_for_substitution | ( | struct macro_buffer * | replacement_list,
|  | struct macro_buffer * | token,
|  | char ** | start,
|  | struct macro_buffer * | lookahead,
|  | char ** | lookahead_start,
|  | int * | lookahead_valid,
|  | bool * | keep_going
| ) |  |
| static

Definition at line 953 of file macroexp.c.

References get_token(), keep_going(), and macro_buffer::text.

Referenced by substitute_args().

## ◆ get_pp_number()

static int get_pp_number | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 292 of file macroexp.c.

References macro_is_digit(), macro_is_identifier_nondigit(), and set_token().

Referenced by get_token().

## ◆ get_punctuator()

static int get_punctuator | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 442 of file macroexp.c.

References set_token().

Referenced by get_token().

## ◆ get_string_literal()

static int get_string_literal | ( | struct macro_buffer * | tok,
|  | char * | p,
|  | char * | end
| ) |  |
| static

Definition at line 392 of file macroexp.c.

References _, c_parse_escape(), error(), gdb_assert_not_reached, and set_token().

Referenced by get_token().

## ◆ get_token()

static int get_token | ( | struct macro_buffer * | tok,
|  | struct macro_buffer * | src
| ) |  |
| static

Definition at line 503 of file macroexp.c.

References gdb_assert, get_character_constant(), get_comment(), get_identifier(), get_pp_number(), get_punctuator(), get_string_literal(), macro_buffer::len, macro_is_whitespace(), set_token(), macro_buffer::shared, and macro_buffer::text.

Referenced by append_tokens_without_splicing(), gather_arguments(), get_next_token_for_substitution(), macro_expand_next(), scan(), and substitute_args().

## ◆ init_buffer()

static void init_buffer | ( | struct macro_buffer * | b,
|  | int | n
| ) |  |
| static

Definition at line 81 of file macroexp.c.

References macro_buffer::last_token, macro_buffer::len, macro_buffer::shared, macro_buffer::size, macro_buffer::text, and xmalloc().

Referenced by expand(), macro_expand(), macro_expand_next(), and macro_stringify().

## ◆ init_shared_buffer()

static void init_shared_buffer | ( | struct macro_buffer * | buf,
|  | const char * | addr,
|  | int | len
| ) |  |
| static

Definition at line 98 of file macroexp.c.

References macro_buffer::last_token, macro_buffer::len, macro_buffer::shared, macro_buffer::size, and macro_buffer::text.

Referenced by append_tokens_without_splicing(), expand(), gather_arguments(), macro_expand(), macro_expand_next(), set_token(), and substitute_args().

## ◆ macro_expand()

char* macro_expand | ( | const char * | source,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_func_baton
| ) |  |

Definition at line 1489 of file macroexp.c.

References appendc(), cleanup_macro_buffer(), discard_cleanups(), init_buffer(), init_shared_buffer(), macro_buffer::last_token, make_cleanup(), scan(), and macro_buffer::text.

Referenced by macro_expand_command().

## ◆ macro_expand_next()

char* macro_expand_next | ( | const char ** | lexptr,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_baton
| ) |  |

Definition at line 1521 of file macroexp.c.

References appendc(), cleanup_macro_buffer(), discard_cleanups(), do_cleanups(), get_token(), init_buffer(), init_shared_buffer(), macro_buffer::last_token, lexptr, make_cleanup(), maybe_expand(), and macro_buffer::text.

Referenced by lex_one_token().

## ◆ macro_expand_once()

char* macro_expand_once | ( | const char * | source,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_func_baton
| ) |  |

Definition at line 1512 of file macroexp.c.

References _, and error().

Referenced by macro_expand_once_command().

## ◆ macro_is_digit()

int macro_is_digit | ( | int | c | ) |

Definition at line 201 of file macroexp.c.

Referenced by extract_identifier(), get_identifier(), and get_pp_number().

## ◆ macro_is_identifier_nondigit()

int macro_is_identifier_nondigit | ( | int | c | ) |

Definition at line 208 of file macroexp.c.

Referenced by extract_identifier(), get_identifier(), and get_pp_number().

## ◆ macro_is_whitespace()

int macro_is_whitespace | ( | int | c | ) |

Definition at line 190 of file macroexp.c.

Referenced by get_token(), skip_ws(), and stringify().

## ◆ macro_stringify()

char* macro_stringify | ( | const char * | str | ) |

Definition at line 706 of file macroexp.c.

References appendc(), free_buffer_return_text(), init_buffer(), macro_buffer::len, and stringify().

Referenced by fixup_definition().

## ◆ maybe_expand()

static int maybe_expand | ( | struct macro_buffer * | dest,
|  | struct macro_buffer * | src_first,
|  | struct macro_buffer * | src_rest,
|  | struct macro_name_list * | no_loop,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_baton
| ) |  |
| static

Definition at line 1396 of file macroexp.c.

References currently_rescanning(), do_cleanups(), expand(), gdb_assert, macro_buffer::is_identifier, macro_buffer::len, make_cleanup(), macro_buffer::shared, macro_buffer::text, xfree(), and xmalloc().

Referenced by macro_expand_next(), and scan().

## ◆ resize_buffer()

static void resize_buffer | ( | struct macro_buffer * | b,
|  | int | n
| ) |  |
| static

Definition at line 142 of file macroexp.c.

References gdb_assert, macro_buffer::shared, macro_buffer::size, macro_buffer::text, and xrealloc().

Referenced by appendc(), and appendmem().

## ◆ scan()

static void scan | ( | struct macro_buffer * | dest,
|  | struct macro_buffer * | src,
|  | struct macro_name_list * | no_loop,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_baton
| ) |  |
| static

Definition at line 1446 of file macroexp.c.

References append_tokens_without_splicing(), appendmem(), gdb_assert, get_token(), macro_buffer::last_token, macro_buffer::len, maybe_expand(), macro_buffer::shared, and macro_buffer::text.

Referenced by attach_fields_to_type(), expand(), find_end_quote(), find_toplevel_char(), gdb_rl_find_completion_word(), gnu_write_inferior(), int_to_threadref(), macro_expand(), remove_qualifiers(), skip_quoted_chars(), substitute_args(), and threadref_to_int().

## ◆ set_token()

static void set_token | ( | struct macro_buffer * | tok,
|  | char * | start,
|  | char * | end
| ) |  |
| static

Definition at line 217 of file macroexp.c.

References init_shared_buffer(), macro_buffer::is_identifier, and macro_buffer::last_token.

Referenced by gather_arguments(), get_character_constant(), get_comment(), get_identifier(), get_pp_number(), get_punctuator(), get_string_literal(), and get_token().

## ◆ stringify()

static void stringify | ( | struct macro_buffer * | dest,
|  | const char * | arg,
|  | int | len
| ) |  |
| static

Definition at line 660 of file macroexp.c.

References appendc(), macro_buffer::last_token, macro_buffer::len, and macro_is_whitespace().

Referenced by macro_stringify(), and substitute_args().

## ◆ substitute_args()

static void substitute_args | ( | struct macro_buffer * | dest,
|  | struct macro_definition * | def,
|  | int | is_varargs,
|  | const struct macro_buffer * | va_arg_name,
|  | int | argc,
|  | struct macro_buffer * | argv,
|  | struct macro_name_list * | no_loop,
|  | macro_lookup_ftype * | lookup_func,
|  | void * | lookup_baton
| ) |  |
| static

Definition at line 989 of file macroexp.c.

References _, append_tokens_without_splicing(), appendmem(), macro_definition::argc, gdb::argv, macro_definition::argv, error(), find_parameter(), gdb_assert, get_next_token_for_substitution(), get_token(), init_shared_buffer(), keep_going(), macro_buffer::last_token, macro_buffer::len, macro_definition::replacement, scan(), stringify(), and macro_buffer::text.

Referenced by expand().