1 http://sourceware.org/gdb/wiki/ProjectArcher
2 http://sourceware.org/gdb/wiki/ArcherBranchManagement
5 commit e734ed95d296a3342d4147873c4641cea6c4d7fe
7 branch `archer' - the merge of branches:
8 archer-jankratochvil-merge-expr
9 archer-keiths-expr-cumulative
10 (archer-swagiaal-using-directive)
11 archer-jankratochvil-misc
12 archer-jankratochvil-python
13 archer-jankratochvil-type-refcount
15 archer-jankratochvil-vla
16 archer-jankratochvil-type-refcount
17 archer-pmuldoon-exception-rewind-master
18 archer-sergio-catch-syscall
20 archer-tromey-delayed-symfile
23 diff --git a/bfd/po/es.po b/bfd/po/es.po
24 index 9f2ec21..e4410d7 100644
28 -# Mensajes en español para bfd 2.17.90.
29 -# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
30 -# Cristian Othón Martínez Vera <cfuga@itam.mx>, 2002, 2003, 2004, 2005, 2006, 2007
31 +# Mensajes en español para bfd 2.18.90.
32 +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
33 +# This file is distributed under the same license as the binutils package.
34 +# Cristian Othón Martínez Vera <cfuga@itam.mx>, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
38 -"Project-Id-Version: bfd 2.17.90\n"
39 -"Report-Msgid-Bugs-To: \n"
40 -"POT-Creation-Date: 2007-08-06 16:21-0400\n"
41 -"PO-Revision-Date: 2007-09-08 08:57-0500\n"
42 +"Project-Id-Version: bfd 2.18.90\n"
43 +"Report-Msgid-Bugs-To: bug-binutils@gnu.org\n"
44 +"POT-Creation-Date: 2008-09-09 15:56+0930\n"
45 +"PO-Revision-Date: 2009-03-03 22:20-0600\n"
46 "Last-Translator: Cristian Othón Martínez Vera <cfuga@itam.mx>\n"
47 "Language-Team: Spanish <es@li.org>\n"
49 @@ -31,143 +32,143 @@ msgstr "%B: Tipo de reubicaci
50 msgid "%B: Bad relocation record imported: %d"
51 msgstr "%B: Registro de reubicación importado erróneo: %d"
53 -#: aoutx.h:1268 aoutx.h:1602
54 +#: aoutx.h:1268 aoutx.h:1604
56 msgid "%s: can not represent section `%s' in a.out object file format"
57 msgstr "%s: no se puede representar la sección `%s' en el fichero objeto de formato a.out"
62 msgid "%s: can not represent section for symbol `%s' in a.out object file format"
63 msgstr "%s: no se puede representar la sección para el símbolo `%s' en el fichero objeto de formato a.out"
68 msgstr "*desconocido*"
70 -#: aoutx.h:3987 aoutx.h:4313
71 +#: aoutx.h:3989 aoutx.h:4315
72 msgid "%P: %B: unexpected relocation type\n"
73 msgstr "%P: %B: tipo de reubicación inesperado\n"
78 msgid "%s: relocatable link from %s to %s not supported"
79 msgstr "%s: no se admite el enlace reubicable de %s a %s"
83 msgid "Warning: writing archive was slow: rewriting timestamp\n"
84 msgstr "Aviso: la escritura del fichero fue lenta: se reescribe la marca de tiempo\n"
86 # ¡Uff! Si utilizáramos file=archivo, esta traducción sería imposible. cfuga
89 msgid "Reading archive file mod timestamp"
90 msgstr "Se lee el archivo de la modificación de marca de tiempo del fichero"
94 msgid "Writing updated armap timestamp"
95 msgstr "Se escribe la marca de tiempo actualizada de armap"
100 msgstr "No hay error"
104 msgid "System call error"
105 msgstr "Error en la llamada al sistema"
109 msgid "Invalid bfd target"
110 msgstr "Objetivo bfd inválido"
114 msgid "File in wrong format"
115 msgstr "Fichero en formato erróneo"
119 msgid "Archive object file in wrong format"
120 msgstr "Archivo de ficheros objeto en formato erróneo"
124 msgid "Invalid operation"
125 msgstr "Operación inválida"
129 msgid "Memory exhausted"
130 msgstr "Memoria agotada"
135 msgstr "No hay símbolos"
139 msgid "Archive has no index; run ranlib to add one"
140 msgstr "El archivo no tiene índice; ejecute ranlib para agregar uno"
144 msgid "No more archived files"
145 msgstr "No hay más ficheros archivados"
149 msgid "Malformed archive"
150 msgstr "Archivo malformado"
154 msgid "File format not recognized"
155 msgstr "No se reconoce el formato del fichero"
159 msgid "File format is ambiguous"
160 msgstr "El formato del fichero es ambiguo"
164 msgid "Section has no contents"
165 msgstr "La sección no tiene contenidos"
169 msgid "Nonrepresentable section on output"
170 msgstr "Sección no representable en la salida"
174 msgid "Symbol needs debug section which does not exist"
175 msgstr "Un símbolo requiere de una sección de depuración, la cual no existe"
180 msgstr "Valor erróneo"
184 msgid "File truncated"
185 msgstr "Fichero truncado"
190 msgstr "Fichero demasiado grande"
195 msgid "Error reading %s: %s"
196 msgstr "Error al leer %s: %s"
200 msgid "#<Invalid error code>"
201 msgstr "#<Código de error inválido>"
206 msgid "BFD %s assertion fail %s:%d"
207 msgstr "falló la aseveración BFD %s %s:%d"
212 msgid "BFD %s internal error, aborting at %s line %d in %s\n"
213 msgstr "error interno de BFD %s, se aborta en %s línea %d en %s\n"
218 msgid "BFD %s internal error, aborting at %s line %d\n"
219 msgstr "error interno de BFD %s, se aborta en %s línea %d\n"
223 msgid "Please report this bug.\n"
224 msgstr "Por favor reporte este bicho.\n"
226 @@ -186,14 +187,10 @@ msgstr "no se mapea: no se estableci
227 msgid "Warning: Writing section `%s' to huge (ie negative) file offset 0x%lx."
228 msgstr "Aviso: Se escribe la sección `%s' a un desplazamiento de fichero grande (pe negativo) 0x%lx."
232 msgid "reopening %B: %s\n"
233 msgstr "se reabre %B: %s\n"
235 -#: coff64-rs6000.c:2126 coff-rs6000.c:3624
236 -msgid "%B: symbol `%s' has unrecognized smclas %d"
237 -msgstr "%B: el símbolo `%s' tiene smclas %d que no se reconoce"
241 "%B: Cannot handle compressed Alpha binaries.\n"
242 @@ -206,7 +203,7 @@ msgstr ""
243 msgid "%B: unknown/unsupported relocation type %d"
244 msgstr "%B: tipo de reubicación %d desconocida/no admitida"
246 -#: coff-alpha.c:899 coff-alpha.c:936 coff-alpha.c:2024 coff-mips.c:1002
247 +#: coff-alpha.c:899 coff-alpha.c:936 coff-alpha.c:2024 coff-mips.c:1003
248 msgid "GP relative relocation used when GP not defined"
249 msgstr "se usó una reubicación GP relativa cuando GP no estaba definido"
251 @@ -222,22 +219,22 @@ msgstr "%B: tipo de reubicaci
252 msgid "%B: unsupported relocation: ALPHA_R_GPRELLOW"
253 msgstr "%B: tipo de reubicación no admitida: ALPHA_R_GPRELLOW"
255 -#: coff-alpha.c:1574 elf32-m32r.c:2487 elf64-alpha.c:3953 elf64-alpha.c:4106
256 -#: elf32-ia64.c:4675 elf64-ia64.c:4675
257 +#: coff-alpha.c:1574 elf32-m32r.c:2487 elf64-alpha.c:3970 elf64-alpha.c:4125
258 +#: elf32-ia64.c:4465 elf64-ia64.c:4465
259 msgid "%B: unknown relocation type %d"
260 msgstr "%B: tipo de reubicación %d desconocido"
265 msgid "%B: unable to find THUMB glue '%s' for `%s'"
266 msgstr "%B: no se puede encontrar el pegamento THUMB '%s' para `%s'"
271 msgid "%B: unable to find ARM glue '%s' for `%s'"
272 msgstr "%B: no se puede encontrar el pegamento ARM '%s' para `%s'"
274 -#: coff-arm.c:1367 elf32-arm.c:4167
275 +#: coff-arm.c:1370 elf32-arm.c:5453
278 "%B(%s): warning: interworking not enabled.\n"
279 @@ -246,7 +243,7 @@ msgstr ""
280 "%B(%s): aviso: no se activó la interoperabilidad.\n"
281 " primer suceso: %B: llamada arm a thumb"
287 "%B(%s): warning: interworking not enabled.\n"
288 @@ -257,188 +254,118 @@ msgstr ""
289 " primer suceso: %B: llamada arm a thumb\n"
290 " considere reenlazar con --support-old-code activado"
292 -#: coff-arm.c:1750 cofflink.c:3018 coff-tic80.c:695
293 +#: coff-arm.c:1755 coff-tic80.c:695 cofflink.c:3018
294 msgid "%B: bad reloc address 0x%lx in section `%A'"
295 msgstr "%B: dirección de reubicación 0x%lx errónea en la sección `%A'"
299 msgid "%B: illegal symbol index in reloc: %d"
300 msgstr "%B: índice de símbolos ilegal en la reubicación: %d"
305 msgid "ERROR: %B is compiled for APCS-%d, whereas %B is compiled for APCS-%d"
306 msgstr "ERROR: %B está compilado para APCS-%d, mientras que %B está compilado para APCS-%d"
308 -#: coff-arm.c:2222 elf32-arm.c:7072
309 +#: coff-arm.c:2227 elf32-arm.c:8563
311 msgid "ERROR: %B passes floats in float registers, whereas %B passes them in integer registers"
312 msgstr "ERROR: %B pasa números de coma flotante en registros de coma flotante, mientras que %B los pasa en registros enteros"
314 -#: coff-arm.c:2225 elf32-arm.c:7076
315 +#: coff-arm.c:2230 elf32-arm.c:8567
317 msgid "ERROR: %B passes floats in integer registers, whereas %B passes them in float registers"
318 msgstr "ERROR: %B pasa números de coma flotante en registros enteros, mientras que %B los pasa en registros de coma flotante"
323 msgid "ERROR: %B is compiled as position independent code, whereas target %B is absolute position"
324 msgstr "ERROR: %B está compilado como código independiente de posición, mientras que el objetivo %B es de posición absoluta"
329 msgid "ERROR: %B is compiled as absolute position code, whereas target %B is position independent"
330 msgstr "ERROR: %B está compilado como código de posición absoluta, mientras que el objetivo %B es independiente de posición"
332 -#: coff-arm.c:2270 elf32-arm.c:7141
333 +#: coff-arm.c:2275 elf32-arm.c:8632
335 msgid "Warning: %B supports interworking, whereas %B does not"
336 msgstr "Aviso: %B admite interoperabilidad, mientras que %B no"
338 -#: coff-arm.c:2273 elf32-arm.c:7147
339 +#: coff-arm.c:2278 elf32-arm.c:8638
341 msgid "Warning: %B does not support interworking, whereas %B does"
342 msgstr "Aviso: %B no admite interoperabilidad, mientras que %B sí"
347 msgid "private flags = %x:"
348 msgstr "opciones privadas = %x:"
350 -#: coff-arm.c:2305 elf32-arm.c:7198
351 +#: coff-arm.c:2310 elf32-arm.c:8689
353 msgid " [floats passed in float registers]"
354 msgstr "[números de coma flotante pasados en registros de coma flotante]"
359 msgid " [floats passed in integer registers]"
360 msgstr "[números de coma flotante pasados en registros enteros]"
362 -#: coff-arm.c:2310 elf32-arm.c:7201
363 +#: coff-arm.c:2315 elf32-arm.c:8692
365 msgid " [position independent]"
366 msgstr "[independiente de posición]"
371 msgid " [absolute position]"
372 msgstr "[posición absoluta]"
377 msgid " [interworking flag not initialised]"
378 msgstr "[no se inicializó la opción de interoperabilidad]"
383 msgid " [interworking supported]"
384 msgstr "[admite interoperabilidad]"
389 msgid " [interworking not supported]"
390 msgstr "[no admite interoperabilidad]"
392 -#: coff-arm.c:2366 elf32-arm.c:6578
393 +#: coff-arm.c:2371 elf32-arm.c:8050
395 msgid "Warning: Not setting interworking flag of %B since it has already been specified as non-interworking"
396 msgstr "Aviso: No se establece la opción de interoperabilidad de %B ya que se había especificado con anterioridad como no interoperable"
398 -#: coff-arm.c:2370 elf32-arm.c:6582
399 +#: coff-arm.c:2375 elf32-arm.c:8054
401 msgid "Warning: Clearing the interworking flag of %B due to outside request"
402 msgstr "Aviso: Se limpia la opción de interoperabilidad de %B debido a una petición externa"
405 -msgid "%B: warning: COMDAT symbol '%s' does not match section name '%s'"
406 -msgstr "%B: aviso: el símbolo COMDAT '%s' no coincide con el nombre de sección '%s'"
408 -#. Generate a warning message rather using the 'unhandled'
409 -#. variable as this will allow some .sys files generate by
410 -#. other toolchains to be processed. See bugzilla issue 196.
412 -msgid "%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"
413 -msgstr "%B: Aviso: Se descarta la opción de sección IMAGE_SCN_MEM_NOT_PAGED en la sección %s"
416 -msgid "%B (%s): Section flag %s (0x%x) ignored"
417 -msgstr "%B (%s): Se descarta la opción de sección %s (0x%x)"
421 -msgid "Unrecognized TI COFF target id '0x%x'"
422 -msgstr "No se reconoce el id de objetivo TI COFF '0x%x'"
425 -msgid "%B: reloc against a non-existant symbol index: %ld"
426 -msgstr "%B: reubicación contra un índice símbolo que no existe: %ld"
429 -msgid "%B: warning: line number table read failed"
430 -msgstr "%B: aviso: falló la lectura de tabla de números de línea"
433 -msgid "%B: warning: illegal symbol index %ld in line numbers"
434 -msgstr "%B: aviso: índice de símbolos %ld ilegal en los números de línea"
437 -msgid "%B: warning: duplicate line number information for `%s'"
438 -msgstr "%B: aviso: información duplicada de números de línea para `%s'"
441 -msgid "%B: Unrecognized storage class %d for %s symbol `%s'"
442 -msgstr "%B: Clase de almacenamiento %d no reconocida para %s símbolo `%s'"
445 -msgid "warning: %B: local symbol `%s' has no section"
446 -msgstr "aviso: %B: el símbolo local `%s' no tiene sección"
448 -#: coffcode.h:4966 coff-i860.c:601 coff-tic54x.c:393
449 -msgid "%B: warning: illegal symbol index %ld in relocs"
450 -msgstr "%B: aviso: índice de símbolos %ld ilegal en reubicaciones"
453 -msgid "%B: illegal relocation type %d at address 0x%lx"
454 -msgstr "%B: tipo de reubicación %d ilegal en la dirección 0x%lx"
457 -msgid "%B: bad string table size %lu"
458 -msgstr "%B: tamaño de tabla de cadenas %lu erróneo"
462 msgid "cannot handle R_MEM_INDIRECT reloc when using %s output"
463 msgstr "no se puede manejar la reubicación R_MEM_INDIRECT cuando se utiliza la salida %s"
468 msgid "Relocation `%s' not yet implemented\n"
469 msgstr "La reubicación `%s' aún no está implementada\n"
471 -#: coff-i960.c:138 coff-i960.c:501
472 +#: coff-i860.c:605 coff-tic54x.c:398 coffcode.h:4975
473 +msgid "%B: warning: illegal symbol index %ld in relocs"
474 +msgstr "%B: aviso: índice de símbolos %ld ilegal en reubicaciones"
476 +#: coff-i960.c:143 coff-i960.c:506
477 msgid "uncertain calling convention for non-COFF symbol"
478 msgstr "convención de llamada incierta para un símbolo que no es COFF"
480 -#: cofflink.c:513 elflink.c:4175
481 -msgid "Warning: type of symbol `%s' changed from %d to %d in %B"
482 -msgstr "Aviso: el tipo del símbolo `%s' cambió de %d a %d en %B"
485 -msgid "%B: relocs in section `%A', but it has no contents"
486 -msgstr "%B: reubicaciones en la sección `%A', pero no tiene contenido"
488 -#: cofflink.c:2627 coffswap.h:824
490 -msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
491 -msgstr "%s: %s: desbordamiento de reubicación: 0x%lx > 0xffff"
493 -#: cofflink.c:2636 coffswap.h:810
495 -msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
496 -msgstr "%s: aviso: %s: desbordamiento de número de línea: 0x%lx > 0xffff"
498 -#: coff-m68k.c:506 elf32-bfin.c:5434 elf32-m68k.c:2393
499 +#: coff-m68k.c:506 elf32-bfin.c:5510 elf32-m68k.c:3938
500 msgid "unsupported reloc type"
501 msgstr "no se admite el tipo de reubicación"
503 @@ -462,31 +389,35 @@ msgstr "La direcci
504 msgid "Unrecognized Reloc Type"
505 msgstr "Tipo de Reubicación no Reconocida"
507 -#: coff-mips.c:687 elf32-mips.c:958 elf32-score.c:345 elf64-mips.c:1911
508 -#: elfn32-mips.c:1752
509 +#: coff-mips.c:688 elf32-mips.c:1014 elf32-score.c:345 elf64-mips.c:1991
510 +#: elfn32-mips.c:1832
511 msgid "GP relative relocation when _gp not defined"
512 msgstr "reubicación GP relativa cuando _gp no está definido"
516 msgid "Unrecognized reloc"
517 msgstr "Reubicación no reconocida"
519 -#: coff-rs6000.c:2799
520 +#: coff-rs6000.c:2803
522 msgid "%s: unsupported relocation type 0x%02x"
523 msgstr "%s: no se admite el tipo de reubicación 0x%02x"
525 -#: coff-rs6000.c:2892
526 +#: coff-rs6000.c:2896
528 msgid "%s: TOC reloc at 0x%x to symbol `%s' with no TOC entry"
529 msgstr "%s: reubicación de TOC en 0x%x al símbolo `%s' sin entrada TOC"
531 -#: coff-tic4x.c:191 coff-tic54x.c:299 coff-tic80.c:458
532 +#: coff-rs6000.c:3628 coff64-rs6000.c:2130
533 +msgid "%B: symbol `%s' has unrecognized smclas %d"
534 +msgstr "%B: el símbolo `%s' tiene smclas %d que no se reconoce"
536 +#: coff-tic4x.c:195 coff-tic54x.c:299 coff-tic80.c:458
538 msgid "Unrecognized reloc type 0x%x"
539 msgstr "Tipo de reubicación 0x%x no reconocida"
544 msgid "%s: warning: illegal symbol index %ld in relocs"
545 msgstr "%s: aviso: íncide de símbolos %ld ilegal en reubicaciones"
546 @@ -496,6 +427,76 @@ msgstr "%s: aviso:
547 msgid "ignoring reloc %s\n"
548 msgstr "se descarta la reubicación %s\n"
551 +msgid "%B: warning: COMDAT symbol '%s' does not match section name '%s'"
552 +msgstr "%B: aviso: el símbolo COMDAT '%s' no coincide con el nombre de sección '%s'"
554 +#. Generate a warning message rather using the 'unhandled'
555 +#. variable as this will allow some .sys files generate by
556 +#. other toolchains to be processed. See bugzilla issue 196.
558 +msgid "%B: Warning: Ignoring section flag IMAGE_SCN_MEM_NOT_PAGED in section %s"
559 +msgstr "%B: Aviso: Se descarta la opción de sección IMAGE_SCN_MEM_NOT_PAGED en la sección %s"
562 +msgid "%B (%s): Section flag %s (0x%x) ignored"
563 +msgstr "%B (%s): Se descarta la opción de sección %s (0x%x)"
567 +msgid "Unrecognized TI COFF target id '0x%x'"
568 +msgstr "No se reconoce el id de objetivo TI COFF '0x%x'"
571 +msgid "%B: reloc against a non-existant symbol index: %ld"
572 +msgstr "%B: reubicación contra un índice símbolo que no existe: %ld"
575 +msgid "%B: warning: line number table read failed"
576 +msgstr "%B: aviso: falló la lectura de tabla de números de línea"
579 +msgid "%B: warning: illegal symbol index %ld in line numbers"
580 +msgstr "%B: aviso: índice de símbolos %ld ilegal en los números de línea"
583 +msgid "%B: warning: duplicate line number information for `%s'"
584 +msgstr "%B: aviso: información duplicada de números de línea para `%s'"
587 +msgid "%B: Unrecognized storage class %d for %s symbol `%s'"
588 +msgstr "%B: Clase de almacenamiento %d no reconocida para %s símbolo `%s'"
591 +msgid "warning: %B: local symbol `%s' has no section"
592 +msgstr "aviso: %B: el símbolo local `%s' no tiene sección"
595 +msgid "%B: illegal relocation type %d at address 0x%lx"
596 +msgstr "%B: tipo de reubicación %d ilegal en la dirección 0x%lx"
599 +msgid "%B: bad string table size %lu"
600 +msgstr "%B: tamaño de tabla de cadenas %lu erróneo"
602 +#: cofflink.c:513 elflink.c:4218
603 +msgid "Warning: type of symbol `%s' changed from %d to %d in %B"
604 +msgstr "Aviso: el tipo del símbolo `%s' cambió de %d a %d en %B"
607 +msgid "%B: relocs in section `%A', but it has no contents"
608 +msgstr "%B: reubicaciones en la sección `%A', pero no tiene contenido"
610 +#: cofflink.c:2627 coffswap.h:824
612 +msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
613 +msgstr "%s: %s: desbordamiento de reubicación: 0x%lx > 0xffff"
615 +#: cofflink.c:2636 coffswap.h:810
617 +msgid "%s: warning: %s: line number overflow: 0x%lx > 0xffff"
618 +msgstr "%s: aviso: %s: desbordamiento de número de línea: 0x%lx > 0xffff"
620 #: cpu-arm.c:189 cpu-arm.c:200
621 msgid "ERROR: %B is compiled for the EP9312, whereas %B is compiled for XScale"
622 msgstr "ERROR: %B está compilado para el EP9312, mientras que %B está compilado para XScale"
623 @@ -505,66 +506,50 @@ msgstr "ERROR: %B est
624 msgid "warning: unable to update contents of %s section in %s"
625 msgstr "aviso: no se puede actualizar el contenido de la sección %s en %s"
628 -msgid "Dwarf Error: Can't find .debug_str section."
629 -msgstr "Error de Dwarf: No se puede encontrar la sección .debug_str."
634 -msgid "Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."
635 -msgstr "Error de Dwarf: El desplazamiento DW_FROM_strp (%lu) es más grande o igual que el tamaño de .debug_str (%lu)."
636 +msgid "Dwarf Error: Can't find %s section."
637 +msgstr "Error de Dwarf: No se puede encontrar la sección %s."
640 -msgid "Dwarf Error: Can't find .debug_abbrev section."
641 -msgstr "Error de Dwarf: No se puede encontrar la sección .debug_abbrev."
644 +msgid "Dwarf Error: unable to decompress %s section."
645 +msgstr "Error de Dwarf: no se puede descomprimir la sección %s."
650 -msgid "Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."
651 -msgstr "Error de Dwarf: El desplazamiento de abreviatura (%lu) es más grande o igual que el tamaño de .debug_abbrev (%lu)."
652 +msgid "Dwarf Error: Offset (%lu) greater than or equal to %s size (%lu)."
653 +msgstr "Error de Dwarf: El desplazamiento (%lu) es mayor que o igual que el tamaño de %s (%lu)."
658 msgid "Dwarf Error: Invalid or unhandled FORM value: %u."
659 msgstr "Error de Dwarf: Valor de FORM inválido o no manejado: %u."
663 msgid "Dwarf Error: mangled line number section (bad file number)."
664 msgstr "Error de Dwarf: sección de números de línea revuelta (número erróneo de fichero)."
667 -msgid "Dwarf Error: Can't find .debug_line section."
668 -msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_line."
672 -msgid "Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%lu)."
673 -msgstr "Error de Dwarf: El desplazamiento de línea (%lu) es más grande o igual que el tamaño de .debug_line (%lu)."
677 msgid "Dwarf Error: mangled line number section."
678 msgstr "Error de Dwarf: sección de números de línea revuelta."
681 -msgid "Dwarf Error: Can't find .debug_ranges section."
682 -msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_ranges."
684 -#: dwarf2.c:1731 dwarf2.c:1847 dwarf2.c:2119
685 +#: dwarf2.c:1726 dwarf2.c:1842 dwarf2.c:2114
687 msgid "Dwarf Error: Could not find abbrev number %u."
688 msgstr "Error de Dwarf: No se puede encontrar el número de abreviatura %u."
693 msgid "Dwarf Error: found dwarf version '%u', this reader only handles version 2 information."
694 msgstr "Error de Dwarf: se encontró la versión de dwarf '%u', este lector solamente maneja información de la versión 2."
699 msgid "Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."
700 msgstr "Error de Dwarf: se encontró el tamaño de dirección '%u', este lector no puede manejar tamaños más grandes que '%u'."
705 msgid "Dwarf Error: Bad abbrev number: %u."
706 msgstr "Error de Dwarf: Número de abreviación erróneo: %u."
707 @@ -646,35 +631,271 @@ msgstr ""
713 +msgid "ERROR: %B: Must be processed by '%s' toolchain"
714 +msgstr "ERROR: %B: Se debe procesar por la cadena de compilación '%s'"
716 +#: elf-attrs.c:602 elf-attrs.c:621
717 +msgid "ERROR: %B: Incompatible object tag '%s':%d"
718 +msgstr "ERROR: %B: Etiqueta de objeto '%s' incompatible:%d"
720 +#: elf-eh-frame.c:866
721 +msgid "%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"
722 +msgstr "%P: error en %B(%A); no se creará la tabla .eh_frame_hdr.\n"
724 +#: elf-eh-frame.c:1102
725 +msgid "%P: fde encoding in %B(%A) prevents .eh_frame_hdr table being created.\n"
726 +msgstr "%P: la codificación fde en %B(%A) previene la creación de la tabla .eh_frame_hdr.\n"
728 +#: elf-hppa.h:2241 elf-m10300.c:1546 elf32-arm.c:7954 elf32-i386.c:3582
729 +#: elf32-m32r.c:2598 elf32-m68k.c:3516 elf32-ppc.c:7223 elf32-s390.c:3058
730 +#: elf32-sh.c:3438 elf32-xtensa.c:3021 elf64-ppc.c:11528 elf64-s390.c:3019
731 +#: elf64-sh64.c:1648 elf64-x86-64.c:3239 elfxx-sparc.c:3336
732 +msgid "%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"
733 +msgstr "%B(%A+0x%lx): reubicación %s sin resolución contra el símbolo `%s'"
735 +#: elf-hppa.h:2266 elf-hppa.h:2280
736 +msgid "%B(%A): warning: unresolvable relocation against symbol `%s'"
737 +msgstr "%B(%A): aviso: reubicación sin resolución contra el símbolo `%s'"
739 +#: elf-m10200.c:456 elf-m10300.c:1609 elf32-avr.c:1250 elf32-bfin.c:3214
740 +#: elf32-cr16.c:959 elf32-cr16c.c:790 elf32-cris.c:1538 elf32-crx.c:933
741 +#: elf32-d10v.c:516 elf32-fr30.c:616 elf32-frv.c:4114 elf32-h8300.c:516
742 +#: elf32-i860.c:1218 elf32-ip2k.c:1499 elf32-iq2000.c:691 elf32-m32c.c:560
743 +#: elf32-m32r.c:3124 elf32-m68hc1x.c:1135 elf32-mep.c:541 elf32-msp430.c:493
744 +#: elf32-mt.c:402 elf32-openrisc.c:411 elf32-score.c:2451 elf32-spu.c:4132
745 +#: elf32-v850.c:1703 elf32-xstormy16.c:948 elf64-mmix.c:1533
746 +msgid "internal error: out of range error"
747 +msgstr "error interno: error fuera de rango"
749 +#: elf-m10200.c:460 elf-m10300.c:1613 elf32-avr.c:1254 elf32-bfin.c:3218
750 +#: elf32-cr16.c:963 elf32-cr16c.c:794 elf32-cris.c:1542 elf32-crx.c:937
751 +#: elf32-d10v.c:520 elf32-fr30.c:620 elf32-frv.c:4118 elf32-h8300.c:520
752 +#: elf32-i860.c:1222 elf32-iq2000.c:695 elf32-m32c.c:564 elf32-m32r.c:3128
753 +#: elf32-m68hc1x.c:1139 elf32-mep.c:545 elf32-msp430.c:497
754 +#: elf32-openrisc.c:415 elf32-score.c:2455 elf32-spu.c:4136 elf32-v850.c:1707
755 +#: elf32-xstormy16.c:952 elf64-mmix.c:1537 elfxx-mips.c:9065
756 +msgid "internal error: unsupported relocation error"
757 +msgstr "error interno: error de reubicación no admitida"
759 +#: elf-m10200.c:464 elf32-cr16.c:967 elf32-cr16c.c:798 elf32-crx.c:941
760 +#: elf32-d10v.c:524 elf32-h8300.c:524 elf32-m32r.c:3132 elf32-m68hc1x.c:1143
761 +#: elf32-score.c:2459 elf32-spu.c:4140
762 +msgid "internal error: dangerous error"
763 +msgstr "error interno: error peligroso"
765 +#: elf-m10200.c:468 elf-m10300.c:1626 elf32-avr.c:1262 elf32-bfin.c:3226
766 +#: elf32-cr16.c:971 elf32-cr16c.c:802 elf32-cris.c:1550 elf32-crx.c:945
767 +#: elf32-d10v.c:528 elf32-fr30.c:628 elf32-frv.c:4126 elf32-h8300.c:528
768 +#: elf32-i860.c:1230 elf32-ip2k.c:1514 elf32-iq2000.c:703 elf32-m32c.c:572
769 +#: elf32-m32r.c:3136 elf32-m68hc1x.c:1147 elf32-mep.c:553 elf32-msp430.c:505
770 +#: elf32-mt.c:410 elf32-openrisc.c:423 elf32-score.c:2463 elf32-spu.c:4144
771 +#: elf32-v850.c:1727 elf32-xstormy16.c:960 elf64-mmix.c:1545
772 +msgid "internal error: unknown error"
773 +msgstr "error interno: error desconocido"
775 +#: elf-m10300.c:1618
776 +msgid "error: inappropriate relocation type for shared library (did you forget -fpic?)"
777 +msgstr "error: tipo de reubicación inapropiada para la biblioteca compartida (¿olvidó -fpic?)"
779 +#: elf-m10300.c:1621
780 +msgid "internal error: suspicious relocation type used in shared library"
781 +msgstr "error interno: se usó un tipo de reubicación sospechosa en una biblioteca compartida"
783 +#: elf-m10300.c:4397 elf32-arm.c:9578 elf32-cris.c:2403 elf32-hppa.c:1921
784 +#: elf32-i370.c:506 elf32-i386.c:1807 elf32-m32r.c:1931 elf32-m68k.c:2787
785 +#: elf32-ppc.c:4693 elf32-s390.c:1687 elf32-sh.c:2583 elf32-vax.c:1055
786 +#: elf64-ppc.c:6075 elf64-s390.c:1662 elf64-sh64.c:3432 elf64-x86-64.c:1641
787 +#: elfxx-sparc.c:1828
789 +msgid "dynamic variable `%s' is zero size"
790 +msgstr "la variable dinámica `%s' es de tamaño cero"
793 +msgid "%B: invalid string offset %u >= %lu for section `%s'"
794 +msgstr "%B: desplazamiento de cadena inválido %u >= %lu para la sección `%s'"
797 +msgid "%B symbol number %lu references nonexistent SHT_SYMTAB_SHNDX section"
798 +msgstr "%B el número de símbolo %lu hace referencia a la sección inexistente SHT_SYMTAB_SHNDX"
801 +msgid "%B: Corrupt size field in group section header: 0x%lx"
802 +msgstr "%B: Tamaño de campo corrupto en el encabezado de la sección de grupo: 0x%lx"
805 +msgid "%B: invalid SHT_GROUP entry"
806 +msgstr "%B: entrada SHT_GROUP inválida"
809 +msgid "%B: no group info for section %A"
810 +msgstr "%B: no hay información de grupo para la sección %A"
812 +#: elf.c:729 elf.c:2976 elflink.c:9746
813 +msgid "%B: warning: sh_link not set for section `%A'"
814 +msgstr "%B: aviso: no se estableción sh_link para la sección `%A'"
817 +msgid "%B: sh_link [%d] in section `%A' is incorrect"
818 +msgstr "%B: sh_link [%d] en la sección `%A', es incorrecto"
821 +msgid "%B: unknown [%d] section `%s' in group [%s]"
822 +msgstr "%B: sección [%d] desconocida `%s' en el grupo [%s]"
831 +"Encabezado del Programa:\n"
837 +"Dynamic Section:\n"
840 +"Sección Dinámica:\n"
846 +"Version definitions:\n"
849 +"Definiciones de versión:\n"
855 +"Version References:\n"
858 +"Referencias de Versión:\n"
862 +msgid " required from %s:\n"
863 +msgstr " requerido desde %s:\n"
866 +msgid "%B: invalid link %lu for reloc section %s (index %u)"
867 +msgstr "%B: enlace %lu inválido para la sección de reubicación %s (índice %u)"
870 +msgid "%B: don't know how to handle allocated, application specific section `%s' [0x%8x]"
871 +msgstr "%B: no se sabe cómo manejar lo reservado, aplicación específica de la sección `%s' [0x%8x]"
874 +msgid "%B: don't know how to handle processor specific section `%s' [0x%8x]"
875 +msgstr "%B: no se sabe cómo manejar la sección específica de procesador `%s' [0x%8x]"
878 +msgid "%B: don't know how to handle OS specific section `%s' [0x%8x]"
879 +msgstr "%B: no se sabe cómo manejar la sección específica de SO `%s' [0x%8x]"
882 +msgid "%B: don't know how to handle section `%s' [0x%8x]"
883 +msgstr "%B: no se sabe cómo manejar la sección `%s' [0x%8x]"
887 +msgid "warning: section `%A' type changed to PROGBITS"
888 +msgstr "aviso: el tipo de la sección `%A' cambió a PROGBITS"
891 +msgid "%B: sh_link of section `%A' points to discarded section `%A' of `%B'"
892 +msgstr "%B: sh_link de la sección `%A' apunta a la sección descartada `%A' de `%B'"
895 +msgid "%B: sh_link of section `%A' points to removed section `%A' of `%B'"
896 +msgstr "%B: sh_link de la sección `%A' apunta a la sección descartada `%A' de `%B'"
899 +msgid "%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"
900 +msgstr "%B: La primera sección en el segmento PT_DYNAMIC no es la sección .dynamic"
903 +msgid "%B: Not enough room for program headers, try linking with -N"
904 +msgstr "%B: No hay suficiente espacio para los encabezados del programa, pruebe enlazar con -N"
907 +msgid "%B: section %A vma 0x%lx overlaps previous sections"
908 +msgstr "%B: la sección %A vma 0x%lx traslapa las secciones anteriores"
911 +msgid "%B: section `%A' can't be allocated in segment %d"
912 +msgstr "%B: la sección `%A' no se puede asignar en el segmento %d"
915 +msgid "%B: warning: allocated section `%s' not in segment"
916 +msgstr "%B: aviso: la sección asignada `%s' no está en el segmento"
919 +msgid "%B: symbol `%s' required but not present"
920 +msgstr "%B: se requiere el símbolo `%s' pero no está presente"
923 +msgid "%B: warning: Empty loadable segment detected, is this intentional ?\n"
924 +msgstr "%B: aviso: Se detectó un segmento cargable vacío, ¿ esto es intencional ?\n"
928 +msgid "Unable to find equivalent output section for symbol '%s' from section '%s'"
929 +msgstr "No se puede encontrar la sección de salida equivalente para el símbolo '%s' de la sección '%s'"
932 +msgid "%B: unsupported relocation type %s"
933 +msgstr "%B: no se admite el tipo de reubicación %s"
935 +#: elf32-arm.c:2846 elf32-arm.c:2878
937 +"%B(%s): warning: interworking not enabled.\n"
938 +" first occurrence: %B: Thumb call to ARM"
940 +"%B(%s): aviso: no se activó la interoperabilidad.\n"
941 +" primer suceso: %B: llamada Thumb para ARM"
945 +msgid "%s: cannot create stub entry %s"
946 +msgstr "%s: no se puede crear la entrada de cabo %s"
950 msgid "unable to find THUMB glue '%s' for '%s'"
951 msgstr "no se puede encontrar el pegamento THUMB '%s' para `%s'"
956 msgid "unable to find ARM glue '%s' for '%s'"
957 msgstr "no se puede encontrar el pegamento ARM '%s' para `%s'"
961 msgid "%B: BE8 images only valid in big-endian mode."
962 msgstr "%B: las imágenes BE8 sólo son válidas en modo big-endian."
964 #. Give a warning, but do as the user requests anyway.
967 msgid "%B: warning: selected VFP11 erratum workaround is not necessary for target architecture"
968 msgstr "%B: aviso: no se necesita la alternativa para evita la errata del VFP11 seleccionado para la arquitectura objetivo"
970 -#: elf32-arm.c:3865 elf32-arm.c:3885
971 +#: elf32-arm.c:5212 elf32-arm.c:5232
972 msgid "%B: unable to find VFP11 veneer `%s'"
973 msgstr "%B: no se puede encontrar la chapa de VFP11 `%s'"
978 msgid "Invalid TARGET2 relocation type '%s'."
979 msgstr "Tipo de reubicación TARGET2 '%s' inválido."
984 "%B(%s): warning: interworking not enabled.\n"
985 " first occurrence: %B: thumb call to arm"
986 @@ -682,374 +903,326 @@ msgstr ""
987 "%s(%s): aviso: no se activó la interoperabilidad.\n"
988 " primer suceso: %B: llamada thumb para arm"
992 msgid "\\%B: Warning: Arm BLX instruction targets Arm function '%s'."
993 msgstr "\\%B: Aviso: La instrucción Arm BLX apunta a la función Arm '%s'."
997 msgid "%B: Warning: Thumb BLX instruction targets thumb function '%s'."
998 msgstr "%B: Aviso: La instrucción Thumb BLX apunta a la función thumb '%s'."
1000 -#: elf32-arm.c:5689
1001 +#: elf32-arm.c:7095
1002 msgid "%B(%A+0x%lx): R_ARM_TLS_LE32 relocation not permitted in shared object"
1003 msgstr "%B(%A+0x%lx): la reubicación R_ARM_TLS_LE32 no se permite en objetos compartidos"
1005 -#: elf32-arm.c:5890
1006 +#: elf32-arm.c:7310
1007 msgid "%B(%A+0x%lx): Only ADD or SUB instructions are allowed for ALU group relocations"
1008 msgstr "%B(%A+0x%lx): Sólo se permiten las instrucciones ADD o SUB para la reubicación de grupo ALU"
1010 -#: elf32-arm.c:5930 elf32-arm.c:6017 elf32-arm.c:6100 elf32-arm.c:6185
1011 +#: elf32-arm.c:7350 elf32-arm.c:7437 elf32-arm.c:7520 elf32-arm.c:7605
1012 msgid "%B(%A+0x%lx): Overflow whilst splitting 0x%lx for group relocation %s"
1013 msgstr "%B(%A+0x%lx): Desborde al dividirse 0x%lx para la reubicación de grupo %s"
1015 -#: elf32-arm.c:6369 elf32-sh.c:3304 elf64-sh64.c:1556
1016 +#: elf32-arm.c:7812 elf32-sh.c:3334 elf64-sh64.c:1556
1017 msgid "%B(%A+0x%lx): %s relocation against SEC_MERGE section"
1018 msgstr "%B(%A+0x%lx): reubicación %s contra la sección SEC_MERGE"
1020 -#: elf32-arm.c:6458 elf64-ppc.c:9973
1021 +#: elf32-arm.c:7930 elf32-xtensa.c:2759 elf64-ppc.c:10374
1022 msgid "%B(%A+0x%lx): %s used with TLS symbol %s"
1023 msgstr "%B(%A+0x%lx): se usó %s con el símbolo TLS %s"
1025 -#: elf32-arm.c:6459 elf64-ppc.c:9974
1026 +#: elf32-arm.c:7931 elf32-xtensa.c:2760 elf64-ppc.c:10375
1027 msgid "%B(%A+0x%lx): %s used with non-TLS symbol %s"
1028 msgstr "%B(%A+0x%lx): se usó %s con el símbolo %s que no es TLS"
1030 -#: elf32-arm.c:6482 elf32-i386.c:3310 elf32-m32r.c:2598 elf32-m68k.c:1982
1031 -#: elf32-ppc.c:6796 elf32-s390.c:3048 elf32-sh.c:3408 elf32-xtensa.c:2290
1032 -#: elf64-ppc.c:11138 elf64-s390.c:3009 elf64-sh64.c:1648 elf64-x86-64.c:3002
1033 -#: elf-hppa.h:2194 elf-m10300.c:1460 elfxx-sparc.c:3256
1034 -msgid "%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"
1035 -msgstr "%B(%A+0x%lx): reubicación %s sin resolución contra el símbolo `%s'"
1037 -#: elf32-arm.c:6516
1038 +#: elf32-arm.c:7988
1039 msgid "out of range"
1040 msgstr "fuera de rango"
1042 -#: elf32-arm.c:6520
1043 +#: elf32-arm.c:7992
1044 msgid "unsupported relocation"
1045 msgstr "no se admite la reubicación"
1047 -#: elf32-arm.c:6528
1048 +#: elf32-arm.c:8000
1049 msgid "unknown error"
1050 msgstr "error desconocido"
1052 -#: elf32-arm.c:6628
1053 +#: elf32-arm.c:8099
1054 msgid "Warning: Clearing the interworking flag of %B because non-interworking code in %B has been linked with it"
1055 msgstr "Aviso: Se limpia la opción de interoperación en %B porque se ha enlazado con él código no interoperable en %B"
1057 -#: elf32-arm.c:6730
1058 +#: elf32-arm.c:8205
1059 msgid "ERROR: %B uses VFP register arguments, %B does not"
1060 msgstr "ERROR: %B utiliza argumentos de registro VFP, mientras que %B no"
1062 -#: elf32-arm.c:6780
1063 +#: elf32-arm.c:8254
1064 msgid "ERROR: %B: Conflicting architecture profiles %c/%c"
1065 msgstr "ERROR: %B: Perfiles de arquitecturas en conflicto %c/%c"
1067 -#: elf32-arm.c:6795
1068 +#: elf32-arm.c:8274
1069 msgid "Warning: %B: Conflicting platform configuration"
1070 msgstr "Aviso: %B: Configuración de plataformas en conflicto"
1072 -#: elf32-arm.c:6804
1073 +#: elf32-arm.c:8283
1074 msgid "ERROR: %B: Conflicting use of R9"
1075 msgstr "ERROR: %B: Uso en conflicto de R9"
1077 -#: elf32-arm.c:6816
1078 +#: elf32-arm.c:8295
1079 msgid "ERROR: %B: SB relative addressing conflicts with use of R9"
1080 msgstr "ERROR: %B: El direccionamiento relativo a SB tiene conflictos con el uso de R9"
1082 -#: elf32-arm.c:6838
1083 -msgid "ERROR: %B: Conflicting definitions of wchar_t"
1084 -msgstr "ERROR: %B: Definiciones en conflicto de wchar_t"
1085 +#: elf32-arm.c:8318
1086 +msgid "warning: %B uses %u-byte wchar_t yet the output is to use %u-byte wchar_t; use of wchar_t values across objects may fail"
1087 +msgstr "aviso: %B usa wchar_t de %u bytes aunque la salida usa wchar_t de %u bytes; el uso de valores wchar_t entre objetos puede fallar"
1089 -#: elf32-arm.c:6867
1090 +#: elf32-arm.c:8347
1091 msgid "warning: %B uses %s enums yet the output is to use %s enums; use of enum values across objects may fail"
1092 msgstr "aviso: %B usa %s enums aunque la salida usa %s enums; el uso de valores enum entre objetos puede fallar"
1094 -#: elf32-arm.c:6880
1095 +#: elf32-arm.c:8360
1096 msgid "ERROR: %B uses iWMMXt register arguments, %B does not"
1097 msgstr "ERROR: %B utiliza argumentos de registro iWMMXt, mientras que %B no"
1099 -#: elf32-arm.c:6920
1100 +#: elf32-arm.c:8400
1101 msgid "Warning: %B: Unknown EABI object attribute %d"
1102 msgstr "Aviso: %B: Atributo de objeto EABI %d desconocido"
1104 -#: elf32-arm.c:7045
1105 +#: elf32-arm.c:8460
1106 +msgid "ERROR: %B is already in final BE8 format"
1107 +msgstr "ERROR: %B ya está en el formato BE8 final"
1109 +#: elf32-arm.c:8536
1110 msgid "ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"
1111 msgstr "ERROR: El objeto fuente %B tiene EABI versión %d, pero el objetivo %B tiene EABI versión %d"
1113 -#: elf32-arm.c:7061
1114 +#: elf32-arm.c:8552
1115 msgid "ERROR: %B is compiled for APCS-%d, whereas target %B uses APCS-%d"
1116 msgstr "ERROR: %B está compilado para APCS-%d mientras que el objetivo %B usa APCS-%d"
1118 -#: elf32-arm.c:7086
1119 +#: elf32-arm.c:8577
1120 msgid "ERROR: %B uses VFP instructions, whereas %B does not"
1121 msgstr "ERROR: %B utiliza instrucciones VFP, mientras que %B no"
1123 -#: elf32-arm.c:7090
1124 +#: elf32-arm.c:8581
1125 msgid "ERROR: %B uses FPA instructions, whereas %B does not"
1126 msgstr "ERROR: %B utiliza instrucciones FPA, mientras que %B no"
1128 -#: elf32-arm.c:7100
1129 +#: elf32-arm.c:8591
1130 msgid "ERROR: %B uses Maverick instructions, whereas %B does not"
1131 msgstr "ERROR: %B utiliza instrucciones Maverick, mientras que %B no"
1133 -#: elf32-arm.c:7104
1134 +#: elf32-arm.c:8595
1135 msgid "ERROR: %B does not use Maverick instructions, whereas %B does"
1136 msgstr "ERROR: %B no utiliza instrucciones Maverick, mientras que %B sí"
1138 -#: elf32-arm.c:7123
1139 +#: elf32-arm.c:8614
1140 msgid "ERROR: %B uses software FP, whereas %B uses hardware FP"
1141 msgstr "ERROR: %B utiliza FP de software, mientras que %B utiliza FP de hardware"
1143 -#: elf32-arm.c:7127
1144 +#: elf32-arm.c:8618
1145 msgid "ERROR: %B uses hardware FP, whereas %B uses software FP"
1146 msgstr "ERROR: %B utiliza FP de hardware, mientras que %B utiliza FP de software"
1148 #. Ignore init flag - it may not be set, despite the flags field
1149 #. containing valid data.
1150 #. Ignore init flag - it may not be set, despite the flags field containing valid data.
1151 -#: elf32-arm.c:7174 elf32-bfin.c:4795 elf32-cris.c:3234 elf32-m68hc1x.c:1277
1152 -#: elf32-m68k.c:620 elf32-score.c:3753 elf32-vax.c:538 elfxx-mips.c:11331
1153 +#: elf32-arm.c:8665 elf32-bfin.c:4899 elf32-cris.c:3235 elf32-m68hc1x.c:1279
1154 +#: elf32-m68k.c:774 elf32-score.c:3750 elf32-vax.c:538 elfxx-mips.c:12699
1156 msgid "private flags = %lx:"
1157 msgstr "opciones privadas = %lx:"
1159 -#: elf32-arm.c:7183
1160 +#: elf32-arm.c:8674
1162 msgid " [interworking enabled]"
1163 msgstr " [interoperabilidad activada]"
1165 -#: elf32-arm.c:7191
1166 +#: elf32-arm.c:8682
1168 msgid " [VFP float format]"
1169 msgstr " [formato de coma flotante VFP]"
1171 -#: elf32-arm.c:7193
1172 +#: elf32-arm.c:8684
1174 msgid " [Maverick float format]"
1175 msgstr " [formato de coma flotante Maverick]"
1177 -#: elf32-arm.c:7195
1178 +#: elf32-arm.c:8686
1180 msgid " [FPA float format]"
1181 msgstr " [formato de coma flotante FPA]"
1183 -#: elf32-arm.c:7204
1184 +#: elf32-arm.c:8695
1187 msgstr " [ABI nuevo]"
1189 -#: elf32-arm.c:7207
1190 +#: elf32-arm.c:8698
1193 msgstr " [ABI antiguo]"
1195 -#: elf32-arm.c:7210
1196 +#: elf32-arm.c:8701
1198 msgid " [software FP]"
1199 msgstr " [FP por software]"
1201 -#: elf32-arm.c:7219
1202 +#: elf32-arm.c:8710
1204 msgid " [Version1 EABI]"
1205 msgstr " [EABI Version1]"
1207 -#: elf32-arm.c:7222 elf32-arm.c:7233
1208 +#: elf32-arm.c:8713 elf32-arm.c:8724
1210 msgid " [sorted symbol table]"
1211 msgstr " [tabla de símbolos ordenados]"
1213 -#: elf32-arm.c:7224 elf32-arm.c:7235
1214 +#: elf32-arm.c:8715 elf32-arm.c:8726
1216 msgid " [unsorted symbol table]"
1217 msgstr " [tabla de símbolos sin ordenar]"
1219 -#: elf32-arm.c:7230
1220 +#: elf32-arm.c:8721
1222 msgid " [Version2 EABI]"
1223 msgstr " [EABI Version2]"
1225 -#: elf32-arm.c:7238
1226 +#: elf32-arm.c:8729
1228 msgid " [dynamic symbols use segment index]"
1229 msgstr " [los símbolos dinámicos utilizan índices de segmento]"
1231 -#: elf32-arm.c:7241
1232 +#: elf32-arm.c:8732
1234 msgid " [mapping symbols precede others]"
1235 msgstr " [el mapeo de símbolos precede a otros]"
1237 -#: elf32-arm.c:7248
1238 +#: elf32-arm.c:8739
1240 msgid " [Version3 EABI]"
1241 msgstr " [EABI Version3]"
1243 -#: elf32-arm.c:7252
1244 +#: elf32-arm.c:8743
1246 msgid " [Version4 EABI]"
1247 msgstr " [EABI Version4]"
1249 -#: elf32-arm.c:7256
1250 +#: elf32-arm.c:8747
1252 msgid " [Version5 EABI]"
1253 msgstr " [EABI Version5]"
1255 -#: elf32-arm.c:7259
1256 +#: elf32-arm.c:8750
1261 -#: elf32-arm.c:7262
1262 +#: elf32-arm.c:8753
1267 -#: elf32-arm.c:7268
1268 +#: elf32-arm.c:8759
1270 msgid " <EABI version unrecognised>"
1271 msgstr " <versión de EABI no reconocida>"
1273 -#: elf32-arm.c:7275
1274 +#: elf32-arm.c:8766
1276 msgid " [relocatable executable]"
1277 msgstr " [ejecutable reubicable]"
1279 -#: elf32-arm.c:7278
1280 +#: elf32-arm.c:8769
1282 msgid " [has entry point]"
1283 msgstr " [tiene punto de entrada]"
1285 -#: elf32-arm.c:7283
1286 +#: elf32-arm.c:8774
1288 msgid "<Unrecognised flag bits set>"
1289 msgstr "<Conjunto de bits de opción sin reconocer>"
1291 -#: elf32-arm.c:7522 elf32-i386.c:961 elf32-s390.c:1003 elf32-xtensa.c:814
1292 -#: elf64-s390.c:958 elf64-x86-64.c:773 elfxx-sparc.c:1115
1293 +#: elf32-arm.c:9013 elf32-i386.c:1236 elf32-s390.c:1006 elf32-xtensa.c:999
1294 +#: elf64-s390.c:961 elf64-x86-64.c:1016 elfxx-sparc.c:1127
1295 msgid "%B: bad symbol index: %d"
1296 msgstr "%B: índice de símbolos erróneo: %d"
1298 -#: elf32-arm.c:8080 elf32-cris.c:2400 elf32-hppa.c:1906 elf32-i370.c:506
1299 -#: elf32-i386.c:1522 elf32-m32r.c:1931 elf32-m68k.c:1331 elf32-ppc.c:4314
1300 -#: elf32-s390.c:1679 elf32-sh.c:2584 elf32-vax.c:1050 elf64-ppc.c:5898
1301 -#: elf64-s390.c:1654 elf64-sh64.c:3438 elf64-x86-64.c:1382 elf-m10300.c:4207
1302 -#: elfxx-sparc.c:1797
1304 -msgid "dynamic variable `%s' is zero size"
1305 -msgstr "la variable dinámica `%s' es de tamaño cero"
1307 -#: elf32-arm.c:8603
1308 +#: elf32-arm.c:10125
1310 msgid "Errors encountered processing file %s"
1311 msgstr "Se encontraron errores al procesar el fichero %s"
1313 -#: elf32-arm.c:9839 elf32-arm.c:9861
1314 +#: elf32-arm.c:11526 elf32-arm.c:11548
1315 msgid "%B: error: VFP11 veneer out of range"
1316 msgstr "%B: error: la chapa VFP11 está fuera de rango"
1318 -#: elf32-avr.c:1253 elf32-bfin.c:2795 elf32-cr16.c:887 elf32-cr16c.c:790
1319 -#: elf32-cris.c:1538 elf32-crx.c:933 elf32-d10v.c:517 elf32-fr30.c:616
1320 -#: elf32-frv.c:4129 elf32-h8300.c:516 elf32-i860.c:1218 elf32-ip2k.c:1499
1321 -#: elf32-iq2000.c:647 elf32-m32c.c:560 elf32-m32r.c:3124 elf32-m68hc1x.c:1133
1322 -#: elf32-mep.c:642 elf32-msp430.c:497 elf32-mt.c:402 elf32-openrisc.c:411
1323 -#: elf32-score.c:2456 elf32-spu.c:2813 elf32-v850.c:1701 elf32-xstormy16.c:946
1324 -#: elf64-mmix.c:1533 elf-m10200.c:456 elf-m10300.c:1523
1325 -msgid "internal error: out of range error"
1326 -msgstr "error interno: error fuera de rango"
1328 -#: elf32-avr.c:1257 elf32-bfin.c:2799 elf32-cr16.c:891 elf32-cr16c.c:794
1329 -#: elf32-cris.c:1542 elf32-crx.c:937 elf32-d10v.c:521 elf32-fr30.c:620
1330 -#: elf32-frv.c:4133 elf32-h8300.c:520 elf32-i860.c:1222 elf32-iq2000.c:651
1331 -#: elf32-m32c.c:564 elf32-m32r.c:3128 elf32-m68hc1x.c:1137 elf32-mep.c:646
1332 -#: elf32-msp430.c:501 elf32-openrisc.c:415 elf32-score.c:2460 elf32-spu.c:2817
1333 -#: elf32-v850.c:1705 elf32-xstormy16.c:950 elf64-mmix.c:1537 elf-m10200.c:460
1334 -#: elf-m10300.c:1527 elfxx-mips.c:8025
1335 -msgid "internal error: unsupported relocation error"
1336 -msgstr "error interno: error de reubicación no admitida"
1338 -#: elf32-avr.c:1261 elf32-bfin.c:2803 elf32-cris.c:1546 elf32-fr30.c:624
1339 -#: elf32-frv.c:4137 elf32-i860.c:1226 elf32-ip2k.c:1510 elf32-iq2000.c:655
1340 -#: elf32-m32c.c:568 elf32-mep.c:650 elf32-msp430.c:505 elf32-mt.c:406
1341 -#: elf32-openrisc.c:419 elf32-v850.c:1709 elf32-xstormy16.c:954
1342 +#: elf32-avr.c:1258 elf32-bfin.c:3222 elf32-cris.c:1546 elf32-fr30.c:624
1343 +#: elf32-frv.c:4122 elf32-i860.c:1226 elf32-ip2k.c:1510 elf32-iq2000.c:699
1344 +#: elf32-m32c.c:568 elf32-mep.c:549 elf32-msp430.c:501 elf32-mt.c:406
1345 +#: elf32-openrisc.c:419 elf32-v850.c:1711 elf32-xstormy16.c:956
1346 #: elf64-mmix.c:1541
1347 msgid "internal error: dangerous relocation"
1348 msgstr "error interno: reubicación peligrosa"
1350 -#: elf32-avr.c:1265 elf32-bfin.c:2807 elf32-cr16.c:899 elf32-cr16c.c:802
1351 -#: elf32-cris.c:1550 elf32-crx.c:945 elf32-d10v.c:529 elf32-fr30.c:628
1352 -#: elf32-frv.c:4141 elf32-h8300.c:528 elf32-i860.c:1230 elf32-ip2k.c:1514
1353 -#: elf32-iq2000.c:659 elf32-m32c.c:572 elf32-m32r.c:3136 elf32-m68hc1x.c:1145
1354 -#: elf32-mep.c:654 elf32-msp430.c:509 elf32-mt.c:410 elf32-openrisc.c:423
1355 -#: elf32-score.c:2468 elf32-spu.c:2825 elf32-v850.c:1725 elf32-xstormy16.c:958
1356 -#: elf64-mmix.c:1545 elf-m10200.c:468 elf-m10300.c:1540
1357 -msgid "internal error: unknown error"
1358 -msgstr "error interno: error desconocido"
1360 -#: elf32-avr.c:2369 elf32-hppa.c:595 elf32-m68hc1x.c:164 elf64-ppc.c:3802
1361 +#: elf32-avr.c:2396 elf32-hppa.c:605 elf32-m68hc1x.c:164 elf64-ppc.c:3983
1362 msgid "%B: cannot create stub entry %s"
1363 msgstr "%B: no se puede crear la entrada de cabo %s"
1365 -#: elf32-bfin.c:2274
1366 +#: elf32-bfin.c:1585
1367 +msgid "%B(%A+0x%lx): unresolvable relocation against symbol `%s'"
1368 +msgstr "%B(%A+0x%lx): reubicación sin resolución contra el símbolo `%s'"
1370 +#: elf32-bfin.c:1618 elf32-i386.c:3623 elf32-m68k.c:3557 elf32-s390.c:3110
1371 +#: elf64-s390.c:3071 elf64-x86-64.c:3278
1372 +msgid "%B(%A+0x%lx): reloc against `%s': error %d"
1373 +msgstr "%B(%A+0x%lx): reubicación contra `%s': error %d"
1375 +#: elf32-bfin.c:2711
1376 msgid "%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"
1377 msgstr "%B: la reubicación en `%A+0x%x' referencía al símbolo `%s' con adición que no es cero"
1379 -#: elf32-bfin.c:2288 elf32-frv.c:2919
1380 +#: elf32-bfin.c:2725 elf32-frv.c:2904
1381 msgid "relocation references symbol not defined in the module"
1382 msgstr "la reubicación referencía un símbolo que no está definido en el módulo"
1384 -#: elf32-bfin.c:2385
1385 +#: elf32-bfin.c:2822
1386 msgid "R_BFIN_FUNCDESC references dynamic symbol with nonzero addend"
1387 msgstr "R_BFIN_FUNCDESC referencía un símbolo dinámico con adición que no es cero"
1389 -#: elf32-bfin.c:2424 elf32-bfin.c:2547 elf32-frv.c:3656 elf32-frv.c:3777
1390 +#: elf32-bfin.c:2861 elf32-bfin.c:2987 elf32-frv.c:3641 elf32-frv.c:3762
1391 msgid "cannot emit fixups in read-only section"
1392 msgstr "no se pueden emitir composturas en la sección de sólo lectura"
1394 -#: elf32-bfin.c:2452 elf32-bfin.c:2587 elf32-frv.c:3687 elf32-frv.c:3821
1395 +#: elf32-bfin.c:2889 elf32-bfin.c:3036 elf32-frv.c:3672 elf32-frv.c:3806
1396 msgid "cannot emit dynamic relocations in read-only section"
1397 -msgstr "no se pueden emitri reubicaciones dinámicas en la sección de sólo lectura"
1398 +msgstr "no se pueden emitir reubicaciones dinámicas en la sección de sólo lectura"
1400 -#: elf32-bfin.c:2505
1401 +#: elf32-bfin.c:2945
1402 msgid "R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
1403 msgstr "R_BFIN_FUNCDESC_VALUE referencía un símbolo dinámico con adición que no es cero"
1405 -#: elf32-bfin.c:2673
1406 +#: elf32-bfin.c:3126
1407 msgid "relocations between different segments are not supported"
1408 msgstr "no se admiten las reubicaciones entre segmentos diferentes"
1410 -#: elf32-bfin.c:2674
1411 +#: elf32-bfin.c:3127
1412 msgid "warning: relocation references a different segment"
1413 msgstr "aviso: la reubicación referencía un segmento diferente"
1415 -#: elf32-bfin.c:3083
1416 -msgid "%B(%A+0x%lx): unresolvable relocation against symbol `%s'"
1417 -msgstr "%B(%A+0x%lx): reubicación sin resolución contra el símbolo `%s'"
1419 -#: elf32-bfin.c:3116 elf32-i386.c:3351 elf32-m68k.c:2023 elf32-s390.c:3100
1420 -#: elf64-s390.c:3061 elf64-x86-64.c:3041
1421 -msgid "%B(%A+0x%lx): reloc against `%s': error %d"
1422 -msgstr "%B(%A+0x%lx): reubicación contra `%s': error %d"
1424 -#: elf32-bfin.c:4687 elf32-frv.c:6423
1425 +#: elf32-bfin.c:4791 elf32-frv.c:6404
1426 msgid "%B: unsupported relocation type %i"
1427 msgstr "%B: no se admite el tipo de reubicación %i"
1429 -#: elf32-bfin.c:4868 elf32-frv.c:6831
1430 +#: elf32-bfin.c:4944 elf32-frv.c:6812
1432 msgid "%s: cannot link non-fdpic object file into fdpic executable"
1433 msgstr "%s: no se puede enlazar el fichero objeto que no es fdpic en un ejecutable fdpic"
1435 -#: elf32-bfin.c:4872 elf32-frv.c:6835
1436 +#: elf32-bfin.c:4948 elf32-frv.c:6816
1438 msgid "%s: cannot link fdpic object file into non-fdpic executable"
1439 msgstr "%s: no se puede enlazar el fichero objeto fdpic en un ejecutable que no es fdpic"
1441 -#: elf32-cr16.c:895 elf32-cr16c.c:798 elf32-crx.c:941 elf32-d10v.c:525
1442 -#: elf32-h8300.c:524 elf32-m32r.c:3132 elf32-m68hc1x.c:1141 elf32-score.c:2464
1443 -#: elf32-spu.c:2821 elf-m10200.c:464
1444 -msgid "internal error: dangerous error"
1445 -msgstr "error interno: error peligroso"
1447 #: elf32-cris.c:1060
1448 msgid "%B, section %A: unresolvable relocation %s against symbol `%s'"
1449 msgstr "%B, sección %A: reubicación %s sin resolución contra el símbolo `%s'"
1450 @@ -1086,7 +1259,7 @@ msgstr "%B, secci
1451 msgid "%B: Internal inconsistency; no relocation section %s"
1452 msgstr "%B: Inconsistencia interna; no se encuentra la sección de reubicación %s"
1454 -#: elf32-cris.c:2511
1455 +#: elf32-cris.c:2510
1458 " v10/v32 compatible object %s must not contain a PIC relocation"
1459 @@ -1094,7 +1267,7 @@ msgstr ""
1461 " el objeto %s compatible con v10/v32 no debe contener una reubicación PIC"
1463 -#: elf32-cris.c:2698 elf32-cris.c:2766
1464 +#: elf32-cris.c:2697 elf32-cris.c:2765
1467 " relocation %s should not be used in a shared object; recompile with -fPIC"
1468 @@ -1102,129 +1275,129 @@ msgstr ""
1470 " la reubicación %s no se debe usar en un objeto compartido; recompile con -fPIC"
1472 -#: elf32-cris.c:3183
1473 +#: elf32-cris.c:3184
1474 msgid "Unexpected machine number"
1475 msgstr "Número de máquina inesperado"
1477 -#: elf32-cris.c:3237
1478 +#: elf32-cris.c:3238
1480 msgid " [symbols have a _ prefix]"
1481 msgstr " [los símbolos tiene un prefijo _]"
1483 -#: elf32-cris.c:3240
1484 +#: elf32-cris.c:3241
1486 msgid " [v10 and v32]"
1487 msgstr " [v10 y v32]"
1489 -#: elf32-cris.c:3243
1490 +#: elf32-cris.c:3244
1495 -#: elf32-cris.c:3288
1496 +#: elf32-cris.c:3289
1497 msgid "%B: uses _-prefixed symbols, but writing file with non-prefixed symbols"
1498 msgstr "%B: utiliza símbolos con prefijo _, pero escribe el fichero con símbolos sin prefijo"
1500 -#: elf32-cris.c:3289
1501 +#: elf32-cris.c:3290
1502 msgid "%B: uses non-prefixed symbols, but writing file with _-prefixed symbols"
1503 msgstr "%B: utiliza símbolos sin prefijo, pero escribe el fichero con símbolos con prefijo _"
1505 -#: elf32-cris.c:3308
1506 +#: elf32-cris.c:3309
1507 msgid "%B contains CRIS v32 code, incompatible with previous objects"
1508 msgstr "%B contiene código CRIS v32, incompatible con objetos previos"
1510 -#: elf32-cris.c:3310
1511 +#: elf32-cris.c:3311
1512 msgid "%B contains non-CRIS-v32 code, incompatible with previous objects"
1513 msgstr "%B contiene código que no es CRIS v32, incompatible con objetos previos"
1515 -#: elf32-frv.c:1523 elf32-frv.c:1672
1516 +#: elf32-frv.c:1507 elf32-frv.c:1656
1517 msgid "relocation requires zero addend"
1518 msgstr "la reubicación requiere una adición cero"
1520 -#: elf32-frv.c:2906
1521 +#: elf32-frv.c:2891
1522 msgid "%B(%A+0x%x): relocation to `%s+%x' may have caused the error above"
1523 msgstr "%B(%A+0x%x): la reubicación a `%s+%x' tal vez causó el error anterior"
1525 -#: elf32-frv.c:2995
1526 +#: elf32-frv.c:2980
1527 msgid "R_FRV_GETTLSOFF not applied to a call instruction"
1528 msgstr "no se aplicó R_FRV_GETTLSOFF a una instrucción call"
1530 -#: elf32-frv.c:3037
1531 +#: elf32-frv.c:3022
1532 msgid "R_FRV_GOTTLSDESC12 not applied to an lddi instruction"
1533 msgstr "no se aplicó R_FRV_GOTTLSDESC12 a una instrucción lddi"
1535 -#: elf32-frv.c:3108
1536 +#: elf32-frv.c:3093
1537 msgid "R_FRV_GOTTLSDESCHI not applied to a sethi instruction"
1538 msgstr "no se aplicó R_FRV_GOTTLSDESCHI a una instrucción sethi"
1540 -#: elf32-frv.c:3145
1541 +#: elf32-frv.c:3130
1542 msgid "R_FRV_GOTTLSDESCLO not applied to a setlo or setlos instruction"
1543 msgstr "no se aplicó R_FRV_GOTTLSDESCLO a una instrucción setlo o setlos"
1545 -#: elf32-frv.c:3193
1546 +#: elf32-frv.c:3178
1547 msgid "R_FRV_TLSDESC_RELAX not applied to an ldd instruction"
1548 msgstr "no se aplicó R_FRV_GOTTLSDESC_RELAX a una instrucción ldd"
1550 -#: elf32-frv.c:3277
1551 +#: elf32-frv.c:3262
1552 msgid "R_FRV_GETTLSOFF_RELAX not applied to a calll instruction"
1553 msgstr "no se aplicó R_FRV_GETTLSOFF_RELAX a una instrucción calll"
1555 -#: elf32-frv.c:3332
1556 +#: elf32-frv.c:3317
1557 msgid "R_FRV_GOTTLSOFF12 not applied to an ldi instruction"
1558 msgstr "no se aplicó R_FRV_GOTTLSOFF12 a una instrucción ldi"
1560 -#: elf32-frv.c:3362
1561 +#: elf32-frv.c:3347
1562 msgid "R_FRV_GOTTLSOFFHI not applied to a sethi instruction"
1563 msgstr "no se aplicó R_FRV_GOTTLSOFFHI a una instrucción sethi"
1565 -#: elf32-frv.c:3391
1566 +#: elf32-frv.c:3376
1567 msgid "R_FRV_GOTTLSOFFLO not applied to a setlo or setlos instruction"
1568 msgstr "no se aplicó R_FRV_GOTTLSOFFLO a una instrucción setlo o setlos"
1570 -#: elf32-frv.c:3422
1571 +#: elf32-frv.c:3407
1572 msgid "R_FRV_TLSOFF_RELAX not applied to an ld instruction"
1573 msgstr "no se aplicó R_FRV_TLSOFF_RELAX a una instrucción ld"
1575 -#: elf32-frv.c:3467
1576 +#: elf32-frv.c:3452
1577 msgid "R_FRV_TLSMOFFHI not applied to a sethi instruction"
1578 msgstr "no se aplicó R_FRV_TLSMOFFHI a una instrucción sethi"
1580 -#: elf32-frv.c:3494
1581 +#: elf32-frv.c:3479
1582 msgid "R_FRV_TLSMOFFLO not applied to a setlo or setlos instruction"
1583 msgstr "no se aplicó R_FRV_TLSMOFFLO a una instrucción setlo o setlos"
1585 -#: elf32-frv.c:3615
1586 +#: elf32-frv.c:3600
1587 msgid "R_FRV_FUNCDESC references dynamic symbol with nonzero addend"
1588 msgstr "R_FRV_FUNCDESC referencía un símbolo dinámico con adición que no es cero"
1590 -#: elf32-frv.c:3735
1591 +#: elf32-frv.c:3720
1592 msgid "R_FRV_FUNCDESC_VALUE references dynamic symbol with nonzero addend"
1593 msgstr "R_FRV_FUNCDESC_VALUE referencía un símbolo dinámico con adición que no es cero"
1595 -#: elf32-frv.c:3992 elf32-frv.c:4148
1596 +#: elf32-frv.c:3977 elf32-frv.c:4133
1597 msgid "%B(%A+0x%lx): reloc against `%s': %s"
1598 msgstr "%B(%A+0x%lx): reubicación contra `%s': %s"
1600 -#: elf32-frv.c:3994 elf32-frv.c:3998
1601 +#: elf32-frv.c:3979 elf32-frv.c:3983
1602 msgid "relocation references a different segment"
1603 msgstr "la reubicación referencía un segmento diferente"
1605 -#: elf32-frv.c:6745
1606 +#: elf32-frv.c:6726
1608 msgid "%s: compiled with %s and linked with modules that use non-pic relocations"
1609 msgstr "%s: compilado con %s y enlazado con módulos que usan reubicaciones que no son pic"
1611 -#: elf32-frv.c:6798 elf32-iq2000.c:808 elf32-m32c.c:819
1612 +#: elf32-frv.c:6779 elf32-iq2000.c:852 elf32-m32c.c:814
1614 msgid "%s: compiled with %s and linked with modules compiled with %s"
1615 msgstr "%s: compilado con %s y enlazado con módulos compilados con %s"
1617 -#: elf32-frv.c:6810
1618 +#: elf32-frv.c:6791
1620 msgid "%s: uses different unknown e_flags (0x%lx) fields than previous modules (0x%lx)"
1621 msgstr "%s: usa campos e_flags desconocidos (0x%lx) diferentes a aquéllos de los módulos previos (0x%lx)"
1623 -#: elf32-frv.c:6860 elf32-iq2000.c:845 elf32-m32c.c:855 elf32-mt.c:587
1624 +#: elf32-frv.c:6841 elf32-iq2000.c:889 elf32-m32c.c:850 elf32-mt.c:583
1626 msgid "private flags = 0x%lx:"
1627 msgstr "opciones privadas = 0x%lx:"
1628 @@ -1233,55 +1406,79 @@ msgstr "opciones privadas = 0x%lx:"
1629 msgid "%B: Relocations in generic ELF (EM: %d)"
1630 msgstr "%B: Reubicaciones en ELF genérico (EM: %d)"
1632 -#: elf32-hppa.c:844 elf32-hppa.c:3577
1633 +#: elf32-hppa.c:854 elf32-hppa.c:3600
1634 msgid "%B(%A+0x%lx): cannot reach %s, recompile with -ffunction-sections"
1635 msgstr "%B(%A+0x%lx): no se puede alcanzar %s, recompile con -ffuntion-sections"
1637 -#: elf32-hppa.c:1253
1638 +#: elf32-hppa.c:1263
1639 msgid "%B: relocation %s can not be used when making a shared object; recompile with -fPIC"
1640 msgstr "%B: no se puede usar la reubicación %s cuando se hace un objeto compartido; recompile con -fPIC"
1642 -#: elf32-hppa.c:1506
1643 +#: elf32-hppa.c:1518
1645 msgid "Could not find relocation section for %s"
1646 msgstr "No se puede encontrar la sección de reubicación para %s"
1648 -#: elf32-hppa.c:2795
1649 +#: elf32-hppa.c:2810
1650 msgid "%B: duplicate export stub %s"
1651 msgstr "%B: cabo de exportación %s duplicado"
1653 -#: elf32-hppa.c:3413
1654 +#: elf32-hppa.c:3436
1655 msgid "%B(%A+0x%lx): %s fixup for insn 0x%x is not supported in a non-shared link"
1656 msgstr "%B(%A+0x%lx): la compostura %s para la insn 0x%x no se admite en un enlazado que no es compartido"
1658 -#: elf32-hppa.c:4267
1659 +#: elf32-hppa.c:4290
1660 msgid "%B(%A+0x%lx): cannot handle %s for %s"
1661 msgstr "%B(%A+0x%lx): no se puede manejar %s para %s"
1663 -#: elf32-hppa.c:4574
1664 +#: elf32-hppa.c:4597
1665 msgid ".got section not immediately after .plt section"
1666 msgstr "la sección .got no está inmediatamente después de la sección .plt"
1668 -#: elf32-i386.c:364 elf32-ppc.c:1616 elf32-s390.c:379 elf64-ppc.c:2148
1669 -#: elf64-s390.c:403 elf64-x86-64.c:221
1670 +#: elf32-i386.c:362 elf32-ppc.c:1616 elf32-s390.c:379 elf64-ppc.c:2153
1671 +#: elf64-s390.c:403 elf64-x86-64.c:222
1672 msgid "%B: invalid relocation type %d"
1673 msgstr "%B: tipo de reubicación %d inválido"
1675 -#: elf32-i386.c:1085 elf32-s390.c:1185 elf32-sh.c:5063 elf64-s390.c:1149
1676 -#: elfxx-sparc.c:1243
1677 +#: elf32-i386.c:1183 elf64-x86-64.c:964
1678 +msgid "%B: TLS transition from %s to %s against `%s' at 0x%lx in section `%A' failed"
1679 +msgstr "%B: falló la transición TLS de %s para %s contra `%s' en 0x%lx en la sección `%A'"
1681 +#: elf32-i386.c:1364 elf32-s390.c:1188 elf32-sh.c:5098 elf32-xtensa.c:1162
1682 +#: elf64-s390.c:1152 elfxx-sparc.c:1263
1683 msgid "%B: `%s' accessed both as normal and thread local symbol"
1684 msgstr "%B: se accesó `%s' como un símbolo normal y un símbolo local de hilo"
1686 -#: elf32-i386.c:1200 elf32-s390.c:1294 elf64-ppc.c:4864 elf64-s390.c:1261
1687 -#: elf64-x86-64.c:1051
1688 +#: elf32-i386.c:1479 elf32-s390.c:1297 elf64-ppc.c:5046 elf64-s390.c:1264
1689 +#: elf64-x86-64.c:1299
1690 msgid "%B: bad relocation section name `%s'"
1691 msgstr "%B: nombre de sección de reubicación `%s' erróneo"
1693 -#: elf32-i386.c:2257
1694 +#: elf32-i386.c:2598
1695 msgid "%B: unrecognized relocation (0x%x) in section `%A'"
1696 msgstr "%B: no se reconoce la dirección de reubicación (0x%lx) en la sección `%A'"
1698 -#: elf32-i386.c:2479
1699 +#: elf32-i386.c:2822 elf64-x86-64.c:2660
1700 +msgid "hidden symbol"
1701 +msgstr "símbolo oculto"
1703 +#: elf32-i386.c:2825 elf64-x86-64.c:2663
1704 +msgid "internal symbol"
1705 +msgstr "símbolo interno"
1707 +#: elf32-i386.c:2828 elf64-x86-64.c:2666
1708 +msgid "protected symbol"
1709 +msgstr "símbolos protegido"
1711 +#: elf32-i386.c:2831 elf64-x86-64.c:2669
1715 +#: elf32-i386.c:2836
1716 +msgid "%B: relocation R_386_GOTOFF against undefined %s `%s' can not be used when making a shared object"
1717 +msgstr "%B: no se puede usar la reubicación R_386_GOTOFF contra %s indefinida `%s' cuando se hace un objeto compartido"
1719 +#: elf32-i386.c:2846
1720 msgid "%B: relocation R_386_GOTOFF against protected function `%s' can not be used when making a shared object"
1721 msgstr "%B: no se puede usar la reubicación R_386_GOTOFF contra la función protegida `%s' cuando se hace un objeto compartido"
1723 @@ -1308,7 +1505,7 @@ msgstr "enlazador ip2k: instrucci
1724 msgid "unsupported relocation between data/insn address spaces"
1725 msgstr "no se admite la reubicación entre espacios de direcciones datos/insn"
1727 -#: elf32-iq2000.c:821 elf32-m32c.c:831
1728 +#: elf32-iq2000.c:865 elf32-m32c.c:826
1730 msgid "%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
1731 msgstr "%s: usa campos de e_flags diferentes (0x%lx) que los módulos previos (0x%lx)"
1732 @@ -1345,86 +1542,94 @@ msgstr ": instrucciones m32rx"
1733 msgid ": m32r2 instructions"
1734 msgstr ": instrucciones m32r2"
1736 -#: elf32-m68hc1x.c:1045
1737 +#: elf32-m68hc1x.c:1047
1739 msgid "Reference to the far symbol `%s' using a wrong relocation may result in incorrect execution"
1740 msgstr "El referenciar al símbolo far `%s' usando una reubicación incorrecta puede resultar en una ejecución incorrecta"
1742 -#: elf32-m68hc1x.c:1068
1743 +#: elf32-m68hc1x.c:1070
1745 msgid "banked address [%lx:%04lx] (%lx) is not in the same bank as current banked address [%lx:%04lx] (%lx)"
1746 msgstr "la dirección almacenada [%lx:%04lx] (%lx) no está en el mismo banco que la dirección almacenada actual [%lx:%04lx] (%lx)"
1748 -#: elf32-m68hc1x.c:1087
1749 +#: elf32-m68hc1x.c:1089
1751 msgid "reference to a banked address [%lx:%04lx] in the normal address space at %04lx"
1752 msgstr "referencia a una dirección almacenada [%lx:%04lx] en el espacio normal de direcciones en %04lx"
1754 -#: elf32-m68hc1x.c:1220
1755 +#: elf32-m68hc1x.c:1222
1756 msgid "%B: linking files compiled for 16-bit integers (-mshort) and others for 32-bit integers"
1757 msgstr "%B: se enlazan ficheros compilados con enteros de 16-bit (-mshort) y otros con enteros de 32-bit"
1759 -#: elf32-m68hc1x.c:1227
1760 +#: elf32-m68hc1x.c:1229
1761 msgid "%B: linking files compiled for 32-bit double (-fshort-double) and others for 64-bit double"
1762 msgstr "%B: se enlazan ficheros compilados con dobles de 32-bit (-fshort-double) y otros con dobles de 64-bit"
1764 -#: elf32-m68hc1x.c:1236
1765 +#: elf32-m68hc1x.c:1238
1766 msgid "%B: linking files compiled for HCS12 with others compiled for HC12"
1767 msgstr "%B: se enlazan ficheros compilados para HCS12, con otros compilados para HC12"
1769 -#: elf32-m68hc1x.c:1252 elf32-ppc.c:3734 elf64-sparc.c:697 elfxx-mips.c:11292
1770 +#: elf32-m68hc1x.c:1254 elf32-ppc.c:4046 elf64-sparc.c:697 elfxx-mips.c:12561
1771 msgid "%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"
1772 msgstr "%B: usa campos de e_flags diferentes (0x%lx) que los módulos previos (0x%lx)"
1774 -#: elf32-m68hc1x.c:1280
1775 +#: elf32-m68hc1x.c:1282
1777 msgid "[abi=32-bit int, "
1778 msgstr "[abi=int de 32-bit, "
1780 -#: elf32-m68hc1x.c:1282
1781 +#: elf32-m68hc1x.c:1284
1783 msgid "[abi=16-bit int, "
1784 msgstr "[abi=int de 16-bit, "
1786 -#: elf32-m68hc1x.c:1285
1787 +#: elf32-m68hc1x.c:1287
1789 msgid "64-bit double, "
1790 msgstr "doble de 64-bit, "
1792 -#: elf32-m68hc1x.c:1287
1793 +#: elf32-m68hc1x.c:1289
1795 msgid "32-bit double, "
1796 msgstr "doble de 32-bit, "
1798 -#: elf32-m68hc1x.c:1290
1799 +#: elf32-m68hc1x.c:1292
1804 -#: elf32-m68hc1x.c:1292
1805 +#: elf32-m68hc1x.c:1294
1810 -#: elf32-m68hc1x.c:1294
1811 +#: elf32-m68hc1x.c:1296
1816 -#: elf32-m68hc1x.c:1297
1817 +#: elf32-m68hc1x.c:1299
1819 msgid " [memory=bank-model]"
1820 msgstr " [memoria=modelo de bancos]"
1822 -#: elf32-m68hc1x.c:1299
1823 +#: elf32-m68hc1x.c:1301
1825 msgid " [memory=flat]"
1826 msgstr " [memoria=plana]"
1828 -#: elf32-m68k.c:635 elf32-m68k.c:636
1829 +#: elf32-m68k.c:789 elf32-m68k.c:790
1831 msgstr "desconocido"
1833 +#: elf32-m68k.c:1216
1834 +msgid "%B: GOT overflow: Number of R_68K_GOT8O relocations > %d"
1835 +msgstr "%B: desbordamiento de GOT: Número de reubicaciones R_68K_GOT80 > %d"
1837 +#: elf32-m68k.c:1221
1838 +msgid "%B: GOT overflow: Number of R_68K_GOT8O and R_68K_GOT16O relocations > %d"
1839 +msgstr "%B desbordamiento de GOT: Número de reubicaciones R_68K_GOT80 Y R_68K_GOT160 > %d"
1841 #: elf32-mcore.c:99 elf32-mcore.c:442
1842 msgid "%B: Relocation %s (%d) is not currently supported.\n"
1843 msgstr "%B: La reubicación %s (%d) actualmente no se admite.\n"
1844 @@ -1433,24 +1638,24 @@ msgstr "%B: La reubicaci
1845 msgid "%B: Unknown relocation type %d\n"
1846 msgstr "%B: Tipo de reubicación %d desconocido\n"
1850 msgid "%B and %B are for different cores"
1851 msgstr "%B y %B son para núcleos diferentes"
1855 msgid "%B and %B are for different configurations"
1856 msgstr "%B y %B son para configuraciones diferentes"
1861 msgid "private flags = 0x%lx"
1862 msgstr "opciones privadas = 0x%lx"
1864 -#: elf32-mips.c:989 elf64-mips.c:1976 elfn32-mips.c:1808
1865 +#: elf32-mips.c:1045 elf64-mips.c:2056 elfn32-mips.c:1888
1866 msgid "literal relocation occurs for an external symbol"
1867 msgstr "la reubicación literal sucede para un símbolo externo"
1869 -#: elf32-mips.c:1029 elf32-score.c:484 elf64-mips.c:2019 elfn32-mips.c:1849
1870 +#: elf32-mips.c:1085 elf32-score.c:484 elf64-mips.c:2099 elfn32-mips.c:1929
1871 msgid "32bits gp relative relocation occurs for an external symbol"
1872 msgstr "la reubicación gp relativa de 32bits sucede para un símbolo externo"
1874 @@ -1459,162 +1664,143 @@ msgstr "la reubicaci
1875 msgid "generic linker can't handle %s"
1876 msgstr "el enlazador genérico no puede manejar %s"
1878 -#: elf32-ppc.c:2163
1879 +#: elf32-ppc.c:2161
1880 msgid "corrupt or empty %s section in %B"
1881 msgstr "sección %s corrupta o vacía en %B"
1883 -#: elf32-ppc.c:2170
1884 +#: elf32-ppc.c:2168
1885 msgid "unable to read in %s section from %B"
1886 msgstr "no se puede leer en la sección %s desde %B"
1888 -#: elf32-ppc.c:2176
1889 +#: elf32-ppc.c:2174
1890 msgid "corrupt %s section in %B"
1891 msgstr "sección %s corrupta en %B"
1893 -#: elf32-ppc.c:2219
1894 +#: elf32-ppc.c:2217
1895 msgid "warning: unable to set size of %s section in %B"
1896 msgstr "aviso: no se puede establecer el tamaño de la sección %s en %B"
1898 -#: elf32-ppc.c:2267
1899 +#: elf32-ppc.c:2265
1900 msgid "failed to allocate space for new APUinfo section."
1901 msgstr "no se puede reservar espacio para la nueva sección APUinfo."
1903 -#: elf32-ppc.c:2286
1904 +#: elf32-ppc.c:2284
1905 msgid "failed to compute new APUinfo section."
1906 msgstr "no se puede calcular la nueva sección APUinfo."
1908 -#: elf32-ppc.c:2289
1909 +#: elf32-ppc.c:2287
1910 msgid "failed to install new APUinfo section."
1911 msgstr "no se puede instalar la nueva sección APUinfo."
1913 -#: elf32-ppc.c:3022
1914 +#: elf32-ppc.c:3263
1915 msgid "%B: relocation %s cannot be used when making a shared object"
1916 msgstr "%B: no se puede usar la reubicación %s cuando se hace un objeto compartido"
1918 #. It does not make sense to have a procedure linkage
1919 #. table entry for a local symbol.
1920 -#: elf32-ppc.c:3292
1921 +#: elf32-ppc.c:3534
1922 msgid "%B(%A+0x%lx): %s reloc against local symbol"
1923 msgstr "%B(%A+0x%lx): reubicación %s contra un símbolo local"
1925 -#: elf32-ppc.c:3633 elf32-ppc.c:3637 elfxx-mips.c:11036 elfxx-mips.c:11055
1926 -#: elfxx-mips.c:11070
1927 +#: elf32-ppc.c:3885 elf32-ppc.c:3900 elfxx-mips.c:12268 elfxx-mips.c:12294
1928 +#: elfxx-mips.c:12316 elfxx-mips.c:12342
1929 msgid "Warning: %B uses hard float, %B uses soft float"
1930 msgstr "Aviso: %B usa coma flotante hard, %B usa coma flotante soft"
1932 -#: elf32-ppc.c:3640 elf32-ppc.c:3644 elfxx-mips.c:11017 elfxx-mips.c:11021
1933 +#: elf32-ppc.c:3888 elf32-ppc.c:3892
1934 +msgid "Warning: %B uses double-precision hard float, %B uses single-precision hard float"
1935 +msgstr "Aviso: %B usa coma flotante hard de doble precisión, %B usa coma flotante hard de precisión simple"
1937 +#: elf32-ppc.c:3896
1938 +msgid "Warning: %B uses soft float, %B uses single-precision hard float"
1939 +msgstr "Aviso: %B usa coma flotante soft, %B usa coma flotante hard de precisión simple"
1941 +#: elf32-ppc.c:3903 elf32-ppc.c:3907 elfxx-mips.c:12248 elfxx-mips.c:12252
1942 msgid "Warning: %B uses unknown floating point ABI %d"
1943 msgstr "Aviso: %B usa la ABI de coma flotante desconocida %d"
1945 -#: elf32-ppc.c:3699
1946 +#: elf32-ppc.c:3949 elf32-ppc.c:3953
1947 +msgid "Warning: %B uses unknown vector ABI %d"
1948 +msgstr "Aviso: %B usa la ABI de vector desconocida %d"
1950 +#: elf32-ppc.c:3957
1951 +msgid "Warning: %B uses vector ABI \"%s\", %B uses \"%s\""
1952 +msgstr "Aviso: %B usa la ABI de vector \"%s\", %B usa \"%s\""
1954 +#: elf32-ppc.c:4011
1955 msgid "%B: compiled with -mrelocatable and linked with modules compiled normally"
1956 msgstr "%B: compilado con -mrelocatable y enlazado con módulos compilados de forma normal"
1958 -#: elf32-ppc.c:3707
1959 +#: elf32-ppc.c:4019
1960 msgid "%B: compiled normally and linked with modules compiled with -mrelocatable"
1961 msgstr "%B: compilado de forma normal y enlazado con módulos compilados con -mrelocatable"
1963 -#: elf32-ppc.c:3793
1964 +#: elf32-ppc.c:4105
1965 msgid "Using bss-plt due to %B"
1966 msgstr "Se usa bss-plt debido a %B"
1968 -#: elf32-ppc.c:6002 elf64-ppc.c:10490
1969 +#: elf32-ppc.c:6418 elf64-ppc.c:10881
1970 msgid "%B: unknown relocation type %d for symbol %s"
1971 msgstr "%B: tipo de reubicación %d desconocido para el símbolo %s"
1973 -#: elf32-ppc.c:6252
1974 +#: elf32-ppc.c:6668
1975 msgid "%B(%A+0x%lx): non-zero addend on %s reloc against `%s'"
1976 msgstr "%B(%A+0x%lx): adición que no es cero en la reubicación %s contra `%s'"
1978 -#: elf32-ppc.c:6597 elf32-ppc.c:6623 elf32-ppc.c:6682
1979 +#: elf32-ppc.c:7024 elf32-ppc.c:7050 elf32-ppc.c:7109
1980 msgid "%B: the target (%s) of a %s relocation is in the wrong output section (%s)"
1981 msgstr "%B: el objetivo (%s) de una reubicación %s está en la sección de salida errónea (%s)"
1983 -#: elf32-ppc.c:6737
1984 +#: elf32-ppc.c:7164
1985 msgid "%B: relocation %s is not yet supported for symbol %s."
1986 msgstr "%B: la reubicación %s aún no se admite para el símbolo %s."
1988 -#: elf32-ppc.c:6845 elf64-ppc.c:11185
1989 +#: elf32-ppc.c:7272 elf64-ppc.c:11575
1990 msgid "%B(%A+0x%lx): %s reloc against `%s': error %d"
1991 msgstr "%B(%A+0x%lx): reubicación %s contra `%s': error %d"
1993 -#: elf32-s390.c:2238 elf64-s390.c:2212
1994 +#: elf32-s390.c:2246 elf64-s390.c:2220
1995 msgid "%B(%A+0x%lx): invalid instruction for TLS relocation %s"
1996 msgstr "%B(%A+0x%lx): instrucción inválida para la reubicación TLS %s"
1998 -#: elf32-score.c:1418 elfxx-mips.c:2699
1999 +#: elf32-score.c:1415 elfxx-mips.c:3273
2000 msgid "not enough GOT space for local GOT entries"
2001 msgstr "no hay suficiente espacio GOT para entradas GOT locales"
2003 -#: elf32-score.c:2550
2004 +#: elf32-score.c:2545
2006 msgid "%s: Malformed reloc detected for section %s"
2007 msgstr "%s: Se detectó una reubicación malformada para la sección %s"
2009 -#: elf32-score.c:2601
2010 +#: elf32-score.c:2596
2011 msgid "%B: CALL15 reloc at 0x%lx not against global symbol"
2012 msgstr "%B: la reubicación CALL15 en 0x%lx no es contra un símbolo global"
2014 -#: elf32-score.c:3756
2015 +#: elf32-score.c:3753
2020 -#: elf32-score.c:3760
2021 +#: elf32-score.c:3757
2026 -#: elf32-score.c:3802 elfxx-mips.c:11201
2027 +#: elf32-score.c:3799
2028 msgid "%B: warning: linking PIC files with non-PIC files"
2029 msgstr "%B: aviso: se enlazan ficheros PIC con ficheros que no son PIC"
2031 -#: elf32-sh64.c:222 elf64-sh64.c:2350
2033 -msgid "%s: compiled as 32-bit object and %s is 64-bit"
2034 -msgstr "%s: compilado como un objeto de 32-bit y %s es de 64-bit"
2036 -#: elf32-sh64.c:225 elf64-sh64.c:2353
2038 -msgid "%s: compiled as 64-bit object and %s is 32-bit"
2039 -msgstr "%s: compilado como un objeto de 64-bit y %s es de 32-bit"
2041 -#: elf32-sh64.c:227 elf64-sh64.c:2355
2043 -msgid "%s: object size does not match that of target %s"
2044 -msgstr "%s: el tamaño del objeto no coincide con el tamaño del objetivo %s"
2046 -#: elf32-sh64.c:450 elf64-sh64.c:2894
2048 -msgid "%s: encountered datalabel symbol in input"
2049 -msgstr "%s: se encontró un símbolo datalabel en la entrada"
2051 -#: elf32-sh64.c:527
2052 -msgid "PTB mismatch: a SHmedia address (bit 0 == 1)"
2053 -msgstr "No coincide PTB: una dirección SHmedia (bit 0 == 1)"
2055 -#: elf32-sh64.c:530
2056 -msgid "PTA mismatch: a SHcompact address (bit 0 == 0)"
2057 -msgstr "No coincide PTA: una dirección SHcompact (bit 0 == 0)"
2059 -#: elf32-sh64.c:548
2061 -msgid "%s: GAS error: unexpected PTB insn with R_SH_PT_16"
2062 -msgstr "%s: error de GAS: instrucción PTB inesperada con R_SH_PT_16"
2064 -#: elf32-sh64.c:597
2065 -msgid "%B: error: unaligned relocation type %d at %08x reloc %p\n"
2066 -msgstr "%B: error: tipo de reubicación %d sin alinear en %08x reubicación %p\n"
2067 +#: elf32-sh-symbian.c:130
2068 +msgid "%B: IMPORT AS directive for %s conceals previous IMPORT AS"
2069 +msgstr "%B: la directiva IMPORT AS para %s oculta un IMPORT AS previo"
2071 -#: elf32-sh64.c:673
2073 -msgid "%s: could not write out added .cranges entries"
2074 -msgstr "%s: no se pueden escribir las entradas .cranges agregadas"
2075 +#: elf32-sh-symbian.c:383
2076 +msgid "%B: Unrecognised .directive command: %s"
2077 +msgstr "%B: Orden .directive no reconocida: %s"
2079 -#: elf32-sh64.c:733
2081 -msgid "%s: could not write out sorted .cranges entries"
2082 -msgstr "%s: no se pueden escribir las entradas .cranges ordenadas"
2083 +#: elf32-sh-symbian.c:504
2084 +msgid "%B: Failed to add renamed symbol %s"
2085 +msgstr "%B: Falló al agregar el símbolo renombrado %s"
2088 msgid "%B: 0x%lx: warning: bad R_SH_USES offset"
2089 @@ -1648,41 +1834,76 @@ msgstr "%B: 0x%lx: aviso: cuenta err
2090 msgid "%B: 0x%lx: fatal: reloc overflow while relaxing"
2091 msgstr "%B: 0x%lx: fatal: desbordamiento de reubicación durante la relajación"
2093 -#: elf32-sh.c:3249 elf64-sh64.c:1526
2094 +#: elf32-sh.c:3279 elf64-sh64.c:1526
2095 msgid "Unexpected STO_SH5_ISA32 on local symbol is not handled"
2096 msgstr "No se maneja un STO_SH5_ISA32 inesperado en un símbolo local"
2100 msgid "%B: 0x%lx: fatal: unaligned branch target for relax-support relocation"
2101 msgstr "%B: 0x%lx: fatal: objetivo de ramificación sin alineación para la reubicación de soporte de relajamiento"
2103 -#: elf32-sh.c:3519 elf32-sh.c:3534
2104 +#: elf32-sh.c:3549 elf32-sh.c:3564
2105 msgid "%B: 0x%lx: fatal: unaligned %s relocation 0x%lx"
2106 msgstr "%B: 0x%lx: fatal: reubicación %s sin alineación 0x%lx"
2110 msgid "%B: 0x%lx: fatal: R_SH_PSHA relocation %d not in range -32..32"
2111 msgstr "%B: 0x%lx: fatal: la reubicación R_SH_PSHA %d no está en el rango -32..32"
2115 msgid "%B: 0x%lx: fatal: R_SH_PSHL relocation %d not in range -32..32"
2116 msgstr "%B: 0x%lx: fatal: la reubicación R_SH_PSHL %d no está en el rango -32..32"
2118 -#: elf32-sh.c:5275 elf64-alpha.c:4533
2119 +#: elf32-sh.c:5310 elf64-alpha.c:4552
2120 msgid "%B: TLS local exec code cannot be linked into shared objects"
2121 msgstr "%B: el código de ejecución local TLS no se puede enlazar en objetos compartidos"
2123 -#: elf32-sh-symbian.c:130
2124 -msgid "%B: IMPORT AS directive for %s conceals previous IMPORT AS"
2125 -msgstr "%B: la directiva IMPORT AS para %s oculta un IMPORT AS previo"
2126 +#: elf32-sh64.c:222 elf64-sh64.c:2345
2128 +msgid "%s: compiled as 32-bit object and %s is 64-bit"
2129 +msgstr "%s: compilado como un objeto de 32-bit y %s es de 64-bit"
2131 -#: elf32-sh-symbian.c:383
2132 -msgid "%B: Unrecognised .directive command: %s"
2133 -msgstr "%B: Orden .directive no reconocida: %s"
2134 +#: elf32-sh64.c:225 elf64-sh64.c:2348
2136 +msgid "%s: compiled as 64-bit object and %s is 32-bit"
2137 +msgstr "%s: compilado como un objeto de 64-bit y %s es de 32-bit"
2139 -#: elf32-sh-symbian.c:504
2140 -msgid "%B: Failed to add renamed symbol %s"
2141 -msgstr "%B: Falló al agregar el símbolo renombrado %s"
2142 +#: elf32-sh64.c:227 elf64-sh64.c:2350
2144 +msgid "%s: object size does not match that of target %s"
2145 +msgstr "%s: el tamaño del objeto no coincide con el tamaño del objetivo %s"
2147 +#: elf32-sh64.c:450 elf64-sh64.c:2888
2149 +msgid "%s: encountered datalabel symbol in input"
2150 +msgstr "%s: se encontró un símbolo datalabel en la entrada"
2152 +#: elf32-sh64.c:527
2153 +msgid "PTB mismatch: a SHmedia address (bit 0 == 1)"
2154 +msgstr "No coincide PTB: una dirección SHmedia (bit 0 == 1)"
2156 +#: elf32-sh64.c:530
2157 +msgid "PTA mismatch: a SHcompact address (bit 0 == 0)"
2158 +msgstr "No coincide PTA: una dirección SHcompact (bit 0 == 0)"
2160 +#: elf32-sh64.c:548
2162 +msgid "%s: GAS error: unexpected PTB insn with R_SH_PT_16"
2163 +msgstr "%s: error de GAS: instrucción PTB inesperada con R_SH_PT_16"
2165 +#: elf32-sh64.c:597
2166 +msgid "%B: error: unaligned relocation type %d at %08x reloc %p\n"
2167 +msgstr "%B: error: tipo de reubicación %d sin alinear en %08x reubicación %p\n"
2169 +#: elf32-sh64.c:673
2171 +msgid "%s: could not write out added .cranges entries"
2172 +msgstr "%s: no se pueden escribir las entradas .cranges agregadas"
2174 +#: elf32-sh64.c:733
2176 +msgid "%s: could not write out sorted .cranges entries"
2177 +msgstr "%s: no se pueden escribir las entradas .cranges ordenadas"
2180 msgid "%B: compiled for a 64 bit system and target is 32 bit"
2181 @@ -1692,69 +1913,103 @@ msgstr "%B: compilado para un sistema de 64 bit y el objetivo es de 32 bit"
2182 msgid "%B: linking little endian files with big endian files"
2183 msgstr "%B: se enlazan ficheros little endian con ficheros big endian"
2187 +msgid "%X%P: overlay sections %A and %A do not start at the same address.\n"
2188 +msgstr "%X%P: las secciones de sobreescritura %A y %A no inician en la misma dirección.\n"
2191 msgid "warning: call to non-function symbol %s defined in %B"
2192 msgstr "aviso: se llama al símbolo %s que no es función, definido en %B"
2194 -#: elf32-spu.c:1315
2195 +#: elf32-spu.c:1406
2196 msgid "%B is not allowed to define %s"
2197 msgstr "%B no se permite para definir %s"
2199 -#: elf32-spu.c:1352
2200 +#: elf32-spu.c:1453
2202 msgid "%s in overlay section"
2203 msgstr "%s en la sección de sobreescritura"
2205 -#: elf32-spu.c:1363
2206 +#: elf32-spu.c:1469
2207 msgid "overlay stub relocation overflow"
2208 msgstr "desbordamiento del segmento de reubicación de sobreescritura"
2210 -#: elf32-spu.c:1820
2211 +#: elf32-spu.c:1478 elf64-ppc.c:10078
2212 +msgid "stubs don't match calculated size"
2213 +msgstr "los cabos no coinciden con el tamaño calculado"
2215 +#: elf32-spu.c:1976
2217 msgid "warning: %s overlaps %s\n"
2218 msgstr "aviso: %s sobreescribe %s\n"
2220 -#: elf32-spu.c:1836
2221 +#: elf32-spu.c:1992
2223 msgid "warning: %s exceeds section size\n"
2224 msgstr "aviso: %s excede el tamaño de la sección\n"
2226 -#: elf32-spu.c:1867
2227 +#: elf32-spu.c:2023
2228 msgid "%A:0x%v not found in function table\n"
2229 msgstr "%A:0x%v no se encuentra en la tabla de función\n"
2231 -#: elf32-spu.c:1958
2232 -msgid "%B(%A+0x%v): call to non-code section %B(%A), stack analysis incomplete\n"
2233 -msgstr "%B(%A+0x%v): se llama a la sección %B(%A) que no es de código, análisis de pila incompleto\n"
2234 +#: elf32-spu.c:2165
2235 +msgid "%B(%A+0x%v): call to non-code section %B(%A), analysis incomplete\n"
2236 +msgstr "%B(%A+0x%v): se llama a la sección %B(%A) que no es de código, análisis incompleto\n"
2238 -#: elf32-spu.c:2079
2239 +#: elf32-spu.c:2339
2241 msgid "%A link_order not found\n"
2242 msgstr "no se encontró link_order %A\n"
2244 -#: elf32-spu.c:2358
2245 +#: elf32-spu.c:2706
2247 msgid "Stack analysis will ignore the call from %s to %s\n"
2248 msgstr "El análisis de pila descartará la llamada de %s a %s\n"
2250 -#: elf32-spu.c:2513
2251 +#: elf32-spu.c:3348
2252 +msgid " %s: 0x%v\n"
2253 +msgstr " %s: 0x%v\n"
2255 +#: elf32-spu.c:3349
2256 msgid "%s: 0x%v 0x%v\n"
2257 msgstr "%s: 0x%v 0x%v\n"
2259 -#: elf32-spu.c:2517
2260 +#: elf32-spu.c:3354
2264 -#: elf32-spu.c:2524
2265 +#: elf32-spu.c:3362
2270 -#: elf32-spu.c:2585
2271 +#: elf32-spu.c:3564
2273 +msgid "%s duplicated in %s\n"
2274 +msgstr "%s duplicado en %s\n"
2276 +#: elf32-spu.c:3568
2278 +msgid "%s duplicated\n"
2279 +msgstr "%s duplicado\n"
2281 +#: elf32-spu.c:3575
2282 +msgid "sorry, no support for duplicate object files in auto-overlay script\n"
2283 +msgstr "perdón, no se admiten ficheros objeto duplicados en el guión de sobreescritura automática\n"
2285 +#: elf32-spu.c:3605
2286 +msgid "non-overlay size of 0x%v plus maximum overlay size of 0x%v exceeds local store\n"
2287 +msgstr "eltamaño 0x%v que no es de sobreescritura mas el tamaño de sobreescritura máximo de 0x%v excede el almacenamiento local\n"
2289 +#: elf32-spu.c:3741
2290 +msgid "%B:%A%s exceeds overlay size\n"
2291 +msgstr "%B:%A%s excede el tamaño de sobreescritura\n"
2293 +#: elf32-spu.c:3862
2294 msgid "Stack size for call graph root nodes.\n"
2295 msgstr "Tamaño de la pila para los nodos raíz del grafo de llamadas.\n"
2297 -#: elf32-spu.c:2586
2298 +#: elf32-spu.c:3863
2301 "Stack size for functions. Annotations: '*' max stack, 't' tail call\n"
2302 @@ -1762,80 +2017,76 @@ msgstr ""
2304 "Tamaño de la pila para funciones. Anotaciones: '*' max de pila, 't' llamada cola\n"
2306 -#: elf32-spu.c:2615
2307 -msgid " %s: 0x%v\n"
2308 -msgstr " %s: 0x%v\n"
2310 -#: elf32-spu.c:2625
2311 +#: elf32-spu.c:3871
2312 msgid "Maximum stack required is 0x%v\n"
2313 msgstr "La pila máxima requerida es 0x%v\n"
2315 -#: elf32-spu.c:2751
2316 +#: elf32-spu.c:4067
2317 msgid "%B(%s+0x%lx): unresolvable %s relocation against symbol `%s'"
2318 msgstr "%B(%s+0x%lx): reubicación %s sin resolución contra el símbolo `%s'"
2320 -#: elf32-v850.c:163
2321 +#: elf32-v850.c:165
2323 msgid "Variable `%s' cannot occupy in multiple small data regions"
2324 msgstr "La variable `%s' no puede ocupar múltiples regiones de datos small"
2326 -#: elf32-v850.c:166
2327 +#: elf32-v850.c:168
2329 msgid "Variable `%s' can only be in one of the small, zero, and tiny data regions"
2330 msgstr "La variable `%s' solamente puede estar en una de las regiones de datos small, cero, y tiny"
2332 -#: elf32-v850.c:169
2333 +#: elf32-v850.c:171
2335 msgid "Variable `%s' cannot be in both small and zero data regions simultaneously"
2336 msgstr "La variable `%s' no puede estar simultáneamente en las regiones de datos small y cero"
2338 -#: elf32-v850.c:172
2339 +#: elf32-v850.c:174
2341 msgid "Variable `%s' cannot be in both small and tiny data regions simultaneously"
2342 msgstr "La variable `%s' no puede estar simultáneamente en las regiones de datos small y tiny"
2344 -#: elf32-v850.c:175
2345 +#: elf32-v850.c:177
2347 msgid "Variable `%s' cannot be in both zero and tiny data regions simultaneously"
2348 msgstr "La variable `%s' no puede estar simultáneamente en las regiones de datos cero y tiny"
2350 -#: elf32-v850.c:478
2351 +#: elf32-v850.c:480
2353 msgid "FAILED to find previous HI16 reloc\n"
2354 msgstr "FALLO para encontrar la reubicación HI16 previa\n"
2356 -#: elf32-v850.c:1713
2357 +#: elf32-v850.c:1715
2358 msgid "could not locate special linker symbol __gp"
2359 msgstr "no se puede localizar el símbolo especial del enlazador __gp"
2361 -#: elf32-v850.c:1717
2362 +#: elf32-v850.c:1719
2363 msgid "could not locate special linker symbol __ep"
2364 msgstr "no se puede localizar el símbolo especial del enlazador __ep"
2366 -#: elf32-v850.c:1721
2367 +#: elf32-v850.c:1723
2368 msgid "could not locate special linker symbol __ctbp"
2369 msgstr "no se puede localizar el símbolo especial del enlazador __ctbp"
2371 -#: elf32-v850.c:1871
2372 +#: elf32-v850.c:1873
2373 msgid "%B: Architecture mismatch with previous modules"
2374 msgstr "%B: No coincide la arquitectura con los módulos previos"
2376 -#: elf32-v850.c:1890
2377 +#: elf32-v850.c:1892
2379 msgid "private flags = %lx: "
2380 msgstr "opciones privadas = %lx: "
2382 -#: elf32-v850.c:1895
2383 +#: elf32-v850.c:1897
2385 msgid "v850 architecture"
2386 msgstr "arquitectura v850"
2388 -#: elf32-v850.c:1896
2389 +#: elf32-v850.c:1898
2391 msgid "v850e architecture"
2392 msgstr "arquitectura v850e"
2394 -#: elf32-v850.c:1897
2395 +#: elf32-v850.c:1899
2397 msgid "v850e1 architecture"
2398 msgstr "arquitectura v850e1"
2399 @@ -1860,114 +2111,118 @@ msgstr " [flotante-g]"
2400 msgid "%s: warning: GOT addend of %ld to `%s' does not match previous GOT addend of %ld"
2401 msgstr "%s: aviso: la adición GOT de %ld a `%s' no coincide con la adición previa GOT de %ld"
2403 -#: elf32-vax.c:1584
2404 +#: elf32-vax.c:1589
2406 msgid "%s: warning: PLT addend of %d to `%s' from %s section ignored"
2407 msgstr "%s: aviso: se descarta la adición PLT de %d a `%s' de la sección %s"
2409 -#: elf32-vax.c:1721
2410 +#: elf32-vax.c:1726
2412 msgid "%s: warning: %s relocation against symbol `%s' from %s section"
2413 msgstr "%s: aviso: reubicación %s contra el símbolo `%s' de la sección %s"
2415 -#: elf32-vax.c:1727
2416 +#: elf32-vax.c:1732
2418 msgid "%s: warning: %s relocation to 0x%x from %s section"
2419 msgstr "%s: aviso: reubicación %s a 0x%x de la sección %s"
2421 -#: elf32-xstormy16.c:451 elf32-ia64.c:2962 elf64-ia64.c:2962
2422 +#: elf32-xstormy16.c:451 elf32-ia64.c:2794 elf64-ia64.c:2794
2423 msgid "non-zero addend in @fptr reloc"
2424 msgstr "adición que no es cero en la reubicación @fptr"
2426 -#: elf32-xtensa.c:733
2427 +#: elf32-xtensa.c:911
2428 msgid "%B(%A): invalid property table"
2429 msgstr "%B(%A): tabla de propiedades inválida"
2431 -#: elf32-xtensa.c:2177
2432 +#: elf32-xtensa.c:2734
2433 msgid "%B(%A+0x%lx): relocation offset out of range (size=0x%x)"
2434 msgstr "%B(%A+0x%lx): desplazamiento de reubicación fuera de rango (tamaño=0x%x)"
2436 -#: elf32-xtensa.c:2234
2437 +#: elf32-xtensa.c:2813 elf32-xtensa.c:2934
2438 msgid "dynamic relocation in read-only section"
2439 msgstr "reubicación dinámica en la sección de sólo lectura"
2441 -#: elf32-xtensa.c:2407
2442 +#: elf32-xtensa.c:2910
2443 +msgid "TLS relocation invalid without dynamic sections"
2444 +msgstr "reubicación TLS inválida sin secciones dinámicas"
2446 +#: elf32-xtensa.c:3127
2447 msgid "internal inconsistency in size of .got.loc section"
2448 msgstr "inconsistencia interna en el tamaño de la sección .got.loc"
2450 -#: elf32-xtensa.c:2714
2451 +#: elf32-xtensa.c:3437
2452 msgid "%B: incompatible machine type. Output is 0x%x. Input is 0x%x"
2453 msgstr "%B: tipo de máquina incompatible. La salida es 0x%x. La entrada es 0x%x"
2455 -#: elf32-xtensa.c:3920 elf32-xtensa.c:3928
2456 +#: elf32-xtensa.c:4666 elf32-xtensa.c:4674
2457 msgid "Attempt to convert L32R/CALLX to CALL failed"
2458 msgstr "Falló el intento de convertir L32R/CALLX a CALL"
2460 -#: elf32-xtensa.c:5522 elf32-xtensa.c:5598 elf32-xtensa.c:6714
2461 +#: elf32-xtensa.c:6276 elf32-xtensa.c:6352 elf32-xtensa.c:7468
2462 msgid "%B(%A+0x%lx): could not decode instruction; possible configuration mismatch"
2463 msgstr "%B(%A+0x%lx): no se puede decodificar la instrucción; posible falta de coincidencia de la configuración"
2465 -#: elf32-xtensa.c:6454
2466 +#: elf32-xtensa.c:7208
2467 msgid "%B(%A+0x%lx): could not decode instruction for XTENSA_ASM_SIMPLIFY relocation; possible configuration mismatch"
2468 msgstr "%B(%A+0x%lx): no se puede decodificar la instrucción para la reubicación XTENSA_ASM_SIMPLIFY; posible falta de coincidencia de la configuración"
2470 -#: elf32-xtensa.c:8166
2471 +#: elf32-xtensa.c:8969
2472 msgid "invalid relocation address"
2473 msgstr "dirección de reubicación inválida"
2475 -#: elf32-xtensa.c:8215
2476 +#: elf32-xtensa.c:9018
2477 msgid "overflow after relaxation"
2478 msgstr "desbordamiento después de la relajación"
2480 -#: elf32-xtensa.c:9341
2481 +#: elf32-xtensa.c:10154
2482 msgid "%B(%A+0x%lx): unexpected fix for %s relocation"
2483 msgstr "%B(%A+0x%lx): compostura inesperada para la reubicación %s"
2485 -#: elf64-alpha.c:453
2486 +#: elf64-alpha.c:452
2487 msgid "GPDISP relocation did not find ldah and lda instructions"
2488 msgstr "la reubicación GPDISP no encontró las instrucciones ldah y lda"
2490 -#: elf64-alpha.c:2404
2491 +#: elf64-alpha.c:2416
2492 msgid "%B: .got subsegment exceeds 64K (size %d)"
2493 msgstr "%B: el subsegmento .got excede los 64K (tamaño %d)"
2495 -#: elf64-alpha.c:4277 elf64-alpha.c:4289
2496 +#: elf64-alpha.c:4296 elf64-alpha.c:4308
2497 msgid "%B: gp-relative relocation against dynamic symbol %s"
2498 msgstr "%B: reubicación gp relativa contra el símbolo dinámico %s"
2500 -#: elf64-alpha.c:4315 elf64-alpha.c:4450
2501 +#: elf64-alpha.c:4334 elf64-alpha.c:4469
2502 msgid "%B: pc-relative relocation against dynamic symbol %s"
2503 msgstr "%B: reubicación relativa al pc contra el símbolo dinámico %s"
2505 -#: elf64-alpha.c:4343
2506 +#: elf64-alpha.c:4362
2507 msgid "%B: change in gp: BRSGP %s"
2508 msgstr "%B: cambio en gp: BRSGP %s"
2510 -#: elf64-alpha.c:4368
2511 +#: elf64-alpha.c:4387
2513 msgstr "<desconocido>"
2515 -#: elf64-alpha.c:4373
2516 +#: elf64-alpha.c:4392
2517 msgid "%B: !samegp reloc against symbol without .prologue: %s"
2518 msgstr "%B: reubicación !samegp contra un símbolo sin .prologue: %s"
2520 -#: elf64-alpha.c:4425
2521 +#: elf64-alpha.c:4444
2522 msgid "%B: unhandled dynamic relocation against %s"
2523 msgstr "%B: reubicación dinámica sin manejar contra %s"
2525 -#: elf64-alpha.c:4457
2526 +#: elf64-alpha.c:4476
2527 msgid "%B: pc-relative relocation against undefined weak symbol %s"
2528 msgstr "%B: reubicación relativa al pc contra el símbolo débil sin definir %s"
2530 -#: elf64-alpha.c:4517
2531 +#: elf64-alpha.c:4536
2532 msgid "%B: dtp-relative relocation against dynamic symbol %s"
2533 msgstr "%B: reubicación relativa a dtp contra el símbolo dinámico %s"
2535 -#: elf64-alpha.c:4540
2536 +#: elf64-alpha.c:4559
2537 msgid "%B: tp-relative relocation against dynamic symbol %s"
2538 msgstr "%B: reubicación relativa a tp contra el símbolo dinámico %s"
2540 -#: elf64-hppa.c:2040
2541 +#: elf64-hppa.c:2071
2543 msgid "stub entry for %s cannot load .plt, dp offset = %ld"
2544 msgstr "la entrada de cabo para %s no puede cargar .plt, desplazamiento dp = %ld"
2545 @@ -2011,16 +2266,16 @@ msgstr "%s: la directiva LOCAL s
2546 msgid "%s: LOCAL directive: Register $%ld is not a local register. First global register is $%ld."
2547 msgstr "%s: directiva LOCAL: El registro $%ld no es un registro local. El primer registro global es $%ld."
2549 -#: elf64-mmix.c:2202
2550 +#: elf64-mmix.c:2201
2552 msgid "%s: Error: multiple definition of `%s'; start of %s is set in a earlier linked file\n"
2553 msgstr "%s: Error: definición múltiple de `%s'; el inicio de %s está definido en un fichero enlazado con anterioridad\n"
2555 -#: elf64-mmix.c:2260
2556 +#: elf64-mmix.c:2259
2557 msgid "Register section has contents\n"
2558 msgstr "La sección de registros no tiene contenido\n"
2560 -#: elf64-mmix.c:2452
2561 +#: elf64-mmix.c:2451
2564 "Internal inconsistency: remaining %u != max %u.\n"
2565 @@ -2029,69 +2284,65 @@ msgstr ""
2566 "Inconsistencia interna: %u restante != %u máximo.\n"
2567 " Por favor reporte este bicho."
2569 -#: elf64-ppc.c:2569 libbfd.c:950
2570 +#: elf64-ppc.c:2561 libbfd.c:978
2571 msgid "%B: compiled for a big endian system and target is little endian"
2572 msgstr "%B: compilado para un sistema big endian y el objetivo es little endian"
2574 -#: elf64-ppc.c:2572 libbfd.c:952
2575 +#: elf64-ppc.c:2564 libbfd.c:980
2576 msgid "%B: compiled for a little endian system and target is big endian"
2577 msgstr "%B: compilado para un sistema little endian y el objetivo es big endian"
2579 -#: elf64-ppc.c:5888
2580 +#: elf64-ppc.c:6065
2582 msgid "copy reloc against `%s' requires lazy plt linking; avoid setting LD_BIND_NOW=1 or upgrade gcc"
2583 msgstr "la reubicación de copia contra `%s' requiere de enlazado plt suelto; evite establecer LD_BIND_NOW=1 o actualice gcc"
2585 -#: elf64-ppc.c:6316
2586 +#: elf64-ppc.c:6486
2587 msgid "dynreloc miscount for %B, section %A"
2588 msgstr "cuenta errónea de la reubicación dinámica de %B, sección %A"
2590 -#: elf64-ppc.c:6420
2591 +#: elf64-ppc.c:6570
2592 msgid "%B: .opd is not a regular array of opd entries"
2593 msgstr "%B: .opd no es una matriz regular de entradas opd"
2595 -#: elf64-ppc.c:6429
2596 +#: elf64-ppc.c:6579
2597 msgid "%B: unexpected reloc type %u in .opd section"
2598 msgstr "%B: tipo de reubicación %u inesperado en la sección .opd"
2600 -#: elf64-ppc.c:6450
2601 +#: elf64-ppc.c:6600
2602 msgid "%B: undefined sym `%s' in .opd section"
2603 msgstr "%B: símbolo `%s' indefinido en la sección .opd"
2605 -#: elf64-ppc.c:7157 elf64-ppc.c:7537
2606 +#: elf64-ppc.c:7377 elf64-ppc.c:7754
2608 msgid "%s defined in removed toc entry"
2609 msgstr "se definió %s en la entrada toc eliminada"
2611 -#: elf64-ppc.c:8272
2612 +#: elf64-ppc.c:8581
2614 msgid "long branch stub `%s' offset overflow"
2615 msgstr "desbordamiento del desplazamiento de stub de ramificación long `%s'"
2617 -#: elf64-ppc.c:8347
2618 +#: elf64-ppc.c:8640
2620 msgid "can't find branch stub `%s'"
2621 msgstr "no se puede encontrar la ramificación de cabo `%s'"
2623 -#: elf64-ppc.c:8413 elf64-ppc.c:8489
2624 +#: elf64-ppc.c:8702 elf64-ppc.c:8822
2626 msgid "linkage table error against `%s'"
2627 msgstr "error de la tabla de enlazado contra `%s'"
2629 -#: elf64-ppc.c:8618
2630 +#: elf64-ppc.c:8978
2632 msgid "can't build branch stub `%s'"
2633 msgstr "no se puede construir la ramificación de cabos `%s'"
2635 -#: elf64-ppc.c:9070
2636 +#: elf64-ppc.c:9451
2637 msgid "%B section %A exceeds stub group size"
2638 msgstr "%B sección %A excede el tamaño de grupo de stub"
2640 -#: elf64-ppc.c:9682
2641 -msgid "stubs don't match calculated size"
2642 -msgstr "los cabos no coinciden con el tamaño calculado"
2644 -#: elf64-ppc.c:9694
2645 +#: elf64-ppc.c:10090
2648 "linker stubs in %u group%s\n"
2649 @@ -2108,19 +2359,19 @@ msgstr ""
2650 " ajuste toc long %lu\n"
2653 -#: elf64-ppc.c:10378
2654 +#: elf64-ppc.c:10769
2655 msgid "%B(%A+0x%lx): automatic multiple TOCs not supported using your crt files; recompile with -mminimal-toc or upgrade gcc"
2656 msgstr "%B(%A+0x%lx): no se admiten los TOCs múltiples automáticos, utilizando sus ficheros crt; recompile con -mminimal-toc o actualice gcc"
2658 -#: elf64-ppc.c:10386
2659 +#: elf64-ppc.c:10777
2660 msgid "%B(%A+0x%lx): sibling call optimization to `%s' does not allow automatic multiple TOCs; recompile with -mminimal-toc or -fno-optimize-sibling-calls, or make `%s' extern"
2661 msgstr "%B(%A+0x%lx): la optimización de llamada hermana a `%s' no permite TOCs múltiples automáticos; recompile con -mminimal-toc ó -fno-optimize-sibling-calls, o vuelva `%s' externa"
2663 -#: elf64-ppc.c:11037
2664 +#: elf64-ppc.c:11427
2665 msgid "%B: relocation %s is not supported for symbol %s."
2666 msgstr "%B: no se admite la reubicación %s para el símbolo %s."
2668 -#: elf64-ppc.c:11119
2669 +#: elf64-ppc.c:11509
2670 msgid "%B: error: relocation %s not a multiple of %d"
2671 msgstr "%B: error: la reubicación %s no es un múltiplo de %d"
2673 @@ -2149,194 +2400,48 @@ msgstr "El s
2674 msgid "%B: linking UltraSPARC specific with HAL specific code"
2675 msgstr "%B: se enlaza código específico de UltraSPARC con código específico de HAL"
2677 -#: elf64-x86-64.c:799 elf64-x86-64.c:959 elf64-x86-64.c:2360
2678 +#: elf64-x86-64.c:1047 elf64-x86-64.c:1207 elfxx-mips.c:7834
2679 msgid "%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"
2680 msgstr "%B: no se puede usar la reubicación %s contra `%s' cuando se hace un objeto compartido; recompile con -fPIC"
2682 -#: elf64-x86-64.c:890
2683 -msgid "%B: %s' accessed both as normal and thread local symbol"
2684 -msgstr "%B: se accesó `%s' como un símbolo normal y como un símbolo local de hilo"
2685 +#: elf64-x86-64.c:1138
2686 +msgid "%B: '%s' accessed both as normal and thread local symbol"
2687 +msgstr "%B: se accedió a '%s' como un símbolo normal y como un símbolo local de hilo"
2689 -#: elf64-x86-64.c:2272
2690 +#: elf64-x86-64.c:2559
2691 msgid "%B: relocation R_X86_64_GOTOFF64 against protected function `%s' can not be used when making a shared object"
2692 msgstr "%B: no se puede usar la reubicación R_X86_64_GOTOFF contra la función protegida `%s' cuando se hace un objeto compartido"
2694 -#: elf64-x86-64.c:2356
2695 -msgid "%B: relocation R_X86_64_PC32 against protected function `%s' can not be used when making a shared object"
2696 -msgstr "%B: no se puede usar la reubicación R_X86_64_PC32 contra la función protegida `%' cuando se hace un objeto compartido"
2697 +#: elf64-x86-64.c:2670
2698 +msgid "; recompile with -fPIC"
2699 +msgstr "; recompile con -fPIC"
2702 -msgid "ERROR: %B: Must be processed by '%s' toolchain"
2703 -msgstr "ERROR: %B: Se debe procesar por la cadena de compilación '%s'"
2705 -#: elf-attrs.c:602 elf-attrs.c:621
2706 -msgid "ERROR: %B: Incompatible object tag '%s':%d"
2707 -msgstr "ERROR: %B: Etiqueta de objeto '%s' incompatible:%d"
2710 -msgid "%B: invalid string offset %u >= %lu for section `%s'"
2711 -msgstr "%B: desplazamiento de cadena inválido %u >= %lu para la sección `%s'"
2714 -msgid "%B symbol number %lu references nonexistent SHT_SYMTAB_SHNDX section"
2715 -msgstr "%B el número de símbolo %lu hace referencia a la sección inexistente SHT_SYMTAB_SHNDX"
2718 -msgid "%B: Corrupt size field in group section header: 0x%lx"
2719 -msgstr "%B: Tamaño de campo corrupto en el encabezado de la sección de grupo: 0x%lx"
2720 +#: elf64-x86-64.c:2675
2721 +msgid "%B: relocation %s against %s `%s' can not be used when making a shared object%s"
2722 +msgstr "%B: no se puede usar la reubicación %s contra %s `%s' cuando se hace un objeto compartido%s"
2725 -msgid "%B: invalid SHT_GROUP entry"
2726 -msgstr "%B: entrada SHT_GROUP inválida"
2729 -msgid "%B: no group info for section %A"
2730 -msgstr "%B: no hay información de grupo para la sección %A"
2731 +#: elf64-x86-64.c:2677
2732 +msgid "%B: relocation %s against undefined %s `%s' can not be used when making a shared object%s"
2733 +msgstr "%B: no se puede usar la reubicación %s contra %s sin definir `%s' cuando se hace un objeto compartido%s"
2735 -#: elf.c:703 elf.c:2886 elflink.c:9858
2736 -msgid "%B: warning: sh_link not set for section `%A'"
2737 -msgstr "%B: aviso: no se estableción sh_link para la sección `%A'"
2740 -msgid "%B: sh_link [%d] in section `%A' is incorrect"
2741 -msgstr "%B: sh_link [%d] en la sección `%A', es incorrecto"
2744 -msgid "%B: unknown [%d] section `%s' in group [%s]"
2745 -msgstr "%B: sección [%d] desconocida `%s' en el grupo [%s]"
2751 -"Program Header:\n"
2754 -"Encabezado del Programa:\n"
2760 -"Dynamic Section:\n"
2763 -"Sección Dinámica:\n"
2769 -"Version definitions:\n"
2772 -"Definiciones de versión:\n"
2778 -"Version References:\n"
2781 -"Referencias de Versión:\n"
2785 -msgid " required from %s:\n"
2786 -msgstr " requerido desde %s:\n"
2789 -msgid "%B: invalid link %lu for reloc section %s (index %u)"
2790 -msgstr "%B: enlace %lu inválido para la sección de reubicación %s (índice %u)"
2793 -msgid "%B: don't know how to handle allocated, application specific section `%s' [0x%8x]"
2794 -msgstr "%B: no se sabe cómo manejar lo reservado, aplicación específica de la sección `%s' [0x%8x]"
2797 -msgid "%B: don't know how to handle processor specific section `%s' [0x%8x]"
2798 -msgstr "%B: no se sabe cómo manejar la sección específica de procesador `%s' [0x%8x]"
2801 -msgid "%B: don't know how to handle OS specific section `%s' [0x%8x]"
2802 -msgstr "%B: no se sabe cómo manejar la sección específica de SO `%s' [0x%8x]"
2805 -msgid "%B: don't know how to handle section `%s' [0x%8x]"
2806 -msgstr "%B: no se sabe cómo manejar la sección `%s' [0x%8x]"
2809 -msgid "%B: sh_link of section `%A' points to discarded section `%A' of `%B'"
2810 -msgstr "%B: sh_link de la sección `%A' apunta a la sección descartada `%A' de `%B'"
2813 -msgid "%B: sh_link of section `%A' points to removed section `%A' of `%B'"
2814 -msgstr "%B: sh_link de la sección `%A' apunta a la sección descartada `%A' de `%B'"
2817 -msgid "%B: The first section in the PT_DYNAMIC segment is not the .dynamic section"
2818 -msgstr "%B: La primera sección en el segmento PT_DYNAMIC no es la sección .dynamic"
2821 -msgid "%B: Not enough room for program headers, try linking with -N"
2822 -msgstr "%B: No hay suficiente espacio para los encabezados del programa, pruebe enlazar con -N"
2825 -msgid "%B: section %A lma 0x%lx overlaps previous sections"
2826 -msgstr "%B: la sección %A lma 0x%lx traslapa las secciones anteriores"
2829 -msgid "%B: section `%A' can't be allocated in segment %d"
2830 -msgstr "%B: la sección `%A' no se puede asignar en el segmento %d"
2833 -msgid "%B: warning: allocated section `%s' not in segment"
2834 -msgstr "%B: aviso: la sección asignada `%s' no está en el segmento"
2837 -msgid "%B: symbol `%s' required but not present"
2838 -msgstr "%B: se requiere el símbolo `%s' pero no está presente"
2841 -msgid "%B: warning: Empty loadable segment detected, is this intentional ?\n"
2842 -msgstr "%B: aviso: Se detectó un segmento cargable vacío, ¿ esto es intencional ?\n"
2846 -msgid "Unable to find equivalent output section for symbol '%s' from section '%s'"
2847 -msgstr "No se puede encontrar la sección de salida equivalente para el símbolo '%s' de la sección '%s'"
2850 -msgid "%B: unsupported relocation type %s"
2851 -msgstr "%B: no se admite el tipo de reubicación %s"
2856 msgid "warning: %s has a corrupt string table index - ignoring"
2857 msgstr "aviso: %s tiene un índice de tablas de cadenas corrupto - se descarta"
2862 msgid "%s: version count (%ld) does not match symbol count (%ld)"
2863 msgstr "%s: la cuenta de versión (%ld) no coincide con la cuenta de símbolos (%ld)"
2868 msgid "%s(%s): relocation %d has invalid symbol index %ld"
2869 msgstr "%s(%s): la reubicación %d tiene un índice de símbolo %ld inválido"
2871 -#: elf-eh-frame.c:823
2872 -msgid "%P: fde encoding in %B(%A) prevents .eh_frame_hdr table being created.\n"
2873 -msgstr "%P: la codificación fde en %B(%A) previene la creación de la tabla .eh_frame_hdr.\n"
2875 -#: elf-eh-frame.c:974
2876 -msgid "%P: error in %B(%A); no .eh_frame_hdr table will be created.\n"
2877 -msgstr "%P: error en %B(%A); no se creará la tabla .eh_frame_hdr.\n"
2879 -#: elf-hppa.h:2219 elf-hppa.h:2233
2880 -msgid "%B(%A): warning: unresolvable relocation against symbol `%s'"
2881 -msgstr "%B(%A): aviso: reubicación sin resolución contra el símbolo `%s'"
2883 +msgid "Warning: %B is truncated: expected core file size >= %lu, found: %lu."
2884 +msgstr "Aviso: se truncó %B: se esperaba el tamaño de fichero core >= %lu, se encontró: %lu."
2887 msgid "%s: TLS definition in %B section %A mismatches non-TLS definition in %B section %A"
2888 @@ -2358,282 +2463,295 @@ msgstr "%s: la referencia TLS en %B no coincide con la definici
2889 msgid "%B: unexpected redefinition of indirect versioned symbol `%s'"
2890 msgstr "%B: redefinición inesperada del símbolo con versión indirecta `%s'"
2894 msgid "%B: version node not found for symbol %s"
2895 msgstr "%B: no se encuentra la versión del nodo para el símbolo %s"
2899 msgid "%B: bad reloc symbol index (0x%lx >= 0x%lx) for offset 0x%lx in section `%A'"
2900 msgstr "%B: índice de símbolos de reubicación inválido (0x%lx >= 0x%lx) erróneo para el desplazamiento 0x%lx en la sección `%A'"
2904 msgid "%B: relocation size mismatch in %B section %A"
2905 msgstr "%B: el tamaño de reubicación no coincide en %B sección %A"
2910 msgid "warning: type and size of dynamic symbol `%s' are not defined"
2911 msgstr "aviso: el tipo y tamaño del símbolo dinámico `%s' no están definidos"
2915 msgid "%B: %s: invalid version %u (max %d)"
2916 msgstr "%B: %s: versión %u inválida (máximo %d)"
2920 msgid "%B: %s: invalid needed version %d"
2921 msgstr "%B: %s: versión requerida %d inválida"
2925 msgid "Warning: alignment %u of common symbol `%s' in %B is greater than the alignment (%u) of its section %A"
2926 msgstr "Aviso: la alineación %u del símbolo común `%s' en %B es más grande que la alineación (%u) de su sección %A"
2930 msgid "Warning: alignment %u of symbol `%s' in %B is smaller than %u in %B"
2931 msgstr "Aviso: la alineación %u del símbolo `%s' en %B es más pequeña que %u en %B"
2935 msgid "Warning: size of symbol `%s' changed from %lu in %B to %lu in %B"
2936 msgstr "Aviso: el tamaño del símbolo `%s' cambió de %lu en %B a %lu en %B"
2941 msgid "%s: invalid DSO for symbol `%s' definition"
2942 msgstr "%s: DSO inválido para la definición del símbolo `%s'"
2947 msgid "%s: undefined version: %s"
2948 msgstr "%s: versión sin definir: %s"
2952 msgid "%B: .preinit_array section is not allowed in DSO"
2953 msgstr "%B: no se permite la sección .preinit_array en DSO"
2958 msgid "undefined %s reference in complex symbol: %s"
2959 msgstr "referencia %s indefinida en el símbolo complejo: %s"
2964 msgid "unknown operator '%c' in complex symbol"
2965 msgstr "operador desconocido '%c' en el símbolo complejo"
2967 -#: elflink.c:8053 elflink.c:8070 elflink.c:8107 elflink.c:8124
2968 +#: elflink.c:7904 elflink.c:7921 elflink.c:7958 elflink.c:7975
2969 msgid "%B: Unable to sort relocs - they are in more than one size"
2970 msgstr "%B: No se pueden ordenar las reubicaciones - son de tamaños diferentes"
2972 -#: elflink.c:8084 elflink.c:8138
2973 +#: elflink.c:7935 elflink.c:7989
2974 msgid "%B: Unable to sort relocs - they are of an unknown size"
2975 msgstr "%B: No se pueden ordenar las reubicaciones - son de tamaño desconocido"
2979 msgid "Not enough memory to sort relocations"
2980 msgstr "No hay suficiente memoria para ordenar las reubicaciones"
2984 msgid "%B: Too many sections: %d (>= %d)"
2985 msgstr "%B: Demasiadas secciones: %d (>= %d)"
2989 msgid "%B: %s symbol `%s' in %B is referenced by DSO"
2990 msgstr "%B: el símbolo %s `%s' en %B está referenciado por DSO"
2994 msgid "%B: could not find output section %A for input section %A"
2995 msgstr "%B: no se puede encontrar la sección de salida %A para la sección de entrada %A"
2999 msgid "%B: %s symbol `%s' isn't defined"
3000 msgstr "%B: el símbolo %s `%s' no está definido"
3004 msgid "error: %B contains a reloc (0x%s) for section %A that references a non-existent global symbol"
3005 msgstr "error: %B contiene una reubicación (0x%s) para la sección %A que refiere a un símbolo global que no existe"
3009 msgid "%X`%s' referenced in section `%A' of %B: defined in discarded section `%A' of %B\n"
3010 msgstr "%X`%s' referido en la sección `%A' de %B: se definió en la sección descartada `%A' de %B\n"
3014 msgid "%A has both ordered [`%A' in %B] and unordered [`%A' in %B] sections"
3015 msgstr "%A tiene tanto secciones ordenadas [`%A' en %B] como desordenadas [`%A' en %B]"
3020 msgid "%A has both ordered and unordered sections"
3021 msgstr "%A tiene tanto secciones ordenadas como desordenadas"
3023 -#: elflink.c:10828 elflink.c:10872
3024 +#: elflink.c:10715 elflink.c:10759
3025 msgid "%B: could not find output section %s"
3026 msgstr "%B: no se puede encontrar la sección de salida %s"
3031 msgid "warning: %s section has zero size"
3032 msgstr "aviso: la sección %s es de tamaño cero"
3036 msgid "%P: warning: creating a DT_TEXTREL in a shared object.\n"
3037 msgstr "%P: aviso: se crea un DT_TEXTREL en un objeto compartido.\n"
3041 +msgid "%P%X: can not read symbols: %E\n"
3042 +msgstr "%P%X: no se pueden leer símbolos: %E\n"
3045 msgid "Removing unused section '%s' in file '%B'"
3046 msgstr "Se elimina la sección sin uso '%s' en el fichero '%B'"
3050 msgid "Warning: gc-sections option ignored"
3051 msgstr "Aviso: se descarta la opción gc-sections"
3054 -msgid "%P%X: can not read symbols: %E\n"
3055 -msgstr "%P%X: no se pueden leer símbolos: %E\n"
3059 msgid "%B: ignoring duplicate section `%A'"
3060 msgstr "%B: se descarta la sección duplicada `%A'"
3062 -#: elflink.c:12136 elflink.c:12143
3063 +#: elflink.c:12063 elflink.c:12070
3064 msgid "%B: duplicate section `%A' has different size"
3065 msgstr "%B: la sección duplicada `%A' tiene tamaño diferente"
3067 -#: elflink.c:12151 elflink.c:12156
3068 +#: elflink.c:12078 elflink.c:12083
3069 msgid "%B: warning: could not read contents of section `%A'"
3070 msgstr "%B: aviso: no se puede leer el contenido de la sección `%A'"
3074 msgid "%B: warning: duplicate section `%A' has different contents"
3075 msgstr "%B: aviso: la sección duplicada `%A' tiene contenido diferente"
3077 -#: elflink.c:12239 linker.c:3081
3078 +#: elflink.c:12166 linker.c:3080
3079 msgid "%F%P: already_linked_table: %E"
3080 msgstr "%F%P: already_linked_table: %E"
3082 -#: elf-m10300.c:1532
3083 -msgid "error: inappropriate relocation type for shared library (did you forget -fpic?)"
3084 -msgstr "error: tipo de reubicación inapropiada para la biblioteca compartida (¿olvidó -fpic?)"
3086 -#: elf-m10300.c:1535
3087 -msgid "internal error: suspicious relocation type used in shared library"
3088 -msgstr "error interno: se usó un tipo de reubicación sospechosa en una biblioteca compartida"
3090 -#: elfxx-mips.c:990
3091 +#: elfxx-mips.c:1197
3092 msgid "static procedure (no name)"
3093 msgstr "procedimiento estático (sin nombre)"
3095 -#: elfxx-mips.c:4663
3096 +#: elfxx-mips.c:5562
3097 msgid "%B: %A+0x%lx: jump to stub routine which is not jal"
3098 msgstr "%B: %A+0x%lx: salto a una rutina cabo la cual no es jal"
3100 -#: elfxx-mips.c:5326 elfxx-mips.c:5546
3101 +#: elfxx-mips.c:6206 elfxx-mips.c:6427
3102 msgid "%B: Warning: bad `%s' option size %u smaller than its header"
3103 msgstr "%B: Aviso: el tamaño de opción `%s' %u erróneo es más pequeño que su encabezado"
3105 -#: elfxx-mips.c:6405
3106 +#: elfxx-mips.c:7174 elfxx-mips.c:7299
3107 +msgid "%B: Warning: cannot determine the target function for stub section `%s'"
3108 +msgstr "%B: Aviso: no se puede determinar la función objetivo para la sección de cabo `%s'"
3110 +#: elfxx-mips.c:7428
3111 msgid "%B: Malformed reloc detected for section %s"
3112 msgstr "%B: Se detectó una reubicación malformada para la sección %s"
3114 -#: elfxx-mips.c:6447
3115 +#: elfxx-mips.c:7468
3116 msgid "%B: GOT reloc at 0x%lx not expected in executables"
3117 msgstr "%B: no se esperaba la reubicación GOT en 0x%lx en ejecutables"
3119 -#: elfxx-mips.c:6517
3120 +#: elfxx-mips.c:7566
3121 msgid "%B: CALL16 reloc at 0x%lx not against global symbol"
3122 msgstr "%B: la reubicación CALL16 en 0x%lx no es contra un símbolo global"
3124 -#: elfxx-mips.c:7880
3125 +#: elfxx-mips.c:8244
3127 +msgid "non-dynamic relocations refer to dynamic symbol %s"
3128 +msgstr "reubicaciones que no son dinámicas se refieren al símbolo dinámico %s"
3130 +#: elfxx-mips.c:8947
3131 msgid "%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"
3132 msgstr "%B: No se puede encontrar una reubicación LO16 coincidente contra `%s' para %s en 0x%lx en la sección `%A'"
3134 -#: elfxx-mips.c:8046
3135 +#: elfxx-mips.c:9086
3136 msgid "small-data section exceeds 64KB; lower small-data size limit (see option -G)"
3137 msgstr "la sección small-data excede los 64KB; disminuya el límite de tamaño de small-data (vea la opción -G)"
3139 -#: elfxx-mips.c:10661
3140 +#: elfxx-mips.c:11887
3142 msgid "%s: illegal section name `%s'"
3143 msgstr "%s: nombre de sección `%s' ilegal"
3145 -#: elfxx-mips.c:11031 elfxx-mips.c:11050
3146 +#: elfxx-mips.c:12262 elfxx-mips.c:12288
3147 msgid "Warning: %B uses -msingle-float, %B uses -mdouble-float"
3148 msgstr "Aviso: %B usa -msingle-float, %B usa -mdouble-float"
3150 -#: elfxx-mips.c:11106
3151 +#: elfxx-mips.c:12274 elfxx-mips.c:12330
3152 +msgid "Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"
3153 +msgstr "Aviso: %B usa -msingle-float, %B usa -mips32r2 -mfp64"
3155 +#: elfxx-mips.c:12300 elfxx-mips.c:12336
3156 +msgid "Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"
3157 +msgstr "Aviso: %B usa -mdouble-float, %B usa -mips32r2 -mfp64"
3159 +#: elfxx-mips.c:12378
3160 msgid "%B: endianness incompatible with that of the selected emulation"
3161 msgstr "%B: la endianez es incompatible con aquella de la emulación seleccionada"
3163 -#: elfxx-mips.c:11118
3164 +#: elfxx-mips.c:12389
3165 msgid "%B: ABI is incompatible with that of the selected emulation"
3166 msgstr "%B: la ABI es incompatible con aquella de la emulación seleccionada"
3168 -#: elfxx-mips.c:11218
3169 +#: elfxx-mips.c:12470
3170 +msgid "%B: warning: linking abicalls files with non-abicalls files"
3171 +msgstr "%B: aviso: se enlazan ficheros de llamadas abi con ficheros que no son de llamadas abi"
3173 +#: elfxx-mips.c:12487
3174 msgid "%B: linking 32-bit code with 64-bit code"
3175 msgstr "%B: se enlaza código de 32-bit con código de 64-bit"
3177 -#: elfxx-mips.c:11246
3178 +#: elfxx-mips.c:12515
3179 msgid "%B: linking %s module with previous %s modules"
3180 msgstr "%B: se enlaza el módulo %s con módulos %s previos"
3182 -#: elfxx-mips.c:11269
3183 +#: elfxx-mips.c:12538
3184 msgid "%B: ABI mismatch: linking %s module with previous %s modules"
3185 msgstr "%B: no coincide el ABI: se enlaza el módulo %s con módulos %s previos"
3187 -#: elfxx-mips.c:11334
3188 +#: elfxx-mips.c:12702
3193 -#: elfxx-mips.c:11336
3194 +#: elfxx-mips.c:12704
3199 -#: elfxx-mips.c:11338
3200 +#: elfxx-mips.c:12706
3202 msgid " [abi=EABI32]"
3203 msgstr " [abi=EABI32]"
3205 -#: elfxx-mips.c:11340
3206 +#: elfxx-mips.c:12708
3208 msgid " [abi=EABI64]"
3209 msgstr " [abi=EABI64]"
3211 -#: elfxx-mips.c:11342
3212 +#: elfxx-mips.c:12710
3214 msgid " [abi unknown]"
3215 msgstr " [abi desconocido]"
3217 -#: elfxx-mips.c:11344
3218 +#: elfxx-mips.c:12712
3223 -#: elfxx-mips.c:11346
3224 +#: elfxx-mips.c:12714
3229 -#: elfxx-mips.c:11348
3230 +#: elfxx-mips.c:12716
3232 msgid " [no abi set]"
3233 msgstr " [no hay conjunto abi]"
3235 -#: elfxx-mips.c:11369
3236 +#: elfxx-mips.c:12737
3238 msgid " [unknown ISA]"
3239 msgstr " [ISA desconocido]"
3241 -#: elfxx-mips.c:11380
3242 +#: elfxx-mips.c:12748
3244 msgid " [not 32bitmode]"
3245 msgstr " [no es modo 32bit]"
3247 -#: elfxx-sparc.c:430
3248 +#: elfxx-sparc.c:440
3250 msgid "invalid relocation type %d"
3251 msgstr "tipo de reubicación %d inválido"
3253 -#: elfxx-sparc.c:2901
3254 +#: elfxx-sparc.c:2976
3255 msgid "%B: probably compiled without -fPIC?"
3256 msgstr "%B: ¿Compilado probablemente sin -fPIC?"
3258 @@ -2720,34 +2838,34 @@ msgstr "%B: longitud de secci
3259 msgid "%s: address 0x%s out of range for Intel Hex file"
3260 msgstr "%s: la dirección 0x%s está fuera de rango en el fichero Hexadecimal de Intel"
3265 msgid "Deprecated %s called at %s line %d in %s\n"
3266 msgstr "Se llamó a %s que es obsoleto en %s línea %d en %s\n"
3271 msgid "Deprecated %s called\n"
3272 msgstr "Se llamó a %s que es obsoleto\n"
3276 msgid "%B: indirect symbol `%s' to `%s' is a loop"
3277 msgstr "%B: el símbolo indirecto `%s' para `%s' es un ciclo"
3282 msgid "Attempt to do relocatable link with %s input and %s output"
3283 msgstr "Se intentó hacer un enlace reubicable con entrada %s y salida %s"
3287 msgid "%B: warning: ignoring duplicate section `%A'\n"
3288 msgstr "%B: aviso: se descarta la sección duplicada `%A'\n"
3292 msgid "%B: warning: duplicate section `%A' has different size\n"
3293 msgstr "%B: aviso: la sección duplicada `%A' es de tamaño diferente\n"
3298 msgid "%s: access beyond end of merged section (%ld)"
3299 msgstr "%s: acceso más allá del final de la sección mezclada (%ld)"
3300 @@ -2887,6 +3005,26 @@ msgstr "%s: no se puede representar la secci
3301 msgid "Unhandled OSF/1 core file section type %d\n"
3302 msgstr "Tipo de sección de fichero núcleo OSF/1 %d sin manejar\n"
3305 +msgid "%B: `ld -r' not supported with PE MIPS objects\n"
3306 +msgstr "%B: `ld -r' no se admite con objetos PE MIPS\n"
3308 +#. OK, at this point the following variables are set up:
3309 +#. src = VMA of the memory we're fixing up
3310 +#. mem = pointer to memory we're fixing up
3311 +#. val = VMA of what we need to refer to.
3313 +msgid "%B: unimplemented %s\n"
3314 +msgstr "%B: %s sin implementar\n"
3317 +msgid "%B: jump too far away\n"
3318 +msgstr "%B: salto demasiado lejos\n"
3321 +msgid "%B: bad pair/reflo after refhi\n"
3322 +msgstr "%B: pair/reflo erróneo después de refhi\n"
3324 #. XXX code yet to be written.
3326 msgid "%B: Unhandled import type; %x"
3327 @@ -2916,26 +3054,6 @@ msgstr "%B: el tama
3328 msgid "%B: string not null terminated in ILF object file."
3329 msgstr "%B: cadena no terminada en null en el fichero objeto ILF."
3332 -msgid "%B: `ld -r' not supported with PE MIPS objects\n"
3333 -msgstr "%B: `ld -r' no se admite con objetos PE MIPS\n"
3335 -#. OK, at this point the following variables are set up:
3336 -#. src = VMA of the memory we're fixing up
3337 -#. mem = pointer to memory we're fixing up
3338 -#. val = VMA of what we need to refer to.
3340 -msgid "%B: unimplemented %s\n"
3341 -msgstr "%B: %s sin implementar\n"
3344 -msgid "%B: jump too far away\n"
3345 -msgstr "%B: salto demasiado lejos\n"
3348 -msgid "%B: bad pair/reflo after refhi\n"
3349 -msgstr "%B: pair/reflo erróneo después de refhi\n"
3354 @@ -2950,22 +3068,22 @@ msgstr ""
3355 msgid "Entry offset = 0x%.8lx (%ld)\n"
3356 msgstr "Desplazamiento de entrada = 0x%.8lx (%ld)\n"
3361 msgid "Length = 0x%.8lx (%ld)\n"
3362 msgstr "Longitud = 0x%.8lx (%ld)\n"
3367 msgid "Flag field = 0x%.2x\n"
3368 msgstr "Campo de opciones = 0x%.2x\n"
3373 msgid "Partition name = \"%s\"\n"
3374 msgstr "Nombre de la partición = \"%s\"\n"
3381 @@ -2974,22 +3092,22 @@ msgstr ""
3383 "Partición[%d] inicio = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
3388 msgid "Partition[%d] end = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
3389 msgstr "Partición[%d] fin = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
3394 msgid "Partition[%d] sector = 0x%.8lx (%ld)\n"
3395 msgstr "Partición[%d] sector = 0x%.8lx (%ld)\n"
3400 msgid "Partition[%d] length = 0x%.8lx (%ld)\n"
3401 msgstr "Partición[%d] longitud = 0x%.8lx (%ld)\n"
3408 @@ -2998,7 +3116,7 @@ msgstr ""
3410 "Encabezado Auxiliar de Ejecución\n"
3414 msgid "som_sizeof_headers unimplemented"
3415 msgstr "som_sizeof_headers sin implementar"
3417 @@ -3006,11 +3124,15 @@ msgstr "som_sizeof_headers sin implementar"
3418 msgid "%B:%d: Unexpected character `%s' in S-record file\n"
3419 msgstr "%B:%d: Caractér `%s' inesperado en el fichero S-record\n"
3421 +#: srec.c:567 srec.c:600
3422 +msgid "%B:%d: Bad checksum in S-record file\n"
3423 +msgstr "%B:%d: Suma de comprobación errónea en el fichero S-record\n"
3426 msgid "%B(%A+0x%lx): Stabs entry has invalid string index."
3427 msgstr "%B(%A+0x%lx): La entrada de cabos tiene una cadena índice inválida."
3431 msgid "Unsupported .stab relocation"
3432 msgstr "No se admite la reubicación .stab"
3434 @@ -3047,20 +3169,20 @@ msgstr "Desbordamiento de la pila (%d) en _bfd_vms_push"
3435 msgid "Stack underflow in _bfd_vms_pop"
3436 msgstr "Desbordamiento por debajo de la pila en _bfd_vms_pop"
3440 msgid "_bfd_vms_output_counted called with zero bytes"
3441 msgstr "se llamó _bfd_vms_output_counted con cero bytes"
3445 msgid "_bfd_vms_output_counted called with too many bytes"
3446 msgstr "se llamó _bfd_vms_output_counted con demasiados bytes"
3451 msgid "Symbol %s replaced by %s\n"
3452 msgstr "El símbolo %s fue reemplazado por %s\n"
3457 msgid "failed to enter %s"
3458 msgstr "falló la introducción de %s"
3459 @@ -3256,73 +3378,77 @@ msgstr "%s: reubicaci
3460 msgid "%s: `%s' in loader reloc but not loader sym"
3461 msgstr "%s: `%s' en la reubicación del cargador pero no es un símbolo del cargador"
3463 -#: elf32-ia64.c:1169 elf64-ia64.c:1169
3464 +#: elf32-ia64.c:1037 elf64-ia64.c:1037
3465 msgid "%B: Can't relax br at 0x%lx in section `%A'. Please use brl or indirect branch."
3466 msgstr "%B: No se puede relajar br en 0x%lx en la sección `%A'. Por favor use brl o ramificación indirecta."
3468 -#: elf32-ia64.c:2910 elf64-ia64.c:2910
3469 +#: elf32-ia64.c:2742 elf64-ia64.c:2742
3470 msgid "@pltoff reloc against local symbol"
3471 msgstr "reubicación @pltoff contra un símbolo local"
3473 -#: elf32-ia64.c:4523 elf64-ia64.c:4523
3474 +#: elf32-ia64.c:4317 elf64-ia64.c:4317
3476 msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
3477 msgstr "%s: segmento de datos short desbordado (0x%lx >= 0x400000)"
3479 -#: elf32-ia64.c:4534 elf64-ia64.c:4534
3480 +#: elf32-ia64.c:4328 elf64-ia64.c:4328
3482 msgid "%s: __gp does not cover short data segment"
3483 msgstr "%s: __gp no cubre el segmento de datos short"
3485 -#: elf32-ia64.c:4808 elf64-ia64.c:4808
3486 +#: elf32-ia64.c:4598 elf64-ia64.c:4598
3487 msgid "%B: non-pic code with imm relocation against dynamic symbol `%s'"
3488 msgstr "%B: código que no es pic con reubicación imm contra el símbolo dinámico %s"
3490 -#: elf32-ia64.c:4875 elf64-ia64.c:4875
3491 +#: elf32-ia64.c:4665 elf64-ia64.c:4665
3492 msgid "%B: @gprel relocation against dynamic symbol %s"
3493 msgstr "%B: reubicación @gprel contra el símbolo dinámico %s"
3495 -#: elf32-ia64.c:4938 elf64-ia64.c:4938
3496 +#: elf32-ia64.c:4728 elf64-ia64.c:4728
3497 msgid "%B: linking non-pic code in a position independent executable"
3498 msgstr "%B: se enlaza código que no es pic en un ejecutable independiente de posición"
3500 -#: elf32-ia64.c:5075 elf64-ia64.c:5075
3501 +#: elf32-ia64.c:4865 elf64-ia64.c:4865
3502 msgid "%B: @internal branch to dynamic symbol %s"
3503 msgstr "%B: ramificación @internal al símbolo dinámico %s"
3505 -#: elf32-ia64.c:5077 elf64-ia64.c:5077
3506 +#: elf32-ia64.c:4867 elf64-ia64.c:4867
3507 msgid "%B: speculation fixup to dynamic symbol %s"
3508 msgstr "%B: compostura de especulación al símbolo dinámico %s"
3510 -#: elf32-ia64.c:5079 elf64-ia64.c:5079
3511 +#: elf32-ia64.c:4869 elf64-ia64.c:4869
3512 msgid "%B: @pcrel relocation against dynamic symbol %s"
3513 msgstr "%B: reubicación @pcrel contra el símbolo dinámico %s"
3515 -#: elf32-ia64.c:5279 elf64-ia64.c:5279
3516 +#: elf32-ia64.c:5066 elf64-ia64.c:5066
3517 msgid "unsupported reloc"
3518 msgstr "no se admite la reubicación"
3520 -#: elf32-ia64.c:5312 elf64-ia64.c:5312
3521 +#: elf32-ia64.c:5104 elf64-ia64.c:5104
3522 +msgid "%B: missing TLS section for relocation %s against `%s' at 0x%lx in section `%A'."
3523 +msgstr "%B: falta la sección TLS para la reubicación %s contra `%s' en 0x%lx en la sección `%A'."
3525 +#: elf32-ia64.c:5119 elf64-ia64.c:5119
3526 msgid "%B: Can't relax br (%s) to `%s' at 0x%lx in section `%A' with size 0x%lx (> 0x1000000)."
3527 msgstr "%B: No se puede relajar br (%s) a `%s' en 0x%lx en la sección `%A' con tamaño 0x%lx (> 0x1000000)."
3529 -#: elf32-ia64.c:5573 elf64-ia64.c:5573
3530 +#: elf32-ia64.c:5375 elf64-ia64.c:5375
3531 msgid "%B: linking trap-on-NULL-dereference with non-trapping files"
3532 msgstr "%B: se enlaza deferencias-captura-en-NULL con ficheros que no son de captura"
3534 -#: elf32-ia64.c:5582 elf64-ia64.c:5582
3535 +#: elf32-ia64.c:5384 elf64-ia64.c:5384
3536 msgid "%B: linking big-endian files with little-endian files"
3537 msgstr "%B: se enlazan ficheros big-endian con ficheros little-endian"
3539 -#: elf32-ia64.c:5591 elf64-ia64.c:5591
3540 +#: elf32-ia64.c:5393 elf64-ia64.c:5393
3541 msgid "%B: linking 64-bit files with 32-bit files"
3542 msgstr "%B: se enlazan ficheros de 64-bit con ficheros de 32-bit"
3544 -#: elf32-ia64.c:5600 elf64-ia64.c:5600
3545 +#: elf32-ia64.c:5402 elf64-ia64.c:5402
3546 msgid "%B: linking constant-gp files with non-constant-gp files"
3547 msgstr "%B: se enlazan ficheros de gp constante con ficheros con gp no constante"
3549 -#: elf32-ia64.c:5610 elf64-ia64.c:5610
3550 +#: elf32-ia64.c:5412 elf64-ia64.c:5412
3551 msgid "%B: linking auto-pic files with non-auto-pic files"
3552 msgstr "%B: se enlazan ficheros de pic automático con ficheros sin pic automático"
3554 @@ -3602,12 +3728,14 @@ msgstr ""
3556 "Tabla [Puntero a Ordinal/Nombre]\n"
3558 -#: peigen.c:1610 pepigen.c:1610 pex64igen.c:1610
3559 +#: peigen.c:1617 peigen.c:1796 pepigen.c:1617 pepigen.c:1796 pex64igen.c:1617
3560 +#: pex64igen.c:1796
3562 msgid "Warning, .pdata section size (%ld) is not a multiple of %d\n"
3563 msgstr "Aviso, el tamaño de la sección .pdata (%ld) no es un múltiplo de %d\n"
3565 -#: peigen.c:1614 pepigen.c:1614 pex64igen.c:1614
3566 +#: peigen.c:1621 peigen.c:1800 pepigen.c:1621 pepigen.c:1800 pex64igen.c:1621
3567 +#: pex64igen.c:1800
3571 @@ -3616,12 +3744,12 @@ msgstr ""
3573 "La Tabla de Funciones (se interpretaron los contenidos de la sección .pdata)\n"
3575 -#: peigen.c:1617 pepigen.c:1617 pex64igen.c:1617
3576 +#: peigen.c:1624 pepigen.c:1624 pex64igen.c:1624
3578 msgid " vma:\t\t\tBegin Address End Address Unwind Info\n"
3579 msgstr " vma:\t\t\tDirección Inicio Dirección Fin Información Desenvuelta\n"
3581 -#: peigen.c:1619 pepigen.c:1619 pex64igen.c:1619
3582 +#: peigen.c:1626 pepigen.c:1626 pex64igen.c:1626
3585 " vma:\t\tBegin End EH EH PrologEnd Exception\n"
3586 @@ -3630,22 +3758,31 @@ msgstr ""
3587 " vma:\t\tInicio Fin EH EH FinPrólogo Excepción\n"
3588 " \t\tDirecc Direcc Asa Datos Dirección Máscara\n"
3590 -#: peigen.c:1689 pepigen.c:1689 pex64igen.c:1689
3591 +#: peigen.c:1696 pepigen.c:1696 pex64igen.c:1696
3593 msgid " Register save millicode"
3594 msgstr " Registro para guardar milicódigo"
3596 -#: peigen.c:1692 pepigen.c:1692 pex64igen.c:1692
3597 +#: peigen.c:1699 pepigen.c:1699 pex64igen.c:1699
3599 msgid " Register restore millicode"
3600 msgstr " Registro para restaurar milicódigo"
3602 -#: peigen.c:1695 pepigen.c:1695 pex64igen.c:1695
3603 +#: peigen.c:1702 pepigen.c:1702 pex64igen.c:1702
3605 msgid " Glue code sequence"
3606 msgstr " Secuencia de código pegamento"
3608 -#: peigen.c:1745 pepigen.c:1745 pex64igen.c:1745
3609 +#: peigen.c:1802 pepigen.c:1802 pex64igen.c:1802
3612 +" vma:\t\tBegin Prolog Function Flags Exception EH\n"
3613 +" \t\tAddress Length Length 32b exc Handler Data\n"
3615 +" vma:\t\tInicio Prólogo Función Opciones Excepción EH\n"
3616 +" \t\tDirecc Longitud Longitud 32b exc Manejador Datos\n"
3618 +#: peigen.c:1933 pepigen.c:1933 pex64igen.c:1933
3622 @@ -3656,7 +3793,7 @@ msgstr ""
3624 "Reubicaciones de Fichero Base PE (se interpretaron los contenidos de la sección .reloc)\n"
3626 -#: peigen.c:1775 pepigen.c:1775 pex64igen.c:1775
3627 +#: peigen.c:1963 pepigen.c:1963 pex64igen.c:1963
3631 @@ -3665,7 +3802,7 @@ msgstr ""
3633 "Dirección Virtual: %08lx Tamaño del trozo %ld (0x%lx) Número de composturas %ld\n"
3635 -#: peigen.c:1788 pepigen.c:1788 pex64igen.c:1788
3636 +#: peigen.c:1976 pepigen.c:1976 pex64igen.c:1976
3638 msgid "\treloc %4d offset %4x [%4lx] %s"
3639 msgstr "\treubicación %4d desplazamiento %4x [%4lx] %s"
3640 @@ -3673,7 +3810,7 @@ msgstr "\treubicaci
3641 #. The MS dumpbin program reportedly ands with 0xff0f before
3642 #. printing the characteristics field. Not sure why. No reason to
3644 -#: peigen.c:1827 pepigen.c:1827 pex64igen.c:1827
3645 +#: peigen.c:2015 pepigen.c:2015 pex64igen.c:2015
3649 @@ -3682,26 +3819,47 @@ msgstr ""
3651 "Características 0x%x\n"
3653 -#: peigen.c:2088 pepigen.c:2088 pex64igen.c:2088
3654 +#: peigen.c:2289 pepigen.c:2289 pex64igen.c:2289
3655 msgid "%B: unable to fill in DataDictionary[1] because .idata$2 is missing"
3656 msgstr "%B: no se puede llenar DataDictionary[1] porque falta .idata$2"
3658 -#: peigen.c:2106 pepigen.c:2106 pex64igen.c:2106
3659 +#: peigen.c:2307 pepigen.c:2307 pex64igen.c:2307
3660 msgid "%B: unable to fill in DataDictionary[1] because .idata$4 is missing"
3661 msgstr "%B: no se puede llenar DataDictionary[1] porque falta .idata$4"
3663 -#: peigen.c:2125 pepigen.c:2125 pex64igen.c:2125
3664 +#: peigen.c:2326 pepigen.c:2326 pex64igen.c:2326
3665 msgid "%B: unable to fill in DataDictionary[12] because .idata$5 is missing"
3666 msgstr "%B: no se puede llenar DataDictionary[12] porque falta .idata$5"
3668 -#: peigen.c:2143 pepigen.c:2143 pex64igen.c:2143
3669 +#: peigen.c:2344 pepigen.c:2344 pex64igen.c:2344
3670 msgid "%B: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] because .idata$6 is missing"
3671 msgstr "%B: no se puede llenar DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] porque falta .idata$6"
3673 -#: peigen.c:2163 pepigen.c:2163 pex64igen.c:2163
3674 +#: peigen.c:2364 pepigen.c:2364 pex64igen.c:2364
3675 msgid "%B: unable to fill in DataDictionary[9] because __tls_used is missing"
3676 msgstr "%B: no se puede llenar DataDictionary[9] porque falta __tls_used"
3678 +#~ msgid "Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."
3679 +#~ msgstr "Error de Dwarf: El desplazamiento DW_FROM_strp (%lu) es más grande o igual que el tamaño de .debug_str (%lu)."
3681 +#~ msgid "Dwarf Error: Can't find .debug_abbrev section."
3682 +#~ msgstr "Error de Dwarf: No se puede encontrar la sección .debug_abbrev."
3684 +#~ msgid "Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."
3685 +#~ msgstr "Error de Dwarf: El desplazamiento de abreviatura (%lu) es más grande o igual que el tamaño de .debug_abbrev (%lu)."
3687 +#~ msgid "Dwarf Error: Can't find .debug_line section."
3688 +#~ msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_line."
3690 +#~ msgid "Dwarf Error: Can't find .debug_ranges section."
3691 +#~ msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_ranges."
3693 +#~ msgid "ERROR: %B: Conflicting definitions of wchar_t"
3694 +#~ msgstr "ERROR: %B: Definiciones en conflicto de wchar_t"
3696 +#~ msgid "%B: relocation R_X86_64_PC32 against protected function `%s' can not be used when making a shared object"
3697 +#~ msgstr "%B: no se puede usar la reubicación R_X86_64_PC32 contra la función protegida `%' cuando se hace un objeto compartido"
3699 #~ msgid "ERROR: %B: Conflicting enum sizes"
3700 #~ msgstr "ERROR: %B: Tamaños de enum en conflicto"
3702 @@ -3846,9 +4004,6 @@ msgstr "%B: no se puede llenar DataDictionary[9] porque falta __tls_used"
3703 #~ msgid "local symbols in discarded section %s"
3704 #~ msgstr "símbolos locales en la sección descartada %s"
3706 -#~ msgid "%s: linking abicalls files with non-abicalls files"
3707 -#~ msgstr "%s: se enlazan ficheros de llamadas abi con ficheros que no son de llamadas abi"
3709 #~ msgid "%s: ISA mismatch (-mips%d) with previous modules (-mips%d)"
3710 #~ msgstr "%s: no coincide el ISA (-mips%d) con módulos previos (-mips%d)"
3712 diff --git a/gdb/Makefile.in b/gdb/Makefile.in
3713 index 74aa72e..c84a4ac 100644
3714 --- a/gdb/Makefile.in
3715 +++ b/gdb/Makefile.in
3716 @@ -167,11 +167,20 @@ INTL_CFLAGS = @INCINTL@
3718 # Where is the ICONV library? This can be empty if libc has iconv.
3719 LIBICONV = @LIBICONV@
3720 +LIBICONV_INCLUDE = @LIBICONV_INCLUDE@
3721 +LIBICONV_LIBDIR = @LIBICONV_LIBDIR@
3723 # Did the user give us a --with-sysroot option?
3724 TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
3725 TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
3727 +# Did the user give us a --with-gdb-datadir option?
3728 +GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
3730 +# The argument to --with-pythondir. If not given, this is
3731 +# GDB_DATADIR_PATH/python.
3732 +pythondir = @pythondir@
3734 # Helper code from gnulib.
3735 LIBGNU = gnulib/libgnu.a
3736 INCGNU = -I$(srcdir)/gnulib -Ignulib
3737 @@ -270,12 +279,34 @@ SUBDIR_TUI_CFLAGS= \
3739 SUBDIR_PYTHON_OBS = \
3742 + python-breakpoint.o \
3745 + python-function.o \
3748 + python-objfile.o \
3755 SUBDIR_PYTHON_SRCS = \
3757 + python/python-block.c \
3758 + python/python-breakpoint.c \
3759 python/python-cmd.c \
3760 + python/python-frame.c \
3761 + python/python-function.c \
3762 + python/python-hooks.c \
3763 + python/python-membuf.c \
3764 + python/python-objfile.c \
3765 + python/python-param.c \
3766 + python/python-symbol.c \
3767 + python/python-symtab.c \
3768 + python/python-type.c \
3769 python/python-utils.c \
3770 python/python-value.c
3771 SUBDIR_PYTHON_DEPS =
3772 @@ -390,7 +421,8 @@ INTERNAL_CFLAGS_BASE = \
3773 $(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
3774 $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
3775 $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
3776 - $(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
3777 + $(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) \
3778 + $(LIBICONV_INCLUDE)
3779 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
3780 INTERNAL_CFLAGS = $(INTERNAL_WARN_CFLAGS) $(GDB_WERROR_CFLAGS)
3782 @@ -402,7 +434,7 @@ LDFLAGS = @LDFLAGS@
3783 # I think it's perfectly reasonable for a user to set -pg in CFLAGS
3784 # and have it work; that's why CFLAGS is here.
3785 # PROFILE_CFLAGS is _not_ included, however, because we use monstartup.
3786 -INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS)
3787 +INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_LDFLAGS) $(LIBICONV_LIBDIR)
3789 # If your system is missing alloca(), or, more likely, it's there but
3790 # it doesn't work, then refer to libiberty.
3791 @@ -663,6 +695,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
3792 valarith.c valops.c valprint.c value.c varobj.c vec.c \
3794 xml-tdesc.c xml-support.c \
3798 LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
3799 @@ -733,7 +766,8 @@ config/sparc/nm-sol2.h config/nm-linux.h config/mips/nm-irix5.h \
3800 config/rs6000/nm-rs6000.h top.h bsd-kvm.h gdb-stabs.h reggroups.h \
3801 annotate.h sim-regno.h dictionary.h dfp.h main.h frame-unwind.h \
3802 remote-fileio.h i386-linux-tdep.h vax-tdep.h objc-lang.h \
3803 -sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h
3804 +sentinel-frame.h bcache.h symfile.h windows-tdep.h linux-tdep.h xml-syscall.h \
3805 +python/python.h python/python-internal.h
3807 # Header files that already have srcdir in them, or which are in objdir.
3809 @@ -812,10 +846,16 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
3812 solib.o solib-null.o \
3813 - prologue-value.o memory-map.o xml-support.o \
3814 + prologue-value.o memory-map.o xml-support.o xml-syscall.o \
3815 target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
3818 +# Definitions for the syscall's XML files and dir
3819 +XML_SYSCALLS_DIR = syscalls/
3820 +XML_SYSCALLS_FILES = gdb-syscalls.dtd \
3821 + ppc-linux.xml ppc64-linux.xml \
3822 + i386-linux.xml amd64-linux.xml
3827 @@ -849,11 +889,38 @@ generated_files = config.h observer.h observer.inc ada-lex.c \
3831 -all: gdb$(EXEEXT) $(CONFIG_ALL)
3832 +all: gdb$(EXEEXT) $(CONFIG_ALL) .gdbinit xml-syscall-copy
3833 @$(MAKE) $(FLAGS_TO_PASS) DO=all "DODIRS=`echo $(SUBDIRS) | sed 's/testsuite//'`" subdir_do
3835 all-tui: $(TUI)$(EXEEXT)
3838 + if [ "`cd $(srcdir) && pwd`" != "`pwd`" ] ; then \
3839 + mkdir -p ./$(XML_SYSCALLS_DIR) ; \
3840 + list='$(XML_SYSCALLS_FILES)' ; \
3841 + for file in $$list ; do \
3842 + f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
3843 + if test -f $$f ; then \
3844 + $(INSTALL_DATA) $$f \
3845 + ./$(XML_SYSCALLS_DIR) ; \
3850 +# This target is responsible for properly installing the syscalls'
3851 +# XML files in the system.
3852 +xml-syscall-install:
3853 + $(SHELL) $(srcdir)/../mkinstalldirs \
3854 + $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
3855 + list='$(XML_SYSCALLS_FILES)' ; \
3856 + for file in $$list ; do \
3857 + f=$(srcdir)/$(XML_SYSCALLS_DIR)/$$file ; \
3858 + if test -f $$f ; then \
3859 + $(INSTALL_DATA) $$f \
3860 + $(DESTDIR)$(GDB_DATADIR_PATH)/$(XML_SYSCALLS_DIR) ; \
3866 # The check target can not use subdir_do, because subdir_do does not
3867 @@ -907,8 +974,11 @@ gdb.z:gdb.1
3868 # source file and doesn't care about rebuilding or just wants to save the
3869 # time it takes for make to check that all is up to date.
3870 # install-only is intended to address that need.
3871 -install: all install-only
3872 -install-only: $(CONFIG_INSTALL)
3873 +install: all install-only
3875 +# The "install-only" target also installs the syscalls' XML files in
3877 +install-only: $(CONFIG_INSTALL) xml-syscall-install
3878 transformed_name=`t='$(program_transform_name)'; \
3879 echo gdb | sed -e "$$t"` ; \
3880 if test "x$$transformed_name" = x; then \
3881 @@ -1202,6 +1272,12 @@ stamp-h: config.in config.status
3883 $(SHELL) config.status
3885 +.gdbinit: gdbinit.in config.status
3886 + CONFIG_FILES=".gdbinit:gdbinit.in" \
3887 + CONFIG_COMMANDS= \
3889 + $(SHELL) config.status
3891 config.status: configure configure.tgt configure.host
3892 $(SHELL) config.status --recheck
3894 @@ -1845,10 +1921,54 @@ python.o: $(srcdir)/python/python.c
3895 $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python.c
3898 +python-block.o: $(srcdir)/python/python-block.c
3899 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-block.c
3902 +python-breakpoint.o: $(srcdir)/python/python-breakpoint.c
3903 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-breakpoint.c
3906 python-cmd.o: $(srcdir)/python/python-cmd.c
3907 $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-cmd.c
3910 +python-frame.o: $(srcdir)/python/python-frame.c
3911 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-frame.c
3914 +python-function.o: $(srcdir)/python/python-function.c
3915 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-function.c
3918 +python-hooks.o: $(srcdir)/python/python-hooks.c
3919 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-hooks.c
3922 +python-membuf.o: $(srcdir)/python/python-membuf.c
3923 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-membuf.c
3926 +python-objfile.o: $(srcdir)/python/python-objfile.c
3927 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-objfile.c
3930 +python-param.o: $(srcdir)/python/python-param.c
3931 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-param.c
3934 +python-symbol.o: $(srcdir)/python/python-symbol.c
3935 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-symbol.c
3938 +python-symtab.o: $(srcdir)/python/python-symtab.c
3939 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-symtab.c
3942 +python-type.o: $(srcdir)/python/python-type.c
3943 + $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-type.c
3946 python-utils.o: $(srcdir)/python/python-utils.c
3947 $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-utils.c
3949 @@ -1857,6 +1977,38 @@ python-value.o: $(srcdir)/python/python-value.c
3950 $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-value.c
3953 +# All python library files, with the "python/lib" stripped off.
3954 +# Note that we should only install files in the "gdb" module.
3955 +PY_FILES = gdb/FrameIterator.py gdb/command/alias.py \
3956 + gdb/command/backtrace.py gdb/command/require.py \
3957 + gdb/command/pahole.py gdb/command/__init__.py \
3958 + gdb/command/ignore_errors.py gdb/command/save_breakpoints.py \
3959 + gdb/libstdcxx/v6/printers.py gdb/libstdcxx/v6/__init__.py \
3960 + gdb/libstdcxx/__init__.py gdb/function/caller_is.py \
3961 + gdb/function/in_scope.py gdb/function/__init__.py gdb/backtrace.py \
3964 +# Install the Python library. Python library files go under
3967 + files='$(PY_FILES)'; for file in $$files; do \
3968 + dir=`echo "$$file" | sed 's,/[^/]*$$,,'`; \
3969 + $(SHELL) $(srcdir)/../mkinstalldirs $(DESTDIR)$(pythondir)/$$dir; \
3970 + $(INSTALL_DATA) $(srcdir)/python/lib/$$file $(DESTDIR)$(pythondir)/$$file; \
3973 +# Other packages may have their files installed in $(pythondir).
3975 + files='$(PY_FILES)'; for file in $$files; do \
3976 + slashdir=`echo "/$$file" | sed 's,/[^/]*$$,,'`; \
3977 + rm -f $(DESTDIR)$(pythondir)/$$file; \
3978 + while test "x$$file" != "x$$slashdir"; do \
3979 + rmdir 2>/dev/null "$(DESTDIR)$(pythondir)$$slashdir"; \
3980 + file="$$slashdir"; \
3981 + slashdir=`echo "$$file" | sed 's,/[^/]*$$,,'`; \
3986 # Dependency tracking. Most of this is conditional on GNU Make being
3987 # found by configure; if GNU Make is not found, we fall back to a
3988 diff --git a/gdb/NEWS b/gdb/NEWS
3989 index 9078412..3f084e7 100644
3994 *** Changes since GDB 6.8
3996 +* GDB now has support for multi-byte and wide character sets on the
3997 +target. Strings whose character type is wchar_t, char16_t, or
3998 +char32_t are now correctly printed. GDB supports wide- and unicode-
3999 +literals in C, that is, L'x', L"string", u'x', u"string", U'x', and
4000 +U"string" syntax. And, GDB allows the "%ls" and "%lc" formats in
4003 * GDB now supports automatic retrieval of shared library files from
4004 remote targets. To use this feature, specify a system root that begins
4005 with the `remote:' prefix, either via the `set sysroot' command or via
4006 @@ -182,6 +189,11 @@ set target-async
4007 with GDB while the target is running. "show target-async" displays the
4008 current state of asynchronous execution of the target.
4010 +set target-wide-charset
4011 +show target-wide-charset
4012 + The target-wide-charset is the name of the character set that GDB
4013 + uses when printing characters whose type is wchar_t.
4015 set tcp auto-retry (on|off)
4017 set tcp connect-timeout
4018 diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
4019 index 81b5d47..c2bd043 100644
4020 --- a/gdb/acinclude.m4
4021 +++ b/gdb/acinclude.m4
4022 @@ -29,6 +29,9 @@ sinclude([../config/depstand.m4])
4023 dnl For AM_LC_MESSAGES
4024 sinclude([../config/lcmessage.m4])
4026 +dnl For AM_LANGINFO_CODESET.
4027 +sinclude([../config/codeset.m4])
4030 # Sometimes the native compiler is a bogus stub for gcc or /usr/ucb/cc. This
4031 # makes configure think it's cross compiling. If --target wasn't used, then
4032 @@ -174,8 +177,8 @@ AC_DEFUN([AM_ICONV],
4033 AC_ARG_WITH([libiconv-prefix],
4034 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
4035 for dir in `echo "$withval" | tr : ' '`; do
4036 - if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
4037 - if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
4038 + if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
4039 + if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; LDFLAGS="$LDFLAGS -L$dir/lib"; fi
4043 @@ -230,6 +233,8 @@ size_t iconv();
4047 + AC_SUBST(LIBICONV_INCLUDE)
4048 + AC_SUBST(LIBICONV_LIBDIR)
4051 dnl written by Guido Draheim <guidod@gmx.de>, original by Alexandre Oliva
4052 diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
4053 index 671cb35..edcee3f 100644
4054 --- a/gdb/ada-lang.c
4055 +++ b/gdb/ada-lang.c
4056 @@ -486,7 +486,7 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
4057 set_value_component_location (result, val);
4058 set_value_bitsize (result, value_bitsize (val));
4059 set_value_bitpos (result, value_bitpos (val));
4060 - VALUE_ADDRESS (result) += value_offset (val);
4061 + set_value_address (result, value_address (val));
4062 if (value_lazy (val)
4063 || TYPE_LENGTH (type) > TYPE_LENGTH (value_type (val)))
4064 set_value_lazy (result, 1);
4065 @@ -1328,7 +1328,7 @@ thin_data_pntr (struct value *val)
4068 return value_from_longest (desc_data_type (thin_descriptor_type (type)),
4069 - VALUE_ADDRESS (val) + value_offset (val));
4070 + value_address (val));
4073 /* True iff TYPE indicates a "thick" array pointer type. */
4074 @@ -1393,7 +1393,7 @@ desc_bounds (struct value *arr)
4075 if (TYPE_CODE (type) == TYPE_CODE_PTR)
4076 addr = value_as_long (arr);
4078 - addr = VALUE_ADDRESS (arr) + value_offset (arr);
4079 + addr = value_address (arr);
4082 value_from_longest (lookup_pointer_type (bounds_type),
4083 @@ -1666,8 +1666,8 @@ ada_type_of_array (struct value *arr, int bounds)
4087 - struct type *range_type = alloc_type (objf);
4088 - struct type *array_type = alloc_type (objf);
4089 + struct type *range_type = alloc_type (objf, NULL);
4090 + struct type *array_type = alloc_type (objf, NULL);
4091 struct value *low = desc_one_bound (descriptor, arity, 0);
4092 struct value *high = desc_one_bound (descriptor, arity, 1);
4094 @@ -1774,9 +1774,9 @@ packed_array_type (struct type *type, long *elt_bits)
4095 if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
4098 - new_type = alloc_type (TYPE_OBJFILE (type));
4099 new_elt_type = packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
4101 + new_type = alloc_type (TYPE_OBJFILE (type), new_elt_type);
4102 create_array_type (new_type, new_elt_type, TYPE_INDEX_TYPE (type));
4103 TYPE_FIELD_BITSIZE (new_type, 0) = *elt_bits;
4104 TYPE_NAME (new_type) = ada_type_name (type);
4105 @@ -1831,6 +1831,7 @@ decode_packed_array_type (struct type *type)
4108 shadow_type = SYMBOL_TYPE (sym);
4109 + CHECK_TYPEDEF (shadow_type);
4111 if (TYPE_CODE (shadow_type) != TYPE_CODE_ARRAY)
4113 @@ -2005,10 +2006,9 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
4115 else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
4117 - v = value_at (type,
4118 - VALUE_ADDRESS (obj) + value_offset (obj) + offset);
4119 + v = value_at (type, value_address (obj) + offset);
4120 bytes = (unsigned char *) alloca (len);
4121 - read_memory (VALUE_ADDRESS (v), bytes, len);
4122 + read_memory (value_address (v), bytes, len);
4126 @@ -2018,15 +2018,18 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
4130 + CORE_ADDR new_addr;
4132 set_value_component_location (v, obj);
4133 - VALUE_ADDRESS (v) += value_offset (obj) + offset;
4134 + new_addr = value_address (obj) + offset;
4135 set_value_bitpos (v, bit_offset + value_bitpos (obj));
4136 set_value_bitsize (v, bit_size);
4137 if (value_bitpos (v) >= HOST_CHAR_BIT)
4139 - VALUE_ADDRESS (v) += 1;
4141 set_value_bitpos (v, value_bitpos (v) - HOST_CHAR_BIT);
4143 + set_value_address (v, new_addr);
4146 set_value_bitsize (v, bit_size);
4147 @@ -2218,7 +2221,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
4149 char *buffer = (char *) alloca (len);
4151 - CORE_ADDR to_addr = VALUE_ADDRESS (toval) + value_offset (toval);
4152 + CORE_ADDR to_addr = value_address (toval);
4154 if (TYPE_CODE (type) == TYPE_CODE_FLT)
4155 fromval = value_cast (type, fromval);
4156 @@ -2259,8 +2262,7 @@ value_assign_to_component (struct value *container, struct value *component,
4159 LONGEST offset_in_container =
4160 - (LONGEST) (VALUE_ADDRESS (component) + value_offset (component)
4161 - - VALUE_ADDRESS (container) - value_offset (container));
4162 + (LONGEST) (value_address (component) - value_address (container));
4163 int bit_offset_in_container =
4164 value_bitpos (component) - value_bitpos (container);
4166 @@ -3788,7 +3790,7 @@ parse_old_style_renaming (struct type *type,
4167 /* Return an lvalue containing the value VAL. This is the identity on
4168 lvalues, and otherwise has the side-effect of pushing a copy of VAL
4169 on the stack, using and updating *SP as the stack pointer, and
4170 - returning an lvalue whose VALUE_ADDRESS points to the copy. */
4171 + returning an lvalue whose value_address points to the copy. */
4173 static struct value *
4174 ensure_lval (struct value *val, CORE_ADDR *sp)
4175 @@ -3802,12 +3804,12 @@ ensure_lval (struct value *val, CORE_ADDR *sp)
4177 if (gdbarch_inner_than (current_gdbarch, 1, 2))
4179 - /* Stack grows downward. Align SP and VALUE_ADDRESS (val) after
4180 + /* Stack grows downward. Align SP and value_address (val) after
4181 reserving sufficient space. */
4183 if (gdbarch_frame_align_p (current_gdbarch))
4184 *sp = gdbarch_frame_align (current_gdbarch, *sp);
4185 - VALUE_ADDRESS (val) = *sp;
4186 + set_value_address (val, *sp);
4190 @@ -3815,14 +3817,14 @@ ensure_lval (struct value *val, CORE_ADDR *sp)
4191 then again, re-align the frame. */
4192 if (gdbarch_frame_align_p (current_gdbarch))
4193 *sp = gdbarch_frame_align (current_gdbarch, *sp);
4194 - VALUE_ADDRESS (val) = *sp;
4195 + set_value_address (val, *sp);
4197 if (gdbarch_frame_align_p (current_gdbarch))
4198 *sp = gdbarch_frame_align (current_gdbarch, *sp);
4200 VALUE_LVAL (val) = lval_memory;
4202 - write_memory (VALUE_ADDRESS (val), value_contents_raw (val), len);
4203 + write_memory (value_address (val), value_contents_raw (val), len);
4207 @@ -3911,12 +3913,12 @@ make_array_descriptor (struct type *type, struct value *arr, CORE_ADDR *sp)
4208 bounds = ensure_lval (bounds, sp);
4210 modify_general_field (value_contents_writeable (descriptor),
4211 - VALUE_ADDRESS (ensure_lval (arr, sp)),
4212 + value_address (ensure_lval (arr, sp)),
4213 fat_pntr_data_bitpos (desc_type),
4214 fat_pntr_data_bitsize (desc_type));
4216 modify_general_field (value_contents_writeable (descriptor),
4217 - VALUE_ADDRESS (bounds),
4218 + value_address (bounds),
4219 fat_pntr_bounds_bitpos (desc_type),
4220 fat_pntr_bounds_bitsize (desc_type));
4222 @@ -6790,7 +6792,7 @@ variant_field_index (struct type *type)
4223 static struct type *
4224 empty_record (struct objfile *objfile)
4226 - struct type *type = alloc_type (objfile);
4227 + struct type *type = alloc_type (objfile, NULL);
4228 TYPE_CODE (type) = TYPE_CODE_STRUCT;
4229 TYPE_NFIELDS (type) = 0;
4230 TYPE_FIELDS (type) = NULL;
4231 @@ -6847,7 +6849,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
4235 - rtype = alloc_type (TYPE_OBJFILE (type));
4236 + rtype = alloc_type (TYPE_OBJFILE (type), NULL);
4237 TYPE_CODE (rtype) = TYPE_CODE_STRUCT;
4238 INIT_CPLUS_SPECIFIC (rtype);
4239 TYPE_NFIELDS (rtype) = nfields;
4240 @@ -7034,7 +7036,8 @@ template_to_static_fixed_type (struct type *type0)
4241 new_type = static_unwrap_type (field_type);
4242 if (type == type0 && new_type != field_type)
4244 - TYPE_TARGET_TYPE (type0) = type = alloc_type (TYPE_OBJFILE (type0));
4245 + TYPE_TARGET_TYPE (type0) = type = alloc_type (TYPE_OBJFILE (type0),
4247 TYPE_CODE (type) = TYPE_CODE (type0);
4248 INIT_CPLUS_SPECIFIC (type);
4249 TYPE_NFIELDS (type) = nfields;
4250 @@ -7079,7 +7082,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
4254 - rtype = alloc_type (TYPE_OBJFILE (type));
4255 + rtype = alloc_type (TYPE_OBJFILE (type), NULL);
4256 TYPE_CODE (rtype) = TYPE_CODE_STRUCT;
4257 INIT_CPLUS_SPECIFIC (rtype);
4258 TYPE_NFIELDS (rtype) = nfields;
4259 @@ -7251,7 +7254,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
4260 if (elt_type0 == elt_type)
4263 - result = create_array_type (alloc_type (TYPE_OBJFILE (type0)),
4264 + result = create_array_type (alloc_type (TYPE_OBJFILE (type0), NULL),
4265 elt_type, TYPE_INDEX_TYPE (type0));
4268 @@ -7281,7 +7284,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
4269 struct type *range_type =
4270 to_fixed_range_type (TYPE_FIELD_NAME (index_type_desc, i),
4271 dval, TYPE_OBJFILE (type0));
4272 - result = create_array_type (alloc_type (TYPE_OBJFILE (type0)),
4273 + result = create_array_type (alloc_type (TYPE_OBJFILE (type0), NULL),
4274 result, range_type);
4276 if (!ignore_too_big && TYPE_LENGTH (result) > varsize_limit)
4277 @@ -7523,7 +7526,7 @@ static struct value *
4278 ada_to_fixed_value (struct value *val)
4280 return ada_to_fixed_value_create (value_type (val),
4281 - VALUE_ADDRESS (val) + value_offset (val),
4282 + value_address (val),
4286 @@ -7869,7 +7872,7 @@ unwrap_value (struct value *val)
4288 coerce_unspec_val_to_type
4289 (val, ada_to_fixed_type (raw_real_type, 0,
4290 - VALUE_ADDRESS (val) + value_offset (val),
4291 + value_address (val),
4295 @@ -9546,7 +9549,7 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
4296 if (L < INT_MIN || U > INT_MAX)
4299 - return create_range_type (alloc_type (objfile), raw_type,
4300 + return create_range_type (alloc_type (objfile, NULL), raw_type,
4301 discrete_type_low_bound (raw_type),
4302 discrete_type_high_bound (raw_type));
4304 @@ -9611,7 +9614,7 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
4306 if (objfile == NULL)
4307 objfile = TYPE_OBJFILE (base_type);
4308 - type = create_range_type (alloc_type (objfile), base_type, L, U);
4309 + type = create_range_type (alloc_type (objfile, NULL), base_type, L, U);
4310 TYPE_NAME (type) = name;
4313 @@ -11009,9 +11012,9 @@ ada_language_arch_info (struct gdbarch *gdbarch,
4314 /* Not really used, but needed in the ada_language_defn. */
4317 -emit_char (int c, struct ui_file *stream, int quoter)
4318 +emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
4320 - ada_emit_char (c, stream, quoter, 1);
4321 + ada_emit_char (c, type, stream, quoter, 1);
4325 diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
4326 index c7cc62a..fac027b 100644
4327 --- a/gdb/ada-lang.h
4328 +++ b/gdb/ada-lang.h
4329 @@ -257,12 +257,12 @@ extern int ada_value_print (struct value *, struct ui_file *,
4331 /* Defined in ada-lang.c */
4333 -extern void ada_emit_char (int, struct ui_file *, int, int);
4334 +extern void ada_emit_char (int, struct type *, struct ui_file *, int, int);
4336 -extern void ada_printchar (int, struct ui_file *);
4337 +extern void ada_printchar (int, struct type *, struct ui_file *);
4339 -extern void ada_printstr (struct ui_file *, const gdb_byte *,
4340 - unsigned int, int, int,
4341 +extern void ada_printstr (struct ui_file *, struct type *, const gdb_byte *,
4342 + unsigned int, int,
4343 const struct value_print_options *);
4345 struct value *ada_convert_actual (struct value *actual,
4346 diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
4347 index 61ed06e..8b1639e 100644
4348 --- a/gdb/ada-tasks.c
4349 +++ b/gdb/ada-tasks.c
4350 @@ -293,7 +293,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
4352 /* Extract LEN characters from the fat string. */
4353 array_val = value_ind (value_field (val, array_fieldno));
4354 - read_memory (VALUE_ADDRESS (array_val), dest, len);
4355 + read_memory (value_address (array_val), dest, len);
4357 /* Add the NUL character to close the string. */
4359 diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
4360 index f00824a..ef665c4 100644
4361 --- a/gdb/ada-typeprint.c
4362 +++ b/gdb/ada-typeprint.c
4363 @@ -357,16 +357,17 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
4365 fprintf_filtered (stream, "array (");
4369 + fprintf_filtered (stream, _("<undecipherable array type>"));
4375 fprintf_filtered (stream, "...");
4380 - fprintf_filtered (stream, _("<undecipherable array type>"));
4383 if (ada_is_simple_array_type (type))
4385 struct type *range_desc_type =
4386 diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
4387 index 9647971..cfa94a2 100644
4388 --- a/gdb/ada-valprint.c
4389 +++ b/gdb/ada-valprint.c
4390 @@ -269,7 +269,8 @@ printable_val_type (struct type *type, const gdb_byte *valaddr)
4391 (1 or 2) of the character. */
4394 -ada_emit_char (int c, struct ui_file *stream, int quoter, int type_len)
4395 +ada_emit_char (int c, struct type *type, struct ui_file *stream,
4396 + int quoter, int type_len)
4400 @@ -366,10 +367,10 @@ ada_print_floating (const gdb_byte *valaddr, struct type *type,
4404 -ada_printchar (int c, struct ui_file *stream)
4405 +ada_printchar (int c, struct type *type, struct ui_file *stream)
4407 fputs_filtered ("'", stream);
4408 - ada_emit_char (c, stream, '\'', 1);
4409 + ada_emit_char (c, type, stream, '\'', 1);
4410 fputs_filtered ("'", stream);
4413 @@ -411,7 +412,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
4416 case TYPE_CODE_CHAR:
4417 - LA_PRINT_CHAR ((unsigned char) val, stream);
4418 + LA_PRINT_CHAR ((unsigned char) val, type, stream);
4421 case TYPE_CODE_BOOL:
4422 @@ -454,7 +455,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
4426 -printstr (struct ui_file *stream, const gdb_byte *string,
4427 +printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
4428 unsigned int length, int force_ellipses, int type_len,
4429 const struct value_print_options *options)
4431 @@ -506,7 +507,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
4434 fputs_filtered ("'", stream);
4435 - ada_emit_char (char_at (string, i, type_len), stream, '\'',
4436 + ada_emit_char (char_at (string, i, type_len), elttype, stream, '\'',
4438 fputs_filtered ("'", stream);
4439 fprintf_filtered (stream, _(" <repeats %u times>"), reps);
4440 @@ -524,7 +525,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
4441 fputs_filtered ("\"", stream);
4444 - ada_emit_char (char_at (string, i, type_len), stream, '"',
4445 + ada_emit_char (char_at (string, i, type_len), elttype, stream, '"',
4447 things_printed += 1;
4449 @@ -544,11 +545,12 @@ printstr (struct ui_file *stream, const gdb_byte *string,
4453 -ada_printstr (struct ui_file *stream, const gdb_byte *string,
4454 - unsigned int length, int width, int force_ellipses,
4455 +ada_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
4456 + unsigned int length, int force_ellipses,
4457 const struct value_print_options *options)
4459 - printstr (stream, string, length, force_ellipses, width, options);
4460 + printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type),
4465 @@ -637,7 +639,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
4469 - printstr (stream, valaddr, len, 0, eltlen, options);
4470 + printstr (stream, elttype, valaddr, len, 0, eltlen, options);
4474 @@ -688,7 +690,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4477 retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
4478 - VALUE_ADDRESS (val), stream, recurse, options);
4479 + value_address (val), stream, recurse, options);
4480 value_free_to_mark (mark);
4483 @@ -817,7 +819,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4485 fputs_filtered (" ", stream);
4486 ada_printchar ((unsigned char) unpack_long (type, valaddr),
4492 @@ -904,7 +906,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4494 val_print (value_type (deref_val),
4495 value_contents (deref_val), 0,
4496 - VALUE_ADDRESS (deref_val), stream, recurse + 1,
4497 + value_address (deref_val), stream, recurse + 1,
4498 options, current_language);
4501 @@ -944,7 +946,7 @@ ada_value_print (struct value *val0, struct ui_file *stream,
4502 const struct value_print_options *options)
4504 const gdb_byte *valaddr = value_contents (val0);
4505 - CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
4506 + CORE_ADDR address = value_address (val0);
4508 ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
4510 diff --git a/gdb/auxv.c b/gdb/auxv.c
4511 index 5007cd0..3a51ec5 100644
4514 @@ -205,6 +205,7 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
4515 TAG (AT_UCACHEBSIZE, _("Unified cache block size"), dec);
4516 TAG (AT_IGNOREPPC, _("Entry should be ignored"), dec);
4517 TAG (AT_BASE_PLATFORM, _("String identifying base platform"), str);
4518 + TAG (AT_RANDOM, _("Address of 16 random bytes"), hex);
4519 TAG (AT_EXECFN, _("File name of executable"), str);
4520 TAG (AT_SECURE, _("Boolean, was exec setuid-like?"), dec);
4521 TAG (AT_SYSINFO, _("Special system info/entry points"), hex);
4522 @@ -247,7 +248,8 @@ fprint_target_auxv (struct ui_file *file, struct target_ops *ops)
4523 get_user_print_options (&opts);
4524 if (opts.addressprint)
4525 fprintf_filtered (file, "0x%s", paddr_nz (val));
4526 - val_print_string (val, -1, 1, file, &opts);
4527 + val_print_string (builtin_type (target_gdbarch)->builtin_char,
4528 + val, -1, file, &opts);
4529 fprintf_filtered (file, "\n");
4532 diff --git a/gdb/block.c b/gdb/block.c
4533 index 8f0140c..d451769 100644
4536 @@ -207,24 +207,16 @@ block_set_scope (struct block *block, const char *scope,
4539 /* This returns the first using directives associated to BLOCK, if
4542 -/* FIXME: carlton/2003-04-23: This uses the fact that we currently
4543 - only have using directives in static blocks, because we only
4544 - generate using directives from anonymous namespaces. Eventually,
4545 - when we support using directives everywhere, we'll want to replace
4546 - this by some iterator functions. */
4547 + any. Each BLOCK_NAMESPACE()->USING already contains all the namespaces
4548 + imported at that code point - even those from its parent blocks. */
4550 struct using_direct *
4551 block_using (const struct block *block)
4553 - const struct block *static_block = block_static_block (block);
4555 - if (static_block == NULL
4556 - || BLOCK_NAMESPACE (static_block) == NULL)
4557 + if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
4560 - return BLOCK_NAMESPACE (static_block)->using;
4561 + return BLOCK_NAMESPACE (block)->using;
4564 /* Set BLOCK's using member to USING; if needed, allocate memory via
4565 diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
4566 index b23b294..531c43d 100644
4567 --- a/gdb/breakpoint.c
4568 +++ b/gdb/breakpoint.c
4569 @@ -191,6 +191,8 @@ static int is_hardware_watchpoint (struct breakpoint *bpt);
4571 static void insert_breakpoint_locations (void);
4573 +static int syscall_catchpoint_p (struct breakpoint *b);
4576 bpdisp_text (enum bpdisp disp)
4578 @@ -341,6 +343,18 @@ set_breakpoint_count (int num)
4579 value_from_longest (builtin_type_int32, (LONGEST) num));
4582 +/* Used in run_command to reset syscall catchpoints fields. */
4585 +clear_syscall_catchpoints_info (void)
4587 + struct breakpoint *b;
4589 + ALL_BREAKPOINTS (b)
4590 + if (syscall_catchpoint_p (b))
4591 + b->syscall_number = UNKNOWN_SYSCALL;
4594 /* Used in run_command to zero the hit count when a new run starts. */
4597 @@ -523,6 +537,53 @@ get_number_or_range (char **pp)
4601 +/* Set break condition of breakpoint B to EXP. */
4604 +set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty)
4606 + struct bp_location *loc = b->loc;
4608 + for (; loc; loc = loc->next)
4612 + xfree (loc->cond);
4617 + if (b->cond_string != NULL)
4618 + xfree (b->cond_string);
4622 + b->cond_string = NULL;
4624 + printf_filtered (_("Breakpoint %d now unconditional.\n"), b->number);
4630 + /* I don't know if it matters whether this is the string the user
4631 + typed in or the decompiled expression. */
4632 + b->cond_string = savestring (arg, strlen (arg));
4633 + b->condition_not_parsed = 0;
4634 + for (loc = b->loc; loc; loc = loc->next)
4638 + parse_exp_1 (&arg, block_for_pc (loc->address), 0);
4640 + error (_("Junk at end of expression"));
4644 + breakpoints_changed ();
4645 + observer_notify_breakpoint_modified (b->number);
4648 /* condition N EXP -- set break condition of breakpoint N to EXP. */
4651 @@ -543,42 +604,7 @@ condition_command (char *arg, int from_tty)
4653 if (b->number == bnum)
4655 - struct bp_location *loc = b->loc;
4656 - for (; loc; loc = loc->next)
4660 - xfree (loc->cond);
4664 - if (b->cond_string != NULL)
4665 - xfree (b->cond_string);
4669 - b->cond_string = NULL;
4671 - printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum);
4676 - /* I don't know if it matters whether this is the string the user
4677 - typed in or the decompiled expression. */
4678 - b->cond_string = savestring (arg, strlen (arg));
4679 - b->condition_not_parsed = 0;
4680 - for (loc = b->loc; loc; loc = loc->next)
4684 - parse_exp_1 (&arg, block_for_pc (loc->address), 0);
4686 - error (_("Junk at end of expression"));
4689 - breakpoints_changed ();
4690 - observer_notify_breakpoint_modified (b->number);
4691 + set_breakpoint_condition (b, p, from_tty);
4695 @@ -961,7 +987,7 @@ update_watchpoint (struct breakpoint *b, int reparse)
4697 struct bp_location *loc, **tmp;
4699 - addr = VALUE_ADDRESS (v) + value_offset (v);
4700 + addr = value_address (v);
4701 len = TYPE_LENGTH (value_type (v));
4703 if (b->type == bp_read_watchpoint)
4704 @@ -3948,8 +3974,8 @@ check_duplicates_for (CORE_ADDR address, struct obj_section *section)
4707 /* If we found a permanent breakpoint at this address, go over the
4708 - list again and declare all the other breakpoints there to be the
4710 + list again and declare all the other breakpoints there (except
4711 + other permanent breakpoints) to be the duplicates. */
4714 perm_bp->duplicate = 0;
4715 @@ -3963,7 +3989,8 @@ check_duplicates_for (CORE_ADDR address, struct obj_section *section)
4716 ALL_BP_LOCATIONS (b)
4719 - if (b->owner->enable_state != bp_disabled
4720 + if (b->owner->enable_state != bp_permanent
4721 + && b->owner->enable_state != bp_disabled
4722 && b->owner->enable_state != bp_call_disabled
4723 && b->enabled && !b->shlib_disabled
4724 && b->address == address /* address / overlay match */
4725 @@ -4134,6 +4161,8 @@ set_raw_breakpoint_without_location (enum bptype bptype)
4726 b->frame_id = null_frame_id;
4727 b->forked_inferior_pid = null_ptid;
4728 b->exec_pathname = NULL;
4729 + b->syscalls_to_be_caught = NULL;
4730 + b->syscall_number = UNKNOWN_SYSCALL;
4732 b->condition_not_parsed = 0;
4734 @@ -4660,7 +4689,241 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops =
4735 print_mention_catch_vfork
4738 -/* Create a new breakpoint of the bp_catchpoint kind and return it.
4739 +/* We keep a count of the number of times the user has requested a
4740 + particular syscall to be tracked, and pass this information to the
4741 + target. This lets capable targets implement filtering directly. */
4743 +/* Number of times that "any" syscall is requested. */
4744 +static int any_syscall_count;
4746 +/* Count of each system call. */
4747 +static int *syscalls_counts;
4749 +/* Number of system entries in SYSCALLS_COUNTS. */
4750 +static int syscalls_size;
4752 +/* This counts all syscall catch requests, so we can readily determine
4753 + if any catching is necessary. */
4754 +static int total_syscalls_count;
4756 +/* Implement the "insert" breakpoint_ops method for syscall
4760 +insert_catch_syscall (struct breakpoint *b)
4762 + ++total_syscalls_count;
4763 + if (!b->syscalls_to_be_caught)
4764 + ++any_syscall_count;
4767 + struct syscall_filter *iter;
4768 + for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4770 + if (iter->syscall >= syscalls_size)
4772 + syscalls_counts = xrealloc (syscalls_counts,
4773 + (iter->syscall + 1) * sizeof (int));
4774 + memset (&syscalls_counts[syscalls_size], 0,
4775 + (iter->syscall + 1 - syscalls_size) * sizeof (int));
4777 + ++syscalls_counts[iter->syscall];
4781 + target_set_syscall_catchpoint (PIDGET (inferior_ptid),
4782 + total_syscalls_count != 0,
4783 + any_syscall_count,
4788 +/* Implement the "remove" breakpoint_ops method for syscall
4792 +remove_catch_syscall (struct breakpoint *b)
4794 + --total_syscalls_count;
4795 + if (!b->syscalls_to_be_caught)
4796 + --any_syscall_count;
4799 + struct syscall_filter *iter;
4800 + for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4802 + if (iter->syscall >= syscalls_size)
4804 + /* Shouldn't happen. */
4807 + --syscalls_counts[iter->syscall];
4811 + return target_set_syscall_catchpoint (PIDGET (inferior_ptid),
4812 + total_syscalls_count != 0,
4813 + any_syscall_count,
4818 +/* Implement the "breakpoint_hit" breakpoint_ops method for syscall
4822 +breakpoint_hit_catch_syscall (struct breakpoint *b)
4824 + /* We must check if we are catching specific syscalls in this breakpoint.
4825 + If we are, then we must guarantee that the called syscall is the same
4826 + syscall we are catching. */
4827 + int syscall_number = 0;
4829 + if (!inferior_has_called_syscall (inferior_ptid, &syscall_number))
4832 + /* Now, checking if the syscall is the same. */
4833 + if (b->syscalls_to_be_caught)
4835 + struct syscall_filter *iter;
4836 + for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4837 + if (syscall_number == iter->syscall)
4839 + /* Not the same. */
4844 + /* It's the same syscall. We can update the breakpoint struct
4845 + with the correct information. */
4846 + b->syscall_number = syscall_number;
4851 +/* Implement the "print_it" breakpoint_ops method for syscall
4854 +static enum print_stop_action
4855 +print_it_catch_syscall (struct breakpoint *b)
4857 + /* These are needed because we want to know in which state a
4858 + syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY
4859 + or TARGET_WAITKIND_SYSCALL_RETURN, and depending on it we
4860 + must print "called syscall" or "returned from syscall". */
4862 + struct target_waitstatus last;
4864 + struct cleanup *old_chain;
4867 + gdbarch_get_syscall_by_number (current_gdbarch, b->syscall_number, &s);
4869 + get_last_target_status (&ptid, &last);
4871 + annotate_catchpoint (b->number);
4873 + if (s.name == NULL)
4874 + syscall_id = xstrprintf ("%d", b->syscall_number);
4876 + syscall_id = xstrprintf ("'%s'", s.name);
4878 + old_chain = make_cleanup (xfree, syscall_id);
4880 + if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY)
4881 + printf_filtered (_("\nCatchpoint %d (call to syscall %s), "),
4882 + b->number, syscall_id);
4884 + printf_filtered (_("\nCatchpoint %d (returned from syscall %s), "),
4885 + b->number, syscall_id);
4887 + do_cleanups (old_chain);
4889 + return PRINT_SRC_AND_LOC;
4892 +/* Implement the "print_one" breakpoint_ops method for syscall
4896 +print_one_catch_syscall (struct breakpoint *b, CORE_ADDR *last_addr)
4898 + struct value_print_options opts;
4901 + gdbarch_get_syscall_by_number (current_gdbarch, b->syscall_number, &s);
4903 + get_user_print_options (&opts);
4904 + /* Field 4, the address, is omitted (which makes the columns
4905 + not line up too nicely with the headers, but the effect
4906 + is relatively readable). */
4907 + if (opts.addressprint)
4908 + ui_out_field_skip (uiout, "addr");
4909 + annotate_field (5);
4910 + ui_out_text (uiout, "syscall \"");
4911 + if (b->syscall_number != UNKNOWN_SYSCALL)
4914 + ui_out_field_string (uiout, "what", s.name);
4916 + ui_out_field_int (uiout, "what", b->syscall_number);
4919 + ui_out_field_string (uiout, "what", "<any syscall>");
4920 + ui_out_text (uiout, "\" ");
4923 +/* Implement the "print_mention" breakpoint_ops method for syscall
4927 +print_mention_catch_syscall (struct breakpoint *b)
4929 + if (b->syscalls_to_be_caught)
4931 + struct syscall_filter *iter;
4932 + printf_filtered (_("Catchpoint %d (syscall(s)"), b->number);
4933 + for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4936 + gdbarch_get_syscall_by_number (current_gdbarch, iter->syscall, &s);
4939 + printf_filtered (" '%s'", s.name);
4941 + printf_filtered (" %d", iter->syscall);
4943 + printf_filtered (")");
4946 + printf_filtered (_("Catchpoint %d (any syscall)"),
4950 +/* The breakpoint_ops structure to be used in syscall catchpoints. */
4952 +static struct breakpoint_ops catch_syscall_breakpoint_ops =
4954 + insert_catch_syscall,
4955 + remove_catch_syscall,
4956 + breakpoint_hit_catch_syscall,
4957 + print_it_catch_syscall,
4958 + print_one_catch_syscall,
4959 + print_mention_catch_syscall
4962 +/* Returns non-zero if 'b' is a syscall catchpoint. */
4965 +syscall_catchpoint_p (struct breakpoint *b)
4967 + return (b->ops == &catch_syscall_breakpoint_ops);
4970 +/* Create a new breakpoint of the bp_catchpoint kind and return it,
4971 + but does NOT mention it nor update the global location list.
4972 + This is useful if you need to fill more fields in the
4973 + struct breakpoint before calling mention.
4975 If TEMPFLAG is non-zero, then make the breakpoint temporary.
4976 If COND_STRING is not NULL, then store it in the breakpoint.
4977 @@ -4668,16 +4931,13 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops =
4978 to the catchpoint. */
4980 static struct breakpoint *
4981 -create_catchpoint (int tempflag, char *cond_string,
4982 - struct breakpoint_ops *ops)
4983 +create_catchpoint_without_mention (int tempflag, char *cond_string,
4984 + struct breakpoint_ops *ops)
4986 struct symtab_and_line sal;
4987 struct breakpoint *b;
4991 - sal.symtab = NULL;
4994 b = set_raw_breakpoint (sal, bp_catchpoint);
4995 set_breakpoint_count (breakpoint_count + 1);
4996 @@ -4691,6 +4951,23 @@ create_catchpoint (int tempflag, char *cond_string,
4997 b->disposition = tempflag ? disp_del : disp_donttouch;
5003 +/* Create a new breakpoint of the bp_catchpoint kind and return it.
5005 + If TEMPFLAG is non-zero, then make the breakpoint temporary.
5006 + If COND_STRING is not NULL, then store it in the breakpoint.
5007 + OPS, if not NULL, is the breakpoint_ops structure associated
5008 + to the catchpoint. */
5010 +static struct breakpoint *
5011 +create_catchpoint (int tempflag, char *cond_string,
5012 + struct breakpoint_ops *ops)
5014 + struct breakpoint *b =
5015 + create_catchpoint_without_mention (tempflag, cond_string, ops);
5018 update_global_location_list (1);
5020 @@ -4775,6 +5052,23 @@ static struct breakpoint_ops catch_exec_breakpoint_ops =
5021 print_mention_catch_exec
5025 +create_syscall_event_catchpoint (int tempflag, struct syscall_filter *filter,
5026 + struct breakpoint_ops *ops)
5028 + struct breakpoint *b =
5029 + create_catchpoint_without_mention (tempflag, NULL, ops);
5031 + b->syscalls_to_be_caught = filter;
5032 + /* We still don't know the syscall that will be caught :-). */
5033 + b->syscall_number = UNKNOWN_SYSCALL;
5035 + /* Now, we have to mention the breakpoint and update the global
5038 + update_global_location_list (1);
5042 hw_breakpoint_used_count (void)
5044 @@ -5188,7 +5482,6 @@ expand_line_sal_maybe (struct symtab_and_line sal)
5045 struct symtabs_and_lines expanded;
5046 CORE_ADDR original_pc = sal.pc;
5047 char *original_function = NULL;
5051 /* If we have explicit pc, don't expand.
5052 @@ -5264,14 +5557,42 @@ expand_line_sal_maybe (struct symtab_and_line sal)
5057 + /* Find all the other PCs for a line of code with multiple instances
5058 + (locations). If the instruction is in the middle of an instruction
5059 + block for source line GDB cannot safely find the same instruction in
5060 + the other compiled instances of the same source line because the other
5061 + instances may have been compiled completely differently.
5063 + The testcase gdb.cp/expand-sals.exp shows that breaking at the return
5064 + address in a caller of the current frame works for the current
5065 + instance but the breakpoint cannot catch the point (instruction) where
5066 + the callee returns in the other compiled instances of this source line.
5068 + The current implementation will place the breakpoint at the expected
5069 + returning address of the current instance of the caller. But the
5070 + other instances will get the breakpoint at the first instruction of
5071 + the source line - therefore before the call would be made. Another
5072 + possibility would be to place the breakpoint in the other instances at
5073 + the start of the next source line.
5075 + A possible heuristics would compare the instructions length of each of
5076 + the instances of the current source line and if it matches it would
5077 + place the breakpoint at the same offset. Unfortunately a mistaken
5078 + guess would possibly crash the inferior. */
5080 + CORE_ADDR best = -1;
5082 + /* Find the nearest preceding PC and set it to ORIGINAL_PC. */
5083 for (i = 0; i < expanded.nelts; ++i)
5084 - if (expanded.sals[i].pc == original_pc)
5089 - gdb_assert (found);
5090 + if (expanded.sals[i].pc <= original_pc
5091 + && (best == -1 || expanded.sals[best].pc < expanded.sals[i].pc))
5095 + error (_("Cannot find the best address for %s out of the %d locations"),
5096 + paddr (original_pc), expanded.nelts);
5098 + expanded.sals[best].pc = original_pc;
5102 @@ -5310,8 +5631,6 @@ create_breakpoints (struct symtabs_and_lines sals, char **addr_string,
5103 cond_string, type, disposition,
5104 thread, ignore_count, ops, from_tty, enabled);
5107 - update_global_location_list (1);
5110 /* Parse ARG which is assumed to be a SAL specification possibly
5111 @@ -5637,7 +5956,6 @@ break_command_really (char *arg, char *cond_string, int thread,
5113 b->enable_state = enabled ? bp_enabled : bp_disabled;
5115 - update_global_location_list (1);
5119 @@ -5649,6 +5967,11 @@ break_command_really (char *arg, char *cond_string, int thread,
5120 discard_cleanups (breakpoint_chain);
5121 /* But cleanup everything else. */
5122 do_cleanups (old_chain);
5124 + /* Have already BREAKPOINT_CHAIN discarded as we may get an exception while
5125 + inserting the breakpoints which would double-free the resources both by
5126 + BREAKPOINT_CHAIN now and during DELETE_BREAKPOINT in the future. */
5127 + update_global_location_list (1);
5130 /* Set a breakpoint.
5131 @@ -6131,7 +6454,7 @@ can_use_hardware_watchpoint (struct value *v)
5132 || (TYPE_CODE (vtype) != TYPE_CODE_STRUCT
5133 && TYPE_CODE (vtype) != TYPE_CODE_ARRAY))
5135 - CORE_ADDR vaddr = VALUE_ADDRESS (v) + value_offset (v);
5136 + CORE_ADDR vaddr = value_address (v);
5137 int len = TYPE_LENGTH (value_type (v));
5139 if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
5140 @@ -6668,6 +6991,122 @@ catch_ada_exception_command (char *arg, int from_tty,
5144 +/* Cleanup function for a syscall filter list. */
5146 +clean_up_filters (void *arg)
5148 + struct syscall_filter *iter = *(struct syscall_filter **) arg;
5151 + struct syscall_filter *next = iter->next;
5157 +/* Splits the argument using space as delimiter. Returns an xmalloc'd
5158 + filter list, or NULL if no filtering is required. */
5159 +static struct syscall_filter *
5160 +catch_syscall_split_args (char *arg)
5162 + struct syscall_filter *result = NULL;
5163 + struct cleanup *cleanup = make_cleanup (clean_up_filters, &result);
5165 + while (*arg != '\0')
5167 + int i, syscall_number;
5169 + char cur_name[128];
5170 + struct syscall_filter *new_filter;
5173 + /* Skip whitespace. */
5174 + while (isspace (*arg))
5177 + for (i = 0; arg[i] && !isspace (arg[i]); ++i)
5178 + cur_name[i] = arg[i];
5179 + cur_name[i] = '\0';
5182 + /* Check if the user provided a syscall name or a number. */
5183 + syscall_number = (int) strtol (cur_name, &endptr, 10);
5184 + if (*endptr == '\0')
5186 + gdbarch_get_syscall_by_number (current_gdbarch,
5187 + syscall_number, &s);
5189 + if (s.name == NULL)
5190 + /* We can issue just a warning, but still create the catchpoint.
5191 + This is because, even not knowing the syscall name that
5192 + this number represents, we can still try to catch the syscall
5194 + warning (_("The number '%d' does not represent a known syscall."),
5199 + /* We have a name. Let's check if it's valid and convert it
5201 + gdbarch_get_syscall_by_name (current_gdbarch, cur_name, &s);
5203 + if (s.number == UNKNOWN_SYSCALL)
5204 + /* Here we have to issue an error instead of a warning, because
5205 + GDB cannot do anything useful if there's no syscall number to
5207 + error (_("Unknown syscall name '%s'."), cur_name);
5210 + /* Ok, it's valid. */
5211 + new_filter = XNEW (struct syscall_filter);
5212 + new_filter->syscall = s.number;
5213 + new_filter->next = result;
5214 + result = new_filter;
5217 + discard_cleanups (cleanup);
5221 +/* Implement the "catch syscall" command. */
5224 +catch_syscall_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
5227 + struct syscall_filter *filter;
5230 + /* Checking if the feature if supported. */
5231 + if (gdbarch_get_syscall_number_p (current_gdbarch) == 0)
5232 + error (_("The feature 'catch syscall' is not supported on \
5233 +this architeture yet."));
5235 + tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
5237 + ep_skip_leading_whitespace (&arg);
5239 + /* We need to do this first "dummy" translation in order
5240 + to get the syscall XML file loaded or, most important,
5241 + to display a warning to the user if there's no XML file
5242 + for his/her architecture. */
5243 + gdbarch_get_syscall_by_number (current_gdbarch, 0, &s);
5245 + /* The allowed syntax is:
5247 + catch syscall <name | number> [<name | number> ... <name | number>]
5249 + Let's check if there's a syscall name. */
5252 + filter = catch_syscall_split_args (arg);
5256 + create_syscall_event_catchpoint (tempflag, filter,
5257 + &catch_syscall_breakpoint_ops);
5260 /* Implement the "catch assert" command. */
5263 @@ -7134,6 +7573,7 @@ delete_breakpoint (struct breakpoint *bpt)
5264 xfree (bpt->source_file);
5265 if (bpt->exec_pathname != NULL)
5266 xfree (bpt->exec_pathname);
5267 + clean_up_filters (&bpt->syscalls_to_be_caught);
5269 /* Be sure no bpstat's are pointing at it after it's been freed. */
5270 /* FIXME, how can we find all bpstat's?
5271 @@ -8041,6 +8481,56 @@ single_step_breakpoint_inserted_here_p (CORE_ADDR pc)
5275 +/* Returns 0 if 'bp' is NOT a syscall catchpoint,
5276 + non-zero otherwise. */
5278 +is_syscall_catchpoint_enabled (struct breakpoint *bp)
5280 + if (syscall_catchpoint_p (bp)
5281 + && bp->enable_state != bp_disabled
5282 + && bp->enable_state != bp_call_disabled)
5289 +catch_syscall_enabled (void)
5291 + return total_syscalls_count != 0;
5295 +catching_syscall_number (int syscall_number)
5297 + struct breakpoint *bp;
5299 + ALL_BREAKPOINTS (bp)
5300 + if (is_syscall_catchpoint_enabled (bp))
5302 + if (bp->syscalls_to_be_caught)
5304 + struct syscall_filter *iter;
5305 + for (iter = bp->syscalls_to_be_caught; iter; iter = iter->next)
5306 + if (syscall_number == iter->syscall)
5316 +/* Complete syscall names. Used by "catch syscall". */
5318 +catch_syscall_completer (struct cmd_list_element *self, char *text, char *word)
5320 + const char **list =
5321 + gdbarch_get_syscall_names (current_gdbarch);
5322 + return (list == NULL) ? NULL : complete_on_enum (list, text, word);
5326 /* This help string is used for the break, hbreak, tbreak and thbreak commands.
5327 It is defined as a macro to prevent duplication.
5328 @@ -8073,6 +8563,8 @@ static void
5329 add_catch_command (char *name, char *docstring,
5330 void (*sfunc) (char *args, int from_tty,
5331 struct cmd_list_element *command),
5332 + char **(*completion_function) (struct cmd_list_element *self,
5333 + char *text, char *word),
5334 void *user_data_catch,
5335 void *user_data_tcatch)
5337 @@ -8082,11 +8574,13 @@ add_catch_command (char *name, char *docstring,
5339 set_cmd_sfunc (command, sfunc);
5340 set_cmd_context (command, user_data_catch);
5341 + set_cmd_completer (command, completion_function);
5343 command = add_cmd (name, class_breakpoint, NULL, docstring,
5345 set_cmd_sfunc (command, sfunc);
5346 set_cmd_context (command, user_data_tcatch);
5347 + set_cmd_completer (command, completion_function);
5351 @@ -8361,36 +8855,50 @@ Set temporary catchpoints to catch events."),
5352 Catch an exception, when caught.\n\
5353 With an argument, catch only exceptions with the given name."),
5354 catch_catch_command,
5358 add_catch_command ("throw", _("\
5359 Catch an exception, when thrown.\n\
5360 With an argument, catch only exceptions with the given name."),
5361 catch_throw_command,
5365 add_catch_command ("fork", _("Catch calls to fork."),
5366 catch_fork_command_1,
5368 (void *) (uintptr_t) catch_fork_permanent,
5369 (void *) (uintptr_t) catch_fork_temporary);
5370 add_catch_command ("vfork", _("Catch calls to vfork."),
5371 catch_fork_command_1,
5373 (void *) (uintptr_t) catch_vfork_permanent,
5374 (void *) (uintptr_t) catch_vfork_temporary);
5375 add_catch_command ("exec", _("Catch calls to exec."),
5376 catch_exec_command_1,
5380 + add_catch_command ("syscall", _("\
5381 +Catch system calls.\n\
5382 +With an argument, catch only that syscall."),
5383 + catch_syscall_command_1,
5384 + catch_syscall_completer,
5387 add_catch_command ("exception", _("\
5388 Catch Ada exceptions, when raised.\n\
5389 With an argument, catch only exceptions with the given name."),
5390 catch_ada_exception_command,
5394 add_catch_command ("assert", _("\
5395 Catch failed Ada assertions, when raised.\n\
5396 With an argument, catch only exceptions with the given name."),
5397 catch_assert_command,
5402 diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
5403 index 94287de..8552e1b 100644
5404 --- a/gdb/breakpoint.h
5405 +++ b/gdb/breakpoint.h
5406 @@ -33,7 +33,8 @@ struct block;
5408 #define BREAKPOINT_MAX 16
5410 -/* Type of breakpoint. */
5412 +/* Type of breakpoint. */
5413 /* FIXME In the future, we should fold all other breakpoint-like things into
5414 here. This includes:
5416 @@ -337,6 +338,17 @@ enum watchpoint_triggered
5420 +/* A syscall filter is represented as a linked list of syscall
5422 +struct syscall_filter
5424 + /* The system call to accept. */
5427 + /* The next filter. */
5428 + struct syscall_filter *next;
5431 typedef struct bp_location *bp_location_p;
5432 DEF_VEC_P(bp_location_p);
5434 @@ -442,6 +454,20 @@ struct breakpoint
5436 char *exec_pathname;
5438 + /* Syscall number used for the 'catch syscall' feature.
5439 + If no syscall has been called, its value is UNKNOWN_SYSCALL.
5440 + Otherwise, it holds the system call number in the target.
5442 + This field is only valid immediately after this catchpoint has
5444 + int syscall_number;
5446 + /* Syscall numbers used for the 'catch syscall' feature.
5447 + If no syscall has been specified for filtering, its value is NULL.
5448 + Otherwise, it holds a list of all syscalls to be caught.
5449 + The list elements are allocated with xmalloc. */
5450 + struct syscall_filter *syscalls_to_be_caught;
5452 /* Methods associated with this breakpoint. */
5453 struct breakpoint_ops *ops;
5455 @@ -783,6 +809,8 @@ extern void enable_watchpoints_after_interactive_call_stop (void);
5456 extern enum command_control_type commands_from_control_command
5457 (char *arg, struct command_line *cmd);
5459 +extern void clear_syscall_catchpoints_info (void);
5461 extern void clear_breakpoint_hit_counts (void);
5463 extern int get_number (char **);
5464 @@ -857,7 +885,19 @@ extern int breakpoints_always_inserted_mode (void);
5465 in our opinion won't ever trigger. */
5466 extern void breakpoint_retire_moribund (void);
5468 +/* Checks if we are catching syscalls or not.
5469 + Returns 0 if not, greater than 0 if we are. */
5470 +extern int catch_syscall_enabled (void);
5472 +/* Checks if we are catching syscalls with the specific
5473 + syscall_number. Used for "filtering" the catchpoints.
5474 + Returns 0 if not, greater than 0 if we are. */
5475 +extern int catching_syscall_number (int syscall_number);
5477 /* Tell a breakpoint to be quiet. */
5478 extern void make_breakpoint_silent (struct breakpoint *);
5480 +/* Set break condition of breakpoint B to EXP. */
5481 +extern void set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty);
5483 #endif /* !defined (BREAKPOINT_H) */
5484 diff --git a/gdb/buildsym.c b/gdb/buildsym.c
5485 index 55ace15..2722daa 100644
5486 --- a/gdb/buildsym.c
5487 +++ b/gdb/buildsym.c
5488 @@ -384,6 +384,8 @@ finish_block (struct symbol *symbol, struct pending **listhead,
5492 + block_set_using (block, using_directives, &objfile->objfile_obstack);
5494 record_pending_block (objfile, block, opblock);
5497 @@ -815,10 +817,6 @@ start_symtab (char *name, char *dirname, CORE_ADDR start_addr)
5498 /* We shouldn't have any address map at this point. */
5499 gdb_assert (! pending_addrmap);
5501 - /* Set up support for C++ namespace support, in case we need it. */
5503 - cp_initialize_namespace ();
5505 /* Initialize the list of sub source files with one entry for this
5506 file (the top-level source file). */
5508 @@ -1015,8 +1013,6 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section)
5509 finish_block (0, &global_symbols, 0, last_source_start_addr, end_addr,
5511 blockvector = make_blockvector (objfile);
5512 - cp_finalize_namespace (BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK),
5513 - &objfile->objfile_obstack);
5516 /* Read the line table if it has to be read separately. */
5517 @@ -1202,10 +1198,12 @@ push_context (int desc, CORE_ADDR valu)
5518 new->params = param_symbols;
5519 new->old_blocks = pending_blocks;
5520 new->start_addr = valu;
5521 + new->using_directives = using_directives;
5524 local_symbols = NULL;
5525 param_symbols = NULL;
5526 + using_directives = NULL;
5530 diff --git a/gdb/buildsym.h b/gdb/buildsym.h
5531 index bf23ecc..f542aca 100644
5532 --- a/gdb/buildsym.h
5533 +++ b/gdb/buildsym.h
5534 @@ -125,6 +125,10 @@ EXTERN struct pending *local_symbols;
5536 EXTERN struct pending *param_symbols;
5538 +/* using directives local to lexical context */
5540 +EXTERN struct using_direct *using_directives;
5542 /* Stack representing unclosed lexical contexts (that will become
5543 blocks, eventually). */
5545 @@ -138,6 +142,10 @@ struct context_stack
5547 struct pending *params;
5549 + /* Pending using directives at the time we entered */
5551 + struct using_direct *using_directives;
5553 /* Pointer into blocklist as of entry */
5555 struct pending_block *old_blocks;
5556 diff --git a/gdb/c-exp.y b/gdb/c-exp.y
5557 index d4bbbcc..107452a 100644
5560 @@ -119,6 +119,8 @@ static int yylex (void);
5562 void yyerror (char *);
5564 +/* Cleanup for 'nonempty_typelist' */
5565 +static struct cleanup *typelist_cleanup;
5568 /* Although the yacc "value" of an expression is not used,
5569 @@ -143,6 +145,7 @@ void yyerror (char *);
5573 + struct typed_stoken tsval;
5575 struct symtoken ssym;
5577 @@ -150,6 +153,7 @@ void yyerror (char *);
5578 enum exp_opcode opcode;
5579 struct internalvar *ivar;
5581 + struct stoken_vector svec;
5585 @@ -182,11 +186,13 @@ static int parse_number (char *, int, int, YYSTYPE *);
5586 Contexts where this distinction is not important can use the
5587 nonterminal "name", which matches either NAME or TYPENAME. */
5589 -%token <sval> STRING
5590 +%token <tsval> STRING
5591 +%token <tsval> CHAR
5592 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
5593 %token <voidval> COMPLETE
5594 %token <tsym> TYPENAME
5595 -%type <sval> name string_exp
5597 +%type <svec> string_exp
5598 %type <ssym> name_not_typename
5599 %type <tsym> typename
5601 @@ -399,6 +405,38 @@ arglist : arglist ',' exp %prec ABOVE_COMMA
5605 +exp : exp '(' nonempty_typelist ')'
5607 + /* What to do about freeing memory if
5608 + there is an error during parsing? */
5609 + write_exp_elt_opcode (TYPE_INSTANCE);
5610 + write_exp_elt_longcst ((LONGEST) $<ivec>3[0]);
5611 + for (i = 0; i < $<ivec>3[0]; ++i)
5612 + write_exp_elt_type ($<tvec>3[i + 1]);
5613 + write_exp_elt_longcst((LONGEST) $<ivec>3[0]);
5614 + write_exp_elt_opcode (TYPE_INSTANCE);
5615 + do_cleanups (typelist_cleanup);
5620 +exp : BLOCKNAME '(' nonempty_typelist ')'
5622 + write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP);
5623 + write_exp_elt_sym ($1.sym);
5624 + write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP);
5626 + write_exp_elt_opcode (TYPE_INSTANCE);
5627 + write_exp_elt_longcst ((LONGEST) $<ivec>3[0]);
5628 + for (i = 0; i < $<ivec>3[0]; ++i)
5629 + write_exp_elt_type ($<tvec>3[i + 1]);
5630 + write_exp_elt_longcst((LONGEST) $<ivec>3[0]);
5631 + write_exp_elt_opcode (TYPE_INSTANCE);
5632 + do_cleanups (typelist_cleanup);
5638 { $$ = end_arglist () - 1; }
5640 @@ -524,6 +562,15 @@ exp : INT
5641 write_exp_elt_opcode (OP_LONG); }
5646 + struct stoken_vector vec;
5649 + write_exp_string_vector ($1.type, &vec);
5655 parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
5656 @@ -572,48 +619,64 @@ string_exp:
5657 string. Note that we follow the
5658 NUL-termination convention of the
5660 - $$.length = $1.length;
5661 - $$.ptr = malloc ($1.length + 1);
5662 - memcpy ($$.ptr, $1.ptr, $1.length + 1);
5663 + struct typed_stoken *vec = XNEW (struct typed_stoken);
5667 + vec->type = $1.type;
5668 + vec->length = $1.length;
5669 + vec->ptr = malloc ($1.length + 1);
5670 + memcpy (vec->ptr, $1.ptr, $1.length + 1);
5675 /* Note that we NUL-terminate here, but just
5678 - t.length = $1.length + $2.length;
5679 - t.ptr = malloc (t.length + 1);
5680 - memcpy (t.ptr, $1.ptr, $1.length);
5681 - memcpy (t.ptr + $1.length, $2.ptr, $2.length + 1);
5686 + $$.tokens = realloc ($$.tokens,
5687 + $$.len * sizeof (struct typed_stoken));
5689 + p = malloc ($2.length + 1);
5690 + memcpy (p, $2.ptr, $2.length + 1);
5692 + $$.tokens[$$.len - 1].type = $2.type;
5693 + $$.tokens[$$.len - 1].length = $2.length;
5694 + $$.tokens[$$.len - 1].ptr = p;
5699 - { /* C strings are converted into array constants with
5700 - an explicit null byte added at the end. Thus
5701 - the array upper bound is the string length.
5702 - There is no such thing in C as a completely empty
5704 - char *sp = $1.ptr; int count = $1.length;
5705 - while (count-- > 0)
5708 + enum c_string_type type = C_STRING;
5710 + for (i = 0; i < $1.len; ++i)
5712 - write_exp_elt_opcode (OP_LONG);
5713 - write_exp_elt_type (parse_type->builtin_char);
5714 - write_exp_elt_longcst ((LONGEST)(*sp++));
5715 - write_exp_elt_opcode (OP_LONG);
5716 + switch ($1.tokens[i].type)
5720 + case C_WIDE_STRING:
5723 + if (type != C_STRING
5724 + && type != $1.tokens[i].type)
5725 + error ("Undefined string concatenation.");
5726 + type = $1.tokens[i].type;
5729 + /* internal error */
5730 + internal_error (__FILE__, __LINE__,
5731 + "unrecognized type in string concatenation");
5734 - write_exp_elt_opcode (OP_LONG);
5735 - write_exp_elt_type (parse_type->builtin_char);
5736 - write_exp_elt_longcst ((LONGEST)'\0');
5737 - write_exp_elt_opcode (OP_LONG);
5738 - write_exp_elt_opcode (OP_ARRAY);
5739 - write_exp_elt_longcst ((LONGEST) 0);
5740 - write_exp_elt_longcst ((LONGEST) ($1.length));
5741 - write_exp_elt_opcode (OP_ARRAY);
5744 + write_exp_string_vector (type, &$1);
5745 + for (i = 0; i < $1.len; ++i)
5746 + free ($1.tokens[i].ptr);
5751 @@ -713,12 +776,13 @@ qualified_name: typebase COLONCOLON name
5754 variable: qualified_name
5755 + | COLONCOLON qualified_name
5758 char *name = copy_name ($2);
5760 struct minimal_symbol *msymbol;
5764 lookup_symbol (name, (const struct block *) NULL,
5765 VAR_DOMAIN, (int *) NULL);
5766 @@ -856,7 +920,7 @@ array_mod: '[' ']'
5769 | '(' nonempty_typelist ')'
5770 - { free ($2); $$ = 0; }
5771 + { do_cleanups (typelist_cleanup); $$ = 0; }
5774 /* We used to try to recognize pointer to member types here, but
5775 @@ -1057,12 +1121,15 @@ typename: TYPENAME
5778 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
5779 + typelist_cleanup = make_cleanup (free, $$);
5780 $<ivec>$[0] = 1; /* Number of types in vector */
5783 | nonempty_typelist ',' type
5784 { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
5785 $$ = (struct type **) realloc ((char *) $1, len);
5786 + discard_cleanups (typelist_cleanup);
5787 + typelist_cleanup = make_cleanup (free, $$);
5788 $$[$<ivec>$[0]] = $3;
5791 @@ -1361,6 +1428,263 @@ parse_number (p, len, parsed_float, putithere)
5795 +/* Temporary obstack used for holding strings. */
5796 +static struct obstack tempbuf;
5797 +static int tempbuf_init;
5799 +/* Parse a C escape sequence. The initial backslash of the sequence
5800 + is at (*PTR)[-1]. *PTR will be updated to point to just after the
5801 + last character of the sequence. If OUTPUT is not NULL, the
5802 + translated form of the escape sequence will be written there. If
5803 + OUTPUT is NULL, no output is written and the call will only affect
5804 + *PTR. If an escape sequence is expressed in target bytes, then the
5805 + entire sequence will simply be copied to OUTPUT. Return 1 if any
5806 + character was emitted, 0 otherwise. */
5809 +c_parse_escape (char **ptr, struct obstack *output)
5811 + char *tokptr = *ptr;
5814 + /* Some escape sequences undergo character set conversion. Those we
5815 + translate here. */
5818 + /* Hex escapes do not undergo character set conversion, so keep
5819 + the escape sequence for later. */
5822 + obstack_grow_str (output, "\\x");
5824 + if (!isxdigit (*tokptr))
5825 + error (_("\\x escape without a following hex digit"));
5826 + while (isxdigit (*tokptr))
5829 + obstack_1grow (output, *tokptr);
5834 + /* Octal escapes do not undergo character set conversion, so
5835 + keep the escape sequence for later. */
5845 + obstack_grow_str (output, "\\");
5846 + while (isdigit (*tokptr) && *tokptr != '8' && *tokptr != '9')
5849 + obstack_1grow (output, *tokptr);
5854 + /* We handle UCNs later. We could handle them here, but that
5855 + would mean a spurious error in the case where the UCN could
5856 + be converted to the target charset but not the host
5862 + int i, len = c == 'U' ? 8 : 4;
5865 + obstack_1grow (output, '\\');
5866 + obstack_1grow (output, *tokptr);
5869 + if (!isxdigit (*tokptr))
5870 + error (_("\\%c escape without a following hex digit"), c);
5871 + for (i = 0; i < len && isxdigit (*tokptr); ++i)
5874 + obstack_1grow (output, *tokptr);
5880 + /* We must pass backslash through so that it does not
5881 + cause quoting during the second expansion. */
5884 + obstack_grow_str (output, "\\\\");
5888 + /* Escapes which undergo conversion. */
5891 + obstack_1grow (output, '\a');
5896 + obstack_1grow (output, '\b');
5901 + obstack_1grow (output, '\f');
5906 + obstack_1grow (output, '\n');
5911 + obstack_1grow (output, '\r');
5916 + obstack_1grow (output, '\t');
5921 + obstack_1grow (output, '\v');
5925 + /* GCC extension. */
5928 + obstack_1grow (output, HOST_ESCAPE_CHAR);
5932 + /* Backslash-newline expands to nothing at all. */
5938 + /* A few escapes just expand to the character itself. */
5942 + /* GCC extensions. */
5947 + /* Unrecognized escapes turn into the character itself. */
5950 + obstack_1grow (output, *tokptr);
5958 +/* Parse a string or character literal from TOKPTR. The string or
5959 + character may be wide or unicode. *OUTPTR is set to just after the
5960 + end of the literal in the input string. The resulting token is
5961 + stored in VALUE. This returns a token value, either STRING or
5962 + CHAR, depending on what was parsed. *HOST_CHARS is set to the
5963 + number of host characters in the literal. */
5965 +parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
5969 + enum c_string_type type;
5971 + /* Build the gdb internal form of the input string in tempbuf. Note
5972 + that the buffer is null byte terminated *only* for the
5973 + convenience of debugging gdb itself and printing the buffer
5974 + contents when the buffer contains no embedded nulls. Gdb does
5975 + not depend upon the buffer being null byte terminated, it uses
5976 + the length string instead. This allows gdb to handle C strings
5977 + (as well as strings in other languages) with embedded null
5980 + if (!tempbuf_init)
5983 + obstack_free (&tempbuf, NULL);
5984 + obstack_init (&tempbuf);
5986 + /* Record the string type. */
5987 + if (*tokptr == 'L')
5989 + type = C_WIDE_STRING;
5992 + else if (*tokptr == 'u')
5994 + type = C_STRING_16;
5997 + else if (*tokptr == 'U')
5999 + type = C_STRING_32;
6005 + /* Skip the quote. */
6007 + if (quote == '\'')
6019 + *host_chars += c_parse_escape (&tokptr, &tempbuf);
6021 + else if (c == quote)
6025 + obstack_1grow (&tempbuf, c);
6027 + /* FIXME: this does the wrong thing with multi-byte host
6028 + characters. We could use mbrlen here, but that would
6029 + make "set host-charset" a bit less useful. */
6034 + if (*tokptr != quote)
6037 + error ("Unterminated string in expression.");
6039 + error ("Unmatched single quote.");
6043 + value->type = type;
6044 + value->ptr = obstack_base (&tempbuf);
6045 + value->length = obstack_object_size (&tempbuf);
6049 + return quote == '"' ? STRING : CHAR;
6055 @@ -1526,23 +1850,33 @@ static int last_was_structop;
6059 + /* name_prefix stores the full qualification of a variable that is
6060 + specified in the expression. It is used to eleminate confusion
6062 + static char* name_prefix = NULL;
6063 + static int name_prefix_len = 0;
6064 + static int terminate_prefix = 0;
6072 - static char *tempbuf;
6073 - static int tempbufsize;
6074 - char * token_string = NULL;
6075 - int class_prefix = 0;
6076 int saw_structop = last_was_structop;
6079 last_was_structop = 0;
6085 + if(terminate_prefix ||
6086 + lexptr != name_prefix + name_prefix_len // Some token was skiped so clear name_prefix
6088 + name_prefix = NULL;
6089 + name_prefix_len = 0;
6092 + terminate_prefix = 1;
6094 /* Check if this is a macro invocation that we need to expand. */
6095 if (! scanning_macro_expansion ())
6097 @@ -1570,10 +1904,19 @@ yylex ()
6098 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
6099 if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
6102 + if(tokentab2[i].token == COLONCOLON){
6103 + name_prefix_len += 2;
6104 + terminate_prefix = 0;
6105 + if(name_prefix == NULL){
6106 + name_prefix = lexptr;
6110 yylval.opcode = tokentab2[i].opcode;
6111 if (in_parse_field && tokentab2[i].token == ARROW)
6112 last_was_structop = 1;
6114 return tokentab2[i].token;
6117 @@ -1602,51 +1945,13 @@ yylex ()
6121 + name_prefix_len++;
6122 + terminate_prefix = 0;
6129 - /* We either have a character constant ('0' or '\177' for example)
6130 - or we have a quoted symbol reference ('foo(int,int)' in C++
6135 - c = parse_escape (&lexptr);
6136 - else if (c == '\'')
6137 - error ("Empty character constant.");
6138 - else if (! host_char_to_target (c, &c))
6140 - int toklen = lexptr - tokstart + 1;
6141 - char *tok = alloca (toklen + 1);
6142 - memcpy (tok, tokstart, toklen);
6143 - tok[toklen] = '\0';
6144 - error ("There is no character corresponding to %s in the target "
6145 - "character set `%s'.", tok, target_charset ());
6148 - yylval.typed_val_int.val = c;
6149 - yylval.typed_val_int.type = parse_type->builtin_char;
6154 - namelen = skip_quoted (tokstart) - tokstart;
6157 - lexptr = tokstart + namelen;
6158 - if (lexptr[-1] != '\'')
6159 - error ("Unmatched single quote.");
6164 - error ("Invalid character constant.");
6171 @@ -1764,70 +2069,33 @@ yylex ()
6178 + if (tokstart[1] != '"' && tokstart[1] != '\'')
6180 + /* Fall through. */
6184 - /* Build the gdb internal form of the input string in tempbuf,
6185 - translating any standard C escape forms seen. Note that the
6186 - buffer is null byte terminated *only* for the convenience of
6187 - debugging gdb itself and printing the buffer contents when
6188 - the buffer contains no embedded nulls. Gdb does not depend
6189 - upon the buffer being null byte terminated, it uses the length
6190 - string instead. This allows gdb to handle C strings (as well
6191 - as strings in other languages) with embedded null bytes */
6193 - tokptr = ++tokstart;
6197 - char *char_start_pos = tokptr;
6199 - /* Grow the static temp buffer if necessary, including allocating
6200 - the first one on demand. */
6201 - if (tempbufindex + 1 >= tempbufsize)
6203 - tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
6208 + int result = parse_string_or_char (tokstart, &lexptr, &yylval.tsval,
6210 + if (result == CHAR)
6214 - /* Do nothing, loop will terminate. */
6218 - c = parse_escape (&tokptr);
6220 + if (host_len == 0)
6221 + error ("Empty character constant.");
6222 + else if (host_len > 2 && c == '\'')
6226 + namelen = lexptr - tokstart - 1;
6229 - tempbuf[tempbufindex++] = c;
6233 - if (! host_char_to_target (c, &c))
6235 - int len = tokptr - char_start_pos;
6236 - char *copy = alloca (len + 1);
6237 - memcpy (copy, char_start_pos, len);
6240 - error ("There is no character corresponding to `%s' "
6241 - "in the target character set `%s'.",
6242 - copy, target_charset ());
6244 - tempbuf[tempbufindex++] = c;
6246 + else if (host_len > 1)
6247 + error ("Invalid character constant.");
6249 - } while ((*tokptr != '"') && (*tokptr != '\0'));
6250 - if (*tokptr++ != '"')
6252 - error ("Unterminated string in expression.");
6254 - tempbuf[tempbufindex] = '\0'; /* See note above */
6255 - yylval.sval.ptr = tempbuf;
6256 - yylval.sval.length = tempbufindex;
6263 if (!(c == '_' || c == '$'
6264 @@ -1836,11 +2104,13 @@ yylex ()
6265 error ("Invalid character '%c' in expression.", c);
6267 /* It's a name. See how long it is. */
6270 for (c = tokstart[namelen];
6271 (c == '_' || c == '$' || (c >= '0' && c <= '9')
6272 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
6275 /* Template parameter lists are part of the name.
6276 FIXME: This mishandles `print $a<4&&$a>3'. */
6278 @@ -1904,14 +2174,29 @@ yylex ()
6279 currently as names of types; NAME for other symbols.
6280 The caller is not constrained to care about the distinction. */
6284 int is_a_field_of_this = 0;
6287 - sym = lookup_symbol (copy, expression_context_block,
6288 + if(name_prefix != NULL){
6289 + tmp = savestring (name_prefix, name_prefix_len+namelen);
6292 + sym = lookup_symbol (tmp, expression_context_block,
6294 parse_language->la_language == language_cplus
6295 ? &is_a_field_of_this : (int *) NULL);
6297 + /* keep this name as prefix for the next name */
6299 + if(name_prefix == NULL){
6300 + name_prefix = tokstart;
6302 + name_prefix_len += namelen;
6303 + terminate_prefix = 0;
6306 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
6307 no psymtabs (coff, xcoff, or some future change to blow away the
6308 psymtabs once once symbols are read). */
6309 @@ -1970,6 +2255,7 @@ yylex ()
6310 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
6311 if (in_parse_field && *lexptr == '\0')
6312 saw_name_at_eof = 1;
6317 diff --git a/gdb/c-lang.c b/gdb/c-lang.c
6318 index 8b5410f..188755b 100644
6321 @@ -33,48 +33,304 @@
6322 #include "demangle.h"
6324 #include "cp-support.h"
6325 +#include "gdb_obstack.h"
6328 +#include <wctype.h>
6330 extern void _initialize_c_language (void);
6331 -static void c_emit_char (int c, struct ui_file * stream, int quoter);
6333 +/* Given a C string type, STR_TYPE, return the corresponding target
6334 + character set name. */
6336 +static const char *
6337 +charset_for_string_type (enum c_string_type str_type)
6339 + switch (str_type & ~C_CHAR)
6342 + return target_charset ();
6343 + case C_WIDE_STRING:
6344 + return target_wide_charset ();
6346 + /* FIXME: UCS-2 is not always correct. */
6347 + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
6352 + /* FIXME: UCS-4 is not always correct. */
6353 + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
6358 + internal_error (__FILE__, __LINE__, "unhandled c_string_type");
6361 +/* Classify ELTTYPE according to what kind of character it is. Return
6362 + the enum constant representing the character type. Also set
6363 + *ENCODING to the name of the character set to use when converting
6364 + characters of this type to the host character set. */
6366 +static enum c_string_type
6367 +classify_type (struct type *elttype, const char **encoding)
6369 + struct type *saved_type;
6370 + enum c_string_type result;
6372 + /* We do one or two passes -- one on ELTTYPE, and then maybe a
6373 + second one on a typedef target. */
6376 + char *name = TYPE_NAME (elttype);
6378 + if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
6384 + if (!strcmp (name, "wchar_t"))
6386 + result = C_WIDE_CHAR;
6390 + if (!strcmp (name, "char16_t"))
6392 + result = C_CHAR_16;
6396 + if (!strcmp (name, "char32_t"))
6398 + result = C_CHAR_32;
6402 + saved_type = elttype;
6403 + CHECK_TYPEDEF (elttype);
6405 + while (elttype != saved_type);
6411 + *encoding = charset_for_string_type (result);
6415 +/* Return true if print_wchar can display W without resorting to a
6416 + numeric escape, false otherwise. */
6419 +wchar_printable (wchar_t w)
6421 + return (iswprint (w)
6422 + || w == L'\a' || w == L'\b' || w == L'\f' || w == L'\n'
6423 + || w == L'\r' || w == L'\t' || w == L'\v');
6426 +/* A helper function that converts the contents of STRING to wide
6427 + characters and then appends them to OUTPUT. */
6430 +append_string_as_wide (const char *string, struct obstack *output)
6432 + for (; *string; ++string)
6434 + wchar_t w = btowc (*string);
6435 + obstack_grow (output, &w, sizeof (wchar_t));
6439 +/* Print a wide character W to OUTPUT. ORIG is a pointer to the
6440 + original (target) bytes representing the character, ORIG_LEN is the
6441 + number of valid bytes. WIDTH is the number of bytes in a base
6442 + characters of the type. OUTPUT is an obstack to which wide
6443 + characters are emitted. QUOTER is a (narrow) character indicating
6444 + the style of quotes surrounding the character to be printed.
6445 + NEED_ESCAPE is an in/out flag which is used to track numeric
6446 + escapes across calls. */
6449 +print_wchar (wint_t w, const gdb_byte *orig, int orig_len,
6450 + int width, struct obstack *output, int quoter,
6451 + int *need_escapep)
6453 + int need_escape = *need_escapep;
6454 + *need_escapep = 0;
6455 + if (iswprint (w) && (!need_escape || (!iswdigit (w)
6459 + if (w == btowc (quoter) || w == L'\\')
6460 + obstack_grow_wstr (output, L"\\");
6461 + obstack_grow (output, &w, sizeof (wchar_t));
6468 + obstack_grow_wstr (output, L"\\a");
6471 + obstack_grow_wstr (output, L"\\b");
6474 + obstack_grow_wstr (output, L"\\f");
6477 + obstack_grow_wstr (output, L"\\n");
6480 + obstack_grow_wstr (output, L"\\r");
6483 + obstack_grow_wstr (output, L"\\t");
6486 + obstack_grow_wstr (output, L"\\v");
6492 + for (i = 0; i + width <= orig_len; i += width)
6495 + ULONGEST value = extract_unsigned_integer (&orig[i], width);
6496 + sprintf (octal, "\\%lo", (long) value);
6497 + append_string_as_wide (octal, output);
6499 + /* If we somehow have extra bytes, print them now. */
6500 + while (i < orig_len)
6503 + sprintf (octal, "\\%.3o", orig[i] & 0xff);
6504 + append_string_as_wide (octal, output);
6508 + *need_escapep = 1;
6515 /* Print the character C on STREAM as part of the contents of a literal
6516 string whose delimiter is QUOTER. Note that that format for printing
6517 characters and strings is language specific. */
6520 -c_emit_char (int c, struct ui_file *stream, int quoter)
6521 +c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
6523 - const char *escape;
6525 + struct obstack wchar_buf, output;
6526 + struct cleanup *cleanups;
6527 + const char *encoding;
6529 + struct wchar_iterator *iter;
6530 + int need_escape = 0;
6532 - c &= 0xFF; /* Avoid sign bit follies */
6533 + classify_type (type, &encoding);
6535 - escape = c_target_char_has_backslash_escape (c);
6538 - if (quoter == '"' && strcmp (escape, "0") == 0)
6539 - /* Print nulls embedded in double quoted strings as \000 to
6540 - prevent ambiguity. */
6541 - fprintf_filtered (stream, "\\000");
6543 - fprintf_filtered (stream, "\\%s", escape);
6545 - else if (target_char_to_host (c, &host_char)
6546 - && host_char_print_literally (host_char))
6547 + buf = alloca (TYPE_LENGTH (type));
6548 + pack_long (buf, type, c);
6550 + iter = make_wchar_iterator (buf, TYPE_LENGTH (type), encoding,
6551 + TYPE_LENGTH (type));
6552 + cleanups = make_cleanup_wchar_iterator (iter);
6554 + /* This holds the printable form of the wchar_t data. */
6555 + obstack_init (&wchar_buf);
6556 + make_cleanup_obstack_free (&wchar_buf);
6560 - if (host_char == '\\' || host_char == quoter)
6561 - fputs_filtered ("\\", stream);
6562 - fprintf_filtered (stream, "%c", host_char);
6565 + const gdb_byte *buf;
6567 + int print_escape = 1;
6568 + enum wchar_iterate_result result;
6570 + num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
6571 + if (num_chars < 0)
6573 + if (num_chars > 0)
6575 + /* If all characters are printable, print them. Otherwise,
6576 + we're going to have to print an escape sequence. We
6577 + check all characters because we want to print the target
6578 + bytes in the escape sequence, and we don't know character
6579 + boundaries there. */
6583 + for (i = 0; i < num_chars; ++i)
6584 + if (!wchar_printable (chars[i]))
6590 + if (!print_escape)
6592 + for (i = 0; i < num_chars; ++i)
6593 + print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
6594 + &wchar_buf, quoter, &need_escape);
6598 + /* This handles the NUM_CHARS == 0 case as well. */
6600 + print_wchar (WEOF, buf, buflen, TYPE_LENGTH (type), &wchar_buf, quoter,
6604 - fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
6606 + /* The output in the host encoding. */
6607 + obstack_init (&output);
6608 + make_cleanup_obstack_free (&output);
6610 + convert_between_encodings ("wchar_t", host_charset (),
6611 + obstack_base (&wchar_buf),
6612 + obstack_object_size (&wchar_buf),
6613 + 1, &output, translit_char);
6614 + obstack_1grow (&output, '\0');
6616 + fputs_filtered (obstack_base (&output), stream);
6618 + do_cleanups (cleanups);
6622 -c_printchar (int c, struct ui_file *stream)
6623 +c_printchar (int c, struct type *type, struct ui_file *stream)
6625 + enum c_string_type str_type;
6626 + const char *encoding;
6628 + str_type = classify_type (type, &encoding);
6634 + fputc_filtered ('L', stream);
6637 + fputc_filtered ('u', stream);
6640 + fputc_filtered ('U', stream);
6644 fputc_filtered ('\'', stream);
6645 - LA_EMIT_CHAR (c, stream, '\'');
6646 + LA_EMIT_CHAR (c, type, stream, '\'');
6647 fputc_filtered ('\'', stream);
6650 @@ -85,87 +341,206 @@ c_printchar (int c, struct ui_file *stream)
6651 printing LENGTH characters, or if FORCE_ELLIPSES. */
6654 -c_printstr (struct ui_file *stream, const gdb_byte *string,
6655 - unsigned int length, int width, int force_ellipses,
6656 +c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
6657 + unsigned int length, int force_ellipses,
6658 const struct value_print_options *options)
6661 unsigned int things_printed = 0;
6664 + int width = TYPE_LENGTH (type);
6665 + struct obstack wchar_buf, output;
6666 + struct cleanup *cleanup;
6667 + enum c_string_type str_type;
6668 + const char *encoding;
6669 + struct wchar_iterator *iter;
6671 + int need_escape = 0;
6673 /* If the string was not truncated due to `set print elements', and
6674 the last byte of it is a null, we don't print that, in traditional C
6678 - && (extract_unsigned_integer (string + (length - 1) * width, width)
6680 + && (extract_unsigned_integer (string + (length - 1) * width, width) == 0))
6683 + str_type = classify_type (type, &encoding) & ~C_CHAR;
6688 + case C_WIDE_STRING:
6689 + fputs_filtered ("L", stream);
6692 + fputs_filtered ("u", stream);
6695 + fputs_filtered ("U", stream);
6701 fputs_filtered ("\"\"", stream);
6705 - for (i = 0; i < length && things_printed < options->print_max; ++i)
6708 + unsigned long current_char = 1;
6709 + for (i = 0; current_char; ++i)
6712 + current_char = extract_unsigned_integer (string + i * width, width);
6717 + /* Arrange to iterate over the characters, in wchar_t form. */
6718 + iter = make_wchar_iterator (string, length * width, encoding, width);
6719 + cleanup = make_cleanup_wchar_iterator (iter);
6721 + /* WCHAR_BUF is the obstack we use to represent the string in
6723 + obstack_init (&wchar_buf);
6724 + make_cleanup_obstack_free (&wchar_buf);
6726 + while (!finished && things_printed < options->print_max)
6728 - /* Position of the character we are examining
6729 - to see whether it is repeated. */
6730 - unsigned int rep1;
6731 - /* Number of repetitions we have detected so far. */
6732 - unsigned int reps;
6733 - unsigned long current_char;
6735 + enum wchar_iterate_result result;
6737 + const gdb_byte *buf;
6744 - fputs_filtered (", ", stream);
6745 + obstack_grow_wstr (&wchar_buf, L", ");
6749 - current_char = extract_unsigned_integer (string + i * width, width);
6750 + num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
6751 + /* We only look at repetitions when we were able to convert a
6752 + single character in isolation. This makes the code simpler
6753 + and probably does the sensible thing in the majority of
6755 + while (num_chars == 1)
6757 + /* Count the number of repetitions. */
6758 + unsigned int reps = 0;
6759 + wchar_t current_char = chars[0];
6760 + const gdb_byte *orig_buf = buf;
6761 + int orig_len = buflen;
6765 - while (rep1 < length
6766 - && extract_unsigned_integer (string + rep1 * width, width)
6770 + obstack_grow_wstr (&wchar_buf, L", ");
6774 + while (num_chars == 1 && current_char == chars[0])
6776 + num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
6780 + /* Emit CURRENT_CHAR according to the repetition count and
6782 + if (reps > options->repeat_count_threshold)
6786 + if (options->inspect_it)
6787 + obstack_grow_wstr (&wchar_buf, L"\\\", ");
6789 + obstack_grow_wstr (&wchar_buf, L"\", ");
6792 + obstack_grow_wstr (&wchar_buf, L"'");
6794 + print_wchar (current_char, orig_buf, orig_len, width,
6795 + &wchar_buf, '\'', &need_escape);
6796 + obstack_grow_wstr (&wchar_buf, L"'");
6798 + /* Painful gyrations. */
6800 + char *s = xstrprintf (_(" <repeats %u times>"), reps);
6801 + for (j = 0; s[j]; ++j)
6803 + wchar_t w = btowc (s[j]);
6804 + obstack_grow (&wchar_buf, &w, sizeof (wchar_t));
6808 + things_printed += options->repeat_count_threshold;
6813 + /* Saw the character one or more times, but fewer than
6814 + the repetition threshold. */
6817 + if (options->inspect_it)
6818 + obstack_grow_wstr (&wchar_buf, L"\\\"");
6820 + obstack_grow_wstr (&wchar_buf, L"\"");
6825 + while (reps-- > 0)
6827 + print_wchar (current_char, orig_buf, orig_len, width,
6828 + &wchar_buf, '"', &need_escape);
6834 + /* NUM_CHARS and the other outputs from wchar_iterate are valid
6835 + here regardless of which branch was taken above. */
6836 + if (num_chars < 0)
6845 - if (reps > options->repeat_count_threshold)
6849 + case wchar_iterate_invalid:
6852 if (options->inspect_it)
6853 - fputs_filtered ("\\\", ", stream);
6854 + obstack_grow_wstr (&wchar_buf, L"\\\"");
6856 - fputs_filtered ("\", ", stream);
6858 + obstack_grow_wstr (&wchar_buf, L"\"");
6861 - LA_PRINT_CHAR (current_char, stream);
6862 - fprintf_filtered (stream, _(" <repeats %u times>"), reps);
6864 - things_printed += options->repeat_count_threshold;
6871 + print_wchar (WEOF, buf, buflen, width, &wchar_buf, '"', &need_escape);
6874 + case wchar_iterate_incomplete:
6877 if (options->inspect_it)
6878 - fputs_filtered ("\\\"", stream);
6879 + obstack_grow_wstr (&wchar_buf, L"\\\",");
6881 - fputs_filtered ("\"", stream);
6883 + obstack_grow_wstr (&wchar_buf, L"\",");
6886 - LA_EMIT_CHAR (current_char, stream, '"');
6888 + obstack_grow_wstr (&wchar_buf, L" <incomplete sequence ");
6889 + print_wchar (WEOF, buf, buflen, width, &wchar_buf, 0, &need_escape);
6890 + obstack_grow_wstr (&wchar_buf, L">");
6896 @@ -173,13 +548,27 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
6899 if (options->inspect_it)
6900 - fputs_filtered ("\\\"", stream);
6901 + obstack_grow_wstr (&wchar_buf, L"\\\"");
6903 - fputs_filtered ("\"", stream);
6904 + obstack_grow_wstr (&wchar_buf, L"\"");
6907 - if (force_ellipses || i < length)
6908 - fputs_filtered ("...", stream);
6909 + if (force_ellipses || !finished)
6910 + obstack_grow_wstr (&wchar_buf, L"...");
6912 + /* OUTPUT is where we collect `char's for printing. */
6913 + obstack_init (&output);
6914 + make_cleanup_obstack_free (&output);
6916 + convert_between_encodings ("wchar_t", host_charset (),
6917 + obstack_base (&wchar_buf),
6918 + obstack_object_size (&wchar_buf),
6919 + 1, &output, translit_char);
6920 + obstack_1grow (&output, '\0');
6922 + fputs_filtered (obstack_base (&output), stream);
6924 + do_cleanups (cleanup);
6927 /* Obtain a C string from the inferior storing it in a newly allocated
6928 @@ -298,7 +687,285 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
6932 -/* Preprocessing and parsing C and C++ expressions. */
6933 +/* Evaluating C and C++ expressions. */
6935 +/* Convert a UCN. The digits of the UCN start at P and extend no
6936 + farther than LIMIT. DEST_CHARSET is the name of the character set
6937 + into which the UCN should be converted. The results are written to
6938 + OUTPUT. LENGTH is the maximum length of the UCN, either 4 or 8.
6939 + Returns a pointer to just after the final digit of the UCN. */
6942 +convert_ucn (char *p, char *limit, const char *dest_charset,
6943 + struct obstack *output, int length)
6945 + unsigned long result = 0;
6949 + for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
6950 + result = (result << 4) + host_hex_value (*p);
6952 + for (i = 3; i >= 0; --i)
6954 + data[i] = result & 0xff;
6958 + convert_between_encodings ("UCS-4BE", dest_charset, data, 4, 4, output,
6964 +/* Emit a character, VALUE, which was specified numerically, to
6965 + OUTPUT. TYPE is the target character type. */
6968 +emit_numeric_character (struct type *type, unsigned long value,
6969 + struct obstack *output)
6973 + buffer = alloca (TYPE_LENGTH (type));
6974 + pack_long (buffer, type, value);
6975 + obstack_grow (output, buffer, TYPE_LENGTH (type));
6978 +/* Convert an octal escape sequence. TYPE is the target character
6979 + type. The digits of the escape sequence begin at P and extend no
6980 + farther than LIMIT. The result is written to OUTPUT. Returns a
6981 + pointer to just after the final digit of the escape sequence. */
6984 +convert_octal (struct type *type, char *p, char *limit, struct obstack *output)
6986 + unsigned long value = 0;
6988 + while (p < limit && isdigit (*p) && *p != '8' && *p != '9')
6990 + value = 8 * value + host_hex_value (*p);
6994 + emit_numeric_character (type, value, output);
6999 +/* Convert a hex escape sequence. TYPE is the target character type.
7000 + The digits of the escape sequence begin at P and extend no farther
7001 + than LIMIT. The result is written to OUTPUT. Returns a pointer to
7002 + just after the final digit of the escape sequence. */
7005 +convert_hex (struct type *type, char *p, char *limit, struct obstack *output)
7007 + unsigned long value = 0;
7009 + while (p < limit && isxdigit (*p))
7011 + value = 16 * value + host_hex_value (*p);
7015 + emit_numeric_character (type, value, output);
7024 + error (_("Malformed escape sequence")); \
7027 +/* Convert an escape sequence to a target format. TYPE is the target
7028 + character type to use, and DEST_CHARSET is the name of the target
7029 + character set. The backslash of the escape sequence is at *P, and
7030 + the escape sequence will not extend past LIMIT. The results are
7031 + written to OUTPUT. Returns a pointer to just past the final
7032 + character of the escape sequence. */
7035 +convert_escape (struct type *type, const char *dest_charset,
7036 + char *p, char *limit, struct obstack *output)
7038 + /* Skip the backslash. */
7044 + obstack_1grow (output, '\\');
7050 + if (!isxdigit (*p))
7051 + error (_("\\x used with no following hex digits."));
7052 + p = convert_hex (type, p, limit, output);
7063 + p = convert_octal (type, p, limit, output);
7069 + int length = *p == 'u' ? 4 : 8;
7071 + if (!isxdigit (*p))
7072 + error (_("\\u used with no following hex digits"));
7073 + p = convert_ucn (p, limit, dest_charset, output, length);
7080 +/* Given a single string from a (C-specific) OP_STRING list, convert
7081 + it to a target string, handling escape sequences specially. The
7082 + output is written to OUTPUT. DATA is the input string, which has
7083 + length LEN. DEST_CHARSET is the name of the target character set,
7084 + and TYPE is the type of target character to use. */
7087 +parse_one_string (struct obstack *output, char *data, int len,
7088 + const char *dest_charset, struct type *type)
7092 + limit = data + len;
7094 + while (data < limit)
7097 + /* Look for next escape, or the end of the input. */
7098 + while (p < limit && *p != '\\')
7100 + /* If we saw a run of characters, convert them all. */
7102 + convert_between_encodings (host_charset (), dest_charset,
7103 + data, p - data, 1, output, translit_none);
7104 + /* If we saw an escape, convert it. */
7106 + p = convert_escape (type, dest_charset, p, limit, output);
7111 +/* Expression evaluator for the C language family. Most operations
7112 + are delegated to evaluate_subexp_standard; see that function for a
7113 + description of the arguments. */
7115 +static struct value *
7116 +evaluate_subexp_c (struct type *expect_type, struct expression *exp,
7117 + int *pos, enum noside noside)
7119 + enum exp_opcode op = exp->elts[*pos].opcode;
7126 + struct type *type;
7127 + struct obstack output;
7128 + struct cleanup *cleanup;
7129 + struct value *result;
7130 + enum c_string_type dest_type;
7131 + const char *dest_charset;
7133 + obstack_init (&output);
7134 + cleanup = make_cleanup_obstack_free (&output);
7137 + oplen = longest_to_int (exp->elts[*pos].longconst);
7140 + limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
7142 + = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
7143 + switch (dest_type & ~C_CHAR)
7146 + type = language_string_char_type (current_language,
7149 + case C_WIDE_STRING:
7150 + type = lookup_typename ("wchar_t", NULL, 0);
7153 + type = lookup_typename ("char16_t", NULL, 0);
7156 + type = lookup_typename ("char32_t", NULL, 0);
7159 + internal_error (__FILE__, __LINE__, "unhandled c_string_type");
7161 + dest_charset = charset_for_string_type (dest_type);
7164 + while (*pos < limit)
7168 + len = longest_to_int (exp->elts[*pos].longconst);
7171 + if (noside != EVAL_SKIP)
7172 + parse_one_string (&output, &exp->elts[*pos].string, len,
7173 + dest_charset, type);
7174 + *pos += BYTES_TO_EXP_ELEM (len);
7177 + /* Skip the trailing length and opcode. */
7180 + if (noside == EVAL_SKIP)
7183 + if ((dest_type & C_CHAR) != 0)
7187 + if (obstack_object_size (&output) != TYPE_LENGTH (type))
7188 + error (_("Could not convert character constant to target character set"));
7189 + value = unpack_long (type, obstack_base (&output));
7190 + result = value_from_longest (type, value);
7195 + /* Write the terminating character. */
7196 + for (i = 0; i < TYPE_LENGTH (type); ++i)
7197 + obstack_1grow (&output, 0);
7198 + result = value_typed_string (obstack_base (&output),
7199 + obstack_object_size (&output),
7202 + do_cleanups (cleanup);
7210 + return evaluate_subexp_standard (expect_type, exp, pos, noside);
7215 @@ -396,6 +1063,15 @@ c_language_arch_info (struct gdbarch *gdbarch,
7216 lai->bool_type_default = builtin->builtin_int;
7219 +static const struct exp_descriptor exp_descriptor_c =
7221 + print_subexp_standard,
7222 + operator_length_standard,
7224 + dump_subexp_body_standard,
7228 const struct language_defn c_language_defn =
7230 "c", /* Language name */
7231 @@ -405,7 +1081,7 @@ const struct language_defn c_language_defn =
7235 - &exp_descriptor_standard,
7236 + &exp_descriptor_c,
7240 @@ -524,7 +1200,7 @@ const struct language_defn cplus_language_defn =
7244 - &exp_descriptor_standard,
7245 + &exp_descriptor_c,
7249 @@ -562,7 +1238,7 @@ const struct language_defn asm_language_defn =
7253 - &exp_descriptor_standard,
7254 + &exp_descriptor_c,
7258 @@ -605,7 +1281,7 @@ const struct language_defn minimal_language_defn =
7262 - &exp_descriptor_standard,
7263 + &exp_descriptor_c,
7267 diff --git a/gdb/c-lang.h b/gdb/c-lang.h
7268 index 06c5767..ba9d996 100644
7271 @@ -29,9 +29,38 @@ struct language_arch_info;
7272 #include "macroexp.h"
7275 -extern int c_parse (void); /* Defined in c-exp.y */
7277 -extern void c_error (char *); /* Defined in c-exp.y */
7278 +/* The various kinds of C string and character. Note that these
7279 + values are chosen so that they may be or'd together in certain
7283 + /* An ordinary string: "value". */
7285 + /* A wide string: L"value". */
7286 + C_WIDE_STRING = 1,
7287 + /* A 16-bit Unicode string: u"value". */
7289 + /* A 32-bit Unicode string: U"value". */
7291 + /* An ordinary char: 'v'. This can also be or'd with one of the
7292 + above to form the corresponding CHAR value from a STRING
7295 + /* A wide char: L'v'. */
7297 + /* A 16-bit Unicode char: u'v'. */
7299 + /* A 32-bit Unicode char: U'v'. */
7303 +/* Defined in c-exp.y. */
7305 +extern int c_parse (void);
7307 +extern void c_error (char *);
7309 +extern int c_parse_escape (char **, struct obstack *);
7311 /* Defined in c-typeprint.c */
7312 extern void c_print_type (struct type *, char *, struct ui_file *, int,
7313 @@ -48,10 +77,10 @@ extern int c_value_print (struct value *, struct ui_file *,
7315 /* These are in c-lang.c: */
7317 -extern void c_printchar (int, struct ui_file *);
7318 +extern void c_printchar (int, struct type *, struct ui_file *);
7320 -extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
7321 - unsigned int length, int width,
7322 +extern void c_printstr (struct ui_file * stream, struct type *elttype,
7323 + const gdb_byte *string, unsigned int length,
7325 const struct value_print_options *options);
7327 diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
7328 index 0929516..c005fe4 100644
7329 --- a/gdb/c-typeprint.c
7330 +++ b/gdb/c-typeprint.c
7331 @@ -40,8 +40,6 @@ static void cp_type_print_method_args (struct type *mtype, char *prefix,
7332 char *varstring, int staticp,
7333 struct ui_file *stream);
7335 -static void c_type_print_args (struct type *, struct ui_file *);
7337 static void cp_type_print_derivation_info (struct ui_file *, struct type *);
7339 static void c_type_print_varspec_prefix (struct type *, struct ui_file *, int,
7340 @@ -199,6 +197,23 @@ cp_type_print_method_args (struct type *mtype, char *prefix, char *varstring,
7341 fprintf_filtered (stream, "void");
7343 fprintf_filtered (stream, ")");
7345 + /* For non-static methods, read qualifiers from the type of
7349 + struct type *domain;
7351 + gdb_assert (nargs > 0);
7352 + gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR);
7353 + domain = TYPE_TARGET_TYPE (args[0].type);
7355 + if (TYPE_CONST (domain))
7356 + fprintf_filtered (stream, " const");
7358 + if (TYPE_VOLATILE (domain))
7359 + fprintf_filtered (stream, " volatile");
7364 @@ -354,10 +369,12 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
7366 /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
7367 or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this"
7368 - in non-static methods, are displayed. */
7369 + in non-static methods, are displayed if SHOW_ARTIFICIAL is
7373 -c_type_print_args (struct type *type, struct ui_file *stream)
7375 +c_type_print_args (struct type *type, struct ui_file *stream,
7376 + int show_artificial)
7380 @@ -369,6 +386,9 @@ c_type_print_args (struct type *type, struct ui_file *stream)
7382 for (i = 0; i < TYPE_NFIELDS (type); i++)
7384 + if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
7389 fprintf_filtered (stream, ", ");
7390 @@ -559,7 +579,12 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7391 fprintf_filtered (stream, ")");
7393 fprintf_filtered (stream, "[");
7394 - if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
7395 + if (TYPE_ARRAY_BOUND_IS_DWARF_BLOCK (type, 1))
7397 + /* No _() - printed sources should not be locale dependent. */
7398 + fprintf_filtered (stream, "variable");
7400 + else if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
7401 && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
7402 fprintf_filtered (stream, "%d",
7404 @@ -592,7 +617,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7406 fprintf_filtered (stream, ")");
7407 if (!demangled_args)
7408 - c_type_print_args (type, stream);
7409 + c_type_print_args (type, stream, 1);
7410 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, show,
7413 diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
7414 index 0b616f7..3433da2 100644
7415 --- a/gdb/c-valprint.c
7416 +++ b/gdb/c-valprint.c
7417 @@ -55,6 +55,18 @@ print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
7421 +/* A helper for textual_element_type. This checks the name of the
7422 + typedef. This is bogus but it isn't apparent that the compiler
7423 + provides us the help we may need. */
7426 +textual_name (const char *name)
7428 + return (!strcmp (name, "wchar_t")
7429 + || !strcmp (name, "char16_t")
7430 + || !strcmp (name, "char32_t"));
7433 /* Apply a heuristic to decide whether an array of TYPE or a pointer
7434 to TYPE should be printed as a textual string. Return non-zero if
7435 it should, or zero if it should be treated as an array of integers
7436 @@ -77,6 +89,15 @@ textual_element_type (struct type *type, char format)
7437 /* TYPE_CODE_CHAR is always textual. */
7438 if (TYPE_CODE (true_type) == TYPE_CODE_CHAR)
7440 + /* Any other character-like types must be integral. */
7441 + if (TYPE_CODE (true_type) != TYPE_CODE_INT)
7444 + /* Check the names of the type and the typedef. */
7445 + if (TYPE_NAME (type) && textual_name (TYPE_NAME (type)))
7447 + if (TYPE_NAME (true_type) && textual_name (TYPE_NAME (true_type)))
7452 @@ -115,7 +136,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7454 unsigned int i = 0; /* Number of characters printed */
7456 - struct type *elttype;
7457 + struct type *elttype, *unresolved_elttype;
7458 + struct type *unresolved_type = type;
7462 @@ -124,8 +146,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7463 switch (TYPE_CODE (type))
7465 case TYPE_CODE_ARRAY:
7466 - elttype = check_typedef (TYPE_TARGET_TYPE (type));
7467 - if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
7468 + unresolved_elttype = TYPE_TARGET_TYPE (type);
7469 + elttype = check_typedef (unresolved_elttype);
7470 + if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (unresolved_elttype) > 0)
7472 eltlen = TYPE_LENGTH (elttype);
7473 len = TYPE_LENGTH (type) / eltlen;
7474 @@ -135,7 +158,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7477 /* Print arrays of textual chars with a string syntax. */
7478 - if (textual_element_type (elttype, options->format))
7479 + if (textual_element_type (unresolved_elttype, options->format))
7481 /* If requested, look for the first null char and only print
7482 elements up to it. */
7483 @@ -143,15 +166,19 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7485 unsigned int temp_len;
7487 - /* Look for a NULL char. */
7489 - (valaddr + embedded_offset)[temp_len]
7490 - && temp_len < len && temp_len < options->print_max;
7493 + && temp_len < options->print_max
7494 + && extract_unsigned_integer (valaddr + embedded_offset
7495 + + temp_len * eltlen,
7502 - LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
7503 + LA_PRINT_STRING (stream, unresolved_elttype,
7504 + valaddr + embedded_offset, len, 0, options);
7508 @@ -209,7 +236,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7509 print_function_pointer_address (addr, stream, options->addressprint);
7512 - elttype = check_typedef (TYPE_TARGET_TYPE (type));
7513 + unresolved_elttype = TYPE_TARGET_TYPE (type);
7514 + elttype = check_typedef (unresolved_elttype);
7516 addr = unpack_pointer (type, valaddr + embedded_offset);
7517 print_unpacked_pointer:
7518 @@ -228,12 +256,11 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7520 /* For a pointer to a textual type, also print the string
7521 pointed to, unless pointer is null. */
7522 - /* FIXME: need to handle wchar_t here... */
7524 - if (textual_element_type (elttype, options->format)
7525 + if (textual_element_type (unresolved_elttype, options->format)
7528 - i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
7529 + i = val_print_string (unresolved_elttype, addr, -1, stream,
7532 else if (cp_is_vtbl_member (type))
7533 @@ -268,7 +295,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7537 - wtype = TYPE_TARGET_TYPE (type);
7538 + wtype = unresolved_elttype;
7540 vt_val = value_at (wtype, vt_address);
7541 common_val_print (vt_val, stream, recurse + 1, options,
7542 @@ -442,11 +469,11 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7543 Since we don't know whether the value is really intended to
7544 be used as an integer or a character, print the character
7545 equivalent as well. */
7546 - if (textual_element_type (type, options->format))
7547 + if (textual_element_type (unresolved_type, options->format))
7549 fputs_filtered (" ", stream);
7550 LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
7552 + unresolved_type, stream);
7556 @@ -468,7 +495,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7558 fprintf_filtered (stream, "%d", (int) val);
7559 fputs_filtered (" ", stream);
7560 - LA_PRINT_CHAR ((unsigned char) val, stream);
7561 + LA_PRINT_CHAR ((unsigned char) val, unresolved_type, stream);
7565 @@ -540,7 +567,7 @@ int
7566 c_value_print (struct value *val, struct ui_file *stream,
7567 const struct value_print_options *options)
7569 - struct type *type, *real_type;
7570 + struct type *type, *real_type, *val_type;
7571 int full, top, using_enc;
7572 struct value_print_options opts = *options;
7574 @@ -553,7 +580,11 @@ c_value_print (struct value *val, struct ui_file *stream,
7575 C++: if it is a member pointer, we will take care
7576 of that when we print it. */
7578 - type = check_typedef (value_type (val));
7579 + /* Preserve the original type before stripping typedefs. We prefer
7580 + to pass down the original type when possible, but for local
7581 + checks it is better to look past the typedefs. */
7582 + val_type = value_type (val);
7583 + type = check_typedef (val_type);
7585 if (TYPE_CODE (type) == TYPE_CODE_PTR
7586 || TYPE_CODE (type) == TYPE_CODE_REF)
7587 @@ -561,11 +592,12 @@ c_value_print (struct value *val, struct ui_file *stream,
7588 /* Hack: remove (char *) for char strings. Their
7589 type is indicated by the quoted string anyway.
7590 (Don't use textual_element_type here; quoted strings
7591 - are always exactly (char *). */
7592 - if (TYPE_CODE (type) == TYPE_CODE_PTR
7593 - && TYPE_NAME (type) == NULL
7594 - && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL
7595 - && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0)
7596 + are always exactly (char *), (wchar_t *), or the like. */
7597 + if (TYPE_CODE (val_type) == TYPE_CODE_PTR
7598 + && TYPE_NAME (val_type) == NULL
7599 + && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL
7600 + && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)), "char") == 0
7601 + || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type)))))
7605 @@ -608,6 +640,7 @@ c_value_print (struct value *val, struct ui_file *stream,
7607 type_print (type, "", stream, -1);
7608 fprintf_filtered (stream, ") ");
7613 @@ -635,7 +668,7 @@ c_value_print (struct value *val, struct ui_file *stream,
7614 /* Print out object: enclosing type is same as real_type if full */
7615 return val_print (value_enclosing_type (val),
7616 value_contents_all (val), 0,
7617 - VALUE_ADDRESS (val), stream, 0,
7618 + value_address (val), stream, 0,
7619 &opts, current_language);
7620 /* Note: When we look up RTTI entries, we don't get any information on
7621 const or volatile attributes */
7622 @@ -647,14 +680,14 @@ c_value_print (struct value *val, struct ui_file *stream,
7623 TYPE_NAME (value_enclosing_type (val)));
7624 return val_print (value_enclosing_type (val),
7625 value_contents_all (val), 0,
7626 - VALUE_ADDRESS (val), stream, 0,
7627 + value_address (val), stream, 0,
7628 &opts, current_language);
7630 /* Otherwise, we end up at the return outside this "if" */
7633 - return val_print (type, value_contents_all (val),
7634 + return val_print (val_type, value_contents_all (val),
7635 value_embedded_offset (val),
7636 - VALUE_ADDRESS (val) + value_offset (val),
7637 + value_address (val),
7638 stream, 0, &opts, current_language);
7640 diff --git a/gdb/charset-list.h b/gdb/charset-list.h
7641 new file mode 100644
7642 index 0000000..59c64c5
7644 +++ b/gdb/charset-list.h
7646 +/* List of character set names for GDB.
7648 + Copyright (C) 2009 Free Software Foundation, Inc.
7650 + This file is part of GDB.
7652 + This program is free software; you can redistribute it and/or modify
7653 + it under the terms of the GNU General Public License as published by
7654 + the Free Software Foundation; either version 3 of the License, or
7655 + (at your option) any later version.
7657 + This program is distributed in the hope that it will be useful,
7658 + but WITHOUT ANY WARRANTY; without even the implied warranty of
7659 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7660 + GNU General Public License for more details.
7662 + You should have received a copy of the GNU General Public License
7663 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
7665 +/* Note that the first entry must always be "auto".
7666 + The remaining entries were created by running this script:
7668 + iconv -l | sed -e '/[/]...*$/d' -e 's@^\(.*\)//$@"\1", \\@'
7670 + .. and then removing the final backslash. It would be nice to
7671 + separate narrow and wide character sets, but there is no good way
7673 +#define DEFAULT_CHARSET_NAMES \
7708 +"ANSI_X3.4-1968", \
7709 +"ANSI_X3.4-1986", \
7711 +"ANSI_X3.110-1983", \
7880 +"CSA_Z243.4-1985-1", \
7881 +"CSA_Z243.4-1985-2", \
7882 +"CSA_Z243.419851", \
7883 +"CSA_Z243.419852", \
7901 +"CSEUCPKDFMTJAPANESE", \
8003 +"CSISO4UNITEDKINGDOM", \
8004 +"CSISO10SWEDISH", \
8005 +"CSISO11SWEDISHFORNAMES", \
8006 +"CSISO14JISC6220RO", \
8007 +"CSISO15ITALIAN", \
8008 +"CSISO16PORTUGESE", \
8009 +"CSISO17SPANISH", \
8010 +"CSISO18GREEK7OLD", \
8011 +"CSISO19LATINGREEK", \
8014 +"CSISO27LATINGREEK1", \
8017 +"CSISO51INISCYRILLIC", \
8019 +"CSISO60DANISHNORWEGIAN", \
8020 +"CSISO60NORWEGIAN1", \
8021 +"CSISO61NORWEGIAN2", \
8023 +"CSISO84PORTUGUESE2", \
8024 +"CSISO85SPANISH2", \
8025 +"CSISO86HUNGARIAN", \
8027 +"CSISO89ASMO449", \
8029 +"CSISO92JISC62991984B", \
8031 +"CSISO103T618BIT", \
8032 +"CSISO111ECMACYRILLIC", \
8033 +"CSISO121CANADIAN1", \
8034 +"CSISO122CANADIAN2", \
8035 +"CSISO139CSN369103", \
8036 +"CSISO141JUSIB1002", \
8037 +"CSISO143IECP271", \
8039 +"CSISO150GREEKCCITT", \
8041 +"CSISO153GOST1976874", \
8042 +"CSISO646DANISH", \
8048 +"CSISO5427CYRILLIC", \
8049 +"CSISO5427CYRILLIC1981", \
8050 +"CSISO5428GREEK", \
8058 +"CSISOLATINARABIC", \
8059 +"CSISOLATINCYRILLIC", \
8060 +"CSISOLATINGREEK", \
8061 +"CSISOLATINHEBREW", \
8068 +"CSPC8CODEPAGE437", \
8070 +"CSPC850MULTILINGUAL", \
8071 +"CSPC862LATINHEBREW", \
8090 +"EBCDIC-AT-DE-A", \
8111 +"EBCDIC-CP-ROECE", \
8117 +"EBCDIC-CYRILLIC", \
8118 +"EBCDIC-DK-NO-A", \
8123 +"EBCDIC-FI-SE-A", \
8129 +"EBCDIC-IS-FRISS", \
8132 +"EBCDIC-JP-KANA", \
8182 +"GEORGIAN-ACADEMY", \
8401 +"ISO-2022-CN-EXT", \
8503 +"ISO646-JP-OCR-B", \
8553 +"ISO_646.IRV:1991", \
8563 +"ISO_6937-2:1983", \
8567 +"ISO_8859-1:1987", \
8569 +"ISO_8859-2:1987", \
8571 +"ISO_8859-3:1988", \
8573 +"ISO_8859-4:1988", \
8575 +"ISO_8859-5:1988", \
8577 +"ISO_8859-6:1987", \
8579 +"ISO_8859-7:1987", \
8580 +"ISO_8859-7:2003", \
8582 +"ISO_8859-8:1988", \
8584 +"ISO_8859-9:1989", \
8587 +"ISO_8859-10:1992", \
8589 +"ISO_8859-14:1998", \
8591 +"ISO_8859-15:1998", \
8593 +"ISO_8859-16:2001", \
8600 +"JIS_C6220-1969-RO", \
8601 +"JIS_C6229-1984-B", \
8602 +"JIS_C62201969RO", \
8603 +"JIS_C62291984B", \
8642 +"MAC-CENTRALEUROPE", \
8660 +"MS-MAC-CYRILLIC", \
8678 +"NF_Z_62-010_(1973)", \
8679 +"NF_Z_62-010_1973", \
8681 +"NF_Z_62010_1973", \
8762 +"SHIFT_JISX0213", \
8775 +"TCVN5712-1:1993", \
8836 diff --git a/gdb/charset.c b/gdb/charset.c
8837 index 32eb9c3..4850fbf 100644
8841 #include "charset.h"
8843 #include "gdb_assert.h"
8844 +#include "gdb_obstack.h"
8845 +#include "charset-list.h"
8849 #include "gdb_string.h"
8852 /* How GDB's character set support works
8854 - GDB has two global settings:
8855 + GDB has three global settings:
8857 - The `current host character set' is the character set GDB should
8858 use in talking to the user, and which (hopefully) the user's
8859 - terminal knows how to display properly.
8860 + terminal knows how to display properly. Most users should not
8863 - The `current target character set' is the character set the
8864 program being debugged uses.
8866 + - The `current target wide character set' is the wide character set
8867 + the program being debugged uses, that is, the encoding used for
8870 There are commands to set each of these, and mechanisms for
8871 choosing reasonable default values. GDB has a global list of
8872 character sets that it can use as its host or target character
8873 @@ -57,118 +65,37 @@
8874 characters the user enters in expressions (mostly host->target
8879 - Now, many of these operations are specific to a particular
8880 - host/target character set pair. If GDB supports N character sets,
8881 - there are N^2 possible pairs. This means that, the larger GDB's
8882 - repertoire of character sets gets, the more expensive it gets to add
8883 - new character sets.
8885 - To make sure that GDB can do the right thing for every possible
8886 - pairing of host and target character set, while still allowing
8887 - GDB's repertoire to scale, we use a two-tiered approach:
8889 - - We maintain a global table of "translations" --- groups of
8890 - functions specific to a particular pair of character sets.
8892 - - However, a translation can be incomplete: some functions can be
8893 - omitted. Where there is not a translation to specify exactly
8894 - what function to use, we provide reasonable defaults. The
8895 - default behaviors try to use the "iconv" library functions, which
8896 - support a wide range of character sets. However, even if iconv
8897 - is not available, there are fallbacks to support trivial
8898 - translations: when the host and target character sets are the
8902 -/* The character set and translation structures. */
8905 -/* A character set GDB knows about. GDB only supports character sets
8906 - with stateless encodings, in which every character is one byte
8910 - /* A singly-linked list of all known charsets. */
8911 - struct charset *next;
8913 - /* The name of the character set. Comparisons on character set
8914 - names are case-sensitive. */
8917 - /* Non-zero iff this character set can be used as a host character
8918 - set. At present, GDB basically assumes that the host character
8919 - set is a superset of ASCII. */
8920 - int valid_host_charset;
8922 - /* Pointers to charset-specific functions that depend only on a
8923 - single character set, and data pointers to pass to them. */
8924 - int (*host_char_print_literally) (void *baton,
8926 - void *host_char_print_literally_baton;
8928 - int (*target_char_to_control_char) (void *baton,
8930 - int *target_ctrl_char);
8931 - void *target_char_to_control_char_baton;
8935 -/* A translation from one character set to another. */
8936 -struct translation {
8938 - /* A singly-linked list of all known translations. */
8939 - struct translation *next;
8941 - /* This structure describes functions going from the FROM character
8942 - set to the TO character set. Comparisons on character set names
8943 - are case-sensitive. */
8944 - const char *from, *to;
8946 - /* Pointers to translation-specific functions, and data pointers to
8947 - pass to them. These pointers can be zero, indicating that GDB
8948 - should fall back on the default behavior. We hope the default
8949 - behavior will be correct for many from/to pairs, reducing the
8950 - number of translations that need to be registered explicitly. */
8952 - /* TARGET_CHAR is in the `from' charset.
8953 - Returns a string in the `to' charset. */
8954 - const char *(*c_target_char_has_backslash_escape) (void *baton,
8956 - void *c_target_char_has_backslash_escape_baton;
8958 - /* HOST_CHAR is in the `from' charset.
8959 - TARGET_CHAR points to a char in the `to' charset. */
8960 - int (*c_parse_backslash) (void *baton, int host_char, int *target_char);
8961 - void *c_parse_backslash_baton;
8963 - /* This is used for the host_char_to_target and target_char_to_host
8965 - int (*convert_char) (void *baton, int from, int *to);
8966 - void *convert_char_baton;
8971 + To avoid excessive code duplication and maintenance efforts,
8972 + GDB simply requires a capable iconv function. Users on platforms
8973 + without a suitable iconv can use the GNU iconv library. */
8976 /* The global lists of character sets and translations. */
8979 -#ifndef GDB_DEFAULT_HOST_CHARSET
8980 -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
8983 #ifndef GDB_DEFAULT_TARGET_CHARSET
8984 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
8987 -static const char *host_charset_name = GDB_DEFAULT_HOST_CHARSET;
8988 +#ifndef GDB_DEFAULT_TARGET_WIDE_CHARSET
8989 +#define GDB_DEFAULT_TARGET_WIDE_CHARSET "UCS-4"
8992 +static const char *auto_host_charset_name = GDB_DEFAULT_HOST_CHARSET;
8993 +static const char *host_charset_name = "auto";
8995 show_host_charset_name (struct ui_file *file, int from_tty,
8996 struct cmd_list_element *c,
8999 - fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
9000 + if (!strcmp (value, "auto"))
9001 + fprintf_filtered (file,
9002 + _("The host character set is \"auto; currently %s\".\n"),
9003 + auto_host_charset_name);
9005 + fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
9008 static const char *target_charset_name = GDB_DEFAULT_TARGET_CHARSET;
9009 @@ -180,1060 +107,534 @@ show_target_charset_name (struct ui_file *file, int from_tty,
9014 -static const char *host_charset_enum[] =
9015 +static const char *target_wide_charset_name = GDB_DEFAULT_TARGET_WIDE_CHARSET;
9017 +show_target_wide_charset_name (struct ui_file *file, int from_tty,
9018 + struct cmd_list_element *c, const char *value)
9024 + fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
9028 -static const char *target_charset_enum[] =
9029 +static const char *default_charset_names[] =
9035 + DEFAULT_CHARSET_NAMES
9039 -/* The global list of all the charsets GDB knows about. */
9040 -static struct charset *all_charsets;
9041 +static const char **charset_enum;
9044 +/* If the target wide character set has big- or little-endian
9045 + variants, these are the corresponding names. */
9046 +static const char *target_wide_charset_be_name;
9047 +static const char *target_wide_charset_le_name;
9050 -register_charset (struct charset *cs)
9052 - struct charset **ptr;
9054 - /* Put the new charset on the end, so that the list ends up in the
9055 - same order as the registrations in the _initialize function. */
9056 - for (ptr = &all_charsets; *ptr; ptr = &(*ptr)->next)
9063 +/* A helper function for validate which sets the target wide big- and
9064 + little-endian character set names, if possible. */
9066 -static struct charset *
9067 -lookup_charset (const char *name)
9069 +set_be_le_names (void)
9071 - struct charset *cs;
9074 - for (cs = all_charsets; cs; cs = cs->next)
9075 - if (! strcmp (name, cs->name))
9077 + target_wide_charset_le_name = NULL;
9078 + target_wide_charset_be_name = NULL;
9081 + len = strlen (target_wide_charset_name);
9082 + for (i = 0; charset_enum[i]; ++i)
9084 + if (strncmp (target_wide_charset_name, charset_enum[i], len))
9086 + if ((charset_enum[i][len] == 'B'
9087 + || charset_enum[i][len] == 'L')
9088 + && charset_enum[i][len + 1] == 'E'
9089 + && charset_enum[i][len + 2] == '\0')
9091 + if (charset_enum[i][len] == 'B')
9092 + target_wide_charset_be_name = charset_enum[i];
9094 + target_wide_charset_le_name = charset_enum[i];
9100 -/* The global list of translations. */
9101 -static struct translation *all_translations;
9103 +/* 'Set charset', 'set host-charset', 'set target-charset', 'set
9104 + target-wide-charset', 'set charset' sfunc's. */
9107 -register_translation (struct translation *t)
9110 - t->next = all_translations;
9111 - all_translations = t;
9115 -static struct translation *
9116 -lookup_translation (const char *from, const char *to)
9118 - struct translation *t;
9120 - for (t = all_translations; t; t = t->next)
9121 - if (! strcmp (from, t->from)
9122 - && ! strcmp (to, t->to))
9125 + const char *host_cset = host_charset ();
9132 -/* Constructing charsets. */
9134 -/* Allocate, initialize and return a straightforward charset.
9135 - Use this function, rather than creating the structures yourself,
9136 - so that we can add new fields to the structure in the future without
9137 - having to tweak all the old charset descriptions. */
9138 -static struct charset *
9139 -simple_charset (const char *name,
9140 - int valid_host_charset,
9141 - int (*host_char_print_literally) (void *baton, int host_char),
9142 - void *host_char_print_literally_baton,
9143 - int (*target_char_to_control_char) (void *baton,
9145 - int *target_ctrl_char),
9146 - void *target_char_to_control_char_baton)
9148 - struct charset *cs = xmalloc (sizeof (*cs));
9149 + desc = iconv_open (target_wide_charset_name, host_cset);
9150 + if (desc == (iconv_t) -1)
9151 + error ("Cannot convert between character sets `%s' and `%s'",
9152 + target_wide_charset_name, host_cset);
9153 + iconv_close (desc);
9155 - memset (cs, 0, sizeof (*cs));
9157 - cs->valid_host_charset = valid_host_charset;
9158 - cs->host_char_print_literally = host_char_print_literally;
9159 - cs->host_char_print_literally_baton = host_char_print_literally_baton;
9160 - cs->target_char_to_control_char = target_char_to_control_char;
9161 - cs->target_char_to_control_char_baton = target_char_to_control_char_baton;
9162 + desc = iconv_open (target_charset_name, host_cset);
9163 + if (desc == (iconv_t) -1)
9164 + error ("Cannot convert between character sets `%s' and `%s'",
9165 + target_charset_name, host_cset);
9166 + iconv_close (desc);
9169 + set_be_le_names ();
9174 -/* ASCII functions. */
9177 -ascii_print_literally (void *baton, int c)
9178 +/* This is the sfunc for the 'set charset' command. */
9180 +set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
9184 - return (0x20 <= c && c <= 0x7e);
9185 + /* CAREFUL: set the target charset here as well. */
9186 + target_charset_name = host_charset_name;
9192 -ascii_to_control (void *baton, int c, int *ctrl_char)
9193 +/* 'set host-charset' command sfunc. We need a wrapper here because
9194 + the function needs to have a specific signature. */
9196 +set_host_charset_sfunc (char *charset, int from_tty,
9197 + struct cmd_list_element *c)
9199 - *ctrl_char = (c & 037);
9205 -/* ISO-8859 family functions. */
9209 -iso_8859_print_literally (void *baton, int c)
9210 +/* Wrapper for the 'set target-charset' command. */
9212 +set_target_charset_sfunc (char *charset, int from_tty,
9213 + struct cmd_list_element *c)
9217 - return ((0x20 <= c && c <= 0x7e) /* ascii printables */
9218 - || (! sevenbit_strings && 0xA0 <= c)); /* iso 8859 printables */
9224 -iso_8859_to_control (void *baton, int c, int *ctrl_char)
9225 +/* Wrapper for the 'set target-wide-charset' command. */
9227 +set_target_wide_charset_sfunc (char *charset, int from_tty,
9228 + struct cmd_list_element *c)
9230 - *ctrl_char = (c & 0200) | (c & 037);
9236 -/* Construct an ISO-8859-like character set. */
9237 -static struct charset *
9238 -iso_8859_family_charset (const char *name)
9239 +/* sfunc for the 'show charset' command. */
9241 +show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
9244 - return simple_charset (name, 1,
9245 - iso_8859_print_literally, 0,
9246 - iso_8859_to_control, 0);
9247 + show_host_charset_name (file, from_tty, c, host_charset_name);
9248 + show_target_charset_name (file, from_tty, c, target_charset_name);
9249 + show_target_wide_charset_name (file, from_tty, c, target_wide_charset_name);
9254 -/* EBCDIC family functions. */
9258 -ebcdic_print_literally (void *baton, int c)
9262 - return (64 <= c && c <= 254);
9265 +/* Accessor functions. */
9268 -ebcdic_to_control (void *baton, int c, int *ctrl_char)
9270 +host_charset (void)
9272 - /* There are no control character equivalents in EBCDIC. Use
9273 - numeric escapes. */
9275 + if (!strcmp (host_charset_name, "auto"))
9276 + return auto_host_charset_name;
9277 + return host_charset_name;
9281 -/* Construct an EBCDIC-like character set. */
9282 -static struct charset *
9283 -ebcdic_family_charset (const char *name)
9285 +target_charset (void)
9287 - return simple_charset (name, 0,
9288 - ebcdic_print_literally, 0,
9289 - ebcdic_to_control, 0);
9290 + return target_charset_name;
9297 -/* Fallback functions using iconv. */
9299 -#if defined(HAVE_ICONV)
9301 -struct cached_iconv {
9302 - struct charset *from, *to;
9307 -/* Make sure the iconv cache *CI contains an iconv descriptor
9308 - translating from FROM to TO. If it already does, fine; otherwise,
9309 - close any existing descriptor, and open up a new one. On success,
9310 - return zero; on failure, return -1 and set errno. */
9312 -check_iconv_cache (struct cached_iconv *ci,
9313 - struct charset *from,
9314 - struct charset *to)
9316 +target_wide_charset (void)
9320 - /* Does the cached iconv descriptor match the conversion we're trying
9322 - if (ci->from == from
9324 - && ci->i != (iconv_t) 0)
9327 - /* It doesn't. If we actually had any iconv descriptor open at
9328 - all, close it now. */
9329 - if (ci->i != (iconv_t) 0)
9330 + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
9333 - ci->i = (iconv_t) 0;
9335 - if (iconv_close (i) == -1)
9336 - error (_("Error closing `iconv' descriptor for "
9337 - "`%s'-to-`%s' character conversion: %s"),
9338 - ci->from->name, ci->to->name, safe_strerror (errno));
9339 + if (target_wide_charset_be_name)
9340 + return target_wide_charset_be_name;
9343 - /* Open a new iconv descriptor for the required conversion. */
9344 - i = iconv_open (to->name, from->name);
9345 - if (i == (iconv_t) -1)
9356 -/* Convert FROM_CHAR using the cached iconv conversion *CI. Return
9357 - non-zero if the conversion was successful, zero otherwise. */
9359 -cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
9362 - ICONV_CONST char *from_ptr = &from;
9363 - char to, *to_ptr = &to;
9364 - size_t from_left = sizeof (from), to_left = sizeof (to);
9366 - gdb_assert (ci->i != (iconv_t) 0);
9369 - if (iconv (ci->i, &from_ptr, &from_left, &to_ptr, &to_left)
9373 - /* These all suggest that the input or output character sets
9374 - have multi-byte encodings of some characters, which means
9375 - it's unsuitable for use as a GDB character set. We should
9376 - never have selected it. */
9377 - gdb_assert (errno != E2BIG && errno != EINVAL);
9379 - /* This suggests a bug in the code managing *CI. */
9380 - gdb_assert (errno != EBADF);
9382 - /* This seems to mean that there is no equivalent character in
9383 - the `to' character set. */
9384 - if (errno == EILSEQ)
9387 - /* Anything else is mysterious. */
9388 - internal_error (__FILE__, __LINE__,
9389 - _("Error converting character `%d' from `%s' to `%s' "
9390 - "character set: %s"),
9391 - from_char, ci->from->name, ci->to->name,
9392 - safe_strerror (errno));
9393 + if (target_wide_charset_le_name)
9394 + return target_wide_charset_le_name;
9397 - /* If the pointers weren't advanced across the input, that also
9398 - suggests something was wrong. */
9399 - gdb_assert (from_left == 0 && to_left == 0);
9401 - *to_char = (unsigned char) to;
9403 + return target_wide_charset_name;
9408 -register_iconv_charsets (void)
9410 - /* Here we should check whether various character sets were
9411 - recognized by the local iconv implementation.
9413 - The first implementation registered a bunch of character sets
9414 - recognized by iconv, but then we discovered that iconv on Solaris
9415 - and iconv on GNU/Linux had no character sets in common. So we
9416 - replaced them with the hard-coded tables that appear later in the
9420 -#endif /* defined (HAVE_ICONV) */
9423 -/* Fallback routines for systems without iconv. */
9424 +/* Host character set management. For the time being, we assume that
9425 + the host character set is some superset of ASCII. */
9427 -#if ! defined (HAVE_ICONV)
9428 -struct cached_iconv { char nothing; };
9431 -check_iconv_cache (struct cached_iconv *ci,
9432 - struct charset *from,
9433 - struct charset *to)
9435 +host_letter_to_control_character (char c)
9445 -cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
9447 - /* This function should never be called. */
9450 +/* Convert a host character, C, to its hex value. C must already have
9451 + been validated using isxdigit. */
9454 -register_iconv_charsets (void)
9458 -#endif /* ! defined(HAVE_ICONV) */
9461 -/* Default trivial conversion functions. */
9464 -identity_either_char_to_other (void *baton, int either_char, int *other_char)
9466 +host_hex_value (char c)
9468 - *other_char = either_char;
9472 + if (c >= 'a' && c <= 'f')
9473 + return 10 + c - 'a';
9474 + gdb_assert (c >= 'A' && c <= 'F');
9475 + return 10 + c - 'A';
9480 -/* Default non-trivial conversion functions. */
9483 -static char backslashable[] = "abfnrtv";
9484 -static char *backslashed[] = {"a", "b", "f", "n", "r", "t", "v", "0"};
9485 -static char represented[] = "\a\b\f\n\r\t\v";
9488 -/* Translate TARGET_CHAR into the host character set, and see if it
9489 - matches any of our standard escape sequences. */
9490 -static const char *
9491 -default_c_target_char_has_backslash_escape (void *baton, int target_char)
9496 - /* If target_char has no equivalent in the host character set,
9497 - assume it doesn't have a backslashed form. */
9498 - if (! target_char_to_host (target_char, &host_char))
9501 - ix = strchr (represented, host_char);
9503 - return backslashed[ix - represented];
9509 -/* Translate the backslash the way we would in the host character set,
9510 - and then try to translate that into the target character set. */
9512 -default_c_parse_backslash (void *baton, int host_char, int *target_char)
9516 - ix = strchr (backslashable, host_char);
9521 - return host_char_to_target (represented[ix - backslashable],
9524 +/* Public character management functions. */
9526 +/* A cleanup function which is run to close an iconv descriptor. */
9528 -/* Convert using a cached iconv descriptor. */
9530 -iconv_convert (void *baton, int from_char, int *to_char)
9532 +cleanup_iconv (void *p)
9534 - struct cached_iconv *ci = baton;
9535 - return cached_iconv_convert (ci, from_char, to_char);
9536 + iconv_t *descp = p;
9537 + iconv_close (*descp);
9541 +convert_between_encodings (const char *from, const char *to,
9542 + const gdb_byte *bytes, unsigned int num_bytes,
9543 + int width, struct obstack *output,
9544 + enum transliterations translit)
9547 + struct cleanup *cleanups;
9550 + unsigned int space_request;
9552 + /* Often, the host and target charsets will be the same. */
9553 + if (!strcmp (from, to))
9555 + obstack_grow (output, bytes, num_bytes);
9560 -/* Conversion tables. */
9563 -/* I'd much rather fall back on iconv whenever possible. But the
9564 - character set names you use with iconv aren't standardized at all,
9565 - a lot of platforms have really meager character set coverage, etc.
9566 - I wanted to have at least something we could use to exercise the
9567 - test suite on all platforms.
9569 - In the long run, we should have a configure-time process explore
9570 - somehow which character sets the host platform supports, and some
9571 - arrangement that allows GDB users to use platform-indepedent names
9572 - for character sets. */
9575 -/* We generated these tables using iconv on a GNU/Linux machine. */
9578 -static int ascii_to_iso_8859_1_table[] = {
9579 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
9580 - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
9581 - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
9582 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
9583 - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
9584 - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
9585 - 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
9586 - 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
9587 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
9588 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
9589 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
9590 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9591 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
9592 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
9593 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
9594 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
9598 -static int ascii_to_ebcdic_us_table[] = {
9599 - 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
9600 - 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
9601 - 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
9602 - 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
9603 - 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
9604 - 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
9605 - 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
9606 - 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
9607 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
9608 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
9609 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
9610 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9611 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
9612 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
9613 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
9614 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
9618 -static int ascii_to_ibm1047_table[] = {
9619 - 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
9620 - 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
9621 - 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
9622 - 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
9623 - 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
9624 - 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
9625 - 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
9626 - 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
9627 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
9628 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
9629 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
9630 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9631 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
9632 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
9633 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
9634 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
9638 -static int iso_8859_1_to_ascii_table[] = {
9639 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
9640 - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
9641 - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
9642 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
9643 - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
9644 - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
9645 - 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
9646 - 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
9647 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
9648 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
9649 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
9650 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9651 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
9652 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
9653 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
9654 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
9658 -static int iso_8859_1_to_ebcdic_us_table[] = {
9659 - 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
9660 - 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
9661 - 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
9662 - 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
9663 - 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
9664 - 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
9665 - 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
9666 - 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
9667 - 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
9668 - 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
9669 - -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
9670 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9671 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
9672 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
9673 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
9674 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
9678 -static int iso_8859_1_to_ibm1047_table[] = {
9679 - 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
9680 - 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
9681 - 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
9682 - 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
9683 - 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
9684 - 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
9685 - 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
9686 - 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
9687 - 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
9688 - 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
9689 - 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
9690 - 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
9691 - 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
9692 - 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
9693 - 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
9694 - 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
9698 -static int ebcdic_us_to_ascii_table[] = {
9699 - 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
9700 - 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
9701 - -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
9702 - -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
9703 - 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
9704 - 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
9705 - 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
9706 - -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
9707 - -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
9708 - -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
9709 - -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
9710 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9711 - 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
9712 - 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
9713 - 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
9714 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
9718 -static int ebcdic_us_to_iso_8859_1_table[] = {
9719 - 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
9720 - 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
9721 - 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
9722 - 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
9723 - 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
9724 - 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
9725 - 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
9726 - -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
9727 - -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
9728 - -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
9729 - -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
9730 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9731 - 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
9732 - 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
9733 - 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
9734 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
9738 -static int ebcdic_us_to_ibm1047_table[] = {
9739 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
9740 - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
9741 - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
9742 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
9743 - 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
9744 - 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
9745 - 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
9746 - -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
9747 - -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
9748 - -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
9749 - -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
9750 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9751 - 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
9752 - 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
9753 - 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
9754 - 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
9758 -static int ibm1047_to_ascii_table[] = {
9759 - 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
9760 - 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
9761 - -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
9762 - -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
9763 - 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
9764 - 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
9765 - 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
9766 - -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
9767 - -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
9768 - -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
9769 - -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
9770 - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
9771 - 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
9772 - 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
9773 - 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
9774 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
9778 -static int ibm1047_to_iso_8859_1_table[] = {
9779 - 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
9780 - 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
9781 - 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
9782 - 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
9783 - 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
9784 - 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
9785 - 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
9786 - 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
9787 - 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
9788 - 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
9789 - 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
9790 - 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
9791 - 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
9792 - 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
9793 - 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
9794 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
9798 -static int ibm1047_to_ebcdic_us_table[] = {
9799 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
9800 - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
9801 - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
9802 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
9803 - 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
9804 - 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
9805 - 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
9806 - -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
9807 - -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
9808 - -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
9809 - -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
9810 - 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
9811 - 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
9812 - 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
9813 - 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
9814 - 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
9816 + desc = iconv_open (to, from);
9817 + if (desc == (iconv_t) -1)
9818 + perror_with_name ("Converting character sets");
9819 + cleanups = make_cleanup (cleanup_iconv, &desc);
9821 + inleft = num_bytes;
9822 + inp = (char *) bytes;
9825 -table_convert_char (void *baton, int from, int *to)
9827 - int *table = (int *) baton;
9828 + space_request = num_bytes;
9830 - if (0 <= from && from <= 255
9831 - && table[from] != -1)
9832 + while (inleft > 0)
9834 - *to = table[from];
9837 + size_t outleft, r;
9840 + old_size = obstack_object_size (output);
9841 + obstack_blank (output, space_request);
9843 + outp = obstack_base (output) + old_size;
9844 + outleft = space_request;
9846 + r = iconv (desc, &inp, &inleft, &outp, &outleft);
9848 + /* Now make sure that the object on the obstack only includes
9849 + bytes we have converted. */
9850 + obstack_blank (output, - (int) outleft);
9852 + if (r == (size_t) -1)
9860 + /* Invalid input sequence. */
9861 + if (translit == translit_none)
9862 + error (_("Could not convert character to `%s' character set"),
9865 + /* We emit escape sequence for the bytes, skip them,
9867 + for (i = 0; i < width; ++i)
9871 + sprintf (octal, "\\%.3o", *inp & 0xff);
9872 + obstack_grow_str (output, octal);
9881 + /* We ran out of space in the output buffer. Make it
9882 + bigger next time around. */
9883 + space_request *= 2;
9887 + /* Incomplete input sequence. FIXME: ought to report this
9888 + to the caller somehow. */
9893 + perror_with_name ("Internal error while converting character sets");
9902 -static struct translation *
9903 -table_translation (const char *from, const char *to, int *table,
9904 - const char *(*c_target_char_has_backslash_escape)
9905 - (void *baton, int target_char),
9906 - void *c_target_char_has_backslash_escape_baton,
9907 - int (*c_parse_backslash) (void *baton,
9909 - int *target_char),
9910 - void *c_parse_backslash_baton)
9912 - struct translation *t = xmalloc (sizeof (*t));
9914 - memset (t, 0, sizeof (*t));
9917 - t->c_target_char_has_backslash_escape = c_target_char_has_backslash_escape;
9918 - t->c_target_char_has_backslash_escape_baton
9919 - = c_target_char_has_backslash_escape_baton;
9920 - t->c_parse_backslash = c_parse_backslash;
9921 - t->c_parse_backslash_baton = c_parse_backslash_baton;
9922 - t->convert_char = table_convert_char;
9923 - t->convert_char_baton = (void *) table;
9926 + do_cleanups (cleanups);
9930 -static struct translation *
9931 -simple_table_translation (const char *from, const char *to, int *table)
9933 - return table_translation (from, to, table, 0, 0, 0, 0);
9938 -/* Setting and retrieving the host and target charsets. */
9941 -/* The current host and target character sets. */
9942 -static struct charset *current_host_charset, *current_target_charset;
9944 -/* The current functions and batons we should use for the functions in
9947 -static const char *(*c_target_char_has_backslash_escape_func)
9948 - (void *baton, int target_char);
9949 -static void *c_target_char_has_backslash_escape_baton;
9951 -static int (*c_parse_backslash_func) (void *baton,
9953 - int *target_char);
9954 -static void *c_parse_backslash_baton;
9956 -static int (*host_char_to_target_func) (void *baton,
9958 - int *target_char);
9959 -static void *host_char_to_target_baton;
9961 -static int (*target_char_to_host_func) (void *baton,
9964 -static void *target_char_to_host_baton;
9967 -/* Cached iconv conversions, that might be useful to fallback
9969 -static struct cached_iconv cached_iconv_host_to_target;
9970 -static struct cached_iconv cached_iconv_target_to_host;
9973 -/* Charset structures manipulation functions. */
9975 -static struct charset *
9976 -lookup_charset_or_error (const char *name)
9977 +/* An iterator that returns host wchar_t's from a target string. */
9978 +struct wchar_iterator
9980 - struct charset *cs = lookup_charset (name);
9981 + /* The underlying iconv descriptor. */
9985 - error (_("GDB doesn't know of any character set named `%s'."), name);
9986 + /* The input string. This is updated as convert characters. */
9988 + /* The number of bytes remaining in the input. */
9993 + /* The width of an input character. */
9997 -check_valid_host_charset (struct charset *cs)
9999 - if (! cs->valid_host_charset)
10000 - error (_("GDB can't use `%s' as its host character set."), cs->name);
10002 + /* The output buffer and its size. */
10007 -/* Set the host and target character sets to HOST and TARGET. */
10009 -set_host_and_target_charsets (struct charset *host, struct charset *target)
10010 +/* Create a new iterator. */
10011 +struct wchar_iterator *
10012 +make_wchar_iterator (const gdb_byte *input, size_t bytes, const char *charset,
10015 - struct translation *h2t, *t2h;
10017 - /* If they're not both initialized yet, then just do nothing for
10018 - now. As soon as we're done running our initialize function,
10019 - everything will be initialized. */
10020 - if (! host || ! target)
10022 - current_host_charset = host;
10023 - current_target_charset = target;
10027 - h2t = lookup_translation (host->name, target->name);
10028 - t2h = lookup_translation (target->name, host->name);
10030 - /* If the translations don't provide conversion functions, make sure
10031 - iconv can back them up. Do this *before* modifying any state. */
10032 - if (host != target)
10034 - if (! h2t || ! h2t->convert_char)
10036 - if (check_iconv_cache (&cached_iconv_host_to_target, host, target)
10038 - error (_("GDB can't convert from the `%s' character set to `%s'."),
10039 - host->name, target->name);
10041 - if (! t2h || ! t2h->convert_char)
10043 - if (check_iconv_cache (&cached_iconv_target_to_host, target, host)
10045 - error (_("GDB can't convert from the `%s' character set to `%s'."),
10046 - target->name, host->name);
10050 - if (t2h && t2h->c_target_char_has_backslash_escape)
10052 - c_target_char_has_backslash_escape_func
10053 - = t2h->c_target_char_has_backslash_escape;
10054 - c_target_char_has_backslash_escape_baton
10055 - = t2h->c_target_char_has_backslash_escape_baton;
10058 - c_target_char_has_backslash_escape_func
10059 - = default_c_target_char_has_backslash_escape;
10061 - if (h2t && h2t->c_parse_backslash)
10063 - c_parse_backslash_func = h2t->c_parse_backslash;
10064 - c_parse_backslash_baton = h2t->c_parse_backslash_baton;
10067 - c_parse_backslash_func = default_c_parse_backslash;
10069 - if (h2t && h2t->convert_char)
10071 - host_char_to_target_func = h2t->convert_char;
10072 - host_char_to_target_baton = h2t->convert_char_baton;
10074 - else if (host == target)
10075 - host_char_to_target_func = identity_either_char_to_other;
10078 - host_char_to_target_func = iconv_convert;
10079 - host_char_to_target_baton = &cached_iconv_host_to_target;
10081 + struct wchar_iterator *result;
10084 - if (t2h && t2h->convert_char)
10086 - target_char_to_host_func = t2h->convert_char;
10087 - target_char_to_host_baton = t2h->convert_char_baton;
10089 - else if (host == target)
10090 - target_char_to_host_func = identity_either_char_to_other;
10093 - target_char_to_host_func = iconv_convert;
10094 - target_char_to_host_baton = &cached_iconv_target_to_host;
10096 + desc = iconv_open ("wchar_t", charset);
10097 + if (desc == (iconv_t) -1)
10098 + perror_with_name ("Converting character sets");
10100 - current_host_charset = host;
10101 - current_target_charset = target;
10104 -/* Do the real work of setting the host charset. */
10106 -set_host_charset (const char *charset)
10108 - struct charset *cs = lookup_charset_or_error (charset);
10109 - check_valid_host_charset (cs);
10110 - set_host_and_target_charsets (cs, current_target_charset);
10112 + result = XNEW (struct wchar_iterator);
10113 + result->desc = desc;
10114 + result->input = (char *) input;
10115 + result->bytes = bytes;
10116 + result->width = width;
10118 -/* Do the real work of setting the target charset. */
10120 -set_target_charset (const char *charset)
10122 - struct charset *cs = lookup_charset_or_error (charset);
10123 + result->out = XNEW (wchar_t);
10124 + result->out_size = 1;
10126 - set_host_and_target_charsets (current_host_charset, cs);
10131 -/* 'Set charset', 'set host-charset', 'set target-charset', 'show
10132 - charset' sfunc's. */
10134 -/* This is the sfunc for the 'set charset' command. */
10136 -set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
10137 +do_cleanup_iterator (void *p)
10139 - struct charset *cs = lookup_charset_or_error (host_charset_name);
10140 - check_valid_host_charset (cs);
10141 - /* CAREFUL: set the target charset here as well. */
10142 - target_charset_name = host_charset_name;
10143 - set_host_and_target_charsets (cs, cs);
10145 + struct wchar_iterator *iter = p;
10147 -/* 'set host-charset' command sfunc. We need a wrapper here because
10148 - the function needs to have a specific signature. */
10150 -set_host_charset_sfunc (char *charset, int from_tty,
10151 - struct cmd_list_element *c)
10153 - set_host_charset (host_charset_name);
10154 + iconv_close (iter->desc);
10155 + xfree (iter->out);
10159 -/* Wrapper for the 'set target-charset' command. */
10161 -set_target_charset_sfunc (char *charset, int from_tty,
10162 - struct cmd_list_element *c)
10164 +make_cleanup_wchar_iterator (struct wchar_iterator *iter)
10166 - set_target_charset (target_charset_name);
10167 + return make_cleanup (do_cleanup_iterator, iter);
10170 -/* sfunc for the 'show charset' command. */
10172 -show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
10173 - const char *name)
10175 - if (current_host_charset == current_target_charset)
10176 - fprintf_filtered (file,
10177 - _("The current host and target character set is `%s'.\n"),
10178 - host_charset ());
10181 +wchar_iterate (struct wchar_iterator *iter,
10182 + enum wchar_iterate_result *out_result,
10183 + wchar_t **out_chars,
10184 + const gdb_byte **ptr,
10187 + size_t out_request;
10189 + /* Try to convert some characters. At first we try to convert just
10190 + a single character. The reason for this is that iconv does not
10191 + necessarily update its outgoing arguments when it encounters an
10192 + invalid input sequence -- but we want to reliably report this to
10193 + our caller so it can emit an escape sequence. */
10195 + while (iter->bytes > 0)
10197 - fprintf_filtered (file, _("The current host character set is `%s'.\n"),
10198 - host_charset ());
10199 - fprintf_filtered (file, _("The current target character set is `%s'.\n"),
10200 - target_charset ());
10201 + char *outptr = (char *) &iter->out[0];
10202 + char *orig_inptr = iter->input;
10203 + size_t orig_in = iter->bytes;
10204 + size_t out_avail = out_request * sizeof (wchar_t);
10208 + size_t r = iconv (iter->desc, (char **) &iter->input, &iter->bytes,
10209 + &outptr, &out_avail);
10210 + if (r == (size_t) -1)
10215 + /* Invalid input sequence. Skip it, and let the caller
10216 + know about it. */
10217 + *out_result = wchar_iterate_invalid;
10218 + *ptr = iter->input;
10219 + *len = iter->width;
10220 + iter->input += iter->width;
10221 + iter->bytes -= iter->width;
10225 + /* We ran out of space. We still might have converted a
10226 + character; if so, return it. Otherwise, grow the
10227 + buffer and try again. */
10228 + if (out_avail < out_request * sizeof (wchar_t))
10232 + if (out_request > iter->out_size)
10234 + iter->out_size = out_request;
10235 + iter->out = xrealloc (iter->out,
10236 + out_request * sizeof (wchar_t));
10241 + /* Incomplete input sequence. Let the caller know, and
10242 + arrange for future calls to see EOF. */
10243 + *out_result = wchar_iterate_incomplete;
10244 + *ptr = iter->input;
10245 + *len = iter->bytes;
10250 + perror_with_name ("Internal error while converting character sets");
10254 + /* We converted something. */
10255 + num = out_request - out_avail / sizeof (wchar_t);
10256 + *out_result = wchar_iterate_ok;
10257 + *out_chars = iter->out;
10258 + *ptr = orig_inptr;
10259 + *len = orig_in - iter->bytes;
10263 + /* Really done. */
10264 + *out_result = wchar_iterate_eof;
10269 -/* Accessor functions. */
10270 +/* The charset.c module initialization function. */
10273 -host_charset (void)
10275 - return current_host_charset->name;
10277 +extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
10280 -target_charset (void)
10282 - return current_target_charset->name;
10284 +typedef char *char_ptr;
10285 +DEF_VEC_P (char_ptr);
10287 +static VEC (char_ptr) *charsets;
10290 -/* Public character management functions. */
10291 +#ifdef HAVE_ICONVLIST
10293 +/* A helper function that adds some character sets to the vector of
10294 + all character sets. This is a callback function for iconvlist. */
10297 -c_target_char_has_backslash_escape (int target_char)
10299 +add_one (unsigned int count, const char *const *names, void *data)
10301 - return ((*c_target_char_has_backslash_escape_func)
10302 - (c_target_char_has_backslash_escape_baton, target_char));
10306 + for (i = 0; i < count; ++i)
10307 + VEC_safe_push (char_ptr, charsets, xstrdup (names[i]));
10310 -c_parse_backslash (int host_char, int *target_char)
10312 - return (*c_parse_backslash_func) (c_parse_backslash_baton,
10313 - host_char, target_char);
10319 -host_char_print_literally (int host_char)
10321 +find_charset_names (void)
10323 - return ((*current_host_charset->host_char_print_literally)
10324 - (current_host_charset->host_char_print_literally_baton,
10326 + iconvlist (add_one, NULL);
10327 + VEC_safe_push (char_ptr, charsets, NULL);
10333 -target_char_to_control_char (int target_char, int *target_ctrl_char)
10335 +find_charset_names (void)
10337 - return ((*current_target_charset->target_char_to_control_char)
10338 - (current_target_charset->target_char_to_control_char_baton,
10339 - target_char, target_ctrl_char));
10343 + in = popen ("iconv -l", "r");
10344 + /* It is ok to ignore errors; we'll fall back on a default. */
10349 -host_char_to_target (int host_char, int *target_char)
10351 - return ((*host_char_to_target_func)
10352 - (host_char_to_target_baton, host_char, target_char));
10354 + /* POSIX says that iconv -l uses an unspecified format. We parse
10355 + the glibc format; feel free to add others as needed. */
10356 + while (!feof (in))
10358 + /* The size of buf is chosen arbitrarily. A character set name
10359 + longer than this would not be very nice. */
10362 + char *r = fgets (buf, sizeof (buf), in);
10365 + len = strlen (r);
10368 + if (buf[len - 2] == '/' && buf[len - 3] == '/')
10369 + buf[len - 3] = '\0';
10370 + VEC_safe_push (char_ptr, charsets, xstrdup (buf));
10376 -target_char_to_host (int target_char, int *host_char)
10378 - return ((*target_char_to_host_func)
10379 - (target_char_to_host_baton, target_char, host_char));
10380 + VEC_safe_push (char_ptr, charsets, NULL);
10385 -/* The charset.c module initialization function. */
10387 -extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
10388 +#endif /* HAVE_ICONVLIST */
10391 _initialize_charset (void)
10393 struct cmd_list_element *new_cmd;
10395 - /* Register all the character set GDB knows about.
10397 - You should use the same names that iconv does, where possible, to
10398 - take advantage of the iconv-based default behaviors.
10400 - CAUTION: if you register a character set, you must also register
10401 - as many translations as are necessary to make that character set
10402 - interoperate correctly with all the other character sets. We do
10403 - provide default behaviors when no translation is available, or
10404 - when a translation's function pointer for a particular operation
10405 - is zero. Hopefully, these defaults will be correct often enough
10406 - that we won't need to provide too many translations. */
10407 - register_charset (simple_charset ("ASCII", 1,
10408 - ascii_print_literally, 0,
10409 - ascii_to_control, 0));
10410 - register_charset (iso_8859_family_charset ("ISO-8859-1"));
10411 - register_charset (ebcdic_family_charset ("EBCDIC-US"));
10412 - register_charset (ebcdic_family_charset ("IBM1047"));
10413 - register_iconv_charsets ();
10416 - struct { char *from; char *to; int *table; } tlist[] = {
10417 - { "ASCII", "ISO-8859-1", ascii_to_iso_8859_1_table },
10418 - { "ASCII", "EBCDIC-US", ascii_to_ebcdic_us_table },
10419 - { "ASCII", "IBM1047", ascii_to_ibm1047_table },
10420 - { "ISO-8859-1", "ASCII", iso_8859_1_to_ascii_table },
10421 - { "ISO-8859-1", "EBCDIC-US", iso_8859_1_to_ebcdic_us_table },
10422 - { "ISO-8859-1", "IBM1047", iso_8859_1_to_ibm1047_table },
10423 - { "EBCDIC-US", "ASCII", ebcdic_us_to_ascii_table },
10424 - { "EBCDIC-US", "ISO-8859-1", ebcdic_us_to_iso_8859_1_table },
10425 - { "EBCDIC-US", "IBM1047", ebcdic_us_to_ibm1047_table },
10426 - { "IBM1047", "ASCII", ibm1047_to_ascii_table },
10427 - { "IBM1047", "ISO-8859-1", ibm1047_to_iso_8859_1_table },
10428 - { "IBM1047", "EBCDIC-US", ibm1047_to_ebcdic_us_table }
10433 - for (i = 0; i < (sizeof (tlist) / sizeof (tlist[0])); i++)
10434 - register_translation (simple_table_translation (tlist[i].from,
10436 - tlist[i].table));
10439 - set_host_charset (host_charset_name);
10440 - set_target_charset (target_charset_name);
10441 + /* The first element is always "auto"; then we skip it for the
10442 + commands where it is not allowed. */
10443 + VEC_safe_push (char_ptr, charsets, "auto");
10444 + find_charset_names ();
10446 + if (VEC_length (char_ptr, charsets) > 1)
10447 + charset_enum = default_charset_names;
10449 + charset_enum = (const char **) VEC_address (char_ptr, charsets);
10451 +#ifdef HAVE_LANGINFO_CODESET
10452 + auto_host_charset_name = nl_langinfo (CODESET);
10453 + target_charset_name = auto_host_charset_name;
10455 + set_be_le_names ();
10458 add_setshow_enum_cmd ("charset", class_support,
10459 - host_charset_enum, &host_charset_name, _("\
10460 + &charset_enum[1], &host_charset_name, _("\
10461 Set the host and target character sets."), _("\
10462 Show the host and target character sets."), _("\
10463 The `host character set' is the one used by the system GDB is running on.\n\
10464 @@ -1249,7 +650,7 @@ To see a list of the character sets GDB supports, type `set charset <TAB>'."),
10465 &setlist, &showlist);
10467 add_setshow_enum_cmd ("host-charset", class_support,
10468 - host_charset_enum, &host_charset_name, _("\
10469 + charset_enum, &host_charset_name, _("\
10470 Set the host character set."), _("\
10471 Show the host character set."), _("\
10472 The `host character set' is the one used by the system GDB is running on.\n\
10473 @@ -1261,7 +662,7 @@ To see a list of the character sets GDB supports, type `set host-charset <TAB>'.
10474 &setlist, &showlist);
10476 add_setshow_enum_cmd ("target-charset", class_support,
10477 - target_charset_enum, &target_charset_name, _("\
10478 + &charset_enum[1], &target_charset_name, _("\
10479 Set the target character set."), _("\
10480 Show the target character set."), _("\
10481 The `target character set' is the one used by the program being debugged.\n\
10482 @@ -1271,4 +672,19 @@ To see a list of the character sets GDB supports, type `set target-charset'<TAB>
10483 set_target_charset_sfunc,
10484 show_target_charset_name,
10485 &setlist, &showlist);
10487 + add_setshow_enum_cmd ("target-wide-charset", class_support,
10488 + &charset_enum[1], &target_wide_charset_name,
10490 +Set the target wide character set."), _("\
10491 +Show the target wide character set."), _("\
10492 +The `target wide character set' is the one used by the program being debugged.\n\
10493 +In particular it is the encoding used by `wchar_t'.\n\
10494 +GDB translates characters and strings between the host and target\n\
10495 +character sets as needed.\n\
10496 +To see a list of the character sets GDB supports, type\n\
10497 +`set target-wide-charset'<TAB>"),
10498 + set_target_wide_charset_sfunc,
10499 + show_target_wide_charset_name,
10500 + &setlist, &showlist);
10502 diff --git a/gdb/charset.h b/gdb/charset.h
10503 index 21780b6..2455355 100644
10504 --- a/gdb/charset.h
10505 +++ b/gdb/charset.h
10510 +#include <wchar.h>
10512 /* If the target program uses a different character set than the host,
10513 GDB has some support for translating between the two; GDB converts
10514 @@ -26,82 +27,123 @@
10515 them, and converts characters and strings appearing in expressions
10516 entered by the user to the target character set.
10518 - At the moment, GDB only supports single-byte, stateless character
10519 - sets. This includes the ISO-8859 family (ASCII extended with
10520 - accented characters, and (I think) Cyrillic, for European
10521 - languages), and the EBCDIC family (used on IBM's mainframes).
10522 - Unfortunately, it excludes many Asian scripts, the fixed- and
10523 - variable-width Unicode encodings, and other desireable things.
10524 - Patches are welcome! (For example, it would be nice if the Java
10525 - string support could simply get absorbed into some more general
10526 - multi-byte encoding support.)
10528 - Furthermore, GDB's code pretty much assumes that the host character
10529 - set is some superset of ASCII; there are plenty if ('0' + n)
10530 - expressions and the like.
10532 - When the `iconv' library routine supports a character set meeting
10533 - the requirements above, it's easy to plug an entry into GDB's table
10534 - that uses iconv to handle the details. */
10535 + GDB's code pretty much assumes that the host character set is some
10536 + superset of ASCII; there are plenty if ('0' + n) expressions and
10539 /* Return the name of the current host/target character set. The
10540 result is owned by the charset module; the caller should not free
10542 const char *host_charset (void);
10543 const char *target_charset (void);
10545 -/* In general, the set of C backslash escapes (\n, \f) is specific to
10546 - the character set. Not all character sets will have form feed
10547 - characters, for example.
10549 - The following functions allow GDB to parse and print control
10550 - characters in a character-set-independent way. They are both
10551 - language-specific (to C and C++) and character-set-specific.
10552 - Putting them here is a compromise. */
10555 -/* If the target character TARGET_CHAR have a backslash escape in the
10556 - C language (i.e., a character like 'n' or 't'), return the host
10557 - character string that should follow the backslash. Otherwise,
10560 - When this function returns non-zero, the string it returns is
10561 - statically allocated; the caller is not responsible for freeing it. */
10562 -const char *c_target_char_has_backslash_escape (int target_char);
10565 -/* If the host character HOST_CHAR is a valid backslash escape in the
10566 - C language for the target character set, return non-zero, and set
10567 - *TARGET_CHAR to the target character the backslash escape represents.
10568 - Otherwise, return zero. */
10569 -int c_parse_backslash (int host_char, int *target_char);
10572 -/* Return non-zero if the host character HOST_CHAR can be printed
10573 - literally --- that is, if it can be readably printed as itself in a
10574 - character or string constant. Return zero if it should be printed
10575 - using some kind of numeric escape, like '\031' in C, '^(25)' in
10576 - Chill, or #25 in Pascal. */
10577 -int host_char_print_literally (int host_char);
10580 -/* If the host character HOST_CHAR has an equivalent in the target
10581 - character set, set *TARGET_CHAR to that equivalent, and return
10582 - non-zero. Otherwise, return zero. */
10583 -int host_char_to_target (int host_char, int *target_char);
10586 -/* If the target character TARGET_CHAR has an equivalent in the host
10587 - character set, set *HOST_CHAR to that equivalent, and return
10588 - non-zero. Otherwise, return zero. */
10589 -int target_char_to_host (int target_char, int *host_char);
10592 -/* If the target character TARGET_CHAR has a corresponding control
10593 - character (also in the target character set), set *TARGET_CTRL_CHAR
10594 - to the control character, and return non-zero. Otherwise, return
10596 -int target_char_to_control_char (int target_char, int *target_ctrl_char);
10598 +const char *target_wide_charset (void);
10600 +/* These values are used to specify the type of transliteration done
10601 + by convert_between_encodings. */
10602 +enum transliterations
10604 + /* Error on failure to convert. */
10606 + /* Transliterate to host char. */
10610 +/* Convert between two encodings.
10612 + FROM is the name of the source encoding.
10613 + TO is the name of the target encoding.
10614 + BYTES holds the bytes to convert; this is assumed to be characters
10615 + in the target encoding.
10616 + NUM_BYTES is the number of bytes.
10617 + WIDTH is the width of a character from the FROM charset, in bytes.
10618 + For a variable width encoding, WIDTH should be the size of a "base
10620 + OUTPUT is an obstack where the converted data is written. The
10621 + caller is responsible for initializing the obstack, and for
10622 + destroying the obstack should an error occur.
10623 + TRANSLIT specifies how invalid conversions should be handled. */
10624 +void convert_between_encodings (const char *from, const char *to,
10625 + const gdb_byte *bytes, unsigned int num_bytes,
10626 + int width, struct obstack *output,
10627 + enum transliterations translit);
10630 +/* These values are used by wchar_iterate to report errors. */
10631 +enum wchar_iterate_result
10633 + /* Ordinary return. */
10634 + wchar_iterate_ok,
10635 + /* Invalid input sequence. */
10636 + wchar_iterate_invalid,
10637 + /* Incomplete input sequence at the end of the input. */
10638 + wchar_iterate_incomplete,
10640 + wchar_iterate_eof
10643 +/* Declaration of the opaque wchar iterator type. */
10644 +struct wchar_iterator;
10646 +/* Create a new character iterator which returns wchar_t's. INPUT is
10647 + the input buffer. BYTES is the number of bytes in the input
10648 + buffer. CHARSET is the name of the character set in which INPUT is
10649 + encoded. WIDTH is the number of bytes in a base character of
10652 + This function either returns a new character set iterator, or calls
10653 + error. The result can be freed using a cleanup; see
10654 + make_cleanup_wchar_iterator. */
10655 +struct wchar_iterator *make_wchar_iterator (const gdb_byte *input, size_t bytes,
10656 + const char *charset,
10659 +/* Return a new cleanup suitable for destroying the wchar iterator
10661 +struct cleanup *make_cleanup_wchar_iterator (struct wchar_iterator *iter);
10663 +/* Perform a single iteration of a wchar_t iterator.
10665 + Returns the number of characters converted. A negative result
10666 + means that EOF has been reached. A positive result indicates the
10667 + number of valid wchar_ts in the result; *OUT_CHARS is updated to
10668 + point to the first valid character.
10670 + In all cases aside from EOF, *PTR is set to point to the first
10671 + converted target byte. *LEN is set to the number of bytes
10674 + A zero result means one of several unusual results. *OUT_RESULT is
10675 + set to indicate the type of un-ordinary return.
10677 + wchar_iterate_invalid means that an invalid input character was
10678 + seen. The iterator is advanced by WIDTH (the argument to
10679 + make_wchar_iterator) bytes.
10681 + wchar_iterate_incomplete means that an incomplete character was
10682 + seen at the end of the input sequence.
10684 + wchar_iterate_eof means that all bytes were successfully
10685 + converted. The other output arguments are not set. */
10686 +int wchar_iterate (struct wchar_iterator *iter,
10687 + enum wchar_iterate_result *out_result,
10688 + wchar_t **out_chars,
10689 + const gdb_byte **ptr, size_t *len);
10693 +/* GDB needs to know a few details of its execution character set.
10694 + This knowledge is isolated here and in charset.c. */
10696 +/* The escape character. */
10697 +#define HOST_ESCAPE_CHAR 27
10699 +/* Convert a letter, like 'c', to its corresponding control
10701 +char host_letter_to_control_character (char c);
10703 +/* Convert a hex digit character to its numeric value. E.g., 'f' is
10704 + converted to 15. This function assumes that C is a valid hex
10705 + digit. Both upper- and lower-case letters are recognized. */
10706 +int host_hex_value (char c);
10708 #endif /* CHARSET_H */
10709 diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
10710 index 4d9c4f3..5fbe398 100644
10711 --- a/gdb/cli/cli-cmds.c
10712 +++ b/gdb/cli/cli-cmds.c
10714 #include "cli/cli-setshow.h"
10715 #include "cli/cli-cmds.h"
10717 +#include "python/python.h"
10720 #include "tui/tui.h" /* For tui_active et.al. */
10722 @@ -178,6 +180,7 @@ struct cmd_list_element *showchecklist;
10724 /* Command tracing state. */
10726 +static int source_python = 0;
10727 int source_verbose = 0;
10728 int trace_commands = 0;
10730 @@ -439,6 +442,7 @@ source_script (char *file, int from_tty)
10731 struct cleanup *old_cleanups;
10732 char *full_pathname = NULL;
10736 if (file == NULL || *file == 0)
10738 @@ -471,8 +475,16 @@ source_script (char *file, int from_tty)
10742 + is_python = source_python;
10743 + if (strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py"))
10746 stream = fdopen (fd, FOPEN_RT);
10747 - script_from_file (stream, file);
10750 + source_python_script (stream, file);
10752 + script_from_file (stream, file);
10754 do_cleanups (old_cleanups);
10756 @@ -486,15 +498,30 @@ source_verbose_cleanup (void *old_value)
10760 +/* A helper for source_command. Look for an argument in *ARGS.
10761 + Update *ARGS by stripping leading whitespace. If an argument is
10762 + found, return it (a character). Otherwise, return 0. */
10764 +find_argument (char **args)
10767 + while (isspace ((*args)[0]))
10769 + if ((*args)[0] == '-' && isalpha ((*args)[1]))
10771 + result = (*args)[1];
10778 source_command (char *args, int from_tty)
10780 struct cleanup *old_cleanups;
10781 - char *file = args;
10782 - int *old_source_verbose = xmalloc (sizeof(int));
10784 - *old_source_verbose = source_verbose;
10785 - old_cleanups = make_cleanup (source_verbose_cleanup, old_source_verbose);
10786 + old_cleanups = make_cleanup_restore_integer (&source_verbose);
10787 + make_cleanup_restore_integer (&source_python);
10789 /* -v causes the source command to run in verbose mode.
10790 We still have to be able to handle filenames with spaces in a
10791 @@ -502,23 +529,28 @@ source_command (char *args, int from_tty)
10795 - /* Make sure leading white space does not break the comparisons. */
10796 - while (isspace(args[0]))
10799 - /* Is -v the first thing in the string? */
10800 - if (args[0] == '-' && args[1] == 'v' && isspace (args[2]))
10803 - source_verbose = 1;
10805 - /* Trim -v and whitespace from the filename. */
10807 - while (isspace (file[0]))
10809 + int arg = find_argument (&args);
10815 + source_verbose = 1;
10818 + source_python = 1;
10821 + error (_("unrecognized option -%c"), arg);
10826 - source_script (file, from_tty);
10827 + source_script (args, from_tty);
10829 + do_cleanups (old_cleanups);
10833 @@ -1282,7 +1314,9 @@ Read commands from a file named FILE.\n\
10834 Optional -v switch (before the filename) causes each command in\n\
10835 FILE to be echoed as it is executed.\n\
10836 Note that the file \"%s\" is read automatically in this way\n\
10837 -when GDB is started."), gdbinit);
10838 +when GDB is started.\n\
10839 +Optional -p switch (before the filename) causes FILE to be evaluated\n\
10840 +as Python code."), gdbinit);
10841 c = add_cmd ("source", class_support, source_command,
10842 source_help_text, &cmdlist);
10843 set_cmd_completer (c, filename_completer);
10844 diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
10845 index ee29f2a..96e6111 100644
10846 --- a/gdb/cli/cli-dump.c
10847 +++ b/gdb/cli/cli-dump.c
10848 @@ -296,7 +296,7 @@ dump_value_to_file (char *cmd, char *mode, char *file_format)
10850 if (VALUE_LVAL (val))
10852 - vaddr = VALUE_ADDRESS (val);
10853 + vaddr = value_address (val);
10857 diff --git a/gdb/coffread.c b/gdb/coffread.c
10858 index 6059d68..47ee601 100644
10859 --- a/gdb/coffread.c
10860 +++ b/gdb/coffread.c
10861 @@ -346,7 +346,7 @@ coff_alloc_type (int index)
10862 We will fill it in later if we find out how. */
10865 - type = alloc_type (current_objfile);
10866 + type = alloc_type (current_objfile, NULL);
10870 @@ -2101,6 +2101,7 @@ static struct sym_fns coff_sym_fns =
10871 coff_new_init, /* sym_new_init: init anything gbl to entire symtab */
10872 coff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
10873 coff_symfile_read, /* sym_read: read a symbol file into symtab */
10874 + NULL, /* sym_read_psymbols */
10875 coff_symfile_finish, /* sym_finish: finished with file, cleanup */
10876 default_symfile_offsets, /* sym_offsets: xlate external to internal form */
10877 default_symfile_segments, /* sym_segments: Get segment information from
10878 diff --git a/gdb/config.in b/gdb/config.in
10879 index 6aaf77a..0c8ccab 100644
10880 --- a/gdb/config.in
10881 +++ b/gdb/config.in
10883 language is requested. */
10886 +/* Global directory for GDB data files. */
10887 +#undef GDB_DATADIR
10889 +/* Define if GDB datadir should be relocated when GDB is moved. */
10890 +#undef GDB_DATADIR_RELOCATABLE
10892 /* Define to be a string naming the default host character set. */
10893 #undef GDB_DEFAULT_HOST_CHARSET
10895 @@ -169,12 +175,18 @@
10896 /* Define if you have the iconv() function. */
10899 +/* Define to 1 if you have the `iconvlist' function. */
10900 +#undef HAVE_ICONVLIST
10902 /* Define if your compiler supports the #include_next directive. */
10903 #undef HAVE_INCLUDE_NEXT
10905 /* Define to 1 if you have the <inttypes.h> header file. */
10906 #undef HAVE_INTTYPES_H
10908 +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
10909 +#undef HAVE_LANGINFO_CODESET
10911 /* Define if your <locale.h> file defines LC_MESSAGES. */
10912 #undef HAVE_LC_MESSAGES
10914 @@ -618,6 +630,9 @@
10916 #undef PTRDIFF_T_SUFFIX
10918 +/* Define to install path for Python sources */
10921 /* Bug reporting address */
10922 #undef REPORT_BUGS_TO
10924 diff --git a/gdb/configure b/gdb/configure
10925 index 7579c84..3a5b582 100755
10926 --- a/gdb/configure
10927 +++ b/gdb/configure
10928 @@ -314,7 +314,7 @@ ac_subdirs_all="$ac_subdirs_all doc testsuite"
10929 ac_subdirs_all="$ac_subdirs_all gdbtk"
10930 ac_subdirs_all="$ac_subdirs_all multi-ice"
10931 ac_subdirs_all="$ac_subdirs_all gdbserver"
10932 -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags nm_h LIBICONV LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
10933 +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP RANLIB ac_ct_RANLIB build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os am__leading_dot DEPDIR CCDEPMODE MAKE GMAKE_TRUE GMAKE_FALSE SET_MAKE USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT localedir GL_COND_LIBTOOL_TRUE GL_COND_LIBTOOL_FALSE GNULIB_MEMMEM GNULIB_MEMPCPY GNULIB_MEMRCHR GNULIB_STPCPY GNULIB_STPNCPY GNULIB_STRCHRNUL GNULIB_STRDUP GNULIB_STRNDUP GNULIB_STRNLEN GNULIB_STRPBRK GNULIB_STRSEP GNULIB_STRSTR GNULIB_STRCASESTR GNULIB_STRTOK_R GNULIB_MBSLEN GNULIB_MBSNLEN GNULIB_MBSCHR GNULIB_MBSRCHR GNULIB_MBSSTR GNULIB_MBSCASECMP GNULIB_MBSNCASECMP GNULIB_MBSPCASECMP GNULIB_MBSCASESTR GNULIB_MBSCSPN GNULIB_MBSPBRK GNULIB_MBSSPN GNULIB_MBSSEP GNULIB_MBSTOK_R GNULIB_STRERROR GNULIB_STRSIGNAL HAVE_DECL_MEMMEM HAVE_MEMPCPY HAVE_DECL_MEMRCHR HAVE_STPCPY HAVE_STPNCPY HAVE_STRCHRNUL HAVE_DECL_STRDUP HAVE_STRNDUP HAVE_DECL_STRNDUP HAVE_DECL_STRNLEN HAVE_STRPBRK HAVE_STRSEP HAVE_STRCASESTR HAVE_DECL_STRTOK_R HAVE_DECL_STRERROR HAVE_DECL_STRSIGNAL REPLACE_STRERROR REPLACE_STRSIGNAL REPLACE_MEMMEM REPLACE_STRCASESTR REPLACE_STRSTR HAVE_LONG_LONG_INT HAVE_UNSIGNED_LONG_LONG_INT HAVE_INTTYPES_H HAVE_SYS_TYPES_H INCLUDE_NEXT NEXT_STDINT_H HAVE_STDINT_H HAVE_SYS_INTTYPES_H HAVE_SYS_BITYPES_H BITSIZEOF_PTRDIFF_T BITSIZEOF_SIG_ATOMIC_T BITSIZEOF_SIZE_T BITSIZEOF_WCHAR_T BITSIZEOF_WINT_T HAVE_SIGNED_SIG_ATOMIC_T HAVE_SIGNED_WCHAR_T HAVE_SIGNED_WINT_T PTRDIFF_T_SUFFIX SIG_ATOMIC_T_SUFFIX SIZE_T_SUFFIX WCHAR_T_SUFFIX WINT_T_SUFFIX STDINT_H NEXT_STRING_H GNULIB_WCWIDTH HAVE_DECL_WCWIDTH REPLACE_WCWIDTH WCHAR_H HAVE_WCHAR_H NEXT_WCHAR_H LIBGNU_LIBDEPS LIBGNU_LTLIBDEPS GNULIB_STDINT_H PACKAGE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK AMTAR am__tar am__untar am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH am__fastdepCC_TRUE am__fastdepCC_FALSE GDB_DATADIR_PATH pythondir subdirs TARGET_OBS PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG LIBICONV LIBICONV_INCLUDE LIBICONV_LIBDIR READLINE READLINE_DEPS READLINE_CFLAGS HAVE_LIBEXPAT LIBEXPAT LTLIBEXPAT PYTHON_CFLAGS ALLOCA CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_PATCH_LEVEL TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_INCLUDE TCL_LIBRARY TCL_DEPS TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC TK_INCLUDE TK_LIBRARY TK_DEPS TK_XINCLUDES X_CFLAGS X_LDFLAGS X_LIBS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR SIM SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags nm_h LIBOBJS LTLIBOBJS gl_LIBOBJS gl_LTLIBOBJS gltests_LIBOBJS gltests_LTLIBOBJS'
10934 ac_subst_files='host_makefile_frag'
10937 @@ -882,9 +882,14 @@ Optional Packages:
10938 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
10939 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
10940 --with-separate-debug-dir=path Look for global separate debug info in this path LIBDIR/debug
10941 + --with-gdb-datadir look for global separate data files in this path
10943 + --with-pythondir install Python data files in this path
10944 + [DATADIR/gdb/python]
10945 --with-libunwind Use libunwind frame unwinding support
10946 --with-pkgversion=PKG Use PKG in the version string in place of "GDB"
10947 --with-bugurl=URL Direct users to URL to report a bug
10948 + --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
10949 --with-system-readline use installed readline library
10950 --with-expat include expat support (auto/yes/no)
10951 --with-gnu-ld assume the C compiler uses GNU ld default=no
10952 @@ -899,7 +904,6 @@ Optional Packages:
10953 --with-tcl directory containing tcl configuration (tclConfig.sh)
10954 --with-tk directory containing tk configuration (tkConfig.sh)
10955 --with-x use the X Window System
10956 - --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib
10958 Some influential environment variables:
10959 CC C compiler command
10960 @@ -7130,6 +7134,75 @@ _ACEOF
10964 +# GDB's datadir relocation
10966 +gdbdatadir=${datadir}/gdb
10969 +# Check whether --with-gdb-datadir or --without-gdb-datadir was given.
10970 +if test "${with_gdb_datadir+set}" = set; then
10971 + withval="$with_gdb_datadir"
10972 + gdbdatadir="${withval}"
10976 + test "x$prefix" = xNONE && prefix="$ac_default_prefix"
10977 + test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
10978 + ac_define_dir=`eval echo $gdbdatadir`
10979 + ac_define_dir=`eval echo $ac_define_dir`
10981 +cat >>confdefs.h <<_ACEOF
10982 +#define GDB_DATADIR "$ac_define_dir"
10987 +if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
10988 + if test "x$prefix" = xNONE; then
10989 + test_prefix=/usr/local
10991 + test_prefix=$prefix
10994 + test_prefix=$exec_prefix
10997 +case ${gdbdatadir} in
10998 + "${test_prefix}"|"${test_prefix}/"*|\
10999 + '${exec_prefix}'|'${exec_prefix}/'*)
11001 +cat >>confdefs.h <<\_ACEOF
11002 +#define GDB_DATADIR_RELOCATABLE 1
11007 +GDB_DATADIR_PATH=${gdbdatadir}
11011 +# Check whether --with-pythondir or --without-pythondir was given.
11012 +if test "${with_pythondir+set}" = set; then
11013 + withval="$with_pythondir"
11014 + pythondir="${withval}"
11019 +# If the user passed in a path, define it. Otherwise, compute it at
11020 +# runtime based on the possibly-relocatable datadir.
11021 +if test "$pythondir" = "no"; then
11022 + pythondir='$(GDB_DATADIR_PATH)/python'
11025 +cat >>confdefs.h <<_ACEOF
11026 +#define PYTHONDIR "$pythondir"
11035 subdirs="$subdirs doc testsuite"
11036 @@ -9989,6 +10062,226 @@ if test "$ac_cv_search_dlgetmodinfo" != no; then
11043 +# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
11044 +if test "${with_libiconv_prefix+set}" = set; then
11045 + withval="$with_libiconv_prefix"
11047 + for dir in `echo "$withval" | tr : ' '`; do
11048 + if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
11049 + if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; LDFLAGS="$LDFLAGS -L$dir/lib"; fi
11054 + echo "$as_me:$LINENO: checking for iconv" >&5
11055 +echo $ECHO_N "checking for iconv... $ECHO_C" >&6
11056 +if test "${am_cv_func_iconv+set}" = set; then
11057 + echo $ECHO_N "(cached) $ECHO_C" >&6
11060 + am_cv_func_iconv="no, consider installing GNU libiconv"
11061 + am_cv_lib_iconv=no
11062 + cat >conftest.$ac_ext <<_ACEOF
11065 +cat confdefs.h >>conftest.$ac_ext
11066 +cat >>conftest.$ac_ext <<_ACEOF
11067 +/* end confdefs.h. */
11068 +#include <stdlib.h>
11069 +#include <iconv.h>
11073 +iconv_t cd = iconv_open("","");
11074 + iconv(cd,NULL,NULL,NULL,NULL);
11080 +rm -f conftest.$ac_objext conftest$ac_exeext
11081 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
11082 + (eval $ac_link) 2>conftest.er1
11084 + grep -v '^ *+' conftest.er1 >conftest.err
11085 + rm -f conftest.er1
11086 + cat conftest.err >&5
11087 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11088 + (exit $ac_status); } &&
11089 + { ac_try='test -z "$ac_c_werror_flag"
11090 + || test ! -s conftest.err'
11091 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11092 + (eval $ac_try) 2>&5
11094 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11095 + (exit $ac_status); }; } &&
11096 + { ac_try='test -s conftest$ac_exeext'
11097 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11098 + (eval $ac_try) 2>&5
11100 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11101 + (exit $ac_status); }; }; then
11102 + am_cv_func_iconv=yes
11104 + echo "$as_me: failed program was:" >&5
11105 +sed 's/^/| /' conftest.$ac_ext >&5
11108 +rm -f conftest.err conftest.$ac_objext \
11109 + conftest$ac_exeext conftest.$ac_ext
11110 + if test "$am_cv_func_iconv" != yes; then
11111 + am_save_LIBS="$LIBS"
11112 + LIBS="$LIBS -liconv"
11113 + cat >conftest.$ac_ext <<_ACEOF
11116 +cat confdefs.h >>conftest.$ac_ext
11117 +cat >>conftest.$ac_ext <<_ACEOF
11118 +/* end confdefs.h. */
11119 +#include <stdlib.h>
11120 +#include <iconv.h>
11124 +iconv_t cd = iconv_open("","");
11125 + iconv(cd,NULL,NULL,NULL,NULL);
11131 +rm -f conftest.$ac_objext conftest$ac_exeext
11132 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
11133 + (eval $ac_link) 2>conftest.er1
11135 + grep -v '^ *+' conftest.er1 >conftest.err
11136 + rm -f conftest.er1
11137 + cat conftest.err >&5
11138 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11139 + (exit $ac_status); } &&
11140 + { ac_try='test -z "$ac_c_werror_flag"
11141 + || test ! -s conftest.err'
11142 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11143 + (eval $ac_try) 2>&5
11145 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11146 + (exit $ac_status); }; } &&
11147 + { ac_try='test -s conftest$ac_exeext'
11148 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11149 + (eval $ac_try) 2>&5
11151 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11152 + (exit $ac_status); }; }; then
11153 + am_cv_lib_iconv=yes
11154 + am_cv_func_iconv=yes
11156 + echo "$as_me: failed program was:" >&5
11157 +sed 's/^/| /' conftest.$ac_ext >&5
11160 +rm -f conftest.err conftest.$ac_objext \
11161 + conftest$ac_exeext conftest.$ac_ext
11162 + LIBS="$am_save_LIBS"
11166 +echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
11167 +echo "${ECHO_T}$am_cv_func_iconv" >&6
11168 + if test "$am_cv_func_iconv" = yes; then
11170 +cat >>confdefs.h <<\_ACEOF
11171 +#define HAVE_ICONV 1
11174 + echo "$as_me:$LINENO: checking for iconv declaration" >&5
11175 +echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
11176 + if test "${am_cv_proto_iconv+set}" = set; then
11177 + echo $ECHO_N "(cached) $ECHO_C" >&6
11180 + cat >conftest.$ac_ext <<_ACEOF
11183 +cat confdefs.h >>conftest.$ac_ext
11184 +cat >>conftest.$ac_ext <<_ACEOF
11185 +/* end confdefs.h. */
11187 +#include <stdlib.h>
11188 +#include <iconv.h>
11190 +#ifdef __cplusplus
11193 +#if defined(__STDC__) || defined(__cplusplus)
11194 +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
11207 +rm -f conftest.$ac_objext
11208 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
11209 + (eval $ac_compile) 2>conftest.er1
11211 + grep -v '^ *+' conftest.er1 >conftest.err
11212 + rm -f conftest.er1
11213 + cat conftest.err >&5
11214 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11215 + (exit $ac_status); } &&
11216 + { ac_try='test -z "$ac_c_werror_flag"
11217 + || test ! -s conftest.err'
11218 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11219 + (eval $ac_try) 2>&5
11221 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11222 + (exit $ac_status); }; } &&
11223 + { ac_try='test -s conftest.$ac_objext'
11224 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11225 + (eval $ac_try) 2>&5
11227 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11228 + (exit $ac_status); }; }; then
11229 + am_cv_proto_iconv_arg1=""
11231 + echo "$as_me: failed program was:" >&5
11232 +sed 's/^/| /' conftest.$ac_ext >&5
11234 +am_cv_proto_iconv_arg1="const"
11236 +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
11237 + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
11240 + am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
11241 + echo "$as_me:$LINENO: result: ${ac_t:-
11242 + }$am_cv_proto_iconv" >&5
11243 +echo "${ECHO_T}${ac_t:-
11244 + }$am_cv_proto_iconv" >&6
11246 +cat >>confdefs.h <<_ACEOF
11247 +#define ICONV_CONST $am_cv_proto_iconv_arg1
11252 + if test "$am_cv_lib_iconv" = yes; then
11253 + LIBICONV="-liconv"
11260 # On alpha-osf, it appears that libtermcap and libcurses are not compatible.
11261 # There is a very specific comment in /usr/include/curses.h explaining that
11262 # termcap routines built into libcurses must not be used.
11263 @@ -11418,6 +11711,8 @@ _ACEOF
11264 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
11265 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
11266 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
11267 + CONFIG_INSTALL="$CONFIG_INSTALL install-python"
11268 + CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python"
11269 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
11271 # Flags needed to compile Python code (taken from python-config --cflags).
11272 @@ -15445,10 +15740,11 @@ fi
11277 for ac_func in canonicalize_file_name realpath getrusage getuid \
11278 getgid poll pread64 sbrk setpgid setpgrp setsid \
11279 sigaction sigprocmask sigsetmask socketpair syscall \
11280 - ttrace wborder setlocale
11281 + ttrace wborder setlocale iconvlist
11283 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
11284 echo "$as_me:$LINENO: checking for $ac_func" >&5
11285 @@ -15550,6 +15846,70 @@ fi
11289 + echo "$as_me:$LINENO: checking for nl_langinfo and CODESET" >&5
11290 +echo $ECHO_N "checking for nl_langinfo and CODESET... $ECHO_C" >&6
11291 +if test "${am_cv_langinfo_codeset+set}" = set; then
11292 + echo $ECHO_N "(cached) $ECHO_C" >&6
11294 + cat >conftest.$ac_ext <<_ACEOF
11297 +cat confdefs.h >>conftest.$ac_ext
11298 +cat >>conftest.$ac_ext <<_ACEOF
11299 +/* end confdefs.h. */
11300 +#include <langinfo.h>
11304 +char* cs = nl_langinfo(CODESET);
11309 +rm -f conftest.$ac_objext conftest$ac_exeext
11310 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
11311 + (eval $ac_link) 2>conftest.er1
11313 + grep -v '^ *+' conftest.er1 >conftest.err
11314 + rm -f conftest.er1
11315 + cat conftest.err >&5
11316 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11317 + (exit $ac_status); } &&
11318 + { ac_try='test -z "$ac_c_werror_flag"
11319 + || test ! -s conftest.err'
11320 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11321 + (eval $ac_try) 2>&5
11323 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11324 + (exit $ac_status); }; } &&
11325 + { ac_try='test -s conftest$ac_exeext'
11326 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11327 + (eval $ac_try) 2>&5
11329 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
11330 + (exit $ac_status); }; }; then
11331 + am_cv_langinfo_codeset=yes
11333 + echo "$as_me: failed program was:" >&5
11334 +sed 's/^/| /' conftest.$ac_ext >&5
11336 +am_cv_langinfo_codeset=no
11338 +rm -f conftest.err conftest.$ac_objext \
11339 + conftest$ac_exeext conftest.$ac_ext
11342 +echo "$as_me:$LINENO: result: $am_cv_langinfo_codeset" >&5
11343 +echo "${ECHO_T}$am_cv_langinfo_codeset" >&6
11344 + if test $am_cv_langinfo_codeset = yes; then
11346 +cat >>confdefs.h <<\_ACEOF
11347 +#define HAVE_LANGINFO_CODESET 1
11353 # Check the return and argument types of ptrace. No canned test for
11354 # this, so roll our own.
11355 gdb_ptrace_headers='
11356 @@ -20776,230 +21136,11 @@ done
11361 cat >>confdefs.h <<\_ACEOF
11362 -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
11363 +#define GDB_DEFAULT_HOST_CHARSET "UTF-8"
11370 -# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
11371 -if test "${with_libiconv_prefix+set}" = set; then
11372 - withval="$with_libiconv_prefix"
11374 - for dir in `echo "$withval" | tr : ' '`; do
11375 - if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
11376 - if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
11381 - echo "$as_me:$LINENO: checking for iconv" >&5
11382 -echo $ECHO_N "checking for iconv... $ECHO_C" >&6
11383 -if test "${am_cv_func_iconv+set}" = set; then
11384 - echo $ECHO_N "(cached) $ECHO_C" >&6
11387 - am_cv_func_iconv="no, consider installing GNU libiconv"
11388 - am_cv_lib_iconv=no
11389 - cat >conftest.$ac_ext <<_ACEOF
11392 -cat confdefs.h >>conftest.$ac_ext
11393 -cat >>conftest.$ac_ext <<_ACEOF
11394 -/* end confdefs.h. */
11395 -#include <stdlib.h>
11396 -#include <iconv.h>
11400 -iconv_t cd = iconv_open("","");
11401 - iconv(cd,NULL,NULL,NULL,NULL);
11407 -rm -f conftest.$ac_objext conftest$ac_exeext
11408 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
11409 - (eval $ac_link) 2>conftest.er1
11411 - grep -v '^ *+' conftest.er1 >conftest.err
11412 - rm -f conftest.er1
11413 - cat conftest.err >&5
11414 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11415 - (exit $ac_status); } &&
11416 - { ac_try='test -z "$ac_c_werror_flag"
11417 - || test ! -s conftest.err'
11418 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11419 - (eval $ac_try) 2>&5
11421 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11422 - (exit $ac_status); }; } &&
11423 - { ac_try='test -s conftest$ac_exeext'
11424 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11425 - (eval $ac_try) 2>&5
11427 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11428 - (exit $ac_status); }; }; then
11429 - am_cv_func_iconv=yes
11431 - echo "$as_me: failed program was:" >&5
11432 -sed 's/^/| /' conftest.$ac_ext >&5
11435 -rm -f conftest.err conftest.$ac_objext \
11436 - conftest$ac_exeext conftest.$ac_ext
11437 - if test "$am_cv_func_iconv" != yes; then
11438 - am_save_LIBS="$LIBS"
11439 - LIBS="$LIBS -liconv"
11440 - cat >conftest.$ac_ext <<_ACEOF
11443 -cat confdefs.h >>conftest.$ac_ext
11444 -cat >>conftest.$ac_ext <<_ACEOF
11445 -/* end confdefs.h. */
11446 -#include <stdlib.h>
11447 -#include <iconv.h>
11451 -iconv_t cd = iconv_open("","");
11452 - iconv(cd,NULL,NULL,NULL,NULL);
11458 -rm -f conftest.$ac_objext conftest$ac_exeext
11459 -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
11460 - (eval $ac_link) 2>conftest.er1
11462 - grep -v '^ *+' conftest.er1 >conftest.err
11463 - rm -f conftest.er1
11464 - cat conftest.err >&5
11465 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11466 - (exit $ac_status); } &&
11467 - { ac_try='test -z "$ac_c_werror_flag"
11468 - || test ! -s conftest.err'
11469 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11470 - (eval $ac_try) 2>&5
11472 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11473 - (exit $ac_status); }; } &&
11474 - { ac_try='test -s conftest$ac_exeext'
11475 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11476 - (eval $ac_try) 2>&5
11478 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11479 - (exit $ac_status); }; }; then
11480 - am_cv_lib_iconv=yes
11481 - am_cv_func_iconv=yes
11483 - echo "$as_me: failed program was:" >&5
11484 -sed 's/^/| /' conftest.$ac_ext >&5
11487 -rm -f conftest.err conftest.$ac_objext \
11488 - conftest$ac_exeext conftest.$ac_ext
11489 - LIBS="$am_save_LIBS"
11493 -echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
11494 -echo "${ECHO_T}$am_cv_func_iconv" >&6
11495 - if test "$am_cv_func_iconv" = yes; then
11497 -cat >>confdefs.h <<\_ACEOF
11498 -#define HAVE_ICONV 1
11501 - echo "$as_me:$LINENO: checking for iconv declaration" >&5
11502 -echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
11503 - if test "${am_cv_proto_iconv+set}" = set; then
11504 - echo $ECHO_N "(cached) $ECHO_C" >&6
11507 - cat >conftest.$ac_ext <<_ACEOF
11510 -cat confdefs.h >>conftest.$ac_ext
11511 -cat >>conftest.$ac_ext <<_ACEOF
11512 -/* end confdefs.h. */
11514 -#include <stdlib.h>
11515 -#include <iconv.h>
11517 -#ifdef __cplusplus
11520 -#if defined(__STDC__) || defined(__cplusplus)
11521 -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
11534 -rm -f conftest.$ac_objext
11535 -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
11536 - (eval $ac_compile) 2>conftest.er1
11538 - grep -v '^ *+' conftest.er1 >conftest.err
11539 - rm -f conftest.er1
11540 - cat conftest.err >&5
11541 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11542 - (exit $ac_status); } &&
11543 - { ac_try='test -z "$ac_c_werror_flag"
11544 - || test ! -s conftest.err'
11545 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11546 - (eval $ac_try) 2>&5
11548 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11549 - (exit $ac_status); }; } &&
11550 - { ac_try='test -s conftest.$ac_objext'
11551 - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
11552 - (eval $ac_try) 2>&5
11554 - echo "$as_me:$LINENO: \$? = $ac_status" >&5
11555 - (exit $ac_status); }; }; then
11556 - am_cv_proto_iconv_arg1=""
11558 - echo "$as_me: failed program was:" >&5
11559 -sed 's/^/| /' conftest.$ac_ext >&5
11561 -am_cv_proto_iconv_arg1="const"
11563 -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
11564 - am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
11567 - am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
11568 - echo "$as_me:$LINENO: result: ${ac_t:-
11569 - }$am_cv_proto_iconv" >&5
11570 -echo "${ECHO_T}${ac_t:-
11571 - }$am_cv_proto_iconv" >&6
11573 -cat >>confdefs.h <<_ACEOF
11574 -#define ICONV_CONST $am_cv_proto_iconv_arg1
11579 - if test "$am_cv_lib_iconv" = yes; then
11580 - LIBICONV="-liconv"
11585 ac_config_files="$ac_config_files Makefile .gdbinit:gdbinit.in gnulib/Makefile"
11586 ac_config_commands="$ac_config_commands default"
11587 cat >confcache <<\_ACEOF
11588 @@ -21865,6 +22006,8 @@ s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t
11589 s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t
11590 s,@am__fastdepCC_TRUE@,$am__fastdepCC_TRUE,;t t
11591 s,@am__fastdepCC_FALSE@,$am__fastdepCC_FALSE,;t t
11592 +s,@GDB_DATADIR_PATH@,$GDB_DATADIR_PATH,;t t
11593 +s,@pythondir@,$pythondir,;t t
11594 s,@subdirs@,$subdirs,;t t
11595 s,@TARGET_OBS@,$TARGET_OBS,;t t
11596 s,@PKGVERSION@,$PKGVERSION,;t t
11597 @@ -21880,6 +22023,9 @@ s,@WINDRES@,$WINDRES,;t t
11598 s,@ac_ct_WINDRES@,$ac_ct_WINDRES,;t t
11600 s,@ac_ct_MIG@,$ac_ct_MIG,;t t
11601 +s,@LIBICONV@,$LIBICONV,;t t
11602 +s,@LIBICONV_INCLUDE@,$LIBICONV_INCLUDE,;t t
11603 +s,@LIBICONV_LIBDIR@,$LIBICONV_LIBDIR,;t t
11604 s,@READLINE@,$READLINE,;t t
11605 s,@READLINE_DEPS@,$READLINE_DEPS,;t t
11606 s,@READLINE_CFLAGS@,$READLINE_CFLAGS,;t t
11607 @@ -21944,7 +22090,6 @@ s,@CONFIG_UNINSTALL@,$CONFIG_UNINSTALL,;t t
11608 s,@target_subdir@,$target_subdir,;t t
11609 s,@frags@,$frags,;t t
11610 s,@nm_h@,$nm_h,;t t
11611 -s,@LIBICONV@,$LIBICONV,;t t
11612 s,@LIBOBJS@,$LIBOBJS,;t t
11613 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
11614 s,@gl_LIBOBJS@,$gl_LIBOBJS,;t t
11615 diff --git a/gdb/configure.ac b/gdb/configure.ac
11616 index 3f81ff2..ff76053 100644
11617 --- a/gdb/configure.ac
11618 +++ b/gdb/configure.ac
11620 dnl Autoconf configure script for GDB, the GNU debugger.
11621 dnl Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
11622 -dnl 2005, 2006, 2007, 2008
11623 +dnl 2005, 2006, 2007, 2008, 2009
11624 dnl Free Software Foundation, Inc.
11626 dnl This file is part of GDB.
11627 @@ -118,6 +118,51 @@ case ${debugdir} in
11631 +# GDB's datadir relocation
11633 +gdbdatadir=${datadir}/gdb
11635 +AC_ARG_WITH([gdb-datadir],
11636 + [AS_HELP_STRING([--with-gdb-datadir],
11637 + [look for global separate data files in this path [DATADIR/gdb]])], [gdbdatadir="${withval}"])
11639 +AC_DEFINE_DIR(GDB_DATADIR, gdbdatadir,
11640 + [Global directory for GDB data files. ])
11642 +if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
11643 + if test "x$prefix" = xNONE; then
11644 + test_prefix=/usr/local
11646 + test_prefix=$prefix
11649 + test_prefix=$exec_prefix
11652 +case ${gdbdatadir} in
11653 + "${test_prefix}"|"${test_prefix}/"*|\
11654 + '${exec_prefix}'|'${exec_prefix}/'*)
11655 + AC_DEFINE(GDB_DATADIR_RELOCATABLE, 1, [Define if GDB datadir should be relocated when GDB is moved.])
11658 +GDB_DATADIR_PATH=${gdbdatadir}
11659 +AC_SUBST(GDB_DATADIR_PATH)
11661 +AC_ARG_WITH([pythondir],
11662 + [AS_HELP_STRING([--with-pythondir],
11663 + [install Python data files in this path [DATADIR/gdb/python]])], [pythondir="${withval}"], [pythondir=no])
11665 +# If the user passed in a path, define it. Otherwise, compute it at
11666 +# runtime based on the possibly-relocatable datadir.
11667 +if test "$pythondir" = "no"; then
11668 + pythondir='$(GDB_DATADIR_PATH)/python'
11670 + AC_DEFINE_UNQUOTED(PYTHONDIR, "$pythondir",
11671 + [Define to install path for Python sources])
11673 +AC_SUBST(pythondir)
11676 AC_CONFIG_SUBDIRS(doc testsuite)
11678 # Check whether to support alternative target configurations
11679 @@ -430,6 +475,8 @@ AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
11680 # On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
11681 AC_SEARCH_LIBS(dlgetmodinfo, [dl xpdl])
11685 # On alpha-osf, it appears that libtermcap and libcurses are not compatible.
11686 # There is a very specific comment in /usr/include/curses.h explaining that
11687 # termcap routines built into libcurses must not be used.
11688 @@ -649,6 +696,8 @@ if test "${have_libpython}" = yes; then
11689 CONFIG_OBS="$CONFIG_OBS \$(SUBDIR_PYTHON_OBS)"
11690 CONFIG_DEPS="$CONFIG_DEPS \$(SUBDIR_PYTHON_DEPS)"
11691 CONFIG_SRCS="$CONFIG_SRCS \$(SUBDIR_PYTHON_SRCS)"
11692 + CONFIG_INSTALL="$CONFIG_INSTALL install-python"
11693 + CONFIG_UNINSTALL="$CONFIG_UNINSTALL uninstall-python"
11694 ENABLE_CFLAGS="$ENABLE_CFLAGS \$(SUBDIR_PYTHON_CFLAGS)"
11696 # Flags needed to compile Python code (taken from python-config --cflags).
11697 @@ -776,7 +825,8 @@ AC_FUNC_VFORK
11698 AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid \
11699 getgid poll pread64 sbrk setpgid setpgrp setsid \
11700 sigaction sigprocmask sigsetmask socketpair syscall \
11701 - ttrace wborder setlocale])
11702 + ttrace wborder setlocale iconvlist])
11703 +AM_LANGINFO_CODESET
11705 # Check the return and argument types of ptrace. No canned test for
11706 # this, so roll our own.
11707 @@ -1930,17 +1980,10 @@ dnl Check for exe extension set on certain hosts (e.g. Win32)
11710 dnl Detect the character set used by this host.
11712 -dnl At the moment, we just assume it's ISO-8859-1 (which is a
11713 -dnl superset of ASCII containing the characters needed for French,
11714 -dnl German, Spanish, Italian, and possibly others), but if were
11715 -dnl *were* to support any host character sets other than ISO-8859-1,
11716 -dnl here's where we'd detect it.
11717 -AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "ISO-8859-1",
11718 +dnl At the moment, we just assume it's UTF-8.
11719 +AC_DEFINE(GDB_DEFAULT_HOST_CHARSET, "UTF-8",
11720 [Define to be a string naming the default host character set.])
11724 AC_OUTPUT(Makefile .gdbinit:gdbinit.in gnulib/Makefile,
11726 dnl Autoconf doesn't provide a mechanism for modifying definitions
11727 diff --git a/gdb/configure.tgt b/gdb/configure.tgt
11728 index 65c3e25..f0cca7d 100644
11729 --- a/gdb/configure.tgt
11730 +++ b/gdb/configure.tgt
11731 @@ -36,7 +36,7 @@ alpha*-*-osf*)
11733 # Target: Little-endian Alpha running Linux
11734 gdb_target_obs="alpha-tdep.o alpha-mdebug-tdep.o alpha-linux-tdep.o \
11735 - solib.o solib-svr4.o"
11736 + solib.o solib-svr4.o linux-tdep.o"
11738 alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
11739 # Target: FreeBSD/alpha
11740 @@ -63,7 +63,7 @@ alpha*-*-*)
11741 am33_2.0*-*-linux*)
11742 # Target: Matsushita mn10300 (AM33) running Linux
11743 gdb_target_obs="mn10300-tdep.o mn10300-linux-tdep.o corelow.o \
11744 - solib.o solib-svr4.o"
11745 + solib.o solib-svr4.o linux-tdep.o"
11748 arm*-wince-pe | arm*-*-mingw32ce*)
11749 @@ -128,7 +128,7 @@ hppa*-*-hpux*)
11751 # Target: HP PA-RISC running Linux
11752 gdb_target_obs="hppa-tdep.o hppa-linux-tdep.o glibc-tdep.o \
11753 - solib.o solib-svr4.o symfile-mem.o"
11754 + solib.o solib-svr4.o symfile-mem.o linux-tdep.o"
11757 # Target: NetBSD/hppa
11758 @@ -218,7 +218,7 @@ i[34567]86-*-*)
11760 # Target: Intel IA-64 running GNU/Linux
11761 gdb_target_obs="ia64-tdep.o ia64-linux-tdep.o \
11762 - solib.o solib-svr4.o symfile-mem.o"
11763 + solib.o solib-svr4.o symfile-mem.o linux-tdep.o"
11764 build_gdbserver=yes
11767 @@ -242,7 +242,8 @@ m32c-*-*)
11769 # Target: Renesas M32R running GNU/Linux
11770 gdb_target_obs="m32r-tdep.o m32r-linux-tdep.o remote-m32r-sdi.o \
11771 - glibc-tdep.o solib.o solib-svr4.o symfile-mem.o"
11772 + glibc-tdep.o solib.o solib-svr4.o symfile-mem.o \
11774 gdb_sim=../sim/m32r/libsim.a
11775 build_gdbserver=yes
11777 @@ -267,7 +268,7 @@ fido-*-elf*)
11779 # Target: Motorola m68k with a.out and ELF
11780 gdb_target_obs="m68k-tdep.o m68klinux-tdep.o solib.o solib-svr4.o \
11781 - glibc-tdep.o symfile-mem.o"
11782 + glibc-tdep.o symfile-mem.o linux-tdep.o"
11783 build_gdbserver=yes
11785 m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
11786 @@ -303,7 +304,8 @@ mips*-sgi-irix6*)
11788 # Target: Linux/MIPS
11789 gdb_target_obs="mips-tdep.o mips-linux-tdep.o glibc-tdep.o \
11790 - corelow.o solib.o solib-svr4.o symfile-mem.o"
11791 + corelow.o solib.o solib-svr4.o symfile-mem.o \
11793 gdb_sim=../sim/mips/libsim.a
11794 build_gdbserver=yes
11796 @@ -354,7 +356,8 @@ powerpc-*-aix* | rs6000-*-*)
11797 powerpc-*-linux* | powerpc64-*-linux*)
11798 # Target: PowerPC running Linux
11799 gdb_target_obs="rs6000-tdep.o ppc-linux-tdep.o ppc-sysv-tdep.o \
11800 - solib.o solib-svr4.o corelow.o symfile-mem.o"
11801 + solib.o solib-svr4.o corelow.o symfile-mem.o \
11803 gdb_sim=../sim/ppc/libsim.a
11804 build_gdbserver=yes
11806 @@ -381,7 +384,8 @@ score-*-*)
11808 # Target: GNU/Linux Super-H
11809 gdb_target_obs="sh-tdep.o sh64-tdep.o sh-linux-tdep.o monitor.o \
11810 - dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o"
11811 + dsrec.o solib.o solib-svr4.o symfile-mem.o glibc-tdep.o \
11813 gdb_sim=../sim/sh/libsim.a
11814 build_gdbserver=yes
11816 @@ -409,13 +413,14 @@ sh*)
11818 # Target: GNU/Linux SPARC
11819 gdb_target_obs="sparc-tdep.o sparc-sol2-tdep.o sol2-tdep.o \
11820 - sparc-linux-tdep.o solib.o solib-svr4.o symfile-mem.o"
11821 + sparc-linux-tdep.o solib.o solib-svr4.o symfile-mem.o \
11825 # Target: GNU/Linux UltraSPARC
11826 gdb_target_obs="sparc64-tdep.o sparc64-sol2-tdep.o sol2-tdep.o \
11827 sparc64-linux-tdep.o sparc-tdep.o sparc-sol2-tdep.o \
11828 - sparc-linux-tdep.o solib.o solib-svr4.o"
11829 + sparc-linux-tdep.o solib.o solib-svr4.o linux-tdep.o"
11830 build_gdbserver=yes
11832 sparc*-*-freebsd* | sparc*-*-kfreebsd*-gnu)
11833 @@ -542,7 +547,8 @@ x86_64-*-openbsd*)
11834 xtensa*-*-linux*) gdb_target=linux
11835 # Target: GNU/Linux Xtensa
11836 gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \
11837 - solib.o solib-svr4.o corelow.o symfile-mem.o"
11838 + solib.o solib-svr4.o corelow.o symfile-mem.o \
11840 build_gdbserver=yes
11843 diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
11844 index 5f5ee3a..a8f8f30 100644
11845 --- a/gdb/cp-name-parser.y
11846 +++ b/gdb/cp-name-parser.y
11848 /* YACC parser for C++ names, for GDB.
11850 - Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009
11851 - Free Software Foundation, Inc.
11852 + Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
11854 Parts of the lexer are based on c-exp.y from GDB.
11856 @@ -501,7 +500,7 @@ operator : OPERATOR NEW
11858 { $$ = make_operator ("->", 2); }
11860 - { $$ = make_operator ("()", 0); }
11861 + { $$ = make_operator ("()", 2); }
11863 { $$ = make_operator ("[]", 2); }
11865 diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
11866 index c6c5617..eace9c4 100644
11867 --- a/gdb/cp-namespace.c
11868 +++ b/gdb/cp-namespace.c
11869 @@ -30,26 +30,13 @@
11870 #include "dictionary.h"
11871 #include "command.h"
11873 +#include "buildsym.h"
11875 /* List of using directives that are active in the current file. */
11877 -static struct using_direct *using_list;
11879 -static struct using_direct *cp_add_using (const char *name,
11880 - unsigned int inner_len,
11881 - unsigned int outer_len,
11882 - struct using_direct *next);
11884 static struct using_direct *cp_copy_usings (struct using_direct *using,
11885 struct obstack *obstack);
11887 -static struct symbol *lookup_namespace_scope (const char *name,
11888 - const char *linkage_name,
11889 - const struct block *block,
11890 - const domain_enum domain,
11891 - const char *scope,
11894 static struct symbol *lookup_symbol_file (const char *name,
11895 const char *linkage_name,
11896 const struct block *block,
11897 @@ -78,31 +65,6 @@ static struct symbol *lookup_possible_namespace_symbol (const char *name);
11899 static void maintenance_cplus_namespace (char *args, int from_tty);
11901 -/* Set up support for dealing with C++ namespace info in the current
11904 -void cp_initialize_namespace ()
11906 - using_list = NULL;
11909 -/* Add all the using directives we've gathered to the current symtab.
11910 - STATIC_BLOCK should be the symtab's static block; OBSTACK is used
11911 - for allocation. */
11914 -cp_finalize_namespace (struct block *static_block,
11915 - struct obstack *obstack)
11917 - if (using_list != NULL)
11919 - block_set_using (static_block,
11920 - cp_copy_usings (using_list, obstack),
11922 - using_list = NULL;
11926 /* Check to see if SYMBOL refers to an object contained within an
11927 anonymous namespace; if so, add an appropriate using directive. */
11929 @@ -136,14 +98,17 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
11930 "(anonymous namespace)",
11931 ANONYMOUS_NAMESPACE_LEN) == 0)
11933 + int outer_len = (previous_component == 0 ? 0 : previous_component - 2);
11934 + char outer[outer_len+1];
11936 + strncpy(outer, name, outer_len);
11938 + outer[outer_len] = '\0';
11939 /* We've found a component of the name that's an
11940 anonymous namespace. So add symbols in it to the
11941 namespace given by the previous component if there is
11942 one, or to the global namespace if there isn't. */
11943 - cp_add_using_directive (name,
11944 - previous_component == 0
11945 - ? 0 : previous_component - 2,
11947 + cp_add_using_directive (outer, name, "", "", 0);
11949 /* The "+ 2" is for the "::". */
11950 previous_component = next_component + 2;
11951 @@ -154,32 +119,27 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
11955 -/* Add a using directive to using_list. NAME is the start of a string
11956 - that should contain the namespaces we want to add as initial
11957 - substrings, OUTER_LENGTH is the end of the outer namespace, and
11958 - INNER_LENGTH is the end of the inner namespace. If the using
11959 - directive in question has already been added, don't add it
11961 +/* Add a using directive to using_list. If the using directive in question
11962 + has already been added, don't add it twice. */
11965 -cp_add_using_directive (const char *name, unsigned int outer_length,
11966 - unsigned int inner_length)
11967 +cp_add_using_directive (const char *outer, const char *inner, const char* alias,
11968 + const char *declaration, const int line_number)
11970 struct using_direct *current;
11971 struct using_direct *new;
11973 /* Has it already been added? */
11975 - for (current = using_list; current != NULL; current = current->next)
11976 + for (current = using_directives; current != NULL; current = current->next)
11978 - if ((strncmp (current->inner, name, inner_length) == 0)
11979 - && (strlen (current->inner) == inner_length)
11980 - && (strlen (current->outer) == outer_length))
11981 + if (strcmp (current->inner, inner) == 0
11982 + && strcmp (current->outer, outer) == 0)
11986 - using_list = cp_add_using (name, inner_length, outer_length,
11988 + using_directives = cp_add_using (outer, inner, alias, declaration,
11989 + line_number,using_directives);
11992 /* Record the namespace that the function defined by SYMBOL was
11993 @@ -230,26 +190,31 @@ cp_is_anonymous (const char *namespace)
11997 -/* Create a new struct using direct whose inner namespace is the
11998 - initial substring of NAME of leng INNER_LEN and whose outer
11999 - namespace is the initial substring of NAME of length OUTER_LENGTH.
12000 +/* Create a new struct using direct whose inner namespace is INNER
12001 + and whose outer namespace is OUTER. ALIAS is the name of the imported
12002 + namespace in the current scope. If ALIAS is an empty string then the
12003 + namespace is known by its original name.
12004 Set its next member in the linked list to NEXT; allocate all memory
12005 using xmalloc. It copies the strings, so NAME can be a temporary
12008 -static struct using_direct *
12009 -cp_add_using (const char *name,
12010 - unsigned int inner_len,
12011 - unsigned int outer_len,
12012 +struct using_direct *
12013 +cp_add_using (const char *outer,
12014 + const char *inner,
12015 + const char *alias,
12016 + const char *declaration,
12017 + const int line_number,
12018 struct using_direct *next)
12020 struct using_direct *retval;
12022 - gdb_assert (outer_len < inner_len);
12024 retval = xmalloc (sizeof (struct using_direct));
12025 - retval->inner = savestring (name, inner_len);
12026 - retval->outer = savestring (name, outer_len);
12027 + retval->inner = savestring (inner, strlen(inner));
12028 + retval->outer = savestring (outer, strlen(outer));
12029 + retval->alias = savestring (alias, strlen(alias));
12030 + retval->declaration = savestring (declaration, strlen(declaration));
12031 + retval->line_number = line_number;
12033 retval->next = next;
12036 @@ -274,11 +239,17 @@ cp_copy_usings (struct using_direct *using,
12037 retval->inner = obsavestring (using->inner, strlen (using->inner),
12039 retval->outer = obsavestring (using->outer, strlen (using->outer),
12042 + retval->alias = obsavestring (using->alias, strlen (using->alias),
12044 + retval->declaration = obsavestring (using->declaration, strlen (using->declaration),
12046 retval->next = cp_copy_usings (using->next, obstack);
12048 xfree (using->inner);
12049 xfree (using->outer);
12050 + xfree (using->alias);
12051 + xfree (using->declaration);
12055 @@ -299,8 +270,14 @@ cp_lookup_symbol_nonlocal (const char *name,
12056 const struct block *block,
12057 const domain_enum domain)
12059 - return lookup_namespace_scope (name, linkage_name, block, domain,
12060 - block_scope (block), 0);
12062 + struct symbol* sym = lookup_namespace_scope(name, linkage_name, block,
12063 + domain, block_scope(block), 0);
12068 + return lookup_symbol_file(name, linkage_name, block, domain, 0);
12071 /* Lookup NAME at namespace scope (or, in C terms, in static and
12072 @@ -318,7 +295,7 @@ cp_lookup_symbol_nonlocal (const char *name,
12073 "A::x", and if that call fails, then the first call looks for
12076 -static struct symbol *
12078 lookup_namespace_scope (const char *name,
12079 const char *linkage_name,
12080 const struct block *block,
12081 @@ -354,10 +331,43 @@ lookup_namespace_scope (const char *name,
12082 namespace = alloca (scope_len + 1);
12083 strncpy (namespace, scope, scope_len);
12084 namespace[scope_len] = '\0';
12085 - return cp_lookup_symbol_namespace (namespace, name, linkage_name,
12086 + return cp_lookup_symbol_namespace_incremental (namespace, name, linkage_name,
12090 +/* Searches the for the given NAME in the given NAMESPACE, using import
12091 + statements implied by the given BLOCK, *and its' parents*. */
12093 +cp_lookup_symbol_namespace_incremental (const char *namespace,
12094 + const char *name,
12095 + const char *linkage_name,
12096 + const struct block *block,
12097 + const domain_enum domain)
12099 + struct symbol *sym;
12100 + const struct block *global_block = block_global_block (block);
12102 + /* Check if either no block is specified or it's a global block. */
12104 + if (global_block == NULL)
12107 + while (block != global_block)
12109 + sym = cp_lookup_symbol_namespace (namespace, name, linkage_name, block, domain);
12114 + block = BLOCK_SUPERBLOCK (block);
12117 + /* We've reached the global block without finding a result. */
12123 /* Look up NAME in the C++ namespace NAMESPACE, applying the using
12124 directives that are active in BLOCK. Other arguments are as in
12125 cp_lookup_symbol_nonlocal. */
12126 @@ -370,7 +380,7 @@ cp_lookup_symbol_namespace (const char *namespace,
12127 const domain_enum domain)
12129 const struct using_direct *current;
12130 - struct symbol *sym;
12131 + struct symbol *sym = NULL;
12133 /* First, go through the using directives. If any of them add new
12134 names to the namespace we're searching in, see if we can find a
12135 @@ -380,15 +390,50 @@ cp_lookup_symbol_namespace (const char *namespace,
12137 current = current->next)
12139 - if (strcmp (namespace, current->outer) == 0)
12141 + int current_line = find_pc_line (get_frame_pc (get_current_frame ()), 0).line;
12143 + if (strcmp (namespace, current->outer) == 0 && current->line_number < current_line)
12145 - sym = cp_lookup_symbol_namespace (current->inner,
12152 + /* If there is an import of a single declaration, compare the imported
12153 + declaration with the sought out name. If there is a match pass
12154 + current->inner as NAMESPACE to direct the search towards the
12155 + imported namespace. */
12156 + if (strcmp ("", current->declaration) != 0)
12158 + if(strcmp (name, current->declaration) == 0){
12159 + sym = cp_lookup_symbol_namespace (current->inner,
12167 + else if(strcmp (name, current->alias) == 0)
12168 + /* If the import is creating an alias and the alias matches the
12169 + sought name. Pass current->inner as the NAME to direct the
12170 + search towards the aliased namespace */
12172 + sym = cp_lookup_symbol_namespace (namespace,
12177 + }else if(strcmp ("", current->alias) == 0){
12178 + /* If this import statement creates no alias, pass current->inner as
12179 + NAMESPACE to direct the search towards the imported namespace. */
12180 + sym = cp_lookup_symbol_namespace (current->inner,
12187 + if (sym != NULL){
12193 @@ -398,8 +443,10 @@ cp_lookup_symbol_namespace (const char *namespace,
12195 if (namespace[0] == '\0')
12197 - return lookup_symbol_file (name, linkage_name, block,
12199 + sym = lookup_symbol_file (name, linkage_name,
12201 + cp_is_anonymous (namespace));
12206 diff --git a/gdb/cp-support.c b/gdb/cp-support.c
12207 index bf42636..9f04c86 100644
12208 --- a/gdb/cp-support.c
12209 +++ b/gdb/cp-support.c
12210 @@ -175,7 +175,8 @@ mangled_name_to_comp (const char *mangled_name, int options,
12214 -/* Return the name of the class containing method PHYSNAME. */
12215 +/* Return the name of the class or namespace containing
12216 + function, method, or variable PHYSNAME. */
12219 cp_class_name_from_physname (const char *physname)
12220 diff --git a/gdb/cp-support.h b/gdb/cp-support.h
12221 index 837ca6c..23f8d5b 100644
12222 --- a/gdb/cp-support.h
12223 +++ b/gdb/cp-support.h
12224 @@ -38,14 +38,28 @@ struct demangle_component;
12226 /* This struct is designed to store data from using directives. It
12227 says that names from namespace INNER should be visible within
12228 - namespace OUTER. OUTER should always be a strict initial substring
12229 - of INNER. These form a linked list; NEXT is the next element of
12231 + namespace OUTER These form a linked list; NEXT is the next element of
12232 + the list. ALIAS is set to a non empty string if the imported namespace
12233 + has been aliased.Eg:
12234 + namespace C=A::B;
12236 + DECLARATION is the name of the imported declaration, if this import
12237 + statement represents one. Eg:
12239 + Where x is variable in namespace A. declaration is set to x.
12242 struct using_direct
12249 + char *declaration;
12253 struct using_direct *next;
12256 @@ -54,6 +68,7 @@ struct using_direct
12258 extern char *cp_canonicalize_string (const char *string);
12261 extern char *cp_class_name_from_physname (const char *physname);
12263 extern char *method_name_from_physname (const char *physname);
12264 @@ -76,9 +91,18 @@ extern struct type *cp_lookup_rtti_type (const char *name,
12266 extern int cp_is_anonymous (const char *namespace);
12268 -extern void cp_add_using_directive (const char *name,
12269 - unsigned int outer_length,
12270 - unsigned int inner_length);
12271 +extern void cp_add_using_directive (const char *outer,
12272 + const char *inner,
12273 + const char *alias,
12274 + const char *declaration,
12275 + const int line_number);
12277 +extern struct using_direct *cp_add_using (const char *outer,
12278 + const char *inner,
12279 + const char *alias,
12280 + const char *declaration,
12281 + const int line_number,
12282 + struct using_direct *next);
12284 extern void cp_initialize_namespace (void);
12286 @@ -98,6 +122,19 @@ extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
12287 const struct block *block,
12288 const domain_enum domain);
12290 +extern struct symbol *lookup_namespace_scope (const char *name,
12291 + const char *linkage_name,
12292 + const struct block *block,
12293 + const domain_enum domain,
12294 + const char *scope,
12297 +extern struct symbol *cp_lookup_symbol_namespace_incremental (const char *namespace,
12298 + const char *name,
12299 + const char *linkage_name,
12300 + const struct block *block,
12301 + const domain_enum domain);
12303 extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
12305 const char *linkage_name,
12306 diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
12307 index 8b7d868..dcd32cb 100644
12308 --- a/gdb/cp-valprint.c
12309 +++ b/gdb/cp-valprint.c
12310 @@ -461,6 +461,7 @@ cp_print_static_field (struct type *type,
12311 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
12313 CORE_ADDR *first_dont_print;
12318 @@ -470,7 +471,7 @@ cp_print_static_field (struct type *type,
12322 - if (VALUE_ADDRESS (val) == first_dont_print[i])
12323 + if (value_address (val) == first_dont_print[i])
12325 fputs_filtered ("<same as static member of an already"
12327 @@ -479,12 +480,13 @@ cp_print_static_field (struct type *type,
12331 - obstack_grow (&dont_print_statmem_obstack, (char *) &VALUE_ADDRESS (val),
12332 + addr = value_address (val);
12333 + obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
12334 sizeof (CORE_ADDR));
12336 CHECK_TYPEDEF (type);
12337 cp_print_value_fields (type, type, value_contents_all (val),
12338 - value_embedded_offset (val), VALUE_ADDRESS (val),
12339 + value_embedded_offset (val), value_address (val),
12340 stream, recurse, options, NULL, 1);
12343 @@ -492,7 +494,7 @@ cp_print_static_field (struct type *type,
12345 opts.deref_ref = 0;
12346 val_print (type, value_contents_all (val),
12347 - value_embedded_offset (val), VALUE_ADDRESS (val),
12348 + value_embedded_offset (val), value_address (val),
12349 stream, recurse, &opts, current_language);
12352 diff --git a/gdb/dbxread.c b/gdb/dbxread.c
12353 index 115bdef..7f756af 100644
12354 --- a/gdb/dbxread.c
12355 +++ b/gdb/dbxread.c
12357 /* Read dbx symbol tables and convert to internal format, for GDB.
12358 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
12359 - 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008.
12360 + 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009.
12361 Free Software Foundation, Inc.
12363 This file is part of GDB.
12364 @@ -1188,6 +1188,8 @@ read_dbx_symtab (struct objfile *objfile)
12365 struct internal_nlist nlist;
12366 CORE_ADDR text_addr;
12373 @@ -1681,6 +1683,28 @@ pos %d"),
12375 continue; /* Not a debugging symbol. */
12378 + if (psymtab_language == language_cplus)
12380 + char *new_name, *name = alloca (p - namestring + 1);
12381 + memcpy (name, namestring, p - namestring);
12382 + name[p - namestring] = '\0';
12383 + new_name = cp_canonicalize_string (name);
12384 + if (new_name != NULL)
12386 + sym_len = strlen (new_name);
12387 + sym_name = obsavestring (new_name, sym_len,
12388 + &objfile->objfile_obstack);
12389 + xfree (new_name);
12393 + if (sym_len == 0)
12395 + sym_name = namestring;
12396 + sym_len = p - namestring;
12399 /* Main processing section for debugging symbols which
12400 the initial read through the symbol tables needs to worry
12401 about. If we reach this point, the symbol which we are
12402 @@ -1698,7 +1722,7 @@ pos %d"),
12403 namestring = gdbarch_static_transform_name (gdbarch,
12406 - add_psymbol_to_list (namestring, p - namestring,
12407 + add_psymbol_to_list (sym_name, sym_len,
12408 VAR_DOMAIN, LOC_STATIC,
12409 &objfile->static_psymbols,
12411 @@ -1710,7 +1734,7 @@ pos %d"),
12413 /* The addresses in these entries are reported to be
12414 wrong. See the code that reads 'G's for symtabs. */
12415 - add_psymbol_to_list (namestring, p - namestring,
12416 + add_psymbol_to_list (sym_name, sym_len,
12417 VAR_DOMAIN, LOC_STATIC,
12418 &objfile->global_psymbols,
12420 @@ -1728,7 +1752,7 @@ pos %d"),
12421 || (p == namestring + 1
12422 && namestring[0] != ' '))
12424 - add_psymbol_to_list (namestring, p - namestring,
12425 + add_psymbol_to_list (sym_name, sym_len,
12426 STRUCT_DOMAIN, LOC_TYPEDEF,
12427 &objfile->static_psymbols,
12429 @@ -1736,7 +1760,7 @@ pos %d"),
12432 /* Also a typedef with the same name. */
12433 - add_psymbol_to_list (namestring, p - namestring,
12434 + add_psymbol_to_list (sym_name, sym_len,
12435 VAR_DOMAIN, LOC_TYPEDEF,
12436 &objfile->static_psymbols,
12438 @@ -1749,7 +1773,7 @@ pos %d"),
12440 if (p != namestring) /* a name is there, not just :T... */
12442 - add_psymbol_to_list (namestring, p - namestring,
12443 + add_psymbol_to_list (sym_name, sym_len,
12444 VAR_DOMAIN, LOC_TYPEDEF,
12445 &objfile->static_psymbols,
12447 @@ -1829,7 +1853,7 @@ pos %d"),
12450 /* Constant, e.g. from "const" in Pascal. */
12451 - add_psymbol_to_list (namestring, p - namestring,
12452 + add_psymbol_to_list (sym_name, sym_len,
12453 VAR_DOMAIN, LOC_CONST,
12454 &objfile->static_psymbols, nlist.n_value,
12455 0, psymtab_language, objfile);
12456 @@ -1893,7 +1917,7 @@ pos %d"),
12457 pst->textlow = nlist.n_value;
12458 textlow_not_set = 0;
12460 - add_psymbol_to_list (namestring, p - namestring,
12461 + add_psymbol_to_list (sym_name, sym_len,
12462 VAR_DOMAIN, LOC_BLOCK,
12463 &objfile->static_psymbols,
12465 @@ -1961,7 +1985,7 @@ pos %d"),
12466 pst->textlow = nlist.n_value;
12467 textlow_not_set = 0;
12469 - add_psymbol_to_list (namestring, p - namestring,
12470 + add_psymbol_to_list (sym_name, sym_len,
12471 VAR_DOMAIN, LOC_BLOCK,
12472 &objfile->global_psymbols,
12474 @@ -3547,6 +3571,7 @@ static struct sym_fns aout_sym_fns =
12475 dbx_new_init, /* sym_new_init: init anything gbl to entire symtab */
12476 dbx_symfile_init, /* sym_init: read initial info, setup for sym_read() */
12477 dbx_symfile_read, /* sym_read: read a symbol file into symtab */
12478 + NULL, /* sym_read_psymbols */
12479 dbx_symfile_finish, /* sym_finish: finished with file, cleanup */
12480 default_symfile_offsets, /* sym_offsets: parse user's offsets to
12482 diff --git a/gdb/defs.h b/gdb/defs.h
12483 index 845b320..ad6e7d7 100644
12486 @@ -151,6 +151,9 @@ extern int dbx_commands;
12487 /* System root path, used to find libraries etc. */
12488 extern char *gdb_sysroot;
12490 +/* GDB datadir, used to store data files. */
12491 +extern char *gdb_datadir;
12493 /* Search path for separate debug files. */
12494 extern char *debug_file_directory;
12496 @@ -366,6 +369,9 @@ extern struct cleanup *make_cleanup_fclose (FILE *file);
12498 extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
12501 +extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
12503 extern struct cleanup *make_cleanup_restore_integer (int *variable);
12505 extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
12506 diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
12507 index 9f01b33..154139a 100644
12508 --- a/gdb/doc/ChangeLog
12509 +++ b/gdb/doc/ChangeLog
12512 2009-02-14 Vladimir Prus <vladimir@codesourcery.com>
12514 - * observer.texi: Add parameter 'print_frame' to normal_stop
12516 + * observer.texi: Add parameter 'print_frame' to normal_stop
12519 2009-02-07 Eli Zaretskii <eliz@gnu.org>
12521 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
12522 index 10e7388..01a0e41 100644
12523 --- a/gdb/doc/gdb.texinfo
12524 +++ b/gdb/doc/gdb.texinfo
12525 @@ -955,8 +955,10 @@ Connect to process ID @var{number}, as with the @code{attach} command.
12526 @itemx -x @var{file}
12527 @cindex @code{--command}
12529 -Execute @value{GDBN} commands from file @var{file}. @xref{Command
12530 -Files,, Command files}.
12531 +Execute commands from file @var{file}. If @var{file} ends in
12532 +@samp{.py}, then the file is evaluated as Python code. If Python
12533 +support is not enabled in this @value{GDBN}, then an error occurs.
12534 +@xref{Command Files,, Command files}.
12536 @item -eval-command @var{command}
12537 @itemx -ex @var{command}
12538 @@ -1148,6 +1150,16 @@ for remote debugging.
12539 Run using @var{device} for your program's standard input and output.
12540 @c FIXME: kingdon thinks there is more to -tty. Investigate.
12545 +@cindex @code{--python}
12546 +Change interpretation of command line so that the argument immediately
12547 +following this switch is taken to be the name of a Python script file.
12548 +This option stops option processing; subsequent options are passed to
12549 +Python as @code{sys.argv}. This option is only available if Python
12550 +scripting support was enabled when @value{GDBN} was configured.
12552 @c resolve the situation of these eventually
12554 @cindex @code{--tui}
12555 @@ -3636,6 +3648,98 @@ A failed Ada assertion.
12556 A call to @code{exec}. This is currently only available for HP-UX
12557 and @sc{gnu}/Linux.
12560 +@itemx syscall @r{[}@var{name} @r{|} @var{number}@r{]} @r{...}
12561 +@cindex break on a system call.
12562 +A call to or return from a @code{syscall}. If no argument is specified,
12563 +then it catches a call to or return from any system call.
12565 +@var{name} can be any valid system call name in the system. You can
12566 +use the @value{GDBN} command-line completion facilities to list the
12567 +available choices. @xref{Completion,, Command Completion}, for
12568 +details on how to do this.
12570 +You may also specify the system call numerically. This may be useful
12571 +if @value{GDBN} does not fully support your system's list of system
12574 +The example below illustrates how this command works if you don't provide
12578 +(@value{GDBP}) catch syscall
12579 +Catchpoint 1 (syscall)
12581 +Starting program: /tmp/catch-syscall
12583 +Catchpoint 1 (call to syscall 'close'), 0xffffe424 in __kernel_vsyscall ()
12587 +Catchpoint 1 (returned from syscall 'close'), 0xffffe424 in __kernel_vsyscall ()
12591 +Here is an example of catching a system call by name:
12594 +(@value{GDBP}) catch syscall chroot
12595 +Catchpoint 1 (syscall(s) 'chroot')
12597 +Starting program: /tmp/catch-syscall
12599 +Catchpoint 1 (call to syscall 'chroot'), 0xffffe424 in __kernel_vsyscall ()
12603 +Catchpoint 1 (returned from syscall 'chroot'), 0xffffe424 in __kernel_vsyscall ()
12607 +And last but not least, an example of specifying a system call
12611 +(@value{GDBP}) catch syscall 252
12612 +Catchpoint 1 (syscall(s) 'exit_group')
12614 +Starting program: /tmp/catch-syscall
12616 +Catchpoint 1 (call to syscall 'exit_group'), 0xffffe424 in __kernel_vsyscall ()
12620 +Program exited normally.
12624 +If you configure @value{GDBN} using the @samp{--without-expat} option,
12625 +it will not be able to display syscall names. Also, if your
12626 +architecture does not have an XML file describing its system calls,
12627 +you will not be able to see the syscall names. In either case, you
12628 +will see a warning like this:
12631 +(@value{GDBP}) catch syscall
12632 +warning: Could not open "syscalls/i386-linux.xml"
12633 +warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'.
12634 +GDB will not be able to display syscall names.
12635 +Catchpoint 1 (syscall)
12639 +Of course, the file name will change depending on your architecture and system.
12641 +Still using the example above, you can also try to catch a syscall by its
12642 +number. In this case, you would see something like:
12645 +(@value{GDBP}) catch syscall 252
12646 +Catchpoint 1 (syscall(s) 252)
12649 +Again, in this case @value{GDBN} would not be able to display syscall's names.
12652 A call to @code{fork}. This is currently only available for HP-UX
12653 and @sc{gnu}/Linux.
12654 @@ -4711,6 +4815,24 @@ the program to report that some thread has stopped before prompting for
12655 another command. In background execution, @value{GDBN} immediately gives
12656 a command prompt so that you can issue other commands while your program runs.
12658 +You need to explicitly enable asynchronous mode before you can use
12659 +background execution commands. You can use these commands to
12660 +manipulate the asynchronous mode setting:
12663 +@kindex set target-async
12664 +@item set target-async on
12665 +Enable asynchronous mode.
12666 +@item set target-async off
12667 +Disable asynchronous mode.
12668 +@kindex show target-async
12669 +@item show target-async
12670 +Show the current target-async setting.
12673 +If the target doesn't support async mode, @value{GDBN} issues an error
12674 +message if you attempt to use the background execution commands.
12676 To specify background execution, add a @code{&} to the command. For example,
12677 the background form of the @code{continue} command is @code{continue&}, or
12678 just @code{c&}. The execution commands that accept background execution
12679 @@ -4776,11 +4898,6 @@ only the current thread. To stop the whole program in non-stop mode,
12680 use @code{interrupt -a}.
12683 -You may need to explicitly enable async mode before you can use background
12684 -execution commands, with the @code{set target-async 1} command. If the
12685 -target doesn't support async mode, @value{GDBN} issues an error message
12686 -if you attempt to use the background execution commands.
12688 @node Thread-Specific Breakpoints
12689 @subsection Thread-Specific Breakpoints
12691 @@ -6536,6 +6653,12 @@ Without this format, @value{GDBN} displays pointers to and arrays of
12692 @code{char}, @w{@code{unsigned char}}, and @w{@code{signed char}} as
12693 strings. Single-byte members of a vector are displayed as an integer
12697 +@cindex raw printing
12698 +Print using the @samp{raw} formatting. By default, @value{GDBN} will
12699 +use a type-specific pretty-printer. The @samp{r} format bypasses any
12700 +pretty-printer which might exist for the value's type.
12703 For example, to print the program counter in hex (@pxref{Registers}), type
12704 @@ -7408,6 +7531,20 @@ On HP-UX systems, if you refer to a function or variable name that
12705 begins with a dollar sign, @value{GDBN} searches for a user or system
12706 name first, before it searches for a convenience variable.
12708 +@cindex convenience functions
12709 +@value{GDBN} also supplies some @dfn{convenience functions}. These
12710 +have a syntax similar to convenience variables. A convenience
12711 +function can be used in an expression just like an ordinary function;
12712 +however, a convenience function is implemented internally to
12716 +@item help function
12717 +@kindex help function
12718 +@cindex show all convenience functions
12719 +Print a list of all convenience functions.
12725 @@ -7931,13 +8068,17 @@ support:
12727 @item set target-charset @var{charset}
12728 @kindex set target-charset
12729 -Set the current target character set to @var{charset}. We list the
12730 -character set names @value{GDBN} recognizes below, but if you type
12731 -@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
12732 -list the target character sets it supports.
12734 +Set the current target character set to @var{charset}. If you type
12735 +@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN}
12736 +will list the target character sets it supports.
12738 +@item set target-wide-charset @var{charset}
12739 +@kindex set target-wide-charset
12740 +Set the current target wide character set to @var{charset}. The
12741 +target wide character set is the character set used by @code{wchar_t}.
12742 +If you type @code{set target-charset} followed by @key{TAB}@key{TAB},
12743 +@value{GDBN} will list the target character sets it supports.
12746 @item set host-charset @var{charset}
12747 @kindex set host-charset
12748 Set the current host character set to @var{charset}.
12749 @@ -7947,10 +8088,9 @@ system it is running on; you can override that default using the
12750 @code{set host-charset} command.
12752 @value{GDBN} can only use certain character sets as its host character
12753 -set. We list the character set names @value{GDBN} recognizes below, and
12754 -indicate which can be host character sets, but if you type
12755 -@code{set target-charset} followed by @key{TAB}@key{TAB}, @value{GDBN} will
12756 -list the host character sets it supports.
12757 +set. If you type @code{set target-charset} followed by
12758 +@key{TAB}@key{TAB}, @value{GDBN} will list the host character sets it
12761 @item set charset @var{charset}
12762 @kindex set charset
12763 @@ -7974,37 +8114,6 @@ Show the name of the current target charset.
12767 -@value{GDBN} currently includes support for the following character
12773 -@cindex ASCII character set
12774 -Seven-bit U.S. @sc{ascii}. @value{GDBN} can use this as its host
12778 -@cindex ISO 8859-1 character set
12779 -@cindex ISO Latin 1 character set
12780 -The ISO Latin 1 character set. This extends @sc{ascii} with accented
12781 -characters needed for French, German, and Spanish. @value{GDBN} can use
12782 -this as its host character set.
12786 -@cindex EBCDIC character set
12787 -@cindex IBM1047 character set
12788 -Variants of the @sc{ebcdic} character set, used on some of IBM's
12789 -mainframe operating systems. (@sc{gnu}/Linux on the S/390 uses U.S. @sc{ascii}.)
12790 -@value{GDBN} cannot use these as its host character set.
12794 -Note that these are all single-byte character sets. More work inside
12795 -@value{GDBN} is needed to support multi-byte or variable-width character
12796 -encodings, like the UTF-8 and UCS-2 encodings of Unicode.
12798 Here is an example of @value{GDBN}'s character set support in action.
12799 Assume that the following source code has been placed in the file
12800 @file{charset-test.c}:
12801 @@ -12481,6 +12590,53 @@ returned. In contrast, the @code{finish} command (@pxref{Continuing
12802 and Stepping, ,Continuing and Stepping}) resumes execution until the
12803 selected stack frame returns naturally.
12805 +@value{GDBN} needs to know how the @var{expression} argument should be set for
12806 +the inferior. The concrete registers assignment depends on the OS ABI and the
12807 +type being returned by the selected stack frame. For example it is common for
12808 +OS ABI to return floating point values in FPU registers while integer values in
12809 +CPU registers. Still some ABIs return even floating point values in CPU
12810 +registers. Larger integer widths (such as @code{long long int}) also have
12811 +specific placement rules. @value{GDBN} already knows the OS ABI from its
12812 +current target so it needs to find out also the type being returned to make the
12813 +assignment into the right register(s).
12815 +Normally, the selected stack frame has debug info. @value{GDBN} will always
12816 +use the debug info instead of the implicit type of @var{expression} when the
12817 +debug info is available. For example, if you type @kbd{return -1}, and the
12818 +function in the current stack frame is declared to return a @code{long long
12819 +int}, @value{GDBN} transparently converts the implicit @code{int} value of -1
12820 +into a @code{long long int}:
12823 +Breakpoint 1, func () at gdb.base/return-nodebug.c:29
12825 +(@value{GDBP}) return -1
12826 +Make func return now? (y or n) y
12827 +#0 0x004004f6 in main () at gdb.base/return-nodebug.c:43
12828 +43 printf ("result=%lld\n", func ());
12832 +However, if the selected stack frame does not have a debug info, e.g., if the
12833 +function was compiled without debug info, @value{GDBN} has to find out the type
12834 +to return from user. Specifying a different type by mistake may set the value
12835 +in different inferior registers than the caller code expects. For example,
12836 +typing @kbd{return -1} with its implicit type @code{int} would set only a part
12837 +of a @code{long long int} result for a debug info less function (on 32-bit
12838 +architectures). Therefore the user is required to specify the return type by
12839 +an appropriate cast explicitly:
12842 +Breakpoint 2, 0x0040050b in func ()
12843 +(@value{GDBP}) return -1
12844 +Return value type not available for selected stack frame.
12845 +Please use an explicit cast of the value to return.
12846 +(@value{GDBP}) return (long long int) -1
12847 +Make selected stack frame return now? (y or n) y
12848 +#0 0x00400526 in main ()
12853 @section Calling Program Functions
12855 @@ -12510,6 +12666,12 @@ It is possible for the function you call via the @code{print} or
12856 the function, or if you passed it incorrect arguments). What happens
12857 in that case is controlled by the @code{set unwindonsignal} command.
12859 +Similarly, with a C++ program it is possible for the function you
12860 +call via the @code{print} or @code{call} command to generate an
12861 +exception that is not handled due to the constraints of the dummy
12862 +frame. What happens in that case is controlled by the
12863 +@code{set unwind-on-terminating-exception} command.
12866 @item set unwindonsignal
12867 @kindex set unwindonsignal
12868 @@ -12526,6 +12688,23 @@ received.
12869 @kindex show unwindonsignal
12870 Show the current setting of stack unwinding in the functions called by
12873 +@item set unwind-on-terminating-exception
12874 +@kindex set unwind-on-terminating-exception
12875 +@cindex unwind stack in called functions
12876 +@cindex call dummy stack unwinding on unhandled exception.
12877 +Set unwinding of the stack if a C++ exception is raised but unhandled
12878 +while in a function that @value{GDBN} called in the program being
12879 +debugged. If set to on (the default), @value{GDBN} unwinds the stack
12880 +it created for the call and restores the context to what it was before
12881 +the call. If set to off, @value{GDBN} the exception is delivered to
12882 +the default C++ exception handler.
12884 +@item show unwind-on-terminating-exception
12885 +@kindex show unwind-on-terminating-exception
12886 +Show the current setting of stack unwinding in the functions called by
12891 @cindex weak alias functions
12892 @@ -17815,7 +17994,7 @@ command:
12895 @cindex execute commands from a file
12896 -@item source [@code{-v}] @var{filename}
12897 +@item source [@code{-v}] [@code{-p}] @var{filename}
12898 Execute the command file @var{filename}.
12901 @@ -17832,6 +18011,11 @@ If @code{-v}, for verbose mode, is given then @value{GDBN} displays
12902 each command as it is executed. The option must be given before
12903 @var{filename}, and is interpreted as part of the filename anywhere else.
12905 +If @var{filename} ends in @samp{.py}, or if @code{-p}, for Python, is
12906 +given then @value{GDBN} evaluates the contents of the file as Python
12907 +code. If Python support is not compiled in to @value{GDBN}, then an
12910 Commands that would ask for confirmation if used interactively proceed
12911 without asking when used in a command file. Many @value{GDBN} commands that
12912 normally print messages to say what they are doing omit the messages
12913 @@ -18093,8 +18277,6 @@ containing @code{end}. For example:
12916 (@value{GDBP}) python
12917 -Type python script
12918 -End with a line saying just "end".
12922 @@ -18107,6 +18289,14 @@ in a Python script. This can be controlled using @code{maint set
12923 python print-stack}: if @code{on}, the default, then Python stack
12924 printing is enabled; if @code{off}, then Python stack printing is
12927 +@kindex maint set python auto-load
12928 +@item maint set python auto-load
12929 +By default, @value{GDBN} will attempt to automatically load Python
12930 +code when an object file is opened. This can be controlled using
12931 +@code{maint set python auto-load}: if @code{on}, the default, then
12932 +Python auto-loading is enabled; if @code{off}, then Python
12933 +auto-loading is disabled.
12937 @@ -18114,6 +18304,14 @@ disabled.
12939 @cindex programming in python
12941 +You can get quick online help for @value{GDBN}'s Python API by issuing
12942 +the command @w{@kbd{python help (gdb)}}.
12944 +Functions and methods which have two or more optional arguments allow
12945 +them to be specified using keyword syntax. This allows passing some
12946 +optional arguments while skipping others. Example:
12947 +@w{@code{gdb.some_function ('foo', bar = 1, baz = 2)}}.
12949 @cindex python stdout
12950 @cindex python pagination
12951 At startup, @value{GDBN} overrides Python's @code{sys.stdout} and
12952 @@ -18125,8 +18323,17 @@ situation, a Python @code{KeyboardInterrupt} exception is thrown.
12954 * Basic Python:: Basic Python Functions.
12955 * Exception Handling::
12956 -* Values From Inferior::
12957 +* Auto-loading:: Automatically loading Python code.
12958 +* Values From Inferior:: Python representation of values.
12959 +* Types From Inferior:: Python representation of types.
12960 +* Pretty Printing:: Pretty-printing values.
12961 +* Threads In Python:: Accessing inferior threads from Python.
12962 * Commands In Python:: Implementing new commands in Python.
12963 +* Parameters In Python:: Adding new @value{GDBN} parameters.
12964 +* Functions In Python:: Writing new convenience functions.
12965 +* Objfiles In Python:: Object files.
12966 +* Breakpoints In Python:: Manipulating breakpoints using Python.
12967 +* Frames In Python:: Acessing inferior stack frames from Python.
12971 @@ -18152,10 +18359,30 @@ command as having originated from the user invoking it interactively.
12972 It must be a boolean value. If omitted, it defaults to @code{False}.
12975 -@findex gdb.get_parameter
12976 -@defun get_parameter parameter
12977 -Return the value of a @value{GDBN} parameter. @var{parameter} is a
12978 -string naming the parameter to look up; @var{parameter} may contain
12979 +@findex gdb.current_objfile
12980 +@defun current_objfile
12981 +When auto-loading a Python script (@pxref{Auto-loading}), @value{GDBN}
12982 +sets the ``current objfile'' to the corresponding objfile. This
12983 +function returns the current objfile. If there is no current objfile,
12984 +this function returns @code{None}.
12987 +@findex gdb.breakpoints
12988 +@defun breakpoints
12989 +Return a sequence holding all of @value{GDBN}'s breakpoints.
12990 +@xref{Breakpoints In Python}, for more information.
12993 +@findex gdb.objfiles
12995 +Return a sequence of all the objfiles current known to @value{GDBN}.
12996 +@xref{Objfiles In Python}.
12999 +@findex gdb.parameter
13000 +@defun parameter name
13001 +Return the value of the named @value{GDBN} parameter. @var{name} is a
13002 +string naming the parameter to look up; @var{name} may contain
13003 spaces if the parameter has a multi-part name. For example,
13004 @samp{print object} is a valid parameter name.
13006 @@ -18179,6 +18406,28 @@ If no exception is raised, the return value is always an instance of
13007 @code{gdb.Value} (@pxref{Values From Inferior}).
13010 +@findex gdb.parse_and_eval
13011 +@defun parse_and_eval expression
13012 +Parse @var{expression} as an expression in the current language,
13013 +evaluate it, and return the result as a @code{gdb.Value}.
13014 +@var{expression} must be a string.
13017 +@findex gdb.post_event
13018 +@defun post_event event
13019 +Put @var{event}, a callable object taking no arguments, into
13020 +@value{GDBN}'s internal event queue. This callable will be invoked at
13021 +some later point, during @value{GDBN}'s event processing. Events
13022 +posted using @code{post_event} will be run in the order in which they
13023 +were posted; however, there is no way to know when they will be
13024 +processed relative to other events inside @value{GDBN}.
13026 +@value{GDBN} is not thread-safe. If your Python program uses multiple
13027 +threads, you must be careful to only call @value{GDBN}-specific
13028 +functions in the main @value{GDBN} thread. @code{post_event} ensures
13033 @defun write string
13034 Print a string to @value{GDBN}'s paginated standard output stream.
13035 @@ -18193,6 +18442,66 @@ Flush @value{GDBN}'s paginated standard output stream. Flushing
13039 +@findex gdb.frames
13041 +Return a tuple of all frame objects.
13044 +@findex gdb.newest_frame
13045 +@defun newest_frame
13046 +Return the newest frame object.
13049 +@findex gdb.selected_frame
13050 +@defun selected_frame
13051 +Return the selected frame object.
13054 +@findex gdb.frame_stop_reason_string
13055 +@defun frame_stop_reason_string @var{reason}
13056 +Return a string explaining the reason why @value{GDBN} stopped unwinding
13057 +frames, as expressed by the given @var{reason} code (an integer, see the
13058 +@code{unwind_stop_reason} method in
13059 +@xref{Frames In Python,,Accessing inferior stack frames from Python}.)
13062 +@findex gdb.read_memory
13063 +@defun read_memory @var{address} @var{length}
13064 +Read @var{length} bytes of memory from the inferior, starting at @var{address}.
13065 +Returns a buffer object, which behaves much like an array or a string. It
13066 +can be modified and given to the @code{gdb.write_memory} function.
13069 +@findex gdb.write_memory
13070 +@defun write_memory @var{address} @var{buffer} @r{[}@var{length}@r{]}
13071 +Write the contents of @var{buffer} (a Python object which supports the buffer
13072 +protocol, i.e., a string, an array or the object returned from
13073 +@code{gdb.read_memory}) to the inferior, starting at @var{address}. If given,
13074 +@var{length} determines the number of bytes from @var{buffer} to be written.
13077 +@findex gdb.search_memory
13078 +@defun search_memory @var{address} @var{length} @var{pattern} @r{[}@var{size}@r{]} @r{[}@var{max_count}@r{]}
13079 +Search a region of the inferior memory starting at @var{address} with the given
13080 +@var{length}. @var{pattern} can be a string, a byte array, a buffer object,
13081 +a number, a @code{gdb.Value} object (@pxref{Values From Inferior}) or a list
13082 +or tuple with elements in any combination of those types. If @var{size} is
13083 +given and is non-zero, it specifies the size in bytes of a Python scalar or
13084 +@code{gdb.Value} in the search pattern. If @var{size} is zero or not specified,
13085 + it is taken from the value's type in the current language.
13086 +This is useful when one wants to specify the search
13087 +pattern as a mixture of types.
13088 +Note that this means, for example, that in the case of C-like languages
13089 +a search for an untyped 0x42 will search for @samp{(int) 0x42}
13090 +which is typically four bytes. @var{max_count} is the highest number of matches
13094 +@findex gdb.solib_address
13095 +@defun solib_address @var{address}
13096 +Return the name of the shared library holding the given address, or None.
13099 @node Exception Handling
13100 @subsubsection Exception Handling
13101 @cindex python exceptions
13102 @@ -18224,6 +18533,44 @@ message as its value, and the Python call stack backtrace at the
13103 Python statement closest to where the @value{GDBN} error occured as the
13106 +@node Auto-loading
13107 +@subsubsection Auto-loading
13109 +When a new object file (@pxref{Objfiles In Python}) is read (for
13110 +example, due to the @code{file} command, or because the inferior has
13111 +loaded a shared library), @value{GDBN} will look for a file named by
13112 +adding @samp{-gdb.py} to the object file's real name (the name formed
13113 +after following all symlinks and resolving @code{.} and @code{..}
13114 +components). If this file exists and is readable, @value{GDBN} will
13115 +evaluate it as a Python script.
13117 +If this file does not exist, and if the parameter
13118 +@code{debug-file-directory} is set, then @value{GDBN} will append the
13119 +object file's real name to the value of this parameter, and try again.
13121 +Finally, if this file does not exist, then @value{GDBN} will look in
13122 +subdirectory of @code{gdb_datadir} (whose value is available from
13123 +@code{maint show gdb_datadir}). Specifically, @value{GDBN} will take
13124 +the value of @code{gdb_datadir}, append @samp{python/auto-load}, and
13125 +then append the object file's real name.
13127 +Also, if a separate debug file is used, @value{GDBN} will look for the
13128 +@samp{-gdb.py} file both in the directory associated with the
13129 +application and the directory associated with the separate debug file.
13131 +When reading a @samp{-gdb.py} file, @value{GDBN} sets the ``current
13132 +objfile''. This is available via the @code{gdb.current_objfile}
13133 +function. This can be useful for registering objfile-specific
13136 +This feature is useful for supplying application-specific debugging
13137 +commands and scripts. It can be disabled using @code{maint set python
13140 +@value{GDBN} does not track which files it has already auto-loaded.
13141 +So, your @samp{-gdb.py} file should take care to ensure that it may be
13142 +evaluated multiple times without error.
13144 @node Values From Inferior
13145 @subsubsection Values From Inferior
13146 @cindex values from inferior, with Python
13147 @@ -18258,8 +18605,21 @@ bar = some_val['foo']
13149 Again, @code{bar} will also be a @code{gdb.Value} object.
13151 -For pointer data types, @code{gdb.Value} provides a method for
13152 -dereferencing the pointer to obtain the object it points to.
13153 +The following methods are provided:
13156 +@defmethod Value address
13157 +If the @code{gdb.Value} object is addressable, this will return a new
13158 +@code{gdb.Value} object representing the address. Otherwise, this
13159 +will throw an exception.
13162 +@defmethod Value cast type
13163 +Cast the @code{gdb.Value} to the type represented by @var{type}, and
13164 +return a new @code{gdb.Value}. @var{type} must be a @code{gdb.Type}
13165 +object. If the cast cannot be performed for some reason, an exception
13169 @defmethod Value dereference
13170 This method returns a new @code{gdb.Value} object whose contents is
13171 @@ -18282,7 +18642,7 @@ The result @code{bar} will be a @code{gdb.Value} object holding the
13172 value pointed to by @code{foo}.
13175 -@defmethod Value string @r{[}encoding @r{[}errors@r{]}@r{]}
13176 +@defmethod Value string @r{[}encoding@r{]} @r{[}errors@r{]}
13177 If this @code{gdb.Value} represents a string, then this method
13178 converts the contents to a Python string. Otherwise, this method will
13179 throw an exception.
13180 @@ -18309,6 +18669,468 @@ The optional @var{errors} argument is the same as the corresponding
13181 argument to Python's @code{string.decode} method.
13184 +@defmethod Value type
13185 +Return the type of this @code{gdb.Value}. The result is a
13186 +@code{gdb.Type} object.
13190 +@node Types From Inferior
13191 +@subsubsection Types From Inferior
13194 +@value{GDBN} represents types from the inferior using the class
13197 +The following methods are provided:
13200 +@defmethod Type Type [name [block]]
13201 +Construct a new instance of @code{gdb.Type}.
13203 +If @var{name} is given, it specifies the name of a type to look up in
13206 +If @var{block} is given, then @var{name} is looked up in that scope.
13207 +Otherwise, it is searched for globally.
13210 +@defmethod Type code
13211 +Return the type code for this type. The type code will be one of the
13212 +@code{TYPE_CODE_} constants defined below.
13215 +@defmethod Type fields
13216 +For structure and union types, this method returns the fields. Range
13217 +types have two fields, the minimum and maximum values. Enum types
13218 +have one field per enum constant. Function and method types have one
13219 +field per parameter. The base types of C++ classes are also
13220 +represented as fields. If the type has no fields, or does not fit
13221 +into one of these categories, an empty sequence will be returned.
13223 +Each field is an object, with some pre-defined attributes:
13226 +This attribute is not available for @code{static} fields. For
13227 +non-@code{static} fields, the value is the bit position of the field.
13230 +The name of the field, or @code{None} for anonymous fields.
13233 +This is @code{True} if the field is artificial, usually meaning that
13234 +it was provided by the compiler and not the user. This attribute is
13235 +always provided, and is @code{False} if the field is not artificial.
13238 +If the field is packed, or is a bitfield, then this will have a
13239 +non-zero value, which is the size of the field in bits. Otherwise,
13240 +this will be zero; in this case the field's size is given by its type.
13243 +The type of the field.
13247 +@defmethod Type const
13248 +Return a new @code{gdb.Type} object which represents a
13249 +@code{const}-qualified variant of this type.
13252 +@defmethod Type volatile
13253 +Return a new @code{gdb.Type} object which represents a
13254 +@code{volatile}-qualified variant of this type.
13257 +@defmethod Type unqualified
13258 +Return a new @code{gdb.Type} object which represents an unqualified
13259 +variant of this type. That is, the result is neither @code{const} nor
13263 +@defmethod Type reference
13264 +Return a new @code{gdb.Type} object which represents a reference to this
13268 +@defmethod Type sizeof
13269 +Return the size of this type, in target @code{char} units. Usually, a
13270 +target's @code{char} type will be an 8-bit byte. However, on some
13271 +unusual platforms, this type may have a different size.
13274 +@defmethod Type strip_typedefs
13275 +Return a new @code{gdb.Type} that represents the real type,
13276 +after removing all layers of typedefs.
13279 +@defmethod Type tag
13280 +Return the tag name for this type. The tag name is the name after
13281 +@code{struct}, @code{union}, or @code{enum} in C; not all languages
13282 +have this concept. If this type has no tag name, then @code{None} is
13286 +@defmethod Type target
13287 +Return a new @code{gdb.Type} object which represents the target type
13290 +For a pointer type, the target type is the type of the pointed-to
13291 +object. For an array type, the target type is the type of the
13292 +elements of the array. For a function type, the target type is the
13293 +type of the return value. For a complex type, the target type is the
13294 +type of the elements. For a typedef, the target type is the aliased
13298 +@defmethod Type template_argument n [block]
13299 +If this @code{gdb.Type} is a template type, this will return a new
13300 +@code{gdb.Type} which represents the type of the @var{n}th template
13303 +If this @code{gdb.Type} is not a template type, this will throw an
13306 +If @var{block} is given, then @var{name} is looked up in that scope.
13307 +Otherwise, it is searched for globally.
13312 +Each type has a code, which indicates what category this type falls
13313 +into. The available type categories are represented by constants
13314 +defined in the @code{gdb} module:
13317 +@findex TYPE_CODE_PTR
13318 +@findex gdb.TYPE_CODE_PTR
13319 +@item TYPE_CODE_PTR
13320 +The type is a pointer.
13322 +@findex TYPE_CODE_ARRAY
13323 +@findex gdb.TYPE_CODE_ARRAY
13324 +@item TYPE_CODE_ARRAY
13325 +The type is an array.
13327 +@findex TYPE_CODE_STRUCT
13328 +@findex gdb.TYPE_CODE_STRUCT
13329 +@item TYPE_CODE_STRUCT
13330 +The type is a structure.
13332 +@findex TYPE_CODE_UNION
13333 +@findex gdb.TYPE_CODE_UNION
13334 +@item TYPE_CODE_UNION
13335 +The type is a union.
13337 +@findex TYPE_CODE_ENUM
13338 +@findex gdb.TYPE_CODE_ENUM
13339 +@item TYPE_CODE_ENUM
13340 +The type is an enum.
13342 +@findex TYPE_CODE_FLAGS
13343 +@findex gdb.TYPE_CODE_FLAGS
13344 +@item TYPE_CODE_FLAGS
13346 +@c FIXME: what is this?
13348 +@findex TYPE_CODE_FUNC
13349 +@findex gdb.TYPE_CODE_FUNC
13350 +@item TYPE_CODE_FUNC
13351 +The type is a function.
13353 +@findex TYPE_CODE_INT
13354 +@findex gdb.TYPE_CODE_INT
13355 +@item TYPE_CODE_INT
13356 +The type is an integer type.
13358 +@findex TYPE_CODE_FLT
13359 +@findex gdb.TYPE_CODE_FLT
13360 +@item TYPE_CODE_FLT
13361 +A floating point type.
13363 +@findex TYPE_CODE_VOID
13364 +@findex gdb.TYPE_CODE_VOID
13365 +@item TYPE_CODE_VOID
13366 +The special type @code{void}.
13368 +@findex TYPE_CODE_SET
13369 +@findex gdb.TYPE_CODE_SET
13370 +@item TYPE_CODE_SET
13371 +A Pascal set type.
13373 +@findex TYPE_CODE_RANGE
13374 +@findex gdb.TYPE_CODE_RANGE
13375 +@item TYPE_CODE_RANGE
13376 +A range type, that is, an integer type with bounds.
13378 +@findex TYPE_CODE_STRING
13379 +@findex gdb.TYPE_CODE_STRING
13380 +@item TYPE_CODE_STRING
13381 +A string type. Note that this is only used for certain languages with
13382 +language-defined string types; C strings are not represented this way.
13384 +@findex TYPE_CODE_BITSTRING
13385 +@findex gdb.TYPE_CODE_BITSTRING
13386 +@item TYPE_CODE_BITSTRING
13389 +@findex TYPE_CODE_ERROR
13390 +@findex gdb.TYPE_CODE_ERROR
13391 +@item TYPE_CODE_ERROR
13392 +An unknown or erroneous type.
13394 +@findex TYPE_CODE_METHOD
13395 +@findex gdb.TYPE_CODE_METHOD
13396 +@item TYPE_CODE_METHOD
13397 +A C++ method type.
13399 +@findex TYPE_CODE_METHODPTR
13400 +@findex gdb.TYPE_CODE_METHODPTR
13401 +@item TYPE_CODE_METHODPTR
13402 +A pointer-to-member-function.
13404 +@findex TYPE_CODE_MEMBERPTR
13405 +@findex gdb.TYPE_CODE_MEMBERPTR
13406 +@item TYPE_CODE_MEMBERPTR
13407 +A pointer-to-member.
13409 +@findex TYPE_CODE_REF
13410 +@findex gdb.TYPE_CODE_REF
13411 +@item TYPE_CODE_REF
13414 +@findex TYPE_CODE_CHAR
13415 +@findex gdb.TYPE_CODE_CHAR
13416 +@item TYPE_CODE_CHAR
13419 +@findex TYPE_CODE_BOOL
13420 +@findex gdb.TYPE_CODE_BOOL
13421 +@item TYPE_CODE_BOOL
13424 +@findex TYPE_CODE_COMPLEX
13425 +@findex gdb.TYPE_CODE_COMPLEX
13426 +@item TYPE_CODE_COMPLEX
13427 +A complex float type.
13429 +@findex TYPE_CODE_TYPEDEF
13430 +@findex gdb.TYPE_CODE_TYPEDEF
13431 +@item TYPE_CODE_TYPEDEF
13432 +A typedef to some other type.
13434 +@findex TYPE_CODE_TEMPLATE
13435 +@findex gdb.TYPE_CODE_TEMPLATE
13436 +@item TYPE_CODE_TEMPLATE
13437 +A C++ template type. Note that this is not used for a template
13438 +instantiation; those appear as ordinary struct types.
13439 +@c FIXME I hope that is true
13441 +@findex TYPE_CODE_TEMPLATE_ARG
13442 +@findex gdb.TYPE_CODE_TEMPLATE_ARG
13443 +@item TYPE_CODE_TEMPLATE_ARG
13444 +A C++ template argument.
13445 +@c FIXME: is this ever used?
13447 +@findex TYPE_CODE_NAMESPACE
13448 +@findex gdb.TYPE_CODE_NAMESPACE
13449 +@item TYPE_CODE_NAMESPACE
13452 +@findex TYPE_CODE_DECFLOAT
13453 +@findex gdb.TYPE_CODE_DECFLOAT
13454 +@item TYPE_CODE_DECFLOAT
13455 +A decimal floating point type.
13457 +@findex TYPE_CODE_INTERNAL_FUNCTION
13458 +@findex gdb.TYPE_CODE_INTERNAL_FUNCTION
13459 +@item TYPE_CODE_INTERNAL_FUNCTION
13460 +A function internal to @value{GDBN}. This is the type used to represent
13461 +convenience functions.
13464 +@node Pretty Printing
13465 +@subsubsection Pretty Printing
13467 +@value{GDBN} provides a mechanism to allow pretty-printing of values
13468 +using Python code. This mechanism works for both MI and the CLI.
13470 +A pretty-printer is an object that implements a specific interface.
13471 +There is no predefined base class for pretty-printers.
13473 +@defop Operation {pretty printer} __init__ (self, val)
13474 +When printing a value, @value{GDBN} constructs an instance of the
13475 +pretty-printer. @var{val} is the value to be printed, an instance of
13479 +@defop Operation {pretty printer} children (self)
13480 +When printing a value, @value{GDBN} will call this method to compute
13481 +the children of the value passed to the object's constructor.
13483 +This method must return an object conforming to the Python iterator
13484 +protocol. Each element returned by the iterator must be a tuple
13485 +holding two elements. The first element is the ``name'' of the child;
13486 +the second element is the child's value. The value can be any Python
13487 +object which is convertible to a @value{GDBN} value.
13489 +This method is optional. If it does not exist, @value{GDBN} will act
13490 +as though the value has no children.
13493 +@defop Operation {pretty printer} display_hint (self)
13494 +This method must return a string. The CLI may use this to change the
13495 +formatting of children of a value. The result will also be supplied
13496 +to an MI consumer as a @samp{displayhint} attribute of the variable
13499 +Some display hints are predefined by @value{GDBN}:
13503 +Indicate that the object being printed is ``array-like''. The CLI
13504 +uses this to respect parameters such as @code{set print elements} and
13505 +@code{set print array}.
13508 +Indicate that the object being printed is ``map-like'', and that the
13509 +children of this value can be assumed to alternate between keys and
13513 +Indicate that the object being printed is ``string-like''. If the
13514 +printer's @code{to_string} method returns a Python string of some
13515 +kind, then @value{GDBN} will call its internal language-specific
13516 +string-printing function to format the string. For the CLI this means
13517 +adding quotation marks, possibly escaping some characters, respecting
13518 +@code{set print elements}, and the like.
13522 +@defop Operation {pretty printer} to_string (self)
13523 +@value{GDBN} will call this method to display the string
13524 +representation of the value passed to the object's constructor.
13526 +When printing from the CLI, if the @code{to_string} method exists,
13527 +then @value{GDBN} will prepend its result to the values returned by
13530 +If this method returns a string, it is printed verbatim. Otherwise,
13531 +the result is converted to a @code{gdb.Value}, following the usual
13532 +algorithm. Then @value{GDBN} prints this value; this may possibly
13533 +result in a call to another pretty-printer. If the result is not
13534 +convertible to @code{gdb.Value}, an exception is raised.
13537 +@subsubsection Selecting Pretty-Printers
13539 +The Python list @code{gdb.pretty_printers} contains an array of
13540 +functions that have been registered via addition as a pretty-printer.
13541 +Each function will be called with a @code{gdb.Value} to be
13542 +pretty-printed. Each @code{gdb.Objfile} also contains a
13543 +@code{pretty_printers} attribute. A function on one of these lists
13544 +takes a single @code{gdb.Value} argument and returns a pretty-printer
13545 +object conforming to the interface definition above. If this function
13546 +cannot create a pretty-printer for the value, it should return
13549 +@value{GDBN} first checks the @code{pretty_printers} attribute of each
13550 +@code{gdb.Objfile} and iteratively calls each function in the list for
13551 +that @code{gdb.Objfile} until it receives a pretty-printer object.
13552 +After these @code{gdb.Objfile} have been exhausted, it tries the
13553 +global @code{gdb.pretty-printers} list, again calling each function
13554 +until an object is returned.
13556 +The order in which the objfiles are searched is not specified.
13557 +Functions are always invoked from the head of the
13558 +@code{gdb.pretty-printers} list, and iterated over sequentially until
13559 +the end of the list, or a printer object is returned.
13561 +Here is an example showing how a @code{std::string} printer might be
13565 +class StdStringPrinter:
13566 + "Print a std::string"
13568 + def __init__ (self, val):
13571 + def to_string (self):
13572 + return self.val['_M_dataplus']['_M_p']
13575 +And here is an example showing how a lookup function for
13576 +the printer example above might be written.
13579 +def str_lookup_function (val):
13581 + lookup_tag = val.type ().tag ()
13582 + regex = re.compile ("^std::basic_string<char,.*>$")
13583 + if lookup_tag == None:
13585 + if regex.match (lookup_tag):
13586 + return StdStringPrinter (val)
13591 +The example lookup function extracts the value's type, and attempts to
13592 +match it to a type that it can pretty-print. If it is a type the
13593 +printer can pretty-print, it will return a printer object. If not, it
13594 +returns: @code{None}.
13596 +We recommend that you put your core pretty-printers into a versioned
13597 +python package, and then restrict your auto-loaded code to idempotent
13598 +behavior -- for example, just @code{import}s of your printer modules,
13599 +followed by a call to a register pretty-printers with the current
13600 +objfile. This approach will scale more nicely to multiple inferiors,
13601 +potentially using different library versions.
13603 +For example, in addition to the above, this code might appear in
13604 +@code{gdb.libstdcxx.v6}:
13607 +def register_printers (objfile):
13608 + objfile.pretty_printers.add (str_lookup_function)
13611 +And then the corresponding contents of the auto-load file would be:
13614 +import gdb.libstdcxx.v6
13615 +gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
13618 +@node Threads In Python
13619 +@subsubsection Threads In Python
13621 +Python scripts can access information about the inferior's threads
13622 +using some functions provided by @value{GDBN}. Like all of
13623 +@value{GDBN}'s Python additions, these are in the @code{gdb} module:
13625 +@findex gdb.threads
13627 +This function returns a tuple holding all the thread IDs which are
13628 +valid when the function is called. If there are no valid threads,
13629 +this will return @code{None}.
13632 +@findex gdb.current_thread
13633 +@defun current_thread
13634 +This function returns the thread ID of the selected thread. If there
13635 +is no selected thread, this will return @code{None}.
13638 +@findex gdb.switch_to_thread
13639 +@defun switch_to_thread id
13640 +This changes @value{GDBN}'s currently selected thread to the thread
13641 +given by @var{id}. @var{id} must be a valid thread ID as returned by
13642 +@code{threads}. If @var{id} is invalid, this function throws an
13646 @node Commands In Python
13647 @subsubsection Commands In Python
13649 @@ -18320,7 +19142,7 @@ You can implement new @value{GDBN} CLI commands in Python. A CLI
13650 command is implemented using an instance of the @code{gdb.Command}
13651 class, most commonly using a subclass.
13653 -@defmethod Command __init__ name @var{command-class} @r{[}@var{completer-class} @var{prefix}@r{]}
13654 +@defmethod Command __init__ name @var{command_class} @r{[}@var{completer_class}@r{]} @r{[}@var{prefix}@r{]}
13655 The object initializer for @code{Command} registers the new command
13656 with @value{GDBN}. This initializer is normally invoked from the
13657 subclass' own @code{__init__} method.
13658 @@ -18332,11 +19154,11 @@ an exception is raised.
13660 There is no support for multi-line commands.
13662 -@var{command-class} should be one of the @samp{COMMAND_} constants
13663 +@var{command_class} should be one of the @samp{COMMAND_} constants
13664 defined below. This argument tells @value{GDBN} how to categorize the
13665 new command in the help system.
13667 -@var{completer-class} is an optional argument. If given, it should be
13668 +@var{completer_class} is an optional argument. If given, it should be
13669 one of the @samp{COMPLETE_} constants defined below. This argument
13670 tells @value{GDBN} how to perform completion for this command. If not
13671 given, @value{GDBN} will attempt to complete using the object's
13672 @@ -18563,6 +19385,374 @@ registration of the command with @value{GDBN}. Depending on how the
13673 Python code is read into @value{GDBN}, you may need to import the
13674 @code{gdb} module explicitly.
13677 +@node Parameters In Python
13678 +@subsubsection Parameters In Python
13680 +@cindex parameters in python
13681 +@cindex python parameters
13682 +@tindex gdb.Parameter
13684 +You can implement new @value{GDBN} parameters using Python. A new
13685 +parameter is implemented as an instance of the @code{gdb.Parameter}
13686 +class. Parameters are exposed to the user via the @code{set} and
13687 +@code{show} commands.
13689 +@defmethod Parameter __init__ name @var{command-class} @var{parameter-class} @r{[}@var{enum-sequence}@r{]}
13690 +The object initializer for @code{Parameter} registers the new
13691 +parameter with @value{GDBN}. This initializer is normally invoked
13692 +from the subclass' own @code{__init__} method.
13694 +@var{name} is the name of the new parameter. If @var{name} consists
13695 +of multiple words, then the initial words are looked for as prefix
13696 +commands. In this case, if one of the prefix commands does not exist,
13697 +an exception is raised.
13699 +@var{command-class} should be one of the @samp{COMMAND_} constants
13700 +(@pxref{Commands In Python}). This argument tells @value{GDBN} how to
13701 +categorize the new parameter in the help system.
13703 +@var{parameter-class} should be one of the @samp{PARAM_} constants
13704 +defined below. This argument tells @value{GDBN} the type of the new
13705 +parameter; this information is used for input validation and
13708 +If @var{parameter-class} is @code{PARAM_ENUM}, then
13709 +@var{enum-sequence} must be a sequence of strings. These strings
13710 +represent the possible values for the parameter.
13712 +If @var{parameter-class} is not @code{PARAM_ENUM}, then the presence
13713 +of a fourth argument will cause an exception to be thrown.
13715 +The help text for the new parameter is taken from the Python
13716 +documentation string for the parameter's class, if there is one. If
13717 +there is no documentation string, a default value is used.
13720 +@defivar Parameter set_doc
13721 +If this attribute exists, and is a string, then its value is used as
13722 +the help text for this parameter's @code{set} command. The value is
13723 +examined when @code{Parameter.__init__} is invoked; subsequent changes
13727 +@defivar Parameter show_doc
13728 +If this attribute exists, and is a string, then its value is used as
13729 +the help text for this parameter's @code{show} command. The value is
13730 +examined when @code{Parameter.__init__} is invoked; subsequent changes
13734 +@defivar Parameter value
13735 +The @code{value} attribute holds the underlying value of the
13736 +parameter. It can be read and assigned to just as any other
13737 +attribute. @value{GDBN} does validation when assignments are made.
13741 +When a new parameter is defined, its type must be specified. The
13742 +available types are represented by constants defined in the @code{gdb}
13746 +@findex PARAM_BOOLEAN
13747 +@findex gdb.PARAM_BOOLEAN
13748 +@item PARAM_BOOLEAN
13749 +The value is a plain boolean. The Python boolean values, @code{True}
13750 +and @code{False} are the only valid values.
13752 +@findex PARAM_AUTO_BOOLEAN
13753 +@findex gdb.PARAM_AUTO_BOOLEAN
13754 +@item PARAM_AUTO_BOOLEAN
13755 +The value has three possible states: true, false, and @samp{auto}. In
13756 +Python, true and false are represented using boolean constants, and
13757 +@samp{auto} is represented using @code{None}.
13759 +@findex PARAM_UINTEGER
13760 +@findex gdb.PARAM_UINTEGER
13761 +@item PARAM_UINTEGER
13762 +The value is an unsigned integer. The value of 0 should be
13763 +interpreted to mean ``unlimited''.
13765 +@findex PARAM_INTEGER
13766 +@findex gdb.PARAM_INTEGER
13767 +@item PARAM_INTEGER
13768 +The value is a signed integer. The value of 0 should be interpreted
13769 +to mean ``unlimited''.
13771 +@findex PARAM_STRING
13772 +@findex gdb.PARAM_STRING
13773 +@item PARAM_STRING
13774 +The value is a string. When the user modifies the string, escapes are
13777 +@findex PARAM_STRING_NOESCAPE
13778 +@findex gdb.PARAM_STRING_NOESCAPE
13779 +@item PARAM_STRING_NOESCAPE
13780 +The value is a string. When the user modifies the string, escapes are
13781 +passed through untranslated.
13783 +@findex PARAM_OPTIONAL_FILENAME
13784 +@findex gdb.PARAM_OPTIONAL_FILENAME
13785 +@item PARAM_OPTIONAL_FILENAME
13786 +The value is a either a filename (a string), or @code{None}.
13788 +@findex PARAM_FILENAME
13789 +@findex gdb.PARAM_FILENAME
13790 +@item PARAM_FILENAME
13791 +The value is a filename (a string).
13793 +@findex PARAM_ZINTEGER
13794 +@findex gdb.PARAM_ZINTEGER
13795 +@item PARAM_ZINTEGER
13796 +The value is an integer. This is like @code{PARAM_INTEGER}, except 0
13797 +is interpreted as itself.
13799 +@findex PARAM_ENUM
13800 +@findex gdb.PARAM_ENUM
13802 +The value is a string, which must be one of a collection string
13803 +constants provided when the parameter is created.
13806 +@node Functions In Python
13807 +@subsubsection Writing new convenience functions
13809 +@cindex writing convenience functions
13810 +@cindex convenience functions in python
13811 +@cindex python convenience functions
13812 +@tindex gdb.Function
13814 +You can implement new convenience functions (@pxref{Convenience Vars})
13815 +in Python. A convenience function is an instance of a subclass of the
13816 +class @code{gdb.Function}.
13818 +@defmethod Function __init__ name
13819 +The initializer for @code{Function} registers the new function with
13820 +@value{GDBN}. The argument @var{name} is the name of the function,
13821 +a string. The function will be visible to the user as a convenience
13822 +variable of type @code{internal function}, whose name is the same as
13823 +the given @var{name}.
13825 +The documentation for the new function is taken from the documentation
13826 +string for the new class.
13829 +@defmethod Function invoke @var{*args}
13830 +When a convenience function is evaluated, its arguments are converted
13831 +to instances of @code{gdb.Value}, and then the function's
13832 +@code{invoke} method is called. Note that @value{GDBN} does not
13833 +predetermine the arity of convenience functions. Instead, all
13834 +available arguments are passed to @code{invoke}, following the
13835 +standard Python calling convention. In particular, a convenience
13836 +function can have default values for parameters without ill effect.
13838 +The return value of this method is used as its value in the enclosing
13839 +expression. If an ordinary Python value is returned, it is converted
13840 +to a @code{gdb.Value} following the usual rules.
13843 +The following code snippet shows how a trivial convenience function can
13844 +be implemented in Python:
13847 +class Greet (gdb.Function):
13848 + """Return string to greet someone.
13849 +Takes a name as argument."""
13851 + def __init__ (self):
13852 + super (Greet, self).__init__ ("greet")
13854 + def invoke (self, name):
13855 + return "Hello, %s!" % name.string ()
13860 +The last line instantiates the class, and is necessary to trigger the
13861 +registration of the function with @value{GDBN}. Depending on how the
13862 +Python code is read into @value{GDBN}, you may need to import the
13863 +@code{gdb} module explicitly.
13865 +@node Objfiles In Python
13866 +@subsubsection Objfiles In Python
13868 +@cindex objfiles in python
13869 +@cindex python objfiles
13870 +@tindex gdb.Objfile
13872 +@value{GDBN} loads symbols for an inferior from various
13873 +symbol-containing files. These include the primary executable file,
13874 +any shared libraries used by the inferior, and any separate debug info
13875 +files. @value{GDBN} calls these symbol-containing files
13878 +Each objfile is represented by an instance of the @code{gdb.Objfile}
13881 +@defivar Objfile filename
13882 +The file name of the objfile as a string.
13885 +@defivar Objfile pretty_printers
13886 +The @code{pretty_printers} attribute is used to look up
13887 +pretty-printers by type. This is a dictionary which maps regular
13888 +expressions (strings) to pretty-printing objects. @xref{Pretty
13889 +Printing}, for more information.
13892 +@node Breakpoints In Python
13893 +@subsubsection Manipulating breakpoints using Python
13895 +@cindex breakpoints in python
13896 +@cindex python breakpoints
13897 +@tindex gdb.Breakpoint
13898 +@tindex Breakpoint
13899 +Python code can manipulate breakpoints via the @code{gdb.Breakpoint}
13902 +@defmethod Breakpoint __init__ location
13903 +Create a new breakpoint. @var{location} is a string naming the
13904 +location of the breakpoint. The contents can be any location
13905 +recognized by the @code{break} command.
13908 +@defmethod Breakpoint is_valid
13909 +Return @code{True} if this @code{Breakpoint} object is valid,
13910 +@code{False} otherwise. A @code{Breakpoint} object can become invalid
13911 +if the user deletes the breakpoint. In this case, the object still
13912 +exists, but the underlying breakpoint does not.
13915 +@defivar Breakpoint enabled
13916 +This attribute is @code{True} if the breakpoint is enabled, and
13917 +@code{False} otherwise. This attribute is writable.
13920 +@defivar Breakpoint silent
13921 +This attribute is @code{True} if the breakpoint is silent, and
13922 +@code{False} otherwise. This attribute is writable.
13924 +Note that a breakpoint can also be silent if it has commands and the
13925 +first command is @code{silent}. This is not reported by the
13926 +@code{silent} attribute.
13929 +@defivar Breakpoint thread
13930 +If the breakpoint is thread-specific, this attribute holds the thread
13931 +id. If the breakpoint is not thread-specific, this attribute is
13932 +@code{None}. This attribute is writable.
13935 +@defivar Breakpoint ignore_count
13936 +This attribute holds the ignore count for the breakpoint, an integer.
13937 +This attribute is writable.
13940 +@defivar Breakpoint number
13941 +This attribute holds the breakpoint's number -- the identifier used by
13942 +the user to manipulate the breakpoint. This attribute is not writable.
13945 +@defivar Breakpoint hit_count
13946 +This attribute holds the hit count for the breakpoint, an integer.
13947 +This attribute is writable, but currently it can only be set to zero.
13950 +@defivar Breakpoint location
13951 +This attribute holds the location of the breakpoint, as specified by
13952 +the user. It is a string. This attribute is not writable.
13955 +@defivar Breakpoint condition
13956 +This attribute holds the condition of the breakpoint, as specified by
13957 +the user. It is a string. If there is no condition, this attribute's
13958 +value is @code{None}. This attribute is writable.
13961 +@defivar Breakpoint commands
13962 +This attribute holds the commands attached to the breakpoint. If
13963 +there are commands, this returns a string holding all the commands,
13964 +separated by newlines. If there are no commands, this attribute is
13965 +@code{None}. This attribute is not writable.
13968 +@node Frames In Python
13969 +@subsubsection Accessing inferior stack frames from Python.
13971 +@cindex frames in python
13974 +When the debugged program stops, @value{GDBN} is able to analyse its call
13975 +stack (@pxref{Frames,,Stack frames}). The @code{gdb.Frame} class
13976 +represents a frame in the stack. You can get a tuple containing all the
13977 +frames in the stack with the @code{gdb.frames} function, the newest
13978 +frame with the @code{gdb.newest_frame} function, and the selected frame
13979 +with the @code{gdb.selected_frame} function
13980 +(see @xref{Selection,,Selecting a Frame}.) See
13981 +@xref{Basic Python,,Basic Python}.
13983 +A @code{gdb.Frame} object has the following methods:
13986 +@defmethod Frame equals @code{frame}
13990 +@defmethod Frame is_valid
13991 +Returns true if the @code{gdb.Frame} object is valid, false if not.
13992 +A frame object can become invalid if the frame it refers to doesn't
13993 +exist anymore in the inferior. All @code{gdb.Frame} methods will throw
13994 +an exception if it is invalid at the time the method call is made.
13997 +@defmethod Frame name
13998 +Returns the function name of the frame, or @code{None} if it can't be
14002 +@defmethod Frame type
14003 +Returns the type of the frame. The value can be one of
14004 +@code{gdb.NORMAL_FRAME}, @code{gdb.DUMMY_FRAME}, @code{gdb.SIGTRAMP_FRAME}
14005 +or @code{gdb.SENTINEL_FRAME}.
14008 +@defmethod Frame unwind_stop_reason
14009 +Return an integer representing the reason why it's not possible to find
14010 +frames older than this. Use @code{gdb.frame_stop_reason_string} to convert
14011 +the value returned by this function to a string.
14014 +@defmethod Frame pc
14015 +Returns the frame's resume address.
14018 +@defmethod Frame block
14019 +Returns the frame's code block. @c (see @xref{Block,,Code Blocks and Scopes}).
14022 +@defmethod Frame address_in_block
14023 +Returns an address which falls within the frame's code block.
14026 +@defmethod Frame older
14027 +Return the frame immediately older (outer) to this frame.
14030 +@defmethod Frame newer
14031 +Return the frame immediately newer (inner) to this frame.
14034 +@defmethod Frame find_sal
14035 +Return the frame's symtab and line object. @c (see @xref{Symtab_and_line,, Symtab and line}).
14038 +@defmethod Frame read_var @var{variable}
14039 +Return the value of the given variable in this frame. @code{variable} can be
14040 +either a string or a @code{gdb.Symbol} object. @c (@pxref{Symbols In Python}).
14045 @chapter Command Interpreters
14046 @cindex command interpreters
14047 @@ -22273,6 +23463,103 @@ Unfreezing a variable does not update it, only subsequent
14051 +@subheading The @code{-var-set-visualizer} command
14052 +@findex -var-set-visualizer
14053 +@anchor{-var-set-visualizer}
14055 +@subsubheading Synopsis
14058 + -var-set-visualizer @var{name} @var{visualizer}
14061 +@subheading The @code{-var-set-child-range} command
14062 +@findex -var-set-child-range
14063 +@anchor{-var-set-child-range}
14065 +Set a visualizer for the variable object @var{name}.
14067 +@var{visualizer} is the visualizer to use. The special value
14068 +@samp{None} means to disable any visualizer in use.
14070 +If not @samp{None}, @var{visualizer} must be a Python expression.
14071 +This expression must evaluate to a callable object which accepts a
14072 +single argument. @value{GDBN} will call this object with the value of
14073 +the varobj @var{name} as an argument. This function must return an
14074 +object which conforms to the pretty-printing interface (@pxref{Pretty
14077 +The pre-defined function @code{gdb.default_visualizer} may be used
14078 +to select a visualizer according to the type of the varobj. This is
14079 +called when a varobj is created, and so ordinarily is not needed.
14081 +@code{gdb.default_visualizer} looks in the global dictionary named
14082 +@code{gdb.pretty_printers}.
14084 +This feature is only available if Python support is enabled.
14086 +@subsubheading Example
14088 +Resetting the visualizer:
14092 +-var-set-visualizer V None
14096 +Reselecting the default (type-based) visualizer:
14100 +-var-set-visualizer V gdb.default_visualizer
14104 +Suppose @code{SomeClass} is a visualizer class. A lambda expression
14105 +can be used to instantiate this class for a varobj:
14109 +-var-set-visualizer V "lambda val: SomeClass()"
14113 +@subsubheading Synopsis
14116 + -var-set-child-range @var{name} @var{from} @var{to}
14119 +Select a sub-range of the children of the variable object @var{name};
14120 +future calls to @code{-var-list-children} will only report the
14121 +selected range of children. This allows an MI consumer to avoid
14122 +inefficiencies if the varobj has very many children.
14124 +If either @var{from} or @var{to} is less than zero, then sub-range
14125 +selection is disabled, and @code{-var-list-children} will report all
14128 +Otherwise, @var{from} and @var{to} are indexes into the array of
14129 +children. Children starting at @var{from} and stopping jsut before
14130 +@var{to} will be reported.
14132 +@subsubheading Example
14136 + -var-list-children n
14137 + ^done,numchild=3,children=[@{name="a",numchild=0,type="int"@},
14138 + @{name="b",numchild=0,type="int"@},
14139 + @{name="c",numchild=0,type="int"@}]
14141 + -var-set-child-range n 1 2
14143 + -var-list-children n
14144 + ^done,numchild=3,children=[@{name="b",numchild=0,type="int"@},
14145 + @{name="c",numchild=0,type="int"@}]
14149 @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14150 @node GDB/MI Data Manipulation
14151 @@ -23832,6 +25119,10 @@ as possible presense of the @code{frozen} field in the output
14152 of @code{-varobj-create}.
14153 @item pending-breakpoints
14154 Indicates presence of the @option{-f} option to the @code{-break-insert} command.
14156 +Indicates presence of Python scripting support, Python-based
14157 +pretty-printing commands, and possible presence of the
14158 +@samp{display_hint} field in the output of @code{-var-list-children}
14160 Indicates presence of the @code{-thread-info} command.
14162 @@ -25402,28 +26693,6 @@ data in a @file{gmon.out} file, be sure to move it to a safe location.
14163 Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
14164 compiled with the @samp{-pg} compiler option.
14166 -@kindex maint set linux-async
14167 -@kindex maint show linux-async
14168 -@cindex asynchronous support
14169 -@item maint set linux-async
14170 -@itemx maint show linux-async
14171 -Control the GNU/Linux native asynchronous support
14172 -(@pxref{Background Execution}) of @value{GDBN}.
14174 -GNU/Linux native asynchronous support will be disabled until you use
14175 -the @samp{maint set linux-async} command to enable it.
14177 -@kindex maint set remote-async
14178 -@kindex maint show remote-async
14179 -@cindex asynchronous support
14180 -@item maint set remote-async
14181 -@itemx maint show remote-async
14182 -Control the remote asynchronous support
14183 -(@pxref{Background Execution}) of @value{GDBN}.
14185 -Remote asynchronous support will be disabled until you use
14186 -the @samp{maint set remote-async} command to enable it.
14188 @kindex maint show-debug-regs
14189 @cindex x86 hardware debug registers
14190 @item maint show-debug-regs
14191 diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
14192 index ce11d89..eaa6a13 100644
14193 --- a/gdb/dwarf2-frame.c
14194 +++ b/gdb/dwarf2-frame.c
14197 #include "complaints.h"
14198 #include "dwarf2-frame.h"
14199 +#include "addrmap.h"
14203 @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
14204 struct dwarf2_fde *fde;
14207 + if (objfile->quick_addrmap)
14209 + if (!addrmap_find (objfile->quick_addrmap, *pc))
14212 + /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info? */
14213 + require_partial_symbols (objfile);
14215 fde = objfile_data (objfile, dwarf2_frame_objfile_data);
14218 diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
14219 index 75a4ec7..aa8ab33 100644
14220 --- a/gdb/dwarf2expr.c
14221 +++ b/gdb/dwarf2expr.c
14222 @@ -752,6 +752,13 @@ execute_stack_op (struct dwarf_expr_context *ctx,
14223 ctx->initialized = 0;
14226 + case DW_OP_push_object_address:
14227 + if (ctx->get_object_address == NULL)
14228 + error (_("DWARF-2 expression error: DW_OP_push_object_address must "
14229 + "have a value to push."));
14230 + result = (ctx->get_object_address) (ctx->baton);
14234 error (_("Unhandled dwarf expression opcode 0x%x"), op);
14236 diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
14237 index 7047922..a287b6f 100644
14238 --- a/gdb/dwarf2expr.h
14239 +++ b/gdb/dwarf2expr.h
14240 @@ -67,10 +67,10 @@ struct dwarf_expr_context
14241 The result must be live until the current expression evaluation
14243 unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length);
14246 /* Return the `object address' for DW_OP_push_object_address. */
14247 CORE_ADDR (*get_object_address) (void *baton);
14250 /* The current depth of dwarf expression recursion, via DW_OP_call*,
14251 DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum
14252 diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
14253 index cad3db8..2251e48 100644
14254 --- a/gdb/dwarf2loc.c
14255 +++ b/gdb/dwarf2loc.c
14256 @@ -107,6 +107,9 @@ struct dwarf_expr_baton
14258 struct frame_info *frame;
14259 struct objfile *objfile;
14260 + /* From DW_TAG_variable's DW_AT_location (not DW_TAG_type's
14261 + DW_AT_data_location) for DW_OP_push_object_address. */
14262 + CORE_ADDR object_address;
14265 /* Helper functions for dwarf2_evaluate_loc_desc. */
14266 @@ -163,22 +166,32 @@ dwarf_expr_frame_base (void *baton, gdb_byte **start, size_t * length)
14267 *start = find_location_expression (symbaton, length,
14268 get_frame_address_in_block (frame));
14271 + else if (SYMBOL_OPS (framefunc) == &dwarf2_locexpr_funcs)
14273 struct dwarf2_locexpr_baton *symbaton;
14275 symbaton = SYMBOL_LOCATION_BATON (framefunc);
14276 - if (symbaton != NULL)
14278 - *length = symbaton->size;
14279 - *start = symbaton->data;
14283 + gdb_assert (symbaton != NULL);
14284 + *start = symbaton->data;
14285 + *length = symbaton->size;
14287 + else if (SYMBOL_OPS (framefunc) == &dwarf2_missing_funcs)
14289 + struct dwarf2_locexpr_baton *symbaton;
14291 + symbaton = SYMBOL_LOCATION_BATON (framefunc);
14292 + gdb_assert (symbaton == NULL);
14294 + *length = 0; /* unused */
14297 + internal_error (__FILE__, __LINE__,
14298 + _("Unsupported SYMBOL_OPS %p for \"%s\""),
14299 + SYMBOL_OPS (framefunc), SYMBOL_PRINT_NAME (framefunc));
14301 if (*start == NULL)
14302 error (_("Could not find the frame base for \"%s\"."),
14303 - SYMBOL_NATURAL_NAME (framefunc));
14304 + SYMBOL_PRINT_NAME (framefunc));
14307 /* Using the objfile specified in BATON, find the address for the
14308 @@ -191,6 +204,119 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset)
14309 return target_translate_tls_address (debaton->objfile, offset);
14313 +dwarf_expr_object_address (void *baton)
14315 + struct dwarf_expr_baton *debaton = baton;
14317 + /* The message is suppressed in DWARF_BLOCK_EXEC. */
14318 + if (debaton->object_address == 0)
14319 + error (_("Cannot resolve DW_OP_push_object_address for a missing object"));
14321 + return debaton->object_address;
14324 +/* Address of the variable we are currently referring to. It is set from
14325 + DW_TAG_variable's DW_AT_location (not DW_TAG_type's DW_AT_data_location) for
14326 + DW_OP_push_object_address. */
14328 +static CORE_ADDR object_address;
14330 +/* Callers use object_address_set while their callers use the result set so we
14331 + cannot run the cleanup at the local block of our direct caller. Still we
14332 + should reset OBJECT_ADDRESS at least for the next GDB command. */
14335 +object_address_cleanup (void *prev_save_voidp)
14337 + CORE_ADDR *prev_save = prev_save_voidp;
14339 + object_address = *prev_save;
14340 + xfree (prev_save);
14343 +/* Set the base address - DW_AT_location - of a variable. It is being later
14344 + used to derive other object addresses by DW_OP_push_object_address.
14346 + It would be useful to sanity check ADDRESS - such as for some objects with
14347 + unset VALUE_ADDRESS - but some valid addresses may be zero (such as first
14348 + objects in relocatable .o files). */
14351 +object_address_set (CORE_ADDR address)
14353 + CORE_ADDR *prev_save;
14355 + prev_save = xmalloc (sizeof *prev_save);
14356 + *prev_save = object_address;
14357 + make_cleanup (object_address_cleanup, prev_save);
14359 + object_address = address;
14362 +/* Evaluate DWARF expression at DATA ... DATA + SIZE with its result readable
14363 + by dwarf_expr_fetch (RETVAL, 0). FRAME parameter can be NULL to call
14364 + get_selected_frame to find it. Returned dwarf_expr_context freeing is
14365 + pushed on the cleanup chain. */
14367 +static struct dwarf_expr_context *
14368 +dwarf_expr_prep_ctx (struct frame_info *frame, gdb_byte *data,
14369 + unsigned short size, struct dwarf2_per_cu_data *per_cu)
14371 + struct dwarf_expr_context *ctx;
14372 + struct dwarf_expr_baton baton;
14375 + frame = get_selected_frame (NULL);
14377 + baton.frame = frame;
14378 + baton.objfile = dwarf2_per_cu_objfile (per_cu);
14379 + baton.object_address = object_address;
14381 + ctx = new_dwarf_expr_context ();
14382 + ctx->gdbarch = get_objfile_arch (baton.objfile);
14383 + ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
14384 + ctx->baton = &baton;
14385 + ctx->read_reg = dwarf_expr_read_reg;
14386 + ctx->read_mem = dwarf_expr_read_mem;
14387 + ctx->get_frame_base = dwarf_expr_frame_base;
14388 + ctx->get_tls_address = dwarf_expr_tls_address;
14389 + ctx->get_object_address = dwarf_expr_object_address;
14391 + make_cleanup ((make_cleanup_ftype *) free_dwarf_expr_context, ctx);
14393 + dwarf_expr_eval (ctx, data, size);
14395 + /* It was used only during dwarf_expr_eval. */
14396 + ctx->baton = NULL;
14401 +/* Evaluate DWARF expression at DLBATON expecting it produces exactly one
14402 + CORE_ADDR result on the DWARF stack stack. */
14405 +dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton)
14407 + struct dwarf_expr_context *ctx;
14408 + CORE_ADDR retval;
14409 + struct cleanup *back_to = make_cleanup (null_cleanup, 0);
14411 + ctx = dwarf_expr_prep_ctx (NULL, dlbaton->data, dlbaton->size,
14412 + dlbaton->per_cu);
14413 + if (ctx->num_pieces > 0)
14414 + error (_("DW_OP_*piece is unsupported for DW_FORM_block"));
14415 + else if (ctx->in_reg)
14416 + error (_("Register result is unsupported for DW_FORM_block"));
14418 + retval = dwarf_expr_fetch (ctx, 0);
14420 + do_cleanups (back_to);
14425 /* Evaluate a location description, starting at DATA and with length
14426 SIZE, to find the current location of variable VAR in the context
14428 @@ -200,8 +326,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14429 struct dwarf2_per_cu_data *per_cu)
14431 struct value *retval;
14432 - struct dwarf_expr_baton baton;
14433 struct dwarf_expr_context *ctx;
14434 + struct cleanup *back_to = make_cleanup (null_cleanup, 0);
14438 @@ -211,19 +337,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14442 - baton.frame = frame;
14443 - baton.objfile = dwarf2_per_cu_objfile (per_cu);
14444 + ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
14446 - ctx = new_dwarf_expr_context ();
14447 - ctx->gdbarch = get_objfile_arch (baton.objfile);
14448 - ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
14449 - ctx->baton = &baton;
14450 - ctx->read_reg = dwarf_expr_read_reg;
14451 - ctx->read_mem = dwarf_expr_read_mem;
14452 - ctx->get_frame_base = dwarf_expr_frame_base;
14453 - ctx->get_tls_address = dwarf_expr_tls_address;
14455 - dwarf_expr_eval (ctx, data, size);
14456 if (ctx->num_pieces > 0)
14459 @@ -261,15 +376,19 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14461 CORE_ADDR address = dwarf_expr_fetch (ctx, 0);
14463 + /* object_address_set called here is required in ALLOCATE_VALUE's
14464 + CHECK_TYPEDEF for the object's possible DW_OP_push_object_address. */
14465 + object_address_set (address);
14467 retval = allocate_value (SYMBOL_TYPE (var));
14468 VALUE_LVAL (retval) = lval_memory;
14469 set_value_lazy (retval, 1);
14470 - VALUE_ADDRESS (retval) = address;
14471 + set_value_address (retval, address);
14474 set_value_initialized (retval, ctx->initialized);
14476 - free_dwarf_expr_context (ctx);
14477 + do_cleanups (back_to);
14481 @@ -587,7 +706,7 @@ static int
14482 loclist_describe_location (struct symbol *symbol, struct ui_file *stream)
14484 /* FIXME: Could print the entire list of locations. */
14485 - fprintf_filtered (stream, "a variable with multiple locations");
14486 + fprintf_filtered (stream, _("a variable with multiple locations"));
14490 @@ -603,16 +722,56 @@ loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
14492 data = find_location_expression (dlbaton, &size, ax->scope);
14494 - error (_("Variable \"%s\" is not available."), SYMBOL_NATURAL_NAME (symbol));
14495 + error (_("Variable \"%s\" is not available."), SYMBOL_PRINT_NAME (symbol));
14497 dwarf2_tracepoint_var_ref (symbol, ax, value, data, size);
14500 -/* The set of location functions used with the DWARF-2 expression
14501 - evaluator and location lists. */
14502 +/* The set of location functions used with the DWARF-2 location lists. */
14503 const struct symbol_ops dwarf2_loclist_funcs = {
14504 loclist_read_variable,
14505 loclist_read_needs_frame,
14506 loclist_describe_location,
14507 loclist_tracepoint_var_ref
14510 +static struct value *
14511 +missing_read_variable (struct symbol *symbol, struct frame_info *frame)
14513 + struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
14515 + gdb_assert (dlbaton == NULL);
14516 + error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
14520 +missing_read_needs_frame (struct symbol *symbol)
14526 +missing_describe_location (struct symbol *symbol, struct ui_file *stream)
14528 + fprintf_filtered (stream, _("a variable we are unable to resolve"));
14533 +missing_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
14534 + struct axs_value *value)
14536 + struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
14538 + gdb_assert (dlbaton == NULL);
14539 + error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
14542 +/* The set of location functions used with the DWARF-2 evaluator when we are
14543 + unable to resolve the symbols. */
14544 +const struct symbol_ops dwarf2_missing_funcs = {
14545 + missing_read_variable,
14546 + missing_read_needs_frame,
14547 + missing_describe_location,
14548 + missing_tracepoint_var_ref
14550 diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
14551 index 76577f1..bf46761 100644
14552 --- a/gdb/dwarf2loc.h
14553 +++ b/gdb/dwarf2loc.h
14554 @@ -71,5 +71,11 @@ struct dwarf2_loclist_baton
14556 extern const struct symbol_ops dwarf2_locexpr_funcs;
14557 extern const struct symbol_ops dwarf2_loclist_funcs;
14558 +extern const struct symbol_ops dwarf2_missing_funcs;
14560 +extern void object_address_set (CORE_ADDR address);
14562 +extern CORE_ADDR dwarf_locexpr_baton_eval
14563 + (struct dwarf2_locexpr_baton *dlbaton);
14565 #endif /* dwarf2loc.h */
14566 diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
14567 index 55868da..71fed38 100644
14568 --- a/gdb/dwarf2read.c
14569 +++ b/gdb/dwarf2read.c
14571 /* DWARF 2 debugging format support for GDB.
14573 Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
14574 - 2004, 2005, 2006, 2007, 2008, 2009
14575 - Free Software Foundation, Inc.
14576 + 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
14578 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
14579 Inc. with support from Florida State University (under contract
14581 #include "command.h"
14582 #include "gdbcmd.h"
14583 #include "addrmap.h"
14584 +#include "f-lang.h"
14585 +#include "c-lang.h"
14586 +#include "typeprint.h"
14589 #include "gdb_string.h"
14590 @@ -103,7 +105,7 @@ typedef struct pubnames_header
14592 #define _ACTUAL_PUBNAMES_HEADER_SIZE 13
14594 -/* .debug_pubnames header
14595 +/* .debug_aranges header
14596 Because of alignment constraints, this structure has padding and cannot
14597 be mapped directly onto the beginning of the .debug_info section. */
14598 typedef struct aranges_header
14599 @@ -299,9 +301,6 @@ struct dwarf2_cu
14600 /* Hash table holding all the loaded partial DIEs. */
14601 htab_t partial_dies;
14603 - /* `.debug_ranges' offset for this `DW_TAG_compile_unit' DIE. */
14604 - unsigned int ranges_offset;
14606 /* Storage for things with the same lifetime as this read-in compilation
14607 unit, including partial DIEs. */
14608 struct obstack comp_unit_obstack;
14609 @@ -349,9 +348,6 @@ struct dwarf2_cu
14610 DIEs for namespaces, we don't need to try to infer them
14611 from mangled names. */
14612 unsigned int has_namespace_info : 1;
14614 - /* Field `ranges_offset' is filled in; flag as the value may be zero. */
14615 - unsigned int has_ranges_offset : 1;
14618 /* Persistent data held for a compilation unit, even when not
14619 @@ -451,17 +447,12 @@ struct partial_die_info
14620 /* DWARF-2 tag for this DIE. */
14621 ENUM_BITFIELD(dwarf_tag) tag : 16;
14623 - /* Language code associated with this DIE. This is only used
14624 - for the compilation unit DIE. */
14625 - unsigned int language : 8;
14627 /* Assorted flags describing the data found in this DIE. */
14628 unsigned int has_children : 1;
14629 unsigned int is_external : 1;
14630 unsigned int is_declaration : 1;
14631 unsigned int has_type : 1;
14632 unsigned int has_specification : 1;
14633 - unsigned int has_stmt_list : 1;
14634 unsigned int has_pc_info : 1;
14636 /* Flag set if the SCOPE field of this structure has been
14637 @@ -472,10 +463,12 @@ struct partial_die_info
14638 unsigned int has_byte_size : 1;
14640 /* The name of this DIE. Normally the value of DW_AT_name, but
14641 - sometimes DW_TAG_MIPS_linkage_name or a string computed in some
14642 - other fashion. */
14643 + sometimes a default name for unnamed DIEs. */
14647 + /* The linkage name of this DIE, from DW_AT_MIPS_linkage_name, or
14648 + NULL if no linkage name was present. */
14649 + char *linkage_name;
14651 /* The scope to prepend to our children. This is generally
14652 allocated on the comp_unit_obstack, so will disappear
14653 @@ -498,9 +491,6 @@ struct partial_die_info
14654 DW_AT_extension). */
14655 unsigned int spec_offset;
14657 - /* If HAS_STMT_LIST, the offset of the Line Number Information data. */
14658 - unsigned int line_offset;
14660 /* Pointers to this DIE's parent, first child, and next sibling,
14662 struct partial_die_info *die_parent, *die_child, *die_sibling;
14663 @@ -523,6 +513,15 @@ struct attr_abbrev
14664 ENUM_BITFIELD(dwarf_form) form : 16;
14667 +/* Additional GDB-specific attribute forms. */
14670 + /* A string which has been updated to GDB's internal
14671 + representation (e.g. converted to canonical form) and does not
14672 + need to be updated again. */
14673 + GDB_FORM_cached_string = 0xff
14676 /* Attributes have a name and a value */
14679 @@ -756,7 +755,7 @@ static void dwarf2_create_include_psymtab (char *, struct partial_symtab *,
14682 static void dwarf2_build_include_psymtabs (struct dwarf2_cu *,
14683 - struct partial_die_info *,
14684 + struct die_info *,
14685 struct partial_symtab *);
14687 static void dwarf2_build_psymtabs_hard (struct objfile *, int);
14688 @@ -768,6 +767,9 @@ static void scan_partial_symbols (struct partial_die_info *,
14689 static void add_partial_symbol (struct partial_die_info *,
14690 struct dwarf2_cu *);
14692 +static gdb_byte *read_comp_unit_head (struct comp_unit_head *, gdb_byte *,
14695 static int pdi_needs_namespace (enum dwarf_tag tag);
14697 static void add_partial_namespace (struct partial_die_info *pdi,
14698 @@ -794,6 +796,10 @@ static void dwarf2_psymtab_to_symtab (struct partial_symtab *);
14700 static void psymtab_to_symtab_1 (struct partial_symtab *);
14702 +static gdb_byte *dwarf2_read_section_1 (struct objfile *objfile,
14703 + struct obstack *obstack,
14704 + asection *sectp);
14706 gdb_byte *dwarf2_read_section (struct objfile *, asection *);
14708 static void dwarf2_read_abbrevs (bfd *abfd, struct dwarf2_cu *cu);
14709 @@ -929,7 +935,8 @@ static int dwarf2_ranges_read (unsigned, CORE_ADDR *, CORE_ADDR *,
14710 struct dwarf2_cu *, struct partial_symtab *);
14712 static int dwarf2_get_pc_bounds (struct die_info *,
14713 - CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *);
14714 + CORE_ADDR *, CORE_ADDR *, struct dwarf2_cu *,
14715 + struct partial_symtab *pst);
14717 static void get_scope_pc_bounds (struct die_info *,
14718 CORE_ADDR *, CORE_ADDR *,
14719 @@ -962,6 +969,8 @@ static void read_namespace (struct die_info *die, struct dwarf2_cu *);
14721 static void read_module (struct die_info *die, struct dwarf2_cu *cu);
14723 +static void read_import_statement (struct die_info *die, struct dwarf2_cu *);
14725 static const char *namespace_name (struct die_info *die,
14726 int *is_anonymous, struct dwarf2_cu *);
14728 @@ -993,6 +1002,9 @@ static void process_die (struct die_info *, struct dwarf2_cu *);
14730 static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *);
14732 +static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *,
14733 + struct obstack *);
14735 static char *dwarf2_name (struct die_info *die, struct dwarf2_cu *);
14737 static struct die_info *dwarf2_extension (struct die_info *die,
14738 @@ -1030,7 +1042,14 @@ static void store_in_ref_table (struct die_info *,
14740 static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
14742 -static int dwarf2_get_attr_constant_value (struct attribute *, int);
14743 +enum dwarf2_get_attr_constant_value
14745 + dwarf2_attr_unknown,
14746 + dwarf2_attr_const,
14747 + dwarf2_attr_block
14749 +static enum dwarf2_get_attr_constant_value dwarf2_get_attr_constant_value
14750 + (struct attribute *attr, int *val_return);
14752 static struct die_info *follow_die_ref (struct die_info *,
14753 struct attribute *,
14754 @@ -1085,6 +1104,9 @@ static void age_cached_comp_units (void);
14756 static void free_one_cached_comp_unit (void *);
14758 +static void fetch_die_type_attrs (struct die_info *die, struct type *type,
14759 + struct dwarf2_cu *cu);
14761 static struct type *set_die_type (struct die_info *, struct type *,
14762 struct dwarf2_cu *);
14764 @@ -1104,19 +1126,28 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
14766 static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
14768 +static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
14769 + (struct attribute *attr, struct dwarf2_cu *cu);
14771 /* Try to locate the sections we need for DWARF 2 debugging
14772 information and return true if we have enough to do something. */
14775 dwarf2_has_info (struct objfile *objfile)
14777 - struct dwarf2_per_objfile *data;
14778 + int update_sizes = 0;
14780 /* Initialize per-objfile state. */
14781 - data = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
14782 - memset (data, 0, sizeof (*data));
14783 - set_objfile_data (objfile, dwarf2_objfile_data_key, data);
14784 - dwarf2_per_objfile = data;
14785 + dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key);
14786 + if (!dwarf2_per_objfile)
14788 + struct dwarf2_per_objfile *data
14789 + = obstack_alloc (&objfile->objfile_obstack, sizeof (*data));
14790 + memset (data, 0, sizeof (*data));
14791 + set_objfile_data (objfile, dwarf2_objfile_data_key, data);
14792 + dwarf2_per_objfile = data;
14793 + update_sizes = 1;
14796 dwarf_info_section = 0;
14797 dwarf_abbrev_section = 0;
14798 @@ -1127,8 +1158,9 @@ dwarf2_has_info (struct objfile *objfile)
14799 dwarf_eh_frame_section = 0;
14800 dwarf_ranges_section = 0;
14801 dwarf_loc_section = 0;
14802 + dwarf_aranges_section = 0;
14804 - bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, NULL);
14805 + bfd_map_over_sections (objfile->obfd, dwarf2_locate_sections, &update_sizes);
14806 return (dwarf_info_section != NULL && dwarf_abbrev_section != NULL);
14809 @@ -1149,51 +1181,61 @@ section_is_p (asection *sectp, const char *name)
14813 -dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
14814 +dwarf2_locate_sections (bfd *abfd, asection *sectp, void *user_data)
14816 + int update_sizes = * (int *) user_data;
14817 if (section_is_p (sectp, INFO_SECTION))
14819 - dwarf2_per_objfile->info_size = bfd_get_section_size (sectp);
14820 + if (update_sizes)
14821 + dwarf2_per_objfile->info_size = bfd_get_section_size (sectp);
14822 dwarf_info_section = sectp;
14824 else if (section_is_p (sectp, ABBREV_SECTION))
14826 - dwarf2_per_objfile->abbrev_size = bfd_get_section_size (sectp);
14827 + if (update_sizes)
14828 + dwarf2_per_objfile->abbrev_size = bfd_get_section_size (sectp);
14829 dwarf_abbrev_section = sectp;
14831 else if (section_is_p (sectp, LINE_SECTION))
14833 - dwarf2_per_objfile->line_size = bfd_get_section_size (sectp);
14834 + if (update_sizes)
14835 + dwarf2_per_objfile->line_size = bfd_get_section_size (sectp);
14836 dwarf_line_section = sectp;
14838 else if (section_is_p (sectp, PUBNAMES_SECTION))
14840 - dwarf2_per_objfile->pubnames_size = bfd_get_section_size (sectp);
14841 + if (update_sizes)
14842 + dwarf2_per_objfile->pubnames_size = bfd_get_section_size (sectp);
14843 dwarf_pubnames_section = sectp;
14845 else if (section_is_p (sectp, ARANGES_SECTION))
14847 - dwarf2_per_objfile->aranges_size = bfd_get_section_size (sectp);
14848 + if (update_sizes)
14849 + dwarf2_per_objfile->aranges_size = bfd_get_section_size (sectp);
14850 dwarf_aranges_section = sectp;
14852 else if (section_is_p (sectp, LOC_SECTION))
14854 - dwarf2_per_objfile->loc_size = bfd_get_section_size (sectp);
14855 + if (update_sizes)
14856 + dwarf2_per_objfile->loc_size = bfd_get_section_size (sectp);
14857 dwarf_loc_section = sectp;
14859 else if (section_is_p (sectp, MACINFO_SECTION))
14861 - dwarf2_per_objfile->macinfo_size = bfd_get_section_size (sectp);
14862 + if (update_sizes)
14863 + dwarf2_per_objfile->macinfo_size = bfd_get_section_size (sectp);
14864 dwarf_macinfo_section = sectp;
14866 else if (section_is_p (sectp, STR_SECTION))
14868 - dwarf2_per_objfile->str_size = bfd_get_section_size (sectp);
14869 + if (update_sizes)
14870 + dwarf2_per_objfile->str_size = bfd_get_section_size (sectp);
14871 dwarf_str_section = sectp;
14873 else if (section_is_p (sectp, FRAME_SECTION))
14875 - dwarf2_per_objfile->frame_size = bfd_get_section_size (sectp);
14876 + if (update_sizes)
14877 + dwarf2_per_objfile->frame_size = bfd_get_section_size (sectp);
14878 dwarf_frame_section = sectp;
14880 else if (section_is_p (sectp, EH_FRAME_SECTION))
14881 @@ -1201,13 +1243,15 @@ dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
14882 flagword aflag = bfd_get_section_flags (ignore_abfd, sectp);
14883 if (aflag & SEC_HAS_CONTENTS)
14885 - dwarf2_per_objfile->eh_frame_size = bfd_get_section_size (sectp);
14886 + if (update_sizes)
14887 + dwarf2_per_objfile->eh_frame_size = bfd_get_section_size (sectp);
14888 dwarf_eh_frame_section = sectp;
14891 else if (section_is_p (sectp, RANGES_SECTION))
14893 - dwarf2_per_objfile->ranges_size = bfd_get_section_size (sectp);
14894 + if (update_sizes)
14895 + dwarf2_per_objfile->ranges_size = bfd_get_section_size (sectp);
14896 dwarf_ranges_section = sectp;
14899 @@ -1250,6 +1294,86 @@ dwarf2_resize_section (asection *sectp, bfd_size_type new_size)
14903 +/* A cleanup that frees an obstack. */
14905 +finalize_obstack (void *o)
14907 + struct obstack *ob = o;
14908 + obstack_free (o, 0);
14911 +/* Read the .debug_aranges section and construct an address map. */
14914 +dwarf2_create_quick_addrmap (struct objfile *objfile)
14916 + char *aranges_buffer, *aranges_ptr;
14917 + bfd *abfd = objfile->obfd;
14918 + CORE_ADDR baseaddr;
14919 + struct cleanup *old;
14920 + struct obstack temp_obstack;
14921 + struct addrmap *mutable_map;
14923 + if (!dwarf_aranges_section)
14926 + baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
14928 + aranges_buffer = dwarf2_read_section_1 (objfile, NULL, dwarf_aranges_section);
14929 + aranges_ptr = aranges_buffer;
14930 + old = make_cleanup (xfree, aranges_buffer);
14932 + obstack_init (&temp_obstack);
14933 + make_cleanup (finalize_obstack, &temp_obstack);
14934 + mutable_map = addrmap_create_mutable (&temp_obstack);
14936 + while ((aranges_ptr - aranges_buffer) < dwarf2_per_objfile->aranges_size)
14938 + struct comp_unit_head cu_header;
14939 + unsigned int bytes_read, segment_size, delta;
14940 + LONGEST info_offset;
14941 + struct dwarf2_cu cu;
14943 + cu_header.initial_length_size = 0;
14944 + aranges_ptr = read_comp_unit_head (&cu_header, aranges_ptr, abfd);
14946 + segment_size = read_1_byte (abfd, aranges_ptr);
14947 + aranges_ptr += 1;
14949 + /* Align the pointer to twice the pointer size. I didn't see
14950 + this in the spec but it appears to be required. */
14951 + delta = (aranges_ptr - aranges_buffer) % (2 * cu_header.addr_size);
14952 + delta = (2 * cu_header.addr_size - delta) % (2 * cu_header.addr_size);
14953 + aranges_ptr += delta;
14955 + memset (&cu, 0, sizeof (cu));
14956 + cu.header.addr_size = cu_header.addr_size;
14960 + CORE_ADDR address, length;
14962 + address = read_address (abfd, aranges_ptr, &cu, &bytes_read);
14963 + aranges_ptr += bytes_read;
14965 + length = read_address (abfd, aranges_ptr, &cu, &bytes_read);
14966 + aranges_ptr += bytes_read;
14968 + if (address == 0 && length == 0)
14971 + address += baseaddr;
14973 + addrmap_set_empty (mutable_map, address, address + length, objfile);
14977 + objfile->quick_addrmap = addrmap_create_fixed (mutable_map,
14978 + &objfile->objfile_obstack);
14979 + do_cleanups (old);
14983 /* Build a partial symbol table. */
14986 @@ -1453,22 +1577,24 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst,
14988 /* Read the Line Number Program data and extract the list of files
14989 included by the source file represented by PST. Build an include
14990 - partial symtab for each of these included files.
14992 - This procedure assumes that there *is* a Line Number Program in
14993 - the given CU. Callers should check that PDI->HAS_STMT_LIST is set
14994 - before calling this procedure. */
14995 + partial symtab for each of these included files. */
14998 dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
14999 - struct partial_die_info *pdi,
15000 + struct die_info *die,
15001 struct partial_symtab *pst)
15003 struct objfile *objfile = cu->objfile;
15004 bfd *abfd = objfile->obfd;
15005 - struct line_header *lh;
15006 + struct line_header *lh = NULL;
15007 + struct attribute *attr;
15009 - lh = dwarf_decode_line_header (pdi->line_offset, abfd, cu);
15010 + attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
15013 + unsigned int line_offset = DW_UNSND (attr);
15014 + lh = dwarf_decode_line_header (line_offset, abfd, cu);
15017 return; /* No linetable, so no includes. */
15019 @@ -1477,6 +1603,36 @@ dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
15020 free_line_header (lh);
15023 +/* Find the base address of the compilation unit for range lists and
15024 + location lists. It will normally be specified by DW_AT_low_pc.
15025 + In DWARF-3 draft 4, the base address could be overridden by
15026 + DW_AT_entry_pc. It's been removed, but GCC still uses this for
15027 + compilation units with discontinuous ranges. */
15030 +dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu)
15032 + struct attribute *attr;
15034 + cu->base_known = 0;
15035 + cu->base_address = 0;
15037 + attr = dwarf2_attr (die, DW_AT_entry_pc, cu);
15040 + cu->base_address = DW_ADDR (attr);
15041 + cu->base_known = 1;
15045 + attr = dwarf2_attr (die, DW_AT_low_pc, cu);
15048 + cu->base_address = DW_ADDR (attr);
15049 + cu->base_known = 1;
15054 /* Build the partial symbol table by doing a quick pass through the
15055 .debug_info and .debug_abbrev sections. */
15056 @@ -1489,7 +1645,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15057 bfd *abfd = objfile->obfd;
15058 gdb_byte *info_ptr;
15059 gdb_byte *beg_of_comp_unit;
15060 - struct partial_die_info comp_unit_die;
15061 + struct die_info *comp_unit_die;
15062 struct partial_symtab *pst;
15063 struct cleanup *back_to;
15064 CORE_ADDR baseaddr;
15065 @@ -1523,9 +1679,12 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15067 struct cleanup *back_to_inner;
15068 struct dwarf2_cu cu;
15069 - struct abbrev_info *abbrev;
15070 unsigned int bytes_read;
15071 struct dwarf2_per_cu_data *this_cu;
15072 + int has_children, has_pc_info;
15073 + struct attribute *attr;
15074 + const char *name;
15075 + CORE_ADDR best_lowpc, best_highpc;
15077 beg_of_comp_unit = info_ptr;
15079 @@ -1551,11 +1710,10 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15080 this_cu = dwarf2_find_comp_unit (cu.header.offset, objfile);
15082 /* Read the compilation unit die */
15083 - abbrev = peek_die_abbrev (info_ptr, &bytes_read, &cu);
15084 - info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
15085 - abfd, info_ptr, &cu);
15086 + info_ptr = read_full_die (&comp_unit_die, abfd, info_ptr, &cu,
15089 - if (comp_unit_die.tag == DW_TAG_partial_unit)
15090 + if (comp_unit_die->tag == DW_TAG_partial_unit)
15092 info_ptr = (beg_of_comp_unit + cu.header.length
15093 + cu.header.initial_length_size);
15094 @@ -1564,20 +1722,27 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15097 /* Set the language we're debugging */
15098 - set_cu_language (comp_unit_die.language, &cu);
15099 + attr = dwarf2_attr (comp_unit_die, DW_AT_language, &cu);
15100 + if (attr != NULL)
15101 + set_cu_language (DW_UNSND (attr), &cu);
15103 + set_cu_language (language_minimal, &cu);
15105 /* Allocate a new partial symbol table structure */
15106 - pst = start_psymtab_common (objfile, objfile->section_offsets,
15107 - comp_unit_die.name ? comp_unit_die.name : "",
15108 + attr = dwarf2_attr (comp_unit_die, DW_AT_name, &cu);
15109 + if (attr != NULL)
15110 + name = DW_STRING (attr);
15113 + pst = start_psymtab_common (objfile, objfile->section_offsets, name,
15114 /* TEXTLOW and TEXTHIGH are set below. */
15116 objfile->global_psymbols.next,
15117 objfile->static_psymbols.next);
15119 - if (comp_unit_die.dirname)
15120 - pst->dirname = obsavestring (comp_unit_die.dirname,
15121 - strlen (comp_unit_die.dirname),
15122 - &objfile->objfile_obstack);
15123 + attr = dwarf2_attr (comp_unit_die, DW_AT_comp_dir, &cu);
15124 + if (attr != NULL)
15125 + pst->dirname = xstrdup (DW_STRING (attr));
15127 pst->read_symtab_private = (char *) this_cu;
15129 @@ -1607,24 +1772,17 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15131 /* Possibly set the default values of LOWPC and HIGHPC from
15133 - if (cu.has_ranges_offset)
15135 - if (dwarf2_ranges_read (cu.ranges_offset, &comp_unit_die.lowpc,
15136 - &comp_unit_die.highpc, &cu, pst))
15137 - comp_unit_die.has_pc_info = 1;
15139 - else if (comp_unit_die.has_pc_info
15140 - && comp_unit_die.lowpc < comp_unit_die.highpc)
15141 - /* Store the contiguous range if it is not empty; it can be empty for
15142 - CUs with no code. */
15143 - addrmap_set_empty (objfile->psymtabs_addrmap,
15144 - comp_unit_die.lowpc + baseaddr,
15145 - comp_unit_die.highpc + baseaddr - 1, pst);
15148 + if (dwarf2_get_pc_bounds (comp_unit_die, &best_lowpc, &best_highpc, &cu,
15151 + dwarf2_find_base_address (comp_unit_die, &cu);
15153 /* Check if comp unit has_children.
15154 If so, read the rest of the partial symbols from this comp unit.
15155 If not, there's no more debug_info for this comp unit. */
15156 - if (comp_unit_die.has_children)
15157 + if (has_children)
15159 struct partial_die_info *first_die;
15160 CORE_ADDR lowpc, highpc;
15161 @@ -1634,8 +1792,7 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15163 first_die = load_partial_dies (abfd, info_ptr, 1, &cu);
15165 - scan_partial_symbols (first_die, &lowpc, &highpc,
15166 - ! comp_unit_die.has_pc_info, &cu);
15167 + scan_partial_symbols (first_die, &lowpc, &highpc, ! has_pc_info, &cu);
15169 /* If we didn't find a lowpc, set it to highpc to avoid
15170 complaints from `maint check'. */
15171 @@ -1644,14 +1801,14 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15173 /* If the compilation unit didn't have an explicit address range,
15174 then use the information extracted from its child dies. */
15175 - if (! comp_unit_die.has_pc_info)
15176 + if (! has_pc_info)
15178 - comp_unit_die.lowpc = lowpc;
15179 - comp_unit_die.highpc = highpc;
15180 + best_lowpc = lowpc;
15181 + best_highpc = highpc;
15184 - pst->textlow = comp_unit_die.lowpc + baseaddr;
15185 - pst->texthigh = comp_unit_die.highpc + baseaddr;
15186 + pst->textlow = best_lowpc + baseaddr;
15187 + pst->texthigh = best_highpc + baseaddr;
15189 pst->n_global_syms = objfile->global_psymbols.next -
15190 (objfile->global_psymbols.list + pst->globals_offset);
15191 @@ -1667,12 +1824,9 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15192 info_ptr = beg_of_comp_unit + cu.header.length
15193 + cu.header.initial_length_size;
15195 - if (comp_unit_die.has_stmt_list)
15197 - /* Get the list of files included in the current compilation unit,
15198 - and build a psymtab for each of them. */
15199 - dwarf2_build_include_psymtabs (&cu, &comp_unit_die, pst);
15201 + /* Get the list of files included in the current compilation unit,
15202 + and build a psymtab for each of them. */
15203 + dwarf2_build_include_psymtabs (&cu, comp_unit_die, pst);
15205 do_cleanups (back_to_inner);
15207 @@ -1690,11 +1844,12 @@ load_comp_unit (struct dwarf2_per_cu_data *this_cu, struct objfile *objfile)
15209 bfd *abfd = objfile->obfd;
15210 gdb_byte *info_ptr, *beg_of_comp_unit;
15211 - struct partial_die_info comp_unit_die;
15212 + struct die_info *comp_unit_die;
15213 struct dwarf2_cu *cu;
15214 - struct abbrev_info *abbrev;
15215 unsigned int bytes_read;
15216 struct cleanup *back_to;
15217 + struct attribute *attr;
15218 + int has_children;
15220 info_ptr = dwarf2_per_objfile->info_buffer + this_cu->offset;
15221 beg_of_comp_unit = info_ptr;
15222 @@ -1716,12 +1871,15 @@ load_comp_unit (struct dwarf2_per_cu_data *this_cu, struct objfile *objfile)
15223 back_to = make_cleanup (dwarf2_free_abbrev_table, cu);
15225 /* Read the compilation unit die. */
15226 - abbrev = peek_die_abbrev (info_ptr, &bytes_read, cu);
15227 - info_ptr = read_partial_die (&comp_unit_die, abbrev, bytes_read,
15228 - abfd, info_ptr, cu);
15229 + info_ptr = read_full_die (&comp_unit_die, abfd, info_ptr, cu,
15232 /* Set the language we're debugging. */
15233 - set_cu_language (comp_unit_die.language, cu);
15234 + attr = dwarf2_attr (comp_unit_die, DW_AT_language, cu);
15236 + set_cu_language (DW_UNSND (attr), cu);
15238 + set_cu_language (language_minimal, cu);
15240 /* Link this compilation unit into the compilation unit tree. */
15242 @@ -1731,7 +1889,7 @@ load_comp_unit (struct dwarf2_per_cu_data *this_cu, struct objfile *objfile)
15243 /* Check if comp unit has_children.
15244 If so, read the rest of the partial symbols from this comp unit.
15245 If not, there's no more debug_info for this comp unit. */
15246 - if (comp_unit_die.has_children)
15247 + if (has_children)
15248 load_partial_dies (abfd, info_ptr, 0, cu);
15250 do_cleanups (back_to);
15251 @@ -1948,7 +2106,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
15253 complaint (&symfile_complaints,
15254 _("unhandled containing DIE tag %d for DIE at %d"),
15255 - parent->tag, pdi->offset);
15256 + parent->tag, real_pdi->offset);
15257 parent->scope = grandparent_scope;
15260 @@ -1963,12 +2121,37 @@ partial_die_full_name (struct partial_die_info *pdi,
15261 struct dwarf2_cu *cu)
15263 char *parent_scope;
15264 + struct partial_die_info *real_pdi;
15266 - parent_scope = partial_die_parent_scope (pdi, cu);
15267 - if (parent_scope == NULL)
15270 + /* We need to look at our parent DIE; if we have a DW_AT_specification,
15271 + then this means the parent of the specification DIE.
15272 + partial_die_parent_scope does this loop also, but we do it here
15273 + since we need to examine real_pdi->parent ourselves. */
15276 + while (real_pdi->has_specification)
15277 + real_pdi = find_partial_die (real_pdi->spec_offset, cu);
15279 + parent_scope = partial_die_parent_scope (real_pdi, cu);
15280 + if (parent_scope != NULL)
15281 return typename_concat (NULL, parent_scope, pdi->name, cu);
15283 + if (!cu->has_namespace_info && pdi->linkage_name
15284 + && !real_pdi->die_parent)
15286 + char *actual_scope
15287 + = language_class_name_from_physname (cu->language_defn,
15288 + pdi->linkage_name);
15289 + if (actual_scope != NULL)
15291 + char *actual_name = typename_concat (NULL, actual_scope,
15293 + xfree (actual_scope);
15294 + return actual_name;
15302 @@ -1984,7 +2167,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
15304 baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
15306 - if (pdi_needs_namespace (pdi->tag))
15307 + if (pdi->linkage_name != NULL)
15308 + actual_name = pdi->linkage_name;
15309 + else if (pdi_needs_namespace (pdi->tag))
15311 actual_name = partial_die_full_name (pdi, cu);
15313 @@ -2133,9 +2318,8 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
15314 if (cu->language == language_cplus
15315 && cu->has_namespace_info == 0
15317 - && SYMBOL_CPLUS_DEMANGLED_NAME (psym) != NULL)
15318 - cp_check_possible_namespace_symbols (SYMBOL_CPLUS_DEMANGLED_NAME (psym),
15320 + && pdi->linkage_name != NULL)
15321 + cp_check_possible_namespace_symbols (actual_name, objfile);
15323 if (built_actual_name)
15324 xfree (actual_name);
15325 @@ -2158,6 +2342,14 @@ pdi_needs_namespace (enum dwarf_tag tag)
15326 case DW_TAG_union_type:
15327 case DW_TAG_enumeration_type:
15328 case DW_TAG_enumerator:
15329 + case DW_TAG_subprogram:
15330 + case DW_TAG_variable:
15332 + case DW_TAG_member:
15333 + /* The only time we will encounter member variables in this
15334 + function is when we are creating a "linkage" name for them;
15335 + therefore they must be static members, so they do need a
15340 @@ -2290,11 +2482,11 @@ guess_structure_name (struct partial_die_info *struct_pdi,
15342 while (child_pdi != NULL)
15344 - if (child_pdi->tag == DW_TAG_subprogram)
15345 + if (child_pdi->tag == DW_TAG_subprogram && child_pdi->linkage_name)
15347 char *actual_class_name
15348 = language_class_name_from_physname (cu->language_defn,
15349 - child_pdi->name);
15350 + child_pdi->linkage_name);
15351 if (actual_class_name != NULL)
15354 @@ -2741,7 +2933,6 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
15355 CORE_ADDR lowpc, highpc;
15356 struct symtab *symtab;
15357 struct cleanup *back_to;
15358 - struct attribute *attr;
15359 CORE_ADDR baseaddr;
15361 baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
15362 @@ -2751,30 +2942,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
15364 cu->list_in_scope = &file_symbols;
15366 - /* Find the base address of the compilation unit for range lists and
15367 - location lists. It will normally be specified by DW_AT_low_pc.
15368 - In DWARF-3 draft 4, the base address could be overridden by
15369 - DW_AT_entry_pc. It's been removed, but GCC still uses this for
15370 - compilation units with discontinuous ranges. */
15372 - cu->base_known = 0;
15373 - cu->base_address = 0;
15375 - attr = dwarf2_attr (cu->dies, DW_AT_entry_pc, cu);
15378 - cu->base_address = DW_ADDR (attr);
15379 - cu->base_known = 1;
15383 - attr = dwarf2_attr (cu->dies, DW_AT_low_pc, cu);
15386 - cu->base_address = DW_ADDR (attr);
15387 - cu->base_known = 1;
15390 + dwarf2_find_base_address (cu->dies, cu);
15392 /* Do line number decoding in read_file_scope () */
15393 process_die (cu->dies, cu);
15394 @@ -2805,6 +2973,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu)
15396 process_die (struct die_info *die, struct dwarf2_cu *cu)
15401 case DW_TAG_padding:
15402 @@ -2849,6 +3018,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
15404 case DW_TAG_base_type:
15405 case DW_TAG_subrange_type:
15406 + case DW_TAG_typedef:
15407 /* Add a typedef symbol for the type definition, if it has a
15409 new_symbol (die, read_type_die (die, cu), cu);
15410 @@ -2867,14 +3037,12 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
15412 case DW_TAG_imported_declaration:
15413 case DW_TAG_imported_module:
15414 - /* FIXME: carlton/2002-10-16: Eventually, we should use the
15415 - information contained in these. DW_TAG_imported_declaration
15416 - dies shouldn't have children; DW_TAG_imported_module dies
15417 - shouldn't in the C++ case, but conceivably could in the
15419 processing_has_namespace_info = 1;
15420 - complaint (&symfile_complaints, _("unsupported tag: '%s'"),
15421 - dwarf_tag_name (die->tag));
15422 + if (die->child != NULL && (die->tag == DW_TAG_imported_declaration
15423 + || cu->language != language_fortran))
15424 + complaint (&symfile_complaints, _("Tag '%s' has unexpected children"),
15425 + dwarf_tag_name (die->tag));
15426 + read_import_statement (die, cu);
15429 new_symbol (die, NULL, cu);
15430 @@ -2904,22 +3072,130 @@ dwarf2_full_name (struct die_info *die, struct dwarf2_cu *cu)
15433 /* If no prefix is necessary for this type of DIE, return the
15434 - unqualified name. The other three tags listed could be handled
15435 - in pdi_needs_namespace, but that requires broader changes. */
15436 - if (!pdi_needs_namespace (die->tag)
15437 - && die->tag != DW_TAG_subprogram
15438 - && die->tag != DW_TAG_variable
15439 - && die->tag != DW_TAG_member)
15440 + unqualified name. */
15441 + if (!pdi_needs_namespace (die->tag))
15444 prefix = determine_prefix (die, cu);
15445 if (*prefix != '\0')
15446 - name = typename_concat (&cu->objfile->objfile_obstack, prefix,
15449 + char *prefixed_name = typename_concat (NULL, prefix, name, cu);
15450 + buf = mem_fileopen ();
15451 + fputs_unfiltered (prefixed_name, buf);
15452 + xfree (prefixed_name);
15455 + if (cu->language == language_cplus && die->tag == DW_TAG_subprogram)
15457 + struct type *type = read_type_die (die, cu);
15461 + buf = mem_fileopen ();
15462 + fputs_unfiltered (name, buf);
15465 + c_type_print_args (type, buf, 0);
15471 + name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack,
15473 + ui_file_delete (buf);
15479 +/* read the given die's decl_line number. Return -1 if in case of an error */
15480 +static int dwarf2_read_decl_line (struct die_info *die, struct dwarf2_cu *cu){
15481 + struct attribute *line_attr;
15483 + line_attr = dwarf2_attr (die, DW_AT_decl_line, cu);
15485 + return DW_UNSND (line_attr);
15491 +/* Read the import statement specified by the given die and record it. */
15494 +read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
15496 + struct attribute *import_attr;
15497 + struct die_info *imported_die;
15498 + const char *imported_name;
15499 + const char *imported_name_prefix;
15500 + char *canonical_name;
15501 + const char *import_alias;
15502 + const char *imported_declaration = "";
15503 + const char *import_prefix;
15505 + int line_number = -1;
15507 + int is_anonymous = 0;
15509 + import_attr = dwarf2_attr (die, DW_AT_import, cu);
15510 + if (import_attr == NULL)
15512 + complaint (&symfile_complaints, _("Tag '%s' has no DW_AT_import"),
15513 + dwarf_tag_name (die->tag));
15517 + imported_die = follow_die_ref (die, import_attr, &cu);
15518 + imported_name = namespace_name (imported_die, &is_anonymous, cu);
15519 + if (imported_name == NULL)
15521 + /* C++ imports from std:: DW_TAG_base_type with no DW_AT_name - why? */
15525 + /* Figure out the local name after import. */
15526 + import_alias = dwarf2_name(die, cu);
15527 + if(import_alias == NULL){
15528 + import_alias = "";
15531 + /* Determine the line number at which the import was made */
15532 + line_number = dwarf2_read_decl_line(die, cu);
15534 + /* Figure out where the statement is being imported to */
15535 + import_prefix = determine_prefix (die, cu);
15538 + Figure out what the scope of the imported die is and prepend it
15539 + to the name of the imported die
15541 + imported_name_prefix = determine_prefix (imported_die, cu);
15543 + if(imported_die->tag != DW_TAG_namespace){
15544 + imported_declaration = imported_name;
15545 + canonical_name = (char*)imported_name_prefix;
15547 + if(strlen (imported_name_prefix) > 0){
15548 + canonical_name = alloca (strlen (imported_name_prefix) + 2 + strlen (imported_name) + 1);
15549 + strcpy (canonical_name, imported_name_prefix);
15550 + strcat (canonical_name, "::");
15551 + strcat (canonical_name, imported_name);
15553 + canonical_name = alloca (strlen (imported_name) + 1);
15554 + strcpy (canonical_name, imported_name);
15558 + using_directives = cp_add_using (import_prefix,
15561 + imported_declaration,
15563 + using_directives);
15567 initialize_cu_func_list (struct dwarf2_cu *cu)
15569 @@ -3076,6 +3352,103 @@ add_to_cu_func_list (const char *name, CORE_ADDR lowpc, CORE_ADDR highpc,
15570 cu->last_fn = thisfn;
15574 +unsigned_int_compar (const void *ap, const void *bp)
15576 + unsigned int a = *(unsigned int *) ap;
15577 + unsigned int b = *(unsigned int *) bp;
15579 + return (a > b) - (b > a);
15582 +static void explore_abstract_origin(struct die_info *die, struct dwarf2_cu *cu, unsigned* die_children_p){
15583 + struct attribute *attr;
15584 + unsigned die_children = *die_children_p;
15585 + struct die_info *child_die;
15587 + attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
15589 + /* GCC currently uses DW_AT_specification to indicate die inheritence
15590 + in the case of import statements. The following is to accommodate that */
15592 + attr = dwarf2_attr (die, DW_AT_specification, cu);
15597 + /* For the list of CHILD_DIEs. */
15598 + unsigned *offsets;
15599 + unsigned *offsets_end, *offsetp;
15600 + struct die_info *origin_die, *origin_child_die;
15601 + struct cleanup *cleanups;
15603 + origin_die = follow_die_ref (die, attr, &cu);
15604 + if (die->tag != origin_die->tag)
15605 + complaint (&symfile_complaints,
15606 + _("DIE 0x%x and its abstract origin 0x%x have different "
15608 + die->offset, origin_die->offset);
15610 + offsets = xmalloc (sizeof (*offsets) * die_children);
15611 + cleanups = make_cleanup (xfree, offsets);
15613 + offsets_end = offsets;
15614 + child_die = die->child;
15615 + while (child_die && child_die->tag)
15617 + attr = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
15619 + complaint (&symfile_complaints,
15620 + _("Child DIE 0x%x of DIE 0x%x has missing "
15621 + "DW_AT_abstract_origin"),
15622 + child_die->offset, die->offset);
15625 + struct die_info *child_origin_die;
15627 + child_origin_die = follow_die_ref (child_die, attr, &cu);
15628 + if (child_die->tag != child_origin_die->tag)
15629 + complaint (&symfile_complaints,
15630 + _("Child DIE 0x%x and its abstract origin 0x%x have "
15631 + "different tags"),
15632 + child_die->offset, child_origin_die->offset);
15633 + *offsets_end++ = child_origin_die->offset;
15635 + child_die = sibling_die (child_die);
15637 + qsort (offsets, offsets_end - offsets, sizeof (*offsets),
15638 + unsigned_int_compar);
15639 + /* Disabled as excessively expensive - check if we may ever complain. */
15642 + for (offsetp = offsets + 1; offsetp < offsets_end; offsetp++)
15643 + if (offsetp[-1] == *offsetp)
15644 + complaint (&symfile_complaints,
15645 + _("Child DIEs of DIE 0x%x duplicitly abstract-origin "
15646 + "referenced DIE 0x%x"),
15647 + die->offset, *offsetp);
15650 + offsetp = offsets;
15651 + origin_child_die = origin_die->child;
15652 + while (origin_child_die && origin_child_die->tag)
15654 + /* Is origin_child_die referenced by any of the DIE children? */
15655 + while (offsetp < offsets_end && *offsetp < origin_child_die->offset)
15657 + if (offsetp >= offsets_end || *offsetp > origin_child_die->offset)
15659 + /* Found that origin_child_die is really not referenced. */
15660 + process_die (origin_child_die, cu);
15662 + origin_child_die = sibling_die (origin_child_die);
15665 + do_cleanups (cleanups);
15671 read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15673 @@ -3088,16 +3461,27 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15675 CORE_ADDR baseaddr;
15676 struct block *block;
15677 + unsigned die_children = 0;
15679 baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
15681 - name = dwarf2_linkage_name (die, cu);
15682 + name = dwarf2_name (die, cu);
15684 /* Ignore functions with missing or empty names and functions with
15685 missing or invalid low and high pc attributes. */
15686 - if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
15687 + if (name == NULL || !dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL)){
15688 + /* explore abstract origins if present. They might contain useful information
15689 + such as import statements. */
15690 + child_die = die->child;
15691 + while (child_die && child_die->tag)
15693 + child_die = sibling_die (child_die);
15696 + explore_abstract_origin(die, cu, &die_children);
15702 highpc += baseaddr;
15704 @@ -3124,16 +3508,91 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15706 cu->list_in_scope = &local_symbols;
15708 - if (die->child != NULL)
15709 + child_die = die->child;
15710 + die_children = 0;
15711 + while (child_die && child_die->tag)
15713 + process_die (child_die, cu);
15714 + child_die = sibling_die (child_die);
15718 + attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
15721 + /* For the list of CHILD_DIEs. */
15722 + unsigned *offsets;
15723 + unsigned *offsets_end, *offsetp;
15724 + struct die_info *origin_die, *origin_child_die;
15725 + struct cleanup *cleanups;
15727 + origin_die = follow_die_ref (die, attr, &cu);
15728 + if (die->tag != origin_die->tag)
15729 + complaint (&symfile_complaints,
15730 + _("DIE 0x%x and its abstract origin 0x%x have different "
15732 + die->offset, origin_die->offset);
15734 + offsets = xmalloc (sizeof (*offsets) * die_children);
15735 + cleanups = make_cleanup (xfree, offsets);
15737 + offsets_end = offsets;
15738 child_die = die->child;
15739 while (child_die && child_die->tag)
15741 - process_die (child_die, cu);
15742 + attr = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
15744 + complaint (&symfile_complaints,
15745 + _("Child DIE 0x%x of DIE 0x%x has missing "
15746 + "DW_AT_abstract_origin"),
15747 + child_die->offset, die->offset);
15750 + struct die_info *child_origin_die;
15752 + child_origin_die = follow_die_ref (child_die, attr, &cu);
15753 + if (child_die->tag != child_origin_die->tag)
15754 + complaint (&symfile_complaints,
15755 + _("Child DIE 0x%x and its abstract origin 0x%x have "
15756 + "different tags"),
15757 + child_die->offset, child_origin_die->offset);
15758 + *offsets_end++ = child_origin_die->offset;
15760 child_die = sibling_die (child_die);
15762 + qsort (offsets, offsets_end - offsets, sizeof (*offsets),
15763 + unsigned_int_compar);
15764 + /* Disabled as excessively expensive - check if we may ever complain. */
15767 + for (offsetp = offsets + 1; offsetp < offsets_end; offsetp++)
15768 + if (offsetp[-1] == *offsetp)
15769 + complaint (&symfile_complaints,
15770 + _("Child DIEs of DIE 0x%x duplicitly abstract-origin "
15771 + "referenced DIE 0x%x"),
15772 + die->offset, *offsetp);
15775 + offsetp = offsets;
15776 + origin_child_die = origin_die->child;
15777 + while (origin_child_die && origin_child_die->tag)
15779 + /* Is origin_child_die referenced by any of the DIE children? */
15780 + while (offsetp < offsets_end && *offsetp < origin_child_die->offset)
15782 + if (offsetp >= offsets_end || *offsetp > origin_child_die->offset)
15784 + /* Found that origin_child_die is really not referenced. */
15785 + process_die (origin_child_die, cu);
15787 + origin_child_die = sibling_die (origin_child_die);
15790 + do_cleanups (cleanups);
15793 + explore_abstract_origin(die, cu, &die_children);
15795 new = pop_context ();
15796 /* Make a block for the local symbols within. */
15797 block = finish_block (new->name, &local_symbols, new->old_blocks,
15798 @@ -3154,6 +3613,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15799 back to building a containing block's symbol lists. */
15800 local_symbols = new->locals;
15801 param_symbols = new->params;
15802 + using_directives = new->using_directives;
15804 /* If we've finished processing a top-level function, subsequent
15805 symbols go in the file symbol list. */
15806 @@ -3180,7 +3640,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
15807 as multiple lexical blocks? Handling children in a sane way would
15808 be nasty. Might be easier to properly extend generic blocks to
15809 describe ranges. */
15810 - if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu))
15811 + if (!dwarf2_get_pc_bounds (die, &lowpc, &highpc, cu, NULL))
15814 highpc += baseaddr;
15815 @@ -3197,7 +3657,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
15817 new = pop_context ();
15819 - if (local_symbols != NULL)
15820 + if (local_symbols != NULL || using_directives!= NULL )
15822 struct block *block
15823 = finish_block (0, &local_symbols, new->old_blocks, new->start_addr,
15824 @@ -3216,6 +3676,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
15825 dwarf2_record_block_ranges (die, block, baseaddr, cu);
15827 local_symbols = new->locals;
15828 + using_directives = new->using_directives;
15831 /* Get low and high pc attributes from DW_AT_ranges attribute value OFFSET.
15832 @@ -3351,7 +3812,8 @@ dwarf2_ranges_read (unsigned offset, CORE_ADDR *low_return,
15833 discontinuous, i.e. derived from DW_AT_ranges information. */
15835 dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
15836 - CORE_ADDR *highpc, struct dwarf2_cu *cu)
15837 + CORE_ADDR *highpc, struct dwarf2_cu *cu,
15838 + struct partial_symtab *pst)
15840 struct attribute *attr;
15842 @@ -3379,7 +3841,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
15844 /* Value of the DW_AT_ranges attribute is the offset in the
15845 .debug_ranges section. */
15846 - if (!dwarf2_ranges_read (DW_UNSND (attr), &low, &high, cu, NULL))
15847 + if (!dwarf2_ranges_read (DW_UNSND (attr), &low, &high, cu, pst))
15849 /* Found discontinuous range of addresses. */
15851 @@ -3418,7 +3880,7 @@ dwarf2_get_subprogram_pc_bounds (struct die_info *die,
15852 CORE_ADDR low, high;
15853 struct die_info *child = die->child;
15855 - if (dwarf2_get_pc_bounds (die, &low, &high, cu))
15856 + if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL))
15858 *lowpc = min (*lowpc, low);
15859 *highpc = max (*highpc, high);
15860 @@ -3455,7 +3917,7 @@ get_scope_pc_bounds (struct die_info *die,
15861 CORE_ADDR best_high = (CORE_ADDR) 0;
15862 CORE_ADDR current_low, current_high;
15864 - if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu))
15865 + if (dwarf2_get_pc_bounds (die, ¤t_low, ¤t_high, cu, NULL))
15867 best_low = current_low;
15868 best_high = current_high;
15869 @@ -3750,8 +4212,14 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
15870 if (fieldname == NULL)
15873 - /* Get physical name. */
15874 + /* Get physical name. We prefer the linkage name if one was specified,
15875 + because this lets GDB find a non-debugging version of the symbol.
15876 + Otherwise construct the full name from type information. Ideally,
15877 + when GDB supports canonicalization of C++ symbol names, we will not
15878 + need the linkage name for anything. */
15879 physname = dwarf2_linkage_name (die, cu);
15880 + if (physname == NULL)
15881 + physname = (char *) dwarf2_full_name (die, cu);
15883 /* The name is already allocated along with this objfile, so we don't
15884 need to duplicate it for the type. */
15885 @@ -3881,8 +4349,14 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
15886 if (fieldname == NULL)
15889 - /* Get the mangled name. */
15890 + /* Get physical name. We prefer the linkage name if one was specified,
15891 + because this lets GDB find a non-debugging version of the symbol.
15892 + Otherwise construct the full name from type information. Ideally,
15893 + when GDB supports canonicalization of C++ symbol names, we will not
15894 + need the linkage name for anything. */
15895 physname = dwarf2_linkage_name (die, cu);
15896 + if (physname == NULL)
15897 + physname = (char *) dwarf2_full_name (die, cu);
15899 /* Look up member function name in fieldlist. */
15900 for (i = 0; i < fip->nfnfields; i++)
15901 @@ -3926,7 +4400,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
15902 /* The name is already allocated along with this objfile, so we don't
15903 need to duplicate it for the type. */
15904 fnp->physname = physname ? physname : "";
15905 - fnp->type = alloc_type (objfile);
15906 + fnp->type = alloc_type (objfile, NULL);
15907 this_type = read_type_die (die, cu);
15908 if (this_type && TYPE_CODE (this_type) == TYPE_CODE_FUNC)
15910 @@ -4110,7 +4584,7 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
15913 domain_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
15914 - type = alloc_type (objfile);
15915 + type = alloc_type (objfile, NULL);
15916 smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type),
15917 TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
15918 TYPE_VARARGS (pfn_type));
15919 @@ -4147,7 +4621,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
15923 - type = alloc_type (objfile);
15924 + type = alloc_type (objfile, NULL);
15925 INIT_CPLUS_SPECIFIC (type);
15926 name = dwarf2_name (die, cu);
15928 @@ -4360,7 +4834,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
15929 struct attribute *attr;
15932 - type = alloc_type (objfile);
15933 + type = alloc_type (objfile, NULL);
15935 TYPE_CODE (type) = TYPE_CODE_ENUM;
15936 name = dwarf2_full_name (die, cu);
15937 @@ -4410,10 +4884,15 @@ determine_class_name (struct die_info *die, struct dwarf2_cu *cu)
15939 if (child->tag == DW_TAG_subprogram)
15941 - char *phys_prefix
15942 + char *phys_prefix;
15943 + char *linkage_name = dwarf2_linkage_name (child, cu);
15945 + if (linkage_name == NULL)
15949 = language_class_name_from_physname (cu->language_defn,
15950 - dwarf2_linkage_name
15954 if (phys_prefix != NULL)
15956 @@ -4510,6 +4989,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
15957 new_symbol (die, this_type, cu);
15960 +/* Create a new array dimension referencing its target type TYPE.
15962 + Multidimensional arrays are internally represented as a stack of
15963 + singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */
15965 +static struct type *
15966 +create_single_array_dimension (struct type *type, struct type *range_type,
15967 + struct die_info *die, struct dwarf2_cu *cu)
15969 + type = create_array_type (NULL, type, range_type);
15971 + /* These generic type attributes need to be fetched by
15972 + evaluate_subexp_standard <multi_f77_subscript>'s call of
15973 + value_subscripted_rvalue only for the innermost array type. */
15974 + fetch_die_type_attrs (die, type, cu);
15976 + /* These generic type attributes are checked for allocated/associated
15977 + validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */
15978 + fetch_die_type_attrs (die, range_type, cu);
15983 /* Extract all information from a DW_TAG_array_type DIE and put it in
15984 the DIE's type field. For now, this only handles one dimensional
15986 @@ -4523,7 +5025,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
15987 struct type *element_type, *range_type, *index_type;
15988 struct type **range_types = NULL;
15989 struct attribute *attr;
15992 struct cleanup *back_to;
15995 @@ -4570,16 +5072,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
15996 type = element_type;
15998 if (read_array_order (die, cu) == DW_ORD_col_major)
16002 - type = create_array_type (NULL, type, range_types[i++]);
16006 - while (ndim-- > 0)
16007 - type = create_array_type (NULL, type, range_types[ndim]);
16009 + for (i = 0; i < ndim; i++)
16010 + type = create_single_array_dimension (type, range_types[i], die, cu);
16011 + else /* (read_array_order (die, cu) == DW_ORD_row_major) */
16012 + for (i = ndim - 1; i >= 0; i--)
16013 + type = create_single_array_dimension (type, range_types[i], die, cu);
16015 /* Understand Dwarf2 support for vector types (like they occur on
16016 the PowerPC w/ AltiVec). Gcc just adds another attribute to the
16017 @@ -4646,12 +5143,14 @@ read_set_type (struct die_info *die, struct dwarf2_cu *cu)
16018 return set_die_type (die, set_type, cu);
16021 -/* First cut: install each common block member as a global variable. */
16022 +/* Create appropriate locally-scoped variables for all the DW_TAG_common_block
16023 + entries. Create also TYPE_CODE_STRUCT listing all such variables to be
16024 + available for `info common'. COMMON_BLOCK_DOMAIN is used to sepate the
16025 + common blocks name namespace from regular variable names. */
16028 read_common_block (struct die_info *die, struct dwarf2_cu *cu)
16030 - struct die_info *child_die;
16031 struct attribute *attr;
16032 struct symbol *sym;
16033 CORE_ADDR base = (CORE_ADDR) 0;
16034 @@ -4676,10 +5175,40 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
16036 if (die->child != NULL)
16038 + struct objfile *objfile = cu->objfile;
16039 + struct die_info *child_die;
16040 + struct type *type;
16041 + struct field *field;
16043 + struct symbol *sym;
16045 + type = alloc_type (objfile, NULL);
16046 + TYPE_CODE (type) = TYPE_CODE_STRUCT;
16047 + /* Artificial type to be used only by `info common'. */
16048 + TYPE_NAME (type) = "<common>";
16050 child_die = die->child;
16051 while (child_die && child_die->tag)
16053 + TYPE_NFIELDS (type)++;
16054 + child_die = sibling_die (child_die);
16057 + TYPE_FIELDS (type) = obstack_alloc (&objfile->objfile_obstack,
16058 + sizeof (*TYPE_FIELDS (type))
16059 + * TYPE_NFIELDS (type));
16060 + memset (TYPE_FIELDS (type), 0, sizeof (*TYPE_FIELDS (type))
16061 + * TYPE_NFIELDS (type));
16063 + field = TYPE_FIELDS (type);
16064 + child_die = die->child;
16065 + while (child_die && child_die->tag)
16067 + /* Create the symbol in the DW_TAG_common_block block in the current
16069 sym = new_symbol (child_die, NULL, cu);
16071 + /* Undocumented in DWARF3, when it can be present? */
16072 attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
16075 @@ -4687,8 +5216,25 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
16076 base + decode_locdesc (DW_BLOCK (attr), cu);
16077 add_symbol_to_list (sym, &global_symbols);
16080 + if (SYMBOL_CLASS (sym) == LOC_STATIC)
16081 + SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
16083 + SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
16084 + FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
16085 + FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym);
16087 child_die = sibling_die (child_die);
16090 + /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even
16091 + with no consecutive address space. */
16093 + sym = new_symbol (die, type, cu);
16094 + /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static. */
16095 + SYMBOL_VALUE_ADDRESS (sym) = base;
16097 + set_die_type (die, type, cu);
16101 @@ -4756,9 +5302,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
16104 const char *previous_prefix = determine_prefix (die, cu);
16105 - cp_add_using_directive (TYPE_NAME (type),
16106 - strlen (previous_prefix),
16107 - strlen (TYPE_NAME (type)));
16108 + cp_add_using_directive (previous_prefix, TYPE_NAME (type), "", "", dwarf2_read_decl_line(die, cu));
16112 @@ -4951,29 +5495,95 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
16113 struct objfile *objfile = cu->objfile;
16114 struct type *type, *range_type, *index_type, *char_type;
16115 struct attribute *attr;
16116 - unsigned int length;
16119 + index_type = builtin_type_int32;
16120 + /* RANGE_TYPE is allocated from OBJFILE, not OBJFILE_INTERNAL. */
16121 + range_type = alloc_type (objfile, index_type);
16122 + /* LOW_BOUND and HIGH_BOUND are set for real below. */
16123 + range_type = create_range_type (range_type, index_type, 0, -1);
16125 + /* C/C++ should probably have the low bound 0 but C/C++ does not use
16126 + DW_TAG_string_type. */
16127 + TYPE_LOW_BOUND (range_type) = 1;
16129 attr = dwarf2_attr (die, DW_AT_string_length, cu);
16132 - length = DW_UNSND (attr);
16136 - /* check for the DW_AT_byte_size attribute */
16137 + switch (dwarf2_get_attr_constant_value (attr, &length))
16139 + case dwarf2_attr_const:
16140 + /* We currently do not support a constant address where the location
16141 + should be read from - DWARF2_ATTR_BLOCK is expected instead. See
16142 + DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference. */
16144 + case dwarf2_attr_unknown:
16145 attr = dwarf2_attr (die, DW_AT_byte_size, cu);
16148 - length = DW_UNSND (attr);
16154 + switch (dwarf2_get_attr_constant_value (attr, &length))
16156 + case dwarf2_attr_unknown:
16159 + case dwarf2_attr_const:
16160 + TYPE_HIGH_BOUND (range_type) = length;
16162 + case dwarf2_attr_block:
16163 + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1);
16164 + TYPE_FIELD_DWARF_BLOCK (range_type, 1) =
16165 + dwarf2_attr_to_locexpr_baton (attr, cu);
16166 + TYPE_DYNAMIC (range_type) = 1;
16170 + case dwarf2_attr_block:
16171 + /* Security check for a size overflow. */
16172 + if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
16174 + TYPE_HIGH_BOUND (range_type) = 1;
16177 + /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size
16178 + instruction as DW_AT_string_length specifies the length location, not
16181 + struct dwarf2_locexpr_baton *length_baton;
16182 + struct attribute *size_attr;
16184 + length_baton = obstack_alloc (&cu->comp_unit_obstack,
16185 + sizeof (*length_baton));
16186 + length_baton->per_cu = cu->per_cu;
16187 + length_baton->data = obstack_alloc (&cu->comp_unit_obstack,
16188 + DW_BLOCK (attr)->size + 2);
16189 + memcpy (length_baton->data, DW_BLOCK (attr)->data,
16190 + DW_BLOCK (attr)->size);
16192 + /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH specifies
16193 + the size of an integer to fetch. */
16195 + size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
16198 + length_baton->size = DW_BLOCK (attr)->size + 2;
16199 + length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref_size;
16200 + length_baton->data[DW_BLOCK (attr)->size + 1]
16201 + = DW_UNSND (size_attr);
16202 + if (length_baton->data[DW_BLOCK (attr)->size + 1]
16203 + != DW_UNSND (size_attr))
16204 + complaint (&symfile_complaints,
16205 + _("DW_AT_string_length's DW_AT_byte_size integer "
16206 + "exceeds the byte size storage"));
16210 + length_baton->size = DW_BLOCK (attr)->size + 1;
16211 + length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref;
16214 + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1);
16215 + TYPE_FIELD_DWARF_BLOCK (range_type, 1) = length_baton;
16216 + TYPE_DYNAMIC (range_type) = 1;
16221 - index_type = builtin_type_int32;
16222 - range_type = create_range_type (NULL, index_type, 1, length);
16223 type = create_string_type (NULL, range_type);
16225 return set_die_type (die, type, cu);
16226 @@ -5067,7 +5677,6 @@ static struct type *
16227 read_typedef (struct die_info *die, struct dwarf2_cu *cu)
16229 struct objfile *objfile = cu->objfile;
16230 - struct attribute *attr;
16231 const char *name = NULL;
16232 struct type *this_type;
16234 @@ -5175,8 +5784,8 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
16235 struct type *base_type;
16236 struct type *range_type;
16237 struct attribute *attr;
16240 + int low, high, byte_stride_int;
16241 + enum dwarf2_get_attr_constant_value high_type;
16244 base_type = die_type (die, cu);
16245 @@ -5189,42 +5798,90 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
16246 0, NULL, cu->objfile);
16249 - if (cu->language == language_fortran)
16251 - /* FORTRAN implies a lower bound of 1, if not given. */
16254 + /* LOW_BOUND and HIGH_BOUND are set for real below. */
16255 + range_type = create_range_type (NULL, base_type, 0, -1);
16257 - /* FIXME: For variable sized arrays either of these could be
16258 - a variable rather than a constant value. We'll allow it,
16259 - but we don't know how to handle it. */
16260 attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
16262 - low = dwarf2_get_attr_constant_value (attr, 0);
16263 + switch (dwarf2_get_attr_constant_value (attr, &low))
16265 + case dwarf2_attr_unknown:
16266 + if (cu->language == language_fortran)
16268 + /* FORTRAN implies a lower bound of 1, if not given. */
16273 + /* According to DWARF we should assume the value 0 only for
16274 + LANGUAGE_C and LANGUAGE_CPLUS. */
16278 + case dwarf2_attr_const:
16279 + TYPE_LOW_BOUND (range_type) = low;
16281 + TYPE_UNSIGNED (range_type) = 1;
16283 + case dwarf2_attr_block:
16284 + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 0);
16285 + TYPE_FIELD_DWARF_BLOCK (range_type, 0) = dwarf2_attr_to_locexpr_baton
16287 + TYPE_DYNAMIC (range_type) = 1;
16288 + /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
16293 attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
16296 - if (attr->form == DW_FORM_block1)
16298 - /* GCC encodes arrays with unspecified or dynamic length
16299 - with a DW_FORM_block1 attribute.
16300 - FIXME: GDB does not yet know how to handle dynamic
16301 - arrays properly, treat them as arrays with unspecified
16304 - FIXME: jimb/2003-09-22: GDB does not really know
16305 - how to handle arrays of unspecified length
16306 - either; we just represent them as zero-length
16307 - arrays. Choose an appropriate upper bound given
16308 - the lower bound we've computed above. */
16312 - high = dwarf2_get_attr_constant_value (attr, 1);
16313 + high_type = dwarf2_get_attr_constant_value (attr, &high);
16314 + if (high_type == dwarf2_attr_unknown)
16316 + attr = dwarf2_attr (die, DW_AT_count, cu);
16317 + high_type = dwarf2_get_attr_constant_value (attr, &high);
16318 + /* It does not hurt but it is needlessly ineffective in check_typedef. */
16319 + if (high_type != dwarf2_attr_unknown)
16321 + TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
16322 + TYPE_DYNAMIC (range_type) = 1;
16324 + /* Pass it now as the regular DW_AT_upper_bound. */
16326 + switch (high_type)
16328 + case dwarf2_attr_unknown:
16329 + TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) = 1;
16332 + case dwarf2_attr_const:
16333 + TYPE_HIGH_BOUND (range_type) = high;
16335 + case dwarf2_attr_block:
16336 + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 1);
16337 + TYPE_FIELD_DWARF_BLOCK (range_type, 1) = dwarf2_attr_to_locexpr_baton
16339 + TYPE_DYNAMIC (range_type) = 1;
16343 - range_type = create_range_type (NULL, base_type, low, high);
16344 + /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
16345 + attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
16346 + switch (dwarf2_get_attr_constant_value (attr, &byte_stride_int))
16348 + case dwarf2_attr_unknown:
16350 + case dwarf2_attr_const:
16351 + if (byte_stride_int == 0)
16352 + complaint (&symfile_complaints,
16353 + _("Found DW_AT_byte_stride with unsupported value 0"));
16354 + TYPE_BYTE_STRIDE (range_type) = byte_stride_int;
16356 + case dwarf2_attr_block:
16357 + TYPE_RANGE_BOUND_SET_DWARF_BLOCK (range_type, 2);
16358 + TYPE_FIELD_DWARF_BLOCK (range_type, 2) = dwarf2_attr_to_locexpr_baton
16360 + TYPE_DYNAMIC (range_type) = 1;
16364 name = dwarf2_name (die, cu);
16366 @@ -5386,10 +6043,13 @@ read_die_and_siblings (gdb_byte *info_ptr, bfd *abfd,
16369 /* Decompress a section that was compressed using zlib. Store the
16370 - decompressed buffer, and its size, in OUTBUF and OUTSIZE. */
16371 + decompressed buffer, and its size, in OUTBUF and OUTSIZE. The
16372 + result is allocated on OBSTACK; if OBSTACK is NULL, xmalloc is
16376 -zlib_decompress_section (struct objfile *objfile, asection *sectp,
16377 +zlib_decompress_section (struct objfile *objfile, struct obstack *obstack,
16379 gdb_byte **outbuf, bfd_size_type *outsize)
16381 bfd *abfd = objfile->obfd;
16382 @@ -5405,6 +6065,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
16385 int header_size = 12;
16386 + struct cleanup *old = NULL;
16388 if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
16389 || bfd_bread (compressed_buffer, compressed_size, abfd) != compressed_size)
16390 @@ -5434,8 +6095,13 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
16391 strm.avail_in = compressed_size - header_size;
16392 strm.next_in = (Bytef*) compressed_buffer + header_size;
16393 strm.avail_out = uncompressed_size;
16394 - uncompressed_buffer = obstack_alloc (&objfile->objfile_obstack,
16395 - uncompressed_size);
16397 + uncompressed_buffer = obstack_alloc (obstack, uncompressed_size);
16400 + uncompressed_buffer = xmalloc (uncompressed_size);
16401 + old = make_cleanup (xfree, uncompressed_buffer);
16403 rc = inflateInit (&strm);
16404 while (strm.avail_in > 0)
16406 @@ -5456,6 +6122,8 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
16407 error (_("Dwarf Error: concluding DWARF uncompression in '%s': %d"),
16408 bfd_get_filename (abfd), rc);
16411 + discard_cleanups (old);
16412 xfree (compressed_buffer);
16413 *outbuf = uncompressed_buffer;
16414 *outsize = uncompressed_size;
16415 @@ -5463,17 +6131,20 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
16419 -/* Read the contents of the section at OFFSET and of size SIZE from the
16420 - object file specified by OBJFILE into the objfile_obstack and return it.
16421 - If the section is compressed, uncompress it before returning. */
16422 +/* Read the contents of the section at OFFSET and of size SIZE from
16423 + the object file specified by OBJFILE into OBSTACK and return it.
16424 + If OBSTACK is NULL, xmalloc is used instead. If the section is
16425 + compressed, uncompress it before returning. */
16428 -dwarf2_read_section (struct objfile *objfile, asection *sectp)
16430 +dwarf2_read_section_1 (struct objfile *objfile, struct obstack *obstack,
16433 bfd *abfd = objfile->obfd;
16434 gdb_byte *buf, *retbuf;
16435 bfd_size_type size = bfd_get_section_size (sectp);
16436 unsigned char header[4];
16437 + struct cleanup *old = NULL;
16441 @@ -5486,30 +6157,49 @@ dwarf2_read_section (struct objfile *objfile, asection *sectp)
16442 /* Upon decompression, update the buffer and its size. */
16443 if (strncmp (header, "ZLIB", sizeof (header)) == 0)
16445 - zlib_decompress_section (objfile, sectp, &buf, &size);
16446 + zlib_decompress_section (objfile, obstack, sectp, &buf, &size);
16447 dwarf2_resize_section (sectp, size);
16452 /* If we get here, we are a normal, not-compressed section. */
16453 - buf = obstack_alloc (&objfile->objfile_obstack, size);
16455 + buf = obstack_alloc (obstack, size);
16458 + buf = xmalloc (size);
16459 + old = make_cleanup (xfree, buf);
16461 /* When debugging .o files, we may need to apply relocations; see
16462 http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
16463 We never compress sections in .o files, so we only need to
16464 try this when the section is not compressed. */
16465 retbuf = symfile_relocate_debug_section (abfd, sectp, buf);
16466 if (retbuf != NULL)
16470 + discard_cleanups (old);
16474 if (bfd_seek (abfd, sectp->filepos, SEEK_SET) != 0
16475 || bfd_bread (buf, size, abfd) != size)
16476 error (_("Dwarf Error: Can't read DWARF data from '%s'"),
16477 bfd_get_filename (abfd));
16480 + discard_cleanups (old);
16486 +dwarf2_read_section (struct objfile *objfile, asection *sectp)
16488 + return dwarf2_read_section_1 (objfile, &objfile->objfile_obstack, sectp);
16491 /* In DWARF version 2, the description of the debugging information is
16492 stored in a separate .debug_abbrev section. Before we read any
16493 dies from a section we read in all abbreviations and install them
16494 @@ -5914,15 +6604,6 @@ read_partial_die (struct partial_die_info *part_die,
16495 struct attribute attr;
16496 int has_low_pc_attr = 0;
16497 int has_high_pc_attr = 0;
16498 - CORE_ADDR base_address = 0;
16501 - base_address_none,
16502 - base_address_low_pc,
16503 - /* Overrides BASE_ADDRESS_LOW_PC. */
16504 - base_address_entry_pc
16506 - base_address_type = base_address_none;
16508 memset (part_die, 0, sizeof (struct partial_die_info));
16510 @@ -5945,47 +6626,35 @@ read_partial_die (struct partial_die_info *part_die,
16515 - /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name. */
16516 - if (part_die->name == NULL)
16517 - part_die->name = DW_STRING (&attr);
16519 - case DW_AT_comp_dir:
16520 - if (part_die->dirname == NULL)
16521 - part_die->dirname = DW_STRING (&attr);
16522 + switch (part_die->tag)
16524 + case DW_TAG_compile_unit:
16525 + /* Compilation units have a DW_AT_name that is a filename, not
16526 + a source language identifier. */
16527 + case DW_TAG_enumeration_type:
16528 + case DW_TAG_enumerator:
16529 + /* These tags always have simple identifiers already; no need
16530 + to canonicalize them. */
16531 + part_die->name = DW_STRING (&attr);
16535 + = dwarf2_canonicalize_name (DW_STRING (&attr), cu,
16536 + &cu->comp_unit_obstack);
16540 case DW_AT_MIPS_linkage_name:
16541 - part_die->name = DW_STRING (&attr);
16542 + part_die->linkage_name = DW_STRING (&attr);
16545 has_low_pc_attr = 1;
16546 part_die->lowpc = DW_ADDR (&attr);
16547 - if (part_die->tag == DW_TAG_compile_unit
16548 - && base_address_type < base_address_low_pc)
16550 - base_address = DW_ADDR (&attr);
16551 - base_address_type = base_address_low_pc;
16554 case DW_AT_high_pc:
16555 has_high_pc_attr = 1;
16556 part_die->highpc = DW_ADDR (&attr);
16558 - case DW_AT_entry_pc:
16559 - if (part_die->tag == DW_TAG_compile_unit
16560 - && base_address_type < base_address_entry_pc)
16562 - base_address = DW_ADDR (&attr);
16563 - base_address_type = base_address_entry_pc;
16566 - case DW_AT_ranges:
16567 - if (part_die->tag == DW_TAG_compile_unit)
16569 - cu->ranges_offset = DW_UNSND (&attr);
16570 - cu->has_ranges_offset = 1;
16573 case DW_AT_location:
16574 /* Support the .debug_loc offsets */
16575 if (attr_form_is_block (&attr))
16576 @@ -6002,9 +6671,6 @@ read_partial_die (struct partial_die_info *part_die,
16577 "partial symbol information");
16580 - case DW_AT_language:
16581 - part_die->language = DW_UNSND (&attr);
16583 case DW_AT_external:
16584 part_die->is_external = DW_UNSND (&attr);
16586 @@ -6029,10 +6695,6 @@ read_partial_die (struct partial_die_info *part_die,
16587 part_die->sibling = dwarf2_per_objfile->info_buffer
16588 + dwarf2_get_ref_die_offset (&attr);
16590 - case DW_AT_stmt_list:
16591 - part_die->has_stmt_list = 1;
16592 - part_die->line_offset = DW_UNSND (&attr);
16594 case DW_AT_byte_size:
16595 part_die->has_byte_size = 1;
16597 @@ -6074,13 +6736,6 @@ read_partial_die (struct partial_die_info *part_die,
16598 || dwarf2_per_objfile->has_section_at_zero))
16599 part_die->has_pc_info = 1;
16601 - if (base_address_type != base_address_none && !cu->base_known)
16603 - gdb_assert (part_die->tag == DW_TAG_compile_unit);
16604 - cu->base_known = 1;
16605 - cu->base_address = base_address;
16611 @@ -6173,7 +6828,9 @@ fixup_partial_die (struct partial_die_info *part_die,
16612 /* If we found a reference attribute and the DIE has no name, try
16613 to find a name in the referred to DIE. */
16615 - if (part_die->name == NULL && part_die->has_specification)
16616 + if (part_die->has_specification
16617 + && (part_die->name == NULL || part_die->linkage_name == NULL
16618 + || !part_die->is_external))
16620 struct partial_die_info *spec_die;
16622 @@ -6189,6 +6846,9 @@ fixup_partial_die (struct partial_die_info *part_die,
16623 if (spec_die->is_external)
16624 part_die->is_external = spec_die->is_external;
16627 + if (spec_die->linkage_name)
16628 + part_die->linkage_name = spec_die->linkage_name;
16631 /* Set default names for some unnamed DIEs. */
16632 @@ -7512,10 +8172,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
16633 (i.e. when the value of a register or memory location is
16634 referenced, or a thread-local block, etc.). Then again, it might
16635 not be worthwhile. I'm assuming that it isn't unless performance
16636 - or memory numbers show me otherwise. */
16637 + or memory numbers show me otherwise.
16639 + SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */
16641 - dwarf2_symbol_mark_computed (attr, sym, cu);
16642 SYMBOL_CLASS (sym) = LOC_COMPUTED;
16643 + dwarf2_symbol_mark_computed (attr, sym, cu);
16646 /* Given a pointer to a DWARF information entry, figure out if we need
16647 @@ -7538,20 +8200,43 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
16648 baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
16650 if (die->tag != DW_TAG_namespace)
16651 - name = dwarf2_linkage_name (die, cu);
16652 + name = dwarf2_name (die, cu);
16654 name = TYPE_NAME (type);
16658 + const char *linkagename;
16660 sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
16661 sizeof (struct symbol));
16662 OBJSTAT (objfile, n_syms++);
16663 memset (sym, 0, sizeof (struct symbol));
16664 + /* Some methods are called without checking SYMBOL_OPS validity. */
16665 + SYMBOL_OPS (sym) = &dwarf2_missing_funcs;
16667 - /* Cache this symbol's name and the name's demangled form (if any). */
16668 SYMBOL_LANGUAGE (sym) = cu->language;
16669 - SYMBOL_SET_NAMES (sym, name, strlen (name), objfile);
16671 + /* Cache this symbol's name and the name's demangled form (if any). */
16673 + linkagename = dwarf2_linkage_name (die, cu);
16675 + /* We use the linkage name if available, for the same reason
16676 + we used it for TYPE_FN_FIELD_PHYSNAME earlier in this file.
16677 + This usage can be removed someday. */
16678 + SYMBOL_SET_NAMES (sym, linkagename, strlen (linkagename), objfile);
16679 + else if (die->tag == DW_TAG_namespace)
16680 + SYMBOL_SET_LINKAGE_NAME (sym, name);
16683 + linkagename = dwarf2_full_name (die, cu);
16685 + /* Set just the "linkage" name to the fully qualified name.
16686 + While this is not really a linkage name, it should match
16687 + the demangled version of the corresponding minimal symbol
16688 + if there is one. */
16689 + SYMBOL_SET_LINKAGE_NAME (sym, (char *) linkagename);
16692 /* Default assumptions.
16693 Use the passed type or decode it from the die. */
16694 @@ -7637,7 +8322,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
16697 var_decode_location (attr, sym, cu);
16698 - attr2 = dwarf2_attr (die, DW_AT_external, cu);
16700 + /* Fortran explicitely imports any global symbols to the local
16701 + scope by DW_TAG_common_block. DW_AT_external means for
16702 + Fortran the variable is importable versus it is automatically
16704 + if (cu->language == language_fortran)
16707 + attr2 = dwarf2_attr (die, DW_AT_external, cu);
16708 if (attr2 && (DW_UNSND (attr2) != 0))
16709 add_symbol_to_list (sym, &global_symbols);
16711 @@ -7780,6 +8473,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
16712 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
16713 add_symbol_to_list (sym, &global_symbols);
16715 + case DW_TAG_common_block:
16716 + SYMBOL_CLASS (sym) = LOC_STATIC;
16717 + SYMBOL_DOMAIN (sym) = COMMON_BLOCK_DOMAIN;
16718 + add_symbol_to_list (sym, cu->list_in_scope);
16721 /* Not a tag we recognize. Hopefully we aren't processing
16722 trash data, but since we must specifically ignore things
16723 @@ -8048,6 +8746,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
16728 + finalize_type (this_type);
16733 @@ -8128,6 +8829,19 @@ determine_prefix (struct die_info *die, struct dwarf2_cu *cu)
16734 members; no typedefs, no member functions, et cetera.
16735 So it does not need a prefix. */
16738 + case DW_TAG_subprogram:
16739 + /* A class's symbol, or a variable's symbol, will live
16740 + directly in a function's block, so no prefix is
16741 + appropriate. However, what about methods of a
16742 + function-local class? They end up in the global symbol
16743 + table because they are separate functions... their mangling
16744 + normally would make them inaccessible. They'll show up
16745 + wrong in breakpoints too. This is a symptom of the
16746 + inconsistent way we handle symbol tables. Namespaces and
16747 + classes should have dictionaries just like blocks do. */
16751 return determine_prefix (parent, cu);
16753 @@ -8192,23 +8906,62 @@ dwarf2_linkage_name (struct die_info *die, struct dwarf2_cu *cu)
16754 attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
16755 if (attr && DW_STRING (attr))
16756 return DW_STRING (attr);
16757 - attr = dwarf2_attr (die, DW_AT_name, cu);
16758 - if (attr && DW_STRING (attr))
16759 - return DW_STRING (attr);
16763 /* Get name of a die, return NULL if not found. */
16766 +dwarf2_canonicalize_name (char *name, struct dwarf2_cu *cu,
16767 + struct obstack *obstack)
16769 + if (name && cu->language == language_cplus)
16771 + char *canon_name = cp_canonicalize_string (name);
16773 + if (canon_name != NULL)
16775 + if (strcmp (canon_name, name) != 0)
16776 + name = obsavestring (canon_name, strlen (canon_name),
16778 + xfree (canon_name);
16785 +/* Get name of a die, return NULL if not found. */
16788 dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
16790 struct attribute *attr;
16792 attr = dwarf2_attr (die, DW_AT_name, cu);
16793 - if (attr && DW_STRING (attr))
16794 - return DW_STRING (attr);
16796 + if (!attr || !DW_STRING (attr))
16799 + switch (die->tag)
16801 + case DW_TAG_compile_unit:
16802 + /* Compilation units have a DW_AT_name that is a filename, not
16803 + a source language identifier. */
16804 + case DW_TAG_enumeration_type:
16805 + case DW_TAG_enumerator:
16806 + /* These tags always have simple identifiers already; no need
16807 + to canonicalize them. */
16808 + return DW_STRING (attr);
16810 + if (attr->form != GDB_FORM_cached_string)
16813 + = dwarf2_canonicalize_name (DW_STRING (attr), cu,
16814 + &cu->objfile->objfile_obstack);
16815 + attr->form = GDB_FORM_cached_string;
16817 + return DW_STRING (attr);
16821 /* Return the die that this die in an extension of, or NULL if there
16822 @@ -8703,6 +9456,8 @@ dwarf_form_name (unsigned form)
16823 return "DW_FORM_ref_udata";
16824 case DW_FORM_indirect:
16825 return "DW_FORM_indirect";
16826 + case GDB_FORM_cached_string:
16827 + return "GDB_FORM_cached_string";
16829 return "DW_FORM_<unknown>";
16831 @@ -9248,6 +10003,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
16833 case DW_FORM_string:
16835 + case GDB_FORM_cached_string:
16836 fprintf_unfiltered (f, "string: \"%s\"",
16837 DW_STRING (&die->attrs[i])
16838 ? DW_STRING (&die->attrs[i]) : "");
16839 @@ -9353,26 +10109,35 @@ dwarf2_get_ref_die_offset (struct attribute *attr)
16843 -/* Return the constant value held by the given attribute. Return -1
16844 - if the value held by the attribute is not constant. */
16845 +/* (*val_return) is filled only if returning dwarf2_attr_const. */
16848 -dwarf2_get_attr_constant_value (struct attribute *attr, int default_value)
16849 +static enum dwarf2_get_attr_constant_value
16850 +dwarf2_get_attr_constant_value (struct attribute *attr, int *val_return)
16852 + if (attr == NULL)
16853 + return dwarf2_attr_unknown;
16854 if (attr->form == DW_FORM_sdata)
16855 - return DW_SND (attr);
16856 - else if (attr->form == DW_FORM_udata
16857 - || attr->form == DW_FORM_data1
16858 - || attr->form == DW_FORM_data2
16859 - || attr->form == DW_FORM_data4
16860 - || attr->form == DW_FORM_data8)
16861 - return DW_UNSND (attr);
16864 - complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"),
16865 - dwarf_form_name (attr->form));
16866 - return default_value;
16867 + *val_return = DW_SND (attr);
16868 + return dwarf2_attr_const;
16870 + if (attr->form == DW_FORM_udata
16871 + || attr->form == DW_FORM_data1
16872 + || attr->form == DW_FORM_data2
16873 + || attr->form == DW_FORM_data4
16874 + || attr->form == DW_FORM_data8)
16876 + *val_return = DW_UNSND (attr);
16877 + return dwarf2_attr_const;
16879 + if (attr->form == DW_FORM_block
16880 + || attr->form == DW_FORM_block1
16881 + || attr->form == DW_FORM_block2
16882 + || attr->form == DW_FORM_block4)
16883 + return dwarf2_attr_block;
16884 + complaint (&symfile_complaints, _("Attribute value is not a constant (%s)"),
16885 + dwarf_form_name (attr->form));
16886 + return dwarf2_attr_unknown;
16889 /* THIS_CU has a reference to PER_CU. If necessary, load the new compilation
16890 @@ -9963,6 +10728,17 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
16892 gdb_byte *mac_ptr, *mac_end;
16893 struct macro_source_file *current_file = 0;
16894 + enum dwarf_macinfo_record_type macinfo_type;
16896 + /* Flag is in use by the second pass and determines if GDB is still before
16897 + first DW_MACINFO_start_file. If true GDB is still reading the definitions
16898 + from command line. First DW_MACINFO_start_file will need to be ignored as
16899 + it was already executed to create CURRENT_FILE for the main source holding
16900 + also the command line definitions. On first met DW_MACINFO_start_file
16901 + this flag is reset to normally execute all the remaining
16902 + DW_MACINFO_start_file macinfos. */
16904 + int at_commandline;
16906 if (dwarf2_per_objfile->macinfo_buffer == NULL)
16908 @@ -9970,19 +10746,24 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
16912 + /* Start the first pass to find ahead the main source file name. GDB has to
16913 + create CURRENT_FILE where to place the macros given to the compiler
16914 + from the command line. Such command line macros are present before first
16915 + DW_MACINFO_start_file but still those macros are associated to the
16916 + compilation unit. The compilation unit GDB identifies by its main source
16919 mac_ptr = dwarf2_per_objfile->macinfo_buffer + offset;
16920 mac_end = dwarf2_per_objfile->macinfo_buffer
16921 + dwarf2_per_objfile->macinfo_size;
16926 - enum dwarf_macinfo_record_type macinfo_type;
16928 /* Do we at least have room for a macinfo type byte? */
16929 if (mac_ptr >= mac_end)
16931 dwarf2_macros_too_long_complaint ();
16936 macinfo_type = read_1_byte (abfd, mac_ptr);
16937 @@ -9993,7 +10774,81 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
16938 /* A zero macinfo type indicates the end of the macro
16944 + case DW_MACINFO_define:
16945 + case DW_MACINFO_undef:
16946 + /* Only skip the data by MAC_PTR. */
16948 + unsigned int bytes_read;
16950 + read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
16951 + mac_ptr += bytes_read;
16952 + read_string (abfd, mac_ptr, &bytes_read);
16953 + mac_ptr += bytes_read;
16957 + case DW_MACINFO_start_file:
16959 + unsigned int bytes_read;
16962 + line = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
16963 + mac_ptr += bytes_read;
16964 + file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
16965 + mac_ptr += bytes_read;
16967 + current_file = macro_start_file (file, line, current_file, comp_dir,
16968 + lh, cu->objfile);
16972 + case DW_MACINFO_end_file:
16973 + /* No data to skip by MAC_PTR. */
16976 + case DW_MACINFO_vendor_ext:
16977 + /* Only skip the data by MAC_PTR. */
16979 + unsigned int bytes_read;
16981 + read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
16982 + mac_ptr += bytes_read;
16983 + read_string (abfd, mac_ptr, &bytes_read);
16984 + mac_ptr += bytes_read;
16991 + } while (macinfo_type != 0 && current_file == NULL);
16993 + /* Here is the second pass to read in the macros starting from the ones
16994 + defined at the command line. */
16996 + mac_ptr = dwarf2_per_objfile->macinfo_buffer + offset;
16997 + at_commandline = 1;
17001 + /* Do we at least have room for a macinfo type byte? */
17002 + if (mac_ptr >= mac_end)
17004 + /* Complaint is in the first pass above. */
17008 + macinfo_type = read_1_byte (abfd, mac_ptr);
17011 + switch (macinfo_type)
17013 + /* A zero macinfo type indicates the end of the macro
17018 case DW_MACINFO_define:
17019 case DW_MACINFO_undef:
17020 @@ -10008,19 +10863,31 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
17021 mac_ptr += bytes_read;
17023 if (! current_file)
17025 + /* DWARF violation as no main source is present. */
17026 + complaint (&symfile_complaints,
17027 + _("debug info with no main source gives macro %s "
17028 + "on line %d: %s"),
17030 + DW_MACINFO_define ? _("definition") : macinfo_type ==
17031 + DW_MACINFO_undef ? _("undefinition") :
17032 + "something-or-other", line, body);
17035 + if (at_commandline != (line == 0))
17036 complaint (&symfile_complaints,
17037 - _("debug info gives macro %s outside of any file: %s"),
17038 + _("debug info gives %s macro %s with %s line %d: %s"),
17039 + at_commandline ? _("command-line") : _("in-file"),
17041 - DW_MACINFO_define ? "definition" : macinfo_type ==
17042 - DW_MACINFO_undef ? "undefinition" :
17043 - "something-or-other", body);
17046 - if (macinfo_type == DW_MACINFO_define)
17047 - parse_macro_definition (current_file, line, body);
17048 - else if (macinfo_type == DW_MACINFO_undef)
17049 - macro_undef (current_file, line, body);
17051 + DW_MACINFO_define ? _("definition") : macinfo_type ==
17052 + DW_MACINFO_undef ? _("undefinition") :
17053 + "something-or-other",
17054 + line == 0 ? _("zero") : _("non-zero"), line, body);
17056 + if (macinfo_type == DW_MACINFO_define)
17057 + parse_macro_definition (current_file, line, body);
17058 + else if (macinfo_type == DW_MACINFO_undef)
17059 + macro_undef (current_file, line, body);
17063 @@ -10034,9 +10901,22 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
17064 file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
17065 mac_ptr += bytes_read;
17067 - current_file = macro_start_file (file, line,
17068 - current_file, comp_dir,
17069 - lh, cu->objfile);
17070 + if (at_commandline != (line == 0))
17071 + complaint (&symfile_complaints,
17072 + _("debug info gives source %d included "
17073 + "from %s at %s line %d"),
17074 + file, at_commandline ? _("command-line") : _("file"),
17075 + line == 0 ? _("zero") : _("non-zero"), line);
17077 + if (at_commandline)
17079 + /* This DW_MACINFO_start_file was executed in the pass one. */
17080 + at_commandline = 0;
17083 + current_file = macro_start_file (file, line,
17084 + current_file, comp_dir,
17085 + lh, cu->objfile);
17089 @@ -10090,7 +10970,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
17094 + } while (macinfo_type != 0);
17097 /* Check if the attribute's form is a DW_FORM_block*
17098 @@ -10150,6 +11030,34 @@ attr_form_is_constant (struct attribute *attr)
17102 +/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK
17103 + attribute type. */
17105 +static struct dwarf2_locexpr_baton *
17106 +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
17108 + struct dwarf2_locexpr_baton *baton;
17110 + gdb_assert (attr_form_is_block (attr));
17112 + baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
17113 + baton->per_cu = cu->per_cu;
17114 + gdb_assert (baton->per_cu);
17116 + /* Note that we're just copying the block's data pointer
17117 + here, not the actual data. We're still pointing into the
17118 + info_buffer for SYM's objfile; right now we never release
17119 + that buffer, but when we do clean up properly this may
17120 + need to change. */
17121 + baton->size = DW_BLOCK (attr)->size;
17122 + baton->data = DW_BLOCK (attr)->data;
17123 + gdb_assert (baton->size == 0 || baton->data != NULL);
17128 +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */
17131 dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
17132 struct dwarf2_cu *cu)
17133 @@ -10179,35 +11087,24 @@ dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
17134 SYMBOL_OPS (sym) = &dwarf2_loclist_funcs;
17135 SYMBOL_LOCATION_BATON (sym) = baton;
17137 + else if (attr_form_is_block (attr))
17139 + SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs;
17140 + SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
17144 - struct dwarf2_locexpr_baton *baton;
17145 + dwarf2_invalid_attrib_class_complaint ("location description",
17146 + SYMBOL_NATURAL_NAME (sym));
17148 - baton = obstack_alloc (&cu->objfile->objfile_obstack,
17149 - sizeof (struct dwarf2_locexpr_baton));
17150 - baton->per_cu = cu->per_cu;
17151 - gdb_assert (baton->per_cu);
17152 + /* Some methods are called without checking SYMBOL_OPS validity. */
17153 + SYMBOL_OPS (sym) = &dwarf2_missing_funcs;
17154 + SYMBOL_LOCATION_BATON (sym) = NULL;
17156 - if (attr_form_is_block (attr))
17158 - /* Note that we're just copying the block's data pointer
17159 - here, not the actual data. We're still pointing into the
17160 - info_buffer for SYM's objfile; right now we never release
17161 - that buffer, but when we do clean up properly this may
17162 - need to change. */
17163 - baton->size = DW_BLOCK (attr)->size;
17164 - baton->data = DW_BLOCK (attr)->data;
17168 - dwarf2_invalid_attrib_class_complaint ("location description",
17169 - SYMBOL_NATURAL_NAME (sym));
17171 - baton->data = NULL;
17174 - SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs;
17175 - SYMBOL_LOCATION_BATON (sym) = baton;
17176 + /* For functions a missing DW_AT_frame_base does not optimize out the
17177 + whole function definition, only its frame base resolving. */
17178 + if (attr->name == DW_AT_location)
17179 + SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
17183 @@ -10482,6 +11379,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs)
17184 return ofs_lhs->offset == ofs_rhs->offset;
17187 +/* Fill in generic attributes applicable for type DIEs. */
17190 +fetch_die_type_attrs (struct die_info *die, struct type *type,
17191 + struct dwarf2_cu *cu)
17193 + struct attribute *attr;
17195 + attr = dwarf2_attr (die, DW_AT_data_location, cu);
17196 + if (attr_form_is_block (attr))
17197 + TYPE_DATA_LOCATION_DWARF_BLOCK (type) = dwarf2_attr_to_locexpr_baton (attr,
17199 + gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
17201 + attr = dwarf2_attr (die, DW_AT_allocated, cu);
17202 + if (attr_form_is_block (attr))
17203 + TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
17204 + gdb_assert (!TYPE_NOT_ALLOCATED (type));
17206 + attr = dwarf2_attr (die, DW_AT_associated, cu);
17207 + if (attr_form_is_block (attr))
17208 + TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
17209 + gdb_assert (!TYPE_NOT_ASSOCIATED (type));
17212 /* Set the type associated with DIE to TYPE. Save it in CU's hash
17213 table if necessary. For convenience, return TYPE. */
17215 @@ -10490,6 +11412,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
17217 struct dwarf2_offset_and_type **slot, ofs;
17219 + fetch_die_type_attrs (die, type, cu);
17221 if (cu->type_hash == NULL)
17223 gdb_assert (cu->per_cu != NULL);
17224 diff --git a/gdb/elfread.c b/gdb/elfread.c
17225 index ff220a2..13158f4 100644
17226 --- a/gdb/elfread.c
17227 +++ b/gdb/elfread.c
17228 @@ -727,10 +727,18 @@ elf_symfile_read (struct objfile *objfile, int mainline)
17230 bfd_section_size (abfd, str_sect));
17233 + if (dwarf2_has_info (objfile))
17234 + dwarf2_create_quick_addrmap (objfile);
17238 +read_psyms (struct objfile *objfile)
17240 if (dwarf2_has_info (objfile))
17242 /* DWARF 2 sections */
17243 - dwarf2_build_psymtabs (objfile, mainline);
17244 + dwarf2_build_psymtabs (objfile, 0);
17247 /* FIXME: kettenis/20030504: This still needs to be integrated with
17248 @@ -880,6 +888,7 @@ static struct sym_fns elf_sym_fns =
17249 elf_new_init, /* sym_new_init: init anything gbl to entire symtab */
17250 elf_symfile_init, /* sym_init: read initial info, setup for sym_read() */
17251 elf_symfile_read, /* sym_read: read a symbol file into symtab */
17252 + read_psyms, /* sym_read_psymbols */
17253 elf_symfile_finish, /* sym_finish: finished with file, cleanup */
17254 default_symfile_offsets, /* sym_offsets: Translate ext. to int. relocation */
17255 elf_symfile_segments, /* sym_segments: Get segment information from
17256 diff --git a/gdb/eval.c b/gdb/eval.c
17257 index 1d35571..6a97e09 100644
17260 @@ -39,10 +39,16 @@
17261 #include "exceptions.h"
17262 #include "regcache.h"
17263 #include "user-regs.h"
17264 +#include "python/python.h"
17265 #include "valprint.h"
17266 +#include "dwarf2loc.h"
17267 +#include "gdb_obstack.h"
17268 +#include "objfiles.h"
17270 #include "gdb_assert.h"
17272 +#include <ctype.h>
17274 /* This is defined in valops.c */
17275 extern int overload_resolution;
17277 @@ -651,6 +657,64 @@ ptrmath_type_p (struct type *type)
17281 +/* Compares the two method/function types T1 and T2 for "equality"
17282 + with respect to the the methods' parameters. If the types of the
17283 + two parameter lists are the same, returns 1; 0 otherwise. This
17284 + comparison ignores any artificial this pointer. */
17286 +compare_parameters (struct type *t1, struct type *t2)
17289 + /* Hacky: we don't know a priori whether or not t1 is a static
17290 + method, so we skip any artificial "this" pointer and hope
17291 + for the best. t2, which comes as user input, never contains a
17292 + "this" pointer (a user would never enter it into expressions. */
17293 + if (TYPE_NFIELDS (t1) > 0)
17294 + has_this = TYPE_FIELD_ARTIFICIAL (t1, 0) ? 1 : 0;
17298 + /* Special case: a method taking void. t1 will contain either
17299 + no fields or just "this". t2 will contain TYPE_CODE_VOID. */
17300 + if ((TYPE_NFIELDS (t1) - has_this) == 0 && TYPE_NFIELDS (t2) == 1
17301 + && TYPE_CODE (TYPE_FIELD_TYPE (t2, 0)) == TYPE_CODE_VOID)
17304 + if ((TYPE_NFIELDS (t1) - has_this) == TYPE_NFIELDS (t2))
17306 + for (i = has_this; i < TYPE_NFIELDS (t1); ++i)
17308 + if (rank_one_type (TYPE_FIELD_TYPE (t1, i),
17309 + TYPE_FIELD_TYPE (t2, i - has_this))
17320 +/* Constructs a fake method with the given parameter types. */
17322 +static struct type *
17323 +make_params (int num_types, struct type **param_types)
17325 + struct type *type = alloc_type (NULL, NULL);
17326 + TYPE_LENGTH (type) = 1;
17327 + TYPE_CODE (type) = TYPE_CODE_METHOD;
17328 + TYPE_NFIELDS (type) = num_types;
17329 + TYPE_FIELDS (type) = (struct field *)
17330 + TYPE_ALLOC (type, sizeof (struct field) * num_types);
17331 + memset (TYPE_FIELDS (type), 0, sizeof (struct field) * num_types);
17333 + while (num_types-- > 0)
17334 + TYPE_FIELD_TYPE (type, num_types) = param_types[num_types];
17340 evaluate_subexp_standard (struct type *expect_type,
17341 struct expression *exp, int *pos,
17342 @@ -671,6 +735,7 @@ evaluate_subexp_standard (struct type *expect_type,
17344 struct type **arg_types;
17346 + struct cleanup *old_chain;
17349 op = exp->elts[pc].opcode;
17350 @@ -684,7 +749,7 @@ evaluate_subexp_standard (struct type *expect_type,
17352 arg1 = value_aggregate_elt (exp->elts[pc + 1].type,
17353 &exp->elts[pc + 3].string,
17355 + expect_type, 0, noside);
17357 error (_("There is no field named %s"), &exp->elts[pc + 3].string);
17359 @@ -1208,9 +1273,9 @@ evaluate_subexp_standard (struct type *expect_type,
17360 if (TYPE_CODE (value_type (method)) != TYPE_CODE_FUNC)
17361 error (_("method address has symbol information with non-function type; skipping"));
17363 - VALUE_ADDRESS (method) = value_as_address (msg_send_stret);
17364 + set_value_address (method, value_as_address (msg_send_stret));
17366 - VALUE_ADDRESS (method) = value_as_address (msg_send);
17367 + set_value_address (method, value_as_address (msg_send));
17368 called_method = method;
17371 @@ -1284,7 +1349,6 @@ evaluate_subexp_standard (struct type *expect_type,
17372 argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3));
17373 if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
17376 /* First, evaluate the structure into arg2 */
17379 @@ -1308,21 +1372,40 @@ evaluate_subexp_standard (struct type *expect_type,
17381 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
17383 - if (TYPE_CODE (check_typedef (value_type (arg1)))
17384 - != TYPE_CODE_METHODPTR)
17385 - error (_("Non-pointer-to-member value used in pointer-to-member "
17388 - if (noside == EVAL_AVOID_SIDE_EFFECTS)
17389 + type = check_typedef (value_type (arg1));
17390 + switch (TYPE_CODE (type))
17392 - struct type *method_type = check_typedef (value_type (arg1));
17393 - arg1 = value_zero (method_type, not_lval);
17394 + case TYPE_CODE_METHODPTR:
17395 + if (noside == EVAL_AVOID_SIDE_EFFECTS)
17396 + arg1 = value_zero (TYPE_TARGET_TYPE (type), not_lval);
17398 + arg1 = cplus_method_ptr_to_value (&arg2, arg1);
17400 + /* Now, say which argument to start evaluating from */
17403 + argvec[1] = arg2;
17406 + case TYPE_CODE_MEMBERPTR:
17407 + /* Now, convert these values to an address. */
17408 + arg2 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
17411 + mem_offset = value_as_long (arg1);
17413 + arg1 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
17414 + value_as_long (arg2) + mem_offset);
17415 + arg1 = value_ind (arg1);
17420 + error (_("Non-pointer-to-member value used in pointer-to-member "
17424 - arg1 = cplus_method_ptr_to_value (&arg2, arg1);
17426 - /* Now, say which argument to start evaluating from */
17428 + argvec[0] = arg1;
17430 else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
17432 @@ -1434,7 +1517,7 @@ evaluate_subexp_standard (struct type *expect_type,
17433 of the ``this'' pointer if necessary, so modify argvec[1] to
17434 reflect any ``this'' changes. */
17435 arg2 = value_from_longest (lookup_pointer_type(value_type (temp)),
17436 - VALUE_ADDRESS (temp) + value_offset (temp)
17437 + value_address (temp)
17438 + value_embedded_offset (temp));
17439 argvec[1] = arg2; /* the ``this'' pointer */
17441 @@ -1448,8 +1531,7 @@ evaluate_subexp_standard (struct type *expect_type,
17443 else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
17445 - argvec[1] = arg2;
17446 - argvec[0] = arg1;
17447 + /* Pointer to member. argvec is already set up. */
17449 else if (op == OP_VAR_VALUE)
17451 @@ -1512,6 +1594,9 @@ evaluate_subexp_standard (struct type *expect_type,
17453 error (_("Expression of type other than \"Function returning ...\" used as function"));
17455 + if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_INTERNAL_FUNCTION)
17456 + return call_internal_function (argvec[0], nargs, argvec + 1);
17458 return call_function_by_hand (argvec[0], nargs, argvec + 1);
17459 /* pai: FIXME save value from call_function_by_hand, then adjust pc by adjust_fn_pc if +ve */
17461 @@ -1529,7 +1614,10 @@ evaluate_subexp_standard (struct type *expect_type,
17463 /* First determine the type code we are dealing with. */
17464 arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
17465 + old_chain = make_cleanup (null_cleanup, 0);
17466 + object_address_set (VALUE_ADDRESS (arg1));
17467 type = check_typedef (value_type (arg1));
17468 + do_cleanups (old_chain);
17469 code = TYPE_CODE (type);
17471 if (code == TYPE_CODE_PTR)
17472 @@ -1696,6 +1784,37 @@ evaluate_subexp_standard (struct type *expect_type,
17473 error (_("non-pointer-to-member value used in pointer-to-member construct"));
17476 + case TYPE_INSTANCE:
17477 + nargs = longest_to_int (exp->elts[pc + 1].longconst);
17478 + arg_types = (struct type **) alloca (nargs * sizeof (struct type *));
17479 + for (ix = 0; ix < nargs; ++ix)
17480 + arg_types[ix] = exp->elts[pc + 1 + ix + 1].type;
17482 + expect_type = make_params (nargs, arg_types);
17483 + *(pos) += 3 + nargs;
17484 + return evaluate_subexp_standard (expect_type, exp, pos, noside);
17486 + case TYPE_INSTANCE_LOOKUP:
17489 + struct symbol *sym;
17490 + struct type **arg_types;
17492 + printf ("TYPE_INSTANCE_LOOKUP\n");
17493 + arg_types = (struct type **) alloca (TYPE_NFIELDS (expect_type)
17494 + * sizeof (struct type *));
17495 + for (i = 0; i < TYPE_NFIELDS (expect_type); ++i)
17496 + arg_types[i] = TYPE_FIELD_TYPE (expect_type, i);
17497 + (void) find_overload_match (arg_types, TYPE_NFIELDS (expect_type),
17498 + NULL /* no need for name */,
17499 + 0 /* not method */,
17500 + 0 /* strict match */,
17501 + NULL, exp->elts[pc + 1].symbol, NULL,
17508 arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
17509 arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
17510 @@ -1963,13 +2082,19 @@ evaluate_subexp_standard (struct type *expect_type,
17512 int subscript_array[MAX_FORTRAN_DIMS];
17513 int array_size_array[MAX_FORTRAN_DIMS];
17514 + int byte_stride_array[MAX_FORTRAN_DIMS];
17515 int ndimensions = 1, i;
17516 struct type *tmp_type;
17517 int offset_item; /* The array offset where the item lives */
17518 + CORE_ADDR offset_byte; /* byte_stride based offset */
17519 + unsigned element_size;
17521 if (nargs > MAX_FORTRAN_DIMS)
17522 error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
17524 + old_chain = make_cleanup (null_cleanup, 0);
17525 + object_address_set (VALUE_ADDRESS (arg1));
17527 tmp_type = check_typedef (value_type (arg1));
17528 ndimensions = calc_f77_array_dims (type);
17530 @@ -1999,6 +2124,9 @@ evaluate_subexp_standard (struct type *expect_type,
17531 upper = f77_get_upperbound (tmp_type);
17532 lower = f77_get_lowerbound (tmp_type);
17534 + byte_stride_array[nargs - i - 1] =
17535 + TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
17537 array_size_array[nargs - i - 1] = upper - lower + 1;
17539 /* Zero-normalize subscripts so that offsetting will work. */
17540 @@ -2017,17 +2145,25 @@ evaluate_subexp_standard (struct type *expect_type,
17541 tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
17544 - /* Now let us calculate the offset for this item */
17545 + /* Kept for the f77_get_upperbound / f77_get_lowerbound calls above. */
17546 + do_cleanups (old_chain);
17548 - offset_item = subscript_array[ndimensions - 1];
17549 + /* Now let us calculate the offset for this item */
17551 - for (i = ndimensions - 1; i > 0; --i)
17553 - array_size_array[i - 1] * offset_item + subscript_array[i - 1];
17557 - /* Construct a value node with the value of the offset */
17558 + for (i = ndimensions - 1; i >= 0; --i)
17560 + offset_item *= array_size_array[i];
17561 + if (byte_stride_array[i] == 0)
17562 + offset_item += subscript_array[i];
17564 + offset_byte += subscript_array[i] * byte_stride_array[i];
17567 - arg2 = value_from_longest (builtin_type_int32, offset_item);
17568 + element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tmp_type));
17569 + offset_byte += offset_item * element_size;
17571 /* Let us now play a dirty trick: we will take arg1
17572 which is a value node pointing to the topmost level
17573 @@ -2037,7 +2173,7 @@ evaluate_subexp_standard (struct type *expect_type,
17574 returns the correct type value */
17576 deprecated_set_value_type (arg1, tmp_type);
17577 - return value_subscripted_rvalue (arg1, arg2, 0);
17578 + return value_subscripted_rvalue (arg1, offset_byte);
17581 case BINOP_LOGICAL_AND:
17582 @@ -2475,7 +2611,17 @@ evaluate_subexp_standard (struct type *expect_type,
17583 if (noside == EVAL_SKIP)
17585 else if (noside == EVAL_AVOID_SIDE_EFFECTS)
17586 - return allocate_value (exp->elts[pc + 1].type);
17588 + struct type *type = exp->elts[pc + 1].type;
17589 + /* If this is a typedef, then find its immediate target. We
17590 + use check_typedef to resolve stubs, but we ignore its
17591 + result because we do not want to dig past all
17593 + check_typedef (type);
17594 + if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
17595 + type = TYPE_TARGET_TYPE (type);
17596 + return allocate_value (type);
17599 error (_("Attempt to use a type name as an expression"));
17601 @@ -2568,7 +2714,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos,
17602 (*pos) += 5 + BYTES_TO_EXP_ELEM (tem + 1);
17603 x = value_aggregate_elt (exp->elts[pc + 1].type,
17604 &exp->elts[pc + 3].string,
17606 + NULL, 1, noside);
17608 error (_("There is no field named %s"), &exp->elts[pc + 3].string);
17610 @@ -2613,7 +2759,7 @@ evaluate_subexp_with_coercion (struct expression *exp,
17612 enum exp_opcode op;
17614 - struct value *val;
17615 + struct value *val = NULL;
17616 struct symbol *var;
17619 @@ -2624,12 +2770,17 @@ evaluate_subexp_with_coercion (struct expression *exp,
17622 var = exp->elts[pc + 2].symbol;
17623 + /* address_of_variable will call object_address_set for check_typedef.
17624 + Call it only if required as it can error-out on VAR in register. */
17625 + if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
17626 + val = address_of_variable (var, exp->elts[pc + 1].block);
17627 type = check_typedef (SYMBOL_TYPE (var));
17628 if (TYPE_CODE (type) == TYPE_CODE_ARRAY
17629 && CAST_IS_CONVERSION)
17632 - val = address_of_variable (var, exp->elts[pc + 1].block);
17634 + val = address_of_variable (var, exp->elts[pc + 1].block);
17635 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
17638 @@ -2681,9 +2832,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
17642 - type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
17644 - value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
17645 + /* We do not need to call read_var_value but the object evaluation may
17646 + need to have executed object_address_set which needs valid
17647 + SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by
17648 + read_var_value we left as lazy. */
17649 + type = value_type (read_var_value (exp->elts[pc + 2].symbol,
17650 + deprecated_safe_get_selected_frame ()));
17651 + return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
17654 val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
17655 diff --git a/gdb/expprint.c b/gdb/expprint.c
17656 index 89bae03..f768940 100644
17657 --- a/gdb/expprint.c
17658 +++ b/gdb/expprint.c
17659 @@ -186,8 +186,8 @@ print_subexp_standard (struct expression *exp, int *pos,
17660 If necessary, we can temporarily set it to zero, or pass it as an
17661 additional parameter to LA_PRINT_STRING. -fnf */
17662 get_user_print_options (&opts);
17663 - LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
17665 + LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17666 + &exp->elts[pc + 2].string, nargs, 0, &opts);
17670 @@ -205,8 +205,8 @@ print_subexp_standard (struct expression *exp, int *pos,
17671 (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
17672 fputs_filtered ("@\"", stream);
17673 get_user_print_options (&opts);
17674 - LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
17676 + LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17677 + &exp->elts[pc + 2].string, nargs, 0, &opts);
17678 fputs_filtered ("\"", stream);
17681 @@ -291,8 +291,8 @@ print_subexp_standard (struct expression *exp, int *pos,
17683 struct value_print_options opts;
17684 get_user_print_options (&opts);
17685 - LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
17687 + LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17688 + tempstr, nargs - 1, 0, &opts);
17692 diff --git a/gdb/expression.h b/gdb/expression.h
17693 index 12163e3..789cb89 100644
17694 --- a/gdb/expression.h
17695 +++ b/gdb/expression.h
17696 @@ -88,6 +88,16 @@ enum exp_opcode
17697 when X is a pointer instead of an aggregate. */
17700 + /* TYPE_INSTANCE is used when the user specifies a specific
17701 + type instantiation for overloaded methods/functions. The format
17702 + is: TYPE_INSTANCE num_types type0 ... typeN num_types TYPE_INSTANCE*/
17705 + /* TYPE_INSTANCE_LOOKUP is used when the user specifies a specific
17706 + type instantiation of a function (not a method). In this case,
17707 + we must toss the results of the parser and manually do the lookup. */
17708 + TYPE_INSTANCE_LOOKUP,
17712 /* For Modula-2 integer division DIV */
17713 @@ -426,6 +436,8 @@ enum noside
17714 extern struct value *evaluate_subexp_standard
17715 (struct type *, struct expression *, int *, enum noside);
17717 +extern int compare_parameters (struct type *, struct type *);
17719 /* From expprint.c */
17721 extern void print_expression (struct expression *, struct ui_file *);
17722 @@ -435,4 +447,5 @@ extern char *op_string (enum exp_opcode);
17723 extern void dump_raw_expression (struct expression *, struct ui_file *, char *);
17724 extern void dump_prefix_expression (struct expression *, struct ui_file *);
17727 #endif /* !defined (EXPRESSION_H) */
17728 diff --git a/gdb/f-exp.y b/gdb/f-exp.y
17729 index d91c413..c984e85 100644
17732 @@ -198,6 +198,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
17733 /* Special type cases, put in to allow the parser to distinguish different
17734 legal basetypes. */
17735 %token INT_KEYWORD INT_S2_KEYWORD LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD
17736 +%token LOGICAL_S8_KEYWORD
17737 %token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD
17738 %token COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD COMPLEX_S32_KEYWORD
17739 %token BOOL_AND BOOL_OR BOOL_NOT
17740 @@ -608,6 +609,8 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
17741 { $$ = parse_f_type->builtin_integer_s2; }
17743 { $$ = parse_f_type->builtin_character; }
17744 + | LOGICAL_S8_KEYWORD
17745 + { $$ = parse_f_type->builtin_logical_s8;}
17747 { $$ = parse_f_type->builtin_logical; }
17748 | LOGICAL_S2_KEYWORD
17749 @@ -860,6 +863,7 @@ static const struct token f77_keywords[] =
17750 { "integer_2", INT_S2_KEYWORD, BINOP_END },
17751 { "logical_1", LOGICAL_S1_KEYWORD, BINOP_END },
17752 { "logical_2", LOGICAL_S2_KEYWORD, BINOP_END },
17753 + { "logical_8", LOGICAL_S8_KEYWORD, BINOP_END },
17754 { "complex_8", COMPLEX_S8_KEYWORD, BINOP_END },
17755 { "integer", INT_KEYWORD, BINOP_END },
17756 { "logical", LOGICAL_KEYWORD, BINOP_END },
17757 diff --git a/gdb/f-lang.c b/gdb/f-lang.c
17758 index 6359841..1754c44 100644
17761 @@ -55,23 +55,10 @@ typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR;
17762 /* Local functions */
17764 extern void _initialize_f_language (void);
17766 -static void clear_function_list (void);
17767 -static long get_bf_for_fcn (long);
17768 -static void clear_bf_list (void);
17769 -static void patch_all_commons_by_name (char *, CORE_ADDR, int);
17770 -static SAVED_F77_COMMON_PTR find_first_common_named (char *);
17771 -static void add_common_entry (struct symbol *);
17772 -static void add_common_block (char *, CORE_ADDR, int, char *);
17773 -static SAVED_FUNCTION *allocate_saved_function_node (void);
17774 -static SAVED_BF_PTR allocate_saved_bf_node (void);
17775 -static COMMON_ENTRY_PTR allocate_common_entry_node (void);
17776 -static SAVED_F77_COMMON_PTR allocate_saved_f77_common_node (void);
17777 -static void patch_common_entries (SAVED_F77_COMMON_PTR, CORE_ADDR, int);
17780 -static void f_printchar (int c, struct ui_file * stream);
17781 -static void f_emit_char (int c, struct ui_file * stream, int quoter);
17783 +static void f_printchar (int c, struct type *type, struct ui_file * stream);
17784 +static void f_emit_char (int c, struct type *type,
17785 + struct ui_file * stream, int quoter);
17787 /* Print the character C on STREAM as part of the contents of a literal
17788 string whose delimiter is QUOTER. Note that that format for printing
17789 @@ -80,7 +67,7 @@ static void f_emit_char (int c, struct ui_file * stream, int quoter);
17790 be replaced with a true F77 version. */
17793 -f_emit_char (int c, struct ui_file *stream, int quoter)
17794 +f_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
17796 c &= 0xFF; /* Avoid sign bit follies */
17798 @@ -126,10 +113,10 @@ f_emit_char (int c, struct ui_file *stream, int quoter)
17799 be replaced with a true F77version. */
17802 -f_printchar (int c, struct ui_file *stream)
17803 +f_printchar (int c, struct type *type, struct ui_file *stream)
17805 fputs_filtered ("'", stream);
17806 - LA_EMIT_CHAR (c, stream, '\'');
17807 + LA_EMIT_CHAR (c, type, stream, '\'');
17808 fputs_filtered ("'", stream);
17811 @@ -141,14 +128,15 @@ f_printchar (int c, struct ui_file *stream)
17812 be replaced with a true F77 version. */
17815 -f_printstr (struct ui_file *stream, const gdb_byte *string,
17816 - unsigned int length, int width, int force_ellipses,
17817 +f_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
17818 + unsigned int length, int force_ellipses,
17819 const struct value_print_options *options)
17822 unsigned int things_printed = 0;
17824 int need_comma = 0;
17825 + int width = TYPE_LENGTH (type);
17829 @@ -190,7 +178,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
17830 fputs_filtered ("', ", stream);
17833 - f_printchar (string[i], stream);
17834 + f_printchar (string[i], type, stream);
17835 fprintf_filtered (stream, " <repeats %u times>", reps);
17837 things_printed += options->repeat_count_threshold;
17838 @@ -206,7 +194,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
17839 fputs_filtered ("'", stream);
17842 - LA_EMIT_CHAR (string[i], stream, '"');
17843 + LA_EMIT_CHAR (string[i], type, stream, '"');
17847 @@ -257,6 +245,7 @@ enum f_primitive_types {
17848 f_primitive_type_logical,
17849 f_primitive_type_logical_s1,
17850 f_primitive_type_logical_s2,
17851 + f_primitive_type_logical_s8,
17852 f_primitive_type_integer,
17853 f_primitive_type_integer_s2,
17854 f_primitive_type_real,
17855 @@ -287,6 +276,8 @@ f_language_arch_info (struct gdbarch *gdbarch,
17856 = builtin->builtin_logical_s1;
17857 lai->primitive_type_vector [f_primitive_type_logical_s2]
17858 = builtin->builtin_logical_s2;
17859 + lai->primitive_type_vector [f_primitive_type_logical_s8]
17860 + = builtin->builtin_logical_s8;
17861 lai->primitive_type_vector [f_primitive_type_real]
17862 = builtin->builtin_real;
17863 lai->primitive_type_vector [f_primitive_type_real_s8]
17864 @@ -378,6 +369,11 @@ build_fortran_types (struct gdbarch *gdbarch)
17865 gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
17866 TYPE_FLAG_UNSIGNED, "logical*2", (struct objfile *) NULL);
17868 + builtin_f_type->builtin_logical_s8 =
17869 + init_type (TYPE_CODE_BOOL,
17870 + gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
17871 + TYPE_FLAG_UNSIGNED, "logical*8", (struct objfile *) NULL);
17873 builtin_f_type->builtin_integer =
17874 init_type (TYPE_CODE_INT,
17875 gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
17876 @@ -451,395 +447,3 @@ _initialize_f_language (void)
17878 add_language (&f_language_defn);
17882 -static SAVED_BF_PTR
17883 -allocate_saved_bf_node (void)
17885 - SAVED_BF_PTR new;
17887 - new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF));
17891 -static SAVED_FUNCTION *
17892 -allocate_saved_function_node (void)
17894 - SAVED_FUNCTION *new;
17896 - new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION));
17900 -static SAVED_F77_COMMON_PTR
17901 -allocate_saved_f77_common_node (void)
17903 - SAVED_F77_COMMON_PTR new;
17905 - new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON));
17909 -static COMMON_ENTRY_PTR
17910 -allocate_common_entry_node (void)
17912 - COMMON_ENTRY_PTR new;
17914 - new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY));
17919 -SAVED_F77_COMMON_PTR head_common_list = NULL; /* Ptr to 1st saved COMMON */
17920 -SAVED_F77_COMMON_PTR tail_common_list = NULL; /* Ptr to last saved COMMON */
17921 -SAVED_F77_COMMON_PTR current_common = NULL; /* Ptr to current COMMON */
17924 -static SAVED_BF_PTR saved_bf_list = NULL; /* Ptr to (.bf,function)
17926 -static SAVED_BF_PTR saved_bf_list_end = NULL; /* Ptr to above list's end */
17927 -static SAVED_BF_PTR current_head_bf_list = NULL; /* Current head of above list
17930 -static SAVED_BF_PTR tmp_bf_ptr; /* Generic temporary for use
17933 -/* The following function simply enters a given common block onto
17934 - the global common block chain */
17937 -add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab)
17939 - SAVED_F77_COMMON_PTR tmp;
17940 - char *c, *local_copy_func_stab;
17942 - /* If the COMMON block we are trying to add has a blank
17943 - name (i.e. "#BLNK_COM") then we set it to __BLANK
17944 - because the darn "#" character makes GDB's input
17945 - parser have fits. */
17948 - if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
17949 - || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
17953 - name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
17954 - strcpy (name, BLANK_COMMON_NAME_LOCAL);
17957 - tmp = allocate_saved_f77_common_node ();
17959 - local_copy_func_stab = xmalloc (strlen (func_stab) + 1);
17960 - strcpy (local_copy_func_stab, func_stab);
17962 - tmp->name = xmalloc (strlen (name) + 1);
17964 - /* local_copy_func_stab is a stabstring, let us first extract the
17965 - function name from the stab by NULLing out the ':' character. */
17969 - c = strchr (local_copy_func_stab, ':');
17974 - error (_("Malformed function STAB found in add_common_block()"));
17977 - tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1);
17979 - strcpy (tmp->owning_function, local_copy_func_stab);
17981 - strcpy (tmp->name, name);
17982 - tmp->offset = offset;
17983 - tmp->next = NULL;
17984 - tmp->entries = NULL;
17985 - tmp->secnum = secnum;
17987 - current_common = tmp;
17989 - if (head_common_list == NULL)
17991 - head_common_list = tail_common_list = tmp;
17995 - tail_common_list->next = tmp;
17996 - tail_common_list = tmp;
18001 -/* The following function simply enters a given common entry onto
18002 - the "current_common" block that has been saved away. */
18006 -add_common_entry (struct symbol *entry_sym_ptr)
18008 - COMMON_ENTRY_PTR tmp;
18012 - /* The order of this list is important, since
18013 - we expect the entries to appear in decl.
18014 - order when we later issue "info common" calls */
18016 - tmp = allocate_common_entry_node ();
18018 - tmp->next = NULL;
18019 - tmp->symbol = entry_sym_ptr;
18021 - if (current_common == NULL)
18022 - error (_("Attempt to add COMMON entry with no block open!"));
18025 - if (current_common->entries == NULL)
18027 - current_common->entries = tmp;
18028 - current_common->end_of_entries = tmp;
18032 - current_common->end_of_entries->next = tmp;
18033 - current_common->end_of_entries = tmp;
18039 -/* This routine finds the first encountred COMMON block named "name" */
18042 -static SAVED_F77_COMMON_PTR
18043 -find_first_common_named (char *name)
18046 - SAVED_F77_COMMON_PTR tmp;
18048 - tmp = head_common_list;
18050 - while (tmp != NULL)
18052 - if (strcmp (tmp->name, name) == 0)
18061 -/* This routine finds the first encountred COMMON block named "name"
18062 - that belongs to function funcname */
18064 -SAVED_F77_COMMON_PTR
18065 -find_common_for_function (char *name, char *funcname)
18068 - SAVED_F77_COMMON_PTR tmp;
18070 - tmp = head_common_list;
18072 - while (tmp != NULL)
18074 - if (strcmp (tmp->name, name) == 0
18075 - && strcmp (tmp->owning_function, funcname) == 0)
18086 -/* The following function is called to patch up the offsets
18087 - for the statics contained in the COMMON block named
18091 -patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum)
18093 - COMMON_ENTRY_PTR entry;
18095 - blk->offset = offset; /* Keep this around for future use. */
18097 - entry = blk->entries;
18099 - while (entry != NULL)
18101 - SYMBOL_VALUE (entry->symbol) += offset;
18102 - SYMBOL_SECTION (entry->symbol) = secnum;
18104 - entry = entry->next;
18106 - blk->secnum = secnum;
18109 -/* Patch all commons named "name" that need patching.Since COMMON
18110 - blocks occur with relative infrequency, we simply do a linear scan on
18111 - the name. Eventually, the best way to do this will be a
18112 - hashed-lookup. Secnum is the section number for the .bss section
18113 - (which is where common data lives). */
18116 -patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum)
18119 - SAVED_F77_COMMON_PTR tmp;
18121 - /* For blank common blocks, change the canonical reprsentation
18122 - of a blank name */
18124 - if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
18125 - || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
18128 - name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
18129 - strcpy (name, BLANK_COMMON_NAME_LOCAL);
18132 - tmp = head_common_list;
18134 - while (tmp != NULL)
18136 - if (COMMON_NEEDS_PATCHING (tmp))
18137 - if (strcmp (tmp->name, name) == 0)
18138 - patch_common_entries (tmp, offset, secnum);
18145 -/* This macro adds the symbol-number for the start of the function
18146 - (the symbol number of the .bf) referenced by symnum_fcn to a
18147 - list. This list, in reality should be a FIFO queue but since
18148 - #line pragmas sometimes cause line ranges to get messed up
18149 - we simply create a linear list. This list can then be searched
18150 - first by a queueing algorithm and upon failure fall back to
18151 - a linear scan. */
18154 -#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
18156 - if (saved_bf_list == NULL) \
18158 - tmp_bf_ptr = allocate_saved_bf_node(); \
18160 - tmp_bf_ptr->symnum_bf = (bf_sym); \
18161 - tmp_bf_ptr->symnum_fcn = (fcn_sym); \
18162 - tmp_bf_ptr->next = NULL; \
18164 - current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
18165 - saved_bf_list_end = tmp_bf_ptr; \
18169 - tmp_bf_ptr = allocate_saved_bf_node(); \
18171 - tmp_bf_ptr->symnum_bf = (bf_sym); \
18172 - tmp_bf_ptr->symnum_fcn = (fcn_sym); \
18173 - tmp_bf_ptr->next = NULL; \
18175 - saved_bf_list_end->next = tmp_bf_ptr; \
18176 - saved_bf_list_end = tmp_bf_ptr; \
18180 -/* This function frees the entire (.bf,function) list */
18184 -clear_bf_list (void)
18187 - SAVED_BF_PTR tmp = saved_bf_list;
18188 - SAVED_BF_PTR next = NULL;
18190 - while (tmp != NULL)
18192 - next = tmp->next;
18196 - saved_bf_list = NULL;
18200 -int global_remote_debug;
18205 -get_bf_for_fcn (long the_function)
18207 - SAVED_BF_PTR tmp;
18210 - /* First use a simple queuing algorithm (i.e. look and see if the
18211 - item at the head of the queue is the one you want) */
18213 - if (saved_bf_list == NULL)
18214 - internal_error (__FILE__, __LINE__,
18215 - _("cannot get .bf node off empty list"));
18217 - if (current_head_bf_list != NULL)
18218 - if (current_head_bf_list->symnum_fcn == the_function)
18220 - if (global_remote_debug)
18221 - fprintf_unfiltered (gdb_stderr, "*");
18223 - tmp = current_head_bf_list;
18224 - current_head_bf_list = current_head_bf_list->next;
18225 - return (tmp->symnum_bf);
18228 - /* If the above did not work (probably because #line directives were
18229 - used in the sourcefile and they messed up our internal tables) we now do
18230 - the ugly linear scan */
18232 - if (global_remote_debug)
18233 - fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
18236 - tmp = saved_bf_list;
18237 - while (tmp != NULL)
18240 - if (tmp->symnum_fcn == the_function)
18242 - if (global_remote_debug)
18243 - fprintf_unfiltered (gdb_stderr, "Found in %d probes\n", nprobes);
18244 - current_head_bf_list = tmp->next;
18245 - return (tmp->symnum_bf);
18253 -static SAVED_FUNCTION_PTR saved_function_list = NULL;
18254 -static SAVED_FUNCTION_PTR saved_function_list_end = NULL;
18257 -clear_function_list (void)
18259 - SAVED_FUNCTION_PTR tmp = saved_function_list;
18260 - SAVED_FUNCTION_PTR next = NULL;
18262 - while (tmp != NULL)
18264 - next = tmp->next;
18269 - saved_function_list = NULL;
18272 diff --git a/gdb/f-lang.h b/gdb/f-lang.h
18273 index 711bdba..cd2f804 100644
18276 @@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined in f-exp.y */
18277 extern void f_print_type (struct type *, char *, struct ui_file *, int,
18280 +extern const char *f_object_address_data_valid_print_to_stream
18281 + (struct type *type, struct ui_file *stream);
18282 +extern void f_object_address_data_valid_or_error (struct type *type);
18284 extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
18285 struct ui_file *, int,
18286 const struct value_print_options *);
18287 @@ -47,41 +51,8 @@ enum f90_range_type
18288 NONE_BOUND_DEFAULT /* "(low:high)" */
18291 -struct common_entry
18293 - struct symbol *symbol; /* The symbol node corresponding
18294 - to this component */
18295 - struct common_entry *next; /* The next component */
18298 -struct saved_f77_common
18300 - char *name; /* Name of COMMON */
18301 - char *owning_function; /* Name of parent function */
18302 - int secnum; /* Section # of .bss */
18303 - CORE_ADDR offset; /* Offset from .bss for
18305 - struct common_entry *entries; /* List of block's components */
18306 - struct common_entry *end_of_entries; /* ptr. to end of components */
18307 - struct saved_f77_common *next; /* Next saved COMMON block */
18310 -typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR;
18312 -typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR;
18314 -extern SAVED_F77_COMMON_PTR head_common_list; /* Ptr to 1st saved COMMON */
18315 -extern SAVED_F77_COMMON_PTR tail_common_list; /* Ptr to last saved COMMON */
18316 -extern SAVED_F77_COMMON_PTR current_common; /* Ptr to current COMMON */
18318 -extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *);
18320 -#define UNINITIALIZED_SECNUM -1
18321 -#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM)
18323 #define BLANK_COMMON_NAME_ORIGINAL "#BLNK_COM" /* XLF assigned */
18324 #define BLANK_COMMON_NAME_MF77 "__BLNK__" /* MF77 assigned */
18325 -#define BLANK_COMMON_NAME_LOCAL "__BLANK" /* Local GDB */
18327 /* When reasonable array bounds cannot be fetched, such as when
18328 you ask to 'mt print symbols' and there is no stack frame and
18329 @@ -113,6 +84,7 @@ struct builtin_f_type
18330 struct type *builtin_logical;
18331 struct type *builtin_logical_s1;
18332 struct type *builtin_logical_s2;
18333 + struct type *builtin_logical_s8;
18334 struct type *builtin_real;
18335 struct type *builtin_real_s8;
18336 struct type *builtin_real_s16;
18337 diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
18338 index 6c9668f..852b9a8 100644
18339 --- a/gdb/f-typeprint.c
18340 +++ b/gdb/f-typeprint.c
18342 #include "gdbcore.h"
18343 #include "target.h"
18344 #include "f-lang.h"
18346 +#include "dwarf2loc.h"
18347 #include "gdb_string.h"
18350 @@ -48,6 +48,34 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *,
18351 void f_type_print_base (struct type *, struct ui_file *, int, int);
18355 +f_object_address_data_valid_print_to_stream (struct type *type,
18356 + struct ui_file *stream)
18360 + msg = object_address_data_not_valid (type);
18363 + /* Assuming the content printed to STREAM should not be localized. */
18364 + fprintf_filtered (stream, "<%s>", msg);
18371 +f_object_address_data_valid_or_error (struct type *type)
18375 + msg = object_address_data_not_valid (type);
18378 + error (_("Cannot access it because the %s."), _(msg));
18382 /* LEVEL is the depth to indent lines by. */
18385 @@ -57,6 +85,9 @@ f_print_type (struct type *type, char *varstring, struct ui_file *stream,
18386 enum type_code code;
18387 int demangled_args;
18389 + if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
18392 f_type_print_base (type, stream, show, level);
18393 code = TYPE_CODE (type);
18394 if ((varstring != NULL && *varstring != '\0')
18395 @@ -166,6 +197,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
18399 + if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
18400 + CHECK_TYPEDEF (type);
18402 switch (TYPE_CODE (type))
18404 case TYPE_CODE_ARRAY:
18405 diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
18406 index 5721041..2cff7bc 100644
18407 --- a/gdb/f-valprint.c
18408 +++ b/gdb/f-valprint.c
18410 #include "gdbcore.h"
18411 #include "command.h"
18415 -static int there_is_a_visible_common_named (char *);
18417 +#include "dictionary.h"
18418 +#include "gdb_assert.h"
18420 extern void _initialize_f_valprint (void);
18421 static void info_common_command (char *, int);
18422 @@ -54,15 +52,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
18423 /* The following macro gives us the size of the nth dimension, Where
18426 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
18427 +#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
18429 -/* The following gives us the offset for row n where n is 1-based. */
18430 +/* The following gives us the element size for row n where n is 1-based. */
18432 -#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
18433 +#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
18436 f77_get_lowerbound (struct type *type)
18438 + f_object_address_data_valid_or_error (type);
18440 if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
18441 error (_("Lower bound may not be '*' in F77"));
18443 @@ -72,14 +72,17 @@ f77_get_lowerbound (struct type *type)
18445 f77_get_upperbound (struct type *type)
18447 + f_object_address_data_valid_or_error (type);
18449 if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
18451 - /* We have an assumed size array on our hands. Assume that
18452 - upper_bound == lower_bound so that we show at least 1 element.
18453 - If the user wants to see more elements, let him manually ask for 'em
18454 - and we'll subscript the array and show him. */
18455 + /* We have an assumed size array on our hands. As type_length_get
18456 + already assumes a length zero of arrays with underfined bounds VALADDR
18457 + passed to the Fortran functions does not contained the real inferior
18458 + memory content. User should request printing of specific array
18459 + elements instead. */
18461 - return f77_get_lowerbound (type);
18462 + return f77_get_lowerbound (type) - 1;
18465 return TYPE_ARRAY_UPPER_BOUND_VALUE (type);
18466 @@ -135,24 +138,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
18467 upper = f77_get_upperbound (tmp_type);
18468 lower = f77_get_lowerbound (tmp_type);
18470 - F77_DIM_SIZE (ndimen) = upper - lower + 1;
18471 + F77_DIM_COUNT (ndimen) = upper - lower + 1;
18473 + F77_DIM_BYTE_STRIDE (ndimen) =
18474 + TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
18476 tmp_type = TYPE_TARGET_TYPE (tmp_type);
18480 - /* Now we multiply eltlen by all the offsets, so that later we
18481 + /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we
18482 can print out array elements correctly. Up till now we
18483 - know an offset to apply to get the item but we also
18484 + know an eltlen to apply to get the item but we also
18485 have to know how much to add to get to the next item */
18488 eltlen = TYPE_LENGTH (tmp_type);
18489 - F77_DIM_OFFSET (ndimen) = eltlen;
18490 + if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
18491 + F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
18492 while (--ndimen > 0)
18494 - eltlen *= F77_DIM_SIZE (ndimen + 1);
18495 - F77_DIM_OFFSET (ndimen) = eltlen;
18496 + eltlen *= F77_DIM_COUNT (ndimen + 1);
18497 + if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
18498 + F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
18502 @@ -172,34 +180,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
18504 if (nss != ndimensions)
18506 - for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
18507 + for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++)
18509 fprintf_filtered (stream, "( ");
18510 f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
18511 - valaddr + i * F77_DIM_OFFSET (nss),
18512 - address + i * F77_DIM_OFFSET (nss),
18513 + valaddr + i * F77_DIM_BYTE_STRIDE (nss),
18514 + address + i * F77_DIM_BYTE_STRIDE (nss),
18515 stream, recurse, options, elts);
18516 fprintf_filtered (stream, ") ");
18518 - if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
18519 + if (*elts >= options->print_max && i < F77_DIM_COUNT (nss))
18520 fprintf_filtered (stream, "...");
18524 - for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
18525 + for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max;
18528 val_print (TYPE_TARGET_TYPE (type),
18529 - valaddr + i * F77_DIM_OFFSET (ndimensions),
18530 + valaddr + i * F77_DIM_BYTE_STRIDE (ndimensions),
18532 - address + i * F77_DIM_OFFSET (ndimensions),
18533 + address + i * F77_DIM_BYTE_STRIDE (ndimensions),
18534 stream, recurse, options, current_language);
18536 - if (i != (F77_DIM_SIZE (nss) - 1))
18537 + if (i != (F77_DIM_COUNT (nss) - 1))
18538 fprintf_filtered (stream, ", ");
18540 if ((*elts == options->print_max - 1)
18541 - && (i != (F77_DIM_SIZE (nss) - 1)))
18542 + && (i != (F77_DIM_COUNT (nss) - 1)))
18543 fprintf_filtered (stream, "...");
18546 @@ -251,12 +259,16 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18550 + if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
18553 CHECK_TYPEDEF (type);
18554 switch (TYPE_CODE (type))
18556 case TYPE_CODE_STRING:
18557 f77_get_dynamic_length_of_aggregate (type);
18558 - LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
18559 + LA_PRINT_STRING (stream, builtin_type (current_gdbarch)->builtin_char,
18560 + valaddr, TYPE_LENGTH (type), 0, options);
18563 case TYPE_CODE_ARRAY:
18564 @@ -293,7 +305,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18565 && TYPE_CODE (elttype) == TYPE_CODE_INT
18566 && (options->format == 0 || options->format == 's')
18568 - i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
18569 + i = val_print_string (TYPE_TARGET_TYPE (type), addr, -1, stream,
18572 /* Return number of characters printed, including the terminating
18573 @@ -365,7 +377,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18575 fputs_filtered (" ", stream);
18576 LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr),
18582 @@ -464,22 +476,54 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18587 -list_all_visible_commons (char *funname)
18589 +info_common_command_for_block (struct block *block, struct frame_info *frame,
18590 + const char *comname)
18592 - SAVED_F77_COMMON_PTR tmp;
18594 - tmp = head_common_list;
18596 - printf_filtered (_("All COMMON blocks visible at this level:\n\n"));
18598 - while (tmp != NULL)
18600 - if (strcmp (tmp->owning_function, funname) == 0)
18601 - printf_filtered ("%s\n", tmp->name);
18605 + struct dict_iterator iter;
18606 + struct symbol *sym;
18607 + int values_printed = 0;
18608 + const char *name;
18609 + struct value_print_options opts;
18611 + get_user_print_options (&opts);
18613 + ALL_BLOCK_SYMBOLS (block, iter, sym)
18614 + if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
18616 + struct type *type = SYMBOL_TYPE (sym);
18619 + gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC);
18620 + gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT);
18622 + if (comname && (!SYMBOL_LINKAGE_NAME (sym)
18623 + || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0))
18626 + values_printed = 1;
18627 + if (SYMBOL_PRINT_NAME (sym))
18628 + printf_filtered (_("Contents of F77 COMMON block '%s':\n"),
18629 + SYMBOL_PRINT_NAME (sym));
18631 + printf_filtered (_("Contents of blank COMMON block:\n"));
18633 + for (index = 0; index < TYPE_NFIELDS (type); index++)
18635 + struct value *val;
18637 + gdb_assert (field_is_static (&TYPE_FIELD (type, index)));
18638 + val = value_static_field (type, index);
18640 + printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index));
18641 + value_print (val, gdb_stdout, &opts);
18642 + putchar_filtered ('\n');
18645 + putchar_filtered ('\n');
18648 + return values_printed;
18651 /* This function is used to print out the values in a given COMMON
18652 @@ -489,11 +533,9 @@ list_all_visible_commons (char *funname)
18654 info_common_command (char *comname, int from_tty)
18656 - SAVED_F77_COMMON_PTR the_common;
18657 - COMMON_ENTRY_PTR entry;
18658 struct frame_info *fi;
18659 - char *funname = 0;
18660 - struct symbol *func;
18661 + struct block *block;
18662 + int values_printed = 0;
18664 /* We have been told to display the contents of F77 COMMON
18665 block supposedly visible in this function. Let us
18666 @@ -505,136 +547,32 @@ info_common_command (char *comname, int from_tty)
18667 /* The following is generally ripped off from stack.c's routine
18668 print_frame_info() */
18670 - func = find_pc_function (get_frame_pc (fi));
18673 - /* In certain pathological cases, the symtabs give the wrong
18674 - function (when we are in the first function in a file which
18675 - is compiled without debugging symbols, the previous function
18676 - is compiled with debugging symbols, and the "foo.o" symbol
18677 - that is supposed to tell us where the file with debugging symbols
18678 - ends has been truncated by ar because it is longer than 15
18681 - So look in the minimal symbol tables as well, and if it comes
18682 - up with a larger address for the function use that instead.
18683 - I don't think this can ever cause any problems; there shouldn't
18684 - be any minimal symbols in the middle of a function.
18685 - FIXME: (Not necessarily true. What about text labels) */
18687 - struct minimal_symbol *msymbol =
18688 - lookup_minimal_symbol_by_pc (get_frame_pc (fi));
18690 - if (msymbol != NULL
18691 - && (SYMBOL_VALUE_ADDRESS (msymbol)
18692 - > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
18693 - funname = SYMBOL_LINKAGE_NAME (msymbol);
18695 - funname = SYMBOL_LINKAGE_NAME (func);
18699 - struct minimal_symbol *msymbol =
18700 - lookup_minimal_symbol_by_pc (get_frame_pc (fi));
18702 - if (msymbol != NULL)
18703 - funname = SYMBOL_LINKAGE_NAME (msymbol);
18704 - else /* Got no 'funname', code below will fail. */
18705 - error (_("No function found for frame."));
18708 - /* If comname is NULL, we assume the user wishes to see the
18709 - which COMMON blocks are visible here and then return */
18711 - if (comname == 0)
18712 + block = get_frame_block (fi, 0);
18713 + if (block == NULL)
18715 - list_all_visible_commons (funname);
18716 + printf_filtered (_("No symbol table info available.\n"));
18720 - the_common = find_common_for_function (comname, funname);
18725 - if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0)
18726 - printf_filtered (_("Contents of blank COMMON block:\n"));
18728 - printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname);
18730 - printf_filtered ("\n");
18731 - entry = the_common->entries;
18733 - while (entry != NULL)
18735 - print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0);
18736 - entry = entry->next;
18738 + if (info_common_command_for_block (block, fi, comname))
18739 + values_printed = 1;
18740 + /* After handling the function's top-level block, stop. Don't
18741 + continue to its superblock, the block of per-file symbols. */
18742 + if (BLOCK_FUNCTION (block))
18744 + block = BLOCK_SUPERBLOCK (block);
18747 - printf_filtered (_("Cannot locate the common block %s in function '%s'\n"),
18748 - comname, funname);
18751 -/* This function is used to determine whether there is a
18752 - F77 common block visible at the current scope called 'comname'. */
18756 -there_is_a_visible_common_named (char *comname)
18758 - SAVED_F77_COMMON_PTR the_common;
18759 - struct frame_info *fi;
18760 - char *funname = 0;
18761 - struct symbol *func;
18763 - if (comname == NULL)
18764 - error (_("Cannot deal with NULL common name!"));
18766 - fi = get_selected_frame (_("No frame selected"));
18768 - /* The following is generally ripped off from stack.c's routine
18769 - print_frame_info() */
18771 - func = find_pc_function (fi->pc);
18773 + if (!values_printed)
18775 - /* In certain pathological cases, the symtabs give the wrong
18776 - function (when we are in the first function in a file which
18777 - is compiled without debugging symbols, the previous function
18778 - is compiled with debugging symbols, and the "foo.o" symbol
18779 - that is supposed to tell us where the file with debugging symbols
18780 - ends has been truncated by ar because it is longer than 15
18783 - So look in the minimal symbol tables as well, and if it comes
18784 - up with a larger address for the function use that instead.
18785 - I don't think this can ever cause any problems; there shouldn't
18786 - be any minimal symbols in the middle of a function.
18787 - FIXME: (Not necessarily true. What about text labels) */
18789 - struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
18791 - if (msymbol != NULL
18792 - && (SYMBOL_VALUE_ADDRESS (msymbol)
18793 - > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
18794 - funname = SYMBOL_LINKAGE_NAME (msymbol);
18796 + printf_filtered (_("No common block '%s'.\n"), comname);
18798 - funname = SYMBOL_LINKAGE_NAME (func);
18799 + printf_filtered (_("No common blocks.\n"));
18803 - struct minimal_symbol *msymbol =
18804 - lookup_minimal_symbol_by_pc (fi->pc);
18806 - if (msymbol != NULL)
18807 - funname = SYMBOL_LINKAGE_NAME (msymbol);
18810 - the_common = find_common_for_function (comname, funname);
18812 - return (the_common ? 1 : 0);
18817 _initialize_f_valprint (void)
18818 diff --git a/gdb/findcmd.c b/gdb/findcmd.c
18819 index 7ae43e5..2894948 100644
18820 --- a/gdb/findcmd.c
18821 +++ b/gdb/findcmd.c
18824 /* Copied from bfd_put_bits. */
18828 put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
18831 @@ -44,6 +44,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
18835 +/* Allocates a buffer in *PATTERN_BUF, with a hard-coded initial size which
18836 + will be returned in *PATTERN_BUF_SIZE. *PATTERN_BUF_END points to the same
18837 + place as *PATTERN_BUF, indicating that the buffer is initially empty. */
18840 +allocate_pattern_buffer (char **pattern_buf, char **pattern_buf_end,
18841 + ULONGEST *pattern_buf_size)
18843 +#define INITIAL_PATTERN_BUF_SIZE 100
18844 + *pattern_buf_size = INITIAL_PATTERN_BUF_SIZE;
18845 + *pattern_buf = xmalloc (*pattern_buf_size);
18846 + *pattern_buf_end = *pattern_buf;
18849 +/* Grows *PATTERN_BUF by a factor of two if it's not large enough to hold
18850 + VAL_BYTES more bytes or a 64-bit value, whichever is larger.
18851 + *PATTERN_BUF_END is updated as necessary. */
18854 +increase_pattern_buffer (char **pattern_buf, char **pattern_buf_end,
18855 + ULONGEST *pattern_buf_size, int val_bytes)
18857 + /* Keep it simple and assume size == 'g' when watching for when we
18858 + need to grow the pattern buf. */
18859 + if ((*pattern_buf_end - *pattern_buf + max (val_bytes, sizeof (int64_t)))
18860 + > *pattern_buf_size)
18862 + size_t current_offset = *pattern_buf_end - *pattern_buf;
18864 + *pattern_buf_size *= 2;
18865 + *pattern_buf = xrealloc (*pattern_buf, *pattern_buf_size);
18866 + *pattern_buf_end = *pattern_buf + current_offset;
18870 /* Subroutine of find_command to simplify it.
18871 Parse the arguments of the "find" command. */
18873 @@ -59,8 +94,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
18875 /* Current size of search pattern buffer.
18876 We realloc space as needed. */
18877 -#define INITIAL_PATTERN_BUF_SIZE 100
18878 - ULONGEST pattern_buf_size = INITIAL_PATTERN_BUF_SIZE;
18879 + ULONGEST pattern_buf_size;
18880 /* Pointer to one past the last in-use part of pattern_buf. */
18881 char *pattern_buf_end;
18882 ULONGEST pattern_len;
18883 @@ -74,8 +108,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
18885 error (_("Missing search parameters."));
18887 - pattern_buf = xmalloc (pattern_buf_size);
18888 - pattern_buf_end = pattern_buf;
18889 + allocate_pattern_buffer (&pattern_buf, &pattern_buf_end, &pattern_buf_size);
18890 old_cleanups = make_cleanup (free_current_contents, &pattern_buf);
18892 /* Get search granularity and/or max count if specified.
18893 @@ -172,16 +205,8 @@ parse_find_args (char *args, ULONGEST *max_countp,
18894 v = parse_to_comma_and_eval (&s);
18895 val_bytes = TYPE_LENGTH (value_type (v));
18897 - /* Keep it simple and assume size == 'g' when watching for when we
18898 - need to grow the pattern buf. */
18899 - if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t)))
18900 - > pattern_buf_size)
18902 - size_t current_offset = pattern_buf_end - pattern_buf;
18903 - pattern_buf_size *= 2;
18904 - pattern_buf = xrealloc (pattern_buf, pattern_buf_size);
18905 - pattern_buf_end = pattern_buf + current_offset;
18907 + increase_pattern_buffer (&pattern_buf, &pattern_buf_end,
18908 + &pattern_buf_size, val_bytes);
18912 @@ -236,6 +261,45 @@ parse_find_args (char *args, ULONGEST *max_countp,
18913 discard_cleanups (old_cleanups);
18916 +/* Drives target_search_memory to sweep through the specified search space,
18917 + possibly in several iterations (with one call to this function for each
18918 + iteration). *START_ADDR is the address where the search starts, and is
18919 + updated to the next starting address to continue the search.
18920 + *SEARCH_SPACE_LEN is the amount of bytes which will be searched, and is
18921 + updated for the next iteration. PATTERN_BUF holds the pattern to be searched
18922 + for, PATTERN_LEN is the size of the pattern in bytes. If a match is found,
18923 + it's address is put in *FOUND_ADDR.
18925 + Returns 1 if found, 0 if not found, and -1 if there was an error requiring
18926 + halting of the search (e.g. memory read error). */
18929 +search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len,
18930 + const char *pattern_buf, ULONGEST pattern_len,
18931 + CORE_ADDR *found_addr)
18933 + /* Offset from start of this iteration to the next iteration. */
18934 + ULONGEST next_iter_incr;
18937 + found = target_search_memory (*start_addr, *search_space_len,
18938 + pattern_buf, pattern_len, found_addr);
18942 + /* Begin next iteration at one byte past this match. */
18943 + next_iter_incr = (*found_addr - *start_addr) + 1;
18945 + /* For robustness, we don't let search_space_len go -ve here. */
18946 + if (*search_space_len >= next_iter_incr)
18947 + *search_space_len -= next_iter_incr;
18949 + *search_space_len = 0;
18950 + *start_addr += next_iter_incr;
18956 find_command (char *args, int from_tty)
18958 @@ -264,12 +328,11 @@ find_command (char *args, int from_tty)
18959 while (search_space_len >= pattern_len
18960 && found_count < max_count)
18962 - /* Offset from start of this iteration to the next iteration. */
18963 - ULONGEST next_iter_incr;
18964 CORE_ADDR found_addr;
18965 - int found = target_search_memory (start_addr, search_space_len,
18966 - pattern_buf, pattern_len, &found_addr);
18969 + found = search_memory (&start_addr, &search_space_len, pattern_buf,
18970 + pattern_len, &found_addr);
18974 @@ -277,16 +340,6 @@ find_command (char *args, int from_tty)
18975 printf_filtered ("\n");
18977 last_found_addr = found_addr;
18979 - /* Begin next iteration at one byte past this match. */
18980 - next_iter_incr = (found_addr - start_addr) + 1;
18982 - /* For robustness, we don't let search_space_len go -ve here. */
18983 - if (search_space_len >= next_iter_incr)
18984 - search_space_len -= next_iter_incr;
18986 - search_space_len = 0;
18987 - start_addr += next_iter_incr;
18990 /* Record and print the results. */
18991 diff --git a/gdb/findvar.c b/gdb/findvar.c
18992 index 1048887..b958ec6 100644
18993 --- a/gdb/findvar.c
18994 +++ b/gdb/findvar.c
18996 #include "user-regs.h"
18998 #include "objfiles.h"
18999 +#include "dwarf2loc.h"
19001 /* Basic byte-swapping routines. GDB has needed these for a long time...
19002 All extract a target-format integer at ADDR which is LEN bytes long. */
19003 @@ -275,7 +276,7 @@ value_of_register (int regnum, struct frame_info *frame)
19004 memcpy (value_contents_raw (reg_val), raw_buffer,
19005 register_size (gdbarch, regnum));
19006 VALUE_LVAL (reg_val) = lval;
19007 - VALUE_ADDRESS (reg_val) = addr;
19008 + set_value_address (reg_val, addr);
19009 VALUE_REGNUM (reg_val) = regnum;
19010 set_value_optimized_out (reg_val, optim);
19011 VALUE_FRAME_ID (reg_val) = get_frame_id (frame);
19012 @@ -382,27 +383,16 @@ symbol_read_needs_frame (struct symbol *sym)
19013 /* Given a struct symbol for a variable,
19014 and a stack frame id, read the value of the variable
19015 and return a (pointer to a) struct value containing the value.
19016 - If the variable cannot be found, return a zero pointer. */
19017 + If the variable cannot be found, return a zero pointer.
19018 + We have to first find the address of the variable before allocating struct
19019 + value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly
19020 + used by its type. */
19023 read_var_value (struct symbol *var, struct frame_info *frame)
19026 struct type *type = SYMBOL_TYPE (var);
19030 - if (SYMBOL_CLASS (var) == LOC_COMPUTED
19031 - || SYMBOL_CLASS (var) == LOC_REGISTER)
19032 - /* These cases do not use V. */
19036 - v = allocate_value (type);
19037 - VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */
19040 - len = TYPE_LENGTH (type);
19042 if (symbol_read_needs_frame (var))
19043 gdb_assert (frame);
19044 @@ -410,31 +400,39 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19045 switch (SYMBOL_CLASS (var))
19048 - /* Put the constant back in target format. */
19049 - store_signed_integer (value_contents_raw (v), len,
19050 - (LONGEST) SYMBOL_VALUE (var));
19051 - VALUE_LVAL (v) = not_lval;
19054 + /* Put the constant back in target format. */
19055 + struct value *v = allocate_value (type);
19056 + VALUE_LVAL (v) = not_lval;
19057 + store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
19058 + (LONGEST) SYMBOL_VALUE (var));
19063 - /* Put the constant back in target format. */
19064 - if (overlay_debugging)
19067 - = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
19068 - SYMBOL_OBJ_SECTION (var));
19069 - store_typed_address (value_contents_raw (v), type, addr);
19072 - store_typed_address (value_contents_raw (v), type,
19073 - SYMBOL_VALUE_ADDRESS (var));
19074 - VALUE_LVAL (v) = not_lval;
19077 + /* Put the constant back in target format. */
19078 + struct value *v = allocate_value (type);
19079 + VALUE_LVAL (v) = not_lval;
19080 + if (overlay_debugging)
19083 + = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
19084 + SYMBOL_OBJ_SECTION (var));
19085 + store_typed_address (value_contents_raw (v), type, addr);
19088 + store_typed_address (value_contents_raw (v), type,
19089 + SYMBOL_VALUE_ADDRESS (var));
19093 case LOC_CONST_BYTES:
19095 - memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len);
19096 + struct value *v = allocate_value (type);
19097 VALUE_LVAL (v) = not_lval;
19098 + memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
19099 + TYPE_LENGTH (type));
19103 @@ -476,12 +474,23 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19107 - if (overlay_debugging)
19108 - VALUE_ADDRESS (v) = symbol_overlayed_address
19109 - (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
19111 - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
19117 + if (overlay_debugging)
19118 + addr = symbol_overlayed_address
19119 + (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
19121 + addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
19122 + /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
19123 + DW_OP_push_object_address. */
19124 + object_address_set (addr);
19125 + v = allocate_value (type);
19126 + VALUE_ADDRESS (v) = addr;
19127 + VALUE_LVAL (v) = lval_memory;
19132 case LOC_REGPARM_ADDR:
19133 @@ -499,7 +508,6 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19134 error (_("Value of register variable not available."));
19136 addr = value_as_address (regval);
19137 - VALUE_LVAL (v) = lval_memory;
19141 @@ -542,18 +550,33 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19144 case LOC_OPTIMIZED_OUT:
19145 - VALUE_LVAL (v) = not_lval;
19146 - set_value_optimized_out (v, 1);
19149 + struct value *v = allocate_value (type);
19151 + VALUE_LVAL (v) = not_lval;
19152 + set_value_optimized_out (v, 1);
19157 error (_("Cannot look up value of a botched symbol."));
19161 - VALUE_ADDRESS (v) = addr;
19162 - set_value_lazy (v, 1);
19167 + /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
19168 + DW_OP_PUSH_OBJECT_ADDRESS. */
19169 + object_address_set (addr);
19170 + v = allocate_value (type);
19171 + VALUE_ADDRESS (v) = addr;
19172 + VALUE_LVAL (v) = lval_memory;
19174 + set_value_lazy (v, 1);
19180 /* Install default attributes for register values. */
19181 @@ -590,10 +613,11 @@ struct value *
19182 value_from_register (struct type *type, int regnum, struct frame_info *frame)
19184 struct gdbarch *gdbarch = get_frame_arch (frame);
19185 - struct type *type1 = check_typedef (type);
19188 - if (gdbarch_convert_register_p (gdbarch, regnum, type1))
19189 + type = check_typedef (type);
19191 + if (gdbarch_convert_register_p (gdbarch, regnum, type))
19193 /* The ISA/ABI need to something weird when obtaining the
19194 specified value from this register. It might need to
19195 @@ -607,7 +631,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
19196 VALUE_FRAME_ID (v) = get_frame_id (frame);
19197 VALUE_REGNUM (v) = regnum;
19198 gdbarch_register_to_value (gdbarch,
19199 - frame, regnum, type1, value_contents_raw (v));
19200 + frame, regnum, type, value_contents_raw (v));
19204 diff --git a/gdb/frame.c b/gdb/frame.c
19205 index dfd6b3d..2ea37c3 100644
19208 @@ -596,7 +596,7 @@ frame_register_unwind (struct frame_info *frame, int regnum,
19210 *optimizedp = value_optimized_out (value);
19211 *lvalp = VALUE_LVAL (value);
19212 - *addrp = VALUE_ADDRESS (value);
19213 + *addrp = value_address (value);
19214 *realnump = VALUE_REGNUM (value);
19217 @@ -682,7 +682,7 @@ frame_unwind_register_value (struct frame_info *frame, int regnum)
19218 VALUE_REGNUM (value));
19219 else if (VALUE_LVAL (value) == lval_memory)
19220 fprintf_unfiltered (gdb_stdlog, " address=0x%s",
19221 - paddr_nz (VALUE_ADDRESS (value)));
19222 + paddr_nz (value_address (value)));
19224 fprintf_unfiltered (gdb_stdlog, " computed");
19226 diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
19227 index ff387db..452f70c 100644
19228 --- a/gdb/frv-tdep.c
19229 +++ b/gdb/frv-tdep.c
19230 @@ -1230,7 +1230,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
19232 if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
19234 - store_unsigned_integer (valbuf, 4, VALUE_ADDRESS (arg));
19235 + store_unsigned_integer (valbuf, 4, value_address (arg));
19236 typecode = TYPE_CODE_PTR;
19239 diff --git a/gdb/gdb_locale.h b/gdb/gdb_locale.h
19240 index e8ba0ea..4fa4d3d 100644
19241 --- a/gdb/gdb_locale.h
19242 +++ b/gdb/gdb_locale.h
19244 # define N_(String) (String)
19247 +#ifdef HAVE_LANGINFO_CODESET
19248 +#include <langinfo.h>
19251 #endif /* GDB_LOCALE_H */
19252 diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h
19253 index 48f49cd..cd1a1d7 100644
19254 --- a/gdb/gdb_obstack.h
19255 +++ b/gdb/gdb_obstack.h
19257 #define obstack_grow_str0(OBSTACK,STRING) \
19258 obstack_grow0 (OBSTACK, STRING, strlen (STRING))
19260 +#define obstack_grow_wstr(OBSTACK, WSTRING) \
19261 + obstack_grow (OBSTACK, WSTRING, sizeof (wchar_t) * wcslen (WSTRING))
19264 diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
19265 index 3273b34..d6c737b 100644
19266 --- a/gdb/gdbarch.c
19267 +++ b/gdb/gdbarch.c
19268 @@ -243,6 +243,11 @@ struct gdbarch
19269 gdbarch_target_signal_to_host_ftype *target_signal_to_host;
19270 gdbarch_get_siginfo_type_ftype *get_siginfo_type;
19271 gdbarch_record_special_symbol_ftype *record_special_symbol;
19272 + gdbarch_get_syscall_number_ftype *get_syscall_number;
19273 + gdbarch_get_syscall_by_number_ftype *get_syscall_by_number;
19274 + gdbarch_get_syscall_by_name_ftype *get_syscall_by_name;
19275 + gdbarch_get_syscall_names_ftype *get_syscall_names;
19276 + const char * xml_syscall_filename;
19277 int has_global_solist;
19280 @@ -378,6 +383,11 @@ struct gdbarch startup_gdbarch =
19281 default_target_signal_to_host, /* target_signal_to_host */
19282 0, /* get_siginfo_type */
19283 0, /* record_special_symbol */
19284 + 0, /* get_syscall_number */
19285 + 0, /* get_syscall_by_number */
19286 + 0, /* get_syscall_by_name */
19287 + 0, /* get_syscall_names */
19288 + 0, /* xml_syscall_filename */
19289 0, /* has_global_solist */
19290 /* startup_gdbarch() */
19292 @@ -634,6 +644,11 @@ verify_gdbarch (struct gdbarch *gdbarch)
19293 /* Skip verify of target_signal_to_host, invalid_p == 0 */
19294 /* Skip verify of get_siginfo_type, has predicate */
19295 /* Skip verify of record_special_symbol, has predicate */
19296 + /* Skip verify of get_syscall_number, has predicate */
19297 + /* Skip verify of get_syscall_by_number, has predicate */
19298 + /* Skip verify of get_syscall_by_name, has predicate */
19299 + /* Skip verify of get_syscall_names, has predicate */
19300 + /* Skip verify of xml_syscall_filename, invalid_p == 0 */
19301 /* Skip verify of has_global_solist, invalid_p == 0 */
19302 buf = ui_file_xstrdup (log, &dummy);
19303 make_cleanup (xfree, buf);
19304 @@ -859,6 +874,30 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
19305 "gdbarch_dump: get_siginfo_type = <%s>\n",
19306 host_address_to_string (gdbarch->get_siginfo_type));
19307 fprintf_unfiltered (file,
19308 + "gdbarch_dump: gdbarch_get_syscall_by_name_p() = %d\n",
19309 + gdbarch_get_syscall_by_name_p (gdbarch));
19310 + fprintf_unfiltered (file,
19311 + "gdbarch_dump: get_syscall_by_name = <%s>\n",
19312 + host_address_to_string (gdbarch->get_syscall_by_name));
19313 + fprintf_unfiltered (file,
19314 + "gdbarch_dump: gdbarch_get_syscall_by_number_p() = %d\n",
19315 + gdbarch_get_syscall_by_number_p (gdbarch));
19316 + fprintf_unfiltered (file,
19317 + "gdbarch_dump: get_syscall_by_number = <%s>\n",
19318 + host_address_to_string (gdbarch->get_syscall_by_number));
19319 + fprintf_unfiltered (file,
19320 + "gdbarch_dump: gdbarch_get_syscall_names_p() = %d\n",
19321 + gdbarch_get_syscall_names_p (gdbarch));
19322 + fprintf_unfiltered (file,
19323 + "gdbarch_dump: get_syscall_names = <%s>\n",
19324 + host_address_to_string (gdbarch->get_syscall_names));
19325 + fprintf_unfiltered (file,
19326 + "gdbarch_dump: gdbarch_get_syscall_number_p() = %d\n",
19327 + gdbarch_get_syscall_number_p (gdbarch));
19328 + fprintf_unfiltered (file,
19329 + "gdbarch_dump: get_syscall_number = <%s>\n",
19330 + host_address_to_string (gdbarch->get_syscall_number));
19331 + fprintf_unfiltered (file,
19332 "gdbarch_dump: has_global_solist = %s\n",
19333 plongest (gdbarch->has_global_solist));
19334 fprintf_unfiltered (file,
19335 @@ -1122,6 +1161,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
19336 fprintf_unfiltered (file,
19337 "gdbarch_dump: write_pc = <%s>\n",
19338 host_address_to_string (gdbarch->write_pc));
19339 + fprintf_unfiltered (file,
19340 + "gdbarch_dump: xml_syscall_filename = %s\n",
19341 + gdbarch->xml_syscall_filename);
19342 if (gdbarch->dump_tdep != NULL)
19343 gdbarch->dump_tdep (gdbarch, file);
19345 @@ -3333,6 +3375,119 @@ set_gdbarch_record_special_symbol (struct gdbarch *gdbarch,
19349 +gdbarch_get_syscall_number_p (struct gdbarch *gdbarch)
19351 + gdb_assert (gdbarch != NULL);
19352 + return gdbarch->get_syscall_number != NULL;
19356 +gdbarch_get_syscall_number (struct gdbarch *gdbarch, ptid_t ptid)
19358 + gdb_assert (gdbarch != NULL);
19359 + gdb_assert (gdbarch->get_syscall_number != NULL);
19360 + if (gdbarch_debug >= 2)
19361 + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_syscall_number called\n");
19362 + return gdbarch->get_syscall_number (gdbarch, ptid);
19366 +set_gdbarch_get_syscall_number (struct gdbarch *gdbarch,
19367 + gdbarch_get_syscall_number_ftype get_syscall_number)
19369 + gdbarch->get_syscall_number = get_syscall_number;
19373 +gdbarch_get_syscall_by_number_p (struct gdbarch *gdbarch)
19375 + gdb_assert (gdbarch != NULL);
19376 + return gdbarch->get_syscall_by_number != NULL;
19380 +gdbarch_get_syscall_by_number (struct gdbarch *gdbarch, int syscall_number, struct syscall *s)
19382 + gdb_assert (gdbarch != NULL);
19383 + gdb_assert (gdbarch->get_syscall_by_number != NULL);
19384 + if (gdbarch_debug >= 2)
19385 + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_syscall_by_number called\n");
19386 + gdbarch->get_syscall_by_number (gdbarch, syscall_number, s);
19390 +set_gdbarch_get_syscall_by_number (struct gdbarch *gdbarch,
19391 + gdbarch_get_syscall_by_number_ftype get_syscall_by_number)
19393 + gdbarch->get_syscall_by_number = get_syscall_by_number;
19397 +gdbarch_get_syscall_by_name_p (struct gdbarch *gdbarch)
19399 + gdb_assert (gdbarch != NULL);
19400 + return gdbarch->get_syscall_by_name != NULL;
19404 +gdbarch_get_syscall_by_name (struct gdbarch *gdbarch, const char *syscall_name, struct syscall *s)
19406 + gdb_assert (gdbarch != NULL);
19407 + gdb_assert (gdbarch->get_syscall_by_name != NULL);
19408 + if (gdbarch_debug >= 2)
19409 + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_syscall_by_name called\n");
19410 + gdbarch->get_syscall_by_name (gdbarch, syscall_name, s);
19414 +set_gdbarch_get_syscall_by_name (struct gdbarch *gdbarch,
19415 + gdbarch_get_syscall_by_name_ftype get_syscall_by_name)
19417 + gdbarch->get_syscall_by_name = get_syscall_by_name;
19421 +gdbarch_get_syscall_names_p (struct gdbarch *gdbarch)
19423 + gdb_assert (gdbarch != NULL);
19424 + return gdbarch->get_syscall_names != NULL;
19428 +gdbarch_get_syscall_names (struct gdbarch *gdbarch)
19430 + gdb_assert (gdbarch != NULL);
19431 + gdb_assert (gdbarch->get_syscall_names != NULL);
19432 + if (gdbarch_debug >= 2)
19433 + fprintf_unfiltered (gdb_stdlog, "gdbarch_get_syscall_names called\n");
19434 + return gdbarch->get_syscall_names (gdbarch);
19438 +set_gdbarch_get_syscall_names (struct gdbarch *gdbarch,
19439 + gdbarch_get_syscall_names_ftype get_syscall_names)
19441 + gdbarch->get_syscall_names = get_syscall_names;
19445 +gdbarch_xml_syscall_filename (struct gdbarch *gdbarch)
19447 + gdb_assert (gdbarch != NULL);
19448 + /* Skip verify of xml_syscall_filename, invalid_p == 0 */
19449 + if (gdbarch_debug >= 2)
19450 + fprintf_unfiltered (gdb_stdlog, "gdbarch_xml_syscall_filename called\n");
19451 + return gdbarch->xml_syscall_filename;
19455 +set_gdbarch_xml_syscall_filename (struct gdbarch *gdbarch,
19456 + const char * xml_syscall_filename)
19458 + gdbarch->xml_syscall_filename = xml_syscall_filename;
19462 gdbarch_has_global_solist (struct gdbarch *gdbarch)
19464 gdb_assert (gdbarch != NULL);
19465 diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
19466 index 04c8920..017b9df 100644
19467 --- a/gdb/gdbarch.h
19468 +++ b/gdb/gdbarch.h
19469 @@ -52,6 +52,7 @@ struct bp_target_info;
19470 struct target_desc;
19471 struct displaced_step_closure;
19472 struct core_regset_section;
19475 extern struct gdbarch *current_gdbarch;
19476 extern struct gdbarch *target_gdbarch;
19477 @@ -839,6 +840,47 @@ typedef void (gdbarch_record_special_symbol_ftype) (struct gdbarch *gdbarch, str
19478 extern void gdbarch_record_special_symbol (struct gdbarch *gdbarch, struct objfile *objfile, asymbol *sym);
19479 extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_record_special_symbol_ftype *record_special_symbol);
19481 +/* Functions for the 'catch syscall' feature.
19482 + Get architecture-specific system calls information from registers. */
19484 +extern int gdbarch_get_syscall_number_p (struct gdbarch *gdbarch);
19486 +typedef LONGEST (gdbarch_get_syscall_number_ftype) (struct gdbarch *gdbarch, ptid_t ptid);
19487 +extern LONGEST gdbarch_get_syscall_number (struct gdbarch *gdbarch, ptid_t ptid);
19488 +extern void set_gdbarch_get_syscall_number (struct gdbarch *gdbarch, gdbarch_get_syscall_number_ftype *get_syscall_number);
19490 +/* Fills the struct syscall (passed as argument) with the corresponding
19491 + system call represented by syscall_number. */
19493 +extern int gdbarch_get_syscall_by_number_p (struct gdbarch *gdbarch);
19495 +typedef void (gdbarch_get_syscall_by_number_ftype) (struct gdbarch *gdbarch, int syscall_number, struct syscall *s);
19496 +extern void gdbarch_get_syscall_by_number (struct gdbarch *gdbarch, int syscall_number, struct syscall *s);
19497 +extern void set_gdbarch_get_syscall_by_number (struct gdbarch *gdbarch, gdbarch_get_syscall_by_number_ftype *get_syscall_by_number);
19499 +/* Fills the struct syscall (passed as argument) with the corresponding
19500 + system call represented by syscall_name. */
19502 +extern int gdbarch_get_syscall_by_name_p (struct gdbarch *gdbarch);
19504 +typedef void (gdbarch_get_syscall_by_name_ftype) (struct gdbarch *gdbarch, const char *syscall_name, struct syscall *s);
19505 +extern void gdbarch_get_syscall_by_name (struct gdbarch *gdbarch, const char *syscall_name, struct syscall *s);
19506 +extern void set_gdbarch_get_syscall_by_name (struct gdbarch *gdbarch, gdbarch_get_syscall_by_name_ftype *get_syscall_by_name);
19508 +/* Returns the array containing the syscall names for the architecture. */
19510 +extern int gdbarch_get_syscall_names_p (struct gdbarch *gdbarch);
19512 +typedef const char ** (gdbarch_get_syscall_names_ftype) (struct gdbarch *gdbarch);
19513 +extern const char ** gdbarch_get_syscall_names (struct gdbarch *gdbarch);
19514 +extern void set_gdbarch_get_syscall_names (struct gdbarch *gdbarch, gdbarch_get_syscall_names_ftype *get_syscall_names);
19516 +/* Stores the name of syscall's XML file. Contains NULL if the file
19519 +extern const char * gdbarch_xml_syscall_filename (struct gdbarch *gdbarch);
19520 +extern void set_gdbarch_xml_syscall_filename (struct gdbarch *gdbarch, const char * xml_syscall_filename);
19522 /* True if the list of shared libraries is one and only for all
19523 processes, as opposed to a list of shared libraries per inferior.
19524 When this property is true, GDB assumes that since shared libraries
19525 @@ -848,6 +890,9 @@ extern void set_gdbarch_record_special_symbol (struct gdbarch *gdbarch, gdbarch_
19526 extern int gdbarch_has_global_solist (struct gdbarch *gdbarch);
19527 extern void set_gdbarch_has_global_solist (struct gdbarch *gdbarch, int has_global_solist);
19529 +/* Definition for an unknown syscall, used basically in error-cases. */
19530 +#define UNKNOWN_SYSCALL (-1)
19532 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
19535 diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
19536 index f93bfc1..66cbcd0 100755
19537 --- a/gdb/gdbarch.sh
19538 +++ b/gdb/gdbarch.sh
19539 @@ -724,6 +724,26 @@ M:struct type *:get_siginfo_type:void:
19540 # Record architecture-specific information from the symbol table.
19541 M:void:record_special_symbol:struct objfile *objfile, asymbol *sym:objfile, sym
19543 +# Functions for the 'catch syscall' feature.
19545 +# Get architecture-specific system calls information from registers.
19546 +M:LONGEST:get_syscall_number:ptid_t ptid:ptid
19548 +# Fills the struct syscall (passed as argument) with the corresponding
19549 +# system call represented by syscall_number.
19550 +M:void:get_syscall_by_number:int syscall_number, struct syscall *s:syscall_number, s
19552 +# Fills the struct syscall (passed as argument) with the corresponding
19553 +# system call represented by syscall_name.
19554 +M:void:get_syscall_by_name:const char *syscall_name, struct syscall *s:syscall_name, s
19556 +# Returns the array containing the syscall names for the architecture.
19557 +M:const char **:get_syscall_names:void:
19559 +# Stores the name of syscall's XML file. Contains NULL if the file
19561 +v:const char *:xml_syscall_filename:::0:0::0:gdbarch->xml_syscall_filename
19563 # True if the list of shared libraries is one and only for all
19564 # processes, as opposed to a list of shared libraries per inferior.
19565 # When this property is true, GDB assumes that since shared libraries
19566 @@ -842,6 +862,7 @@ struct bp_target_info;
19567 struct target_desc;
19568 struct displaced_step_closure;
19569 struct core_regset_section;
19572 extern struct gdbarch *current_gdbarch;
19573 extern struct gdbarch *target_gdbarch;
19574 @@ -911,6 +932,9 @@ done
19578 +/* Definition for an unknown syscall, used basically in error-cases. */
19579 +#define UNKNOWN_SYSCALL (-1)
19581 extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
19584 diff --git a/gdb/gdbinit.in b/gdb/gdbinit.in
19585 index ffb7f53..a2e7e94 100644
19586 --- a/gdb/gdbinit.in
19587 +++ b/gdb/gdbinit.in
19589 echo Setting up the environment for debugging gdb.\n
19591 +# Set up the Python library and "require" command.
19593 +from os.path import abspath
19594 +gdb.datadir = abspath ('@srcdir@/python/lib')
19595 +gdb.pythonlibdir = gdb.datadir
19596 +gdb.__path__ = [gdb.datadir + '/gdb']
19597 +sys.path.insert(0, gdb.datadir)
19599 +source @srcdir@/python/lib/gdb/__init__.py
19604 diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
19605 index 3a405a8..a2e2636 100644
19606 --- a/gdb/gdbthread.h
19607 +++ b/gdb/gdbthread.h
19608 @@ -228,6 +228,9 @@ struct thread_info *find_thread_id (int num);
19609 /* Change the ptid of thread OLD_PTID to NEW_PTID. */
19610 void thread_change_ptid (ptid_t old_ptid, ptid_t new_ptid);
19612 +/* Prune dead threads from the list of threads. */
19613 +extern void prune_threads (void);
19615 /* Iterator function to call a user-provided callback function
19616 once for each known thread. */
19617 typedef int (*thread_callback_func) (struct thread_info *, void *);
19618 diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
19619 index 8102321..012485c 100644
19620 --- a/gdb/gdbtypes.c
19621 +++ b/gdb/gdbtypes.c
19623 #include "cp-abi.h"
19624 #include "gdb_assert.h"
19625 #include "hashtab.h"
19626 +#include "dwarf2expr.h"
19627 +#include "dwarf2loc.h"
19629 /* These variables point to the objects
19630 representing the predefined C data types. */
19631 @@ -146,6 +148,23 @@ static void print_bit_vector (B_TYPE *, int);
19632 static void print_arg_types (struct field *, int, int);
19633 static void dump_fn_fieldlists (struct type *, int);
19634 static void print_cplus_stuff (struct type *, int);
19635 +static void type_init_refc (struct type *new_type, struct type *parent_type);
19637 +/* A reference count structure for the type reference count map. Each
19638 + type in a hierarchy of types is mapped to the same reference
19640 +struct type_refc_entry
19642 + /* One type in the hierarchy. Each type in the hierarchy gets its
19644 + struct type *type;
19646 + /* A pointer to the shared reference count. */
19650 +/* The hash table holding all reference counts. */
19651 +static htab_t type_refc_table;
19654 /* Alloc a new type structure and fill it with some defaults. If
19655 @@ -154,23 +173,25 @@ static void print_cplus_stuff (struct type *, int);
19656 structure by xmalloc () (for permanent types). */
19659 -alloc_type (struct objfile *objfile)
19660 +alloc_type (struct objfile *objfile, struct type *parent)
19664 /* Alloc the structure and start off with all fields zeroed. */
19666 - if (objfile == NULL)
19667 + switch ((long) objfile)
19669 + case (long) OBJFILE_INTERNAL:
19670 + case (long) OBJFILE_MALLOC:
19671 type = XZALLOC (struct type);
19672 TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type);
19678 type = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct type);
19679 TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (&objfile->objfile_obstack,
19681 OBJSTAT (objfile, n_types++);
19685 /* Initialize the fields that might not be zero. */
19686 @@ -180,6 +201,9 @@ alloc_type (struct objfile *objfile)
19687 TYPE_VPTR_FIELDNO (type) = -1;
19688 TYPE_CHAIN (type) = type; /* Chain back to itself. */
19690 + if (objfile == NULL)
19691 + type_init_refc (type, parent);
19696 @@ -194,16 +218,24 @@ alloc_type_instance (struct type *oldtype)
19698 /* Allocate the structure. */
19700 - if (TYPE_OBJFILE (oldtype) == NULL)
19701 - type = XZALLOC (struct type);
19703 - type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
19706 + switch ((long) TYPE_OBJFILE (oldtype))
19708 + case (long) OBJFILE_INTERNAL:
19709 + case (long) OBJFILE_MALLOC:
19710 + type = XZALLOC (struct type);
19713 + type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
19717 TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
19719 TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
19721 + if (TYPE_OBJFILE (oldtype) == NULL)
19722 + type_init_refc (type, oldtype);
19727 @@ -248,7 +280,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
19729 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
19731 - ntype = alloc_type (TYPE_OBJFILE (type));
19732 + ntype = alloc_type (TYPE_OBJFILE (type), type);
19736 @@ -260,6 +292,9 @@ make_pointer_type (struct type *type, struct type **typeptr)
19737 smash_type (ntype);
19738 TYPE_CHAIN (ntype) = chain;
19739 TYPE_OBJFILE (ntype) = objfile;
19741 + /* Callers may only supply storage if there is an objfile. */
19742 + gdb_assert (objfile);
19745 TYPE_TARGET_TYPE (ntype) = type;
19746 @@ -328,7 +363,7 @@ make_reference_type (struct type *type, struct type **typeptr)
19748 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
19750 - ntype = alloc_type (TYPE_OBJFILE (type));
19751 + ntype = alloc_type (TYPE_OBJFILE (type), type);
19755 @@ -340,6 +375,9 @@ make_reference_type (struct type *type, struct type **typeptr)
19756 smash_type (ntype);
19757 TYPE_CHAIN (ntype) = chain;
19758 TYPE_OBJFILE (ntype) = objfile;
19760 + /* Callers may only supply storage if there is an objfile. */
19761 + gdb_assert (objfile);
19764 TYPE_TARGET_TYPE (ntype) = type;
19765 @@ -388,7 +426,7 @@ make_function_type (struct type *type, struct type **typeptr)
19767 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
19769 - ntype = alloc_type (TYPE_OBJFILE (type));
19770 + ntype = alloc_type (TYPE_OBJFILE (type), type);
19774 @@ -398,6 +436,9 @@ make_function_type (struct type *type, struct type **typeptr)
19775 objfile = TYPE_OBJFILE (ntype);
19776 smash_type (ntype);
19777 TYPE_OBJFILE (ntype) = objfile;
19779 + /* Callers may only supply storage if there is an objfile. */
19780 + gdb_assert (objfile);
19783 TYPE_TARGET_TYPE (ntype) = type;
19784 @@ -643,7 +684,7 @@ lookup_memberptr_type (struct type *type, struct type *domain)
19786 struct type *mtype;
19788 - mtype = alloc_type (TYPE_OBJFILE (type));
19789 + mtype = alloc_type (TYPE_OBJFILE (type), NULL);
19790 smash_to_memberptr_type (mtype, domain, type);
19793 @@ -655,7 +696,7 @@ lookup_methodptr_type (struct type *to_type)
19795 struct type *mtype;
19797 - mtype = alloc_type (TYPE_OBJFILE (to_type));
19798 + mtype = alloc_type (TYPE_OBJFILE (to_type), NULL);
19799 TYPE_TARGET_TYPE (mtype) = to_type;
19800 TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
19801 TYPE_LENGTH (mtype) = cplus_method_ptr_size (to_type);
19802 @@ -696,19 +737,20 @@ create_range_type (struct type *result_type, struct type *index_type,
19803 int low_bound, int high_bound)
19805 if (result_type == NULL)
19806 - result_type = alloc_type (TYPE_OBJFILE (index_type));
19807 + result_type = alloc_type (TYPE_OBJFILE (index_type), index_type);
19808 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
19809 TYPE_TARGET_TYPE (result_type) = index_type;
19810 if (TYPE_STUB (index_type))
19811 TYPE_TARGET_STUB (result_type) = 1;
19813 TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
19814 - TYPE_NFIELDS (result_type) = 2;
19815 + TYPE_NFIELDS (result_type) = 3;
19816 TYPE_FIELDS (result_type) = TYPE_ZALLOC (result_type,
19817 TYPE_NFIELDS (result_type)
19818 * sizeof (struct field));
19819 TYPE_LOW_BOUND (result_type) = low_bound;
19820 TYPE_HIGH_BOUND (result_type) = high_bound;
19821 + TYPE_BYTE_STRIDE (result_type) = 0;
19823 if (low_bound >= 0)
19824 TYPE_UNSIGNED (result_type) = 1;
19825 @@ -727,6 +769,9 @@ get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
19826 switch (TYPE_CODE (type))
19828 case TYPE_CODE_RANGE:
19829 + if (TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (type)
19830 + || TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (type))
19832 *lowp = TYPE_LOW_BOUND (type);
19833 *highp = TYPE_HIGH_BOUND (type);
19835 @@ -805,30 +850,56 @@ create_array_type (struct type *result_type,
19837 if (result_type == NULL)
19839 - result_type = alloc_type (TYPE_OBJFILE (range_type));
19840 + result_type = alloc_type (TYPE_OBJFILE (range_type), range_type);
19844 + /* Callers may only supply storage if there is an objfile. */
19845 + gdb_assert (TYPE_OBJFILE (result_type));
19848 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
19849 TYPE_TARGET_TYPE (result_type) = element_type;
19850 - if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
19851 - low_bound = high_bound = 0;
19852 - CHECK_TYPEDEF (element_type);
19853 - /* Be careful when setting the array length. Ada arrays can be
19854 - empty arrays with the high_bound being smaller than the low_bound.
19855 - In such cases, the array length should be zero. */
19856 - if (high_bound < low_bound)
19857 - TYPE_LENGTH (result_type) = 0;
19859 - TYPE_LENGTH (result_type) =
19860 - TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
19861 TYPE_NFIELDS (result_type) = 1;
19862 TYPE_FIELDS (result_type) =
19863 (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
19864 + /* FIXME: type alloc. */
19865 TYPE_INDEX_TYPE (result_type) = range_type;
19866 TYPE_VPTR_FIELDNO (result_type) = -1;
19868 - /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
19869 + /* DWARF blocks may depend on runtime information like
19870 + DW_OP_PUSH_OBJECT_ADDRESS not being available during the
19871 + CREATE_ARRAY_TYPE time. */
19872 + if (TYPE_RANGE_BOUND_IS_DWARF_BLOCK (range_type, 0)
19873 + || TYPE_RANGE_BOUND_IS_DWARF_BLOCK (range_type, 1)
19874 + || TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type)
19875 + || TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (range_type)
19876 + || get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
19882 + /* Be careful when setting the array length. Ada arrays can be
19883 + empty arrays with the high_bound being smaller than the low_bound.
19884 + In such cases, the array length should be zero. TYPE_TARGET_STUB needs to
19885 + be checked as it may have dependencies on DWARF blocks depending on
19886 + runtime information not available during the CREATE_ARRAY_TYPE time. */
19887 + if (high_bound < low_bound || TYPE_TARGET_STUB (element_type))
19888 + TYPE_LENGTH (result_type) = 0;
19891 + CHECK_TYPEDEF (element_type);
19892 + TYPE_LENGTH (result_type) =
19893 + TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
19896 if (TYPE_LENGTH (result_type) == 0)
19897 - TYPE_TARGET_STUB (result_type) = 1;
19899 + /* The real size will be computed for specific instances by
19900 + CHECK_TYPEDEF. */
19901 + TYPE_TARGET_STUB (result_type) = 1;
19904 return (result_type);
19906 @@ -865,7 +936,12 @@ create_set_type (struct type *result_type, struct type *domain_type)
19908 if (result_type == NULL)
19910 - result_type = alloc_type (TYPE_OBJFILE (domain_type));
19911 + result_type = alloc_type (TYPE_OBJFILE (domain_type), domain_type);
19915 + /* Callers may only supply storage if there is an objfile. */
19916 + gdb_assert (TYPE_OBJFILE (result_type));
19918 TYPE_CODE (result_type) = TYPE_CODE_SET;
19919 TYPE_NFIELDS (result_type) = 1;
19920 @@ -1368,6 +1444,84 @@ stub_noname_complaint (void)
19921 complaint (&symfile_complaints, _("stub type has NULL name"));
19924 +/* Calculate the memory length of array TYPE.
19926 + TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as
19927 + a performance hint. Feel free to pass NULL. Set FULL_SPAN to return the
19928 + size incl. the possible padding of the last element - it may differ from the
19929 + cleared FULL_SPAN return value (the expected SIZEOF) for non-zero
19930 + TYPE_BYTE_STRIDE values. */
19933 +type_length_get (struct type *type, struct type *target_type, int full_span)
19935 + struct type *range_type;
19937 + CORE_ADDR byte_stride = 0; /* `= 0' for a false GCC warning. */
19938 + CORE_ADDR element_size;
19940 + if (TYPE_CODE (type) != TYPE_CODE_ARRAY
19941 + && TYPE_CODE (type) != TYPE_CODE_STRING)
19942 + return TYPE_LENGTH (type);
19944 + /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
19945 + Fortran arrays. The allocated data will never be used so they can be
19947 + if (object_address_data_not_valid (type))
19950 + range_type = TYPE_INDEX_TYPE (type);
19951 + if (TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (range_type)
19952 + || TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type))
19954 + count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
19955 + /* It may happen for wrong DWARF annotations returning garbage data. */
19957 + warning (_("Range for type %s has invalid bounds %d..%d"),
19958 + TYPE_NAME (type), TYPE_LOW_BOUND (range_type),
19959 + TYPE_HIGH_BOUND (range_type));
19960 + /* The code below does not handle count == 0 right. */
19963 + if (full_span || count > 1)
19965 + /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to
19966 + force FULL_SPAN to 1. */
19967 + byte_stride = TYPE_BYTE_STRIDE (range_type);
19968 + if (byte_stride == 0)
19970 + if (target_type == NULL)
19971 + target_type = check_typedef (TYPE_TARGET_TYPE (type));
19972 + byte_stride = type_length_get (target_type, NULL, 1);
19976 + return count * byte_stride;
19977 + if (target_type == NULL)
19978 + target_type = check_typedef (TYPE_TARGET_TYPE (type));
19979 + element_size = type_length_get (target_type, NULL, 1);
19980 + return (count - 1) * byte_stride + element_size;
19983 +/* Prepare TYPE after being read in by the backend. Currently this function
19984 + only propagates the TYPE_DYNAMIC flag. */
19987 +finalize_type (struct type *type)
19991 + for (i = 0; i < TYPE_NFIELDS (type); ++i)
19992 + if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
19995 + /* FIXME: cplus_stuff is ignored here. */
19996 + if (i < TYPE_NFIELDS (type)
19997 + || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
19998 + || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
19999 + TYPE_DYNAMIC (type) = 1;
20002 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
20004 If this is a stubbed struct (i.e. declared as struct foo *), see if
20005 @@ -1384,7 +1538,8 @@ stub_noname_complaint (void)
20006 /* Find the real type of TYPE. This function returns the real type,
20007 after removing all layers of typedefs and completing opaque or stub
20008 types. Completion changes the TYPE argument, but stripping of
20009 - typedefs does not. */
20010 + typedefs does not. Still original passed TYPE will have TYPE_LENGTH
20011 + updated. FIXME: Remove this dependency (only ada_to_fixed_type?). */
20014 check_typedef (struct type *type)
20015 @@ -1420,7 +1575,7 @@ check_typedef (struct type *type)
20017 TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
20018 else /* TYPE_CODE_UNDEF */
20019 - TYPE_TARGET_TYPE (type) = alloc_type (NULL);
20020 + TYPE_TARGET_TYPE (type) = alloc_type (NULL, NULL);
20022 type = TYPE_TARGET_TYPE (type);
20024 @@ -1494,34 +1649,37 @@ check_typedef (struct type *type)
20028 - if (TYPE_TARGET_STUB (type))
20029 + /* copy_type_recursive automatically makes the resulting type containing only
20030 + constant values expected by the callers of this function. */
20031 + if (TYPE_DYNAMIC (type))
20033 + htab_t copied_types;
20034 + struct type *type_old = type;
20036 + copied_types = create_copied_types_hash (NULL);
20037 + type = copy_type_recursive (type, copied_types);
20038 + htab_delete (copied_types);
20040 + gdb_assert (TYPE_DYNAMIC (type) == 0);
20043 + if (!currently_reading_symtab
20044 + && (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type)))
20046 - struct type *range_type;
20047 struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
20049 + if (TYPE_DYNAMIC (type))
20050 + TYPE_TARGET_TYPE (type) = target_type;
20051 if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
20055 else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
20056 - && TYPE_NFIELDS (type) == 1
20057 - && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type))
20058 - == TYPE_CODE_RANGE))
20059 + || TYPE_CODE (type) == TYPE_CODE_STRING)
20061 /* Now recompute the length of the array type, based on its
20062 - number of elements and the target type's length.
20063 - Watch out for Ada null Ada arrays where the high bound
20064 - is smaller than the low bound. */
20065 - const int low_bound = TYPE_LOW_BOUND (range_type);
20066 - const int high_bound = TYPE_HIGH_BOUND (range_type);
20069 - if (high_bound < low_bound)
20072 - nb_elements = high_bound - low_bound + 1;
20074 - TYPE_LENGTH (type) = nb_elements * TYPE_LENGTH (target_type);
20075 + number of elements and the target type's length. */
20076 + TYPE_LENGTH (type) = type_length_get (type, target_type, 0);
20077 TYPE_TARGET_STUB (type) = 0;
20079 else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
20080 @@ -1529,9 +1687,12 @@ check_typedef (struct type *type)
20081 TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
20082 TYPE_TARGET_STUB (type) = 0;
20084 + TYPE_DYNAMIC (type) = 0;
20087 /* Cache TYPE_LENGTH for future use. */
20088 TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
20093 @@ -1753,7 +1914,7 @@ init_type (enum type_code code, int length, int flags,
20097 - type = alloc_type (objfile);
20098 + type = alloc_type (objfile, NULL);
20099 TYPE_CODE (type) = code;
20100 TYPE_LENGTH (type) = length;
20102 @@ -1783,15 +1944,24 @@ init_type (enum type_code code, int length, int flags,
20103 if (flags & TYPE_FLAG_FIXED_INSTANCE)
20104 TYPE_FIXED_INSTANCE (type) = 1;
20106 - if ((name != NULL) && (objfile != NULL))
20108 - TYPE_NAME (type) = obsavestring (name, strlen (name),
20109 - &objfile->objfile_obstack);
20113 - TYPE_NAME (type) = name;
20116 + switch ((long) objfile)
20118 + case (long) OBJFILE_INTERNAL:
20119 + TYPE_NAME (type) = name;
20121 + case (long) OBJFILE_MALLOC:
20122 + TYPE_NAME (type) = xstrdup (name);
20124 +#if 0 /* OBJFILE_MALLOC duplication now. */
20125 + case (long) NULL:
20126 + internal_error (__FILE__, __LINE__,
20127 + _("OBJFILE pointer NULL should be OBJFILE_* instead"));
20130 + TYPE_NAME (type) = obsavestring (name, strlen (name),
20131 + &objfile->objfile_obstack);
20136 @@ -1803,6 +1973,10 @@ init_type (enum type_code code, int length, int flags,
20138 INIT_CPLUS_SPECIFIC (type);
20142 + type_incref (type);
20147 @@ -2916,33 +3090,47 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
20150 /* Allocate the hash table used by copy_type_recursive to walk
20151 - types without duplicates. We use OBJFILE's obstack, because
20152 - OBJFILE is about to be deleted. */
20153 + types without duplicates. */
20156 create_copied_types_hash (struct objfile *objfile)
20158 - return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
20159 - NULL, &objfile->objfile_obstack,
20160 - hashtab_obstack_allocate,
20161 - dummy_obstack_deallocate);
20162 + if (objfile == NULL)
20164 + /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in
20165 + OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN. Table
20166 + element entries get allocated by xmalloc - so use xfree. */
20167 + return htab_create (1, type_pair_hash, type_pair_eq, xfree);
20171 + /* Use OBJFILE's obstack, because OBJFILE is about to be deleted. Table
20172 + element entries get allocated by xmalloc - so use xfree. */
20173 + return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
20174 + xfree, &objfile->objfile_obstack,
20175 + hashtab_obstack_allocate,
20176 + dummy_obstack_deallocate);
20180 -/* Recursively copy (deep copy) TYPE, if it is associated with
20181 - OBJFILE. Return a new type allocated using malloc, a saved type if
20182 - we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
20183 - not associated with OBJFILE. */
20184 +/* A helper for copy_type_recursive. This does all the work.
20185 + REPRESENTATIVE is a pointer to a type. This is used to register
20186 + newly-created types in the type_refc_table. Initially it pointer
20187 + to a NULL pointer, but it is filled in the first time a type is
20188 + copied. OBJFILE is used only for an assertion checking. */
20191 -copy_type_recursive (struct objfile *objfile,
20192 - struct type *type,
20193 - htab_t copied_types)
20194 +static struct type *
20195 +copy_type_recursive_1 (struct objfile *objfile,
20196 + struct type *type,
20197 + htab_t copied_types,
20198 + struct type **representative)
20200 struct type_pair *stored, pair;
20202 struct type *new_type;
20204 - if (TYPE_OBJFILE (type) == NULL)
20205 + if (TYPE_OBJFILE (type) == OBJFILE_INTERNAL
20206 + || (objfile == OBJFILE_MALLOC && !TYPE_DYNAMIC (type)))
20209 /* This type shouldn't be pointing to any types in other objfiles;
20210 @@ -2954,11 +3142,15 @@ copy_type_recursive (struct objfile *objfile,
20212 return ((struct type_pair *) *slot)->new;
20214 - new_type = alloc_type (NULL);
20215 + new_type = alloc_type (OBJFILE_MALLOC, *representative);
20216 + if (!*representative)
20217 + *representative = new_type;
20219 /* We must add the new type to the hash table immediately, in case
20220 - we encounter this type again during a recursive call below. */
20221 - stored = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
20222 + we encounter this type again during a recursive call below. Memory could
20223 + be allocated from OBJFILE in the case we will be removing OBJFILE, this
20224 + optimization is missed and xfree is called for it from COPIED_TYPES. */
20225 + stored = xmalloc (sizeof (*stored));
20226 stored->old = type;
20227 stored->new = new_type;
20229 @@ -2968,6 +3160,13 @@ copy_type_recursive (struct objfile *objfile,
20230 *TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type);
20231 TYPE_OBJFILE (new_type) = NULL;
20233 + /* Pre-clear the fields processed by delete_main_type. If DWARF block
20234 + evaluations below call error we would leave an unfreeable TYPE. */
20235 + TYPE_TARGET_TYPE (new_type) = NULL;
20236 + TYPE_VPTR_BASETYPE (new_type) = NULL;
20237 + TYPE_NFIELDS (new_type) = 0;
20238 + TYPE_FIELDS (new_type) = NULL;
20240 if (TYPE_NAME (type))
20241 TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
20242 if (TYPE_TAG_NAME (type))
20243 @@ -2976,12 +3175,45 @@ copy_type_recursive (struct objfile *objfile,
20244 TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
20245 TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
20247 + if (TYPE_ALLOCATED (new_type))
20249 + gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
20251 + if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
20252 + TYPE_NOT_ALLOCATED (new_type) = 1;
20253 + TYPE_ALLOCATED (new_type) = NULL;
20256 + if (TYPE_ASSOCIATED (new_type))
20258 + gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
20260 + if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
20261 + TYPE_NOT_ASSOCIATED (new_type) = 1;
20262 + TYPE_ASSOCIATED (new_type) = NULL;
20265 + if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
20266 + && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
20268 + if (TYPE_NOT_ALLOCATED (new_type)
20269 + || TYPE_NOT_ASSOCIATED (new_type))
20270 + TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
20273 + TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1;
20274 + TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval
20275 + (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type));
20279 /* Copy the fields. */
20280 if (TYPE_NFIELDS (type))
20284 nfields = TYPE_NFIELDS (type);
20285 + TYPE_NFIELDS (new_type) = nfields;
20286 TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
20287 for (i = 0; i < nfields; i++)
20289 @@ -2990,8 +3222,8 @@ copy_type_recursive (struct objfile *objfile,
20290 TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
20291 if (TYPE_FIELD_TYPE (type, i))
20292 TYPE_FIELD_TYPE (new_type, i)
20293 - = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
20295 + = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
20296 + copied_types, representative);
20297 if (TYPE_FIELD_NAME (type, i))
20298 TYPE_FIELD_NAME (new_type, i) =
20299 xstrdup (TYPE_FIELD_NAME (type, i));
20300 @@ -3010,6 +3242,16 @@ copy_type_recursive (struct objfile *objfile,
20301 xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type,
20304 + case FIELD_LOC_KIND_DWARF_BLOCK:
20305 + /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
20306 + it is expected to be made constant by CHECK_TYPEDEF. */
20307 + if (TYPE_NOT_ALLOCATED (new_type)
20308 + || TYPE_NOT_ASSOCIATED (new_type))
20309 + SET_FIELD_DWARF_BLOCK (TYPE_FIELD (new_type, i), NULL);
20311 + SET_FIELD_BITPOS (TYPE_FIELD (new_type, i),
20312 + dwarf_locexpr_baton_eval (TYPE_FIELD_DWARF_BLOCK (type, i)));
20315 internal_error (__FILE__, __LINE__,
20316 _("Unexpected type field location kind: %d"),
20317 @@ -3018,17 +3260,32 @@ copy_type_recursive (struct objfile *objfile,
20321 + /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */
20322 + if (TYPE_CODE (type) == TYPE_CODE_RANGE
20323 + && TYPE_RANGE_HIGH_BOUND_IS_COUNT (type))
20325 + TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0;
20326 + TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (type)
20327 + + TYPE_HIGH_BOUND (type) - 1;
20330 + /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
20331 + possibly converted. */
20332 + TYPE_DYNAMIC (new_type) = 0;
20334 /* Copy pointers to other types. */
20335 if (TYPE_TARGET_TYPE (type))
20336 TYPE_TARGET_TYPE (new_type) =
20337 - copy_type_recursive (objfile,
20338 - TYPE_TARGET_TYPE (type),
20340 + copy_type_recursive_1 (objfile,
20341 + TYPE_TARGET_TYPE (type),
20344 if (TYPE_VPTR_BASETYPE (type))
20345 TYPE_VPTR_BASETYPE (new_type) =
20346 - copy_type_recursive (objfile,
20347 - TYPE_VPTR_BASETYPE (type),
20349 + copy_type_recursive_1 (objfile,
20350 + TYPE_VPTR_BASETYPE (type),
20353 /* Maybe copy the type_specific bits.
20355 NOTE drow/2005-12-09: We do not copy the C++-specific bits like
20356 @@ -3046,6 +3303,20 @@ copy_type_recursive (struct objfile *objfile,
20360 +/* Recursively copy (deep copy) TYPE. Return a new type allocated using
20361 + malloc, a saved type if we have already visited TYPE (using COPIED_TYPES),
20362 + or TYPE if it is not associated with OBJFILE. */
20365 +copy_type_recursive (struct type *type,
20366 + htab_t copied_types)
20368 + struct type *representative = NULL;
20370 + return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types,
20371 + &representative);
20374 /* Make a copy of the given TYPE, except that the pointer & reference
20375 types are not preserved.
20377 @@ -3059,7 +3330,7 @@ copy_type (const struct type *type)
20379 gdb_assert (TYPE_OBJFILE (type) != NULL);
20381 - new_type = alloc_type (TYPE_OBJFILE (type));
20382 + new_type = alloc_type (TYPE_OBJFILE (type), NULL);
20383 TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
20384 TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
20385 memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
20386 @@ -3068,6 +3339,232 @@ copy_type (const struct type *type)
20390 +static void delete_type (struct type *type);
20392 +/* A helper for delete_type which deletes a main_type and the things to which
20393 + it refers. TYPE is a type whose main_type we wish to destroy. */
20396 +delete_main_type (struct main_type *main_type)
20402 + struct main_type *main_type;
20403 + } type_local = { main_type }, *type = &type_local;
20405 + gdb_assert (TYPE_OBJFILE (type) == OBJFILE_MALLOC);
20407 + xfree (TYPE_NAME (type));
20408 + xfree (TYPE_TAG_NAME (type));
20410 + for (i = 0; i < TYPE_NFIELDS (type); ++i)
20412 + xfree (TYPE_FIELD_NAME (type, i));
20414 + if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
20415 + xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
20417 + xfree (TYPE_FIELDS (type));
20419 + /* Strangely, HAVE_CPLUS_STRUCT will return true when there isn't
20421 + gdb_assert (!HAVE_CPLUS_STRUCT (type) || !TYPE_CPLUS_SPECIFIC (type));
20423 + xfree (TYPE_MAIN_TYPE (type));
20426 +/* Store `struct main_type *' entries which got `struct type *' deleted. */
20428 +static htab_t deleted_main_types_hash;
20430 +/* To be called before any call of delete_type. */
20433 +delete_type_begin (void)
20435 + gdb_assert (deleted_main_types_hash == NULL);
20437 + deleted_main_types_hash = htab_create_alloc (10, htab_hash_pointer,
20438 + htab_eq_pointer, NULL, xcalloc, xfree);
20441 +/* Helper for delete_type_finish. */
20444 +delete_type_finish_traverse (void **slot, void *unused)
20446 + struct main_type *main_type = *slot;
20448 + delete_main_type (main_type);
20453 +/* To be called after all the calls of delete_type. Each MAIN_TYPE must have
20454 + either none or all of its TYPE entries deleted. */
20457 +delete_type_finish (void)
20459 + htab_traverse (deleted_main_types_hash, delete_type_finish_traverse, NULL);
20461 + htab_delete (deleted_main_types_hash);
20462 + deleted_main_types_hash = NULL;
20465 +/* Delete TYPE and remember MAIN_TYPE it references. TYPE must have been
20466 + allocated using xmalloc -- not using an objfile. You must wrap calls of
20467 + this function by delete_type_begin and delete_type_finish. */
20470 +delete_type (struct type *type)
20477 + if (TYPE_OBJFILE (type) == OBJFILE_INTERNAL)
20479 + gdb_assert (TYPE_OBJFILE (type) == OBJFILE_MALLOC);
20481 + slot = htab_find_slot (deleted_main_types_hash, TYPE_MAIN_TYPE (type),
20483 + gdb_assert (!*slot);
20484 + *slot = TYPE_MAIN_TYPE (type);
20489 +/* Hash function for type_refc_table. */
20492 +type_refc_hash (const void *p)
20494 + const struct type_refc_entry *entry = p;
20495 + return htab_hash_pointer (entry->type);
20498 +/* Equality function for type_refc_table. */
20501 +type_refc_equal (const void *a, const void *b)
20503 + const struct type_refc_entry *left = a;
20504 + const struct type_refc_entry *right = b;
20505 + return left->type == right->type;
20508 +/* Insert the new type NEW_TYPE into the table. Does nothing if
20509 + NEW_TYPE has an objfile. If PARENT_TYPE is not NULL, then NEW_TYPE
20510 + will be inserted into the same hierarchy as PARENT_TYPE. In this
20511 + case, PARENT_TYPE must already exist in the reference count map.
20512 + If PARENT_TYPE is NULL, a new reference count is allocated and set
20516 +type_init_refc (struct type *new_type, struct type *parent_type)
20520 + struct type_refc_entry *new_entry;
20522 + if (TYPE_OBJFILE (new_type))
20527 + struct type_refc_entry entry, *found;
20528 + entry.type = parent_type;
20529 + found = htab_find (type_refc_table, &entry);
20530 + gdb_assert (found);
20531 + refc = found->refc;
20535 + refc = xmalloc (sizeof (int));
20539 + new_entry = XNEW (struct type_refc_entry);
20540 + new_entry->type = new_type;
20541 + new_entry->refc = refc;
20543 + slot = htab_find_slot (type_refc_table, new_entry, INSERT);
20544 + gdb_assert (!*slot);
20545 + *slot = new_entry;
20548 +/* Increment the reference count for TYPE. */
20551 +type_incref (struct type *type)
20553 + struct type_refc_entry entry, *found;
20555 + if (TYPE_OBJFILE (type))
20558 + entry.type = type;
20559 + found = htab_find (type_refc_table, &entry);
20560 + gdb_assert (found);
20561 + ++*(found->refc);
20564 +/* A traverse callback for type_refc_table which removes any entry
20565 + whose reference count is zero (unused entry). */
20568 +type_refc_remove (void **slot, void *unused)
20570 + struct type_refc_entry *entry = *slot;
20572 + if (*entry->refc == 0)
20574 + delete_type (entry->type);
20577 + htab_clear_slot (type_refc_table, slot);
20583 +/* Decrement the reference count for TYPE. Even if TYPE has no more
20584 + references still do not delete it as callers may hold pointers to types
20585 + dynamically generated by check_typedef where type_incref is never called.
20586 + Always rely on the free_all_types garbage collector. */
20589 +type_decref (struct type *type)
20591 + struct type_refc_entry entry, *found;
20593 + if (TYPE_OBJFILE (type))
20596 + entry.type = type;
20597 + found = htab_find (type_refc_table, &entry);
20598 + gdb_assert (found);
20599 + gdb_assert (found->refc > 0);
20600 + --*(found->refc);
20603 +/* Free all the types that have been allocated and that are not used according
20604 + to type_refc_entry->refc. Called after each command, successful or not.
20605 + Use this cleanup only in the GDB idle state as GDB code does not necessarily
20606 + use type_incref / type_decref during temporary use of types. */
20609 +free_all_types (void)
20611 + delete_type_begin ();
20612 + htab_traverse (type_refc_table, type_refc_remove, NULL);
20613 + delete_type_finish ();
20616 static struct type *
20617 build_flt (int bit, char *name, const struct floatformat **floatformats)
20619 @@ -3105,7 +3602,7 @@ build_complex (int bit, char *name, struct type *target_type)
20620 return builtin_type_error;
20622 t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT,
20623 - 0, name, (struct objfile *) NULL);
20624 + 0, name, OBJFILE_INTERNAL);
20625 TYPE_TARGET_TYPE (t) = target_type;
20628 @@ -3119,56 +3616,56 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
20629 builtin_type->builtin_void =
20630 init_type (TYPE_CODE_VOID, 1,
20632 - "void", (struct objfile *) NULL);
20633 + "void", OBJFILE_INTERNAL);
20634 builtin_type->builtin_char =
20635 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20637 | (gdbarch_char_signed (gdbarch) ? 0 : TYPE_FLAG_UNSIGNED)),
20638 - "char", (struct objfile *) NULL);
20639 + "char", OBJFILE_INTERNAL);
20640 builtin_type->builtin_signed_char =
20641 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20643 - "signed char", (struct objfile *) NULL);
20644 + "signed char", OBJFILE_INTERNAL);
20645 builtin_type->builtin_unsigned_char =
20646 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20647 TYPE_FLAG_UNSIGNED,
20648 - "unsigned char", (struct objfile *) NULL);
20649 + "unsigned char", OBJFILE_INTERNAL);
20650 builtin_type->builtin_short =
20651 init_type (TYPE_CODE_INT,
20652 gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
20653 - 0, "short", (struct objfile *) NULL);
20654 + 0, "short", OBJFILE_INTERNAL);
20655 builtin_type->builtin_unsigned_short =
20656 init_type (TYPE_CODE_INT,
20657 gdbarch_short_bit (gdbarch) / TARGET_CHAR_BIT,
20658 TYPE_FLAG_UNSIGNED, "unsigned short",
20659 - (struct objfile *) NULL);
20660 + OBJFILE_INTERNAL);
20661 builtin_type->builtin_int =
20662 init_type (TYPE_CODE_INT,
20663 gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
20664 - 0, "int", (struct objfile *) NULL);
20665 + 0, "int", OBJFILE_INTERNAL);
20666 builtin_type->builtin_unsigned_int =
20667 init_type (TYPE_CODE_INT,
20668 gdbarch_int_bit (gdbarch) / TARGET_CHAR_BIT,
20669 TYPE_FLAG_UNSIGNED, "unsigned int",
20670 - (struct objfile *) NULL);
20671 + OBJFILE_INTERNAL);
20672 builtin_type->builtin_long =
20673 init_type (TYPE_CODE_INT,
20674 gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
20675 - 0, "long", (struct objfile *) NULL);
20676 + 0, "long", OBJFILE_INTERNAL);
20677 builtin_type->builtin_unsigned_long =
20678 init_type (TYPE_CODE_INT,
20679 gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT,
20680 TYPE_FLAG_UNSIGNED, "unsigned long",
20681 - (struct objfile *) NULL);
20682 + OBJFILE_INTERNAL);
20683 builtin_type->builtin_long_long =
20684 init_type (TYPE_CODE_INT,
20685 gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
20686 - 0, "long long", (struct objfile *) NULL);
20687 + 0, "long long", OBJFILE_INTERNAL);
20688 builtin_type->builtin_unsigned_long_long =
20689 init_type (TYPE_CODE_INT,
20690 gdbarch_long_long_bit (gdbarch) / TARGET_CHAR_BIT,
20691 TYPE_FLAG_UNSIGNED, "unsigned long long",
20692 - (struct objfile *) NULL);
20693 + OBJFILE_INTERNAL);
20694 builtin_type->builtin_float
20695 = build_flt (gdbarch_float_bit (gdbarch), "float",
20696 gdbarch_float_format (gdbarch));
20697 @@ -3187,26 +3684,26 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
20698 builtin_type->builtin_string =
20699 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20701 - "string", (struct objfile *) NULL);
20702 + "string", OBJFILE_INTERNAL);
20703 builtin_type->builtin_bool =
20704 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20706 - "bool", (struct objfile *) NULL);
20707 + "bool", OBJFILE_INTERNAL);
20709 /* The following three are about decimal floating point types, which
20710 are 32-bits, 64-bits and 128-bits respectively. */
20711 builtin_type->builtin_decfloat
20712 = init_type (TYPE_CODE_DECFLOAT, 32 / 8,
20714 - "_Decimal32", (struct objfile *) NULL);
20715 + "_Decimal32", OBJFILE_INTERNAL);
20716 builtin_type->builtin_decdouble
20717 = init_type (TYPE_CODE_DECFLOAT, 64 / 8,
20719 - "_Decimal64", (struct objfile *) NULL);
20720 + "_Decimal64", OBJFILE_INTERNAL);
20721 builtin_type->builtin_declong
20722 = init_type (TYPE_CODE_DECFLOAT, 128 / 8,
20724 - "_Decimal128", (struct objfile *) NULL);
20725 + "_Decimal128", OBJFILE_INTERNAL);
20727 /* Pointer/Address types. */
20729 @@ -3245,27 +3742,28 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
20730 init_type (TYPE_CODE_INT,
20731 gdbarch_addr_bit (gdbarch) / 8,
20732 TYPE_FLAG_UNSIGNED,
20733 - "__CORE_ADDR", (struct objfile *) NULL);
20734 + "__CORE_ADDR", OBJFILE_INTERNAL);
20737 /* The following set of types is used for symbols with no
20738 debug information. */
20739 builtin_type->nodebug_text_symbol =
20740 init_type (TYPE_CODE_FUNC, 1, 0,
20741 - "<text variable, no debug info>", NULL);
20742 + "<text variable, no debug info>", OBJFILE_INTERNAL);
20743 TYPE_TARGET_TYPE (builtin_type->nodebug_text_symbol) =
20744 builtin_type->builtin_int;
20745 builtin_type->nodebug_data_symbol =
20746 init_type (TYPE_CODE_INT,
20747 gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
20748 - "<data variable, no debug info>", NULL);
20749 + "<data variable, no debug info>", OBJFILE_INTERNAL);
20750 builtin_type->nodebug_unknown_symbol =
20751 init_type (TYPE_CODE_INT, 1, 0,
20752 - "<variable (not text or data), no debug info>", NULL);
20753 + "<variable (not text or data), no debug info>",
20754 + OBJFILE_INTERNAL);
20755 builtin_type->nodebug_tls_symbol =
20756 init_type (TYPE_CODE_INT,
20757 gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
20758 - "<thread local variable, no debug info>", NULL);
20759 + "<thread local variable, no debug info>", OBJFILE_INTERNAL);
20761 return builtin_type;
20763 @@ -3276,6 +3774,9 @@ _initialize_gdbtypes (void)
20765 gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
20767 + type_refc_table = htab_create_alloc (20, type_refc_hash, type_refc_equal,
20768 + NULL, xcalloc, xfree);
20770 /* FIXME: The following types are architecture-neutral. However,
20771 they contain pointer_type and reference_type fields potentially
20772 caching pointer or reference types that *are* architecture
20773 @@ -3284,47 +3785,47 @@ _initialize_gdbtypes (void)
20774 builtin_type_int0 =
20775 init_type (TYPE_CODE_INT, 0 / 8,
20777 - "int0_t", (struct objfile *) NULL);
20778 + "int0_t", OBJFILE_INTERNAL);
20779 builtin_type_int8 =
20780 init_type (TYPE_CODE_INT, 8 / 8,
20782 - "int8_t", (struct objfile *) NULL);
20783 + "int8_t", OBJFILE_INTERNAL);
20784 builtin_type_uint8 =
20785 init_type (TYPE_CODE_INT, 8 / 8,
20786 TYPE_FLAG_UNSIGNED | TYPE_FLAG_NOTTEXT,
20787 - "uint8_t", (struct objfile *) NULL);
20788 + "uint8_t", OBJFILE_INTERNAL);
20789 builtin_type_int16 =
20790 init_type (TYPE_CODE_INT, 16 / 8,
20792 - "int16_t", (struct objfile *) NULL);
20793 + "int16_t", OBJFILE_INTERNAL);
20794 builtin_type_uint16 =
20795 init_type (TYPE_CODE_INT, 16 / 8,
20796 TYPE_FLAG_UNSIGNED,
20797 - "uint16_t", (struct objfile *) NULL);
20798 + "uint16_t", OBJFILE_INTERNAL);
20799 builtin_type_int32 =
20800 init_type (TYPE_CODE_INT, 32 / 8,
20802 - "int32_t", (struct objfile *) NULL);
20803 + "int32_t", OBJFILE_INTERNAL);
20804 builtin_type_uint32 =
20805 init_type (TYPE_CODE_INT, 32 / 8,
20806 TYPE_FLAG_UNSIGNED,
20807 - "uint32_t", (struct objfile *) NULL);
20808 + "uint32_t", OBJFILE_INTERNAL);
20809 builtin_type_int64 =
20810 init_type (TYPE_CODE_INT, 64 / 8,
20812 - "int64_t", (struct objfile *) NULL);
20813 + "int64_t", OBJFILE_INTERNAL);
20814 builtin_type_uint64 =
20815 init_type (TYPE_CODE_INT, 64 / 8,
20816 TYPE_FLAG_UNSIGNED,
20817 - "uint64_t", (struct objfile *) NULL);
20818 + "uint64_t", OBJFILE_INTERNAL);
20819 builtin_type_int128 =
20820 init_type (TYPE_CODE_INT, 128 / 8,
20822 - "int128_t", (struct objfile *) NULL);
20823 + "int128_t", OBJFILE_INTERNAL);
20824 builtin_type_uint128 =
20825 init_type (TYPE_CODE_INT, 128 / 8,
20826 TYPE_FLAG_UNSIGNED,
20827 - "uint128_t", (struct objfile *) NULL);
20828 + "uint128_t", OBJFILE_INTERNAL);
20830 builtin_type_ieee_single =
20831 build_flt (-1, "builtin_type_ieee_single", floatformats_ieee_single);
20832 @@ -3344,15 +3845,15 @@ _initialize_gdbtypes (void)
20833 builtin_type_void =
20834 init_type (TYPE_CODE_VOID, 1,
20836 - "void", (struct objfile *) NULL);
20837 + "void", OBJFILE_INTERNAL);
20838 builtin_type_true_char =
20839 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20841 - "true character", (struct objfile *) NULL);
20842 + "true character", OBJFILE_INTERNAL);
20843 builtin_type_true_unsigned_char =
20844 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
20845 TYPE_FLAG_UNSIGNED,
20846 - "true character", (struct objfile *) NULL);
20847 + "true character", OBJFILE_INTERNAL);
20849 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
20850 Set debugging of C++ overloading."), _("\
20851 diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
20852 index c90b6d7..077b89c 100644
20853 --- a/gdb/gdbtypes.h
20854 +++ b/gdb/gdbtypes.h
20855 @@ -134,7 +134,10 @@ enum type_code
20857 TYPE_CODE_NAMESPACE, /* C++ namespace. */
20859 - TYPE_CODE_DECFLOAT /* Decimal floating point. */
20860 + TYPE_CODE_DECFLOAT, /* Decimal floating point. */
20862 + /* Internal function type. */
20863 + TYPE_CODE_INTERNAL_FUNCTION
20866 /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
20867 @@ -209,6 +212,11 @@ enum type_instance_flag_value
20869 #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
20871 +/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
20874 +#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic)
20876 /* Static type. If this is set, the corresponding type had
20877 * a static modifier.
20878 * Note: This may be unnecessary, since static data members
20879 @@ -266,6 +274,36 @@ enum type_instance_flag_value
20881 #define TYPE_NOTTEXT(t) (TYPE_MAIN_TYPE (t)->flag_nottext)
20883 +/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */
20885 +#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
20886 + (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
20888 +/* Not allocated. TYPE_ALLOCATED(t) must be NULL in such case. If this flag
20889 + is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated. If this
20890 + flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block
20891 + determines the actual allocation state. */
20893 +#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated)
20895 +/* Not associated. TYPE_ASSOCIATED(t) must be NULL in such case. If this flag
20896 + is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated. If
20897 + this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block
20898 + determines the actual association state. */
20900 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
20902 +/* Address of the actual data as for DW_AT_data_location. Its dwarf block must
20903 + not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are
20904 + false. If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value
20905 + is the actual data address value. If unset and
20906 + TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal
20907 + VALUE_ADDRESS copy. If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL
20908 + then its DWARF block determines the actual data address. */
20910 +#define TYPE_DATA_LOCATION_IS_ADDR(t) \
20911 + (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
20913 /* Constant type. If this is set, the corresponding type has a
20916 @@ -352,6 +390,11 @@ struct main_type
20917 unsigned int flag_stub_supported : 1;
20918 unsigned int flag_nottext : 1;
20919 unsigned int flag_fixed_instance : 1;
20920 + unsigned int flag_dynamic : 1;
20921 + unsigned int flag_range_high_bound_is_count : 1;
20922 + unsigned int flag_not_allocated : 1;
20923 + unsigned int flag_not_associated : 1;
20924 + unsigned int flag_data_location_is_addr : 1;
20926 /* Number of fields described for this type. This field appears at
20927 this location because it packs nicely here. */
20928 @@ -414,6 +457,20 @@ struct main_type
20930 struct type *target_type;
20932 + /* For DW_AT_data_location. */
20935 + struct dwarf2_locexpr_baton *dwarf_block;
20940 + /* For DW_AT_allocated. */
20941 + struct dwarf2_locexpr_baton *allocated;
20943 + /* For DW_AT_associated. */
20944 + struct dwarf2_locexpr_baton *associated;
20946 /* For structure and union types, a description of each field.
20947 For set and pascal array types, there is one "field",
20948 whose type is the domain type of the set or array.
20949 @@ -795,9 +852,9 @@ extern void allocate_cplus_struct_type (struct type *);
20950 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
20951 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
20952 #define TYPE_CHAIN(thistype) (thistype)->chain
20953 -/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
20954 - But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
20955 - so you only have to call check_typedef once. Since allocate_value
20956 +/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call
20957 + check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF
20958 + type, so you only have to call check_typedef once. Since allocate_value
20959 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */
20960 #define TYPE_LENGTH(thistype) (thistype)->length
20961 #define TYPE_OBJFILE(thistype) TYPE_MAIN_TYPE(thistype)->objfile
20962 @@ -807,23 +864,44 @@ extern void allocate_cplus_struct_type (struct type *);
20963 #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
20964 #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->fields
20965 #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
20966 +#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block
20967 +#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr
20968 +#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated
20969 +#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
20971 #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
20972 #define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
20973 #define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
20975 -/* Moto-specific stuff for FORTRAN arrays */
20977 -#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
20978 - (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),1))
20979 +#define TYPE_BYTE_STRIDE(range_type) TYPE_FIELD_BITPOS (range_type, 2)
20981 +/* Whether we should use TYPE_FIELD_DWARF_BLOCK (and not TYPE_FIELD_BITPOS). */
20982 +#define TYPE_RANGE_BOUND_IS_DWARF_BLOCK(range_type, fieldno) \
20983 + (TYPE_FIELD_LOC_KIND (range_type, fieldno) == FIELD_LOC_KIND_DWARF_BLOCK)
20984 +#define TYPE_RANGE_BOUND_SET_DWARF_BLOCK(range_type, fieldno) \
20985 + (TYPE_FIELD_LOC_KIND (range_type, fieldno) = FIELD_LOC_KIND_DWARF_BLOCK)
20986 +#define TYPE_ARRAY_BOUND_IS_DWARF_BLOCK(array_type, fieldno) \
20987 + TYPE_RANGE_BOUND_IS_DWARF_BLOCK (TYPE_INDEX_TYPE (array_type), fieldno)
20989 +/* Unbound arrays, such as GCC array[]; at end of struct. */
20990 +#define TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED(rangetype) \
20991 + TYPE_FIELD_ARTIFICIAL((rangetype),0)
20992 +#define TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED(rangetype) \
20993 + TYPE_FIELD_ARTIFICIAL((rangetype),1)
20994 #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
20995 - (TYPE_FIELD_ARTIFICIAL(TYPE_INDEX_TYPE((arraytype)),0))
20997 -#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
20998 - (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
20999 + TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (TYPE_INDEX_TYPE (arraytype))
21000 +#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
21001 + TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (TYPE_INDEX_TYPE (arraytype))
21003 #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
21004 - (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
21005 + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
21006 +#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
21007 + TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (arraytype))
21008 +/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
21009 + element size if no specific stride value is known. */
21010 +#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \
21011 + (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
21012 + ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \
21013 + : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
21017 @@ -1078,6 +1156,16 @@ extern struct type *builtin_type_error;
21018 (TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) \
21019 : MIN_OF_SIZE(TYPE_LENGTH(t)))
21021 +/* Virtual OBJFILE used for builtin types. */
21022 +#define OBJFILE_INTERNAL ((struct objfile *) 1L)
21024 +/* Virtual OBJFILE used for types allocated by malloc. FIXME: Currently
21025 + backward compatible with the old NULL value; fix then also init_type. */
21026 +#define OBJFILE_MALLOC ((struct objfile *) 0L)
21028 +#define OBJFILE_IS_VIRTUAL(objfile) ((objfile) == OBJFILE_INTERNAL \
21029 + || (objfile) == OBJFILE_MALLOC)
21031 /* Allocate space for storing data associated with a particular type.
21032 We ensure that the space is allocated using the same mechanism that
21033 was used to allocate the space for the type structure itself. I.E.
21034 @@ -1087,18 +1175,18 @@ extern struct type *builtin_type_error;
21035 builtin types), then the data space will be allocated with xmalloc,
21036 the same as for the type structure. */
21038 -#define TYPE_ALLOC(t,size) \
21039 - (TYPE_OBJFILE (t) != NULL \
21040 - ? obstack_alloc (&TYPE_OBJFILE (t) -> objfile_obstack, size) \
21041 - : xmalloc (size))
21042 +#define TYPE_ALLOC(t,size) \
21043 + (OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (t)) \
21044 + ? xmalloc (size) \
21045 + : obstack_alloc (&TYPE_OBJFILE (t) -> objfile_obstack, size))
21047 -#define TYPE_ZALLOC(t,size) \
21048 - (TYPE_OBJFILE (t) != NULL \
21049 - ? memset (obstack_alloc (&TYPE_OBJFILE (t)->objfile_obstack, size), \
21051 - : xzalloc (size))
21052 +#define TYPE_ZALLOC(t,size) \
21053 + (OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (t)) \
21054 + ? xzalloc (size) \
21055 + : memset (obstack_alloc (&TYPE_OBJFILE (t)->objfile_obstack, size), \
21058 -extern struct type *alloc_type (struct objfile *);
21059 +extern struct type *alloc_type (struct objfile *, struct type *);
21061 extern struct type *init_type (enum type_code, int, int, char *,
21063 @@ -1172,6 +1260,18 @@ extern struct type *create_range_type (struct type *, struct type *, int,
21064 extern struct type *create_array_type (struct type *, struct type *,
21067 +extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
21070 +extern int type_range_high_bound_internal (struct type *range_type);
21072 +extern int type_range_count_bound_internal (struct type *range_type);
21074 +extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
21075 + struct type *element_type);
21077 +extern void finalize_type (struct type *type);
21079 extern struct type *create_string_type (struct type *, struct type *);
21081 extern struct type *create_set_type (struct type *, struct type *);
21082 @@ -1263,10 +1363,15 @@ extern void maintenance_print_type (char *, int);
21084 extern htab_t create_copied_types_hash (struct objfile *objfile);
21086 -extern struct type *copy_type_recursive (struct objfile *objfile,
21087 - struct type *type,
21088 +extern struct type *copy_type_recursive (struct type *type,
21089 htab_t copied_types);
21091 extern struct type *copy_type (const struct type *type);
21093 +extern void type_incref (struct type *type);
21095 +extern void type_decref (struct type *type);
21097 +extern void free_all_types (void);
21099 #endif /* GDBTYPES_H */
21100 diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
21101 index 7cacac1..a456228 100644
21102 --- a/gdb/gnu-v2-abi.c
21103 +++ b/gdb/gnu-v2-abi.c
21104 @@ -242,7 +242,7 @@ gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc)
21105 we'd waste a bunch of time figuring out we already know the type.
21106 Besides, we don't care about the type, just the actual pointer
21108 - if (VALUE_ADDRESS (value_field (v, known_type_vptr_fieldno)) == 0)
21109 + if (value_address (value_field (v, known_type_vptr_fieldno)) == 0)
21112 vtbl = value_as_address (value_field (v, known_type_vptr_fieldno));
21113 diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
21114 index 3a52df3..6cdf716 100644
21115 --- a/gdb/gnu-v3-abi.c
21116 +++ b/gdb/gnu-v3-abi.c
21117 @@ -269,8 +269,7 @@ gnuv3_rtti_type (struct value *value,
21119 /* Find the linker symbol for this vtable. */
21121 - = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtable)
21122 - + value_offset (vtable)
21123 + = lookup_minimal_symbol_by_pc (value_address (vtable)
21124 + value_embedded_offset (vtable));
21125 if (! vtable_symbol)
21127 @@ -487,10 +486,8 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
21128 LONGEST adjustment)
21131 - const char *physname;
21133 /* Search this class first. */
21135 if (adjustment == 0)
21138 @@ -615,13 +612,15 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
21140 char *demangled_name = cplus_demangle (physname,
21141 DMGL_ANSI | DMGL_PARAMS);
21142 - if (demangled_name != NULL)
21143 + fprintf_filtered (stream, "&virtual ");
21144 + if (demangled_name == NULL)
21145 + fputs_filtered (physname, stream);
21148 - fprintf_filtered (stream, "&virtual ");
21149 fputs_filtered (demangled_name, stream);
21150 xfree (demangled_name);
21157 diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
21158 index 2366474..f83de32 100644
21159 --- a/gdb/i386-linux-nat.c
21160 +++ b/gdb/i386-linux-nat.c
21161 @@ -751,7 +751,13 @@ i386_linux_resume (struct target_ops *ops,
21163 int pid = PIDGET (ptid);
21165 - int request = PTRACE_CONT;
21168 + if (target_passed_by_entrypoint () > 0
21169 + && catch_syscall_enabled () > 0)
21170 + request = PTRACE_SYSCALL;
21172 + request = PTRACE_CONT;
21176 diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
21177 index 1a2e4f0..973eced 100644
21178 --- a/gdb/i386-linux-tdep.c
21179 +++ b/gdb/i386-linux-tdep.c
21181 #include "symtab.h"
21182 #include "arch-utils.h"
21183 #include "regset.h"
21184 +#include "linux-tdep.h"
21186 +/* The syscall's XML filename for i386. */
21187 +#define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml"
21189 /* Supported register note sections. */
21190 static struct core_regset_section i386_linux_regset_sections[] =
21191 @@ -349,6 +353,26 @@ i386_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
21196 +i386_linux_get_syscall_number (struct gdbarch *gdbarch,
21199 + struct regcache *regcache = get_thread_regcache (ptid);
21200 + /* The content of a register. */
21202 + /* The result. */
21205 + /* Getting the system call number from the register.
21206 + When dealing with x86 architecture, this information
21207 + is stored at %eax register. */
21208 + regcache_cooked_read (regcache, I386_LINUX_ORIG_EAX_REGNUM, buf);
21210 + ret = extract_signed_integer (buf, 4);
21215 /* The register sets used in GNU/Linux ELF core-dumps are identical to
21216 the register sets in `struct user' that are used for a.out
21217 core-dumps. These are also used by ptrace(2). The corresponding
21218 @@ -419,6 +443,9 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
21220 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
21222 + /* Initializing common functions. */
21223 + linux_tdep_init (gdbarch);
21225 /* GNU/Linux uses ELF. */
21226 i386_elf_init_abi (info, gdbarch);
21228 @@ -472,6 +499,11 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
21229 displaced_step_at_entry_point);
21231 set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
21233 + /* Functions for 'catch syscall'. */
21234 + set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_I386);
21235 + set_gdbarch_get_syscall_number (gdbarch,
21236 + i386_linux_get_syscall_number);
21239 /* Provide a prototype to silence -Wmissing-prototypes. */
21240 diff --git a/gdb/inf-child.c b/gdb/inf-child.c
21241 index 38311f1..fc968cf 100644
21242 --- a/gdb/inf-child.c
21243 +++ b/gdb/inf-child.c
21244 @@ -148,6 +148,15 @@ inf_child_remove_exec_catchpoint (int pid)
21248 +inf_child_set_syscall_catchpoint (int pid, int needed, int any_count,
21249 + int table_size, int *table)
21251 + /* This version of Unix doesn't support notification of syscall
21257 inf_child_can_run (void)
21260 @@ -190,6 +199,7 @@ inf_child_target (void)
21261 t->to_follow_fork = inf_child_follow_fork;
21262 t->to_insert_exec_catchpoint = inf_child_insert_exec_catchpoint;
21263 t->to_remove_exec_catchpoint = inf_child_remove_exec_catchpoint;
21264 + t->to_set_syscall_catchpoint = inf_child_set_syscall_catchpoint;
21265 t->to_can_run = inf_child_can_run;
21266 t->to_pid_to_exec_file = inf_child_pid_to_exec_file;
21267 t->to_stratum = process_stratum;
21268 diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
21269 index f40b6b7..ff429c4 100644
21270 --- a/gdb/inf-ptrace.c
21271 +++ b/gdb/inf-ptrace.c
21272 @@ -356,13 +356,19 @@ inf_ptrace_resume (struct target_ops *ops,
21273 ptid_t ptid, int step, enum target_signal signal)
21275 pid_t pid = ptid_get_pid (ptid);
21276 - int request = PT_CONTINUE;
21280 /* Resume all threads. Traditionally ptrace() only supports
21281 single-threaded processes, so simply resume the inferior. */
21282 pid = ptid_get_pid (inferior_ptid);
21284 + if (target_passed_by_entrypoint () > 0
21285 + && catch_syscall_enabled () > 0)
21286 + request = PT_SYSCALL;
21288 + request = PT_CONTINUE;
21292 /* If this system does not support PT_STEP, a higher level
21293 diff --git a/gdb/infcall.c b/gdb/infcall.c
21294 index d6da8b2..80168b3 100644
21295 --- a/gdb/infcall.c
21296 +++ b/gdb/infcall.c
21297 @@ -98,6 +98,28 @@ Unwinding of stack if a signal is received while in a call dummy is %s.\n"),
21301 +/* This boolean tells what gdb should do if a std::terminate call is
21302 + made while in a function called from gdb (call dummy).
21303 + As the confines of a single dummy stack prohibit out-of-frame
21304 + handlers from handling a raised exception, and as out-of-frame
21305 + handlers are common in C++, this can lead to no handler being found
21306 + by the unwinder, and a std::terminate call. This is a false positive.
21307 + If set, gdb unwinds the stack and restores the context to what it
21308 + was before the call.
21310 + The default is to unwind the frame if a std::terminate call is made.. */
21312 +static int unwind_on_terminating_exception_p = 1;
21314 +show_unwind_on_terminating_exception_p (struct ui_file *file, int from_tty,
21315 + struct cmd_list_element *c,
21316 + const char *value)
21319 + fprintf_filtered (file, _("\
21320 +Unwind stack if a C++ exception is unhandled while in a call dummy is %s.\n"),
21324 /* Perform the standard coercions that are specified
21325 for arguments to be passed to C or Ada functions.
21326 @@ -217,7 +239,7 @@ find_function_addr (struct value *function, struct type **retval_type)
21327 /* Determine address to call. */
21328 if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
21330 - funaddr = VALUE_ADDRESS (function);
21331 + funaddr = value_address (function);
21332 value_type = TYPE_TARGET_TYPE (ftype);
21334 else if (code == TYPE_CODE_PTR)
21335 @@ -419,6 +441,8 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
21336 struct cleanup *args_cleanup;
21337 struct frame_info *frame;
21338 struct gdbarch *gdbarch;
21339 + struct breakpoint *terminate_bp = 0;
21340 + struct minimal_symbol *tm;
21341 ptid_t call_thread_ptid;
21342 struct gdb_exception e;
21344 @@ -718,6 +742,29 @@ call_function_by_hand (struct value *function, int nargs, struct value **args)
21345 bpt = set_momentary_breakpoint (sal, dummy_id, bp_call_dummy);
21346 bpt->disposition = disp_del;
21349 + /* Create a breakpoint in std::terminate.
21350 + If a C++ exception is raised in the dummy-frame, and the
21351 + exception handler is (normally, and expected to be) out-of-frame,
21352 + the default C++ handler will (wrongly) be called in an inferior
21353 + function call. This is wrong, as an exception can be normally
21354 + and legally handled out-of-frame. The confines of the dummy frame
21355 + prevent the unwinder from finding the correct handler (or any
21356 + handler, unless it is in-frame). The default handler calls
21357 + std::terminate. This will kill the inferior. Assert that
21358 + terminate should never be called in an inferior function
21359 + call. Place a momentary breakpoint in the std::terminate function
21360 + and if triggered in the call, rewind */
21361 + if (unwind_on_terminating_exception_p)
21363 + tm = lookup_minimal_symbol ("std::terminate()", NULL, NULL);
21366 + terminate_bp = set_momentary_breakpoint_at_pc
21367 + (SYMBOL_VALUE_ADDRESS (tm), bp_breakpoint);
21368 + make_cleanup_delete_breakpoint (terminate_bp);
21372 /* Everything's ready, push all the info needed to restore the
21373 caller (and identify the dummy-frame) onto the dummy-frame
21374 @@ -828,6 +875,16 @@ When the function is done executing, GDB will silently stop."),
21378 + if (! target_has_execution)
21380 + /* If we try to restore the inferior status (via the cleanup),
21381 + we'll crash as the inferior is no longer running. */
21382 + discard_cleanups (inf_status_cleanup);
21383 + discard_inferior_status (inf_status);
21385 +The program being debugged exited while in a function called from GDB."));
21388 if (stopped_by_random_signal || !stop_stack_dummy)
21390 const char *name = get_function_name (funaddr,
21391 @@ -884,6 +941,38 @@ When the function is done executing, GDB will silently stop."),
21393 if (!stop_stack_dummy)
21396 + /* Check if unwind on terminating exception behaviour is on */
21397 + if (unwind_on_terminating_exception_p)
21399 + /* Check that the breakpoint is our special std::terminate
21400 + breakpoint. If it is, we do not want to kill the inferior
21401 + in an inferior function call. Rewind, and warn the user */
21403 + if ((terminate_bp != NULL) &&
21404 + (inferior_thread()->stop_bpstat->breakpoint_at->address
21405 + == terminate_bp->loc->address))
21410 + /* We must get back to the frame we were before the
21412 + dummy_frame_pop (dummy_id);
21414 + /* We also need to restore inferior status to that before the
21416 + restore_inferior_status (inf_status);
21419 +The program being debugged entered a std::terminate call which would\n\
21420 +have terminated the program being debugged. GDB has restored the\n\
21421 +context to what it was before the call\n\
21422 +To change this behaviour use \"set unwind-on-terminating-exception off\"\n\
21423 +Evaluation of the expression containing the function (%s) will be abandoned."),
21427 /* We hit a breakpoint inside the FUNCTION.
21428 Keep the dummy frame, the user may want to examine its state.
21429 Discard inferior status, we're not at the same point
21430 @@ -992,4 +1081,19 @@ The default is to stop in the frame where the signal was received."),
21432 show_unwind_on_signal_p,
21433 &setlist, &showlist);
21435 + add_setshow_boolean_cmd ("unwind-on-terminating-exception", no_class,
21436 + &unwind_on_terminating_exception_p, _("\
21437 +Set unwinding of stack if a std::terminate() call originates from\n\
21438 +the default C++ exception handler."), _("\
21439 +Show unwinding of stack if a std::terminate() call originates from\n\
21440 +the default C++ exception handler."), _("\
21441 +The unwind on terminating exception flag lets the user determine\n\
21442 +what gdb should do if a std::terminate() call is made from the\n\
21443 +default exception handler.\n\
21444 +The default is to unwind the frame."),
21446 + show_unwind_on_terminating_exception_p,
21447 + &setlist, &showlist);
21450 diff --git a/gdb/infcmd.c b/gdb/infcmd.c
21451 index 0a17dab..d48f4b1 100644
21454 @@ -466,6 +466,11 @@ run_command_1 (char *args, int from_tty, int tbreak_at_main)
21455 init_wait_for_inferior ();
21456 clear_breakpoint_hit_counts ();
21458 + /* If we already caught a syscall catchpoint, then reset its
21459 + syscall_number information because we are starting all over
21461 + clear_syscall_catchpoints_info ();
21463 /* Clean up any leftovers from other runs. Some other things from
21464 this function should probably be moved into target_pre_inferior. */
21465 target_pre_inferior (from_tty);
21466 diff --git a/gdb/infrun.c b/gdb/infrun.c
21467 index ee5f987..2f627ea 100644
21470 @@ -1046,7 +1046,7 @@ a command like `return' or `jump' to continue execution."));
21474 - /* If there were any forks/vforks/execs that were caught and are
21475 + /* If there were any forks/vforks/execs/syscalls that were caught and are
21476 now to be followed, then do so. */
21477 switch (pending_follow.kind)
21479 @@ -1069,6 +1069,11 @@ a command like `return' or `jump' to continue execution."));
21480 pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
21483 + case TARGET_WAITKIND_SYSCALL_ENTRY:
21484 + case TARGET_WAITKIND_SYSCALL_RETURN:
21485 + pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
21491 @@ -1509,7 +1514,7 @@ init_wait_for_inferior (void)
21493 breakpoint_init_inferior (inf_starting);
21495 - /* The first resume is not following a fork/vfork/exec. */
21496 + /* The first resume is not following a fork/vfork/exec/syscall. */
21497 pending_follow.kind = TARGET_WAITKIND_SPURIOUS; /* I.e., none. */
21499 clear_proceed_status ();
21500 @@ -2155,6 +2160,50 @@ ensure_not_running (void)
21501 error_is_running ();
21504 +/* Auxiliary function that handles syscall entry/return events.
21505 + It returns 1 if the inferior should keep going (and GDB
21506 + should ignore the event), or 0 if the event deserves to be
21509 +deal_with_syscall_event (struct execution_control_state *ecs)
21511 + int syscall_number = gdbarch_get_syscall_number (current_gdbarch,
21513 + if (catch_syscall_enabled () > 0
21514 + && catching_syscall_number (syscall_number) > 0)
21516 + ecs->event_thread->stop_signal = TARGET_SIGNAL_TRAP;
21517 + pending_follow.kind = ecs->ws.kind;
21519 + if (!ptid_equal (ecs->ptid, inferior_ptid))
21521 + context_switch (ecs->ptid);
21522 + reinit_frame_cache ();
21525 + stop_pc = read_pc ();
21527 + ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
21529 + ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
21531 + /* If no catchpoint triggered for this, then keep going. */
21532 + if (ecs->random_signal)
21534 + ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
21535 + keep_going (ecs);
21542 + resume (0, TARGET_SIGNAL_0);
21543 + prepare_to_wait (ecs);
21548 /* Given an execution control state that has been freshly filled in
21549 by an event from the inferior, figure out what it means and take
21550 appropriate action. */
21551 @@ -2449,9 +2498,11 @@ handle_inferior_event (struct execution_control_state *ecs)
21552 case TARGET_WAITKIND_SYSCALL_ENTRY:
21554 fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SYSCALL_ENTRY\n");
21555 - resume (0, TARGET_SIGNAL_0);
21556 - prepare_to_wait (ecs);
21558 + /* Getting the current syscall number */
21559 + if (deal_with_syscall_event (ecs) != 0)
21561 + goto process_event_stop_test;
21564 /* Before examining the threads further, step this thread to
21565 get it entirely out of the syscall. (We get notice of the
21566 @@ -2461,9 +2512,10 @@ handle_inferior_event (struct execution_control_state *ecs)
21567 case TARGET_WAITKIND_SYSCALL_RETURN:
21569 fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SYSCALL_RETURN\n");
21570 - target_resume (ecs->ptid, 1, TARGET_SIGNAL_0);
21571 - prepare_to_wait (ecs);
21573 + if (deal_with_syscall_event (ecs) != 0)
21575 + goto process_event_stop_test;
21578 case TARGET_WAITKIND_STOPPED:
21580 @@ -5166,6 +5218,25 @@ inferior_has_execd (ptid_t pid, char **execd_pathname)
21585 +inferior_has_called_syscall (ptid_t pid, int *syscall_number)
21587 + struct target_waitstatus last;
21588 + ptid_t last_ptid;
21590 + get_last_target_status (&last_ptid, &last);
21592 + if (last.kind != TARGET_WAITKIND_SYSCALL_ENTRY &&
21593 + last.kind != TARGET_WAITKIND_SYSCALL_RETURN)
21596 + if (!ptid_equal (last_ptid, pid))
21599 + *syscall_number = last.value.syscall_number;
21603 /* Oft used ptids */
21605 ptid_t minus_one_ptid;
21606 diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
21607 index b702ebf..a211adf 100644
21608 --- a/gdb/jv-lang.c
21609 +++ b/gdb/jv-lang.c
21610 @@ -61,7 +61,8 @@ static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
21611 static int java_class_is_primitive (struct value *clas);
21612 static struct value *java_value_string (char *ptr, int len);
21614 -static void java_emit_char (int c, struct ui_file * stream, int quoter);
21615 +static void java_emit_char (int c, struct type *type,
21616 + struct ui_file * stream, int quoter);
21618 static char *java_class_name_from_physname (const char *physname);
21620 @@ -210,8 +211,7 @@ get_java_utf8_name (struct obstack *obstack, struct value *name)
21621 CORE_ADDR data_addr;
21622 temp = value_struct_elt (&temp, NULL, "length", NULL, "structure");
21623 name_length = (int) value_as_long (temp);
21624 - data_addr = VALUE_ADDRESS (temp) + value_offset (temp)
21625 - + TYPE_LENGTH (value_type (temp));
21626 + data_addr = value_address (temp) + TYPE_LENGTH (value_type (temp));
21627 chrs = obstack_alloc (obstack, name_length + 1);
21628 chrs[name_length] = '\0';
21629 read_memory (data_addr, (gdb_byte *) chrs, name_length);
21630 @@ -266,7 +266,7 @@ type_from_class (struct value *clas)
21632 clas = value_ind (clas);
21634 - addr = VALUE_ADDRESS (clas) + value_offset (clas);
21635 + addr = value_address (clas);
21638 get_java_class_symtab ();
21639 @@ -302,7 +302,7 @@ type_from_class (struct value *clas)
21643 - type = alloc_type (objfile);
21644 + type = alloc_type (objfile, NULL);
21645 TYPE_CODE (type) = TYPE_CODE_STRUCT;
21646 INIT_CPLUS_SPECIFIC (type);
21648 @@ -422,7 +422,7 @@ java_link_class_type (struct type *type, struct value *clas)
21650 nfields--; /* First set up dummy "class" field. */
21651 SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields),
21652 - VALUE_ADDRESS (clas) + value_offset (clas));
21653 + value_address (clas));
21654 TYPE_FIELD_NAME (type, nfields) = "class";
21655 TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
21656 SET_TYPE_FIELD_PRIVATE (type, nfields);
21657 @@ -439,7 +439,9 @@ java_link_class_type (struct type *type, struct value *clas)
21660 { /* Re-use field value for next field. */
21661 - VALUE_ADDRESS (field) += TYPE_LENGTH (value_type (field));
21663 + = value_address (field) + TYPE_LENGTH (value_type (field));
21664 + set_value_address (field, addr);
21665 set_value_lazy (field, 1);
21668 @@ -509,7 +511,9 @@ java_link_class_type (struct type *type, struct value *clas)
21671 { /* Re-use method value for next method. */
21672 - VALUE_ADDRESS (method) += TYPE_LENGTH (value_type (method));
21674 + = value_address (method) + TYPE_LENGTH (value_type (method));
21675 + set_value_address (method, addr);
21676 set_value_lazy (method, 1);
21679 @@ -796,7 +800,7 @@ java_value_string (char *ptr, int len)
21680 characters and strings is language specific. */
21683 -java_emit_char (int c, struct ui_file *stream, int quoter)
21684 +java_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
21688 diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
21689 index d3606fd..cdcb440 100644
21690 --- a/gdb/jv-valprint.c
21691 +++ b/gdb/jv-valprint.c
21692 @@ -45,7 +45,7 @@ java_value_print (struct value *val, struct ui_file *stream,
21693 struct value_print_options opts;
21695 type = value_type (val);
21696 - address = VALUE_ADDRESS (val) + value_offset (val);
21697 + address = value_address (val);
21699 if (is_object_type (type))
21701 @@ -143,8 +143,8 @@ java_value_print (struct value *val, struct ui_file *stream,
21702 struct value *v = allocate_value (el_type);
21703 struct value *next_v = allocate_value (el_type);
21705 - VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
21706 - VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
21707 + set_value_address (v, address + JAVA_OBJECT_SIZE + 4);
21708 + set_value_address (next_v, value_raw_address (v));
21710 while (i < length && things_printed < options->print_max)
21712 @@ -230,7 +230,7 @@ java_value_print (struct value *val, struct ui_file *stream,
21714 value_free_to_mark (mark); /* Release unnecessary values */
21716 - val_print_string (data + boffset, count, 2, stream, options);
21717 + val_print_string (java_char_type, data + boffset, count, stream, options);
21721 @@ -520,7 +520,7 @@ java_val_print (struct type *type, const gdb_byte *valaddr,
21722 || (TYPE_CODE (type) == TYPE_CODE_INT
21723 && TYPE_LENGTH (type) == 2
21724 && strcmp (TYPE_NAME (type), "char") == 0))
21725 - LA_PRINT_CHAR ((int) unpack_long (type, valaddr), stream);
21726 + LA_PRINT_CHAR ((int) unpack_long (type, valaddr), type, stream);
21728 val_print_type_code_int (type, valaddr, stream);
21730 diff --git a/gdb/language.c b/gdb/language.c
21731 index 3c37a64..6209d7f 100644
21732 --- a/gdb/language.c
21733 +++ b/gdb/language.c
21734 @@ -65,9 +65,11 @@ static void set_check (char *, int);
21736 static void set_type_range_case (void);
21738 -static void unk_lang_emit_char (int c, struct ui_file *stream, int quoter);
21739 +static void unk_lang_emit_char (int c, struct type *type,
21740 + struct ui_file *stream, int quoter);
21742 -static void unk_lang_printchar (int c, struct ui_file *stream);
21743 +static void unk_lang_printchar (int c, struct type *type,
21744 + struct ui_file *stream);
21746 static void unk_lang_print_type (struct type *, char *, struct ui_file *,
21748 @@ -1065,20 +1067,22 @@ unk_lang_error (char *msg)
21752 -unk_lang_emit_char (int c, struct ui_file *stream, int quoter)
21753 +unk_lang_emit_char (int c, struct type *type, struct ui_file *stream,
21756 error (_("internal error - unimplemented function unk_lang_emit_char called."));
21760 -unk_lang_printchar (int c, struct ui_file *stream)
21761 +unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
21763 error (_("internal error - unimplemented function unk_lang_printchar called."));
21767 -unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
21768 - unsigned int length, int width, int force_ellipses,
21769 +unk_lang_printstr (struct ui_file *stream, struct type *type,
21770 + const gdb_byte *string, unsigned int length,
21771 + int force_ellipses,
21772 const struct value_print_options *options)
21774 error (_("internal error - unimplemented function unk_lang_printstr called."));
21775 diff --git a/gdb/language.h b/gdb/language.h
21776 index 85826fd..e5f80ab 100644
21777 --- a/gdb/language.h
21778 +++ b/gdb/language.h
21779 @@ -186,14 +186,15 @@ struct language_defn
21781 void (*la_post_parser) (struct expression ** expp, int void_context_p);
21783 - void (*la_printchar) (int ch, struct ui_file * stream);
21784 + void (*la_printchar) (int ch, struct type *chtype, struct ui_file * stream);
21786 - void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
21787 - unsigned int length, int width,
21788 + void (*la_printstr) (struct ui_file * stream, struct type *elttype,
21789 + const gdb_byte *string, unsigned int length,
21790 int force_ellipses,
21791 const struct value_print_options *);
21793 - void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
21794 + void (*la_emitchar) (int ch, struct type *chtype,
21795 + struct ui_file * stream, int quoter);
21797 /* Print a type using syntax appropriate for this language. */
21799 @@ -381,13 +382,13 @@ extern enum language set_language (enum language);
21800 #define LA_VALUE_PRINT(val,stream,options) \
21801 (current_language->la_value_print(val,stream,options))
21803 -#define LA_PRINT_CHAR(ch, stream) \
21804 - (current_language->la_printchar(ch, stream))
21805 -#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
21806 - (current_language->la_printstr(stream, string, length, width, \
21807 +#define LA_PRINT_CHAR(ch, type, stream) \
21808 + (current_language->la_printchar(ch, type, stream))
21809 +#define LA_PRINT_STRING(stream, elttype, string, length, force_ellipses,options) \
21810 + (current_language->la_printstr(stream, elttype, string, length, \
21811 force_ellipses,options))
21812 -#define LA_EMIT_CHAR(ch, stream, quoter) \
21813 - (current_language->la_emitchar(ch, stream, quoter))
21814 +#define LA_EMIT_CHAR(ch, type, stream, quoter) \
21815 + (current_language->la_emitchar(ch, type, stream, quoter))
21816 #define LA_GET_STRING(value, buffer, length, encoding) \
21817 (current_language->la_get_string(value, buffer, length, encoding))
21819 diff --git a/gdb/linespec.c b/gdb/linespec.c
21820 index 6579d42..b3ae6c0 100644
21821 --- a/gdb/linespec.c
21822 +++ b/gdb/linespec.c
21823 @@ -842,13 +842,33 @@ decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
21825 else if (paren_pointer != NULL)
21827 - p = paren_pointer + 1;
21828 + /* We need to deal with method and function overloads
21829 + with no parameters. Gdb and gcc (and who knows about other
21830 + compilers) are very inconsistent with the keyword "void".
21831 + Canonicalizing C++ types is insufficient in this case, since
21832 + we still need to enforce the presence (or lack thereof) of
21833 + "void". For simplicity, omit the keyword "void" if present. */
21834 + if (strncmp (paren_pointer - 5, "(void)", 6) == 0)
21837 + a = paren_pointer - 4;
21838 + b = paren_pointer;
21839 + while ((*(a++) = *(b++)) != '\0') ;
21841 + p = paren_pointer - 3;
21844 + p = paren_pointer + 1;
21848 p = skip_quoted (*argptr);
21851 + /* Make sure we keep important kewords like "const" */
21852 + if (strncmp (p, " const", 6) == 0)
21855 copy = (char *) alloca (p - *argptr + 1);
21856 memcpy (copy, *argptr, p - *argptr);
21857 copy[p - *argptr] = '\0';
21858 diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
21859 index 12b786e..e30bf9a 100644
21860 --- a/gdb/linux-nat.c
21861 +++ b/gdb/linux-nat.c
21864 #endif /* HAVE_PERSONALITY */
21866 +/* To be used when one needs to know wether a
21867 + WSTOPSIG (status) is a syscall */
21868 +#define TRAP_IS_SYSCALL (SIGTRAP | 0x80)
21870 /* This comment documents high-level logic of this file.
21872 Waiting for events in sync mode
21873 @@ -281,17 +285,29 @@ struct simple_pid_list *stopped_pids;
21875 static int linux_supports_tracefork_flag = -1;
21877 +/* This variable is a tri-state flag: -1 for unknown, 0 if PTRACE_O_TRACESYSGOOD
21878 + can not be used, 1 if it can. */
21880 +static int linux_supports_tracesysgood_flag = -1;
21882 /* If we have PTRACE_O_TRACEFORK, this flag indicates whether we also have
21883 PTRACE_O_TRACEVFORKDONE. */
21885 static int linux_supports_tracevforkdone_flag = -1;
21887 +/* If the inferior have passed through its entrypoint (AT_ENTRY),
21888 + then this flag is set to 1. Otherwise, its value is 0. */
21889 +static int linux_passed_by_entrypoint_flag = 0;
21891 /* Async mode support */
21893 /* Zero if the async mode, although enabled, is masked, which means
21894 linux_nat_wait should behave as if async mode was off. */
21895 static int linux_nat_async_mask_value = 1;
21897 +/* Stores the current used ptrace() options. */
21898 +static int current_ptrace_options = 0;
21900 /* The read/write ends of the pipe registered as waitable file in the
21902 static int linux_nat_event_pipe[2] = { -1, -1 };
21903 @@ -636,6 +652,41 @@ linux_test_for_tracefork (int original_pid)
21904 linux_nat_async_events (async_events_original_state);
21907 +/* Determine if PTRACE_O_TRACESYSGOOD can be used to follow syscalls.
21909 + We try to enable syscall tracing on ORIGINAL_PID. If this fails,
21910 + we know that the feature is not available. This may change the tracing
21911 + options for ORIGINAL_PID, but we'll be setting them shortly anyway. */
21914 +linux_test_for_tracesysgood (int original_pid)
21917 + enum sigchld_state async_events_original_state;
21919 + async_events_original_state = linux_nat_async_events (sigchld_sync);
21921 + linux_supports_tracesysgood_flag = 0;
21923 + ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACESYSGOOD);
21927 + linux_supports_tracesysgood_flag = 1;
21928 + linux_nat_async_events (async_events_original_state);
21931 +/* Determine wether we support PTRACE_O_TRACESYSGOOD option available.
21932 + This function also sets linux_supports_tracesysgood_flag. */
21935 +linux_supports_tracesysgood (int pid)
21937 + if (linux_supports_tracesysgood_flag == -1)
21938 + linux_test_for_tracesysgood (pid);
21939 + return linux_supports_tracesysgood_flag;
21942 /* Return non-zero iff we have tracefork functionality available.
21943 This function also sets linux_supports_tracefork_flag. */
21945 @@ -655,12 +706,34 @@ linux_supports_tracevforkdone (int pid)
21946 return linux_supports_tracevforkdone_flag;
21950 +linux_enable_tracesysgood (ptid_t ptid)
21952 + int pid = ptid_get_lwp (ptid);
21955 + pid = ptid_get_pid (ptid);
21957 + if (linux_supports_tracesysgood (pid) == 0)
21960 + current_ptrace_options |= PTRACE_O_TRACESYSGOOD;
21961 + linux_passed_by_entrypoint_flag = 1;
21963 + ptrace (PTRACE_SETOPTIONS, pid, 0, current_ptrace_options);
21967 +linux_passed_by_entrypoint (void)
21969 + return linux_passed_by_entrypoint_flag;
21974 linux_enable_event_reporting (ptid_t ptid)
21976 int pid = ptid_get_lwp (ptid);
21980 pid = ptid_get_pid (ptid);
21981 @@ -668,15 +741,16 @@ linux_enable_event_reporting (ptid_t ptid)
21982 if (! linux_supports_tracefork (pid))
21985 - options = PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACEEXEC
21986 - | PTRACE_O_TRACECLONE;
21987 + current_ptrace_options |= PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK
21988 + | PTRACE_O_TRACEEXEC | PTRACE_O_TRACECLONE;
21990 if (linux_supports_tracevforkdone (pid))
21991 - options |= PTRACE_O_TRACEVFORKDONE;
21992 + current_ptrace_options |= PTRACE_O_TRACEVFORKDONE;
21994 /* Do not enable PTRACE_O_TRACEEXIT until GDB is more prepared to support
21995 read-only process state. */
21997 - ptrace (PTRACE_SETOPTIONS, pid, 0, options);
21998 + ptrace (PTRACE_SETOPTIONS, pid, 0, current_ptrace_options);
22002 @@ -684,6 +758,7 @@ linux_child_post_attach (int pid)
22004 linux_enable_event_reporting (pid_to_ptid (pid));
22005 check_for_thread_db ();
22006 + linux_enable_tracesysgood (pid_to_ptid (pid));
22010 @@ -691,6 +766,7 @@ linux_child_post_startup_inferior (ptid_t ptid)
22012 linux_enable_event_reporting (ptid);
22013 check_for_thread_db ();
22014 + linux_enable_tracesysgood (ptid);
22018 @@ -931,6 +1007,16 @@ linux_child_insert_exec_catchpoint (int pid)
22019 error (_("Your system does not support exec catchpoints."));
22023 +linux_child_set_syscall_catchpoint (int pid, int needed, int any_count,
22024 + int table_size, int *table)
22026 + if (! linux_supports_tracesysgood (pid))
22027 + error (_("Your system does not support syscall catchpoints."));
22028 + /* We ignore the arguments. */
22032 /* On GNU/Linux there are no real LWP's. The closest thing to LWP's
22033 are processes sharing the same VM space. A multi-threaded process
22034 is basically a group of such processes. However, such a grouping
22035 @@ -1352,6 +1438,9 @@ linux_nat_create_inferior (struct target_ops *ops,
22036 int personality_orig = 0, personality_set = 0;
22037 #endif /* HAVE_PERSONALITY */
22039 + /* We are sarting, so we still have not passed through our entrypoint. */
22040 + linux_passed_by_entrypoint_flag = 0;
22042 /* The fork_child mechanism is synchronous and calls target_wait, so
22043 we have to mask the async mode. */
22045 @@ -1996,6 +2085,26 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
22049 + /* Used for 'catch syscall' feature. */
22050 + if (WSTOPSIG (status) == TRAP_IS_SYSCALL)
22052 + if (catch_syscall_enabled () == 0)
22053 + ourstatus->kind = TARGET_WAITKIND_IGNORE;
22056 + struct regcache *regcache = get_thread_regcache (lp->ptid);
22057 + struct gdbarch *gdbarch = get_regcache_arch (regcache);
22059 + ourstatus->kind =
22060 + (lp->syscall_state == TARGET_WAITKIND_SYSCALL_ENTRY) ?
22061 + TARGET_WAITKIND_SYSCALL_RETURN : TARGET_WAITKIND_SYSCALL_ENTRY;
22062 + lp->syscall_state = ourstatus->kind;
22063 + ourstatus->value.syscall_number =
22064 + (int) gdbarch_get_syscall_number (gdbarch, lp->ptid);
22069 internal_error (__FILE__, __LINE__,
22070 _("unknown ptrace event %d"), event);
22072 @@ -2606,11 +2715,16 @@ linux_nat_filter_event (int lwpid, int status, int options)
22075 /* Save the trap's siginfo in case we need it later. */
22076 - if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP)
22077 + if (WIFSTOPPED (status)
22078 + && (WSTOPSIG (status) == SIGTRAP || WSTOPSIG (status) == TRAP_IS_SYSCALL))
22081 - /* Handle GNU/Linux's extended waitstatus for trace events. */
22082 - if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)
22083 + /* Handle GNU/Linux's extended waitstatus for trace events.
22084 + It is necessary to check if WSTOPSIG is signaling a that
22085 + the inferior is entering/exiting a system call. */
22086 + if (WIFSTOPPED (status)
22087 + && ((WSTOPSIG (status) == TRAP_IS_SYSCALL)
22088 + || (WSTOPSIG (status) == SIGTRAP && status >> 16 != 0)))
22090 if (debug_linux_nat)
22091 fprintf_unfiltered (gdb_stdlog,
22092 @@ -4262,12 +4376,14 @@ linux_target_install_ops (struct target_ops *t)
22093 t->to_insert_fork_catchpoint = linux_child_insert_fork_catchpoint;
22094 t->to_insert_vfork_catchpoint = linux_child_insert_vfork_catchpoint;
22095 t->to_insert_exec_catchpoint = linux_child_insert_exec_catchpoint;
22096 + t->to_set_syscall_catchpoint = linux_child_set_syscall_catchpoint;
22097 t->to_pid_to_exec_file = linux_child_pid_to_exec_file;
22098 t->to_post_startup_inferior = linux_child_post_startup_inferior;
22099 t->to_post_attach = linux_child_post_attach;
22100 t->to_follow_fork = linux_child_follow_fork;
22101 t->to_find_memory_regions = linux_nat_find_memory_regions;
22102 t->to_make_corefile_notes = linux_nat_make_corefile_notes;
22103 + t->to_passed_by_entrypoint = linux_passed_by_entrypoint;
22105 super_xfer_partial = t->to_xfer_partial;
22106 t->to_xfer_partial = linux_xfer_partial;
22107 diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
22108 index fec5139..36d2439 100644
22109 --- a/gdb/linux-nat.h
22110 +++ b/gdb/linux-nat.h
22111 @@ -70,6 +70,13 @@ struct lwp_info
22112 or to a local variable in lin_lwp_wait. */
22113 struct target_waitstatus waitstatus;
22115 + /* Signal wether we are in a SYSCALL_ENTRY or
22116 + in a SYSCALL_RETURN event.
22118 + - TARGET_WAITKIND_SYSCALL_ENTRY
22119 + - TARGET_WAITKIND_SYSCALL_RETURN */
22120 + int syscall_state;
22122 /* Next LWP in list. */
22123 struct lwp_info *next;
22125 diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
22126 index e18e134..d44b505 100644
22127 --- a/gdb/linux-tdep.c
22128 +++ b/gdb/linux-tdep.c
22131 #include "gdbtypes.h"
22132 #include "linux-tdep.h"
22133 +#include "xml-syscall.h"
22134 +#include "target.h"
22136 /* This function is suitable for architectures that don't
22137 extend/override the standard siginfo structure. */
22138 @@ -137,3 +139,81 @@ linux_get_siginfo_type (struct gdbarch *gdbarch)
22140 return siginfo_type;
22143 +/* Structure used to store information about the available syscalls in
22145 +static const struct syscalls_info *sysinfo = NULL;
22147 +/* A flag to tell if we already initialized the structure above. */
22148 +static int have_initialized_sysinfo = 0;
22150 +/* The filename of the syscall's XML. */
22151 +static const char *xml_syscall_file = NULL;
22153 +/* Initializes the syscalls_info structure according to the
22156 +init_sysinfo (struct gdbarch *gdbarch)
22158 + /* Did we already try to initialize the structure? */
22159 + if (have_initialized_sysinfo)
22162 + if (xml_syscall_file == NULL)
22163 + xml_syscall_file = gdbarch_xml_syscall_filename (gdbarch);
22165 + sysinfo = xml_init_syscalls_info (xml_syscall_file);
22167 + have_initialized_sysinfo = 1;
22169 + if (sysinfo == NULL)
22171 + if (xml_syscall_file)
22172 + /* The initialization failed. Let's show a warning
22173 + message to the user (just this time) and leave. */
22174 + warning (_("Could not load the syscall XML file '%s'.\n\
22175 +GDB will not be able to display syscall names."), xml_syscall_file);
22177 + /* There's no file to open. Let's warn the user. */
22178 + warning (_("There is no XML file to open.\n\
22179 +GDB will not be able to display syscall names."));
22184 +linux_get_syscall_by_number (struct gdbarch *gdbarch,
22185 + int syscall_number,
22186 + struct syscall *s)
22188 + init_sysinfo (gdbarch);
22190 + s->number = syscall_number;
22191 + s->name = xml_get_syscall_name (sysinfo, syscall_number);
22195 +linux_get_syscall_by_name (struct gdbarch *gdbarch,
22196 + const char *syscall_name,
22197 + struct syscall *s)
22199 + init_sysinfo (gdbarch);
22201 + s->number = xml_get_syscall_number (sysinfo, syscall_name);
22202 + s->name = syscall_name;
22205 +static const char **
22206 +linux_get_syscall_names (struct gdbarch *gdbarch)
22208 + init_sysinfo (gdbarch);
22210 + return xml_list_of_syscalls (sysinfo);
22214 +linux_tdep_init (struct gdbarch *gdbarch)
22216 + set_gdbarch_get_syscall_by_number (gdbarch, linux_get_syscall_by_number);
22217 + set_gdbarch_get_syscall_by_name (gdbarch, linux_get_syscall_by_name);
22218 + set_gdbarch_get_syscall_names (gdbarch, linux_get_syscall_names);
22220 diff --git a/gdb/linux-tdep.h b/gdb/linux-tdep.h
22221 index 50af511..1e1e541 100644
22222 --- a/gdb/linux-tdep.h
22223 +++ b/gdb/linux-tdep.h
22226 struct type *linux_get_siginfo_type (struct gdbarch *);
22228 +extern void linux_tdep_init (struct gdbarch *gdbarch);
22230 #endif /* linux-tdep.h */
22231 diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
22232 index 9e4bb1b..9ca3ae1 100644
22233 --- a/gdb/m2-lang.c
22234 +++ b/gdb/m2-lang.c
22236 #include "valprint.h"
22238 extern void _initialize_m2_language (void);
22239 -static void m2_printchar (int, struct ui_file *);
22240 -static void m2_emit_char (int, struct ui_file *, int);
22241 +static void m2_printchar (int, struct type *, struct ui_file *);
22242 +static void m2_emit_char (int, struct type *, struct ui_file *, int);
22244 /* Print the character C on STREAM as part of the contents of a literal
22245 string whose delimiter is QUOTER. Note that that format for printing
22246 @@ -39,7 +39,7 @@ static void m2_emit_char (int, struct ui_file *, int);
22247 be replaced with a true Modula version. */
22250 -m2_emit_char (int c, struct ui_file *stream, int quoter)
22251 +m2_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
22254 c &= 0xFF; /* Avoid sign bit follies */
22255 @@ -88,10 +88,10 @@ m2_emit_char (int c, struct ui_file *stream, int quoter)
22256 be replaced with a true Modula version. */
22259 -m2_printchar (int c, struct ui_file *stream)
22260 +m2_printchar (int c, struct type *type, struct ui_file *stream)
22262 fputs_filtered ("'", stream);
22263 - LA_EMIT_CHAR (c, stream, '\'');
22264 + LA_EMIT_CHAR (c, type, stream, '\'');
22265 fputs_filtered ("'", stream);
22268 @@ -103,14 +103,15 @@ m2_printchar (int c, struct ui_file *stream)
22269 be replaced with a true Modula version. */
22272 -m2_printstr (struct ui_file *stream, const gdb_byte *string,
22273 - unsigned int length, int width, int force_ellipses,
22274 +m2_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
22275 + unsigned int length, int force_ellipses,
22276 const struct value_print_options *options)
22279 unsigned int things_printed = 0;
22281 int need_comma = 0;
22282 + int width = TYPE_LENGTH (type);
22286 @@ -152,7 +153,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
22287 fputs_filtered ("\", ", stream);
22290 - m2_printchar (string[i], stream);
22291 + m2_printchar (string[i], type, stream);
22292 fprintf_filtered (stream, " <repeats %u times>", reps);
22294 things_printed += options->repeat_count_threshold;
22295 @@ -168,7 +169,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
22296 fputs_filtered ("\"", stream);
22299 - LA_EMIT_CHAR (string[i], stream, '"');
22300 + LA_EMIT_CHAR (string[i], type, stream, '"');
22304 diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
22305 index 71c410c..41fb8fe 100644
22306 --- a/gdb/m2-valprint.c
22307 +++ b/gdb/m2-valprint.c
22308 @@ -237,7 +237,8 @@ print_unpacked_pointer (struct type *type,
22309 && TYPE_CODE (elttype) == TYPE_CODE_INT
22310 && (options->format == 0 || options->format == 's')
22312 - return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
22313 + return val_print_string (TYPE_TARGET_TYPE (type), addr, -1,
22314 + stream, options);
22318 @@ -294,7 +295,7 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
22319 || ((current_language->la_language == language_m2)
22320 && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
22321 && (options->format == 0 || options->format == 's'))
22322 - val_print_string (address, len+1, eltlen, stream, options);
22323 + val_print_string (type, address, len+1, stream, options);
22326 fprintf_filtered (stream, "{");
22327 @@ -359,7 +360,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
22331 - LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
22332 + LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
22333 + valaddr + embedded_offset, len, 0,
22337 @@ -547,7 +549,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
22339 fprintf_filtered (stream, "%d", (int) val);
22340 fputs_filtered (" ", stream);
22341 - LA_PRINT_CHAR ((unsigned char) val, stream);
22342 + LA_PRINT_CHAR ((unsigned char) val, type, stream);
22346 diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
22347 index 5f4b9a6..eccfe31 100644
22348 --- a/gdb/m32r-tdep.c
22349 +++ b/gdb/m32r-tdep.c
22350 @@ -713,7 +713,7 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
22352 && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
22354 - store_unsigned_integer (valbuf, 4, VALUE_ADDRESS (args[argnum]));
22355 + store_unsigned_integer (valbuf, 4, value_address (args[argnum]));
22356 typecode = TYPE_CODE_PTR;
22359 diff --git a/gdb/macroexp.c b/gdb/macroexp.c
22360 index f0a8c1f..752a939 100644
22361 --- a/gdb/macroexp.c
22362 +++ b/gdb/macroexp.c
22364 #include "macrotab.h"
22365 #include "macroexp.h"
22366 #include "gdb_assert.h"
22367 +#include "c-lang.h"
22371 @@ -320,14 +321,17 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
22372 way GDB's C/C++ lexer does. So we call parse_escape in utils.c
22373 to handle escape sequences. */
22374 if ((p + 1 <= end && *p == '\'')
22375 - || (p + 2 <= end && p[0] == 'L' && p[1] == '\''))
22377 + && (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
22378 + && p[1] == '\''))
22380 char *tok_start = p;
22382 + int char_count = 0;
22386 - else if (*p == 'L')
22387 + else if (*p == 'L' || *p == 'u' || *p == 'U')
22391 @@ -339,7 +343,7 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
22392 error (_("Unmatched single quote."));
22393 else if (*p == '\'')
22395 - if (p == body_start)
22397 error (_("A character constant must contain at least one "
22400 @@ -348,10 +352,13 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
22401 else if (*p == '\\')
22404 - parse_escape (&p);
22405 + char_count += c_parse_escape (&p, NULL);
22415 set_token (tok, tok_start, p);
22416 @@ -370,16 +377,16 @@ static int
22417 get_string_literal (struct macro_buffer *tok, char *p, char *end)
22424 - && p[1] == '\"'))
22425 + && (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
22428 char *tok_start = p;
22433 - else if (*p == 'L')
22434 + else if (*p == 'L' || *p == 'u' || *p == 'U')
22438 @@ -388,7 +395,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
22441 error (_("Unterminated string in expression."));
22442 - else if (*p == '\"')
22443 + else if (*p == '"')
22447 @@ -399,7 +406,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
22448 else if (*p == '\\')
22451 - parse_escape (&p);
22452 + c_parse_escape (&p, NULL);
22456 diff --git a/gdb/main.c b/gdb/main.c
22457 index 5d4640b..6f9e61b 100644
22461 #include "interps.h"
22464 +#include "python/python.h"
22466 /* If nonzero, display time usage both at startup and for each command. */
22469 @@ -62,6 +64,9 @@ int dbx_commands = 0;
22470 /* System root path, used to find libraries etc. */
22471 char *gdb_sysroot = 0;
22473 +/* GDB datadir, used to store data files. */
22474 +char *gdb_datadir = 0;
22476 struct ui_file *gdb_stdout;
22477 struct ui_file *gdb_stderr;
22478 struct ui_file *gdb_stdlog;
22479 @@ -211,6 +216,8 @@ captured_main (void *data)
22480 char *cdarg = NULL;
22481 char *ttyarg = NULL;
22483 + int python_script = 0;
22485 /* These are static so that we can take their address in an initializer. */
22486 static int print_help;
22487 static int print_version;
22488 @@ -357,6 +364,40 @@ captured_main (void *data)
22492 +#ifdef GDB_DATADIR_RELOCATABLE
22493 + gdb_datadir = make_relative_prefix (argv[0], BINDIR, GDB_DATADIR);
22499 + if (stat (gdb_datadir, &s) == 0)
22500 + if (S_ISDIR (s.st_mode))
22505 + xfree (gdb_datadir);
22506 + gdb_datadir = xstrdup (GDB_DATADIR);
22510 + gdb_datadir = xstrdup (GDB_DATADIR);
22512 + gdb_datadir = xstrdup (GDB_DATADIR);
22513 +#endif /* GDB_DATADIR_RELOCATABLE */
22515 + /* Canonicalize the GDB's datadir path. */
22516 + if (*gdb_datadir)
22518 + char *canon_debug = lrealpath (gdb_datadir);
22521 + xfree (gdb_datadir);
22522 + gdb_datadir = canon_debug;
22526 get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
22528 /* There will always be an interpreter. Either the one passed into
22529 @@ -441,10 +482,14 @@ captured_main (void *data)
22530 {"args", no_argument, &set_args, 1},
22531 {"l", required_argument, 0, 'l'},
22532 {"return-child-result", no_argument, &return_child_result, 1},
22534 + {"python", no_argument, 0, 'P'},
22535 + {"P", no_argument, 0, 'P'},
22537 {0, no_argument, 0, 0}
22541 + while (!python_script)
22545 @@ -462,6 +507,9 @@ captured_main (void *data)
22547 /* Long option that just sets a flag. */
22550 + python_script = 1;
22555 @@ -638,7 +686,31 @@ extern int gdbtk_test (char *);
22560 + if (python_script)
22562 + /* The first argument is a python script to evaluate, and
22563 + subsequent arguments are passed to the script for
22564 + processing there. */
22565 + if (optind >= argc)
22567 + fprintf_unfiltered (gdb_stderr,
22568 + _("%s: Python script file name required\n"),
22573 + /* FIXME: should handle inferior I/O intelligently here.
22574 + E.g., should be possible to run gdb in pipeline and have
22575 + Python (and gdb) output go to stderr or file; and if a
22576 + prompt is needed, open the tty. */
22578 + /* FIXME: should read .gdbinit if, and only if, a prompt is
22579 + requested by the script. Though... maybe this is not
22581 + /* FIXME: likewise, reading in history. */
22582 + inhibit_gdbinit = 1;
22584 + else if (set_args)
22586 /* The remaining options are the command-line options for the
22587 inferior. The first one is the sym/exec file, and the rest
22588 @@ -866,7 +938,8 @@ Can't attach to process and specify a core file at the same time."));
22591 /* Read in the old history after all the command files have been read. */
22593 + if (!python_script)
22598 @@ -895,13 +968,25 @@ Can't attach to process and specify a core file at the same time."));
22602 - /* NOTE: cagney/1999-11-07: There is probably no reason for not
22603 - moving this loop and the code found in captured_command_loop()
22604 - into the command_loop() proper. The main thing holding back that
22605 - change - SET_TOP_LEVEL() - has been eliminated. */
22608 + if (python_script)
22610 - catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
22611 + extern int pagination_enabled;
22612 + pagination_enabled = 0;
22613 + run_python_script (argc - optind, &argv[optind]);
22619 + /* NOTE: cagney/1999-11-07: There is probably no reason for not
22620 + moving this loop and the code found in captured_command_loop()
22621 + into the command_loop() proper. The main thing holding back that
22622 + change - SET_TOP_LEVEL() - has been eliminated. */
22625 + catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
22628 /* No exit -- exit is through quit_command. */
22630 @@ -933,7 +1018,12 @@ print_gdb_help (struct ui_file *stream)
22631 fputs_unfiltered (_("\
22632 This is the GNU debugger. Usage:\n\n\
22633 gdb [options] [executable-file [core-file or process-id]]\n\
22634 - gdb [options] --args executable-file [inferior-arguments ...]\n\n\
22635 + gdb [options] --args executable-file [inferior-arguments ...]\n"), stream);
22637 + fputs_unfiltered (_("\
22638 + gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream);
22640 + fputs_unfiltered (_("\n\
22643 fputs_unfiltered (_("\
22644 @@ -971,7 +1061,13 @@ Options:\n\n\
22645 --nw Do not use a window interface.\n\
22646 --nx Do not read "), stream);
22647 fputs_unfiltered (gdbinit, stream);
22648 - fputs_unfiltered (_(" file.\n\
22649 + fputs_unfiltered (_(" file.\n"), stream);
22651 + fputs_unfiltered (_("\
22652 + --python, -P Following argument is Python script file; remaining\n\
22653 + arguments are passed to script.\n"), stream);
22655 + fputs_unfiltered (_("\
22656 --quiet Do not print version number on startup.\n\
22657 --readnow Fully read symbol files on first access.\n\
22659 diff --git a/gdb/maint.c b/gdb/maint.c
22660 index 56cafe9..1b57ff5 100644
22663 @@ -906,4 +906,12 @@ When enabled GDB is profiled."),
22664 show_maintenance_profile_p,
22665 &maintenance_set_cmdlist,
22666 &maintenance_show_cmdlist);
22667 + add_setshow_filename_cmd ("gdb_datadir", class_maintenance,
22668 + &gdb_datadir, _("Set GDB's datadir path."),
22669 + _("Show GDB's datadir path."),
22671 +When set, GDB uses the specified path to search for data files."),
22673 + &maintenance_set_cmdlist,
22674 + &maintenance_show_cmdlist);
22676 diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
22677 index 7cbcc59..e507c3b 100644
22678 --- a/gdb/mdebugread.c
22679 +++ b/gdb/mdebugread.c
22680 @@ -4696,7 +4696,7 @@ new_type (char *name)
22684 - t = alloc_type (current_objfile);
22685 + t = alloc_type (current_objfile, NULL);
22686 TYPE_NAME (t) = name;
22687 TYPE_CPLUS_SPECIFIC (t) = (struct cplus_struct_type *) &cplus_struct_default;
22689 diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
22690 index 143074b..0f4efba 100644
22691 --- a/gdb/mi/mi-cmd-var.c
22692 +++ b/gdb/mi/mi-cmd-var.c
22693 @@ -249,6 +249,41 @@ mi_cmd_var_set_format (char *command, char **argv, int argc)
22697 +mi_cmd_var_set_visualizer (char *command, char **argv, int argc)
22699 + struct varobj *var;
22702 + error ("Usage: NAME VISUALIZER_FUNCTION.");
22704 + var = varobj_get_handle (argv[0]);
22707 + error ("Variable object not found");
22709 + varobj_set_visualizer (var, argv[1]);
22713 +mi_cmd_var_set_child_range (char *command, char **argv, int argc)
22715 + struct varobj *var;
22719 + error (_("-var-set-child-range: NAME FROM TO"));
22721 + var = varobj_get_handle (argv[0]);
22723 + error (_("Variable object not found"));
22725 + from = atoi (argv[1]);
22726 + to = atoi (argv[2]);
22728 + varobj_set_child_range (var, from, to);
22732 mi_cmd_var_set_frozen (char *command, char **argv, int argc)
22734 struct varobj *var;
22735 @@ -369,6 +404,8 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
22737 enum print_values print_values;
22740 + char *display_hint;
22742 if (argc != 1 && argc != 2)
22743 error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
22744 @@ -388,14 +425,22 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
22746 print_values = PRINT_NO_VALUES;
22748 - if (VEC_length (varobj_p, children) == 0)
22749 + varobj_get_child_range (var, children, &from, &to);
22753 + display_hint = varobj_get_display_hint (var);
22754 + if (display_hint)
22756 + ui_out_field_string (uiout, "displayhint", display_hint);
22757 + xfree (display_hint);
22760 if (mi_version (uiout) == 1)
22761 cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
22763 cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
22764 - for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
22765 + for (ix = from; ix < to && VEC_iterate (varobj_p, children, ix, child); ++ix)
22767 struct cleanup *cleanup_child;
22768 cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
22769 @@ -662,6 +707,8 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
22771 for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i)
22773 + char *display_hint;
22775 if (mi_version (uiout) > 1)
22776 cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
22777 ui_out_field_string (uiout, "name", varobj_get_objname (r->varobj));
22778 @@ -695,6 +742,36 @@ varobj_update_one (struct varobj *var, enum print_values print_values,
22779 ui_out_field_int (uiout, "new_num_children",
22780 varobj_get_num_children (r->varobj));
22783 + display_hint = varobj_get_display_hint (var);
22784 + if (display_hint)
22786 + ui_out_field_string (uiout, "displayhint", display_hint);
22787 + xfree (display_hint);
22790 + if (r->children_changed)
22792 + int ix, from, to;
22793 + struct varobj *child;
22794 + struct cleanup *cleanup =
22795 + make_cleanup_ui_out_list_begin_end (uiout, "children");
22797 + VEC (varobj_p)* children = varobj_list_children (r->varobj);
22798 + varobj_get_child_range (r->varobj, children, &from, &to);
22801 + ix < to && VEC_iterate (varobj_p, children, ix, child);
22804 + struct cleanup *cleanup_child;
22805 + cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
22806 + print_varobj (child, print_values, 1 /* print expression */);
22807 + do_cleanups (cleanup_child);
22810 + do_cleanups (cleanup);
22813 if (mi_version (uiout) > 1)
22814 do_cleanups (cleanup);
22815 diff --git a/gdb/mi/mi-cmds.c b/gdb/mi/mi-cmds.c
22816 index 2610b6a..f31233b 100644
22817 --- a/gdb/mi/mi-cmds.c
22818 +++ b/gdb/mi/mi-cmds.c
22819 @@ -160,7 +160,9 @@ struct mi_cmd mi_cmds[] =
22820 { "var-info-num-children", { NULL, 0 }, mi_cmd_var_info_num_children},
22821 { "var-info-type", { NULL, 0 }, mi_cmd_var_info_type},
22822 { "var-list-children", { NULL, 0 }, mi_cmd_var_list_children},
22823 + { "var-set-child-range", { NULL, 0 }, mi_cmd_var_set_child_range },
22824 { "var-set-format", { NULL, 0 }, mi_cmd_var_set_format},
22825 + { "var-set-visualizer", { NULL, 0 }, mi_cmd_var_set_visualizer},
22826 { "var-set-frozen", { NULL, 0 }, mi_cmd_var_set_frozen},
22827 { "var-show-attributes", { NULL, 0 }, mi_cmd_var_show_attributes},
22828 { "var-show-format", { NULL, 0 }, mi_cmd_var_show_format},
22829 diff --git a/gdb/mi/mi-cmds.h b/gdb/mi/mi-cmds.h
22830 index 39f16fb..291a07f 100644
22831 --- a/gdb/mi/mi-cmds.h
22832 +++ b/gdb/mi/mi-cmds.h
22833 @@ -92,7 +92,9 @@ extern mi_cmd_argv_ftype mi_cmd_var_info_num_children;
22834 extern mi_cmd_argv_ftype mi_cmd_var_info_type;
22835 extern mi_cmd_argv_ftype mi_cmd_var_list_children;
22836 extern mi_cmd_argv_ftype mi_cmd_var_set_format;
22837 +extern mi_cmd_argv_ftype mi_cmd_var_set_child_range;
22838 extern mi_cmd_argv_ftype mi_cmd_var_set_frozen;
22839 +extern mi_cmd_argv_ftype mi_cmd_var_set_visualizer;
22840 extern mi_cmd_argv_ftype mi_cmd_var_show_attributes;
22841 extern mi_cmd_argv_ftype mi_cmd_var_show_format;
22842 extern mi_cmd_argv_ftype mi_cmd_var_update;
22843 diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
22844 index b905a9e..eaa5f12 100644
22845 --- a/gdb/mi/mi-main.c
22846 +++ b/gdb/mi/mi-main.c
22847 @@ -777,7 +777,7 @@ mi_cmd_data_evaluate_expression (char *command, char **argv, int argc)
22848 get_user_print_options (&opts);
22849 opts.deref_ref = 0;
22850 val_print (value_type (val), value_contents (val),
22851 - value_embedded_offset (val), VALUE_ADDRESS (val),
22852 + value_embedded_offset (val), value_address (val),
22853 stb->stream, 0, &opts, current_language);
22855 ui_out_field_stream (uiout, "value", stb);
22856 @@ -1101,6 +1101,10 @@ mi_cmd_list_features (char *command, char **argv, int argc)
22857 ui_out_field_string (uiout, NULL, "frozen-varobjs");
22858 ui_out_field_string (uiout, NULL, "pending-breakpoints");
22859 ui_out_field_string (uiout, NULL, "thread-info");
22862 + ui_out_field_string (uiout, NULL, "python");
22865 do_cleanups (cleanup);
22867 @@ -1317,6 +1321,7 @@ mi_cmd_execute (struct mi_parse *parse)
22868 struct cleanup *cleanup;
22870 free_all_values ();
22871 + free_all_types ();
22873 current_token = xstrdup (parse->token);
22874 cleanup = make_cleanup (free_current_contents, ¤t_token);
22875 diff --git a/gdb/minsyms.c b/gdb/minsyms.c
22876 index bf776b3..e4b0f31 100644
22877 --- a/gdb/minsyms.c
22878 +++ b/gdb/minsyms.c
22881 #include "cp-abi.h"
22882 #include "target.h"
22883 +#include "cp-support.h"
22884 +#include "language.h"
22886 /* Accumulate the minimal symbols for each objfile in bunches of BUNCH_SIZE.
22887 At the end, copy them all into one newly allocated location on an objfile's
22888 @@ -187,6 +189,9 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22889 unsigned int hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE;
22890 unsigned int dem_hash = msymbol_hash_iw (name) % MINIMAL_SYMBOL_HASH_SIZE;
22892 + int needtofreename = 0;
22893 + const char *modified_name;
22897 char *p = strrchr (sfile, '/');
22898 @@ -194,6 +199,18 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22902 + /* For C++, canonicalize the input name. */
22903 + modified_name = name;
22904 + if (current_language->la_language == language_cplus)
22906 + char *cname = cp_canonicalize_string (name);
22909 + modified_name = cname;
22910 + needtofreename = 1;
22914 for (objfile = object_files;
22915 objfile != NULL && found_symbol == NULL;
22916 objfile = objfile->next)
22917 @@ -218,9 +235,16 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22921 - match = strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0;
22923 + match = strcmp (SYMBOL_LINKAGE_NAME (msymbol),
22924 + modified_name) == 0;
22927 - match = SYMBOL_MATCHES_SEARCH_NAME (msymbol, name);
22929 + match = SYMBOL_MATCHES_SEARCH_NAME (msymbol,
22935 switch (MSYMBOL_TYPE (msymbol))
22936 @@ -259,6 +283,10 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22941 + if (needtofreename)
22942 + xfree ((void *) modified_name);
22944 /* External symbols are best. */
22946 return found_symbol;
22947 diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
22948 index 6c8c4c0..7d283a4 100644
22949 --- a/gdb/mips-tdep.c
22950 +++ b/gdb/mips-tdep.c
22951 @@ -2757,7 +2757,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
22953 && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
22955 - store_unsigned_integer (valbuf, regsize, VALUE_ADDRESS (arg));
22956 + store_unsigned_integer (valbuf, regsize, value_address (arg));
22957 typecode = TYPE_CODE_PTR;
22960 diff --git a/gdb/mipsread.c b/gdb/mipsread.c
22961 index a84003f..924c1c5 100644
22962 --- a/gdb/mipsread.c
22963 +++ b/gdb/mipsread.c
22964 @@ -394,6 +394,7 @@ static struct sym_fns ecoff_sym_fns =
22965 mipscoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
22966 mipscoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
22967 mipscoff_symfile_read, /* sym_read: read a symbol file into symtab */
22968 + NULL, /* sym_read_psymbols */
22969 mipscoff_symfile_finish, /* sym_finish: finished with file, cleanup */
22970 default_symfile_offsets, /* sym_offsets: dummy FIXME til implem sym reloc */
22971 default_symfile_segments, /* sym_segments: Get segment information from
22972 diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
22973 index f0cea27..02be43a 100644
22974 --- a/gdb/mn10300-tdep.c
22975 +++ b/gdb/mn10300-tdep.c
22976 @@ -1027,7 +1027,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
22977 /* Change to pointer-to-type. */
22978 arg_len = push_size;
22979 store_unsigned_integer (valbuf, push_size,
22980 - VALUE_ADDRESS (*args));
22981 + value_address (*args));
22985 diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
22986 index a6c74a3..9b8d801 100644
22987 --- a/gdb/objc-lang.c
22988 +++ b/gdb/objc-lang.c
22989 @@ -280,7 +280,7 @@ objc_demangle (const char *mangled, int options)
22990 for printing characters and strings is language specific. */
22993 -objc_emit_char (int c, struct ui_file *stream, int quoter)
22994 +objc_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
22997 c &= 0xFF; /* Avoid sign bit follies. */
22998 @@ -326,10 +326,10 @@ objc_emit_char (int c, struct ui_file *stream, int quoter)
23002 -objc_printchar (int c, struct ui_file *stream)
23003 +objc_printchar (int c, struct type *type, struct ui_file *stream)
23005 fputs_filtered ("'", stream);
23006 - objc_emit_char (c, stream, '\'');
23007 + objc_emit_char (c, type, stream, '\'');
23008 fputs_filtered ("'", stream);
23011 @@ -340,14 +340,16 @@ objc_printchar (int c, struct ui_file *stream)
23015 -objc_printstr (struct ui_file *stream, const gdb_byte *string,
23016 - unsigned int length, int width, int force_ellipses,
23017 +objc_printstr (struct ui_file *stream, struct type *type,
23018 + const gdb_byte *string, unsigned int length,
23019 + int force_ellipses,
23020 const struct value_print_options *options)
23023 unsigned int things_printed = 0;
23025 int need_comma = 0;
23026 + int width = TYPE_LENGTH (type);
23028 /* If the string was not truncated due to `set print elements', and
23029 the last byte of it is a null, we don't print that, in
23030 @@ -395,7 +397,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
23031 fputs_filtered ("\", ", stream);
23034 - objc_printchar (string[i], stream);
23035 + objc_printchar (string[i], type, stream);
23036 fprintf_filtered (stream, " <repeats %u times>", reps);
23038 things_printed += options->repeat_count_threshold;
23039 @@ -411,7 +413,7 @@ objc_printstr (struct ui_file *stream, const gdb_byte *string,
23040 fputs_filtered ("\"", stream);
23043 - objc_emit_char (string[i], stream, '"');
23044 + objc_emit_char (string[i], type, stream, '"');
23048 diff --git a/gdb/objfiles.c b/gdb/objfiles.c
23049 index bc77de8..079ebcf 100644
23050 --- a/gdb/objfiles.c
23051 +++ b/gdb/objfiles.c
23052 @@ -691,6 +691,20 @@ have_partial_symbols (void)
23057 + /* Try again, after reading partial symbols. We do this in two
23058 + passes because objfiles are always added to the head of the list,
23059 + and there might be a later objfile for which we've already read
23060 + partial symbols. */
23061 + ALL_OBJFILES (ofp)
23063 + require_partial_symbols (ofp);
23064 + if (ofp->psymtabs != NULL)
23073 diff --git a/gdb/objfiles.h b/gdb/objfiles.h
23074 index 60d3143..b6fdd92 100644
23075 --- a/gdb/objfiles.h
23076 +++ b/gdb/objfiles.h
23077 @@ -212,6 +212,11 @@ struct objfile
23079 struct partial_symtab *psymtabs;
23081 + /* An address map that can be used to quickly determine if an
23082 + address comes from this objfile. This can be NULL. */
23084 + struct addrmap *quick_addrmap;
23086 /* Map addresses to the entries of PSYMTABS. It would be more efficient to
23087 have a map per the whole process but ADDRMAP cannot selectively remove
23088 its items during FREE_OBJFILE. This mapping is already present even for
23089 @@ -420,6 +425,15 @@ struct objfile
23090 #define OBJF_KEEPBFD (1 << 4) /* Do not delete bfd */
23093 +/* Set if we have tried to read partial symtabs for this objfile.
23094 + This is used to allow lazy reading of partial symtabs. */
23096 +#define OBJF_SYMTABS_READ (1 << 6)
23098 +/* This flag is set for the main objfile. */
23100 +#define OBJF_MAIN (1 << 7)
23102 /* The object file that the main symbol table was loaded from (e.g. the
23103 argument to the "symbol-file" or "file" command). */
23105 @@ -556,6 +570,13 @@ extern void *objfile_data (struct objfile *objfile,
23106 ALL_OBJFILES (objfile) \
23107 ALL_OBJFILE_PSYMTABS (objfile, p)
23109 +/* Like ALL_PSYMTABS, but ensure that partial symbols have been read
23110 + before examining the objfile. */
23112 +#define ALL_PSYMTABS_REQUIRED(objfile, p) \
23113 + ALL_OBJFILES (objfile) \
23114 + ALL_OBJFILE_PSYMTABS (require_partial_symbols (objfile), p)
23116 /* Traverse all minimal symbols in all objfiles. */
23118 #define ALL_MSYMBOLS(objfile, m) \
23119 diff --git a/gdb/p-lang.c b/gdb/p-lang.c
23120 index 41da3e0..e743a6f 100644
23123 @@ -97,7 +97,8 @@ pascal_main_name (void)
23124 but this does not happen for Free Pascal nor for GPC. */
23126 is_pascal_string_type (struct type *type,int *length_pos,
23127 - int *length_size, int *string_pos, int *char_size,
23128 + int *length_size, int *string_pos,
23129 + struct type **char_type,
23132 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
23133 @@ -114,8 +115,8 @@ is_pascal_string_type (struct type *type,int *length_pos,
23134 *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
23136 *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
23140 + *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
23142 *arrayname = TYPE_FIELDS (type)[1].name;
23144 @@ -126,7 +127,6 @@ is_pascal_string_type (struct type *type,int *length_pos,
23145 && strcmp (TYPE_FIELDS (type)[0].name, "Capacity") == 0
23146 && strcmp (TYPE_FIELDS (type)[1].name, "length") == 0)
23148 - struct type *char_type;
23150 *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
23152 @@ -134,13 +134,12 @@ is_pascal_string_type (struct type *type,int *length_pos,
23154 *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
23155 /* FIXME: how can I detect wide chars in GPC ?? */
23156 - char_type = TYPE_FIELD_TYPE (type,2);
23157 - if (char_size && TYPE_CODE (char_type) == TYPE_CODE_ARRAY)
23160 - *char_size = TYPE_LENGTH (TYPE_TARGET_TYPE (char_type));
23161 + *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
23162 + if (TYPE_CODE (*char_type) == TYPE_CODE_ARRAY)
23163 + *char_type = TYPE_TARGET_TYPE (*char_type);
23165 - else if (char_size)
23168 *arrayname = TYPE_FIELDS (type)[2].name;
23170 @@ -182,14 +181,15 @@ pascal_one_char (int c, struct ui_file *stream, int *in_quotes)
23174 -static void pascal_emit_char (int c, struct ui_file *stream, int quoter);
23175 +static void pascal_emit_char (int c, struct type *type,
23176 + struct ui_file *stream, int quoter);
23178 /* Print the character C on STREAM as part of the contents of a literal
23179 string whose delimiter is QUOTER. Note that that format for printing
23180 characters and strings is language specific. */
23183 -pascal_emit_char (int c, struct ui_file *stream, int quoter)
23184 +pascal_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
23187 pascal_one_char (c, stream, &in_quotes);
23188 @@ -198,7 +198,7 @@ pascal_emit_char (int c, struct ui_file *stream, int quoter)
23192 -pascal_printchar (int c, struct ui_file *stream)
23193 +pascal_printchar (int c, struct type *type, struct ui_file *stream)
23196 pascal_one_char (c, stream, &in_quotes);
23197 @@ -212,14 +212,16 @@ pascal_printchar (int c, struct ui_file *stream)
23198 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
23201 -pascal_printstr (struct ui_file *stream, const gdb_byte *string,
23202 - unsigned int length, int width, int force_ellipses,
23203 +pascal_printstr (struct ui_file *stream, struct type *type,
23204 + const gdb_byte *string, unsigned int length,
23205 + int force_ellipses,
23206 const struct value_print_options *options)
23209 unsigned int things_printed = 0;
23211 int need_comma = 0;
23212 + int width = TYPE_LENGTH (type);
23214 /* If the string was not truncated due to `set print elements', and
23215 the last byte of it is a null, we don't print that, in traditional C
23216 @@ -273,7 +275,7 @@ pascal_printstr (struct ui_file *stream, const gdb_byte *string,
23217 fputs_filtered ("', ", stream);
23220 - pascal_printchar (current_char, stream);
23221 + pascal_printchar (current_char, type, stream);
23222 fprintf_filtered (stream, " <repeats %u times>", reps);
23224 things_printed += options->repeat_count_threshold;
23225 diff --git a/gdb/p-lang.h b/gdb/p-lang.h
23226 index 09a4569..2b2eb2d 100644
23229 @@ -48,12 +48,13 @@ extern void pascal_type_print_method_args (char *, char *,
23230 /* These are in p-lang.c: */
23233 - is_pascal_string_type (struct type *, int *, int *, int *, int *, char **);
23234 + is_pascal_string_type (struct type *, int *, int *, int *,
23235 + struct type **, char **);
23237 -extern void pascal_printchar (int, struct ui_file *);
23238 +extern void pascal_printchar (int, struct type *, struct ui_file *);
23240 -extern void pascal_printstr (struct ui_file *, const gdb_byte *,
23241 - unsigned int, int, int,
23242 +extern void pascal_printstr (struct ui_file *, struct type *, const gdb_byte *,
23243 + unsigned int, int,
23244 const struct value_print_options *);
23246 extern struct type **const (pascal_builtin_types[]);
23247 diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
23248 index 27ae619..29f0e6d 100644
23249 --- a/gdb/p-valprint.c
23250 +++ b/gdb/p-valprint.c
23251 @@ -61,7 +61,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23252 struct type *elttype;
23254 int length_pos, length_size, string_pos;
23256 + struct type *char_type;
23260 @@ -100,8 +100,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23264 - LA_PRINT_STRING (stream, valaddr + embedded_offset, len,
23265 - eltlen, 0, options);
23266 + LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
23267 + valaddr + embedded_offset, len, 0,
23272 @@ -175,8 +176,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23275 /* no wide string yet */
23276 - i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
23278 + i = val_print_string (elttype, addr, -1, stream, options);
23280 /* also for pointers to pascal strings */
23281 /* Note: this is Free Pascal specific:
23282 @@ -184,7 +184,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23283 Pascal strings are mapped to records
23284 with lowercase names PM */
23285 if (is_pascal_string_type (elttype, &length_pos, &length_size,
23286 - &string_pos, &char_size, NULL)
23287 + &string_pos, &char_type, NULL)
23290 ULONGEST string_length;
23291 @@ -193,7 +193,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23292 read_memory (addr + length_pos, buffer, length_size);
23293 string_length = extract_unsigned_integer (buffer, length_size);
23295 - i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
23296 + i = val_print_string (char_type ,addr + string_pos, string_length, stream, options);
23298 else if (pascal_object_is_vtbl_member (type))
23300 @@ -298,10 +298,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23303 if (is_pascal_string_type (type, &length_pos, &length_size,
23304 - &string_pos, &char_size, NULL))
23305 + &string_pos, &char_type, NULL))
23307 len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
23308 - LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
23309 + LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, 0, options);
23312 pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
23313 @@ -426,7 +426,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23315 fprintf_filtered (stream, "%d", (int) val);
23316 fputs_filtered (" ", stream);
23317 - LA_PRINT_CHAR ((unsigned char) val, stream);
23318 + LA_PRINT_CHAR ((unsigned char) val, type, stream);
23322 @@ -931,7 +931,7 @@ pascal_object_print_static_field (struct value *val,
23324 if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
23326 - CORE_ADDR *first_dont_print;
23327 + CORE_ADDR *first_dont_print, addr;
23331 @@ -941,7 +941,7 @@ pascal_object_print_static_field (struct value *val,
23335 - if (VALUE_ADDRESS (val) == first_dont_print[i])
23336 + if (value_address (val) == first_dont_print[i])
23338 fputs_filtered ("<same as static member of an already seen type>",
23340 @@ -949,11 +949,12 @@ pascal_object_print_static_field (struct value *val,
23344 - obstack_grow (&dont_print_statmem_obstack, (char *) &VALUE_ADDRESS (val),
23345 + addr = value_address (val);
23346 + obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
23347 sizeof (CORE_ADDR));
23349 CHECK_TYPEDEF (type);
23350 - pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
23351 + pascal_object_print_value_fields (type, value_contents (val), value_address (val),
23352 stream, recurse, options, NULL, 1);
23355 diff --git a/gdb/parse.c b/gdb/parse.c
23356 index eee1f8e..66aaf6a 100644
23359 @@ -306,7 +306,7 @@ write_exp_elt_intern (struct internalvar *expelt)
23360 strings with embedded null bytes, as is required for some languages.
23362 Don't be fooled by the fact that the string is null byte terminated,
23363 - this is strictly for the convenience of debugging gdb itself. Gdb
23364 + this is strictly for the convenience of debugging gdb itself.
23365 Gdb does not depend up the string being null terminated, since the
23366 actual length is recorded in expression elements at each end of the
23367 string. The null byte is taken into consideration when computing how
23368 @@ -352,6 +352,65 @@ write_exp_string (struct stoken str)
23369 write_exp_elt_longcst ((LONGEST) len);
23372 +/* Add a vector of string constants to the end of the expression.
23374 + This adds an OP_STRING operation, but encodes the contents
23375 + differently from write_exp_string. The language is expected to
23376 + handle evaluation of this expression itself.
23378 + After the usual OP_STRING header, TYPE is written into the
23379 + expression as a long constant. The interpretation of this field is
23380 + up to the language evaluator.
23382 + Next, each string in VEC is written. The length is written as a
23383 + long constant, followed by the contents of the string. */
23386 +write_exp_string_vector (int type, struct stoken_vector *vec)
23388 + int i, n_slots, len;
23390 + /* Compute the size. We compute the size in number of slots to
23391 + avoid issues with string padding. */
23393 + for (i = 0; i < vec->len; ++i)
23395 + /* One slot for the length of this element, plus the number of
23396 + slots needed for this string. */
23397 + n_slots += 1 + BYTES_TO_EXP_ELEM (vec->tokens[i].length);
23400 + /* One more slot for the type of the string. */
23403 + /* Now compute a phony string length. */
23404 + len = EXP_ELEM_TO_BYTES (n_slots) - 1;
23407 + if ((expout_ptr + n_slots) >= expout_size)
23409 + expout_size = max (expout_size * 2, expout_ptr + n_slots + 10);
23410 + expout = (struct expression *)
23411 + xrealloc ((char *) expout, (sizeof (struct expression)
23412 + + EXP_ELEM_TO_BYTES (expout_size)));
23415 + write_exp_elt_opcode (OP_STRING);
23416 + write_exp_elt_longcst (len);
23417 + write_exp_elt_longcst (type);
23419 + for (i = 0; i < vec->len; ++i)
23421 + write_exp_elt_longcst (vec->tokens[i].length);
23422 + memcpy (&expout->elts[expout_ptr], vec->tokens[i].ptr,
23423 + vec->tokens[i].length);
23424 + expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
23427 + write_exp_elt_longcst (len);
23428 + write_exp_elt_opcode (OP_STRING);
23431 /* Add a bitstring constant to the end of the expression.
23433 Bitstring constants are stored by first writing an expression element
23434 @@ -777,6 +836,15 @@ operator_length_standard (struct expression *expr, int endpos,
23435 args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
23438 + case TYPE_INSTANCE:
23439 + oplen = 4 + longest_to_int (expr->elts[endpos - 2].longconst);
23443 + case TYPE_INSTANCE_LOOKUP:
23447 case OP_OBJC_MSGCALL: /* Objective C message (method) call */
23449 args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
23450 diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
23451 index 2c4b755..cbda9c3 100644
23452 --- a/gdb/parser-defs.h
23453 +++ b/gdb/parser-defs.h
23454 @@ -69,6 +69,22 @@ struct stoken
23458 +struct typed_stoken
23460 + /* A language-specific type field. */
23462 + /* Pointer to first byte of char-string or first bit of bit-string */
23464 + /* Length of string in bytes for char-string or bits for bit-string */
23468 +struct stoken_vector
23471 + struct typed_stoken *tokens;
23476 struct stoken stoken;
23477 @@ -130,6 +146,8 @@ extern void write_exp_elt_intern (struct internalvar *);
23479 extern void write_exp_string (struct stoken);
23481 +void write_exp_string_vector (int type, struct stoken_vector *vec);
23483 extern void write_exp_bitstring (struct stoken);
23485 extern void write_exp_elt_block (struct block *);
23486 diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
23487 index d08d4fc..c2bbdf9 100644
23488 --- a/gdb/ppc-linux-tdep.c
23489 +++ b/gdb/ppc-linux-tdep.c
23491 #include "trad-frame.h"
23492 #include "frame-unwind.h"
23493 #include "tramp-frame.h"
23494 +#include "linux-tdep.h"
23496 #include "features/rs6000/powerpc-32l.c"
23497 #include "features/rs6000/powerpc-altivec32l.c"
23499 #include "features/rs6000/powerpc-isa205-vsx64l.c"
23500 #include "features/rs6000/powerpc-e500l.c"
23502 +/* The syscall's XML filename for PPC and PPC64. */
23503 +#define XML_SYSCALL_FILENAME_PPC "syscalls/ppc-linux.xml"
23504 +#define XML_SYSCALL_FILENAME_PPC64 "syscalls/ppc64-linux.xml"
23506 /* ppc_linux_memory_remove_breakpoints attempts to remove a breakpoint
23507 in much the same fashion as memory_remove_breakpoint in mem-break.c,
23508 @@ -1009,6 +1013,38 @@ ppc_linux_trap_reg_p (struct gdbarch *gdbarch)
23509 && register_size (gdbarch, PPC_TRAP_REGNUM) > 0;
23512 +/* Return the current system call's number present in the
23513 + r0 register. When the function fails, it returns -1. */
23515 +ppc_linux_get_syscall_number (struct gdbarch *gdbarch,
23518 + struct regcache *regcache = get_thread_regcache (ptid);
23519 + struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
23520 + struct cleanup *cleanbuf;
23521 + /* The content of a register */
23526 + /* Make sure we're in a 32- or 64-bit machine */
23527 + gdb_assert (tdep->wordsize == 4 || tdep->wordsize == 8);
23529 + buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte));
23531 + cleanbuf = make_cleanup (xfree, buf);
23533 + /* Getting the system call number from the register.
23534 + When dealing with PowerPC architecture, this information
23535 + is stored at 0th register. */
23536 + regcache_cooked_read (regcache, tdep->ppc_gp0_regnum, buf);
23538 + ret = extract_signed_integer (buf, tdep->wordsize);
23539 + do_cleanups (cleanbuf);
23545 ppc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
23547 @@ -1069,6 +1105,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
23548 struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
23549 struct tdesc_arch_data *tdesc_data = (void *) info.tdep_info;
23551 + /* Initializing common methods. */
23552 + linux_tdep_init (gdbarch);
23554 /* PPC GNU/Linux uses either 64-bit or 128-bit long doubles; where
23555 128-bit, they are IBM long double, not IEEE quad long double as
23556 in the System V ABI PowerPC Processor Supplement. We can safely
23557 @@ -1080,6 +1119,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
23558 /* Handle inferior calls during interrupted system calls. */
23559 set_gdbarch_write_pc (gdbarch, ppc_linux_write_pc);
23561 + /* Get the syscall number from the arch's register. */
23562 + set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number);
23564 if (tdep->wordsize == 4)
23566 /* Until November 2001, gcc did not comply with the 32 bit SysV
23567 @@ -1099,6 +1141,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
23568 set_solib_svr4_fetch_link_map_offsets
23569 (gdbarch, svr4_ilp32_fetch_link_map_offsets);
23571 + /* Setting the correct XML syscall filename. */
23572 + set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_PPC);
23575 tramp_frame_prepend_unwinder (gdbarch, &ppc32_linux_sigaction_tramp_frame);
23576 tramp_frame_prepend_unwinder (gdbarch, &ppc32_linux_sighandler_tramp_frame);
23577 @@ -1116,6 +1161,9 @@ ppc_linux_init_abi (struct gdbarch_info info,
23578 set_solib_svr4_fetch_link_map_offsets
23579 (gdbarch, svr4_lp64_fetch_link_map_offsets);
23581 + /* Setting the correct XML syscall filename. */
23582 + set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_PPC64);
23585 tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sigaction_tramp_frame);
23586 tramp_frame_prepend_unwinder (gdbarch, &ppc64_linux_sighandler_tramp_frame);
23587 diff --git a/gdb/printcmd.c b/gdb/printcmd.c
23588 index 375f82e..8c3f476 100644
23589 --- a/gdb/printcmd.c
23590 +++ b/gdb/printcmd.c
23592 #include "disasm.h"
23594 #include "valprint.h"
23595 +#include "charset.h"
23598 #include "tui/tui.h" /* For tui_active et.al. */
23599 @@ -62,11 +63,15 @@ struct format_data
23604 + /* True if the value should be printed raw -- that is, bypassing
23605 + python-based formatters. */
23606 + unsigned char raw;
23609 /* Last specified output format. */
23611 -static char last_format = 'x';
23612 +static char last_format = 0;
23614 /* Last specified examination size. 'b', 'h', 'w' or `q'. */
23616 @@ -175,6 +180,7 @@ decode_format (char **string_ptr, int oformat, int osize)
23622 if (*p >= '0' && *p <= '9')
23623 val.count = atoi (p);
23624 @@ -187,6 +193,11 @@ decode_format (char **string_ptr, int oformat, int osize)
23626 if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
23628 + else if (*p == 'r')
23633 else if (*p >= 'a' && *p <= 'z')
23636 @@ -264,24 +275,27 @@ print_formatted (struct value *val, int size,
23637 int len = TYPE_LENGTH (type);
23639 if (VALUE_LVAL (val) == lval_memory)
23640 - next_address = VALUE_ADDRESS (val) + len;
23641 + next_address = value_address (val) + len;
23645 switch (options->format)
23648 - /* FIXME: Need to handle wchar_t's here... */
23649 - next_address = VALUE_ADDRESS (val)
23650 - + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
23653 + struct type *elttype = value_type (val);
23654 + next_address = (value_address (val)
23655 + + val_print_string (elttype,
23656 + value_address (val), -1,
23657 + stream, options));
23662 /* We often wrap here if there are long symbolic names. */
23664 - next_address = (VALUE_ADDRESS (val)
23665 - + gdb_print_insn (VALUE_ADDRESS (val), stream,
23666 + next_address = (value_address (val)
23667 + + gdb_print_insn (value_address (val), stream,
23668 &branch_delay_insns));
23671 @@ -369,7 +383,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
23672 print_hex_chars (stream, valaddr, len, byte_order);
23675 - print_char_chars (stream, valaddr, len, byte_order);
23676 + print_char_chars (stream, type, valaddr, len, byte_order);
23680 @@ -865,6 +879,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
23688 @@ -878,6 +893,11 @@ print_command_1 (char *exp, int inspect, int voidprint)
23690 val = access_value_history (0);
23692 + /* Do not try to OBJECT_ADDRESS_SET here anything. We are interested in the
23693 + source variable base addresses as found by READ_VAR_VALUE. The value here
23694 + can be already a calculated expression address inappropriate for
23695 + DW_OP_push_object_address. */
23697 if (voidprint || (val && value_type (val) &&
23698 TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
23700 @@ -900,6 +920,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
23702 get_formatted_print_options (&opts, format);
23703 opts.inspect_it = inspect;
23704 + opts.raw = fmt.raw;
23706 print_formatted (val, fmt.size, &opts, gdb_stdout);
23707 printf_filtered ("\n");
23708 @@ -950,6 +971,7 @@ output_command (char *exp, int from_tty)
23709 struct value_print_options opts;
23714 if (exp && *exp == '/')
23716 @@ -967,6 +989,7 @@ output_command (char *exp, int from_tty)
23717 annotate_value_begin (value_type (val));
23719 get_formatted_print_options (&opts, format);
23720 + opts.raw = fmt.raw;
23721 print_formatted (val, fmt.size, &opts, gdb_stdout);
23723 annotate_value_end ();
23724 @@ -1287,9 +1310,10 @@ x_command (char *exp, int from_tty)
23725 struct cleanup *old_chain;
23728 - fmt.format = last_format;
23729 + fmt.format = last_format ? last_format : 'x';
23730 fmt.size = last_size;
23734 if (exp && *exp == '/')
23736 @@ -1316,7 +1340,7 @@ x_command (char *exp, int from_tty)
23737 if (/* last_format == 'i' && */
23738 TYPE_CODE (value_type (val)) == TYPE_CODE_FUNC
23739 && VALUE_LVAL (val) == lval_memory)
23740 - next_address = VALUE_ADDRESS (val);
23741 + next_address = value_address (val);
23743 next_address = value_as_address (val);
23744 do_cleanups (old_chain);
23745 @@ -1393,6 +1417,7 @@ display_command (char *exp, int from_tty)
23752 innermost_block = 0;
23753 @@ -1585,6 +1610,7 @@ do_one_display (struct display *d)
23754 annotate_display_expression ();
23756 get_formatted_print_options (&opts, d->format.format);
23757 + opts.raw = d->format.raw;
23758 print_formatted (evaluate_expression (d->exp),
23759 d->format.size, &opts, gdb_stdout);
23760 printf_filtered ("\n");
23761 @@ -1865,7 +1891,8 @@ printf_command (char *arg, int from_tty)
23765 - int_arg, long_arg, long_long_arg, ptr_arg, string_arg,
23766 + int_arg, long_arg, long_long_arg, ptr_arg,
23767 + string_arg, wide_string_arg, wide_char_arg,
23768 double_arg, long_double_arg, decfloat_arg
23770 enum argclass *argclass;
23771 @@ -1997,8 +2024,8 @@ printf_command (char *arg, int from_tty)
23775 - this_argclass = int_arg;
23776 - if (lcount || seen_h || seen_big_l)
23777 + this_argclass = lcount == 0 ? int_arg : wide_char_arg;
23778 + if (lcount > 1 || seen_h || seen_big_l)
23780 if (seen_prec || seen_zero || seen_space || seen_plus)
23782 @@ -2013,8 +2040,8 @@ printf_command (char *arg, int from_tty)
23786 - this_argclass = string_arg;
23787 - if (lcount || seen_h || seen_big_l)
23788 + this_argclass = lcount == 0 ? string_arg : wide_string_arg;
23789 + if (lcount > 1 || seen_h || seen_big_l)
23791 if (seen_zero || seen_space || seen_plus)
23793 @@ -2066,6 +2093,15 @@ printf_command (char *arg, int from_tty)
23794 last_arg[length_before_ll + lcount];
23795 current_substring += length_before_ll + 4;
23797 + else if (this_argclass == wide_string_arg
23798 + || this_argclass == wide_char_arg)
23800 + /* Convert %ls or %lc to %s. */
23801 + int length_before_ls = f - last_arg - 2;
23802 + strncpy (current_substring, last_arg, length_before_ls);
23803 + strcpy (current_substring + length_before_ls, "s");
23804 + current_substring += length_before_ls + 2;
23808 strncpy (current_substring, last_arg, f - last_arg);
23809 @@ -2130,6 +2166,76 @@ printf_command (char *arg, int from_tty)
23810 printf_filtered (current_substring, (char *) str);
23813 + case wide_string_arg:
23818 + struct type *wctype = lookup_typename ("wchar_t", NULL, 0);
23819 + int wcwidth = TYPE_LENGTH (wctype);
23820 + gdb_byte *buf = alloca (wcwidth);
23821 + struct obstack output;
23822 + struct cleanup *inner_cleanup;
23824 + tem = value_as_address (val_args[i]);
23826 + /* This is a %s argument. Find the length of the string. */
23827 + for (j = 0;; j += wcwidth)
23830 + read_memory (tem + j, buf, wcwidth);
23831 + if (extract_unsigned_integer (buf, wcwidth) == 0)
23835 + /* Copy the string contents into a string inside GDB. */
23836 + str = (gdb_byte *) alloca (j + wcwidth);
23838 + read_memory (tem, str, j);
23839 + memset (&str[j], 0, wcwidth);
23841 + obstack_init (&output);
23842 + inner_cleanup = make_cleanup_obstack_free (&output);
23844 + convert_between_encodings (target_wide_charset (),
23847 + &output, translit_char);
23848 + obstack_grow_str0 (&output, "");
23850 + printf_filtered (current_substring, obstack_base (&output));
23851 + do_cleanups (inner_cleanup);
23854 + case wide_char_arg:
23856 + struct type *wctype = lookup_typename ("wchar_t", NULL, 0);
23857 + struct type *valtype;
23858 + struct obstack output;
23859 + struct cleanup *inner_cleanup;
23860 + const gdb_byte *bytes;
23862 + valtype = value_type (val_args[i]);
23863 + if (TYPE_LENGTH (valtype) != TYPE_LENGTH (wctype)
23864 + || TYPE_CODE (valtype) != TYPE_CODE_INT)
23865 + error (_("expected wchar_t argument for %%lc"));
23867 + bytes = value_contents (val_args[i]);
23869 + obstack_init (&output);
23870 + inner_cleanup = make_cleanup_obstack_free (&output);
23872 + convert_between_encodings (target_wide_charset (),
23874 + bytes, TYPE_LENGTH (valtype),
23875 + TYPE_LENGTH (valtype),
23876 + &output, translit_char);
23877 + obstack_grow_str0 (&output, "");
23879 + printf_filtered (current_substring, obstack_base (&output));
23880 + do_cleanups (inner_cleanup);
23885 struct type *type = value_type (val_args[i]);
23886 diff --git a/gdb/python/lib/gdb/FrameIterator.py b/gdb/python/lib/gdb/FrameIterator.py
23887 new file mode 100644
23888 index 0000000..87fb074
23890 +++ b/gdb/python/lib/gdb/FrameIterator.py
23892 +# Iterator over frames.
23894 +# Copyright (C) 2008 Free Software Foundation, Inc.
23896 +# This program is free software; you can redistribute it and/or modify
23897 +# it under the terms of the GNU General Public License as published by
23898 +# the Free Software Foundation; either version 3 of the License, or
23899 +# (at your option) any later version.
23901 +# This program is distributed in the hope that it will be useful,
23902 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
23903 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23904 +# GNU General Public License for more details.
23906 +# You should have received a copy of the GNU General Public License
23907 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
23909 +class FrameIterator:
23910 + """An iterator that iterates over frames."""
23912 + def __init__ (self, frame):
23913 + "Initialize a FrameIterator. FRAME is the starting frame."
23914 + self.frame = frame
23916 + def __iter__ (self):
23920 + result = self.frame
23921 + if result == None:
23922 + raise StopIteration
23923 + self.frame = result.older ()
23925 diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py
23926 new file mode 100644
23927 index 0000000..b375c68
23929 +++ b/gdb/python/lib/gdb/__init__.py
23933 +# Copyright (C) 2008 Free Software Foundation, Inc.
23935 +# This program is free software; you can redistribute it and/or modify
23936 +# it under the terms of the GNU General Public License as published by
23937 +# the Free Software Foundation; either version 3 of the License, or
23938 +# (at your option) any later version.
23940 +# This program is distributed in the hope that it will be useful,
23941 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
23942 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23943 +# GNU General Public License for more details.
23945 +# You should have received a copy of the GNU General Public License
23946 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
23948 +# Load the require command by default.
23949 +import gdb.command.require
23950 diff --git a/gdb/python/lib/gdb/backtrace.py b/gdb/python/lib/gdb/backtrace.py
23951 new file mode 100644
23952 index 0000000..2baab5f
23954 +++ b/gdb/python/lib/gdb/backtrace.py
23956 +# Filtering backtrace.
23958 +# Copyright (C) 2008 Free Software Foundation, Inc.
23960 +# This program is free software; you can redistribute it and/or modify
23961 +# it under the terms of the GNU General Public License as published by
23962 +# the Free Software Foundation; either version 3 of the License, or
23963 +# (at your option) any later version.
23965 +# This program is distributed in the hope that it will be useful,
23966 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
23967 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23968 +# GNU General Public License for more details.
23970 +# You should have received a copy of the GNU General Public License
23971 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
23976 +# Our only exports.
23977 +__all__ = ['push_frame_filter', 'create_frame_filter']
23979 +frame_filter = None
23981 +def push_frame_filter (constructor):
23982 + """Register a new backtrace filter class with the 'backtrace' command.
23983 +The filter will be passed an iterator as an argument. The iterator
23984 +will return gdb.Frame-like objects. The filter should in turn act as
23985 +an iterator returning such objects."""
23986 + global frame_filter
23987 + if frame_filter == None:
23988 + frame_filter = constructor
23990 + frame_filter = lambda iterator: constructor (frame_filter (iterator))
23992 +def create_frame_filter (iter):
23993 + global frame_filter
23994 + if frame_filter is None:
23996 + return frame_filter (iter)
23998 diff --git a/gdb/python/lib/gdb/command/__init__.py b/gdb/python/lib/gdb/command/__init__.py
23999 new file mode 100644
24000 index 0000000..8b13789
24002 +++ b/gdb/python/lib/gdb/command/__init__.py
24005 diff --git a/gdb/python/lib/gdb/command/alias.py b/gdb/python/lib/gdb/command/alias.py
24006 new file mode 100644
24007 index 0000000..96b6618
24009 +++ b/gdb/python/lib/gdb/command/alias.py
24013 +# Copyright (C) 2008 Free Software Foundation, Inc.
24015 +# This program is free software; you can redistribute it and/or modify
24016 +# it under the terms of the GNU General Public License as published by
24017 +# the Free Software Foundation; either version 3 of the License, or
24018 +# (at your option) any later version.
24020 +# This program is distributed in the hope that it will be useful,
24021 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24022 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24023 +# GNU General Public License for more details.
24025 +# You should have received a copy of the GNU General Public License
24026 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24030 +class AliasImplementation (gdb.Command):
24031 + def __init__ (self, name, real, doc):
24032 + # Have to set __doc__ before the super init call.
24033 + # It would be nice if gdb's help looked up __doc__ dynamically.
24034 + self.__doc__ = doc
24035 + # Note: no good way to complete :(
24036 + super (AliasImplementation, self).__init__ (name, gdb.COMMAND_NONE)
24039 + def invoke(self, arg, from_tty):
24040 + gdb.execute (self.real + ' ' + arg, from_tty)
24042 +class AliasCommand (gdb.Command):
24043 + """Alias one command to another.
24044 +In the simplest form, the first word is the name of the alias, and
24045 +the remaining words are the the expansion.
24046 +An '=' by itself can be used to define a multi-word alias; words
24047 +before the '=' are the name of the new command."""
24049 + def __init__ (self):
24050 + # Completion is not quite right here.
24051 + super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
24052 + gdb.COMPLETE_COMMAND)
24054 + def invoke (self, arg, from_tty):
24055 + self.dont_repeat ()
24056 + # Without some form of quoting we can't alias a multi-word
24057 + # command to another command.
24058 + args = arg.split()
24060 + start = args.index ('=')
24062 + except ValueError:
24065 + target = " ".join(args[end:])
24066 + AliasImplementation (" ".join (args[0:start]), target,
24067 + "This command is an alias for '%s'." % target)
24070 diff --git a/gdb/python/lib/gdb/command/backtrace.py b/gdb/python/lib/gdb/command/backtrace.py
24071 new file mode 100644
24072 index 0000000..f07696e
24074 +++ b/gdb/python/lib/gdb/command/backtrace.py
24076 +# New backtrace command.
24078 +# Copyright (C) 2008 Free Software Foundation, Inc.
24080 +# This program is free software; you can redistribute it and/or modify
24081 +# it under the terms of the GNU General Public License as published by
24082 +# the Free Software Foundation; either version 3 of the License, or
24083 +# (at your option) any later version.
24085 +# This program is distributed in the hope that it will be useful,
24086 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24087 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24088 +# GNU General Public License for more details.
24090 +# You should have received a copy of the GNU General Public License
24091 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24094 +import gdb.backtrace
24096 +from gdb.FrameIterator import FrameIterator
24099 +class FrameWrapper:
24100 + def __init__ (self, frame):
24101 + self.frame = frame;
24103 + def write_symbol (self, stream, sym, block):
24104 + if len (sym.linkage_name):
24105 + nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block)
24106 + if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER:
24109 + stream.write (sym.print_name + "=")
24111 + val = self.frame.read_var (sym)
24114 + # FIXME: would be nice to have a more precise exception here.
24115 + except RuntimeError, text:
24118 + stream.write ("???")
24120 + stream.write (str (val))
24122 + def print_frame_locals (self, stream, func):
24127 + block = func.value
24129 + for sym in block:
24130 + if sym.is_argument:
24133 + self.write_symbol (stream, sym, block)
24134 + stream.write ('\n')
24136 + def print_frame_args (self, stream, func):
24141 + block = func.value
24143 + for sym in block:
24144 + if not sym.is_argument:
24148 + stream.write (", ")
24150 + self.write_symbol (stream, sym, block)
24153 + # FIXME: this should probably just be a method on gdb.Frame.
24154 + # But then we need stream wrappers.
24155 + def describe (self, stream, full):
24156 + if self.frame.type () == gdb.DUMMY_FRAME:
24157 + stream.write (" <function called from gdb>\n")
24158 + elif self.frame.type () == gdb.SIGTRAMP_FRAME:
24159 + stream.write (" <signal handler called>\n")
24161 + sal = self.frame.find_sal ()
24162 + pc = self.frame.pc ()
24163 + name = self.frame.name ()
24166 + if pc != sal.pc or not sal.symtab:
24167 + stream.write (" 0x%08x in" % pc)
24168 + stream.write (" " + name + " (")
24170 + func = gdb.find_pc_function (self.frame.addr_in_block ())
24171 + self.print_frame_args (stream, func)
24173 + stream.write (")")
24175 + if sal.symtab and sal.symtab.filename:
24176 + stream.write (" at " + sal.symtab.filename)
24177 + stream.write (":" + str (sal.line))
24179 + if not self.frame.name () or (not sal.symtab or not sal.symtab.filename):
24180 + lib = gdb.solib_address (pc)
24182 + stream.write (" from " + lib)
24184 + stream.write ("\n")
24187 + self.print_frame_locals (stream, func)
24189 + def __getattr__ (self, name):
24190 + return getattr (self.frame, name)
24192 +class ReverseBacktraceParameter (gdb.Parameter):
24193 + """The new-backtrace command can show backtraces in 'reverse' order.
24194 +This means that the innermost frame will be printed last.
24195 +Note that reverse backtraces are more expensive to compute."""
24197 + set_doc = "Enable or disable reverse backtraces."
24198 + show_doc = "Show whether backtraces will be printed in reverse order."
24200 + def __init__(self):
24201 + gdb.Parameter.__init__ (self, "reverse-backtrace",
24202 + gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
24203 + # Default to compatibility with gdb.
24204 + self.value = False
24206 +class FilteringBacktrace (gdb.Command):
24207 + """Print backtrace of all stack frames, or innermost COUNT frames.
24208 +With a negative argument, print outermost -COUNT frames.
24209 +Use of the 'full' qualifier also prints the values of the local variables.
24210 +Use of the 'raw' qualifier avoids any filtering by loadable modules.
24213 + def __init__ (self):
24214 + # FIXME: this is not working quite well enough to replace
24215 + # "backtrace" yet.
24216 + gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK)
24217 + self.reverse = ReverseBacktraceParameter()
24219 + def reverse_iter (self, iter):
24221 + for item in iter:
24222 + result.append (item)
24226 + def final_n (self, iter, x):
24228 + for item in iter:
24229 + result.append (item)
24230 + return result[x:]
24232 + def invoke (self, arg, from_tty):
24238 + for word in arg.split (" "):
24241 + elif word == 'raw':
24243 + elif word == 'full':
24246 + count = int (word)
24248 + # FIXME: provide option to start at selected frame
24249 + # However, should still number as if starting from newest
24250 + iter = itertools.imap (FrameWrapper,
24251 + FrameIterator (gdb.newest_frame ()))
24253 + iter = gdb.backtrace.create_frame_filter (iter)
24255 + # Now wrap in an iterator that numbers the frames.
24256 + iter = itertools.izip (itertools.count (0), iter)
24258 + # Reverse if the user wanted that.
24259 + if self.reverse.value:
24260 + iter = self.reverse_iter (iter)
24262 + # Extract sub-range user wants.
24264 + iter = self.final_n (iter, count)
24266 + iter = itertools.islice (iter, 0, count)
24268 + for pair in iter:
24269 + sys.stdout.write ("#%-2d" % pair[0])
24270 + pair[1].describe (sys.stdout, full)
24272 +FilteringBacktrace()
24273 diff --git a/gdb/python/lib/gdb/command/ignore_errors.py b/gdb/python/lib/gdb/command/ignore_errors.py
24274 new file mode 100644
24275 index 0000000..6fa48ff
24277 +++ b/gdb/python/lib/gdb/command/ignore_errors.py
24279 +# Ignore errors in user commands.
24281 +# Copyright (C) 2008 Free Software Foundation, Inc.
24283 +# This program is free software; you can redistribute it and/or modify
24284 +# it under the terms of the GNU General Public License as published by
24285 +# the Free Software Foundation; either version 3 of the License, or
24286 +# (at your option) any later version.
24288 +# This program is distributed in the hope that it will be useful,
24289 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24290 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24291 +# GNU General Public License for more details.
24293 +# You should have received a copy of the GNU General Public License
24294 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24298 +class IgnoreErrorsCommand (gdb.Command):
24299 + """Execute a single command, ignoring all errors.
24300 +Only one-line commands are supported.
24301 +This is primarily useful in scripts."""
24303 + def __init__ (self):
24304 + super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
24305 + gdb.COMMAND_OBSCURE,
24307 + gdb.COMPLETE_COMMAND)
24309 + def invoke (self, arg, from_tty):
24311 + gdb.execute (arg, from_tty)
24315 +IgnoreErrorsCommand ()
24316 diff --git a/gdb/python/lib/gdb/command/pahole.py b/gdb/python/lib/gdb/command/pahole.py
24317 new file mode 100644
24318 index 0000000..569b816
24320 +++ b/gdb/python/lib/gdb/command/pahole.py
24322 +# pahole command for gdb
24324 +# Copyright (C) 2008 Free Software Foundation, Inc.
24326 +# This program is free software; you can redistribute it and/or modify
24327 +# it under the terms of the GNU General Public License as published by
24328 +# the Free Software Foundation; either version 3 of the License, or
24329 +# (at your option) any later version.
24331 +# This program is distributed in the hope that it will be useful,
24332 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24333 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24334 +# GNU General Public License for more details.
24336 +# You should have received a copy of the GNU General Public License
24337 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24341 +class Pahole (gdb.Command):
24342 + """Show the holes in a structure.
24343 +This command takes a single argument, a type name.
24344 +It prints the type and displays comments showing where holes are."""
24346 + def __init__ (self):
24347 + super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
24348 + gdb.COMPLETE_SYMBOL)
24351 + def strip (type):
24352 + while type.code () == gdb.TYPE_CODE_TYPEDEF:
24353 + type = type.target ()
24356 + def pahole (self, type, level, name):
24359 + tag = type.tag ()
24362 + print '%sstruct %s {' % (' ' * (2 * level), tag)
24364 + for field in type.fields ():
24365 + # Skip static fields.
24366 + if not hasattr (field, ('bitpos')):
24369 + ftype = self.strip (field.type)
24371 + if bitpos != field.bitpos:
24372 + hole = field.bitpos - bitpos
24373 + print ' /* XXX %d bit hole, try to pack */' % hole
24374 + bitpos = field.bitpos
24375 + if field.bitsize > 0:
24376 + fieldsize = field.bitsize
24378 + # TARGET_CHAR_BIT here...
24379 + fieldsize = 8 * ftype.sizeof ()
24381 + # TARGET_CHAR_BIT
24382 + print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
24383 + bitpos = bitpos + fieldsize
24385 + if ftype.code () == gdb.TYPE_CODE_STRUCT:
24386 + self.pahole (ftype, level + 1, field.name)
24388 + print ' ' * (2 + 2 * level),
24389 + print '%s %s' % (str (ftype), field.name)
24391 + print ' ' * (14 + 2 * level),
24392 + print '} %s' % name
24394 + def invoke (self, arg, from_tty):
24395 + type = gdb.Type (arg)
24396 + type = self.strip (type)
24397 + if type.code () != gdb.TYPE_CODE_STRUCT:
24398 + raise TypeError, '%s is not a struct type' % arg
24400 + self.pahole (type, 0, '')
24403 diff --git a/gdb/python/lib/gdb/command/require.py b/gdb/python/lib/gdb/command/require.py
24404 new file mode 100644
24405 index 0000000..1fbc1e8
24407 +++ b/gdb/python/lib/gdb/command/require.py
24409 +# Demand-loading commands.
24411 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24413 +# This program is free software; you can redistribute it and/or modify
24414 +# it under the terms of the GNU General Public License as published by
24415 +# the Free Software Foundation; either version 3 of the License, or
24416 +# (at your option) any later version.
24418 +# This program is distributed in the hope that it will be useful,
24419 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24420 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24421 +# GNU General Public License for more details.
24423 +# You should have received a copy of the GNU General Public License
24424 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24429 +class RequireCommand (gdb.Command):
24430 + """Prefix command for requiring features."""
24432 + def __init__ (self):
24433 + super (RequireCommand, self).__init__ ("require",
24434 + gdb.COMMAND_SUPPORT,
24435 + gdb.COMPLETE_NONE,
24438 +class RequireSubcommand (gdb.Command):
24439 + """Demand-load a command by name."""
24441 + def __init__ (self, name):
24442 + self.__doc__ = "Demand-load a %s by name." % name
24443 + super (RequireSubcommand, self).__init__ ("require %s" % name,
24444 + gdb.COMMAND_SUPPORT)
24447 + def invoke (self, arg, from_tty):
24448 + for cmd in arg.split():
24449 + exec ('import gdb.' + self.name + '.' + cmd, globals ())
24451 + def complete (self, text, word):
24452 + dir = gdb.pythondir + '/gdb/' + self.name
24454 + for file in os.listdir(dir):
24455 + if not file.startswith (word) or not file.endswith ('.py'):
24457 + feature = file[0:-3]
24458 + if feature == 'require' or feature == '__init__':
24460 + result.append (feature)
24464 +RequireSubcommand("command")
24465 +RequireSubcommand("function")
24466 diff --git a/gdb/python/lib/gdb/command/save_breakpoints.py b/gdb/python/lib/gdb/command/save_breakpoints.py
24467 new file mode 100644
24468 index 0000000..90e07db
24470 +++ b/gdb/python/lib/gdb/command/save_breakpoints.py
24472 +# Save breakpoints.
24474 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24476 +# This program is free software; you can redistribute it and/or modify
24477 +# it under the terms of the GNU General Public License as published by
24478 +# the Free Software Foundation; either version 3 of the License, or
24479 +# (at your option) any later version.
24481 +# This program is distributed in the hope that it will be useful,
24482 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24483 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24484 +# GNU General Public License for more details.
24486 +# You should have received a copy of the GNU General Public License
24487 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24489 +from __future__ import with_statement
24492 +class SavePrefixCommand (gdb.Command):
24493 + "Prefix command for saving things."
24495 + def __init__ (self):
24496 + super (SavePrefixCommand, self).__init__ ("save",
24497 + gdb.COMMAND_SUPPORT,
24498 + gdb.COMPLETE_NONE, True)
24500 +class SaveBreakpointsCommand (gdb.Command):
24501 + """Save the current breakpoints to a file.
24502 +This command takes a single argument, a file name.
24503 +The breakpoints can be restored using the 'source' command."""
24505 + def __init__ (self):
24506 + super (SaveBreakpointsCommand, self).__init__ ("save breakpoints",
24507 + gdb.COMMAND_SUPPORT,
24508 + gdb.COMPLETE_FILENAME)
24510 + def invoke (self, arg, from_tty):
24511 + self.dont_repeat ()
24512 + bps = gdb.breakpoints ()
24514 + raise RuntimeError, 'No breakpoints to save'
24515 + with open (arg.strip (), 'w') as f:
24517 + print >> f, "break", bp.location,
24518 + if bp.thread is not None:
24519 + print >> f, " thread", bp.thread,
24520 + if bp.condition is not None:
24521 + print >> f, " if", bp.condition,
24523 + if not bp.enabled:
24524 + print >> f, "disable %d" % bp.number
24525 + # Note: we don't save the ignore count; there doesn't
24526 + # seem to be much point.
24527 + commands = bp.commands
24528 + if commands is not None:
24529 + print >> f, "commands"
24530 + # Note that COMMANDS has a trailing newline.
24531 + print >> f, commands,
24532 + print >> f, "end"
24535 +SavePrefixCommand ()
24536 +SaveBreakpointsCommand ()
24537 diff --git a/gdb/python/lib/gdb/function/__init__.py b/gdb/python/lib/gdb/function/__init__.py
24538 new file mode 100644
24539 index 0000000..8b13789
24541 +++ b/gdb/python/lib/gdb/function/__init__.py
24544 diff --git a/gdb/python/lib/gdb/function/caller_is.py b/gdb/python/lib/gdb/function/caller_is.py
24545 new file mode 100644
24546 index 0000000..2b9c5c7
24548 +++ b/gdb/python/lib/gdb/function/caller_is.py
24550 +# Caller-is functions.
24552 +# Copyright (C) 2008 Free Software Foundation, Inc.
24554 +# This program is free software; you can redistribute it and/or modify
24555 +# it under the terms of the GNU General Public License as published by
24556 +# the Free Software Foundation; either version 3 of the License, or
24557 +# (at your option) any later version.
24559 +# This program is distributed in the hope that it will be useful,
24560 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24561 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24562 +# GNU General Public License for more details.
24564 +# You should have received a copy of the GNU General Public License
24565 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24570 +class CallerIs (gdb.Function):
24571 + """Return True if the calling function's name is equal to a string.
24572 +This function takes one or two arguments.
24573 +The first argument is the name of a function; if the calling function's
24574 +name is equal to this argument, this function returns True.
24575 +The optional second argument tells this function how many stack frames
24576 +to traverse to find the calling function. The default is 1."""
24578 + def __init__ (self):
24579 + super (CallerIs, self).__init__ ("caller_is")
24581 + def invoke (self, name, nframes = 1):
24582 + frame = gdb.selected_frame ()
24583 + while nframes > 0:
24584 + frame = frame.older ()
24585 + nframes = nframes - 1
24586 + return frame.name () == name.string ()
24588 +class CallerMatches (gdb.Function):
24589 + """Return True if the calling function's name matches a string.
24590 +This function takes one or two arguments.
24591 +The first argument is a regular expression; if the calling function's
24592 +name is matched by this argument, this function returns True.
24593 +The optional second argument tells this function how many stack frames
24594 +to traverse to find the calling function. The default is 1."""
24596 + def __init__ (self):
24597 + super (CallerMatches, self).__init__ ("caller_matches")
24599 + def invoke (self, name, nframes = 1):
24600 + frame = gdb.selected_frame ()
24601 + while nframes > 0:
24602 + frame = frame.older ()
24603 + nframes = nframes - 1
24604 + return re.match (name.string (), frame.name ()) is not None
24608 diff --git a/gdb/python/lib/gdb/function/in_scope.py b/gdb/python/lib/gdb/function/in_scope.py
24609 new file mode 100644
24610 index 0000000..debb3bb
24612 +++ b/gdb/python/lib/gdb/function/in_scope.py
24614 +# In-scope function.
24616 +# Copyright (C) 2008 Free Software Foundation, Inc.
24618 +# This program is free software; you can redistribute it and/or modify
24619 +# it under the terms of the GNU General Public License as published by
24620 +# the Free Software Foundation; either version 3 of the License, or
24621 +# (at your option) any later version.
24623 +# This program is distributed in the hope that it will be useful,
24624 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24625 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24626 +# GNU General Public License for more details.
24628 +# You should have received a copy of the GNU General Public License
24629 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24633 +class InScope (gdb.Function):
24634 + """Return True if all the given variables or macros are in scope.
24635 +Takes one argument for each variable name to be checked."""
24637 + def __init__ (self):
24638 + super (InScope, self).__init__ ("in_scope")
24640 + def invoke (self, *vars):
24641 + if len (vars) == 0:
24642 + raise TypeError, "in_scope takes at least one argument"
24644 + # gdb.Value isn't hashable so it can't be put in a map.
24645 + # Convert to string first.
24646 + wanted = set (map (lambda x: x.string (), vars))
24648 + block = gdb.selected_frame ().block ()
24650 + for sym in block:
24651 + if (sym.is_argument or sym.is_constant
24652 + or sym.is_function or sym.is_variable):
24653 + if sym.name in wanted:
24654 + found.add (sym.name)
24656 + block = block.superblock
24658 + return wanted == found
24661 diff --git a/gdb/python/lib/gdb/libstdcxx/__init__.py b/gdb/python/lib/gdb/libstdcxx/__init__.py
24662 new file mode 100644
24663 index 0000000..8b13789
24665 +++ b/gdb/python/lib/gdb/libstdcxx/__init__.py
24668 diff --git a/gdb/python/lib/gdb/libstdcxx/v6/__init__.py b/gdb/python/lib/gdb/libstdcxx/v6/__init__.py
24669 new file mode 100644
24670 index 0000000..8b13789
24672 +++ b/gdb/python/lib/gdb/libstdcxx/v6/__init__.py
24675 diff --git a/gdb/python/lib/gdb/libstdcxx/v6/hook.in b/gdb/python/lib/gdb/libstdcxx/v6/hook.in
24676 new file mode 100644
24677 index 0000000..fe7c072
24679 +++ b/gdb/python/lib/gdb/libstdcxx/v6/hook.in
24682 +# Copyright (C) 2009 Free Software Foundation, Inc.
24684 +# This program is free software; you can redistribute it and/or modify
24685 +# it under the terms of the GNU General Public License as published by
24686 +# the Free Software Foundation; either version 3 of the License, or
24687 +# (at your option) any later version.
24689 +# This program is distributed in the hope that it will be useful,
24690 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24691 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24692 +# GNU General Public License for more details.
24694 +# You should have received a copy of the GNU General Public License
24695 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24700 +# Update module path.
24702 +if not dir in sys.path:
24703 + sys.path.insert(0, dir)
24705 +# Load the pretty-printers.
24706 +from libstdcxx.v6.printers import register_libstdcxx_printers
24707 +register_libstdcxx_printers (gdb.current_objfile ())
24708 diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
24709 new file mode 100644
24710 index 0000000..2572731
24712 +++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
24714 +# Pretty-printers for libstc++.
24716 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24718 +# This program is free software; you can redistribute it and/or modify
24719 +# it under the terms of the GNU General Public License as published by
24720 +# the Free Software Foundation; either version 3 of the License, or
24721 +# (at your option) any later version.
24723 +# This program is distributed in the hope that it will be useful,
24724 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
24725 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24726 +# GNU General Public License for more details.
24728 +# You should have received a copy of the GNU General Public License
24729 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
24735 +class StdPointerPrinter:
24736 + "Print a smart pointer of some kind"
24738 + def __init__ (self, typename, val):
24739 + self.typename = typename
24742 + def to_string (self):
24743 + return '%s (count %d) %s' % (self.typename,
24744 + self.val['_M_refcount']['_M_pi']['_M_use_count'],
24745 + self.val['_M_ptr'])
24747 +class UniquePointerPrinter:
24748 + "Print a unique_ptr"
24750 + def __init__ (self, val):
24753 + def to_string (self):
24754 + return self.val['_M_t']
24756 +class StdListPrinter:
24757 + "Print a std::list"
24760 + def __init__(self, nodetype, head):
24761 + self.nodetype = nodetype
24762 + self.base = head['_M_next']
24763 + self.head = head.address()
24766 + def __iter__(self):
24770 + if self.base == self.head:
24771 + raise StopIteration
24772 + elt = self.base.cast(self.nodetype).dereference()
24773 + self.base = elt['_M_next']
24774 + count = self.count
24775 + self.count = self.count + 1
24776 + return ('[%d]' % count, elt['_M_data'])
24778 + def __init__(self, val):
24781 + def children(self):
24782 + itype = self.val.type().template_argument(0)
24783 + nodetype = gdb.Type('std::_List_node<%s>' % itype).pointer()
24784 + return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
24786 + def to_string(self):
24787 + if self.val['_M_impl']['_M_node'].address() == self.val['_M_impl']['_M_node']['_M_next']:
24788 + return 'empty std::list'
24789 + return 'std::list'
24791 +class StdListIteratorPrinter:
24792 + "Print std::list::iterator"
24794 + def __init__(self, val):
24797 + def to_string(self):
24798 + itype = self.val.type().template_argument(0)
24799 + nodetype = gdb.Type('std::_List_node<%s>' % itype).pointer()
24800 + return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
24802 +class StdSlistPrinter:
24803 + "Print a __gnu_cxx::slist"
24806 + def __init__(self, nodetype, head):
24807 + self.nodetype = nodetype
24808 + self.base = head['_M_head']['_M_next']
24811 + def __iter__(self):
24815 + if self.base == 0:
24816 + raise StopIteration
24817 + elt = self.base.cast(self.nodetype).dereference()
24818 + self.base = elt['_M_next']
24819 + count = self.count
24820 + self.count = self.count + 1
24821 + return ('[%d]' % count, elt['_M_data'])
24823 + def __init__(self, val):
24826 + def children(self):
24827 + itype = self.val.type().template_argument(0)
24828 + nodetype = gdb.Type('__gnu_cxx::_Slist_node<%s>' % itype).pointer()
24829 + return self._iterator(nodetype, self.val)
24831 + def to_string(self):
24832 + if self.val['_M_head']['_M_next'] == 0:
24833 + return 'empty __gnu_cxx::slist'
24834 + return '__gnu_cxx::slist'
24836 +class StdSlistIteratorPrinter:
24837 + "Print __gnu_cxx::slist::iterator"
24839 + def __init__(self, val):
24842 + def to_string(self):
24843 + itype = self.val.type().template_argument(0)
24844 + nodetype = gdb.Type('__gnu_cxx::_Slist_node<%s>' % itype).pointer()
24845 + return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
24847 +class StdVectorPrinter:
24848 + "Print a std::vector"
24851 + def __init__ (self, start, finish):
24852 + self.item = start
24853 + self.finish = finish
24856 + def __iter__(self):
24860 + if self.item == self.finish:
24861 + raise StopIteration
24862 + count = self.count
24863 + self.count = self.count + 1
24864 + elt = self.item.dereference()
24865 + self.item = self.item + 1
24866 + return ('[%d]' % count, elt)
24868 + def __init__(self, val):
24871 + def children(self):
24872 + return self._iterator(self.val['_M_impl']['_M_start'],
24873 + self.val['_M_impl']['_M_finish'])
24875 + def to_string(self):
24876 + start = self.val['_M_impl']['_M_start']
24877 + finish = self.val['_M_impl']['_M_finish']
24878 + end = self.val['_M_impl']['_M_end_of_storage']
24879 + return ('std::vector of length %d, capacity %d'
24880 + % (int (finish - start), int (end - start)))
24882 + def display_hint(self):
24885 +class StdVectorIteratorPrinter:
24886 + "Print std::vector::iterator"
24888 + def __init__(self, val):
24891 + def to_string(self):
24892 + return self.val['_M_current'].dereference()
24894 +class StdStackOrQueuePrinter:
24895 + "Print a std::stack or std::queue"
24897 + def __init__ (self, typename, val):
24898 + self.typename = typename
24899 + self.visualizer = gdb.default_visualizer(val['c'])
24901 + def children (self):
24902 + return self.visualizer.children()
24904 + def to_string (self):
24905 + return '%s wrapping: %s' % (self.typename,
24906 + self.visualizer.to_string())
24908 + def display_hint (self):
24909 + if hasattr (self.visualizer, 'display_hint'):
24910 + return self.visualizer.display_hint ()
24913 +class RbtreeIterator:
24914 + def __init__(self, rbtree):
24915 + self.size = rbtree['_M_t']['_M_impl']['_M_node_count']
24916 + self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left']
24919 + def __iter__(self):
24922 + def __len__(self):
24923 + return int (self.size)
24926 + if self.count == self.size:
24927 + raise StopIteration
24928 + result = self.node
24929 + self.count = self.count + 1
24930 + if self.count < self.size:
24931 + # Compute the next node.
24933 + if node.dereference()['_M_right']:
24934 + node = node.dereference()['_M_right']
24935 + while node.dereference()['_M_left']:
24936 + node = node.dereference()['_M_left']
24938 + parent = node.dereference()['_M_parent']
24939 + while node == parent.dereference()['_M_right']:
24941 + parent = parent.dereference()['_M_parent']
24942 + if node.dereference()['_M_right'] != parent:
24947 +# This is a pretty printer for std::_Rb_tree_iterator (which is
24948 +# std::map::iterator), and has nothing to do with the RbtreeIterator
24950 +class StdRbtreeIteratorPrinter:
24951 + "Print std::map::iterator"
24953 + def __init__ (self, val):
24956 + def to_string (self):
24957 + valuetype = self.val.type().template_argument(0)
24958 + nodetype = gdb.Type('std::_Rb_tree_node < %s >' % valuetype)
24959 + nodetype = nodetype.pointer()
24960 + return self.val.cast(nodetype).dereference()['_M_value_field']
24963 +class StdMapPrinter:
24964 + "Print a std::map or std::multimap"
24966 + # Turn an RbtreeIterator into a pretty-print iterator.
24968 + def __init__(self, rbiter, type):
24969 + self.rbiter = rbiter
24973 + def __iter__(self):
24977 + if self.count % 2 == 0:
24978 + n = self.rbiter.next()
24979 + n = n.cast(self.type).dereference()['_M_value_field']
24981 + item = n['first']
24983 + item = self.pair['second']
24984 + result = ('[%d]' % self.count, item)
24985 + self.count = self.count + 1
24988 + def __init__ (self, typename, val):
24989 + self.typename = typename
24991 + self.iter = RbtreeIterator (val)
24993 + def to_string (self):
24994 + return '%s with %d elements' % (self.typename, len (self.iter))
24996 + def children (self):
24997 + keytype = self.val.type().template_argument(0).const()
24998 + valuetype = self.val.type().template_argument(1)
24999 + nodetype = gdb.Type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype))
25000 + nodetype = nodetype.pointer()
25001 + return self._iter (self.iter, nodetype)
25003 + def display_hint (self):
25006 +class StdSetPrinter:
25007 + "Print a std::set or std::multiset"
25009 + # Turn an RbtreeIterator into a pretty-print iterator.
25011 + def __init__(self, rbiter, type):
25012 + self.rbiter = rbiter
25016 + def __iter__(self):
25020 + item = self.rbiter.next()
25021 + item = item.cast(self.type).dereference()['_M_value_field']
25022 + # FIXME: this is weird ... what to do?
25023 + # Maybe a 'set' display hint?
25024 + result = ('[%d]' % self.count, item)
25025 + self.count = self.count + 1
25028 + def __init__ (self, typename, val):
25029 + self.typename = typename
25031 + self.iter = RbtreeIterator (val)
25033 + def to_string (self):
25034 + return '%s with %d elements' % (self.typename, len (self.iter))
25036 + def children (self):
25037 + keytype = self.val.type().template_argument(0)
25038 + nodetype = gdb.Type('std::_Rb_tree_node< %s >' % keytype).pointer()
25039 + return self._iter (self.iter, nodetype)
25041 +class StdBitsetPrinter:
25042 + "Print a std::bitset"
25044 + def __init__(self, val):
25047 + def to_string (self):
25048 + # If template_argument handled values, we could print the
25049 + # size. Or we could use a regexp on the type.
25050 + return 'std::bitset'
25052 + def children (self):
25053 + words = self.val['_M_w']
25054 + wtype = words.type()
25056 + # The _M_w member can be either an unsigned long, or an
25057 + # array. This depends on the template specialization used.
25058 + # If it is a single long, convert to a single element list.
25059 + if wtype.code () == gdb.TYPE_CODE_ARRAY:
25060 + tsize = wtype.target ().sizeof ()
25063 + tsize = wtype.sizeof ()
25065 + nwords = wtype.sizeof() / tsize
25068 + while byte < nwords:
25073 + # Another spot where we could use 'set'?
25074 + result.append(('[%d]' % (byte * tsize * 8 + bit), 1))
25080 +class StdDequePrinter:
25081 + "Print a std::deque"
25084 + def __init__(self, node, start, end, last, buffer_size):
25089 + self.buffer_size = buffer_size
25092 + def __iter__(self):
25096 + if self.p == self.last:
25097 + raise StopIteration
25099 + result = ('[%d]' % self.count, self.p.dereference())
25100 + self.count = self.count + 1
25102 + # Advance the 'cur' pointer.
25103 + self.p = self.p + 1
25104 + if self.p == self.end:
25105 + # If we got to the end of this bucket, move to the
25107 + self.node = self.node + 1
25108 + self.p = self.node[0]
25109 + self.end = self.p + self.buffer_size
25113 + def __init__(self, val):
25115 + self.elttype = val.type().template_argument(0)
25116 + size = self.elttype.sizeof ()
25118 + self.buffer_size = int (512 / size)
25120 + self.buffer_size = 1
25122 + def to_string(self):
25123 + start = self.val['_M_impl']['_M_start']
25124 + end = self.val['_M_impl']['_M_finish']
25126 + delta_n = end['_M_node'] - start['_M_node'] - 1
25127 + delta_s = start['_M_last'] - start['_M_cur']
25128 + delta_e = end['_M_cur'] - end['_M_first']
25130 + size = self.buffer_size * delta_n + delta_s + delta_e
25132 + return 'std::deque with %d elements' % long (size)
25134 + def children(self):
25135 + start = self.val['_M_impl']['_M_start']
25136 + end = self.val['_M_impl']['_M_finish']
25137 + return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'],
25138 + end['_M_cur'], self.buffer_size)
25140 + def display_hint (self):
25143 +class StdDequeIteratorPrinter:
25144 + "Print std::deque::iterator"
25146 + def __init__(self, val):
25149 + def to_string(self):
25150 + return self.val['_M_cur'].dereference()
25152 +class StdStringPrinter:
25153 + "Print a std::basic_string of some kind"
25155 + def __init__(self, encoding, val):
25156 + self.encoding = encoding
25159 + def to_string(self):
25160 + # Look up the target encoding as late as possible.
25161 + encoding = self.encoding
25162 + if encoding[0] is '@':
25163 + encoding = gdb.parameter(encoding[1:])
25164 + return self.val['_M_dataplus']['_M_p'].string(encoding)
25166 + def display_hint (self):
25169 +class Tr1HashtableIterator:
25170 + def __init__ (self, hash):
25172 + self.n_buckets = hash['_M_element_count']
25173 + if self.n_buckets == 0:
25174 + self.node = False
25176 + self.bucket = hash['_M_buckets']
25177 + self.node = self.bucket[0]
25180 + def __iter__ (self):
25183 + def update (self):
25184 + # If we advanced off the end of the chain, move to the next
25186 + while self.node == 0:
25187 + self.bucket = self.bucket + 1
25188 + self.node = self.bucket[0]
25190 + # If we advanced off the end of the bucket array, then
25192 + if self.count == self.n_buckets:
25193 + self.node = False
25195 + self.count = self.count + 1
25198 + if not self.node:
25199 + raise StopIteration
25200 + result = self.node.dereference()['_M_v']
25201 + self.node = self.node.dereference()['_M_next']
25205 +class Tr1UnorderedSetPrinter:
25206 + "Print a tr1::unordered_set"
25208 + def __init__ (self, typename, val):
25209 + self.typename = typename
25212 + def to_string (self):
25213 + return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
25216 + def format_count (i):
25217 + return '[%d]' % i
25219 + def children (self):
25220 + counter = itertools.imap (self.format_count, itertools.count())
25221 + return itertools.izip (counter, Tr1HashtableIterator (self.val))
25223 +class Tr1UnorderedMapPrinter:
25224 + "Print a tr1::unordered_map"
25226 + def __init__ (self, typename, val):
25227 + self.typename = typename
25230 + def to_string (self):
25231 + return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
25234 + def flatten (list):
25240 + def format_one (elt):
25241 + return (elt['first'], elt['second'])
25244 + def format_count (i):
25245 + return '[%d]' % i
25247 + def children (self):
25248 + counter = itertools.imap (self.format_count, itertools.count())
25249 + # Map over the hash table and flatten the result.
25250 + data = self.flatten (itertools.imap (self.format_one, Tr1HashtableIterator (self.val)))
25251 + # Zip the two iterators together.
25252 + return itertools.izip (counter, data)
25254 + def display_hint (self):
25257 +def register_libstdcxx_printers (obj):
25258 + "Register libstdc++ pretty-printers with objfile Obj."
25263 + obj.pretty_printers.append (lookup_function)
25265 +def lookup_function (val):
25266 + "Look-up and return a pretty-printer that can print val."
25269 + type = val.type ();
25271 + # If it points to a reference, get the reference.
25272 + if type.code () == gdb.TYPE_CODE_REF:
25273 + type = type.target ()
25275 + # Get the unqualified type, stripped of typedefs.
25276 + type = type.unqualified ().strip_typedefs ()
25278 + # Get the type name.
25279 + typename = type.tag ()
25280 + if typename == None:
25283 + # Iterate over local dictionary of types to determine
25284 + # if a printer is registered for that type. Return an
25285 + # instantiation of the printer if found.
25286 + for function in pretty_printers_dict:
25287 + if function.search (typename):
25288 + return pretty_printers_dict[function] (val)
25290 + # Cannot find a pretty printer. Return None.
25293 +def build_libstdcxx_dictionary ():
25294 + # libstdc++ objects requiring pretty-printing.
25296 + # http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
25297 + pretty_printers_dict[re.compile('^std::basic_string<char,.*>$')] = lambda val: StdStringPrinter('@target-charset', val)
25298 + pretty_printers_dict[re.compile('^std::basic_string<wchar_t,.*>$')] = lambda val: StdStringPrinter('@target-wide-charset', val)
25299 + pretty_printers_dict[re.compile('^std::basic_string<char16_t,.*>$')] = lambda val: StdStringPrinter('UTF-16', val)
25300 + pretty_printers_dict[re.compile('^std::basic_string<char32_t,.*>$')] = lambda val: StdStringPrinter('UTF-32', val)
25301 + pretty_printers_dict[re.compile('^std::bitset<.*>$')] = StdBitsetPrinter
25302 + pretty_printers_dict[re.compile('^std::deque<.*>$')] = StdDequePrinter
25303 + pretty_printers_dict[re.compile('^std::list<.*>$')] = StdListPrinter
25304 + pretty_printers_dict[re.compile('^std::map<.*>$')] = lambda val: StdMapPrinter("std::map", val)
25305 + pretty_printers_dict[re.compile('^std::multimap<.*>$')] = lambda val: StdMapPrinter("std::multimap", val)
25306 + pretty_printers_dict[re.compile('^std::multiset<.*>$')] = lambda val: StdSetPrinter("std::multiset", val)
25307 + pretty_printers_dict[re.compile('^std::priority_queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::priority_queue", val)
25308 + pretty_printers_dict[re.compile('^std::queue<.*>$')] = lambda val: StdStackOrQueuePrinter("std::queue", val)
25309 + pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
25310 + pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
25311 + pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
25312 + pretty_printers_dict[re.compile('^std::vector<.*>$')] = StdVectorPrinter
25315 + # These are the C++0x printers. They also exist in the standard namespace.
25316 + # For array - the default GDB pretty-printer seems reasonable.
25317 + pretty_printers_dict[re.compile('^std::(tr1::)?shared_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::shared_ptr', val)
25318 + pretty_printers_dict[re.compile('^std::(tr1::)?weak_ptr<.*>$')] = lambda val: StdPointerPrinter ('std::weak_ptr', val)
25319 + pretty_printers_dict[re.compile('^std::(tr1::)?unordered_map<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_map', val)
25320 + pretty_printers_dict[re.compile('^std::(tr1::)?unordered_set<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_set', val)
25321 + pretty_printers_dict[re.compile('^std::(tr1::)?unordered_multimap<.*>$')] = lambda val: Tr1UnorderedMapPrinter ('std::tr1::unordered_multimap', val)
25322 + pretty_printers_dict[re.compile('^std::(tr1::)?unordered_multiset<.*>$')] = lambda val: Tr1UnorderedSetPrinter ('std::tr1::unordered_multiset', val)
25326 + pretty_printers_dict[re.compile('^__gnu_cxx::slist<.*>$')] = StdSlistPrinter
25329 + # These shouldn't be necessary, if GDB "print *i" worked.
25330 + # But it often doesn't, so here they are.
25331 + pretty_printers_dict[re.compile('^std::_List_iterator<.*>$')] = lambda val: StdListIteratorPrinter(val)
25332 + pretty_printers_dict[re.compile('^std::_List_const_iterator<.*>$')] = lambda val: StdListIteratorPrinter(val)
25333 + pretty_printers_dict[re.compile('^std::_Rb_tree_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val)
25334 + pretty_printers_dict[re.compile('^std::_Rb_tree_const_iterator<.*>$')] = lambda val: StdRbtreeIteratorPrinter(val)
25335 + pretty_printers_dict[re.compile('^std::_Deque_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
25336 + pretty_printers_dict[re.compile('^std::_Deque_const_iterator<.*>$')] = lambda val: StdDequeIteratorPrinter(val)
25337 + pretty_printers_dict[re.compile('^__gnu_cxx::__normal_iterator<.*>$')] = lambda val: StdVectorIteratorPrinter(val)
25338 + pretty_printers_dict[re.compile('^__gnu_cxx::_Slist_iterator<.*>$')] = lambda val: StdSlistIteratorPrinter(val)
25340 +pretty_printers_dict = {}
25342 +build_libstdcxx_dictionary ()
25343 diff --git a/gdb/python/python-block.c b/gdb/python/python-block.c
25344 new file mode 100644
25345 index 0000000..8019e9d
25347 +++ b/gdb/python/python-block.c
25349 +/* Python interface to blocks.
25351 + Copyright (C) 2008 Free Software Foundation, Inc.
25353 + This file is part of GDB.
25355 + This program is free software; you can redistribute it and/or modify
25356 + it under the terms of the GNU General Public License as published by
25357 + the Free Software Foundation; either version 3 of the License, or
25358 + (at your option) any later version.
25360 + This program is distributed in the hope that it will be useful,
25361 + but WITHOUT ANY WARRANTY; without even the implied warranty of
25362 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25363 + GNU General Public License for more details.
25365 + You should have received a copy of the GNU General Public License
25366 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
25369 +#include "block.h"
25370 +#include "dictionary.h"
25371 +#include "symtab.h"
25372 +#include "python-internal.h"
25376 + struct block *block;
25381 + struct dictionary *dict;
25382 + struct dict_iterator iter;
25383 + int initialized_p;
25384 +} block_syms_iterator_object;
25386 +static PyTypeObject block_syms_iterator_object_type;
25389 +blpy_iter (PyObject *self)
25391 + block_syms_iterator_object *block_iter_obj;
25393 + block_iter_obj = PyObject_New (block_syms_iterator_object,
25394 + &block_syms_iterator_object_type);
25395 + if (block_iter_obj == NULL)
25397 + PyErr_SetString (PyExc_MemoryError,
25398 + "Could not allocate iterator object.");
25402 + block_iter_obj->dict = BLOCK_DICT (((block_object *) self)->block);
25403 + block_iter_obj->initialized_p = 0;
25405 + return (PyObject *) block_iter_obj;
25409 +blpy_get_start (PyObject *self, void *closure)
25411 + block_object *self_block = (block_object *) self;
25413 + return PyLong_FromUnsignedLongLong (BLOCK_START (self_block->block));
25417 +blpy_get_end (PyObject *self, void *closure)
25419 + block_object *self_block = (block_object *) self;
25421 + return PyLong_FromUnsignedLongLong (BLOCK_END (self_block->block));
25425 +blpy_get_function (PyObject *self, void *closure)
25427 + block_object *self_block = (block_object *) self;
25428 + struct symbol *sym;
25430 + sym = BLOCK_FUNCTION (self_block->block);
25432 + return symbol_to_symbol_object (sym);
25438 +blpy_get_superblock (PyObject *self, void *closure)
25440 + block_object *self_block = (block_object *) self;
25441 + struct block *block;
25443 + block = BLOCK_SUPERBLOCK (self_block->block);
25445 + return block_to_block_object (block);
25451 +block_to_block_object (struct block *block)
25453 + block_object *block_obj;
25455 + block_obj = PyObject_New (block_object, &block_object_type);
25456 + if (block_obj == NULL)
25458 + PyErr_SetString (PyExc_MemoryError, "Could not allocate block object.");
25462 + block_obj->block = block;
25464 + return (PyObject *) block_obj;
25468 +block_object_to_block (PyObject *obj)
25470 + if (! PyObject_TypeCheck (obj, &block_object_type))
25472 + return ((block_object *) obj)->block;
25476 +blpy_block_syms_iter (PyObject *self)
25482 +blpy_block_syms_iternext (PyObject *self)
25484 + block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self;
25485 + struct symbol *sym;
25487 + if (!iter_obj->initialized_p)
25489 + sym = dict_iterator_first (iter_obj->dict, &(iter_obj->iter));
25490 + iter_obj->initialized_p = 1;
25493 + sym = dict_iterator_next (&(iter_obj->iter));
25495 + return (sym == NULL)? NULL : symbol_to_symbol_object (sym);
25498 +/* Return the innermost lexical block containing the specified pc value,
25499 + or 0 if there is none. */
25502 +gdbpy_block_for_pc (PyObject *self, PyObject *args)
25504 + unsigned PY_LONG_LONG pc;
25505 + struct block *block;
25506 + PyObject *sym_obj;
25508 + if (!PyArg_ParseTuple (args, "K", &pc))
25511 + block = block_for_pc (pc);
25513 + return block_to_block_object (block);
25519 +gdbpy_initialize_blocks (void)
25521 + block_object_type.tp_new = PyType_GenericNew;
25522 + if (PyType_Ready (&block_object_type) < 0)
25525 + block_syms_iterator_object_type.tp_new = PyType_GenericNew;
25526 + if (PyType_Ready (&block_syms_iterator_object_type) < 0)
25529 + Py_INCREF (&block_object_type);
25530 + PyModule_AddObject (gdb_module, "Block", (PyObject *) &block_object_type);
25532 + Py_INCREF (&block_syms_iterator_object_type);
25533 + PyModule_AddObject (gdb_module, "BlockIterator",
25534 + (PyObject *) &block_syms_iterator_object_type);
25539 +static PyGetSetDef block_object_getset[] = {
25540 + { "start", blpy_get_start, NULL, "Start address of the block.", NULL },
25541 + { "end", blpy_get_end, NULL, "End address of the block.", NULL },
25542 + { "function", blpy_get_function, NULL,
25543 + "Symbol that names the block, or None.", NULL },
25544 + { "superblock", blpy_get_superblock, NULL,
25545 + "Block containing the block, or None.", NULL },
25546 + { NULL } /* Sentinel */
25549 +PyTypeObject block_object_type = {
25550 + PyObject_HEAD_INIT (NULL)
25552 + "gdb.Block", /*tp_name*/
25553 + sizeof (block_object), /*tp_basicsize*/
25554 + 0, /*tp_itemsize*/
25555 + 0, /*tp_dealloc*/
25557 + 0, /*tp_getattr*/
25558 + 0, /*tp_setattr*/
25559 + 0, /*tp_compare*/
25561 + 0, /*tp_as_number*/
25562 + 0, /*tp_as_sequence*/
25563 + 0, /*tp_as_mapping*/
25567 + 0, /*tp_getattro*/
25568 + 0, /*tp_setattro*/
25569 + 0, /*tp_as_buffer*/
25570 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
25571 + "GDB block object", /* tp_doc */
25572 + 0, /* tp_traverse */
25573 + 0, /* tp_clear */
25574 + 0, /* tp_richcompare */
25575 + 0, /* tp_weaklistoffset */
25576 + blpy_iter, /* tp_iter */
25577 + 0, /* tp_iternext */
25578 + 0, /* tp_methods */
25579 + 0, /* tp_members */
25580 + block_object_getset /* tp_getset */
25583 +static PyTypeObject block_syms_iterator_object_type = {
25584 + PyObject_HEAD_INIT (NULL)
25586 + "gdb.BlockIterator", /*tp_name*/
25587 + sizeof (block_syms_iterator_object), /*tp_basicsize*/
25588 + 0, /*tp_itemsize*/
25589 + 0, /*tp_dealloc*/
25591 + 0, /*tp_getattr*/
25592 + 0, /*tp_setattr*/
25593 + 0, /*tp_compare*/
25595 + 0, /*tp_as_number*/
25596 + 0, /*tp_as_sequence*/
25597 + 0, /*tp_as_mapping*/
25601 + 0, /*tp_getattro*/
25602 + 0, /*tp_setattro*/
25603 + 0, /*tp_as_buffer*/
25604 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
25605 + "GDB block syms iterator object", /* tp_doc */
25606 + 0, /* tp_traverse */
25607 + 0, /* tp_clear */
25608 + 0, /* tp_richcompare */
25609 + 0, /* tp_weaklistoffset */
25610 + blpy_block_syms_iter, /* tp_iter */
25611 + blpy_block_syms_iternext, /* tp_iternext */
25612 + 0 /* tp_methods */
25614 diff --git a/gdb/python/python-breakpoint.c b/gdb/python/python-breakpoint.c
25615 new file mode 100644
25616 index 0000000..ec80419
25618 +++ b/gdb/python/python-breakpoint.c
25620 +/* Python interface to breakpoints
25622 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
25624 + This file is part of GDB.
25626 + This program is free software; you can redistribute it and/or modify
25627 + it under the terms of the GNU General Public License as published by
25628 + the Free Software Foundation; either version 3 of the License, or
25629 + (at your option) any later version.
25631 + This program is distributed in the hope that it will be useful,
25632 + but WITHOUT ANY WARRANTY; without even the implied warranty of
25633 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25634 + GNU General Public License for more details.
25636 + You should have received a copy of the GNU General Public License
25637 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
25640 +#include "value.h"
25641 +#include "exceptions.h"
25642 +#include "python-internal.h"
25643 +#include "charset.h"
25644 +#include "breakpoint.h"
25645 +#include "gdbcmd.h"
25646 +#include "gdbthread.h"
25647 +#include "observer.h"
25650 +/* From breakpoint.c. */
25651 +extern struct breakpoint *breakpoint_chain;
25654 +typedef struct breakpoint_object breakpoint_object;
25656 +static PyTypeObject breakpoint_object_type;
25658 +/* A dynamically allocated vector of breakpoint objects. Each
25659 + breakpoint has a number. A breakpoint is valid if its slot in this
25660 + vector is non-null. When a breakpoint is deleted, we drop our
25661 + reference to it and zero its slot; this is how we let the Python
25662 + object have a lifetime which is independent from that of the gdb
25664 +static breakpoint_object **bppy_breakpoints;
25666 +/* Number of slots in bppy_breakpoints. */
25667 +static int bppy_slots;
25669 +/* Number of live breakpoints. */
25670 +static int bppy_live;
25672 +/* Variables used to pass information between the Breakpoint
25673 + constructor and the breakpoint-created hook function. */
25674 +static breakpoint_object *bppy_pending_object;
25676 +struct breakpoint_object
25680 + /* The breakpoint number according to gdb. */
25683 + /* The gdb breakpoint object, or NULL if the breakpoint has been
25685 + struct breakpoint *bp;
25688 +/* Evaluate to true if the breakpoint NUM is valid, false otherwise. */
25689 +#define BPPY_VALID_P(Num) \
25691 + && (Num) < bppy_slots \
25692 + && bppy_breakpoints[Num] != NULL)
25694 +/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
25695 + exception if it is invalid. */
25696 +#define BPPY_REQUIRE_VALID(Breakpoint) \
25698 + if (! BPPY_VALID_P ((Breakpoint)->number)) \
25699 + return PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
25700 + (Breakpoint)->number); \
25703 +/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
25704 + exception if it is invalid. This macro is for use in setter functions. */
25705 +#define BPPY_SET_REQUIRE_VALID(Breakpoint) \
25707 + if (! BPPY_VALID_P ((Breakpoint)->number)) \
25709 + PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
25710 + (Breakpoint)->number); \
25715 +/* Python function which checks the validity of a breakpoint object. */
25717 +bppy_is_valid (PyObject *self, PyObject *args)
25719 + if (((breakpoint_object *) self)->bp)
25724 +/* Python function to test whether or not the breakpoint is enabled. */
25726 +bppy_get_enabled (PyObject *self, void *closure)
25728 + if (! ((breakpoint_object *) self)->bp)
25730 + /* Not clear what we really want here. */
25731 + if (((breakpoint_object *) self)->bp->enable_state == bp_enabled)
25736 +/* Python function to test whether or not the breakpoint is silent. */
25738 +bppy_get_silent (PyObject *self, void *closure)
25740 + BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25741 + if (((breakpoint_object *) self)->bp->silent)
25746 +/* Python function to set the enabled state of a breakpoint. */
25748 +bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
25750 + breakpoint_object *self_bp = (breakpoint_object *) self;
25753 + BPPY_SET_REQUIRE_VALID (self_bp);
25755 + if (newvalue == NULL)
25757 + PyErr_SetString (PyExc_TypeError, "cannot delete `enabled' attribute");
25760 + else if (! PyBool_Check (newvalue))
25762 + PyErr_SetString (PyExc_TypeError,
25763 + "the value of `enabled' must be a boolean");
25767 + cmp = PyObject_IsTrue (newvalue);
25770 + else if (cmp == 1)
25771 + enable_breakpoint (self_bp->bp);
25773 + disable_breakpoint (self_bp->bp);
25777 +/* Python function to set the 'silent' state of a breakpoint. */
25779 +bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
25781 + breakpoint_object *self_bp = (breakpoint_object *) self;
25784 + BPPY_SET_REQUIRE_VALID (self_bp);
25786 + if (newvalue == NULL)
25788 + PyErr_SetString (PyExc_TypeError, "cannot delete `silent' attribute");
25791 + else if (! PyBool_Check (newvalue))
25793 + PyErr_SetString (PyExc_TypeError,
25794 + "the value of `silent' must be a boolean");
25798 + cmp = PyObject_IsTrue (newvalue);
25802 + self_bp->bp->silent = cmp;
25807 +/* Python function to set the thread of a breakpoint. */
25809 +bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
25811 + breakpoint_object *self_bp = (breakpoint_object *) self;
25814 + BPPY_SET_REQUIRE_VALID (self_bp);
25816 + if (newvalue == NULL)
25818 + PyErr_SetString (PyExc_TypeError, "cannot delete `thread' attribute");
25821 + else if (PyInt_Check (newvalue))
25823 + id = (int) PyInt_AsLong (newvalue);
25824 + if (! valid_thread_id (id))
25826 + PyErr_SetString (PyExc_RuntimeError, "invalid thread id");
25830 + else if (newvalue == Py_None)
25834 + PyErr_SetString (PyExc_TypeError,
25835 + "the value of `thread' must be an integer or None");
25839 + self_bp->bp->thread = id;
25844 +/* Python function to set the ignore count of a breakpoint. */
25846 +bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
25848 + breakpoint_object *self_bp = (breakpoint_object *) self;
25851 + BPPY_SET_REQUIRE_VALID (self_bp);
25853 + if (newvalue == NULL)
25855 + PyErr_SetString (PyExc_TypeError,
25856 + "cannot delete `ignore_count' attribute");
25859 + else if (! PyInt_Check (newvalue))
25861 + PyErr_SetString (PyExc_TypeError,
25862 + "the value of `ignore_count' must be an integer");
25866 + value = PyInt_AsLong (newvalue);
25869 + set_ignore_count (self_bp->number, (int) value, 0);
25874 +/* Python function to set the hit count of a breakpoint. */
25876 +bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
25878 + breakpoint_object *self_bp = (breakpoint_object *) self;
25880 + BPPY_SET_REQUIRE_VALID (self_bp);
25882 + if (newvalue == NULL)
25884 + PyErr_SetString (PyExc_TypeError, "cannot delete `hit_count' attribute");
25887 + else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0)
25889 + PyErr_SetString (PyExc_AttributeError,
25890 + "the value of `hit_count' must be zero");
25894 + self_bp->bp->hit_count = 0;
25899 +/* Python function to get the location of a breakpoint. */
25901 +bppy_get_location (PyObject *self, void *closure)
25905 + BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25906 + str = ((breakpoint_object *) self)->bp->addr_string;
25907 + /* FIXME: watchpoints? tracepoints? */
25910 + return PyString_Decode (str, strlen (str), host_charset (), NULL);
25913 +/* Python function to get the condition expression of a breakpoint. */
25915 +bppy_get_condition (PyObject *self, void *closure)
25918 + BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25920 + str = ((breakpoint_object *) self)->bp->cond_string;
25923 + return PyString_Decode (str, strlen (str), host_charset (), NULL);
25927 +bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
25930 + breakpoint_object *self_bp = (breakpoint_object *) self;
25931 + volatile struct gdb_exception except;
25933 + BPPY_SET_REQUIRE_VALID (self_bp);
25935 + if (newvalue == NULL)
25937 + PyErr_SetString (PyExc_TypeError, "cannot delete `condition' attribute");
25940 + else if (newvalue == Py_None)
25944 + exp = python_string_to_host_string (newvalue);
25949 + TRY_CATCH (except, RETURN_MASK_ALL)
25951 + set_breakpoint_condition (self_bp->bp, exp, 0);
25953 + GDB_PY_SET_HANDLE_EXCEPTION (except);
25958 +/* Python function to get the commands attached to a breakpoint. */
25960 +bppy_get_commands (PyObject *self, void *closure)
25962 + breakpoint_object *self_bp = (breakpoint_object *) self;
25964 + volatile struct gdb_exception except;
25965 + struct ui_file *string_file;
25966 + struct cleanup *chain;
25967 + PyObject *result;
25970 + BPPY_REQUIRE_VALID (self_bp);
25972 + if (! self_bp->bp->commands)
25975 + string_file = mem_fileopen ();
25976 + chain = make_cleanup_ui_file_delete (string_file);
25978 + TRY_CATCH (except, RETURN_MASK_ALL)
25980 + /* FIXME: this can fail. Maybe we need to be making a new
25981 + ui_out object here? */
25982 + ui_out_redirect (uiout, string_file);
25983 + print_command_lines (uiout, self_bp->bp->commands, 0);
25984 + ui_out_redirect (uiout, NULL);
25986 + cmdstr = ui_file_xstrdup (string_file, &length);
25987 + GDB_PY_HANDLE_EXCEPTION (except);
25989 + result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
25990 + do_cleanups (chain);
25995 +/* Python function to get the breakpoint's number. */
25997 +bppy_get_number (PyObject *self, void *closure)
25999 + breakpoint_object *self_bp = (breakpoint_object *) self;
26001 + BPPY_REQUIRE_VALID (self_bp);
26003 + return PyInt_FromLong (self_bp->number);
26006 +/* Python function to get the breakpoint's thread ID. */
26008 +bppy_get_thread (PyObject *self, void *closure)
26010 + breakpoint_object *self_bp = (breakpoint_object *) self;
26012 + BPPY_REQUIRE_VALID (self_bp);
26014 + if (self_bp->bp->thread == -1)
26017 + return PyInt_FromLong (self_bp->bp->thread);
26020 +/* Python function to get the breakpoint's hit count. */
26022 +bppy_get_hit_count (PyObject *self, void *closure)
26024 + breakpoint_object *self_bp = (breakpoint_object *) self;
26026 + BPPY_REQUIRE_VALID (self_bp);
26028 + return PyInt_FromLong (self_bp->bp->hit_count);
26031 +/* Python function to get the breakpoint's ignore count. */
26033 +bppy_get_ignore_count (PyObject *self, void *closure)
26035 + breakpoint_object *self_bp = (breakpoint_object *) self;
26037 + BPPY_REQUIRE_VALID (self_bp);
26039 + return PyInt_FromLong (self_bp->bp->ignore_count);
26042 +/* Python function to create a new breakpoint. */
26044 +bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
26046 + PyObject *result;
26048 + volatile struct gdb_exception except;
26050 + /* FIXME: allow condition, thread, temporary, ... ? */
26051 + if (! PyArg_ParseTuple (args, "s", &spec))
26053 + result = subtype->tp_alloc (subtype, 0);
26056 + bppy_pending_object = (breakpoint_object *) result;
26057 + bppy_pending_object->number = -1;
26058 + bppy_pending_object->bp = NULL;
26060 + TRY_CATCH (except, RETURN_MASK_ALL)
26062 + set_breakpoint (spec, NULL, 0, 0, -1, 0, AUTO_BOOLEAN_TRUE,
26065 + if (except.reason < 0)
26067 + subtype->tp_free (result);
26068 + return PyErr_Format (except.reason == RETURN_QUIT
26069 + ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
26070 + "%s", except.message);
26073 + BPPY_REQUIRE_VALID ((breakpoint_object *) result);
26079 +/* Static function to return a tuple holding all breakpoints. */
26082 +gdbpy_breakpoints (PyObject *self, PyObject *args)
26084 + PyObject *result;
26086 + if (bppy_live == 0)
26089 + result = PyTuple_New (bppy_live);
26093 + for (i = 0; out < bppy_live; ++i)
26095 + if (! bppy_breakpoints[i])
26097 + Py_INCREF (bppy_breakpoints[i]);
26098 + PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]);
26107 +/* Event callback functions. */
26109 +/* Callback that is used when a breakpoint is created. This function
26110 + will create a new Python breakpoint object. */
26112 +gdbpy_breakpoint_created (int num)
26114 + breakpoint_object *newbp;
26115 + struct breakpoint *bp;
26116 + PyGILState_STATE state;
26121 + for (bp = breakpoint_chain; bp; bp = bp->next)
26122 + if (bp->number == num)
26127 + if (num >= bppy_slots)
26129 + int old = bppy_slots;
26130 + bppy_slots = bppy_slots * 2 + 10;
26132 + = (breakpoint_object **) xrealloc (bppy_breakpoints,
26134 + * sizeof (breakpoint_object *)));
26135 + memset (&bppy_breakpoints[old], 0,
26136 + (bppy_slots - old) * sizeof (PyObject *));
26141 + state = PyGILState_Ensure ();
26143 + if (bppy_pending_object)
26145 + newbp = bppy_pending_object;
26146 + bppy_pending_object = NULL;
26149 + newbp = PyObject_New (breakpoint_object, &breakpoint_object_type);
26152 + PyObject *hookfn;
26154 + newbp->number = num;
26156 + bppy_breakpoints[num] = newbp;
26158 + hookfn = gdbpy_get_hook_function ("new_breakpoint");
26161 + PyObject *result;
26162 + result = PyObject_CallFunctionObjArgs (hookfn, newbp, NULL);
26165 + Py_DECREF (result);
26167 + Py_DECREF (hookfn);
26171 + /* Just ignore errors here. */
26174 + PyGILState_Release (state);
26177 +/* Callback that is used when a breakpoint is deleted. This will
26178 + invalidate the corresponding Python object. */
26180 +gdbpy_breakpoint_deleted (int num)
26182 + PyGILState_STATE state;
26184 + state = PyGILState_Ensure ();
26185 + if (BPPY_VALID_P (num))
26187 + bppy_breakpoints[num]->bp = NULL;
26188 + Py_DECREF (bppy_breakpoints[num]);
26189 + bppy_breakpoints[num] = NULL;
26192 + PyGILState_Release (state);
26197 +/* Initialize the Python breakpoint code. */
26199 +gdbpy_initialize_breakpoints (void)
26201 + breakpoint_object_type.tp_new = bppy_new;
26202 + if (PyType_Ready (&breakpoint_object_type) < 0)
26205 + Py_INCREF (&breakpoint_object_type);
26206 + PyModule_AddObject (gdb_module, "Breakpoint",
26207 + (PyObject *) &breakpoint_object_type);
26209 + observer_attach_breakpoint_created (gdbpy_breakpoint_created);
26210 + observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
26215 +static PyGetSetDef breakpoint_object_getset[] = {
26216 + { "enabled", bppy_get_enabled, bppy_set_enabled,
26217 + "Boolean telling whether the breakpoint is enabled.", NULL },
26218 + { "silent", bppy_get_silent, bppy_set_silent,
26219 + "Boolean telling whether the breakpoint is silent.", NULL },
26220 + { "thread", bppy_get_thread, bppy_set_thread,
26221 + "Thread ID for the breakpoint.\n\
26222 +If the value is a thread ID (integer), then this is a thread-specific breakpoint.\n\
26223 +If the value is None, then this breakpoint not thread-specific.\n\
26224 +No other type of value can be used.", NULL },
26225 + { "ignore_count", bppy_get_ignore_count, bppy_set_ignore_count,
26226 + "Number of times this breakpoint should be automatically continued.",
26228 + { "number", bppy_get_number, NULL,
26229 + "Breakpoint's number assigned by GDB.", NULL },
26230 + { "hit_count", bppy_get_hit_count, bppy_set_hit_count,
26231 + "Number of times the breakpoint has been hit.\n\
26232 +Can be set to zero to clear the count. No other value is valid\n\
26233 +when setting this property.", NULL },
26234 + { "location", bppy_get_location, NULL,
26235 + "Location of the breakpoint, as specified by the user.", NULL},
26236 + { "condition", bppy_get_condition, bppy_set_condition,
26237 + "Condition of the breakpoint, as specified by the user,\
26238 +or None if no condition set."},
26239 + { "commands", bppy_get_commands, NULL,
26240 + "Commands of the breakpoint, as specified by the user."},
26241 + { NULL } /* Sentinel. */
26244 +static PyMethodDef breakpoint_object_methods[] =
26246 + { "is_valid", bppy_is_valid, METH_NOARGS,
26247 + "Return true if this breakpoint is valid, false if not." },
26248 + { NULL } /* Sentinel. */
26251 +static PyTypeObject breakpoint_object_type =
26253 + PyObject_HEAD_INIT (NULL)
26255 + "gdb.Breakpoint", /*tp_name*/
26256 + sizeof (breakpoint_object), /*tp_basicsize*/
26257 + 0, /*tp_itemsize*/
26258 + 0, /*tp_dealloc*/
26260 + 0, /*tp_getattr*/
26261 + 0, /*tp_setattr*/
26262 + 0, /*tp_compare*/
26264 + 0, /*tp_as_number*/
26265 + 0, /*tp_as_sequence*/
26266 + 0, /*tp_as_mapping*/
26270 + 0, /*tp_getattro*/
26271 + 0, /*tp_setattro*/
26272 + 0, /*tp_as_buffer*/
26273 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
26274 + "GDB breakpoint object", /* tp_doc */
26275 + 0, /* tp_traverse */
26276 + 0, /* tp_clear */
26277 + 0, /* tp_richcompare */
26278 + 0, /* tp_weaklistoffset */
26280 + 0, /* tp_iternext */
26281 + breakpoint_object_methods, /* tp_methods */
26282 + 0, /* tp_members */
26283 + breakpoint_object_getset /* tp_getset */
26285 diff --git a/gdb/python/python-cmd.c b/gdb/python/python-cmd.c
26286 index 36cde34..e6e3ac0 100644
26287 --- a/gdb/python/python-cmd.c
26288 +++ b/gdb/python/python-cmd.c
26289 @@ -47,8 +47,7 @@ static struct cmdpy_completer completers[] =
26291 #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
26293 -/* A gdb command. For the time being only ordinary commands (not
26294 - set/show commands) are allowed. */
26295 +/* A gdb command. */
26296 struct cmdpy_object
26299 @@ -68,7 +67,6 @@ typedef struct cmdpy_object cmdpy_object;
26301 static PyTypeObject cmdpy_object_type;
26304 /* Constants used by this module. */
26305 static PyObject *invoke_cst;
26306 static PyObject *complete_cst;
26307 @@ -265,10 +263,13 @@ cmdpy_completer (struct cmd_list_element *command, char *text, char *word)
26308 *BASE_LIST is set to the final prefix command's list of
26311 + START_LIST is the list in which the search starts.
26313 This function returns the xmalloc()d name of the new command. On
26314 error sets the Python error and returns NULL. */
26316 -parse_command_name (char *text, struct cmd_list_element ***base_list)
26318 +gdbpy_parse_command_name (char *text, struct cmd_list_element ***base_list,
26319 + struct cmd_list_element **start_list)
26321 struct cmd_list_element *elt;
26322 int len = strlen (text);
26323 @@ -301,7 +302,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26327 - *base_list = &cmdlist;
26328 + *base_list = start_list;
26332 @@ -310,7 +311,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26333 prefix_text[i + 1] = '\0';
26335 text = prefix_text;
26336 - elt = lookup_cmd_1 (&text, cmdlist, NULL, 1);
26337 + elt = lookup_cmd_1 (&text, *start_list, NULL, 1);
26338 if (!elt || elt == (struct cmd_list_element *) -1)
26340 PyErr_Format (PyExc_RuntimeError, _("could not find command prefix %s"),
26341 @@ -336,16 +337,16 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26343 /* Object initializer; sets up gdb-side structures for command.
26345 - Use: __init__(NAME, CMDCLASS, [COMPLETERCLASS, [PREFIX]]).
26346 + Use: __init__(NAME, COMMAND_CLASS, [COMPLETER_CLASS, [PREFIX]]).
26348 NAME is the name of the command. It may consist of multiple words,
26349 in which case the final word is the name of the new command, and
26350 earlier words must be prefix commands.
26352 - CMDCLASS is the kind of command. It should be one of the COMMAND_*
26353 + COMMAND_CLASS is the kind of command. It should be one of the COMMAND_*
26354 constants defined in the gdb module.
26356 - COMPLETERCLASS is the kind of completer. If not given, the
26357 + COMPLETER_CLASS is the kind of completer. If not given, the
26358 "complete" method will be used. Otherwise, it should be one of the
26359 COMPLETE_* constants defined in the gdb module.
26361 @@ -356,7 +357,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26365 -cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26366 +cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
26368 cmdpy_object *obj = (cmdpy_object *) self;
26370 @@ -366,6 +367,8 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26371 volatile struct gdb_exception except;
26372 struct cmd_list_element **cmd_list;
26373 char *cmd_name, *pfx_name;
26374 + static char *keywords[] = { "name", "command_class", "completer_class",
26375 + "prefix", NULL };
26376 PyObject *is_prefix = NULL;
26379 @@ -378,7 +381,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26383 - if (! PyArg_ParseTuple (args, "si|iO", &name, &cmdtype,
26384 + if (! PyArg_ParseTupleAndKeywords (args, kw, "si|iO", keywords, &name, &cmdtype,
26385 &completetype, &is_prefix))
26388 @@ -399,7 +402,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26392 - cmd_name = parse_command_name (name, &cmd_list);
26393 + cmd_name = gdbpy_parse_command_name (name, &cmd_list, &cmdlist);
26397 diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c
26398 new file mode 100644
26399 index 0000000..c257ac3
26401 +++ b/gdb/python/python-frame.c
26403 +/* Python interface to stack frames
26405 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
26407 + This file is part of GDB.
26409 + This program is free software; you can redistribute it and/or modify
26410 + it under the terms of the GNU General Public License as published by
26411 + the Free Software Foundation; either version 3 of the License, or
26412 + (at your option) any later version.
26414 + This program is distributed in the hope that it will be useful,
26415 + but WITHOUT ANY WARRANTY; without even the implied warranty of
26416 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26417 + GNU General Public License for more details.
26419 + You should have received a copy of the GNU General Public License
26420 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
26423 +#include "charset.h"
26424 +#include "block.h"
26425 +#include "frame.h"
26426 +#include "exceptions.h"
26427 +#include "symtab.h"
26428 +#include "stack.h"
26429 +#include "value.h"
26430 +#include "python-internal.h"
26434 + struct frame_id frame_id;
26435 + struct gdbarch *gdbarch;
26437 + /* Marks that the FRAME_ID member actually holds the ID of the frame next
26438 + to this, and not this frames' ID itself. This is a hack to permit Python
26439 + frame objects which represent invalid frames (i.e., the last frame_info
26440 + in a corrupt stack). The problem arises from the fact that this code
26441 + relies on FRAME_ID to uniquely identify a frame, which is not always true
26442 + for the last "frame" in a corrupt stack (it can have a null ID, or the same
26443 + ID as the previous frame). Whenever get_prev_frame returns NULL, we
26444 + record the frame_id of the next frame and set FRAME_ID_IS_NEXT to 1. */
26445 + int frame_id_is_next;
26448 +/* Require a valid frame. This must be called inside a TRY_CATCH, or
26449 + another context in which a gdb exception is allowed. */
26450 +#define FRAPY_REQUIRE_VALID(frame_obj, frame) \
26452 + frame = frame_object_to_frame_info (frame_obj); \
26453 + if (frame == NULL) \
26454 + error ("Frame is invalid."); \
26457 +static PyTypeObject frame_object_type;
26459 +/* Returns the frame_info object corresponding to the given Python Frame
26460 + object. If the frame doesn't exist anymore (the frame id doesn't
26461 + correspond to any frame in the inferior), returns NULL. */
26463 +static struct frame_info *
26464 +frame_object_to_frame_info (frame_object *frame_obj)
26466 + struct frame_info *frame;
26468 + frame = frame_find_by_id (frame_obj->frame_id);
26469 + if (frame == NULL)
26472 + if (frame_obj->frame_id_is_next)
26473 + frame = get_prev_frame (frame);
26478 +/* Called by the Python interpreter to obtain string representation
26479 + of the object. */
26482 +frapy_str (PyObject *self)
26486 + PyObject *result;
26487 + struct ui_file *strfile;
26489 + strfile = mem_fileopen ();
26490 + fprint_frame_id (strfile, ((frame_object *) self)->frame_id);
26491 + s = ui_file_xstrdup (strfile, &len);
26492 + result = PyString_FromString (s);
26498 +/* Implementation of gdb.Frame.is_valid (self) -> Boolean.
26499 + Returns True if the frame corresponding to the frame_id of this
26500 + object still exists in the inferior. */
26503 +frapy_is_valid (PyObject *self, PyObject *args)
26505 + struct frame_info *frame;
26507 + frame = frame_object_to_frame_info ((frame_object *) self);
26508 + if (frame == NULL)
26514 +/* Implementation of gdb.Frame.equals (self, other) -> Boolean. */
26517 +frapy_equal_p (PyObject *self, PyObject *args)
26519 + int equalp = 0; /* Initialize to appease gcc warning. */
26520 + frame_object *self_frame = (frame_object *) self;
26521 + frame_object *other;
26522 + volatile struct gdb_exception except;
26524 + if (!PyArg_ParseTuple (args, "O!", &frame_object_type, &other))
26527 + TRY_CATCH (except, RETURN_MASK_ALL)
26529 + equalp = frame_id_eq (self_frame->frame_id, other->frame_id);
26531 + GDB_PY_HANDLE_EXCEPTION (except);
26539 +/* Implementation of gdb.Frame.name (self) -> String.
26540 + Returns the name of the function corresponding to this frame. */
26543 +frapy_name (PyObject *self, PyObject *args)
26545 + struct frame_info *frame;
26547 + enum language lang;
26548 + PyObject *result;
26549 + volatile struct gdb_exception except;
26551 + TRY_CATCH (except, RETURN_MASK_ALL)
26553 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26555 + find_frame_funname (frame, &name, &lang);
26557 + GDB_PY_HANDLE_EXCEPTION (except);
26560 + result = target_string_to_unicode (name, strlen (name));
26563 + result = Py_None;
26564 + Py_INCREF (Py_None);
26570 +/* Implementation of gdb.Frame.type (self) -> Integer.
26571 + Returns the frame type, namely one of the gdb.*_FRAME constants. */
26574 +frapy_type (PyObject *self, PyObject *args)
26576 + struct frame_info *frame;
26577 + enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning. */
26578 + volatile struct gdb_exception except;
26580 + TRY_CATCH (except, RETURN_MASK_ALL)
26582 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26584 + type = get_frame_type (frame);
26586 + GDB_PY_HANDLE_EXCEPTION (except);
26588 + return PyInt_FromLong (type);
26591 +/* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
26592 + Returns one of the gdb.FRAME_UNWIND_* constants. */
26595 +frapy_unwind_stop_reason (PyObject *self, PyObject *args)
26597 + struct frame_info *frame = NULL; /* Initialize to appease gcc warning. */
26598 + volatile struct gdb_exception except;
26599 + enum unwind_stop_reason stop_reason;
26601 + TRY_CATCH (except, RETURN_MASK_ALL)
26603 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26605 + GDB_PY_HANDLE_EXCEPTION (except);
26607 + stop_reason = get_frame_unwind_stop_reason (frame);
26609 + return PyInt_FromLong (stop_reason);
26612 +/* Implementation of gdb.Frame.pc (self) -> Long.
26613 + Returns the frame's resume address. */
26616 +frapy_pc (PyObject *self, PyObject *args)
26618 + CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
26619 + struct frame_info *frame;
26620 + volatile struct gdb_exception except;
26622 + TRY_CATCH (except, RETURN_MASK_ALL)
26624 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26626 + pc = get_frame_pc (frame);
26628 + GDB_PY_HANDLE_EXCEPTION (except);
26630 + return PyLong_FromUnsignedLongLong (pc);
26633 +/* Implementation of gdb.Frame.block (self) -> gdb.Block.
26634 + Returns the frame's code block. */
26637 +frapy_block (PyObject *self, PyObject *args)
26639 + struct frame_info *frame;
26640 + struct block *block = NULL;
26641 + volatile struct gdb_exception except;
26643 + TRY_CATCH (except, RETURN_MASK_ALL)
26645 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26647 + block = block_for_pc (get_frame_address_in_block (frame));
26649 + GDB_PY_HANDLE_EXCEPTION (except);
26652 + return block_to_block_object (block);
26658 +/* Implementation of gdb.Frame.addr_in_block (self) -> Long.
26659 + Returns an address which falls within the frame's code block. */
26662 +frapy_addr_in_block (PyObject *self, PyObject *args)
26664 + CORE_ADDR pc = 0; /* Initialize to appease gcc warning. */
26665 + struct frame_info *frame;
26666 + volatile struct gdb_exception except;
26668 + TRY_CATCH (except, RETURN_MASK_ALL)
26670 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26672 + pc = get_frame_address_in_block (frame);
26674 + GDB_PY_HANDLE_EXCEPTION (except);
26676 + return PyLong_FromUnsignedLongLong (pc);
26679 +/* Convert a frame_info struct to a Python Frame object.
26680 + Sets a Python exception and returns NULL on error. */
26682 +static frame_object *
26683 +frame_info_to_frame_object (struct frame_info *frame)
26685 + frame_object *frame_obj;
26687 + frame_obj = PyObject_New (frame_object, &frame_object_type);
26688 + if (frame_obj == NULL)
26690 + PyErr_SetString (PyExc_MemoryError, "Could not allocate frame object.");
26694 + /* Try to get the previous frame, to determine if this is the last frame
26695 + in a corrupt stack. If so, we need to store the frame_id of the next
26696 + frame and not of this one (which is possibly invalid). */
26697 + if (get_prev_frame (frame) == NULL
26698 + && get_frame_unwind_stop_reason (frame) != UNWIND_NO_REASON
26699 + && get_next_frame (frame) != NULL)
26701 + frame_obj->frame_id = get_frame_id (get_next_frame (frame));
26702 + frame_obj->frame_id_is_next = 1;
26706 + frame_obj->frame_id = get_frame_id (frame);
26707 + frame_obj->frame_id_is_next = 0;
26710 + frame_obj->gdbarch = get_frame_arch (frame);
26712 + return frame_obj;
26715 +/* Implementation of gdb.Frame.older (self) -> gdb.Frame.
26716 + Returns the frame immediately older (outer) to this frame, or None if
26717 + there isn't one. */
26720 +frapy_older (PyObject *self, PyObject *args)
26722 + struct frame_info *frame, *prev;
26723 + volatile struct gdb_exception except;
26724 + PyObject *prev_obj = NULL; /* Initialize to appease gcc warning. */
26726 + TRY_CATCH (except, RETURN_MASK_ALL)
26728 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26730 + prev = get_prev_frame (frame);
26732 + prev_obj = (PyObject *) frame_info_to_frame_object (prev);
26735 + Py_INCREF (Py_None);
26736 + prev_obj = Py_None;
26739 + GDB_PY_HANDLE_EXCEPTION (except);
26744 +/* Implementation of gdb.Frame.newer (self) -> gdb.Frame.
26745 + Returns the frame immediately newer (inner) to this frame, or None if
26746 + there isn't one. */
26749 +frapy_newer (PyObject *self, PyObject *args)
26751 + struct frame_info *frame, *next;
26752 + volatile struct gdb_exception except;
26753 + PyObject *next_obj = NULL; /* Initialize to appease gcc warning. */
26755 + TRY_CATCH (except, RETURN_MASK_ALL)
26757 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26759 + next = get_next_frame (frame);
26761 + next_obj = (PyObject *) frame_info_to_frame_object (next);
26764 + Py_INCREF (Py_None);
26765 + next_obj = Py_None;
26768 + GDB_PY_HANDLE_EXCEPTION (except);
26773 +/* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line.
26774 + Returns the frame's symtab and line. */
26777 +frapy_find_sal (PyObject *self, PyObject *args)
26779 + struct frame_info *frame;
26780 + struct symtab_and_line sal;
26781 + volatile struct gdb_exception except;
26782 + PyObject *sal_obj = NULL; /* Initialize to appease gcc warning. */
26784 + TRY_CATCH (except, RETURN_MASK_ALL)
26786 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26788 + find_frame_sal (frame, &sal);
26789 + sal_obj = symtab_and_line_to_sal_object (sal);
26791 + GDB_PY_HANDLE_EXCEPTION (except);
26796 +/* Implementation of gdb.Frame.read_var (self, variable) -> gdb.Value.
26797 + Returns the value of the given variable in this frame. The argument can be
26798 + either a gdb.Symbol or a string. Returns None if GDB can't find the
26799 + specified variable. */
26802 +frapy_read_var (PyObject *self, PyObject *args)
26804 + struct frame_info *frame;
26805 + PyObject *sym_obj;
26806 + struct symbol *var = NULL; /* gcc-4.3.2 false warning. */
26807 + struct value *val = NULL;
26808 + volatile struct gdb_exception except;
26810 + if (!PyArg_ParseTuple (args, "O", &sym_obj))
26813 + if (PyObject_TypeCheck (sym_obj, &symbol_object_type))
26814 + var = symbol_object_to_symbol (sym_obj);
26815 + else if (gdbpy_is_string (sym_obj))
26818 + struct block *block = NULL;
26819 + struct cleanup *cleanup;
26820 + volatile struct gdb_exception except;
26822 + var_name = python_string_to_target_string (sym_obj);
26825 + cleanup = make_cleanup (xfree, var_name);
26827 + TRY_CATCH (except, RETURN_MASK_ALL)
26829 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26831 + block = block_for_pc (get_frame_address_in_block (frame));
26832 + var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
26834 + GDB_PY_HANDLE_EXCEPTION (except);
26838 + PyErr_Format (PyExc_ValueError,
26839 + _("variable '%s' not found"), var_name);
26840 + do_cleanups (cleanup);
26845 + do_cleanups (cleanup);
26849 + PyErr_SetString (PyExc_TypeError,
26850 + _("argument must be a symbol or string"));
26854 + TRY_CATCH (except, RETURN_MASK_ALL)
26856 + FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26858 + val = read_var_value (var, frame);
26860 + GDB_PY_HANDLE_EXCEPTION (except);
26863 + return value_to_value_object (val);
26868 +/* Implementation of gdb.frames () -> (gdb.Frame, ...).
26869 + Returns a tuple of all frame objects. */
26872 +gdbpy_frames (PyObject *self, PyObject *args)
26875 + struct frame_info *frame;
26876 + frame_object *frame_obj;
26877 + PyObject *list, *tuple;
26878 + volatile struct gdb_exception except;
26880 + list = PyList_New (0);
26881 + if (list == NULL)
26883 + PyErr_SetString (PyExc_MemoryError, "Could not allocate frames list.");
26887 + TRY_CATCH (except, RETURN_MASK_ALL)
26889 + for (frame = get_current_frame (); frame; frame = get_prev_frame (frame))
26891 + frame_obj = frame_info_to_frame_object (frame);
26892 + if (frame_obj == NULL)
26894 + Py_DECREF (list);
26899 + PyList_Append (list, (PyObject *) frame_obj);
26902 + if (except.reason < 0)
26904 + Py_DECREF (list);
26905 + return PyErr_Format (except.reason == RETURN_QUIT
26906 + ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
26907 + "%s", except.message);
26912 + tuple = PyList_AsTuple (list);
26913 + Py_DECREF (list);
26921 +/* Implementation of gdb.newest_frame () -> gdb.Frame.
26922 + Returns the newest frame object. */
26925 +gdbpy_newest_frame (PyObject *self, PyObject *args)
26927 + struct frame_info *frame;
26928 + frame_object *frame_obj = NULL; /* Initialize to appease gcc warning. */
26929 + volatile struct gdb_exception except;
26931 + TRY_CATCH (except, RETURN_MASK_ALL)
26933 + frame = get_current_frame ();
26934 + frame_obj = frame_info_to_frame_object (frame);
26936 + GDB_PY_HANDLE_EXCEPTION (except);
26938 + return (PyObject *) frame_obj;
26941 +/* Implementation of gdb.selected_frame () -> gdb.Frame.
26942 + Returns the selected frame object. */
26945 +gdbpy_selected_frame (PyObject *self, PyObject *args)
26947 + struct frame_info *frame;
26948 + frame_object *frame_obj = NULL; /* Initialize to appease gcc warning. */
26949 + volatile struct gdb_exception except;
26951 + TRY_CATCH (except, RETURN_MASK_ALL)
26953 + frame = get_selected_frame ("No frame is currently selected.");
26954 + frame_obj = frame_info_to_frame_object (frame);
26956 + GDB_PY_HANDLE_EXCEPTION (except);
26958 + return (PyObject *) frame_obj;
26961 +/* Implementation of gdb.stop_reason_string (Integer) -> String.
26962 + Return a string explaining the unwind stop reason. */
26965 +gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
26970 + if (!PyArg_ParseTuple (args, "i", &reason))
26973 + if (reason < 0 || reason > UNWIND_NO_SAVED_PC)
26975 + PyErr_SetString (PyExc_ValueError, "Invalid frame stop reason.");
26979 + str = frame_stop_reason_string (reason);
26980 + return PyUnicode_Decode (str, strlen (str), host_charset (), NULL);
26983 +/* Sets up the Frame API in the gdb module. */
26986 +gdbpy_initialize_frames (void)
26988 + frame_object_type.tp_new = PyType_GenericNew;
26989 + if (PyType_Ready (&frame_object_type) < 0)
26992 + /* Note: These would probably be best exposed as class attributes of Frame,
26993 + but I don't know how to do it except by messing with the type's dictionary.
26994 + That seems too messy. */
26995 + PyModule_AddIntConstant (gdb_module, "NORMAL_FRAME", NORMAL_FRAME);
26996 + PyModule_AddIntConstant (gdb_module, "DUMMY_FRAME", DUMMY_FRAME);
26997 + PyModule_AddIntConstant (gdb_module, "SIGTRAMP_FRAME", SIGTRAMP_FRAME);
26998 + PyModule_AddIntConstant (gdb_module, "SENTINEL_FRAME", SENTINEL_FRAME);
26999 + PyModule_AddIntConstant (gdb_module,
27000 + "FRAME_UNWIND_NO_REASON", UNWIND_NO_REASON);
27001 + PyModule_AddIntConstant (gdb_module,
27002 + "FRAME_UNWIND_NULL_ID", UNWIND_NULL_ID);
27003 + PyModule_AddIntConstant (gdb_module,
27004 + "FRAME_UNWIND_FIRST_ERROR", UNWIND_FIRST_ERROR);
27005 + PyModule_AddIntConstant (gdb_module,
27006 + "FRAME_UNWIND_INNER_ID", UNWIND_INNER_ID);
27007 + PyModule_AddIntConstant (gdb_module,
27008 + "FRAME_UNWIND_SAME_ID", UNWIND_SAME_ID);
27009 + PyModule_AddIntConstant (gdb_module,
27010 + "FRAME_UNWIND_NO_SAVED_PC", UNWIND_NO_SAVED_PC);
27012 + Py_INCREF (&frame_object_type);
27013 + PyModule_AddObject (gdb_module, "Frame", (PyObject *) &frame_object_type);
27018 +static PyMethodDef frame_object_methods[] = {
27019 + { "equals", frapy_equal_p, METH_VARARGS,
27020 + "equals (frame) -> Boolean.\n\
27021 +Compare this frame to the given frame." },
27022 + { "is_valid", frapy_is_valid, METH_NOARGS,
27023 + "is_valid () -> Boolean.\n\
27024 +Return true if this frame is valid, false if not." },
27025 + { "name", frapy_name, METH_NOARGS,
27026 + "name () -> String.\n\
27027 +Return the function name of the frame, or None if it can't be determined." },
27028 + { "type", frapy_type, METH_NOARGS,
27029 + "type () -> Integer.\n\
27030 +Return the type of the frame." },
27031 + { "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
27032 + "unwind_stop_reason () -> Integer.\n\
27033 +Return the reason why it's not possible to find frames older than this." },
27034 + { "pc", frapy_pc, METH_NOARGS,
27035 + "pc () -> Long.\n\
27036 +Return the frame's resume address." },
27037 + { "block", frapy_block, METH_NOARGS,
27038 + "block () -> gdb.Block.\n\
27039 +Return the frame's code block." },
27040 + { "addr_in_block", frapy_addr_in_block, METH_NOARGS,
27041 + "addr_in_block () -> Long.\n\
27042 +Return an address which falls within the frame's code block." },
27043 + { "older", frapy_older, METH_NOARGS,
27044 + "older () -> gdb.Frame.\n\
27045 +Return the frame immediately older (outer) to this frame." },
27046 + { "newer", frapy_newer, METH_NOARGS,
27047 + "newer () -> gdb.Frame.\n\
27048 +Return the frame immetidaely newer (inner) to this frame." },
27049 + { "find_sal", frapy_find_sal, METH_NOARGS,
27050 + "find_sal () -> gdb.Symtab_and_line.\n\
27051 +Return the frame's symtab and line." },
27052 + { "read_var", frapy_read_var, METH_VARARGS,
27053 + "read_var (variable) -> gdb.Value.\n\
27054 +Return the value of the variable in this frame." },
27055 + {NULL} /* Sentinel */
27058 +static PyTypeObject frame_object_type = {
27059 + PyObject_HEAD_INIT (NULL)
27061 + "gdb.Frame", /* tp_name */
27062 + sizeof (frame_object), /* tp_basicsize */
27063 + 0, /* tp_itemsize */
27064 + 0, /* tp_dealloc */
27065 + 0, /* tp_print */
27066 + 0, /* tp_getattr */
27067 + 0, /* tp_setattr */
27068 + 0, /* tp_compare */
27070 + 0, /* tp_as_number */
27071 + 0, /* tp_as_sequence */
27072 + 0, /* tp_as_mapping */
27075 + frapy_str, /* tp_str */
27076 + 0, /* tp_getattro */
27077 + 0, /* tp_setattro */
27078 + 0, /* tp_as_buffer */
27079 + Py_TPFLAGS_DEFAULT, /* tp_flags */
27080 + "GDB frame object", /* tp_doc */
27081 + 0, /* tp_traverse */
27082 + 0, /* tp_clear */
27083 + 0, /* tp_richcompare */
27084 + 0, /* tp_weaklistoffset */
27086 + 0, /* tp_iternext */
27087 + frame_object_methods /* tp_methods */
27089 diff --git a/gdb/python/python-function.c b/gdb/python/python-function.c
27090 new file mode 100644
27091 index 0000000..4a85a33
27093 +++ b/gdb/python/python-function.c
27095 +/* Convenience functions implemented in Python.
27097 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27099 + This file is part of GDB.
27101 + This program is free software; you can redistribute it and/or modify
27102 + it under the terms of the GNU General Public License as published by
27103 + the Free Software Foundation; either version 3 of the License, or
27104 + (at your option) any later version.
27106 + This program is distributed in the hope that it will be useful,
27107 + but WITHOUT ANY WARRANTY; without even the implied warranty of
27108 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27109 + GNU General Public License for more details.
27111 + You should have received a copy of the GNU General Public License
27112 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
27116 +#include "value.h"
27117 +#include "exceptions.h"
27118 +#include "python-internal.h"
27119 +#include "charset.h"
27120 +#include "gdbcmd.h"
27121 +#include "cli/cli-decode.h"
27122 +#include "completer.h"
27123 +#include "expression.h"
27125 +static PyTypeObject fnpy_object_type;
27130 +convert_values_to_python (int argc, struct value **argv)
27133 + PyObject *result = PyTuple_New (argc);
27134 + for (i = 0; i < argc; ++i)
27136 + PyObject *elt = value_to_value_object (argv[i]);
27139 + Py_DECREF (result);
27140 + error (_("Could not convert value to Python object."));
27142 + PyTuple_SetItem (result, i, elt);
27147 +/* Call a Python function object's invoke method. */
27149 +static struct value *
27150 +fnpy_call (void *cookie, int argc, struct value **argv)
27153 + struct value *value = NULL;
27154 + PyObject *result, *callable, *args;
27155 + struct cleanup *cleanup;
27156 + PyGILState_STATE state;
27158 + state = PyGILState_Ensure ();
27159 + cleanup = make_cleanup_py_restore_gil (&state);
27161 + args = convert_values_to_python (argc, argv);
27163 + callable = PyObject_GetAttrString ((PyObject *) cookie, "invoke");
27166 + Py_DECREF (args);
27167 + error (_("No method named 'invoke' in object."));
27170 + result = PyObject_Call (callable, args, NULL);
27171 + Py_DECREF (callable);
27172 + Py_DECREF (args);
27176 + gdbpy_print_stack ();
27177 + error (_("Error while executing Python code."));
27180 + value = convert_value_from_python (result);
27181 + if (value == NULL)
27183 + Py_DECREF (result);
27184 + gdbpy_print_stack ();
27185 + error (_("Error while executing Python code."));
27188 + Py_DECREF (result);
27189 + do_cleanups (cleanup);
27194 +/* Initializer for a Function object. It takes one argument, the name
27195 + of the function. */
27198 +fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
27200 + char *name, *docstring = NULL;
27201 + if (! PyArg_ParseTuple (args, "s", &name))
27203 + Py_INCREF (self);
27205 + if (PyObject_HasAttrString (self, "__doc__"))
27207 + PyObject *ds_obj = PyObject_GetAttrString (self, "__doc__");
27208 + if (ds_obj && gdbpy_is_string (ds_obj))
27209 + /* Nothing ever frees this. */
27210 + docstring = python_string_to_host_string (ds_obj);
27213 + docstring = _("This function is not documented.");
27215 + add_internal_function (name, docstring, fnpy_call, self);
27219 +/* Initialize internal function support. */
27222 +gdbpy_initialize_functions (void)
27224 + if (PyType_Ready (&fnpy_object_type) < 0)
27227 + Py_INCREF (&fnpy_object_type);
27228 + PyModule_AddObject (gdb_module, "Function", (PyObject *) &fnpy_object_type);
27233 +static PyTypeObject fnpy_object_type =
27235 + PyObject_HEAD_INIT (NULL)
27237 + "gdb.Function", /*tp_name*/
27238 + sizeof (PyObject), /*tp_basicsize*/
27239 + 0, /*tp_itemsize*/
27240 + 0, /*tp_dealloc*/
27242 + 0, /*tp_getattr*/
27243 + 0, /*tp_setattr*/
27244 + 0, /*tp_compare*/
27246 + 0, /*tp_as_number*/
27247 + 0, /*tp_as_sequence*/
27248 + 0, /*tp_as_mapping*/
27252 + 0, /*tp_getattro*/
27253 + 0, /*tp_setattro*/
27254 + 0, /*tp_as_buffer*/
27255 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
27256 + "GDB function object", /* tp_doc */
27257 + 0, /* tp_traverse */
27258 + 0, /* tp_clear */
27259 + 0, /* tp_richcompare */
27260 + 0, /* tp_weaklistoffset */
27262 + 0, /* tp_iternext */
27263 + 0, /* tp_methods */
27264 + 0, /* tp_members */
27265 + 0, /* tp_getset */
27268 + 0, /* tp_descr_get */
27269 + 0, /* tp_descr_set */
27270 + 0, /* tp_dictoffset */
27271 + fnpy_init, /* tp_init */
27272 + 0, /* tp_alloc */
27273 + PyType_GenericNew /* tp_new */
27275 diff --git a/gdb/python/python-hooks.c b/gdb/python/python-hooks.c
27276 new file mode 100644
27277 index 0000000..a3140bc
27279 +++ b/gdb/python/python-hooks.c
27281 +/* Notifications from gdb to Python
27283 + Copyright (C) 2008 Free Software Foundation, Inc.
27285 + This file is part of GDB.
27287 + This program is free software; you can redistribute it and/or modify
27288 + it under the terms of the GNU General Public License as published by
27289 + the Free Software Foundation; either version 3 of the License, or
27290 + (at your option) any later version.
27292 + This program is distributed in the hope that it will be useful,
27293 + but WITHOUT ANY WARRANTY; without even the implied warranty of
27294 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27295 + GNU General Public License for more details.
27297 + You should have received a copy of the GNU General Public License
27298 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
27301 +#include "cli/cli-decode.h"
27302 +#include "charset.h"
27303 +#include "python.h"
27304 +#include "python-internal.h"
27305 +#include "observer.h"
27308 +gdbpy_get_hook_function (const char *name)
27311 + PyObject *result;
27313 + if (! PyObject_HasAttrString (gdb_module, "hooks"))
27315 + hooks = PyObject_GetAttrString (gdb_module, "hooks");
27318 + /* The cast is because the Python function doesn't declare const argument.
27319 + This is a problem in Python version 2.4, but not in 2.5. */
27320 + if (! PyObject_HasAttrString (hooks, (char *) name))
27322 + Py_DECREF (hooks);
27325 + /* The cast is because the Python function doesn't declare const argument.
27326 + This is a problem in Python version 2.4, but not in 2.5. */
27327 + result = PyObject_GetAttrString (hooks, (char *) name);
27328 + Py_DECREF (hooks);
27331 diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
27332 index 02dbfc4..4aae0aa 100644
27333 --- a/gdb/python/python-internal.h
27334 +++ b/gdb/python/python-internal.h
27337 #if HAVE_LIBPYTHON2_4
27338 #include "python2.4/Python.h"
27339 +#include "python2.4/frameobject.h"
27340 /* Py_ssize_t is not defined until 2.5.
27341 Logical type for Py_ssize_t is Py_intptr_t, but that fails in 64-bit
27342 compilation due to several apparent mistakes in python2.4 API, so we
27344 typedef int Py_ssize_t;
27345 #elif HAVE_LIBPYTHON2_5
27346 #include "python2.5/Python.h"
27347 +#include "python2.5/frameobject.h"
27348 #elif HAVE_LIBPYTHON2_6
27349 #include "python2.6/Python.h"
27350 +#include "python2.6/frameobject.h"
27352 #error "Unable to find usable Python.h"
27354 @@ -58,23 +61,69 @@ typedef int Py_ssize_t;
27355 #define PyEval_ReleaseLock() 0
27358 +#include "command.h"
27362 +struct symtab_and_line;
27365 extern PyObject *gdb_module;
27366 +extern PyTypeObject block_object_type;
27367 extern PyTypeObject value_object_type;
27368 +extern PyTypeObject symbol_object_type;
27370 PyObject *gdbpy_history (PyObject *self, PyObject *args);
27372 +PyObject *gdbpy_breakpoints (PyObject *, PyObject *);
27373 +PyObject *gdbpy_frames (PyObject *, PyObject *);
27374 +PyObject *gdbpy_newest_frame (PyObject *, PyObject *);
27375 +PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *);
27376 +PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw);
27377 +PyObject *gdbpy_selected_frame (PyObject *self, PyObject *args);
27378 +PyObject *gdbpy_block_for_pc (PyObject *self, PyObject *args);
27379 +PyObject *gdbpy_read_memory (PyObject *self, PyObject *args);
27380 +PyObject *gdbpy_write_memory (PyObject *self, PyObject *args);
27382 +PyObject *symtab_and_line_to_sal_object (struct symtab_and_line sal);
27383 +PyObject *symtab_to_symtab_object (struct symtab *symtab);
27384 +PyObject *symbol_to_symbol_object (struct symbol *sym);
27385 +PyObject *block_to_block_object (struct block *block);
27386 PyObject *value_to_value_object (struct value *v);
27387 +PyObject *type_to_type_object (struct type *);
27388 +PyObject *objfile_to_objfile_object (struct objfile *);
27390 +PyObject *objfpy_get_printers (PyObject *, void *);
27392 +struct block *block_object_to_block (PyObject *obj);
27393 +struct symbol *symbol_object_to_symbol (PyObject *obj);
27394 +struct value *value_object_to_value (PyObject *self);
27395 struct value *convert_value_from_python (PyObject *obj);
27396 +struct type *type_object_to_type (PyObject *obj);
27398 +PyObject *gdbpy_get_hook_function (const char *);
27400 void gdbpy_initialize_values (void);
27401 +void gdbpy_initialize_breakpoints (void);
27402 +void gdbpy_initialize_frames (void);
27403 +void gdbpy_initialize_symtabs (void);
27404 void gdbpy_initialize_commands (void);
27405 +void gdbpy_initialize_symbols (void);
27406 +void gdbpy_initialize_types (void);
27407 +void gdbpy_initialize_blocks (void);
27408 +void gdbpy_initialize_functions (void);
27409 +void gdbpy_initialize_objfile (void);
27410 +void gdbpy_initialize_parameters (void);
27411 +void gdbpy_initialize_membuf (void);
27413 struct cleanup *make_cleanup_py_decref (PyObject *py);
27414 struct cleanup *make_cleanup_py_restore_gil (PyGILState_STATE *state);
27416 +char *gdbpy_parse_command_name (char *text,
27417 + struct cmd_list_element ***base_list,
27418 + struct cmd_list_element **start_list);
27420 +PyObject *gdbpy_parameter_value (enum var_types, void *);
27422 /* Use this after a TRY_EXCEPT to throw the appropriate Python
27424 #define GDB_PY_HANDLE_EXCEPTION(Exception) \
27425 @@ -85,6 +134,19 @@ struct cleanup *make_cleanup_py_restore_gil (PyGILState_STATE *state);
27426 "%s", Exception.message); \
27429 +/* Use this after a TRY_EXCEPT to throw the appropriate Python
27430 + exception. This macro is for use inside setter functions. */
27431 +#define GDB_PY_SET_HANDLE_EXCEPTION(Exception) \
27433 + if (Exception.reason < 0) \
27435 + PyErr_Format (Exception.reason == RETURN_QUIT \
27436 + ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
27437 + "%s", Exception.message); \
27443 void gdbpy_print_stack (void);
27445 @@ -95,6 +157,21 @@ char *python_string_to_host_string (PyObject *obj);
27446 PyObject *target_string_to_unicode (const gdb_byte *str, int length);
27447 int gdbpy_is_string (PyObject *obj);
27449 +int gdbpy_is_value_object (PyObject *obj);
27451 +/* Note that these are declared here, and not in python.h with the
27452 + other pretty-printer functions, because they refer to PyObject. */
27453 +char *apply_varobj_pretty_printer (PyObject *print_obj,
27454 + struct value **replacement);
27455 +PyObject *gdbpy_get_varobj_pretty_printer (struct value *value);
27456 +PyObject *gdbpy_instantiate_printer (PyObject *cons, PyObject *value);
27457 +char *gdbpy_get_display_hint (PyObject *printer);
27459 +extern PyObject *gdbpy_children_cst;
27460 +extern PyObject *gdbpy_to_string_cst;
27461 +extern PyObject *gdbpy_display_hint_cst;
27462 extern PyObject *gdbpy_doc_cst;
27464 +int get_addr_from_python (PyObject *obj, CORE_ADDR *addr);
27466 #endif /* GDB_PYTHON_INTERNAL_H */
27467 diff --git a/gdb/python/python-membuf.c b/gdb/python/python-membuf.c
27468 new file mode 100644
27469 index 0000000..a4c7d74
27471 +++ b/gdb/python/python-membuf.c
27473 +/* Python interface to the inferior memory.
27475 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27477 + This file is part of GDB.
27479 + This program is free software; you can redistribute it and/or modify
27480 + it under the terms of the GNU General Public License as published by
27481 + the Free Software Foundation; either version 3 of the License, or
27482 + (at your option) any later version.
27484 + This program is distributed in the hope that it will be useful,
27485 + but WITHOUT ANY WARRANTY; without even the implied warranty of
27486 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27487 + GNU General Public License for more details.
27489 + You should have received a copy of the GNU General Public License
27490 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
27493 +#include "exceptions.h"
27494 +#include "gdbcore.h"
27495 +#include "python-internal.h"
27501 + /* These are kept just for mbpy_str. */
27503 + CORE_ADDR length;
27506 +static PyTypeObject membuf_object_type;
27508 +/* Implementation of gdb.read_memory (address, length).
27509 + Returns a Python buffer object with LENGTH bytes of the inferior's memory
27510 + at ADDRESS. Both arguments are integers. */
27513 +gdbpy_read_memory (PyObject *self, PyObject *args)
27515 + CORE_ADDR addr, length;
27517 + membuf_object *membuf_obj;
27518 + struct cleanup *cleanups;
27519 + volatile struct gdb_exception except;
27521 + /* Assume CORE_ADDR corresponds to unsigned long. */
27522 + if (! PyArg_ParseTuple (args, "kk", &addr, &length))
27525 + buffer = xmalloc (length);
27526 + cleanups = make_cleanup (xfree, buffer);
27528 + TRY_CATCH (except, RETURN_MASK_ALL)
27530 + read_memory (addr, buffer, length);
27532 + GDB_PY_HANDLE_EXCEPTION (except);
27534 + discard_cleanups (cleanups);
27536 + membuf_obj = PyObject_New (membuf_object, &membuf_object_type);
27537 + if (membuf_obj == NULL)
27540 + PyErr_SetString (PyExc_MemoryError,
27541 + "Could not allocate memory buffer object.");
27545 + membuf_obj->buffer = buffer;
27547 + membuf_obj->addr = addr;
27548 + membuf_obj->length = length;
27550 + return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, Py_END_OF_BUFFER);
27553 +/* Implementation of gdb.write_memory (address, buffer [, length]).
27554 + Writes the contents of BUFFER (a Python object supporting the read buffer
27555 + protocol) at ADDRESS in the inferior's memory. Write LENGTH bytes from
27556 + BUFFER, or its entire contents if the argument is not provided. The
27557 + function returns nothing. */
27560 +gdbpy_write_memory (PyObject *self, PyObject *args)
27563 + const char *buffer;
27564 + long length = -1;
27566 + volatile struct gdb_exception except;
27568 + /* Assume CORE_ADDR corresponds to unsigned long. */
27569 + if (! PyArg_ParseTuple (args, "ks#|l", &addr, &buffer, &buf_len, &length))
27572 + if (length == -1)
27573 + length = buf_len;
27575 + TRY_CATCH (except, RETURN_MASK_ALL)
27577 + write_memory (addr, buffer, length);
27579 + GDB_PY_HANDLE_EXCEPTION (except);
27584 +/* Destructor of Membuf objects. */
27587 +mbpy_dealloc (PyObject *self)
27589 + xfree (((membuf_object *) self)->buffer);
27590 + self->ob_type->tp_free (self);
27593 +/* Return a description of the Membuf object. */
27596 +mbpy_str (PyObject *self)
27598 + membuf_object *membuf_obj = (membuf_object *) self;
27600 + return PyString_FromFormat ("memory buffer for address %s, %s bytes long",
27601 + paddress (membuf_obj->addr),
27602 + pulongest (membuf_obj->length));
27606 +get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
27608 + membuf_object *membuf_obj = (membuf_object *) self;
27612 + PyErr_SetString (PyExc_SystemError,
27613 + "The memory buffer supports only one segment.");
27617 + *ptrptr = membuf_obj->buffer;
27619 + return membuf_obj->length;
27623 +get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
27625 + return get_read_buffer (self, segment, ptrptr);
27629 +get_seg_count (PyObject *self, Py_ssize_t *lenp)
27632 + *lenp = ((membuf_object *) self)->length;
27638 +get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr)
27640 + void *ptr = NULL;
27643 + ret = get_read_buffer (self, segment, &ptr);
27644 + *ptrptr = (char *) ptr;
27649 +/* Python doesn't provide a decent way to get compatibility here. */
27650 +#if HAVE_LIBPYTHON2_4
27651 +#define CHARBUFFERPROC_NAME getcharbufferproc
27653 +#define CHARBUFFERPROC_NAME charbufferproc
27656 +static PyBufferProcs buffer_procs = {
27658 + get_write_buffer,
27660 + /* The cast here works around a difference between Python 2.4 and
27662 + (CHARBUFFERPROC_NAME) get_char_buffer
27665 +static PyTypeObject membuf_object_type = {
27666 + PyObject_HEAD_INIT (NULL)
27668 + "gdb.Membuf", /*tp_name*/
27669 + sizeof (membuf_object), /*tp_basicsize*/
27670 + 0, /*tp_itemsize*/
27671 + mbpy_dealloc, /*tp_dealloc*/
27673 + 0, /*tp_getattr*/
27674 + 0, /*tp_setattr*/
27675 + 0, /*tp_compare*/
27677 + 0, /*tp_as_number*/
27678 + 0, /*tp_as_sequence*/
27679 + 0, /*tp_as_mapping*/
27682 + mbpy_str, /*tp_str*/
27683 + 0, /*tp_getattro*/
27684 + 0, /*tp_setattro*/
27685 + &buffer_procs, /*tp_as_buffer*/
27686 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
27687 + "GDB memory buffer object", /*tp_doc*/
27688 + 0, /* tp_traverse */
27689 + 0, /* tp_clear */
27690 + 0, /* tp_richcompare */
27691 + 0, /* tp_weaklistoffset */
27693 + 0, /* tp_iternext */
27694 + 0, /* tp_methods */
27695 + 0, /* tp_members */
27696 + 0, /* tp_getset */
27699 + 0, /* tp_descr_get */
27700 + 0, /* tp_descr_set */
27701 + 0, /* tp_dictoffset */
27703 + 0, /* tp_alloc */
27704 + PyType_GenericNew /* tp_new */
27708 +gdbpy_initialize_membuf (void)
27710 + if (PyType_Ready (&membuf_object_type) < 0)
27713 + Py_INCREF (&membuf_object_type);
27714 + PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type);
27716 diff --git a/gdb/python/python-objfile.c b/gdb/python/python-objfile.c
27717 new file mode 100644
27718 index 0000000..e97d3a2
27720 +++ b/gdb/python/python-objfile.c
27722 +/* Python interface to objfiles.
27724 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27726 + This file is part of GDB.
27728 + This program is free software; you can redistribute it and/or modify
27729 + it under the terms of the GNU General Public License as published by
27730 + the Free Software Foundation; either version 3 of the License, or
27731 + (at your option) any later version.
27733 + This program is distributed in the hope that it will be useful,
27734 + but WITHOUT ANY WARRANTY; without even the implied warranty of
27735 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27736 + GNU General Public License for more details.
27738 + You should have received a copy of the GNU General Public License
27739 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
27742 +#include "python-internal.h"
27743 +#include "charset.h"
27744 +#include "objfiles.h"
27750 + /* The corresponding objfile. */
27751 + struct objfile *objfile;
27753 + /* The pretty-printer list of functions. */
27754 + PyObject *printers;
27757 +static PyTypeObject objfile_object_type;
27759 +static const struct objfile_data *objfpy_objfile_data_key;
27763 +/* An Objfile method which returns the objfile's file name, or None. */
27765 +objfpy_get_filename (PyObject *self, void *closure)
27767 + objfile_object *obj = (objfile_object *) self;
27768 + if (obj->objfile && obj->objfile->name)
27769 + return PyString_Decode (obj->objfile->name, strlen (obj->objfile->name),
27770 + host_charset (), NULL);
27775 +objfpy_dealloc (PyObject *o)
27777 + objfile_object *self = (objfile_object *) o;
27778 + Py_XDECREF (self->printers);
27779 + self->ob_type->tp_free ((PyObject *) self);
27783 +objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
27785 + objfile_object *self = (objfile_object *) type->tp_alloc (type, 0);
27788 + self->objfile = NULL;
27790 + self->printers = PyList_New (0);
27791 + if (!self->printers)
27793 + Py_DECREF (self);
27797 + return (PyObject *) self;
27801 +objfpy_get_printers (PyObject *o, void *ignore)
27803 + objfile_object *self = (objfile_object *) o;
27804 + Py_INCREF (self->printers);
27805 + return self->printers;
27809 +objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
27811 + objfile_object *self = (objfile_object *) o;
27814 + PyErr_SetString (PyExc_TypeError,
27815 + "cannot delete the pretty_printers attribute");
27819 + if (! PyList_Check (value))
27821 + PyErr_SetString (PyExc_TypeError,
27822 + "the pretty_printers attribute must be a list");
27826 + Py_XDECREF (self->printers);
27827 + Py_INCREF (value);
27828 + self->printers = value;
27835 +/* Clear the OBJFILE pointer in an Objfile object and remove the
27838 +clean_up_objfile (struct objfile *objfile, void *datum)
27840 + objfile_object *object = datum;
27841 + object->objfile = NULL;
27842 + Py_DECREF ((PyObject *) object);
27845 +/* Return the Python object of type Objfile representing OBJFILE. If
27846 + the object has already been created, return it. Otherwise, create
27847 + it. Return NULL and set the Python error on failure. */
27849 +objfile_to_objfile_object (struct objfile *objfile)
27851 + objfile_object *object;
27853 + object = objfile_data (objfile, objfpy_objfile_data_key);
27856 + object = PyObject_New (objfile_object, &objfile_object_type);
27861 + object->objfile = objfile;
27863 + object->printers = PyList_New (0);
27864 + if (!object->printers)
27866 + Py_DECREF (object);
27870 + set_objfile_data (objfile, objfpy_objfile_data_key, object);
27874 + return (PyObject *) object;
27878 +gdbpy_initialize_objfile (void)
27880 + objfpy_objfile_data_key
27881 + = register_objfile_data_with_cleanup (clean_up_objfile);
27883 + if (PyType_Ready (&objfile_object_type) < 0)
27886 + Py_INCREF (&objfile_object_type);
27887 + PyModule_AddObject (gdb_module, "Objfile", (PyObject *) &objfile_object_type);
27892 +static PyGetSetDef objfile_getset[] =
27894 + { "filename", objfpy_get_filename, NULL,
27895 + "The objfile's filename, or None.", NULL },
27896 + { "pretty_printers", objfpy_get_printers, objfpy_set_printers,
27897 + "Pretty printers.", NULL },
27901 +static PyTypeObject objfile_object_type =
27903 + PyObject_HEAD_INIT (NULL)
27905 + "gdb.Objfile", /*tp_name*/
27906 + sizeof (objfile_object), /*tp_basicsize*/
27907 + 0, /*tp_itemsize*/
27908 + objfpy_dealloc, /*tp_dealloc*/
27910 + 0, /*tp_getattr*/
27911 + 0, /*tp_setattr*/
27912 + 0, /*tp_compare*/
27914 + 0, /*tp_as_number*/
27915 + 0, /*tp_as_sequence*/
27916 + 0, /*tp_as_mapping*/
27920 + 0, /*tp_getattro*/
27921 + 0, /*tp_setattro*/
27922 + 0, /*tp_as_buffer*/
27923 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
27924 + "GDB objfile object", /* tp_doc */
27925 + 0, /* tp_traverse */
27926 + 0, /* tp_clear */
27927 + 0, /* tp_richcompare */
27928 + 0, /* tp_weaklistoffset */
27930 + 0, /* tp_iternext */
27931 + 0, /* tp_methods */
27932 + 0, /* tp_members */
27933 + objfile_getset, /* tp_getset */
27936 + 0, /* tp_descr_get */
27937 + 0, /* tp_descr_set */
27938 + 0, /* tp_dictoffset */
27940 + 0, /* tp_alloc */
27941 + objfpy_new, /* tp_new */
27943 diff --git a/gdb/python/python-param.c b/gdb/python/python-param.c
27944 new file mode 100644
27945 index 0000000..1f591a8
27947 +++ b/gdb/python/python-param.c
27949 +/* gdb parameters implemented in Python
27951 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27953 + This file is part of GDB.
27955 + This program is free software; you can redistribute it and/or modify
27956 + it under the terms of the GNU General Public License as published by
27957 + the Free Software Foundation; either version 3 of the License, or
27958 + (at your option) any later version.
27960 + This program is distributed in the hope that it will be useful,
27961 + but WITHOUT ANY WARRANTY; without even the implied warranty of
27962 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27963 + GNU General Public License for more details.
27965 + You should have received a copy of the GNU General Public License
27966 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
27970 +#include "value.h"
27971 +#include "exceptions.h"
27972 +#include "python-internal.h"
27973 +#include "charset.h"
27974 +#include "gdbcmd.h"
27975 +#include "cli/cli-decode.h"
27976 +#include "completer.h"
27978 +/* Parameter constants and their values. */
27979 +struct parm_constant
27985 +struct parm_constant parm_constants[] =
27987 + { "PARAM_BOOLEAN", var_boolean },
27988 + { "PARAM_AUTO_BOOLEAN", var_auto_boolean },
27989 + { "PARAM_UINTEGER", var_uinteger },
27990 + { "PARAM_INTEGER", var_integer },
27991 + { "PARAM_STRING", var_string },
27992 + { "PARAM_STRING_NOESCAPE", var_string_noescape },
27993 + { "PARAM_OPTIONAL_FILENAME", var_optional_filename },
27994 + { "PARAM_FILENAME", var_filename },
27995 + { "PARAM_ZINTEGER", var_zinteger },
27996 + { "PARAM_ENUM", var_enum },
28000 +/* A union that can hold anything described by enum var_types. */
28001 +union parmpy_variable
28003 + /* Hold an integer value, for boolean and integer types. */
28006 + /* Hold an auto_boolean. */
28007 + enum auto_boolean autoboolval;
28009 + /* Hold an unsigned integer value, for uinteger. */
28010 + unsigned int uintval;
28012 + /* Hold a string, for the various string types. */
28015 + /* Hold a string, for enums. */
28016 + const char *cstringval;
28019 +/* A gdb parameter. */
28020 +struct parmpy_object
28024 + /* The type of the parameter. */
28025 + enum var_types type;
28027 + /* The value of the parameter. */
28028 + union parmpy_variable value;
28030 + /* For an enum command, the possible values. The vector is
28031 + allocated with xmalloc, as is each element. It is
28032 + NULL-terminated. */
28033 + const char **enumeration;
28036 +typedef struct parmpy_object parmpy_object;
28038 +static PyTypeObject parmpy_object_type;
28040 +/* Some handy string constants. */
28041 +static PyObject *set_doc_cst;
28042 +static PyObject *show_doc_cst;
28046 +/* Get an attribute. */
28048 +get_attr (PyObject *obj, PyObject *attr_name)
28050 + if (PyString_Check (attr_name)
28051 + && ! strcmp (PyString_AsString (attr_name), "value"))
28053 + parmpy_object *self = (parmpy_object *) obj;
28054 + return gdbpy_parameter_value (self->type, &self->value);
28057 + return PyObject_GenericGetAttr (obj, attr_name);
28060 +/* Set a parameter value from a Python value. Return 0 on success, -1
28063 +set_parameter_value (parmpy_object *self, PyObject *value)
28067 + switch (self->type)
28070 + case var_string_noescape:
28071 + case var_optional_filename:
28072 + case var_filename:
28073 + if (! gdbpy_is_string (value)
28074 + && (self->type == var_filename
28075 + || value != Py_None))
28077 + PyErr_SetString (PyExc_RuntimeError, "string required");
28080 + if (self->value.stringval)
28081 + xfree (self->value.stringval);
28082 + if (value == Py_None)
28084 + if (self->type == var_optional_filename)
28085 + self->value.stringval = xstrdup ("");
28087 + self->value.stringval = NULL;
28090 + self->value.stringval = python_string_to_host_string (value);
28098 + if (! gdbpy_is_string (value))
28100 + PyErr_SetString (PyExc_RuntimeError, "string required");
28104 + str = python_string_to_host_string (value);
28105 + for (i = 0; self->enumeration[i]; ++i)
28106 + if (! strcmp (self->enumeration[i], str))
28109 + if (! self->enumeration[i])
28111 + PyErr_SetString (PyExc_RuntimeError,
28112 + "value must be member of enumeration");
28115 + self->value.cstringval = self->enumeration[i];
28119 + case var_boolean:
28120 + if (! PyBool_Check (value))
28122 + PyErr_SetString (PyExc_RuntimeError, "boolean required");
28125 + cmp = PyObject_IsTrue (value);
28128 + self->value.intval = cmp;
28131 + case var_auto_boolean:
28132 + if (! PyBool_Check (value) && value != Py_None)
28134 + PyErr_SetString (PyExc_RuntimeError,
28135 + "boolean or None required");
28139 + if (value == Py_None)
28140 + self->value.autoboolval = AUTO_BOOLEAN_AUTO;
28143 + cmp = PyObject_IsTrue (value);
28147 + self->value.autoboolval = AUTO_BOOLEAN_TRUE;
28149 + self->value.autoboolval = AUTO_BOOLEAN_FALSE;
28154 + case var_integer:
28155 + case var_zinteger:
28156 + case var_uinteger:
28161 + if (! PyInt_Check (value))
28163 + PyErr_SetString (PyExc_RuntimeError, "value must be integer");
28167 + l = PyInt_AsLong (value);
28168 + if (self->type == var_uinteger)
28170 + ok = (l >= 0 && l <= UINT_MAX);
28174 + else if (self->type == var_integer)
28176 + ok = (l >= INT_MIN && l <= INT_MAX);
28181 + ok = (l >= INT_MIN && l <= INT_MAX);
28185 + PyErr_SetString (PyExc_RuntimeError, "range exceeded");
28189 + self->value.intval = (int) l;
28194 + PyErr_SetString (PyExc_RuntimeError, "programmer error: unhandled type");
28201 +/* Set an attribute. */
28203 +set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
28205 + if (PyString_Check (attr_name)
28206 + && ! strcmp (PyString_AsString (attr_name), "value"))
28210 + PyErr_SetString (PyExc_RuntimeError,
28211 + "cannot delete a parameter's value");
28214 + return set_parameter_value ((parmpy_object *) obj, val);
28217 + return PyObject_GenericSetAttr (obj, attr_name, val);
28222 +/* A helper function that dispatches to the appropriate add_setshow
28225 +add_setshow_generic (int parmclass, enum command_class cmdclass,
28226 + char *cmd_name, parmpy_object *self,
28227 + char *set_doc, char *show_doc, char *help_doc,
28228 + struct cmd_list_element **set_list,
28229 + struct cmd_list_element **show_list)
28231 + switch (parmclass)
28233 + case var_boolean:
28234 + add_setshow_boolean_cmd (cmd_name, cmdclass, &self->value.intval,
28235 + set_doc, show_doc, help_doc,
28236 + NULL, NULL, set_list, show_list);
28239 + case var_auto_boolean:
28240 + add_setshow_auto_boolean_cmd (cmd_name, cmdclass,
28241 + &self->value.autoboolval,
28242 + set_doc, show_doc, help_doc,
28243 + NULL, NULL, set_list, show_list);
28246 + case var_uinteger:
28247 + add_setshow_uinteger_cmd (cmd_name, cmdclass, &self->value.uintval,
28248 + set_doc, show_doc, help_doc,
28249 + NULL, NULL, set_list, show_list);
28252 + case var_integer:
28253 + add_setshow_integer_cmd (cmd_name, cmdclass, &self->value.intval,
28254 + set_doc, show_doc, help_doc,
28255 + NULL, NULL, set_list, show_list);
28259 + add_setshow_string_cmd (cmd_name, cmdclass, &self->value.stringval,
28260 + set_doc, show_doc, help_doc,
28261 + NULL, NULL, set_list, show_list);
28264 + case var_string_noescape:
28265 + add_setshow_string_noescape_cmd (cmd_name, cmdclass,
28266 + &self->value.stringval,
28267 + set_doc, show_doc, help_doc,
28268 + NULL, NULL, set_list, show_list);
28271 + case var_optional_filename:
28272 + add_setshow_optional_filename_cmd (cmd_name, cmdclass,
28273 + &self->value.stringval,
28274 + set_doc, show_doc, help_doc,
28275 + NULL, NULL, set_list, show_list);
28278 + case var_filename:
28279 + add_setshow_filename_cmd (cmd_name, cmdclass, &self->value.stringval,
28280 + set_doc, show_doc, help_doc,
28281 + NULL, NULL, set_list, show_list);
28284 + case var_zinteger:
28285 + add_setshow_zinteger_cmd (cmd_name, cmdclass, &self->value.intval,
28286 + set_doc, show_doc, help_doc,
28287 + NULL, NULL, set_list, show_list);
28291 + add_setshow_enum_cmd (cmd_name, cmdclass, self->enumeration,
28292 + &self->value.cstringval,
28293 + set_doc, show_doc, help_doc,
28294 + NULL, NULL, set_list, show_list);
28295 + /* Initialize the value, just in case. */
28296 + self->value.cstringval = self->enumeration[0];
28301 +/* A helper which computes enum values. Returns 1 on success, 0 on
28304 +compute_enum_values (parmpy_object *self, PyObject *enum_values)
28306 + Py_ssize_t size, i;
28308 + if (! enum_values)
28310 + PyErr_SetString (PyExc_RuntimeError,
28311 + "enumeration required for PARAM_ENUM");
28315 + if (! PySequence_Check (enum_values))
28317 + PyErr_SetString (PyExc_RuntimeError, "enumeration is not a sequence");
28321 + size = PySequence_Size (enum_values);
28326 + PyErr_SetString (PyExc_RuntimeError, "empty enumeration");
28330 + self->enumeration = xmalloc ((size + 1) * sizeof (char *));
28331 + memset (self->enumeration, 0, (size + 1) * sizeof (char *));
28333 + for (i = 0; i < size; ++i)
28335 + PyObject *item = PySequence_GetItem (enum_values, i);
28338 + if (! gdbpy_is_string (item))
28340 + PyErr_SetString (PyExc_RuntimeError, "enumeration item not a string");
28343 + self->enumeration[i] = python_string_to_host_string (item);
28349 +/* A helper function which returns a documentation string for an
28352 +get_doc_string (PyObject *object, PyObject *attr)
28354 + char *result = NULL;
28355 + if (PyObject_HasAttr (object, attr))
28357 + PyObject *ds_obj = PyObject_GetAttr (object, attr);
28358 + if (ds_obj && gdbpy_is_string (ds_obj))
28359 + result = python_string_to_host_string (ds_obj);
28362 + result = xstrdup ("This command is not documented.");
28366 +/* Object initializer; sets up gdb-side structures for command.
28368 + Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM])
28370 + NAME is the name of the parameter. It may consist of multiple
28371 + words, in which case the final word is the name of the new command,
28372 + and earlier words must be prefix commands.
28374 + CMDCLASS is the kind of command. It should be one of the COMMAND_*
28375 + constants defined in the gdb module.
28377 + PARMCLASS is the type of the parameter. It should be one of the
28378 + PARAM_* constants defined in the gdb module.
28380 + If PARMCLASS is PARAM_ENUM, then the final argument should be a
28381 + collection of strings. These strings are the valid values for this
28384 + The documentation for the parameter is taken from the doc string
28385 + for the python class.
28389 +parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
28391 + parmpy_object *obj = (parmpy_object *) self;
28393 + char *set_doc, *show_doc, *doc;
28395 + int parmclass, cmdtype;
28396 + PyObject *enum_values = NULL;
28397 + struct cmd_list_element *cmd_list;
28398 + struct cmd_list_element **set_list, **show_list;
28399 + volatile struct gdb_exception except;
28401 + if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
28405 + if (cmdtype != no_class && cmdtype != class_run
28406 + && cmdtype != class_vars && cmdtype != class_stack
28407 + && cmdtype != class_files && cmdtype != class_support
28408 + && cmdtype != class_info && cmdtype != class_breakpoint
28409 + && cmdtype != class_trace && cmdtype != class_obscure
28410 + && cmdtype != class_maintenance)
28412 + PyErr_Format (PyExc_RuntimeError, "invalid command class argument");
28416 + if (parmclass != var_boolean && parmclass != var_auto_boolean
28417 + && parmclass != var_uinteger && parmclass != var_integer
28418 + && parmclass != var_string && parmclass != var_string_noescape
28419 + && parmclass != var_optional_filename && parmclass != var_filename
28420 + && parmclass != var_zinteger && parmclass != var_enum)
28422 + PyErr_SetString (PyExc_RuntimeError, "invalid parameter class argument");
28426 + if (enum_values && parmclass != var_enum)
28428 + PyErr_SetString (PyExc_RuntimeError,
28429 + "only PARAM_ENUM accepts a fourth argument");
28432 + if (parmclass == var_enum)
28434 + if (! compute_enum_values (obj, enum_values))
28438 + obj->type = (enum var_types) parmclass;
28439 + memset (&obj->value, 0, sizeof (obj->value));
28440 + obj->enumeration = NULL;
28442 + cmd_name = gdbpy_parse_command_name (name, &set_list, &setlist);
28445 + xfree (cmd_name);
28446 + cmd_name = gdbpy_parse_command_name (name, &show_list, &showlist);
28450 + /* FIXME: there is no way to register a destructor function for
28451 + set/show commands. So, these are leaked. */
28452 + set_doc = get_doc_string (self, set_doc_cst);
28453 + show_doc = get_doc_string (self, show_doc_cst);
28454 + doc = get_doc_string (self, gdbpy_doc_cst);
28456 + Py_INCREF (self);
28458 + TRY_CATCH (except, RETURN_MASK_ALL)
28460 + add_setshow_generic (parmclass, (enum command_class) cmdtype,
28462 + set_doc, show_doc,
28463 + doc, set_list, show_list);
28465 + if (except.reason < 0)
28467 + xfree (cmd_name);
28469 + xfree (show_doc);
28471 + Py_DECREF (self);
28472 + PyErr_Format (except.reason == RETURN_QUIT
28473 + ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
28474 + "%s", except.message);
28482 +/* Initialize the 'parameters' module. */
28484 +gdbpy_initialize_parameters (void)
28488 + if (PyType_Ready (&parmpy_object_type) < 0)
28491 + set_doc_cst = PyString_FromString ("set_doc");
28492 + if (! set_doc_cst)
28494 + show_doc_cst = PyString_FromString ("show_doc");
28495 + if (! show_doc_cst)
28498 + for (i = 0; parm_constants[i].name; ++i)
28500 + if (PyModule_AddIntConstant (gdb_module,
28501 + parm_constants[i].name,
28502 + parm_constants[i].value) < 0)
28506 + Py_INCREF (&parmpy_object_type);
28507 + PyModule_AddObject (gdb_module, "Parameter",
28508 + (PyObject *) &parmpy_object_type);
28513 +static PyTypeObject parmpy_object_type =
28515 + PyObject_HEAD_INIT (NULL)
28517 + "gdb.Parameter", /*tp_name*/
28518 + sizeof (parmpy_object), /*tp_basicsize*/
28519 + 0, /*tp_itemsize*/
28520 + 0, /*tp_dealloc*/
28522 + 0, /*tp_getattr*/
28523 + 0, /*tp_setattr*/
28524 + 0, /*tp_compare*/
28526 + 0, /*tp_as_number*/
28527 + 0, /*tp_as_sequence*/
28528 + 0, /*tp_as_mapping*/
28532 + get_attr, /*tp_getattro*/
28533 + set_attr, /*tp_setattro*/
28534 + 0, /*tp_as_buffer*/
28535 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
28536 + "GDB parameter object", /* tp_doc */
28537 + 0, /* tp_traverse */
28538 + 0, /* tp_clear */
28539 + 0, /* tp_richcompare */
28540 + 0, /* tp_weaklistoffset */
28542 + 0, /* tp_iternext */
28543 + 0, /* tp_methods */
28544 + 0, /* tp_members */
28545 + 0, /* tp_getset */
28548 + 0, /* tp_descr_get */
28549 + 0, /* tp_descr_set */
28550 + 0, /* tp_dictoffset */
28551 + parmpy_init, /* tp_init */
28552 + 0, /* tp_alloc */
28553 + PyType_GenericNew /* tp_new */
28555 diff --git a/gdb/python/python-symbol.c b/gdb/python/python-symbol.c
28556 new file mode 100644
28557 index 0000000..c7fda5c
28559 +++ b/gdb/python/python-symbol.c
28561 +/* Python interface to symbols.
28563 + Copyright (C) 2008 Free Software Foundation, Inc.
28565 + This file is part of GDB.
28567 + This program is free software; you can redistribute it and/or modify
28568 + it under the terms of the GNU General Public License as published by
28569 + the Free Software Foundation; either version 3 of the License, or
28570 + (at your option) any later version.
28572 + This program is distributed in the hope that it will be useful,
28573 + but WITHOUT ANY WARRANTY; without even the implied warranty of
28574 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28575 + GNU General Public License for more details.
28577 + You should have received a copy of the GNU General Public License
28578 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
28581 +#include "block.h"
28582 +#include "exceptions.h"
28583 +#include "frame.h"
28584 +#include "symtab.h"
28585 +#include "python-internal.h"
28589 + struct symbol *symbol;
28594 +sympy_str (PyObject *self)
28598 + PyObject *result;
28600 + ret = asprintf (&s, "symbol for %s",
28601 + SYMBOL_PRINT_NAME (((symbol_object *) self)->symbol));
28605 + result = PyString_FromString (s);
28612 +sympy_get_value (PyObject *self, void *closure)
28614 + symbol_object *self_sym = (symbol_object *) self;
28616 + switch (SYMBOL_CLASS (self_sym->symbol))
28619 + return block_to_block_object (SYMBOL_BLOCK_VALUE (self_sym->symbol));
28622 + PyErr_SetString (PyExc_NotImplementedError,
28623 + "Symbol type not yet supported in Python scripts.");
28628 +sympy_get_symtab (PyObject *self, void *closure)
28630 + symbol_object *self_sym = (symbol_object *) self;
28632 + return symtab_to_symtab_object (SYMBOL_SYMTAB (self_sym->symbol));
28636 +sympy_get_name (PyObject *self, void *closure)
28638 + symbol_object *self_sym = (symbol_object *) self;
28640 + return PyString_FromString (SYMBOL_NATURAL_NAME (self_sym->symbol));
28644 +sympy_get_linkage_name (PyObject *self, void *closure)
28646 + symbol_object *self_sym = (symbol_object *) self;
28648 + return PyString_FromString (SYMBOL_LINKAGE_NAME (self_sym->symbol));
28652 +sympy_get_print_name (PyObject *self, void *closure)
28654 + symbol_object *self_sym = (symbol_object *) self;
28656 + return PyString_FromString (SYMBOL_PRINT_NAME (self_sym->symbol));
28660 +sympy_get_addr_class (PyObject *self, void *closure)
28662 + symbol_object *self_sym = (symbol_object *) self;
28664 + return PyInt_FromLong (SYMBOL_CLASS (self_sym->symbol));
28668 +sympy_is_argument (PyObject *self, void *closure)
28670 + symbol_object *self_sym = (symbol_object *) self;
28672 + return PyBool_FromLong (SYMBOL_IS_ARGUMENT (self_sym->symbol));
28676 +sympy_is_constant (PyObject *self, void *closure)
28678 + symbol_object *self_sym = (symbol_object *) self;
28679 + enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28681 + return PyBool_FromLong (class == LOC_CONST || class == LOC_CONST_BYTES);
28685 +sympy_is_function (PyObject *self, void *closure)
28687 + symbol_object *self_sym = (symbol_object *) self;
28688 + enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28690 + return PyBool_FromLong (class == LOC_BLOCK);
28694 +sympy_is_variable (PyObject *self, void *closure)
28696 + symbol_object *self_sym = (symbol_object *) self;
28697 + enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28699 + return PyBool_FromLong (!SYMBOL_IS_ARGUMENT (self_sym->symbol)
28700 + && (class == LOC_LOCAL || class == LOC_REGISTER || class == LOC_STATIC
28701 + || class == LOC_COMPUTED || class == LOC_OPTIMIZED_OUT));
28705 +symbol_to_symbol_object (struct symbol *sym)
28707 + symbol_object *sym_obj;
28709 + sym_obj = PyObject_New (symbol_object, &symbol_object_type);
28710 + if (sym_obj == NULL)
28712 + PyErr_SetString (PyExc_MemoryError, "Could not allocate symbol object.");
28716 + sym_obj->symbol = sym;
28718 + return (PyObject *) sym_obj;
28722 +symbol_object_to_symbol (PyObject *obj)
28724 + if (! PyObject_TypeCheck (obj, &symbol_object_type))
28726 + return ((symbol_object *) obj)->symbol;
28729 +/* Implementation of
28730 + gdb.lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)
28731 + A tuple with 2 elements is always returned. The first is the symbol
28732 + object or None, the second is a boolean with the value of
28733 + is_a_field_of_this (see comment in lookup_symbol_in_language). */
28735 +PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
28737 + int domain = VAR_DOMAIN, is_a_field_of_this = 0;
28738 + const char *name;
28739 + static char *keywords[] = { "name", "block", "domain", NULL };
28740 + struct symbol *symbol;
28741 + PyObject *block_obj = NULL, *ret_tuple, *sym_obj, *bool_obj;
28742 + struct block *block = NULL;
28744 + if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
28745 + &block_object_type, &block_obj, &domain))
28749 + block = block_object_to_block (block_obj);
28752 + struct frame_info *selected_frame;
28753 + volatile struct gdb_exception except;
28755 + TRY_CATCH (except, RETURN_MASK_ALL)
28757 + selected_frame = get_selected_frame (_("No frame selected."));
28758 + block = block_for_pc (get_frame_address_in_block (selected_frame));
28760 + GDB_PY_HANDLE_EXCEPTION (except);
28763 + symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
28765 + ret_tuple = PyTuple_New (2);
28768 + PyErr_SetString (PyExc_MemoryError, "Could not allocate tuple object.");
28774 + sym_obj = symbol_to_symbol_object (symbol);
28777 + Py_DECREF (ret_tuple);
28783 + sym_obj = Py_None;
28784 + Py_INCREF (Py_None);
28786 + PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
28788 + bool_obj = is_a_field_of_this? Py_True : Py_False;
28789 + Py_INCREF (bool_obj);
28790 + PyTuple_SET_ITEM (ret_tuple, 1, bool_obj);
28792 + return ret_tuple;
28796 +gdbpy_initialize_symbols (void)
28798 + symbol_object_type.tp_new = PyType_GenericNew;
28799 + if (PyType_Ready (&symbol_object_type) < 0)
28802 + /* FIXME: These would probably be best exposed as class attributes of Symbol,
28803 + but I don't know how to do it except by messing with the type's dictionary.
28804 + That seems too messy. */
28805 + /* FIXME 2: Some of these were removed from GDB since I first wrote this code,
28806 + so it's probably a good idea not to expose them to Python. */
28807 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNDEF", LOC_UNDEF);
28808 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST", LOC_CONST);
28809 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_STATIC", LOC_STATIC);
28810 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGISTER", LOC_REGISTER);
28811 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_ARG", LOC_ARG);
28812 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REF_ARG", LOC_REF_ARG);
28813 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LOCAL", LOC_LOCAL);
28814 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_TYPEDEF", LOC_TYPEDEF);
28815 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_LABEL", LOC_LABEL);
28816 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_BLOCK", LOC_BLOCK);
28817 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_CONST_BYTES",
28818 + LOC_CONST_BYTES);
28819 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_UNRESOLVED", LOC_UNRESOLVED);
28820 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_OPTIMIZED_OUT",
28821 + LOC_OPTIMIZED_OUT);
28822 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMPUTED", LOC_COMPUTED);
28823 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
28824 + LOC_REGPARM_ADDR);
28825 + PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN", UNDEF_DOMAIN);
28826 + PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN", VAR_DOMAIN);
28827 + PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN", STRUCT_DOMAIN);
28828 + PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN", LABEL_DOMAIN);
28829 + PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN",
28830 + VARIABLES_DOMAIN);
28831 + PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
28832 + FUNCTIONS_DOMAIN);
28833 + PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN", TYPES_DOMAIN);
28835 + Py_INCREF (&symbol_object_type);
28836 + PyModule_AddObject (gdb_module, "Symbol", (PyObject *) &symbol_object_type);
28841 +static PyGetSetDef symbol_object_getset[] = {
28842 + { "value", sympy_get_value, NULL, "Value of the symbol.", NULL },
28843 + { "symtab", sympy_get_symtab, NULL,
28844 + "Symbol table in which the symbol appears.", NULL },
28845 + { "name", sympy_get_name, NULL,
28846 + "Name of the symbol, as it appears in the source code.", NULL },
28847 + { "linkage_name", sympy_get_linkage_name, NULL,
28848 + "Name of the symbol, as used by the linker (i.e., may be mangled).", NULL },
28849 + { "print_name", sympy_get_print_name, NULL,
28850 + "Name of the symbol in a form suitable for output.\n\
28851 +This is either name or linkage_name, depending on whether the user asked GDB\n\
28852 +to display demangled or mangled names.", NULL },
28853 + { "addr_class", sympy_get_addr_class, NULL, "Address class of the symbol." },
28854 + { "is_argument", sympy_is_argument, NULL,
28855 + "True if the symbol is an argument of a function." },
28856 + { "is_constant", sympy_is_constant, NULL,
28857 + "True if the symbol is a constant." },
28858 + { "is_function", sympy_is_function, NULL,
28859 + "True if the symbol is a function or method." },
28860 + { "is_variable", sympy_is_variable, NULL,
28861 + "True if the symbol is a variable." },
28862 + { NULL } /* Sentinel */
28865 +PyTypeObject symbol_object_type = {
28866 + PyObject_HEAD_INIT (NULL)
28868 + "gdb.Symbol", /*tp_name*/
28869 + sizeof (symbol_object), /*tp_basicsize*/
28870 + 0, /*tp_itemsize*/
28871 + 0, /*tp_dealloc*/
28873 + 0, /*tp_getattr*/
28874 + 0, /*tp_setattr*/
28875 + 0, /*tp_compare*/
28877 + 0, /*tp_as_number*/
28878 + 0, /*tp_as_sequence*/
28879 + 0, /*tp_as_mapping*/
28882 + sympy_str, /*tp_str*/
28883 + 0, /*tp_getattro*/
28884 + 0, /*tp_setattro*/
28885 + 0, /*tp_as_buffer*/
28886 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
28887 + "GDB symbol object", /* tp_doc */
28888 + 0, /* tp_traverse */
28889 + 0, /* tp_clear */
28890 + 0, /* tp_richcompare */
28891 + 0, /* tp_weaklistoffset */
28893 + 0, /* tp_iternext */
28894 + 0, /* tp_methods */
28895 + 0, /* tp_members */
28896 + symbol_object_getset /* tp_getset */
28898 diff --git a/gdb/python/python-symtab.c b/gdb/python/python-symtab.c
28899 new file mode 100644
28900 index 0000000..a48c38c
28902 +++ b/gdb/python/python-symtab.c
28904 +/* Python interface to symbol tables.
28906 + Copyright (C) 2008 Free Software Foundation, Inc.
28908 + This file is part of GDB.
28910 + This program is free software; you can redistribute it and/or modify
28911 + it under the terms of the GNU General Public License as published by
28912 + the Free Software Foundation; either version 3 of the License, or
28913 + (at your option) any later version.
28915 + This program is distributed in the hope that it will be useful,
28916 + but WITHOUT ANY WARRANTY; without even the implied warranty of
28917 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28918 + GNU General Public License for more details.
28920 + You should have received a copy of the GNU General Public License
28921 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
28924 +#include "charset.h"
28925 +#include "symtab.h"
28926 +#include "source.h"
28927 +#include "python-internal.h"
28931 + struct symtab *symtab;
28934 +static PyTypeObject symtab_object_type;
28938 + symtab_object *symtab;
28939 + struct symtab_and_line *sal;
28942 +static PyTypeObject sal_object_type;
28946 +stpy_str (PyObject *self)
28950 + PyObject *result;
28952 + ret = asprintf (&s, "symbol table for %s",
28953 + ((symtab_object *) self)->symtab->filename);
28957 + result = PyString_FromString (s);
28964 +stpy_get_filename (PyObject *self, void *closure)
28966 + symtab_object *self_symtab = (symtab_object *) self;
28967 + PyObject *str_obj;
28969 + /* FIXME: Can symtab->filename really be NULL? */
28970 + if (self_symtab->symtab->filename)
28971 + str_obj = PyString_Decode (self_symtab->symtab->filename,
28972 + strlen (self_symtab->symtab->filename),
28973 + host_charset (), NULL);
28976 + str_obj = Py_None;
28977 + Py_INCREF (Py_None);
28984 +stpy_fullname (PyObject *self, PyObject *args)
28988 + fullname = symtab_to_fullname (((symtab_object *) self)->symtab);
28990 + return PyString_Decode (fullname, strlen (fullname), host_charset (), NULL);
28996 +salpy_str (PyObject *self)
28999 + char *s, *filename;
29000 + sal_object *sal_obj;
29001 + PyObject *result;
29003 + sal_obj = (sal_object *) self;
29004 + filename = (sal_obj->symtab == (symtab_object *) Py_None)? "<unknown>" :
29005 + sal_obj->symtab->symtab->filename;
29006 + ret = asprintf (&s, "symbol and line for %s, line %d", filename,
29007 + sal_obj->sal->line);
29011 + result = PyString_FromString (s);
29018 +salpy_get_pc (PyObject *self, void *closure)
29020 + return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->pc);
29024 +salpy_get_line (PyObject *self, void *closure)
29026 + return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->line);
29030 +salpy_get_symtab (PyObject *self, void *closure)
29032 + sal_object *self_sal = (sal_object *) self;
29034 + Py_INCREF (self_sal->symtab);
29036 + return (PyObject *) self_sal->symtab;
29040 +salpy_dealloc (PyObject *self)
29042 + sal_object *self_sal = (sal_object *) self;
29044 + Py_DECREF (self_sal->symtab);
29045 + xfree (self_sal->sal);
29046 + self_sal->ob_type->tp_free (self);
29050 +symtab_and_line_to_sal_object (struct symtab_and_line sal)
29052 + sal_object *sal_obj;
29053 + symtab_object *symtab_obj;
29055 + sal_obj = PyObject_New (sal_object, &sal_object_type);
29056 + if (sal_obj == NULL)
29058 + PyErr_SetString (PyExc_MemoryError,
29059 + "Could not allocate Symtab_and_line object.");
29065 + symtab_obj = (symtab_object *) symtab_to_symtab_object (sal.symtab);
29066 + if (symtab_obj == NULL)
29068 + Py_DECREF (sal_obj);
29072 + symtab_obj->symtab = sal.symtab;
29076 + symtab_obj = (symtab_object *) Py_None;
29077 + Py_INCREF (Py_None);
29080 + sal_obj->sal = (struct symtab_and_line *)
29081 + xmalloc (sizeof (struct symtab_and_line));
29082 + *(sal_obj->sal) = sal;
29083 + sal_obj->symtab = symtab_obj;
29085 + return (PyObject *) sal_obj;
29089 +symtab_to_symtab_object (struct symtab *symtab)
29091 + symtab_object *symtab_obj;
29093 + symtab_obj = PyObject_New (symtab_object, &symtab_object_type);
29094 + if (symtab_obj == NULL)
29096 + PyErr_SetString (PyExc_MemoryError,
29097 + "Could not allocate Symtab object.");
29102 + symtab_obj->symtab = symtab;
29104 + return (PyObject *) symtab_obj;
29108 +gdbpy_initialize_symtabs (void)
29110 + symtab_object_type.tp_new = PyType_GenericNew;
29111 + if (PyType_Ready (&symtab_object_type) < 0)
29114 + sal_object_type.tp_new = PyType_GenericNew;
29115 + if (PyType_Ready (&sal_object_type) < 0)
29118 + Py_INCREF (&symtab_object_type);
29119 + PyModule_AddObject (gdb_module, "Symtab", (PyObject *) &symtab_object_type);
29121 + Py_INCREF (&sal_object_type);
29122 + PyModule_AddObject (gdb_module, "Symtab_and_line",
29123 + (PyObject *) &sal_object_type);
29128 +static PyGetSetDef symtab_object_getset[] = {
29129 + { "filename", stpy_get_filename, NULL,
29130 + "The symbol table's source filename.", NULL },
29131 + {NULL} /* Sentinel */
29134 +static PyMethodDef symtab_object_methods[] = {
29135 + { "fullname", stpy_fullname, METH_NOARGS,
29136 + "Return the symtab's full source filename." },
29137 + {NULL} /* Sentinel */
29140 +static PyTypeObject symtab_object_type = {
29141 + PyObject_HEAD_INIT (NULL)
29143 + "gdb.Symtab", /*tp_name*/
29144 + sizeof (symtab_object), /*tp_basicsize*/
29145 + 0, /*tp_itemsize*/
29146 + 0, /*tp_dealloc*/
29148 + 0, /*tp_getattr*/
29149 + 0, /*tp_setattr*/
29150 + 0, /*tp_compare*/
29152 + 0, /*tp_as_number*/
29153 + 0, /*tp_as_sequence*/
29154 + 0, /*tp_as_mapping*/
29157 + stpy_str, /*tp_str*/
29158 + 0, /*tp_getattro*/
29159 + 0, /*tp_setattro*/
29160 + 0, /*tp_as_buffer*/
29161 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
29162 + "GDB symtab object", /* tp_doc */
29163 + 0, /* tp_traverse */
29164 + 0, /* tp_clear */
29165 + 0, /* tp_richcompare */
29166 + 0, /* tp_weaklistoffset */
29168 + 0, /* tp_iternext */
29169 + symtab_object_methods, /* tp_methods */
29170 + 0, /* tp_members */
29171 + symtab_object_getset /* tp_getset */
29174 +static PyGetSetDef sal_object_getset[] = {
29175 + { "symtab", salpy_get_symtab, NULL, "Symtab object.", NULL },
29176 + { "pc", salpy_get_pc, NULL, "Return the symtab_and_line's pc.", NULL },
29177 + { "line", salpy_get_line, NULL,
29178 + "Return the symtab_and_line's line.", NULL },
29179 + {NULL} /* Sentinel */
29182 +static PyTypeObject sal_object_type = {
29183 + PyObject_HEAD_INIT (NULL)
29185 + "gdb.Symtab_and_line", /*tp_name*/
29186 + sizeof (sal_object), /*tp_basicsize*/
29187 + 0, /*tp_itemsize*/
29188 + salpy_dealloc, /*tp_dealloc*/
29190 + 0, /*tp_getattr*/
29191 + 0, /*tp_setattr*/
29192 + 0, /*tp_compare*/
29194 + 0, /*tp_as_number*/
29195 + 0, /*tp_as_sequence*/
29196 + 0, /*tp_as_mapping*/
29199 + salpy_str, /*tp_str*/
29200 + 0, /*tp_getattro*/
29201 + 0, /*tp_setattro*/
29202 + 0, /*tp_as_buffer*/
29203 + Py_TPFLAGS_DEFAULT, /*tp_flags*/
29204 + "GDB symtab_and_line object", /* tp_doc */
29205 + 0, /* tp_traverse */
29206 + 0, /* tp_clear */
29207 + 0, /* tp_richcompare */
29208 + 0, /* tp_weaklistoffset */
29210 + 0, /* tp_iternext */
29211 + 0, /* tp_methods */
29212 + 0, /* tp_members */
29213 + sal_object_getset /* tp_getset */
29215 diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
29216 new file mode 100644
29217 index 0000000..772a011
29219 +++ b/gdb/python/python-type.c
29221 +/* Python interface to types.
29223 + Copyright (C) 2008, 2009 Free Software Foundation, Inc.
29225 + This file is part of GDB.
29227 + This program is free software; you can redistribute it and/or modify
29228 + it under the terms of the GNU General Public License as published by
29229 + the Free Software Foundation; either version 3 of the License, or
29230 + (at your option) any later version.
29232 + This program is distributed in the hope that it will be useful,
29233 + but WITHOUT ANY WARRANTY; without even the implied warranty of
29234 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29235 + GNU General Public License for more details.
29237 + You should have received a copy of the GNU General Public License
29238 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
29241 +#include "value.h"
29242 +#include "exceptions.h"
29243 +#include "python-internal.h"
29244 +#include "charset.h"
29245 +#include "gdbtypes.h"
29246 +#include "cp-support.h"
29247 +#include "demangle.h"
29248 +#include "objfiles.h"
29249 +#include "gdb_assert.h"
29251 +typedef struct pyty_type_object
29254 + struct type *type;
29256 + /* If a Type object is associated with an objfile, it is kept on a
29257 + doubly-linked list, rooted in the objfile. This lets us copy the
29258 + underlying struct type when the objfile is deleted. */
29259 + struct pyty_type_object *prev;
29260 + struct pyty_type_object *next;
29263 +static PyTypeObject type_object_type;
29265 +/* A Field object. */
29266 +typedef struct pyty_field_object
29270 + /* Dictionary holding our attributes. */
29274 +static PyTypeObject field_object_type;
29276 +/* This is used to initialize various gdb.TYPE_ constants. */
29280 + enum type_code code;
29282 + const char *name;
29285 +#define ENTRY(X) { X, #X }
29287 +static struct pyty_code pyty_codes[] =
29289 + ENTRY (TYPE_CODE_PTR),
29290 + ENTRY (TYPE_CODE_ARRAY),
29291 + ENTRY (TYPE_CODE_STRUCT),
29292 + ENTRY (TYPE_CODE_UNION),
29293 + ENTRY (TYPE_CODE_ENUM),
29294 + ENTRY (TYPE_CODE_FLAGS),
29295 + ENTRY (TYPE_CODE_FUNC),
29296 + ENTRY (TYPE_CODE_INT),
29297 + ENTRY (TYPE_CODE_FLT),
29298 + ENTRY (TYPE_CODE_VOID),
29299 + ENTRY (TYPE_CODE_SET),
29300 + ENTRY (TYPE_CODE_RANGE),
29301 + ENTRY (TYPE_CODE_STRING),
29302 + ENTRY (TYPE_CODE_BITSTRING),
29303 + ENTRY (TYPE_CODE_ERROR),
29304 + ENTRY (TYPE_CODE_METHOD),
29305 + ENTRY (TYPE_CODE_METHODPTR),
29306 + ENTRY (TYPE_CODE_MEMBERPTR),
29307 + ENTRY (TYPE_CODE_REF),
29308 + ENTRY (TYPE_CODE_CHAR),
29309 + ENTRY (TYPE_CODE_BOOL),
29310 + ENTRY (TYPE_CODE_COMPLEX),
29311 + ENTRY (TYPE_CODE_TYPEDEF),
29312 + ENTRY (TYPE_CODE_TEMPLATE),
29313 + ENTRY (TYPE_CODE_TEMPLATE_ARG),
29314 + ENTRY (TYPE_CODE_NAMESPACE),
29315 + ENTRY (TYPE_CODE_DECFLOAT),
29316 + ENTRY (TYPE_CODE_INTERNAL_FUNCTION),
29317 + { TYPE_CODE_UNDEF, NULL }
29323 +field_dealloc (PyObject *obj)
29325 + field_object *f = (field_object *) obj;
29326 + Py_XDECREF (f->dict);
29332 + field_object *result = PyObject_New (field_object, &field_object_type);
29335 + result->dict = PyDict_New ();
29336 + if (!result->dict)
29338 + Py_DECREF (result);
29342 + return (PyObject *) result;
29347 +/* Return the code for this type. */
29349 +typy_code (PyObject *self, PyObject *args)
29351 + struct type *type = ((type_object *) self)->type;
29352 + return PyInt_FromLong (TYPE_CODE (type));
29355 +/* Helper function for typy_fields which converts a single field to a
29356 + dictionary. Returns NULL on error. */
29358 +convert_field (struct type *type, int field)
29360 + PyObject *result = field_new ();
29366 + if (!field_is_static (&TYPE_FIELD (type, field)))
29368 + arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
29372 + if (PyObject_SetAttrString (result, "bitpos", arg) < 0)
29376 + if (TYPE_FIELD_NAME (type, field))
29377 + arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
29385 + if (PyObject_SetAttrString (result, "name", arg) < 0)
29388 + arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
29390 + if (PyObject_SetAttrString (result, "artificial", arg) < 0)
29393 + arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
29396 + if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
29399 + arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
29402 + if (PyObject_SetAttrString (result, "type", arg) < 0)
29410 + Py_DECREF (result);
29414 +/* Return a sequence of all fields. Each field is a dictionary with
29415 + some pre-defined keys. */
29417 +typy_fields (PyObject *self, PyObject *args)
29419 + PyObject *result;
29421 + struct type *type = ((type_object *) self)->type;
29423 + /* We would like to make a tuple here, make fields immutable, and
29424 + then memoize the result (and perhaps make Field.type() lazy).
29425 + However, that can lead to cycles. */
29426 + result = PyList_New (0);
29428 + for (i = 0; i < TYPE_NFIELDS (type); ++i)
29430 + PyObject *dict = convert_field (type, i);
29433 + Py_DECREF (result);
29436 + if (PyList_Append (result, dict))
29438 + Py_DECREF (dict);
29439 + Py_DECREF (result);
29447 +/* Return the type's tag, or None. */
29449 +typy_tag (PyObject *self, PyObject *args)
29451 + struct type *type = ((type_object *) self)->type;
29452 + if (!TYPE_TAG_NAME (type))
29454 + return PyString_FromString (TYPE_TAG_NAME (type));
29457 +/* Return the type, stripped of typedefs. */
29459 +typy_strip_typedefs (PyObject *self, PyObject *args)
29461 + struct type *type = ((type_object *) self)->type;
29463 + return type_to_type_object (check_typedef (type));
29466 +/* Return a Type object which represents a pointer to SELF. */
29468 +typy_pointer (PyObject *self, PyObject *args)
29470 + struct type *type = ((type_object *) self)->type;
29471 + volatile struct gdb_exception except;
29473 + TRY_CATCH (except, RETURN_MASK_ALL)
29475 + type = lookup_pointer_type (type);
29477 + GDB_PY_HANDLE_EXCEPTION (except);
29479 + return type_to_type_object (type);
29482 +/* Return a Type object which represents a reference to SELF. */
29484 +typy_reference (PyObject *self, PyObject *args)
29486 + struct type *type = ((type_object *) self)->type;
29487 + volatile struct gdb_exception except;
29489 + TRY_CATCH (except, RETURN_MASK_ALL)
29491 + type = lookup_reference_type (type);
29493 + GDB_PY_HANDLE_EXCEPTION (except);
29495 + return type_to_type_object (type);
29498 +/* Return a Type object which represents the target type of SELF. */
29500 +typy_target (PyObject *self, PyObject *args)
29502 + struct type *type = ((type_object *) self)->type;
29504 + if (!TYPE_TARGET_TYPE (type))
29506 + PyErr_SetString (PyExc_RuntimeError, "type does not have a target");
29510 + return type_to_type_object (TYPE_TARGET_TYPE (type));
29513 +/* Return a const-qualified type variant. */
29515 +typy_const (PyObject *self, PyObject *args)
29517 + struct type *type = ((type_object *) self)->type;
29518 + volatile struct gdb_exception except;
29520 + TRY_CATCH (except, RETURN_MASK_ALL)
29522 + type = make_cv_type (1, 0, type, NULL);
29524 + GDB_PY_HANDLE_EXCEPTION (except);
29526 + return type_to_type_object (type);
29529 +/* Return a volatile-qualified type variant. */
29531 +typy_volatile (PyObject *self, PyObject *args)
29533 + struct type *type = ((type_object *) self)->type;
29534 + volatile struct gdb_exception except;
29536 + TRY_CATCH (except, RETURN_MASK_ALL)
29538 + type = make_cv_type (0, 1, type, NULL);
29540 + GDB_PY_HANDLE_EXCEPTION (except);
29542 + return type_to_type_object (type);
29545 +/* Return an unqualified type variant. */
29547 +typy_unqualified (PyObject *self, PyObject *args)
29549 + struct type *type = ((type_object *) self)->type;
29550 + volatile struct gdb_exception except;
29552 + TRY_CATCH (except, RETURN_MASK_ALL)
29554 + type = make_cv_type (0, 0, type, NULL);
29556 + GDB_PY_HANDLE_EXCEPTION (except);
29558 + return type_to_type_object (type);
29561 +/* Return the size of the type represented by SELF, in bytes. */
29563 +typy_sizeof (PyObject *self, PyObject *args)
29565 + struct type *type = ((type_object *) self)->type;
29566 + volatile struct gdb_exception except;
29568 + TRY_CATCH (except, RETURN_MASK_ALL)
29570 + CHECK_TYPEDEF (type);
29572 + GDB_PY_HANDLE_EXCEPTION (except);
29574 + return PyLong_FromLong (TYPE_LENGTH (type));
29577 +static struct type *
29578 +typy_lookup_typename (char *type_name, struct block *block)
29580 + struct type *type = NULL;
29581 + volatile struct gdb_exception except;
29582 + TRY_CATCH (except, RETURN_MASK_ALL)
29584 + if (!strncmp (type_name, "struct ", 7))
29585 + type = lookup_struct (type_name + 7, block);
29586 + else if (!strncmp (type_name, "union ", 6))
29587 + type = lookup_union (type_name + 6, block);
29588 + else if (!strncmp (type_name, "enum ", 5))
29589 + type = lookup_enum (type_name + 5, block);
29591 + type = lookup_typename (type_name, block, 0);
29593 + if (except.reason < 0)
29595 + PyErr_Format (except.reason == RETURN_QUIT
29596 + ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
29597 + "%s", except.message);
29604 +static struct type *
29605 +typy_lookup_type (struct demangle_component *demangled,
29606 + struct block *block)
29608 + struct type *type;
29610 + enum demangle_component_type demangled_type;
29612 + /* Save the type: typy_lookup_type() may (indirectly) overwrite
29613 + memory pointed by demangled. */
29614 + demangled_type = demangled->type;
29616 + if (demangled_type == DEMANGLE_COMPONENT_POINTER
29617 + || demangled_type == DEMANGLE_COMPONENT_REFERENCE
29618 + || demangled_type == DEMANGLE_COMPONENT_CONST
29619 + || demangled_type == DEMANGLE_COMPONENT_VOLATILE)
29621 + type = typy_lookup_type (demangled->u.s_binary.left, block);
29625 + switch (demangled_type)
29627 + case DEMANGLE_COMPONENT_REFERENCE:
29628 + return lookup_reference_type (type);
29629 + case DEMANGLE_COMPONENT_POINTER:
29630 + return lookup_pointer_type (type);
29631 + case DEMANGLE_COMPONENT_CONST:
29632 + return make_cv_type (1, 0, type, NULL);
29633 + case DEMANGLE_COMPONENT_VOLATILE:
29634 + return make_cv_type (0, 1, type, NULL);
29638 + type_name = cp_comp_to_string (demangled, 10);
29639 + type = typy_lookup_typename (type_name, block);
29640 + xfree (type_name);
29646 +typy_template_argument (PyObject *self, PyObject *args)
29648 + int i, argno, n_pointers;
29649 + struct type *type = ((type_object *) self)->type;
29650 + struct demangle_component *demangled;
29652 + struct type *argtype;
29653 + struct block *block = NULL;
29654 + PyObject *block_obj = NULL;
29656 + if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
29661 + block = block_object_to_block (block_obj);
29664 + PyErr_SetString (PyExc_RuntimeError,
29665 + "second argument must be block");
29670 + type = check_typedef (type);
29671 + if (TYPE_CODE (type) == TYPE_CODE_REF)
29672 + type = check_typedef (TYPE_TARGET_TYPE (type));
29674 + if (TYPE_NAME (type) == NULL)
29676 + PyErr_SetString (PyExc_RuntimeError, "null type name");
29680 + /* Note -- this is not thread-safe. */
29681 + demangled = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
29684 + PyErr_SetString (PyExc_RuntimeError, err);
29688 + /* Strip off component names. */
29689 + while (demangled->type == DEMANGLE_COMPONENT_QUAL_NAME
29690 + || demangled->type == DEMANGLE_COMPONENT_LOCAL_NAME)
29691 + demangled = demangled->u.s_binary.right;
29693 + if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
29695 + PyErr_SetString (PyExc_RuntimeError, "type is not a template");
29699 + /* Skip from the template to the arguments. */
29700 + demangled = demangled->u.s_binary.right;
29702 + for (i = 0; demangled && i < argno; ++i)
29703 + demangled = demangled->u.s_binary.right;
29707 + PyErr_Format (PyExc_RuntimeError, "no argument %d in template",
29712 + argtype = typy_lookup_type (demangled->u.s_binary.left, block);
29716 + return type_to_type_object (argtype);
29720 +typy_str (PyObject *self)
29722 + volatile struct gdb_exception except;
29723 + char *thetype = NULL;
29724 + PyObject *result;
29726 + TRY_CATCH (except, RETURN_MASK_ALL)
29728 + struct cleanup *old_chain;
29729 + struct ui_file *stb;
29732 + stb = mem_fileopen ();
29733 + old_chain = make_cleanup_ui_file_delete (stb);
29735 + type_print (type_object_to_type (self), "", stb, -1);
29737 + thetype = ui_file_xstrdup (stb, &length);
29738 + do_cleanups (old_chain);
29740 + if (except.reason < 0)
29743 + GDB_PY_HANDLE_EXCEPTION (except);
29746 + result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL);
29754 +static const struct objfile_data *typy_objfile_data_key;
29757 +clean_up_objfile_types (struct objfile *objfile, void *datum)
29759 + type_object *obj = datum;
29760 + htab_t copied_types;
29761 + struct cleanup *cleanup;
29762 + PyGILState_STATE state;
29764 + /* This prevents another thread from freeing the objects we're
29766 + state = PyGILState_Ensure ();
29767 + cleanup = make_cleanup_py_restore_gil (&state);
29769 + copied_types = create_copied_types_hash (objfile);
29773 + type_object *next = obj->next;
29775 + htab_empty (copied_types);
29777 + /* No need to decref the old type here, since we know it has no
29778 + reference count. */
29779 + gdb_assert (objfile == TYPE_OBJFILE (obj->type));
29780 + obj->type = copy_type_recursive (obj->type, copied_types);
29781 + type_incref (obj->type);
29783 + obj->next = NULL;
29784 + obj->prev = NULL;
29789 + htab_delete (copied_types);
29791 + do_cleanups (cleanup);
29795 +set_type (type_object *obj, struct type *type)
29797 + obj->type = type;
29798 + type_incref (type);
29799 + obj->prev = NULL;
29800 + if (type && !OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (type)))
29802 + struct objfile *objfile = TYPE_OBJFILE (type);
29804 + obj->next = objfile_data (objfile, typy_objfile_data_key);
29806 + obj->next->prev = obj;
29807 + set_objfile_data (objfile, typy_objfile_data_key, obj);
29810 + obj->next = NULL;
29814 +typy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
29816 + char *type_name = NULL;
29817 + struct type *type = NULL;
29818 + type_object *result;
29819 + PyObject *block_obj = NULL;
29820 + struct block *block = NULL;
29822 + /* FIXME: it is strange to allow a Type with no name, but we need
29823 + this for type_to_type_object. */
29824 + if (! PyArg_ParseTuple (args, "|sO", &type_name, &block_obj))
29829 + block = block_object_to_block (block_obj);
29832 + PyErr_SetString (PyExc_RuntimeError,
29833 + "second argument must be block");
29840 + type = typy_lookup_typename (type_name, block);
29845 + result = (type_object *) subtype->tp_alloc (subtype, 1);
29849 + set_type (result, type);
29851 + return (PyObject *) result;
29855 +typy_dealloc (PyObject *obj)
29857 + type_object *type = (type_object *) obj;
29860 + type_decref (type->type);
29863 + type->prev->next = type->next;
29864 + else if (type->type && !OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (type->type)))
29866 + /* Must reset head of list. */
29867 + struct objfile *objfile = TYPE_OBJFILE (type->type);
29869 + set_objfile_data (objfile, typy_objfile_data_key, type->next);
29872 + type->next->prev = type->prev;
29874 + type->ob_type->tp_free (type);
29877 +/* Create a new Type referring to TYPE. */
29879 +type_to_type_object (struct type *type)
29881 + type_object *type_obj;
29883 + type_obj = PyObject_New (type_object, &type_object_type);
29885 + set_type (type_obj, type);
29887 + return (PyObject *) type_obj;
29891 +type_object_to_type (PyObject *obj)
29893 + if (! PyObject_TypeCheck (obj, &type_object_type))
29895 + return ((type_object *) obj)->type;
29901 +gdbpy_initialize_types (void)
29905 + typy_objfile_data_key
29906 + = register_objfile_data_with_cleanup (clean_up_objfile_types);
29908 + if (PyType_Ready (&type_object_type) < 0)
29910 + if (PyType_Ready (&field_object_type) < 0)
29913 + for (i = 0; pyty_codes[i].name; ++i)
29915 + if (PyModule_AddIntConstant (gdb_module,
29916 + /* Cast needed for Python 2.4. */
29917 + (char *) pyty_codes[i].name,
29918 + pyty_codes[i].code) < 0)
29922 + Py_INCREF (&type_object_type);
29923 + PyModule_AddObject (gdb_module, "Type", (PyObject *) &type_object_type);
29925 + Py_INCREF (&field_object_type);
29926 + PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
29931 +static PyMethodDef type_object_methods[] =
29933 + { "code", typy_code, METH_NOARGS, "Return the code for this type" },
29934 + { "const", typy_const, METH_NOARGS, "Return a const variant of this type" },
29935 + { "fields", typy_fields, METH_NOARGS,
29936 + "Return a sequence holding all the fields of this type.\n\
29937 +Each field is a dictionary." },
29938 + { "pointer", typy_pointer, METH_NOARGS, "Return pointer to this type" },
29939 + { "reference", typy_reference, METH_NOARGS, "Return reference to this type" },
29940 + { "sizeof", typy_sizeof, METH_NOARGS,
29941 + "Return the size of this type, in bytes" },
29942 + { "tag", typy_tag, METH_NOARGS,
29943 + "Return the tag name for this type, or None." },
29944 + { "strip_typedefs", typy_strip_typedefs, METH_NOARGS,
29945 + "Return a type stripped of typedefs"},
29946 + { "target", typy_target, METH_NOARGS,
29947 + "Return the target type of this type" },
29948 + { "template_argument", typy_template_argument, METH_VARARGS,
29949 + "Return a single template argument type" },
29950 + { "unqualified", typy_unqualified, METH_NOARGS,
29951 + "Return a variant of this type without const or volatile attributes" },
29952 + { "volatile", typy_volatile, METH_NOARGS,
29953 + "Return a volatile variant of this type" },
29957 +static PyTypeObject type_object_type =
29959 + PyObject_HEAD_INIT (NULL)
29961 + "gdb.Type", /*tp_name*/
29962 + sizeof (type_object), /*tp_basicsize*/
29963 + 0, /*tp_itemsize*/
29964 + typy_dealloc, /*tp_dealloc*/
29966 + 0, /*tp_getattr*/
29967 + 0, /*tp_setattr*/
29968 + 0, /*tp_compare*/
29970 + 0, /*tp_as_number*/
29971 + 0, /*tp_as_sequence*/
29972 + 0, /*tp_as_mapping*/
29975 + typy_str, /*tp_str*/
29976 + 0, /*tp_getattro*/
29977 + 0, /*tp_setattro*/
29978 + 0, /*tp_as_buffer*/
29979 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
29980 + "GDB type object", /* tp_doc */
29981 + 0, /* tp_traverse */
29982 + 0, /* tp_clear */
29983 + 0, /* tp_richcompare */
29984 + 0, /* tp_weaklistoffset */
29986 + 0, /* tp_iternext */
29987 + type_object_methods, /* tp_methods */
29988 + 0, /* tp_members */
29989 + 0, /* tp_getset */
29992 + 0, /* tp_descr_get */
29993 + 0, /* tp_descr_set */
29994 + 0, /* tp_dictoffset */
29996 + 0, /* tp_alloc */
29997 + typy_new, /* tp_new */
30000 +static PyTypeObject field_object_type =
30002 + PyObject_HEAD_INIT (NULL)
30004 + "gdb.Field", /*tp_name*/
30005 + sizeof (field_object), /*tp_basicsize*/
30006 + 0, /*tp_itemsize*/
30007 + field_dealloc, /*tp_dealloc*/
30009 + 0, /*tp_getattr*/
30010 + 0, /*tp_setattr*/
30011 + 0, /*tp_compare*/
30013 + 0, /*tp_as_number*/
30014 + 0, /*tp_as_sequence*/
30015 + 0, /*tp_as_mapping*/
30019 + 0, /*tp_getattro*/
30020 + 0, /*tp_setattro*/
30021 + 0, /*tp_as_buffer*/
30022 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_ITER, /*tp_flags*/
30023 + "GDB field object", /* tp_doc */
30024 + 0, /* tp_traverse */
30025 + 0, /* tp_clear */
30026 + 0, /* tp_richcompare */
30027 + 0, /* tp_weaklistoffset */
30029 + 0, /* tp_iternext */
30030 + 0, /* tp_methods */
30031 + 0, /* tp_members */
30032 + 0, /* tp_getset */
30035 + 0, /* tp_descr_get */
30036 + 0, /* tp_descr_set */
30037 + offsetof (field_object, dict), /* tp_dictoffset */
30039 + 0, /* tp_alloc */
30042 diff --git a/gdb/python/python-utils.c b/gdb/python/python-utils.c
30043 index ddac2f5..f9c9486 100644
30044 --- a/gdb/python/python-utils.c
30045 +++ b/gdb/python/python-utils.c
30049 #include "charset.h"
30050 +#include "value.h"
30051 #include "python-internal.h"
30054 @@ -99,8 +100,8 @@ python_string_to_unicode (PyObject *obj)
30057 /* Returns a newly allocated string with the contents of the given unicode
30058 - string object converted to CHARSET. If an error occurs during the
30059 - conversion, NULL will be returned and a python exception will be set.
30060 + string object converted to a named charset. If an error occurs during
30061 + the conversion, NULL will be returned and a python exception will be set.
30063 The caller is responsible for xfree'ing the string. */
30065 @@ -191,3 +192,48 @@ gdbpy_is_string (PyObject *obj)
30067 return PyString_Check (obj) || PyUnicode_Check (obj);
30070 +/* Converts OBJ to a CORE_ADDR value.
30072 + Returns 1 on success or 0 on failure, with a Python exception set. This
30073 + function can also throw GDB exceptions. */
30076 +get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
30078 + if (gdbpy_is_value_object (obj))
30079 + *addr = value_as_address (value_object_to_value (obj));
30080 + else if (PyLong_Check (obj))
30082 + /* Assume CORE_ADDR corresponds to unsigned long. */
30083 + *addr = PyLong_AsUnsignedLong (obj);
30084 + if (PyErr_Occurred () != NULL)
30087 + else if (PyInt_Check (obj))
30091 + /* Assume CORE_ADDR corresponds to unsigned long. */
30092 + val = PyInt_AsLong (obj);
30098 + /* If no error ocurred, VAL is indeed negative. */
30099 + if (PyErr_Occurred () != NULL)
30102 + PyErr_SetString (PyExc_ValueError, "negative address");
30108 + PyErr_SetString (PyExc_TypeError, "invalid type for address");
30114 diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
30115 index bc077b6..2507fcd 100644
30116 --- a/gdb/python/python-value.c
30117 +++ b/gdb/python/python-value.c
30118 @@ -52,6 +52,10 @@ struct value *values_in_python = NULL;
30119 /* Python's long type corresponds to C's long long type. */
30120 #define builtin_type_pylong builtin_type (current_gdbarch)->builtin_long_long
30122 +/* Python's long type corresponds to C's long long type. Unsigned version. */
30123 +#define builtin_type_upylong builtin_type \
30124 + (current_gdbarch)->builtin_unsigned_long_long
30126 #define builtin_type_pybool \
30127 language_bool_type (current_language, current_gdbarch)
30129 @@ -143,10 +147,19 @@ valpy_address (PyObject *self, PyObject *args)
30130 return value_to_value_object (res_val);
30133 -/* Return Unicode string with value contents (assumed to be encoded in the
30134 - target's charset). */
30135 +/* Return type of the value. */
30137 +valpy_type (PyObject *self, PyObject *args)
30139 + struct value *value = ((value_object *) self)->value;
30140 + return type_to_type_object (value_type (value));
30143 +/* Implementation of gdb.Value.string ([encoding] [, errors]) -> string
30144 + Return Unicode string with value contents. If ENCODING is not given,
30145 + the string is assumed to be encoded in the target's charset. */
30147 -valpy_string (PyObject *self, PyObject *args)
30148 +valpy_string (PyObject *self, PyObject *args, PyObject *kw)
30150 int length, ret = 0;
30152 @@ -157,8 +170,10 @@ valpy_string (PyObject *self, PyObject *args)
30153 const char *errors = NULL;
30154 const char *user_encoding = NULL;
30155 const char *la_encoding = NULL;
30156 + static char *keywords[] = { "encoding", "errors" };
30158 - if (!PyArg_ParseTuple (args, "|ss", &user_encoding, &errors))
30159 + if (!PyArg_ParseTupleAndKeywords (args, kw, "|ss", keywords,
30160 + &user_encoding, &errors))
30163 TRY_CATCH (except, RETURN_MASK_ALL)
30164 @@ -174,6 +189,34 @@ valpy_string (PyObject *self, PyObject *args)
30168 +/* Cast a value to a given type. */
30170 +valpy_cast (PyObject *self, PyObject *args)
30172 + PyObject *type_obj;
30173 + struct type *type;
30174 + struct value *res_val = NULL; /* Initialize to appease gcc warning. */
30175 + volatile struct gdb_exception except;
30177 + if (! PyArg_ParseTuple (args, "O", &type_obj))
30180 + type = type_object_to_type (type_obj);
30183 + PyErr_SetString (PyExc_RuntimeError, "argument must be a Type");
30187 + TRY_CATCH (except, RETURN_MASK_ALL)
30189 + res_val = value_cast (type, ((value_object *) self)->value);
30191 + GDB_PY_HANDLE_EXCEPTION (except);
30193 + return value_to_value_object (res_val);
30197 valpy_length (PyObject *self)
30199 @@ -306,11 +349,11 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
30200 a gdb.Value object and need to convert it from python as well. */
30201 arg1 = convert_value_from_python (self);
30206 arg2 = convert_value_from_python (other);
30213 @@ -387,7 +430,7 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
30215 GDB_PY_HANDLE_EXCEPTION (except);
30217 - return value_to_value_object (res_val);
30218 + return res_val ? value_to_value_object (res_val) : NULL;
30222 @@ -718,6 +761,17 @@ value_to_value_object (struct value *val)
30223 return (PyObject *) val_obj;
30226 +/* Returns value structure corresponding to the given value object. */
30228 +value_object_to_value (PyObject *self)
30230 + value_object *real;
30231 + if (! PyObject_TypeCheck (self, &value_object_type))
30233 + real = (value_object *) self;
30234 + return real->value;
30237 /* Try to convert a Python value to a gdb value. If the value cannot
30238 be converted, set a Python exception and return NULL. */
30240 @@ -751,7 +805,34 @@ convert_value_from_python (PyObject *obj)
30242 LONGEST l = PyLong_AsLongLong (obj);
30244 - if (! PyErr_Occurred ())
30245 + if (PyErr_Occurred ())
30247 + /* If the error was an overflow, we can try converting to
30248 + ULONGEST instead. */
30249 + if (PyErr_ExceptionMatches (PyExc_OverflowError))
30251 + PyObject *etype, *evalue, *etraceback, *zero;
30253 + PyErr_Fetch (&etype, &evalue, &etraceback);
30254 + zero = PyInt_FromLong (0);
30256 + /* Check whether obj is positive. */
30257 + if (PyObject_RichCompareBool (obj, zero, Py_GT) > 0)
30261 + ul = PyLong_AsUnsignedLongLong (obj);
30262 + if (! PyErr_Occurred ())
30263 + value = value_from_ulongest (builtin_type_upylong, ul);
30266 + /* There's nothing we can do. */
30267 + PyErr_Restore (etype, evalue, etraceback);
30269 + Py_DECREF (zero);
30273 value = value_from_longest (builtin_type_pylong, l);
30275 else if (PyFloat_Check (obj))
30276 @@ -774,7 +855,7 @@ convert_value_from_python (PyObject *obj)
30279 else if (PyObject_TypeCheck (obj, &value_object_type))
30280 - value = ((value_object *) obj)->value;
30281 + value = value_copy (((value_object *) obj)->value);
30283 PyErr_Format (PyExc_TypeError, _("Could not convert Python object: %s"),
30284 PyString_AsString (PyObject_Str (obj)));
30285 @@ -810,6 +891,14 @@ gdbpy_history (PyObject *self, PyObject *args)
30286 return value_to_value_object (res_val);
30289 +/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise. */
30292 +gdbpy_is_value_object (PyObject *obj)
30294 + return PyObject_TypeCheck (obj, &value_object_type);
30298 gdbpy_initialize_values (void)
30300 @@ -822,11 +911,16 @@ gdbpy_initialize_values (void)
30301 values_in_python = NULL;
30306 static PyMethodDef value_object_methods[] = {
30307 { "address", valpy_address, METH_NOARGS, "Return the address of the value." },
30308 + { "cast", valpy_cast, METH_VARARGS, "Cast the value to the supplied type." },
30309 { "dereference", valpy_dereference, METH_NOARGS, "Dereferences the value." },
30310 - { "string", valpy_string, METH_VARARGS,
30311 - "Return Unicode string representation of the value." },
30312 + { "type", valpy_type, METH_NOARGS, "Return type of the value." },
30313 + { "string", (PyCFunction) valpy_string, METH_VARARGS | METH_KEYWORDS,
30314 + "string ([encoding] [, errors]) -> string\n\
30315 +Return Unicode string representation of the value." },
30316 {NULL} /* Sentinel */
30319 diff --git a/gdb/python/python.c b/gdb/python/python.c
30320 index b3a27d6..2b06748 100644
30321 --- a/gdb/python/python.c
30322 +++ b/gdb/python/python.c
30324 #include "ui-out.h"
30325 #include "cli/cli-script.h"
30326 #include "gdbcmd.h"
30327 +#include "objfiles.h"
30328 +#include "observer.h"
30329 +#include "gdb_regex.h"
30330 +#include "language.h"
30331 +#include "valprint.h"
30332 +#include "event-loop.h"
30337 false otherwise. */
30338 static int gdbpy_should_print_stack = 1;
30340 +/* This is true if we should auto-load python code when an objfile is
30341 + opened, false otherwise. */
30342 +static int gdbpy_auto_load = 1;
30346 #include "python.h"
30347 @@ -36,16 +46,29 @@ static int gdbpy_should_print_stack = 1;
30348 #include "cli/cli-decode.h"
30349 #include "charset.h"
30351 +#include "solib.h"
30352 #include "exceptions.h"
30353 #include "python-internal.h"
30354 +#include "linespec.h"
30355 +#include "symtab.h"
30356 +#include "source.h"
30357 #include "version.h"
30358 +#include "inferior.h"
30359 +#include "gdbthread.h"
30360 #include "target.h"
30361 #include "gdbthread.h"
30362 +#include "event-top.h"
30364 +static PyMethodDef GdbMethods[];
30366 static PyMethodDef GdbMethods[];
30368 PyObject *gdb_module;
30370 +/* Some string constants we may wish to use. */
30371 +PyObject *gdbpy_to_string_cst;
30372 +PyObject *gdbpy_children_cst;
30373 +PyObject *gdbpy_display_hint_cst;
30374 PyObject *gdbpy_doc_cst;
30376 /* Given a command_line, return a command string suitable for passing
30377 @@ -143,10 +166,10 @@ python_command (char *arg, int from_tty)
30378 NULL (and set a Python exception) on error. Helper function for
30382 -parameter_to_python (struct cmd_list_element *cmd)
30384 +gdbpy_parameter_value (enum var_types type, void *var)
30386 - switch (cmd->var_type)
30390 case var_string_noescape:
30391 @@ -154,7 +177,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30395 - char *str = * (char **) cmd->var;
30396 + char *str = * (char **) var;
30399 return PyString_Decode (str, strlen (str), host_charset (), NULL);
30400 @@ -162,7 +185,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30404 - if (* (int *) cmd->var)
30405 + if (* (int *) var)
30409 @@ -170,7 +193,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30411 case var_auto_boolean:
30413 - enum auto_boolean ab = * (enum auto_boolean *) cmd->var;
30414 + enum auto_boolean ab = * (enum auto_boolean *) var;
30415 if (ab == AUTO_BOOLEAN_TRUE)
30417 else if (ab == AUTO_BOOLEAN_FALSE)
30418 @@ -180,15 +203,15 @@ parameter_to_python (struct cmd_list_element *cmd)
30422 - if ((* (int *) cmd->var) == INT_MAX)
30423 + if ((* (int *) var) == INT_MAX)
30425 /* Fall through. */
30427 - return PyLong_FromLong (* (int *) cmd->var);
30428 + return PyLong_FromLong (* (int *) var);
30432 - unsigned int val = * (unsigned int *) cmd->var;
30433 + unsigned int val = * (unsigned int *) var;
30434 if (val == UINT_MAX)
30436 return PyLong_FromUnsignedLong (val);
30437 @@ -202,10 +225,11 @@ parameter_to_python (struct cmd_list_element *cmd)
30441 -get_parameter (PyObject *self, PyObject *args)
30442 +gdbpy_parameter (PyObject *self, PyObject *args)
30444 struct cmd_list_element *alias, *prefix, *cmd;
30445 char *arg, *newarg;
30447 volatile struct gdb_exception except;
30449 if (! PyArg_ParseTuple (args, "s", &arg))
30450 @@ -215,19 +239,17 @@ get_parameter (PyObject *self, PyObject *args)
30452 TRY_CATCH (except, RETURN_MASK_ALL)
30454 - if (! lookup_cmd_composition (newarg, &alias, &prefix, &cmd))
30457 - return PyErr_Format (PyExc_RuntimeError,
30458 - "could not find variable `%s'", arg);
30460 + found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd);
30463 GDB_PY_HANDLE_EXCEPTION (except);
30465 + return PyErr_Format (PyExc_RuntimeError,
30466 + "could not find parameter `%s'", arg);
30469 - return PyErr_Format (PyExc_RuntimeError, "`%s' is not a variable", arg);
30470 - return parameter_to_python (cmd);
30471 + return PyErr_Format (PyExc_RuntimeError, "`%s' is not a parameter", arg);
30472 + return gdbpy_parameter_value (cmd->var_type, cmd->var);
30475 /* A Python function which evaluates a string using the gdb CLI. */
30476 @@ -266,6 +288,570 @@ execute_gdb_command (PyObject *self, PyObject *args)
30480 +/* Implementation of gdb.solib_address (Long) -> String.
30481 + Returns the name of the shared library holding a given address, or None. */
30484 +gdbpy_solib_address (PyObject *self, PyObject *args)
30486 + unsigned long long pc;
30488 + PyObject *str_obj;
30490 + if (!PyArg_ParseTuple (args, "K", &pc))
30493 + soname = solib_address (pc);
30495 + str_obj = PyString_Decode (soname, strlen (soname), host_charset (), NULL);
30498 + str_obj = Py_None;
30499 + Py_INCREF (Py_None);
30506 +gdbpy_find_pc_function (PyObject *self, PyObject *args)
30508 + unsigned long long pc;
30509 + struct symbol *sym;
30510 + PyObject *sym_obj;
30512 + if (!PyArg_ParseTuple (args, "K", &pc))
30515 + sym = find_pc_function (pc);
30517 + return symbol_to_symbol_object (sym);
30522 +/* Adds GDB value V to the pattern buffer in *PATTERN_BUF. If SIZE is not zero,
30523 + it specifies the number of bytes from V to copy to *PATTERN_BUF. The
30524 + function increases the size of *PATTERN_BUF as necessary, adjusting
30525 + *PATTERN_BUF_END and *PATTERN_BUF_SIZE in the process. */
30528 +add_value_pattern (struct value *v, int size, char **pattern_buf,
30529 + char **pattern_buf_end, ULONGEST *pattern_buf_size)
30535 + LONGEST x = value_as_long (v);
30538 + *(*pattern_buf_end)++ = x;
30541 + put_bits (x, *pattern_buf_end, size * 8,
30542 + gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG);
30543 + *pattern_buf_end += size;
30548 + val_bytes = TYPE_LENGTH (value_type (v));
30550 + increase_pattern_buffer (pattern_buf, pattern_buf_end,
30551 + pattern_buf_size, val_bytes);
30553 + memcpy (*pattern_buf_end, value_contents_raw (v), val_bytes);
30554 + *pattern_buf_end += val_bytes;
30558 +/* This function does the actual work of constructing the pattern buffer from
30559 + OBJ. If OBJ is an object which implements the read buffer protocol (such
30560 + as a string, a byte array or gdb.Membuf), then its contents are directly
30561 + copied to *PATTERN_BUF. If it is a list, then this function is recursively
30562 + called for each of its elements. If OBJ is an object which can be converted
30563 + to a GDB value, then the contents of the value are copied to PATTERN_BUF.
30564 + If SIZE is different than zero, then it limits the number of bytes which
30565 + are copied to the buffer in case OBJ is converted to a GDB value. That
30566 + means that SIZE influences only Python scalars and gdb.Value objects.
30567 + The function increases the size of *PATTERN_BUF as necessary, adjusting
30568 + *PATTERN_BUF_END and *PATTERN_BUF_SIZE in the process.
30570 + Returns 1 on success or 0 on failure, with a Python exception set. This
30571 + function can also throw GDB exceptions. */
30574 +add_pattern_element (PyObject *obj, int size, char **pattern_buf,
30575 + char **pattern_buf_end, ULONGEST *pattern_buf_size)
30577 + if (PyObject_CheckReadBuffer (obj))
30579 + /* Handle string, Unicode string, byte array, gdb.Membuf and any other
30580 + object implementing the buffer protocol. The SIZE parameter is
30581 + ignored in this case. */
30583 + Py_ssize_t val_bytes;
30584 + const void *buffer;
30586 + if (PyObject_AsReadBuffer (obj, &buffer, &val_bytes) == -1)
30589 + increase_pattern_buffer (pattern_buf, pattern_buf_end,
30590 + pattern_buf_size, val_bytes);
30592 + memcpy (*pattern_buf_end, buffer, val_bytes);
30593 + *pattern_buf_end += val_bytes;
30595 + else if (gdbpy_is_value_object (obj))
30596 + add_value_pattern (value_object_to_value (obj), size, pattern_buf,
30597 + pattern_buf_end, pattern_buf_size);
30598 + else if (PySequence_Check (obj))
30600 + /* Handle lists and tuples. */
30602 + Py_ssize_t i, num_objs;
30604 + num_objs = PySequence_Size (obj);
30605 + for (i = 0; i < num_objs; i++)
30606 + if (!add_pattern_element (PySequence_GetItem (obj, i), size,
30607 + pattern_buf, pattern_buf_end,
30608 + pattern_buf_size))
30613 + /* See if we can convert from a Python object to a GDB value. */
30615 + struct value *v = convert_value_from_python (obj);
30618 + add_value_pattern (v, size, pattern_buf, pattern_buf_end,
30619 + pattern_buf_size);
30627 +/* Constructs the search pattern from OBJ, putting it in *PATTERN_BUFP, and its
30628 + size in *PATTERN_LENP. See the function add_pattern_element to learn how
30629 + the search pattern is obtained from OBJ.
30631 + Returns 1 on success or 0 on failure, with a Python exception set. This
30632 + function can also throw GDB exceptions. */
30635 +get_search_pattern (PyObject *obj, int size, char **pattern_bufp,
30636 + ULONGEST *pattern_lenp)
30638 + /* Buffer to hold the search pattern. */
30639 + char *pattern_buf;
30640 + /* Current size of search pattern buffer.
30641 + We realloc space as needed. */
30642 + ULONGEST pattern_buf_size;
30643 + /* Pointer to one past the last in-use part of pattern_buf. */
30644 + char *pattern_buf_end;
30645 + struct cleanup *old_cleanups;
30647 + allocate_pattern_buffer (&pattern_buf, &pattern_buf_end, &pattern_buf_size);
30648 + old_cleanups = make_cleanup (free_current_contents, &pattern_buf);
30650 + if (!add_pattern_element (obj, size, &pattern_buf, &pattern_buf_end,
30651 + &pattern_buf_size))
30653 + do_cleanups (old_cleanups);
30658 + *pattern_bufp = pattern_buf;
30659 + *pattern_lenp = pattern_buf_end - pattern_buf;
30661 + discard_cleanups (old_cleanups);
30666 +/* Implementation of
30667 + gdb.search_memory (address, length, pattern [, size] [, max_count]).
30668 + The third argument may be either a pattern, or a list or tupple of patterns
30669 + to be searched. Size is the size in bytes of each search query value, either
30670 + 1, 2, 4 or 8. Returns a list of the addresses where matches were found. */
30673 +gdbpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
30677 + unsigned int found_count = 0;
30678 + long max_count = 0;
30679 + CORE_ADDR start_addr;
30680 + char *pattern_buf;
30681 + static char *keywords[] = { "address", "length", "pattern", "size",
30682 + "max_count", NULL };
30683 + ULONGEST pattern_len, search_space_len;
30684 + PyObject *pattern, *list = NULL, *start_addr_obj;
30685 + volatile struct gdb_exception except;
30687 + /* Assume CORE_ADDR corresponds to unsigned long. */
30688 + if (! PyArg_ParseTupleAndKeywords (args, kw, "OlO|il", keywords,
30689 + &start_addr_obj, &length, &pattern,
30690 + &size, &max_count))
30694 + max_count = LONG_MAX;
30698 + PyErr_SetString (PyExc_ValueError, "empty search range");
30701 + else if (length < 0)
30703 + PyErr_SetString (PyExc_ValueError, "invalid search range");
30708 + /* Watch for overflows. */
30709 + if (length > CORE_ADDR_MAX
30710 + || (start_addr + length - 1) < start_addr)
30712 + PyErr_SetString (PyExc_ValueError, "search range too large");
30716 + search_space_len = length;
30719 + if (size != 0 && size != 1 && size != 2 && size != 4 && size != 8)
30721 + PyErr_SetString (PyExc_ValueError, "invalid pattern size");
30725 + TRY_CATCH (except, RETURN_MASK_ALL)
30727 + if (get_addr_from_python (start_addr_obj, &start_addr))
30729 + if (get_search_pattern (pattern, size, &pattern_buf, &pattern_len))
30731 + /* Any cleanups get automatically executed on an exception. */
30732 + struct cleanup *cleanups = make_cleanup (xfree, pattern_buf);
30734 + list = PyList_New (0);
30736 + while (search_space_len >= pattern_len && found_count < max_count)
30738 + CORE_ADDR found_addr;
30741 + found = search_memory (&start_addr, &search_space_len,
30742 + pattern_buf, pattern_len, &found_addr);
30746 + PyList_Append (list, PyLong_FromUnsignedLong (found_addr));
30750 + do_cleanups (cleanups);
30754 + GDB_PY_HANDLE_EXCEPTION (except);
30759 +/* A Python function which is a wrapper for decode_line_1. */
30762 +gdbpy_decode_line (PyObject *self, PyObject *args)
30764 + struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to appease gcc. */
30765 + struct symtab_and_line sal;
30766 + char *arg = NULL;
30767 + int free_sals = 0, i;
30768 + PyObject *result = NULL;
30769 + volatile struct gdb_exception except;
30771 + if (! PyArg_ParseTuple (args, "|s", &arg))
30774 + TRY_CATCH (except, RETURN_MASK_ALL)
30780 + arg = strdup (arg);
30783 + sals = decode_line_1 (©, 0, 0, 0, 0, 0);
30788 + set_default_source_symtab_and_line ();
30789 + sal = get_current_source_symtab_and_line ();
30790 + sals.sals = &sal;
30797 + if (except.reason < 0)
30800 + xfree (sals.sals);
30801 + /* We know this will always throw. */
30802 + GDB_PY_HANDLE_EXCEPTION (except);
30807 + result = PyTuple_New (sals.nelts);
30808 + for (i = 0; i < sals.nelts; ++i)
30813 + obj = symtab_and_line_to_sal_object (sals.sals[i]);
30816 + Py_DECREF (result);
30821 + PyTuple_SetItem (result, i, obj);
30826 + xfree (sals.sals);
30833 +/* Parse a string and evaluate it as an expression. */
30835 +gdbpy_parse_and_eval (PyObject *self, PyObject *args)
30838 + struct value *result = NULL;
30839 + volatile struct gdb_exception except;
30841 + if (!PyArg_ParseTuple (args, "s", &expr_str))
30844 + TRY_CATCH (except, RETURN_MASK_ALL)
30846 + result = parse_and_eval (expr_str);
30848 + GDB_PY_HANDLE_EXCEPTION (except);
30850 + return value_to_value_object (result);
30855 +/* Posting and handling events. */
30857 +/* A single event. */
30858 +struct gdbpy_event
30860 + /* The Python event. This is just a callable object. */
30862 + /* The next event. */
30863 + struct gdbpy_event *next;
30866 +/* All pending events. */
30867 +static struct gdbpy_event *gdbpy_event_list;
30868 +/* The final link of the event list. */
30869 +static struct gdbpy_event **gdbpy_event_list_end;
30871 +/* We use a file handler, and not an async handler, so that we can
30872 + wake up the main thread even when it is blocked in poll(). */
30873 +static int gdbpy_event_fds[2];
30875 +/* The file handler callback. This reads from the internal pipe, and
30876 + then processes the Python event queue. This will always be run in
30877 + the main gdb thread. */
30879 +gdbpy_run_events (int err, gdb_client_data ignore)
30881 + PyGILState_STATE state;
30882 + char buffer[100];
30885 + state = PyGILState_Ensure ();
30887 + /* Just read whatever is available on the fd. It is relatively
30888 + harmless if there are any bytes left over. */
30889 + r = read (gdbpy_event_fds[0], buffer, sizeof (buffer));
30891 + while (gdbpy_event_list)
30893 + /* Dispatching the event might push a new element onto the event
30894 + loop, so we update here "atomically enough". */
30895 + struct gdbpy_event *item = gdbpy_event_list;
30896 + gdbpy_event_list = gdbpy_event_list->next;
30897 + if (gdbpy_event_list == NULL)
30898 + gdbpy_event_list_end = &gdbpy_event_list;
30900 + /* Ignore errors. */
30901 + PyObject_CallObject (item->event, NULL);
30903 + Py_DECREF (item->event);
30907 + PyGILState_Release (state);
30910 +/* Submit an event to the gdb thread. */
30912 +gdbpy_post_event (PyObject *self, PyObject *args)
30914 + struct gdbpy_event *event;
30918 + if (!PyArg_ParseTuple (args, "O", &func))
30921 + if (!PyCallable_Check (func))
30923 + PyErr_SetString (PyExc_RuntimeError, "Posted event is not callable");
30927 + Py_INCREF (func);
30929 + /* From here until the end of the function, we have the GIL, so we
30930 + can operate on our global data structures without worrying. */
30931 + wakeup = gdbpy_event_list == NULL;
30933 + event = XNEW (struct gdbpy_event);
30934 + event->event = func;
30935 + event->next = NULL;
30936 + *gdbpy_event_list_end = event;
30937 + gdbpy_event_list_end = &event->next;
30939 + /* Wake up gdb when needed. */
30942 + char c = 'q'; /* Anything. */
30943 + if (write (gdbpy_event_fds[1], &c, 1) != 1)
30944 + return PyErr_SetFromErrno (PyExc_IOError);
30950 +/* Initialize the Python event handler. */
30952 +gdbpy_initialize_events (void)
30954 + if (!pipe (gdbpy_event_fds))
30956 + gdbpy_event_list_end = &gdbpy_event_list;
30957 + add_file_handler (gdbpy_event_fds[0], gdbpy_run_events, NULL);
30965 +/* Callback function for use with iterate_over_threads. This function
30966 + just counts the number of threads. */
30969 +count_callback (struct thread_info *info, void *user_data)
30971 + int *count = (int *) user_data;
30976 +/* Structure for storing some state when iterating over threads. */
30978 +struct set_thread_info
30984 +/* Callback function for use with iterate_over_threads. This function
30985 + stores the thread ID into a Python tuple. */
30988 +update_tuple_callback (struct thread_info *info, void *user_data)
30990 + struct set_thread_info *tinfo = (struct set_thread_info *) user_data;
30991 + PyTuple_SetItem (tinfo->tuple, tinfo->index, PyInt_FromLong (info->num));
30996 +/* Python function which yields a tuple holding all valid thread IDs. */
30999 +gdbpy_threads (PyObject *unused1, PyObject *unused2)
31001 + int thread_count = 0;
31002 + struct set_thread_info info;
31003 + PyObject *result;
31005 + prune_threads ();
31006 + target_find_new_threads ();
31008 + iterate_over_threads (count_callback, &thread_count);
31010 + if (!thread_count)
31013 + result = PyTuple_New (thread_count);
31014 + info.tuple = result;
31016 + iterate_over_threads (update_tuple_callback, &info);
31020 +/* Python function that returns the current thread's ID. */
31023 +gdbpy_current_thread (PyObject *unused1, PyObject *unused2)
31025 + if (PIDGET (inferior_ptid) == 0)
31027 + return PyInt_FromLong (pid_to_thread_id (inferior_ptid));
31030 +/* Python function for switching to a given thread. */
31033 +gdbpy_switch_to_thread (PyObject *self, PyObject *args)
31036 + if (! PyArg_ParseTuple (args, "i", &id))
31038 + if (! valid_thread_id (id))
31039 + return PyErr_Format (PyExc_RuntimeError, "invalid thread id");
31040 + switch_to_thread (thread_id_to_pid (id));
31047 @@ -302,6 +888,769 @@ gdbpy_print_stack (void)
31053 +/* Script interface. */
31055 +/* True if 'gdb -P' was used, false otherwise. */
31056 +static int running_python_script;
31058 +/* True if we are currently in a call to 'gdb.cli', false otherwise. */
31059 +static int in_cli;
31061 +/* Enter the command loop. */
31064 +gdbpy_cli (PyObject *unused1, PyObject *unused2)
31066 + if (! running_python_script || in_cli)
31067 + return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
31070 + cli_command_loop ();
31076 +/* Set up the Python argument vector and evaluate a script. This is
31077 + used to implement 'gdb -P'. */
31080 +run_python_script (int argc, char **argv)
31083 + PyGILState_STATE state;
31085 + /* We never free this, since we plan to exit at the end. */
31086 + state = PyGILState_Ensure ();
31088 + running_python_script = 1;
31089 + PySys_SetArgv (argc - 1, argv + 1);
31090 + input = fopen (argv[0], "r");
31093 + fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno));
31096 + PyRun_SimpleFile (input, argv[0]);
31102 +source_python_script (FILE *stream, char *file)
31104 + PyGILState_STATE state;
31106 + state = PyGILState_Ensure ();
31108 + PyRun_SimpleFile (stream, file);
31111 + PyGILState_Release (state);
31116 +/* The "current" objfile. This is set when gdb detects that a new
31117 + objfile has been loaded. It is only set for the duration of a call
31118 + to gdbpy_new_objfile; it is NULL at other times. */
31119 +static struct objfile *gdbpy_current_objfile;
31121 +/* The file name we attempt to read. */
31122 +#define GDBPY_AUTO_FILENAME "-gdb.py"
31124 +/* This is a new_objfile observer callback which loads python code
31125 + based on the path to the objfile. */
31127 +gdbpy_new_objfile (struct objfile *objfile)
31130 + char *filename, *debugfile;
31133 + PyGILState_STATE state;
31134 + struct cleanup *cleanups;
31136 + if (!gdbpy_auto_load || !objfile || !objfile->name)
31139 + state = PyGILState_Ensure ();
31141 + gdbpy_current_objfile = objfile;
31143 + realname = gdb_realpath (objfile->name);
31144 + len = strlen (realname);
31145 + filename = xmalloc (len + sizeof (GDBPY_AUTO_FILENAME));
31146 + memcpy (filename, realname, len);
31147 + strcpy (filename + len, GDBPY_AUTO_FILENAME);
31149 + input = fopen (filename, "r");
31150 + debugfile = filename;
31152 + cleanups = make_cleanup (xfree, filename);
31153 + make_cleanup (xfree, realname);
31155 + if (!input && debug_file_directory)
31157 + /* Also try the same file in the separate debug info directory. */
31158 + debugfile = xmalloc (strlen (filename)
31159 + + strlen (debug_file_directory) + 1);
31160 + strcpy (debugfile, debug_file_directory);
31161 + /* FILENAME is absolute, so we don't need a "/" here. */
31162 + strcat (debugfile, filename);
31164 + make_cleanup (xfree, debugfile);
31165 + input = fopen (debugfile, "r");
31168 + if (!input && gdb_datadir)
31170 + /* Also try the same file in a subdirectory of gdb's data
31172 + debugfile = xmalloc (strlen (gdb_datadir) + strlen (filename)
31173 + + strlen ("/auto-load") + 1);
31174 + strcpy (debugfile, gdb_datadir);
31175 + strcat (debugfile, "/auto-load");
31176 + /* FILENAME is absolute, so we don't need a "/" here. */
31177 + strcat (debugfile, filename);
31179 + make_cleanup (xfree, debugfile);
31180 + input = fopen (debugfile, "r");
31185 + /* We don't want to throw an exception here -- but the user
31186 + would like to know that something went wrong. */
31187 + if (PyRun_SimpleFile (input, debugfile))
31188 + gdbpy_print_stack ();
31192 + do_cleanups (cleanups);
31193 + gdbpy_current_objfile = NULL;
31195 + PyGILState_Release (state);
31198 +/* Return the current Objfile, or None if there isn't one. */
31200 +gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
31202 + PyObject *result;
31204 + if (! gdbpy_current_objfile)
31207 + result = objfile_to_objfile_object (gdbpy_current_objfile);
31209 + Py_INCREF (result);
31213 +/* Return a sequence holding all the Objfiles. */
31215 +gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
31217 + struct objfile *objf;
31220 + list = PyList_New (0);
31224 + ALL_OBJFILES (objf)
31226 + PyObject *item = objfile_to_objfile_object (objf);
31227 + if (!item || PyList_Append (list, item) == -1)
31229 + Py_DECREF (list);
31239 +/* Helper function for find_pretty_printer which iterates over a
31240 + list, calls each function and inspects output. */
31242 +search_pp_list (PyObject *list, PyObject *value)
31244 + Py_ssize_t pp_list_size, list_index;
31245 + PyObject *function, *printer = NULL;
31247 + pp_list_size = PyList_Size (list);
31248 + for (list_index = 0; list_index < pp_list_size; list_index++)
31250 + function = PyList_GetItem (list, list_index);
31254 + /* gdbpy_instantiate_printer can return three possible return
31255 + values: NULL on error; Py_None if the pretty-printer
31256 + in the list cannot print the value; or a printer instance if
31257 + the printer can print the value. */
31258 + printer = gdbpy_instantiate_printer (function, value);
31261 + else if (printer != Py_None)
31264 + Py_DECREF (printer);
31270 +/* Find the pretty-printing constructor function for TYPE. If no
31271 + pretty-printer exists, return NULL. If one exists, return a new
31274 +find_pretty_printer (PyObject *value)
31276 + PyObject *pp_list = NULL;
31277 + PyObject *function = NULL;
31278 + struct objfile *obj;
31279 + volatile struct gdb_exception except;
31281 + /* Look at the pretty-printer dictionary for each objfile. */
31282 + ALL_OBJFILES (obj)
31284 + PyObject *objf = objfile_to_objfile_object (obj);
31288 + pp_list = objfpy_get_printers (objf, NULL);
31289 + function = search_pp_list (pp_list, value);
31291 + /* If there is an error in any objfile list, abort the search and
31295 + Py_XDECREF (pp_list);
31299 + if (function != Py_None)
31302 + /* In this loop, if function is not an instantiation of a
31303 + pretty-printer, and it is not null, then it is a return of
31304 + Py_RETURN_NONE, which must be decremented. */
31305 + Py_DECREF (function);
31306 + Py_XDECREF (pp_list);
31310 + /* Fetch the global pretty printer dictionary. */
31311 + if (! PyObject_HasAttrString (gdb_module, "pretty_printers"))
31313 + pp_list = PyObject_GetAttrString (gdb_module, "pretty_printers");
31316 + if (! PyList_Check (pp_list))
31319 + function = search_pp_list (pp_list, value);
31322 + Py_XDECREF (pp_list);
31327 +/* Pretty-print a single value, via the printer object PRINTER. If
31328 + the function returns a string, an xmalloc()d copy is returned.
31329 + Otherwise, if the function returns a value, a *OUT_VALUE is set to
31330 + the value, and NULL is returned. On error, *OUT_VALUE is set to
31331 + NULL and NULL is returned. */
31333 +pretty_print_one_value (PyObject *printer, struct value **out_value)
31335 + char *output = NULL;
31336 + volatile struct gdb_exception except;
31338 + TRY_CATCH (except, RETURN_MASK_ALL)
31340 + PyObject *result;
31342 + result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
31345 + if (gdbpy_is_string (result))
31346 + output = python_string_to_host_string (result);
31347 + else if (PyObject_TypeCheck (result, &value_object_type))
31349 + /* If we just call convert_value_from_python for this
31350 + type, we won't know who owns the result. For this
31351 + one case we need to copy the resulting value. */
31352 + struct value *v = value_object_to_value (result);
31353 + *out_value = value_copy (v);
31356 + *out_value = convert_value_from_python (result);
31357 + Py_DECREF (result);
31364 +/* Instantiate a pretty-printer given a constructor, CONS, and a
31365 + value, VAL. Return NULL on error. Ownership of the object
31366 + instance is transferred to the reciever */
31368 +gdbpy_instantiate_printer (PyObject *cons, PyObject *value)
31370 + PyObject *result;
31371 + result = PyObject_CallFunctionObjArgs (cons, value, NULL);
31375 +/* Return the display hint for the object printer, PRINTER. Return
31376 + NULL if there is no display_hint method, or if the method did not
31377 + return a string. On error, print stack trace and return NULL. On
31378 + success, return an xmalloc()d string. */
31380 +gdbpy_get_display_hint (PyObject *printer)
31383 + char *result = NULL;
31385 + if (! PyObject_HasAttr (printer, gdbpy_display_hint_cst))
31388 + hint = PyObject_CallMethodObjArgs (printer, gdbpy_display_hint_cst, NULL);
31389 + if (gdbpy_is_string (hint))
31390 + result = python_string_to_host_string (hint);
31392 + Py_DECREF (hint);
31394 + gdbpy_print_stack ();
31399 +/* Helper for apply_val_pretty_printer which calls to_string and
31400 + formats the result. */
31402 +print_string_repr (PyObject *printer, const char *hint,
31403 + struct ui_file *stream, int recurse,
31404 + const struct value_print_options *options,
31405 + const struct language_defn *language)
31408 + struct value *replacement = NULL;
31410 + output = pretty_print_one_value (printer, &replacement);
31413 + if (hint && !strcmp (hint, "string"))
31415 + struct type *string_char_type;
31417 + /* OUTPUT is already in the hosts's charset. */
31418 + string_char_type = language_string_char_type (language,
31419 + current_gdbarch);
31420 + LA_PRINT_STRING (stream, string_char_type, (gdb_byte *) output,
31421 + strlen (output), 0, options);
31424 + fputs_filtered (output, stream);
31427 + else if (replacement)
31428 + common_val_print (replacement, stream, recurse, options, language);
31430 + gdbpy_print_stack ();
31434 +py_restore_tstate (void *p)
31436 + PyFrameObject *frame = p;
31437 + PyThreadState *tstate = PyThreadState_GET ();
31438 + tstate->frame = frame;
31441 +/* Create a dummy PyFrameObject, needed to work around
31442 + a Python-2.4 bug with generators. */
31444 +push_dummy_python_frame ()
31446 + PyObject *empty_string, *null_tuple, *globals;
31447 + PyCodeObject *code;
31448 + PyFrameObject *frame;
31449 + PyThreadState *tstate;
31451 + empty_string = PyString_FromString ("");
31452 + if (!empty_string)
31455 + null_tuple = PyTuple_New (0);
31458 + Py_DECREF (empty_string);
31462 + code = PyCode_New (0, /* argcount */
31464 + 0, /* stacksize */
31466 + empty_string, /* code */
31467 + null_tuple, /* consts */
31468 + null_tuple, /* names */
31469 + null_tuple, /* varnames */
31470 +#if PYTHON_API_VERSION >= 1010
31471 + null_tuple, /* freevars */
31472 + null_tuple, /* cellvars */
31474 + empty_string, /* filename */
31475 + empty_string, /* name */
31476 + 1, /* firstlineno */
31477 + empty_string /* lnotab */
31480 + Py_DECREF (empty_string);
31481 + Py_DECREF (null_tuple);
31486 + globals = PyDict_New ();
31489 + Py_DECREF (code);
31493 + tstate = PyThreadState_GET ();
31495 + frame = PyFrame_New (tstate, code, globals, NULL);
31497 + Py_DECREF (globals);
31498 + Py_DECREF (code);
31503 + tstate->frame = frame;
31504 + make_cleanup (py_restore_tstate, frame->f_back);
31505 + return (PyObject *) frame;
31508 +/* Helper for apply_val_pretty_printer that formats children of the
31509 + printer, if any exist. */
31511 +print_children (PyObject *printer, const char *hint,
31512 + struct ui_file *stream, int recurse,
31513 + const struct value_print_options *options,
31514 + const struct language_defn *language)
31516 + int is_map, is_array, done_flag, pretty;
31518 + PyObject *children, *iter, *frame;
31519 + struct cleanup *cleanups;
31521 + if (! PyObject_HasAttr (printer, gdbpy_children_cst))
31524 + /* If we are printing a map or an array, we want some special
31526 + is_map = hint && ! strcmp (hint, "map");
31527 + is_array = hint && ! strcmp (hint, "array");
31529 + children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
31533 + gdbpy_print_stack ();
31537 + cleanups = make_cleanup_py_decref (children);
31539 + iter = PyObject_GetIter (children);
31542 + gdbpy_print_stack ();
31545 + make_cleanup_py_decref (iter);
31547 + /* Use the prettyprint_arrays option if we are printing an array,
31548 + and the pretty option otherwise. */
31549 + pretty = is_array ? options->prettyprint_arrays : options->pretty;
31551 + /* Manufacture a dummy Python frame to work around Python 2.4 bug,
31552 + where it insists on having a non-NULL tstate->frame when
31553 + a generator is called. */
31554 + frame = push_dummy_python_frame ();
31557 + gdbpy_print_stack ();
31560 + make_cleanup_py_decref (frame);
31563 + for (i = 0; i < options->print_max; ++i)
31565 + PyObject *py_v, *item = PyIter_Next (iter);
31567 + struct cleanup *inner_cleanup;
31571 + if (PyErr_Occurred ())
31572 + gdbpy_print_stack ();
31573 + /* Set a flag so we can know whether we printed all the
31574 + available elements. */
31580 + if (! PyArg_ParseTuple (item, "sO", &name, &py_v))
31582 + gdbpy_print_stack ();
31583 + Py_DECREF (item);
31586 + inner_cleanup = make_cleanup_py_decref (item);
31588 + /* Print initial "{". For other elements, there are three
31590 + 1. Maps. Print a "," after each value element.
31591 + 2. Arrays. Always print a ",".
31592 + 3. Other. Always print a ",". */
31594 + fputs_filtered (" = {", stream);
31595 + else if (! is_map || i % 2 == 0)
31596 + fputs_filtered (pretty ? "," : ", ", stream);
31598 + /* In summary mode, we just want to print "= {...}" if there is
31600 + if (options->summary)
31602 + /* This increment tricks the post-loop logic to print what
31610 + if (! is_map || i % 2 == 0)
31614 + fputs_filtered ("\n", stream);
31615 + print_spaces_filtered (2 + 2 * recurse, stream);
31618 + wrap_here (n_spaces (2 + 2 *recurse));
31621 + if (is_map && i % 2 == 0)
31622 + fputs_filtered ("[", stream);
31623 + else if (is_array)
31625 + /* We print the index, not whatever the child method
31626 + returned as the name. */
31627 + if (options->print_array_indexes)
31628 + fprintf_filtered (stream, "[%d] = ", i);
31630 + else if (! is_map)
31632 + fputs_filtered (name, stream);
31633 + fputs_filtered (" = ", stream);
31636 + if (gdbpy_is_string (py_v))
31638 + char *text = python_string_to_host_string (py_v);
31640 + gdbpy_print_stack ();
31643 + fputs_filtered (text, stream);
31649 + struct value *value = convert_value_from_python (py_v);
31651 + if (value == NULL)
31653 + gdbpy_print_stack ();
31654 + error (_("Error while executing Python code."));
31657 + common_val_print (value, stream, recurse + 1, options, language);
31660 + if (is_map && i % 2 == 0)
31661 + fputs_filtered ("] = ", stream);
31663 + do_cleanups (inner_cleanup);
31672 + fputs_filtered ("\n", stream);
31673 + print_spaces_filtered (2 + 2 * recurse, stream);
31675 + fputs_filtered ("...", stream);
31679 + fputs_filtered ("\n", stream);
31680 + print_spaces_filtered (2 * recurse, stream);
31682 + fputs_filtered ("}", stream);
31686 + do_cleanups (cleanups);
31690 +apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
31691 + int embedded_offset, CORE_ADDR address,
31692 + struct ui_file *stream, int recurse,
31693 + const struct value_print_options *options,
31694 + const struct language_defn *language)
31696 + PyObject *printer = NULL;
31697 + PyObject *val_obj = NULL;
31698 + struct value *value;
31699 + char *hint = NULL;
31700 + struct cleanup *cleanups;
31702 + PyGILState_STATE state;
31704 + state = PyGILState_Ensure ();
31705 + cleanups = make_cleanup_py_restore_gil (&state);
31707 + /* Instantiate the printer. */
31709 + valaddr += embedded_offset;
31710 + value = value_from_contents_and_address (type, valaddr, address);
31712 + val_obj = value_to_value_object (value);
31716 + /* Find the constructor. */
31717 + printer = find_pretty_printer (val_obj);
31718 + Py_DECREF (val_obj);
31719 + make_cleanup_py_decref (printer);
31720 + if (! printer || printer == Py_None)
31723 + /* If we are printing a map, we want some special formatting. */
31724 + hint = gdbpy_get_display_hint (printer);
31725 + make_cleanup (free_current_contents, &hint);
31727 + /* Print the section */
31728 + print_string_repr (printer, hint, stream, recurse, options, language);
31729 + print_children (printer, hint, stream, recurse, options, language);
31734 + if (PyErr_Occurred ())
31735 + gdbpy_print_stack ();
31736 + do_cleanups (cleanups);
31740 +/* Apply a pretty-printer for the varobj code. PRINTER_OBJ is the
31741 + print object. It must have a 'to_string' method (but this is
31742 + checked by varobj, not here) which takes no arguments and
31743 + returns a string. This function returns an xmalloc()d string if
31744 + the printer returns a string. The printer may return a replacement
31745 + value instead; in this case *REPLACEMENT is set to the replacement
31746 + value, and this function returns NULL. On error, *REPLACEMENT is
31747 + set to NULL and this function also returns NULL. */
31749 +apply_varobj_pretty_printer (PyObject *printer_obj,
31750 + struct value **replacement)
31753 + PyGILState_STATE state = PyGILState_Ensure ();
31755 + *replacement = NULL;
31756 + result = pretty_print_one_value (printer_obj, replacement);
31757 + if (result == NULL);
31758 + gdbpy_print_stack ();
31759 + PyGILState_Release (state);
31764 +/* Find a pretty-printer object for the varobj module. Returns a new
31765 + reference to the object if successful; returns NULL if not. VALUE
31766 + is the value for which a printer tests to determine if it
31767 + can pretty-print the value. */
31769 +gdbpy_get_varobj_pretty_printer (struct value *value)
31771 + PyObject *val_obj;
31772 + PyObject *pretty_printer = NULL;
31773 + volatile struct gdb_exception except;
31775 + TRY_CATCH (except, RETURN_MASK_ALL)
31777 + value = value_copy (value);
31779 + GDB_PY_HANDLE_EXCEPTION (except);
31781 + val_obj = value_to_value_object (value);
31785 + pretty_printer = find_pretty_printer (val_obj);
31786 + Py_DECREF (val_obj);
31787 + return pretty_printer;
31790 +/* A Python function which wraps find_pretty_printer and instantiates
31791 + the resulting class. This accepts a Value argument and returns a
31792 + pretty printer instance, or None. This function is useful as an
31793 + argument to the MI command -var-set-visualizer. */
31795 +gdbpy_default_visualizer (PyObject *self, PyObject *args)
31797 + PyObject *val_obj;
31798 + PyObject *cons, *printer = NULL;
31799 + struct value *value;
31801 + if (! PyArg_ParseTuple (args, "O", &val_obj))
31803 + value = value_object_to_value (val_obj);
31806 + PyErr_SetString (PyExc_TypeError, "argument must be a gdb.Value");
31810 + cons = find_pretty_printer (val_obj);
31814 #else /* HAVE_PYTHON */
31816 /* Dummy implementation of the gdb "python" command. */
31817 @@ -328,6 +1677,24 @@ eval_python_from_control_command (struct command_line *cmd)
31818 error (_("Python scripting is not supported in this copy of GDB."));
31822 +apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
31823 + int embedded_offset, CORE_ADDR address,
31824 + struct ui_file *stream, int format,
31825 + int deref_ref, int recurse,
31826 + enum val_prettyprint pretty,
31827 + const struct language_defn *language)
31833 +source_python_script (FILE *stream)
31836 + error (_("Python scripting is not supported in this copy of GDB."));
31839 #endif /* HAVE_PYTHON */
31842 @@ -355,9 +1722,6 @@ show_python (char *args, int from_tty)
31844 /* Initialize the Python code. */
31846 -/* Provide a prototype to silence -Wmissing-prototypes. */
31847 -extern initialize_file_ftype _initialize_python;
31850 _initialize_python (void)
31852 @@ -400,6 +1764,15 @@ Enables or disables printing of Python stack traces."),
31854 &show_python_list);
31856 + add_setshow_boolean_cmd ("auto-load", class_maintenance,
31857 + &gdbpy_auto_load, _("\
31858 +Enable or disable auto-loading of Python code when an object is opened."), _("\
31859 +Show whether Python code will be auto-loaded when an object is opened."), _("\
31860 +Enables or disables auto-loading of Python code when an object is opened."),
31862 + &set_python_list,
31863 + &show_python_list);
31867 PyEval_InitThreads ();
31868 @@ -410,11 +1783,36 @@ Enables or disables printing of Python stack traces."),
31869 PyModule_AddStringConstant (gdb_module, "VERSION", (char*) version);
31870 PyModule_AddStringConstant (gdb_module, "HOST_CONFIG", (char*) host_name);
31871 PyModule_AddStringConstant (gdb_module, "TARGET_CONFIG", (char*) target_name);
31873 + PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR);
31876 + PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir);
31879 gdbpy_initialize_values ();
31880 + gdbpy_initialize_breakpoints ();
31881 + gdbpy_initialize_frames ();
31882 + gdbpy_initialize_symtabs ();
31883 gdbpy_initialize_commands ();
31884 + gdbpy_initialize_symbols ();
31885 + gdbpy_initialize_blocks ();
31886 + gdbpy_initialize_functions ();
31887 + gdbpy_initialize_types ();
31888 + gdbpy_initialize_parameters ();
31889 + gdbpy_initialize_objfile ();
31890 + gdbpy_initialize_events ();
31891 + gdbpy_initialize_membuf ();
31893 PyRun_SimpleString ("import gdb");
31894 + PyRun_SimpleString ("gdb.pretty_printers = []");
31896 + observer_attach_new_objfile (gdbpy_new_objfile);
31898 + gdbpy_to_string_cst = PyString_FromString ("to_string");
31899 + gdbpy_children_cst = PyString_FromString ("children");
31900 + gdbpy_display_hint_cst = PyString_FromString ("display_hint");
31901 + gdbpy_doc_cst = PyString_FromString ("__doc__");
31903 gdbpy_doc_cst = PyString_FromString ("__doc__");
31905 @@ -442,6 +1840,15 @@ class GdbOutputFile:\n\
31907 sys.stderr = GdbOutputFile()\n\
31908 sys.stdout = GdbOutputFile()\n\
31909 +if hasattr (gdb, 'datadir'):\n\
31910 + gdb.pythondir = gdb.datadir + '/python'\n\
31911 +if hasattr (gdb, 'pythondir'):\n\
31912 + sys.path.insert(0, gdb.pythondir)\n\
31913 + gdb.__path__ = [gdb.pythondir + '/gdb']\n\
31914 + from os.path import exists\n\
31915 + ipy = gdb.pythondir + '/gdb/__init__.py'\n\
31916 + if exists (ipy):\n\
31917 + execfile (ipy)\n\
31920 /* Release the GIL while gdb runs. */
31921 @@ -461,9 +1868,79 @@ static PyMethodDef GdbMethods[] =
31922 "Get a value from history" },
31923 { "execute", execute_gdb_command, METH_VARARGS,
31924 "Execute a gdb command" },
31925 - { "get_parameter", get_parameter, METH_VARARGS,
31926 + { "cli", gdbpy_cli, METH_NOARGS,
31927 + "Enter the gdb CLI" },
31928 + { "parameter", gdbpy_parameter, METH_VARARGS,
31929 "Return a gdb parameter's value" },
31931 + { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
31932 + "Return a tuple of all breakpoint objects" },
31934 + { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS,
31935 + "Find the default visualizer for a Value." },
31937 + { "current_objfile", gdbpy_get_current_objfile, METH_NOARGS,
31938 + "Return the current Objfile being loaded, or None." },
31939 + { "objfiles", gdbpy_objfiles, METH_NOARGS,
31940 + "Return a sequence of all loaded objfiles." },
31942 + { "frames", gdbpy_frames, METH_NOARGS,
31943 + "frames () -> (gdb.Frame, ...).\n\
31944 +Return a tuple of all frame objects." },
31945 + { "newest_frame", gdbpy_newest_frame, METH_NOARGS,
31946 + "newest_frame () -> gdb.Frame.\n\
31947 +Return the newest frame object." },
31948 + { "selected_frame", gdbpy_selected_frame, METH_NOARGS,
31949 + "selected_frame () -> gdb.Frame.\n\
31950 +Return the selected frame object." },
31951 + { "frame_stop_reason_string", gdbpy_frame_stop_reason_string, METH_VARARGS,
31952 + "stop_reason_string (Integer) -> String.\n\
31953 +Return a string explaining unwind stop reason." },
31955 + { "lookup_symbol", (PyCFunction) gdbpy_lookup_symbol,
31956 + METH_VARARGS | METH_KEYWORDS,
31957 + "lookup_symbol (name [, block] [, domain]) -> (symbol, is_field_of_this)\n\
31958 +Return a tuple with the symbol corresponding to the given name (or None) and\n\
31959 +a boolean indicating if name is a field of the current implied argument\n\
31960 +`this' (when the current language is object-oriented)." },
31961 + { "solib_address", gdbpy_solib_address, METH_VARARGS,
31962 + "solib_address (Long) -> String.\n\
31963 +Return the name of the shared library holding a given address, or None." },
31965 + { "find_pc_function", gdbpy_find_pc_function, METH_VARARGS,
31966 + "Return the function containing the given pc value, or None." },
31968 + { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS,
31969 + "Return the block containing the given pc value, or None." },
31971 + { "decode_line", gdbpy_decode_line, METH_VARARGS,
31972 + "Decode a string argument the way that 'break' or 'edit' does.\n\
31973 +Return a tuple holding the file name (or None) and line number (or None).\n\
31974 +Note: may later change to return an object." },
31976 + { "threads", gdbpy_threads, METH_NOARGS,
31977 + "Return a tuple holding all the valid thread IDs." },
31978 + { "current_thread", gdbpy_current_thread, METH_NOARGS,
31979 + "Return the thread ID of the current thread." },
31980 + { "switch_to_thread", gdbpy_switch_to_thread, METH_VARARGS,
31981 + "Switch to a thread, given the thread ID." },
31983 + { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS,
31984 + "Parse a string as an expression, evaluate it, and return the result." },
31986 + { "post_event", gdbpy_post_event, METH_VARARGS,
31987 + "Post an event into gdb's event loop." },
31989 + { "read_memory", gdbpy_read_memory, METH_VARARGS,
31990 + "read_memory (address, length) -> buffer\n\
31991 +Return a buffer object for reading from the inferior's memory." },
31992 + { "write_memory", gdbpy_write_memory, METH_VARARGS,
31993 + "write_memory (address, buffer [, length])\n\
31994 +Write the given buffer object to the inferior's memory." },
31995 + { "search_memory", (PyCFunction) gdbpy_search_memory, METH_VARARGS | METH_KEYWORDS,
31996 + "search_memory (address, length, pattern [, size] [, max_count]) -> list\n\
31997 +Return a list with the addresses where matches were found." },
31999 { "write", gdbpy_write, METH_VARARGS,
32000 "Write a string using gdb's filtered stream." },
32001 { "flush", gdbpy_flush, METH_NOARGS,
32002 diff --git a/gdb/python/python.h b/gdb/python/python.h
32003 index e63c447..767af86 100644
32004 --- a/gdb/python/python.h
32005 +++ b/gdb/python/python.h
32006 @@ -26,4 +26,14 @@ extern struct value *values_in_python;
32008 void eval_python_from_control_command (struct command_line *);
32010 +void source_python_script (FILE *stream, char *file);
32012 +void run_python_script (int argc, char **argv);
32014 +int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
32015 + int embedded_offset, CORE_ADDR address,
32016 + struct ui_file *stream, int recurse,
32017 + const struct value_print_options *options,
32018 + const struct language_defn *language);
32020 #endif /* GDB_PYTHON_H */
32021 diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
32022 index 345befd..e2568c8 100644
32023 --- a/gdb/scm-lang.c
32024 +++ b/gdb/scm-lang.c
32025 @@ -43,14 +43,14 @@ static int in_eval_c (void);
32026 struct type *builtin_type_scm;
32029 -scm_printchar (int c, struct ui_file *stream)
32030 +scm_printchar (int c, struct type *type, struct ui_file *stream)
32032 fprintf_filtered (stream, "#\\%c", c);
32036 -scm_printstr (struct ui_file *stream, const gdb_byte *string,
32037 - unsigned int length, int width, int force_ellipses,
32038 +scm_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
32039 + unsigned int length, int force_ellipses,
32040 const struct value_print_options *options)
32042 fprintf_filtered (stream, "\"%s\"", string);
32043 diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
32044 index 6bf88f5..1798b2f 100644
32045 --- a/gdb/scm-lang.h
32046 +++ b/gdb/scm-lang.h
32047 @@ -59,7 +59,7 @@ extern void scm_scmval_print (LONGEST, struct ui_file *, int,
32049 extern int is_scmvalue_type (struct type *);
32051 -extern void scm_printchar (int, struct ui_file *);
32052 +extern void scm_printchar (int, struct type *, struct ui_file *);
32054 extern struct value *scm_evaluate_string (char *, int);
32056 diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
32057 index f0a7642..a32add5 100644
32058 --- a/gdb/scm-valprint.c
32059 +++ b/gdb/scm-valprint.c
32060 @@ -187,7 +187,8 @@ taloop:
32061 if (SCM_ICHRP (svalue))
32063 svalue = SCM_ICHR (svalue);
32064 - scm_printchar (svalue, stream);
32065 + scm_printchar (svalue, builtin_type (current_gdbarch)->builtin_char,
32069 else if (SCM_IFLAGP (svalue)
32070 diff --git a/gdb/stabsread.c b/gdb/stabsread.c
32071 index 2d7eb15..7423b32 100644
32072 --- a/gdb/stabsread.c
32073 +++ b/gdb/stabsread.c
32074 @@ -322,7 +322,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
32076 if (typenums[0] == -1)
32078 - return (alloc_type (objfile));
32079 + return (alloc_type (objfile, NULL));
32082 type_addr = dbx_lookup_type (typenums);
32083 @@ -332,7 +332,7 @@ dbx_alloc_type (int typenums[2], struct objfile *objfile)
32084 We will fill it in later if we find out how. */
32085 if (*type_addr == 0)
32087 - *type_addr = alloc_type (objfile);
32088 + *type_addr = alloc_type (objfile, NULL);
32091 return (*type_addr);
32092 @@ -589,6 +589,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
32096 + char *new_name = NULL;
32098 /* We would like to eliminate nameless symbols, but keep their types.
32099 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
32100 @@ -683,9 +684,37 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
32103 SYMBOL_LANGUAGE (sym) = current_subfile->language;
32104 - SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32105 + if (current_subfile->language == language_cplus)
32107 + char *name = alloca (p - string + 1);
32108 + memcpy (name, string, p - string);
32109 + name[p - string] = '\0';
32110 + new_name = cp_canonicalize_string (name);
32113 + if (new_name != NULL)
32115 + SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
32116 + xfree (new_name);
32119 + SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32121 if (SYMBOL_LANGUAGE (sym) == language_cplus)
32122 - cp_scan_for_anonymous_namespaces (sym);
32124 + char *name = alloca (p - string + 1);
32125 + memcpy (name, string, p - string);
32126 + name[p - string] = '\0';
32127 + new_name = cp_canonicalize_string (name);
32128 + cp_scan_for_anonymous_namespaces (sym);
32130 + if (new_name != NULL)
32132 + SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
32133 + xfree (new_name);
32136 + SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32140 @@ -1519,18 +1548,35 @@ again:
32142 return error_type (pp, objfile);
32145 - (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
32147 - /* Copy the name. */
32152 + type_name = NULL;
32153 + if (current_subfile->language == language_cplus)
32155 + char *new_name, *name = alloca (p - *pp + 1);
32156 + memcpy (name, *pp, p - *pp);
32157 + name[p - *pp] = '\0';
32158 + new_name = cp_canonicalize_string (name);
32159 + if (new_name != NULL)
32161 + type_name = obsavestring (new_name, strlen (new_name),
32162 + &objfile->objfile_obstack);
32163 + xfree (new_name);
32166 + if (type_name == NULL)
32169 + (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
32171 + /* Copy the name. */
32178 /* Set the pointer ahead of the name which we just read, and
32184 /* If this type has already been declared, then reuse the same
32185 diff --git a/gdb/stack.c b/gdb/stack.c
32186 index 3bcf758..094a4ce 100644
32189 @@ -380,6 +380,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
32191 get_raw_print_options (&opts);
32192 opts.deref_ref = 0;
32193 + opts.summary = 1;
32194 common_val_print (val, stb->stream, 2,
32196 ui_out_field_stream (uiout, "value", stb);
32197 @@ -579,20 +580,16 @@ print_frame_info (struct frame_info *frame, int print_level,
32198 gdb_flush (gdb_stdout);
32202 -print_frame (struct frame_info *frame, int print_level,
32203 - enum print_what print_what, int print_args,
32204 - struct symtab_and_line sal)
32205 +/* Attempt to obtain the FUNNAME and FUNLANG of the function corresponding
32208 +find_frame_funname (struct frame_info *frame, char **funname,
32209 + enum language *funlang)
32211 struct symbol *func;
32212 - char *funname = NULL;
32213 - enum language funlang = language_unknown;
32214 - struct ui_stream *stb;
32215 - struct cleanup *old_chain, *list_chain;
32216 - struct value_print_options opts;
32218 - stb = ui_out_stream_new (uiout);
32219 - old_chain = make_cleanup_ui_out_stream_delete (stb);
32221 + *funlang = language_unknown;
32223 func = find_pc_function (get_frame_address_in_block (frame));
32225 @@ -625,24 +622,24 @@ print_frame (struct frame_info *frame, int print_level,
32226 /* We also don't know anything about the function besides
32227 its address and name. */
32229 - funname = SYMBOL_PRINT_NAME (msymbol);
32230 - funlang = SYMBOL_LANGUAGE (msymbol);
32231 + *funname = SYMBOL_PRINT_NAME (msymbol);
32232 + *funlang = SYMBOL_LANGUAGE (msymbol);
32236 - funname = SYMBOL_PRINT_NAME (func);
32237 - funlang = SYMBOL_LANGUAGE (func);
32238 - if (funlang == language_cplus)
32239 + *funname = SYMBOL_PRINT_NAME (func);
32240 + *funlang = SYMBOL_LANGUAGE (func);
32241 + if (*funlang == language_cplus)
32243 /* It seems appropriate to use SYMBOL_PRINT_NAME() here,
32244 to display the demangled name that we already have
32245 stored in the symbol table, but we stored a version
32246 with DMGL_PARAMS turned on, and here we don't want to
32247 display parameters. So remove the parameters. */
32248 - char *func_only = cp_remove_params (funname);
32249 + char *func_only = cp_remove_params (*funname);
32252 - funname = func_only;
32253 + *funname = func_only;
32254 make_cleanup (xfree, func_only);
32257 @@ -655,10 +652,27 @@ print_frame (struct frame_info *frame, int print_level,
32259 if (msymbol != NULL)
32261 - funname = SYMBOL_PRINT_NAME (msymbol);
32262 - funlang = SYMBOL_LANGUAGE (msymbol);
32263 + *funname = SYMBOL_PRINT_NAME (msymbol);
32264 + *funlang = SYMBOL_LANGUAGE (msymbol);
32270 +print_frame (struct frame_info *frame, int print_level,
32271 + enum print_what print_what, int print_args,
32272 + struct symtab_and_line sal)
32274 + char *funname = NULL;
32275 + enum language funlang = language_unknown;
32276 + struct ui_stream *stb;
32277 + struct cleanup *old_chain, *list_chain;
32278 + struct value_print_options opts;
32280 + stb = ui_out_stream_new (uiout);
32281 + old_chain = make_cleanup_ui_out_stream_delete (stb);
32283 + find_frame_funname (frame, &funname, &funlang);
32285 annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
32286 get_frame_pc (frame));
32287 @@ -694,7 +708,7 @@ print_frame (struct frame_info *frame, int print_level,
32288 struct print_args_args args;
32289 struct cleanup *args_list_chain;
32290 args.frame = frame;
32291 - args.func = func;
32292 + args.func = find_pc_function (get_frame_address_in_block (frame));
32293 args.stream = gdb_stdout;
32294 args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args");
32295 catch_errors (print_args_stub, &args, "", RETURN_MASK_ERROR);
32296 @@ -1208,24 +1222,24 @@ backtrace_command_1 (char *count_exp, int show_locals, int from_tty)
32300 - if (info_verbose)
32302 - struct partial_symtab *ps;
32304 - /* Read in symbols for all of the frames. Need to do this in a
32305 - separate pass so that "Reading in symbols for xxx" messages
32306 - don't screw up the appearance of the backtrace. Also if
32307 - people have strong opinions against reading symbols for
32308 - backtrace this may have to be an option. */
32310 - for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi))
32313 - ps = find_pc_psymtab (get_frame_address_in_block (fi));
32315 - PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in. */
32319 + struct partial_symtab *ps;
32321 + /* Read in symbols for all of the frames. Need to do this
32322 + unconditionally to ensure that psymbols are read. Also need to
32323 + do this in a separate pass so that "Reading in symbols for xxx"
32324 + messages don't screw up the appearance of the backtrace. Also
32325 + if people have strong opinions against reading symbols for
32326 + backtrace this may have to be an option. */
32328 + for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi))
32331 + ps = find_pc_psymtab (get_frame_address_in_block (fi));
32332 + if (info_verbose && ps)
32333 + PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in. */
32337 for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi))
32339 @@ -1373,6 +1387,8 @@ print_block_frame_locals (struct block *b, struct frame_info *frame,
32341 if (SYMBOL_IS_ARGUMENT (sym))
32343 + if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
32345 values_printed = 1;
32346 print_variable_and_value (NULL, sym, frame, stream, 4 * num_tabs);
32348 @@ -1796,18 +1812,27 @@ return_command (char *retval_exp, int from_tty)
32352 + struct expression *retval_expr = parse_expression (retval_exp);
32353 + struct cleanup *old_chain = make_cleanup (xfree, retval_expr);
32354 struct type *return_type = NULL;
32356 /* Compute the return value. Should the computation fail, this
32357 call throws an error. */
32358 - return_value = parse_and_eval (retval_exp);
32359 + return_value = evaluate_expression (retval_expr);
32361 /* Cast return value to the return type of the function. Should
32362 the cast fail, this call throws an error. */
32363 if (thisfun != NULL)
32364 return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun));
32365 if (return_type == NULL)
32366 - return_type = builtin_type (get_frame_arch (thisframe))->builtin_int;
32368 + if (retval_expr->elts[0].opcode != UNOP_CAST)
32369 + error (_("Return value type not available for selected "
32371 + "Please use an explicit cast of the value to return."));
32372 + return_type = value_type (return_value);
32374 + do_cleanups (old_chain);
32375 CHECK_TYPEDEF (return_type);
32376 return_value = value_cast (return_type, return_value);
32378 diff --git a/gdb/stack.h b/gdb/stack.h
32379 index 973a57f..56b1d91 100644
32384 void select_frame_command (char *level_exp, int from_tty);
32386 +/* Attempt to obtain the FUNNAME and FUNLANG of the function corresponding
32388 +void find_frame_funname (struct frame_info *frame, char **funname,
32389 + enum language *funlang);
32391 #endif /* #ifndef STACK_H */
32392 diff --git a/gdb/symfile.c b/gdb/symfile.c
32393 index 63b5c1d..b047e94 100644
32394 --- a/gdb/symfile.c
32395 +++ b/gdb/symfile.c
32396 @@ -929,6 +929,17 @@ new_symfile_objfile (struct objfile *objfile, int mainline, int verbo)
32397 clear_complaints (&symfile_complaints, 0, verbo);
32400 +/* A helper function which returns true if OBJFILE has any debug
32401 + symbols, and false otherwise. */
32403 +has_any_debug_symbols (struct objfile *objfile)
32405 + return (objfile->psymtabs || objfile->quick_addrmap
32406 + || (objfile->separate_debug_objfile
32407 + && (objfile->separate_debug_objfile->psymtabs
32408 + || objfile->separate_debug_objfile->quick_addrmap)));
32411 /* Process a symbol file, as either the main file or as a dynamically
32414 @@ -965,13 +976,15 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32415 /* Give user a chance to burp if we'd be
32416 interactively wiping out any existing symbols. */
32418 - if ((have_full_symbols () || have_partial_symbols ())
32422 + && (have_full_symbols () || have_partial_symbols ())
32423 && !query (_("Load new symbol table from \"%s\"? "), name))
32424 error (_("Not confirmed."));
32426 objfile = allocate_objfile (abfd, flags);
32428 + objfile->flags |= OBJF_MAIN;
32429 discard_cleanups (my_cleanups);
32432 @@ -1007,6 +1020,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32434 if ((flags & OBJF_READNOW) || readnow_symbol_files)
32436 + require_partial_symbols (objfile);
32438 if ((from_tty || info_verbose) && print_symbol_loading)
32440 printf_unfiltered (_("expanding to full symbols..."));
32441 @@ -1025,7 +1040,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32442 /* If the file has its own symbol tables it has no separate debug info.
32443 `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS.
32444 `.gnu_debuglink' may no longer be present with `.note.gnu.build-id'. */
32445 - if (objfile->psymtabs == NULL)
32446 + if (!has_any_debug_symbols (objfile))
32447 debugfile = find_separate_debug_file (objfile);
32450 @@ -1049,8 +1064,10 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32454 - if (!have_partial_symbols () && !have_full_symbols ()
32455 - && print_symbol_loading)
32456 + /* has_any_debug_symbols is not fully compatible with the former calls which
32457 + would just be needlessly expensive here. */
32458 + if ((from_tty || info_verbose) && print_symbol_loading
32459 + && !has_any_debug_symbols (objfile) && mainline)
32462 printf_unfiltered (_("(no debugging symbols found)"));
32463 @@ -2423,13 +2440,15 @@ reread_symbols (void)
32464 zero is OK since dbxread.c also does what it needs to do if
32465 objfile->global_psymbols.size is 0. */
32466 (*objfile->sf->sym_read) (objfile, 0);
32467 - if (!have_partial_symbols () && !have_full_symbols ())
32468 + if (!has_any_debug_symbols (objfile))
32471 printf_unfiltered (_("(no debugging symbols found)\n"));
32475 + objfile->flags &= ~OBJF_SYMTABS_READ;
32477 /* We're done reading the symbol file; finish off complaints. */
32478 clear_complaints (&symfile_complaints, 0, 1);
32480 @@ -2726,7 +2745,7 @@ allocate_symtab (char *filename, struct objfile *objfile)
32483 struct partial_symtab *
32484 -allocate_psymtab (char *filename, struct objfile *objfile)
32485 +allocate_psymtab (const char *filename, struct objfile *objfile)
32487 struct partial_symtab *psymtab;
32489 @@ -3040,7 +3059,8 @@ again2:
32491 struct partial_symtab *
32492 start_psymtab_common (struct objfile *objfile,
32493 - struct section_offsets *section_offsets, char *filename,
32494 + struct section_offsets *section_offsets,
32495 + const char *filename,
32496 CORE_ADDR textlow, struct partial_symbol **global_syms,
32497 struct partial_symbol **static_syms)
32499 diff --git a/gdb/symfile.h b/gdb/symfile.h
32500 index 88f8326..50671c1 100644
32501 --- a/gdb/symfile.h
32502 +++ b/gdb/symfile.h
32503 @@ -140,6 +140,12 @@ struct sym_fns
32505 void (*sym_read) (struct objfile *, int);
32507 + /* Read the partial symbols for an objfile. This may be NULL, in
32508 + which case gdb assumes that sym_read already read the partial
32511 + void (*sym_read_psymbols) (struct objfile *);
32513 /* Called when we are finished with an objfile. Should do all
32514 cleanup that is specific to the object file format for the
32515 particular objfile. */
32516 @@ -250,7 +256,7 @@ extern void free_section_addr_info (struct section_addr_info *);
32518 extern struct partial_symtab *start_psymtab_common (struct objfile *,
32519 struct section_offsets *,
32520 - char *, CORE_ADDR,
32521 + const char *, CORE_ADDR,
32522 struct partial_symbol **,
32523 struct partial_symbol **);
32525 @@ -300,7 +306,7 @@ extern int auto_solib_limit;
32527 extern void set_initial_language (void);
32529 -extern struct partial_symtab *allocate_psymtab (char *, struct objfile *);
32530 +extern struct partial_symtab *allocate_psymtab (const char *, struct objfile *);
32532 extern void discard_psymtab (struct partial_symtab *);
32534 @@ -369,7 +375,7 @@ void free_symfile_segment_data (struct symfile_segment_data *data);
32535 /* From dwarf2read.c */
32537 extern int dwarf2_has_info (struct objfile *);
32539 +extern void dwarf2_create_quick_addrmap (struct objfile *);
32540 extern void dwarf2_build_psymtabs (struct objfile *, int);
32541 extern void dwarf2_build_frame_info (struct objfile *);
32543 diff --git a/gdb/symtab.c b/gdb/symtab.c
32544 index d2ba1f3..b4da8c1 100644
32548 #include "ada-lang.h"
32549 #include "p-lang.h"
32550 #include "addrmap.h"
32551 +#include "cp-support.h"
32553 #include "hashtab.h"
32556 #include "gdb_stat.h"
32558 #include "cp-abi.h"
32559 +#include "cp-support.h"
32560 #include "observer.h"
32561 #include "gdb_assert.h"
32562 #include "solist.h"
32563 @@ -273,7 +275,7 @@ lookup_partial_symtab (const char *name)
32564 make_cleanup (xfree, real_path);
32567 - ALL_PSYMTABS (objfile, pst)
32568 + ALL_PSYMTABS_REQUIRED (objfile, pst)
32570 if (FILENAME_CMP (name, pst->filename) == 0)
32572 @@ -870,7 +872,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
32573 than the later used TEXTLOW/TEXTHIGH one. */
32575 ALL_OBJFILES (objfile)
32576 - if (objfile->psymtabs_addrmap != NULL)
32578 + if (objfile->quick_addrmap)
32580 + if (!addrmap_find (objfile->quick_addrmap, pc))
32583 + if (require_partial_symbols (objfile)->psymtabs_addrmap != NULL)
32585 struct partial_symtab *pst;
32587 @@ -903,6 +911,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
32593 /* Existing PSYMTABS_ADDRMAP mapping is present even for PARTIAL_SYMTABs
32594 which still have no corresponding full SYMTABs read. But it is not
32595 @@ -1170,6 +1179,22 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
32599 +/* Ensure that the partial symbols for OBJFILE have been loaded. This
32600 + function always returns its argument, as a convenience. */
32603 +require_partial_symbols (struct objfile *objfile)
32605 + if ((objfile->flags & OBJF_SYMTABS_READ) == 0)
32607 + objfile->flags |= OBJF_SYMTABS_READ;
32609 + if (objfile->sf->sym_read_psymbols)
32610 + (*objfile->sf->sym_read_psymbols) (objfile);
32615 /* Find the definition for a specified symbol name NAME
32616 in domain DOMAIN, visible from lexical block BLOCK.
32617 Returns the struct symbol pointer, or zero if no symbol is found.
32618 @@ -1200,6 +1225,11 @@ lookup_symbol_in_language (const char *name, const struct block *block,
32619 int needtofreename = 0;
32620 struct symbol *returnval;
32622 + if(strncmp(name, "::", 2) == 0){/* this must be a global name */
32627 modified_name = name;
32629 /* If we are using C++ or Java, demangle the name before doing a lookup, so
32630 @@ -1213,6 +1243,17 @@ lookup_symbol_in_language (const char *name, const struct block *block,
32631 modified_name = demangled_name;
32632 needtofreename = 1;
32636 + /* If we were given a non-mangled name, canonicalize it
32637 + according to the language (so far only for C++). */
32638 + demangled_name = cp_canonicalize_string (name);
32639 + if (demangled_name)
32641 + modified_name = demangled_name;
32642 + needtofreename = 1;
32646 else if (lang == language_java)
32648 @@ -1296,13 +1337,15 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
32651 struct symbol *sym = NULL;
32652 + const struct block *function_block = block;
32654 /* 'this' is only defined in the function's block, so find the
32655 enclosing function block. */
32656 - for (; block && !BLOCK_FUNCTION (block);
32657 - block = BLOCK_SUPERBLOCK (block));
32658 + for (; function_block && !BLOCK_FUNCTION (function_block);
32659 + function_block = BLOCK_SUPERBLOCK (function_block));
32661 - if (block && !dict_empty (BLOCK_DICT (block)))
32662 - sym = lookup_block_symbol (block, langdef->la_name_of_this,
32663 + if (function_block && !dict_empty (BLOCK_DICT (function_block)))
32664 + sym = lookup_block_symbol (function_block, langdef->la_name_of_this,
32668 @@ -1361,22 +1404,24 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
32669 const domain_enum domain)
32671 struct symbol *sym;
32672 - const struct block *static_block = block_static_block (block);
32673 + const struct block *global_block = block_global_block (block);
32674 + const struct block *block_iterator = block;
32676 /* Check if either no block is specified or it's a global block. */
32678 - if (static_block == NULL)
32679 + if (global_block == NULL)
32682 - while (block != static_block)
32683 + while (block_iterator != global_block)
32685 - sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
32686 + sym = lookup_symbol_aux_block (name, linkage_name, block_iterator, domain);
32689 - block = BLOCK_SUPERBLOCK (block);
32691 + block_iterator = BLOCK_SUPERBLOCK (block_iterator);
32694 - /* We've reached the static block without finding a result. */
32695 + /* We've reached the global block without finding a result. */
32699 @@ -1450,6 +1495,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile,
32702 /* Now go through psymtabs. */
32703 + require_partial_symbols ((struct objfile *) objfile);
32704 ALL_OBJFILE_PSYMTABS (objfile, ps)
32707 @@ -1520,7 +1566,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
32709 const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
32711 - ALL_PSYMTABS (objfile, ps)
32712 + ALL_PSYMTABS_REQUIRED (objfile, ps)
32715 && lookup_partial_symbol (ps, name, linkage_name,
32716 @@ -1805,7 +1851,11 @@ basic_lookup_transparent_type (const char *name)
32720 - ALL_PSYMTABS (objfile, ps)
32721 + /* FIXME: .debug_pubnames should be read in.
32723 + One may also try to the first pass without the require_partial_symbols
32724 + call but that would behave nondeterministically. */
32725 + ALL_PSYMTABS_REQUIRED (objfile, ps)
32727 if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
32729 @@ -1853,7 +1903,12 @@ basic_lookup_transparent_type (const char *name)
32733 - ALL_PSYMTABS (objfile, ps)
32734 + /* FIXME: Something like .debug_pubnames containing also static symbols
32735 + should be read in. Compiler needs to be taught to generate it first.
32737 + One may also try to the first pass without the require_partial_symbols
32738 + call but that would behave nondeterministically. */
32739 + ALL_PSYMTABS_REQUIRED (objfile, ps)
32741 if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_DOMAIN))
32743 @@ -1894,7 +1949,21 @@ find_main_psymtab (void)
32744 struct partial_symtab *pst;
32745 struct objfile *objfile;
32747 - ALL_PSYMTABS (objfile, pst)
32748 + ALL_OBJFILES (objfile)
32750 + if ((objfile->flags & OBJF_MAIN) == 0)
32752 + require_partial_symbols (objfile);
32753 + ALL_OBJFILE_PSYMTABS (objfile, pst)
32755 + if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
32762 + ALL_PSYMTABS_REQUIRED (objfile, pst)
32764 if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
32766 @@ -3085,7 +3154,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
32767 matching the regexp. That way we don't have to reproduce all of
32768 the machinery below. */
32770 - ALL_PSYMTABS (objfile, ps)
32771 + ALL_PSYMTABS_REQUIRED (objfile, ps)
32773 struct partial_symbol **bound, **gbound, **sbound;
32774 int keep_going = 1;
32775 diff --git a/gdb/symtab.h b/gdb/symtab.h
32776 index 8b086f3..06bf7e8 100644
32779 @@ -171,9 +171,6 @@ extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
32780 #define SYMBOL_SECTION(symbol) (symbol)->ginfo.section
32781 #define SYMBOL_OBJ_SECTION(symbol) (symbol)->ginfo.obj_section
32783 -#define SYMBOL_CPLUS_DEMANGLED_NAME(symbol) \
32784 - (symbol)->ginfo.language_specific.cplus_specific.demangled_name
32786 /* Initializes the language dependent portion of a symbol
32787 depending upon the language for the symbol. */
32788 #define SYMBOL_INIT_LANGUAGE_SPECIFIC(symbol,language) \
32789 @@ -394,7 +391,10 @@ typedef enum domain_enum_tag
32792 /* All defined types */
32796 + /* Fortran common blocks. Their naming must be separate from VAR_DOMAIN. */
32797 + COMMON_BLOCK_DOMAIN
32801 @@ -1027,6 +1027,8 @@ extern void clear_pc_function_cache (void);
32803 /* from symtab.c: */
32805 +struct objfile *require_partial_symbols (struct objfile *);
32807 /* lookup partial symbol table by filename */
32809 extern struct partial_symtab *lookup_partial_symtab (const char *);
32810 diff --git a/gdb/syscalls/gdb-syscalls.dtd b/gdb/syscalls/gdb-syscalls.dtd
32811 new file mode 100644
32812 index 0000000..0d40ab4
32814 +++ b/gdb/syscalls/gdb-syscalls.dtd
32816 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
32818 + Copying and distribution of this file, with or without modification,
32819 + are permitted in any medium without royalty provided the copyright
32820 + notice and this notice are preserved. -->
32822 +<!-- The root element of a syscall info is <syscalls_info>. -->
32824 +<!ELEMENT syscalls_info (syscall*)>
32826 +<!-- Maybe the 'number' attribute will have to be changed from
32828 +<!ELEMENT syscall EMPTY>
32830 + name CDATA #REQUIRED
32831 + number ID #REQUIRED>
32833 +<!ELEMENT xi:include (EMPTY)>
32834 +<!ATTLIST xi:include
32835 + xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
32836 + href CDATA #REQUIRED>
32837 diff --git a/gdb/syscalls/i386-linux.xml b/gdb/syscalls/i386-linux.xml
32838 new file mode 100644
32839 index 0000000..6f2beee
32841 +++ b/gdb/syscalls/i386-linux.xml
32843 +<?xml version="1.0"?>
32844 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
32846 + Copying and distribution of this file, with or without modification,
32847 + are permitted in any medium without royalty provided the copyright
32848 + notice and this notice are preserved. -->
32850 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
32853 + <syscall name="restart_syscall" number="0"/>
32854 + <syscall name="exit" number="1"/>
32855 + <syscall name="fork" number="2"/>
32856 + <syscall name="read" number="3"/>
32857 + <syscall name="write" number="4"/>
32858 + <syscall name="open" number="5"/>
32859 + <syscall name="close" number="6"/>
32860 + <syscall name="waitpid" number="7"/>
32861 + <syscall name="creat" number="8"/>
32862 + <syscall name="link" number="9"/>
32863 + <syscall name="unlink" number="10"/>
32864 + <syscall name="execve" number="11"/>
32865 + <syscall name="chdir" number="12"/>
32866 + <syscall name="time" number="13"/>
32867 + <syscall name="mknod" number="14"/>
32868 + <syscall name="chmod" number="15"/>
32869 + <syscall name="lchown" number="16"/>
32870 + <syscall name="break" number="17"/>
32871 + <syscall name="oldstat" number="18"/>
32872 + <syscall name="lseek" number="19"/>
32873 + <syscall name="getpid" number="20"/>
32874 + <syscall name="mount" number="21"/>
32875 + <syscall name="umount" number="22"/>
32876 + <syscall name="setuid" number="23"/>
32877 + <syscall name="getuid" number="24"/>
32878 + <syscall name="stime" number="25"/>
32879 + <syscall name="ptrace" number="26"/>
32880 + <syscall name="alarm" number="27"/>
32881 + <syscall name="oldfstat" number="28"/>
32882 + <syscall name="pause" number="29"/>
32883 + <syscall name="utime" number="30"/>
32884 + <syscall name="stty" number="31"/>
32885 + <syscall name="gtty" number="32"/>
32886 + <syscall name="access" number="33"/>
32887 + <syscall name="nice" number="34"/>
32888 + <syscall name="ftime" number="35"/>
32889 + <syscall name="sync" number="36"/>
32890 + <syscall name="kill" number="37"/>
32891 + <syscall name="rename" number="38"/>
32892 + <syscall name="mkdir" number="39"/>
32893 + <syscall name="rmdir" number="40"/>
32894 + <syscall name="dup" number="41"/>
32895 + <syscall name="pipe" number="42"/>
32896 + <syscall name="times" number="43"/>
32897 + <syscall name="prof" number="44"/>
32898 + <syscall name="brk" number="45"/>
32899 + <syscall name="setgid" number="46"/>
32900 + <syscall name="getgid" number="47"/>
32901 + <syscall name="signal" number="48"/>
32902 + <syscall name="geteuid" number="49"/>
32903 + <syscall name="getegid" number="50"/>
32904 + <syscall name="acct" number="51"/>
32905 + <syscall name="umount2" number="52"/>
32906 + <syscall name="lock" number="53"/>
32907 + <syscall name="ioctl" number="54"/>
32908 + <syscall name="fcntl" number="55"/>
32909 + <syscall name="mpx" number="56"/>
32910 + <syscall name="setpgid" number="57"/>
32911 + <syscall name="ulimit" number="58"/>
32912 + <syscall name="oldolduname" number="59"/>
32913 + <syscall name="umask" number="60"/>
32914 + <syscall name="chroot" number="61"/>
32915 + <syscall name="ustat" number="62"/>
32916 + <syscall name="dup2" number="63"/>
32917 + <syscall name="getppid" number="64"/>
32918 + <syscall name="getpgrp" number="65"/>
32919 + <syscall name="setsid" number="66"/>
32920 + <syscall name="sigaction" number="67"/>
32921 + <syscall name="sgetmask" number="68"/>
32922 + <syscall name="ssetmask" number="69"/>
32923 + <syscall name="setreuid" number="70"/>
32924 + <syscall name="setregid" number="71"/>
32925 + <syscall name="sigsuspend" number="72"/>
32926 + <syscall name="sigpending" number="73"/>
32927 + <syscall name="sethostname" number="74"/>
32928 + <syscall name="setrlimit" number="75"/>
32929 + <syscall name="getrlimit" number="76"/>
32930 + <syscall name="getrusage" number="77"/>
32931 + <syscall name="gettimeofday" number="78"/>
32932 + <syscall name="settimeofday" number="79"/>
32933 + <syscall name="getgroups" number="80"/>
32934 + <syscall name="setgroups" number="81"/>
32935 + <syscall name="select" number="82"/>
32936 + <syscall name="symlink" number="83"/>
32937 + <syscall name="oldlstat" number="84"/>
32938 + <syscall name="readlink" number="85"/>
32939 + <syscall name="uselib" number="86"/>
32940 + <syscall name="swapon" number="87"/>
32941 + <syscall name="reboot" number="88"/>
32942 + <syscall name="readdir" number="89"/>
32943 + <syscall name="mmap" number="90"/>
32944 + <syscall name="munmap" number="91"/>
32945 + <syscall name="truncate" number="92"/>
32946 + <syscall name="ftruncate" number="93"/>
32947 + <syscall name="fchmod" number="94"/>
32948 + <syscall name="fchown" number="95"/>
32949 + <syscall name="getpriority" number="96"/>
32950 + <syscall name="setpriority" number="97"/>
32951 + <syscall name="profil" number="98"/>
32952 + <syscall name="statfs" number="99"/>
32953 + <syscall name="fstatfs" number="100"/>
32954 + <syscall name="ioperm" number="101"/>
32955 + <syscall name="socketcall" number="102"/>
32956 + <syscall name="syslog" number="103"/>
32957 + <syscall name="setitimer" number="104"/>
32958 + <syscall name="getitimer" number="105"/>
32959 + <syscall name="stat" number="106"/>
32960 + <syscall name="lstat" number="107"/>
32961 + <syscall name="fstat" number="108"/>
32962 + <syscall name="olduname" number="109"/>
32963 + <syscall name="iopl" number="110"/>
32964 + <syscall name="vhangup" number="111"/>
32965 + <syscall name="idle" number="112"/>
32966 + <syscall name="vm86old" number="113"/>
32967 + <syscall name="wait4" number="114"/>
32968 + <syscall name="swapoff" number="115"/>
32969 + <syscall name="sysinfo" number="116"/>
32970 + <syscall name="ipc" number="117"/>
32971 + <syscall name="fsync" number="118"/>
32972 + <syscall name="sigreturn" number="119"/>
32973 + <syscall name="clone" number="120"/>
32974 + <syscall name="setdomainname" number="121"/>
32975 + <syscall name="uname" number="122"/>
32976 + <syscall name="modify_ldt" number="123"/>
32977 + <syscall name="adjtimex" number="124"/>
32978 + <syscall name="mprotect" number="125"/>
32979 + <syscall name="sigprocmask" number="126"/>
32980 + <syscall name="create_module" number="127"/>
32981 + <syscall name="init_module" number="128"/>
32982 + <syscall name="delete_module" number="129"/>
32983 + <syscall name="get_kernel_syms" number="130"/>
32984 + <syscall name="quotactl" number="131"/>
32985 + <syscall name="getpgid" number="132"/>
32986 + <syscall name="fchdir" number="133"/>
32987 + <syscall name="bdflush" number="134"/>
32988 + <syscall name="sysfs" number="135"/>
32989 + <syscall name="personality" number="136"/>
32990 + <syscall name="afs_syscall" number="137"/>
32991 + <syscall name="setfsuid" number="138"/>
32992 + <syscall name="setfsgid" number="139"/>
32993 + <syscall name="_llseek" number="140"/>
32994 + <syscall name="getdents" number="141"/>
32995 + <syscall name="_newselect" number="142"/>
32996 + <syscall name="flock" number="143"/>
32997 + <syscall name="msync" number="144"/>
32998 + <syscall name="readv" number="145"/>
32999 + <syscall name="writev" number="146"/>
33000 + <syscall name="getsid" number="147"/>
33001 + <syscall name="fdatasync" number="148"/>
33002 + <syscall name="_sysctl" number="149"/>
33003 + <syscall name="mlock" number="150"/>
33004 + <syscall name="munlock" number="151"/>
33005 + <syscall name="mlockall" number="152"/>
33006 + <syscall name="munlockall" number="153"/>
33007 + <syscall name="sched_setparam" number="154"/>
33008 + <syscall name="sched_getparam" number="155"/>
33009 + <syscall name="sched_setscheduler" number="156"/>
33010 + <syscall name="sched_getscheduler" number="157"/>
33011 + <syscall name="sched_yield" number="158"/>
33012 + <syscall name="sched_get_priority_max" number="159"/>
33013 + <syscall name="sched_get_priority_min" number="160"/>
33014 + <syscall name="sched_rr_get_interval" number="161"/>
33015 + <syscall name="nanosleep" number="162"/>
33016 + <syscall name="mremap" number="163"/>
33017 + <syscall name="setresuid" number="164"/>
33018 + <syscall name="getresuid" number="165"/>
33019 + <syscall name="vm86" number="166"/>
33020 + <syscall name="query_module" number="167"/>
33021 + <syscall name="poll" number="168"/>
33022 + <syscall name="nfsservctl" number="169"/>
33023 + <syscall name="setresgid" number="170"/>
33024 + <syscall name="getresgid" number="171"/>
33025 + <syscall name="prctl" number="172"/>
33026 + <syscall name="rt_sigreturn" number="173"/>
33027 + <syscall name="rt_sigaction" number="174"/>
33028 + <syscall name="rt_sigprocmask" number="175"/>
33029 + <syscall name="rt_sigpending" number="176"/>
33030 + <syscall name="rt_sigtimedwait" number="177"/>
33031 + <syscall name="rt_sigqueueinfo" number="178"/>
33032 + <syscall name="rt_sigsuspend" number="179"/>
33033 + <syscall name="pread64" number="180"/>
33034 + <syscall name="pwrite64" number="181"/>
33035 + <syscall name="chown" number="182"/>
33036 + <syscall name="getcwd" number="183"/>
33037 + <syscall name="capget" number="184"/>
33038 + <syscall name="capset" number="185"/>
33039 + <syscall name="sigaltstack" number="186"/>
33040 + <syscall name="sendfile" number="187"/>
33041 + <syscall name="getpmsg" number="188"/>
33042 + <syscall name="putpmsg" number="189"/>
33043 + <syscall name="vfork" number="190"/>
33044 + <syscall name="ugetrlimit" number="191"/>
33045 + <syscall name="mmap2" number="192"/>
33046 + <syscall name="truncate64" number="193"/>
33047 + <syscall name="ftruncate64" number="194"/>
33048 + <syscall name="stat64" number="195"/>
33049 + <syscall name="lstat64" number="196"/>
33050 + <syscall name="fstat64" number="197"/>
33051 + <syscall name="lchown32" number="198"/>
33052 + <syscall name="getuid32" number="199"/>
33053 + <syscall name="getgid32" number="200"/>
33054 + <syscall name="geteuid32" number="201"/>
33055 + <syscall name="getegid32" number="202"/>
33056 + <syscall name="setreuid32" number="203"/>
33057 + <syscall name="setregid32" number="204"/>
33058 + <syscall name="getgroups32" number="205"/>
33059 + <syscall name="setgroups32" number="206"/>
33060 + <syscall name="fchown32" number="207"/>
33061 + <syscall name="setresuid32" number="208"/>
33062 + <syscall name="getresuid32" number="209"/>
33063 + <syscall name="setresgid32" number="210"/>
33064 + <syscall name="getresgid32" number="211"/>
33065 + <syscall name="chown32" number="212"/>
33066 + <syscall name="setuid32" number="213"/>
33067 + <syscall name="setgid32" number="214"/>
33068 + <syscall name="setfsuid32" number="215"/>
33069 + <syscall name="setfsgid32" number="216"/>
33070 + <syscall name="pivot_root" number="217"/>
33071 + <syscall name="mincore" number="218"/>
33072 + <syscall name="madvise" number="219"/>
33073 + <syscall name="madvise1" number="220"/>
33074 + <syscall name="getdents64" number="221"/>
33075 + <syscall name="fcntl64" number="222"/>
33076 + <syscall name="gettid" number="224"/>
33077 + <syscall name="readahead" number="225"/>
33078 + <syscall name="setxattr" number="226"/>
33079 + <syscall name="lsetxattr" number="227"/>
33080 + <syscall name="fsetxattr" number="228"/>
33081 + <syscall name="getxattr" number="229"/>
33082 + <syscall name="lgetxattr" number="230"/>
33083 + <syscall name="fgetxattr" number="231"/>
33084 + <syscall name="listxattr" number="232"/>
33085 + <syscall name="llistxattr" number="233"/>
33086 + <syscall name="flistxattr" number="234"/>
33087 + <syscall name="removexattr" number="235"/>
33088 + <syscall name="lremovexattr" number="236"/>
33089 + <syscall name="fremovexattr" number="237"/>
33090 + <syscall name="tkill" number="238"/>
33091 + <syscall name="sendfile64" number="239"/>
33092 + <syscall name="futex" number="240"/>
33093 + <syscall name="sched_setaffinity" number="241"/>
33094 + <syscall name="sched_getaffinity" number="242"/>
33095 + <syscall name="set_thread_area" number="243"/>
33096 + <syscall name="get_thread_area" number="244"/>
33097 + <syscall name="io_setup" number="245"/>
33098 + <syscall name="io_destroy" number="246"/>
33099 + <syscall name="io_getevents" number="247"/>
33100 + <syscall name="io_submit" number="248"/>
33101 + <syscall name="io_cancel" number="249"/>
33102 + <syscall name="fadvise64" number="250"/>
33103 + <syscall name="exit_group" number="252"/>
33104 + <syscall name="lookup_dcookie" number="253"/>
33105 + <syscall name="epoll_create" number="254"/>
33106 + <syscall name="epoll_ctl" number="255"/>
33107 + <syscall name="epoll_wait" number="256"/>
33108 + <syscall name="remap_file_pages" number="257"/>
33109 + <syscall name="set_tid_address" number="258"/>
33110 + <syscall name="timer_create" number="259"/>
33111 + <syscall name="timer_settime" number="260"/>
33112 + <syscall name="timer_gettime" number="261"/>
33113 + <syscall name="timer_getoverrun" number="262"/>
33114 + <syscall name="timer_delete" number="263"/>
33115 + <syscall name="clock_settime" number="264"/>
33116 + <syscall name="clock_gettime" number="265"/>
33117 + <syscall name="clock_getres" number="266"/>
33118 + <syscall name="clock_nanosleep" number="267"/>
33119 + <syscall name="statfs64" number="268"/>
33120 + <syscall name="fstatfs64" number="269"/>
33121 + <syscall name="tgkill" number="270"/>
33122 + <syscall name="utimes" number="271"/>
33123 + <syscall name="fadvise64_64" number="272"/>
33124 + <syscall name="vserver" number="273"/>
33125 + <syscall name="mbind" number="274"/>
33126 + <syscall name="get_mempolicy" number="275"/>
33127 + <syscall name="set_mempolicy" number="276"/>
33128 + <syscall name="mq_open" number="277"/>
33129 + <syscall name="mq_unlink" number="278"/>
33130 + <syscall name="mq_timedsend" number="279"/>
33131 + <syscall name="mq_timedreceive" number="280"/>
33132 + <syscall name="mq_notify" number="281"/>
33133 + <syscall name="mq_getsetattr" number="282"/>
33134 + <syscall name="kexec_load" number="283"/>
33135 + <syscall name="waitid" number="284"/>
33136 + <syscall name="add_key" number="286"/>
33137 + <syscall name="request_key" number="287"/>
33138 + <syscall name="keyctl" number="288"/>
33139 + <syscall name="ioprio_set" number="289"/>
33140 + <syscall name="ioprio_get" number="290"/>
33141 + <syscall name="inotify_init" number="291"/>
33142 + <syscall name="inotify_add_watch" number="292"/>
33143 + <syscall name="inotify_rm_watch" number="293"/>
33144 + <syscall name="migrate_pages" number="294"/>
33145 + <syscall name="openat" number="295"/>
33146 + <syscall name="mkdirat" number="296"/>
33147 + <syscall name="mknodat" number="297"/>
33148 + <syscall name="fchownat" number="298"/>
33149 + <syscall name="futimesat" number="299"/>
33150 + <syscall name="fstatat64" number="300"/>
33151 + <syscall name="unlinkat" number="301"/>
33152 + <syscall name="renameat" number="302"/>
33153 + <syscall name="linkat" number="303"/>
33154 + <syscall name="symlinkat" number="304"/>
33155 + <syscall name="readlinkat" number="305"/>
33156 + <syscall name="fchmodat" number="306"/>
33157 + <syscall name="faccessat" number="307"/>
33158 + <syscall name="pselect6" number="308"/>
33159 + <syscall name="ppoll" number="309"/>
33160 + <syscall name="unshare" number="310"/>
33161 + <syscall name="set_robust_list" number="311"/>
33162 + <syscall name="get_robust_list" number="312"/>
33163 + <syscall name="splice" number="313"/>
33164 + <syscall name="sync_file_range" number="314"/>
33165 + <syscall name="tee" number="315"/>
33166 + <syscall name="vmsplice" number="316"/>
33167 + <syscall name="move_pages" number="317"/>
33168 + <syscall name="getcpu" number="318"/>
33169 + <syscall name="epoll_pwait" number="319"/>
33170 + <syscall name="utimensat" number="320"/>
33171 + <syscall name="signalfd" number="321"/>
33172 + <syscall name="timerfd_create" number="322"/>
33173 + <syscall name="eventfd" number="323"/>
33174 + <syscall name="fallocate" number="324"/>
33175 + <syscall name="timerfd_settime" number="325"/>
33177 diff --git a/gdb/syscalls/ppc-linux.xml b/gdb/syscalls/ppc-linux.xml
33178 new file mode 100644
33179 index 0000000..f09fabd
33181 +++ b/gdb/syscalls/ppc-linux.xml
33183 +<?xml version="1.0"?>
33184 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
33186 + Copying and distribution of this file, with or without modification,
33187 + are permitted in any medium without royalty provided the copyright
33188 + notice and this notice are preserved. -->
33190 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
33193 + <syscall name="restart_syscall" number="0"/>
33194 + <syscall name="exit" number="1"/>
33195 + <syscall name="fork" number="2"/>
33196 + <syscall name="read" number="3"/>
33197 + <syscall name="write" number="4"/>
33198 + <syscall name="open" number="5"/>
33199 + <syscall name="close" number="6"/>
33200 + <syscall name="waitpid" number="7"/>
33201 + <syscall name="creat" number="8"/>
33202 + <syscall name="link" number="9"/>
33203 + <syscall name="unlink" number="10"/>
33204 + <syscall name="execve" number="11"/>
33205 + <syscall name="chdir" number="12"/>
33206 + <syscall name="time" number="13"/>
33207 + <syscall name="mknod" number="14"/>
33208 + <syscall name="chmod" number="15"/>
33209 + <syscall name="lchown" number="16"/>
33210 + <syscall name="break" number="17"/>
33211 + <syscall name="oldstat" number="18"/>
33212 + <syscall name="lseek" number="19"/>
33213 + <syscall name="getpid" number="20"/>
33214 + <syscall name="mount" number="21"/>
33215 + <syscall name="umount" number="22"/>
33216 + <syscall name="setuid" number="23"/>
33217 + <syscall name="getuid" number="24"/>
33218 + <syscall name="stime" number="25"/>
33219 + <syscall name="ptrace" number="26"/>
33220 + <syscall name="alarm" number="27"/>
33221 + <syscall name="oldfstat" number="28"/>
33222 + <syscall name="pause" number="29"/>
33223 + <syscall name="utime" number="30"/>
33224 + <syscall name="stty" number="31"/>
33225 + <syscall name="gtty" number="32"/>
33226 + <syscall name="access" number="33"/>
33227 + <syscall name="nice" number="34"/>
33228 + <syscall name="ftime" number="35"/>
33229 + <syscall name="sync" number="36"/>
33230 + <syscall name="kill" number="37"/>
33231 + <syscall name="rename" number="38"/>
33232 + <syscall name="mkdir" number="39"/>
33233 + <syscall name="rmdir" number="40"/>
33234 + <syscall name="dup" number="41"/>
33235 + <syscall name="pipe" number="42"/>
33236 + <syscall name="times" number="43"/>
33237 + <syscall name="prof" number="44"/>
33238 + <syscall name="brk" number="45"/>
33239 + <syscall name="setgid" number="46"/>
33240 + <syscall name="getgid" number="47"/>
33241 + <syscall name="signal" number="48"/>
33242 + <syscall name="geteuid" number="49"/>
33243 + <syscall name="getegid" number="50"/>
33244 + <syscall name="acct" number="51"/>
33245 + <syscall name="umount2" number="52"/>
33246 + <syscall name="lock" number="53"/>
33247 + <syscall name="ioctl" number="54"/>
33248 + <syscall name="fcntl" number="55"/>
33249 + <syscall name="mpx" number="56"/>
33250 + <syscall name="setpgid" number="57"/>
33251 + <syscall name="ulimit" number="58"/>
33252 + <syscall name="oldolduname" number="59"/>
33253 + <syscall name="umask" number="60"/>
33254 + <syscall name="chroot" number="61"/>
33255 + <syscall name="ustat" number="62"/>
33256 + <syscall name="dup2" number="63"/>
33257 + <syscall name="getppid" number="64"/>
33258 + <syscall name="getpgrp" number="65"/>
33259 + <syscall name="setsid" number="66"/>
33260 + <syscall name="sigaction" number="67"/>
33261 + <syscall name="sgetmask" number="68"/>
33262 + <syscall name="ssetmask" number="69"/>
33263 + <syscall name="setreuid" number="70"/>
33264 + <syscall name="setregid" number="71"/>
33265 + <syscall name="sigsuspend" number="72"/>
33266 + <syscall name="sigpending" number="73"/>
33267 + <syscall name="sethostname" number="74"/>
33268 + <syscall name="setrlimit" number="75"/>
33269 + <syscall name="getrlimit" number="76"/>
33270 + <syscall name="getrusage" number="77"/>
33271 + <syscall name="gettimeofday" number="78"/>
33272 + <syscall name="settimeofday" number="79"/>
33273 + <syscall name="getgroups" number="80"/>
33274 + <syscall name="setgroups" number="81"/>
33275 + <syscall name="select" number="82"/>
33276 + <syscall name="symlink" number="83"/>
33277 + <syscall name="oldlstat" number="84"/>
33278 + <syscall name="readlink" number="85"/>
33279 + <syscall name="uselib" number="86"/>
33280 + <syscall name="swapon" number="87"/>
33281 + <syscall name="reboot" number="88"/>
33282 + <syscall name="readdir" number="89"/>
33283 + <syscall name="mmap" number="90"/>
33284 + <syscall name="munmap" number="91"/>
33285 + <syscall name="truncate" number="92"/>
33286 + <syscall name="ftruncate" number="93"/>
33287 + <syscall name="fchmod" number="94"/>
33288 + <syscall name="fchown" number="95"/>
33289 + <syscall name="getpriority" number="96"/>
33290 + <syscall name="setpriority" number="97"/>
33291 + <syscall name="profil" number="98"/>
33292 + <syscall name="statfs" number="99"/>
33293 + <syscall name="fstatfs" number="100"/>
33294 + <syscall name="ioperm" number="101"/>
33295 + <syscall name="socketcall" number="102"/>
33296 + <syscall name="syslog" number="103"/>
33297 + <syscall name="setitimer" number="104"/>
33298 + <syscall name="getitimer" number="105"/>
33299 + <syscall name="stat" number="106"/>
33300 + <syscall name="lstat" number="107"/>
33301 + <syscall name="fstat" number="108"/>
33302 + <syscall name="olduname" number="109"/>
33303 + <syscall name="iopl" number="110"/>
33304 + <syscall name="vhangup" number="111"/>
33305 + <syscall name="idle" number="112"/>
33306 + <syscall name="vm86" number="113"/>
33307 + <syscall name="wait4" number="114"/>
33308 + <syscall name="swapoff" number="115"/>
33309 + <syscall name="sysinfo" number="116"/>
33310 + <syscall name="ipc" number="117"/>
33311 + <syscall name="fsync" number="118"/>
33312 + <syscall name="sigreturn" number="119"/>
33313 + <syscall name="clone" number="120"/>
33314 + <syscall name="setdomainname" number="121"/>
33315 + <syscall name="uname" number="122"/>
33316 + <syscall name="modify_ldt" number="123"/>
33317 + <syscall name="adjtimex" number="124"/>
33318 + <syscall name="mprotect" number="125"/>
33319 + <syscall name="sigprocmask" number="126"/>
33320 + <syscall name="create_module" number="127"/>
33321 + <syscall name="init_module" number="128"/>
33322 + <syscall name="delete_module" number="129"/>
33323 + <syscall name="get_kernel_syms" number="130"/>
33324 + <syscall name="quotactl" number="131"/>
33325 + <syscall name="getpgid" number="132"/>
33326 + <syscall name="fchdir" number="133"/>
33327 + <syscall name="bdflush" number="134"/>
33328 + <syscall name="sysfs" number="135"/>
33329 + <syscall name="personality" number="136"/>
33330 + <syscall name="afs_syscall" number="137"/>
33331 + <syscall name="setfsuid" number="138"/>
33332 + <syscall name="setfsgid" number="139"/>
33333 + <syscall name="_llseek" number="140"/>
33334 + <syscall name="getdents" number="141"/>
33335 + <syscall name="_newselect" number="142"/>
33336 + <syscall name="flock" number="143"/>
33337 + <syscall name="msync" number="144"/>
33338 + <syscall name="readv" number="145"/>
33339 + <syscall name="writev" number="146"/>
33340 + <syscall name="getsid" number="147"/>
33341 + <syscall name="fdatasync" number="148"/>
33342 + <syscall name="_sysctl" number="149"/>
33343 + <syscall name="mlock" number="150"/>
33344 + <syscall name="munlock" number="151"/>
33345 + <syscall name="mlockall" number="152"/>
33346 + <syscall name="munlockall" number="153"/>
33347 + <syscall name="sched_setparam" number="154"/>
33348 + <syscall name="sched_getparam" number="155"/>
33349 + <syscall name="sched_setscheduler" number="156"/>
33350 + <syscall name="sched_getscheduler" number="157"/>
33351 + <syscall name="sched_yield" number="158"/>
33352 + <syscall name="sched_get_priority_max" number="159"/>
33353 + <syscall name="sched_get_priority_min" number="160"/>
33354 + <syscall name="sched_rr_get_interval" number="161"/>
33355 + <syscall name="nanosleep" number="162"/>
33356 + <syscall name="mremap" number="163"/>
33357 + <syscall name="setresuid" number="164"/>
33358 + <syscall name="getresuid" number="165"/>
33359 + <syscall name="query_module" number="166"/>
33360 + <syscall name="poll" number="167"/>
33361 + <syscall name="nfsservctl" number="168"/>
33362 + <syscall name="setresgid" number="169"/>
33363 + <syscall name="getresgid" number="170"/>
33364 + <syscall name="prctl" number="171"/>
33365 + <syscall name="rt_sigreturn" number="172"/>
33366 + <syscall name="rt_sigaction" number="173"/>
33367 + <syscall name="rt_sigprocmask" number="174"/>
33368 + <syscall name="rt_sigpending" number="175"/>
33369 + <syscall name="rt_sigtimedwait" number="176"/>
33370 + <syscall name="rt_sigqueueinfo" number="177"/>
33371 + <syscall name="rt_sigsuspend" number="178"/>
33372 + <syscall name="pread64" number="179"/>
33373 + <syscall name="pwrite64" number="180"/>
33374 + <syscall name="chown" number="181"/>
33375 + <syscall name="getcwd" number="182"/>
33376 + <syscall name="capget" number="183"/>
33377 + <syscall name="capset" number="184"/>
33378 + <syscall name="sigaltstack" number="185"/>
33379 + <syscall name="sendfile" number="186"/>
33380 + <syscall name="getpmsg" number="187"/>
33381 + <syscall name="putpmsg" number="188"/>
33382 + <syscall name="vfork" number="189"/>
33383 + <syscall name="ugetrlimit" number="190"/>
33384 + <syscall name="readahead" number="191"/>
33385 + <syscall name="mmap2" number="192"/>
33386 + <syscall name="truncate64" number="193"/>
33387 + <syscall name="ftruncate64" number="194"/>
33388 + <syscall name="stat64" number="195"/>
33389 + <syscall name="lstat64" number="196"/>
33390 + <syscall name="fstat64" number="197"/>
33391 + <syscall name="pciconfig_read" number="198"/>
33392 + <syscall name="pciconfig_write" number="199"/>
33393 + <syscall name="pciconfig_iobase" number="200"/>
33394 + <syscall name="multiplexer" number="201"/>
33395 + <syscall name="getdents64" number="202"/>
33396 + <syscall name="pivot_root" number="203"/>
33397 + <syscall name="fcntl64" number="204"/>
33398 + <syscall name="madvise" number="205"/>
33399 + <syscall name="mincore" number="206"/>
33400 + <syscall name="gettid" number="207"/>
33401 + <syscall name="tkill" number="208"/>
33402 + <syscall name="setxattr" number="209"/>
33403 + <syscall name="lsetxattr" number="210"/>
33404 + <syscall name="fsetxattr" number="211"/>
33405 + <syscall name="getxattr" number="212"/>
33406 + <syscall name="lgetxattr" number="213"/>
33407 + <syscall name="fgetxattr" number="214"/>
33408 + <syscall name="listxattr" number="215"/>
33409 + <syscall name="llistxattr" number="216"/>
33410 + <syscall name="flistxattr" number="217"/>
33411 + <syscall name="removexattr" number="218"/>
33412 + <syscall name="lremovexattr" number="219"/>
33413 + <syscall name="fremovexattr" number="220"/>
33414 + <syscall name="futex" number="221"/>
33415 + <syscall name="sched_setaffinity" number="222"/>
33416 + <syscall name="sched_getaffinity" number="223"/>
33417 + <syscall name="tuxcall" number="225"/>
33418 + <syscall name="sendfile64" number="226"/>
33419 + <syscall name="io_setup" number="227"/>
33420 + <syscall name="io_destroy" number="228"/>
33421 + <syscall name="io_getevents" number="229"/>
33422 + <syscall name="io_submit" number="230"/>
33423 + <syscall name="io_cancel" number="231"/>
33424 + <syscall name="set_tid_address" number="232"/>
33425 + <syscall name="fadvise64" number="233"/>
33426 + <syscall name="exit_group" number="234"/>
33427 + <syscall name="lookup_dcookie" number="235"/>
33428 + <syscall name="epoll_create" number="236"/>
33429 + <syscall name="epoll_ctl" number="237"/>
33430 + <syscall name="epoll_wait" number="238"/>
33431 + <syscall name="remap_file_pages" number="239"/>
33432 + <syscall name="timer_create" number="240"/>
33433 + <syscall name="timer_settime" number="241"/>
33434 + <syscall name="timer_gettime" number="242"/>
33435 + <syscall name="timer_getoverrun" number="243"/>
33436 + <syscall name="timer_delete" number="244"/>
33437 + <syscall name="clock_settime" number="245"/>
33438 + <syscall name="clock_gettime" number="246"/>
33439 + <syscall name="clock_getres" number="247"/>
33440 + <syscall name="clock_nanosleep" number="248"/>
33441 + <syscall name="swapcontext" number="249"/>
33442 + <syscall name="tgkill" number="250"/>
33443 + <syscall name="utimes" number="251"/>
33444 + <syscall name="statfs64" number="252"/>
33445 + <syscall name="fstatfs64" number="253"/>
33446 + <syscall name="fadvise64_64" number="254"/>
33447 + <syscall name="rtas" number="255"/>
33448 + <syscall name="sys_debug_setcontext" number="256"/>
33449 + <syscall name="mbind" number="259"/>
33450 + <syscall name="get_mempolicy" number="260"/>
33451 + <syscall name="set_mempolicy" number="261"/>
33452 + <syscall name="mq_open" number="262"/>
33453 + <syscall name="mq_unlink" number="263"/>
33454 + <syscall name="mq_timedsend" number="264"/>
33455 + <syscall name="mq_timedreceive" number="265"/>
33456 + <syscall name="mq_notify" number="266"/>
33457 + <syscall name="mq_getsetattr" number="267"/>
33458 + <syscall name="kexec_load" number="268"/>
33459 + <syscall name="add_key" number="269"/>
33460 + <syscall name="request_key" number="270"/>
33461 + <syscall name="keyctl" number="271"/>
33462 + <syscall name="waitid" number="272"/>
33463 + <syscall name="ioprio_set" number="273"/>
33464 + <syscall name="ioprio_get" number="274"/>
33465 + <syscall name="inotify_init" number="275"/>
33466 + <syscall name="inotify_add_watch" number="276"/>
33467 + <syscall name="inotify_rm_watch" number="277"/>
33468 + <syscall name="spu_run" number="278"/>
33469 + <syscall name="spu_create" number="279"/>
33470 + <syscall name="pselect6" number="280"/>
33471 + <syscall name="ppoll" number="281"/>
33472 + <syscall name="unshare" number="282"/>
33473 + <syscall name="openat" number="286"/>
33474 + <syscall name="mkdirat" number="287"/>
33475 + <syscall name="mknodat" number="288"/>
33476 + <syscall name="fchownat" number="289"/>
33477 + <syscall name="futimesat" number="290"/>
33478 + <syscall name="fstatat64" number="291"/>
33479 + <syscall name="unlinkat" number="292"/>
33480 + <syscall name="renameat" number="293"/>
33481 + <syscall name="linkat" number="294"/>
33482 + <syscall name="symlinkat" number="295"/>
33483 + <syscall name="readlinkat" number="296"/>
33484 + <syscall name="fchmodat" number="297"/>
33485 + <syscall name="faccessat" number="298"/>
33487 diff --git a/gdb/syscalls/ppc64-linux.xml b/gdb/syscalls/ppc64-linux.xml
33488 new file mode 100644
33489 index 0000000..7ee929c
33491 +++ b/gdb/syscalls/ppc64-linux.xml
33493 +<?xml version="1.0"?>
33494 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
33496 + Copying and distribution of this file, with or without modification,
33497 + are permitted in any medium without royalty provided the copyright
33498 + notice and this notice are preserved. -->
33500 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
33503 + <syscall name="restart_syscall" number="0"/>
33504 + <syscall name="exit" number="1"/>
33505 + <syscall name="fork" number="2"/>
33506 + <syscall name="read" number="3"/>
33507 + <syscall name="write" number="4"/>
33508 + <syscall name="open" number="5"/>
33509 + <syscall name="close" number="6"/>
33510 + <syscall name="waitpid" number="7"/>
33511 + <syscall name="creat" number="8"/>
33512 + <syscall name="link" number="9"/>
33513 + <syscall name="unlink" number="10"/>
33514 + <syscall name="execve" number="11"/>
33515 + <syscall name="chdir" number="12"/>
33516 + <syscall name="time" number="13"/>
33517 + <syscall name="mknod" number="14"/>
33518 + <syscall name="chmod" number="15"/>
33519 + <syscall name="lchown" number="16"/>
33520 + <syscall name="break" number="17"/>
33521 + <syscall name="oldstat" number="18"/>
33522 + <syscall name="lseek" number="19"/>
33523 + <syscall name="getpid" number="20"/>
33524 + <syscall name="mount" number="21"/>
33525 + <syscall name="umount" number="22"/>
33526 + <syscall name="setuid" number="23"/>
33527 + <syscall name="getuid" number="24"/>
33528 + <syscall name="stime" number="25"/>
33529 + <syscall name="ptrace" number="26"/>
33530 + <syscall name="alarm" number="27"/>
33531 + <syscall name="oldfstat" number="28"/>
33532 + <syscall name="pause" number="29"/>
33533 + <syscall name="utime" number="30"/>
33534 + <syscall name="stty" number="31"/>
33535 + <syscall name="gtty" number="32"/>
33536 + <syscall name="access" number="33"/>
33537 + <syscall name="nice" number="34"/>
33538 + <syscall name="ftime" number="35"/>
33539 + <syscall name="sync" number="36"/>
33540 + <syscall name="kill" number="37"/>
33541 + <syscall name="rename" number="38"/>
33542 + <syscall name="mkdir" number="39"/>
33543 + <syscall name="rmdir" number="40"/>
33544 + <syscall name="dup" number="41"/>
33545 + <syscall name="pipe" number="42"/>
33546 + <syscall name="times" number="43"/>
33547 + <syscall name="prof" number="44"/>
33548 + <syscall name="brk" number="45"/>
33549 + <syscall name="setgid" number="46"/>
33550 + <syscall name="getgid" number="47"/>
33551 + <syscall name="signal" number="48"/>
33552 + <syscall name="geteuid" number="49"/>
33553 + <syscall name="getegid" number="50"/>
33554 + <syscall name="acct" number="51"/>
33555 + <syscall name="umount2" number="52"/>
33556 + <syscall name="lock" number="53"/>
33557 + <syscall name="ioctl" number="54"/>
33558 + <syscall name="fcntl" number="55"/>
33559 + <syscall name="mpx" number="56"/>
33560 + <syscall name="setpgid" number="57"/>
33561 + <syscall name="ulimit" number="58"/>
33562 + <syscall name="oldolduname" number="59"/>
33563 + <syscall name="umask" number="60"/>
33564 + <syscall name="chroot" number="61"/>
33565 + <syscall name="ustat" number="62"/>
33566 + <syscall name="dup2" number="63"/>
33567 + <syscall name="getppid" number="64"/>
33568 + <syscall name="getpgrp" number="65"/>
33569 + <syscall name="setsid" number="66"/>
33570 + <syscall name="sigaction" number="67"/>
33571 + <syscall name="sgetmask" number="68"/>
33572 + <syscall name="ssetmask" number="69"/>
33573 + <syscall name="setreuid" number="70"/>
33574 + <syscall name="setregid" number="71"/>
33575 + <syscall name="sigsuspend" number="72"/>
33576 + <syscall name="sigpending" number="73"/>
33577 + <syscall name="sethostname" number="74"/>
33578 + <syscall name="setrlimit" number="75"/>
33579 + <syscall name="getrlimit" number="76"/>
33580 + <syscall name="getrusage" number="77"/>
33581 + <syscall name="gettimeofday" number="78"/>
33582 + <syscall name="settimeofday" number="79"/>
33583 + <syscall name="getgroups" number="80"/>
33584 + <syscall name="setgroups" number="81"/>
33585 + <syscall name="select" number="82"/>
33586 + <syscall name="symlink" number="83"/>
33587 + <syscall name="oldlstat" number="84"/>
33588 + <syscall name="readlink" number="85"/>
33589 + <syscall name="uselib" number="86"/>
33590 + <syscall name="swapon" number="87"/>
33591 + <syscall name="reboot" number="88"/>
33592 + <syscall name="readdir" number="89"/>
33593 + <syscall name="mmap" number="90"/>
33594 + <syscall name="munmap" number="91"/>
33595 + <syscall name="truncate" number="92"/>
33596 + <syscall name="ftruncate" number="93"/>
33597 + <syscall name="fchmod" number="94"/>
33598 + <syscall name="fchown" number="95"/>
33599 + <syscall name="getpriority" number="96"/>
33600 + <syscall name="setpriority" number="97"/>
33601 + <syscall name="profil" number="98"/>
33602 + <syscall name="statfs" number="99"/>
33603 + <syscall name="fstatfs" number="100"/>
33604 + <syscall name="ioperm" number="101"/>
33605 + <syscall name="socketcall" number="102"/>
33606 + <syscall name="syslog" number="103"/>
33607 + <syscall name="setitimer" number="104"/>
33608 + <syscall name="getitimer" number="105"/>
33609 + <syscall name="stat" number="106"/>
33610 + <syscall name="lstat" number="107"/>
33611 + <syscall name="fstat" number="108"/>
33612 + <syscall name="olduname" number="109"/>
33613 + <syscall name="iopl" number="110"/>
33614 + <syscall name="vhangup" number="111"/>
33615 + <syscall name="idle" number="112"/>
33616 + <syscall name="vm86" number="113"/>
33617 + <syscall name="wait4" number="114"/>
33618 + <syscall name="swapoff" number="115"/>
33619 + <syscall name="sysinfo" number="116"/>
33620 + <syscall name="ipc" number="117"/>
33621 + <syscall name="fsync" number="118"/>
33622 + <syscall name="sigreturn" number="119"/>
33623 + <syscall name="clone" number="120"/>
33624 + <syscall name="setdomainname" number="121"/>
33625 + <syscall name="uname" number="122"/>
33626 + <syscall name="modify_ldt" number="123"/>
33627 + <syscall name="adjtimex" number="124"/>
33628 + <syscall name="mprotect" number="125"/>
33629 + <syscall name="sigprocmask" number="126"/>
33630 + <syscall name="create_module" number="127"/>
33631 + <syscall name="init_module" number="128"/>
33632 + <syscall name="delete_module" number="129"/>
33633 + <syscall name="get_kernel_syms" number="130"/>
33634 + <syscall name="quotactl" number="131"/>
33635 + <syscall name="getpgid" number="132"/>
33636 + <syscall name="fchdir" number="133"/>
33637 + <syscall name="bdflush" number="134"/>
33638 + <syscall name="sysfs" number="135"/>
33639 + <syscall name="personality" number="136"/>
33640 + <syscall name="afs_syscall" number="137"/>
33641 + <syscall name="setfsuid" number="138"/>
33642 + <syscall name="setfsgid" number="139"/>
33643 + <syscall name="_llseek" number="140"/>
33644 + <syscall name="getdents" number="141"/>
33645 + <syscall name="_newselect" number="142"/>
33646 + <syscall name="flock" number="143"/>
33647 + <syscall name="msync" number="144"/>
33648 + <syscall name="readv" number="145"/>
33649 + <syscall name="writev" number="146"/>
33650 + <syscall name="getsid" number="147"/>
33651 + <syscall name="fdatasync" number="148"/>
33652 + <syscall name="_sysctl" number="149"/>
33653 + <syscall name="mlock" number="150"/>
33654 + <syscall name="munlock" number="151"/>
33655 + <syscall name="mlockall" number="152"/>
33656 + <syscall name="munlockall" number="153"/>
33657 + <syscall name="sched_setparam" number="154"/>
33658 + <syscall name="sched_getparam" number="155"/>
33659 + <syscall name="sched_setscheduler" number="156"/>
33660 + <syscall name="sched_getscheduler" number="157"/>
33661 + <syscall name="sched_yield" number="158"/>
33662 + <syscall name="sched_get_priority_max" number="159"/>
33663 + <syscall name="sched_get_priority_min" number="160"/>
33664 + <syscall name="sched_rr_get_interval" number="161"/>
33665 + <syscall name="nanosleep" number="162"/>
33666 + <syscall name="mremap" number="163"/>
33667 + <syscall name="setresuid" number="164"/>
33668 + <syscall name="getresuid" number="165"/>
33669 + <syscall name="query_module" number="166"/>
33670 + <syscall name="poll" number="167"/>
33671 + <syscall name="nfsservctl" number="168"/>
33672 + <syscall name="setresgid" number="169"/>
33673 + <syscall name="getresgid" number="170"/>
33674 + <syscall name="prctl" number="171"/>
33675 + <syscall name="rt_sigreturn" number="172"/>
33676 + <syscall name="rt_sigaction" number="173"/>
33677 + <syscall name="rt_sigprocmask" number="174"/>
33678 + <syscall name="rt_sigpending" number="175"/>
33679 + <syscall name="rt_sigtimedwait" number="176"/>
33680 + <syscall name="rt_sigqueueinfo" number="177"/>
33681 + <syscall name="rt_sigsuspend" number="178"/>
33682 + <syscall name="pread64" number="179"/>
33683 + <syscall name="pwrite64" number="180"/>
33684 + <syscall name="chown" number="181"/>
33685 + <syscall name="getcwd" number="182"/>
33686 + <syscall name="capget" number="183"/>
33687 + <syscall name="capset" number="184"/>
33688 + <syscall name="sigaltstack" number="185"/>
33689 + <syscall name="sendfile" number="186"/>
33690 + <syscall name="getpmsg" number="187"/>
33691 + <syscall name="putpmsg" number="188"/>
33692 + <syscall name="vfork" number="189"/>
33693 + <syscall name="ugetrlimit" number="190"/>
33694 + <syscall name="readahead" number="191"/>
33695 + <syscall name="pciconfig_read" number="198"/>
33696 + <syscall name="pciconfig_write" number="199"/>
33697 + <syscall name="pciconfig_iobase" number="200"/>
33698 + <syscall name="multiplexer" number="201"/>
33699 + <syscall name="getdents64" number="202"/>
33700 + <syscall name="pivot_root" number="203"/>
33701 + <syscall name="madvise" number="205"/>
33702 + <syscall name="mincore" number="206"/>
33703 + <syscall name="gettid" number="207"/>
33704 + <syscall name="tkill" number="208"/>
33705 + <syscall name="setxattr" number="209"/>
33706 + <syscall name="lsetxattr" number="210"/>
33707 + <syscall name="fsetxattr" number="211"/>
33708 + <syscall name="getxattr" number="212"/>
33709 + <syscall name="lgetxattr" number="213"/>
33710 + <syscall name="fgetxattr" number="214"/>
33711 + <syscall name="listxattr" number="215"/>
33712 + <syscall name="llistxattr" number="216"/>
33713 + <syscall name="flistxattr" number="217"/>
33714 + <syscall name="removexattr" number="218"/>
33715 + <syscall name="lremovexattr" number="219"/>
33716 + <syscall name="fremovexattr" number="220"/>
33717 + <syscall name="futex" number="221"/>
33718 + <syscall name="sched_setaffinity" number="222"/>
33719 + <syscall name="sched_getaffinity" number="223"/>
33720 + <syscall name="tuxcall" number="225"/>
33721 + <syscall name="io_setup" number="227"/>
33722 + <syscall name="io_destroy" number="228"/>
33723 + <syscall name="io_getevents" number="229"/>
33724 + <syscall name="io_submit" number="230"/>
33725 + <syscall name="io_cancel" number="231"/>
33726 + <syscall name="set_tid_address" number="232"/>
33727 + <syscall name="fadvise64" number="233"/>
33728 + <syscall name="exit_group" number="234"/>
33729 + <syscall name="lookup_dcookie" number="235"/>
33730 + <syscall name="epoll_create" number="236"/>
33731 + <syscall name="epoll_ctl" number="237"/>
33732 + <syscall name="epoll_wait" number="238"/>
33733 + <syscall name="remap_file_pages" number="239"/>
33734 + <syscall name="timer_create" number="240"/>
33735 + <syscall name="timer_settime" number="241"/>
33736 + <syscall name="timer_gettime" number="242"/>
33737 + <syscall name="timer_getoverrun" number="243"/>
33738 + <syscall name="timer_delete" number="244"/>
33739 + <syscall name="clock_settime" number="245"/>
33740 + <syscall name="clock_gettime" number="246"/>
33741 + <syscall name="clock_getres" number="247"/>
33742 + <syscall name="clock_nanosleep" number="248"/>
33743 + <syscall name="swapcontext" number="249"/>
33744 + <syscall name="tgkill" number="250"/>
33745 + <syscall name="utimes" number="251"/>
33746 + <syscall name="statfs64" number="252"/>
33747 + <syscall name="fstatfs64" number="253"/>
33748 + <syscall name="rtas" number="255"/>
33749 + <syscall name="sys_debug_setcontext" number="256"/>
33750 + <syscall name="mbind" number="259"/>
33751 + <syscall name="get_mempolicy" number="260"/>
33752 + <syscall name="set_mempolicy" number="261"/>
33753 + <syscall name="mq_open" number="262"/>
33754 + <syscall name="mq_unlink" number="263"/>
33755 + <syscall name="mq_timedsend" number="264"/>
33756 + <syscall name="mq_timedreceive" number="265"/>
33757 + <syscall name="mq_notify" number="266"/>
33758 + <syscall name="mq_getsetattr" number="267"/>
33759 + <syscall name="kexec_load" number="268"/>
33760 + <syscall name="add_key" number="269"/>
33761 + <syscall name="request_key" number="270"/>
33762 + <syscall name="keyctl" number="271"/>
33763 + <syscall name="waitid" number="272"/>
33764 + <syscall name="ioprio_set" number="273"/>
33765 + <syscall name="ioprio_get" number="274"/>
33766 + <syscall name="inotify_init" number="275"/>
33767 + <syscall name="inotify_add_watch" number="276"/>
33768 + <syscall name="inotify_rm_watch" number="277"/>
33769 + <syscall name="spu_run" number="278"/>
33770 + <syscall name="spu_create" number="279"/>
33771 + <syscall name="pselect6" number="280"/>
33772 + <syscall name="ppoll" number="281"/>
33773 + <syscall name="unshare" number="282"/>
33774 + <syscall name="unlinkat" number="286"/>
33775 + <syscall name="renameat" number="287"/>
33776 + <syscall name="linkat" number="288"/>
33777 + <syscall name="symlinkat" number="289"/>
33778 + <syscall name="readlinkat" number="290"/>
33779 + <syscall name="fchmodat" number="291"/>
33780 + <syscall name="faccessat" number="292"/>
33782 diff --git a/gdb/target.c b/gdb/target.c
33783 index b89d551..831070c 100644
33786 @@ -443,6 +443,8 @@ update_current_target (void)
33787 /* Do not inherit to_follow_fork. */
33788 INHERIT (to_insert_exec_catchpoint, t);
33789 INHERIT (to_remove_exec_catchpoint, t);
33790 + INHERIT (to_passed_by_entrypoint, t);
33791 + INHERIT (to_set_syscall_catchpoint, t);
33792 INHERIT (to_has_exited, t);
33793 /* Do not inherit to_mourn_inferiour. */
33794 INHERIT (to_can_run, t);
33795 @@ -586,9 +588,15 @@ update_current_target (void)
33796 de_fault (to_insert_exec_catchpoint,
33799 + de_fault (to_passed_by_entrypoint,
33802 de_fault (to_remove_exec_catchpoint,
33805 + de_fault (to_set_syscall_catchpoint,
33806 + (int (*) (int, int, int, int, int *))
33808 de_fault (to_has_exited,
33809 (int (*) (int, int, int *))
33811 @@ -2677,9 +2685,9 @@ target_waitstatus_to_string (const struct target_waitstatus *ws)
33812 case TARGET_WAITKIND_EXECD:
33813 return xstrprintf ("%sexecd", kind_str);
33814 case TARGET_WAITKIND_SYSCALL_ENTRY:
33815 - return xstrprintf ("%ssyscall-entry", kind_str);
33816 + return xstrprintf ("%sentered syscall", kind_str);
33817 case TARGET_WAITKIND_SYSCALL_RETURN:
33818 - return xstrprintf ("%ssyscall-return", kind_str);
33819 + return xstrprintf ("%sexited syscall", kind_str);
33820 case TARGET_WAITKIND_SPURIOUS:
33821 return xstrprintf ("%sspurious", kind_str);
33822 case TARGET_WAITKIND_IGNORE:
33823 diff --git a/gdb/target.h b/gdb/target.h
33824 index 7f4cd8f..8dcc3d6 100644
33827 @@ -140,18 +140,34 @@ struct target_waitstatus
33829 enum target_waitkind kind;
33831 - /* Forked child pid, execd pathname, exit status or signal number. */
33832 + /* Forked child pid, execd pathname, exit status, signal number or
33837 enum target_signal sig;
33838 ptid_t related_pid;
33839 char *execd_pathname;
33841 + int syscall_number;
33846 +/* The structure below stores information about a system call.
33847 + It is basically used in the "catch syscall" command, and in
33848 + every function that gives information about a system call.
33850 + It's also good to mention that its fields represent everything
33851 + that we currently know about a syscall in GDB. */
33854 + /* The syscall number. */
33857 + /* The syscall name. */
33858 + const char *name;
33861 /* Return a pretty printed form of target_waitstatus.
33862 Space for the result is malloc'd, caller must free. */
33863 extern char *target_waitstatus_to_string (const struct target_waitstatus *);
33864 @@ -392,6 +408,8 @@ struct target_ops
33865 int (*to_follow_fork) (struct target_ops *, int);
33866 void (*to_insert_exec_catchpoint) (int);
33867 int (*to_remove_exec_catchpoint) (int);
33868 + int (*to_passed_by_entrypoint) (void);
33869 + int (*to_set_syscall_catchpoint) (int, int, int, int, int *);
33870 int (*to_has_exited) (int, int, int *);
33871 void (*to_mourn_inferior) (struct target_ops *);
33872 int (*to_can_run) (void);
33873 @@ -723,6 +741,8 @@ extern int inferior_has_vforked (ptid_t pid, ptid_t *child_pid);
33875 extern int inferior_has_execd (ptid_t pid, char **execd_pathname);
33877 +extern int inferior_has_called_syscall (ptid_t pid, int *syscall_number);
33881 extern void print_section_info (struct target_ops *, bfd *);
33882 @@ -881,6 +901,21 @@ int target_follow_fork (int follow_child);
33883 #define target_remove_exec_catchpoint(pid) \
33884 (*current_target.to_remove_exec_catchpoint) (pid)
33886 +/* Has the inferior already passed through its entrypoint? */
33887 +#define target_passed_by_entrypoint() \
33888 + (*current_target.to_passed_by_entrypoint) ()
33890 +/* Syscall catch. NEEDED is nonzero if any syscall catch (of any
33891 + kind) is requested. ANY_COUNT is nonzero if a generic
33892 + (filter-less) syscall catch is being requested. TABLE is an array
33893 + of ints, indexed by syscall number. An element in this array is
33894 + nonzero if that syscall should be caught. TABLE_SIZE is the number
33895 + of elements in TABLE. */
33897 +#define target_set_syscall_catchpoint(pid, needed, any_count, table_size, table) \
33898 + (*current_target.to_set_syscall_catchpoint) (pid, needed, any_count, \
33899 + table_size, table)
33901 /* Returns TRUE if PID has exited. And, also sets EXIT_STATUS to the
33902 exit code of PID, if any. */
33904 @@ -1146,6 +1181,20 @@ extern int target_search_memory (CORE_ADDR start_addr,
33905 ULONGEST pattern_len,
33906 CORE_ADDR *found_addrp);
33908 +/* Utility functions which can be used by search_memory implementations. */
33910 +void allocate_pattern_buffer (char **pattern_bufp, char **pattern_buf_end,
33911 + ULONGEST *pattern_buf_size);
33913 +void increase_pattern_buffer (char **pattern_bufp, char **pattern_buf_end,
33914 + ULONGEST *pattern_buf_size, int val_bytes);
33916 +int search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len,
33917 + const char *pattern_buf, ULONGEST pattern_len,
33918 + CORE_ADDR *found_addr);
33920 +void put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p);
33922 /* Command logging facility. */
33924 #define target_log_command(p) \
33925 diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
33926 index e3aaeab..e886869 100644
33927 --- a/gdb/testsuite/ChangeLog
33928 +++ b/gdb/testsuite/ChangeLog
33930 +2009-03-05 Pedro Alves <pedro@codesourcery.com>
33932 + * gdb.arch/i386-permbkpt.S, gdb.arch/i386-permbkpt.exp: New.
33934 2009-02-18 Jan Kratochvil <jan.kratochvil@redhat.com>
33936 * gdb.base/macscp.exp (objfile): Move it to ${objdir}/${subdir}/.
33937 diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac
33938 index 3d8fae4..5fb9067 100644
33939 --- a/gdb/testsuite/configure.ac
33940 +++ b/gdb/testsuite/configure.ac
33943 # Process this file with autoconf to produce a configure script.
33945 -# Copyright 2002, 2003, 2004, 2005
33946 +# Copyright 2002, 2003, 2004, 2005, 2008
33947 # Free Software Foundation, Inc.
33949 # This program is free software; you can redistribute it and/or modify
33950 diff --git a/gdb/testsuite/gdb.arch/i386-permbkpt.S b/gdb/testsuite/gdb.arch/i386-permbkpt.S
33951 new file mode 100644
33952 index 0000000..02a31d6
33954 +++ b/gdb/testsuite/gdb.arch/i386-permbkpt.S
33956 +/* Copyright 2009 Free Software Foundation, Inc.
33958 + This program is free software; you can redistribute it and/or modify
33959 + it under the terms of the GNU General Public License as published by
33960 + the Free Software Foundation; either version 3 of the License, or
33961 + (at your option) any later version.
33963 + This program is distributed in the hope that it will be useful,
33964 + but WITHOUT ANY WARRANTY; without even the implied warranty of
33965 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33966 + GNU General Public License for more details.
33968 + You should have received a copy of the GNU General Public License
33969 + along with this program. If not, see <http://www.gnu.org/licenses/>.
33971 + This file is part of the gdb testsuite. */
33973 +#define CONCAT1(a, b) CONCAT2(a, b)
33974 +#define CONCAT2(a, b) a ## b
33976 +#ifdef SYMBOL_PREFIX
33977 +# define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str)
33979 +# define SYMBOL(str) str
33982 + .global SYMBOL(main)
33986 diff --git a/gdb/testsuite/gdb.arch/i386-permbkpt.exp b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
33987 new file mode 100644
33988 index 0000000..f1930e5
33990 +++ b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
33992 +# Copyright (C) 2009 Free Software Foundation, Inc.
33994 +# This program is free software; you can redistribute it and/or modify
33995 +# it under the terms of the GNU General Public License as published by
33996 +# the Free Software Foundation; either version 3 of the License, or
33997 +# (at your option) any later version.
33999 +# This program is distributed in the hope that it will be useful,
34000 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
34001 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34002 +# GNU General Public License for more details.
34004 +# You should have received a copy of the GNU General Public License
34005 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
34008 +# This file is part of the gdb testsuite.
34011 + strace $tracelevel
34014 +# Test inserting breakpoints over permanent breakpoints on i386 and amd64.
34016 +if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
34017 + verbose "Skipping i386 test for multi break at permanent breakpoint location."
34021 +set testfile "i386-permbkpt"
34022 +set srcfile ${testfile}.S
34023 +set binfile ${objdir}/${subdir}/${testfile}
34025 +# Some targets have leading underscores on assembly symbols.
34026 +# TODO: detect this automatically
34027 +set additional_flags ""
34028 +if { [istarget "*-*-cygwin*"] || [istarget "*-*-mingw*"] } then {
34029 + set additional_flags "additional_flags=-DSYMBOL_PREFIX=_"
34032 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
34033 + untested i386-permbkpt.exp
34039 +gdb_reinitialize_dir $srcdir/$subdir
34040 +gdb_load ${binfile}
34042 +gdb_test "break main" "" "First permanent break"
34043 +gdb_test "break main" "" "Second permanent break"
34044 diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.exp b/gdb/testsuite/gdb.arch/powerpc-power7.exp
34045 new file mode 100644
34046 index 0000000..d9c48f9
34048 +++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp
34050 +# Copyright 2009 Free Software Foundation, Inc.
34052 +# This program is free software; you can redistribute it and/or modify
34053 +# it under the terms of the GNU General Public License as published by
34054 +# the Free Software Foundation; either version 2 of the License, or
34055 +# (at your option) any later version.
34057 +# This program is distributed in the hope that it will be useful,
34058 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
34059 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34060 +# GNU General Public License for more details.
34062 +# You should have received a copy of the GNU General Public License
34063 +# along with this program; if not, write to the Free Software
34064 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34066 +# Test PowerPC Power7 instructions disassembly.
34068 +if {![istarget "powerpc*-*-*"]} then {
34069 + verbose "Skipping PowerPC Power7 instructions disassembly."
34073 +set testfile "powerpc-power7"
34074 +set srcfile ${testfile}.s
34075 +set objfile ${objdir}/${subdir}/${testfile}.o
34077 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } {
34078 + untested "PowerPC Power7 instructions disassembly"
34085 +gdb_reinitialize_dir $srcdir/$subdir
34086 +gdb_load ${objfile}
34089 +# Disassemble the function.
34091 +set test "disass func"
34092 +gdb_test_multiple $test $test {
34093 + -re "\r\nDump of assembler code for function func:(\r\n.*\r\n)End of assembler dump.\r\n$gdb_prompt $" {
34094 + set func $expect_out(1,string)
34099 +proc func_check {offset instr} {
34102 + # 0x0000000000000018 <func+24>: stxvd2x vs43,r4,r5
34103 + set patt ".*\r\n[string map {0x 0x0*} $offset] <func\\+?\[0-9\]*>:\[ \t\]*[string map [list { } "\[ \t\]+" . {\.}] $instr]\[ \t\]*\r\n.*"
34104 + set test "Found $offset: $instr"
34105 + if [regexp -nocase -line $patt $func] {
34112 +func_check 0x0 "lxvd2x vs3,r4,r5"
34113 +func_check 0x4 "lxvd2ux vs3,r4,r5"
34114 +func_check 0x8 "lxvd2x vs43,r4,r5"
34115 +func_check 0xc "lxvd2ux vs43,r4,r5"
34116 +func_check 0x10 "stxvd2x vs3,r4,r5"
34117 +func_check 0x14 "stxvd2ux vs3,r4,r5"
34118 +func_check 0x18 "stxvd2x vs43,r4,r5"
34119 +func_check 0x1c "stxvd2ux vs43,r4,r5"
34120 +func_check 0x20 "xxmrghd vs3,vs4,vs5"
34121 +func_check 0x24 "xxmrghd vs43,vs44,vs45"
34122 +func_check 0x28 "xxmrgld vs3,vs4,vs5"
34123 +func_check 0x2c "xxmrgld vs43,vs44,vs45"
34124 +func_check 0x30 "xxmrghd vs3,vs4,vs5"
34125 +func_check 0x34 "xxmrghd vs43,vs44,vs45"
34126 +func_check 0x38 "xxmrgld vs3,vs4,vs5"
34127 +func_check 0x3c "xxmrgld vs43,vs44,vs45"
34128 +func_check 0x40 "xxpermdi vs3,vs4,vs5,1"
34129 +func_check 0x44 "xxpermdi vs43,vs44,vs45,1"
34130 +func_check 0x48 "xxpermdi vs3,vs4,vs5,2"
34131 +func_check 0x4c "xxpermdi vs43,vs44,vs45,2"
34132 +func_check 0x50 "xvmovdp vs3,vs4"
34133 +func_check 0x54 "xvmovdp vs43,vs44"
34134 +func_check 0x58 "xvmovdp vs3,vs4"
34135 +func_check 0x5c "xvmovdp vs43,vs44"
34136 +func_check 0x60 "xvcpsgndp vs3,vs4,vs5"
34137 +func_check 0x64 "xvcpsgndp vs43,vs44,vs45"
34138 +func_check 0x68 "wait"
34139 +func_check 0x6c "wait"
34140 +func_check 0x70 "waitrsv"
34141 +func_check 0x74 "waitrsv"
34142 +func_check 0x78 "waitimpl"
34143 +func_check 0x7c "waitimpl"
34144 +func_check 0x80 "doze"
34145 +func_check 0x84 "nap"
34146 +func_check 0x88 "sleep"
34147 +func_check 0x8c "rvwinkle"
34148 +func_check 0x90 "prtyw r3,r4"
34149 +func_check 0x94 "prtyd r13,r14"
34150 +func_check 0x98 "mfcfar r10"
34151 +func_check 0x9c "mtcfar r11"
34152 +func_check 0xa0 "cmpb r3,r4,r5"
34153 +func_check 0xa4 "lwzcix r10,r11,r12"
34154 +func_check 0xa8 "dadd f16,f17,f18"
34155 +func_check 0xac "daddq f20,f22,f24"
34156 +func_check 0xb0 "dss 3"
34157 +func_check 0xb4 "dssall"
34158 +func_check 0xb8 "dst r5,r4,1"
34159 +func_check 0xbc "dstt r8,r7,0"
34160 +func_check 0xc0 "dstst r5,r6,3"
34161 +func_check 0xc4 "dststt r4,r5,2"
34162 +func_check 0xc8 "divwe r10,r11,r12"
34163 +func_check 0xcc "divwe. r11,r12,r13"
34164 +func_check 0xd0 "divweo r12,r13,r14"
34165 +func_check 0xd4 "divweo. r13,r14,r15"
34166 +func_check 0xd8 "divweu r10,r11,r12"
34167 +func_check 0xdc "divweu. r11,r12,r13"
34168 +func_check 0xe0 "divweuo r12,r13,r14"
34169 +func_check 0xe4 "divweuo. r13,r14,r15"
34170 +func_check 0xe8 "bpermd r7,r17,r27"
34171 +func_check 0xec "popcntw r10,r20"
34172 +func_check 0xf0 "popcntd r10,r20"
34173 +func_check 0xf4 "ldbrx r20,r21,r22"
34174 +func_check 0xf8 "stdbrx r20,r21,r22"
34175 +func_check 0xfc "lfiwzx f10,0,r10"
34176 +func_check 0x100 "lfiwzx f10,r9,r10"
34177 +func_check 0x104 "fcfids f4,f5"
34178 +func_check 0x108 "fcfids. f4,f5"
34179 +func_check 0x10c "fcfidus f4,f5"
34180 +func_check 0x110 "fcfidus. f4,f5"
34181 +func_check 0x114 "fctiwu f4,f5"
34182 +func_check 0x118 "fctiwu. f4,f5"
34183 +func_check 0x11c "fctiwuz f4,f5"
34184 +func_check 0x120 "fctiwuz. f4,f5"
34185 +func_check 0x124 "fctidu f4,f5"
34186 +func_check 0x128 "fctidu. f4,f5"
34187 +func_check 0x12c "fctiduz f4,f5"
34188 +func_check 0x130 "fctiduz. f4,f5"
34189 +func_check 0x134 "fcfidu f4,f5"
34190 +func_check 0x138 "fcfidu. f4,f5"
34191 +func_check 0x13c "ftdiv cr0,f10,f11"
34192 +func_check 0x140 "ftdiv cr7,f10,f11"
34193 +func_check 0x144 "ftsqrt cr0,f10"
34194 +func_check 0x148 "ftsqrt cr7,f10"
34195 +func_check 0x14c "dcbtt r8,r9"
34196 +func_check 0x150 "dcbtstt r8,r9"
34197 +func_check 0x154 "dcffix f10,f12"
34198 +func_check 0x158 "dcffix. f20,f22"
34199 +func_check 0x15c "lbarx r10,r11,r12"
34200 +func_check 0x160 "lbarx r10,r11,r12"
34201 +func_check 0x164 "lbarx r10,r11,r12,1"
34202 +func_check 0x168 "lharx r20,r21,r22"
34203 +func_check 0x16c "lharx r20,r21,r22"
34204 +func_check 0x170 "lharx r20,r21,r22,1"
34205 +func_check 0x174 "stbcx. r10,r11,r12"
34206 +func_check 0x178 "sthcx. r10,r11,r12"
34207 +func_check 0x17c "fre f14,f15"
34208 +func_check 0x180 "fre. f14,f15"
34209 +func_check 0x184 "fres f14,f15"
34210 +func_check 0x188 "fres. f14,f15"
34211 +func_check 0x18c "frsqrte f14,f15"
34212 +func_check 0x190 "frsqrte. f14,f15"
34213 +func_check 0x194 "frsqrtes f14,f15"
34214 +func_check 0x198 "frsqrtes. f14,f15"
34215 +func_check 0x19c "isel r2,r3,r4,28"
34216 diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.s b/gdb/testsuite/gdb.arch/powerpc-power7.s
34217 new file mode 100644
34218 index 0000000..98b2e79
34220 +++ b/gdb/testsuite/gdb.arch/powerpc-power7.s
34225 + .long 0x7c642e98 /* 0: lxvd2x vs3,r4,r5 */
34226 + .long 0x7c642ed8 /* 4: lxvd2ux vs3,r4,r5 */
34227 + .long 0x7d642e99 /* 8: lxvd2x vs43,r4,r5 */
34228 + .long 0x7d642ed9 /* c: lxvd2ux vs43,r4,r5 */
34229 + .long 0x7c642f98 /* 10: stxvd2x vs3,r4,r5 */
34230 + .long 0x7c642fd8 /* 14: stxvd2ux vs3,r4,r5 */
34231 + .long 0x7d642f99 /* 18: stxvd2x vs43,r4,r5 */
34232 + .long 0x7d642fd9 /* 1c: stxvd2ux vs43,r4,r5 */
34233 + .long 0xf0642850 /* 20: xxmrghd vs3,vs4,vs5 */
34234 + .long 0xf16c6857 /* 24: xxmrghd vs43,vs44,vs45 */
34235 + .long 0xf0642b50 /* 28: xxmrgld vs3,vs4,vs5 */
34236 + .long 0xf16c6b57 /* 2c: xxmrgld vs43,vs44,vs45 */
34237 + .long 0xf0642850 /* 30: xxmrghd vs3,vs4,vs5 */
34238 + .long 0xf16c6857 /* 34: xxmrghd vs43,vs44,vs45 */
34239 + .long 0xf0642b50 /* 38: xxmrgld vs3,vs4,vs5 */
34240 + .long 0xf16c6b57 /* 3c: xxmrgld vs43,vs44,vs45 */
34241 + .long 0xf0642950 /* 40: xxpermdi vs3,vs4,vs5,1 */
34242 + .long 0xf16c6957 /* 44: xxpermdi vs43,vs44,vs45,1 */
34243 + .long 0xf0642a50 /* 48: xxpermdi vs3,vs4,vs5,2 */
34244 + .long 0xf16c6a57 /* 4c: xxpermdi vs43,vs44,vs45,2 */
34245 + .long 0xf0642780 /* 50: xvmovdp vs3,vs4 */
34246 + .long 0xf16c6787 /* 54: xvmovdp vs43,vs44 */
34247 + .long 0xf0642780 /* 58: xvmovdp vs3,vs4 */
34248 + .long 0xf16c6787 /* 5c: xvmovdp vs43,vs44 */
34249 + .long 0xf0642f80 /* 60: xvcpsgndp vs3,vs4,vs5 */
34250 + .long 0xf16c6f87 /* 64: xvcpsgndp vs43,vs44,vs45 */
34251 + .long 0x7c00007c /* 68: wait */
34252 + .long 0x7c00007c /* 6c: wait */
34253 + .long 0x7c20007c /* 70: waitrsv */
34254 + .long 0x7c20007c /* 74: waitrsv */
34255 + .long 0x7c40007c /* 78: waitimpl */
34256 + .long 0x7c40007c /* 7c: waitimpl */
34257 + .long 0x4c000324 /* 80: doze */
34258 + .long 0x4c000364 /* 84: nap */
34259 + .long 0x4c0003a4 /* 88: sleep */
34260 + .long 0x4c0003e4 /* 8c: rvwinkle */
34261 + .long 0x7c830134 /* 90: prtyw r3,r4 */
34262 + .long 0x7dcd0174 /* 94: prtyd r13,r14 */
34263 + .long 0x7d5c02a6 /* 98: mfcfar r10 */
34264 + .long 0x7d7c03a6 /* 9c: mtcfar r11 */
34265 + .long 0x7c832bf8 /* a0: cmpb r3,r4,r5 */
34266 + .long 0x7d4b662a /* a4: lwzcix r10,r11,r12 */
34267 + .long 0xee119004 /* a8: dadd f16,f17,f18 */
34268 + .long 0xfe96c004 /* ac: daddq f20,f22,f24 */
34269 + .long 0x7c60066c /* b0: dss 3 */
34270 + .long 0x7e00066c /* b4: dssall */
34271 + .long 0x7c2522ac /* b8: dst r5,r4,1 */
34272 + .long 0x7e083aac /* bc: dstt r8,r7,0 */
34273 + .long 0x7c6532ec /* c0: dstst r5,r6,3 */
34274 + .long 0x7e442aec /* c4: dststt r4,r5,2 */
34275 + .long 0x7d4b6356 /* c8: divwe r10,r11,r12 */
34276 + .long 0x7d6c6b57 /* cc: divwe. r11,r12,r13 */
34277 + .long 0x7d8d7756 /* d0: divweo r12,r13,r14 */
34278 + .long 0x7dae7f57 /* d4: divweo. r13,r14,r15 */
34279 + .long 0x7d4b6316 /* d8: divweu r10,r11,r12 */
34280 + .long 0x7d6c6b17 /* dc: divweu. r11,r12,r13 */
34281 + .long 0x7d8d7716 /* e0: divweuo r12,r13,r14 */
34282 + .long 0x7dae7f17 /* e4: divweuo. r13,r14,r15 */
34283 + .long 0x7e27d9f8 /* e8: bpermd r7,r17,r27 */
34284 + .long 0x7e8a02f4 /* ec: popcntw r10,r20 */
34285 + .long 0x7e8a03f4 /* f0: popcntd r10,r20 */
34286 + .long 0x7e95b428 /* f4: ldbrx r20,r21,r22 */
34287 + .long 0x7e95b528 /* f8: stdbrx r20,r21,r22 */
34288 + .long 0x7d4056ee /* fc: lfiwzx f10,0,r10 */
34289 + .long 0x7d4956ee /* 100: lfiwzx f10,r9,r10 */
34290 + .long 0xec802e9c /* 104: fcfids f4,f5 */
34291 + .long 0xec802e9d /* 108: fcfids. f4,f5 */
34292 + .long 0xec802f9c /* 10c: fcfidus f4,f5 */
34293 + .long 0xec802f9d /* 110: fcfidus. f4,f5 */
34294 + .long 0xfc80291c /* 114: fctiwu f4,f5 */
34295 + .long 0xfc80291d /* 118: fctiwu. f4,f5 */
34296 + .long 0xfc80291e /* 11c: fctiwuz f4,f5 */
34297 + .long 0xfc80291f /* 120: fctiwuz. f4,f5 */
34298 + .long 0xfc802f5c /* 124: fctidu f4,f5 */
34299 + .long 0xfc802f5d /* 128: fctidu. f4,f5 */
34300 + .long 0xfc802f5e /* 12c: fctiduz f4,f5 */
34301 + .long 0xfc802f5f /* 130: fctiduz. f4,f5 */
34302 + .long 0xfc802f9c /* 134: fcfidu f4,f5 */
34303 + .long 0xfc802f9d /* 138: fcfidu. f4,f5 */
34304 + .long 0xfc0a5900 /* 13c: ftdiv cr0,f10,f11 */
34305 + .long 0xff8a5900 /* 140: ftdiv cr7,f10,f11 */
34306 + .long 0xfc005140 /* 144: ftsqrt cr0,f10 */
34307 + .long 0xff805140 /* 148: ftsqrt cr7,f10 */
34308 + .long 0x7e084a2c /* 14c: dcbtt r8,r9 */
34309 + .long 0x7e0849ec /* 150: dcbtstt r8,r9 */
34310 + .long 0xed406644 /* 154: dcffix f10,f12 */
34311 + .long 0xee80b645 /* 158: dcffix. f20,f22 */
34312 + .long 0x7d4b6068 /* 15c: lbarx r10,r11,r12 */
34313 + .long 0x7d4b6068 /* 160: lbarx r10,r11,r12 */
34314 + .long 0x7d4b6069 /* 164: lbarx r10,r11,r12,1 */
34315 + .long 0x7e95b0e8 /* 168: lharx r20,r21,r22 */
34316 + .long 0x7e95b0e8 /* 16c: lharx r20,r21,r22 */
34317 + .long 0x7e95b0e9 /* 170: lharx r20,r21,r22,1 */
34318 + .long 0x7d4b656d /* 174: stbcx. r10,r11,r12 */
34319 + .long 0x7d4b65ad /* 178: sthcx. r10,r11,r12 */
34320 + .long 0xfdc07830 /* 17c: fre f14,f15 */
34321 + .long 0xfdc07831 /* 180: fre. f14,f15 */
34322 + .long 0xedc07830 /* 184: fres f14,f15 */
34323 + .long 0xedc07831 /* 188: fres. f14,f15 */
34324 + .long 0xfdc07834 /* 18c: frsqrte f14,f15 */
34325 + .long 0xfdc07835 /* 190: frsqrte. f14,f15 */
34326 + .long 0xedc07834 /* 194: frsqrtes f14,f15 */
34327 + .long 0xedc07835 /* 198: frsqrtes. f14,f15 */
34328 + .long 0x7c43271e /* 19c: isel r2,r3,r4,28 */
34329 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
34330 new file mode 100644
34331 index 0000000..66f7a39
34333 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
34335 + .file "x86_64-vla-typedef.c"
34336 + .section .debug_abbrev,"",@progbits
34338 + .section .debug_info,"",@progbits
34340 + .section .debug_line,"",@progbits
34345 + .type foo, @function
34348 + .file 1 "x86_64-vla-typedef.c"
34356 + movl %edi, -36(%rbp)
34359 + movq %rax, -48(%rbp)
34361 + movl -36(%rbp), %edx
34364 + movq %rax, -24(%rbp)
34372 + movq %rsp, -56(%rbp)
34373 + movq -56(%rbp), %rax
34377 + movq %rax, -56(%rbp)
34378 + movq -56(%rbp), %rax
34379 + movq %rax, -16(%rbp)
34381 + movl $0, -4(%rbp)
34385 + movl -4(%rbp), %esi
34386 + movl -4(%rbp), %eax
34388 + movq -16(%rbp), %rdx
34390 + movb %cl, (%rdx,%rax)
34392 + addl $1, -4(%rbp)
34394 + movl -4(%rbp), %eax
34395 + cmpl -36(%rbp), %eax
34398 + .globl break_here
34400 + movq -16(%rbp), %rax
34402 + movq -48(%rbp), %rsp
34408 + .section .debug_frame,"",@progbits
34410 + .long .LECIE0-.LSCIE0
34426 + .long .LEFDE0-.LASFDE0
34430 + .quad .LFE2-.LFB2
34432 + .long .LCFI0-.LFB2
34438 + .long .LCFI1-.LCFI0
34443 + .section .eh_frame,"a",@progbits
34445 + .long .LECIE1-.LSCIE1
34463 + .long .LEFDE1-.LASFDE1
34465 + .long .LASFDE1-.Lframe1
34467 + .long .LFE2-.LFB2
34470 + .long .LCFI0-.LFB2
34476 + .long .LCFI1-.LCFI0
34483 + .section .debug_loc,"",@progbits
34486 + .quad .LFB2-.Ltext0
34487 + .quad .LCFI0-.Ltext0
34491 + .quad .LCFI0-.Ltext0
34492 + .quad .LCFI1-.Ltext0
34496 + .quad .LCFI1-.Ltext0
34497 + .quad .LFE2-.Ltext0
34503 + .section .debug_info
34504 + .long .Ldebug_end - .Ldebug_start
34507 + .long .Ldebug_abbrev0
34516 + .long .Ldebug_line0
34540 + .long .Ltag_array_type - .debug_info
34541 + .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
34546 + .long .Ltag_typedef - .debug_info
34548 + /* Debugging only: Skip the typedef indirection. */
34549 + .long .Ltag_array_type - .debug_info
34551 + /* DW_AT_location: DW_FORM_block1: start */
34556 + .byte 0x6 /* DW_OP_deref */
34558 + .byte 0x96 /* DW_OP_nop */
34560 + /* DW_AT_location: DW_FORM_block1: end */
34575 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
34576 + .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
34577 + .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
34578 +1: /* DW_AT_data_location: DW_FORM_block1: start */
34579 + .byte 2f - 3f /* length */
34581 + .byte 0x97 /* DW_OP_push_object_address */
34582 + .byte 0x6 /* DW_OP_deref */
34583 +2: /* DW_AT_data_location: DW_FORM_block1: end */
34585 + .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
34600 + .section .debug_abbrev
34712 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
34715 + .uleb128 0x49 /* DW_AT_type */
34716 + .uleb128 0x13 /* DW_FORM_ref4 */
34717 + .uleb128 0x1 /* DW_AT_sibling */
34718 + .uleb128 0x13 /* DW_FORM_ref4 */
34719 + .uleb128 0x50 /* DW_AT_data_location */
34720 + .uleb128 0xa /* DW_FORM_block1 */
34726 + .uleb128 0x49 /* DW_AT_type */
34727 + .uleb128 0x13 /* DW_FORM_ref4 */
34753 + .section .debug_pubnames,"",@progbits
34756 + .long .Ldebug_info0
34761 + .section .debug_aranges,"",@progbits
34764 + .long .Ldebug_info0
34770 + .quad .Letext0-.Ltext0
34773 + .section .debug_str,"MS",@progbits,1
34779 + .string "x86_64-vla-typedef.c"
34781 + .string "array_t"
34785 + .string "gdb.arch"
34787 + .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
34788 + .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
34789 + .section .note.GNU-stack,"",@progbits
34790 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
34791 new file mode 100644
34792 index 0000000..b809c4e
34794 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
34796 +/* This testcase is part of GDB, the GNU debugger.
34798 + Copyright 2008 Free Software Foundation, Inc.
34800 + This program is free software; you can redistribute it and/or modify
34801 + it under the terms of the GNU General Public License as published by
34802 + the Free Software Foundation; either version 3 of the License, or
34803 + (at your option) any later version.
34805 + This program is distributed in the hope that it will be useful,
34806 + but WITHOUT ANY WARRANTY; without even the implied warranty of
34807 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34808 + GNU General Public License for more details.
34810 + You should have received a copy of the GNU General Public License
34811 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
34818 + typedef char array_t[size];
34822 + for (i = 0; i < size; i++)
34825 + array[0] = 0; /* break-here */
34839 diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
34840 new file mode 100644
34841 index 0000000..534120a
34843 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
34845 +# Copyright 2009 Free Software Foundation, Inc.
34847 +# This program is free software; you can redistribute it and/or modify
34848 +# it under the terms of the GNU General Public License as published by
34849 +# the Free Software Foundation; either version 3 of the License, or
34850 +# (at your option) any later version.
34852 +# This program is distributed in the hope that it will be useful,
34853 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
34854 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34855 +# GNU General Public License for more details.
34857 +# You should have received a copy of the GNU General Public License
34858 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
34860 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
34862 +if ![istarget "x86_64-*-*"] then {
34863 + verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
34867 +set testfile x86_64-vla-typedef
34868 +set srcasmfile ${testfile}-foo.S
34869 +set srcfile ${testfile}.c
34870 +set binfile ${objdir}/${subdir}/${testfile}
34871 +set binobjfile ${objdir}/${subdir}/${testfile}-foo.o
34872 +if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
34873 + untested "Couldn't compile test program"
34876 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
34877 + untested "Couldn't compile test program"
34883 +gdb_reinitialize_dir $srcdir/$subdir
34884 +gdb_load ${binfile}
34886 +if ![runto_main] {
34887 + untested x86_64-vla-typedef
34891 +gdb_breakpoint "break_here"
34893 +gdb_continue_to_breakpoint "break_here"
34895 +gdb_test "whatis array" "type = array_t" "first: whatis array"
34897 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
34899 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\1'"
34900 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\2'"
34901 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\3'"
34902 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\4'"
34904 +gdb_continue_to_breakpoint "break_here"
34906 +gdb_test "whatis array" "type = array_t" "second: whatis array"
34908 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
34909 diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in
34910 index 9f382db..12db521 100644
34911 --- a/gdb/testsuite/gdb.base/Makefile.in
34912 +++ b/gdb/testsuite/gdb.base/Makefile.in
34913 @@ -12,7 +12,7 @@ EXECUTABLES = all-types annota1 bitfields break \
34914 scope section_command setshow setvar shmain sigall signals \
34915 solib solib_sl so-impl-ld so-indr-cl \
34916 step-line step-test structs structs2 \
34917 - twice-tmp varargs vforked-prog watchpoint whatis
34918 + twice-tmp varargs vforked-prog watchpoint whatis catch-syscall
34920 MISCELLANEOUS = coremmap.data ../foobar.baz \
34921 shr1.sl shr2.sl solib_sl.sl solib1.sl solib2.sl
34922 diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp
34923 index 3359c70..f73dd7f 100644
34924 --- a/gdb/testsuite/gdb.base/call-rt-st.exp
34925 +++ b/gdb/testsuite/gdb.base/call-rt-st.exp
34926 @@ -186,7 +186,7 @@ if {![gdb_skip_float_test "print print_two_floats(*f3)"] && \
34928 if ![gdb_skip_stdio_test "print print_bit_flags_char(*cflags)"] {
34929 print_struct_call "print_bit_flags_char(*cflags)" \
34930 - ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\0', gamma = 1 '\\\\001', delta = 0 '\\\\0', epsilon = 1 '\\\\001', omega = 0 '\\\\0'\\}"
34931 + ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\1', beta = 0 '\\\\0', gamma = 1 '\\\\1', delta = 0 '\\\\0', epsilon = 1 '\\\\1', omega = 0 '\\\\0'\\}"
34934 if ![gdb_skip_stdio_test "print print_bit_flags_short(*sflags)"] {
34935 diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
34936 index 6d8aa45..be6a872 100644
34937 --- a/gdb/testsuite/gdb.base/callfuncs.exp
34938 +++ b/gdb/testsuite/gdb.base/callfuncs.exp
34939 @@ -437,7 +437,7 @@ gdb_test "print t_small_values(1,3,5,7,9,11,13,15,17,19)" \
34940 "The program being debugged stopped while.*" \
34941 "stop at nested call level 4"
34942 gdb_test "backtrace" \
34943 - "\#0 t_small_values \\(arg1=1 '.001', arg2=3, arg3=5, arg4=7 '.a', arg5=9, arg6=11 '.v', arg7=13, arg8=15, arg9=17, arg10=19\\).*\#2 sum10 \\(i0=2, i1=4, i2=6, i3=8, i4=10, i5=12, i6=14, i7=16, i8=18, i9=20\\).*\#3 <function called from gdb>.*\#4 add \\(a=4, b=5\\).*\#5 <function called from gdb>.*\#6 add \\(a=2, b=3\\).*\#7 <function called from gdb>.*\#8 main.*" \
34944 + "\#0 t_small_values \\(arg1=1 '.1', arg2=3, arg3=5, arg4=7 '.a', arg5=9, arg6=11 '.v', arg7=13, arg8=15, arg9=17, arg10=19\\).*\#2 sum10 \\(i0=2, i1=4, i2=6, i3=8, i4=10, i5=12, i6=14, i7=16, i8=18, i9=20\\).*\#3 <function called from gdb>.*\#4 add \\(a=4, b=5\\).*\#5 <function called from gdb>.*\#6 add \\(a=2, b=3\\).*\#7 <function called from gdb>.*\#8 main.*" \
34945 "backtrace at nested call level 4"
34946 gdb_test "finish" "Value returned is .* = 100" \
34947 "Finish from nested call level 4"
34948 diff --git a/gdb/testsuite/gdb.base/catch-syscall.c b/gdb/testsuite/gdb.base/catch-syscall.c
34949 new file mode 100644
34950 index 0000000..64850de
34952 +++ b/gdb/testsuite/gdb.base/catch-syscall.c
34954 +/* This file is used to test the 'catch syscall' feature on GDB.
34956 + Please, if you are going to edit this file DO NOT change the syscalls
34957 + being called (nor the order of them). If you really must do this, then
34958 + take a look at catch-syscall.exp and modify there too.
34960 + Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
34961 + September, 2008 */
34963 +#include <unistd.h>
34964 +#include <fcntl.h>
34965 +#include <sys/stat.h>
34970 + /* A close() with a wrong argument. We are only
34971 + interested in the syscall. */
34976 + /* The last syscall. Do not change this. */
34979 diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
34980 new file mode 100644
34981 index 0000000..a9f6937
34983 +++ b/gdb/testsuite/gdb.base/catch-syscall.exp
34985 +# Copyright 1997, 1999, 2007, 2008 Free Software Foundation, Inc.
34987 +# This program is free software; you can redistribute it and/or modify
34988 +# it under the terms of the GNU General Public License as published by
34989 +# the Free Software Foundation; either version 3 of the License, or
34990 +# (at your option) any later version.
34992 +# This program is distributed in the hope that it will be useful,
34993 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
34994 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34995 +# GNU General Public License for more details.
34997 +# You should have received a copy of the GNU General Public License
34998 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
35001 +# This program tests the 'catch syscall' functionality.
35003 +# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
35004 +# on September/2008.
35006 +if { [is_remote target] || ![isnative] } then {
35014 +set testfile "catch-syscall"
35015 +set srcfile ${testfile}.c
35016 +set binfile ${objdir}/${subdir}/${testfile}
35018 +# All (but the last) syscalls from the example code
35019 +# They are ordered according to the file, so do not change this.
35020 +set all_syscalls { "close" "chroot" }
35021 +# The last syscall (exit()) does not return, so
35022 +# we cannot expect the catchpoint to be triggered
35023 +# twice. It is a special case.
35024 +set last_syscall "exit_group"
35026 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
35027 + untested catch-syscall.exp
35031 +# Until "catch syscall" is implemented on other targets...
35032 +if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
35036 +# This shall be updated whenever 'catch syscall' is implemented
35037 +# on some architecture.
35038 +#if { ![istarget "x86_64-*-linux*"] && ![istarget "i\[34567\]86-*-linux*"]
35039 +if { ![istarget "i\[34567\]86-*-linux*"]
35040 + && ![istarget "powerpc-*-linux*"] && ![istarget "powerpc64-*-linux*"] } {
35044 +# Internal procedure used to check if, before any syscall is caught,
35045 +# the command 'info breakpoints' correctly lists the catchpoints AND
35046 +# says that nothing was caught yet.
35047 +proc check_init_info_breakpoints {} {
35048 + global gdb_prompt
35050 + # Verifying that the catchpoint appears in the 'info breakpoints'
35051 + # command, but with "<any syscall>".
35052 + set thistest "catch syscall appears in 'info breakpoints'"
35053 + gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall \"<any syscall>\".*" $thistest
35056 +# This procedure checks if, after a syscall catchpoint is hit, the
35057 +# command 'info breakpoints' correctly lists the syscall name.
35058 +proc check_info_breakpoints { syscall } {
35059 + global gdb_prompt
35061 + set thistest "syscall $syscall appears in 'info breakpoints'"
35062 + gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall (.)?${syscall}(.)?.*" $thistest
35065 +# This procedure checks if there was a call to a syscall.
35066 +proc check_call_to_syscall { syscall } {
35067 + global gdb_prompt
35069 + set thistest "program has called $syscall"
35070 + gdb_test "continue" "Catchpoint .*(call to syscall .?${syscall}.?).*" $thistest
35072 + # Checking if the syscall is reported to be caught in
35073 + # 'info breakpoints'.
35074 + check_info_breakpoints "$syscall"
35077 +# This procedure checks if the syscall returned.
35078 +proc check_return_from_syscall { syscall } {
35079 + global gdb_prompt
35081 + set thistest "syscall $syscall has returned"
35082 + gdb_test "continue" "Catchpoint .*(returned from syscall (.)?${syscall}(.)?).*" $thistest
35084 + # Checking if the syscall is reported to be caught in
35085 + # 'info breakpoints'.
35086 + check_info_breakpoints "$syscall"
35089 +# Internal procedure that performs two 'continue' commands and checks if
35090 +# a syscall call AND return occur.
35091 +proc check_continue { syscall } {
35092 + global gdb_prompt
35094 + # Testing if the 'continue' stops at the
35095 + # specified syscall_name. If it does, then it should
35096 + # first print that the infeior has called the syscall,
35097 + # and after print that the syscall has returned.
35099 + # Testing if the inferiorr has called the syscall.
35100 + check_call_to_syscall $syscall
35101 + # And now, that the syscall has returned.
35102 + check_return_from_syscall $syscall
35105 +# Inserts a syscall catchpoint with an argument.
35106 +proc insert_catch_syscall_with_arg { syscall } {
35107 + global gdb_prompt
35109 + # Trying to set the syscall
35110 + set thistest "catch syscall with arguments ($syscall)"
35111 + gdb_test "catch syscall $syscall" "Catchpoint .*(syscall\[(\]s\[)\] (.)?${syscall}(.)?).*" $thistest
35114 +proc check_for_program_end {} {
35115 + global gdb_prompt
35117 + # Deleting the catchpoints
35118 + delete_breakpoints
35120 + set thistest "successful program end"
35121 + gdb_test "continue" "Program exited normally.*" $thistest
35125 +proc test_catch_syscall_without_args {} {
35126 + global gdb_prompt all_syscalls last_syscall
35128 + # Trying to set the syscall
35129 + set thistest "setting catch syscall without arguments"
35130 + gdb_test "catch syscall" "Catchpoint .*(syscall).*" $thistest
35132 + check_init_info_breakpoints
35134 + # We have to check every syscall
35135 + foreach name $all_syscalls {
35136 + check_continue $name
35139 + # At last but not least, we check if the inferior
35140 + # has called the last (exit) syscall.
35141 + check_call_to_syscall $last_syscall
35143 + # Now let's see if the inferior correctly finishes.
35144 + check_for_program_end
35147 +proc test_catch_syscall_with_args {} {
35148 + global gdb_prompt
35149 + set syscall_name "close"
35151 + insert_catch_syscall_with_arg $syscall_name
35152 + check_init_info_breakpoints
35154 + # Can we continue until we catch the syscall?
35155 + check_continue $syscall_name
35157 + # Now let's see if the inferior correctly finishes.
35158 + check_for_program_end
35161 +proc test_catch_syscall_with_wrong_args {} {
35162 + global gdb_prompt
35163 + # mlock is not called from the source
35164 + set syscall_name "mlock"
35166 + insert_catch_syscall_with_arg $syscall_name
35167 + check_init_info_breakpoints
35169 + # Now, we must verify if the program stops with a continue.
35170 + # If it doesn't, everything is right (since we don't have
35171 + # a syscall named "mlock" in it). Otherwise, this is a failure.
35172 + set thistest "catch syscall with unused syscall ($syscall_name)"
35173 + gdb_test "continue" "Program exited normally.*" $thistest
35176 +proc test_catch_syscall_restarting_inferior {} {
35177 + global gdb_prompt
35178 + set syscall_name "chroot"
35180 + insert_catch_syscall_with_arg $syscall_name
35181 + check_init_info_breakpoints
35183 + # Let's first reach the call of the syscall.
35184 + check_call_to_syscall $syscall_name
35186 + # Now, restart the program
35189 + # And check for call/return
35190 + check_continue $syscall_name
35193 + check_for_program_end
35196 +proc do_syscall_tests {} {
35197 + global gdb_prompt srcdir
35199 + # First, we need to set GDB datadir.
35200 + send_gdb "maintenance set gdb_datadir $srcdir/..\n"
35202 + -re "$gdb_prompt $" {
35203 + verbose "Setting GDB datadir to $srcdir/..." 2
35206 + error "Couldn't set GDB datadir."
35210 + # Verify that the 'catch syscall' help is available
35211 + set thistest "help catch syscall"
35212 + gdb_test "help catch syscall" "Catch system calls.*" $thistest
35214 + # Try to set a catchpoint to a nonsense syscall
35215 + set thistest "catch syscall to a nonsense syscall is prohibited"
35216 + gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .*" $thistest
35218 + # Testing the 'catch syscall' command without arguments.
35219 + # This test should catch any syscalls.
35220 + if [runto_main] then { test_catch_syscall_without_args }
35222 + # Testing the 'catch syscall' command with arguments.
35223 + # This test should only catch the specified syscall.
35224 + if [runto_main] then { test_catch_syscall_with_args }
35226 + # Testing the 'catch syscall' command with WRONG arguments.
35227 + # This test should not trigger any catchpoints.
35228 + if [runto_main] then { test_catch_syscall_with_wrong_args }
35230 + # Testing the 'catch' syscall command during a restart of
35232 + if [runto_main] then { test_catch_syscall_restarting_inferior }
35235 +proc test_catch_syscall_fail_noxml {} {
35236 + global gdb_prompt
35239 + delete_breakpoints
35241 + # Testing to see if we receive a warning when calling "catch syscall"
35242 + # without XML support.
35243 + set thistest "Catch syscall displays a warning when there is no XML support"
35244 + gdb_test "catch syscall" "warning: Could not open .*warning: Could not load the syscall XML file .*GDB will not be able to display syscall names.*Catchpoint .*(syscall).*" $thistest
35246 + # Since the catchpoint was set, we must check if it's present at
35247 + # "info breakpoints"
35248 + check_init_info_breakpoints
35251 + delete_breakpoints
35254 +proc test_catch_syscall_without_args_noxml {} {
35255 + # We will need the syscall names even not using it
35256 + # because we need to know know many syscalls are in
35257 + # the example file.
35258 + global gdb_prompt all_syscalls last_syscall
35260 + delete_breakpoints
35262 + set thistest "Catch syscall without arguments and without XML support"
35263 + gdb_test "catch syscall" "Catchpoint .*(syscall).*"
35265 + # Now, we should be able to set a catchpoint,
35266 + # and GDB shall not display the warning anymore.
35267 + foreach name $all_syscalls {
35268 + # Unfortunately, we don't know the syscall number
35269 + # that will be caught because this information is
35270 + # arch-dependent. Thus, we try to catch anything
35271 + # similar to a number.
35272 + check_continue "\[0-9\]*"
35275 + # At last but not least, we check if the inferior
35276 + # has called the last (exit) syscall.
35277 + check_call_to_syscall "\[0-9\]*"
35279 + delete_breakpoints
35282 +proc test_catch_syscall_with_args_noxml {} {
35283 + global gdb_prompt
35285 + # The number of the "close" syscall. This is our
35286 + # options for a "long-estabilished" syscall in all
35287 + # Linux architectures, but unfortunately x86_64 and
35288 + # a few other platforms don't "follow the convention".
35289 + # Because of this, we need this ugly check :-(.
35290 + set close_number ""
35291 + if { [istarget "x86_64-*-linux*"] } {
35292 + set close_number "3"
35294 + set close_number "6"
35297 + delete_breakpoints
35299 + insert_catch_syscall_with_arg $close_number
35300 + check_init_info_breakpoints
35302 + check_continue $close_number
35304 + delete_breakpoints
35307 +proc test_catch_syscall_with_wrong_args_noxml {} {
35308 + global gdb_prompt
35310 + delete_breakpoints
35312 + # Even without XML support, GDB should not accept unknown
35313 + # syscall names for the catchpoint.
35314 + set thistest "Catch a nonsense syscall without XML support"
35315 + gdb_test "catch syscall nonsense_syscall" "Unknown syscall name .nonsense_syscall.*" $thistest
35317 + delete_breakpoints
35320 +proc do_syscall_tests_without_xml {} {
35321 + global gdb_prompt srcdir
35323 + # In this case, we don't need to set GDB's datadir because
35324 + # we want GDB to display only numbers, not names. So, let's
35325 + # begin with the tests.
35327 + # The first test is to see if GDB displays a warning when we
35328 + # try to catch syscalls without the XML support.
35329 + test_catch_syscall_fail_noxml
35331 + # Now, let's test if we can catch syscalls without XML support.
35332 + # We should succeed, but GDB is not supposed to print syscall names.
35333 + if [runto_main] then { test_catch_syscall_without_args_noxml }
35335 + # The only valid argument "catch syscall" should accept is the
35336 + # syscall number, and not the name (since it can't translate a
35337 + # name to a number).
35339 + # It's worth mentioning that we only try to catch the syscall
35340 + # close(). This is because the syscall number is an arch-dependent
35341 + # information, so we can't assume that we know every syscall number
35342 + # in this system. Therefore, we have decided to use a "long-estabilished"
35343 + # system call, and close() just sounded the right choice :-).
35344 + if [runto_main] then { test_catch_syscall_with_args_noxml }
35346 + # Now, we'll try to provide a syscall name (valid or not) to the command,
35347 + # and expect it to fail.
35348 + if [runto_main] then { test_catch_syscall_with_wrong_args_noxml }
35351 +# Start with a fresh gdb
35355 +gdb_reinitialize_dir $srcdir/$subdir
35356 +gdb_load ${binfile}
35358 +# Execute the tests, using XML support
35365 +gdb_reinitialize_dir $srcdir/$subdir
35366 +gdb_load ${binfile}
35368 +# Execute the tests, without XML support. In this case, GDB will
35369 +# only display syscall numbers, and not syscall names.
35370 +do_syscall_tests_without_xml
35371 diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c
35372 index b640702..55a50ce 100644
35373 --- a/gdb/testsuite/gdb.base/charset.c
35374 +++ b/gdb/testsuite/gdb.base/charset.c
35376 Please email any bugs, comments, and/or additions to this file to:
35379 -#include <stdio.h>
35380 -#include <stdlib.h>
35381 -#include <string.h>
35384 /* X_string is a null-terminated string in the X charset whose
35385 elements are as follows. X should be the name the `set charset'
35386 command uses for the character set, in lower-case, with any
35387 @@ -54,6 +49,21 @@ char iso_8859_1_string[NUM_CHARS];
35388 char ebcdic_us_string[NUM_CHARS];
35389 char ibm1047_string[NUM_CHARS];
35391 +/* We make a phony wchar_t and then pretend that this platform uses
35392 + UCS-4 (or UCS-2, depending on the size -- same difference for the
35393 + purposes of this test). */
35394 +typedef unsigned int wchar_t;
35395 +wchar_t ucs_4_string[NUM_CHARS];
35397 +/* We also define a couple phony types for testing the u'' and U''
35398 + support. It is ok if these have the wrong size on some platforms
35399 + -- the test case will skip the tests in that case. */
35400 +typedef unsigned short char16_t;
35401 +typedef unsigned int char32_t;
35403 +/* Make sure to use the typedefs. */
35408 init_string (char string[],
35409 @@ -62,7 +72,10 @@ init_string (char string[],
35410 char line_feed, char carriage_return, char horizontal_tab,
35411 char vertical_tab, char cent, char misc_ctrl)
35413 - memset (string, x, NUM_CHARS);
35416 + for (i = 0; i < NUM_CHARS; ++i)
35419 string[1] = backspace;
35420 string[2] = form_feed;
35421 @@ -85,13 +98,21 @@ fill_run (char string[], int start, int len, int first)
35430 + for (i = 0; i < NUM_CHARS; ++i)
35431 + ucs_4_string[i] = iso_8859_1_string[i] & 0xff;
35440 - (void) malloc (1);
35441 /* Initialize ascii_string. */
35442 init_string (ascii_string,
35444 @@ -146,5 +167,7 @@ int main ()
35445 /* The digits, at least, are contiguous. */
35446 fill_run (ibm1047_string, 59, 10, 240);
35448 - puts ("All set!"); /* all strings initialized */
35451 + return 0; /* all strings initialized */
35453 diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
35454 index fa26521..93f66c0 100644
35455 --- a/gdb/testsuite/gdb.base/charset.exp
35456 +++ b/gdb/testsuite/gdb.base/charset.exp
35457 @@ -47,13 +47,7 @@ proc parse_show_charset_output {testname} {
35461 - -re "The current host and target character set is `(.*)'\\.\[\r\n\]+$gdb_prompt $" {
35462 - set host_charset $expect_out(1,string)
35463 - set target_charset $expect_out(1,string)
35464 - set retlist [list $host_charset $target_charset]
35467 - -re "The current host character set is `(.*)'\\.\[\r\n\]+The current target character set is `(.*)'\\.\[\r\n\]+$gdb_prompt $" {
35468 + -re "The host character set is \"(.*)\"\\.\[\r\n\]+The target character set is \"(.*)\"\\.\[\r\n\]+The target wide character set is \"(.*)\"\\.\[\r\n\]+$gdb_prompt $" {
35469 set host_charset $expect_out(1,string)
35470 set target_charset $expect_out(2,string)
35471 set retlist [list $host_charset $target_charset]
35472 @@ -81,79 +75,35 @@ proc parse_show_charset_output {testname} {
35476 -# Try the various `show charset' commands. These are all aliases of each
35477 -# other; `show target-charset' and `show host-charset' actually print
35478 -# both the host and target charsets.
35479 +# Try the various `show charset' commands.
35481 send_gdb "show charset\n"
35482 set show_charset [parse_show_charset_output "show charset"]
35484 send_gdb "show target-charset\n"
35485 -set show_target_charset [parse_show_charset_output "show target-charset"]
35486 +set show_target_charset \
35487 + [lindex [parse_show_charset_output "show target-charset"] 0]
35489 -if {[lsearch $show_charset $show_target_charset] >= 0} {
35490 +if {[lsearch -exact $show_charset $show_target_charset] >= 0} {
35491 pass "check `show target-charset' against `show charset'"
35493 fail "check `show target-charset' against `show charset'"
35496 send_gdb "show host-charset\n"
35497 -set show_host_charset [parse_show_charset_output "show host-charset"]
35498 +set show_host_charset \
35499 + [lindex [parse_show_charset_output "show host-charset"] 0]
35501 -if {[lsearch $show_charset $show_host_charset] >= 0} {
35502 +if {[lsearch -exact $show_charset $show_host_charset] >= 0} {
35503 pass "check `show host-charset' against `show charset'"
35505 fail "check `show host-charset' against `show charset'"
35509 -# Get the list of supported (host) charsets as possible completions.
35510 -send_gdb "set charset \t\t"
35512 -# Check that we can at least use ASCII as a host character set.
35515 - -re "^set charset .*\r\nASCII.*\r\n$gdb_prompt set charset " {
35516 - # We got the output that we wanted, including ASCII as possible
35517 - # charset. Send a newline to get us back to the prompt. This will
35518 - # also generate an error message. Let's not check here that the error
35519 - # message makes sense, we do that below, as a separate testcase.
35522 - -re ".*Requires an argument.*$gdb_prompt $" {
35523 - pass "get valid character sets"
35525 - -re ".*$gdb_prompt $" {
35528 - -re ".*$gdb_prompt $" {
35529 - fail "get valid character sets"
35534 - fail "(timeout) get valid character sets"
35538 - -re ".*$gdb_prompt $" {
35539 - # We got some output that ended with a regular prompt
35540 - fail "get valid character sets"
35542 - -re ".*$gdb_prompt set charset.*$" {
35543 - # We got some other output, send a cntrl-c to gdb to get us back
35546 - fail "get valid character sets"
35549 - fail "get valid character sets (timeout)"
35553 # Try a malformed `set charset'.
35554 +# Also check that we can at least use ASCII as a host character set.
35555 gdb_test "set charset" \
35556 - "Requires an argument. Valid arguments are.*" \
35557 + "Requires an argument. Valid arguments are.* ASCII,.*" \
35558 "try malformed `set charset'"
35560 # Try using `set host-charset' on an invalid character set.
35561 @@ -244,8 +194,10 @@ gdb_expect {
35565 -# Make sure that GDB supports every host/target charset combination.
35566 -foreach host_charset [all_charset_names] {
35567 +# We don't want to test all the charset names here, since that would
35568 +# be too many combinations. We we pick a subset.
35569 +set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047}
35570 +foreach host_charset $charset_subset {
35571 if {[valid_host_charset $host_charset]} {
35573 set testname "try `set host-charset $host_charset'"
35574 @@ -279,7 +231,7 @@ foreach host_charset [all_charset_names] {
35576 # Now try setting every possible target character set,
35577 # given that host charset.
35578 - foreach target_charset [all_charset_names] {
35579 + foreach target_charset $charset_subset {
35580 set testname "try `set target-charset $target_charset'"
35581 send_gdb "set target-charset $target_charset\n"
35583 @@ -404,23 +356,42 @@ gdb_expect {
35587 +# We only try the wide character tests on machines where the wchar_t
35588 +# typedef in the test case has the right size.
35589 +set wchar_size [get_sizeof wchar_t 99]
35591 +if {$wchar_size == 2} {
35592 + lappend charset_subset UCS-2
35594 +} elseif {$wchar_size == 4} {
35595 + lappend charset_subset UCS-4
35599 gdb_test "set host-charset ASCII" ""
35600 -foreach target_charset [all_charset_names] {
35601 - send_gdb "set target-charset $target_charset\n"
35602 +foreach target_charset $charset_subset {
35603 + if {$target_charset == "UCS-4" || $target_charset == "UCS-2"} {
35604 + set param target-wide-charset
35607 + set param target-charset
35610 + send_gdb "set $param $target_charset\n"
35612 -re "$gdb_prompt $" {
35613 - pass "set target-charset $target_charset"
35614 + pass "set $param $target_charset"
35617 - fail "set target-charset $target_charset (timeout)"
35618 + fail "set $param $target_charset (timeout)"
35622 # Try printing the null character. There seems to be a bug in
35623 # gdb_test that requires us to use gdb_expect here.
35624 - send_gdb "print '\\0'\n"
35625 + send_gdb "print $L'\\0'\n"
35627 - -re "\\\$${decimal} = 0 '\\\\0'\[\r\n\]+$gdb_prompt $" {
35628 + -re "\\\$${decimal} = 0 $L'\\\\0'\[\r\n\]+$gdb_prompt $" {
35629 pass "print the null character in ${target_charset}"
35631 -re "$gdb_prompt $" {
35632 @@ -435,8 +406,14 @@ foreach target_charset [all_charset_names] {
35633 # a string in $target_charset. The variable's name is the
35634 # character set's name, in lower-case, with all non-identifier
35635 # characters replaced with '_', with "_string" stuck on the end.
35636 - set var_name [string tolower "${target_charset}_string"]
35637 - regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
35638 + if {$target_charset == "UCS-2"} {
35639 + # We still use the ucs_4_string variable -- but the size is
35640 + # correct for UCS-2.
35641 + set var_name ucs_4_string
35643 + set var_name [string tolower "${target_charset}_string"]
35644 + regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
35647 # Compute a regexp matching the results we expect. This is static,
35648 # but it's easier than writing it out.
35649 @@ -444,12 +421,12 @@ foreach target_charset [all_charset_names] {
35650 set uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
35651 set lowercase "abcdefghijklmnopqrstuvwxyz"
35652 set digits "0123456789"
35653 - set octal_escape "\\\\\[0-9\]\[0-9\]\[0-9\]"
35654 + set octal_escape "\\\\\[0-9\]+"
35656 send_gdb "print $var_name\n"
35657 # ${escapes}${uppercase}${lowercase}${digits}${octal}${octal}
35659 - -re ".* = \"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(\\\\\[0-9\]\[0-9\]\[0-9\]|x)(\\\\\[0-9\]\[0-9\]\[0-9\]|x).*\"\[\r\n\]+$gdb_prompt $" {
35660 + -re ".* = $L\"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(${octal_escape}|x)+\"\[\r\n\]+$gdb_prompt $" {
35661 pass "print string in $target_charset"
35663 -re "$gdb_prompt $" {
35664 @@ -461,22 +438,22 @@ foreach target_charset [all_charset_names] {
35667 # Try entering a character literal, and see if it comes back unchanged.
35668 - gdb_test "print 'A'" \
35669 - " = \[0-9-\]+ 'A'" \
35670 + gdb_test "print $L'A'" \
35671 + " = \[0-9-\]+ $L'A'" \
35672 "parse character literal in ${target_charset}"
35674 # Check that the character literal was encoded correctly.
35675 - gdb_test "print 'A' == $var_name\[7\]" \
35676 + gdb_test "print $L'A' == $var_name\[7\]" \
35678 "check value of parsed character literal in ${target_charset}"
35680 # Try entering a string literal, and see if it comes back unchanged.
35681 - gdb_test "print \"abcdefABCDEF012345\"" \
35682 - " = \"abcdefABCDEF012345\"" \
35683 + gdb_test "print $L\"abcdefABCDEF012345\"" \
35684 + " = $L\"abcdefABCDEF012345\"" \
35685 "parse string literal in ${target_charset}"
35687 # Check that the string literal was encoded correctly.
35688 - gdb_test "print \"q\"\[0\] == $var_name\[49\]" \
35689 + gdb_test "print $L\"q\"\[0\] == $var_name\[49\]" \
35691 "check value of parsed string literal in ${target_charset}"
35693 @@ -509,7 +486,7 @@ foreach target_charset [all_charset_names] {
35694 send_gdb "print $var_name\[$i\]\n"
35697 - -re "= \[0-9-\]+ '\\\\${escape}'\[\r\n\]+$gdb_prompt $" {
35698 + -re "= \[0-9-\]+ $L'\\\\${escape}'\[\r\n\]+$gdb_prompt $" {
35699 pass "try printing '\\${escape}' in ${target_charset}"
35701 -re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" {
35702 @@ -527,12 +504,12 @@ foreach target_charset [all_charset_names] {
35703 if {$have_escape} {
35705 # Try parsing a backslash escape in a character literal.
35706 - gdb_test "print '\\${escape}' == $var_name\[$i\]" \
35707 + gdb_test "print $L'\\${escape}' == $var_name\[$i\]" \
35709 "check value of '\\${escape}' in ${target_charset}"
35711 # Try parsing a backslash escape in a string literal.
35712 - gdb_test "print \"\\${escape}\"\[0\] == $var_name\[$i\]" \
35713 + gdb_test "print $L\"\\${escape}\"\[0\] == $var_name\[$i\]" \
35715 "check value of \"\\${escape}\" in ${target_charset}"
35717 @@ -540,10 +517,73 @@ foreach target_charset [all_charset_names] {
35719 # Try printing a character escape that doesn't exist. We should
35720 # get the unescaped character, in the target character set.
35721 - gdb_test "print '\\q'" " = \[0-9-\]+ 'q'" \
35722 + gdb_test "print $L'\\q'" " = \[0-9-\]+ $L'q'" \
35723 "print escape that doesn't exist in $target_charset"
35724 - gdb_test "print '\\q' == $var_name\[49\]" " = 1" \
35725 + gdb_test "print $L'\\q' == $var_name\[49\]" " = 1" \
35726 "check value of escape that doesn't exist in $target_charset"
35729 +# Reset the target charset.
35730 +gdb_test "set target-charset UTF-8" ""
35732 +# \242 is not a valid UTF-8 character.
35733 +gdb_test "print \"\\242\"" " = \"\\\\242\"" \
35734 + "non-representable target character"
35736 +gdb_test "print '\\x'" "\\\\x escape without a following hex digit."
35737 +gdb_test "print '\\u'" "\\\\u escape without a following hex digit."
35738 +gdb_test "print '\\9'" " = \[0-9\]+ '9'"
35740 +# Tests for wide- or unicode- strings. L is the prefix letter to use,
35741 +# either "L" (for wide strings), "u" (for UCS-2), or "U" (for UCS-4).
35742 +# NAME is used in the test names and should be related to the prefix
35743 +# letter in some easy-to-undestand way.
35744 +proc test_wide_or_unicode {L name} {
35745 + gdb_test "print $L\"ab\" $L\"c\"" " = $L\"abc\"" \
35746 + "basic $name string concatenation"
35747 + gdb_test "print $L\"ab\" \"c\"" " = $L\"abc\"" \
35748 + "narrow and $name string concatenation"
35749 + gdb_test "print \"ab\" $L\"c\"" " = $L\"abc\"" \
35750 + "$name and narrow string concatenation"
35751 + gdb_test "print $L\"\\xe\" $L\"c\"" " = $L\"\\\\16c\"" \
35752 + "$name string concatenation with escape"
35753 + gdb_test "print $L\"\" \"abcdef\" \"g\"" \
35754 + "$L\"abcdefg\"" \
35755 + "concatenate three strings with empty $name string"
35757 + gdb_test "print $L'a'" "= \[0-9\]+ $L'a'" \
35758 + "basic $name character"
35762 + test_wide_or_unicode L wide
35765 +set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}]
35767 + test_wide_or_unicode u UCS-2
35770 +set ucs4_ok [expr {[get_sizeof char32_t 99] == 4}]
35772 + test_wide_or_unicode U UCS-4
35775 +# Test an invalid string combination.
35776 +proc test_combination {L1 name1 L2 name2} {
35777 + gdb_test "print $L1\"abc\" $L2\"def\"" \
35778 + "Undefined string concatenation." \
35779 + "undefined concatenation of $name1 and $name2"
35782 +if {$wchar_ok && $ucs2_ok} {
35783 + test_combination L wide u UCS-2
35785 +if {$wchar_ok && $ucs4_ok} {
35786 + test_combination L wide U UCS-4
35788 +if {$ucs2_ok && $ucs4_ok} {
35789 + test_combination u UCS-2 U UCS-4
35793 diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp
35794 index d53a826..6d1bd12 100644
35795 --- a/gdb/testsuite/gdb.base/constvars.exp
35796 +++ b/gdb/testsuite/gdb.base/constvars.exp
35797 @@ -161,7 +161,7 @@ proc do_constvar_tests {} {
35798 gdb_test "print laconic" " = 65 'A'"
35799 local_compiler_xfail_check
35800 gdb_test "ptype laconic" "type = const char"
35801 - gdb_test "print laggard" " = 1 '.001'"
35802 + gdb_test "print laggard" " = 1 '.1'"
35803 local_compiler_xfail_check
35804 gdb_test "ptype laggard" "type = const unsigned char"
35805 gdb_test "print lagoon" " = 2"
35806 @@ -209,7 +209,7 @@ proc do_constvar_tests {} {
35807 gdb_test "print *lewd" " = 65 'A'"
35808 local_compiler_xfail_check
35809 gdb_test "ptype lewd" "type = const char \\* const"
35810 - gdb_test "print *lexicographer" " = 1 '.001'"
35811 + gdb_test "print *lexicographer" " = 1 '.1'"
35812 local_compiler_xfail_check
35813 gdb_test "ptype lexicographer" "type = const unsigned char \\* const"
35814 gdb_test "print *lexicon" " = 2"
35815 @@ -233,7 +233,7 @@ proc do_constvar_tests {} {
35816 gdb_test "print *languish" " = 65 'A'"
35817 local_compiler_xfail_check
35818 gdb_test "ptype languish" "type = const char \\*"
35819 - gdb_test "print *languor" " = 1 '.001'"
35820 + gdb_test "print *languor" " = 1 '.1'"
35821 local_compiler_xfail_check
35822 gdb_test "ptype languor" "type = const unsigned char \\*"
35823 gdb_test "print *lank" " = 2"
35824 diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp
35825 index d62e8bf..aa65373 100644
35826 --- a/gdb/testsuite/gdb.base/display.exp
35827 +++ b/gdb/testsuite/gdb.base/display.exp
35828 @@ -180,8 +180,12 @@ gdb_test "printf \"%p\\n\", 1" "0x1"
35830 # play with "print", too
35832 -gdb_test "print/r j" ".*Undefined output format.*"
35833 -gdb_test "print j" ".*" "debug test output"
35834 +gdb_test "print/z j" ".*Undefined output format.*"
35835 +gdb_test "print/d j" " = 0\[\\r\\n\]+" "debug test output 1"
35836 +gdb_test "print/r j" " = 0\[\\r\\n\]+" "debug test output 1a"
35837 +gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2"
35838 +gdb_test "print/r j" " = 0x0\[\\r\\n\]+" "debug test output 2a"
35839 +gdb_test "print j" " = 0\[\\r\\n\]+" "debug test output 3"
35841 # x/0 j doesn't produce any output and terminates PA64 process when testing
35842 if [istarget "hppa2.0w-hp-hpux11*"] {
35843 diff --git a/gdb/testsuite/gdb.base/help.exp b/gdb/testsuite/gdb.base/help.exp
35844 index 4618a2c..40830c3 100644
35845 --- a/gdb/testsuite/gdb.base/help.exp
35846 +++ b/gdb/testsuite/gdb.base/help.exp
35847 @@ -603,7 +603,7 @@ gdb_test "help stepi" "Step one instruction exactly\.\[\r\n\]+Argument N means d
35848 gdb_test "help signal" "Continue program giving it signal.*" "help signal"
35850 # vxgdb reads .vxgdbinit
35851 -gdb_test "help source" "Read commands from a file named FILE\.\[\r\n\]+Optional -v switch \\(before the filename\\) causes each command in\[\r\n\]+FILE to be echoed as it is executed\.\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way\[\r\n\]+when GDB is started\." "help source"
35852 +gdb_test "help source" "Read commands from a file named FILE\.\[\r\n\]+Optional -v switch \\(before the filename\\) causes each command in\[\r\n\]+FILE to be echoed as it is executed\.\[\r\n\]+Note that the file \"\[^\"\]*\" is read automatically in this way\[\r\n\]+when GDB is started\.\[\r\n\]+Optional -p switch \\(before the filename\\) causes FILE to be evaluated\[\r\n\]+as Python code\." "help source"
35854 test_class_help "stack" {
35855 "Examining the stack\..*\[\r\n\]+"
35856 diff --git a/gdb/testsuite/gdb.base/lineno-makeup-func.c b/gdb/testsuite/gdb.base/lineno-makeup-func.c
35857 new file mode 100644
35858 index 0000000..1a0220e
35860 +++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c
35862 +/* This testcase is part of GDB, the GNU debugger.
35864 + Copyright 2009 Free Software Foundation, Inc.
35866 + This program is free software; you can redistribute it and/or modify
35867 + it under the terms of the GNU General Public License as published by
35868 + the Free Software Foundation; either version 3 of the License, or
35869 + (at your option) any later version.
35871 + This program is distributed in the hope that it will be useful,
35872 + but WITHOUT ANY WARRANTY; without even the implied warranty of
35873 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35874 + GNU General Public License for more details.
35876 + You should have received a copy of the GNU General Public License
35877 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
35883 diff --git a/gdb/testsuite/gdb.base/lineno-makeup.c b/gdb/testsuite/gdb.base/lineno-makeup.c
35884 new file mode 100644
35885 index 0000000..bb20e98
35887 +++ b/gdb/testsuite/gdb.base/lineno-makeup.c
35889 +/* This testcase is part of GDB, the GNU debugger.
35891 + Copyright 2009 Free Software Foundation, Inc.
35893 + This program is free software; you can redistribute it and/or modify
35894 + it under the terms of the GNU General Public License as published by
35895 + the Free Software Foundation; either version 3 of the License, or
35896 + (at your option) any later version.
35898 + This program is distributed in the hope that it will be useful,
35899 + but WITHOUT ANY WARRANTY; without even the implied warranty of
35900 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35901 + GNU General Public License for more details.
35903 + You should have received a copy of the GNU General Public License
35904 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
35906 +/* DW_AT_low_pc-DW_AT_high_pc should cover the function without line number
35907 + information (.debug_line) so we cannot use an external object file.
35909 + It must not be just a label as it would alias on the next function even for
35910 + correct GDB. Therefore some stub data must be placed there.
35912 + We need to provide a real stub function body as at least s390
35913 + (s390_analyze_prologue) would skip the whole body till reaching `main'. */
35915 +extern void func (void);
35916 +asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\"");
35924 diff --git a/gdb/testsuite/gdb.base/lineno-makeup.exp b/gdb/testsuite/gdb.base/lineno-makeup.exp
35925 new file mode 100644
35926 index 0000000..0c75b84
35928 +++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
35930 +# Copyright 2009 Free Software Foundation, Inc.
35932 +# This program is free software; you can redistribute it and/or modify
35933 +# it under the terms of the GNU General Public License as published by
35934 +# the Free Software Foundation; either version 3 of the License, or
35935 +# (at your option) any later version.
35937 +# This program is distributed in the hope that it will be useful,
35938 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
35939 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35940 +# GNU General Public License for more details.
35942 +# You should have received a copy of the GNU General Public License
35943 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
35945 +set testfile "lineno-makeup"
35946 +set srcfuncfile ${testfile}-func.c
35947 +set srcfile ${testfile}.c
35948 +set objfuncfile ${objdir}/${subdir}/${testfile}-func.o
35949 +set binfuncfile ${objdir}/${subdir}/${testfile}-func.bin
35950 +set binfile ${objdir}/${subdir}/${testfile}
35952 +if { [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" "${objfuncfile}" object {}] != "" } {
35953 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
35956 +set objcopy [catch "exec objcopy -O binary --only-section .text ${objfuncfile} ${binfuncfile}" output]
35957 +verbose -log "objcopy=$objcopy: $output"
35958 +if { $objcopy != 0 } {
35959 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
35961 +set binfuncfilesize [file size $binfuncfile]
35962 +verbose -log "file size $binfuncfile = $binfuncfilesize"
35964 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
35965 + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
35970 +gdb_reinitialize_dir $srcdir/$subdir
35971 +gdb_load ${binfile}
35974 +set test "break func"
35975 +gdb_test_multiple $test $test {
35976 + -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
35977 + set b_addr $expect_out(1,string)
35980 + -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" {
35981 + set b_addr $expect_out(1,string)
35985 +verbose -log "b_addr=<$b_addr>"
35988 +set test "print func"
35989 +gdb_test_multiple $test $test {
35990 + -re "\\$\[0-9\]+ = {<text variable, no debug info>} (0x\[0-9a-f\]+) <func>\r\n$gdb_prompt $" {
35991 + set p_addr $expect_out(1,string)
35995 +verbose -log "p_addr=<$p_addr>"
35997 +set test "break address belongs to func"
35998 +if {$b_addr == $p_addr} {
35999 + pass "$test (exact match)"
36001 + set skip [expr $b_addr - $p_addr]
36002 + if {$skip > 0 && $skip < $binfuncfilesize} {
36003 + pass "$test (prologue skip by $skip bytes)"
36008 diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp
36009 index d0ad5ba..5189324 100644
36010 --- a/gdb/testsuite/gdb.base/long_long.exp
36011 +++ b/gdb/testsuite/gdb.base/long_long.exp
36012 @@ -210,7 +210,7 @@ gdb_test_char "p/o *(char *)c" "01"
36013 gdb_test_char "p/t *(char *)c" "1"
36014 gdb_test_char "p/a *(char *)c" "0x1( <.*>)?"
36015 gdb_test_char "p/f *(char *)c" "1"
36016 -gdb_test_char "p/c *(char *)c" "1 '.001'"
36017 +gdb_test_char "p/c *(char *)c" "1 '.1'"
36019 gdb_test_short "p/x *(short *)s" "" "0x123" ""
36020 gdb_test_short "p/d *(short *)s" "" "291" ""
36021 @@ -257,7 +257,7 @@ gdb_test "x/u w" "19088743"
36022 gdb_test "x/o w" "0110642547"
36023 gdb_test "x/t w" "00000001001000110100010101100111"
36024 gdb_test_xptr "x/a" { b "" } { h "" } { w "0x1234567" } { g "0x123456789abcdef" }
36025 -gdb_test "x/c b" "1 '.001'"
36026 +gdb_test "x/c b" "1 '.1'"
36027 if { $sizeof_double == 8 || $sizeof_long_double == 8 } {
36028 gdb_test "x/f &val.oct" "-5.9822653797615723e-120"
36030 @@ -273,7 +273,7 @@ gdb_test "x/2u g" "81985529216486895.*12046818088235383159"
36031 gdb_test "x/2o g" "04432126361152746757.*01234567123456701234567"
36032 gdb_test "x/2t g" "0000000100100011010001010110011110001001101010111100110111101111.*1010011100101110111001010011100101110111000001010011100101110111"
36033 gdb_test_xptr "x/2a" { b "" } { h "" } { w "0x1234567.*0xa72ee539" } { g "0x123456789abcdef.*0xa72ee53977053977" }
36034 -gdb_test "x/2c b" "1 '.001'.*-89 '.'"
36035 +gdb_test "x/2c b" "1 '.1'.*-89 '.\[0-9\]*'"
36036 if { $sizeof_double == 8 || $sizeof_long_double == 8 } {
36037 gdb_test "x/2f &val.oct" "-5.9822653797615723e-120.*-5.9041889495880968e-100"
36039 @@ -288,7 +288,7 @@ gdb_test "x/2bu b" "1.*167"
36040 gdb_test "x/2bo b" "01.*0247"
36041 gdb_test "x/2bt b" "00000001.*10100111"
36042 gdb_test_ptr "x/2ba b" "" "" "0x1.*0xffffffa7" "0x1.*0xffffffffffffffa7"
36043 -gdb_test "x/2bc b" "1 '.001'.*-89 '.'"
36044 +gdb_test "x/2bc b" "1 '.1'.*-89 '.\[0-9\]*'"
36045 gdb_test "x/2bf b" "1.*-89"
36047 gdb_test "x/2hx h" "0x0123.*0xa72e"
36048 @@ -315,7 +315,7 @@ gdb_test "x/2gu g" "81985529216486895.*12046818088235383159"
36049 gdb_test "x/2go g" "04432126361152746757.*01234567123456701234567"
36050 gdb_test "x/2gt g" "0000000100100011010001010110011110001001101010111100110111101111.*1010011100101110111001010011100101110111000001010011100101110111"
36051 gdb_test_ptr "x/2ga g" "" "" "0x89abcdef.*0x77053977" "0x123456789abcdef.*0xa72ee53977053977"
36052 -gdb_test "x/2gc g" "-17 '.'.*119 'w'"
36053 +gdb_test "x/2gc g" "-17 '.\[0-9\]*'.*119 'w'"
36054 gdb_test "x/2gf g" "3.5127005640885037e-303.*-5.9822653797615723e-120"
36057 diff --git a/gdb/testsuite/gdb.base/macscp.exp b/gdb/testsuite/gdb.base/macscp.exp
36058 index 7086e90..dd196d7 100644
36059 --- a/gdb/testsuite/gdb.base/macscp.exp
36060 +++ b/gdb/testsuite/gdb.base/macscp.exp
36061 @@ -26,13 +26,21 @@ set testfile "macscp"
36062 set objfile ${objdir}/${subdir}/${testfile}.o
36063 set binfile ${objdir}/${subdir}/${testfile}
36065 -set options { debug }
36066 +set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
36068 get_compiler_info ${binfile}
36069 if [test_compiler_info gcc*] {
36070 lappend options additional_flags=-g3
36073 +# Workaround ccache making lineno non-zero for command-line definitions.
36074 +if {[find_gcc] == "gcc" && [file executable "/usr/bin/gcc"]} {
36075 + set result [catch "exec which gcc" output]
36076 + if {$result == 0 && [string first "/ccache/" $output] >= -1} {
36077 + lappend options "compiler=/usr/bin/gcc"
36081 # Generate the intermediate object file. This is required by Darwin to
36082 # have access to the .debug_macinfo section.
36083 if {[gdb_compile "${srcdir}/${subdir}/macscp1.c" "${objfile}" \
36084 @@ -79,11 +87,15 @@ proc info_macro {macro} {
36086 if {$debug_me} {exp_internal 1}
36088 - -re "Defined at \[^\r\n\]*(${filepat}):${decimal}\[\r\n\]" {
36089 + -re "Defined at \[^\r\n\]*(${filepat}):(${decimal})\[\r\n\]" {
36090 # `location' and `definition' should be empty when we see
36092 if {[llength $location] == 0 && [llength $definition] == 0} {
36093 set location $expect_out(1,string)
36094 + # Definitions from gcc command-line get suffixed by the lineno.
36095 + if {$expect_out(2,string) == "0" } {
36096 + set location "$location:$expect_out(2,string)"
36100 # Exit this expect loop, with a result indicating failure.
36101 @@ -198,6 +210,8 @@ proc list_and_check_macro {func macro expected} {
36105 +list_and_check_macro main FROM_COMMANDLINE "macscp1.c:0 ARG"
36107 if {[list_and_check_macro main WHERE {macscp1.c {before macscp1_3}}]} {
36110 diff --git a/gdb/testsuite/gdb.base/multi-forks.exp b/gdb/testsuite/gdb.base/multi-forks.exp
36111 index ac56fb0..f853180 100644
36112 --- a/gdb/testsuite/gdb.base/multi-forks.exp
36113 +++ b/gdb/testsuite/gdb.base/multi-forks.exp
36114 @@ -51,7 +51,62 @@ global gdb_prompt
36116 # This is a test of gdb's ability to follow the parent, child or both
36117 # parent and child of multiple Unix fork() system calls.
36120 +set exit_bp_loc [gdb_get_line_number "Set exit breakpoint here."]
36122 +# Insert a breakpoint at the location provided by the exit_bp_loc global
36123 +# and resume the execution until hitting that breakpoint. We also make
36124 +# sure to consume all the expected output from all processes as well,
36125 +# to make sure it doesn't cause trouble during a subsequent test.
36127 +proc continue_to_exit_bp_loc {} {
36128 + global exit_bp_loc decimal gdb_prompt
36130 + gdb_breakpoint $exit_bp_loc
36132 + send_gdb "continue\n"
36134 + # The output from the child processes can be interleaved arbitrarily
36135 + # with the output from GDB and the parent process. If we don't
36136 + # consume it all now, it can confuse later interactions.
36139 + set seen_prompt 0
36140 + set seen_timeout 0
36141 + while { ($seen_done < 16 || ! $seen_prompt) && ! $seen_timeout } {
36142 + # We don't know what order the interesting things will arrive in.
36143 + # Using a pattern of the form 'x|y|z' instead of -re x ... -re y
36144 + # ... -re z ensures that expect always chooses the match that
36145 + # occurs leftmost in the input, and not the pattern appearing
36146 + # first in the script that occurs anywhere in the input, so that
36147 + # we don't skip anything.
36149 + -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
36150 + if {[info exists expect_out(1,string)]} {
36152 + } elseif {[info exists expect_out(2,string)]} {
36154 + } elseif {[info exists expect_out(3,string)]} {
36155 + set seen_prompt 1
36157 + array unset expect_out
36159 + timeout { set seen_timeout 1 }
36163 + if { $seen_timeout } {
36164 + fail "run to exit 2 (timeout)"
36165 + } elseif { ! $seen_prompt } {
36166 + fail "run to exit 2 (no prompt)"
36167 + } elseif { ! $seen_break } {
36168 + fail "run to exit 2 (no breakpoint hit)"
36169 + } elseif { $seen_done != 16 } {
36170 + fail "run to exit 2 (missing done messages)"
36172 + pass "run to exit 2"
36176 # The inferior program builds a tree of processes by executing a loop
36177 # four times, calling fork at each iteration. Thus, at each
36178 @@ -66,69 +121,17 @@ global gdb_prompt
36179 # The result should be that each of the 4 forks returns zero.
36182 -set exit_bp_loc [gdb_get_line_number "Set exit breakpoint here."]
36183 -gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
36184 -gdb_test "set follow child" "" ""
36186 -send_gdb "continue\n"
36188 - -re ".*Break.* main .*$gdb_prompt.*$" {}
36189 - -re ".*$gdb_prompt $" {fail "run to exit 1"}
36190 - default {fail "run to exit 1 (timeout)"}
36192 +gdb_test "set follow child"
36193 +continue_to_exit_bp_loc
36195 gdb_test "print pids" "\\$.* = \\{0, 0, 0, 0\\}.*" "follow child, print pids"
36197 # Now set gdb to follow the parent.
36198 # Result should be that none of the 4 forks returns zero.
36200 -delete_breakpoints
36202 -gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
36203 gdb_test "set follow parent" "" ""
36205 -send_gdb "continue\n"
36207 -# The output from the child processes can be interleaved arbitrarily
36208 -# with the output from GDB and the parent process. If we don't
36209 -# consume it all now, it can confuse later interactions.
36213 -set seen_timeout 0
36214 -while { ($seen_done < 16 || ! $seen_prompt) && ! $seen_timeout } {
36215 - # We don't know what order the interesting things will arrive in.
36216 - # Using a pattern of the form 'x|y|z' instead of -re x ... -re y
36217 - # ... -re z ensures that expect always chooses the match that
36218 - # occurs leftmost in the input, and not the pattern appearing
36219 - # first in the script that occurs anywhere in the input, so that
36220 - # we don't skip anything.
36222 - -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
36223 - if {[info exists expect_out(1,string)]} {
36225 - } elseif {[info exists expect_out(2,string)]} {
36227 - } elseif {[info exists expect_out(3,string)]} {
36228 - set seen_prompt 1
36230 - array unset expect_out
36232 - timeout { set seen_timeout 1 }
36236 -if { $seen_timeout } {
36237 - fail "run to exit 2 (timeout)"
36238 -} elseif { ! $seen_prompt } {
36239 - fail "run to exit 2 (no prompt)"
36240 -} elseif { ! $seen_break } {
36241 - fail "run to exit 2 (no breakpoint hit)"
36242 -} elseif { $seen_done != 16 } {
36243 - fail "run to exit 2 (missing done messages)"
36245 - pass "run to exit 2"
36247 +continue_to_exit_bp_loc
36249 gdb_test "print pids\[0\]==0 || pids\[1\]==0 || pids\[2\]==0 || pids\[3\]==0" \
36250 " = 0" "follow parent, print pids"
36251 @@ -138,7 +141,7 @@ gdb_test "print pids\[0\]==0 || pids\[1\]==0 || pids\[2\]==0 || pids\[3\]==0" \
36255 -gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" ""
36256 +gdb_breakpoint $exit_bp_loc
36258 gdb_test "help set detach-on-fork" "whether gdb will detach the child.*" \
36260 diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp
36261 index 91838a2..2d0a70e 100644
36262 --- a/gdb/testsuite/gdb.base/pointers.exp
36263 +++ b/gdb/testsuite/gdb.base/pointers.exp
36264 @@ -389,7 +389,7 @@ gdb_expect {
36266 send_gdb "print *pUC\n"
36268 - -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" {
36269 + -re ".\[0-9\]* = 21 \'.25\'.*$gdb_prompt $" {
36270 pass "print value of *pUC"
36272 -re ".*$gdb_prompt $" { fail "print value of *pUC" }
36273 diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
36274 index 1e17da4..b6f8a1f 100644
36275 --- a/gdb/testsuite/gdb.base/printcmds.exp
36276 +++ b/gdb/testsuite/gdb.base/printcmds.exp
36277 @@ -137,12 +137,12 @@ proc test_print_all_chars {} {
36280 gdb_test "p ctable1\[0\]" " = 0 '\\\\0'"
36281 - gdb_test "p ctable1\[1\]" " = 1 '\\\\001'"
36282 - gdb_test "p ctable1\[2\]" " = 2 '\\\\002'"
36283 - gdb_test "p ctable1\[3\]" " = 3 '\\\\003'"
36284 - gdb_test "p ctable1\[4\]" " = 4 '\\\\004'"
36285 - gdb_test "p ctable1\[5\]" " = 5 '\\\\005'"
36286 - gdb_test "p ctable1\[6\]" " = 6 '\\\\006'"
36287 + gdb_test "p ctable1\[1\]" " = 1 '\\\\1'"
36288 + gdb_test "p ctable1\[2\]" " = 2 '\\\\2'"
36289 + gdb_test "p ctable1\[3\]" " = 3 '\\\\3'"
36290 + gdb_test "p ctable1\[4\]" " = 4 '\\\\4'"
36291 + gdb_test "p ctable1\[5\]" " = 5 '\\\\5'"
36292 + gdb_test "p ctable1\[6\]" " = 6 '\\\\6'"
36293 gdb_test "p ctable1\[7\]" " = 7 '\\\\a'"
36294 gdb_test "p ctable1\[8\]" " = 8 '\\\\b'"
36295 gdb_test "p ctable1\[9\]" " = 9 '\\\\t'"
36296 @@ -150,24 +150,24 @@ proc test_print_all_chars {} {
36297 gdb_test "p ctable1\[11\]" " = 11 '\\\\v'"
36298 gdb_test "p ctable1\[12\]" " = 12 '\\\\f'"
36299 gdb_test "p ctable1\[13\]" " = 13 '\\\\r'"
36300 - gdb_test "p ctable1\[14\]" " = 14 '\\\\016'"
36301 - gdb_test "p ctable1\[15\]" " = 15 '\\\\017'"
36302 - gdb_test "p ctable1\[16\]" " = 16 '\\\\020'"
36303 - gdb_test "p ctable1\[17\]" " = 17 '\\\\021'"
36304 - gdb_test "p ctable1\[18\]" " = 18 '\\\\022'"
36305 - gdb_test "p ctable1\[19\]" " = 19 '\\\\023'"
36306 - gdb_test "p ctable1\[20\]" " = 20 '\\\\024'"
36307 - gdb_test "p ctable1\[21\]" " = 21 '\\\\025'"
36308 - gdb_test "p ctable1\[22\]" " = 22 '\\\\026'"
36309 - gdb_test "p ctable1\[23\]" " = 23 '\\\\027'"
36310 - gdb_test "p ctable1\[24\]" " = 24 '\\\\030'"
36311 - gdb_test "p ctable1\[25\]" " = 25 '\\\\031'"
36312 - gdb_test "p ctable1\[26\]" " = 26 '\\\\032'"
36313 - gdb_test "p ctable1\[27\]" " = 27 '\\\\033'"
36314 - gdb_test "p ctable1\[28\]" " = 28 '\\\\034'"
36315 - gdb_test "p ctable1\[29\]" " = 29 '\\\\035'"
36316 - gdb_test "p ctable1\[30\]" " = 30 '\\\\036'"
36317 - gdb_test "p ctable1\[31\]" " = 31 '\\\\037'"
36318 + gdb_test "p ctable1\[14\]" " = 14 '\\\\16'"
36319 + gdb_test "p ctable1\[15\]" " = 15 '\\\\17'"
36320 + gdb_test "p ctable1\[16\]" " = 16 '\\\\20'"
36321 + gdb_test "p ctable1\[17\]" " = 17 '\\\\21'"
36322 + gdb_test "p ctable1\[18\]" " = 18 '\\\\22'"
36323 + gdb_test "p ctable1\[19\]" " = 19 '\\\\23'"
36324 + gdb_test "p ctable1\[20\]" " = 20 '\\\\24'"
36325 + gdb_test "p ctable1\[21\]" " = 21 '\\\\25'"
36326 + gdb_test "p ctable1\[22\]" " = 22 '\\\\26'"
36327 + gdb_test "p ctable1\[23\]" " = 23 '\\\\27'"
36328 + gdb_test "p ctable1\[24\]" " = 24 '\\\\30'"
36329 + gdb_test "p ctable1\[25\]" " = 25 '\\\\31'"
36330 + gdb_test "p ctable1\[26\]" " = 26 '\\\\32'"
36331 + gdb_test "p ctable1\[27\]" " = 27 '\\\\33'"
36332 + gdb_test "p ctable1\[28\]" " = 28 '\\\\34'"
36333 + gdb_test "p ctable1\[29\]" " = 29 '\\\\35'"
36334 + gdb_test "p ctable1\[30\]" " = 30 '\\\\36'"
36335 + gdb_test "p ctable1\[31\]" " = 31 '\\\\37'"
36336 gdb_test "p ctable1\[32\]" " = 32 ' '"
36337 gdb_test "p ctable1\[33\]" " = 33 '!'"
36338 gdb_test "p ctable1\[34\]" " = 34 '\"'"
36339 @@ -475,13 +475,13 @@ proc test_print_strings {} {
36340 gdb_test "p &ctable1\[0\]" \
36341 " = \\(unsigned char \\*\\) \"\""
36342 gdb_test "p &ctable1\[1\]" \
36343 - " = \\(unsigned char \\*\\) \"\\\\001\\\\002\\\\003\\\\004\\\\005\\\\006\\\\a\\\\b\"..."
36344 + " = \\(unsigned char \\*\\) \"\\\\1\\\\2\\\\3\\\\4\\\\5\\\\6\\\\a\\\\b\"..."
36345 gdb_test "p &ctable1\[1*8\]" \
36346 - " = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\016\\\\017\"..."
36347 + " = \\(unsigned char \\*\\) \"\\\\b\\\\t\\\\n\\\\v\\\\f\\\\r\\\\16\\\\17\"..."
36348 gdb_test "p &ctable1\[2*8\]" \
36349 - " = \\(unsigned char \\*\\) \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..."
36350 + " = \\(unsigned char \\*\\) \"\\\\20\\\\21\\\\22\\\\23\\\\24\\\\25\\\\26\\\\27\"..."
36351 gdb_test "p &ctable1\[3*8\]" \
36352 - " = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..."
36353 + " = \\(unsigned char \\*\\) \"\\\\30\\\\31\\\\32\\\\33\\\\34\\\\35\\\\36\\\\37\"..."
36354 gdb_test "p &ctable1\[4*8\]" \
36355 " = \\(unsigned char \\*\\) \" !\\\\\"#\\\$%&'\"..."
36356 gdb_test "p &ctable1\[5*8\]" \
36357 @@ -622,7 +622,7 @@ proc test_print_string_constants {} {
36360 gdb_test "p \"a string\"" " = \"a string\""
36361 - gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\000 null\""
36362 + gdb_test "p \"embedded \\000 null\"" " = \"embedded \\\\0 null\""
36363 gdb_test "p \"abcd\"\[2\]" " = 99 'c'"
36364 gdb_test "p sizeof (\"abcdef\")" " = 7"
36365 gdb_test "ptype \"foo\"" " = char \\\[4\\\]"
36366 diff --git a/gdb/testsuite/gdb.base/return-nodebug.c b/gdb/testsuite/gdb.base/return-nodebug.c
36367 new file mode 100644
36368 index 0000000..e1211b3
36370 +++ b/gdb/testsuite/gdb.base/return-nodebug.c
36372 +/* This testcase is part of GDB, the GNU debugger.
36374 + Copyright 2009 Free Software Foundation, Inc.
36376 + This program is free software; you can redistribute it and/or modify
36377 + it under the terms of the GNU General Public License as published by
36378 + the Free Software Foundation; either version 3 of the License, or
36379 + (at your option) any later version.
36381 + This program is distributed in the hope that it will be useful,
36382 + but WITHOUT ANY WARRANTY; without even the implied warranty of
36383 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36384 + GNU General Public License for more details.
36386 + You should have received a copy of the GNU General Public License
36387 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
36389 +#include <stdio.h>
36411 + /* Preinitialize registers to 0 to avoid false PASS by leftover garbage. */
36414 + printf ("result=" FORMAT "\n", CAST func ());
36416 + /* Cannot `next' with no debug info. */
36421 diff --git a/gdb/testsuite/gdb.base/return-nodebug.exp b/gdb/testsuite/gdb.base/return-nodebug.exp
36422 new file mode 100644
36423 index 0000000..7d43776
36425 +++ b/gdb/testsuite/gdb.base/return-nodebug.exp
36427 +# Copyright (C) 2009 Free Software Foundation, Inc.
36429 +# This program is free software; you can redistribute it and/or modify
36430 +# it under the terms of the GNU General Public License as published by
36431 +# the Free Software Foundation; either version 3 of the License, or
36432 +# (at your option) any later version.
36434 +# This program is distributed in the hope that it will be useful,
36435 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
36436 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36437 +# GNU General Public License for more details.
36439 +# You should have received a copy of the GNU General Public License
36440 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
36442 +proc do_test {type} {
36443 + set typenospace [string map {{ } -} $type]
36446 + set old_prefix $pf_prefix
36447 + lappend pf_prefix "$typenospace:"
36449 + if {[runto "func"]} {
36450 + # Verify that we do not crash when using "return" from a function with
36451 + # no debugging info. Such function has no `struct symbol'. It may
36452 + # still have an associated `struct minimal_symbol'.
36454 + gdb_test "return -1" \
36455 + "Return value type not available for selected stack frame\\.\r\nPlease use an explicit cast of the value to return\\." \
36456 + "return from function with no debug info without a cast"
36458 + # Cast of the result to the proper width must be done explicitely.
36459 + gdb_test "return ($type) -1" "#0 .* main \\(.*" \
36460 + "return from function with no debug info with a cast" \
36461 + "Make selected stack frame return now\\? \\(y or n\\) " "y"
36463 + # And if it returned the full width of the result.
36464 + gdb_test "adv marker" "\r\nresult=-1\r\n.* in marker \\(.*" \
36465 + "full width of the returned result"
36468 + set pf_prefix $old_prefix
36471 +foreach case {{{signed char} %d (int)} \
36472 + {{short} %d (int)} \
36475 + {{long long} %lld}} {
36476 + set type [lindex $case 0]
36477 + set format [lindex $case 1]
36478 + set cast [lindex $case 2]
36480 + set typeesc [string map {{ } {\ }} $type]
36481 + set typenospace [string map {{ } -} $type]
36483 + if {[prepare_for_testing return-nodebug.exp "return-nodebug-$typenospace" "return-nodebug.c" \
36484 + [list "additional_flags=-DFORMAT=\"$format\" -DTYPE=$typeesc -DCAST=$cast"]] == 0} {
36488 diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp
36489 index 2350a33..3be8424 100644
36490 --- a/gdb/testsuite/gdb.base/setvar.exp
36491 +++ b/gdb/testsuite/gdb.base/setvar.exp
36492 @@ -121,7 +121,7 @@ proc test_set { args } {
36495 test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0"
36496 -test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1"
36497 +test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.1\'" "set variable char=1"
36498 test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)"
36499 test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)"
36500 test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')"
36501 @@ -132,7 +132,7 @@ test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'"
36502 # test "set variable" for type "signed char"
36504 test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0"
36505 -test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1"
36506 +test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.1\'" "set variable signed char=1"
36507 test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)"
36508 test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)"
36509 test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')"
36510 @@ -151,7 +151,7 @@ gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
36511 # test "set variable" for type "unsigned char"
36513 test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0"
36514 -test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1"
36515 +test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.1\'" "set variable unsigned char=1"
36516 test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)"
36517 test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)"
36518 test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')"
36519 diff --git a/gdb/testsuite/gdb.base/store.exp b/gdb/testsuite/gdb.base/store.exp
36520 index 963bb19..feab6bd 100644
36521 --- a/gdb/testsuite/gdb.base/store.exp
36522 +++ b/gdb/testsuite/gdb.base/store.exp
36523 @@ -74,7 +74,7 @@ proc check_set { t l r new add } {
36524 "${prefix}; print incremented l, expecting ${add}"
36527 -check_set "charest" "-1 .*" "-2 .*" "4 ..004." "2 ..002."
36528 +check_set "charest" "-1 .*" "-2 .*" "4 ..4." "2 ..2."
36529 check_set "short" "-1" "-2" "4" "2"
36530 check_set "int" "-1" "-2" "4" "2"
36531 check_set "long" "-1" "-2" "4" "2"
36532 @@ -102,7 +102,7 @@ proc up_set { t l r new } {
36533 "${prefix}; print new l, expecting ${new}"
36536 -up_set "charest" "-1 .*" "-2 .*" "4 ..004."
36537 +up_set "charest" "-1 .*" "-2 .*" "4 ..4."
36538 up_set "short" "-1" "-2" "4"
36539 up_set "int" "-1" "-2" "4"
36540 up_set "long" "-1" "-2" "4"
36541 diff --git a/gdb/testsuite/gdb.base/valgrind-attach.c b/gdb/testsuite/gdb.base/valgrind-attach.c
36542 new file mode 100644
36543 index 0000000..84b57db
36545 +++ b/gdb/testsuite/gdb.base/valgrind-attach.c
36547 +/* This testcase is part of GDB, the GNU debugger.
36549 + Copyright 2009 Free Software Foundation, Inc.
36551 + This program is free software; you can redistribute it and/or modify
36552 + it under the terms of the GNU General Public License as published by
36553 + the Free Software Foundation; either version 3 of the License, or
36554 + (at your option) any later version.
36556 + This program is distributed in the hope that it will be useful,
36557 + but WITHOUT ANY WARRANTY; without even the implied warranty of
36558 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36559 + GNU General Public License for more details.
36561 + You should have received a copy of the GNU General Public License
36562 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
36564 +#include <stdlib.h>
36569 + int *a = malloc (1);
36571 + a[10] = 0; /* crash-here */
36575 diff --git a/gdb/testsuite/gdb.base/valgrind-attach.exp b/gdb/testsuite/gdb.base/valgrind-attach.exp
36576 new file mode 100644
36577 index 0000000..1f9b26e
36579 +++ b/gdb/testsuite/gdb.base/valgrind-attach.exp
36581 +# Copyright 2009 Free Software Foundation, Inc.
36583 +# This program is free software; you can redistribute it and/or modify
36584 +# it under the terms of the GNU General Public License as published by
36585 +# the Free Software Foundation; either version 3 of the License, or
36586 +# (at your option) any later version.
36588 +# This program is distributed in the hope that it will be useful,
36589 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
36590 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36591 +# GNU General Public License for more details.
36593 +# You should have received a copy of the GNU General Public License
36594 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
36596 +set testfile valgrind-attach
36597 +set shfile ${testfile}.sh
36598 +set srcfile ${testfile}.c
36599 +set binfile ${objdir}/${subdir}/${testfile}
36600 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36601 + untested "Couldn't compile test program"
36606 +gdb_stop_suppressing_tests;
36608 +set VALGRIND "valgrind"
36610 +# Syntax for ${shfile} is: <binfile> <valgrind> <db-command-arguments>
36611 +set VALGRIND_SPAWN "sh ${srcdir}/${subdir}/${shfile} $binfile $VALGRIND $GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts]"
36613 +set test "spawn valgrind"
36614 +verbose "Spawning $VALGRIND_SPAWN"
36616 +if [info exists gdb_spawn_id] {
36621 +if ![is_remote host] {
36622 + if { [which $VALGRIND] == 0 } then {
36623 + untested "Couldn't find $VALGRIND"
36627 +set res [remote_spawn host "$VALGRIND_SPAWN"]
36628 +if { $res < 0 || $res == "" } {
36629 + perror "Spawning $VALGRIND_SPAWN failed."
36632 +set gdb_spawn_id -1;
36635 + -re "---- Attach to debugger \\? --- \\\[Return/N/n/Y/y/C/c\\\] ---- $" {
36639 + perror "(eof) $VALGRIND never initialized"
36640 + remote_close host
36644 + perror "(timeout) $VALGRIND never initialized"
36645 + remote_close host
36651 +set test "spawn gdb"
36652 +set test2 "crash line caught"
36654 + -re "starting debugger with cmd:.* in main .* crash-here .*\[\r\n\]$gdb_prompt $" {
36658 + -re "starting debugger with cmd:.*\[\r\n\]$gdb_prompt $" {
36663 + perror "(eof) $GDB never initialized"
36664 + remote_close host
36668 + perror "(timeout) $GDB never initialized"
36669 + remote_close host
36675 diff --git a/gdb/testsuite/gdb.base/valgrind-attach.sh b/gdb/testsuite/gdb.base/valgrind-attach.sh
36676 new file mode 100755
36677 index 0000000..f02c6f7
36679 +++ b/gdb/testsuite/gdb.base/valgrind-attach.sh
36683 +# Copyright 2009 Free Software Foundation, Inc.
36685 +# This program is free software; you can redistribute it and/or modify
36686 +# it under the terms of the GNU General Public License as published by
36687 +# the Free Software Foundation; either version 3 of the License, or
36688 +# (at your option) any later version.
36690 +# This program is distributed in the hope that it will be useful,
36691 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
36692 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36693 +# GNU General Public License for more details.
36695 +# You should have received a copy of the GNU General Public License
36696 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
36698 +BINFILE="$1"; shift
36699 +VALGRIND="$1"; shift
36700 +"$VALGRIND" --db-attach=yes --db-command="$* %f %p" "$BINFILE"
36701 diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
36702 new file mode 100644
36703 index 0000000..c5d5ee0
36705 +++ b/gdb/testsuite/gdb.base/vla-overflow.c
36707 +/* This testcase is part of GDB, the GNU debugger.
36709 + Copyright 2008 Free Software Foundation, Inc.
36711 + This program is free software; you can redistribute it and/or modify
36712 + it under the terms of the GNU General Public License as published by
36713 + the Free Software Foundation; either version 3 of the License, or
36714 + (at your option) any later version.
36716 + This program is distributed in the hope that it will be useful,
36717 + but WITHOUT ANY WARRANTY; without even the implied warranty of
36718 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36719 + GNU General Public License for more details.
36721 + You should have received a copy of the GNU General Public License
36722 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
36724 +#include <stdlib.h>
36727 +main (int argc, char **argv)
36731 + array[0] = array[0];
36737 diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
36738 new file mode 100644
36739 index 0000000..7203a48
36741 +++ b/gdb/testsuite/gdb.base/vla-overflow.exp
36743 +# Copyright 2008 Free Software Foundation, Inc.
36745 +# This program is free software; you can redistribute it and/or modify
36746 +# it under the terms of the GNU General Public License as published by
36747 +# the Free Software Foundation; either version 3 of the License, or
36748 +# (at your option) any later version.
36750 +# This program is distributed in the hope that it will be useful,
36751 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
36752 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36753 +# GNU General Public License for more details.
36755 +# You should have received a copy of the GNU General Public License
36756 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
36758 +# We could crash in:
36759 +# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
36760 +# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
36761 +# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
36762 +# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
36763 +# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
36764 +# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
36765 +# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
36766 +# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
36768 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
36770 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
36772 +set testfile vla-overflow
36773 +set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
36774 +set srcfile ${testfile}.c
36775 +set binfile ${objdir}/${subdir}/${testfile}
36776 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36777 + untested "Couldn't compile test program"
36781 +set f [open "|getconf PAGESIZE" "r"]
36787 +gdb_reinitialize_dir $srcdir/$subdir
36788 +gdb_load ${binfile}
36790 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
36792 +if { [runto_main] < 0 } {
36793 + untested vla-overflow
36797 +# Get the GDB memory size when we stay at main.
36799 +proc memory_v_pages_get {} {
36800 + global pid_of_gdb pagesize
36801 + set fd [open "/proc/$pid_of_gdb/statm"]
36804 + # number of pages of virtual memory
36805 + scan $line "%d" drs
36809 +set pages_found [memory_v_pages_get]
36812 +verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
36813 +set kb_found [expr $pages_found * $pagesize / 1024]
36814 +set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
36815 +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
36817 +# Create the ulimit wrapper.
36818 +set f [open $shfile "w"]
36819 +puts $f "#! /bin/sh"
36820 +puts $f "ulimit -v $kb_permit"
36821 +puts $f "exec $GDB \"\$@\""
36823 +remote_exec host "chmod +x $shfile"
36831 +gdb_reinitialize_dir $srcdir/$subdir
36832 +gdb_load ${binfile}
36834 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
36836 +# Check the size again after the second run.
36837 +# We must not stop in main as it would cache `array' and never crash later.
36841 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
36843 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
36845 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
36847 +# `abort' can get expressed as `*__GI_abort'.
36848 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
36850 +verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
36851 diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
36852 new file mode 100644
36853 index 0000000..e1f3ed1
36855 +++ b/gdb/testsuite/gdb.base/vla.c
36857 +/* This testcase is part of GDB, the GNU debugger.
36859 + Copyright 2008 Free Software Foundation, Inc.
36861 + This program is free software; you can redistribute it and/or modify
36862 + it under the terms of the GNU General Public License as published by
36863 + the Free Software Foundation; either version 3 of the License, or
36864 + (at your option) any later version.
36866 + This program is distributed in the hope that it will be useful,
36867 + but WITHOUT ANY WARRANTY; without even the implied warranty of
36868 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36869 + GNU General Public License for more details.
36871 + You should have received a copy of the GNU General Public License
36872 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
36874 +#include <string.h>
36882 +bar (char *a, char *b, char *c, int size)
36884 + memset (a, '1', size);
36885 + memset (b, '2', size);
36886 + memset (c, '3', 48);
36892 + char temp1[size];
36895 + temp1[size - 1] = '\0';
36897 + char temp2[size];
36899 + bar (temp1, temp2, temp3, size);
36901 + marker (); /* break-here */
36912 diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
36913 new file mode 100644
36914 index 0000000..5da7378
36916 +++ b/gdb/testsuite/gdb.base/vla.exp
36918 +# Copyright 2008 Free Software Foundation, Inc.
36920 +# This program is free software; you can redistribute it and/or modify
36921 +# it under the terms of the GNU General Public License as published by
36922 +# the Free Software Foundation; either version 3 of the License, or
36923 +# (at your option) any later version.
36925 +# This program is distributed in the hope that it will be useful,
36926 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
36927 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36928 +# GNU General Public License for more details.
36930 +# You should have received a copy of the GNU General Public License
36931 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
36934 +set srcfile ${testfile}.c
36935 +set binfile ${objdir}/${subdir}/${testfile}
36936 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
36937 + untested "Couldn't compile test program"
36943 +gdb_reinitialize_dir $srcdir/$subdir
36944 +gdb_load ${binfile}
36946 +if ![runto_main] {
36951 +gdb_breakpoint [gdb_get_line_number "break-here"]
36953 +gdb_continue_to_breakpoint "break-here"
36955 +gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1"
36956 +gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2"
36957 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
36959 +gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
36960 +gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
36961 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
36963 +gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
36964 +gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
36965 +gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
36967 +gdb_continue_to_breakpoint "break-here"
36969 +gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1"
36970 +gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2"
36971 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
36973 +gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
36974 +gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
36975 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
36977 +gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
36978 +gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
36979 +gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
36980 diff --git a/gdb/testsuite/gdb.cp/Makefile.in b/gdb/testsuite/gdb.cp/Makefile.in
36981 index 1787ad5..391bfc2 100644
36982 --- a/gdb/testsuite/gdb.cp/Makefile.in
36983 +++ b/gdb/testsuite/gdb.cp/Makefile.in
36984 @@ -4,7 +4,7 @@ srcdir = @srcdir@
36985 EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \
36986 derivation inherit local member-ptr method misc \
36987 overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace \
36988 - ref-types ref-params method2 pr9594
36989 + ref-types ref-params method2 pr9594 gdb2495
36991 all info install-info dvi install uninstall installcheck check:
36992 @echo "Nothing to be done for $@..."
36993 diff --git a/gdb/testsuite/gdb.cp/abstract-origin.cc b/gdb/testsuite/gdb.cp/abstract-origin.cc
36994 new file mode 100644
36995 index 0000000..e2de3fb
36997 +++ b/gdb/testsuite/gdb.cp/abstract-origin.cc
36999 +/* This testcase is part of GDB, the GNU debugger.
37001 + Copyright 2008 Free Software Foundation, Inc.
37003 + This program is free software; you can redistribute it and/or modify
37004 + it under the terms of the GNU General Public License as published by
37005 + the Free Software Foundation; either version 3 of the License, or
37006 + (at your option) any later version.
37008 + This program is distributed in the hope that it will be useful,
37009 + but WITHOUT ANY WARRANTY; without even the implied warranty of
37010 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37011 + GNU General Public License for more details.
37013 + You should have received a copy of the GNU General Public License
37014 + along with this program. If not, see <http://www.gnu.org/licenses/>.
37017 +extern void f (int *);
37027 + static int *problem = new int(i);
37028 + f (problem); /* break-here */
37041 diff --git a/gdb/testsuite/gdb.cp/abstract-origin.exp b/gdb/testsuite/gdb.cp/abstract-origin.exp
37042 new file mode 100644
37043 index 0000000..92cc23c
37045 +++ b/gdb/testsuite/gdb.cp/abstract-origin.exp
37047 +# Copyright 2008 Free Software Foundation, Inc.
37049 +# This program is free software; you can redistribute it and/or modify
37050 +# it under the terms of the GNU General Public License as published by
37051 +# the Free Software Foundation; either version 3 of the License, or
37052 +# (at your option) any later version.
37054 +# This program is distributed in the hope that it will be useful,
37055 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
37056 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37057 +# GNU General Public License for more details.
37059 +# You should have received a copy of the GNU General Public License
37060 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
37062 +set testfile abstract-origin
37063 +set srcfile ${testfile}.cc
37064 +set binfile ${objdir}/${subdir}/${testfile}
37065 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37066 + untested "Couldn't compile test program"
37070 +# Get things started.
37074 +gdb_reinitialize_dir $srcdir/$subdir
37075 +gdb_load ${binfile}
37077 +if ![runto_main] {
37078 + untested abstract-origin
37082 +gdb_breakpoint [gdb_get_line_number "break-here"]
37083 +gdb_continue_to_breakpoint "break-here"
37085 +# The Bug was: No symbol "problem" in current context.
37086 +gdb_test "p problem" " = \\(int \\*\\) 0x.*"
37087 diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.cc b/gdb/testsuite/gdb.cp/cplusfuncs.cc
37088 index 7f033d6..1a50a32 100644
37089 --- a/gdb/testsuite/gdb.cp/cplusfuncs.cc
37090 +++ b/gdb/testsuite/gdb.cp/cplusfuncs.cc
37091 @@ -191,6 +191,12 @@ char * dm_type_char_star (char * p) { return p; }
37092 int dm_type_foo_ref (foo & foo) { return foo.ifoo; }
37093 int * dm_type_int_star (int * p) { return p; }
37094 long * dm_type_long_star (long * p) { return p; }
37095 +int dm_type_short (short i) { return i; }
37096 +int dm_type_long (long i) { return i; }
37097 int dm_type_unsigned_int (unsigned int i) { return i; }
37098 +int dm_type_unsigned_short (unsigned short i) { return i; }
37099 +int dm_type_unsigned_long (unsigned long i) { return i; }
37100 int dm_type_void (void) { return 0; }
37101 void * dm_type_void_star (void * p) { return p; }
37102 +typedef int myint;
37103 +int dm_type_typedef (myint i) { return i; }
37104 diff --git a/gdb/testsuite/gdb.cp/cplusfuncs.exp b/gdb/testsuite/gdb.cp/cplusfuncs.exp
37105 index 5e08768..8c8e038 100644
37106 --- a/gdb/testsuite/gdb.cp/cplusfuncs.exp
37107 +++ b/gdb/testsuite/gdb.cp/cplusfuncs.exp
37108 @@ -66,9 +66,25 @@ set dm_type_unsigned_int "unsigned"
37109 set dm_type_void ""
37110 set dm_type_void_star "void*"
37112 +# Some other vagaries of GDB's type printing machinery. The integer types
37113 +# may have unsigned before or after their length, and may have "int"
37114 +# appended. The char* conversion operator may have name "char*" even if
37115 +# the type is "char *", because the name comes from the debug information
37116 +# and the type from GDB. Function types may not see through typedefs.
37118 +set dm_type_short "short"
37119 +set dm_type_long "long"
37120 +set dm_type_unsigned_short "unsigned short"
37121 +set dm_type_unsigned_long "unsigned long"
37122 +set dm_operator_char_star "char*"
37123 +set dm_operator_char_star_quoted "char\\*"
37124 +set dm_type_typedef 0
37126 proc probe_demangler { } {
37128 global dm_operator_comma
37129 + global dm_operator_char_star
37130 + global dm_operator_char_star_quoted
37131 global dm_type_char_star
37132 global dm_type_char_star_quoted
37133 global dm_type_foo_ref
37134 @@ -77,6 +93,11 @@ proc probe_demangler { } {
37135 global dm_type_unsigned_int
37136 global dm_type_void
37137 global dm_type_void_star
37138 + global dm_type_short
37139 + global dm_type_unsigned_short
37140 + global dm_type_long
37141 + global dm_type_unsigned_long
37142 + global dm_type_typedef
37144 send_gdb "print &'foo::operator,(foo&)'\n"
37146 @@ -97,6 +118,26 @@ proc probe_demangler { } {
37150 + send_gdb "print &'foo::operator char*()'\n"
37152 + -re ".*foo::operator char \\*\\(void\\).*\r\n$gdb_prompt $" {
37153 + # v2 demangler or GDB type printer
37154 + set dm_operator_char_star "char *"
37155 + set dm_operator_char_star_quoted "char \\*"
37156 + pass "detect dm_operator_char_star"
37158 + -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" {
37160 + pass "detect dm_operator_char_star"
37162 + -re ".*$gdb_prompt $" {
37163 + fail "detect dm_operator_char_star"
37166 + fail "detect dm_operator_char_star"
37170 send_gdb "print &'dm_type_char_star'\n"
37172 -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
37173 @@ -166,6 +207,11 @@ proc probe_demangler { } {
37175 pass "detect dm_type_long_star"
37177 + -re ".*dm_type_long_star\\(long int \\*\\).*\r\n$gdb_prompt $" {
37178 + # GCC v3 and GDB's type printer
37179 + set dm_type_long_star "long int *"
37180 + pass "detect dm_type_long_star"
37182 -re ".*$gdb_prompt $" {
37183 fail "detect dm_type_long_star"
37185 @@ -230,6 +276,101 @@ proc probe_demangler { } {
37186 fail "detect dm_type_void_star (timeout)"
37190 + send_gdb "print &'dm_type_short'\n"
37192 + -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" {
37193 + # v2 and v3 demanglers
37194 + pass "detect dm_type_short"
37196 + -re ".*dm_type_short\\(short int\\).*\r\n$gdb_prompt $" {
37197 + # GDB type printer
37198 + set dm_type_short "short int"
37199 + pass "detect dm_type_short"
37201 + -re ".*$gdb_prompt $" {
37202 + fail "detect dm_type_short"
37205 + fail "detect dm_type_short (timeout)"
37209 + send_gdb "print &'dm_type_unsigned_short'\n"
37211 + -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" {
37212 + # v2 and v3 demanglers
37213 + pass "detect dm_type_unsigned_short"
37215 + -re ".*dm_type_unsigned_short\\(short unsigned int\\).*\r\n$gdb_prompt $" {
37216 + # GDB type printer
37217 + set dm_type_unsigned_short "short unsigned int"
37218 + pass "detect dm_type_unsigned_short"
37220 + -re ".*$gdb_prompt $" {
37221 + fail "detect dm_type_unsigned_short"
37224 + fail "detect dm_type_unsigned_short (timeout)"
37228 + send_gdb "print &'dm_type_long'\n"
37230 + -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" {
37231 + # v2 and v3 demanglers
37232 + pass "detect dm_type_long"
37234 + -re ".*dm_type_long\\(long int\\).*\r\n$gdb_prompt $" {
37235 + # GDB type printer
37236 + set dm_type_long "long int"
37237 + pass "detect dm_type_long"
37239 + -re ".*$gdb_prompt $" {
37240 + fail "detect dm_type_long"
37243 + fail "detect dm_type_long (timeout)"
37247 + send_gdb "print &'dm_type_unsigned_long'\n"
37249 + -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" {
37250 + # v2 and v3 demanglers
37251 + pass "detect dm_type_unsigned_long"
37253 + -re ".*dm_type_unsigned_long\\(long unsigned int\\).*\r\n$gdb_prompt $" {
37254 + # GDB type printer
37255 + set dm_type_unsigned_long "long unsigned int"
37256 + pass "detect dm_type_unsigned_long"
37258 + -re ".*$gdb_prompt $" {
37259 + fail "detect dm_type_unsigned_long"
37262 + fail "detect dm_type_unsigned_long (timeout)"
37266 + send_gdb "print &'dm_type_typedef'\n"
37268 + -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" {
37269 + # v2 and v3 demanglers
37270 + pass "detect dm_type_typedef"
37272 + -re ".*dm_type_typedef\\(myint\\).*\r\n$gdb_prompt $" {
37273 + # GDB type printer
37274 + set dm_type_typedef 1
37275 + pass "detect dm_type_typedef"
37277 + -re ".*$gdb_prompt $" {
37278 + fail "detect dm_type_typedef"
37281 + fail "detect dm_type_typedef (timeout)"
37287 @@ -345,8 +486,9 @@ proc print_addr { name } {
37289 proc test_lookup_operator_functions {} {
37290 global dm_operator_comma
37291 + global dm_operator_char_star
37292 global dm_type_char_star
37293 - global dm_type_char_star_quoted
37294 + global dm_operator_char_star_quoted
37295 global dm_type_foo_ref
37296 global dm_type_void
37297 global dm_type_void_star
37298 @@ -404,8 +546,8 @@ proc test_lookup_operator_functions {} {
37300 info_func "operator int(" "int foo::operator int($dm_type_void);"
37301 info_func "operator()(" "void foo::operator()($dm_type_foo_ref);"
37302 - info_func "operator $dm_type_char_star_quoted\(" \
37303 - "char *foo::operator $dm_type_char_star\($dm_type_void);"
37304 + info_func "operator $dm_operator_char_star_quoted\(" \
37305 + "char *foo::operator $dm_operator_char_star\($dm_type_void);"
37309 @@ -420,6 +562,7 @@ proc test_paddr_operator_functions {} {
37310 global dm_type_unsigned_int
37311 global dm_type_void
37312 global dm_type_void_star
37313 + global dm_operator_char_star
37315 print_addr "foo::operator*($dm_type_foo_ref)"
37316 print_addr "foo::operator%($dm_type_foo_ref)"
37317 @@ -470,7 +613,7 @@ proc test_paddr_operator_functions {} {
37320 print_addr "foo::operator int($dm_type_void)"
37321 - print_addr "foo::operator $dm_type_char_star\($dm_type_void)"
37322 + print_addr "foo::operator $dm_operator_char_star\($dm_type_void)"
37326 @@ -480,17 +623,21 @@ proc test_paddr_operator_functions {} {
37327 proc test_paddr_overloaded_functions {} {
37328 global dm_type_unsigned_int
37329 global dm_type_void
37330 + global dm_type_short
37331 + global dm_type_unsigned_short
37332 + global dm_type_long
37333 + global dm_type_unsigned_long
37335 print_addr "overload1arg($dm_type_void)"
37336 print_addr "overload1arg(char)"
37337 print_addr "overload1arg(signed char)"
37338 print_addr "overload1arg(unsigned char)"
37339 - print_addr "overload1arg(short)"
37340 - print_addr "overload1arg(unsigned short)"
37341 + print_addr "overload1arg($dm_type_short)"
37342 + print_addr "overload1arg($dm_type_unsigned_short)"
37343 print_addr "overload1arg(int)"
37344 print_addr "overload1arg($dm_type_unsigned_int)"
37345 - print_addr "overload1arg(long)"
37346 - print_addr "overload1arg(unsigned long)"
37347 + print_addr "overload1arg($dm_type_long)"
37348 + print_addr "overload1arg($dm_type_unsigned_long)"
37349 print_addr "overload1arg(float)"
37350 print_addr "overload1arg(double)"
37352 @@ -513,17 +660,31 @@ proc test_paddr_hairy_functions {} {
37353 global dm_type_char_star
37354 global dm_type_int_star
37355 global dm_type_long_star
37356 + global dm_type_typedef
37358 print_addr_2 "hairyfunc1" "hairyfunc1(int)"
37359 - print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
37360 - print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
37361 - print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
37363 - # gdb-gnats bug gdb/19:
37364 - # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
37365 - print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19"
37366 - print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19"
37367 - print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19"
37369 + if {$dm_type_typedef == 0} {
37370 + print_addr_2 "hairyfunc2" "hairyfunc2(int (*)($dm_type_char_star))"
37371 + print_addr_2 "hairyfunc3" "hairyfunc3(int (*)(short (*)($dm_type_long_star)))"
37372 + print_addr_2 "hairyfunc4" "hairyfunc4(int (*)(short (*)($dm_type_char_star)))"
37374 + # gdb-gnats bug gdb/19:
37375 + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
37376 + print_addr_2_kfail "hairyfunc5" "hairyfunc5(int (*(*)($dm_type_char_star))(long))" "hairyfunc5(int (*)(long) (*)(char*))" "gdb/19"
37377 + print_addr_2_kfail "hairyfunc6" "hairyfunc6(int (*(*)($dm_type_int_star))(long))" "hairyfunc6(int (*)(long) (*)(int*))" "gdb/19"
37378 + print_addr_2_kfail "hairyfunc7" "hairyfunc7(int (*(*)(int (*)($dm_type_char_star)))(long))" "hairyfunc7(int (*)(long) (*)(int (*)(char*)))" "gdb/19"
37380 + print_addr_2 "hairyfunc2" "hairyfunc2(PFPc_i)"
37381 + print_addr_2 "hairyfunc3" "hairyfunc3(PFPFPl_s_i)"
37382 + print_addr_2 "hairyfunc4" "hairyfunc4(PFPFPc_s_i)"
37384 + # gdb-gnats bug gdb/19:
37385 + # "gdb v3 demangler fails on hairyfunc5 hairyfunc6 hairyfunc7"
37386 + print_addr_2 "hairyfunc5" "hairyfunc5(PFPc_PFl_i)"
37387 + print_addr_2 "hairyfunc6" "hairyfunc6(PFPi_PFl_i)"
37388 + print_addr_2 "hairyfunc7" "hairyfunc7(PFPFPc_i_PFl_i)"
37393 diff --git a/gdb/testsuite/gdb.cp/expand-sals.cc b/gdb/testsuite/gdb.cp/expand-sals.cc
37394 new file mode 100644
37395 index 0000000..6169a05
37397 +++ b/gdb/testsuite/gdb.cp/expand-sals.cc
37399 +/* This testcase is part of GDB, the GNU debugger.
37401 + Copyright (C) 2009 Free Software Foundation, Inc.
37403 + This file is part of GDB.
37405 + This program is free software; you can redistribute it and/or modify
37406 + it under the terms of the GNU General Public License as published by
37407 + the Free Software Foundation; either version 3 of the License, or
37408 + (at your option) any later version.
37410 + This program is distributed in the hope that it will be useful,
37411 + but WITHOUT ANY WARRANTY; without even the implied warranty of
37412 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37413 + GNU General Public License for more details.
37415 + You should have received a copy of the GNU General Public License
37416 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
37421 + return 42; /* func-line */
37424 +volatile int global_x;
37431 + global_x = func (); /* caller-line */
37435 +/* class B is here just to make the `func' calling line above having multiple
37436 + instances - multiple locations. Template cannot be used as its instances
37437 + would have different function names which get discarded by GDB
37438 + expand_line_sal_maybe. */
37440 +class B : public A
37450 + return 0; /* exit-line */
37452 diff --git a/gdb/testsuite/gdb.cp/expand-sals.exp b/gdb/testsuite/gdb.cp/expand-sals.exp
37453 new file mode 100644
37454 index 0000000..6e04cbf
37456 +++ b/gdb/testsuite/gdb.cp/expand-sals.exp
37458 +# Copyright 2009 Free Software Foundation, Inc.
37460 +# This program is free software; you can redistribute it and/or modify
37461 +# it under the terms of the GNU General Public License as published by
37462 +# the Free Software Foundation; either version 3 of the License, or
37463 +# (at your option) any later version.
37465 +# This program is distributed in the hope that it will be useful,
37466 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
37467 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37468 +# GNU General Public License for more details.
37470 +# You should have received a copy of the GNU General Public License
37471 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
37473 +if { [skip_cplus_tests] } { continue }
37475 +set srcfile expand-sals.cc
37476 +if { [prepare_for_testing expand-sals.exp expand-sals $srcfile {debug c++}] } {
37479 +if ![runto_main] {
37483 +gdb_breakpoint [gdb_get_line_number "exit-line"]
37485 +gdb_breakpoint [gdb_get_line_number "func-line"]
37486 +gdb_continue_to_breakpoint "func" ".*func-line.*"
37488 +gdb_test "up" "caller-line.*"
37490 +# PC should not be at the boundary of source lines to make the original bug
37493 +set test "p/x \$pc"
37495 +gdb_test_multiple $test $test {
37496 + -re "\\$\[0-9\]+ = (0x\[0-9a-f\]+)\r\n$gdb_prompt $" {
37497 + set pc $expect_out(1,string)
37502 +set test "info line"
37504 +gdb_test_multiple $test $test {
37505 + -re "Line \[0-9\]+ of .* starts at address 0x\[0-9a-f\]+.* and ends at (0x\[0-9a-f\]+).*\\.\r\n$gdb_prompt $" {
37506 + set end $expect_out(1,string)
37511 +set test "caller line has trailing code"
37512 +if {$pc != $end} {
37518 +# Original problem was an internal error here. Still sanity multiple locations
37519 +# were found at this code place as otherwise this test would not test anything.
37521 +gdb_test_multiple $test $test {
37522 + -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\. \\(\[2-9\] locations\\)\r\n$gdb_prompt $" {
37525 + -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\.\r\n$gdb_prompt $" {
37526 + # It just could not be decided if GDB is OK by this testcase.
37527 + setup_xfail *-*-*
37533 +gdb_continue_to_breakpoint "caller" ".*caller-line.*"
37535 +# Test GDB caught this return call and not the next one through B::B()
37537 + "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \
37540 +gdb_continue_to_breakpoint "next caller instance" ".*caller-line.*"
37542 +# Test that GDB caught now already A through B::B() in the other instance.
37543 +# As discussed in GDB expand_line_sal_maybe it would more match the original
37544 +# instance behavior to catch here the `func' breakpoint and catch the
37545 +# multiple-locations breakpoint only during the call return. This is not the
37546 +# case, expecting here to catch the breakpoint before the call happens.
37549 + "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* (B::)?B \[^\r\n\]*\r\n#2 \[^\r\n\]* main \[^\r\n\]*" \
37550 + "bt from B before the call"
37552 +gdb_continue_to_breakpoint "next caller func" ".*func-line.*"
37554 +# Verify GDB really could not catch the originally intended point of the return
37557 +gdb_continue_to_breakpoint "uncaught return" ".*exit-line.*"
37558 diff --git a/gdb/testsuite/gdb.cp/gdb1355.exp b/gdb/testsuite/gdb.cp/gdb1355.exp
37559 index 77687a6..66d16cf 100644
37560 --- a/gdb/testsuite/gdb.cp/gdb1355.exp
37561 +++ b/gdb/testsuite/gdb.cp/gdb1355.exp
37562 @@ -68,11 +68,11 @@ set s_tail ".*"
37564 set f_i "${ws}int m_int;"
37565 set f_c "${ws}char m_char;"
37566 -set f_li "${ws}long int m_long_int;"
37567 +set f_li "${ws}long m_long_int;"
37568 set f_ui "${ws}unsigned int m_unsigned_int;"
37569 -set f_lui "${ws}long unsigned int m_long_unsigned_int;"
37570 -set f_si "${ws}short int m_short_int;"
37571 -set f_sui "${ws}short unsigned int m_short_unsigned_int;"
37572 +set f_lui "${ws}unsigned long m_long_unsigned_int;"
37573 +set f_si "${ws}short m_short_int;"
37574 +set f_sui "${ws}unsigned short m_short_unsigned_int;"
37575 set f_uc "${ws}unsigned char m_unsigned_char;"
37576 set f_f "${ws}float m_float;"
37577 set f_d "${ws}double m_double;"
37578 diff --git a/gdb/testsuite/gdb.cp/gdb2495.cc b/gdb/testsuite/gdb.cp/gdb2495.cc
37579 new file mode 100644
37580 index 0000000..4df265f
37582 +++ b/gdb/testsuite/gdb.cp/gdb2495.cc
37584 +/* This testcase is part of GDB, the GNU debugger.
37586 + Copyright 2008 Free Software Foundation, Inc.
37588 + This program is free software; you can redistribute it and/or modify
37589 + it under the terms of the GNU General Public License as published by
37590 + the Free Software Foundation; either version 3 of the License, or
37591 + (at your option) any later version.
37593 + This program is distributed in the hope that it will be useful,
37594 + but WITHOUT ANY WARRANTY; without even the implied warranty of
37595 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37596 + GNU General Public License for more details.
37598 + You should have received a copy of the GNU General Public License
37599 + along with this program. If not, see <http://www.gnu.org/licenses/>.
37602 +#include <iostream>
37603 +#include <signal.h>
37605 +using namespace std;
37607 +class SimpleException
37612 + void raise_signal (int dummy)
37618 + int no_throw_function ()
37623 + void throw_function ()
37628 + int throw_function_with_handler ()
37636 + cout << "Handled" << endl;
37642 + void call_throw_function_no_handler ()
37644 + throw_function ();
37647 + void call_throw_function_handler ()
37649 + throw_function_with_handler ();
37652 +SimpleException exceptions;
37657 + // Have to call all these functions
37658 + // so not optimized away.
37659 + exceptions.raise_signal (-1);
37660 + exceptions.no_throw_function ();
37661 + exceptions.throw_function_with_handler ();
37662 + exceptions.call_throw_function_handler ();
37665 + exceptions.throw_function ();
37666 + exceptions.call_throw_function_no_handler ();
37674 diff --git a/gdb/testsuite/gdb.cp/gdb2495.exp b/gdb/testsuite/gdb.cp/gdb2495.exp
37675 new file mode 100644
37676 index 0000000..62c09c2
37678 +++ b/gdb/testsuite/gdb.cp/gdb2495.exp
37680 +# Copyright 2008 Free Software Foundation, Inc.
37682 +# This program is free software; you can redistribute it and/or modify
37683 +# it under the terms of the GNU General Public License as published by
37684 +# the Free Software Foundation; either version 3 of the License, or
37685 +# (at your option) any later version.
37687 +# This program is distributed in the hope that it will be useful,
37688 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
37689 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37690 +# GNU General Public License for more details.
37692 +# You should have received a copy of the GNU General Public License
37693 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
37696 +# In gdb inferior function calls, if a C++ exception is raised in the
37697 +# dummy-frame, and the exception handler is (normally, and expected to
37698 +# be) out-of-frame, the default C++ handler will (wrongly) be called
37699 +# in an inferior function call.
37700 +# This is incorrect as an exception can normally and legally be handled
37701 +# out-of-frame. The confines of the dummy frame prevent the unwinder
37702 +# from finding the correct handler (or any handler, unless it is
37703 +# in-frame). The default handler calls std::terminate. This will kill
37704 +# the inferior. Assert that terminate should never be called in an
37705 +# inferior function call. These tests test the functionality around
37706 +# unwinding that sequence and also tests the flag behaviour gating this
37709 +# This test is largley based off gdb.base/callfuncs.exp.
37711 +if $tracelevel then {
37712 + strace $tracelevel
37715 +if { [skip_cplus_tests] } { continue }
37720 +set testfile "gdb2495"
37721 +set srcfile ${testfile}.cc
37722 +set binfile $objdir/$subdir/$testfile
37724 +# Create and source the file that provides information about the compiler
37725 +# used to compile the test case.
37726 +if [get_compiler_info ${binfile} "c++"] {
37730 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37731 + untested gdb2495.exp
37735 +# Some targets can't do function calls, so don't even bother with this
37737 +if [target_info exists gdb,cannot_call_functions] {
37738 + setup_xfail "*-*-*" 2416
37739 + fail "This target can not call functions"
37745 +gdb_reinitialize_dir $srcdir/$subdir
37746 +gdb_load ${binfile}
37748 +if ![runto_main] then {
37749 + perror "couldn't run to main"
37753 +# See http://sources.redhat.com/gdb/bugs/2495
37755 +# Test normal baseline behaviour. Call a function that
37756 +# does not raise an exception ...
37757 +gdb_test "p exceptions.no_throw_function()" " = 1"
37758 +# And one that does but handles it in-frame ...
37759 +gdb_test "p exceptions.throw_function_with_handler()" " = 2"
37760 +# Both should return normally.
37762 +# Test basic unwind. Call a function that raises an exception but
37763 +# does not handle it. It should be rewound ...
37764 +gdb_test "p exceptions.throw_function()" \
37765 + "The program being debugged entered a std::terminate call .*" \
37766 + "Call a function that raises an exception without a handler."
37768 +# Make sure that after rewinding we are back at the call parent.
37771 + "bt after returning from a popped frame"
37773 +# Make sure the only breakpoint is the one set via the runto_main
37774 +# call and that the std::terminate breakpoint has evaporated and
37776 +gdb_test "info breakpoints" \
37777 + "gdb.cp/gdb2495\.cc.*"
37779 +# Turn off this new behaviour ...
37780 +send_gdb "set unwind-on-terminating-exception off\n"
37782 + -re "$gdb_prompt $" {pass "set unwind-on-terminating-exception"}
37783 + timeout {fail "(timeout) set unwind-on-terminating-exception"}
37786 +# Check that it is turned off ...
37787 +gdb_test "show unwind-on-terminating-exception" \
37788 + "exception is unhandled while in a call dummy is off.*" \
37789 + "Turn off unwind on terminating exception flag"
37791 +# Check that the old behaviour is restored.
37792 +gdb_test "p exceptions.throw_function()" \
37793 + "The program being debugged stopped while in a function called .*" \
37794 + "Call a function that raises an exception with unwinding off.."
37797 +# Restart back at main
37798 +if ![runto_main] then {
37799 + perror "couldn't run to main"
37804 +# Check to see if our new behaviour alters the unwind signal
37805 +# behaviour. It should not. Test both on and off states.
37807 +# Turn on unwind on signal behaviour ...
37808 +send_gdb "set unwindonsignal on\n"
37810 + -re "$gdb_prompt $" {pass "set unwindonsignal on"}
37811 + timeout {fail "(timeout) set unwindonsignal on"}
37814 +# Check that it is turned on ...
37815 +gdb_test "show unwindonsignal" \
37816 + "signal is received while in a call dummy is on.*" \
37817 + "Turn on unwind on signal"
37819 +# Check to see if new behaviour interferes with
37820 +# normal signal handling in inferior function calls.
37821 +gdb_test "p exceptions.raise_signal(1)" \
37822 + "To change this behavior use \"set unwindonsignal off\".*"
37824 +# And reverse. Turn off
37825 +send_gdb "set unwindonsignal off\n"
37827 + -re "$gdb_prompt $" {pass "set unwindonsignal off"}
37828 + timeout {fail "(timeout) set unwindonsignal off"}
37831 +# Check that it is turned off ...
37832 +gdb_test "show unwindonsignal" \
37833 + "signal is received while in a call dummy is off.*" \
37834 + "Turn off unwind on signal"
37836 +# Check to see if new behaviour interferes with
37837 +# normal signal handling in inferior function calls.
37838 +gdb_test "p exceptions.raise_signal(1)" \
37839 + "To change this behavior use \"set unwindonsignal on\".*"
37840 diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc
37841 index 1dff70a..648b2af 100644
37842 --- a/gdb/testsuite/gdb.cp/member-ptr.cc
37843 +++ b/gdb/testsuite/gdb.cp/member-ptr.cc
37844 @@ -138,6 +138,7 @@ class Diamond : public Padding, public Left, public Right
37847 virtual int vget_base ();
37848 + int (*func_ptr) (int);
37851 int Diamond::vget_base ()
37852 @@ -145,6 +146,12 @@ int Diamond::vget_base ()
37853 return this->Left::x + 2000;
37865 @@ -162,6 +169,7 @@ int main ()
37866 int (Diamond::*right_vpmf) ();
37867 int (Base::*base_vpmf) ();
37868 int Diamond::*diamond_pmi;
37869 + int (* Diamond::*diamond_pfunc_ptr) (int);
37873 @@ -179,6 +187,7 @@ int main ()
37875 diamond.Left::x = 77;
37876 diamond.Right::x = 88;
37877 + diamond.func_ptr = func;
37879 /* Some valid pointer to members from a base class. */
37880 left_pmf = (int (Diamond::*) ()) (int (Left::*) ()) (&Base::get_x);
37881 @@ -193,11 +202,19 @@ int main ()
37882 /* A pointer to data member from a base class. */
37883 diamond_pmi = (int Diamond::*) (int Left::*) &Base::x;
37885 + /* A pointer to data member, where the member is itself a pointer to
37887 + diamond_pfunc_ptr = (int (* Diamond::*) (int)) &Diamond::func_ptr;
37892 pmi = NULL; /* Breakpoint 1 here. */
37894 + // Invalid (uses diamond_pfunc_ptr as a function):
37895 + // diamond.*diamond_pfunc_ptr (20);
37896 + (diamond.*diamond_pfunc_ptr) (20);
37901 diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp
37902 index b69d4ad..476711f 100644
37903 --- a/gdb/testsuite/gdb.cp/member-ptr.exp
37904 +++ b/gdb/testsuite/gdb.cp/member-ptr.exp
37905 @@ -390,6 +390,33 @@ gdb_test_multiple "print ((int) pmi) == ((char *) &a.j - (char *) & a)" $name {
37909 +# Check pointers to data members, which are themselves pointers to
37910 +# functions. These behave like data members, not like pointers to
37911 +# member functions.
37913 +gdb_test "ptype diamond_pfunc_ptr" \
37914 + "type = int \\(\\*Diamond::\\*\\)\\(int\\)"
37916 +gdb_test "ptype diamond.*diamond_pfunc_ptr" \
37917 + "type = int \\(\\*\\)\\(int\\)"
37919 +# This one is invalid; () binds more tightly than .*, so it tries to
37920 +# call the member pointer as a normal pointer-to-function.
37922 +gdb_test "print diamond.*diamond_pfunc_ptr (20)" \
37923 + "Invalid data type for function to be called."
37925 +# With parentheses, it is valid.
37927 +gdb_test "print (diamond.*diamond_pfunc_ptr) (20)" \
37930 +# Make sure that we do not interpret this as either a member pointer
37931 +# call or a member function call.
37933 +gdb_test "print diamond.func_ptr (20)" \
37936 # ==========================
37937 # pointer to member function
37938 # ==========================
37939 @@ -608,6 +635,9 @@ gdb_test_multiple "print (a.*pmf)(3)" $name {
37943 +gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)"
37944 +gdb_test "ptype (a.*pmf)(3)" "type = int"
37946 # Print out a pointer to data member which requires looking into
37948 gdb_test "print diamond_pmi" "$vhn = &Base::x"
37949 diff --git a/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc b/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc
37950 new file mode 100644
37951 index 0000000..6b180d6
37953 +++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc
37962 +using namespace A;
37975 diff --git a/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp b/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp
37976 new file mode 100644
37977 index 0000000..e4bb9f8
37979 +++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp
37981 +# Copyright 2008 Free Software Foundation, Inc.
37983 +# This program is free software; you can redistribute it and/or modify
37984 +# it under the terms of the GNU General Public License as published by
37985 +# the Free Software Foundation; either version 3 of the License, or
37986 +# (at your option) any later version.
37988 +# This program is distributed in the hope that it will be useful,
37989 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
37990 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37991 +# GNU General Public License for more details.
37993 +# You should have received a copy of the GNU General Public License
37994 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
37996 +if $tracelevel then {
37997 + strace $tracelevel
38003 +set testfile namespace-multiple-imports
38004 +set srcfile ${testfile}.cc
38005 +set binfile ${objdir}/${subdir}/${testfile}
38006 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38007 + untested "Couldn't compile test program"
38011 +# Get things started.
38015 +gdb_reinitialize_dir $srcdir/$subdir
38016 +gdb_load ${binfile}
38018 +############################################
38019 +# test printing of namespace imported within
38022 +if ![runto_main] then {
38023 + perror "couldn't run to breakpoint main"
38027 +gdb_test "print x" "\\$\[0-9\].* = 11"
38028 +gdb_test "print xx" "\\$\[0-9\].* = 22"
38029 +gdb_test "print xxx" "\\$\[0-9\].* = 33"
38030 diff --git a/gdb/testsuite/gdb.cp/namespace-using.cc b/gdb/testsuite/gdb.cp/namespace-using.cc
38031 new file mode 100644
38032 index 0000000..97af850
38034 +++ b/gdb/testsuite/gdb.cp/namespace-using.cc
38036 +//--------------------------
38046 + using namespace M;
38047 + int y = x+1; // marker10 stop
38048 + using namespace N;
38051 +//--------------------------
38059 + return marker10();
38064 + using namespace J;
38067 + return K::marker9();
38070 +//--------------------------
38072 +//--------------------------
38082 + using namespace G::H;
38084 + return L::marker8();
38087 +//--------------------------
38089 +//--------------------------
38095 +using namespace E::F;
38098 + return I::marker7();
38100 +//--------------------------
38119 +using namespace C;
38123 + return marker6();
38129 + return marker5();
38134 + return marker4();
38141 + return marker3();
38150 + using namespace A;
38154 + total = _a + b + c + d + marker2(); // marker1 stop
38163 + using namespace A;
38165 + return marker1();
38167 diff --git a/gdb/testsuite/gdb.cp/namespace-using.exp b/gdb/testsuite/gdb.cp/namespace-using.exp
38168 new file mode 100644
38169 index 0000000..ab6e6a4
38171 +++ b/gdb/testsuite/gdb.cp/namespace-using.exp
38173 +# Copyright 2008 Free Software Foundation, Inc.
38175 +# This program is free software; you can redistribute it and/or modify
38176 +# it under the terms of the GNU General Public License as published by
38177 +# the Free Software Foundation; either version 3 of the License, or
38178 +# (at your option) any later version.
38180 +# This program is distributed in the hope that it will be useful,
38181 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
38182 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38183 +# GNU General Public License for more details.
38185 +# You should have received a copy of the GNU General Public License
38186 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
38188 +if $tracelevel then {
38189 + strace $tracelevel
38195 +set testfile namespace-using
38196 +set srcfile ${testfile}.cc
38197 +set binfile ${objdir}/${subdir}/${testfile}
38198 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
38199 + untested "Couldn't compile test program"
38203 +# Get things started.
38207 +gdb_reinitialize_dir $srcdir/$subdir
38208 +gdb_load ${binfile}
38210 +############################################
38211 +# test printing of namespace imported within
38214 +if ![runto_main] then {
38215 + perror "couldn't run to breakpoint main"
38219 +gdb_test "print _a" "= 1"
38221 +# Test that names are not printed when they
38222 +# are not imported
38224 +gdb_breakpoint marker3
38225 +gdb_continue_to_breakpoint "marker3"
38227 +#send_gdb "break marker3\n"
38228 +#send_gdb "continue\n"
38230 +gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import"
38234 +gdb_reinitialize_dir $srcdir/$subdir
38235 +gdb_load ${binfile}
38238 +############################################
38239 +# test printing of namespace imported into
38240 +# a scope containing the pc.
38242 +if ![runto_main] then {
38243 + perror "couldn't run to breakpoint main"
38247 +gdb_breakpoint [gdb_get_line_number "marker1 stop"]
38248 +gdb_continue_to_breakpoint "marker1 stop"
38250 +gdb_test "print _a" "= 1" "print _a in a nested scope"
38255 +gdb_reinitialize_dir $srcdir/$subdir
38256 +gdb_load ${binfile}
38258 +############################################
38259 +# test printing of namespace imported into
38263 +if ![runto marker5] then {
38264 + perror "couldn't run to breakpoint marker5"
38268 +gdb_test "print cc" "= 3"
38272 +gdb_reinitialize_dir $srcdir/$subdir
38273 +gdb_load ${binfile}
38276 +############################################
38277 +# Test printing of namespace aliases
38279 +if ![runto marker2] then {
38280 + perror "couldn't run to breakpoint marker2"
38284 +gdb_test "print B::_a" "= 1"
38286 +gdb_test "print _a" "No symbol \"_a\" in current context." "print _a in namespace alias scope"
38287 +gdb_test "print x" "No symbol \"x\" in current context." "print x in namespace alias scope"
38291 +gdb_reinitialize_dir $srcdir/$subdir
38292 +gdb_load ${binfile}
38295 +############################################
38296 +# Test printing of namespace aliases
38298 +if ![runto marker4] then {
38299 + perror "couldn't run to breakpoint marker4"
38303 +gdb_test "print dx" "= 4"
38305 +############################################
38306 +# Test printing of namespace aliases
38308 +if ![runto marker6] then {
38309 + perror "couldn't run to breakpoint marker6"
38313 +gdb_test "print efx" "= 5"
38315 +############################################
38316 +# Test printing of variables imported from
38317 +# nested namespaces
38319 +if ![runto I::marker7] then {
38320 + perror "couldn't run to breakpoint I::marker7"
38324 +gdb_test "print ghx" "= 6"
38326 +############################################
38327 +# Test that variables are not printed in a namespace
38328 +# that is sibling to the namespace containing an import
38330 +if ![runto L::marker8] then {
38331 + perror "couldn't run to breakpoint L::marker8"
38335 +gdb_test "print jx" "= 44"
38337 +gdb_breakpoint "K::marker9"
38338 +gdb_continue_to_breakpoint "K::marker9"
38340 +gdb_test "print jx" "No symbol \"jx\" in current context."
38342 +############################################
38343 +# Test that variables are only printed after the line
38344 +# containing the import
38346 +if ![runto_main] then {
38347 + perror "couldn't run to breakpoint main"
38351 +gdb_breakpoint [gdb_get_line_number "marker10 stop"]
38352 +gdb_continue_to_breakpoint "marker10 stop"
38354 +# Assert that M::x is printed and not N::x
38355 +gdb_test "print x" "= 911" "print x (from M::x)"
38356 diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp
38357 index 76b1b82..2042db2 100644
38358 --- a/gdb/testsuite/gdb.cp/namespace.exp
38359 +++ b/gdb/testsuite/gdb.cp/namespace.exp
38362 # Note: As of 2000-06-03, they passed under g++ - djb
38364 +load_lib "cp-support.exp"
38366 if $tracelevel then {
38368 @@ -259,11 +260,16 @@ gdb_test "ptype E" "type = namespace C::D::E"
38369 gdb_test "ptype CClass" "type = (class C::CClass \{\r\n public:|struct C::CClass \{)\r\n int x;\r\n\}"
38370 gdb_test "ptype CClass::NestedClass" "type = (class C::CClass::NestedClass \{\r\n public:|struct C::CClass::NestedClass \{)\r\n int y;\r\n\}"
38371 gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context."
38372 -setup_kfail "gdb/1448" "*-*-*"
38373 -gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}"
38374 -setup_kfail "gdb/1448" "*-*-*"
38375 -gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}"
38376 -setup_kfail "gdb/1448" "*-*-*"
38377 +cp_test_ptype_class \
38378 + "ptype ::C::CClass" "" "class" "C::CClass" \
38380 + { field public "int x;" }
38382 +cp_test_ptype_class \
38383 + "ptype ::C::CClass::NestedClass" "" "class" "C::CClass::NestedClass" \
38385 + { field public "int y;" }
38387 gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"."
38388 gdb_test "ptype C::CClass" "No symbol \"CClass\" in namespace \"C::C\"."
38389 gdb_test "ptype C::CClass::NestedClass" "No type \"CClass\" within class or namespace \"C::C\"."
38390 @@ -273,8 +279,11 @@ gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"
38392 gdb_test "print cOtherFile" "\\$\[0-9\].* = 316"
38393 gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}"
38394 -setup_kfail "gdb/1448" "*-*-*"
38395 -gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}"
38396 +cp_test_ptype_class \
38397 + "ptype ::C::OtherFileClass" "" "class" "C::OtherFileClass" \
38399 + { field public "int z;" }
38401 gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
38403 # Some anonymous namespace tests.
38404 diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
38405 index 24025a2..a72932e 100644
38406 --- a/gdb/testsuite/gdb.cp/overload.exp
38407 +++ b/gdb/testsuite/gdb.cp/overload.exp
38408 @@ -74,12 +74,12 @@ set re_methods "${re_methods}${ws}int overload1arg\\((void|)\\);"
38409 set re_methods "${re_methods}${ws}int overload1arg\\(char\\);"
38410 set re_methods "${re_methods}${ws}int overload1arg\\(signed char\\);"
38411 set re_methods "${re_methods}${ws}int overload1arg\\(unsigned char\\);"
38412 -set re_methods "${re_methods}${ws}int overload1arg\\(short\\);"
38413 -set re_methods "${re_methods}${ws}int overload1arg\\(unsigned short\\);"
38414 +set re_methods "${re_methods}${ws}int overload1arg\\(short( int)?\\);"
38415 +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned short|short unsigned)( int)?\\);"
38416 set re_methods "${re_methods}${ws}int overload1arg\\(int\\);"
38417 set re_methods "${re_methods}${ws}int overload1arg\\(unsigned int\\);"
38418 -set re_methods "${re_methods}${ws}int overload1arg\\(long\\);"
38419 -set re_methods "${re_methods}${ws}int overload1arg\\(unsigned long\\);"
38420 +set re_methods "${re_methods}${ws}int overload1arg\\(long( int)?\\);"
38421 +set re_methods "${re_methods}${ws}int overload1arg\\((unsigned long|long unsigned)( int)?\\);"
38422 set re_methods "${re_methods}${ws}int overload1arg\\(float\\);"
38423 set re_methods "${re_methods}${ws}int overload1arg\\(double\\);"
38424 set re_methods "${re_methods}${ws}int overloadfnarg\\((void|)\\);"
38425 diff --git a/gdb/testsuite/gdb.cp/ovldbreak.exp b/gdb/testsuite/gdb.cp/ovldbreak.exp
38426 index 8a6b795..897171c 100644
38427 --- a/gdb/testsuite/gdb.cp/ovldbreak.exp
38428 +++ b/gdb/testsuite/gdb.cp/ovldbreak.exp
38429 @@ -127,10 +127,24 @@ proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} {
38432 # This is the expected menu for overload1arg.
38433 -# Note the arg type variations on lines 6 and 13.
38434 +# Note the arg type variations for void and integer types.
38435 # This accommodates different versions of g++.
38437 -set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $"
38438 +set menu_overload1arg "\\\[0\\\] cancel\r\n"
38439 +append menu_overload1arg "\\\[1\\\] all\r\n"
38440 +append menu_overload1arg "\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n"
38441 +append menu_overload1arg "\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n"
38442 +append menu_overload1arg "\\\[4\\\] foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r\n"
38443 +append menu_overload1arg "\\\[5\\\] foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r\n"
38444 +append menu_overload1arg "\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n"
38445 +append menu_overload1arg "\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n"
38446 +append menu_overload1arg "\\\[8\\\] foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r\n"
38447 +append menu_overload1arg "\\\[9\\\] foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r\n"
38448 +append menu_overload1arg "\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n"
38449 +append menu_overload1arg "\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n"
38450 +append menu_overload1arg "\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n"
38451 +append menu_overload1arg "\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n"
38452 +append menu_overload1arg "> $"
38454 # Set multiple-symbols to "ask", to allow us to test the use
38455 # of the multiple-choice menu when breaking on an overloaded method.
38456 @@ -157,17 +171,17 @@ set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13 13 110
38458 gdb_test "info break" \
38459 "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
38460 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
38461 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\(void\\))? at.*$srcfile:49\r
38462 \[\t \]+breakpoint already hit 1 time\r
38463 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
38464 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
38465 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
38466 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
38467 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
38468 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
38469 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
38470 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
38471 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
38472 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
38473 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
38474 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
38475 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
38476 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
38477 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
38478 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
38479 @@ -215,17 +229,17 @@ gdb_expect {
38481 gdb_test "info break" \
38482 "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
38483 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
38484 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in main(\\(void\\))? at.*$srcfile:49\r
38485 \[\t \]+breakpoint already hit 1 time\r
38486 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
38487 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
38488 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
38489 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
38490 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
38491 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
38492 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
38493 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
38494 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
38495 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
38496 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
38497 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
38498 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
38499 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
38500 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
38501 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
38502 @@ -296,12 +310,12 @@ gdb_test "info break" \
38503 "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
38504 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
38505 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
38506 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
38507 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
38508 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned long|long unsigned)( int)?\\) at.*$srcfile:119\r
38509 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long( int)?\\) at.*$srcfile:118\r
38510 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
38511 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
38512 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
38513 -\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
38514 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned short|short unsigned)( int)?\\) at.*$srcfile:115\r
38515 +\[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short( int)?\\) at.*$srcfile:114\r
38516 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
38517 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
38518 \[0-9\]+\[\t \]+breakpoint keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
38519 diff --git a/gdb/testsuite/gdb.cp/ref-types.exp b/gdb/testsuite/gdb.cp/ref-types.exp
38520 index 4784cb2..b2e55cf 100644
38521 --- a/gdb/testsuite/gdb.cp/ref-types.exp
38522 +++ b/gdb/testsuite/gdb.cp/ref-types.exp
38523 @@ -284,7 +284,7 @@ gdb_expect {
38525 send_gdb "print UC\n"
38527 - -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
38528 + -re ".\[0-9\]* = 21 '\.25'\.*$gdb_prompt $" {
38529 pass "print value of UC"
38531 -re ".*$gdb_prompt $" { fail "print value of UC" }
38532 @@ -557,7 +557,7 @@ gdb_expect {
38534 send_gdb "print rUC\n"
38536 - -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
38537 + -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.25\'.*$gdb_prompt $" {
38538 pass "print value of rUC"
38540 -re ".*$gdb_prompt $" { fail "print value of rUC" }
38541 diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
38542 index cd9b770..f49caff 100644
38543 --- a/gdb/testsuite/gdb.cp/templates.exp
38544 +++ b/gdb/testsuite/gdb.cp/templates.exp
38545 @@ -329,13 +329,11 @@ gdb_expect {
38547 send_gdb "print Foo<volatile char *>::foo\n"
38549 - -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }
38550 + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }
38551 -re "No symbol \"Foo<volatile char \\*>\" in current context.\r\n$gdb_prompt $"
38553 - # This used to be a kfail gdb/33. That problem has been
38554 - # fixed, but now gdb/931 and gdb/1512 are rearing their ugly
38556 - kfail "gdb/931" "print Foo<volatile char *>::foo"
38557 + # This used to be a kfail gdb/33 and then kfail gdb/931.
38558 + fail "print Foo<volatile char *>::foo"
38560 -re "$gdb_prompt $" { fail "print Foo<volatile char *>::foo" }
38561 timeout { fail "(timeout) print Foo<volatile char *>::foo" }
38562 @@ -343,13 +341,11 @@ gdb_expect {
38564 send_gdb "print Foo<volatile char*>::foo\n"
38566 - -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" }
38567 + -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<(volatile char|char volatile) ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char*>::foo" }
38568 -re "No symbol \"Foo<volatile char\\*>\" in current context.\r\n$gdb_prompt $"
38570 - # This used to be a kfail gdb/33. That problem has been
38571 - # fixed, but now gdb/931 and gdb/1512 are rearing their ugly
38573 - kfail "gdb/931" "print Foo<volatile char*>::foo"
38574 + # This used to be a kfail gdb/33 and then kfail gdb/931.
38575 + fail "print Foo<volatile char*>::foo"
38577 -re "$gdb_prompt $" { fail "print Foo<volatile char*>::foo" }
38578 timeout { fail "(timeout) print Foo<volatile char*>::foo" }
38579 @@ -459,7 +455,7 @@ send_gdb "ptype quxint\n"
38581 -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*.*int qux\\(int, int\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
38582 -re "type = class Qux<int, ?& ?string> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
38583 - -re "type = class Qux<int, ?\\(char ?\\*\\)\\(& ?string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
38584 + -re "type = class Qux<int, ?\\(char ?\\*\\)\\(& ?\\(?string\\)?\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" { pass "ptype quxint" }
38585 -re "type = class Qux<int, ?& ?\\(string\\)> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int qux\\(int, int\\);.*\r\n\\}\r\n$gdb_prompt $" {
38586 kfail "gdb/1512" "ptype quxint"
38588 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
38589 new file mode 100644
38590 index 0000000..1f02d90
38592 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
38594 +/* This testcase is part of GDB, the GNU debugger.
38596 + Copyright 2004 Free Software Foundation, Inc.
38598 + This program is free software; you can redistribute it and/or modify
38599 + it under the terms of the GNU General Public License as published by
38600 + the Free Software Foundation; either version 2 of the License, or
38601 + (at your option) any later version.
38603 + This program is distributed in the hope that it will be useful,
38604 + but WITHOUT ANY WARRANTY; without even the implied warranty of
38605 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38606 + GNU General Public License for more details.
38608 + You should have received a copy of the GNU General Public License
38609 + along with this program; if not, write to the Free Software
38610 + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
38614 +/* The function `func1' traced into must have debug info on offset > 0;
38615 + (DW_UNSND (attr)). This is the reason of `func0' existence. */
38618 +func0(int a, int b)
38622 +/* `func1' being traced into must have some arguments to dump. */
38625 +func1(int a, int b)
38636 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
38637 new file mode 100644
38638 index 0000000..1c6e84a
38640 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
38642 +# Copyright 2006 Free Software Foundation, Inc.
38644 +# This program is free software; you can redistribute it and/or modify
38645 +# it under the terms of the GNU General Public License as published by
38646 +# the Free Software Foundation; either version 2 of the License, or
38647 +# (at your option) any later version.
38649 +# This program is distributed in the hope that it will be useful,
38650 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
38651 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38652 +# GNU General Public License for more details.
38654 +# You should have received a copy of the GNU General Public License
38655 +# along with this program; if not, write to the Free Software
38656 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38658 +# Minimal DWARF-2 unit test
38660 +# This test can only be run on targets which support DWARF-2.
38661 +# For now pick a sampling of likely targets.
38662 +if {![istarget *-*-linux*]
38663 + && ![istarget *-*-gnu*]
38664 + && ![istarget *-*-elf*]
38665 + && ![istarget *-*-openbsd*]
38666 + && ![istarget arm-*-eabi*]
38667 + && ![istarget powerpc-*-eabi*]} {
38671 +set testfile "dw2-stripped"
38672 +set srcfile ${testfile}.c
38673 +set binfile ${objdir}/${subdir}/${testfile}.x
38675 +remote_exec build "rm -f ${binfile}"
38677 +# get the value of gcc_compiled
38678 +if [get_compiler_info ${binfile}] {
38682 +# This test can only be run on gcc as we use additional_flags=FIXME
38683 +if {$gcc_compiled == 0} {
38687 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
38691 +remote_exec build "objcopy -R .debug_loc ${binfile}"
38692 +set strip_output [remote_exec build "objdump -h ${binfile}"]
38694 +set test "stripping test file preservation"
38695 +if [ regexp ".debug_info " $strip_output] {
38696 + pass "$test (.debug_info preserved)"
38698 + fail "$test (.debug_info got also stripped)"
38701 +set test "stripping test file functionality"
38702 +if [ regexp ".debug_loc " $strip_output] {
38703 + fail "$test (.debug_loc still present)"
38705 + pass "$test (.debug_loc stripped)"
38710 +gdb_reinitialize_dir $srcdir/$subdir
38711 +gdb_load ${binfile}
38713 +# For C programs, "start" should stop in main().
38715 +gdb_test "start" \
38716 + ".*main \\(\\) at .*" \
38719 + "func.* \\(.*\\) at .*" \
38721 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-strp.S b/gdb/testsuite/gdb.dwarf2/dw2-strp.S
38722 index a1602a5..293cc1b 100644
38723 --- a/gdb/testsuite/gdb.dwarf2/dw2-strp.S
38724 +++ b/gdb/testsuite/gdb.dwarf2/dw2-strp.S
38727 .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
38728 .4byte .Lproducer /* DW_AT_producer */
38729 - .byte 1 /* DW_AT_language (C) */
38730 + /* Use C++ to exploit a bug in parsing DW_AT_name "". */
38731 + .byte 4 /* DW_AT_language (C++) - */
38734 .uleb128 2 /* Abbrev: DW_TAG_array_type */
38737 .uleb128 6 /* Abbrev: DW_TAG_const_type */
38738 .4byte .Larray_type-.Lcu1_begin/* DW_AT_type */
38740 + .uleb128 7 /* Abbrev: DW_TAG_variable (name "") */
38741 + .4byte .Lemptyname /* DW_AT_name */
38743 .byte 0 /* End of children of CU */
38746 @@ -126,6 +131,15 @@
38747 .uleb128 0x13 /* DW_FORM_ref4 */
38748 .byte 0x0 /* Terminator */
38749 .byte 0x0 /* Terminator */
38751 + .uleb128 7 /* Abbrev code */
38752 + .uleb128 0x34 /* DW_TAG_variable */
38753 + .byte 0x0 /* DW_children_no */
38754 + .uleb128 0x3 /* DW_AT_name */
38755 + .uleb128 0xe /* DW_FORM_strp */
38756 + .byte 0x0 /* Terminator */
38757 + .byte 0x0 /* Terminator */
38759 .byte 0x0 /* Terminator */
38762 @@ -140,3 +154,5 @@
38765 .string "hello world!\n"
38768 diff --git a/gdb/testsuite/gdb.fortran/common-block.exp b/gdb/testsuite/gdb.fortran/common-block.exp
38769 new file mode 100644
38770 index 0000000..888f6c3
38772 +++ b/gdb/testsuite/gdb.fortran/common-block.exp
38774 +# Copyright 2008 Free Software Foundation, Inc.
38776 +# This program is free software; you can redistribute it and/or modify
38777 +# it under the terms of the GNU General Public License as published by
38778 +# the Free Software Foundation; either version 2 of the License, or
38779 +# (at your option) any later version.
38781 +# This program is distributed in the hope that it will be useful,
38782 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
38783 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38784 +# GNU General Public License for more details.
38786 +# You should have received a copy of the GNU General Public License
38787 +# along with this program; if not, write to the Free Software
38788 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38790 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
38792 +set testfile "common-block"
38793 +set srcfile ${testfile}.f90
38794 +set binfile ${objdir}/${subdir}/${testfile}
38796 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
38797 + untested "Couldn't compile ${srcfile}"
38803 +gdb_reinitialize_dir $srcdir/$subdir
38804 +gdb_load ${binfile}
38806 +if ![runto MAIN__] then {
38807 + perror "couldn't run to breakpoint MAIN__"
38811 +gdb_breakpoint [gdb_get_line_number "stop-here-out"]
38812 +gdb_continue_to_breakpoint "stop-here-out"
38814 +# Common block naming with source name /foo/:
38815 +# .symtab DW_TAG_common_block's DW_AT_name
38816 +# Intel Fortran foo_ foo_
38817 +# GNU Fortran foo_ foo
38821 +set int4 {(integer\(kind=4\)|INTEGER\(4\))}
38822 +set real4 {(real\(kind=4\)|REAL\(4\))}
38823 +set real8 {(real\(kind=8\)|REAL\(8\))}
38825 +gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context."
38826 +gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context."
38827 +gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context."
38828 +gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
38829 +gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
38830 +gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context."
38832 +gdb_test "info locals" "ix_x = 11\r\niy_y = 22\r\niz_z = 33\r\nix = 1\r\niy = 2\r\niz = 3" "info locals out"
38833 +gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix_x = 11\r\niy_y = 22\r\niz_z = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix = 1\r\niy = 2\r\niz = 3" "info common out"
38835 +gdb_test "ptype ix" "type = $int4" "ptype ix out"
38836 +gdb_test "ptype iy" "type = $real4" "ptype iy out"
38837 +gdb_test "ptype iz" "type = $real8" "ptype iz out"
38838 +gdb_test "ptype ix_x" "type = $int4" "ptype ix_x out"
38839 +gdb_test "ptype iy_y" "type = $real4" "ptype iy_y out"
38840 +gdb_test "ptype iz_z" "type = $real8" "ptype iz_z out"
38842 +gdb_test "p ix" " = 1 *" "p ix out"
38843 +gdb_test "p iy" " = 2 *" "p iy out"
38844 +gdb_test "p iz" " = 3 *" "p iz out"
38845 +gdb_test "p ix_x" " = 11 *" "p ix_x out"
38846 +gdb_test "p iy_y" " = 22 *" "p iy_y out"
38847 +gdb_test "p iz_z" " = 33 *" "p iz_z out"
38849 +gdb_breakpoint [gdb_get_line_number "stop-here-in"]
38850 +gdb_continue_to_breakpoint "stop-here-in"
38852 +gdb_test "whatis foo$suffix" "No symbol \"foo$suffix\" in current context." "whatis foo$suffix in"
38853 +gdb_test "ptype foo$suffix" "No symbol \"foo$suffix\" in current context." "ptype foo$suffix in"
38854 +gdb_test "p foo$suffix" "No symbol \"foo$suffix\" in current context." "p foo$suffix in"
38855 +gdb_test "whatis fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "whatis fo_o$suffix in"
38856 +gdb_test "ptype fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "ptype fo_o$suffix in"
38857 +gdb_test "p fo_o$suffix" "No symbol \"fo_o$suffix\" in current context." "p fo_o$suffix in"
38859 +gdb_test "info locals" "ix = 11\r\niy2 = 22\r\niz = 33\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3\r\niy = 5\r\niz_z = 55" "info locals in"
38860 +gdb_test "info common" "Contents of F77 COMMON block 'fo_o':\r\nix = 11\r\niy2 = 22\r\niz = 33\r\n\r\nContents of F77 COMMON block 'foo':\r\nix_x = 1\r\niy_y = 2\r\niz_z2 = 3" "info common in"
38862 +gdb_test "ptype ix" "type = $int4" "ptype ix in"
38863 +gdb_test "ptype iy2" "type = $real4" "ptype iy2 in"
38864 +gdb_test "ptype iz" "type = $real8" "ptype iz in"
38865 +gdb_test "ptype ix_x" "type = $int4" "ptype ix_x in"
38866 +gdb_test "ptype iy_y" "type = $real4" "ptype iy_y in"
38867 +gdb_test "ptype iz_z2" "type = $real8" "ptype iz_z2 in"
38869 +gdb_test "p ix" " = 11 *" "p ix in"
38870 +gdb_test "p iy2" " = 22 *" "p iy2 in"
38871 +gdb_test "p iz" " = 33 *" "p iz in"
38872 +gdb_test "p ix_x" " = 1 *" "p ix_x in"
38873 +gdb_test "p iy_y" " = 2 *" "p iy_y in"
38874 +gdb_test "p iz_z2" " = 3 *" "p iz_z2 in"
38875 diff --git a/gdb/testsuite/gdb.fortran/common-block.f90 b/gdb/testsuite/gdb.fortran/common-block.f90
38876 new file mode 100644
38877 index 0000000..b614e8a
38879 +++ b/gdb/testsuite/gdb.fortran/common-block.f90
38881 +! Copyright 2008 Free Software Foundation, Inc.
38883 +! This program is free software; you can redistribute it and/or modify
38884 +! it under the terms of the GNU General Public License as published by
38885 +! the Free Software Foundation; either version 2 of the License, or
38886 +! (at your option) any later version.
38888 +! This program is distributed in the hope that it will be useful,
38889 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
38890 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38891 +! GNU General Public License for more details.
38893 +! You should have received a copy of the GNU General Public License
38894 +! along with this program; if not, write to the Free Software
38895 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38897 +! Ihis file is the Fortran source file for dynamic.exp.
38898 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
38899 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
38911 + common /fo_o/ix,iy2,iz
38912 + common /foo/ix_x,iy_y,iz_z2
38917 + if (ix .ne. 11 .or. iy2 .ne. 22.0 .or. iz .ne. 33.0) call abort
38918 + if (ix_x .ne. 1 .or. iy_y .ne. 2.0 .or. iz_z2 .ne. 3.0) call abort
38920 + ix = 0 ! stop-here-in
38924 +program common_test
38934 + common /foo/ix,iy,iz
38935 + common /fo_o/ix_x,iy_y,iz_z
38945 + call in ! stop-here-out
38947 +end program common_test
38948 diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
38949 new file mode 100644
38950 index 0000000..77a1203
38952 +++ b/gdb/testsuite/gdb.fortran/dynamic.exp
38954 +# Copyright 2007 Free Software Foundation, Inc.
38956 +# This program is free software; you can redistribute it and/or modify
38957 +# it under the terms of the GNU General Public License as published by
38958 +# the Free Software Foundation; either version 2 of the License, or
38959 +# (at your option) any later version.
38961 +# This program is distributed in the hope that it will be useful,
38962 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
38963 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38964 +# GNU General Public License for more details.
38966 +# You should have received a copy of the GNU General Public License
38967 +# along with this program; if not, write to the Free Software
38968 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38970 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
38972 +# This file is part of the gdb testsuite. It contains tests for dynamically
38973 +# allocated Fortran arrays.
38974 +# It depends on the GCC dynamic Fortran arrays DWARF support:
38975 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
38977 +set testfile "dynamic"
38978 +set srcfile ${testfile}.f90
38979 +set binfile ${objdir}/${subdir}/${testfile}
38981 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
38982 + untested "Couldn't compile ${srcfile}"
38988 +gdb_reinitialize_dir $srcdir/$subdir
38989 +gdb_load ${binfile}
38991 +if ![runto MAIN__] then {
38992 + perror "couldn't run to breakpoint MAIN__"
38996 +gdb_breakpoint [gdb_get_line_number "varx-init"]
38997 +gdb_continue_to_breakpoint "varx-init"
38998 +gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated"
38999 +gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated"
39000 +gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) unallocated"
39001 +gdb_test "p varx(1,5,17)=1" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17)=1 unallocated"
39002 +gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) unallocated"
39004 +gdb_breakpoint [gdb_get_line_number "varx-allocated"]
39005 +gdb_continue_to_breakpoint "varx-allocated"
39006 +# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
39007 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
39008 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
39009 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
39011 +gdb_breakpoint [gdb_get_line_number "varx-filled"]
39012 +gdb_continue_to_breakpoint "varx-filled"
39013 +gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
39014 +gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
39015 +gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
39016 +gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
39017 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
39018 +gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv unassociated"
39019 +gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv unassociated"
39021 +gdb_breakpoint [gdb_get_line_number "varv-associated"]
39022 +gdb_continue_to_breakpoint "varv-associated"
39023 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
39024 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
39025 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
39026 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
39027 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
39028 +# Intel Fortran Compiler 10.1.008 uses the pointer type.
39029 +gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
39031 +gdb_breakpoint [gdb_get_line_number "varv-filled"]
39032 +gdb_continue_to_breakpoint "varv-filled"
39033 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
39034 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
39036 +gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
39037 +gdb_continue_to_breakpoint "varv-deassociated"
39038 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
39039 +gdb_test "p varv" "\\$\[0-9\]* = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated"
39040 +gdb_test "ptype varv" "type = (<(object|the array) is not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "ptype varv deassociated"
39041 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
39042 +gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
39043 +gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
39045 +gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
39046 +gdb_continue_to_breakpoint "varx-deallocated"
39047 +gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated"
39048 +gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated"
39049 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
39050 +gdb_test "p varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "p varx(1,5,17) deallocated"
39051 +gdb_test "ptype varx(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not allocated\\." "ptype varx(1,5,17) deallocated"
39053 +gdb_breakpoint [gdb_get_line_number "vary-passed"]
39054 +gdb_continue_to_breakpoint "vary-passed"
39055 +# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
39056 +gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
39058 +gdb_breakpoint [gdb_get_line_number "vary-filled"]
39059 +gdb_continue_to_breakpoint "vary-filled"
39060 +gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
39061 +gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
39062 +gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
39063 +gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
39064 +# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
39065 +gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
39067 +gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
39068 +gdb_continue_to_breakpoint "varw-almostfilled"
39069 +gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
39070 +gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
39071 +# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
39072 +gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
39073 +# "up" works with GCC but other Fortran compilers may copy the values into the
39074 +# outer function only on the exit of the inner function.
39075 +gdb_test "finish" ".*call bar \\(y, x\\)"
39076 +gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
39077 +gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
39078 +gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
39079 +gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
39081 +gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
39082 +gdb_continue_to_breakpoint "varz-almostfilled"
39083 +# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
39084 +gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
39085 +# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
39086 +# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
39087 +gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
39088 +gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
39089 +gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
39090 +gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
39091 +# maps to foo::vary(1,1)
39092 +gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
39093 +# maps to foo::vary(2,2)
39094 +gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
39095 +# maps to foo::vary(1,3)
39096 +gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
39098 +set test "quit #1"
39099 +gdb_test_multiple "quit" $test {
39100 + -re "The program is running. Quit anyway \\(and kill it\\)\\? \\(y or n\\) " {
39104 +set test "quit #2"
39105 +gdb_test_multiple "y" $test {
39110 diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
39111 new file mode 100644
39112 index 0000000..0f43564
39114 +++ b/gdb/testsuite/gdb.fortran/dynamic.f90
39116 +! Copyright 2007 Free Software Foundation, Inc.
39118 +! This program is free software; you can redistribute it and/or modify
39119 +! it under the terms of the GNU General Public License as published by
39120 +! the Free Software Foundation; either version 2 of the License, or
39121 +! (at your option) any later version.
39123 +! This program is distributed in the hope that it will be useful,
39124 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
39125 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39126 +! GNU General Public License for more details.
39128 +! You should have received a copy of the GNU General Public License
39129 +! along with this program; if not, write to the Free Software
39130 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39132 +! Ihis file is the Fortran source file for dynamic.exp.
39133 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
39134 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
39137 + real, target, allocatable :: varx (:, :, :)
39138 + real, pointer :: varv (:, :, :)
39139 + real, target :: varu (1, 2, 3)
39141 + allocate (varx (1:6, 5:15, 17:28)) ! varx-init
39142 + l = allocated (varx)
39143 + varx(:, :, :) = 6 ! varx-allocated
39144 + varx(1, 5, 17) = 7
39145 + varx(2, 6, 18) = 8
39146 + varx(6, 15, 28) = 9
39147 + varv => varx ! varx-filled
39148 + l = associated (varv)
39149 + varv(3, 7, 19) = 10 ! varv-associated
39150 + varv => null () ! varv-filled
39151 + l = associated (varv)
39152 + deallocate (varx) ! varv-deassociated
39153 + l = allocated (varx)
39154 + varu(:, :, :) = 10 ! varx-deallocated
39155 + allocate (varv (1:6, 5:15, 17:28))
39156 + l = associated (varv)
39157 + varv(:, :, :) = 6
39158 + varv(1, 5, 17) = 7
39159 + varv(2, 6, 18) = 8
39160 + varv(6, 15, 28) = 9
39161 + deallocate (varv)
39162 + l = associated (varv)
39164 + varv(1, 1, 1) = 6
39165 + varv(1, 2, 3) = 7
39166 + l = associated (varv)
39167 +end subroutine baz
39168 +subroutine foo (vary, varw)
39169 + real :: vary (:, :)
39170 + real :: varw (:, :, :)
39171 + vary(:, :) = 4 ! vary-passed
39175 + varw(:, :, :) = 5 ! vary-filled
39176 + varw(1, 1, 1) = 6
39177 + varw(2, 2, 2) = 7 ! varw-almostfilled
39178 +end subroutine foo
39179 +subroutine bar (varz, vart)
39181 + real :: vart (2:11, 7:*)
39183 + varz(2) = 5 ! varz-almostfilled
39184 + vart(2,7) = vart(2,7)
39185 +end subroutine bar
39188 + subroutine foo (vary, varw)
39189 + real :: vary (:, :)
39190 + real :: varw (:, :, :)
39194 + subroutine bar (varz, vart)
39196 + real :: vart (2:11, 7:*)
39199 + real :: x (10, 10), y (5), z(8, 8, 8)
39204 + call foo (x, z(2:6, 4:7, 6:8))
39206 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
39207 + if (x (1, 3) .ne. 10) call abort
39208 + if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
39209 + if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
39210 + call foo (transpose (x), z)
39211 + if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
39212 + if (x (3, 1) .ne. 10) call abort
39214 diff --git a/gdb/testsuite/gdb.fortran/logical.exp b/gdb/testsuite/gdb.fortran/logical.exp
39215 new file mode 100644
39216 index 0000000..ef76f43
39218 +++ b/gdb/testsuite/gdb.fortran/logical.exp
39220 +# Copyright 2007 Free Software Foundation, Inc.
39222 +# This program is free software; you can redistribute it and/or modify
39223 +# it under the terms of the GNU General Public License as published by
39224 +# the Free Software Foundation; either version 2 of the License, or
39225 +# (at your option) any later version.
39227 +# This program is distributed in the hope that it will be useful,
39228 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
39229 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39230 +# GNU General Public License for more details.
39232 +# You should have received a copy of the GNU General Public License
39233 +# along with this program; if not, write to the Free Software
39234 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39236 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
39238 +set testfile "logical"
39239 +set srcfile ${testfile}.f90
39240 +set binfile ${objdir}/${subdir}/${testfile}
39242 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
39243 + untested "Couldn't compile ${srcfile}"
39249 +gdb_reinitialize_dir $srcdir/$subdir
39250 +gdb_load ${binfile}
39252 +if ![runto MAIN__] then {
39253 + perror "couldn't run to breakpoint MAIN__"
39257 +gdb_breakpoint [gdb_get_line_number "stop-here"]
39258 +gdb_continue_to_breakpoint "stop-here"
39259 +gdb_test "p l" " = \\.TRUE\\."
39260 +gdb_test "p l1" " = \\.TRUE\\."
39261 +gdb_test "p l2" " = \\.TRUE\\."
39262 +gdb_test "p l4" " = \\.TRUE\\."
39263 +gdb_test "p l8" " = \\.TRUE\\."
39264 diff --git a/gdb/testsuite/gdb.fortran/logical.f90 b/gdb/testsuite/gdb.fortran/logical.f90
39265 new file mode 100644
39266 index 0000000..4229304
39268 +++ b/gdb/testsuite/gdb.fortran/logical.f90
39270 +! Copyright 2008 Free Software Foundation, Inc.
39272 +! This program is free software; you can redistribute it and/or modify
39273 +! it under the terms of the GNU General Public License as published by
39274 +! the Free Software Foundation; either version 2 of the License, or
39275 +! (at your option) any later version.
39277 +! This program is distributed in the hope that it will be useful,
39278 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
39279 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39280 +! GNU General Public License for more details.
39282 +! You should have received a copy of the GNU General Public License
39283 +! along with this program; if not, write to the Free Software
39284 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39286 +! Ihis file is the Fortran source file for dynamic.exp.
39287 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
39288 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
39292 + logical (kind=1) :: l1
39293 + logical (kind=2) :: l2
39294 + logical (kind=4) :: l4
39295 + logical (kind=8) :: l8
39301 + l = .FALSE. ! stop-here
39303 diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
39304 new file mode 100644
39305 index 0000000..ab72206
39307 +++ b/gdb/testsuite/gdb.fortran/string.exp
39309 +# Copyright 2008 Free Software Foundation, Inc.
39311 +# This program is free software; you can redistribute it and/or modify
39312 +# it under the terms of the GNU General Public License as published by
39313 +# the Free Software Foundation; either version 2 of the License, or
39314 +# (at your option) any later version.
39316 +# This program is distributed in the hope that it will be useful,
39317 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
39318 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39319 +# GNU General Public License for more details.
39321 +# You should have received a copy of the GNU General Public License
39322 +# along with this program; if not, write to the Free Software
39323 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39325 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
39327 +# This file is part of the gdb testsuite. It contains tests for Fortran
39328 +# strings with dynamic length.
39330 +set testfile "string"
39331 +set srcfile ${testfile}.f90
39332 +set binfile ${objdir}/${subdir}/${testfile}
39334 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
39335 + untested "Couldn't compile ${srcfile}"
39341 +gdb_reinitialize_dir $srcdir/$subdir
39342 +gdb_load ${binfile}
39344 +if ![runto MAIN__] then {
39345 + perror "couldn't run to breakpoint MAIN__"
39349 +gdb_breakpoint [gdb_get_line_number "var-init"]
39350 +gdb_continue_to_breakpoint "var-init"
39351 +gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
39352 +gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
39353 +gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
39354 +gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
39355 +gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
39356 +gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
39357 +gdb_test "p c" "\\$\[0-9\]* = 'c'"
39358 +gdb_test "p d" "\\$\[0-9\]* = 'd '"
39359 +gdb_test "p e" "\\$\[0-9\]* = 'g '"
39360 +gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)"
39361 +gdb_test "p *e" "Attempt to take contents of a non-pointer value."
39362 +gdb_test "p *f" "Attempt to take contents of a non-pointer value."
39364 +gdb_breakpoint [gdb_get_line_number "var-finish"]
39365 +gdb_continue_to_breakpoint "var-finish"
39366 +gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
39367 +gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set"
39369 +set test "quit #1"
39370 +gdb_test_multiple "quit" $test {
39371 + -re "The program is running. Quit anyway \\(and kill it\\)\\? \\(y or n\\) " {
39375 +set test "quit #2"
39376 +gdb_test_multiple "y" $test {
39381 diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
39382 new file mode 100644
39383 index 0000000..226dc5d
39385 +++ b/gdb/testsuite/gdb.fortran/string.f90
39387 +! Copyright 2008 Free Software Foundation, Inc.
39389 +! This program is free software; you can redistribute it and/or modify
39390 +! it under the terms of the GNU General Public License as published by
39391 +! the Free Software Foundation; either version 2 of the License, or
39392 +! (at your option) any later version.
39394 +! This program is distributed in the hope that it will be useful,
39395 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
39396 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39397 +! GNU General Public License for more details.
39399 +! You should have received a copy of the GNU General Public License
39400 +! along with this program; if not, write to the Free Software
39401 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39403 +! Ihis file is the Fortran source file for dynamic.exp.
39404 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
39405 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
39407 +subroutine foo (e, f)
39408 + character (len=1) :: c
39409 + character (len=8) :: d
39410 + character (len=*) :: e
39411 + character (len=*) :: f (1:7, 8:10)
39414 + e = 'e' ! var-init
39417 + c = 'c' ! var-finish
39418 +end subroutine foo
39419 + character (len=4) :: g, h (1:7, 8:10)
39424 diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
39425 index 495ae45..d08d7a4 100644
39426 --- a/gdb/testsuite/gdb.gdb/selftest.exp
39427 +++ b/gdb/testsuite/gdb.gdb/selftest.exp
39428 @@ -95,6 +95,10 @@ proc do_steps_and_nexts {} {
39429 set description "step over ttyarg initialization"
39432 + -re ".*python_script = 0.*$gdb_prompt $" {
39433 + set description "step over python_script initialization"
39434 + set command "step"
39436 -re ".*time_at_startup = get_run_time.*$gdb_prompt $" {
39437 set description "next over get_run_time and everything it calls"
39439 diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
39440 new file mode 100644
39441 index 0000000..729f457
39443 +++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
39445 +/* This file is part of GDB, the GNU debugger.
39447 + Copyright 2009 Free Software Foundation, Inc.
39449 + This program is free software; you can redistribute it and/or modify
39450 + it under the terms of the GNU General Public License as published by
39451 + the Free Software Foundation; either version 3 of the License, or
39452 + (at your option) any later version.
39454 + This program is distributed in the hope that it will be useful,
39455 + but WITHOUT ANY WARRANTY; without even the implied warranty of
39456 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39457 + GNU General Public License for more details.
39459 + You should have received a copy of the GNU General Public License
39460 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
39467 diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
39468 new file mode 100644
39469 index 0000000..3090e7e
39471 +++ b/gdb/testsuite/gdb.opt/array-from-register.c
39473 +/* This file is part of GDB, the GNU debugger.
39475 + Copyright 2009 Free Software Foundation, Inc.
39477 + This program is free software; you can redistribute it and/or modify
39478 + it under the terms of the GNU General Public License as published by
39479 + the Free Software Foundation; either version 3 of the License, or
39480 + (at your option) any later version.
39482 + This program is distributed in the hope that it will be useful,
39483 + but WITHOUT ANY WARRANTY; without even the implied warranty of
39484 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39485 + GNU General Public License for more details.
39487 + You should have received a copy of the GNU General Public License
39488 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
39490 +extern int func (int *arr);
39495 + int arr[] = { 42 };
39501 diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
39502 new file mode 100644
39503 index 0000000..f2de718
39505 +++ b/gdb/testsuite/gdb.opt/array-from-register.exp
39507 +# Copyright 2009 Free Software Foundation, Inc.
39509 +# This program is free software; you can redistribute it and/or modify
39510 +# it under the terms of the GNU General Public License as published by
39511 +# the Free Software Foundation; either version 2 of the License, or
39512 +# (at your option) any later version.
39514 +# This program is distributed in the hope that it will be useful,
39515 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
39516 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39517 +# GNU General Public License for more details.
39519 +# You should have received a copy of the GNU General Public License
39520 +# along with this program; if not, write to the Free Software
39521 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
39523 +# This file is part of the gdb testsuite.
39525 +if { [prepare_for_testing array-from-register.exp "array-from-register" \
39526 + {array-from-register.c array-from-register-func.c} \
39527 + {debug optimize=-O2}] } {
39531 +if ![runto func] then {
39535 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
39537 +# Seen regression:
39538 +# Address requested for identifier "arr" which is in register $rdi
39539 +gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
39540 diff --git a/gdb/testsuite/gdb.python/Makefile.in b/gdb/testsuite/gdb.python/Makefile.in
39541 index 79be9e7..c49f713 100644
39542 --- a/gdb/testsuite/gdb.python/Makefile.in
39543 +++ b/gdb/testsuite/gdb.python/Makefile.in
39548 -EXECUTABLES = python-value
39549 +EXECUTABLES = python-value python-prettyprint python-template
39551 all info install-info dvi install uninstall installcheck check:
39552 @echo "Nothing to be done for $@..."
39553 diff --git a/gdb/testsuite/gdb.python/find.c b/gdb/testsuite/gdb.python/find.c
39554 new file mode 100644
39555 index 0000000..35ddd8c
39557 +++ b/gdb/testsuite/gdb.python/find.c
39559 +/* Testcase for the search_memory Python function.
39560 + This testcase is part of GDB, the GNU debugger.
39562 + Copyright 2009 Free Software Foundation, Inc.
39564 + This program is free software; you can redistribute it and/or modify
39565 + it under the terms of the GNU General Public License as published by
39566 + the Free Software Foundation; either version 3 of the License, or
39567 + (at your option) any later version.
39569 + This program is distributed in the hope that it will be useful,
39570 + but WITHOUT ANY WARRANTY; without even the implied warranty of
39571 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39572 + GNU General Public License for more details.
39574 + You should have received a copy of the GNU General Public License
39575 + along with this program. If not, see <http://www.gnu.org/licenses/>.
39577 + Please email any bugs, comments, and/or additions to this file to:
39578 + bug-gdb@gnu.org */
39580 +/* Based on the gdb.base/find.c testcase. */
39582 +#include <stdlib.h>
39583 +#include <stdint.h>
39585 +#define CHUNK_SIZE 16000 /* same as findcmd.c's */
39586 +#define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */
39588 +static int8_t int8_search_buf[100];
39589 +static int16_t int16_search_buf[100];
39590 +static int32_t int32_search_buf[100];
39591 +static int64_t int64_search_buf[100];
39593 +static char *search_buf;
39594 +static int search_buf_size;
39601 + x = 1; // stop here
39607 + search_buf_size = BUF_SIZE;
39608 + search_buf = malloc (search_buf_size);
39609 + if (search_buf == NULL)
39611 + memset (search_buf, 'x', search_buf_size);
39623 diff --git a/gdb/testsuite/gdb.python/find.exp b/gdb/testsuite/gdb.python/find.exp
39624 new file mode 100644
39625 index 0000000..dd9aabc
39627 +++ b/gdb/testsuite/gdb.python/find.exp
39629 +# Copyright 2008, 2009 Free Software Foundation, Inc.
39631 +# This program is free software; you can redistribute it and/or modify
39632 +# it under the terms of the GNU General Public License as published by
39633 +# the Free Software Foundation; either version 3 of the License, or
39634 +# (at your option) any later version.
39636 +# This program is distributed in the hope that it will be useful,
39637 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
39638 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39639 +# GNU General Public License for more details.
39641 +# You should have received a copy of the GNU General Public License
39642 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
39644 +# This tests the search_memory Python function.
39645 +# Based on the gdb.base/find.exp testcase.
39647 +if $tracelevel then {
39648 + strace $tracelevel
39651 +# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}...
39652 +# Run a test named NAME, consisting of multiple lines of input.
39653 +# After each input line INPUT, search for result line RESULT.
39654 +# Succeed if all results are seen; fail otherwise.
39655 +proc gdb_py_test_multiple {name args} {
39656 + global gdb_prompt
39657 + foreach {input result} $args {
39658 + if {[gdb_test_multiple $input "$name - $input" {
39659 + -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
39660 + pass "$name - $input"
39669 +set testfile "find"
39670 +set srcfile ${testfile}.c
39671 +set binfile ${objdir}/${subdir}/${testfile}
39673 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
39674 + untested find.exp
39680 +gdb_reinitialize_dir $srcdir/$subdir
39681 +gdb_load ${binfile}
39683 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
39684 + -re "not supported.*$gdb_prompt $" {
39685 + unsupported "python support is disabled"
39688 + -re "$gdb_prompt $" {}
39691 +gdb_test "break $srcfile:stop_here" \
39692 + "Breakpoint.*at.* file .*$srcfile, line.*" \
39693 + "breakpoint function in file"
39697 + -re "Breakpoint \[0-9\]+,.*stop_here.* at .*$srcfile:.*$gdb_prompt $" {
39698 + pass "run until function breakpoint"
39700 + -re "$gdb_prompt $" {
39701 + fail "run until function breakpoint"
39704 + fail "run until function breakpoint (timeout)"
39708 +# We've now got the target program in a state where we can test "find".
39710 +set hex_number {0x[0-9a-fA-F][0-9a-fA-F]*}
39711 +set dec_number {[0-9]+}
39712 +set history_prefix {[$][0-9]* = }
39713 +set newline {[\r\n]+}
39714 +set pattern_not_found "${newline}.]"
39715 +set one_pattern_found "${newline}.${dec_number}L]"
39716 +set two_patterns_found "${newline}.${dec_number}L, ${dec_number}L]"
39718 +# Test string pattern.
39720 +gdb_test "set *(int32_t*) &int8_search_buf\[10\] = 0x61616161" "" ""
39721 +gdb_test "py search_buf = gdb.selected_frame ().read_var ('int8_search_buf')" "" ""
39722 +gdb_test "py start_addr = search_buf.address ()" "" ""
39723 +gdb_test "py length = search_buf.type ().sizeof ()" "" ""
39725 +gdb_test "py print gdb.search_memory (start_addr, length, 'aaa')" \
39726 + "${two_patterns_found}" "find string pattern"
39728 +# Test not finding pattern because search range too small, with
39729 +# potential find at the edge of the range.
39731 +gdb_test "py print gdb.search_memory (start_addr, 10+3, 'aaaa')" \
39732 + "${pattern_not_found}" "pattern not found at end of range"
39734 +# Increase the search range by 1 and we should find the pattern.
39736 +gdb_test "py print gdb.search_memory (start_addr, 10+3+1, \['a', 'a', 'a', 'a'\])" \
39737 + "${one_pattern_found}" "pattern found at end of range"
39739 +# Test max-count with size, with different parameter position
39741 +gdb_test "py print gdb.search_memory (start_addr, length, \[0x61, 0x61\], 1, 1)" \
39742 + "${one_pattern_found}" "size = 1, max_count = 1"
39744 +gdb_test "py print gdb.search_memory (start_addr, length, \[0x61, 0x61\], 1, 2)" \
39745 + "${two_patterns_found}" "size = 1, max_count = 2, normal ordering"
39747 +gdb_test "py print gdb.search_memory (start_addr, length, \[0x61, 0x61\], size = 1, max_count = 2)" \
39748 + "${two_patterns_found}" "size = 1, max_count = 2, normal ordering, with keywords"
39750 +gdb_test "py print gdb.search_memory (start_addr, length, \[0x61, 0x61\], max_count = 2, size = 1)" \
39751 + "${two_patterns_found}" "size = 1, max_count = 2, inverted ordering"
39753 +gdb_test "py print gdb.search_memory (start_addr, length, \['a', 'a'\], max_count = 2)" \
39754 + "${two_patterns_found}" "max_count = 2, with keyword"
39756 +# Test 16-bit pattern.
39758 +gdb_test "set int16_search_buf\[10\] = 0x1234" "" ""
39759 +gdb_test "py search_buf = gdb.selected_frame ().read_var ('int16_search_buf')" "" ""
39760 +gdb_test "py start_addr = search_buf.address ()" "" ""
39761 +gdb_test "py length = search_buf.type ().sizeof ()" "" ""
39762 +gdb_test "py pattern = gdb.parse_and_eval ('(int16_t) 0x1234')" "" ""
39764 +gdb_test "py print gdb.search_memory (start_addr, length, 0x1234, 2)" \
39765 + "${one_pattern_found}" "find 16-bit pattern, with python pattern"
39767 +gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \
39768 + "${one_pattern_found}" "find 16-bit pattern, with value pattern"
39770 +# Test 32-bit pattern.
39772 +gdb_test "set int32_search_buf\[10\] = 0x12345678" "" ""
39773 +gdb_test "py search_buf = gdb.selected_frame ().read_var ('int32_search_buf')" "" ""
39774 +gdb_test "py start_addr = search_buf.address ()" "" ""
39775 +gdb_test "py length = search_buf.type ().sizeof ()" "" ""
39776 +gdb_test "py pattern = gdb.parse_and_eval ('(int32_t) 0x12345678')" "" ""
39778 +gdb_test "py print gdb.search_memory (start_addr, length, 0x12345678, 4)" \
39779 + "${one_pattern_found}" "find 32-bit pattern, with python pattern"
39780 +gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \
39781 + "${one_pattern_found}" "find 32-bit pattern, with value pattern"
39783 +# Test 64-bit pattern.
39785 +gdb_test "set int64_search_buf\[10\] = 0xfedcba9876543210LL" "" ""
39786 +gdb_test "py search_buf = gdb.selected_frame ().read_var ('int64_search_buf')" "" ""
39787 +gdb_test "py start_addr = search_buf.address ()" "" ""
39788 +gdb_test "py length = search_buf.type ().sizeof ()" "" ""
39789 +gdb_test "py pattern = gdb.parse_and_eval ('(int64_t) 0xfedcba9876543210LL')" "" ""
39791 +gdb_test "py print gdb.search_memory (start_addr, length, 0xfedcba9876543210, 8)" \
39792 + "${one_pattern_found}" "find 64-bit pattern, with python pattern"
39793 +gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \
39794 + "${one_pattern_found}" "find 64-bit pattern, with value pattern"
39796 +# Test mixed-sized patterns.
39798 +gdb_test "set *(int8_t*) &search_buf\[10\] = 0x62" "" ""
39799 +gdb_test "set *(int16_t*) &search_buf\[11\] = 0x6363" "" ""
39800 +gdb_test "set *(int32_t*) &search_buf\[13\] = 0x64646464" "" ""
39801 +gdb_test "py search_buf = gdb.selected_frame ().read_var ('search_buf')" "" ""
39802 +gdb_test "py start_addr = search_buf\[0\].address ()" "" ""
39803 +gdb_test "py pattern1 = gdb.parse_and_eval ('(int8_t) 0x62')" "" ""
39804 +gdb_test "py pattern2 = gdb.parse_and_eval ('(int16_t) 0x6363')" "" ""
39805 +gdb_test "py pattern3 = gdb.parse_and_eval ('(int32_t) 0x64646464')" "" ""
39807 +gdb_test "py print gdb.search_memory (start_addr, 100, \[pattern1, pattern2, pattern3\])" \
39808 + "${one_pattern_found}" "find mixed-sized pattern"
39810 +# Test search spanning a large range, in the particular case of native
39811 +# targets, test the search spanning multiple chunks.
39812 +# Remote targets may implement the search differently.
39814 +set CHUNK_SIZE 16000 ;
39816 +gdb_test "set *(int32_t*) &search_buf\[0*${CHUNK_SIZE}+100\] = 0x12345678" "" ""
39817 +gdb_test "set *(int32_t*) &search_buf\[1*${CHUNK_SIZE}+100\] = 0x12345678" "" ""
39818 +gdb_test "py start_addr = gdb.selected_frame ().read_var ('search_buf')" "" ""
39819 +gdb_test "py length = gdb.selected_frame ().read_var ('search_buf_size')" "" ""
39821 +gdb_test "py print gdb.search_memory (start_addr, length, 0x12345678, 4)" \
39822 + "${two_patterns_found}" "search spanning large range"
39824 +# For native targets, test a pattern straddling a chunk boundary.
39827 + gdb_test "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531" "" ""
39829 + gdb_test "py print gdb.search_memory (start_addr, length, 0xfdb97531, 4)" \
39830 + "${one_pattern_found}" "find pattern straddling chunk boundary"
39832 diff --git a/gdb/testsuite/gdb.python/python-cmd.exp b/gdb/testsuite/gdb.python/python-cmd.exp
39833 index 6c73ff2..f6ef938 100644
39834 --- a/gdb/testsuite/gdb.python/python-cmd.exp
39835 +++ b/gdb/testsuite/gdb.python/python-cmd.exp
39836 @@ -92,6 +92,32 @@ gdb_py_test_multiple "input subcommand" \
39838 gdb_test "prefix_cmd subcmd ugh" "subcmd output, arg = ugh" "call subcmd"
39840 +# Test prefix command using keyword arguments.
39842 +gdb_py_test_multiple "input prefix command, keyword arguments" \
39844 + "class prefix_cmd2 (gdb.Command):" "" \
39845 + " def __init__ (self):" "" \
39846 + " super (prefix_cmd2, self).__init__ (\"prefix_cmd2\", gdb.COMMAND_OBSCURE, prefix = True, completer_class = gdb.COMPLETE_FILENAME)" "" \
39847 + " def invoke (self, arg, from_tty):" "" \
39848 + " print \"prefix_cmd2 output, arg = %s\" % arg" "" \
39849 + "prefix_cmd2 ()" "" \
39852 +gdb_test "prefix_cmd2 argh" "prefix_cmd2 output, arg = argh" "call prefix command, keyword arguments"
39854 +gdb_py_test_multiple "input subcommand under prefix_cmd2" \
39856 + "class subcmd (gdb.Command):" "" \
39857 + " def __init__ (self):" "" \
39858 + " super (subcmd, self).__init__ (\"prefix_cmd2 subcmd\", gdb.COMMAND_OBSCURE)" "" \
39859 + " def invoke (self, arg, from_tty):" "" \
39860 + " print \"subcmd output, arg = %s\" % arg" "" \
39864 +gdb_test "prefix_cmd2 subcmd ugh" "subcmd output, arg = ugh" "call subcmd under prefix_cmd2"
39866 # Test a subcommand in an existing GDB prefix.
39868 gdb_py_test_multiple "input new subcommand" \
39869 diff --git a/gdb/testsuite/gdb.python/python-frame.c b/gdb/testsuite/gdb.python/python-frame.c
39870 new file mode 100644
39871 index 0000000..22eb9f2
39873 +++ b/gdb/testsuite/gdb.python/python-frame.c
39880 +int f1 (int a, int b)
39882 + return f2(a) + b;
39885 +int main (int argc, char *argv[])
39887 + return f1 (1, 2);
39889 diff --git a/gdb/testsuite/gdb.python/python-frame.exp b/gdb/testsuite/gdb.python/python-frame.exp
39890 new file mode 100644
39891 index 0000000..674c25e
39893 +++ b/gdb/testsuite/gdb.python/python-frame.exp
39895 +# Copyright (C) 2009 Free Software Foundation, Inc.
39897 +# This program is free software; you can redistribute it and/or modify
39898 +# it under the terms of the GNU General Public License as published by
39899 +# the Free Software Foundation; either version 3 of the License, or
39900 +# (at your option) any later version.
39902 +# This program is distributed in the hope that it will be useful,
39903 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
39904 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39905 +# GNU General Public License for more details.
39907 +# You should have received a copy of the GNU General Public License
39908 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
39910 +# This file is part of the GDB testsuite. It tests the mechanism
39911 +# exposing values to Python.
39913 +if $tracelevel then {
39914 + strace $tracelevel
39917 +set testfile "python-frame"
39918 +set srcfile ${testfile}.c
39919 +set binfile ${objdir}/${subdir}/${testfile}
39920 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
39921 + untested "Couldn't compile ${srcfile}"
39925 +# Run a command in GDB, and report a failure if a Python exception is thrown.
39926 +# If report_pass is true, report a pass if no exception is thrown.
39927 +proc gdb_py_test_silent_cmd {cmd name report_pass} {
39928 + global gdb_prompt
39930 + gdb_test_multiple $cmd $name {
39931 + -re "Traceback.*$gdb_prompt $" { fail $name }
39932 + -re "$gdb_prompt $" { if $report_pass { pass $name } }
39936 +# Start with a fresh gdb.
39940 +gdb_reinitialize_dir $srcdir/$subdir
39941 +gdb_load ${binfile}
39943 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
39944 + -re "not supported.*$gdb_prompt $" {
39945 + unsupported "python support is disabled"
39948 + -re "$gdb_prompt $" {}
39951 +# The following tests require execution.
39953 +if ![runto_main] then {
39954 + fail "Can't run to main"
39958 +gdb_breakpoint "f2"
39959 +gdb_continue_to_breakpoint "breakpoint at f2"
39960 +gdb_test "up" "" ""
39962 +gdb_py_test_silent_cmd "python frames = gdb.frames ()" "get frames list" 1
39963 +gdb_test "python print frames" "\\(<gdb.Frame object at 0x\[\[:xdigit:\]\]+>, <gdb.Frame object at 0x\[\[:xdigit:\]\]+>, <gdb.Frame object at 0x\[\[:xdigit:\]\]+>\\)" "verify frames list"
39964 +gdb_py_test_silent_cmd "python f0 = frames\[0\]" "get first frame" 0
39965 +gdb_py_test_silent_cmd "python f1 = frames\[1\]" "get second frame" 0
39967 +gdb_test "python print 'result =', f0.equals (f1)" " = False" "test equals (false)"
39968 +gdb_test "python print 'result =', f0.equals (f0)" " = True" "test equals (true)"
39969 +gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid"
39970 +gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name"
39971 +gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type"
39972 +gdb_test "python print 'result =', f0.unwind_stop_reason () == gdb.FRAME_UNWIND_NO_REASON" " = True" "test Frame.type"
39973 +gdb_test "python print 'result =', gdb.frame_stop_reason_string (gdb.FRAME_UNWIND_INNER_ID)" " = previous frame inner to this frame \\(corrupt stack\\?\\)" "test gdb.frame_stop_reason_string"
39974 +gdb_test "python print 'result =', f0.pc ()" " = \[0-9\]+" "test Frame.pc"
39975 +gdb_test "python print 'result =', f0.addr_in_block ()" " = \[0-9\]+" "test Frame.addr_in_block"
39976 +gdb_test "python print 'result =', f0.older ().equals (f1)" " = True" "test Frame.older"
39977 +gdb_test "python print 'result =', f1.newer ().equals (f0)" " = True" "test Frame.newer"
39978 +gdb_test "python print 'result =', f0.read_var ('variable_which_surely_doesnt_exist')" \
39979 + "ValueError: variable 'variable_which_surely_doesnt_exist' not found.*Error while executing Python code." \
39980 + "test Frame.read_var - error"
39981 +gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success"
39983 +gdb_test "python print 'result =', gdb.newest_frame ().equals (f0)" " = True" "test gdb.newest_frame"
39984 +gdb_test "python print 'result =', gdb.selected_frame ().equals (f1)" " = True" "test gdb.selected_frame"
39986 +gdb_test "python print 'result =', f0.block ()" "<gdb.Block object at 0x\[\[:xdigit:\]\]+>" "test Frame.block"
39987 diff --git a/gdb/testsuite/gdb.python/python-function.exp b/gdb/testsuite/gdb.python/python-function.exp
39988 new file mode 100644
39989 index 0000000..7feca2b
39991 +++ b/gdb/testsuite/gdb.python/python-function.exp
39993 +# Copyright (C) 2009 Free Software Foundation, Inc.
39995 +# This program is free software; you can redistribute it and/or modify
39996 +# it under the terms of the GNU General Public License as published by
39997 +# the Free Software Foundation; either version 3 of the License, or
39998 +# (at your option) any later version.
40000 +# This program is distributed in the hope that it will be useful,
40001 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
40002 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40003 +# GNU General Public License for more details.
40005 +# You should have received a copy of the GNU General Public License
40006 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
40008 +# This file is part of the GDB testsuite. It tests the mechanism
40009 +# exposing convenience functions to Python.
40011 +if $tracelevel then {
40012 + strace $tracelevel
40015 +# Usage: gdb_py_test_multiple NAME INPUT RESULT {INPUT RESULT}...
40016 +# Run a test named NAME, consisting of multiple lines of input.
40017 +# After each input line INPUT, search for result line RESULT.
40018 +# Succeed if all results are seen; fail otherwise.
40019 +proc gdb_py_test_multiple {name args} {
40020 + global gdb_prompt
40021 + foreach {input result} $args {
40022 + if {[gdb_test_multiple $input "$name - $input" {
40023 + -re "\[\r\n\]*($result)\[\r\n\]+($gdb_prompt | *>)$" {
40024 + pass "$name - $input"
40033 +# Start with a fresh gdb.
40037 +gdb_reinitialize_dir $srcdir/$subdir
40039 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
40040 + -re "not supported.*$gdb_prompt $" {
40041 + unsupported "python support is disabled"
40044 + -re "$gdb_prompt $" {}
40047 +gdb_py_test_multiple "input convenience function" \
40049 + "class test_func (gdb.Function):" "" \
40050 + " def __init__ (self):" "" \
40051 + " super (test_func, self).__init__ (\"test_func\")" "" \
40052 + " def invoke (self, arg):" "" \
40053 + " return \"test_func output, arg = %s\" % arg.string ()" "" \
40054 + "test_func ()" "" \
40057 +gdb_test "print \$test_func (\"ugh\")" "= \"test_func output, arg = ugh\"" "call function"
40059 +# Test returning a gdb.Value from the function. This segfaulted GDB at one point.
40061 +gdb_py_test_multiple "input value-returning convenience function" \
40063 + "class Double (gdb.Function):" "" \
40064 + " def __init__ (self):" "" \
40065 + " super (Double, self).__init__ (\"double\")" "" \
40066 + " def invoke (self, n):" "" \
40067 + " return n*2" "" \
40071 +gdb_test "print \$double (1)" "= 2" "call value-returning function"
40072 diff --git a/gdb/testsuite/gdb.python/python-mi.exp b/gdb/testsuite/gdb.python/python-mi.exp
40073 new file mode 100644
40074 index 0000000..5c9f3c7
40076 +++ b/gdb/testsuite/gdb.python/python-mi.exp
40078 +# Copyright (C) 2008 Free Software Foundation, Inc.
40080 +# This program is free software; you can redistribute it and/or modify
40081 +# it under the terms of the GNU General Public License as published by
40082 +# the Free Software Foundation; either version 3 of the License, or
40083 +# (at your option) any later version.
40085 +# This program is distributed in the hope that it will be useful,
40086 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
40087 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40088 +# GNU General Public License for more details.
40090 +# You should have received a copy of the GNU General Public License
40091 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
40093 +# This file is part of the GDB testsuite. It tests Python-based
40094 +# pretty-printing for MI.
40096 +load_lib mi-support.exp
40097 +set MIFLAGS "-i=mi2"
40100 +if [mi_gdb_start] {
40104 +set testfile "python-prettyprint"
40105 +set srcfile ${testfile}.c
40106 +set binfile ${objdir}/${subdir}/${testfile}
40107 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DMI}] != "" } {
40108 + untested mi2-var-child.exp
40112 +mi_delete_breakpoints
40113 +mi_gdb_reinitialize_dir $srcdir/$subdir
40114 +mi_gdb_load ${binfile}
40116 +if {[lsearch -exact [mi_get_features] python] < 0} {
40117 + unsupported "python support is disabled"
40123 +mi_gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" ""
40125 +mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${testfile}.c] \
40126 + "step to breakpoint"
40128 +mi_create_floating_varobj container c "create container varobj"
40130 +mi_list_varobj_children container {
40131 +} "examine container children=0"
40133 +mi_next "next over update 1"
40135 +mi_varobj_update_dynamic container {
40136 + { {container.\[0\]} {\[0\]} 0 int }
40137 +} "varobj update 1"
40139 +mi_next "next over update 2"
40141 +mi_varobj_update_dynamic container {
40142 + { {container.\[0\]} {\[0\]} 0 int }
40143 + { {container.\[1\]} {\[1\]} 0 int }
40144 +} "varobj update 2"
40146 +mi_gdb_test "-var-set-visualizer container None" \
40148 + "clear visualizer"
40150 +mi_gdb_test "-var-update container" \
40151 + "\\^done,changelist=\\\[\\\]" \
40152 + "varobj update after clearing"
40154 +mi_gdb_test "-var-set-visualizer container gdb.default_visualizer" \
40156 + "choose default visualizer"
40158 +mi_varobj_update_dynamic container {
40159 + { {container.\[0\]} {\[0\]} 0 int }
40160 + { {container.\[1\]} {\[1\]} 0 int }
40161 +} "varobj update after choosing default"
40163 +mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
40165 + "choose visualizer using expression"
40167 +mi_varobj_update_dynamic container {
40168 + { {container.\[0\]} {\[0\]} 0 int }
40169 + { {container.\[1\]} {\[1\]} 0 int }
40170 +} "varobj update after choosing via expression"
40172 +mi_gdb_test "-var-set-child-range container 1 2" \
40174 + "select child range"
40176 +mi_gdb_test "-var-update container" \
40177 + "\\^done,changelist=\\\[\\\]" \
40178 + "varobj update after selecting child range"
40180 +mi_list_varobj_children_range container 2 {
40181 + { {container.\[1\]} {\[1\]} 0 int }
40182 +} "list varobj children after selecting child range"
40184 +mi_gdb_test "-var-set-child-range container -1 -1" \
40186 + "reset child range"
40188 +mi_gdb_test "-var-update container" \
40189 + "\\^done,changelist=\\\[\\\]" \
40190 + "varobj update after resetting child range"
40192 +mi_list_varobj_children container {
40193 + { {container.\[0\]} {\[0\]} 0 int }
40194 + { {container.\[1\]} {\[1\]} 0 int }
40195 +} "list varobj children after resetting child range"
40197 +mi_continue_to_line \
40198 + [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \
40199 + "step to second breakpoint"
40201 +mi_varobj_update_with_type_change container int 0 "update after type change"
40202 diff --git a/gdb/testsuite/gdb.python/python-prettyprint.c b/gdb/testsuite/gdb.python/python-prettyprint.c
40203 new file mode 100644
40204 index 0000000..f8c2435
40206 +++ b/gdb/testsuite/gdb.python/python-prettyprint.c
40208 +/* This testcase is part of GDB, the GNU debugger.
40210 + Copyright 2008 Free Software Foundation, Inc.
40212 + This program is free software; you can redistribute it and/or modify
40213 + it under the terms of the GNU General Public License as published by
40214 + the Free Software Foundation; either version 3 of the License, or
40215 + (at your option) any later version.
40217 + This program is distributed in the hope that it will be useful,
40218 + but WITHOUT ANY WARRANTY; without even the implied warranty of
40219 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40220 + GNU General Public License for more details.
40222 + You should have received a copy of the GNU General Public License
40223 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
40237 +#ifdef __cplusplus
40238 +struct S : public s {
40249 + SSS (int x, const S& r);
40253 +SSS::SSS (int x, const S& r) : a(x), b(r) { }
40256 +typedef struct string_repr
40260 + const char *contents;
40264 +/* This lets us avoid malloc. */
40274 +typedef struct container zzz_type;
40277 +make_string (const char *s)
40280 + result.whybother.contents = s;
40285 +make_container (const char *s)
40289 + result.name = make_string (s);
40291 + result.elements = 0;
40297 +add_item (zzz_type *c, int val)
40300 + c->elements = array;
40301 + c->elements[c->len] = val;
40305 +void init_s(struct s *s, int a)
40311 +void init_ss(struct ss *s, int a, int b)
40313 + init_s(&s->a, a);
40314 + init_s(&s->b, b);
40317 +void do_nothing(void)
40321 + c = 23; /* Another MI breakpoint */
40328 + struct ss ssa[2];
40329 + string x = make_string ("this is x");
40330 + zzz_type c = make_container ("container");
40331 + const struct string_repr cstring = { { "const string" } };
40333 + init_ss(&ss, 1, 2);
40334 + init_ss(ssa+0, 3, 4);
40335 + init_ss(ssa+1, 5, 6);
40337 +#ifdef __cplusplus
40345 + init_s(&cpss.s, 10);
40348 + cpssa[0].zss = 11;
40349 + init_s(&cpssa[0].s, 12);
40350 + cpssa[1].zss = 13;
40351 + init_s(&cpssa[1].s, 14);
40353 + SSS sss(15, cps);
40358 + add_item (&c, 23); /* MI breakpoint here */
40359 + add_item (&c, 72);
40365 + return 0; /* break to inspect struct and union */
40367 diff --git a/gdb/testsuite/gdb.python/python-prettyprint.exp b/gdb/testsuite/gdb.python/python-prettyprint.exp
40368 new file mode 100644
40369 index 0000000..b2ccb2b
40371 +++ b/gdb/testsuite/gdb.python/python-prettyprint.exp
40373 +# Copyright (C) 2008 Free Software Foundation, Inc.
40375 +# This program is free software; you can redistribute it and/or modify
40376 +# it under the terms of the GNU General Public License as published by
40377 +# the Free Software Foundation; either version 3 of the License, or
40378 +# (at your option) any later version.
40380 +# This program is distributed in the hope that it will be useful,
40381 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
40382 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40383 +# GNU General Public License for more details.
40385 +# You should have received a copy of the GNU General Public License
40386 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
40388 +# This file is part of the GDB testsuite. It tests Python-based
40389 +# pretty-printing for the CLI.
40391 +if $tracelevel then {
40392 + strace $tracelevel
40395 +set testfile "python-prettyprint"
40396 +set srcfile ${testfile}.c
40397 +set binfile ${objdir}/${subdir}/${testfile}
40399 +# Start with a fresh gdb.
40402 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
40403 + -re "not supported.*$gdb_prompt $" {
40404 + unsupported "python support is disabled"
40407 + -re "$gdb_prompt $" {}
40410 +proc run_lang_tests {lang} {
40411 + global srcdir subdir srcfile binfile testfile hex
40412 + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug $lang"] != "" } {
40413 + untested "Couldn't compile ${srcfile} in $lang mode"
40417 + set nl "\[\r\n\]+"
40419 + # Start with a fresh gdb.
40422 + gdb_reinitialize_dir $srcdir/$subdir
40423 + gdb_load ${binfile}
40426 + if ![runto_main ] then {
40427 + perror "couldn't run to breakpoint"
40431 + gdb_test "set print pretty on" ""
40433 + gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
40435 + gdb_test "continue" ".*Breakpoint.*"
40437 + gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" ""
40439 + gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
40440 + gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
40441 + gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
40443 + if {$lang == "c++"} {
40444 + gdb_test "print cps" "= a=<8> b=<$hex>"
40445 + gdb_test "print cpss" " = {$nl *zss = 9, *$nl *s = a=<10> b=<$hex>$nl}"
40446 + gdb_test "print cpssa\[0\]" " = {$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl}"
40447 + gdb_test "print cpssa\[1\]" " = {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl}"
40448 + gdb_test "print cpssa" " = {{$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl *}, {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl *}}"
40449 + gdb_test "print sss" "= a=<15> b=< a=<8> b=<$hex>>"
40450 + gdb_test "print ref" "= a=<15> b=< a=<8> b=<$hex>>"
40453 + gdb_test "print x" " = $hex \"this is x\""
40454 + gdb_test "print cstring" " = $hex \"const string\""
40456 + gdb_test "print c" " = container $hex \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
40458 + gdb_test "continue" "Program exited normally\."
40461 +run_lang_tests "c"
40462 +run_lang_tests "c++"
40463 diff --git a/gdb/testsuite/gdb.python/python-prettyprint.py b/gdb/testsuite/gdb.python/python-prettyprint.py
40464 new file mode 100644
40465 index 0000000..0d9cb87
40467 +++ b/gdb/testsuite/gdb.python/python-prettyprint.py
40469 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
40471 +# This program is free software; you can redistribute it and/or modify
40472 +# it under the terms of the GNU General Public License as published by
40473 +# the Free Software Foundation; either version 3 of the License, or
40474 +# (at your option) any later version.
40476 +# This program is distributed in the hope that it will be useful,
40477 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
40478 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40479 +# GNU General Public License for more details.
40481 +# You should have received a copy of the GNU General Public License
40482 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
40484 +# This file is part of the GDB testsuite. It tests python pretty
40489 +# Test returning a Value from a printer.
40490 +class string_print:
40491 + def __init__(self, val):
40494 + def to_string(self):
40495 + return self.val['whybother']['contents']
40497 +# Test a class-based printer.
40498 +class ContainerPrinter:
40500 + def __init__ (self, pointer, len):
40501 + self.start = pointer
40502 + self.pointer = pointer
40503 + self.end = pointer + len
40505 + def __iter__(self):
40509 + if self.pointer == self.end:
40510 + raise StopIteration
40511 + result = self.pointer
40512 + self.pointer = self.pointer + 1
40513 + return ('[%d]' % int (result - self.start), result.dereference())
40515 + def __init__(self, val):
40518 + def to_string(self):
40519 + return 'container %s with %d elements' % (self.val['name'], self.val['len'])
40521 + def children(self):
40522 + return self._iterator(self.val['elements'], self.val['len'])
40525 + def __init__(self, val):
40528 + def to_string(self):
40529 + a = self.val["a"]
40530 + b = self.val["b"]
40531 + if a.address() != b:
40532 + raise Exception("&a(%s) != b(%s)" % (str(a.address()), str(b)))
40533 + return " a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
40536 + def __init__(self, val):
40539 + def to_string(self):
40540 + return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
40543 + def __init__(self, val):
40546 + def to_string(self):
40547 + return "a=<" + str(self.val['a']) + "> b=<" + str(self.val["b"]) + ">"
40549 +def lookup_function (val):
40550 + "Look-up and return a pretty-printer that can print val."
40553 + type = val.type ();
40555 + # If it points to a reference, get the reference.
40556 + if type.code () == gdb.TYPE_CODE_REF:
40557 + type = type.target ()
40559 + # Get the unqualified type, stripped of typedefs.
40560 + type = type.unqualified ().strip_typedefs ()
40562 + # Get the type name.
40563 + typename = type.tag ()
40565 + if typename == None:
40568 + # Iterate over local dictionary of types to determine
40569 + # if a printer is registered for that type. Return an
40570 + # instantiation of the printer if found.
40571 + for function in pretty_printers_dict:
40572 + if function.match (typename):
40573 + return pretty_printers_dict[function] (val)
40575 + # Cannot find a pretty printer. Return None.
40580 +def register_pretty_printers ():
40581 + pretty_printers_dict[re.compile ('^struct s$')] = pp_s
40582 + pretty_printers_dict[re.compile ('^s$')] = pp_s
40583 + pretty_printers_dict[re.compile ('^S$')] = pp_s
40585 + pretty_printers_dict[re.compile ('^struct ss$')] = pp_ss
40586 + pretty_printers_dict[re.compile ('^ss$')] = pp_ss
40587 + pretty_printers_dict[re.compile ('^const S &$')] = pp_s
40588 + pretty_printers_dict[re.compile ('^SSS$')] = pp_sss
40590 + # Note that we purposely omit the typedef names here.
40591 + # Printer lookup is based on canonical name.
40592 + # However, we do need both tagged and untagged variants, to handle
40593 + # both the C and C++ cases.
40594 + pretty_printers_dict[re.compile ('^struct string_repr$')] = string_print
40595 + pretty_printers_dict[re.compile ('^struct container$')] = ContainerPrinter
40596 + pretty_printers_dict[re.compile ('^string_repr$')] = string_print
40597 + pretty_printers_dict[re.compile ('^container$')] = ContainerPrinter
40599 +pretty_printers_dict = {}
40601 +register_pretty_printers ()
40602 +gdb.pretty_printers.append (lookup_function)
40603 diff --git a/gdb/testsuite/gdb.python/python-template.cc b/gdb/testsuite/gdb.python/python-template.cc
40604 new file mode 100644
40605 index 0000000..bd6a212
40607 +++ b/gdb/testsuite/gdb.python/python-template.cc
40609 +/* This testcase is part of GDB, the GNU debugger.
40611 + Copyright 2008 Free Software Foundation, Inc.
40613 + This program is free software; you can redistribute it and/or modify
40614 + it under the terms of the GNU General Public License as published by
40615 + the Free Software Foundation; either version 3 of the License, or
40616 + (at your option) any later version.
40618 + This program is distributed in the hope that it will be useful,
40619 + but WITHOUT ANY WARRANTY; without even the implied warranty of
40620 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40621 + GNU General Public License for more details.
40623 + You should have received a copy of the GNU General Public License
40624 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
40626 +template <typename T>
40637 + return 0; // break here
40639 diff --git a/gdb/testsuite/gdb.python/python-template.exp b/gdb/testsuite/gdb.python/python-template.exp
40640 new file mode 100644
40641 index 0000000..561ff73
40643 +++ b/gdb/testsuite/gdb.python/python-template.exp
40645 +# Copyright (C) 2008 Free Software Foundation, Inc.
40647 +# This program is free software; you can redistribute it and/or modify
40648 +# it under the terms of the GNU General Public License as published by
40649 +# the Free Software Foundation; either version 3 of the License, or
40650 +# (at your option) any later version.
40652 +# This program is distributed in the hope that it will be useful,
40653 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
40654 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40655 +# GNU General Public License for more details.
40657 +# You should have received a copy of the GNU General Public License
40658 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
40660 +# This file is part of the GDB testsuite. It tests the mechanism
40661 +# exposing values to Python.
40663 +if $tracelevel then {
40664 + strace $tracelevel
40667 +set testfile "python-template"
40668 +set srcfile ${testfile}.cc
40669 +set binfile ${objdir}/${subdir}/${testfile}
40670 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
40671 + {debug c++}] != "" } {
40672 + untested "Couldn't compile ${srcfile}"
40676 +# Start with a fresh gdb.
40680 +gdb_reinitialize_dir $srcdir/$subdir
40682 +gdb_test_multiple "python print 23" "verify python support" {
40683 + -re "not supported.*$gdb_prompt $" {
40684 + unsupported "python support is disabled"
40687 + -re "$gdb_prompt $" {}
40690 +proc test_template_arg {type} {
40691 + global testfile srcdir subdir srcfile binfile
40692 + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
40694 + [list debug c++ additional_flags="-DTYPE=$type"]] != "" } {
40698 + gdb_load ${binfile}
40699 + if ![runto_main ] then {
40700 + perror "couldn't run to breakpoint"
40703 + # There is no executable code in main(), so we are where we want to be
40704 + gdb_test "print foo" ""
40705 + gdb_test "python foo = gdb.history(0)" ""
40707 + # Replace '*' with '\*' in regex.
40708 + regsub -all {\*} $type {\*} t
40709 + gdb_test "python print foo.type().template_argument(0)" $t $type
40712 +test_template_arg "const int"
40713 +test_template_arg "volatile int"
40714 +test_template_arg "const int &"
40715 +test_template_arg "volatile int &"
40716 +test_template_arg "volatile int * const"
40717 +test_template_arg "volatile int * const *"
40718 +test_template_arg "const int * volatile"
40719 +test_template_arg "const int * volatile * const * volatile *"
40720 diff --git a/gdb/testsuite/gdb.python/python-value.c b/gdb/testsuite/gdb.python/python-value.c
40721 index 17e5c62..9637fe9 100644
40722 --- a/gdb/testsuite/gdb.python/python-value.c
40723 +++ b/gdb/testsuite/gdb.python/python-value.c
40724 @@ -33,13 +33,17 @@ enum e
40728 +typedef struct s *PTR;
40730 enum e evalue = TWO;
40733 main (int argc, char *argv[])
40735 + char *cp = argv[0]; /* Prevent gcc from optimizing argv[] out. */
40742 diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp
40743 index 8f5e0ab..9ca9593 100644
40744 --- a/gdb/testsuite/gdb.python/python-value.exp
40745 +++ b/gdb/testsuite/gdb.python/python-value.exp
40746 @@ -227,6 +227,37 @@ proc test_value_in_inferior {} {
40747 gdb_test "python print arg0" "0x.*$testfile\"" "verify dereferenced value"
40750 +proc test_value_after_death {} {
40751 + # Construct a type while the inferior is still running.
40752 + gdb_py_test_silent_cmd "python ptrtype = gdb.Type('PTR')" \
40753 + "create PTR type" 1
40755 + # Check the type has the expected name.
40756 + gdb_test "python print ptrtype" "PTR" \
40757 + "check initial PTR type"
40759 + # Kill the inferior and remove the symbols.
40760 + gdb_test "kill" "" "kill the inferior" \
40761 + "Kill the program being debugged. .y or n. $" \
40763 + gdb_test "file" "" "Discard the symbols" \
40764 + "Discard symbol table from.*y or n. $" \
40767 + # Now create a value using that type. Relies on arg0, created by
40768 + # test_value_in_inferior.
40769 + gdb_py_test_silent_cmd "python castval = arg0.cast(ptrtype.pointer())" \
40770 + "cast arg0 to PTR" 1
40772 + # Make sure the type is deleted.
40773 + gdb_py_test_silent_cmd "python ptrtype = None" \
40774 + "delete PTR type" 1
40776 + # Now see if the value's type is still valid.
40777 + gdb_test "python print castval.type()" "PTR \\*" \
40778 + "print value's type"
40782 # Start with a fresh gdb.
40784 @@ -256,3 +287,4 @@ if ![runto_main] then {
40787 test_value_in_inferior
40788 +test_value_after_death
40789 diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp
40790 index dbd2f59..44e1b51 100644
40791 --- a/gdb/testsuite/lib/cp-support.exp
40792 +++ b/gdb/testsuite/lib/cp-support.exp
40793 @@ -222,7 +222,7 @@ proc cp_test_ptype_class { in_command in_testname in_key in_tag in_class_table {
40796 gdb_test_multiple "$in_command" "$in_testname // parse failed" {
40797 - -re "type = (struct|class)${wsopt}(\[A-Za-z0-9_\]*)${wsopt}((:\[^\{\]*)?)${wsopt}\{(.*)\}${wsopt}(\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" {
40798 + -re "type = (struct|class)${wsopt}(\[A-Za-z0-9_:\]*)${wsopt}((:\[^\{\]*)?)${wsopt}\{(.*)\}${wsopt}(\[^\r\n\]*)\[\r\n\]+$gdb_prompt $" {
40800 set actual_key $expect_out(1,string)
40801 set actual_tag $expect_out(2,string)
40802 @@ -231,6 +231,7 @@ proc cp_test_ptype_class { in_command in_testname in_key in_tag in_class_table {
40803 set actual_tail $expect_out(6,string)
40807 if { ! $parse_okay } then { return }
40809 # Check the actual key. It would be nice to require that it match
40810 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
40811 index 820ab20..8b8e7c6 100644
40812 --- a/gdb/testsuite/lib/gdb.exp
40813 +++ b/gdb/testsuite/lib/gdb.exp
40814 @@ -1162,9 +1162,12 @@ proc default_gdb_start { } {
40817 global gdb_spawn_id;
40820 gdb_stop_suppressing_tests;
40822 + set env(LC_CTYPE) C
40824 verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
40826 if [info exists gdb_spawn_id] {
40827 diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
40828 index f62c240..bda7ea1 100644
40829 --- a/gdb/testsuite/lib/mi-support.exp
40830 +++ b/gdb/testsuite/lib/mi-support.exp
40831 @@ -1237,6 +1237,21 @@ proc mi_varobj_update_with_type_change { name new_type new_children testname } {
40832 mi_gdb_test "-var-update $name" $er $testname
40835 +# Update a dynamic varobj named NAME. CHILDREN is a list of children,
40836 +# in the same form as mi_list_varobj_children. TESTNAME is the name
40838 +proc mi_varobj_update_dynamic {name children testname} {
40839 + set children_exp_j [mi_child_regexp $children 0]
40841 + set er "\\^done,changelist=\\\["
40843 + append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\""
40844 + append er ",children=\\\[$children_exp_j.*\\\]}\\\]"
40846 + verbose -log "Expecting: $er"
40847 + mi_gdb_test "-var-update $name" $er $testname
40850 proc mi_check_varobj_value { name value testname } {
40852 mi_gdb_test "-var-evaluate-expression $name" \
40853 @@ -1244,6 +1259,42 @@ proc mi_check_varobj_value { name value testname } {
40857 +# Helper proc which constructs a child regexp for
40858 +# mi_list_varobj_children and mi_varobj_update_dynamic.
40859 +proc mi_child_regexp {children add_child} {
40860 + set children_exp {}
40861 + set whatever "\"\[^\"\]+\""
40863 + if {$add_child} {
40869 + foreach item $children {
40871 + set name [lindex $item 0]
40872 + set exp [lindex $item 1]
40873 + set numchild [lindex $item 2]
40874 + if {[llength $item] == 5} {
40875 + set type [lindex $item 3]
40876 + set value [lindex $item 4]
40878 + lappend children_exp\
40879 + "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\"$value\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40880 + } elseif {[llength $item] == 4} {
40881 + set type [lindex $item 3]
40883 + lappend children_exp\
40884 + "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40886 + lappend children_exp\
40887 + "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
40890 + return [join $children_exp ","]
40893 # Check the results of the:
40895 # -var-list-children VARNAME
40896 @@ -1265,39 +1316,23 @@ proc mi_check_varobj_value { name value testname } {
40899 proc mi_list_varobj_children { varname children testname } {
40900 + mi_list_varobj_children_range $varname [llength $children] $children \
40904 +# Like mi_list_varobj_children, but assumes that a subrange has been
40905 +# selected with -var-set-child-range. NUMCHILDREN is the total number
40907 +proc mi_list_varobj_children_range {varname numchildren children testname} {
40909 if {[llength $varname] == 2} {
40910 set options [lindex $varname 1]
40911 set varname [lindex $varname 0]
40914 - set numchildren [llength $children]
40915 - set children_exp {}
40916 set whatever "\"\[^\"\]+\""
40918 - foreach item $children {
40920 - set name [lindex $item 0]
40921 - set exp [lindex $item 1]
40922 - set numchild [lindex $item 2]
40923 - if {[llength $item] == 5} {
40924 - set type [lindex $item 3]
40925 - set value [lindex $item 4]
40927 - lappend children_exp\
40928 - "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",value=\"$value\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40929 - } elseif {[llength $item] == 4} {
40930 - set type [lindex $item 3]
40932 - lappend children_exp\
40933 - "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40935 - lappend children_exp\
40936 - "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
40939 - set children_exp_j [join $children_exp ","]
40940 + set children_exp_j [mi_child_regexp $children 1]
40941 if {$numchildren} {
40942 set expected "\\^done,numchild=\".*\",children=\\\[$children_exp_j.*\\\]"
40944 @@ -1770,3 +1805,25 @@ proc mi_check_thread_states { xstates test } {
40945 verbose -log "expecting: $pattern"
40946 mi_gdb_test "-thread-info" $pattern $test
40949 +# Return a list of MI features supported by this gdb.
40950 +proc mi_get_features {} {
40951 + global expect_out mi_gdb_prompt
40953 + send_gdb "-list-features\n"
40956 + -re "\\^done,features=\\\[(.*)\\\]\r\n$mi_gdb_prompt$" {
40957 + regsub -all -- \" $expect_out(1,string) "" features
40958 + return [split $features ,]
40960 + -re ".*\r\n$mi_gdb_prompt$" {
40961 + verbose -log "got $expect_out(buffer)"
40965 + verbose -log "timeout in mi_gdb_prompt"
40970 diff --git a/gdb/thread.c b/gdb/thread.c
40971 index 9dea7c2..326e44e 100644
40974 @@ -61,7 +61,6 @@ static int thread_alive (struct thread_info *);
40975 static void info_threads_command (char *, int);
40976 static void thread_apply_command (char *, int);
40977 static void restore_current_thread (ptid_t);
40978 -static void prune_threads (void);
40980 /* Frontend view of the thread state. Possible extensions: stepping,
40981 finishing, until(ling),... */
40982 @@ -459,16 +458,23 @@ thread_alive (struct thread_info *tp)
40988 prune_threads (void)
40990 - struct thread_info *tp, *next;
40991 + struct thread_info *tp;
40992 + struct thread_info **prevp = &thread_list;
40994 - for (tp = thread_list; tp; tp = next)
40995 + for (tp = *prevp; tp; tp = *prevp)
40998 + /* If the thread has died, free it and unlink it from the list.
40999 + Otherwise, advance to the next thread. */
41000 if (!thread_alive (tp))
41001 - delete_thread (tp->ptid);
41003 + *prevp = tp->next;
41004 + free_thread (tp);
41007 + prevp = &tp->next;
41011 diff --git a/gdb/top.c b/gdb/top.c
41012 index d676f02..d6b17f0 100644
41015 @@ -377,6 +377,7 @@ execute_command (char *p, int from_tty)
41018 free_all_values ();
41019 + free_all_types ();
41021 /* Force cleanup of any alloca areas if using C alloca instead of
41022 a builtin alloca. */
41023 @@ -1246,7 +1247,8 @@ quit_target (void *arg)
41024 struct qt_args *qt = (struct qt_args *)arg;
41026 /* Kill or detach all inferiors. */
41027 - iterate_over_inferiors (kill_or_detach, qt);
41028 + if (target_has_execution)
41029 + iterate_over_inferiors (kill_or_detach, qt);
41031 /* Give all pushed targets a chance to do minimal cleanup, and pop
41033 diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
41034 index 83df64e..003ef3a 100644
41035 --- a/gdb/tracepoint.c
41036 +++ b/gdb/tracepoint.c
41037 @@ -1587,7 +1587,7 @@ encode_actions (struct tracepoint *t, char ***tdp_actions,
41039 /* safe because we know it's a simple expression */
41040 tempval = evaluate_expression (exp);
41041 - addr = VALUE_ADDRESS (tempval) + value_offset (tempval);
41042 + addr = value_address (tempval);
41043 len = TYPE_LENGTH (check_typedef (exp->elts[1].type));
41044 add_memrange (collect, memrange_absolute, addr, len);
41046 diff --git a/gdb/typeprint.c b/gdb/typeprint.c
41047 index 1f824fa..4a92a13 100644
41048 --- a/gdb/typeprint.c
41049 +++ b/gdb/typeprint.c
41051 #include "gdb_string.h"
41052 #include "exceptions.h"
41053 #include "valprint.h"
41054 +#include "dwarf2loc.h"
41057 extern void _initialize_typeprint (void);
41058 @@ -76,6 +77,9 @@ void
41059 type_print (struct type *type, char *varstring, struct ui_file *stream,
41063 + type = check_typedef (type);
41065 LA_PRINT_TYPE (type, varstring, stream, show, 0);
41068 @@ -115,7 +119,8 @@ whatis_exp (char *exp, int show)
41070 struct expression *expr;
41072 - struct cleanup *old_chain = NULL;
41073 + /* Required at least for the object_address_set call. */
41074 + struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
41075 struct type *real_type = NULL;
41078 @@ -126,12 +131,13 @@ whatis_exp (char *exp, int show)
41081 expr = parse_expression (exp);
41082 - old_chain = make_cleanup (free_current_contents, &expr);
41083 + make_cleanup (free_current_contents, &expr);
41084 val = evaluate_type (expr);
41087 val = access_value_history (0);
41089 + object_address_set (VALUE_ADDRESS (val));
41090 type = value_type (val);
41092 get_user_print_options (&opts);
41093 @@ -168,8 +174,7 @@ whatis_exp (char *exp, int show)
41094 type_print (type, "", gdb_stdout, show);
41095 printf_filtered ("\n");
41098 - do_cleanups (old_chain);
41099 + do_cleanups (old_chain);
41103 @@ -236,7 +241,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
41106 case TYPE_CODE_CHAR:
41107 - LA_PRINT_CHAR ((unsigned char) val, stream);
41108 + LA_PRINT_CHAR ((unsigned char) val, type, stream);
41111 case TYPE_CODE_BOOL:
41112 diff --git a/gdb/typeprint.h b/gdb/typeprint.h
41113 index f561310..b39fd17 100644
41114 --- a/gdb/typeprint.h
41115 +++ b/gdb/typeprint.h
41116 @@ -26,4 +26,6 @@ void print_type_scalar (struct type * type, LONGEST, struct ui_file *);
41118 void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
41121 +void c_type_print_args (struct type *, struct ui_file *, int);
41123 diff --git a/gdb/ui-file.c b/gdb/ui-file.c
41124 index 02a0314..5c8c96e 100644
41125 --- a/gdb/ui-file.c
41126 +++ b/gdb/ui-file.c
41130 #include "ui-file.h"
41131 +#include "gdb_obstack.h"
41132 #include "gdb_string.h"
41135 @@ -263,7 +264,7 @@ set_ui_file_data (struct ui_file *file, void *data,
41138 /* ui_file utility function for converting a ``struct ui_file'' into
41139 - a memory buffer''. */
41140 + a memory buffer. */
41142 struct accumulated_ui_file
41144 @@ -297,6 +298,23 @@ ui_file_xstrdup (struct ui_file *file,
41145 *length = acc.length;
41150 +do_ui_file_obsavestring (void *context, const char *buffer, long length)
41152 + struct obstack *obstack = (struct obstack *) context;
41153 + obstack_grow (obstack, buffer, length);
41157 +ui_file_obsavestring (struct ui_file *file, struct obstack *obstack,
41160 + ui_file_put (file, do_ui_file_obsavestring, obstack);
41161 + *length = obstack_object_size (obstack);
41162 + obstack_1grow (obstack, '\0');
41163 + return obstack_finish (obstack);
41166 /* A pure memory based ``struct ui_file'' that can be used an output
41167 buffer. The buffers accumulated contents are available via
41168 diff --git a/gdb/ui-file.h b/gdb/ui-file.h
41169 index 1562d5a..d86a7eb 100644
41170 --- a/gdb/ui-file.h
41171 +++ b/gdb/ui-file.h
41179 /* Create a generic ui_file object with null methods. */
41180 @@ -77,7 +78,10 @@ extern void ui_file_put (struct ui_file *src, ui_file_put_method_ftype *write, v
41182 extern char *ui_file_xstrdup (struct ui_file *file, long *length);
41185 +/* Similar to ui_file_xstrdup, but return a new string allocated on
41187 +extern char *ui_file_obsavestring (struct ui_file *file,
41188 + struct obstack *obstack, long *length);
41190 extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
41192 diff --git a/gdb/utils.c b/gdb/utils.c
41193 index 9224839..88a9a39 100644
41196 @@ -272,6 +272,19 @@ make_cleanup_fclose (FILE *file)
41200 +do_obstack_free (void *arg)
41202 + struct obstack *ob = arg;
41203 + obstack_free (ob, NULL);
41207 +make_cleanup_obstack_free (struct obstack *obstack)
41209 + return make_cleanup (do_obstack_free, obstack);
41213 do_ui_file_delete (void *arg)
41215 ui_file_delete (arg);
41216 @@ -1554,21 +1567,33 @@ query (const char *ctlstr, ...)
41220 -/* Print an error message saying that we couldn't make sense of a
41221 - \^mumble sequence in a string or character constant. START and END
41222 - indicate a substring of some larger string that contains the
41223 - erroneous backslash sequence, missing the initial backslash. */
41224 -static NORETURN int
41225 -no_control_char_error (const char *start, const char *end)
41226 +/* A helper for parse_escape that converts a host character to a
41227 + target character. C is the host character. If conversion is
41228 + possible, then the target character is stored in *TARGET_C and the
41229 + function returns 1. Otherwise, the function returns 0. */
41232 +host_char_to_target (int c, int *target_c)
41234 - int len = end - start;
41235 - char *copy = alloca (end - start + 1);
41236 + struct obstack host_data;
41237 + char the_char = c;
41238 + struct cleanup *cleanups;
41241 + obstack_init (&host_data);
41242 + cleanups = make_cleanup_obstack_free (&host_data);
41244 + convert_between_encodings (target_charset (), host_charset (),
41245 + &the_char, 1, 1, &host_data, translit_none);
41247 - memcpy (copy, start, len);
41248 - copy[len] = '\0';
41249 + if (obstack_object_size (&host_data) == 1)
41252 + *target_c = *(char *) obstack_base (&host_data);
41255 - error (_("There is no control character `\\%s' in the `%s' character set."),
41256 - copy, target_charset ());
41257 + do_cleanups (cleanups);
41261 /* Parse a C escape sequence. STRING_PTR points to a variable
41262 @@ -1591,53 +1616,13 @@ parse_escape (char **string_ptr)
41265 int c = *(*string_ptr)++;
41266 - if (c_parse_backslash (c, &target_char))
41267 - return target_char;
41280 - /* Remember where this escape sequence started, for reporting
41282 - char *sequence_start_pos = *string_ptr - 1;
41284 - c = *(*string_ptr)++;
41288 - /* XXXCHARSET: What is `delete' in the host character set? */
41291 - if (!host_char_to_target (c, &target_char))
41292 - error (_("There is no character corresponding to `Delete' "
41293 - "in the target character set `%s'."), host_charset ());
41295 - return target_char;
41297 - else if (c == '\\')
41298 - target_char = parse_escape (string_ptr);
41301 - if (!host_char_to_target (c, &target_char))
41302 - no_control_char_error (sequence_start_pos, *string_ptr);
41305 - /* Now target_char is something like `c', and we want to find
41306 - its control-character equivalent. */
41307 - if (!target_char_to_control_char (target_char, &target_char))
41308 - no_control_char_error (sequence_start_pos, *string_ptr);
41310 - return target_char;
41313 - /* XXXCHARSET: we need to use isdigit and value-of-digit
41314 - methods of the host character set here. */
41318 @@ -1648,16 +1633,16 @@ parse_escape (char **string_ptr)
41323 + int i = host_hex_value (c);
41325 while (++count < 3)
41327 c = (**string_ptr);
41328 - if (c >= '0' && c <= '7')
41329 + if (isdigit (c) && c != '8' && c != '9')
41334 + i += host_hex_value (c);
41338 @@ -1666,14 +1651,39 @@ parse_escape (char **string_ptr)
41343 - if (!host_char_to_target (c, &target_char))
41345 - ("The escape sequence `\%c' is equivalent to plain `%c', which"
41346 - " has no equivalent\n" "in the `%s' character set.", c, c,
41347 - target_charset ());
41348 - return target_char;
41377 + if (!host_char_to_target (c, &target_char))
41379 + ("The escape sequence `\%c' is equivalent to plain `%c', which"
41380 + " has no equivalent\n" "in the `%s' character set.", c, c,
41381 + target_charset ());
41382 + return target_char;
41385 /* Print the character C on STREAM as part of the contents of a literal
41386 diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
41387 index 9850de4..285fe3f 100644
41388 --- a/gdb/v850-tdep.c
41389 +++ b/gdb/v850-tdep.c
41390 @@ -705,7 +705,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
41391 if (!v850_type_is_scalar (value_type (*args))
41392 && TYPE_LENGTH (value_type (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS)
41394 - store_unsigned_integer (valbuf, 4, VALUE_ADDRESS (*args));
41395 + store_unsigned_integer (valbuf, 4, value_address (*args));
41399 diff --git a/gdb/valarith.c b/gdb/valarith.c
41400 index f38cdb8..8e103cf 100644
41401 --- a/gdb/valarith.c
41402 +++ b/gdb/valarith.c
41403 @@ -164,9 +164,9 @@ an integer nor a pointer of the same type."));
41405 value_subscript (struct value *array, struct value *idx)
41407 - struct value *bound;
41408 int c_style = current_language->c_style_arrays;
41409 struct type *tarray;
41410 + LONGEST index = value_as_long (idx);
41412 array = coerce_ref (array);
41413 tarray = check_typedef (value_type (array));
41414 @@ -179,13 +179,26 @@ value_subscript (struct value *array, struct value *idx)
41415 get_discrete_bounds (range_type, &lowerbound, &upperbound);
41417 if (VALUE_LVAL (array) != lval_memory)
41418 - return value_subscripted_rvalue (array, idx, lowerbound);
41420 + if (index >= lowerbound && index <= upperbound)
41422 + CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
41423 + CORE_ADDR offset = (index - lowerbound) * element_size;
41425 + return value_subscripted_rvalue (array, offset);
41427 + error (_("array or string index out of range"));
41432 - LONGEST index = value_as_long (idx);
41433 if (index >= lowerbound && index <= upperbound)
41434 - return value_subscripted_rvalue (array, idx, lowerbound);
41436 + CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
41437 + CORE_ADDR offset = (index - lowerbound) * element_size;
41439 + return value_subscripted_rvalue (array, offset);
41441 /* Emit warning unless we have an array of unknown size.
41442 An array of unknown size has lowerbound 0 and upperbound -1. */
41443 if (upperbound > -1)
41444 @@ -194,49 +207,52 @@ value_subscript (struct value *array, struct value *idx)
41448 - if (lowerbound != 0)
41450 - bound = value_from_longest (value_type (idx), (LONGEST) lowerbound);
41451 - idx = value_binop (idx, bound, BINOP_SUB);
41454 + index -= lowerbound;
41455 array = value_coerce_array (array);
41459 - return value_ind (value_ptradd (array, idx));
41461 + struct value *idx;
41463 + idx = value_from_longest (builtin_type_int32, index);
41464 + return value_ind (value_ptradd (array, idx));
41467 error (_("not an array or string"));
41470 -/* Return the value of EXPR[IDX], expr an aggregate rvalue
41471 - (eg, a vector register). This routine used to promote floats
41472 - to doubles, but no longer does. */
41473 +/* Return the value of *((void *) ARRAY + ELEMENT), ARRAY an aggregate rvalue
41474 + (eg, a vector register). This routine used to promote floats to doubles,
41475 + but no longer does. OFFSET is zero-based with 0 for the lowermost existing
41476 + element, it must be expressed in bytes (therefore multiplied by
41477 + check_typedef (TYPE_TARGET_TYPE (array_type)). */
41480 -value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
41481 +value_subscripted_rvalue (struct value *array, CORE_ADDR offset)
41483 struct type *array_type = check_typedef (value_type (array));
41484 struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
41485 - unsigned int elt_size = TYPE_LENGTH (elt_type);
41486 - LONGEST index = value_as_long (idx);
41487 - unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
41490 - if (index < lowerbound || elt_offs >= TYPE_LENGTH (array_type))
41491 - error (_("no such vector element"));
41492 + /* Do not check TYPE_LENGTH (array_type) as we may have been given the
41493 + innermost dimension of a multi-dimensional Fortran array where its length
41494 + is shorter than the possibly accessed element offset. */
41496 v = allocate_value (elt_type);
41497 if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
41498 set_value_lazy (v, 1);
41500 - memcpy (value_contents_writeable (v),
41501 - value_contents (array) + elt_offs, elt_size);
41503 + unsigned int elt_size = TYPE_LENGTH (elt_type);
41504 + memcpy (value_contents_writeable (v),
41505 + value_contents (array) + offset, elt_size);
41508 set_value_component_location (v, array);
41509 VALUE_REGNUM (v) = VALUE_REGNUM (array);
41510 VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
41511 - set_value_offset (v, value_offset (array) + elt_offs);
41512 + set_value_offset (v, value_offset (array) + offset);
41516 diff --git a/gdb/valops.c b/gdb/valops.c
41517 index 9810f2b..14c562e 100644
41521 #include "cp-support.h"
41523 #include "user-regs.h"
41524 +#include "dwarf2loc.h"
41527 #include "gdb_string.h"
41528 @@ -254,9 +255,8 @@ value_cast_structs (struct type *type, struct value *v2)
41531 /* Downcasting is possible (t1 is superclass of v2). */
41532 - CORE_ADDR addr2 = VALUE_ADDRESS (v2);
41533 - addr2 -= (VALUE_ADDRESS (v)
41534 - + value_offset (v)
41535 + CORE_ADDR addr2 = value_address (v2);
41536 + addr2 -= (value_address (v)
41537 + value_embedded_offset (v));
41538 return value_at (type, addr2);
41540 @@ -371,8 +371,6 @@ value_cast (struct type *type, struct value *arg2)
41541 new_length = val_length / element_length;
41542 if (val_length % element_length != 0)
41543 warning (_("array element type size does not divide object size in cast"));
41544 - /* FIXME-type-allocation: need a way to free this type when
41545 - we are done with it. */
41546 range_type = create_range_type ((struct type *) NULL,
41547 TYPE_TARGET_TYPE (range_type),
41549 @@ -511,7 +509,7 @@ value_cast (struct type *type, struct value *arg2)
41551 else if (VALUE_LVAL (arg2) == lval_memory)
41552 return value_at_lazy (type,
41553 - VALUE_ADDRESS (arg2) + value_offset (arg2));
41554 + value_address (arg2));
41555 else if (code1 == TYPE_CODE_VOID)
41557 return value_zero (builtin_type_void, not_lval);
41558 @@ -568,6 +566,64 @@ value_one (struct type *type, enum lval_type lv)
41562 +/* object_address_set must be already called before this function. */
41565 +object_address_data_not_valid (struct type *type)
41567 + /* Attributes are present only at the target type of a typedef. Make the
41568 + call conditional as it would otherwise loop through type_length_get. */
41569 + if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
41570 + CHECK_TYPEDEF (type);
41572 + /* DW_AT_associated has a preference over DW_AT_allocated. */
41573 + if (TYPE_NOT_ASSOCIATED (type)
41574 + || (TYPE_ASSOCIATED (type) != NULL
41575 + && 0 == dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (type))))
41576 + return N_("object is not associated");
41578 + if (TYPE_NOT_ALLOCATED (type)
41579 + || (TYPE_ALLOCATED (type) != NULL
41580 + && 0 == dwarf_locexpr_baton_eval (TYPE_ALLOCATED (type))))
41581 + return N_("object is not allocated");
41586 +/* Return non-zero if the variable is valid. If it is valid the function
41587 + may store the data address (DW_AT_DATA_LOCATION) of TYPE at *ADDRESS_RETURN.
41588 + You must set *ADDRESS_RETURN as VALUE_ADDRESS (VAL) before calling this
41589 + function. If no DW_AT_DATA_LOCATION is present for TYPE the address at
41590 + *ADDRESS_RETURN is left unchanged. ADDRESS_RETURN must not be NULL, use
41591 + object_address_data_not_valid () for just the data validity check. */
41594 +object_address_get_data (struct type *type, CORE_ADDR *address_return)
41596 + gdb_assert (address_return != NULL);
41598 + object_address_set (*address_return);
41600 + /* TYPE_DATA_LOCATION_DWARF_BLOCK / TYPE_DATA_LOCATION_ADDR are present only
41601 + at the target type of a typedef. */
41602 + CHECK_TYPEDEF (type);
41604 + if (object_address_data_not_valid (type) != NULL)
41606 + /* Do not try to evaluate DW_AT_data_location as it may even crash
41607 + (it would just return the value zero in the gfortran case). */
41611 + if (TYPE_DATA_LOCATION_IS_ADDR (type))
41612 + *address_return = TYPE_DATA_LOCATION_ADDR (type);
41613 + else if (TYPE_DATA_LOCATION_DWARF_BLOCK (type) != NULL)
41615 + = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type));
41620 /* Return a value with type TYPE located at ADDR.
41622 Call value_at only if the data needs to be fetched immediately;
41623 @@ -593,7 +649,7 @@ value_at (struct type *type, CORE_ADDR addr)
41624 read_memory (addr, value_contents_all_raw (val), TYPE_LENGTH (type));
41626 VALUE_LVAL (val) = lval_memory;
41627 - VALUE_ADDRESS (val) = addr;
41628 + set_value_address (val, addr);
41632 @@ -611,7 +667,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr)
41633 val = allocate_value_lazy (type);
41635 VALUE_LVAL (val) = lval_memory;
41636 - VALUE_ADDRESS (val) = addr;
41637 + set_value_address (val, addr);
41641 @@ -637,11 +693,19 @@ value_fetch_lazy (struct value *val)
41642 allocate_value_contents (val);
41643 if (VALUE_LVAL (val) == lval_memory)
41645 - CORE_ADDR addr = VALUE_ADDRESS (val) + value_offset (val);
41646 - int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
41647 + CORE_ADDR addr = VALUE_ADDRESS (val);
41649 + if (object_address_get_data (value_type (val), &addr))
41651 + struct type *type = value_enclosing_type (val);
41652 + int length = TYPE_LENGTH (check_typedef (type));
41655 - read_memory (addr, value_contents_all_raw (val), length);
41658 + addr += value_offset (val);
41659 + read_memory (addr, value_contents_all_raw (val), length);
41663 else if (VALUE_LVAL (val) == lval_register)
41665 @@ -709,7 +773,7 @@ value_fetch_lazy (struct value *val)
41666 VALUE_REGNUM (new_val));
41667 else if (VALUE_LVAL (new_val) == lval_memory)
41668 fprintf_unfiltered (gdb_stdlog, " address=0x%s",
41669 - paddr_nz (VALUE_ADDRESS (new_val)));
41670 + paddr_nz (value_address (new_val)));
41672 fprintf_unfiltered (gdb_stdlog, " computed");
41674 @@ -813,16 +877,15 @@ value_assign (struct value *toval, struct value *fromval)
41675 error (_("Can't handle bitfields which don't fit in a %d bit word."),
41676 (int) sizeof (LONGEST) * HOST_CHAR_BIT);
41678 - read_memory (VALUE_ADDRESS (toval) + value_offset (toval),
41679 - buffer, changed_len);
41680 + read_memory (value_address (toval), buffer, changed_len);
41681 modify_field (buffer, value_as_long (fromval),
41682 value_bitpos (toval), value_bitsize (toval));
41683 - changed_addr = VALUE_ADDRESS (toval) + value_offset (toval);
41684 + changed_addr = value_address (toval);
41685 dest_buffer = buffer;
41689 - changed_addr = VALUE_ADDRESS (toval) + value_offset (toval);
41690 + changed_addr = value_address (toval);
41691 changed_len = TYPE_LENGTH (type);
41692 dest_buffer = value_contents (fromval);
41694 @@ -985,11 +1048,11 @@ value_repeat (struct value *arg1, int count)
41696 val = allocate_repeat_value (value_enclosing_type (arg1), count);
41698 - read_memory (VALUE_ADDRESS (arg1) + value_offset (arg1),
41699 + read_memory (value_address (arg1),
41700 value_contents_all_raw (val),
41701 TYPE_LENGTH (value_enclosing_type (val)));
41702 VALUE_LVAL (val) = lval_memory;
41703 - VALUE_ADDRESS (val) = VALUE_ADDRESS (arg1) + value_offset (arg1);
41704 + set_value_address (val, value_address (arg1));
41708 @@ -1036,10 +1099,11 @@ address_of_variable (struct symbol *var, struct block *b)
41710 val = value_of_variable (var, b);
41712 - if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
41713 + if ((VALUE_LVAL (val) == lval_memory && value_lazy (val)
41714 + && object_address_get_data (type, &VALUE_ADDRESS (val)))
41715 || TYPE_CODE (type) == TYPE_CODE_FUNC)
41717 - CORE_ADDR addr = VALUE_ADDRESS (val);
41718 + CORE_ADDR addr = value_address (val);
41719 return value_from_pointer (lookup_pointer_type (type), addr);
41722 @@ -1145,6 +1209,7 @@ struct value *
41723 value_coerce_array (struct value *arg1)
41725 struct type *type = check_typedef (value_type (arg1));
41726 + CORE_ADDR address;
41728 /* If the user tries to do something requiring a pointer with an
41729 array that has not yet been pushed to the target, then this would
41730 @@ -1154,8 +1219,12 @@ value_coerce_array (struct value *arg1)
41731 if (VALUE_LVAL (arg1) != lval_memory)
41732 error (_("Attempt to take address of value not located in memory."));
41734 + address = VALUE_ADDRESS (arg1);
41735 + if (!object_address_get_data (type, &address))
41736 + error (_("Attempt to take address of non-valid value."));
41738 return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
41739 - (VALUE_ADDRESS (arg1) + value_offset (arg1)));
41740 + address + value_offset (arg1));
41743 /* Given a value which is a function, return a value which is a pointer
41744 @@ -1170,7 +1239,7 @@ value_coerce_function (struct value *arg1)
41745 error (_("Attempt to take address of value not located in memory."));
41747 retval = value_from_pointer (lookup_pointer_type (value_type (arg1)),
41748 - (VALUE_ADDRESS (arg1) + value_offset (arg1)));
41749 + (value_address (arg1)));
41753 @@ -1205,8 +1274,7 @@ value_addr (struct value *arg1)
41755 /* Get target memory address */
41756 arg2 = value_from_pointer (lookup_pointer_type (value_type (arg1)),
41757 - (VALUE_ADDRESS (arg1)
41758 - + value_offset (arg1)
41759 + (value_address (arg1)
41760 + value_embedded_offset (arg1)));
41762 /* This may be a pointer to a base subobject; so remember the
41763 @@ -1352,6 +1420,24 @@ value_array (int lowbound, int highbound, struct value **elemvec)
41768 +value_typed_string (char *ptr, int len, struct type *char_type)
41770 + struct value *val;
41771 + int lowbound = current_language->string_lower_bound;
41772 + int highbound = len / TYPE_LENGTH (char_type);
41773 + struct type *rangetype = create_range_type ((struct type *) NULL,
41774 + builtin_type_int32,
41776 + highbound + lowbound - 1);
41777 + struct type *stringtype
41778 + = create_array_type ((struct type *) NULL, char_type, rangetype);
41780 + val = allocate_value (stringtype);
41781 + memcpy (value_contents_raw (val), ptr, len);
41785 /* Create a value for a string constant by allocating space in the
41786 inferior, copying the data into that space, and returning the
41787 address with type TYPE_CODE_STRING. PTR points to the string
41788 @@ -1600,8 +1686,7 @@ search_struct_field (char *name, struct value *arg1, int offset,
41790 boffset = baseclass_offset (type, i,
41791 value_contents (arg1) + offset,
41792 - VALUE_ADDRESS (arg1)
41793 - + value_offset (arg1) + offset);
41794 + value_address (arg1) + offset);
41796 error (_("virtual baseclass botch"));
41798 @@ -1616,13 +1701,13 @@ search_struct_field (char *name, struct value *arg1, int offset,
41800 v2 = allocate_value (basetype);
41802 - VALUE_ADDRESS (arg1) + value_offset (arg1) + boffset;
41803 + value_address (arg1) + boffset;
41804 if (target_read_memory (base_addr,
41805 value_contents_raw (v2),
41806 TYPE_LENGTH (basetype)) != 0)
41807 error (_("virtual baseclass botch"));
41808 VALUE_LVAL (v2) = lval_memory;
41809 - VALUE_ADDRESS (v2) = base_addr;
41810 + set_value_address (v2, base_addr);
41814 @@ -1745,8 +1830,7 @@ search_struct_method (char *name, struct value **arg1p,
41815 if (offset < 0 || offset >= TYPE_LENGTH (type))
41817 gdb_byte *tmp = alloca (TYPE_LENGTH (baseclass));
41818 - if (target_read_memory (VALUE_ADDRESS (*arg1p)
41819 - + value_offset (*arg1p) + offset,
41820 + if (target_read_memory (value_address (*arg1p) + offset,
41821 tmp, TYPE_LENGTH (baseclass)) != 0)
41822 error (_("virtual baseclass botch"));
41823 base_valaddr = tmp;
41824 @@ -1755,8 +1839,7 @@ search_struct_method (char *name, struct value **arg1p,
41825 base_valaddr = value_contents (*arg1p) + offset;
41827 base_offset = baseclass_offset (type, i, base_valaddr,
41828 - VALUE_ADDRESS (*arg1p)
41829 - + value_offset (*arg1p) + offset);
41830 + value_address (*arg1p) + offset);
41831 if (base_offset == -1)
41832 error (_("virtual baseclass botch"));
41834 @@ -1965,7 +2048,7 @@ find_method_list (struct value **argp, char *method,
41835 base_offset = value_offset (*argp) + offset;
41836 base_offset = baseclass_offset (type, i,
41837 value_contents (*argp) + base_offset,
41838 - VALUE_ADDRESS (*argp) + base_offset);
41839 + value_address (*argp) + base_offset);
41840 if (base_offset == -1)
41841 error (_("virtual baseclass botch"));
41843 @@ -2083,12 +2166,25 @@ find_overload_match (struct type **arg_types, int nargs,
41848 + /* OBJ may be a pointer value rather than the object itself. */
41849 + obj = coerce_ref (obj);
41850 + while (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_PTR)
41851 + obj = coerce_ref (value_ind (obj));
41852 obj_type_name = TYPE_NAME (value_type (obj));
41853 - /* Hack: evaluate_subexp_standard often passes in a pointer
41854 - value rather than the object itself, so try again. */
41855 - if ((!obj_type_name || !*obj_type_name)
41856 - && (TYPE_CODE (value_type (obj)) == TYPE_CODE_PTR))
41857 - obj_type_name = TYPE_NAME (TYPE_TARGET_TYPE (value_type (obj)));
41859 + /* First check whether this is a data member, e.g. a pointer to
41861 + if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT)
41863 + *valp = search_struct_field (name, obj, 0,
41864 + check_typedef (value_type (obj)), 0);
41872 fns_ptr = value_find_oload_method_list (&temp, name,
41874 @@ -2108,16 +2204,29 @@ find_overload_match (struct type **arg_types, int nargs,
41878 - const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym);
41879 + const char *qualified_name = SYMBOL_NATURAL_NAME (fsym);
41881 - /* If we have a C++ name, try to extract just the function
41883 - if (qualified_name)
41884 - func_name = cp_func_name (qualified_name);
41885 + /* If we have a function with a C++ name, try to extract just
41886 + the function part. Do not try this for non-functions (e.g.
41887 + function pointers). */
41888 + if (qualified_name
41889 + && TYPE_CODE (check_typedef (SYMBOL_TYPE (fsym))) == TYPE_CODE_FUNC)
41891 + func_name = cp_func_name (qualified_name);
41893 + /* If cp_func_name did not remove anything, the name of the
41894 + symbol did not include scope or argument types - it was
41895 + probably a C-style function. */
41896 + if (func_name && strcmp (func_name, qualified_name) == 0)
41898 + xfree (func_name);
41899 + func_name = NULL;
41903 - /* If there was no C++ name, this must be a C-style function.
41904 - Just return the same symbol. Do the same if cp_func_name
41905 - fails for some reason. */
41906 + /* If there was no C++ name, this must be a C-style function or
41907 + not a function at all. Just return the same symbol. Do the
41908 + same if cp_func_name fails for some reason. */
41909 if (func_name == NULL)
41912 @@ -2558,8 +2667,8 @@ check_field (struct type *type, const char *name)
41913 the comment before value_struct_elt_for_reference. */
41916 -value_aggregate_elt (struct type *curtype,
41917 - char *name, int want_address,
41918 +value_aggregate_elt (struct type *curtype, char *name,
41919 + struct type *expect_type, int want_address,
41920 enum noside noside)
41922 switch (TYPE_CODE (curtype))
41923 @@ -2567,7 +2676,7 @@ value_aggregate_elt (struct type *curtype,
41924 case TYPE_CODE_STRUCT:
41925 case TYPE_CODE_UNION:
41926 return value_struct_elt_for_reference (curtype, 0, curtype,
41928 + name, expect_type,
41929 want_address, noside);
41930 case TYPE_CODE_NAMESPACE:
41931 return value_namespace_elt (curtype, name,
41932 @@ -2671,7 +2780,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
41936 - if (TYPE_FN_FIELD_TYPE (f, j) == intype)
41937 + if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype))
41940 error (_("no member function matches that type instantiation"));
41941 @@ -2725,7 +2834,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
41942 result = allocate_value (lookup_methodptr_type (TYPE_FN_FIELD_TYPE (f, j)));
41943 cplus_make_method_ptr (value_type (result),
41944 value_contents_writeable (result),
41945 - VALUE_ADDRESS (v), 0);
41946 + value_address (v), 0);
41950 @@ -2791,7 +2900,7 @@ value_maybe_namespace_elt (const struct type *curtype,
41951 struct symbol *sym;
41952 struct value *result;
41954 - sym = cp_lookup_symbol_namespace (namespace_name, name, NULL,
41955 + sym = cp_lookup_symbol_namespace_incremental (namespace_name, name, NULL,
41956 get_selected_block (0),
41959 @@ -2884,7 +2993,7 @@ value_full_object (struct value *argp,
41960 /* Go back by the computed top_offset from the beginning of the
41961 object, adjusting for the embedded offset of argp if that's what
41962 value_rtti_type used for its computation. */
41963 - new_val = value_at_lazy (real_type, VALUE_ADDRESS (argp) - top +
41964 + new_val = value_at_lazy (real_type, value_address (argp) - top +
41965 (using_enc ? 0 : value_embedded_offset (argp)));
41966 deprecated_set_value_type (new_val, value_type (argp));
41967 set_value_embedded_offset (new_val, (using_enc
41968 @@ -2989,8 +3098,6 @@ value_slice (struct value *array, int lowbound, int length)
41969 || lowbound + length - 1 > upperbound)
41970 error (_("slice out of range"));
41972 - /* FIXME-type-allocation: need a way to free this type when we are
41974 slice_range_type = create_range_type ((struct type *) NULL,
41975 TYPE_TARGET_TYPE (range_type),
41977 diff --git a/gdb/valprint.c b/gdb/valprint.c
41978 index b02e9df..a9e8227 100644
41979 --- a/gdb/valprint.c
41980 +++ b/gdb/valprint.c
41982 #include "doublest.h"
41983 #include "exceptions.h"
41985 +#include "python/python.h"
41989 @@ -80,7 +81,9 @@ struct value_print_options user_print_options =
41990 0, /* print_array_indexes */
41992 1, /* static_field_print */
41993 - 1 /* pascal_static_field_print */
41994 + 1, /* pascal_static_field_print */
41999 /* Initialize *OPTS to be a copy of the user print options. */
42000 @@ -257,6 +260,15 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
42004 + if (!options->raw)
42006 + ret = apply_val_pretty_printer (type, valaddr, embedded_offset,
42007 + address, stream, recurse, options,
42013 TRY_CATCH (except, RETURN_MASK_ERROR)
42015 ret = language->la_val_print (type, valaddr, embedded_offset, address,
42016 @@ -287,6 +299,13 @@ value_check_printable (struct value *val, struct ui_file *stream)
42020 + if (TYPE_CODE (value_type (val)) == TYPE_CODE_INTERNAL_FUNCTION)
42022 + fprintf_filtered (stream, _("<internal function %s>"),
42023 + value_internal_function_name (val));
42030 @@ -308,7 +327,7 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
42033 return val_print (value_type (val), value_contents_all (val),
42034 - value_embedded_offset (val), VALUE_ADDRESS (val),
42035 + value_embedded_offset (val), value_address (val),
42036 stream, recurse, options, language);
42039 @@ -324,6 +343,18 @@ value_print (struct value *val, struct ui_file *stream,
42040 if (!value_check_printable (val, stream))
42043 + if (!options->raw)
42045 + int r = apply_val_pretty_printer (value_type (val),
42046 + value_contents_all (val),
42047 + value_embedded_offset (val),
42048 + value_address (val),
42049 + stream, 0, options,
42050 + current_language);
42055 return LA_VALUE_PRINT (val, stream, options);
42058 @@ -919,7 +950,8 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
42059 Omit any leading zero chars. */
42062 -print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
42063 +print_char_chars (struct ui_file *stream, struct type *type,
42064 + const gdb_byte *valaddr,
42065 unsigned len, enum bfd_endian byte_order)
42068 @@ -932,7 +964,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
42070 while (p < valaddr + len)
42072 - LA_EMIT_CHAR (*p, stream, '\'');
42073 + LA_EMIT_CHAR (*p, type, stream, '\'');
42077 @@ -944,7 +976,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
42079 while (p >= valaddr)
42081 - LA_EMIT_CHAR (*p, stream, '\'');
42082 + LA_EMIT_CHAR (*p, type, stream, '\'');
42086 @@ -1085,6 +1117,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42088 for (; i < len && things_printed < options->print_max; i++)
42090 + size_t elt_offset = i * eltlen;
42093 if (options->prettyprint_arrays)
42094 @@ -1104,7 +1137,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42097 while ((rep1 < len) &&
42098 - !memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen))
42099 + !memcmp (valaddr + elt_offset, valaddr + rep1 * eltlen, eltlen))
42103 @@ -1112,7 +1145,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42105 if (reps > options->repeat_count_threshold)
42107 - val_print (elttype, valaddr + i * eltlen, 0, address + i * eltlen,
42108 + val_print (elttype, valaddr + elt_offset, 0, address + elt_offset,
42109 stream, recurse + 1, options, current_language);
42110 annotate_elt_rep (reps);
42111 fprintf_filtered (stream, " <repeats %u times>", reps);
42112 @@ -1123,7 +1156,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42116 - val_print (elttype, valaddr + i * eltlen, 0, address + i * eltlen,
42117 + val_print (elttype, valaddr + elt_offset, 0, address + elt_offset,
42118 stream, recurse + 1, options, current_language);
42121 @@ -1315,7 +1348,8 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
42122 whichever is smaller. */
42125 -val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
42126 +val_print_string (struct type *elttype, CORE_ADDR addr, int len,
42127 + struct ui_file *stream,
42128 const struct value_print_options *options)
42130 int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
42131 @@ -1325,6 +1359,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
42133 gdb_byte *buffer = NULL; /* Dynamically growable fetch buffer. */
42134 struct cleanup *old_chain = NULL; /* Top of the old cleanup chain. */
42135 + int width = TYPE_LENGTH (elttype);
42137 /* First we need to figure out the limit on the number of characters we are
42138 going to attempt to fetch and print. This is actually pretty simple. If
42139 @@ -1378,7 +1413,7 @@ val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
42141 fputs_filtered (" ", stream);
42143 - LA_PRINT_STRING (stream, buffer, bytes_read / width, width, force_ellipsis, options);
42144 + LA_PRINT_STRING (stream, elttype, buffer, bytes_read / width, force_ellipsis, options);
42148 diff --git a/gdb/valprint.h b/gdb/valprint.h
42149 index 8b65af6..4f63fa6 100644
42150 --- a/gdb/valprint.h
42151 +++ b/gdb/valprint.h
42152 @@ -84,6 +84,12 @@ struct value_print_options
42153 /* If nonzero, print static fields for Pascal. FIXME: C++ and Java
42154 share one flag, why not Pascal too? */
42155 int pascal_static_field_print;
42157 + /* Controls Python pretty-printing. */
42160 + /* If nonzero, print the value in "summary" form. */
42164 /* The global print options set by the user. In general this should
42165 @@ -134,9 +140,10 @@ extern void print_decimal_chars (struct ui_file *, const gdb_byte *,
42166 extern void print_hex_chars (struct ui_file *, const gdb_byte *,
42167 unsigned int, enum bfd_endian);
42169 -extern void print_char_chars (struct ui_file *, const gdb_byte *,
42170 - unsigned int, enum bfd_endian);
42171 +extern void print_char_chars (struct ui_file *, struct type *,
42172 + const gdb_byte *, unsigned int, enum bfd_endian);
42174 int read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
42175 gdb_byte **buffer, int *bytes_read);
42178 diff --git a/gdb/value.c b/gdb/value.c
42179 index 4d4329e..5c81d83 100644
42185 #include "objfiles.h"
42186 +#include "cli/cli-decode.h"
42187 #include "valprint.h"
42189 #include "python/python.h"
42192 void _initialize_values (void);
42194 +/* Definition of a user function. */
42195 +struct internal_function
42197 + /* The name of the function. It is a bit odd to have this in the
42198 + function itself -- the user might use a differently-named
42199 + convenience variable to hold the function. */
42202 + /* The handler. */
42203 + internal_function_fn handler;
42205 + /* User data for the handler. */
42209 +static struct cmd_list_element *functionlist;
42213 /* Type of value; either not an lval, or one of the various
42214 @@ -203,6 +221,10 @@ struct value_history_chunk
42215 static struct value_history_chunk *value_history_chain;
42217 static int value_history_count; /* Abs number of last entry stored */
42219 +/* The type of internal functions. */
42221 +static struct type *internal_fn_type;
42223 /* List of all value objects currently allocated
42224 (except for those released by calls to release_value)
42225 @@ -225,9 +247,11 @@ allocate_value_lazy (struct type *type)
42226 val->next = all_values;
42229 + type_incref (type);
42230 val->enclosing_type = type;
42231 + type_incref (type);
42232 VALUE_LVAL (val) = not_lval;
42233 - VALUE_ADDRESS (val) = 0;
42234 + val->location.address = 0;
42235 VALUE_FRAME_ID (val) = null_frame_id;
42238 @@ -269,13 +293,9 @@ struct value *
42239 allocate_repeat_value (struct type *type, int count)
42241 int low_bound = current_language->string_lower_bound; /* ??? */
42242 - /* FIXME-type-allocation: need a way to free this type when we are
42244 struct type *range_type
42245 = create_range_type ((struct type *) NULL, builtin_type_int32,
42246 low_bound, count + low_bound - 1);
42247 - /* FIXME-type-allocation: need a way to free this type when we are
42249 return allocate_value (create_array_type ((struct type *) NULL,
42250 type, range_type));
42252 @@ -335,6 +355,8 @@ value_type (struct value *value)
42254 deprecated_set_value_type (struct value *value, struct type *type)
42256 + type_incref (type);
42257 + type_decref (value->type);
42258 value->type = type;
42261 @@ -509,6 +531,32 @@ deprecated_value_address_hack (struct value *value)
42262 return &value->location.address;
42266 +value_address (struct value *value)
42268 + if (value->lval == lval_internalvar
42269 + || value->lval == lval_internalvar_component)
42271 + return value->location.address + value->offset;
42275 +value_raw_address (struct value *value)
42277 + if (value->lval == lval_internalvar
42278 + || value->lval == lval_internalvar_component)
42280 + return value->location.address;
42284 +set_value_address (struct value *value, CORE_ADDR addr)
42286 + gdb_assert (value->lval != lval_internalvar
42287 + && value->lval != lval_internalvar_component);
42288 + value->location.address = addr;
42291 struct internalvar **
42292 deprecated_value_internalvar_hack (struct value *value)
42294 @@ -547,11 +595,16 @@ value_mark (void)
42298 +/* Deallocate a value and run destructors if needed. */
42301 value_free (struct value *val)
42305 + type_decref (val->type);
42306 + type_decref (val->enclosing_type);
42308 if (VALUE_LVAL (val) == lval_computed)
42310 struct lval_funcs *funcs = val->location.computed.funcs;
42311 @@ -655,6 +708,8 @@ value_copy (struct value *arg)
42312 val = allocate_value_lazy (encl_type);
42314 val = allocate_value (encl_type);
42315 + type_incref (arg->type);
42316 + type_decref (val->type);
42317 val->type = arg->type;
42318 VALUE_LVAL (val) = VALUE_LVAL (arg);
42319 val->location = arg->location;
42320 @@ -693,6 +748,7 @@ set_value_component_location (struct value *component, struct value *whole)
42321 VALUE_LVAL (component) = VALUE_LVAL (whole);
42323 component->location = whole->location;
42325 if (VALUE_LVAL (whole) == lval_computed)
42327 struct lval_funcs *funcs = whole->location.computed.funcs;
42328 @@ -700,6 +756,8 @@ set_value_component_location (struct value *component, struct value *whole)
42329 if (funcs->copy_closure)
42330 component->location.computed.closure = funcs->copy_closure (whole);
42333 + object_address_get_data (value_type (whole), &VALUE_ADDRESS (component));
42337 @@ -830,6 +888,25 @@ show_values (char *num_exp, int from_tty)
42342 +/* Sanity check for memory leaks and proper types reference counting. */
42345 +value_history_cleanup (void *unused)
42347 + while (value_history_chain)
42349 + struct value_history_chunk *chunk = value_history_chain;
42352 + for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
42353 + value_free (chunk->values[i]);
42355 + value_history_chain = chunk->next;
42358 + value_history_count = 0;
42361 /* Internal variables. These are variables within the debugger
42362 that hold values assigned by debugger commands.
42363 @@ -878,7 +955,7 @@ init_if_undefined_command (char* args, int from_tty)
42364 the return value is NULL. */
42366 struct internalvar *
42367 -lookup_only_internalvar (char *name)
42368 +lookup_only_internalvar (const char *name)
42370 struct internalvar *var;
42372 @@ -894,7 +971,7 @@ lookup_only_internalvar (char *name)
42373 NAME should not normally include a dollar sign. */
42375 struct internalvar *
42376 -create_internalvar (char *name)
42377 +create_internalvar (const char *name)
42379 struct internalvar *var;
42380 var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
42381 @@ -902,6 +979,7 @@ create_internalvar (char *name)
42382 var->value = allocate_value (builtin_type_void);
42383 var->endian = gdbarch_byte_order (current_gdbarch);
42384 var->make_value = NULL;
42385 + var->canonical = 0;
42386 release_value (var->value);
42387 var->next = internalvars;
42388 internalvars = var;
42389 @@ -934,7 +1012,7 @@ create_internalvar_type_lazy (char *name, internalvar_make_value fun)
42390 one is created, with a void value. */
42392 struct internalvar *
42393 -lookup_internalvar (char *name)
42394 +lookup_internalvar (const char *name)
42396 struct internalvar *var;
42398 @@ -1031,6 +1109,9 @@ set_internalvar (struct internalvar *var, struct value *val)
42400 struct value *newval;
42402 + if (var->canonical)
42403 + error (_("Cannot overwrite convenience function %s"), var->name);
42405 newval = value_copy (val);
42406 newval->modifiable = 1;
42408 @@ -1042,7 +1123,7 @@ set_internalvar (struct internalvar *var, struct value *val)
42410 /* Begin code which must not call error(). If var->value points to
42411 something free'd, an error() obviously leaves a dangling pointer.
42412 - But we also get a danling pointer if var->value points to
42413 + But we also get a dangling pointer if var->value points to
42414 something in the value chain (i.e., before release_value is
42415 called), because after the error free_all_values will get called before
42417 @@ -1059,6 +1140,76 @@ internalvar_name (struct internalvar *var)
42421 +static struct value *
42422 +value_create_internal_function (const char *name,
42423 + internal_function_fn handler,
42426 + struct value *result = allocate_value (internal_fn_type);
42427 + gdb_byte *addr = value_contents_writeable (result);
42428 + struct internal_function **fnp = (struct internal_function **) addr;
42429 + struct internal_function *ifn = XNEW (struct internal_function);
42430 + ifn->name = xstrdup (name);
42431 + ifn->handler = handler;
42432 + ifn->cookie = cookie;
42438 +value_internal_function_name (struct value *val)
42440 + gdb_byte *addr = value_contents_writeable (val);
42441 + struct internal_function *ifn = * (struct internal_function **) addr;
42442 + return ifn->name;
42446 +call_internal_function (struct value *func, int argc, struct value **argv)
42448 + gdb_byte *addr = value_contents_writeable (func);
42449 + struct internal_function *ifn = * (struct internal_function **) addr;
42450 + return (*ifn->handler) (ifn->cookie, argc, argv);
42453 +/* The 'function' command. This does nothing -- it is just a
42454 + placeholder to let "help function NAME" work. This is also used as
42455 + the implementation of the sub-command that is created when
42456 + registering an internal function. */
42458 +function_command (char *command, int from_tty)
42460 + /* Do nothing. */
42463 +/* Clean up if an internal function's command is destroyed. */
42465 +function_destroyer (struct cmd_list_element *self, void *ignore)
42467 + xfree (self->name);
42468 + xfree (self->doc);
42471 +/* Add a new internal function. NAME is the name of the function; DOC
42472 + is a documentation string describing the function. HANDLER is
42473 + called when the function is invoked. COOKIE is an arbitrary
42474 + pointer which is passed to HANDLER and is intended for "user
42477 +add_internal_function (const char *name, const char *doc,
42478 + internal_function_fn handler, void *cookie)
42480 + struct cmd_list_element *cmd;
42481 + struct internalvar *var = lookup_internalvar (name);
42482 + struct value *fnval = value_create_internal_function (name, handler, cookie);
42483 + set_internalvar (var, fnval);
42484 + var->canonical = 1;
42486 + cmd = add_cmd (xstrdup (name), no_class, function_command, (char *) doc,
42488 + cmd->destroyer = function_destroyer;
42491 /* Update VALUE before discarding OBJFILE. COPIED_TYPES is used to
42492 prevent cycles / duplicates. */
42494 @@ -1067,12 +1218,21 @@ preserve_one_value (struct value *value, struct objfile *objfile,
42495 htab_t copied_types)
42497 if (TYPE_OBJFILE (value->type) == objfile)
42498 - value->type = copy_type_recursive (objfile, value->type, copied_types);
42500 + /* No need to decref the old type here, since we know it has no
42501 + reference count. */
42502 + value->type = copy_type_recursive (value->type, copied_types);
42503 + type_incref (value->type);
42506 if (TYPE_OBJFILE (value->enclosing_type) == objfile)
42507 - value->enclosing_type = copy_type_recursive (objfile,
42508 - value->enclosing_type,
42511 + /* No need to decref the old type here, since we know it has no
42512 + reference count. */
42513 + value->enclosing_type = copy_type_recursive (value->enclosing_type,
42515 + type_incref (value->enclosing_type);
42519 /* Update the internal variables and value history when OBJFILE is
42520 @@ -1196,7 +1356,7 @@ value_as_address (struct value *val)
42522 Upon entry to this function, if VAL is a value of type `function'
42523 (that is, TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC), then
42524 - VALUE_ADDRESS (val) is the address of the function. This is what
42525 + value_address (val) is the address of the function. This is what
42526 you'll get if you evaluate an expression like `main'. The call
42527 to COERCE_ARRAY below actually does all the usual unary
42528 conversions, which includes converting values of type `function'
42529 @@ -1216,7 +1376,7 @@ value_as_address (struct value *val)
42530 function, just return its address directly. */
42531 if (TYPE_CODE (value_type (val)) == TYPE_CODE_FUNC
42532 || TYPE_CODE (value_type (val)) == TYPE_CODE_METHOD)
42533 - return VALUE_ADDRESS (val);
42534 + return value_address (val);
42536 val = coerce_array (val);
42538 @@ -1447,7 +1607,7 @@ value_static_field (struct type *type, int fieldno)
42540 if (retval && VALUE_LVAL (retval) == lval_memory)
42541 SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
42542 - VALUE_ADDRESS (retval));
42543 + value_address (retval));
42547 @@ -1465,6 +1625,8 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type)
42549 (gdb_byte *) xrealloc (val->contents, TYPE_LENGTH (new_encl_type));
42551 + type_incref (new_encl_type);
42552 + type_decref (val->enclosing_type);
42553 val->enclosing_type = new_encl_type;
42556 @@ -1516,6 +1678,8 @@ value_primitive_field (struct value *arg1, int offset,
42557 memcpy (value_contents_all_raw (v), value_contents_all_raw (arg1),
42558 TYPE_LENGTH (value_enclosing_type (arg1)));
42560 + type_incref (type);
42561 + type_decref (v->type);
42563 v->offset = value_offset (arg1);
42564 v->embedded_offset = (offset + value_embedded_offset (arg1)
42565 @@ -1592,7 +1756,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty
42566 v = allocate_value (ftype);
42569 - VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
42570 + set_value_address (v, BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
42574 @@ -1601,9 +1765,9 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty
42575 struct objfile *objfile = msymbol_objfile (msym);
42576 struct gdbarch *gdbarch = get_objfile_arch (objfile);
42578 - VALUE_ADDRESS (v)
42579 - = gdbarch_convert_from_func_ptr_addr
42580 - (gdbarch, SYMBOL_VALUE_ADDRESS (msym), ¤t_target);
42581 + set_value_address (v,
42582 + gdbarch_convert_from_func_ptr_addr
42583 + (gdbarch, SYMBOL_VALUE_ADDRESS (msym), ¤t_target));
42587 @@ -1750,6 +1914,41 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
42591 +/* Pack NUM into BUF using a target format of TYPE. */
42594 +pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num)
42598 + type = check_typedef (type);
42599 + len = TYPE_LENGTH (type);
42601 + switch (TYPE_CODE (type))
42603 + case TYPE_CODE_INT:
42604 + case TYPE_CODE_CHAR:
42605 + case TYPE_CODE_ENUM:
42606 + case TYPE_CODE_FLAGS:
42607 + case TYPE_CODE_BOOL:
42608 + case TYPE_CODE_RANGE:
42609 + case TYPE_CODE_MEMBERPTR:
42610 + store_unsigned_integer (buf, len, num);
42613 + case TYPE_CODE_REF:
42614 + case TYPE_CODE_PTR:
42615 + store_typed_address (buf, type, (CORE_ADDR) num);
42620 +Unexpected type (%d) encountered for unsigned integer constant."),
42621 + TYPE_CODE (type));
42626 /* Convert C numbers into newly allocated values. */
42629 @@ -1763,6 +1962,19 @@ value_from_longest (struct type *type, LONGEST num)
42633 +/* Convert C unsigned numbers into newly allocated values. */
42636 +value_from_ulongest (struct type *type, ULONGEST num)
42638 + struct value *val = allocate_value (type);
42640 + pack_unsigned_long (value_contents_raw (val), type, num);
42646 /* Create a value representing a pointer of type TYPE to the address
42649 @@ -1816,8 +2028,9 @@ value_from_contents_and_address (struct type *type,
42650 set_value_lazy (v, 1);
42652 memcpy (value_contents_raw (v), valaddr, TYPE_LENGTH (type));
42653 - VALUE_ADDRESS (v) = address;
42654 - VALUE_LVAL (v) = lval_memory;
42655 + set_value_address (v, address);
42656 + if (address != 0)
42657 + VALUE_LVAL (v) = lval_memory;
42661 @@ -1944,4 +2157,15 @@ init-if-undefined VARIABLE = EXPRESSION\n\
42662 Set an internal VARIABLE to the result of the EXPRESSION if it does not\n\
42663 exist or does not contain a value. The EXPRESSION is not evaluated if the\n\
42664 VARIABLE is already initialized."));
42666 + add_prefix_cmd ("function", no_class, function_command, _("\
42667 +Placeholder command for showing help on convenience functions."),
42668 + &functionlist, "function ", 0, &cmdlist);
42670 + internal_fn_type = alloc_type (OBJFILE_INTERNAL, NULL);
42671 + TYPE_CODE (internal_fn_type) = TYPE_CODE_INTERNAL_FUNCTION;
42672 + TYPE_LENGTH (internal_fn_type) = sizeof (struct internal_function *);
42673 + TYPE_NAME (internal_fn_type) = "<internal function>";
42675 + make_final_cleanup (value_history_cleanup, NULL);
42677 diff --git a/gdb/value.h b/gdb/value.h
42678 index aa43365..1ad3c75 100644
42681 @@ -272,12 +272,23 @@ extern void set_value_component_location (struct value *component,
42682 extern enum lval_type *deprecated_value_lval_hack (struct value *);
42683 #define VALUE_LVAL(val) (*deprecated_value_lval_hack (val))
42685 -/* If lval == lval_memory, this is the address in the inferior. If
42686 - lval == lval_register, this is the byte offset into the registers
42688 +/* Backward compatibility for the Fedora merge branch. */
42689 extern CORE_ADDR *deprecated_value_address_hack (struct value *);
42690 #define VALUE_ADDRESS(val) (*deprecated_value_address_hack (val))
42692 +/* If lval == lval_memory, return the address in the inferior. If
42693 + lval == lval_register, return the byte offset into the registers
42694 + structure. Otherwise, return 0. The returned address
42695 + includes the offset, if any. */
42696 +extern CORE_ADDR value_address (struct value *);
42698 +/* Like value_address, except the result does not include value's
42700 +extern CORE_ADDR value_raw_address (struct value *);
42702 +/* Set the address of a value. */
42703 +extern void set_value_address (struct value *, CORE_ADDR);
42705 /* Pointer to internal variable. */
42706 extern struct internalvar **deprecated_value_internalvar_hack (struct value *);
42707 #define VALUE_INTERNALVAR(val) (*deprecated_value_internalvar_hack (val))
42708 @@ -314,6 +325,9 @@ struct internalvar
42709 struct value *value;
42710 internalvar_make_value make_value;
42712 + /* True if this internalvar is the canonical name for a convenience
42718 @@ -342,12 +356,17 @@ extern LONGEST unpack_field_as_long (struct type *type,
42719 extern void pack_long (gdb_byte *buf, struct type *type, LONGEST num);
42721 extern struct value *value_from_longest (struct type *type, LONGEST num);
42722 +extern struct value *value_from_ulongest (struct type *type, ULONGEST num);
42723 extern struct value *value_from_pointer (struct type *type, CORE_ADDR addr);
42724 extern struct value *value_from_double (struct type *type, DOUBLEST num);
42725 extern struct value *value_from_decfloat (struct type *type,
42726 const gdb_byte *decbytes);
42727 extern struct value *value_from_string (char *string);
42729 +extern const char *object_address_data_not_valid (struct type *type);
42730 +extern int object_address_get_data (struct type *type,
42731 + CORE_ADDR *address_return);
42733 extern struct value *value_at (struct type *type, CORE_ADDR addr);
42734 extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
42736 @@ -388,6 +407,8 @@ extern struct value *value_mark (void);
42738 extern void value_free_to_mark (struct value *mark);
42740 +extern struct value *value_typed_string (char *ptr, int len,
42741 + struct type *char_type);
42742 extern struct value *value_string (char *ptr, int len);
42743 extern struct value *value_bitstring (char *ptr, int len);
42745 @@ -435,6 +456,7 @@ extern struct value *value_struct_elt (struct value **argp,
42747 extern struct value *value_aggregate_elt (struct type *curtype,
42749 + struct type *expect_type,
42751 enum noside noside);
42753 @@ -533,14 +555,14 @@ extern void set_internalvar_component (struct internalvar *var,
42754 int bitpos, int bitsize,
42755 struct value *newvalue);
42757 -extern struct internalvar *lookup_only_internalvar (char *name);
42758 +extern struct internalvar *lookup_only_internalvar (const char *name);
42760 -extern struct internalvar *create_internalvar (char *name);
42761 +extern struct internalvar *create_internalvar (const char *name);
42763 extern struct internalvar *
42764 create_internalvar_type_lazy (char *name, internalvar_make_value fun);
42766 -extern struct internalvar *lookup_internalvar (char *name);
42767 +extern struct internalvar *lookup_internalvar (const char *name);
42769 extern int value_equal (struct value *arg1, struct value *arg2);
42771 @@ -619,7 +641,7 @@ extern int common_val_print (struct value *val,
42772 const struct value_print_options *options,
42773 const struct language_defn *language);
42775 -extern int val_print_string (CORE_ADDR addr, int len, int width,
42776 +extern int val_print_string (struct type *elttype, CORE_ADDR addr, int len,
42777 struct ui_file *stream,
42778 const struct value_print_options *options);
42780 @@ -658,5 +680,22 @@ extern struct value *value_allocate_space_in_inferior (int);
42782 extern struct value *value_of_local (const char *name, int complain);
42784 -extern struct value * value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound);
42785 +extern struct value *value_subscripted_rvalue (struct value *array,
42786 + CORE_ADDR offset);
42788 +/* User function handler. */
42790 +typedef struct value *(*internal_function_fn) (void *cookie,
42792 + struct value **argv);
42794 +void add_internal_function (const char *name, const char *doc,
42795 + internal_function_fn handler,
42798 +struct value *call_internal_function (struct value *function,
42799 + int argc, struct value **argv);
42801 +char *value_internal_function_name (struct value *);
42803 #endif /* !defined (VALUE_H) */
42804 diff --git a/gdb/varobj.c b/gdb/varobj.c
42805 index 2ec6d90..1237c96 100644
42808 @@ -29,11 +29,20 @@
42810 #include "gdb_assert.h"
42811 #include "gdb_string.h"
42812 +#include "gdb_regex.h"
42814 #include "varobj.h"
42816 #include "gdbthread.h"
42817 #include "inferior.h"
42818 +#include "valprint.h"
42821 +#include "python/python.h"
42822 +#include "python/python-internal.h"
42824 +typedef int PyObject;
42827 /* Non-zero if we want to see trace of varobj level stuff. */
42829 @@ -138,6 +147,12 @@ struct varobj
42830 /* Children of this object. */
42831 VEC (varobj_p) *children;
42833 + /* Whether the children of this varobj were requested. This field is
42834 + used to decide if dynamic varobj should recompute their children.
42835 + In the event that the frontend never asked for the children, we
42836 + can avoid that. */
42837 + int children_requested;
42839 /* Description of the root variable. Points to root variable for children. */
42840 struct varobj_root *root;
42842 @@ -159,6 +174,16 @@ struct varobj
42843 not fetched if either the variable is frozen, or any parents is
42847 + /* Sub-range of children which the MI consumer has requested. If
42848 + FROM < 0 or TO < 0, means that all children have been
42853 + /* The pretty-printer that has been constructed. If NULL, then a
42854 + new printer object is needed, and one will be constructed. */
42855 + PyObject *pretty_printer;
42859 @@ -190,6 +215,10 @@ static void uninstall_variable (struct varobj *);
42861 static struct varobj *create_child (struct varobj *, int, char *);
42863 +static struct varobj *
42864 +create_child_with_value (struct varobj *parent, int index, const char *name,
42865 + struct value *value);
42867 /* Utility routines */
42869 static struct varobj *new_variable (void);
42870 @@ -200,6 +229,8 @@ static void free_variable (struct varobj *var);
42872 static struct cleanup *make_cleanup_free_variable (struct varobj *var);
42874 +static struct cleanup *make_cleanup_uninstall_variable (struct varobj *var);
42876 static struct type *get_type (struct varobj *var);
42878 static struct type *get_value_type (struct varobj *var);
42879 @@ -215,6 +246,8 @@ static char *cppop (struct cpstack **pstack);
42880 static int install_new_value (struct varobj *var, struct value *value,
42883 +static void install_default_visualizer (struct varobj *var);
42885 /* Language-specific routines. */
42887 static enum varobj_languages variable_language (struct varobj *var);
42888 @@ -232,13 +265,17 @@ static struct value *value_of_child (struct varobj *parent, int index);
42889 static char *my_value_of_variable (struct varobj *var,
42890 enum varobj_display_formats format);
42892 -static char *value_get_print_value (struct value *value,
42893 - enum varobj_display_formats format);
42894 +char *value_get_print_value (struct value *value,
42895 + enum varobj_display_formats format,
42896 + PyObject *value_formatter);
42898 static int varobj_value_is_changeable_p (struct varobj *var);
42900 static int is_root_p (struct varobj *var);
42902 +static struct varobj *
42903 +varobj_add_child (struct varobj *var, const char *name, struct value *value);
42905 /* C implementation */
42907 static int c_number_of_children (struct varobj *var);
42908 @@ -570,8 +607,10 @@ varobj_create (char *objname,
42909 do_cleanups (old_chain);
42912 + make_cleanup_uninstall_variable (var);
42915 + install_default_visualizer (var);
42916 discard_cleanups (old_chain);
42919 @@ -678,6 +717,33 @@ varobj_delete (struct varobj *var, char ***dellist, int only_children)
42923 +/* Convenience function for varobj_set_visualizer. Instantiate a
42924 + pretty-printer for a given value. */
42926 +instantiate_pretty_printer (PyObject *constructor, struct value *value)
42929 + PyObject *val_obj = NULL;
42930 + PyObject *printer;
42931 + volatile struct gdb_exception except;
42933 + TRY_CATCH (except, RETURN_MASK_ALL)
42935 + value = value_copy (value);
42937 + GDB_PY_HANDLE_EXCEPTION (except);
42938 + val_obj = value_to_value_object (value);
42943 + printer = gdbpy_instantiate_printer (constructor, val_obj);
42944 + Py_DECREF (val_obj);
42950 /* Set/Get variable object display format */
42952 enum varobj_display_formats
42953 @@ -702,7 +768,8 @@ varobj_set_display_format (struct varobj *var,
42954 && var->value && !value_lazy (var->value))
42956 xfree (var->print_value);
42957 - var->print_value = value_get_print_value (var->value, var->format);
42958 + var->print_value = value_get_print_value (var->value, var->format,
42959 + var->pretty_printer);
42962 return var->format;
42963 @@ -714,6 +781,21 @@ varobj_get_display_format (struct varobj *var)
42964 return var->format;
42968 +varobj_get_display_hint (struct varobj *var)
42970 + char *result = NULL;
42973 + PyGILState_STATE state = PyGILState_Ensure ();
42974 + if (var->pretty_printer)
42975 + result = gdbpy_get_display_hint (var->pretty_printer);
42976 + PyGILState_Release (state);
42982 /* If the variable object is bound to a specific thread, that
42983 is its evaluation can always be done in context of a frame
42984 inside that thread, returns GDB id of the thread -- which
42985 @@ -746,12 +828,141 @@ varobj_get_frozen (struct varobj *var)
42986 return var->frozen;
42990 +update_dynamic_varobj_children (struct varobj *var,
42991 + VEC (varobj_p) **changed,
42992 + VEC (varobj_p) **new_and_unchanged,
42997 + /* FIXME: we *might* want to provide this functionality as
42998 + a standalone function, so that other interested parties
42999 + than varobj code can benefit for this. */
43000 + struct cleanup *back_to;
43001 + PyObject *children;
43002 + PyObject *iterator;
43004 + int children_changed = 0;
43005 + PyObject *printer = var->pretty_printer;
43006 + PyGILState_STATE state;
43008 + state = PyGILState_Ensure ();
43009 + back_to = make_cleanup_py_restore_gil (&state);
43012 + if (!PyObject_HasAttr (printer, gdbpy_children_cst))
43014 + do_cleanups (back_to);
43018 + children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
43023 + gdbpy_print_stack ();
43024 + error ("Null value returned for children");
43027 + make_cleanup_py_decref (children);
43029 + if (!PyIter_Check (children))
43030 + error ("Returned value is not iterable");
43032 + iterator = PyObject_GetIter (children);
43035 + gdbpy_print_stack ();
43036 + error ("Could not get children iterator");
43038 + make_cleanup_py_decref (iterator);
43040 + for (i = 0; ; ++i)
43042 + PyObject *item = PyIter_Next (iterator);
43046 + struct cleanup *inner;
43050 + inner = make_cleanup_py_decref (item);
43052 + if (!PyArg_ParseTuple (item, "sO", &name, &py_v))
43053 + error ("Invalid item from the child list");
43055 + if (PyObject_TypeCheck (py_v, &value_object_type))
43057 + /* If we just call convert_value_from_python for this type,
43058 + we won't know who owns the result. For this one case we
43059 + need to copy the resulting value. */
43060 + v = value_object_to_value (py_v);
43061 + v = value_copy (v);
43064 + v = convert_value_from_python (py_v);
43066 + /* TODO: This assume the name of the i-th child never changes. */
43068 + /* Now see what to do here. */
43069 + if (VEC_length (varobj_p, var->children) < i + 1)
43071 + /* There's no child yet. */
43072 + struct varobj *child = varobj_add_child (var, name, v);
43073 + if (new_and_unchanged)
43074 + VEC_safe_push (varobj_p, *new_and_unchanged, child);
43075 + children_changed = 1;
43079 + varobj_p existing = VEC_index (varobj_p, var->children, i);
43080 + if (install_new_value (existing, v, 0) && changed)
43083 + VEC_safe_push (varobj_p, *changed, existing);
43087 + if (new_and_unchanged)
43088 + VEC_safe_push (varobj_p, *new_and_unchanged, existing);
43092 + do_cleanups (inner);
43095 + if (i < VEC_length (varobj_p, var->children))
43098 + children_changed = 1;
43099 + for (i = 0; i < VEC_length (varobj_p, var->children); ++i)
43100 + varobj_delete (VEC_index (varobj_p, var->children, i), NULL, 0);
43102 + VEC_truncate (varobj_p, var->children, i);
43103 + var->num_children = VEC_length (varobj_p, var->children);
43105 + do_cleanups (back_to);
43107 + *cchanged = children_changed;
43110 + gdb_assert (0 && "should never be called if Python is not enabled");
43115 varobj_get_num_children (struct varobj *var)
43117 if (var->num_children == -1)
43118 - var->num_children = number_of_children (var);
43121 + if (!var->pretty_printer
43122 + || !update_dynamic_varobj_children (var, NULL, NULL, &changed))
43123 + var->num_children = number_of_children (var);
43126 return var->num_children;
43128 @@ -764,7 +975,16 @@ varobj_list_children (struct varobj *var)
43130 struct varobj *child;
43133 + int i, children_changed;
43135 + var->children_requested = 1;
43137 + if (var->pretty_printer
43138 + /* This, in theory, can result in the number of children changing without
43139 + frontend noticing. But well, calling -var-list-children on the same
43140 + varobj twice is not something a sane frontend would do. */
43141 + && update_dynamic_varobj_children (var, NULL, NULL, &children_changed))
43142 + return var->children;
43144 if (var->num_children == -1)
43145 var->num_children = number_of_children (var);
43146 @@ -790,12 +1010,24 @@ varobj_list_children (struct varobj *var)
43147 name = name_of_child (var, i);
43148 existing = create_child (var, i, name);
43149 VEC_replace (varobj_p, var->children, i, existing);
43150 + install_default_visualizer (existing);
43154 return var->children;
43157 +static struct varobj *
43158 +varobj_add_child (struct varobj *var, const char *name, struct value *value)
43160 + varobj_p v = create_child_with_value (var,
43161 + VEC_length (varobj_p, var->children),
43163 + VEC_safe_push (varobj_p, var->children, v);
43164 + install_default_visualizer (v);
43168 /* Obtain the type of an object Variable as a string similar to the one gdb
43169 prints on the console */
43171 @@ -1002,6 +1234,13 @@ install_new_value (struct varobj *var, struct value *value, int initial)
43173 gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
43174 changeable = varobj_value_is_changeable_p (var);
43176 + /* If the type has custom visualizer, we consider it to be always
43177 + changeable. FIXME: need to make sure this behaviour will not
43178 + mess up read-sensitive values. */
43179 + if (var->pretty_printer)
43182 need_to_fetch = changeable;
43184 /* We are not interested in the address of references, and given
43185 @@ -1053,12 +1292,14 @@ install_new_value (struct varobj *var, struct value *value, int initial)
43190 /* Below, we'll be comparing string rendering of old and new
43191 values. Don't get string rendering if the value is
43192 lazy -- if it is, the code above has decided that the value
43193 should not be fetched. */
43194 if (value && !value_lazy (value))
43195 - print_value = value_get_print_value (value, var->format);
43196 + print_value = value_get_print_value (value, var->format,
43197 + var->pretty_printer);
43199 /* If the type is changeable, compare the old and the new values.
43200 If this is the initial assignment, we don't have any old value
43201 @@ -1123,6 +1364,150 @@ install_new_value (struct varobj *var, struct value *value, int initial)
43205 +/* Return the effective requested range for a varobj. VAR is the
43206 + varobj. CHILDREN is the computed list of children. FROM and TO
43207 + are out parameters. If VAR has no bounds selected, *FROM and *TO
43208 + will be set to the full range of CHILDREN. Otherwise, *FROM and
43209 + *TO will be set to the selected sub-range of VAR, clipped to be in
43210 + range of CHILDREN. */
43212 +varobj_get_child_range (struct varobj *var, VEC (varobj_p) *children,
43213 + int *from, int *to)
43215 + if (var->from < 0 || var->to < 0)
43218 + *to = VEC_length (varobj_p, children);
43222 + *from = var->from;
43223 + if (*from > VEC_length (varobj_p, children))
43224 + *from = VEC_length (varobj_p, children);
43226 + if (*to > VEC_length (varobj_p, children))
43227 + *to = VEC_length (varobj_p, children);
43231 +/* Set the selected sub-range of children of VAR to start at index
43232 + FROM and end at index TO. If either FROM or TO is less than zero,
43233 + this is interpreted as a request for all children. */
43235 +varobj_set_child_range (struct varobj *var, int from, int to)
43237 + var->from = from;
43242 +install_visualizer (struct varobj *var, PyObject *visualizer)
43245 + /* If there are any children now, wipe them. */
43246 + varobj_delete (var, NULL, 1 /* children only */);
43247 + var->num_children = -1;
43249 + Py_XDECREF (var->pretty_printer);
43250 + var->pretty_printer = visualizer;
43252 + install_new_value (var, var->value, 1);
43254 + /* If we removed the visualizer, and the user ever requested the
43255 + object's children, then we must compute the list of children.
43256 + Note that we needn't do this when installing a visualizer,
43257 + because updating will recompute dynamic children. */
43258 + if (!visualizer && var->children_requested)
43259 + varobj_list_children (var);
43261 + error ("Python support required");
43266 +install_default_visualizer (struct varobj *var)
43269 + struct cleanup *cleanup;
43270 + PyGILState_STATE state;
43271 + PyObject *pretty_printer = NULL;
43273 + state = PyGILState_Ensure ();
43274 + cleanup = make_cleanup_py_restore_gil (&state);
43278 + pretty_printer = gdbpy_get_varobj_pretty_printer (var->value);
43279 + if (! pretty_printer)
43281 + gdbpy_print_stack ();
43282 + error (_("Cannot instantiate printer for default visualizer"));
43286 + if (pretty_printer == Py_None)
43288 + Py_DECREF (pretty_printer);
43289 + pretty_printer = NULL;
43292 + install_visualizer (var, pretty_printer);
43293 + do_cleanups (cleanup);
43295 + /* No error is right as this function is inserted just as a hook. */
43300 +varobj_set_visualizer (struct varobj *var, const char *visualizer)
43303 + PyObject *mainmod, *globals, *pretty_printer, *constructor;
43304 + struct cleanup *back_to, *value;
43305 + PyGILState_STATE state;
43308 + state = PyGILState_Ensure ();
43309 + back_to = make_cleanup_py_restore_gil (&state);
43311 + mainmod = PyImport_AddModule ("__main__");
43312 + globals = PyModule_GetDict (mainmod);
43313 + Py_INCREF (globals);
43314 + make_cleanup_py_decref (globals);
43316 + constructor = PyRun_String (visualizer, Py_eval_input, globals, globals);
43318 + /* Do not instantiate NoneType. */
43319 + if (constructor == Py_None)
43321 + pretty_printer = Py_None;
43322 + Py_INCREF (pretty_printer);
43325 + pretty_printer = instantiate_pretty_printer (constructor, var->value);
43327 + Py_XDECREF (constructor);
43329 + if (! pretty_printer)
43331 + gdbpy_print_stack ();
43332 + error ("Could not evaluate visualizer expression: %s", visualizer);
43335 + if (pretty_printer == Py_None)
43337 + Py_DECREF (pretty_printer);
43338 + pretty_printer = NULL;
43341 + install_visualizer (var, pretty_printer);
43343 + do_cleanups (back_to);
43345 + error ("Python support required");
43349 /* Update the values for a variable and its children. This is a
43350 two-pronged attack. First, re-parse the value for the root's
43351 expression to see if it's changed. Then go all the way
43352 @@ -1148,7 +1533,7 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
43353 struct varobj **cv;
43354 struct varobj **templist = NULL;
43356 - VEC (varobj_p) *stack = NULL;
43357 + VEC (varobj_update_result) *stack = NULL;
43358 VEC (varobj_update_result) *result = NULL;
43359 struct frame_info *fi;
43361 @@ -1187,20 +1572,85 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
43364 r.status = VAROBJ_NOT_IN_SCOPE;
43366 - if (r.type_changed || r.changed)
43367 - VEC_safe_push (varobj_update_result, result, &r);
43368 + r.value_installed = 1;
43370 if (r.status == VAROBJ_NOT_IN_SCOPE)
43373 + VEC_safe_push (varobj_update_result, result, &r);
43377 + VEC_safe_push (varobj_update_result, stack, &r);
43381 + varobj_update_result r = {*varp};
43382 + VEC_safe_push (varobj_update_result, stack, &r);
43385 - VEC_safe_push (varobj_p, stack, *varp);
43387 /* Walk through the children, reconstructing them all. */
43388 - while (!VEC_empty (varobj_p, stack))
43389 + while (!VEC_empty (varobj_update_result, stack))
43391 - v = VEC_pop (varobj_p, stack);
43392 + varobj_update_result r = *(VEC_last (varobj_update_result, stack));
43393 + struct varobj *v = r.varobj;
43395 + VEC_pop (varobj_update_result, stack);
43397 + /* Update this variable, unless it's a root, which is already
43399 + if (!r.value_installed)
43401 + new = value_of_child (v->parent, v->index);
43402 + if (install_new_value (v, new, 0 /* type not changed */))
43409 + /* We probably should not get children of a varobj that has a
43410 + pretty-printer, but for which -var-list-children was never
43411 + invoked. Presumably, such varobj is not yet expanded in the
43412 + UI, so we need not bother getting it. */
43413 + if (v->pretty_printer)
43415 + VEC (varobj_p) *changed = 0, *new_and_unchanged = 0;
43416 + int i, children_changed;
43419 + if (!v->children_requested)
43425 + /* If update_dynamic_varobj_children returns 0, then we have
43426 + a non-conforming pretty-printer, so we skip it. */
43427 + if (update_dynamic_varobj_children (v, &changed, &new_and_unchanged,
43428 + &children_changed))
43430 + if (children_changed)
43431 + r.children_changed = 1;
43432 + for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i)
43434 + varobj_update_result r = {tmp};
43436 + r.value_installed = 1;
43437 + VEC_safe_push (varobj_update_result, stack, &r);
43440 + VEC_iterate (varobj_p, new_and_unchanged, i, tmp);
43443 + varobj_update_result r = {tmp};
43444 + r.value_installed = 1;
43445 + VEC_safe_push (varobj_update_result, stack, &r);
43447 + if (r.changed || r.children_changed)
43448 + VEC_safe_push (varobj_update_result, result, &r);
43453 /* Push any children. Use reverse order so that the first
43454 child is popped from the work stack first, and so
43455 @@ -1211,26 +1661,18 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
43456 varobj_p c = VEC_index (varobj_p, v->children, i);
43457 /* Child may be NULL if explicitly deleted by -var-delete. */
43458 if (c != NULL && !c->frozen)
43459 - VEC_safe_push (varobj_p, stack, c);
43462 - /* Update this variable, unless it's a root, which is already
43464 - if (v->root->rootvar != v)
43466 - new = value_of_child (v->parent, v->index);
43467 - if (install_new_value (v, new, 0 /* type not changed */))
43469 - /* Note that it's changed */
43470 - varobj_update_result r = {v};
43472 - VEC_safe_push (varobj_update_result, result, &r);
43474 + varobj_update_result r = {c};
43475 + VEC_safe_push (varobj_update_result, stack, &r);
43479 + if (r.changed || r.type_changed)
43480 + VEC_safe_push (varobj_update_result, result, &r);
43483 - VEC_free (varobj_p, stack);
43484 + VEC_free (varobj_update_result, stack);
43489 @@ -1429,16 +1871,23 @@ uninstall_variable (struct varobj *var)
43490 static struct varobj *
43491 create_child (struct varobj *parent, int index, char *name)
43493 + return create_child_with_value (parent, index, name,
43494 + value_of_child (parent, index));
43497 +static struct varobj *
43498 +create_child_with_value (struct varobj *parent, int index, const char *name,
43499 + struct value *value)
43501 struct varobj *child;
43503 - struct value *value;
43505 child = new_variable ();
43507 /* name is allocated by name_of_child */
43508 - child->name = name;
43509 + /* FIXME: xstrdup should not be here. */
43510 + child->name = xstrdup (name);
43511 child->index = index;
43512 - value = value_of_child (parent, index);
43513 child->parent = parent;
43514 child->root = parent->root;
43515 childs_name = xstrprintf ("%s.%s", parent->obj_name, name);
43516 @@ -1487,6 +1936,10 @@ new_variable (void)
43517 var->print_value = NULL;
43519 var->not_fetched = 0;
43520 + var->children_requested = 0;
43523 + var->pretty_printer = 0;
43527 @@ -1519,6 +1972,14 @@ free_variable (struct varobj *var)
43533 + PyGILState_STATE state = PyGILState_Ensure ();
43534 + Py_XDECREF (var->pretty_printer);
43535 + PyGILState_Release (state);
43540 xfree (var->obj_name);
43541 xfree (var->print_value);
43542 @@ -1538,6 +1999,18 @@ make_cleanup_free_variable (struct varobj *var)
43543 return make_cleanup (do_free_variable_cleanup, var);
43547 +do_uninstall_variable_cleanup (void *var)
43549 + uninstall_variable (var);
43552 +static struct cleanup *
43553 +make_cleanup_uninstall_variable (struct varobj *var)
43555 + return make_cleanup (do_uninstall_variable_cleanup, var);
43558 /* This returns the type of the variable. It also skips past typedefs
43559 to return the real type of the variable.
43561 @@ -1792,24 +2265,71 @@ my_value_of_variable (struct varobj *var, enum varobj_display_formats format)
43566 -value_get_print_value (struct value *value, enum varobj_display_formats format)
43568 +value_get_print_value (struct value *value, enum varobj_display_formats format,
43569 + PyObject *value_formatter)
43572 struct ui_file *stb;
43573 struct cleanup *old_chain;
43575 + char *thevalue = NULL;
43576 struct value_print_options opts;
43583 + PyGILState_STATE state = PyGILState_Ensure ();
43584 + if (value_formatter && PyObject_HasAttr (value_formatter,
43585 + gdbpy_to_string_cst))
43588 + struct value *replacement;
43589 + int string_print = 0;
43591 + hint = gdbpy_get_display_hint (value_formatter);
43594 + if (!strcmp (hint, "string"))
43595 + string_print = 1;
43599 + thevalue = apply_varobj_pretty_printer (value_formatter,
43601 + if (thevalue && !string_print)
43603 + PyGILState_Release (state);
43607 + value = replacement;
43609 + PyGILState_Release (state);
43613 stb = mem_fileopen ();
43614 old_chain = make_cleanup_ui_file_delete (stb);
43616 get_formatted_print_options (&opts, format_code[(int) format]);
43617 opts.deref_ref = 0;
43618 - common_val_print (value, stb, 0, &opts, current_language);
43622 + struct type *string_char_type;
43624 + make_cleanup (xfree, thevalue);
43626 + /* OUTPUT is already in the hosts's charset. */
43627 + string_char_type = language_string_char_type (current_language,
43628 + current_gdbarch);
43629 + LA_PRINT_STRING (stb, string_char_type, (gdb_byte *) thevalue,
43630 + strlen (thevalue), 0, &opts);
43633 + common_val_print (value, stb, 0, &opts, current_language);
43634 thevalue = ui_file_xstrdup (stb, &dummy);
43636 do_cleanups (old_chain);
43637 @@ -1900,7 +2420,7 @@ varobj_floating_p (struct varobj *var)
43638 value is not known.
43640 If WAS_PTR is not NULL, set *WAS_PTR to 0 or 1
43641 - depending on whether pointer was deferenced
43642 + depending on whether pointer was dereferenced
43643 in this function. */
43645 adjust_value_for_child_access (struct value **value,
43646 @@ -2269,6 +2789,11 @@ c_value_of_variable (struct varobj *var, enum varobj_display_formats format)
43647 catch that case explicitly. */
43648 struct type *type = get_type (var);
43650 + /* If we have a custom formatter, return whatever string it has
43652 + if (var->pretty_printer && var->print_value)
43653 + return xstrdup (var->print_value);
43655 /* Strip top-level references. */
43656 while (TYPE_CODE (type) == TYPE_CODE_REF)
43657 type = check_typedef (TYPE_TARGET_TYPE (type));
43658 @@ -2313,7 +2838,8 @@ c_value_of_variable (struct varobj *var, enum varobj_display_formats format)
43659 if (format == var->format)
43660 return xstrdup (var->print_value);
43662 - return value_get_print_value (var->value, format);
43663 + return value_get_print_value (var->value, format,
43664 + var->pretty_printer);
43668 diff --git a/gdb/varobj.h b/gdb/varobj.h
43669 index f2cdcf8..10758d6 100644
43672 @@ -72,7 +72,12 @@ typedef struct varobj_update_result_t
43673 struct varobj *varobj;
43676 + int children_changed;
43677 enum varobj_scope_status status;
43678 + /* This variable is used internally by varobj_update to indicate if the
43679 + new value of varobj is already computed and installed, or has to
43680 + be yet installed. Don't use this outside varobj.c */
43681 + int value_installed;
43682 } varobj_update_result;
43684 DEF_VEC_O (varobj_update_result);
43685 @@ -107,6 +112,14 @@ extern void varobj_set_frozen (struct varobj *var, int frozen);
43687 extern int varobj_get_frozen (struct varobj *var);
43689 +extern void varobj_get_child_range (struct varobj *var,
43690 + VEC (varobj_p) *children,
43691 + int *from, int *to);
43693 +extern void varobj_set_child_range (struct varobj *var, int from, int to);
43695 +extern char *varobj_get_display_hint (struct varobj *var);
43697 extern int varobj_get_num_children (struct varobj *var);
43699 /* Return the list of children of VAR. The returned vector
43700 @@ -141,4 +154,13 @@ extern int varobj_editable_p (struct varobj *var);
43702 extern int varobj_floating_p (struct varobj *var);
43705 +varobj_set_visualizer (struct varobj *var, const char *visualizer);
43708 +varobj_clear_type_visualizers ();
43711 +varobj_set_visualizer (struct varobj *var, const char *visualizer);
43713 #endif /* VAROBJ_H */
43714 diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
43715 index aab3e48..d41738b 100644
43716 --- a/gdb/xcoffread.c
43717 +++ b/gdb/xcoffread.c
43718 @@ -3021,6 +3021,7 @@ static struct sym_fns xcoff_sym_fns =
43719 xcoff_new_init, /* sym_new_init: init anything gbl to entire symtab */
43720 xcoff_symfile_init, /* sym_init: read initial info, setup for sym_read() */
43721 xcoff_initial_scan, /* sym_read: read a symbol file into symtab */
43722 + NULL, /* sym_read_psymbols */
43723 xcoff_symfile_finish, /* sym_finish: finished with file, cleanup */
43724 xcoff_symfile_offsets, /* sym_offsets: xlate offsets ext->int form */
43725 default_symfile_segments, /* sym_segments: Get segment information from
43726 diff --git a/gdb/xml-syscall.c b/gdb/xml-syscall.c
43727 new file mode 100644
43728 index 0000000..498f58a
43730 +++ b/gdb/xml-syscall.c
43732 +/* Functions that provide the mechanism to parse a syscall XML file
43733 + and get its values.
43735 + Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
43736 + 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
43737 + Free Software Foundation, Inc.
43739 + This file is part of GDB.
43741 + This program is free software; you can redistribute it and/or modify
43742 + it under the terms of the GNU General Public License as published by
43743 + the Free Software Foundation; either version 3 of the License, or
43744 + (at your option) any later version.
43746 + This program is distributed in the hope that it will be useful,
43747 + but WITHOUT ANY WARRANTY; without even the implied warranty of
43748 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43749 + GNU General Public License for more details.
43751 + You should have received a copy of the GNU General Public License
43752 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
43755 +#include "gdbtypes.h"
43756 +#include "xml-support.h"
43757 +#include "xml-syscall.h"
43759 +#include "filenames.h"
43761 +#include "gdb_assert.h"
43763 +#ifndef HAVE_LIBEXPAT
43765 +/* Dummy functions to indicate that there's no support for fetching
43766 + syscalls information. */
43769 +syscall_warn_user (void)
43771 + static int have_warned = 0;
43772 + if (!have_warned)
43775 + warning (_("Can not parse XML syscalls information; XML support was "
43776 + "disabled at compile time"));
43780 +const struct syscalls_info *
43781 +xml_init_syscalls_info (const char *filename)
43783 + syscall_warn_user ();
43788 +xml_get_syscall_number (const struct syscalls_info *sysinfo,
43789 + const char *syscall_name)
43791 + syscall_warn_user ();
43792 + return UNKNOWN_SYSCALL;
43796 +xml_get_syscall_name (const struct syscalls_info *sysinfo,
43797 + int syscall_number)
43799 + syscall_warn_user ();
43804 +xml_number_of_syscalls (const struct syscalls_info *sysinfo)
43806 + syscall_warn_user ();
43811 +xml_list_of_syscalls (const struct syscalls_info *sysinfo)
43813 + syscall_warn_user ();
43819 +/* Structure which describes a syscall. */
43821 +typedef struct syscall_desc
43823 + /* The syscall number. */
43827 + /* The syscall name. */
43830 +} *syscall_desc_p;
43831 +DEF_VEC_P(syscall_desc_p);
43833 +/* Structure that represents syscalls information. */
43835 +struct syscalls_info
43837 + /* The syscalls. */
43839 + VEC(syscall_desc_p) *syscalls;
43842 +/* Callback data for syscall information parsing. */
43844 +struct syscall_parsing_data
43846 + /* The syscalls_info we are building. */
43848 + struct syscalls_info *sysinfo;
43852 +static struct syscalls_info *
43853 +allocate_syscalls_info (void)
43855 + return XZALLOC (struct syscalls_info);
43859 +sysinfo_free_syscalls_desc (struct syscall_desc *sd)
43861 + xfree (sd->name);
43865 +free_syscalls_info (void *arg)
43867 + struct syscalls_info *sysinfo = arg;
43868 + struct syscall_desc *sysdesc;
43872 + VEC_iterate (syscall_desc_p, sysinfo->syscalls, i, sysdesc);
43874 + sysinfo_free_syscalls_desc (sysdesc);
43875 + VEC_free (syscall_desc_p, sysinfo->syscalls);
43881 +make_cleanup_free_syscalls_info (struct syscalls_info *sysinfo)
43883 + return make_cleanup (free_syscalls_info, sysinfo);
43886 +/* Open FILENAME, read all its text into memory, close it, and return
43887 + the text. If something goes wrong, return NULL and warn. */
43890 +fetch_xml_from_file (const char *filename, void *baton)
43892 + const char *dirname = baton;
43894 + struct cleanup *back_to;
43896 + size_t len, offset;
43898 + if (dirname && *dirname)
43900 + char *fullname = concat (dirname, "/", filename, (char *) NULL);
43901 + if (fullname == NULL)
43903 + file = fopen (fullname, FOPEN_RT);
43904 + xfree (fullname);
43907 + file = fopen (filename, FOPEN_RT);
43909 + if (file == NULL)
43912 + back_to = make_cleanup_fclose (file);
43914 + /* Read in the whole file, one chunk at a time. */
43917 + text = xmalloc (len);
43918 + make_cleanup (free_current_contents, &text);
43921 + size_t bytes_read;
43923 + /* Continue reading where the last read left off. Leave at least
43924 + one byte so that we can NUL-terminate the result. */
43925 + bytes_read = fread (text + offset, 1, len - offset - 1, file);
43926 + if (ferror (file))
43928 + warning (_("Read error from \"%s\""), filename);
43929 + do_cleanups (back_to);
43933 + offset += bytes_read;
43939 + text = xrealloc (text, len);
43943 + discard_cleanups (back_to);
43945 + text[offset] = '\0';
43950 +syscall_create_syscall_desc (struct syscalls_info *sysinfo,
43951 + const char *name, int number)
43953 + struct syscall_desc *sysdesc = XZALLOC (struct syscall_desc);
43955 + sysdesc->name = xstrdup (name);
43956 + sysdesc->number = number;
43958 + VEC_safe_push (syscall_desc_p, sysinfo->syscalls, sysdesc);
43961 +/* Handle the start of a <syscalls_info> element. */
43964 +syscall_start_syscalls_info (struct gdb_xml_parser *parser,
43965 + const struct gdb_xml_element *element,
43967 + VEC(gdb_xml_value_s) *attributes)
43969 + struct syscall_parsing_data *data = user_data;
43970 + struct syscalls_info *sysinfo = data->sysinfo;
43973 +/* Handle the start of a <syscall> element. */
43976 +syscall_start_syscall (struct gdb_xml_parser *parser,
43977 + const struct gdb_xml_element *element,
43978 + void *user_data, VEC(gdb_xml_value_s) *attributes)
43980 + struct syscall_parsing_data *data = user_data;
43981 + struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes);
43983 + /* syscall info. */
43984 + char *name = NULL;
43987 + len = VEC_length (gdb_xml_value_s, attributes);
43989 + for (i = 0; i < len; i++)
43991 + if (strcmp (attrs[i].name, "name") == 0)
43992 + name = attrs[i].value;
43993 + else if (strcmp (attrs[i].name, "number") == 0)
43994 + number = * (ULONGEST *) attrs[i].value;
43996 + internal_error (__FILE__, __LINE__,
43997 + _("Unknown attribute name '%s'."), attrs[i].name);
44000 + syscall_create_syscall_desc (data->sysinfo, name, number);
44004 +/* The elements and attributes of an XML syscall document. */
44006 +static const struct gdb_xml_attribute syscall_attr[] = {
44007 + { "number", GDB_XML_AF_NONE, gdb_xml_parse_attr_ulongest, NULL },
44008 + { "name", GDB_XML_AF_NONE, NULL, NULL },
44009 + { NULL, GDB_XML_AF_NONE, NULL, NULL }
44012 +static const struct gdb_xml_element syscalls_info_children[] = {
44013 + { "syscall", syscall_attr, NULL,
44014 + GDB_XML_EF_OPTIONAL | GDB_XML_EF_REPEATABLE,
44015 + syscall_start_syscall, NULL },
44016 + { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
44019 +static const struct gdb_xml_element syselements[] = {
44020 + { "syscalls_info", NULL, syscalls_info_children,
44021 + GDB_XML_EF_NONE, syscall_start_syscalls_info, NULL },
44022 + { NULL, NULL, NULL, GDB_XML_EF_NONE, NULL, NULL }
44025 +static struct syscalls_info *
44026 +syscall_parse_xml (const char *document, xml_fetch_another fetcher,
44027 + void *fetcher_baton)
44029 + struct cleanup *result_cleanup;
44030 + struct gdb_xml_parser *parser;
44031 + struct syscall_parsing_data data;
44032 + char *expanded_text;
44035 + parser = gdb_xml_create_parser_and_cleanup (_("syscalls info"),
44036 + syselements, &data);
44038 + memset (&data, 0, sizeof (struct syscall_parsing_data));
44039 + data.sysinfo = allocate_syscalls_info ();
44040 + result_cleanup = make_cleanup_free_syscalls_info (data.sysinfo);
44042 + if (gdb_xml_parse (parser, document) == 0)
44044 + /* Parsed successfully. */
44045 + discard_cleanups (result_cleanup);
44046 + return data.sysinfo;
44050 + warning (_("Could not load XML syscalls info; ignoring"));
44051 + do_cleanups (result_cleanup);
44056 +const struct syscalls_info *
44057 +xml_init_syscalls_info (const char *filename)
44061 + struct syscalls_info *sysinfo;
44062 + struct cleanup *back_to;
44064 + full_file = fetch_xml_from_file (filename, gdb_datadir);
44065 + if (full_file == NULL)
44067 + warning (_("Could not open \"%s\""), filename);
44071 + back_to = make_cleanup (xfree, full_file);
44073 + dirname = ldirname (filename);
44074 + if (dirname != NULL)
44075 + make_cleanup (xfree, dirname);
44077 + sysinfo = syscall_parse_xml (full_file, fetch_xml_from_file, dirname);
44078 + do_cleanups (back_to);
44084 +xml_get_syscall_number (const struct syscalls_info *sysinfo,
44085 + const char *syscall_name)
44087 + struct syscall_desc *sysdesc;
44090 + if (sysinfo == NULL
44091 + || syscall_name == NULL)
44092 + return UNKNOWN_SYSCALL;
44095 + VEC_iterate(syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44097 + if (strcmp (sysdesc->name, syscall_name) == 0)
44098 + return sysdesc->number;
44100 + return UNKNOWN_SYSCALL;
44104 +xml_get_syscall_name (const struct syscalls_info *sysinfo,
44105 + int syscall_number)
44107 + struct syscall_desc *sysdesc;
44110 + if (sysinfo == NULL
44111 + || syscall_number < 0)
44115 + VEC_iterate(syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44117 + if (sysdesc->number == syscall_number)
44118 + return sysdesc->name;
44124 +xml_number_of_syscalls (const struct syscalls_info *sysinfo)
44126 + return (sysinfo == NULL ? 0 : VEC_length(syscall_desc_p,
44127 + sysinfo->syscalls));
44131 +xml_list_of_syscalls (const struct syscalls_info *sysinfo)
44133 + struct syscall_desc *sysdesc;
44134 + const char **names = NULL;
44138 + if (sysinfo == NULL)
44141 + nsyscalls = VEC_length (syscall_desc_p, sysinfo->syscalls);
44142 + names = xmalloc ((nsyscalls + 1) * sizeof (char *));
44145 + VEC_iterate (syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44147 + names[i] = sysdesc->name;
44154 +#endif /* HAVE_LIBEXPAT */
44155 diff --git a/gdb/xml-syscall.h b/gdb/xml-syscall.h
44156 new file mode 100644
44157 index 0000000..ff11f20
44159 +++ b/gdb/xml-syscall.h
44161 +/* Functions that provide the mechanism to parse a syscall XML file
44162 + and get its values.
44164 + Copyright (C) 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
44165 + 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
44166 + Free Software Foundation, Inc.
44168 + This file is part of GDB.
44170 + This program is free software; you can redistribute it and/or modify
44171 + it under the terms of the GNU General Public License as published by
44172 + the Free Software Foundation; either version 3 of the License, or
44173 + (at your option) any later version.
44175 + This program is distributed in the hope that it will be useful,
44176 + but WITHOUT ANY WARRANTY; without even the implied warranty of
44177 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44178 + GNU General Public License for more details.
44180 + You should have received a copy of the GNU General Public License
44181 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
44183 +#ifndef XML_SYSCALL_H
44184 +#define XML_SYSCALL_H 1
44186 +/* Structure that stores information about the system's
44189 +struct syscalls_info;
44192 +/* Function responsible for initializing the information
44193 + about the syscalls. It reads the XML file and fills the
44194 + struct syscalls_info with the values.
44196 + Returns the struct syscalls_info if the file is valid, NULL otherwise. */
44198 +const struct syscalls_info *xml_init_syscalls_info (const char *);
44200 +/* Function that retrieves the syscall number corresponding to the given
44203 + Returns the syscall number if found, or otherwise. */
44205 +int xml_get_syscall_number (const struct syscalls_info *, const char *);
44207 +/* Function that retrieves the syscall name corresponding to the given
44210 + Returns the syscall name if found, NULL otherwise. */
44211 +const char *xml_get_syscall_name (const struct syscalls_info *, int);
44213 +/* Function that returns the number of syscalls defined in the system.
44215 + Returns the number of syscalls, or zero otherwise. */
44216 +int xml_number_of_syscalls (const struct syscalls_info *);
44218 +/* Function used to retrieve the list of syscalls in the system. This list
44219 + is returned as an array of strings.
44221 + Returns the list of syscalls in the system, or NULL otherwise. */
44222 +const char **xml_list_of_syscalls (const struct syscalls_info *sysinfo);
44224 +#endif /* XML_SYSCALL_H */
44225 diff --git a/include/elf/common.h b/include/elf/common.h
44226 index 3ba44d9..764141e 100644
44227 --- a/include/elf/common.h
44228 +++ b/include/elf/common.h
44229 @@ -803,6 +803,7 @@
44230 #define AT_SECURE 23 /* Boolean, was exec setuid-like? */
44231 #define AT_BASE_PLATFORM 24 /* String identifying real platform,
44232 may differ from AT_PLATFORM. */
44233 +#define AT_RANDOM 25 /* Address of 16 random bytes. */
44234 #define AT_EXECFN 31 /* Filename of executable. */
44235 /* Pointer to the global system page used for system calls and other
44237 diff --git a/opcodes/po/es.po b/opcodes/po/es.po
44238 index 873be13..40bea5c 100644
44239 --- a/opcodes/po/es.po
44240 +++ b/opcodes/po/es.po
44242 -# Mensajes en español para opcodes-2.17.90.
44243 -# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
44244 -# Cristian Othón Martínez Vera <cfuga@itam.mx>, 2002, 2003, 2004, 2005, 2006, 2007.
44245 +# Mensajes en español para opcodes-2.18.90.
44246 +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
44247 +# This file is distributed under the same license as the binutils package.
44248 +# Cristian Othón Martínez Vera <cfuga@itam.mx>, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009.
44252 -"Project-Id-Version: opcodes 2.17.90\n"
44253 -"Report-Msgid-Bugs-To: \n"
44254 -"POT-Creation-Date: 2007-07-05 09:17+0100\n"
44255 -"PO-Revision-Date: 2007-09-08 09:17-0500\n"
44256 +"Project-Id-Version: opcodes 2.18.90\n"
44257 +"Report-Msgid-Bugs-To: bug-binutils@gnu.org\n"
44258 +"POT-Creation-Date: 2008-09-09 15:56+0930\n"
44259 +"PO-Revision-Date: 2009-03-03 21:46-0600\n"
44260 "Last-Translator: Cristian Othón Martínez Vera <cfuga@itam.mx>\n"
44261 "Language-Team: Spanish <es@li.org>\n"
44262 "MIME-Version: 1.0\n"
44263 @@ -52,7 +53,7 @@ msgid "too many long constants"
44264 msgstr "demasiadas constantes long"
44267 -msgid "to many shimms in load"
44268 +msgid "too many shimms in load"
44269 msgstr "demasiados shimms en load"
44271 #. Do we have a limm already?
44272 @@ -124,7 +125,7 @@ msgstr "No se reconoce el conjunto de nombres de registro: %s\n"
44273 msgid "Unrecognised disassembler option: %s\n"
44274 msgstr "No se reconoce la opción de desensamblador: %s\n"
44281 @@ -196,14 +197,14 @@ msgstr "La lista de registros no es v
44283 #: fr30-asm.c:310 frv-asm.c:1263 ip2k-asm.c:511 iq2000-asm.c:459
44284 #: m32c-asm.c:1589 m32r-asm.c:328 mep-asm.c:1001 mt-asm.c:595
44285 -#: openrisc-asm.c:241 xc16x-asm.c:375 xstormy16-asm.c:276
44286 +#: openrisc-asm.c:241 xc16x-asm.c:376 xstormy16-asm.c:276
44288 msgid "Unrecognized field %d while parsing.\n"
44289 msgstr "No se reconoció el campo %d durante la decodificación.\n"
44291 #: fr30-asm.c:361 frv-asm.c:1314 ip2k-asm.c:562 iq2000-asm.c:510
44292 #: m32c-asm.c:1640 m32r-asm.c:379 mep-asm.c:1052 mt-asm.c:646
44293 -#: openrisc-asm.c:292 xc16x-asm.c:426 xstormy16-asm.c:327
44294 +#: openrisc-asm.c:292 xc16x-asm.c:427 xstormy16-asm.c:327
44295 msgid "missing mnemonic in syntax string"
44296 msgstr "falta el mnemónico en la cadena sintáctica"
44298 @@ -216,7 +217,7 @@ msgstr "falta el mnem
44299 #: m32r-asm.c:605 m32r-asm.c:706 mep-asm.c:1187 mep-asm.c:1191 mep-asm.c:1278
44300 #: mep-asm.c:1379 mt-asm.c:781 mt-asm.c:785 mt-asm.c:872 mt-asm.c:973
44301 #: openrisc-asm.c:427 openrisc-asm.c:431 openrisc-asm.c:518 openrisc-asm.c:619
44302 -#: xc16x-asm.c:561 xc16x-asm.c:565 xc16x-asm.c:652 xc16x-asm.c:753
44303 +#: xc16x-asm.c:562 xc16x-asm.c:566 xc16x-asm.c:653 xc16x-asm.c:754
44304 #: xstormy16-asm.c:462 xstormy16-asm.c:466 xstormy16-asm.c:553
44305 #: xstormy16-asm.c:654
44306 msgid "unrecognized instruction"
44307 @@ -224,40 +225,40 @@ msgstr "no se reconoce la instrucci
44309 #: fr30-asm.c:543 frv-asm.c:1496 ip2k-asm.c:744 iq2000-asm.c:692
44310 #: m32c-asm.c:1822 m32r-asm.c:561 mep-asm.c:1234 mt-asm.c:828
44311 -#: openrisc-asm.c:474 xc16x-asm.c:608 xstormy16-asm.c:509
44312 +#: openrisc-asm.c:474 xc16x-asm.c:609 xstormy16-asm.c:509
44314 msgid "syntax error (expected char `%c', found `%c')"
44315 msgstr "error sintáctico (se esperaba el carácter `%c', se encontró `%c')"
44317 #: fr30-asm.c:553 frv-asm.c:1506 ip2k-asm.c:754 iq2000-asm.c:702
44318 #: m32c-asm.c:1832 m32r-asm.c:571 mep-asm.c:1244 mt-asm.c:838
44319 -#: openrisc-asm.c:484 xc16x-asm.c:618 xstormy16-asm.c:519
44320 +#: openrisc-asm.c:484 xc16x-asm.c:619 xstormy16-asm.c:519
44322 msgid "syntax error (expected char `%c', found end of instruction)"
44323 msgstr "error sintáctico (se esperaba el carácter `%c', se encontró el final de la instrucción)"
44325 #: fr30-asm.c:581 frv-asm.c:1534 ip2k-asm.c:782 iq2000-asm.c:730
44326 #: m32c-asm.c:1860 m32r-asm.c:599 mep-asm.c:1272 mt-asm.c:866
44327 -#: openrisc-asm.c:512 xc16x-asm.c:646 xstormy16-asm.c:547
44328 +#: openrisc-asm.c:512 xc16x-asm.c:647 xstormy16-asm.c:547
44329 msgid "junk at end of line"
44330 msgstr "basura al final de la línea"
44332 #: fr30-asm.c:687 frv-asm.c:1640 ip2k-asm.c:888 iq2000-asm.c:836
44333 #: m32c-asm.c:1966 m32r-asm.c:705 mep-asm.c:1378 mt-asm.c:972
44334 -#: openrisc-asm.c:618 xc16x-asm.c:752 xstormy16-asm.c:653
44335 +#: openrisc-asm.c:618 xc16x-asm.c:753 xstormy16-asm.c:653
44336 msgid "unrecognized form of instruction"
44337 msgstr "no se reconoce la forma de instrucción"
44339 #: fr30-asm.c:699 frv-asm.c:1652 ip2k-asm.c:900 iq2000-asm.c:848
44340 #: m32c-asm.c:1978 m32r-asm.c:717 mep-asm.c:1390 mt-asm.c:984
44341 -#: openrisc-asm.c:630 xc16x-asm.c:764 xstormy16-asm.c:665
44342 +#: openrisc-asm.c:630 xc16x-asm.c:765 xstormy16-asm.c:665
44344 msgid "bad instruction `%.50s...'"
44345 msgstr "instrucción errónea `%.50s...'"
44347 #: fr30-asm.c:702 frv-asm.c:1655 ip2k-asm.c:903 iq2000-asm.c:851
44348 #: m32c-asm.c:1981 m32r-asm.c:720 mep-asm.c:1393 mt-asm.c:987
44349 -#: openrisc-asm.c:633 xc16x-asm.c:767 xstormy16-asm.c:668
44350 +#: openrisc-asm.c:633 xc16x-asm.c:768 xstormy16-asm.c:668
44352 msgid "bad instruction `%.50s'"
44353 msgstr "instrucción errónea `%.50s'"
44354 @@ -377,11 +378,11 @@ msgstr "no se puede lidiar con insert %d\n"
44355 msgid "%02x\t\t*unknown*"
44356 msgstr "%02x\t\t*desconocido*"
44358 -#: i386-dis.c:3196
44359 +#: i386-dis.c:9545
44360 msgid "<internal disassembler error>"
44361 msgstr "<error interno del desensamblador>"
44363 -#: i386-dis.c:3423
44364 +#: i386-dis.c:9776
44368 @@ -392,79 +393,124 @@ msgstr ""
44369 "Se admiten las siguientes opciones de desensamblador específicas de i386/x86-64\n"
44370 "con el interruptor -M (las opciones múltiples se deben separar con comas):\n"
44372 -#: i386-dis.c:3427
44373 +#: i386-dis.c:9780
44375 msgid " x86-64 Disassemble in 64bit mode\n"
44376 msgstr " x86-64 Desensambla en modo 64bit\n"
44378 -#: i386-dis.c:3428
44379 +#: i386-dis.c:9781
44381 msgid " i386 Disassemble in 32bit mode\n"
44382 msgstr " i386 Desensambla en modo 32bit\n"
44384 -#: i386-dis.c:3429
44385 +#: i386-dis.c:9782
44387 msgid " i8086 Disassemble in 16bit mode\n"
44388 msgstr " i8086 Desensambla en modo 16bit\n"
44390 -#: i386-dis.c:3430
44391 +#: i386-dis.c:9783
44393 msgid " att Display instruction in AT&T syntax\n"
44394 msgstr " att Muestra las instrucciones con sintaxis AT&T\n"
44396 -#: i386-dis.c:3431
44397 +#: i386-dis.c:9784
44399 msgid " intel Display instruction in Intel syntax\n"
44400 msgstr " intel Muestra las instrucciones con sintaxis Intel\n"
44402 -#: i386-dis.c:3432
44403 +#: i386-dis.c:9785
44407 +" Display instruction in AT&T mnemonic\n"
44410 +" Muestra las instrucciones con mnemónicos AT&T\n"
44412 +#: i386-dis.c:9787
44415 +" intel-mnemonic\n"
44416 +" Display instruction in Intel mnemonic\n"
44418 +" intel-mnemonic\n"
44419 +" Muestra las instrucciones con mnemónicos Intel\n"
44421 +#: i386-dis.c:9789
44423 msgid " addr64 Assume 64bit address size\n"
44424 msgstr " addr64 Asume un tamaño de dirección de 64bit\n"
44426 -#: i386-dis.c:3433
44427 +#: i386-dis.c:9790
44429 msgid " addr32 Assume 32bit address size\n"
44430 msgstr " addr32 Asume un tamaño de dirección de 32bit\n"
44432 -#: i386-dis.c:3434
44433 +#: i386-dis.c:9791
44435 msgid " addr16 Assume 16bit address size\n"
44436 msgstr " addr16 Asume un tamaño de dirección de 16bit\n"
44438 -#: i386-dis.c:3435
44439 +#: i386-dis.c:9792
44441 msgid " data32 Assume 32bit data size\n"
44442 msgstr " data32 Asume un tamaño de datos de 32bit\n"
44444 -#: i386-dis.c:3436
44445 +#: i386-dis.c:9793
44447 msgid " data16 Assume 16bit data size\n"
44448 msgstr " data16 Asume un tamaño de datos de 16bit\n"
44450 -#: i386-dis.c:3437
44451 +#: i386-dis.c:9794
44453 msgid " suffix Always display instruction suffix in AT&T syntax\n"
44454 msgstr " suffix Siempre muestra el sufijo de instrucción con sintaxis AT&T\n"
44456 -#: i386-gen.c:42 ia64-gen.c:307
44457 +#: i386-gen.c:411 ia64-gen.c:307
44459 msgid "%s: Error: "
44460 msgstr "%s: Error: "
44463 -msgid "can't find i386-opc.tbl for reading\n"
44464 -msgstr "no se puede encontrar i386-opc.tbl para lectura\n"
44467 +msgid "%s: %d: Unknown bitfield: %s\n"
44468 +msgstr "%s: %d: Campo de bits desconocido: %s\n"
44472 +msgid "can't find i386-opc.tbl for reading, errno = %s\n"
44473 +msgstr "no se puede encontrar i386-opc.tbl para lectura, errno =%s\n"
44476 -msgid "can't find i386-reg.tbl for reading\n"
44477 -msgstr "no se puede encontrar i386-reg.tbl para lectura\n"
44480 +msgid "can't find i386-reg.tbl for reading, errno = %s\n"
44481 +msgstr "no se puede encontrar i386-reg.tbl para lectura, errno = %s\n"
44485 +msgid "can't create i386-init.h, errno = %s\n"
44486 +msgstr "no se puede crear i386-init.h, errno = %s\n"
44488 -#: i386-gen.c:386 ia64-gen.c:2841
44489 +#: i386-gen.c:1032 ia64-gen.c:2850
44491 msgid "unable to change directory to \"%s\", errno = %s\n"
44492 msgstr "no se puede cambiar el directorio a \"%s\", errno = %s\n"
44494 +#: i386-gen.c:1039
44496 +msgid "%d unused bits in i386_cpu_flags.\n"
44497 +msgstr "%d bits sin usar en i386_cpu_flags.\n"
44499 +#: i386-gen.c:1046
44501 +msgid "%d unused bits in i386_operand_type.\n"
44502 +msgstr "%d bits sin usar en i386_operand_type.\n"
44504 +#: i386-gen.c:1060
44506 +msgid "can't create i386-tbl.h, errno = %s\n"
44507 +msgstr "no se puede crear i386-tbl.h, errno = %s\n"
44511 msgid "%s: Warning: "
44512 @@ -503,62 +549,67 @@ msgstr "campo solapado %s->%s\n"
44513 msgid "overwriting note %d with note %d (IC:%s)\n"
44514 msgstr "se sobreescribe la nota %d con la nota %d (IC:%s)\n"
44516 -#: ia64-gen.c:1455
44517 +#: ia64-gen.c:1459
44519 msgid "don't know how to specify %% dependency %s\n"
44520 msgstr "no se sabe cómo especificar la dependencia %% %s\n"
44522 -#: ia64-gen.c:1477
44523 +#: ia64-gen.c:1481
44525 msgid "Don't know how to specify # dependency %s\n"
44526 msgstr "No se sabe cómo especificar la dependencia # %s\n"
44528 -#: ia64-gen.c:1516
44529 +#: ia64-gen.c:1520
44531 msgid "IC:%s [%s] has no terminals or sub-classes\n"
44532 msgstr "IC:%s [%s] no tiene terminales o sub-clases\n"
44534 -#: ia64-gen.c:1519
44535 +#: ia64-gen.c:1523
44537 msgid "IC:%s has no terminals or sub-classes\n"
44538 msgstr "IC:%s no tiene terminales o sub-clases\n"
44540 -#: ia64-gen.c:1528
44541 +#: ia64-gen.c:1532
44543 msgid "no insns mapped directly to terminal IC %s [%s]"
44544 msgstr "no hay insns mapeadas directamente al IC terminal %s [%s]"
44546 -#: ia64-gen.c:1531
44547 +#: ia64-gen.c:1535
44549 msgid "no insns mapped directly to terminal IC %s\n"
44550 msgstr "no hay insns mapeadas directamente al IC terminal %s\n"
44552 -#: ia64-gen.c:1542
44553 +#: ia64-gen.c:1546
44555 msgid "class %s is defined but not used\n"
44556 msgstr "se define la clase %s pero no se utiliza\n"
44558 -#: ia64-gen.c:1553
44559 +#: ia64-gen.c:1559
44561 -msgid "Warning: rsrc %s (%s) has no chks%s\n"
44562 -msgstr "Aviso: el rsrc %s (%s) no tiene chks%s\n"
44563 +msgid "Warning: rsrc %s (%s) has no chks\n"
44564 +msgstr "Aviso: el rsrc %s (%s) no tiene chks\n"
44566 -#: ia64-gen.c:1557
44567 +#: ia64-gen.c:1562
44569 +msgid "Warning: rsrc %s (%s) has no chks or regs\n"
44570 +msgstr "Aviso: el rsrc %s (%s) no tiene chks o regs\n"
44572 +#: ia64-gen.c:1566
44574 msgid "rsrc %s (%s) has no regs\n"
44575 msgstr "el rsrc %s (%s) no tiene registros\n"
44577 -#: ia64-gen.c:2469
44578 +#: ia64-gen.c:2478
44580 msgid "IC note %d in opcode %s (IC:%s) conflicts with resource %s note %d\n"
44581 msgstr "la nota IC %d en el código de operación %s (IC:%s) tiene conflictos con el recurso %s nota %d\n"
44583 -#: ia64-gen.c:2497
44584 +#: ia64-gen.c:2506
44586 msgid "IC note %d for opcode %s (IC:%s) conflicts with resource %s note %d\n"
44587 msgstr "la nota IC %d para el código de operación %s (IC:%s) tiene conflictos con el recurso %s nota %d\n"
44589 -#: ia64-gen.c:2511
44590 +#: ia64-gen.c:2520
44592 msgid "opcode %s has no class (ops %d %d %d)\n"
44593 msgstr "el código de operación %s no tiene clase (ops %d %d %d)\n"
44594 @@ -739,26 +790,26 @@ msgstr "S
44595 msgid "invalid %function() here"
44596 msgstr "%funcion() inválida aquí"
44600 msgid "# internal error, incomplete extension sequence (+)"
44601 msgstr "# error interno, secuencia de extensión incompleta (+)"
44606 msgid "# internal error, undefined extension sequence (+%c)"
44607 msgstr "# error interno, secuencia de extensión sin definir (+%c)"
44609 -#: mips-dis.c:1211
44610 +#: mips-dis.c:1274
44612 -msgid "# internal error, undefined modifier(%c)"
44613 -msgstr "# error interno, modificador(%c) sin definir"
44614 +msgid "# internal error, undefined modifier (%c)"
44615 +msgstr "# error interno, modificador (%c) sin definir"
44617 -#: mips-dis.c:1818
44618 +#: mips-dis.c:1881
44620 msgid "# internal disassembler error, unrecognised modifier (%c)"
44621 msgstr "# error interno del desensamblador, no se reconoce el modificador (%c)"
44623 -#: mips-dis.c:2049
44624 +#: mips-dis.c:2112
44628 @@ -769,7 +820,7 @@ msgstr ""
44629 "Las siguientes opciones de desensamblador específicas de MIPS se admiten\n"
44630 "para usarse con el interruptor -M (las opciones múltiples se deben separar con comas):\n"
44632 -#: mips-dis.c:2053
44633 +#: mips-dis.c:2116
44637 @@ -780,7 +831,7 @@ msgstr ""
44638 " gpr-names=ABI Muestra los nombres GPR de acuerdo a la ABI especificada.\n"
44639 " Por defecto: basado en el binario a desensamblar.\n"
44641 -#: mips-dis.c:2057
44642 +#: mips-dis.c:2120
44646 @@ -791,7 +842,7 @@ msgstr ""
44647 " fpr-names=ABI Muestra los nombres FPR de acuerdo a la ABI especificada.\n"
44648 " Por defecto: numérico.\n"
44650 -#: mips-dis.c:2061
44651 +#: mips-dis.c:2124
44655 @@ -804,7 +855,7 @@ msgstr ""
44656 " la arquitectura especificada.\n"
44657 " Por defecto: basado en el binario a desensamblar.\n"
44659 -#: mips-dis.c:2066
44660 +#: mips-dis.c:2129
44664 @@ -817,7 +868,7 @@ msgstr ""
44666 " Por defecto: basado en el binario a desensamblar.\n"
44668 -#: mips-dis.c:2071
44669 +#: mips-dis.c:2134
44673 @@ -828,7 +879,7 @@ msgstr ""
44674 " reg-names=ABI Muestra los nombres GPR y FPR de acuerdo a\n"
44675 " la ABI especificada.\n"
44677 -#: mips-dis.c:2075
44678 +#: mips-dis.c:2138
44682 @@ -839,7 +890,7 @@ msgstr ""
44683 " reg-names=ARCH Muestra el registro CP0 y los nombres HWR de acuerdo a\n"
44684 " la arquitectura especificada.\n"
44686 -#: mips-dis.c:2079
44687 +#: mips-dis.c:2142
44691 @@ -850,12 +901,12 @@ msgstr ""
44692 " Para las opciones anteriores, se admiten los siguientes valores de \"ABI\":\n"
44695 -#: mips-dis.c:2084 mips-dis.c:2092 mips-dis.c:2094
44696 +#: mips-dis.c:2147 mips-dis.c:2155 mips-dis.c:2157
44701 -#: mips-dis.c:2086
44702 +#: mips-dis.c:2149
44706 @@ -894,9 +945,8 @@ msgid "Biiiig Trouble in parse_imm16!"
44707 msgstr "¡Graaaan Problema en parse_imm16!"
44711 -msgid "%operator operand is not a symbol"
44712 -msgstr "el operando %operator no es un símbolo"
44713 +msgid "The percent-operator's operand is not a symbol"
44714 +msgstr "el operando de operador-porcentaje no es un símbolo"
44717 msgid "invalid operand. type may have values 0,1,2 only."
44718 @@ -912,42 +962,64 @@ msgstr "operando inv
44719 msgid "$<undefined>"
44720 msgstr "$<sin definir>"
44722 -#: ppc-opc.c:782 ppc-opc.c:810
44723 +#: ppc-opc.c:862 ppc-opc.c:890
44724 msgid "invalid conditional option"
44725 msgstr "opción condicional inválida"
44729 msgid "attempt to set y bit when using + or - modifier"
44730 msgstr "intento de establecer el bit y cuando se usaba el modificador + ó -"
44734 msgid "invalid mask field"
44735 msgstr "campo de máscara inválido"
44739 msgid "ignoring invalid mfcr mask"
44740 msgstr "se descarta la máscara mfcr inválida"
44742 -#: ppc-opc.c:920 ppc-opc.c:955
44743 +#: ppc-opc.c:1000 ppc-opc.c:1035
44744 msgid "illegal bitmask"
44745 msgstr "máscara de bits ilegal"
44749 msgid "index register in load range"
44750 msgstr "registro índice en el rango de carga"
44754 msgid "source and target register operands must be different"
44755 msgstr "los operandos de registros fuente y objetivo deben ser diferentes"
44759 msgid "invalid register operand when updating"
44760 msgstr "operando de registro inválido mientras se actualizaba"
44764 msgid "invalid sprg number"
44765 msgstr "número sprg inválido"
44771 +"The following S/390 specific disassembler options are supported for use\n"
44772 +"with the -M switch (multiple options should be separated by commas):\n"
44775 +"Las siguientes opciones de desensamblador específicas de S/390 se admiten\n"
44776 +"para usarse con el interruptor -M (las opciones múltiples se deben\n"
44777 +"separar con comas):\n"
44781 +msgid " esa Disassemble in ESA architecture mode\n"
44782 +msgstr " esa Desensambla en modo de arquitectura ESA\n"
44786 +msgid " zarch Disassemble in z/Architecture mode\n"
44787 +msgstr " zarch Desensambla en modo de z/Architecture\n"
44789 #: score-dis.c:220 score-dis.c:383
44790 msgid "<illegal instruction>"
44791 msgstr "<instrucción ilegal>"
44792 @@ -1031,27 +1103,27 @@ msgstr "el valor inmediato no est
44793 msgid "immediate value must be even"
44794 msgstr "el valor inmediato debe ser par"
44798 msgid "Missing '#' prefix"
44799 msgstr "Falta el prefijo '#'"
44803 msgid "Missing '.' prefix"
44804 msgstr "Falta el prefijo '.'"
44808 msgid "Missing 'pof:' prefix"
44809 msgstr "Falta el prefijo 'pof:'"
44811 -#: xc16x-asm.c:113
44812 +#: xc16x-asm.c:114
44813 msgid "Missing 'pag:' prefix"
44814 msgstr "Falta el prefijo 'pag:'"
44816 -#: xc16x-asm.c:129
44817 +#: xc16x-asm.c:130
44818 msgid "Missing 'sof:' prefix"
44819 msgstr "Falta el prefijo 'sof:'"
44821 -#: xc16x-asm.c:145
44822 +#: xc16x-asm.c:146
44823 msgid "Missing 'seg:' prefix"
44824 msgstr "Falta el prefijo 'seg:'"
44826 @@ -1095,6 +1167,9 @@ msgstr "El operando no es un s
44827 msgid "Syntax error: No trailing ')'"
44828 msgstr "Error sintáctico: No hay ')' al final"
44830 +#~ msgid "%operator operand is not a symbol"
44831 +#~ msgstr "el operando %operator no es un símbolo"
44833 #~ msgid "offset not a multiple of 16"
44834 #~ msgstr "el desplazamiento no es un múltiplo de 16"
44836 diff --git a/opcodes/po/id.po b/opcodes/po/id.po
44837 index 3edf294..0f6c063 100644
44838 --- a/opcodes/po/id.po
44839 +++ b/opcodes/po/id.po
44841 -# opcodes 2.12.1 (Indonesian)
44842 -# Copyright (C) 2002 Free Software Foundation, Inc.
44843 +# Pesan bahasa indonesia untuk opcodes
44844 +# Copyright (C) 2009 Free Software Foundation, Inc.
44845 +# This file is distributed under the same license as the binutils package.
44846 # Tedi Heriyanto <tedi_h@gmx.net>, 2002.
44847 +# Arif E. Nugroho <arif_endro@yahoo.com>, 2009.
44851 -"Project-Id-Version: opcodes 2.12.1\n"
44852 -"POT-Creation-Date: 2002-02-08 03:24-0200\n"
44853 -"PO-Revision-Date: 2002-07-23 12:35GMT+0700\n"
44854 -"Last-Translator: Tedi Heriyanto <tedi_h@gmx.net>\n"
44855 +"Project-Id-Version: opcodes 2.18.90\n"
44856 +"Report-Msgid-Bugs-To: bug-binutils@gnu.org\n"
44857 +"POT-Creation-Date: 2008-09-09 15:56+0930\n"
44858 +"PO-Revision-Date: 2009-03-10 13:30+0700\n"
44859 +"Last-Translator: Arif E. Nugroho <arif_endro@yahoo.com>\n"
44860 "Language-Team: Indonesian <translation-team-id@lists.sourceforge.net>\n"
44861 "MIME-Version: 1.0\n"
44862 "Content-Type: text/plain; charset=UTF-8\n"
44863 "Content-Transfer-Encoding: 8bit\n"
44864 -"X-Generator: KBabel 0.9.5\n"
44866 -#: alpha-opc.c:335
44867 +#: alpha-opc.c:155
44868 msgid "branch operand unaligned"
44869 msgstr "operand cabang tidak rata"
44871 -#: alpha-opc.c:358 alpha-opc.c:380
44872 +#: alpha-opc.c:171 alpha-opc.c:187
44873 msgid "jump hint unaligned"
44874 msgstr "petunjuk lompat tidak rata"
44878 msgid "Illegal limm reference in last instruction!\n"
44879 msgstr "referensi limm ilegal dalam instruksi terakhir!\n"
44883 +msgid "unable to fit different valued constants into instruction"
44884 +msgstr "tidak dapat memasukan nilai konstanta berbeda kedalam instruksi"
44887 +msgid "auxiliary register not allowed here"
44888 +msgstr "register tambahan tidak diperbolehkan disini"
44890 +#: arc-opc.c:401 arc-opc.c:418
44891 +msgid "attempt to set readonly register"
44892 +msgstr "mencoba untuk menset register baca-saja"
44894 +#: arc-opc.c:406 arc-opc.c:423
44895 +msgid "attempt to read writeonly register"
44896 +msgstr "mencoba untuk membaca register tulis-saja"
44900 +msgid "invalid register number `%d'"
44901 +msgstr "nomor register tidak valid `%d'"
44903 +#: arc-opc.c:594 arc-opc.c:645 arc-opc.c:673
44904 +msgid "too many long constants"
44905 +msgstr "terlalu banyak konstanta panjang"
44908 +msgid "too many shimms in load"
44909 +msgstr "terlalu banyak shimm dalam load"
44911 +#. Do we have a limm already?
44913 +msgid "impossible store"
44914 +msgstr "store tidak memungkinkan"
44917 +msgid "st operand error"
44918 +msgstr "operand st error"
44920 +#: arc-opc.c:818 arc-opc.c:860
44921 +msgid "address writeback not allowed"
44922 +msgstr "alamat writeback tidak diijinkan"
44925 +msgid "store value must be zero"
44926 +msgstr "nilai simpan harus nol"
44929 +msgid "invalid load/shimm insn"
44930 +msgstr "insn load/shimm tidak valid"
44933 +msgid "ld operand error"
44934 +msgstr "operand ld error"
44937 +msgid "jump flags, but no .f seen"
44938 +msgstr "tanda jump, tetapi tidak ada .f yang terlihat"
44941 +msgid "jump flags, but no limm addr"
44942 +msgstr "tanda jump, tetapi tidak ada alamat limm"
44945 +msgid "flag bits of jump address limm lost"
44946 +msgstr "tanda bit dari alamat jump limm hilang"
44949 +msgid "attempt to set HR bits"
44950 +msgstr "mencoba menset bit HR"
44953 +msgid "bad jump flags value"
44954 +msgstr "nilai tanda jump buruk"
44957 +msgid "branch address not on 4 byte boundary"
44958 +msgstr "alamat cabang tidak dalam kelipatan 4 byte"
44961 +msgid "must specify .jd or no nullify suffix"
44962 +msgstr "harus menspesifikasikan .jd atau tidak ada akhiran nullify"
44965 msgid "<illegal precision>"
44966 msgstr "<presisi ilegal>"
44969 +#. XXX - should break 'option' at following delimiter.
44972 msgid "Unrecognised register name set: %s\n"
44973 msgstr "Set nama register tidak dikenal: %s\n"
44976 +#. XXX - should break 'option' at following delimiter.
44979 msgid "Unrecognised disassembler option: %s\n"
44980 msgstr "Option disasembler tidak dikenal: %s\n"
44987 "The following ARM specific disassembler options are supported for use with\n"
44988 @@ -50,297 +137,919 @@ msgstr ""
44989 "Option disablembler khusus ARM berikut ini didukung untuk digunakan dengan\n"
44992 -#: avr-dis.c:118 avr-dis.c:128
44993 +#: avr-dis.c:115 avr-dis.c:125
44996 msgstr "tidak didefinisikan"
45001 msgid "Internal disassembler error"
45002 msgstr "Kesalahan disasembler internal"
45007 msgid "unknown constraint `%c'"
45008 msgstr "konstrain tidak dikenal `%c'"
45010 -#: cgen-asm.c:346 fr30-ibld.c:195 m32r-ibld.c:195 openrisc-ibld.c:195 xstormy16-ibld.c:195
45011 +#: cgen-asm.c:336 fr30-ibld.c:200 frv-ibld.c:200 ip2k-ibld.c:200
45012 +#: iq2000-ibld.c:200 m32c-ibld.c:200 m32r-ibld.c:200 mep-ibld.c:200
45013 +#: mt-ibld.c:200 openrisc-ibld.c:200 xc16x-ibld.c:200 xstormy16-ibld.c:200
45015 msgid "operand out of range (%ld not between %ld and %ld)"
45016 msgstr "operand keluar batas (%ld tidak antara %ld dan %ld)"
45021 msgid "operand out of range (%lu not between %lu and %lu)"
45022 msgstr "operand keluar batas (%lu tidak antara %lu dan %lu)"
45027 msgid "<unknown register %d>"
45028 msgstr "<register tidak dikenal %d>"
45034 msgid "Unknown error %d\n"
45035 msgstr "Kesalahan tidak dikenal %d\n"
45040 -msgid "Address 0x%x is out of bounds.\n"
45041 -msgstr "Alamat 0x%x di luar batas.\n"
45042 +msgid "Address 0x%s is out of bounds.\n"
45043 +msgstr "Alamat 0x%s di luar jangkauan.\n"
45045 -#: fr30-asm.c:323 m32r-asm.c:325 openrisc-asm.c:244 xstormy16-asm.c:231
45046 +#: fr30-asm.c:93 m32c-asm.c:877 m32c-asm.c:884
45047 +msgid "Register number is not valid"
45048 +msgstr "Nomor register tidak valid"
45051 +msgid "Register must be between r0 and r7"
45052 +msgstr "Register harus berada diantara r0 dan r7"
45055 +msgid "Register must be between r8 and r15"
45056 +msgstr "Register harus berada diantara r8 dan r15"
45058 +#: fr30-asm.c:116 m32c-asm.c:915
45059 +msgid "Register list is not valid"
45060 +msgstr "Daftar register tidak valid"
45062 +#: fr30-asm.c:310 frv-asm.c:1263 ip2k-asm.c:511 iq2000-asm.c:459
45063 +#: m32c-asm.c:1589 m32r-asm.c:328 mep-asm.c:1001 mt-asm.c:595
45064 +#: openrisc-asm.c:241 xc16x-asm.c:376 xstormy16-asm.c:276
45066 msgid "Unrecognized field %d while parsing.\n"
45067 msgstr "Field tidak dikenal %d saat parsing.\n"
45069 -#: fr30-asm.c:373 m32r-asm.c:375 openrisc-asm.c:294 xstormy16-asm.c:281
45070 +#: fr30-asm.c:361 frv-asm.c:1314 ip2k-asm.c:562 iq2000-asm.c:510
45071 +#: m32c-asm.c:1640 m32r-asm.c:379 mep-asm.c:1052 mt-asm.c:646
45072 +#: openrisc-asm.c:292 xc16x-asm.c:427 xstormy16-asm.c:327
45073 msgid "missing mnemonic in syntax string"
45074 msgstr "mnemonik hilang dalam string sintaks"
45076 #. We couldn't parse it.
45077 -#: fr30-asm.c:509 fr30-asm.c:513 fr30-asm.c:600 fr30-asm.c:702 m32r-asm.c:511 m32r-asm.c:515 m32r-asm.c:602 m32r-asm.c:704 openrisc-asm.c:430 openrisc-asm.c:434 openrisc-asm.c:521 openrisc-asm.c:623 xstormy16-asm.c:417 xstormy16-asm.c:421 xstormy16-asm.c:508 xstormy16-asm.c:610
45078 +#: fr30-asm.c:496 fr30-asm.c:500 fr30-asm.c:587 fr30-asm.c:688 frv-asm.c:1449
45079 +#: frv-asm.c:1453 frv-asm.c:1540 frv-asm.c:1641 ip2k-asm.c:697 ip2k-asm.c:701
45080 +#: ip2k-asm.c:788 ip2k-asm.c:889 iq2000-asm.c:645 iq2000-asm.c:649
45081 +#: iq2000-asm.c:736 iq2000-asm.c:837 m32c-asm.c:1775 m32c-asm.c:1779
45082 +#: m32c-asm.c:1866 m32c-asm.c:1967 m32r-asm.c:514 m32r-asm.c:518
45083 +#: m32r-asm.c:605 m32r-asm.c:706 mep-asm.c:1187 mep-asm.c:1191 mep-asm.c:1278
45084 +#: mep-asm.c:1379 mt-asm.c:781 mt-asm.c:785 mt-asm.c:872 mt-asm.c:973
45085 +#: openrisc-asm.c:427 openrisc-asm.c:431 openrisc-asm.c:518 openrisc-asm.c:619
45086 +#: xc16x-asm.c:562 xc16x-asm.c:566 xc16x-asm.c:653 xc16x-asm.c:754
45087 +#: xstormy16-asm.c:462 xstormy16-asm.c:466 xstormy16-asm.c:553
45088 +#: xstormy16-asm.c:654
45089 msgid "unrecognized instruction"
45090 msgstr "instruksti tidak dikenal"
45092 -#: fr30-asm.c:556 m32r-asm.c:558 openrisc-asm.c:477 xstormy16-asm.c:464
45093 +#: fr30-asm.c:543 frv-asm.c:1496 ip2k-asm.c:744 iq2000-asm.c:692
45094 +#: m32c-asm.c:1822 m32r-asm.c:561 mep-asm.c:1234 mt-asm.c:828
45095 +#: openrisc-asm.c:474 xc16x-asm.c:609 xstormy16-asm.c:509
45097 msgid "syntax error (expected char `%c', found `%c')"
45098 msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan `%c')"
45100 -#: fr30-asm.c:566 m32r-asm.c:568 openrisc-asm.c:487 xstormy16-asm.c:474
45101 +#: fr30-asm.c:553 frv-asm.c:1506 ip2k-asm.c:754 iq2000-asm.c:702
45102 +#: m32c-asm.c:1832 m32r-asm.c:571 mep-asm.c:1244 mt-asm.c:838
45103 +#: openrisc-asm.c:484 xc16x-asm.c:619 xstormy16-asm.c:519
45105 msgid "syntax error (expected char `%c', found end of instruction)"
45106 msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan akhir instruksi)"
45108 -#: fr30-asm.c:594 m32r-asm.c:596 openrisc-asm.c:515 xstormy16-asm.c:502
45109 +#: fr30-asm.c:581 frv-asm.c:1534 ip2k-asm.c:782 iq2000-asm.c:730
45110 +#: m32c-asm.c:1860 m32r-asm.c:599 mep-asm.c:1272 mt-asm.c:866
45111 +#: openrisc-asm.c:512 xc16x-asm.c:647 xstormy16-asm.c:547
45112 msgid "junk at end of line"
45113 msgstr "sampah di akhir baris"
45115 -#: fr30-asm.c:701 m32r-asm.c:703 openrisc-asm.c:622 xstormy16-asm.c:609
45116 +#: fr30-asm.c:687 frv-asm.c:1640 ip2k-asm.c:888 iq2000-asm.c:836
45117 +#: m32c-asm.c:1966 m32r-asm.c:705 mep-asm.c:1378 mt-asm.c:972
45118 +#: openrisc-asm.c:618 xc16x-asm.c:753 xstormy16-asm.c:653
45119 msgid "unrecognized form of instruction"
45120 msgstr "bentuk instruksi tidak dikenal"
45122 -#: fr30-asm.c:713 m32r-asm.c:715 openrisc-asm.c:634 xstormy16-asm.c:621
45123 +#: fr30-asm.c:699 frv-asm.c:1652 ip2k-asm.c:900 iq2000-asm.c:848
45124 +#: m32c-asm.c:1978 m32r-asm.c:717 mep-asm.c:1390 mt-asm.c:984
45125 +#: openrisc-asm.c:630 xc16x-asm.c:765 xstormy16-asm.c:665
45127 msgid "bad instruction `%.50s...'"
45128 msgstr "instruksi buruk `%.50s...'"
45130 -#: fr30-asm.c:716 m32r-asm.c:718 openrisc-asm.c:637 xstormy16-asm.c:624
45131 +#: fr30-asm.c:702 frv-asm.c:1655 ip2k-asm.c:903 iq2000-asm.c:851
45132 +#: m32c-asm.c:1981 m32r-asm.c:720 mep-asm.c:1393 mt-asm.c:987
45133 +#: openrisc-asm.c:633 xc16x-asm.c:768 xstormy16-asm.c:668
45135 msgid "bad instruction `%.50s'"
45136 msgstr "instruksi buruk `%.50s'"
45138 #. Default text to print if an instruction isn't recognized.
45139 -#: fr30-dis.c:39 m32r-dis.c:39 mmix-dis.c:282 openrisc-dis.c:39 xstormy16-dis.c:39
45140 +#: fr30-dis.c:41 frv-dis.c:41 ip2k-dis.c:41 iq2000-dis.c:41 m32c-dis.c:41
45141 +#: m32r-dis.c:41 mep-dis.c:41 mmix-dis.c:278 mt-dis.c:41 openrisc-dis.c:41
45142 +#: xc16x-dis.c:41 xstormy16-dis.c:41
45144 msgstr "*tidak dikenal*"
45146 -#: fr30-dis.c:318 m32r-dis.c:249 openrisc-dis.c:136 xstormy16-dis.c:169
45147 +#: fr30-dis.c:299 frv-dis.c:396 ip2k-dis.c:288 iq2000-dis.c:189 m32c-dis.c:891
45148 +#: m32r-dis.c:256 mep-dis.c:776 mt-dis.c:290 openrisc-dis.c:135
45149 +#: xc16x-dis.c:375 xstormy16-dis.c:168
45151 msgid "Unrecognized field %d while printing insn.\n"
45152 msgstr "Field tidak dikenal %d saat mencetak insn.\n"
45154 -#: fr30-ibld.c:166 m32r-ibld.c:166 openrisc-ibld.c:166 xstormy16-ibld.c:166
45155 +#: fr30-ibld.c:163 frv-ibld.c:163 ip2k-ibld.c:163 iq2000-ibld.c:163
45156 +#: m32c-ibld.c:163 m32r-ibld.c:163 mep-ibld.c:163 mt-ibld.c:163
45157 +#: openrisc-ibld.c:163 xc16x-ibld.c:163 xstormy16-ibld.c:163
45159 msgid "operand out of range (%ld not between %ld and %lu)"
45160 msgstr "operand di luar batas (%ld tidak antara %ld dan %lu)"
45162 -#: fr30-ibld.c:179 m32r-ibld.c:179 openrisc-ibld.c:179 xstormy16-ibld.c:179
45163 +#: fr30-ibld.c:184 frv-ibld.c:184 ip2k-ibld.c:184 iq2000-ibld.c:184
45164 +#: m32c-ibld.c:184 m32r-ibld.c:184 mep-ibld.c:184 mt-ibld.c:184
45165 +#: openrisc-ibld.c:184 xc16x-ibld.c:184 xstormy16-ibld.c:184
45167 -msgid "operand out of range (%lu not between 0 and %lu)"
45168 -msgstr "operand di luar batas (%lu tidak antara 0 dan %lu)"
45169 +msgid "operand out of range (0x%lx not between 0 and 0x%lx)"
45170 +msgstr "operand di luar batas (0x%lx tidak antara 0 dan 0x%lx)"
45172 -#: fr30-ibld.c:730 m32r-ibld.c:659 openrisc-ibld.c:633 xstormy16-ibld.c:678
45173 +#: fr30-ibld.c:726 frv-ibld.c:852 ip2k-ibld.c:603 iq2000-ibld.c:709
45174 +#: m32c-ibld.c:1727 m32r-ibld.c:661 mep-ibld.c:1024 mt-ibld.c:745
45175 +#: openrisc-ibld.c:629 xc16x-ibld.c:748 xstormy16-ibld.c:674
45177 msgid "Unrecognized field %d while building insn.\n"
45178 msgstr "Field tidak dikenal %d saat membuild insn.\n"
45180 -#: fr30-ibld.c:937 m32r-ibld.c:792 openrisc-ibld.c:735 xstormy16-ibld.c:826
45181 +#: fr30-ibld.c:931 frv-ibld.c:1169 ip2k-ibld.c:678 iq2000-ibld.c:884
45182 +#: m32c-ibld.c:2888 m32r-ibld.c:798 mep-ibld.c:1444 mt-ibld.c:965
45183 +#: openrisc-ibld.c:729 xc16x-ibld.c:968 xstormy16-ibld.c:820
45185 msgid "Unrecognized field %d while decoding insn.\n"
45186 msgstr "Field tidak dikenal %d saat mendekode insn.\n"
45188 -#: fr30-ibld.c:1086 m32r-ibld.c:902 openrisc-ibld.c:815 xstormy16-ibld.c:939
45189 +#: fr30-ibld.c:1077 frv-ibld.c:1447 ip2k-ibld.c:752 iq2000-ibld.c:1015
45190 +#: m32c-ibld.c:3505 m32r-ibld.c:911 mep-ibld.c:1737 mt-ibld.c:1165
45191 +#: openrisc-ibld.c:806 xc16x-ibld.c:1189 xstormy16-ibld.c:930
45193 msgid "Unrecognized field %d while getting int operand.\n"
45194 msgstr "Field tidak dikenal %d saat memperoleh operand int.\n"
45196 -#: fr30-ibld.c:1215 m32r-ibld.c:992 openrisc-ibld.c:875 xstormy16-ibld.c:1032
45197 +#: fr30-ibld.c:1205 frv-ibld.c:1707 ip2k-ibld.c:808 iq2000-ibld.c:1128
45198 +#: m32c-ibld.c:4104 m32r-ibld.c:1006 mep-ibld.c:2012 mt-ibld.c:1347
45199 +#: openrisc-ibld.c:865 xc16x-ibld.c:1392 xstormy16-ibld.c:1022
45201 msgid "Unrecognized field %d while getting vma operand.\n"
45202 msgstr "Field tidak dikenal %d saat memperoleh operand vma.\n"
45204 -#: fr30-ibld.c:1349 m32r-ibld.c:1090 openrisc-ibld.c:944 xstormy16-ibld.c:1134
45205 +#: fr30-ibld.c:1336 frv-ibld.c:1974 ip2k-ibld.c:867 iq2000-ibld.c:1248
45206 +#: m32c-ibld.c:4691 m32r-ibld.c:1107 mep-ibld.c:2271 mt-ibld.c:1536
45207 +#: openrisc-ibld.c:931 xc16x-ibld.c:1596 xstormy16-ibld.c:1121
45209 msgid "Unrecognized field %d while setting int operand.\n"
45210 msgstr "Field tidak dikenal %d saat menset operand int.\n"
45212 -#: fr30-ibld.c:1471 m32r-ibld.c:1176 openrisc-ibld.c:1001 xstormy16-ibld.c:1224
45213 +#: fr30-ibld.c:1457 frv-ibld.c:2231 ip2k-ibld.c:916 iq2000-ibld.c:1358
45214 +#: m32c-ibld.c:5268 m32r-ibld.c:1198 mep-ibld.c:2520 mt-ibld.c:1715
45215 +#: openrisc-ibld.c:987 xc16x-ibld.c:1790 xstormy16-ibld.c:1210
45217 msgid "Unrecognized field %d while setting vma operand.\n"
45218 msgstr "Field tidak dikenal %d saat menset operand vma.\n"
45220 -#: h8300-dis.c:384
45222 +msgid "missing `]'"
45223 +msgstr "hilang `]'"
45225 +#: frv-asm.c:611 frv-asm.c:621
45226 +msgid "Special purpose register number is out of range"
45227 +msgstr "Nomor register tujuan spesial di luar batas"
45230 +msgid "Value of A operand must be 0 or 1"
45231 +msgstr "Nilai dari operand A harus berupa 0 atau 1"
45234 +msgid "register number must be even"
45235 +msgstr "nomor register harus genap"
45237 +#. -- assembler routines inserted here.
45239 +#: frv-asm.c:972 iq2000-asm.c:56 m32c-asm.c:141 m32c-asm.c:237 m32c-asm.c:279
45240 +#: m32c-asm.c:338 m32c-asm.c:360 m32r-asm.c:53 mep-asm.c:232 mep-asm.c:250
45241 +#: mep-asm.c:265 mep-asm.c:280 mep-asm.c:292 openrisc-asm.c:54
45242 +msgid "missing `)'"
45243 +msgstr "hilang `)'"
45245 +#: h8300-dis.c:327
45249 +msgid "Hmmmm 0x%x"
45250 +msgstr "Hmmmm 0x%x"
45252 -#: h8300-dis.c:395
45253 +#: h8300-dis.c:708
45255 -msgid "Don't understand %x \n"
45256 -msgstr "Tidak mengerti %x \n"
45257 +msgid "Don't understand 0x%x \n"
45258 +msgstr "Tidak mengerti 0x%x \n"
45260 -#: h8500-dis.c:143
45261 +#: h8500-dis.c:124
45263 msgid "can't cope with insert %d\n"
45264 msgstr "tidak dapat menangani insert %d\n"
45266 #. Couldn't understand anything.
45267 -#: h8500-dis.c:350
45268 +#: h8500-dis.c:324
45270 msgid "%02x\t\t*unknown*"
45271 msgstr "%02x\t\t*tidak dikenal*"
45273 -#: i386-dis.c:1649
45274 +#: i386-dis.c:9545
45275 msgid "<internal disassembler error>"
45276 msgstr "<kesalahan asembler internal>"
45278 -#: m10200-dis.c:199
45279 +#: i386-dis.c:9776
45283 +"The following i386/x86-64 specific disassembler options are supported for use\n"
45284 +"with the -M switch (multiple options should be separated by commas):\n"
45287 +"Option disablembler khusus i386/x86-64 berikut ini didukung untuk digunakan dengan\n"
45288 +"pilihan -M (pilihan double seharusnya dipisahkan dengan koma):\n"
45290 +#: i386-dis.c:9780
45292 +msgid " x86-64 Disassemble in 64bit mode\n"
45293 +msgstr " x86-64 Disasemble dalam mode 64bit\n"
45295 +#: i386-dis.c:9781
45297 +msgid " i386 Disassemble in 32bit mode\n"
45298 +msgstr " i386 Disassemble dalam mode 32bit\n"
45300 +#: i386-dis.c:9782
45302 +msgid " i8086 Disassemble in 16bit mode\n"
45303 +msgstr " i8086 Disassemble dalam mode 16bit\n"
45305 +#: i386-dis.c:9783
45307 +msgid " att Display instruction in AT&T syntax\n"
45308 +msgstr " att Tampilkan instruksi dalam sintaks AT&T\n"
45310 +#: i386-dis.c:9784
45312 +msgid " intel Display instruction in Intel syntax\n"
45313 +msgstr " intel Tampilkan instruksi dalam sintaks Intel\n"
45315 +#: i386-dis.c:9785
45319 +" Display instruction in AT&T mnemonic\n"
45322 +" Tampilkan instruksi dalam mnemonic AT&T\n"
45324 +#: i386-dis.c:9787
45327 +" intel-mnemonic\n"
45328 +" Display instruction in Intel mnemonic\n"
45330 +" intel-mnemonic\n"
45331 +" Tampilkan instruksi dalam mnemonic Intel\n"
45333 +#: i386-dis.c:9789
45335 +msgid " addr64 Assume 64bit address size\n"
45336 +msgstr " addr64 Asumsikan ukuran alamat 64bit\n"
45338 +#: i386-dis.c:9790
45340 +msgid " addr32 Assume 32bit address size\n"
45341 +msgstr " addr32 Asumsikan ukuran alamat 32bit\n"
45343 +#: i386-dis.c:9791
45345 +msgid " addr16 Assume 16bit address size\n"
45346 +msgstr " addr16 Asumsikan ukuran alamat 16bit\n"
45348 +#: i386-dis.c:9792
45350 -msgid "unknown\t0x%02x"
45351 -msgstr "tidak dikenal\t0x%02x"
45352 +msgid " data32 Assume 32bit data size\n"
45353 +msgstr " data32 Asumsikan ukuran data 32bit\n"
45355 -#: m10200-dis.c:339
45356 +#: i386-dis.c:9793
45358 +msgid " data16 Assume 16bit data size\n"
45359 +msgstr " data16 Asumsikan ukuran data 16bit\n"
45361 +#: i386-dis.c:9794
45363 +msgid " suffix Always display instruction suffix in AT&T syntax\n"
45364 +msgstr " akhiran Selalu tampilkan akhiran instruksi dalam sintaks AT&T\n"
45366 +#: i386-gen.c:411 ia64-gen.c:307
45368 +msgid "%s: Error: "
45369 +msgstr "%s: Error: "
45373 +msgid "%s: %d: Unknown bitfield: %s\n"
45374 +msgstr "%s: %d: bitfield tidak diketahui: %s\n"
45378 +msgid "can't find i386-opc.tbl for reading, errno = %s\n"
45379 +msgstr "tidak dapat menemukan i386-opc.tbl untuk pembacaan, nomor error = %s\n"
45383 +msgid "can't find i386-reg.tbl for reading, errno = %s\n"
45384 +msgstr "tidak dapat menemukan i386-reg.tbl untuk pembacaan, nomor error = %s\n"
45388 +msgid "can't create i386-init.h, errno = %s\n"
45389 +msgstr "tidak dapat membuat i386-init.h, nomor error = %s\n"
45391 +#: i386-gen.c:1032 ia64-gen.c:2850
45393 +msgid "unable to change directory to \"%s\", errno = %s\n"
45394 +msgstr "tidak dapat mengubah direktori ke \"%s\", nomor error = %s\n"
45396 +#: i386-gen.c:1039
45398 +msgid "%d unused bits in i386_cpu_flags.\n"
45399 +msgstr "%d bit tidak digunakan dalam i386_cpu_flags.\n"
45401 +#: i386-gen.c:1046
45403 +msgid "%d unused bits in i386_operand_type.\n"
45404 +msgstr "%d bit tidak digunakan dalam i386_operand_type.\n"
45406 +#: i386-gen.c:1060
45408 +msgid "can't create i386-tbl.h, errno = %s\n"
45409 +msgstr "tidak dapat membuat i386-tbl.h, nomor error = %s\n"
45413 +msgid "%s: Warning: "
45414 +msgstr "%s: Peringatan: "
45416 +#: ia64-gen.c:506 ia64-gen.c:740
45418 +msgid "multiple note %s not handled\n"
45419 +msgstr "catatan ganda %s tidak ditangani\n"
45422 +msgid "can't find ia64-ic.tbl for reading\n"
45423 +msgstr "tidak dapat menemukan ia64-ic.tbl untuk pembacaan\n"
45427 +msgid "can't find %s for reading\n"
45428 +msgstr "tidak dapat menemukan %s untuk pembacaan\n"
45430 +#: ia64-gen.c:1046
45433 +"most recent format '%s'\n"
45434 +"appears more restrictive than '%s'\n"
45436 +"format paling baru '%s'\n"
45437 +"tampak lebih terbatas dari '%s'\n"
45439 +#: ia64-gen.c:1057
45441 +msgid "overlapping field %s->%s\n"
45442 +msgstr "daerah saling menimpa %s->%s\n"
45444 +#: ia64-gen.c:1254
45446 +msgid "overwriting note %d with note %d (IC:%s)\n"
45447 +msgstr "catatan saling menulis %d dengan catatan %d (IC:%s)\n"
45449 +#: ia64-gen.c:1459
45451 +msgid "don't know how to specify %% dependency %s\n"
45452 +msgstr "tidak tahu bagaimana menspesifikasikan %% ketergantungan %s\n"
45454 +#: ia64-gen.c:1481
45456 +msgid "Don't know how to specify # dependency %s\n"
45457 +msgstr "Tidak tahu bagaimana menspesifikasikan # ketergantungan %s\n"
45459 +#: ia64-gen.c:1520
45461 +msgid "IC:%s [%s] has no terminals or sub-classes\n"
45462 +msgstr "IC:%s [%s] tidak memiliki terminal atau sub-kelas\n"
45464 +#: ia64-gen.c:1523
45466 +msgid "IC:%s has no terminals or sub-classes\n"
45467 +msgstr "IC:%s tidak memiliki terminal atau sub-kelas\n"
45469 +#: ia64-gen.c:1532
45471 +msgid "no insns mapped directly to terminal IC %s [%s]"
45472 +msgstr "tidak ada insns terpetakan secara langsung ke terminal IC %s [%s]"
45474 +#: ia64-gen.c:1535
45476 +msgid "no insns mapped directly to terminal IC %s\n"
45477 +msgstr "tidak ada insns terpetakan langsung ke terminal IC %s\n"
45479 +#: ia64-gen.c:1546
45481 +msgid "class %s is defined but not used\n"
45482 +msgstr "kelas %s didefinisikan tetapi tidak digunakan\n"
45484 +#: ia64-gen.c:1559
45486 +msgid "Warning: rsrc %s (%s) has no chks\n"
45487 +msgstr "Peringatan: rsrc %s (%s) tidak memiliki chks\n"
45489 +#: ia64-gen.c:1562
45491 +msgid "Warning: rsrc %s (%s) has no chks or regs\n"
45492 +msgstr "Peringatan: rsrc %s (%s) tidak memiliki chks atau regs\n"
45494 +#: ia64-gen.c:1566
45496 +msgid "rsrc %s (%s) has no regs\n"
45497 +msgstr "rsrc %s (%s) tidak memiliki regs\n"
45499 +#: ia64-gen.c:2478
45501 +msgid "IC note %d in opcode %s (IC:%s) conflicts with resource %s note %d\n"
45502 +msgstr "IC catatan %d dalam opcode %s (IC:%s) konflik dengan sumber daya %s catatan %d\n"
45504 +#: ia64-gen.c:2506
45506 +msgid "IC note %d for opcode %s (IC:%s) conflicts with resource %s note %d\n"
45507 +msgstr "IC catatan %d untuk opcode %s (IC:%s) konflik dengan sumber data %s catatan %d\n"
45509 +#: ia64-gen.c:2520
45511 +msgid "opcode %s has no class (ops %d %d %d)\n"
45512 +msgstr "opcode %s tidak memiliki kelas (ops %d %d %d)\n"
45514 +#. We've been passed a w. Return with an error message so that
45515 +#. cgen will try the next parsing option.
45517 +msgid "W keyword invalid in FR operand slot."
45518 +msgstr "W kata kunci tidak valid dalam FR operand slot."
45520 +#. Invalid offset present.
45522 +msgid "offset(IP) is not a valid form"
45523 +msgstr "offset(IP) bukan sebuah bentuk valid"
45525 +#. Found something there in front of (DP) but it's out
45528 +msgid "(DP) offset out of range."
45529 +msgstr "(DP) ofset di luar batas."
45531 +#. Found something there in front of (SP) but it's out
45534 +msgid "(SP) offset out of range."
45535 +msgstr "(SP) ofset di luar batas."
45538 +msgid "illegal use of parentheses"
45539 +msgstr "penggunaan tidak legal dari tanda petik"
45542 +msgid "operand out of range (not between 1 and 255)"
45543 +msgstr "operand di luar batas (tidak antara 1 dan 255)"
45545 +#. Something is very wrong. opindex has to be one of the above.
45547 +msgid "parse_addr16: invalid opindex."
45548 +msgstr "parse_addr16: opindex tidak valid."
45551 +msgid "Byte address required. - must be even."
45552 +msgstr "Alamat byte dibutuhkan. - harus genap."
45555 +msgid "cgen_parse_address returned a symbol. Literal required."
45556 +msgstr "cgen_parse_address mengembalikan sebuah simbol. Literal dibutuhkan."
45559 +msgid "percent-operator operand is not a symbol"
45560 +msgstr "percent-operator operand bukan sebuah simbol"
45563 +msgid "Attempt to find bit index of 0"
45564 +msgstr "Mencoba untuk menemukan bit index dari 0"
45566 +#: iq2000-asm.c:112 iq2000-asm.c:142
45567 +msgid "immediate value cannot be register"
45568 +msgstr "nilai langsung tidak dapat berupa register"
45570 +#: iq2000-asm.c:123 iq2000-asm.c:153
45571 +msgid "immediate value out of range"
45572 +msgstr "nilai langsung di luar batas"
45574 +#: iq2000-asm.c:182
45575 +msgid "21-bit offset out of range"
45576 +msgstr "21-bit ofset di luar batas"
45578 +#: m10200-dis.c:158 m10300-dis.c:582
45580 msgid "unknown\t0x%04lx"
45581 msgstr "tidak dikenal\t0x%04lx"
45583 -#: m10300-dis.c:685
45584 +#: m10200-dis.c:328
45586 -msgid "unknown\t0x%04x"
45587 -msgstr "tidak dikenal\t0x%04x"
45588 +msgid "unknown\t0x%02lx"
45589 +msgstr "tidak dikenal\t0x%02lx"
45592 +msgid "imm:6 immediate is out of range"
45593 +msgstr "imm:6 nilai langsung di luar batas"
45598 -msgid "<internal error in opcode table: %s %s>\n"
45599 -msgstr "<kesalahan internal dalam tabel opcode: %s %s>\n"
45600 +msgid "%dsp8() takes a symbolic address, not a number"
45601 +msgstr "%dsp8() mengambil sebuah alamat simbolik, bukan sebuah angka"
45603 +#: m32c-asm.c:160 m32c-asm.c:164 m32c-asm.c:255
45604 +msgid "dsp:8 immediate is out of range"
45605 +msgstr "dsp:8 nilai langsung di luar batas"
45607 +#: m32c-asm.c:185 m32c-asm.c:189
45608 +msgid "Immediate is out of range -8 to 7"
45609 +msgstr "nilai langsung di luar dari jangkauan -8 ke 7"
45611 +#: m32c-asm.c:210 m32c-asm.c:214
45612 +msgid "Immediate is out of range -7 to 8"
45613 +msgstr "nilai langsung di luar dari jangkauan -7 ke 8"
45617 +msgid "%dsp16() takes a symbolic address, not a number"
45618 +msgstr "%dsp16() mengambil sebuah alamat simbolik, tetapi bukan sebuah angka"
45620 +#: m32c-asm.c:308 m32c-asm.c:315 m32c-asm.c:378
45621 +msgid "dsp:16 immediate is out of range"
45622 +msgstr "dsp:16 nilai langsung di luar batas"
45625 +msgid "dsp:20 immediate is out of range"
45626 +msgstr "dsp:20 nilai langsung di luar batas"
45628 +#: m32c-asm.c:430 m32c-asm.c:450
45629 +msgid "dsp:24 immediate is out of range"
45630 +msgstr "dsp:24 nilai langsung di luar batas"
45633 +msgid "immediate is out of range 1-2"
45634 +msgstr "nilai langsung di luar dari jangkauan 1-2"
45637 +msgid "immediate is out of range 1-8"
45638 +msgstr "nilai langsung di luar dari jangkauan 1-8"
45641 +msgid "immediate is out of range 0-7"
45642 +msgstr "nilai langsung di luar dari jangkauan 0-7"
45645 +msgid "immediate is out of range 2-9"
45646 +msgstr "nilai langsung di luar dari jangkauan 2-9"
45648 -#: m68k-dis.c:1007
45650 +msgid "Bit number for indexing general register is out of range 0-15"
45651 +msgstr "Nomor bit untuk register umum pengindeksan diluar dari jangkauan 0-15"
45653 +#: m32c-asm.c:611 m32c-asm.c:667
45654 +msgid "bit,base is out of range"
45655 +msgstr "bit,bas di luar batas"
45657 +#: m32c-asm.c:618 m32c-asm.c:623 m32c-asm.c:671
45658 +msgid "bit,base out of range for symbol"
45659 +msgstr "bit,base di luar dari jangkauan untuk simbol"
45662 +msgid "not a valid r0l/r0h pair"
45663 +msgstr "bukan sebuah valid pasangan r0l/r0h"
45666 +msgid "Invalid size specifier"
45667 +msgstr "Ukuran penspesifikasi tidak valid"
45669 +#: m68k-dis.c:1163
45671 msgid "<function code %d>"
45672 msgstr "<kode fungsi %d>"
45675 +#: m68k-dis.c:1320
45677 +msgid "<internal error in opcode table: %s %s>\n"
45678 +msgstr "<kesalahan internal dalam tabel opcode: %s %s>\n"
45682 +msgid "# <dis error: %08lx>"
45683 +msgstr "# <kesalahan dis: %08lx>"
45686 +msgid "Only $tp or $13 allowed for this opcode"
45687 +msgstr "Hanya $tp atau $13 diperbolehkan untuk opcode ini"
45690 +msgid "Only $sp or $15 allowed for this opcode"
45691 +msgstr "Hanya $sp atau $15 diperbolehkan untuk opcode ini"
45693 +#: mep-asm.c:299 mep-asm.c:455
45695 +msgid "invalid %function() here"
45696 +msgstr "%function disini tidak valid"
45699 +msgid "# internal error, incomplete extension sequence (+)"
45700 +msgstr "# internal error, urutan ekstensi (+) tidak lengkap"
45704 -msgid "# <dis error: %08x>"
45705 -msgstr "# <kesalahan dis: %08x>"
45706 +msgid "# internal error, undefined extension sequence (+%c)"
45707 +msgstr "# kesalahan internal, tidak terdefinisi urutan ekstensi(+%c)"
45710 +#: mips-dis.c:1274
45712 -msgid "# internal error, undefined modifier(%c)"
45713 -msgstr "# kesalahan internal, modifier tidak didefinisikan(%c)"
45714 +msgid "# internal error, undefined modifier (%c)"
45715 +msgstr "# kesalahan internal, tidak terdefinisi pemodifikasi(%c)"
45717 -#: mips-dis.c:1154
45718 +#: mips-dis.c:1881
45720 msgid "# internal disassembler error, unrecognised modifier (%c)"
45721 msgstr "# kesalahan internal disasembler, modifier tidak dikenal (%c)"
45724 +#: mips-dis.c:2112
45728 +"The following MIPS specific disassembler options are supported for use\n"
45729 +"with the -M switch (multiple options should be separated by commas):\n"
45732 +"Pilihan disablembler khusus MIPS berikut ini didukung untuk digunakan dengan\n"
45733 +"pilihan -M (pilihan ganda seharusnya dipisahkan dengan koma):\n"
45735 +#: mips-dis.c:2116
45739 +" gpr-names=ABI Print GPR names according to specified ABI.\n"
45740 +" Default: based on binary being disassembled.\n"
45743 +" gpr-names=ABI Tampilkan nama GPR menurut ABI yang dispesifikasikan.\n"
45744 +" Baku: berdasar dari binari yang sedang diassembled.\n"
45746 +#: mips-dis.c:2120
45750 +" fpr-names=ABI Print FPR names according to specified ABI.\n"
45751 +" Default: numeric.\n"
45754 +" fpr-names=ABI Tampilkan nama FPR menurut ABI yang dispesifikasikan.\n"
45755 +" Baku: numerik.\n"
45757 +#: mips-dis.c:2124
45761 +" cp0-names=ARCH Print CP0 register names according to\n"
45762 +" specified architecture.\n"
45763 +" Default: based on binary being disassembled.\n"
45766 +" cp0-names=ARCH Tampilkan nama register CP0 menurut arsitektur\n"
45767 +" yang dispesifikasikan.\n"
45768 +" Baku: berdasar dari binari yang sedang diassembled.\n"
45770 +#: mips-dis.c:2129
45774 +" hwr-names=ARCH Print HWR names according to specified \n"
45775 +"\t\t\t architecture.\n"
45776 +" Default: based on binary being disassembled.\n"
45779 +" hwr-names=ARCH Tampilkan nama HWR menurut arsitektur\n"
45780 +"\t\t\t yang dispesifikasikan.\n"
45781 +" Baku: berdasar dari binari yang sedang diassembled.\n"
45783 +#: mips-dis.c:2134
45787 +" reg-names=ABI Print GPR and FPR names according to\n"
45788 +" specified ABI.\n"
45791 +" reg-names=ABI Tampilkan nama GPR dan FPR menurut ABI yang\n"
45792 +" dispesifikasikan.\n"
45794 +#: mips-dis.c:2138
45798 +" reg-names=ARCH Print CP0 register and HWR names according to\n"
45799 +" specified architecture.\n"
45802 +" reg-names=ARCH Tampilkan nama register CP0 dan HWR menurut\n"
45803 +" arsitektur yang dispesifikasikan.\n"
45805 +#: mips-dis.c:2142
45809 +" For the options above, the following values are supported for \"ABI\":\n"
45813 +" Untuk pilihan diatas, nilai berikut didukung untuk \"ABI\":\n"
45816 +#: mips-dis.c:2147 mips-dis.c:2155 mips-dis.c:2157
45821 +#: mips-dis.c:2149
45825 +" For the options above, The following values are supported for \"ARCH\":\n"
45829 +" Untuk pilihan diatas, nilai berikut didukung untuk \"ARCH\":\n"
45834 msgid "Bad case %d (%s) in %s:%d\n"
45835 msgstr "Case buruk %d (%s) dalam %s:%d\n"
45840 msgid "Internal: Non-debugged code (test-case missing): %s:%d"
45841 msgstr "Internal: Kode belum didebug (tidak ada test-case): %s:%d"
45846 msgstr "(tidak dikenal)"
45851 msgid "*unknown operands type: %d*"
45852 msgstr "*tipe operand tidak dikenal: %d*"
45854 +#: mt-asm.c:110 mt-asm.c:190
45855 +msgid "Operand out of range. Must be between -32768 and 32767."
45856 +msgstr "Operand di luar batas. Harus berada diantara -32768 dan 32767."
45859 +msgid "Biiiig Trouble in parse_imm16!"
45860 +msgstr "Masalah BESAR dalam parse_imm16!"
45863 +msgid "The percent-operator's operand is not a symbol"
45864 +msgstr "Operand percent-operator bukan sebuah simbol"
45867 +msgid "invalid operand. type may have values 0,1,2 only."
45868 +msgstr "operand tidak valid. tipe mungkin hanya memiliki nilai 0,1,2."
45870 #. I and Z are output operands and can`t be immediate
45871 -#. * A is an address and we can`t have the address of
45872 -#. * an immediate either. We don't know how much to increase
45873 -#. * aoffsetp by since whatever generated this is broken
45876 -#: ns32k-dis.c:628
45877 +#. A is an address and we can`t have the address of
45878 +#. an immediate either. We don't know how much to increase
45879 +#. aoffsetp by since whatever generated this is broken
45881 +#: ns32k-dis.c:534
45883 msgid "$<undefined>"
45884 msgstr "$<tidak didefinisikan>"
45886 -#: ppc-opc.c:765 ppc-opc.c:798
45887 +#: ppc-opc.c:862 ppc-opc.c:890
45888 msgid "invalid conditional option"
45889 msgstr "option kondisional tidak valid"
45893 msgid "attempt to set y bit when using + or - modifier"
45894 msgstr "berusaha menset bit y saat menggunakan modifier + atau -"
45896 -#: ppc-opc.c:832 ppc-opc.c:884
45897 -msgid "offset not a multiple of 4"
45898 -msgstr "offset bukan kelipatan 4"
45901 -msgid "offset not between -2048 and 2047"
45902 -msgstr "offset tidak berada antara -2048 dan 2047"
45905 -msgid "offset not between -8192 and 8191"
45906 -msgstr "offset tidak berada antara -8192 dan 8191"
45908 +msgid "invalid mask field"
45909 +msgstr "topeng daerah tidak valid"
45912 -msgid "ignoring least significant bits in branch offset"
45913 -msgstr "mengabaikan least significant bit dalam offset cabang"
45915 +msgid "ignoring invalid mfcr mask"
45916 +msgstr "mengabaikan topeng mfcr tidak valid"
45918 -#: ppc-opc.c:944 ppc-opc.c:981
45919 +#: ppc-opc.c:1000 ppc-opc.c:1035
45920 msgid "illegal bitmask"
45921 msgstr "bitmask ilegal"
45924 -msgid "value out of range"
45925 -msgstr "nilai di luar batas"
45929 msgid "index register in load range"
45930 msgstr "register indeks dalam daerah pemuatan"
45934 +msgid "source and target register operands must be different"
45935 +msgstr "sumber dan target operand register harus berbeda"
45938 msgid "invalid register operand when updating"
45939 msgstr "operand register tidak valid saat mengupdate"
45941 -#. Mark as non-valid instruction
45942 -#: sparc-dis.c:750
45944 -msgstr "tidak dikenal"
45946 +msgid "invalid sprg number"
45947 +msgstr "nomor sprg tidak valid"
45953 +"The following S/390 specific disassembler options are supported for use\n"
45954 +"with the -M switch (multiple options should be separated by commas):\n"
45957 +"Pilihan disablembler khusus S/390 berikut ini didukung untuk digunakan dengan\n"
45958 +"pilihan -M (pilihan ganda seharusnya dipisahkan dengan koma):\n"
45962 +msgid " esa Disassemble in ESA architecture mode\n"
45963 +msgstr " esa Disassemble dalam mode arsitektur ESA\n"
45965 -#: sparc-dis.c:825
45968 +msgid " zarch Disassemble in z/Architecture mode\n"
45969 +msgstr " zarch Disassemble dalam mode z/Architecture\n"
45971 +#: score-dis.c:220 score-dis.c:383
45972 +msgid "<illegal instruction>"
45973 +msgstr "<instruksi tidak legal>"
45975 +#: sparc-dis.c:282
45977 msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
45978 msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
45980 -#: sparc-dis.c:836
45981 +#: sparc-dis.c:293
45983 msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
45984 msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
45986 -#: sparc-dis.c:885
45987 +#: sparc-dis.c:343
45989 msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"
45990 msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\" == \"%s\"\n"
45993 +#. Mark as non-valid instruction.
45994 +#: sparc-dis.c:1013
45996 +msgstr "tidak dikenal"
46000 msgid "unknown operand shift: %x\n"
46001 msgstr "shift operand tidak dikenal: %x\n"
46006 msgid "unknown pop reg: %d\n"
46007 msgstr "reg pop tidak dikenal: %d\n"
46008 @@ -350,74 +1059,122 @@ msgstr "reg pop tidak dikenal: %d\n"
46009 #. v850_insert_operand() in gas/config/tc-v850.c. Error messages
46010 #. containing the string 'out of range' will be ignored unless a
46011 #. specific command line option is given to GAS.
46014 msgid "displacement value is not in range and is not aligned"
46015 msgstr "nilai displacement tidak dalam jangkauan dan tidak rata"
46019 msgid "displacement value is out of range"
46020 msgstr "nilai displacement di luar batas"
46024 msgid "displacement value is not aligned"
46025 msgstr "nilai displacement tidak rata"
46029 msgid "immediate value is out of range"
46030 msgstr "nilai langsung di luar batas"
46034 msgid "branch value not in range and to odd offset"
46035 msgstr "nilai cabang tidak dalam jangkauan"
46037 -#: v850-opc.c:85 v850-opc.c:117
46038 +#: v850-opc.c:62 v850-opc.c:89
46039 msgid "branch value out of range"
46040 msgstr "nilai cabang di luar jangkauan"
46042 -#: v850-opc.c:88 v850-opc.c:120
46043 +#: v850-opc.c:65 v850-opc.c:92
46044 msgid "branch to odd offset"
46045 msgstr "cabang offset ganjil"
46049 msgid "branch value not in range and to an odd offset"
46050 msgstr "nilai cabang di luar jangkauan dan offset ganjil"
46054 msgid "invalid register for stack adjustment"
46055 msgstr "register tidak valid untuk penyesuaian stack"
46059 msgid "immediate value not in range and not even"
46060 msgstr "nilai langsung tidak dalam jangkauan dan tidak genap"
46064 msgid "immediate value must be even"
46065 msgstr "nilai langsung harus genap"
46067 -#: xstormy16-asm.c:74
46069 +msgid "Missing '#' prefix"
46070 +msgstr "Hilang awalan '#'"
46073 +msgid "Missing '.' prefix"
46074 +msgstr "Hilang awalan '.'"
46077 +msgid "Missing 'pof:' prefix"
46078 +msgstr "Hilang awalan 'pof:'"
46080 +#: xc16x-asm.c:114
46081 +msgid "Missing 'pag:' prefix"
46082 +msgstr "Hilang awalan 'pag:'"
46084 +#: xc16x-asm.c:130
46085 +msgid "Missing 'sof:' prefix"
46086 +msgstr "Hilang awalan 'sof:'"
46088 +#: xc16x-asm.c:146
46089 +msgid "Missing 'seg:' prefix"
46090 +msgstr "Hilanga awalan 'seg:'"
46092 +#: xstormy16-asm.c:71
46093 msgid "Bad register in preincrement"
46094 msgstr "register buruk dalam preinkremen"
46096 -#: xstormy16-asm.c:79
46097 +#: xstormy16-asm.c:76
46098 msgid "Bad register in postincrement"
46099 msgstr "Register buruk dalam pascainkremen"
46101 -#: xstormy16-asm.c:81
46102 +#: xstormy16-asm.c:78
46103 msgid "Bad register name"
46104 msgstr "Nama register buruk"
46106 -#: xstormy16-asm.c:85
46107 +#: xstormy16-asm.c:82
46108 msgid "Label conflicts with register name"
46109 msgstr "Label konflik dengan nama register"
46111 -#: xstormy16-asm.c:89
46112 +#: xstormy16-asm.c:86
46113 msgid "Label conflicts with `Rx'"
46114 msgstr "Label konflik dengan `Rx'"
46116 -#: xstormy16-asm.c:91
46117 +#: xstormy16-asm.c:88
46118 msgid "Bad immediate expression"
46119 msgstr "Ekspresi langsung yang buruk"
46121 -#: xstormy16-asm.c:120
46122 +#: xstormy16-asm.c:109
46123 +msgid "No relocation for small immediate"
46124 +msgstr "Tidak ada relokasi untuk immediate kecil"
46126 +#: xstormy16-asm.c:119
46127 msgid "Small operand was not an immediate number"
46128 msgstr "Operand kecil bukan sebuah angka immediate"
46130 +#: xstormy16-asm.c:157
46131 +msgid "Operand is not a symbol"
46132 +msgstr "Operand bukan sebuah simbol"
46134 +#: xstormy16-asm.c:165
46135 +msgid "Syntax error: No trailing ')'"
46136 +msgstr "Sintaks error: Tidak ada akhiran ')'"
46138 +#~ msgid "unknown\t0x%04x"
46139 +#~ msgstr "tidak dikenal\t0x%04x"
46141 +#~ msgid "offset not between -2048 and 2047"
46142 +#~ msgstr "offset tidak berada antara -2048 dan 2047"
46144 +#~ msgid "offset not between -8192 and 8191"
46145 +#~ msgstr "offset tidak berada antara -8192 dan 8191"
46147 +#~ msgid "ignoring least significant bits in branch offset"
46148 +#~ msgstr "mengabaikan least significant bit dalam offset cabang"
46149 diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c
46150 index c872db5..5e70395 100644
46151 --- a/opcodes/ppc-opc.c
46152 +++ b/opcodes/ppc-opc.c
46153 @@ -4560,8 +4560,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
46155 {"lhbrx", X(31,790), X_MASK, COM, PPCNONE, {RT, RA0, RB}},
46157 -{"lfqx", X(31,791), X_MASK, POWER2, PPCNONE, {FRT, RA, RB}},
46158 {"lfdpx", X(31,791), X_MASK, POWER6, POWER7, {FRT, RA, RB}},
46159 +{"lfqx", X(31,791), X_MASK, POWER2, PPCNONE, {FRT, RA, RB}},
46161 {"sraw", XRC(31,792,0), X_MASK, PPCCOM, PPCNONE, {RA, RS, RB}},
46162 {"sra", XRC(31,792,0), X_MASK, PWRCOM, PPCNONE, {RA, RS, RB}},
46163 @@ -4638,8 +4638,8 @@ const struct powerpc_opcode powerpc_opcodes[] = {
46165 {"sthbrx", X(31,918), X_MASK, COM, PPCNONE, {RS, RA0, RB}},
46167 -{"stfqx", X(31,919), X_MASK, POWER2, PPCNONE, {FRS, RA, RB}},
46168 {"stfdpx", X(31,919), X_MASK, POWER6, PPCNONE, {FRS, RA, RB}},
46169 +{"stfqx", X(31,919), X_MASK, POWER2, PPCNONE, {FRS, RA, RB}},
46171 {"sraq", XRC(31,920,0), X_MASK, M601, PPCNONE, {RA, RS, RB}},
46172 {"sraq.", XRC(31,920,1), X_MASK, M601, PPCNONE, {RA, RS, RB}},
46173 @@ -4801,12 +4801,12 @@ const struct powerpc_opcode powerpc_opcodes[] = {
46175 {"psq_l", OP(56), OP_MASK, PPCPS, PPCNONE, {FRT,PSD,RA,PSW,PSQ}},
46177 +{"lfdp", OP(57), OP_MASK, POWER6, POWER7, {FRT, D, RA0}},
46179 {"lfqu", OP(57), OP_MASK, POWER2, PPCNONE, {FRT, D, RA0}},
46181 {"psq_lu", OP(57), OP_MASK, PPCPS, PPCNONE, {FRT,PSD,RA,PSW,PSQ}},
46183 -{"lfdp", OP(57), OP_MASK, POWER6, POWER7, {FRT, D, RA0}},
46185 {"ld", DSO(58,0), DS_MASK, PPC64, PPCNONE, {RT, DS, RA0}},
46186 {"ldu", DSO(58,1), DS_MASK, PPC64, PPCNONE, {RT, DS, RAL}},
46187 {"lwa", DSO(58,2), DS_MASK, PPC64, PPCNONE, {RT, DS, RA0}},
46188 @@ -4921,10 +4921,6 @@ const struct powerpc_opcode powerpc_opcodes[] = {
46189 {"fcfidus", XRC(59,974,0), XRA_MASK, POWER7, PPCNONE, {FRT, FRB}},
46190 {"fcfidus.", XRC(59,974,1), XRA_MASK, POWER7, PPCNONE, {FRT, FRB}},
46192 -{"stfq", OP(60), OP_MASK, POWER2, PPCNONE, {FRS, D, RA}},
46194 -{"psq_st", OP(60), OP_MASK, PPCPS, PPCNONE, {FRS,PSD,RA,PSW,PSQ}},
46196 {"xxsldwi", XX3(60,2), XX3SHW_MASK, PPCVSX, PPCNONE, {XT6, XA6, XB6, SHW}},
46197 {"xxsel", XX4(60,3), XX4_MASK, PPCVSX, PPCNONE, {XT6, XA6, XB6, XC6}},
46198 {"xxspltd", XX3(60,10), XX3DM_MASK, PPCVSX, PPCNONE, {XT6, XA6, XB6S, DMEX}},
46199 @@ -5067,12 +5063,16 @@ const struct powerpc_opcode powerpc_opcodes[] = {
46200 {"xvcvsxddp", XX2(60,504), XX2_MASK, PPCVSX, PPCNONE, {XT6, XB6}},
46201 {"xvnegdp", XX2(60,505), XX2_MASK, PPCVSX, PPCNONE, {XT6, XB6}},
46203 -{"psq_stu", OP(61), OP_MASK, PPCPS, PPCNONE, {FRS,PSD,RA,PSW,PSQ}},
46204 +{"stfq", OP(60), OP_MASK, POWER2, PPCNONE, {FRS, D, RA}},
46206 -{"stfqu", OP(61), OP_MASK, POWER2, PPCNONE, {FRS, D, RA}},
46207 +{"psq_st", OP(60), OP_MASK, PPCPS, PPCNONE, {FRS,PSD,RA,PSW,PSQ}},
46209 {"stfdp", OP(61), OP_MASK, POWER6, PPCNONE, {FRT, D, RA0}},
46211 +{"stfqu", OP(61), OP_MASK, POWER2, PPCNONE, {FRS, D, RA}},
46213 +{"psq_stu", OP(61), OP_MASK, PPCPS, PPCNONE, {FRS,PSD,RA,PSW,PSQ}},
46215 {"std", DSO(62,0), DS_MASK, PPC64, PPCNONE, {RS, DS, RA0}},
46216 {"stdu", DSO(62,1), DS_MASK, PPC64, PPCNONE, {RS, DS, RAS}},
46217 {"stq", DSO(62,2), DS_MASK, POWER4, PPCNONE, {RSQ, DS, RA0}},