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_buffergather_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

◆ appendc()

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

◆ appendmem()

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

◆ 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

◆ 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

◆ 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

◆ 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

◆ init_buffer()

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

◆ init_shared_buffer()

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

◆ macro_expand()

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

◆ macro_expand_next()

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

◆ 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

◆ 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

◆ set_token()

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

◆ stringify()

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

◆ 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