X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fstabsread.c;h=8ba6bb5563258bcf0bd08b90ed3ea0647684ed0f;hb=6a2c1b8790e58ce0688507b5b1f8369aa621a665;hp=d72db145f7de739c885fd82af251f8110879b2a4;hpb=2f408ecb929bd56613e94cf1e84ace4692c78257;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/stabsread.c b/gdb/stabsread.c index d72db145f7..8ba6bb5563 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1,6 +1,6 @@ /* Support routines for decoding "stabs" debugging information format. - Copyright (C) 1986-2016 Free Software Foundation, Inc. + Copyright (C) 1986-2017 Free Software Foundation, Inc. This file is part of GDB. @@ -18,10 +18,11 @@ along with this program. If not, see . */ /* Support routines for reading and decoding debugging information in - the "stabs" format. This format is used with many systems that use - the a.out object file format, as well as some systems that use - COFF or ELF where the stabs data is placed in a special section. - Avoid placing any object file format specific code in this file. */ + the "stabs" format. This format is used by some systems that use + COFF or ELF where the stabs data is placed in a special section (as + well as with many old systems that used the a.out object file + format). Avoid placing any object file format specific code in + this file. */ #include "defs.h" #include "bfd.h" @@ -84,14 +85,14 @@ struct field_info }; static void -read_one_struct_field (struct field_info *, char **, char *, +read_one_struct_field (struct field_info *, const char **, const char *, struct type *, struct objfile *); static struct type *dbx_alloc_type (int[2], struct objfile *); -static long read_huge_number (char **, int, int *, int); +static long read_huge_number (const char **, int, int *, int); -static struct type *error_type (char **, struct objfile *); +static struct type *error_type (const char **, struct objfile *); static void patch_block_stabs (struct pending *, struct pending_stabs *, @@ -99,35 +100,37 @@ patch_block_stabs (struct pending *, struct pending_stabs *, static void fix_common_block (struct symbol *, CORE_ADDR); -static int read_type_number (char **, int *); +static int read_type_number (const char **, int *); -static struct type *read_type (char **, struct objfile *); +static struct type *read_type (const char **, struct objfile *); -static struct type *read_range_type (char **, int[2], int, struct objfile *); +static struct type *read_range_type (const char **, int[2], + int, struct objfile *); -static struct type *read_sun_builtin_type (char **, int[2], struct objfile *); +static struct type *read_sun_builtin_type (const char **, + int[2], struct objfile *); -static struct type *read_sun_floating_type (char **, int[2], +static struct type *read_sun_floating_type (const char **, int[2], struct objfile *); -static struct type *read_enum_type (char **, struct type *, struct objfile *); +static struct type *read_enum_type (const char **, struct type *, struct objfile *); static struct type *rs6000_builtin_type (int, struct objfile *); static int -read_member_functions (struct field_info *, char **, struct type *, +read_member_functions (struct field_info *, const char **, struct type *, struct objfile *); static int -read_struct_fields (struct field_info *, char **, struct type *, +read_struct_fields (struct field_info *, const char **, struct type *, struct objfile *); static int -read_baseclasses (struct field_info *, char **, struct type *, +read_baseclasses (struct field_info *, const char **, struct type *, struct objfile *); static int -read_tilde_fields (struct field_info *, char **, struct type *, +read_tilde_fields (struct field_info *, const char **, struct type *, struct objfile *); static int attach_fn_fields_to_type (struct field_info *, struct type *); @@ -135,24 +138,25 @@ static int attach_fn_fields_to_type (struct field_info *, struct type *); static int attach_fields_to_type (struct field_info *, struct type *, struct objfile *); -static struct type *read_struct_type (char **, struct type *, +static struct type *read_struct_type (const char **, struct type *, enum type_code, struct objfile *); -static struct type *read_array_type (char **, struct type *, +static struct type *read_array_type (const char **, struct type *, struct objfile *); -static struct field *read_args (char **, int, struct objfile *, int *, int *); +static struct field *read_args (const char **, int, struct objfile *, + int *, int *); static void add_undefined_type (struct type *, int[2]); static int -read_cpp_abbrev (struct field_info *, char **, struct type *, +read_cpp_abbrev (struct field_info *, const char **, struct type *, struct objfile *); -static char *find_name_end (char *name); +static const char *find_name_end (const char *name); -static int process_reference (char **string); +static int process_reference (const char **string); void stabsread_clear_cache (void); @@ -380,7 +384,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs, { int ii; char *name; - char *pp; + const char *pp; struct symbol *sym; if (stabs) @@ -460,7 +464,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs, Returns 0 for success, -1 for error. */ static int -read_type_number (char **pp, int *typenums) +read_type_number (const char **pp, int *typenums) { int nbits; @@ -495,7 +499,7 @@ read_type_number (char **pp, int *typenums) struct ref_map { - char *stabs; + const char *stabs; CORE_ADDR value; struct symbol *sym; }; @@ -527,7 +531,7 @@ stabsread_clear_cache (void) find them, using their reference numbers as our index. These will be used later when we resolve references. */ void -ref_add (int refnum, struct symbol *sym, char *stabs, CORE_ADDR value) +ref_add (int refnum, struct symbol *sym, const char *stabs, CORE_ADDR value) { if (ref_count == 0) ref_chunk = 0; @@ -562,9 +566,9 @@ ref_search (int refnum) reference number. Move STRING beyond the reference id. */ static int -process_reference (char **string) +process_reference (const char **string) { - char *p; + const char *p; int refnum = 0; if (**string != '#') @@ -587,9 +591,9 @@ process_reference (char **string) definition for later use. Return the reference number. */ int -symbol_reference_defined (char **string) +symbol_reference_defined (const char **string) { - char *p = *string; + const char *p = *string; int refnum = 0; refnum = process_reference (&p); @@ -640,12 +644,12 @@ static int stab_register_index; static int stab_regparm_index; struct symbol * -define_symbol (CORE_ADDR valu, char *string, int desc, int type, +define_symbol (CORE_ADDR valu, const char *string, int desc, int type, struct objfile *objfile) { struct gdbarch *gdbarch = get_objfile_arch (objfile); struct symbol *sym; - char *p = (char *) find_name_end (string); + const char *p = find_name_end (string); int deftype; int synonym = 0; int i; @@ -975,7 +979,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, struct type *ftype = SYMBOL_TYPE (sym); int nsemi = 0; int nparams = 0; - char *p1 = p; + const char *p1 = p; /* Obtain a worst case guess for the number of arguments by counting the semicolons. */ @@ -1489,7 +1493,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, debugger will be able to read the new symbol tables. */ static struct type * -error_type (char **pp, struct objfile *objfile) +error_type (const char **pp, struct objfile *objfile) { complaint (&symfile_complaints, _("couldn't parse type; debugger out of date?")); @@ -1522,7 +1526,7 @@ error_type (char **pp, struct objfile *objfile) deciding whether to call read_type. */ static struct type * -read_type (char **pp, struct objfile *objfile) +read_type (const char **pp, struct objfile *objfile) { struct type *type = 0; struct type *type1; @@ -1594,7 +1598,7 @@ again: char *type_name; { - char *from, *to, *p, *q1, *q2; + const char *from, *p, *q1, *q2; /* Set the type code according to the following letter. */ switch ((*pp)[0]) @@ -1660,7 +1664,7 @@ again: } if (type_name == NULL) { - to = type_name = (char *) + char *to = type_name = (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1); /* Copy the name. */ @@ -1793,7 +1797,8 @@ again: case '&': /* Reference to another type */ type1 = read_type (pp, objfile); - type = make_reference_type (type1, dbx_lookup_type (typenums, objfile)); + type = make_reference_type (type1, dbx_lookup_type (typenums, objfile), + TYPE_CODE_REF); break; case 'f': /* Function returning another type */ @@ -1908,7 +1913,7 @@ again: else /* type attribute */ { - char *attr = *pp; + const char *attr = *pp; /* Skip to the semicolon. */ while (**pp != ';' && **pp != '\0') @@ -2278,8 +2283,8 @@ stabs_method_name_from_physname (const char *physname) Returns 1 for success, 0 for failure. */ static int -read_member_functions (struct field_info *fip, char **pp, struct type *type, - struct objfile *objfile) +read_member_functions (struct field_info *fip, const char **pp, + struct type *type, struct objfile *objfile) { int nfn_fields = 0; int length = 0; @@ -2294,7 +2299,7 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, struct next_fnfieldlist *new_fnlist; struct next_fnfield *new_sublist; char *main_fn_name; - char *p; + const char *p; /* Process each list until we find something that is not a member function or find the end of the functions. */ @@ -2768,10 +2773,10 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, keep parsing and it's time for error_type(). */ static int -read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type, +read_cpp_abbrev (struct field_info *fip, const char **pp, struct type *type, struct objfile *objfile) { - char *p; + const char *p; const char *name; char cpp_abbrev; struct type *context; @@ -2864,7 +2869,7 @@ read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type, } static void -read_one_struct_field (struct field_info *fip, char **pp, char *p, +read_one_struct_field (struct field_info *fip, const char **pp, const char *p, struct type *type, struct objfile *objfile) { struct gdbarch *gdbarch = get_objfile_arch (objfile); @@ -3007,10 +3012,10 @@ read_one_struct_field (struct field_info *fip, char **pp, char *p, Returns 1 for success, 0 for failure. */ static int -read_struct_fields (struct field_info *fip, char **pp, struct type *type, +read_struct_fields (struct field_info *fip, const char **pp, struct type *type, struct objfile *objfile) { - char *p; + const char *p; struct nextfield *newobj; /* We better set p right now, in case there are no fields at all... */ @@ -3105,7 +3110,7 @@ read_struct_fields (struct field_info *fip, char **pp, struct type *type, static int -read_baseclasses (struct field_info *fip, char **pp, struct type *type, +read_baseclasses (struct field_info *fip, const char **pp, struct type *type, struct objfile *objfile) { int i; @@ -3231,10 +3236,10 @@ read_baseclasses (struct field_info *fip, char **pp, struct type *type, so we can look for the vptr base class info. */ static int -read_tilde_fields (struct field_info *fip, char **pp, struct type *type, +read_tilde_fields (struct field_info *fip, const char **pp, struct type *type, struct objfile *objfile) { - char *p; + const char *p; STABS_CONTINUE (pp, objfile); @@ -3507,7 +3512,7 @@ set_length_in_type_chain (struct type *type) */ static struct type * -read_struct_type (char **pp, struct type *type, enum type_code type_code, +read_struct_type (const char **pp, struct type *type, enum type_code type_code, struct objfile *objfile) { struct cleanup *back_to; @@ -3581,7 +3586,7 @@ read_struct_type (char **pp, struct type *type, enum type_code type_code, array. */ static struct type * -read_array_type (char **pp, struct type *type, +read_array_type (const char **pp, struct type *type, struct objfile *objfile) { struct type *index_type, *element_type, *range_type; @@ -3644,11 +3649,11 @@ read_array_type (char **pp, struct type *type, Also defines the symbols that represent the values of the type. */ static struct type * -read_enum_type (char **pp, struct type *type, +read_enum_type (const char **pp, struct type *type, struct objfile *objfile) { struct gdbarch *gdbarch = get_objfile_arch (objfile); - char *p; + const char *p; char *name; long n; struct symbol *sym; @@ -3770,7 +3775,7 @@ read_enum_type (char **pp, struct type *type, FIXME. */ static struct type * -read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile) +read_sun_builtin_type (const char **pp, int typenums[2], struct objfile *objfile) { int type_bits; int nbits; @@ -3845,7 +3850,8 @@ read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile) } static struct type * -read_sun_floating_type (char **pp, int typenums[2], struct objfile *objfile) +read_sun_floating_type (const char **pp, int typenums[2], + struct objfile *objfile) { int nbits; int details; @@ -3893,9 +3899,10 @@ read_sun_floating_type (char **pp, int typenums[2], struct objfile *objfile) If encounter garbage, set *BITS to -1 and return 0. */ static long -read_huge_number (char **pp, int end, int *bits, int twos_complement_bits) +read_huge_number (const char **pp, int end, int *bits, + int twos_complement_bits) { - char *p = *pp; + const char *p = *pp; int sign = 1; int sign_bit = 0; long n = 0; @@ -3930,7 +3937,7 @@ read_huge_number (char **pp, int end, int *bits, int twos_complement_bits) negative number. */ size_t len; - char *p1 = p; + const char *p1 = p; while ((c = *p1) >= '0' && c < '8') p1++; @@ -4057,11 +4064,11 @@ read_huge_number (char **pp, int end, int *bits, int twos_complement_bits) } static struct type * -read_range_type (char **pp, int typenums[2], int type_size, +read_range_type (const char **pp, int typenums[2], int type_size, struct objfile *objfile) { struct gdbarch *gdbarch = get_objfile_arch (objfile); - char *orig_pp = *pp; + const char *orig_pp = *pp; int rangenums[2]; long n2, n3; int n2bits, n3bits; @@ -4265,7 +4272,7 @@ handle_true_range: if there is an error. */ static struct field * -read_args (char **pp, int end, struct objfile *objfile, int *nargsp, +read_args (const char **pp, int end, struct objfile *objfile, int *nargsp, int *varargsp) { /* FIXME! Remove this arbitrary limit! */ @@ -4329,7 +4336,7 @@ static char *common_block_name; to remain after this function returns. */ void -common_block_start (char *name, struct objfile *objfile) +common_block_start (const char *name, struct objfile *objfile) { if (common_block_name != NULL) { @@ -4812,10 +4819,10 @@ finish_global_stabs (struct objfile *objfile) /* Find the end of the name, delimited by a ':', but don't match ObjC symbols which look like -[Foo bar::]:bla. */ -static char * -find_name_end (char *name) +static const char * +find_name_end (const char *name) { - char *s = name; + const char *s = name; if (s[0] == '-' || *s == '+') {