diff options
author | Pierre Muller <muller@sourceware.org> | 2010-04-05 22:43:49 +0000 |
---|---|---|
committer | Pierre Muller <muller@sourceware.org> | 2010-04-05 22:43:49 +0000 |
commit | ec8a089a3021e52b4e686dd75d84e6ef26511737 (patch) | |
tree | 7c347e89526868d1331a59624981b65f68486a4d /gdb/stabsread.c | |
parent | 2244ba2e4ab60c3d509b78893ade3a7efb6618cc (diff) | |
download | gdb-ec8a089a3021e52b4e686dd75d84e6ef26511737.zip gdb-ec8a089a3021e52b4e686dd75d84e6ef26511737.tar.gz gdb-ec8a089a3021e52b4e686dd75d84e6ef26511737.tar.bz2 |
* gdb/stabsread.c (define_symbol): Add support for char
and string constants.
* gdb/testsuite/gdb.stabs/aout.sed: Convert all backslash to double backslash
within one line, unless it is followed by a double quote.
* gdb/testsuite/gdb.stabs/hppa.sed: Idem.
* gdb/testsuite/gdb.stabs/weird.def: Add char and String constants
* gdb/testsuite/gdb.stabs/weird.exp: Check for correct parsing of
chhar and string constants.
* gdb/testsuite/gdb.stabs/xcoff.sed: Ignore escaped quote quotes
in .stabs to .stabx substitution.
Diffstat (limited to 'gdb/stabsread.c')
-rw-r--r-- | gdb/stabsread.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 71c168c..a6b8881 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -793,6 +793,75 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, SYMBOL_CLASS (sym) = LOC_CONST; } break; + + case 'c': + { + SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_char; + SYMBOL_VALUE (sym) = atoi (p); + SYMBOL_CLASS (sym) = LOC_CONST; + } + break; + + case 's': + { + struct type *range_type; + int ind = 0; + char quote = *p++; + char *startp = p; + gdb_byte *string_local = (gdb_byte *) alloca (strlen (p)); + gdb_byte *string_value; + + if (quote != '\'' && quote != '"') + { + SYMBOL_CLASS (sym) = LOC_CONST; + SYMBOL_TYPE (sym) = error_type (&p, objfile); + SYMBOL_DOMAIN (sym) = VAR_DOMAIN; + add_symbol_to_list (sym, &file_symbols); + return sym; + } + + /* Find matching quote, rejecting escaped quotes. */ + while (*p && *p != quote) + { + if (*p == '\\' && p[1] == quote) + { + string_local[ind] = (gdb_byte) quote; + ind++; + p += 2; + } + else if (*p) + { + string_local[ind] = (gdb_byte) (*p); + ind++; + p++; + } + } + if (*p != quote) + { + SYMBOL_CLASS (sym) = LOC_CONST; + SYMBOL_TYPE (sym) = error_type (&p, objfile); + SYMBOL_DOMAIN (sym) = VAR_DOMAIN; + add_symbol_to_list (sym, &file_symbols); + return sym; + } + + /* NULL terminate the string. */ + string_local[ind] = 0; + range_type = create_range_type (NULL, + objfile_type (objfile)->builtin_int, + 0, ind); + SYMBOL_TYPE (sym) = create_array_type (NULL, + objfile_type (objfile)->builtin_char, + range_type); + string_value = obstack_alloc (&objfile->objfile_obstack, ind + 1); + memcpy (string_value, string_local, ind + 1); + p++; + + SYMBOL_VALUE_BYTES (sym) = string_value; + SYMBOL_CLASS (sym) = LOC_CONST_BYTES; + } + break; + case 'e': /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value can be represented as integral. |