1 |
330 |
jeremybenn |
/* C language support routines for GDB, the GNU debugger.
|
2 |
|
|
|
3 |
|
|
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002, 2003,
|
4 |
|
|
2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
5 |
|
|
|
6 |
|
|
This file is part of GDB.
|
7 |
|
|
|
8 |
|
|
This program is free software; you can redistribute it and/or modify
|
9 |
|
|
it under the terms of the GNU General Public License as published by
|
10 |
|
|
the Free Software Foundation; either version 3 of the License, or
|
11 |
|
|
(at your option) any later version.
|
12 |
|
|
|
13 |
|
|
This program is distributed in the hope that it will be useful,
|
14 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
GNU General Public License for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
20 |
|
|
|
21 |
|
|
#include "defs.h"
|
22 |
|
|
#include "symtab.h"
|
23 |
|
|
#include "gdbtypes.h"
|
24 |
|
|
#include "expression.h"
|
25 |
|
|
#include "parser-defs.h"
|
26 |
|
|
#include "language.h"
|
27 |
|
|
#include "c-lang.h"
|
28 |
|
|
#include "valprint.h"
|
29 |
|
|
#include "macroscope.h"
|
30 |
|
|
#include "gdb_assert.h"
|
31 |
|
|
#include "charset.h"
|
32 |
|
|
#include "gdb_string.h"
|
33 |
|
|
#include "demangle.h"
|
34 |
|
|
#include "cp-abi.h"
|
35 |
|
|
#include "cp-support.h"
|
36 |
|
|
#include "gdb_obstack.h"
|
37 |
|
|
#include <ctype.h>
|
38 |
|
|
|
39 |
|
|
extern void _initialize_c_language (void);
|
40 |
|
|
|
41 |
|
|
/* Given a C string type, STR_TYPE, return the corresponding target
|
42 |
|
|
character set name. */
|
43 |
|
|
|
44 |
|
|
static const char *
|
45 |
|
|
charset_for_string_type (enum c_string_type str_type,
|
46 |
|
|
struct gdbarch *gdbarch)
|
47 |
|
|
{
|
48 |
|
|
switch (str_type & ~C_CHAR)
|
49 |
|
|
{
|
50 |
|
|
case C_STRING:
|
51 |
|
|
return target_charset (gdbarch);
|
52 |
|
|
case C_WIDE_STRING:
|
53 |
|
|
return target_wide_charset (gdbarch);
|
54 |
|
|
case C_STRING_16:
|
55 |
|
|
/* FIXME: UTF-16 is not always correct. */
|
56 |
|
|
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
57 |
|
|
return "UTF-16BE";
|
58 |
|
|
else
|
59 |
|
|
return "UTF-16LE";
|
60 |
|
|
case C_STRING_32:
|
61 |
|
|
/* FIXME: UTF-32 is not always correct. */
|
62 |
|
|
if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
|
63 |
|
|
return "UTF-32BE";
|
64 |
|
|
else
|
65 |
|
|
return "UTF-32LE";
|
66 |
|
|
}
|
67 |
|
|
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
|
68 |
|
|
}
|
69 |
|
|
|
70 |
|
|
/* Classify ELTTYPE according to what kind of character it is. Return
|
71 |
|
|
the enum constant representing the character type. Also set
|
72 |
|
|
*ENCODING to the name of the character set to use when converting
|
73 |
|
|
characters of this type in target BYTE_ORDER to the host character set. */
|
74 |
|
|
|
75 |
|
|
static enum c_string_type
|
76 |
|
|
classify_type (struct type *elttype, struct gdbarch *gdbarch,
|
77 |
|
|
const char **encoding)
|
78 |
|
|
{
|
79 |
|
|
enum c_string_type result;
|
80 |
|
|
|
81 |
|
|
/* We loop because ELTTYPE may be a typedef, and we want to
|
82 |
|
|
successively peel each typedef until we reach a type we
|
83 |
|
|
understand. We don't use CHECK_TYPEDEF because that will strip
|
84 |
|
|
all typedefs at once -- but in C, wchar_t is itself a typedef, so
|
85 |
|
|
that would do the wrong thing. */
|
86 |
|
|
while (elttype)
|
87 |
|
|
{
|
88 |
|
|
char *name = TYPE_NAME (elttype);
|
89 |
|
|
|
90 |
|
|
if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
|
91 |
|
|
{
|
92 |
|
|
result = C_CHAR;
|
93 |
|
|
goto done;
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
if (!strcmp (name, "wchar_t"))
|
97 |
|
|
{
|
98 |
|
|
result = C_WIDE_CHAR;
|
99 |
|
|
goto done;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
if (!strcmp (name, "char16_t"))
|
103 |
|
|
{
|
104 |
|
|
result = C_CHAR_16;
|
105 |
|
|
goto done;
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
if (!strcmp (name, "char32_t"))
|
109 |
|
|
{
|
110 |
|
|
result = C_CHAR_32;
|
111 |
|
|
goto done;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
if (TYPE_CODE (elttype) != TYPE_CODE_TYPEDEF)
|
115 |
|
|
break;
|
116 |
|
|
|
117 |
|
|
/* Call for side effects. */
|
118 |
|
|
check_typedef (elttype);
|
119 |
|
|
|
120 |
|
|
if (TYPE_TARGET_TYPE (elttype))
|
121 |
|
|
elttype = TYPE_TARGET_TYPE (elttype);
|
122 |
|
|
else
|
123 |
|
|
{
|
124 |
|
|
/* Perhaps check_typedef did not update the target type. In
|
125 |
|
|
this case, force the lookup again and hope it works out.
|
126 |
|
|
It never will for C, but it might for C++. */
|
127 |
|
|
CHECK_TYPEDEF (elttype);
|
128 |
|
|
}
|
129 |
|
|
}
|
130 |
|
|
|
131 |
|
|
/* Punt. */
|
132 |
|
|
result = C_CHAR;
|
133 |
|
|
|
134 |
|
|
done:
|
135 |
|
|
if (encoding)
|
136 |
|
|
*encoding = charset_for_string_type (result, gdbarch);
|
137 |
|
|
|
138 |
|
|
return result;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
/* Return true if print_wchar can display W without resorting to a
|
142 |
|
|
numeric escape, false otherwise. */
|
143 |
|
|
|
144 |
|
|
static int
|
145 |
|
|
wchar_printable (gdb_wchar_t w)
|
146 |
|
|
{
|
147 |
|
|
return (gdb_iswprint (w)
|
148 |
|
|
|| w == LCST ('\a') || w == LCST ('\b')
|
149 |
|
|
|| w == LCST ('\f') || w == LCST ('\n')
|
150 |
|
|
|| w == LCST ('\r') || w == LCST ('\t')
|
151 |
|
|
|| w == LCST ('\v'));
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
/* A helper function that converts the contents of STRING to wide
|
155 |
|
|
characters and then appends them to OUTPUT. */
|
156 |
|
|
|
157 |
|
|
static void
|
158 |
|
|
append_string_as_wide (const char *string, struct obstack *output)
|
159 |
|
|
{
|
160 |
|
|
for (; *string; ++string)
|
161 |
|
|
{
|
162 |
|
|
gdb_wchar_t w = gdb_btowc (*string);
|
163 |
|
|
obstack_grow (output, &w, sizeof (gdb_wchar_t));
|
164 |
|
|
}
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
/* Print a wide character W to OUTPUT. ORIG is a pointer to the
|
168 |
|
|
original (target) bytes representing the character, ORIG_LEN is the
|
169 |
|
|
number of valid bytes. WIDTH is the number of bytes in a base
|
170 |
|
|
characters of the type. OUTPUT is an obstack to which wide
|
171 |
|
|
characters are emitted. QUOTER is a (narrow) character indicating
|
172 |
|
|
the style of quotes surrounding the character to be printed.
|
173 |
|
|
NEED_ESCAPE is an in/out flag which is used to track numeric
|
174 |
|
|
escapes across calls. */
|
175 |
|
|
|
176 |
|
|
static void
|
177 |
|
|
print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
|
178 |
|
|
int width, enum bfd_endian byte_order, struct obstack *output,
|
179 |
|
|
int quoter, int *need_escapep)
|
180 |
|
|
{
|
181 |
|
|
int need_escape = *need_escapep;
|
182 |
|
|
|
183 |
|
|
*need_escapep = 0;
|
184 |
|
|
if (gdb_iswprint (w) && (!need_escape || (!gdb_iswdigit (w)
|
185 |
|
|
&& w != LCST ('8')
|
186 |
|
|
&& w != LCST ('9'))))
|
187 |
|
|
{
|
188 |
|
|
gdb_wchar_t wchar = w;
|
189 |
|
|
|
190 |
|
|
if (w == gdb_btowc (quoter) || w == LCST ('\\'))
|
191 |
|
|
obstack_grow_wstr (output, LCST ("\\"));
|
192 |
|
|
obstack_grow (output, &wchar, sizeof (gdb_wchar_t));
|
193 |
|
|
}
|
194 |
|
|
else
|
195 |
|
|
{
|
196 |
|
|
switch (w)
|
197 |
|
|
{
|
198 |
|
|
case LCST ('\a'):
|
199 |
|
|
obstack_grow_wstr (output, LCST ("\\a"));
|
200 |
|
|
break;
|
201 |
|
|
case LCST ('\b'):
|
202 |
|
|
obstack_grow_wstr (output, LCST ("\\b"));
|
203 |
|
|
break;
|
204 |
|
|
case LCST ('\f'):
|
205 |
|
|
obstack_grow_wstr (output, LCST ("\\f"));
|
206 |
|
|
break;
|
207 |
|
|
case LCST ('\n'):
|
208 |
|
|
obstack_grow_wstr (output, LCST ("\\n"));
|
209 |
|
|
break;
|
210 |
|
|
case LCST ('\r'):
|
211 |
|
|
obstack_grow_wstr (output, LCST ("\\r"));
|
212 |
|
|
break;
|
213 |
|
|
case LCST ('\t'):
|
214 |
|
|
obstack_grow_wstr (output, LCST ("\\t"));
|
215 |
|
|
break;
|
216 |
|
|
case LCST ('\v'):
|
217 |
|
|
obstack_grow_wstr (output, LCST ("\\v"));
|
218 |
|
|
break;
|
219 |
|
|
default:
|
220 |
|
|
{
|
221 |
|
|
int i;
|
222 |
|
|
|
223 |
|
|
for (i = 0; i + width <= orig_len; i += width)
|
224 |
|
|
{
|
225 |
|
|
char octal[30];
|
226 |
|
|
ULONGEST value;
|
227 |
|
|
|
228 |
|
|
value = extract_unsigned_integer (&orig[i], width, byte_order);
|
229 |
|
|
/* If the value fits in 3 octal digits, print it that
|
230 |
|
|
way. Otherwise, print it as a hex escape. */
|
231 |
|
|
if (value <= 0777)
|
232 |
|
|
sprintf (octal, "\\%.3o", (int) (value & 0777));
|
233 |
|
|
else
|
234 |
|
|
sprintf (octal, "\\x%lx", (long) value);
|
235 |
|
|
append_string_as_wide (octal, output);
|
236 |
|
|
}
|
237 |
|
|
/* If we somehow have extra bytes, print them now. */
|
238 |
|
|
while (i < orig_len)
|
239 |
|
|
{
|
240 |
|
|
char octal[5];
|
241 |
|
|
|
242 |
|
|
sprintf (octal, "\\%.3o", orig[i] & 0xff);
|
243 |
|
|
append_string_as_wide (octal, output);
|
244 |
|
|
++i;
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
*need_escapep = 1;
|
248 |
|
|
}
|
249 |
|
|
break;
|
250 |
|
|
}
|
251 |
|
|
}
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
/* Print the character C on STREAM as part of the contents of a literal
|
255 |
|
|
string whose delimiter is QUOTER. Note that that format for printing
|
256 |
|
|
characters and strings is language specific. */
|
257 |
|
|
|
258 |
|
|
void
|
259 |
|
|
c_emit_char (int c, struct type *type,
|
260 |
|
|
struct ui_file *stream, int quoter)
|
261 |
|
|
{
|
262 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
|
263 |
|
|
struct obstack wchar_buf, output;
|
264 |
|
|
struct cleanup *cleanups;
|
265 |
|
|
const char *encoding;
|
266 |
|
|
gdb_byte *buf;
|
267 |
|
|
struct wchar_iterator *iter;
|
268 |
|
|
int need_escape = 0;
|
269 |
|
|
|
270 |
|
|
classify_type (type, get_type_arch (type), &encoding);
|
271 |
|
|
|
272 |
|
|
buf = alloca (TYPE_LENGTH (type));
|
273 |
|
|
pack_long (buf, type, c);
|
274 |
|
|
|
275 |
|
|
iter = make_wchar_iterator (buf, TYPE_LENGTH (type), encoding,
|
276 |
|
|
TYPE_LENGTH (type));
|
277 |
|
|
cleanups = make_cleanup_wchar_iterator (iter);
|
278 |
|
|
|
279 |
|
|
/* This holds the printable form of the wchar_t data. */
|
280 |
|
|
obstack_init (&wchar_buf);
|
281 |
|
|
make_cleanup_obstack_free (&wchar_buf);
|
282 |
|
|
|
283 |
|
|
while (1)
|
284 |
|
|
{
|
285 |
|
|
int num_chars;
|
286 |
|
|
gdb_wchar_t *chars;
|
287 |
|
|
const gdb_byte *buf;
|
288 |
|
|
size_t buflen;
|
289 |
|
|
int print_escape = 1;
|
290 |
|
|
enum wchar_iterate_result result;
|
291 |
|
|
|
292 |
|
|
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
|
293 |
|
|
if (num_chars < 0)
|
294 |
|
|
break;
|
295 |
|
|
if (num_chars > 0)
|
296 |
|
|
{
|
297 |
|
|
/* If all characters are printable, print them. Otherwise,
|
298 |
|
|
we're going to have to print an escape sequence. We
|
299 |
|
|
check all characters because we want to print the target
|
300 |
|
|
bytes in the escape sequence, and we don't know character
|
301 |
|
|
boundaries there. */
|
302 |
|
|
int i;
|
303 |
|
|
|
304 |
|
|
print_escape = 0;
|
305 |
|
|
for (i = 0; i < num_chars; ++i)
|
306 |
|
|
if (!wchar_printable (chars[i]))
|
307 |
|
|
{
|
308 |
|
|
print_escape = 1;
|
309 |
|
|
break;
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
if (!print_escape)
|
313 |
|
|
{
|
314 |
|
|
for (i = 0; i < num_chars; ++i)
|
315 |
|
|
print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
|
316 |
|
|
byte_order, &wchar_buf, quoter, &need_escape);
|
317 |
|
|
}
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
/* This handles the NUM_CHARS == 0 case as well. */
|
321 |
|
|
if (print_escape)
|
322 |
|
|
print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), byte_order,
|
323 |
|
|
&wchar_buf, quoter, &need_escape);
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
/* The output in the host encoding. */
|
327 |
|
|
obstack_init (&output);
|
328 |
|
|
make_cleanup_obstack_free (&output);
|
329 |
|
|
|
330 |
|
|
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
331 |
|
|
obstack_base (&wchar_buf),
|
332 |
|
|
obstack_object_size (&wchar_buf),
|
333 |
|
|
1, &output, translit_char);
|
334 |
|
|
obstack_1grow (&output, '\0');
|
335 |
|
|
|
336 |
|
|
fputs_filtered (obstack_base (&output), stream);
|
337 |
|
|
|
338 |
|
|
do_cleanups (cleanups);
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
void
|
342 |
|
|
c_printchar (int c, struct type *type, struct ui_file *stream)
|
343 |
|
|
{
|
344 |
|
|
enum c_string_type str_type;
|
345 |
|
|
|
346 |
|
|
str_type = classify_type (type, get_type_arch (type), NULL);
|
347 |
|
|
switch (str_type)
|
348 |
|
|
{
|
349 |
|
|
case C_CHAR:
|
350 |
|
|
break;
|
351 |
|
|
case C_WIDE_CHAR:
|
352 |
|
|
fputc_filtered ('L', stream);
|
353 |
|
|
break;
|
354 |
|
|
case C_CHAR_16:
|
355 |
|
|
fputc_filtered ('u', stream);
|
356 |
|
|
break;
|
357 |
|
|
case C_CHAR_32:
|
358 |
|
|
fputc_filtered ('U', stream);
|
359 |
|
|
break;
|
360 |
|
|
}
|
361 |
|
|
|
362 |
|
|
fputc_filtered ('\'', stream);
|
363 |
|
|
LA_EMIT_CHAR (c, type, stream, '\'');
|
364 |
|
|
fputc_filtered ('\'', stream);
|
365 |
|
|
}
|
366 |
|
|
|
367 |
|
|
/* Print the character string STRING, printing at most LENGTH characters.
|
368 |
|
|
LENGTH is -1 if the string is nul terminated. Each character is WIDTH bytes
|
369 |
|
|
long. Printing stops early if the number hits print_max; repeat counts are
|
370 |
|
|
printed as appropriate. Print ellipses at the end if we had to stop before
|
371 |
|
|
printing LENGTH characters, or if FORCE_ELLIPSES. */
|
372 |
|
|
|
373 |
|
|
void
|
374 |
|
|
c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
|
375 |
|
|
unsigned int length, const char *user_encoding, int force_ellipses,
|
376 |
|
|
const struct value_print_options *options)
|
377 |
|
|
{
|
378 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
|
379 |
|
|
unsigned int i;
|
380 |
|
|
unsigned int things_printed = 0;
|
381 |
|
|
int in_quotes = 0;
|
382 |
|
|
int need_comma = 0;
|
383 |
|
|
int width = TYPE_LENGTH (type);
|
384 |
|
|
struct obstack wchar_buf, output;
|
385 |
|
|
struct cleanup *cleanup;
|
386 |
|
|
enum c_string_type str_type;
|
387 |
|
|
const char *type_encoding;
|
388 |
|
|
const char *encoding;
|
389 |
|
|
struct wchar_iterator *iter;
|
390 |
|
|
int finished = 0;
|
391 |
|
|
int need_escape = 0;
|
392 |
|
|
|
393 |
|
|
if (length == -1)
|
394 |
|
|
{
|
395 |
|
|
unsigned long current_char = 1;
|
396 |
|
|
|
397 |
|
|
for (i = 0; current_char; ++i)
|
398 |
|
|
{
|
399 |
|
|
QUIT;
|
400 |
|
|
current_char = extract_unsigned_integer (string + i * width,
|
401 |
|
|
width, byte_order);
|
402 |
|
|
}
|
403 |
|
|
length = i;
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
/* If the string was not truncated due to `set print elements', and
|
407 |
|
|
the last byte of it is a null, we don't print that, in traditional C
|
408 |
|
|
style. */
|
409 |
|
|
if (!force_ellipses
|
410 |
|
|
&& length > 0
|
411 |
|
|
&& (extract_unsigned_integer (string + (length - 1) * width,
|
412 |
|
|
width, byte_order) == 0))
|
413 |
|
|
length--;
|
414 |
|
|
|
415 |
|
|
str_type = (classify_type (type, get_type_arch (type), &type_encoding)
|
416 |
|
|
& ~C_CHAR);
|
417 |
|
|
switch (str_type)
|
418 |
|
|
{
|
419 |
|
|
case C_STRING:
|
420 |
|
|
break;
|
421 |
|
|
case C_WIDE_STRING:
|
422 |
|
|
fputs_filtered ("L", stream);
|
423 |
|
|
break;
|
424 |
|
|
case C_STRING_16:
|
425 |
|
|
fputs_filtered ("u", stream);
|
426 |
|
|
break;
|
427 |
|
|
case C_STRING_32:
|
428 |
|
|
fputs_filtered ("U", stream);
|
429 |
|
|
break;
|
430 |
|
|
}
|
431 |
|
|
|
432 |
|
|
encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
|
433 |
|
|
|
434 |
|
|
if (length == 0)
|
435 |
|
|
{
|
436 |
|
|
fputs_filtered ("\"\"", stream);
|
437 |
|
|
return;
|
438 |
|
|
}
|
439 |
|
|
|
440 |
|
|
/* Arrange to iterate over the characters, in wchar_t form. */
|
441 |
|
|
iter = make_wchar_iterator (string, length * width, encoding, width);
|
442 |
|
|
cleanup = make_cleanup_wchar_iterator (iter);
|
443 |
|
|
|
444 |
|
|
/* WCHAR_BUF is the obstack we use to represent the string in
|
445 |
|
|
wchar_t form. */
|
446 |
|
|
obstack_init (&wchar_buf);
|
447 |
|
|
make_cleanup_obstack_free (&wchar_buf);
|
448 |
|
|
|
449 |
|
|
while (!finished && things_printed < options->print_max)
|
450 |
|
|
{
|
451 |
|
|
int num_chars;
|
452 |
|
|
enum wchar_iterate_result result;
|
453 |
|
|
gdb_wchar_t *chars;
|
454 |
|
|
const gdb_byte *buf;
|
455 |
|
|
size_t buflen;
|
456 |
|
|
|
457 |
|
|
QUIT;
|
458 |
|
|
|
459 |
|
|
if (need_comma)
|
460 |
|
|
{
|
461 |
|
|
obstack_grow_wstr (&wchar_buf, LCST (", "));
|
462 |
|
|
need_comma = 0;
|
463 |
|
|
}
|
464 |
|
|
|
465 |
|
|
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
|
466 |
|
|
/* We only look at repetitions when we were able to convert a
|
467 |
|
|
single character in isolation. This makes the code simpler
|
468 |
|
|
and probably does the sensible thing in the majority of
|
469 |
|
|
cases. */
|
470 |
|
|
while (num_chars == 1 && things_printed < options->print_max)
|
471 |
|
|
{
|
472 |
|
|
/* Count the number of repetitions. */
|
473 |
|
|
unsigned int reps = 0;
|
474 |
|
|
gdb_wchar_t current_char = chars[0];
|
475 |
|
|
const gdb_byte *orig_buf = buf;
|
476 |
|
|
int orig_len = buflen;
|
477 |
|
|
|
478 |
|
|
if (need_comma)
|
479 |
|
|
{
|
480 |
|
|
obstack_grow_wstr (&wchar_buf, LCST (", "));
|
481 |
|
|
need_comma = 0;
|
482 |
|
|
}
|
483 |
|
|
|
484 |
|
|
while (num_chars == 1 && current_char == chars[0])
|
485 |
|
|
{
|
486 |
|
|
num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
|
487 |
|
|
++reps;
|
488 |
|
|
}
|
489 |
|
|
|
490 |
|
|
/* Emit CURRENT_CHAR according to the repetition count and
|
491 |
|
|
options. */
|
492 |
|
|
if (reps > options->repeat_count_threshold)
|
493 |
|
|
{
|
494 |
|
|
if (in_quotes)
|
495 |
|
|
{
|
496 |
|
|
if (options->inspect_it)
|
497 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\\\", "));
|
498 |
|
|
else
|
499 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\", "));
|
500 |
|
|
in_quotes = 0;
|
501 |
|
|
}
|
502 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("'"));
|
503 |
|
|
need_escape = 0;
|
504 |
|
|
print_wchar (current_char, orig_buf, orig_len, width,
|
505 |
|
|
byte_order, &wchar_buf, '\'', &need_escape);
|
506 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("'"));
|
507 |
|
|
{
|
508 |
|
|
/* Painful gyrations. */
|
509 |
|
|
int j;
|
510 |
|
|
char *s = xstrprintf (_(" <repeats %u times>"), reps);
|
511 |
|
|
|
512 |
|
|
for (j = 0; s[j]; ++j)
|
513 |
|
|
{
|
514 |
|
|
gdb_wchar_t w = gdb_btowc (s[j]);
|
515 |
|
|
obstack_grow (&wchar_buf, &w, sizeof (gdb_wchar_t));
|
516 |
|
|
}
|
517 |
|
|
xfree (s);
|
518 |
|
|
}
|
519 |
|
|
things_printed += options->repeat_count_threshold;
|
520 |
|
|
need_comma = 1;
|
521 |
|
|
}
|
522 |
|
|
else
|
523 |
|
|
{
|
524 |
|
|
/* Saw the character one or more times, but fewer than
|
525 |
|
|
the repetition threshold. */
|
526 |
|
|
if (!in_quotes)
|
527 |
|
|
{
|
528 |
|
|
if (options->inspect_it)
|
529 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
|
530 |
|
|
else
|
531 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\""));
|
532 |
|
|
in_quotes = 1;
|
533 |
|
|
need_escape = 0;
|
534 |
|
|
}
|
535 |
|
|
|
536 |
|
|
while (reps-- > 0)
|
537 |
|
|
{
|
538 |
|
|
print_wchar (current_char, orig_buf, orig_len, width,
|
539 |
|
|
byte_order, &wchar_buf, '"', &need_escape);
|
540 |
|
|
++things_printed;
|
541 |
|
|
}
|
542 |
|
|
}
|
543 |
|
|
}
|
544 |
|
|
|
545 |
|
|
/* NUM_CHARS and the other outputs from wchar_iterate are valid
|
546 |
|
|
here regardless of which branch was taken above. */
|
547 |
|
|
if (num_chars < 0)
|
548 |
|
|
{
|
549 |
|
|
/* Hit EOF. */
|
550 |
|
|
finished = 1;
|
551 |
|
|
break;
|
552 |
|
|
}
|
553 |
|
|
|
554 |
|
|
switch (result)
|
555 |
|
|
{
|
556 |
|
|
case wchar_iterate_invalid:
|
557 |
|
|
if (!in_quotes)
|
558 |
|
|
{
|
559 |
|
|
if (options->inspect_it)
|
560 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
|
561 |
|
|
else
|
562 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\""));
|
563 |
|
|
in_quotes = 1;
|
564 |
|
|
}
|
565 |
|
|
need_escape = 0;
|
566 |
|
|
print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
|
567 |
|
|
'"', &need_escape);
|
568 |
|
|
break;
|
569 |
|
|
|
570 |
|
|
case wchar_iterate_incomplete:
|
571 |
|
|
if (in_quotes)
|
572 |
|
|
{
|
573 |
|
|
if (options->inspect_it)
|
574 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\\\","));
|
575 |
|
|
else
|
576 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\","));
|
577 |
|
|
in_quotes = 0;
|
578 |
|
|
}
|
579 |
|
|
obstack_grow_wstr (&wchar_buf, LCST (" <incomplete sequence "));
|
580 |
|
|
print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
|
581 |
|
|
0, &need_escape);
|
582 |
|
|
obstack_grow_wstr (&wchar_buf, LCST (">"));
|
583 |
|
|
finished = 1;
|
584 |
|
|
break;
|
585 |
|
|
}
|
586 |
|
|
}
|
587 |
|
|
|
588 |
|
|
/* Terminate the quotes if necessary. */
|
589 |
|
|
if (in_quotes)
|
590 |
|
|
{
|
591 |
|
|
if (options->inspect_it)
|
592 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\\\""));
|
593 |
|
|
else
|
594 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("\""));
|
595 |
|
|
}
|
596 |
|
|
|
597 |
|
|
if (force_ellipses || !finished)
|
598 |
|
|
obstack_grow_wstr (&wchar_buf, LCST ("..."));
|
599 |
|
|
|
600 |
|
|
/* OUTPUT is where we collect `char's for printing. */
|
601 |
|
|
obstack_init (&output);
|
602 |
|
|
make_cleanup_obstack_free (&output);
|
603 |
|
|
|
604 |
|
|
convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
|
605 |
|
|
obstack_base (&wchar_buf),
|
606 |
|
|
obstack_object_size (&wchar_buf),
|
607 |
|
|
1, &output, translit_char);
|
608 |
|
|
obstack_1grow (&output, '\0');
|
609 |
|
|
|
610 |
|
|
fputs_filtered (obstack_base (&output), stream);
|
611 |
|
|
|
612 |
|
|
do_cleanups (cleanup);
|
613 |
|
|
}
|
614 |
|
|
|
615 |
|
|
/* Obtain a C string from the inferior storing it in a newly allocated
|
616 |
|
|
buffer in BUFFER, which should be freed by the caller. If the
|
617 |
|
|
in- and out-parameter *LENGTH is specified at -1, the string is read
|
618 |
|
|
until a null character of the appropriate width is found, otherwise
|
619 |
|
|
the string is read to the length of characters specified.
|
620 |
|
|
The size of a character is determined by the length of the target
|
621 |
|
|
type of the pointer or array. If VALUE is an array with a known
|
622 |
|
|
length, the function will not read past the end of the array.
|
623 |
|
|
On completion, *LENGTH will be set to the size of the string read in
|
624 |
|
|
characters. (If a length of -1 is specified, the length returned
|
625 |
|
|
will not include the null character). CHARSET is always set to the
|
626 |
|
|
target charset. */
|
627 |
|
|
|
628 |
|
|
void
|
629 |
|
|
c_get_string (struct value *value, gdb_byte **buffer, int *length,
|
630 |
|
|
struct type **char_type, const char **charset)
|
631 |
|
|
{
|
632 |
|
|
int err, width;
|
633 |
|
|
unsigned int fetchlimit;
|
634 |
|
|
struct type *type = check_typedef (value_type (value));
|
635 |
|
|
struct type *element_type = TYPE_TARGET_TYPE (type);
|
636 |
|
|
int req_length = *length;
|
637 |
|
|
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
|
638 |
|
|
enum c_string_type kind;
|
639 |
|
|
|
640 |
|
|
if (element_type == NULL)
|
641 |
|
|
goto error;
|
642 |
|
|
|
643 |
|
|
if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
|
644 |
|
|
{
|
645 |
|
|
/* If we know the size of the array, we can use it as a limit on the
|
646 |
|
|
number of characters to be fetched. */
|
647 |
|
|
if (TYPE_NFIELDS (type) == 1
|
648 |
|
|
&& TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_RANGE)
|
649 |
|
|
{
|
650 |
|
|
LONGEST low_bound, high_bound;
|
651 |
|
|
|
652 |
|
|
get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),
|
653 |
|
|
&low_bound, &high_bound);
|
654 |
|
|
fetchlimit = high_bound - low_bound + 1;
|
655 |
|
|
}
|
656 |
|
|
else
|
657 |
|
|
fetchlimit = UINT_MAX;
|
658 |
|
|
}
|
659 |
|
|
else if (TYPE_CODE (type) == TYPE_CODE_PTR)
|
660 |
|
|
fetchlimit = UINT_MAX;
|
661 |
|
|
else
|
662 |
|
|
/* We work only with arrays and pointers. */
|
663 |
|
|
goto error;
|
664 |
|
|
|
665 |
|
|
if (! c_textual_element_type (element_type, 0))
|
666 |
|
|
goto error;
|
667 |
|
|
kind = classify_type (element_type,
|
668 |
|
|
get_type_arch (element_type),
|
669 |
|
|
charset);
|
670 |
|
|
width = TYPE_LENGTH (element_type);
|
671 |
|
|
|
672 |
|
|
/* If the string lives in GDB's memory instead of the inferior's, then we
|
673 |
|
|
just need to copy it to BUFFER. Also, since such strings are arrays
|
674 |
|
|
with known size, FETCHLIMIT will hold the size of the array. */
|
675 |
|
|
if ((VALUE_LVAL (value) == not_lval
|
676 |
|
|
|| VALUE_LVAL (value) == lval_internalvar)
|
677 |
|
|
&& fetchlimit != UINT_MAX)
|
678 |
|
|
{
|
679 |
|
|
int i;
|
680 |
|
|
const gdb_byte *contents = value_contents (value);
|
681 |
|
|
|
682 |
|
|
/* If a length is specified, use that. */
|
683 |
|
|
if (*length >= 0)
|
684 |
|
|
i = *length;
|
685 |
|
|
else
|
686 |
|
|
/* Otherwise, look for a null character. */
|
687 |
|
|
for (i = 0; i < fetchlimit; i++)
|
688 |
|
|
if (extract_unsigned_integer (contents + i * width, width,
|
689 |
|
|
byte_order) == 0)
|
690 |
|
|
break;
|
691 |
|
|
|
692 |
|
|
/* I is now either a user-defined length, the number of non-null
|
693 |
|
|
characters, or FETCHLIMIT. */
|
694 |
|
|
*length = i * width;
|
695 |
|
|
*buffer = xmalloc (*length);
|
696 |
|
|
memcpy (*buffer, contents, *length);
|
697 |
|
|
err = 0;
|
698 |
|
|
}
|
699 |
|
|
else
|
700 |
|
|
{
|
701 |
|
|
err = read_string (value_as_address (value), *length, width, fetchlimit,
|
702 |
|
|
byte_order, buffer, length);
|
703 |
|
|
if (err)
|
704 |
|
|
{
|
705 |
|
|
xfree (*buffer);
|
706 |
|
|
error (_("Error reading string from inferior: %s"),
|
707 |
|
|
safe_strerror (err));
|
708 |
|
|
}
|
709 |
|
|
}
|
710 |
|
|
|
711 |
|
|
/* If the LENGTH is specified at -1, we want to return the string
|
712 |
|
|
length up to the terminating null character. If an actual length
|
713 |
|
|
was specified, we want to return the length of exactly what was
|
714 |
|
|
read. */
|
715 |
|
|
if (req_length == -1)
|
716 |
|
|
/* If the last character is null, subtract it from LENGTH. */
|
717 |
|
|
if (*length > 0
|
718 |
|
|
&& extract_unsigned_integer (*buffer + *length - width, width,
|
719 |
|
|
byte_order) == 0)
|
720 |
|
|
*length -= width;
|
721 |
|
|
|
722 |
|
|
/* The read_string function will return the number of bytes read.
|
723 |
|
|
If length returned from read_string was > 0, return the number of
|
724 |
|
|
characters read by dividing the number of bytes by width. */
|
725 |
|
|
if (*length != 0)
|
726 |
|
|
*length = *length / width;
|
727 |
|
|
|
728 |
|
|
*char_type = element_type;
|
729 |
|
|
|
730 |
|
|
return;
|
731 |
|
|
|
732 |
|
|
error:
|
733 |
|
|
{
|
734 |
|
|
char *type_str;
|
735 |
|
|
|
736 |
|
|
type_str = type_to_string (type);
|
737 |
|
|
if (type_str)
|
738 |
|
|
{
|
739 |
|
|
make_cleanup (xfree, type_str);
|
740 |
|
|
error (_("Trying to read string with inappropriate type `%s'."),
|
741 |
|
|
type_str);
|
742 |
|
|
}
|
743 |
|
|
else
|
744 |
|
|
error (_("Trying to read string with inappropriate type."));
|
745 |
|
|
}
|
746 |
|
|
}
|
747 |
|
|
|
748 |
|
|
|
749 |
|
|
/* Evaluating C and C++ expressions. */
|
750 |
|
|
|
751 |
|
|
/* Convert a UCN. The digits of the UCN start at P and extend no
|
752 |
|
|
farther than LIMIT. DEST_CHARSET is the name of the character set
|
753 |
|
|
into which the UCN should be converted. The results are written to
|
754 |
|
|
OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
|
755 |
|
|
Returns a pointer to just after the final digit of the UCN. */
|
756 |
|
|
|
757 |
|
|
static char *
|
758 |
|
|
convert_ucn (char *p, char *limit, const char *dest_charset,
|
759 |
|
|
struct obstack *output, int length)
|
760 |
|
|
{
|
761 |
|
|
unsigned long result = 0;
|
762 |
|
|
gdb_byte data[4];
|
763 |
|
|
int i;
|
764 |
|
|
|
765 |
|
|
for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
|
766 |
|
|
result = (result << 4) + host_hex_value (*p);
|
767 |
|
|
|
768 |
|
|
for (i = 3; i >= 0; --i)
|
769 |
|
|
{
|
770 |
|
|
data[i] = result & 0xff;
|
771 |
|
|
result >>= 8;
|
772 |
|
|
}
|
773 |
|
|
|
774 |
|
|
convert_between_encodings ("UTF-32BE", dest_charset, data, 4, 4, output,
|
775 |
|
|
translit_none);
|
776 |
|
|
|
777 |
|
|
return p;
|
778 |
|
|
}
|
779 |
|
|
|
780 |
|
|
/* Emit a character, VALUE, which was specified numerically, to
|
781 |
|
|
OUTPUT. TYPE is the target character type. */
|
782 |
|
|
|
783 |
|
|
static void
|
784 |
|
|
emit_numeric_character (struct type *type, unsigned long value,
|
785 |
|
|
struct obstack *output)
|
786 |
|
|
{
|
787 |
|
|
gdb_byte *buffer;
|
788 |
|
|
|
789 |
|
|
buffer = alloca (TYPE_LENGTH (type));
|
790 |
|
|
pack_long (buffer, type, value);
|
791 |
|
|
obstack_grow (output, buffer, TYPE_LENGTH (type));
|
792 |
|
|
}
|
793 |
|
|
|
794 |
|
|
/* Convert an octal escape sequence. TYPE is the target character
|
795 |
|
|
type. The digits of the escape sequence begin at P and extend no
|
796 |
|
|
farther than LIMIT. The result is written to OUTPUT. Returns a
|
797 |
|
|
pointer to just after the final digit of the escape sequence. */
|
798 |
|
|
|
799 |
|
|
static char *
|
800 |
|
|
convert_octal (struct type *type, char *p, char *limit, struct obstack *output)
|
801 |
|
|
{
|
802 |
|
|
int i;
|
803 |
|
|
unsigned long value = 0;
|
804 |
|
|
|
805 |
|
|
for (i = 0;
|
806 |
|
|
i < 3 && p < limit && isdigit (*p) && *p != '8' && *p != '9';
|
807 |
|
|
++i)
|
808 |
|
|
{
|
809 |
|
|
value = 8 * value + host_hex_value (*p);
|
810 |
|
|
++p;
|
811 |
|
|
}
|
812 |
|
|
|
813 |
|
|
emit_numeric_character (type, value, output);
|
814 |
|
|
|
815 |
|
|
return p;
|
816 |
|
|
}
|
817 |
|
|
|
818 |
|
|
/* Convert a hex escape sequence. TYPE is the target character type.
|
819 |
|
|
The digits of the escape sequence begin at P and extend no farther
|
820 |
|
|
than LIMIT. The result is written to OUTPUT. Returns a pointer to
|
821 |
|
|
just after the final digit of the escape sequence. */
|
822 |
|
|
|
823 |
|
|
static char *
|
824 |
|
|
convert_hex (struct type *type, char *p, char *limit, struct obstack *output)
|
825 |
|
|
{
|
826 |
|
|
unsigned long value = 0;
|
827 |
|
|
|
828 |
|
|
while (p < limit && isxdigit (*p))
|
829 |
|
|
{
|
830 |
|
|
value = 16 * value + host_hex_value (*p);
|
831 |
|
|
++p;
|
832 |
|
|
}
|
833 |
|
|
|
834 |
|
|
emit_numeric_character (type, value, output);
|
835 |
|
|
|
836 |
|
|
return p;
|
837 |
|
|
}
|
838 |
|
|
|
839 |
|
|
#define ADVANCE \
|
840 |
|
|
do { \
|
841 |
|
|
++p; \
|
842 |
|
|
if (p == limit) \
|
843 |
|
|
error (_("Malformed escape sequence")); \
|
844 |
|
|
} while (0)
|
845 |
|
|
|
846 |
|
|
/* Convert an escape sequence to a target format. TYPE is the target
|
847 |
|
|
character type to use, and DEST_CHARSET is the name of the target
|
848 |
|
|
character set. The backslash of the escape sequence is at *P, and
|
849 |
|
|
the escape sequence will not extend past LIMIT. The results are
|
850 |
|
|
written to OUTPUT. Returns a pointer to just past the final
|
851 |
|
|
character of the escape sequence. */
|
852 |
|
|
|
853 |
|
|
static char *
|
854 |
|
|
convert_escape (struct type *type, const char *dest_charset,
|
855 |
|
|
char *p, char *limit, struct obstack *output)
|
856 |
|
|
{
|
857 |
|
|
/* Skip the backslash. */
|
858 |
|
|
ADVANCE;
|
859 |
|
|
|
860 |
|
|
switch (*p)
|
861 |
|
|
{
|
862 |
|
|
case '\\':
|
863 |
|
|
obstack_1grow (output, '\\');
|
864 |
|
|
++p;
|
865 |
|
|
break;
|
866 |
|
|
|
867 |
|
|
case 'x':
|
868 |
|
|
ADVANCE;
|
869 |
|
|
if (!isxdigit (*p))
|
870 |
|
|
error (_("\\x used with no following hex digits."));
|
871 |
|
|
p = convert_hex (type, p, limit, output);
|
872 |
|
|
break;
|
873 |
|
|
|
874 |
|
|
case '0':
|
875 |
|
|
case '1':
|
876 |
|
|
case '2':
|
877 |
|
|
case '3':
|
878 |
|
|
case '4':
|
879 |
|
|
case '5':
|
880 |
|
|
case '6':
|
881 |
|
|
case '7':
|
882 |
|
|
p = convert_octal (type, p, limit, output);
|
883 |
|
|
break;
|
884 |
|
|
|
885 |
|
|
case 'u':
|
886 |
|
|
case 'U':
|
887 |
|
|
{
|
888 |
|
|
int length = *p == 'u' ? 4 : 8;
|
889 |
|
|
|
890 |
|
|
ADVANCE;
|
891 |
|
|
if (!isxdigit (*p))
|
892 |
|
|
error (_("\\u used with no following hex digits"));
|
893 |
|
|
p = convert_ucn (p, limit, dest_charset, output, length);
|
894 |
|
|
}
|
895 |
|
|
}
|
896 |
|
|
|
897 |
|
|
return p;
|
898 |
|
|
}
|
899 |
|
|
|
900 |
|
|
/* Given a single string from a (C-specific) OP_STRING list, convert
|
901 |
|
|
it to a target string, handling escape sequences specially. The
|
902 |
|
|
output is written to OUTPUT. DATA is the input string, which has
|
903 |
|
|
length LEN. DEST_CHARSET is the name of the target character set,
|
904 |
|
|
and TYPE is the type of target character to use. */
|
905 |
|
|
|
906 |
|
|
static void
|
907 |
|
|
parse_one_string (struct obstack *output, char *data, int len,
|
908 |
|
|
const char *dest_charset, struct type *type)
|
909 |
|
|
{
|
910 |
|
|
char *limit;
|
911 |
|
|
|
912 |
|
|
limit = data + len;
|
913 |
|
|
|
914 |
|
|
while (data < limit)
|
915 |
|
|
{
|
916 |
|
|
char *p = data;
|
917 |
|
|
|
918 |
|
|
/* Look for next escape, or the end of the input. */
|
919 |
|
|
while (p < limit && *p != '\\')
|
920 |
|
|
++p;
|
921 |
|
|
/* If we saw a run of characters, convert them all. */
|
922 |
|
|
if (p > data)
|
923 |
|
|
convert_between_encodings (host_charset (), dest_charset,
|
924 |
|
|
data, p - data, 1, output, translit_none);
|
925 |
|
|
/* If we saw an escape, convert it. */
|
926 |
|
|
if (p < limit)
|
927 |
|
|
p = convert_escape (type, dest_charset, p, limit, output);
|
928 |
|
|
data = p;
|
929 |
|
|
}
|
930 |
|
|
}
|
931 |
|
|
|
932 |
|
|
/* Expression evaluator for the C language family. Most operations
|
933 |
|
|
are delegated to evaluate_subexp_standard; see that function for a
|
934 |
|
|
description of the arguments. */
|
935 |
|
|
|
936 |
|
|
static struct value *
|
937 |
|
|
evaluate_subexp_c (struct type *expect_type, struct expression *exp,
|
938 |
|
|
int *pos, enum noside noside)
|
939 |
|
|
{
|
940 |
|
|
enum exp_opcode op = exp->elts[*pos].opcode;
|
941 |
|
|
|
942 |
|
|
switch (op)
|
943 |
|
|
{
|
944 |
|
|
case OP_STRING:
|
945 |
|
|
{
|
946 |
|
|
int oplen, limit;
|
947 |
|
|
struct type *type;
|
948 |
|
|
struct obstack output;
|
949 |
|
|
struct cleanup *cleanup;
|
950 |
|
|
struct value *result;
|
951 |
|
|
enum c_string_type dest_type;
|
952 |
|
|
const char *dest_charset;
|
953 |
|
|
|
954 |
|
|
obstack_init (&output);
|
955 |
|
|
cleanup = make_cleanup_obstack_free (&output);
|
956 |
|
|
|
957 |
|
|
++*pos;
|
958 |
|
|
oplen = longest_to_int (exp->elts[*pos].longconst);
|
959 |
|
|
|
960 |
|
|
++*pos;
|
961 |
|
|
limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
|
962 |
|
|
dest_type
|
963 |
|
|
= (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
|
964 |
|
|
switch (dest_type & ~C_CHAR)
|
965 |
|
|
{
|
966 |
|
|
case C_STRING:
|
967 |
|
|
type = language_string_char_type (exp->language_defn,
|
968 |
|
|
exp->gdbarch);
|
969 |
|
|
break;
|
970 |
|
|
case C_WIDE_STRING:
|
971 |
|
|
type = lookup_typename (exp->language_defn, exp->gdbarch,
|
972 |
|
|
"wchar_t", NULL, 0);
|
973 |
|
|
break;
|
974 |
|
|
case C_STRING_16:
|
975 |
|
|
type = lookup_typename (exp->language_defn, exp->gdbarch,
|
976 |
|
|
"char16_t", NULL, 0);
|
977 |
|
|
break;
|
978 |
|
|
case C_STRING_32:
|
979 |
|
|
type = lookup_typename (exp->language_defn, exp->gdbarch,
|
980 |
|
|
"char32_t", NULL, 0);
|
981 |
|
|
break;
|
982 |
|
|
default:
|
983 |
|
|
internal_error (__FILE__, __LINE__, "unhandled c_string_type");
|
984 |
|
|
}
|
985 |
|
|
|
986 |
|
|
/* Ensure TYPE_LENGTH is valid for TYPE. */
|
987 |
|
|
check_typedef (type);
|
988 |
|
|
|
989 |
|
|
dest_charset = charset_for_string_type (dest_type, exp->gdbarch);
|
990 |
|
|
|
991 |
|
|
++*pos;
|
992 |
|
|
while (*pos < limit)
|
993 |
|
|
{
|
994 |
|
|
int len;
|
995 |
|
|
|
996 |
|
|
len = longest_to_int (exp->elts[*pos].longconst);
|
997 |
|
|
|
998 |
|
|
++*pos;
|
999 |
|
|
if (noside != EVAL_SKIP)
|
1000 |
|
|
parse_one_string (&output, &exp->elts[*pos].string, len,
|
1001 |
|
|
dest_charset, type);
|
1002 |
|
|
*pos += BYTES_TO_EXP_ELEM (len);
|
1003 |
|
|
}
|
1004 |
|
|
|
1005 |
|
|
/* Skip the trailing length and opcode. */
|
1006 |
|
|
*pos += 2;
|
1007 |
|
|
|
1008 |
|
|
if (noside == EVAL_SKIP)
|
1009 |
|
|
{
|
1010 |
|
|
/* Return a dummy value of the appropriate type. */
|
1011 |
|
|
if ((dest_type & C_CHAR) != 0)
|
1012 |
|
|
result = allocate_value (type);
|
1013 |
|
|
else
|
1014 |
|
|
result = value_cstring ("", 0, type);
|
1015 |
|
|
do_cleanups (cleanup);
|
1016 |
|
|
return result;
|
1017 |
|
|
}
|
1018 |
|
|
|
1019 |
|
|
if ((dest_type & C_CHAR) != 0)
|
1020 |
|
|
{
|
1021 |
|
|
LONGEST value;
|
1022 |
|
|
|
1023 |
|
|
if (obstack_object_size (&output) != TYPE_LENGTH (type))
|
1024 |
|
|
error (_("Could not convert character constant to target character set"));
|
1025 |
|
|
value = unpack_long (type, obstack_base (&output));
|
1026 |
|
|
result = value_from_longest (type, value);
|
1027 |
|
|
}
|
1028 |
|
|
else
|
1029 |
|
|
{
|
1030 |
|
|
int i;
|
1031 |
|
|
|
1032 |
|
|
/* Write the terminating character. */
|
1033 |
|
|
for (i = 0; i < TYPE_LENGTH (type); ++i)
|
1034 |
|
|
obstack_1grow (&output, 0);
|
1035 |
|
|
result = value_cstring (obstack_base (&output),
|
1036 |
|
|
obstack_object_size (&output),
|
1037 |
|
|
type);
|
1038 |
|
|
}
|
1039 |
|
|
do_cleanups (cleanup);
|
1040 |
|
|
return result;
|
1041 |
|
|
}
|
1042 |
|
|
break;
|
1043 |
|
|
|
1044 |
|
|
default:
|
1045 |
|
|
break;
|
1046 |
|
|
}
|
1047 |
|
|
return evaluate_subexp_standard (expect_type, exp, pos, noside);
|
1048 |
|
|
}
|
1049 |
|
|
|
1050 |
|
|
|
1051 |
|
|
|
1052 |
|
|
/* Table mapping opcodes into strings for printing operators
|
1053 |
|
|
and precedences of the operators. */
|
1054 |
|
|
|
1055 |
|
|
const struct op_print c_op_print_tab[] =
|
1056 |
|
|
{
|
1057 |
|
|
{",", BINOP_COMMA, PREC_COMMA, 0},
|
1058 |
|
|
{"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
|
1059 |
|
|
{"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
|
1060 |
|
|
{"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
|
1061 |
|
|
{"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
|
1062 |
|
|
{"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
|
1063 |
|
|
{"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
|
1064 |
|
|
{"==", BINOP_EQUAL, PREC_EQUAL, 0},
|
1065 |
|
|
{"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
|
1066 |
|
|
{"<=", BINOP_LEQ, PREC_ORDER, 0},
|
1067 |
|
|
{">=", BINOP_GEQ, PREC_ORDER, 0},
|
1068 |
|
|
{">", BINOP_GTR, PREC_ORDER, 0},
|
1069 |
|
|
{"<", BINOP_LESS, PREC_ORDER, 0},
|
1070 |
|
|
{">>", BINOP_RSH, PREC_SHIFT, 0},
|
1071 |
|
|
{"<<", BINOP_LSH, PREC_SHIFT, 0},
|
1072 |
|
|
{"+", BINOP_ADD, PREC_ADD, 0},
|
1073 |
|
|
{"-", BINOP_SUB, PREC_ADD, 0},
|
1074 |
|
|
{"*", BINOP_MUL, PREC_MUL, 0},
|
1075 |
|
|
{"/", BINOP_DIV, PREC_MUL, 0},
|
1076 |
|
|
{"%", BINOP_REM, PREC_MUL, 0},
|
1077 |
|
|
{"@", BINOP_REPEAT, PREC_REPEAT, 0},
|
1078 |
|
|
{"-", UNOP_NEG, PREC_PREFIX, 0},
|
1079 |
|
|
{"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
|
1080 |
|
|
{"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
|
1081 |
|
|
{"*", UNOP_IND, PREC_PREFIX, 0},
|
1082 |
|
|
{"&", UNOP_ADDR, PREC_PREFIX, 0},
|
1083 |
|
|
{"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
|
1084 |
|
|
{"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
|
1085 |
|
|
{"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
|
1086 |
|
|
{NULL, 0, 0, 0}
|
1087 |
|
|
};
|
1088 |
|
|
|
1089 |
|
|
enum c_primitive_types {
|
1090 |
|
|
c_primitive_type_int,
|
1091 |
|
|
c_primitive_type_long,
|
1092 |
|
|
c_primitive_type_short,
|
1093 |
|
|
c_primitive_type_char,
|
1094 |
|
|
c_primitive_type_float,
|
1095 |
|
|
c_primitive_type_double,
|
1096 |
|
|
c_primitive_type_void,
|
1097 |
|
|
c_primitive_type_long_long,
|
1098 |
|
|
c_primitive_type_signed_char,
|
1099 |
|
|
c_primitive_type_unsigned_char,
|
1100 |
|
|
c_primitive_type_unsigned_short,
|
1101 |
|
|
c_primitive_type_unsigned_int,
|
1102 |
|
|
c_primitive_type_unsigned_long,
|
1103 |
|
|
c_primitive_type_unsigned_long_long,
|
1104 |
|
|
c_primitive_type_long_double,
|
1105 |
|
|
c_primitive_type_complex,
|
1106 |
|
|
c_primitive_type_double_complex,
|
1107 |
|
|
c_primitive_type_decfloat,
|
1108 |
|
|
c_primitive_type_decdouble,
|
1109 |
|
|
c_primitive_type_declong,
|
1110 |
|
|
nr_c_primitive_types
|
1111 |
|
|
};
|
1112 |
|
|
|
1113 |
|
|
void
|
1114 |
|
|
c_language_arch_info (struct gdbarch *gdbarch,
|
1115 |
|
|
struct language_arch_info *lai)
|
1116 |
|
|
{
|
1117 |
|
|
const struct builtin_type *builtin = builtin_type (gdbarch);
|
1118 |
|
|
|
1119 |
|
|
lai->string_char_type = builtin->builtin_char;
|
1120 |
|
|
lai->primitive_type_vector
|
1121 |
|
|
= GDBARCH_OBSTACK_CALLOC (gdbarch, nr_c_primitive_types + 1,
|
1122 |
|
|
struct type *);
|
1123 |
|
|
lai->primitive_type_vector [c_primitive_type_int] = builtin->builtin_int;
|
1124 |
|
|
lai->primitive_type_vector [c_primitive_type_long] = builtin->builtin_long;
|
1125 |
|
|
lai->primitive_type_vector [c_primitive_type_short] = builtin->builtin_short;
|
1126 |
|
|
lai->primitive_type_vector [c_primitive_type_char] = builtin->builtin_char;
|
1127 |
|
|
lai->primitive_type_vector [c_primitive_type_float] = builtin->builtin_float;
|
1128 |
|
|
lai->primitive_type_vector [c_primitive_type_double] = builtin->builtin_double;
|
1129 |
|
|
lai->primitive_type_vector [c_primitive_type_void] = builtin->builtin_void;
|
1130 |
|
|
lai->primitive_type_vector [c_primitive_type_long_long] = builtin->builtin_long_long;
|
1131 |
|
|
lai->primitive_type_vector [c_primitive_type_signed_char] = builtin->builtin_signed_char;
|
1132 |
|
|
lai->primitive_type_vector [c_primitive_type_unsigned_char] = builtin->builtin_unsigned_char;
|
1133 |
|
|
lai->primitive_type_vector [c_primitive_type_unsigned_short] = builtin->builtin_unsigned_short;
|
1134 |
|
|
lai->primitive_type_vector [c_primitive_type_unsigned_int] = builtin->builtin_unsigned_int;
|
1135 |
|
|
lai->primitive_type_vector [c_primitive_type_unsigned_long] = builtin->builtin_unsigned_long;
|
1136 |
|
|
lai->primitive_type_vector [c_primitive_type_unsigned_long_long] = builtin->builtin_unsigned_long_long;
|
1137 |
|
|
lai->primitive_type_vector [c_primitive_type_long_double] = builtin->builtin_long_double;
|
1138 |
|
|
lai->primitive_type_vector [c_primitive_type_complex] = builtin->builtin_complex;
|
1139 |
|
|
lai->primitive_type_vector [c_primitive_type_double_complex] = builtin->builtin_double_complex;
|
1140 |
|
|
lai->primitive_type_vector [c_primitive_type_decfloat] = builtin->builtin_decfloat;
|
1141 |
|
|
lai->primitive_type_vector [c_primitive_type_decdouble] = builtin->builtin_decdouble;
|
1142 |
|
|
lai->primitive_type_vector [c_primitive_type_declong] = builtin->builtin_declong;
|
1143 |
|
|
|
1144 |
|
|
lai->bool_type_default = builtin->builtin_int;
|
1145 |
|
|
}
|
1146 |
|
|
|
1147 |
|
|
const struct exp_descriptor exp_descriptor_c =
|
1148 |
|
|
{
|
1149 |
|
|
print_subexp_standard,
|
1150 |
|
|
operator_length_standard,
|
1151 |
|
|
operator_check_standard,
|
1152 |
|
|
op_name_standard,
|
1153 |
|
|
dump_subexp_body_standard,
|
1154 |
|
|
evaluate_subexp_c
|
1155 |
|
|
};
|
1156 |
|
|
|
1157 |
|
|
const struct language_defn c_language_defn =
|
1158 |
|
|
{
|
1159 |
|
|
"c", /* Language name */
|
1160 |
|
|
language_c,
|
1161 |
|
|
range_check_off,
|
1162 |
|
|
type_check_off,
|
1163 |
|
|
case_sensitive_on,
|
1164 |
|
|
array_row_major,
|
1165 |
|
|
macro_expansion_c,
|
1166 |
|
|
&exp_descriptor_c,
|
1167 |
|
|
c_parse,
|
1168 |
|
|
c_error,
|
1169 |
|
|
null_post_parser,
|
1170 |
|
|
c_printchar, /* Print a character constant */
|
1171 |
|
|
c_printstr, /* Function to print string constant */
|
1172 |
|
|
c_emit_char, /* Print a single char */
|
1173 |
|
|
c_print_type, /* Print a type using appropriate syntax */
|
1174 |
|
|
c_print_typedef, /* Print a typedef using appropriate syntax */
|
1175 |
|
|
c_val_print, /* Print a value using appropriate syntax */
|
1176 |
|
|
c_value_print, /* Print a top-level value */
|
1177 |
|
|
NULL, /* Language specific skip_trampoline */
|
1178 |
|
|
NULL, /* name_of_this */
|
1179 |
|
|
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
1180 |
|
|
basic_lookup_transparent_type,/* lookup_transparent_type */
|
1181 |
|
|
NULL, /* Language specific symbol demangler */
|
1182 |
|
|
NULL, /* Language specific class_name_from_physname */
|
1183 |
|
|
c_op_print_tab, /* expression operators for printing */
|
1184 |
|
|
1, /* c-style arrays */
|
1185 |
|
|
0, /* String lower bound */
|
1186 |
|
|
default_word_break_characters,
|
1187 |
|
|
default_make_symbol_completion_list,
|
1188 |
|
|
c_language_arch_info,
|
1189 |
|
|
default_print_array_index,
|
1190 |
|
|
default_pass_by_reference,
|
1191 |
|
|
c_get_string,
|
1192 |
|
|
LANG_MAGIC
|
1193 |
|
|
};
|
1194 |
|
|
|
1195 |
|
|
enum cplus_primitive_types {
|
1196 |
|
|
cplus_primitive_type_int,
|
1197 |
|
|
cplus_primitive_type_long,
|
1198 |
|
|
cplus_primitive_type_short,
|
1199 |
|
|
cplus_primitive_type_char,
|
1200 |
|
|
cplus_primitive_type_float,
|
1201 |
|
|
cplus_primitive_type_double,
|
1202 |
|
|
cplus_primitive_type_void,
|
1203 |
|
|
cplus_primitive_type_long_long,
|
1204 |
|
|
cplus_primitive_type_signed_char,
|
1205 |
|
|
cplus_primitive_type_unsigned_char,
|
1206 |
|
|
cplus_primitive_type_unsigned_short,
|
1207 |
|
|
cplus_primitive_type_unsigned_int,
|
1208 |
|
|
cplus_primitive_type_unsigned_long,
|
1209 |
|
|
cplus_primitive_type_unsigned_long_long,
|
1210 |
|
|
cplus_primitive_type_long_double,
|
1211 |
|
|
cplus_primitive_type_complex,
|
1212 |
|
|
cplus_primitive_type_double_complex,
|
1213 |
|
|
cplus_primitive_type_bool,
|
1214 |
|
|
cplus_primitive_type_decfloat,
|
1215 |
|
|
cplus_primitive_type_decdouble,
|
1216 |
|
|
cplus_primitive_type_declong,
|
1217 |
|
|
nr_cplus_primitive_types
|
1218 |
|
|
};
|
1219 |
|
|
|
1220 |
|
|
static void
|
1221 |
|
|
cplus_language_arch_info (struct gdbarch *gdbarch,
|
1222 |
|
|
struct language_arch_info *lai)
|
1223 |
|
|
{
|
1224 |
|
|
const struct builtin_type *builtin = builtin_type (gdbarch);
|
1225 |
|
|
|
1226 |
|
|
lai->string_char_type = builtin->builtin_char;
|
1227 |
|
|
lai->primitive_type_vector
|
1228 |
|
|
= GDBARCH_OBSTACK_CALLOC (gdbarch, nr_cplus_primitive_types + 1,
|
1229 |
|
|
struct type *);
|
1230 |
|
|
lai->primitive_type_vector [cplus_primitive_type_int]
|
1231 |
|
|
= builtin->builtin_int;
|
1232 |
|
|
lai->primitive_type_vector [cplus_primitive_type_long]
|
1233 |
|
|
= builtin->builtin_long;
|
1234 |
|
|
lai->primitive_type_vector [cplus_primitive_type_short]
|
1235 |
|
|
= builtin->builtin_short;
|
1236 |
|
|
lai->primitive_type_vector [cplus_primitive_type_char]
|
1237 |
|
|
= builtin->builtin_char;
|
1238 |
|
|
lai->primitive_type_vector [cplus_primitive_type_float]
|
1239 |
|
|
= builtin->builtin_float;
|
1240 |
|
|
lai->primitive_type_vector [cplus_primitive_type_double]
|
1241 |
|
|
= builtin->builtin_double;
|
1242 |
|
|
lai->primitive_type_vector [cplus_primitive_type_void]
|
1243 |
|
|
= builtin->builtin_void;
|
1244 |
|
|
lai->primitive_type_vector [cplus_primitive_type_long_long]
|
1245 |
|
|
= builtin->builtin_long_long;
|
1246 |
|
|
lai->primitive_type_vector [cplus_primitive_type_signed_char]
|
1247 |
|
|
= builtin->builtin_signed_char;
|
1248 |
|
|
lai->primitive_type_vector [cplus_primitive_type_unsigned_char]
|
1249 |
|
|
= builtin->builtin_unsigned_char;
|
1250 |
|
|
lai->primitive_type_vector [cplus_primitive_type_unsigned_short]
|
1251 |
|
|
= builtin->builtin_unsigned_short;
|
1252 |
|
|
lai->primitive_type_vector [cplus_primitive_type_unsigned_int]
|
1253 |
|
|
= builtin->builtin_unsigned_int;
|
1254 |
|
|
lai->primitive_type_vector [cplus_primitive_type_unsigned_long]
|
1255 |
|
|
= builtin->builtin_unsigned_long;
|
1256 |
|
|
lai->primitive_type_vector [cplus_primitive_type_unsigned_long_long]
|
1257 |
|
|
= builtin->builtin_unsigned_long_long;
|
1258 |
|
|
lai->primitive_type_vector [cplus_primitive_type_long_double]
|
1259 |
|
|
= builtin->builtin_long_double;
|
1260 |
|
|
lai->primitive_type_vector [cplus_primitive_type_complex]
|
1261 |
|
|
= builtin->builtin_complex;
|
1262 |
|
|
lai->primitive_type_vector [cplus_primitive_type_double_complex]
|
1263 |
|
|
= builtin->builtin_double_complex;
|
1264 |
|
|
lai->primitive_type_vector [cplus_primitive_type_bool]
|
1265 |
|
|
= builtin->builtin_bool;
|
1266 |
|
|
lai->primitive_type_vector [cplus_primitive_type_decfloat]
|
1267 |
|
|
= builtin->builtin_decfloat;
|
1268 |
|
|
lai->primitive_type_vector [cplus_primitive_type_decdouble]
|
1269 |
|
|
= builtin->builtin_decdouble;
|
1270 |
|
|
lai->primitive_type_vector [cplus_primitive_type_declong]
|
1271 |
|
|
= builtin->builtin_declong;
|
1272 |
|
|
|
1273 |
|
|
lai->bool_type_symbol = "bool";
|
1274 |
|
|
lai->bool_type_default = builtin->builtin_bool;
|
1275 |
|
|
}
|
1276 |
|
|
|
1277 |
|
|
const struct language_defn cplus_language_defn =
|
1278 |
|
|
{
|
1279 |
|
|
"c++", /* Language name */
|
1280 |
|
|
language_cplus,
|
1281 |
|
|
range_check_off,
|
1282 |
|
|
type_check_off,
|
1283 |
|
|
case_sensitive_on,
|
1284 |
|
|
array_row_major,
|
1285 |
|
|
macro_expansion_c,
|
1286 |
|
|
&exp_descriptor_c,
|
1287 |
|
|
c_parse,
|
1288 |
|
|
c_error,
|
1289 |
|
|
null_post_parser,
|
1290 |
|
|
c_printchar, /* Print a character constant */
|
1291 |
|
|
c_printstr, /* Function to print string constant */
|
1292 |
|
|
c_emit_char, /* Print a single char */
|
1293 |
|
|
c_print_type, /* Print a type using appropriate syntax */
|
1294 |
|
|
c_print_typedef, /* Print a typedef using appropriate syntax */
|
1295 |
|
|
c_val_print, /* Print a value using appropriate syntax */
|
1296 |
|
|
c_value_print, /* Print a top-level value */
|
1297 |
|
|
cplus_skip_trampoline, /* Language specific skip_trampoline */
|
1298 |
|
|
"this", /* name_of_this */
|
1299 |
|
|
cp_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
1300 |
|
|
cp_lookup_transparent_type, /* lookup_transparent_type */
|
1301 |
|
|
cplus_demangle, /* Language specific symbol demangler */
|
1302 |
|
|
cp_class_name_from_physname, /* Language specific class_name_from_physname */
|
1303 |
|
|
c_op_print_tab, /* expression operators for printing */
|
1304 |
|
|
1, /* c-style arrays */
|
1305 |
|
|
0, /* String lower bound */
|
1306 |
|
|
default_word_break_characters,
|
1307 |
|
|
default_make_symbol_completion_list,
|
1308 |
|
|
cplus_language_arch_info,
|
1309 |
|
|
default_print_array_index,
|
1310 |
|
|
cp_pass_by_reference,
|
1311 |
|
|
c_get_string,
|
1312 |
|
|
LANG_MAGIC
|
1313 |
|
|
};
|
1314 |
|
|
|
1315 |
|
|
const struct language_defn asm_language_defn =
|
1316 |
|
|
{
|
1317 |
|
|
"asm", /* Language name */
|
1318 |
|
|
language_asm,
|
1319 |
|
|
range_check_off,
|
1320 |
|
|
type_check_off,
|
1321 |
|
|
case_sensitive_on,
|
1322 |
|
|
array_row_major,
|
1323 |
|
|
macro_expansion_c,
|
1324 |
|
|
&exp_descriptor_c,
|
1325 |
|
|
c_parse,
|
1326 |
|
|
c_error,
|
1327 |
|
|
null_post_parser,
|
1328 |
|
|
c_printchar, /* Print a character constant */
|
1329 |
|
|
c_printstr, /* Function to print string constant */
|
1330 |
|
|
c_emit_char, /* Print a single char */
|
1331 |
|
|
c_print_type, /* Print a type using appropriate syntax */
|
1332 |
|
|
c_print_typedef, /* Print a typedef using appropriate syntax */
|
1333 |
|
|
c_val_print, /* Print a value using appropriate syntax */
|
1334 |
|
|
c_value_print, /* Print a top-level value */
|
1335 |
|
|
NULL, /* Language specific skip_trampoline */
|
1336 |
|
|
NULL, /* name_of_this */
|
1337 |
|
|
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
1338 |
|
|
basic_lookup_transparent_type,/* lookup_transparent_type */
|
1339 |
|
|
NULL, /* Language specific symbol demangler */
|
1340 |
|
|
NULL, /* Language specific class_name_from_physname */
|
1341 |
|
|
c_op_print_tab, /* expression operators for printing */
|
1342 |
|
|
1, /* c-style arrays */
|
1343 |
|
|
0, /* String lower bound */
|
1344 |
|
|
default_word_break_characters,
|
1345 |
|
|
default_make_symbol_completion_list,
|
1346 |
|
|
c_language_arch_info, /* FIXME: la_language_arch_info. */
|
1347 |
|
|
default_print_array_index,
|
1348 |
|
|
default_pass_by_reference,
|
1349 |
|
|
c_get_string,
|
1350 |
|
|
LANG_MAGIC
|
1351 |
|
|
};
|
1352 |
|
|
|
1353 |
|
|
/* The following language_defn does not represent a real language.
|
1354 |
|
|
It just provides a minimal support a-la-C that should allow users
|
1355 |
|
|
to do some simple operations when debugging applications that use
|
1356 |
|
|
a language currently not supported by GDB. */
|
1357 |
|
|
|
1358 |
|
|
const struct language_defn minimal_language_defn =
|
1359 |
|
|
{
|
1360 |
|
|
"minimal", /* Language name */
|
1361 |
|
|
language_minimal,
|
1362 |
|
|
range_check_off,
|
1363 |
|
|
type_check_off,
|
1364 |
|
|
case_sensitive_on,
|
1365 |
|
|
array_row_major,
|
1366 |
|
|
macro_expansion_c,
|
1367 |
|
|
&exp_descriptor_c,
|
1368 |
|
|
c_parse,
|
1369 |
|
|
c_error,
|
1370 |
|
|
null_post_parser,
|
1371 |
|
|
c_printchar, /* Print a character constant */
|
1372 |
|
|
c_printstr, /* Function to print string constant */
|
1373 |
|
|
c_emit_char, /* Print a single char */
|
1374 |
|
|
c_print_type, /* Print a type using appropriate syntax */
|
1375 |
|
|
c_print_typedef, /* Print a typedef using appropriate syntax */
|
1376 |
|
|
c_val_print, /* Print a value using appropriate syntax */
|
1377 |
|
|
c_value_print, /* Print a top-level value */
|
1378 |
|
|
NULL, /* Language specific skip_trampoline */
|
1379 |
|
|
NULL, /* name_of_this */
|
1380 |
|
|
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
1381 |
|
|
basic_lookup_transparent_type,/* lookup_transparent_type */
|
1382 |
|
|
NULL, /* Language specific symbol demangler */
|
1383 |
|
|
NULL, /* Language specific class_name_from_physname */
|
1384 |
|
|
c_op_print_tab, /* expression operators for printing */
|
1385 |
|
|
1, /* c-style arrays */
|
1386 |
|
|
0, /* String lower bound */
|
1387 |
|
|
default_word_break_characters,
|
1388 |
|
|
default_make_symbol_completion_list,
|
1389 |
|
|
c_language_arch_info,
|
1390 |
|
|
default_print_array_index,
|
1391 |
|
|
default_pass_by_reference,
|
1392 |
|
|
c_get_string,
|
1393 |
|
|
LANG_MAGIC
|
1394 |
|
|
};
|
1395 |
|
|
|
1396 |
|
|
void
|
1397 |
|
|
_initialize_c_language (void)
|
1398 |
|
|
{
|
1399 |
|
|
add_language (&c_language_defn);
|
1400 |
|
|
add_language (&cplus_language_defn);
|
1401 |
|
|
add_language (&asm_language_defn);
|
1402 |
|
|
add_language (&minimal_language_defn);
|
1403 |
|
|
}
|