]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-archer.patch
bbc7ff90c76d796a49862ccb2f1556508f1df2b3
[packages/gdb.git] / gdb-archer.patch
1 http://sourceware.org/gdb/wiki/ProjectArcher
2 http://sourceware.org/gdb/wiki/ArcherBranchManagement
3
4 GIT snapshot:
5 commit e734ed95d296a3342d4147873c4641cea6c4d7fe
6
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
14         archer-tromey-python
15 archer-jankratochvil-vla
16         archer-jankratochvil-type-refcount
17 archer-pmuldoon-exception-rewind-master
18 archer-sergio-catch-syscall
19 archer-tromey-charset
20 archer-tromey-delayed-symfile
21
22
23 diff --git a/bfd/po/es.po b/bfd/po/es.po
24 index 9f2ec21..e4410d7 100644
25 --- a/bfd/po/es.po
26 +++ b/bfd/po/es.po
27 @@ -1,13 +1,14 @@
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
35  #
36  msgid ""
37  msgstr ""
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"
48  "MIME-Version: 1.0\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"
52  
53 -#: aoutx.h:1268 aoutx.h:1602
54 +#: aoutx.h:1268 aoutx.h:1604
55  #, c-format
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"
58  
59 -#: aoutx.h:1568
60 +#: aoutx.h:1570
61  #, c-format
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"
64  
65 -#: aoutx.h:1570
66 +#: aoutx.h:1572
67  msgid "*unknown*"
68  msgstr "*desconocido*"
69  
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"
74  
75 -#: aoutx.h:5347
76 +#: aoutx.h:5349
77  #, c-format
78  msgid "%s: relocatable link from %s to %s not supported"
79  msgstr "%s: no se admite el enlace reubicable de %s a %s"
80  
81 -#: archive.c:1766
82 +#: archive.c:2046
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"
85  
86  # ¡Uff! Si utilizáramos file=archivo, esta traducción sería imposible. cfuga
87 -#: archive.c:2029
88 +#: archive.c:2309
89  msgid "Reading archive file mod timestamp"
90  msgstr "Se lee el archivo de la modificación de marca de tiempo del fichero"
91  
92 -#: archive.c:2053
93 +#: archive.c:2333
94  msgid "Writing updated armap timestamp"
95  msgstr "Se escribe la marca de tiempo actualizada de armap"
96  
97 -#: bfd.c:289
98 +#: bfd.c:368
99  msgid "No error"
100  msgstr "No hay error"
101  
102 -#: bfd.c:290
103 +#: bfd.c:369
104  msgid "System call error"
105  msgstr "Error en la llamada al sistema"
106  
107 -#: bfd.c:291
108 +#: bfd.c:370
109  msgid "Invalid bfd target"
110  msgstr "Objetivo bfd inválido"
111  
112 -#: bfd.c:292
113 +#: bfd.c:371
114  msgid "File in wrong format"
115  msgstr "Fichero en formato erróneo"
116  
117 -#: bfd.c:293
118 +#: bfd.c:372
119  msgid "Archive object file in wrong format"
120  msgstr "Archivo de ficheros objeto en formato erróneo"
121  
122 -#: bfd.c:294
123 +#: bfd.c:373
124  msgid "Invalid operation"
125  msgstr "Operación inválida"
126  
127 -#: bfd.c:295
128 +#: bfd.c:374
129  msgid "Memory exhausted"
130  msgstr "Memoria agotada"
131  
132 -#: bfd.c:296
133 +#: bfd.c:375
134  msgid "No symbols"
135  msgstr "No hay símbolos"
136  
137 -#: bfd.c:297
138 +#: bfd.c:376
139  msgid "Archive has no index; run ranlib to add one"
140  msgstr "El archivo no tiene índice; ejecute ranlib para agregar uno"
141  
142 -#: bfd.c:298
143 +#: bfd.c:377
144  msgid "No more archived files"
145  msgstr "No hay más ficheros archivados"
146  
147 -#: bfd.c:299
148 +#: bfd.c:378
149  msgid "Malformed archive"
150  msgstr "Archivo malformado"
151  
152 -#: bfd.c:300
153 +#: bfd.c:379
154  msgid "File format not recognized"
155  msgstr "No se reconoce el formato del fichero"
156  
157 -#: bfd.c:301
158 +#: bfd.c:380
159  msgid "File format is ambiguous"
160  msgstr "El formato del fichero es ambiguo"
161  
162 -#: bfd.c:302
163 +#: bfd.c:381
164  msgid "Section has no contents"
165  msgstr "La sección no tiene contenidos"
166  
167 -#: bfd.c:303
168 +#: bfd.c:382
169  msgid "Nonrepresentable section on output"
170  msgstr "Sección no representable en la salida"
171  
172 -#: bfd.c:304
173 +#: bfd.c:383
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"
176  
177 -#: bfd.c:305
178 +#: bfd.c:384
179  msgid "Bad value"
180  msgstr "Valor erróneo"
181  
182 -#: bfd.c:306
183 +#: bfd.c:385
184  msgid "File truncated"
185  msgstr "Fichero truncado"
186  
187 -#: bfd.c:307
188 +#: bfd.c:386
189  msgid "File too big"
190  msgstr "Fichero demasiado grande"
191  
192 -#: bfd.c:308
193 +#: bfd.c:387
194  #, c-format
195  msgid "Error reading %s: %s"
196  msgstr "Error al leer %s: %s"
197  
198 -#: bfd.c:309
199 +#: bfd.c:388
200  msgid "#<Invalid error code>"
201  msgstr "#<Código de error inválido>"
202  
203 -#: bfd.c:830
204 +#: bfd.c:912
205  #, c-format
206  msgid "BFD %s assertion fail %s:%d"
207  msgstr "falló la aseveración BFD %s %s:%d"
208  
209 -#: bfd.c:842
210 +#: bfd.c:924
211  #, c-format
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"
214  
215 -#: bfd.c:846
216 +#: bfd.c:928
217  #, c-format
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"
220  
221 -#: bfd.c:848
222 +#: bfd.c:930
223  msgid "Please report this bug.\n"
224  msgstr "Por favor reporte este bicho.\n"
225  
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."
229  
230 -#: cache.c:238
231 +#: cache.c:222
232  msgid "reopening %B: %s\n"
233  msgstr "se reabre %B: %s\n"
234  
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"
238 -
239  #: coff-alpha.c:490
240  msgid ""
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"
245  
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"
250  
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"
254  
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"
261  
262 -#: coff-arm.c:1036
263 +#: coff-arm.c:1039
264  #, c-format
265  msgid "%B: unable to find THUMB glue '%s' for `%s'"
266  msgstr "%B: no se puede encontrar el pegamento THUMB '%s' para `%s'"
267  
268 -#: coff-arm.c:1065
269 +#: coff-arm.c:1068
270  #, c-format
271  msgid "%B: unable to find ARM glue '%s' for `%s'"
272  msgstr "%B: no se puede encontrar el pegamento ARM '%s' para `%s'"
273  
274 -#: coff-arm.c:1367 elf32-arm.c:4167
275 +#: coff-arm.c:1370 elf32-arm.c:5453
276  #, c-format
277  msgid ""
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"
282  
283 -#: coff-arm.c:1457
284 +#: coff-arm.c:1460
285  #, c-format
286  msgid ""
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"
291  
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'"
296  
297 -#: coff-arm.c:2075
298 +#: coff-arm.c:2080
299  msgid "%B: illegal symbol index in reloc: %d"
300  msgstr "%B: índice de símbolos ilegal en la reubicación: %d"
301  
302 -#: coff-arm.c:2206
303 +#: coff-arm.c:2211
304  #, c-format
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"
307  
308 -#: coff-arm.c:2222 elf32-arm.c:7072
309 +#: coff-arm.c:2227 elf32-arm.c:8563
310  #, c-format
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"
313  
314 -#: coff-arm.c:2225 elf32-arm.c:7076
315 +#: coff-arm.c:2230 elf32-arm.c:8567
316  #, c-format
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"
319  
320 -#: coff-arm.c:2239
321 +#: coff-arm.c:2244
322  #, c-format
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"
325  
326 -#: coff-arm.c:2242
327 +#: coff-arm.c:2247
328  #, c-format
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"
331  
332 -#: coff-arm.c:2270 elf32-arm.c:7141
333 +#: coff-arm.c:2275 elf32-arm.c:8632
334  #, c-format
335  msgid "Warning: %B supports interworking, whereas %B does not"
336  msgstr "Aviso: %B admite interoperabilidad, mientras que %B no"
337  
338 -#: coff-arm.c:2273 elf32-arm.c:7147
339 +#: coff-arm.c:2278 elf32-arm.c:8638
340  #, c-format
341  msgid "Warning: %B does not support interworking, whereas %B does"
342  msgstr "Aviso: %B no admite interoperabilidad, mientras que %B sí"
343  
344 -#: coff-arm.c:2297
345 +#: coff-arm.c:2302
346  #, c-format
347  msgid "private flags = %x:"
348  msgstr "opciones privadas = %x:"
349  
350 -#: coff-arm.c:2305 elf32-arm.c:7198
351 +#: coff-arm.c:2310 elf32-arm.c:8689
352  #, c-format
353  msgid " [floats passed in float registers]"
354  msgstr "[números de coma flotante pasados en registros de coma flotante]"
355  
356 -#: coff-arm.c:2307
357 +#: coff-arm.c:2312
358  #, c-format
359  msgid " [floats passed in integer registers]"
360  msgstr "[números de coma flotante pasados en registros enteros]"
361  
362 -#: coff-arm.c:2310 elf32-arm.c:7201
363 +#: coff-arm.c:2315 elf32-arm.c:8692
364  #, c-format
365  msgid " [position independent]"
366  msgstr "[independiente de posición]"
367  
368 -#: coff-arm.c:2312
369 +#: coff-arm.c:2317
370  #, c-format
371  msgid " [absolute position]"
372  msgstr "[posición absoluta]"
373  
374 -#: coff-arm.c:2316
375 +#: coff-arm.c:2321
376  #, c-format
377  msgid " [interworking flag not initialised]"
378  msgstr "[no se inicializó la opción de interoperabilidad]"
379  
380 -#: coff-arm.c:2318
381 +#: coff-arm.c:2323
382  #, c-format
383  msgid " [interworking supported]"
384  msgstr "[admite interoperabilidad]"
385  
386 -#: coff-arm.c:2320
387 +#: coff-arm.c:2325
388  #, c-format
389  msgid " [interworking not supported]"
390  msgstr "[no admite interoperabilidad]"
391  
392 -#: coff-arm.c:2366 elf32-arm.c:6578
393 +#: coff-arm.c:2371 elf32-arm.c:8050
394  #, c-format
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"
397  
398 -#: coff-arm.c:2370 elf32-arm.c:6582
399 +#: coff-arm.c:2375 elf32-arm.c:8054
400  #, c-format
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"
403  
404 -#: coffcode.h:850
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'"
407 -
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.
411 -#: coffcode.h:1062
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"
414 -
415 -#: coffcode.h:1117
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)"
418 -
419 -#: coffcode.h:2236
420 -#, c-format
421 -msgid "Unrecognized TI COFF target id '0x%x'"
422 -msgstr "No se reconoce el id de objetivo TI COFF '0x%x'"
423 -
424 -#: coffcode.h:2551
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"
427 -
428 -#: coffcode.h:4296
429 -msgid "%B: warning: line number table read failed"
430 -msgstr "%B: aviso: falló la lectura de tabla de números de línea"
431 -
432 -#: coffcode.h:4329
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"
435 -
436 -#: coffcode.h:4343
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'"
439 -
440 -#: coffcode.h:4735
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'"
443 -
444 -#: coffcode.h:4861
445 -msgid "warning: %B: local symbol `%s' has no section"
446 -msgstr "aviso: %B: el símbolo local `%s' no tiene sección"
447 -
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"
451 -
452 -#: coffcode.h:5004
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"
455 -
456 -#: coffgen.c:1518
457 -msgid "%B: bad string table size %lu"
458 -msgstr "%B: tamaño de tabla de cadenas %lu erróneo"
459 -
460  #: coff-h8300.c:1122
461  #, c-format
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"
464  
465 -#: coff-i860.c:143
466 +#: coff-i860.c:147
467  #, c-format
468  msgid "Relocation `%s' not yet implemented\n"
469  msgstr "La reubicación `%s' aún no está implementada\n"
470  
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"
475 +
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"
479  
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"
483 -
484 -#: cofflink.c:2296
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"
487 -
488 -#: cofflink.c:2627 coffswap.h:824
489 -#, c-format
490 -msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
491 -msgstr "%s: %s: desbordamiento de reubicación: 0x%lx > 0xffff"
492 -
493 -#: cofflink.c:2636 coffswap.h:810
494 -#, c-format
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"
497 -
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"
502  
503 @@ -462,31 +389,35 @@ msgstr "La direcci
504  msgid "Unrecognized Reloc Type"
505  msgstr "Tipo de Reubicación no Reconocida"
506  
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"
513  
514 -#: coff-or32.c:228
515 +#: coff-or32.c:229
516  msgid "Unrecognized reloc"
517  msgstr "Reubicación no reconocida"
518  
519 -#: coff-rs6000.c:2799
520 +#: coff-rs6000.c:2803
521  #, c-format
522  msgid "%s: unsupported relocation type 0x%02x"
523  msgstr "%s: no se admite el tipo de reubicación 0x%02x"
524  
525 -#: coff-rs6000.c:2892
526 +#: coff-rs6000.c:2896
527  #, c-format
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"
530  
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"
535 +
536 +#: coff-tic4x.c:195 coff-tic54x.c:299 coff-tic80.c:458
537  #, c-format
538  msgid "Unrecognized reloc type 0x%x"
539  msgstr "Tipo de reubicación 0x%x no reconocida"
540  
541 -#: coff-tic4x.c:236
542 +#: coff-tic4x.c:240
543  #, c-format
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"
549  
550 +#: coffcode.h:850
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'"
553 +
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.
557 +#: coffcode.h:1062
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"
560 +
561 +#: coffcode.h:1117
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)"
564 +
565 +#: coffcode.h:2244
566 +#, c-format
567 +msgid "Unrecognized TI COFF target id '0x%x'"
568 +msgstr "No se reconoce el id de objetivo TI COFF '0x%x'"
569 +
570 +#: coffcode.h:2559
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"
573 +
574 +#: coffcode.h:4309
575 +msgid "%B: warning: line number table read failed"
576 +msgstr "%B: aviso: falló la lectura de tabla de números de línea"
577 +
578 +#: coffcode.h:4339
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"
581 +
582 +#: coffcode.h:4353
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'"
585 +
586 +#: coffcode.h:4744
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'"
589 +
590 +#: coffcode.h:4870
591 +msgid "warning: %B: local symbol `%s' has no section"
592 +msgstr "aviso: %B: el símbolo local `%s' no tiene sección"
593 +
594 +#: coffcode.h:5013
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"
597 +
598 +#: coffgen.c:1518
599 +msgid "%B: bad string table size %lu"
600 +msgstr "%B: tamaño de tabla de cadenas %lu erróneo"
601 +
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"
605 +
606 +#: cofflink.c:2296
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"
609 +
610 +#: cofflink.c:2627 coffswap.h:824
611 +#, c-format
612 +msgid "%s: %s: reloc overflow: 0x%lx > 0xffff"
613 +msgstr "%s: %s: desbordamiento de reubicación: 0x%lx > 0xffff"
614 +
615 +#: cofflink.c:2636 coffswap.h:810
616 +#, c-format
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"
619 +
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"
626  
627 -#: dwarf2.c:481
628 -msgid "Dwarf Error: Can't find .debug_str section."
629 -msgstr "Error de Dwarf: No se puede encontrar la sección .debug_str."
630 -
631 -#: dwarf2.c:499
632 +#: dwarf2.c:424
633  #, c-format
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."
638  
639 -#: dwarf2.c:592
640 -msgid "Dwarf Error: Can't find .debug_abbrev section."
641 -msgstr "Error de Dwarf: No se puede encontrar la sección .debug_abbrev."
642 +#: dwarf2.c:452
643 +#, c-format
644 +msgid "Dwarf Error: unable to decompress %s section."
645 +msgstr "Error de Dwarf: no se puede descomprimir la sección %s."
646  
647 -#: dwarf2.c:607
648 +#: dwarf2.c:462
649  #, c-format
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)."
654  
655 -#: dwarf2.c:822
656 +#: dwarf2.c:849
657  #, c-format
658  msgid "Dwarf Error: Invalid or unhandled FORM value: %u."
659  msgstr "Error de Dwarf: Valor de FORM inválido o no manejado: %u."
660  
661 -#: dwarf2.c:1025
662 +#: dwarf2.c:1063
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)."
665  
666 -#: dwarf2.c:1137
667 -msgid "Dwarf Error: Can't find .debug_line section."
668 -msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_line."
669 -
670 -#: dwarf2.c:1154
671 -#, c-format
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)."
674 -
675 -#: dwarf2.c:1380
676 +#: dwarf2.c:1393
677  msgid "Dwarf Error: mangled line number section."
678  msgstr "Error de Dwarf: sección de números de línea revuelta."
679  
680 -#: dwarf2.c:1568
681 -msgid "Dwarf Error: Can't find .debug_ranges section."
682 -msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_ranges."
683 -
684 -#: dwarf2.c:1731 dwarf2.c:1847 dwarf2.c:2119
685 +#: dwarf2.c:1726 dwarf2.c:1842 dwarf2.c:2114
686  #, c-format
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."
689  
690 -#: dwarf2.c:2080
691 +#: dwarf2.c:2075
692  #, c-format
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."
695  
696 -#: dwarf2.c:2087
697 +#: dwarf2.c:2082
698  #, c-format
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'."
701  
702 -#: dwarf2.c:2110
703 +#: dwarf2.c:2105
704  #, c-format
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 ""
708  "\n"
709  "      Tipo: %s"
710  
711 -#: elf32-arm.c:2524
712 +#: elf-attrs.c:582
713 +msgid "ERROR: %B: Must be processed by '%s' toolchain"
714 +msgstr "ERROR: %B: Se debe procesar por la cadena de compilación '%s'"
715 +
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"
719 +
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"
723 +
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"
727 +
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'"
734 +
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'"
738 +
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"
748 +
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"
758 +
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"
764 +
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"
774 +
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?)"
778 +
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"
782 +
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
788 +#, c-format
789 +msgid "dynamic variable `%s' is zero size"
790 +msgstr "la variable dinámica `%s' es de tamaño cero"
791 +
792 +#: elf.c:328
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'"
795 +
796 +#: elf.c:438
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"
799 +
800 +#: elf.c:594
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"
803 +
804 +#: elf.c:630
805 +msgid "%B: invalid SHT_GROUP entry"
806 +msgstr "%B: entrada SHT_GROUP inválida"
807 +
808 +#: elf.c:700
809 +msgid "%B: no group info for section %A"
810 +msgstr "%B: no hay información de grupo para la sección %A"
811 +
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'"
815 +
816 +#: elf.c:748
817 +msgid "%B: sh_link [%d] in section `%A' is incorrect"
818 +msgstr "%B: sh_link [%d] en la sección `%A', es incorrecto"
819 +
820 +#: elf.c:783
821 +msgid "%B: unknown [%d] section `%s' in group [%s]"
822 +msgstr "%B: sección [%d] desconocida `%s' en el grupo [%s]"
823 +
824 +#: elf.c:1159
825 +#, c-format
826 +msgid ""
827 +"\n"
828 +"Program Header:\n"
829 +msgstr ""
830 +"\n"
831 +"Encabezado del Programa:\n"
832 +
833 +#: elf.c:1201
834 +#, c-format
835 +msgid ""
836 +"\n"
837 +"Dynamic Section:\n"
838 +msgstr ""
839 +"\n"
840 +"Sección Dinámica:\n"
841 +
842 +#: elf.c:1337
843 +#, c-format
844 +msgid ""
845 +"\n"
846 +"Version definitions:\n"
847 +msgstr ""
848 +"\n"
849 +"Definiciones de versión:\n"
850 +
851 +#: elf.c:1362
852 +#, c-format
853 +msgid ""
854 +"\n"
855 +"Version References:\n"
856 +msgstr ""
857 +"\n"
858 +"Referencias de Versión:\n"
859 +
860 +#: elf.c:1367
861 +#, c-format
862 +msgid "  required from %s:\n"
863 +msgstr "  requerido desde %s:\n"
864 +
865 +#: elf.c:1755
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)"
868 +
869 +#: elf.c:1924
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]"
872 +
873 +#: elf.c:1936
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]"
876 +
877 +#: elf.c:1947
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]"
880 +
881 +#: elf.c:1957
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]"
884 +
885 +#: elf.c:2555
886 +#, c-format
887 +msgid "warning: section `%A' type changed to PROGBITS"
888 +msgstr "aviso: el tipo de la sección `%A' cambió a PROGBITS"
889 +
890 +#: elf.c:2933
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'"
893 +
894 +#: elf.c:2956
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'"
897 +
898 +#: elf.c:4300
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"
901 +
902 +#: elf.c:4327
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"
905 +
906 +#: elf.c:4404
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"
909 +
910 +#: elf.c:4499
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"
913 +
914 +#: elf.c:4549
915 +msgid "%B: warning: allocated section `%s' not in segment"
916 +msgstr "%B: aviso: la sección asignada `%s' no está en el segmento"
917 +
918 +#: elf.c:5064
919 +msgid "%B: symbol `%s' required but not present"
920 +msgstr "%B: se requiere el símbolo `%s' pero no está presente"
921 +
922 +#: elf.c:5403
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"
925 +
926 +#: elf.c:6366
927 +#, c-format
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'"
930 +
931 +#: elf.c:7346
932 +msgid "%B: unsupported relocation type %s"
933 +msgstr "%B: no se admite el tipo de reubicación %s"
934 +
935 +#: elf32-arm.c:2846 elf32-arm.c:2878
936 +msgid ""
937 +"%B(%s): warning: interworking not enabled.\n"
938 +"  first occurrence: %B: Thumb call to ARM"
939 +msgstr ""
940 +"%B(%s): aviso: no se activó la interoperabilidad.\n"
941 +"  primer suceso: %B: llamada Thumb para ARM"
942 +
943 +#: elf32-arm.c:3041
944 +#, c-format
945 +msgid "%s: cannot create stub entry %s"
946 +msgstr "%s: no se puede crear la entrada de cabo %s"
947 +
948 +#: elf32-arm.c:3825
949  #, c-format
950  msgid "unable to find THUMB glue '%s' for '%s'"
951  msgstr "no se puede encontrar el pegamento THUMB '%s' para `%s'"
952  
953 -#: elf32-arm.c:2557
954 +#: elf32-arm.c:3859
955  #, c-format
956  msgid "unable to find ARM glue '%s' for '%s'"
957  msgstr "no se puede encontrar el pegamento ARM '%s' para `%s'"
958  
959 -#: elf32-arm.c:3127
960 +#: elf32-arm.c:4463
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."
963  
964  #. Give a warning, but do as the user requests anyway.
965 -#: elf32-arm.c:3331
966 +#: elf32-arm.c:4678
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"
969  
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'"
974  
975 -#: elf32-arm.c:3930
976 +#: elf32-arm.c:5278
977  #, c-format
978  msgid "Invalid TARGET2 relocation type '%s'."
979  msgstr "Tipo de reubicación TARGET2 '%s' inválido."
980  
981 -#: elf32-arm.c:4071
982 +#: elf32-arm.c:5362
983  msgid ""
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"
989  
990 -#: elf32-arm.c:4759
991 +#: elf32-arm.c:6094
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'."
994  
995 -#: elf32-arm.c:5059
996 +#: elf32-arm.c:6418
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'."
999  
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"
1004  
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"
1009  
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"
1014  
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"
1019  
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"
1024  
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"
1029  
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'"
1036 -
1037 -#: elf32-arm.c:6516
1038 +#: elf32-arm.c:7988
1039  msgid "out of range"
1040  msgstr "fuera de rango"
1041  
1042 -#: elf32-arm.c:6520
1043 +#: elf32-arm.c:7992
1044  msgid "unsupported relocation"
1045  msgstr "no se admite la reubicación"
1046  
1047 -#: elf32-arm.c:6528
1048 +#: elf32-arm.c:8000
1049  msgid "unknown error"
1050  msgstr "error desconocido"
1051  
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"
1056  
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"
1061  
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"
1066  
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"
1071  
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"
1076  
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"
1081  
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"
1088  
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"
1093  
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"
1098  
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"
1103  
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"
1108 +
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"
1112  
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"
1117  
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"
1122  
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"
1127  
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"
1132  
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í"
1137  
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"
1142  
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"
1147  
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
1155  #, c-format
1156  msgid "private flags = %lx:"
1157  msgstr "opciones privadas = %lx:"
1158  
1159 -#: elf32-arm.c:7183
1160 +#: elf32-arm.c:8674
1161  #, c-format
1162  msgid " [interworking enabled]"
1163  msgstr " [interoperabilidad activada]"
1164  
1165 -#: elf32-arm.c:7191
1166 +#: elf32-arm.c:8682
1167  #, c-format
1168  msgid " [VFP float format]"
1169  msgstr " [formato de coma flotante VFP]"
1170  
1171 -#: elf32-arm.c:7193
1172 +#: elf32-arm.c:8684
1173  #, c-format
1174  msgid " [Maverick float format]"
1175  msgstr " [formato de coma flotante Maverick]"
1176  
1177 -#: elf32-arm.c:7195
1178 +#: elf32-arm.c:8686
1179  #, c-format
1180  msgid " [FPA float format]"
1181  msgstr " [formato de coma flotante FPA]"
1182  
1183 -#: elf32-arm.c:7204
1184 +#: elf32-arm.c:8695
1185  #, c-format
1186  msgid " [new ABI]"
1187  msgstr " [ABI nuevo]"
1188  
1189 -#: elf32-arm.c:7207
1190 +#: elf32-arm.c:8698
1191  #, c-format
1192  msgid " [old ABI]"
1193  msgstr " [ABI antiguo]"
1194  
1195 -#: elf32-arm.c:7210
1196 +#: elf32-arm.c:8701
1197  #, c-format
1198  msgid " [software FP]"
1199  msgstr " [FP por software]"
1200  
1201 -#: elf32-arm.c:7219
1202 +#: elf32-arm.c:8710
1203  #, c-format
1204  msgid " [Version1 EABI]"
1205  msgstr " [EABI Version1]"
1206  
1207 -#: elf32-arm.c:7222 elf32-arm.c:7233
1208 +#: elf32-arm.c:8713 elf32-arm.c:8724
1209  #, c-format
1210  msgid " [sorted symbol table]"
1211  msgstr " [tabla de símbolos ordenados]"
1212  
1213 -#: elf32-arm.c:7224 elf32-arm.c:7235
1214 +#: elf32-arm.c:8715 elf32-arm.c:8726
1215  #, c-format
1216  msgid " [unsorted symbol table]"
1217  msgstr " [tabla de símbolos sin ordenar]"
1218  
1219 -#: elf32-arm.c:7230
1220 +#: elf32-arm.c:8721
1221  #, c-format
1222  msgid " [Version2 EABI]"
1223  msgstr " [EABI Version2]"
1224  
1225 -#: elf32-arm.c:7238
1226 +#: elf32-arm.c:8729
1227  #, c-format
1228  msgid " [dynamic symbols use segment index]"
1229  msgstr " [los símbolos dinámicos utilizan índices de segmento]"
1230  
1231 -#: elf32-arm.c:7241
1232 +#: elf32-arm.c:8732
1233  #, c-format
1234  msgid " [mapping symbols precede others]"
1235  msgstr " [el mapeo de símbolos precede a otros]"
1236  
1237 -#: elf32-arm.c:7248
1238 +#: elf32-arm.c:8739
1239  #, c-format
1240  msgid " [Version3 EABI]"
1241  msgstr " [EABI Version3]"
1242  
1243 -#: elf32-arm.c:7252
1244 +#: elf32-arm.c:8743
1245  #, c-format
1246  msgid " [Version4 EABI]"
1247  msgstr " [EABI Version4]"
1248  
1249 -#: elf32-arm.c:7256
1250 +#: elf32-arm.c:8747
1251  #, c-format
1252  msgid " [Version5 EABI]"
1253  msgstr " [EABI Version5]"
1254  
1255 -#: elf32-arm.c:7259
1256 +#: elf32-arm.c:8750
1257  #, c-format
1258  msgid " [BE8]"
1259  msgstr " [BE8]"
1260  
1261 -#: elf32-arm.c:7262
1262 +#: elf32-arm.c:8753
1263  #, c-format
1264  msgid " [LE8]"
1265  msgstr " [LE8]"
1266  
1267 -#: elf32-arm.c:7268
1268 +#: elf32-arm.c:8759
1269  #, c-format
1270  msgid " <EABI version unrecognised>"
1271  msgstr " <versión de EABI no reconocida>"
1272  
1273 -#: elf32-arm.c:7275
1274 +#: elf32-arm.c:8766
1275  #, c-format
1276  msgid " [relocatable executable]"
1277  msgstr " [ejecutable reubicable]"
1278  
1279 -#: elf32-arm.c:7278
1280 +#: elf32-arm.c:8769
1281  #, c-format
1282  msgid " [has entry point]"
1283  msgstr " [tiene punto de entrada]"
1284  
1285 -#: elf32-arm.c:7283
1286 +#: elf32-arm.c:8774
1287  #, c-format
1288  msgid "<Unrecognised flag bits set>"
1289  msgstr "<Conjunto de bits de opción sin reconocer>"
1290  
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"
1297  
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
1303 -#, c-format
1304 -msgid "dynamic variable `%s' is zero size"
1305 -msgstr "la variable dinámica `%s' es de tamaño cero"
1306 -
1307 -#: elf32-arm.c:8603
1308 +#: elf32-arm.c:10125
1309  #, c-format
1310  msgid "Errors encountered processing file %s"
1311  msgstr "Se encontraron errores al procesar el fichero %s"
1312  
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"
1317  
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"
1327 -
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"
1337 -
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"
1349  
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"
1359 -
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"
1364  
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'"
1369 +
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"
1374 +
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"
1378  
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"
1383  
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"
1388  
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"
1393  
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"
1399  
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"
1404  
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"
1409  
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"
1414  
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'"
1418 -
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"
1423 -
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"
1428  
1429 -#: elf32-bfin.c:4868 elf32-frv.c:6831
1430 +#: elf32-bfin.c:4944 elf32-frv.c:6812
1431  #, c-format
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"
1434  
1435 -#: elf32-bfin.c:4872 elf32-frv.c:6835
1436 +#: elf32-bfin.c:4948 elf32-frv.c:6816
1437  #, c-format
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"
1440  
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"
1446 -
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"
1453  
1454 -#: elf32-cris.c:2511
1455 +#: elf32-cris.c:2510
1456  msgid ""
1457  "%B, section %A:\n"
1458  "  v10/v32 compatible object %s must not contain a PIC relocation"
1459 @@ -1094,7 +1267,7 @@ msgstr ""
1460  "%B, sección %A:\n"
1461  "  el objeto %s compatible con v10/v32 no debe contener una reubicación PIC"
1462  
1463 -#: elf32-cris.c:2698 elf32-cris.c:2766
1464 +#: elf32-cris.c:2697 elf32-cris.c:2765
1465  msgid ""
1466  "%B, section %A:\n"
1467  "  relocation %s should not be used in a shared object; recompile with -fPIC"
1468 @@ -1102,129 +1275,129 @@ msgstr ""
1469  "%B, sección %A:\n"
1470  "  la reubicación %s no se debe usar en un objeto compartido; recompile con -fPIC"
1471  
1472 -#: elf32-cris.c:3183
1473 +#: elf32-cris.c:3184
1474  msgid "Unexpected machine number"
1475  msgstr "Número de máquina inesperado"
1476  
1477 -#: elf32-cris.c:3237
1478 +#: elf32-cris.c:3238
1479  #, c-format
1480  msgid " [symbols have a _ prefix]"
1481  msgstr " [los símbolos tiene un prefijo _]"
1482  
1483 -#: elf32-cris.c:3240
1484 +#: elf32-cris.c:3241
1485  #, c-format
1486  msgid " [v10 and v32]"
1487  msgstr " [v10 y v32]"
1488  
1489 -#: elf32-cris.c:3243
1490 +#: elf32-cris.c:3244
1491  #, c-format
1492  msgid " [v32]"
1493  msgstr " [v32]"
1494  
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"
1499  
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 _"
1504  
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"
1509  
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"
1514  
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"
1519  
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"
1524  
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"
1529  
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"
1534  
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"
1539  
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"
1544  
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"
1549  
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"
1554  
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"
1559  
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"
1564  
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"
1569  
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"
1574  
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"
1579  
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"
1584  
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"
1589  
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"
1594  
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"
1599  
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"
1604  
1605 -#: elf32-frv.c:6745
1606 +#: elf32-frv.c:6726
1607  #, c-format
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"
1610  
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
1613  #, c-format
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"
1616  
1617 -#: elf32-frv.c:6810
1618 +#: elf32-frv.c:6791
1619  #, c-format
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)"
1622  
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
1625  #, c-format
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)"
1631  
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"
1636  
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"
1641  
1642 -#: elf32-hppa.c:1506
1643 +#: elf32-hppa.c:1518
1644  #, c-format
1645  msgid "Could not find relocation section for %s"
1646  msgstr "No se puede encontrar la sección de reubicación para %s"
1647  
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"
1652  
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"
1657  
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"
1662  
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"
1667  
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"
1674  
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'"
1680 +
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"
1685  
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"
1692  
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'"
1697  
1698 -#: elf32-i386.c:2479
1699 +#: elf32-i386.c:2822 elf64-x86-64.c:2660
1700 +msgid "hidden symbol"
1701 +msgstr "símbolo oculto"
1702 +
1703 +#: elf32-i386.c:2825 elf64-x86-64.c:2663
1704 +msgid "internal symbol"
1705 +msgstr "símbolo interno"
1706 +
1707 +#: elf32-i386.c:2828 elf64-x86-64.c:2666
1708 +msgid "protected symbol"
1709 +msgstr "símbolos protegido"
1710 +
1711 +#: elf32-i386.c:2831 elf64-x86-64.c:2669
1712 +msgid "symbol"
1713 +msgstr "símbolo"
1714 +
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"
1718 +
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"
1722  
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"
1726  
1727 -#: elf32-iq2000.c:821 elf32-m32c.c:831
1728 +#: elf32-iq2000.c:865 elf32-m32c.c:826
1729  #, c-format
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"
1735  
1736 -#: elf32-m68hc1x.c:1045
1737 +#: elf32-m68hc1x.c:1047
1738  #, c-format
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"
1741  
1742 -#: elf32-m68hc1x.c:1068
1743 +#: elf32-m68hc1x.c:1070
1744  #, c-format
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)"
1747  
1748 -#: elf32-m68hc1x.c:1087
1749 +#: elf32-m68hc1x.c:1089
1750  #, c-format
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"
1753  
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"
1758  
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"
1763  
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"
1768  
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)"
1773  
1774 -#: elf32-m68hc1x.c:1280
1775 +#: elf32-m68hc1x.c:1282
1776  #, c-format
1777  msgid "[abi=32-bit int, "
1778  msgstr "[abi=int de 32-bit, "
1779  
1780 -#: elf32-m68hc1x.c:1282
1781 +#: elf32-m68hc1x.c:1284
1782  #, c-format
1783  msgid "[abi=16-bit int, "
1784  msgstr "[abi=int de 16-bit, "
1785  
1786 -#: elf32-m68hc1x.c:1285
1787 +#: elf32-m68hc1x.c:1287
1788  #, c-format
1789  msgid "64-bit double, "
1790  msgstr "doble de 64-bit, "
1791  
1792 -#: elf32-m68hc1x.c:1287
1793 +#: elf32-m68hc1x.c:1289
1794  #, c-format
1795  msgid "32-bit double, "
1796  msgstr "doble de 32-bit, "
1797  
1798 -#: elf32-m68hc1x.c:1290
1799 +#: elf32-m68hc1x.c:1292
1800  #, c-format
1801  msgid "cpu=HC11]"
1802  msgstr "cpu=HC11]"
1803  
1804 -#: elf32-m68hc1x.c:1292
1805 +#: elf32-m68hc1x.c:1294
1806  #, c-format
1807  msgid "cpu=HCS12]"
1808  msgstr "cpu=HCS12]"
1809  
1810 -#: elf32-m68hc1x.c:1294
1811 +#: elf32-m68hc1x.c:1296
1812  #, c-format
1813  msgid "cpu=HC12]"
1814  msgstr "cpu=HC12]"
1815  
1816 -#: elf32-m68hc1x.c:1297
1817 +#: elf32-m68hc1x.c:1299
1818  #, c-format
1819  msgid " [memory=bank-model]"
1820  msgstr " [memoria=modelo de bancos]"
1821  
1822 -#: elf32-m68hc1x.c:1299
1823 +#: elf32-m68hc1x.c:1301
1824  #, c-format
1825  msgid " [memory=flat]"
1826  msgstr " [memoria=plana]"
1827  
1828 -#: elf32-m68k.c:635 elf32-m68k.c:636
1829 +#: elf32-m68k.c:789 elf32-m68k.c:790
1830  msgid "unknown"
1831  msgstr "desconocido"
1832  
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"
1836 +
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"
1840 +
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"
1847  
1848 -#: elf32-mep.c:812
1849 +#: elf32-mep.c:654
1850  msgid "%B and %B are for different cores"
1851  msgstr "%B y %B son para núcleos diferentes"
1852  
1853 -#: elf32-mep.c:829
1854 +#: elf32-mep.c:671
1855  msgid "%B and %B are for different configurations"
1856  msgstr "%B y %B son para configuraciones diferentes"
1857  
1858 -#: elf32-mep.c:867
1859 +#: elf32-mep.c:709
1860  #, c-format
1861  msgid "private flags = 0x%lx"
1862  msgstr "opciones privadas = 0x%lx"
1863  
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"
1868  
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"
1873  
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"
1877  
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"
1882  
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"
1887  
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"
1892  
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"
1897  
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."
1902  
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."
1907  
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."
1912  
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"
1917  
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"
1924  
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"
1931  
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"
1936 +
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"
1940 +
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"
1944  
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"
1949 +
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\""
1953 +
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"
1957  
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"
1962  
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"
1967  
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"
1972  
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'"
1977  
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)"
1982  
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."
1987  
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"
1992  
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"
1997  
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"
2002  
2003 -#: elf32-score.c:2550
2004 +#: elf32-score.c:2545
2005  #, c-format
2006  msgid "%s: Malformed reloc detected for section %s"
2007  msgstr "%s: Se detectó una reubicación malformada para la sección %s"
2008  
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"
2013  
2014 -#: elf32-score.c:3756
2015 +#: elf32-score.c:3753
2016  #, c-format
2017  msgid " [pic]"
2018  msgstr " [pic]"
2019  
2020 -#: elf32-score.c:3760
2021 +#: elf32-score.c:3757
2022  #, c-format
2023  msgid " [fix dep]"
2024  msgstr " [fix dep]"
2025  
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"
2030  
2031 -#: elf32-sh64.c:222 elf64-sh64.c:2350
2032 -#, c-format
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"
2035 -
2036 -#: elf32-sh64.c:225 elf64-sh64.c:2353
2037 -#, c-format
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"
2040 -
2041 -#: elf32-sh64.c:227 elf64-sh64.c:2355
2042 -#, c-format
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"
2045 -
2046 -#: elf32-sh64.c:450 elf64-sh64.c:2894
2047 -#, c-format
2048 -msgid "%s: encountered datalabel symbol in input"
2049 -msgstr "%s: se encontró un símbolo datalabel en la entrada"
2050 -
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)"
2054 -
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)"
2058 -
2059 -#: elf32-sh64.c:548
2060 -#, c-format
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"
2063 -
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"
2070  
2071 -#: elf32-sh64.c:673
2072 -#, c-format
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"
2078  
2079 -#: elf32-sh64.c:733
2080 -#, c-format
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"
2086  
2087  #: elf32-sh.c:533
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"
2092  
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"
2097  
2098 -#: elf32-sh.c:3486
2099 +#: elf32-sh.c:3516
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"
2102  
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"
2107  
2108 -#: elf32-sh.c:3548
2109 +#: elf32-sh.c:3578
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"
2112  
2113 -#: elf32-sh.c:3562
2114 +#: elf32-sh.c:3592
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"
2117  
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"
2122  
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
2127 +#, c-format
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"
2130  
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
2135 +#, c-format
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"
2138  
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
2143 +#, c-format
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"
2146 +
2147 +#: elf32-sh64.c:450 elf64-sh64.c:2888
2148 +#, c-format
2149 +msgid "%s: encountered datalabel symbol in input"
2150 +msgstr "%s: se encontró un símbolo datalabel en la entrada"
2151 +
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)"
2155 +
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)"
2159 +
2160 +#: elf32-sh64.c:548
2161 +#, c-format
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"
2164 +
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"
2168 +
2169 +#: elf32-sh64.c:673
2170 +#, c-format
2171 +msgid "%s: could not write out added .cranges entries"
2172 +msgstr "%s: no se pueden escribir las entradas .cranges agregadas"
2173 +
2174 +#: elf32-sh64.c:733
2175 +#, c-format
2176 +msgid "%s: could not write out sorted .cranges entries"
2177 +msgstr "%s: no se pueden escribir las entradas .cranges ordenadas"
2178  
2179  #: elf32-sparc.c:89
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"
2184  
2185 -#: elf32-spu.c:995
2186 +#: elf32-spu.c:607
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"
2189 +
2190 +#: elf32-spu.c:805
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"
2193  
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"
2198  
2199 -#: elf32-spu.c:1352
2200 +#: elf32-spu.c:1453
2201  #, c-format
2202  msgid "%s in overlay section"
2203  msgstr "%s en la sección de sobreescritura"
2204  
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"
2209  
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"
2214 +
2215 +#: elf32-spu.c:1976
2216  #, c-format
2217  msgid "warning: %s overlaps %s\n"
2218  msgstr "aviso: %s sobreescribe %s\n"
2219  
2220 -#: elf32-spu.c:1836
2221 +#: elf32-spu.c:1992
2222  #, c-format
2223  msgid "warning: %s exceeds section size\n"
2224  msgstr "aviso: %s excede el tamaño de la sección\n"
2225  
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"
2230  
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"
2237  
2238 -#: elf32-spu.c:2079
2239 +#: elf32-spu.c:2339
2240  #, c-format
2241  msgid "%A link_order not found\n"
2242  msgstr "no se encontró link_order %A\n"
2243  
2244 -#: elf32-spu.c:2358
2245 +#: elf32-spu.c:2706
2246  #, c-format
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"
2249  
2250 -#: elf32-spu.c:2513
2251 +#: elf32-spu.c:3348
2252 +msgid "  %s: 0x%v\n"
2253 +msgstr "  %s: 0x%v\n"
2254 +
2255 +#: elf32-spu.c:3349
2256  msgid "%s: 0x%v 0x%v\n"
2257  msgstr "%s: 0x%v 0x%v\n"
2258  
2259 -#: elf32-spu.c:2517
2260 +#: elf32-spu.c:3354
2261  msgid "  calls:\n"
2262  msgstr "  llama:\n"
2263  
2264 -#: elf32-spu.c:2524
2265 +#: elf32-spu.c:3362
2266  #, c-format
2267  msgid "   %s%s %s\n"
2268  msgstr "   %s%s %s\n"
2269  
2270 -#: elf32-spu.c:2585
2271 +#: elf32-spu.c:3564
2272 +#, c-format
2273 +msgid "%s duplicated in %s\n"
2274 +msgstr "%s duplicado en %s\n"
2275 +
2276 +#: elf32-spu.c:3568
2277 +#, c-format
2278 +msgid "%s duplicated\n"
2279 +msgstr "%s duplicado\n"
2280 +
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"
2284 +
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"
2288 +
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"
2292 +
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"
2296  
2297 -#: elf32-spu.c:2586
2298 +#: elf32-spu.c:3863
2299  msgid ""
2300  "\n"
2301  "Stack size for functions.  Annotations: '*' max stack, 't' tail call\n"
2302 @@ -1762,80 +2017,76 @@ msgstr ""
2303  "\n"
2304  "Tamaño de la pila para funciones. Anotaciones: '*' max de pila, 't' llamada cola\n"
2305  
2306 -#: elf32-spu.c:2615
2307 -msgid "  %s: 0x%v\n"
2308 -msgstr "  %s: 0x%v\n"
2309 -
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"
2314  
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'"
2319  
2320 -#: elf32-v850.c:163
2321 +#: elf32-v850.c:165
2322  #, c-format
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"
2325  
2326 -#: elf32-v850.c:166
2327 +#: elf32-v850.c:168
2328  #, c-format
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"
2331  
2332 -#: elf32-v850.c:169
2333 +#: elf32-v850.c:171
2334  #, c-format
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"
2337  
2338 -#: elf32-v850.c:172
2339 +#: elf32-v850.c:174
2340  #, c-format
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"
2343  
2344 -#: elf32-v850.c:175
2345 +#: elf32-v850.c:177
2346  #, c-format
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"
2349  
2350 -#: elf32-v850.c:478
2351 +#: elf32-v850.c:480
2352  #, c-format
2353  msgid "FAILED to find previous HI16 reloc\n"
2354  msgstr "FALLO para encontrar la reubicación HI16 previa\n"
2355  
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"
2360  
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"
2365  
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"
2370  
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"
2375  
2376 -#: elf32-v850.c:1890
2377 +#: elf32-v850.c:1892
2378  #, c-format
2379  msgid "private flags = %lx: "
2380  msgstr "opciones privadas = %lx: "
2381  
2382 -#: elf32-v850.c:1895
2383 +#: elf32-v850.c:1897
2384  #, c-format
2385  msgid "v850 architecture"
2386  msgstr "arquitectura v850"
2387  
2388 -#: elf32-v850.c:1896
2389 +#: elf32-v850.c:1898
2390  #, c-format
2391  msgid "v850e architecture"
2392  msgstr "arquitectura v850e"
2393  
2394 -#: elf32-v850.c:1897
2395 +#: elf32-v850.c:1899
2396  #, c-format
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"
2402  
2403 -#: elf32-vax.c:1584
2404 +#: elf32-vax.c:1589
2405  #, c-format
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"
2408  
2409 -#: elf32-vax.c:1721
2410 +#: elf32-vax.c:1726
2411  #, c-format
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"
2414  
2415 -#: elf32-vax.c:1727
2416 +#: elf32-vax.c:1732
2417  #, c-format
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"
2420  
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"
2425  
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"
2430  
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)"
2435  
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"
2440  
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"
2445 +
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"
2449  
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"
2454  
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"
2459  
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"
2464  
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"
2469  
2470 -#: elf32-xtensa.c:8166
2471 +#: elf32-xtensa.c:8969
2472  msgid "invalid relocation address"
2473  msgstr "dirección de reubicación inválida"
2474  
2475 -#: elf32-xtensa.c:8215
2476 +#: elf32-xtensa.c:9018
2477  msgid "overflow after relaxation"
2478  msgstr "desbordamiento después de la relajación"
2479  
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"
2484  
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"
2489  
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)"
2494  
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"
2499  
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"
2504  
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"
2509  
2510 -#: elf64-alpha.c:4368
2511 +#: elf64-alpha.c:4387
2512  msgid "<unknown>"
2513  msgstr "<desconocido>"
2514  
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"
2519  
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"
2524  
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"
2529  
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"
2534  
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"
2539  
2540 -#: elf64-hppa.c:2040
2541 +#: elf64-hppa.c:2071
2542  #, c-format
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."
2548  
2549 -#: elf64-mmix.c:2202
2550 +#: elf64-mmix.c:2201
2551  #, c-format
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"
2554  
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"
2559  
2560 -#: elf64-mmix.c:2452
2561 +#: elf64-mmix.c:2451
2562  #, c-format
2563  msgid ""
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."
2568  
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"
2573  
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"
2578  
2579 -#: elf64-ppc.c:5888
2580 +#: elf64-ppc.c:6065
2581  #, c-format
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"
2584  
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"
2589  
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"
2594  
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"
2599  
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"
2604  
2605 -#: elf64-ppc.c:7157 elf64-ppc.c:7537
2606 +#: elf64-ppc.c:7377 elf64-ppc.c:7754
2607  #, c-format
2608  msgid "%s defined in removed toc entry"
2609  msgstr "se definió %s en la entrada toc eliminada"
2610  
2611 -#: elf64-ppc.c:8272
2612 +#: elf64-ppc.c:8581
2613  #, c-format
2614  msgid "long branch stub `%s' offset overflow"
2615  msgstr "desbordamiento del desplazamiento de stub de ramificación long `%s'"
2616  
2617 -#: elf64-ppc.c:8347
2618 +#: elf64-ppc.c:8640
2619  #, c-format
2620  msgid "can't find branch stub `%s'"
2621  msgstr "no se puede encontrar la ramificación de cabo `%s'"
2622  
2623 -#: elf64-ppc.c:8413 elf64-ppc.c:8489
2624 +#: elf64-ppc.c:8702 elf64-ppc.c:8822
2625  #, c-format
2626  msgid "linkage table error against `%s'"
2627  msgstr "error de la tabla de enlazado contra `%s'"
2628  
2629 -#: elf64-ppc.c:8618
2630 +#: elf64-ppc.c:8978
2631  #, c-format
2632  msgid "can't build branch stub `%s'"
2633  msgstr "no se puede construir la ramificación de cabos `%s'"
2634  
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"
2639  
2640 -#: elf64-ppc.c:9682
2641 -msgid "stubs don't match calculated size"
2642 -msgstr "los cabos no coinciden con el tamaño calculado"
2643 -
2644 -#: elf64-ppc.c:9694
2645 +#: elf64-ppc.c:10090
2646  #, c-format
2647  msgid ""
2648  "linker stubs in %u group%s\n"
2649 @@ -2108,19 +2359,19 @@ msgstr ""
2650  "  ajuste toc long %lu\n"
2651  "  llamada plt     %lu"
2652  
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"
2657  
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"
2662  
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."
2667  
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"
2672  
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"
2676  
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"
2681  
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"
2688  
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"
2693  
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"
2700  
2701 -#: elf-attrs.c:582
2702 -msgid "ERROR: %B: Must be processed by '%s' toolchain"
2703 -msgstr "ERROR: %B: Se debe procesar por la cadena de compilación '%s'"
2704 -
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"
2708 -
2709 -#: elf.c:312
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'"
2712 -
2713 -#: elf.c:414
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"
2716 -
2717 -#: elf.c:567
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"
2723  
2724 -#: elf.c:603
2725 -msgid "%B: invalid SHT_GROUP entry"
2726 -msgstr "%B: entrada SHT_GROUP inválida"
2727 -
2728 -#: elf.c:673
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"
2734  
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'"
2738 -
2739 -#: elf.c:719
2740 -msgid "%B: sh_link [%d] in section `%A' is incorrect"
2741 -msgstr "%B: sh_link [%d] en la sección `%A', es incorrecto"
2742 -
2743 -#: elf.c:754
2744 -msgid "%B: unknown [%d] section `%s' in group [%s]"
2745 -msgstr "%B: sección [%d] desconocida `%s' en el grupo [%s]"
2746 -
2747 -#: elf.c:1108
2748 -#, c-format
2749 -msgid ""
2750 -"\n"
2751 -"Program Header:\n"
2752 -msgstr ""
2753 -"\n"
2754 -"Encabezado del Programa:\n"
2755 -
2756 -#: elf.c:1150
2757 -#, c-format
2758 -msgid ""
2759 -"\n"
2760 -"Dynamic Section:\n"
2761 -msgstr ""
2762 -"\n"
2763 -"Sección Dinámica:\n"
2764 -
2765 -#: elf.c:1276
2766 -#, c-format
2767 -msgid ""
2768 -"\n"
2769 -"Version definitions:\n"
2770 -msgstr ""
2771 -"\n"
2772 -"Definiciones de versión:\n"
2773 -
2774 -#: elf.c:1301
2775 -#, c-format
2776 -msgid ""
2777 -"\n"
2778 -"Version References:\n"
2779 -msgstr ""
2780 -"\n"
2781 -"Referencias de Versión:\n"
2782 -
2783 -#: elf.c:1306
2784 -#, c-format
2785 -msgid "  required from %s:\n"
2786 -msgstr "  requerido desde %s:\n"
2787 -
2788 -#: elf.c:1690
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)"
2791 -
2792 -#: elf.c:1858
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]"
2795 -
2796 -#: elf.c:1870
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]"
2799 -
2800 -#: elf.c:1881
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]"
2803 -
2804 -#: elf.c:1891
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]"
2807 -
2808 -#: elf.c:2843
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'"
2811 -
2812 -#: elf.c:2866
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'"
2815 -
2816 -#: elf.c:4142
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"
2819 -
2820 -#: elf.c:4165
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"
2823 -
2824 -#: elf.c:4243
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"
2827 -
2828 -#: elf.c:4341
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"
2831 -
2832 -#: elf.c:4390
2833 -msgid "%B: warning: allocated section `%s' not in segment"
2834 -msgstr "%B: aviso: la sección asignada `%s' no está en el segmento"
2835 -
2836 -#: elf.c:4886
2837 -msgid "%B: symbol `%s' required but not present"
2838 -msgstr "%B: se requiere el símbolo `%s' pero no está presente"
2839 -
2840 -#: elf.c:5199
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"
2843 -
2844 -#: elf.c:6105
2845 -#, c-format
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'"
2848 -
2849 -#: elf.c:7079
2850 -msgid "%B: unsupported relocation type %s"
2851 -msgstr "%B: no se admite el tipo de reubicación %s"
2852 -
2853 -#: elfcode.h:813
2854 +#: elfcode.h:795
2855  #, c-format
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"
2858  
2859 -#: elfcode.h:1226
2860 +#: elfcode.h:1201
2861  #, c-format
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)"
2864  
2865 -#: elfcode.h:1459
2866 +#: elfcode.h:1435
2867  #, c-format
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"
2870  
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"
2874 -
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"
2878 -
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'"
2882 +#: elfcore.h:251
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."
2885  
2886  #: elflink.c:1028
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'"
2891  
2892 -#: elflink.c:1974
2893 +#: elflink.c:1982
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"
2896  
2897 -#: elflink.c:2122
2898 +#: elflink.c:2130
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'"
2901  
2902 -#: elflink.c:2314
2903 +#: elflink.c:2327
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"
2906  
2907 -#: elflink.c:2616
2908 +#: elflink.c:2629
2909  #, c-format
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"
2912  
2913 -#: elflink.c:3910
2914 +#: elflink.c:3953
2915  msgid "%B: %s: invalid version %u (max %d)"
2916  msgstr "%B: %s: versión %u inválida (máximo %d)"
2917  
2918 -#: elflink.c:3946
2919 +#: elflink.c:3989
2920  msgid "%B: %s: invalid needed version %d"
2921  msgstr "%B: %s: versión requerida %d inválida"
2922  
2923 -#: elflink.c:4129
2924 +#: elflink.c:4172
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"
2927  
2928 -#: elflink.c:4135
2929 +#: elflink.c:4178
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"
2932  
2933 -#: elflink.c:4150
2934 +#: elflink.c:4193
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"
2937  
2938 -#: elflink.c:4326
2939 +#: elflink.c:4371
2940  #, c-format
2941  msgid "%s: invalid DSO for symbol `%s' definition"
2942  msgstr "%s: DSO inválido para la definición del símbolo `%s'"
2943  
2944 -#: elflink.c:5552
2945 +#: elflink.c:5621
2946  #, c-format
2947  msgid "%s: undefined version: %s"
2948  msgstr "%s: versión sin definir: %s"
2949  
2950 -#: elflink.c:5620
2951 +#: elflink.c:5689
2952  msgid "%B: .preinit_array section is not allowed in DSO"
2953  msgstr "%B: no se permite la sección .preinit_array en DSO"
2954  
2955 -#: elflink.c:7359
2956 +#: elflink.c:7414
2957  #, c-format
2958  msgid "undefined %s reference in complex symbol: %s"
2959  msgstr "referencia %s indefinida en el símbolo complejo: %s"
2960  
2961 -#: elflink.c:7514
2962 +#: elflink.c:7568
2963  #, c-format
2964  msgid "unknown operator '%c' in complex symbol"
2965  msgstr "operador desconocido '%c' en el símbolo complejo"
2966  
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"
2971  
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"
2976  
2977 -#: elflink.c:8187
2978 +#: elflink.c:8038
2979  msgid "Not enough memory to sort relocations"
2980  msgstr "No hay suficiente memoria para ordenar las reubicaciones"
2981  
2982 -#: elflink.c:8374
2983 +#: elflink.c:8227
2984  msgid "%B: Too many sections: %d (>= %d)"
2985  msgstr "%B: Demasiadas secciones:  %d (>= %d)"
2986  
2987 -#: elflink.c:8608
2988 +#: elflink.c:8461
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"
2991  
2992 -#: elflink.c:8691
2993 +#: elflink.c:8544
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"
2996  
2997 -#: elflink.c:8788
2998 +#: elflink.c:8655
2999  msgid "%B: %s symbol `%s' isn't defined"
3000  msgstr "%B: el símbolo %s `%s' no está definido"
3001  
3002 -#: elflink.c:9284
3003 +#: elflink.c:9141
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"
3006  
3007 -#: elflink.c:9318
3008 +#: elflink.c:9205
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"
3011  
3012 -#: elflink.c:9936
3013 +#: elflink.c:9825
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]"
3016  
3017 -#: elflink.c:9941
3018 +#: elflink.c:9830
3019  #, c-format
3020  msgid "%A has both ordered and unordered sections"
3021  msgstr "%A tiene tanto secciones ordenadas como desordenadas"
3022  
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"
3027  
3028 -#: elflink.c:10833
3029 +#: elflink.c:10720
3030  #, c-format
3031  msgid "warning: %s section has zero size"
3032  msgstr "aviso: la sección %s es de tamaño cero"
3033  
3034 -#: elflink.c:10937
3035 +#: elflink.c:10824
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"
3038  
3039 -#: elflink.c:11305
3040 +#: elflink.c:11006
3041 +msgid "%P%X: can not read symbols: %E\n"
3042 +msgstr "%P%X: no se pueden leer símbolos: %E\n"
3043 +
3044 +#: elflink.c:11313
3045  msgid "Removing unused section '%s' in file '%B'"
3046  msgstr "Se elimina la sección sin uso '%s' en el fichero '%B'"
3047  
3048 -#: elflink.c:11496
3049 +#: elflink.c:11525
3050  msgid "Warning: gc-sections option ignored"
3051  msgstr "Aviso: se descarta la opción gc-sections"
3052  
3053 -#: elflink.c:11987
3054 -msgid "%P%X: can not read symbols: %E\n"
3055 -msgstr "%P%X: no se pueden leer símbolos: %E\n"
3056 -
3057 -#: elflink.c:12129
3058 +#: elflink.c:12056
3059  msgid "%B: ignoring duplicate section `%A'"
3060  msgstr "%B: se descarta la sección duplicada `%A'"
3061  
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"
3066  
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'"
3071  
3072 -#: elflink.c:12160
3073 +#: elflink.c:12087
3074  msgid "%B: warning: duplicate section `%A' has different contents"
3075  msgstr "%B: aviso: la sección duplicada `%A' tiene contenido diferente"
3076  
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"
3081  
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?)"
3085 -
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"
3089 -
3090 -#: elfxx-mips.c:990
3091 +#: elfxx-mips.c:1197
3092  msgid "static procedure (no name)"
3093  msgstr "procedimiento estático (sin nombre)"
3094  
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"
3099  
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"
3104  
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'"
3109 +
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"
3113  
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"
3118  
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"
3123  
3124 -#: elfxx-mips.c:7880
3125 +#: elfxx-mips.c:8244
3126 +#, c-format
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"
3129 +
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'"
3133  
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)"
3138  
3139 -#: elfxx-mips.c:10661
3140 +#: elfxx-mips.c:11887
3141  #, c-format
3142  msgid "%s: illegal section name `%s'"
3143  msgstr "%s: nombre de sección `%s' ilegal"
3144  
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"
3149  
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"
3154 +
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"
3158 +
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"
3162  
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"
3167  
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"
3172 +
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"
3176  
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"
3181  
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"
3186  
3187 -#: elfxx-mips.c:11334
3188 +#: elfxx-mips.c:12702
3189  #, c-format
3190  msgid " [abi=O32]"
3191  msgstr " [abi=O32]"
3192  
3193 -#: elfxx-mips.c:11336
3194 +#: elfxx-mips.c:12704
3195  #, c-format
3196  msgid " [abi=O64]"
3197  msgstr " [abi=O64]"
3198  
3199 -#: elfxx-mips.c:11338
3200 +#: elfxx-mips.c:12706
3201  #, c-format
3202  msgid " [abi=EABI32]"
3203  msgstr " [abi=EABI32]"
3204  
3205 -#: elfxx-mips.c:11340
3206 +#: elfxx-mips.c:12708
3207  #, c-format
3208  msgid " [abi=EABI64]"
3209  msgstr " [abi=EABI64]"
3210  
3211 -#: elfxx-mips.c:11342
3212 +#: elfxx-mips.c:12710
3213  #, c-format
3214  msgid " [abi unknown]"
3215  msgstr " [abi desconocido]"
3216  
3217 -#: elfxx-mips.c:11344
3218 +#: elfxx-mips.c:12712
3219  #, c-format
3220  msgid " [abi=N32]"
3221  msgstr " [abi=N32]"
3222  
3223 -#: elfxx-mips.c:11346
3224 +#: elfxx-mips.c:12714
3225  #, c-format
3226  msgid " [abi=64]"
3227  msgstr " [abi=64]"
3228  
3229 -#: elfxx-mips.c:11348
3230 +#: elfxx-mips.c:12716
3231  #, c-format
3232  msgid " [no abi set]"
3233  msgstr " [no hay conjunto abi]"
3234  
3235 -#: elfxx-mips.c:11369
3236 +#: elfxx-mips.c:12737
3237  #, c-format
3238  msgid " [unknown ISA]"
3239  msgstr " [ISA desconocido]"
3240  
3241 -#: elfxx-mips.c:11380
3242 +#: elfxx-mips.c:12748
3243  #, c-format
3244  msgid " [not 32bitmode]"
3245  msgstr " [no es modo 32bit]"
3246  
3247 -#: elfxx-sparc.c:430
3248 +#: elfxx-sparc.c:440
3249  #, c-format
3250  msgid "invalid relocation type %d"
3251  msgstr "tipo de reubicación %d inválido"
3252  
3253 -#: elfxx-sparc.c:2901
3254 +#: elfxx-sparc.c:2976
3255  msgid "%B: probably compiled without -fPIC?"
3256  msgstr "%B: ¿Compilado probablemente sin -fPIC?"
3257  
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"
3261  
3262 -#: libbfd.c:980
3263 +#: libbfd.c:1008
3264  #, c-format
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"
3267  
3268 -#: libbfd.c:983
3269 +#: libbfd.c:1011
3270  #, c-format
3271  msgid "Deprecated %s called\n"
3272  msgstr "Se llamó a %s que es obsoleto\n"
3273  
3274 -#: linker.c:1875
3275 +#: linker.c:1874
3276  msgid "%B: indirect symbol `%s' to `%s' is a loop"
3277  msgstr "%B: el símbolo indirecto `%s' para `%s' es un ciclo"
3278  
3279 -#: linker.c:2741
3280 +#: linker.c:2740
3281  #, c-format
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"
3284  
3285 -#: linker.c:3048
3286 +#: linker.c:3047
3287  msgid "%B: warning: ignoring duplicate section `%A'\n"
3288  msgstr "%B: aviso: se descarta la sección duplicada `%A'\n"
3289  
3290 -#: linker.c:3062
3291 +#: linker.c:3061
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"
3294  
3295 -#: merge.c:820
3296 +#: merge.c:828
3297  #, c-format
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"
3303  
3304 +#: pe-mips.c:607
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"
3307 +
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.
3312 +#: pe-mips.c:723
3313 +msgid "%B: unimplemented %s\n"
3314 +msgstr "%B: %s sin implementar\n"
3315 +
3316 +#: pe-mips.c:749
3317 +msgid "%B: jump too far away\n"
3318 +msgstr "%B: salto demasiado lejos\n"
3319 +
3320 +#: pe-mips.c:775
3321 +msgid "%B: bad pair/reflo after refhi\n"
3322 +msgstr "%B: pair/reflo erróneo después de refhi\n"
3323 +
3324  #. XXX code yet to be written.
3325  #: peicode.h:759
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."
3330  
3331 -#: pe-mips.c:606
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"
3334 -
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.
3339 -#: pe-mips.c:722
3340 -msgid "%B: unimplemented %s\n"
3341 -msgstr "%B: %s sin implementar\n"
3342 -
3343 -#: pe-mips.c:748
3344 -msgid "%B: jump too far away\n"
3345 -msgstr "%B: salto demasiado lejos\n"
3346 -
3347 -#: pe-mips.c:774
3348 -msgid "%B: bad pair/reflo after refhi\n"
3349 -msgstr "%B: pair/reflo erróneo después de refhi\n"
3350 -
3351  #: ppcboot.c:414
3352  #, c-format
3353  msgid ""
3354 @@ -2950,22 +3068,22 @@ msgstr ""
3355  msgid "Entry offset        = 0x%.8lx (%ld)\n"
3356  msgstr "Desplazamiento de entrada = 0x%.8lx (%ld)\n"
3357  
3358 -#: ppcboot.c:416
3359 +#: ppcboot.c:417
3360  #, c-format
3361  msgid "Length              = 0x%.8lx (%ld)\n"
3362  msgstr "Longitud                  = 0x%.8lx (%ld)\n"
3363  
3364 -#: ppcboot.c:419
3365 +#: ppcboot.c:421
3366  #, c-format
3367  msgid "Flag field          = 0x%.2x\n"
3368  msgstr "Campo de opciones         = 0x%.2x\n"
3369  
3370 -#: ppcboot.c:425
3371 +#: ppcboot.c:427
3372  #, c-format
3373  msgid "Partition name      = \"%s\"\n"
3374  msgstr "Nombre de la partición    = \"%s\"\n"
3375  
3376 -#: ppcboot.c:444
3377 +#: ppcboot.c:446
3378  #, c-format
3379  msgid ""
3380  "\n"
3381 @@ -2974,22 +3092,22 @@ msgstr ""
3382  "\n"
3383  "Partición[%d] inicio = { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }\n"
3384  
3385 -#: ppcboot.c:450
3386 +#: ppcboot.c:452
3387  #, c-format
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"
3390  
3391 -#: ppcboot.c:456
3392 +#: ppcboot.c:458
3393  #, c-format
3394  msgid "Partition[%d] sector = 0x%.8lx (%ld)\n"
3395  msgstr "Partición[%d] sector = 0x%.8lx (%ld)\n"
3396  
3397 -#: ppcboot.c:457
3398 +#: ppcboot.c:460
3399  #, c-format
3400  msgid "Partition[%d] length = 0x%.8lx (%ld)\n"
3401  msgstr "Partición[%d] longitud = 0x%.8lx (%ld)\n"
3402  
3403 -#: som.c:5088
3404 +#: som.c:5137
3405  #, c-format
3406  msgid ""
3407  "\n"
3408 @@ -2998,7 +3116,7 @@ msgstr ""
3409  "\n"
3410  "Encabezado Auxiliar de Ejecución\n"
3411  
3412 -#: som.c:5349
3413 +#: som.c:5440
3414  msgid "som_sizeof_headers unimplemented"
3415  msgstr "som_sizeof_headers sin implementar"
3416  
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"
3420  
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"
3424 +
3425  #: stabs.c:279
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."
3428  
3429 -#: syms.c:1057
3430 +#: syms.c:1067
3431  msgid "Unsupported .stab relocation"
3432  msgstr "No se admite la reubicación .stab"
3433  
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"
3437  
3438 -#: vms-misc.c:803
3439 +#: vms-misc.c:808
3440  msgid "_bfd_vms_output_counted called with zero bytes"
3441  msgstr "se llamó _bfd_vms_output_counted con cero bytes"
3442  
3443 -#: vms-misc.c:808
3444 +#: vms-misc.c:813
3445  msgid "_bfd_vms_output_counted called with too many bytes"
3446  msgstr "se llamó _bfd_vms_output_counted con demasiados bytes"
3447  
3448 -#: vms-misc.c:926
3449 +#: vms-misc.c:931
3450  #, c-format
3451  msgid "Symbol %s replaced by %s\n"
3452  msgstr "El símbolo %s fue reemplazado por %s\n"
3453  
3454 -#: vms-misc.c:985
3455 +#: vms-misc.c:990
3456  #, c-format
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"
3462  
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."
3467  
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"
3472  
3473 -#: elf32-ia64.c:4523 elf64-ia64.c:4523
3474 +#: elf32-ia64.c:4317 elf64-ia64.c:4317
3475  #, c-format
3476  msgid "%s: short data segment overflowed (0x%lx >= 0x400000)"
3477  msgstr "%s: segmento de datos short desbordado (0x%lx >= 0x400000)"
3478  
3479 -#: elf32-ia64.c:4534 elf64-ia64.c:4534
3480 +#: elf32-ia64.c:4328 elf64-ia64.c:4328
3481  #, c-format
3482  msgid "%s: __gp does not cover short data segment"
3483  msgstr "%s: __gp no cubre el segmento de datos short"
3484  
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"
3489  
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"
3494  
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"
3499  
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"
3504  
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"
3509  
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"
3514  
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"
3519  
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'."
3524 +
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)."
3528  
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"
3533  
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"
3538  
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"
3543  
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"
3548  
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"
3553  
3554 @@ -3602,12 +3728,14 @@ msgstr ""
3555  "\n"
3556  "Tabla [Puntero a Ordinal/Nombre]\n"
3557  
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
3561  #, c-format
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"
3564  
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
3568  #, c-format
3569  msgid ""
3570  "\n"
3571 @@ -3616,12 +3744,12 @@ msgstr ""
3572  "\n"
3573  "La Tabla de Funciones (se interpretaron los contenidos de la sección .pdata)\n"
3574  
3575 -#: peigen.c:1617 pepigen.c:1617 pex64igen.c:1617
3576 +#: peigen.c:1624 pepigen.c:1624 pex64igen.c:1624
3577  #, c-format
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"
3580  
3581 -#: peigen.c:1619 pepigen.c:1619 pex64igen.c:1619
3582 +#: peigen.c:1626 pepigen.c:1626 pex64igen.c:1626
3583  #, c-format
3584  msgid ""
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"
3589  
3590 -#: peigen.c:1689 pepigen.c:1689 pex64igen.c:1689
3591 +#: peigen.c:1696 pepigen.c:1696 pex64igen.c:1696
3592  #, c-format
3593  msgid " Register save millicode"
3594  msgstr " Registro para guardar milicódigo"
3595  
3596 -#: peigen.c:1692 pepigen.c:1692 pex64igen.c:1692
3597 +#: peigen.c:1699 pepigen.c:1699 pex64igen.c:1699
3598  #, c-format
3599  msgid " Register restore millicode"
3600  msgstr " Registro para restaurar milicódigo"
3601  
3602 -#: peigen.c:1695 pepigen.c:1695 pex64igen.c:1695
3603 +#: peigen.c:1702 pepigen.c:1702 pex64igen.c:1702
3604  #, c-format
3605  msgid " Glue code sequence"
3606  msgstr " Secuencia de código pegamento"
3607  
3608 -#: peigen.c:1745 pepigen.c:1745 pex64igen.c:1745
3609 +#: peigen.c:1802 pepigen.c:1802 pex64igen.c:1802
3610 +#, c-format
3611 +msgid ""
3612 +" vma:\t\tBegin    Prolog   Function Flags    Exception EH\n"
3613 +"     \t\tAddress  Length   Length   32b exc  Handler   Data\n"
3614 +msgstr ""
3615 +" vma:\t\tInicio   Prólogo  Función  Opciones Excepción EH\n"
3616 +"     \t\tDirecc   Longitud Longitud 32b exc  Manejador Datos\n"
3617 +
3618 +#: peigen.c:1933 pepigen.c:1933 pex64igen.c:1933
3619  #, c-format
3620  msgid ""
3621  "\n"
3622 @@ -3656,7 +3793,7 @@ msgstr ""
3623  "\n"
3624  "Reubicaciones de Fichero Base PE (se interpretaron los contenidos de la sección .reloc)\n"
3625  
3626 -#: peigen.c:1775 pepigen.c:1775 pex64igen.c:1775
3627 +#: peigen.c:1963 pepigen.c:1963 pex64igen.c:1963
3628  #, c-format
3629  msgid ""
3630  "\n"
3631 @@ -3665,7 +3802,7 @@ msgstr ""
3632  "\n"
3633  "Dirección Virtual: %08lx Tamaño del trozo %ld (0x%lx) Número de composturas %ld\n"
3634  
3635 -#: peigen.c:1788 pepigen.c:1788 pex64igen.c:1788
3636 +#: peigen.c:1976 pepigen.c:1976 pex64igen.c:1976
3637  #, c-format
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
3643  #. emulate it here.
3644 -#: peigen.c:1827 pepigen.c:1827 pex64igen.c:1827
3645 +#: peigen.c:2015 pepigen.c:2015 pex64igen.c:2015
3646  #, c-format
3647  msgid ""
3648  "\n"
3649 @@ -3682,26 +3819,47 @@ msgstr ""
3650  "\n"
3651  "Características 0x%x\n"
3652  
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"
3657  
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"
3662  
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"
3667  
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"
3672  
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"
3677  
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)."
3680 +
3681 +#~ msgid "Dwarf Error: Can't find .debug_abbrev section."
3682 +#~ msgstr "Error de Dwarf: No se puede encontrar la sección .debug_abbrev."
3683 +
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)."
3686 +
3687 +#~ msgid "Dwarf Error: Can't find .debug_line section."
3688 +#~ msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_line."
3689 +
3690 +#~ msgid "Dwarf Error: Can't find .debug_ranges section."
3691 +#~ msgstr "Error de Dwarf: No se puede encontrar lan sección .debug_ranges."
3692 +
3693 +#~ msgid "ERROR: %B: Conflicting definitions of wchar_t"
3694 +#~ msgstr "ERROR: %B: Definiciones en conflicto de wchar_t"
3695 +
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"
3698 +
3699  #~ msgid "ERROR: %B: Conflicting enum sizes"
3700  #~ msgstr "ERROR: %B: Tamaños de enum en conflicto"
3701  
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"
3705  
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"
3708 -
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)"
3711  
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@
3717  
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@
3722  
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@
3726  
3727 +# Did the user give us a --with-gdb-datadir option?
3728 +GDB_DATADIR_PATH = @GDB_DATADIR_PATH@
3729 +
3730 +# The argument to --with-pythondir.  If not given, this is
3731 +# GDB_DATADIR_PATH/python.
3732 +pythondir = @pythondir@
3733 +
3734  # Helper code from gnulib.
3735  LIBGNU = gnulib/libgnu.a
3736  INCGNU = -I$(srcdir)/gnulib -Ignulib
3737 @@ -270,12 +279,34 @@ SUBDIR_TUI_CFLAGS= \
3738  #
3739  SUBDIR_PYTHON_OBS = \
3740         python.o \
3741 +       python-block.o \
3742 +       python-breakpoint.o \
3743         python-cmd.o \
3744 +       python-frame.o \
3745 +       python-function.o \
3746 +       python-hooks.o \
3747 +       python-membuf.o \
3748 +       python-objfile.o \
3749 +       python-param.o \
3750 +       python-symbol.o \
3751 +       python-symtab.o \
3752 +       python-type.o \
3753         python-utils.o \
3754         python-value.o
3755  SUBDIR_PYTHON_SRCS = \
3756         python/python.c \
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)
3781  
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)
3788  
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 \
3793         wrapper.c \
3794         xml-tdesc.c xml-support.c \
3795 +       xml-syscall.c \
3796         inferior.c
3797  
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
3806  
3807  # Header files that already have srcdir in them, or which are in objdir.
3808  
3809 @@ -812,10 +846,16 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \
3810         trad-frame.o \
3811         tramp-frame.o \
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 \
3816         inferior.o osdata.o
3817  
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
3823 +
3824  TSOBS = inflow.o
3825  
3826  SUBDIRS = @subdirs@
3827 @@ -849,11 +889,38 @@ generated_files = config.h observer.h observer.inc ada-lex.c \
3828         $(COMPILE) $<
3829         $(POSTCOMPILE)
3830  
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
3834  .PHONY: all-tui
3835  all-tui: $(TUI)$(EXEEXT)
3836  
3837 +xml-syscall-copy:
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) ; \
3846 +           fi ; \
3847 +         done ; \
3848 +       fi ;
3849 +
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) ; \
3861 +         fi ; \
3862 +       done ;
3863 +
3864  installcheck:
3865  
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 
3874 +
3875 +# The "install-only" target also installs the syscalls' XML files in
3876 +# the system.
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
3882           CONFIG_LINKS= \
3883           $(SHELL) config.status
3884  
3885 +.gdbinit: gdbinit.in config.status
3886 +       CONFIG_FILES=".gdbinit:gdbinit.in" \
3887 +         CONFIG_COMMANDS= \
3888 +         CONFIG_HEADERS= \
3889 +         $(SHELL) config.status
3890 +
3891  config.status: configure configure.tgt configure.host
3892         $(SHELL) config.status --recheck
3893  
3894 @@ -1845,10 +1921,54 @@ python.o: $(srcdir)/python/python.c
3895         $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python.c
3896         $(POSTCOMPILE)
3897  
3898 +python-block.o: $(srcdir)/python/python-block.c
3899 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-block.c
3900 +       $(POSTCOMPILE)
3901 +
3902 +python-breakpoint.o: $(srcdir)/python/python-breakpoint.c
3903 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-breakpoint.c
3904 +       $(POSTCOMPILE)
3905 +
3906  python-cmd.o: $(srcdir)/python/python-cmd.c
3907         $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-cmd.c
3908         $(POSTCOMPILE)
3909  
3910 +python-frame.o: $(srcdir)/python/python-frame.c
3911 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-frame.c
3912 +       $(POSTCOMPILE)
3913 +
3914 +python-function.o: $(srcdir)/python/python-function.c
3915 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-function.c
3916 +       $(POSTCOMPILE)
3917 +
3918 +python-hooks.o: $(srcdir)/python/python-hooks.c
3919 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-hooks.c
3920 +       $(POSTCOMPILE)
3921 +
3922 +python-membuf.o: $(srcdir)/python/python-membuf.c
3923 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-membuf.c
3924 +       $(POSTCOMPILE)
3925 +
3926 +python-objfile.o: $(srcdir)/python/python-objfile.c
3927 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-objfile.c
3928 +       $(POSTCOMPILE)
3929 +
3930 +python-param.o: $(srcdir)/python/python-param.c
3931 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-param.c
3932 +       $(POSTCOMPILE)
3933 +
3934 +python-symbol.o: $(srcdir)/python/python-symbol.c
3935 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-symbol.c
3936 +       $(POSTCOMPILE)
3937 +
3938 +python-symtab.o: $(srcdir)/python/python-symtab.c
3939 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-symtab.c
3940 +       $(POSTCOMPILE)
3941 +
3942 +python-type.o: $(srcdir)/python/python-type.c
3943 +       $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-type.c
3944 +       $(POSTCOMPILE)
3945 +
3946  python-utils.o: $(srcdir)/python/python-utils.c
3947         $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-utils.c
3948         $(POSTCOMPILE)
3949 @@ -1857,6 +1977,38 @@ python-value.o: $(srcdir)/python/python-value.c
3950         $(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/python-value.c
3951         $(POSTCOMPILE)
3952  
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 \
3962 +    gdb/__init__.py
3963 +
3964 +# Install the Python library.  Python library files go under
3965 +# $(pythondir).
3966 +install-python:
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; \
3971 +       done
3972 +
3973 +# Other packages may have their files installed in $(pythondir).
3974 +uninstall-python:
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,/[^/]*$$,,'`; \
3982 +         done \
3983 +       done
3984 +
3985  #
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
3990 --- a/gdb/NEWS
3991 +++ b/gdb/NEWS
3992 @@ -3,6 +3,13 @@
3993  
3994  *** Changes since GDB 6.8
3995  
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
4001 +`printf'.
4002 +
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.
4009  
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.
4014 +
4015  set tcp auto-retry (on|off)
4016  show tcp auto-retry
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])
4025  
4026 +dnl For AM_LANGINFO_CODESET.
4027 +sinclude([../config/codeset.m4])
4028 +
4029  #
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
4040      done
4041     ])
4042  
4043 @@ -230,6 +233,8 @@ size_t iconv();
4044      LIBICONV="-liconv"
4045    fi
4046    AC_SUBST(LIBICONV)
4047 +  AC_SUBST(LIBICONV_INCLUDE)
4048 +  AC_SUBST(LIBICONV_LIBDIR)
4049  ])
4050  
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)
4066                         value_copy (val));
4067    else
4068      return value_from_longest (desc_data_type (thin_descriptor_type (type)),
4069 -                               VALUE_ADDRESS (val) + value_offset (val));
4070 +                               value_address (val));
4071  }
4072  
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);
4077        else
4078 -        addr = VALUE_ADDRESS (arr) + value_offset (arr);
4079 +        addr = value_address (arr);
4080  
4081        return
4082          value_from_longest (lookup_pointer_type (bounds_type),
4083 @@ -1666,8 +1666,8 @@ ada_type_of_array (struct value *arr, int bounds)
4084          return NULL;
4085        while (arity > 0)
4086          {
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);
4093            arity -= 1;
4094 @@ -1774,9 +1774,9 @@ packed_array_type (struct type *type, long *elt_bits)
4095    if (TYPE_CODE (type) != TYPE_CODE_ARRAY)
4096      return type;
4097  
4098 -  new_type = alloc_type (TYPE_OBJFILE (type));
4099    new_elt_type = packed_array_type (ada_check_typedef (TYPE_TARGET_TYPE (type)),
4100                                      elt_bits);
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)
4106        return NULL;
4107      }
4108    shadow_type = SYMBOL_TYPE (sym);
4109 +  CHECK_TYPEDEF (shadow_type);
4110  
4111    if (TYPE_CODE (shadow_type) != TYPE_CODE_ARRAY)
4112      {
4113 @@ -2005,10 +2006,9 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
4114      }
4115    else if (VALUE_LVAL (obj) == lval_memory && value_lazy (obj))
4116      {
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);
4123      }
4124    else
4125      {
4126 @@ -2018,15 +2018,18 @@ ada_value_primitive_packed_val (struct value *obj, const gdb_byte *valaddr,
4127  
4128    if (obj != NULL)
4129      {
4130 +      CORE_ADDR new_addr;
4131 +
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)
4138          {
4139 -          VALUE_ADDRESS (v) += 1;
4140 +          new_addr++;
4141            set_value_bitpos (v, value_bitpos (v) - HOST_CHAR_BIT);
4142          }
4143 +      set_value_address (v, new_addr);
4144      }
4145    else
4146      set_value_bitsize (v, bit_size);
4147 @@ -2218,7 +2221,7 @@ ada_value_assign (struct value *toval, struct value *fromval)
4148        int from_size;
4149        char *buffer = (char *) alloca (len);
4150        struct value *val;
4151 -      CORE_ADDR to_addr = VALUE_ADDRESS (toval) + value_offset (toval);
4152 +      CORE_ADDR to_addr = value_address (toval);
4153  
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,
4157                            struct value *val)
4158  {
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);
4165    int bits;
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.  */
4172  
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)
4176          indicated. */
4177        if (gdbarch_inner_than (current_gdbarch, 1, 2))
4178         {
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. */
4182           *sp -= len;
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);
4187         }
4188        else
4189         {
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);
4196           *sp += len;
4197           if (gdbarch_frame_align_p (current_gdbarch))
4198             *sp = gdbarch_frame_align (current_gdbarch, *sp);
4199         }
4200        VALUE_LVAL (val) = lval_memory;
4201  
4202 -      write_memory (VALUE_ADDRESS (val), value_contents_raw (val), len);
4203 +      write_memory (value_address (val), value_contents_raw (val), len);
4204      }
4205  
4206    return val;
4207 @@ -3911,12 +3913,12 @@ make_array_descriptor (struct type *type, struct value *arr, CORE_ADDR *sp)
4208    bounds = ensure_lval (bounds, sp);
4209  
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));
4215  
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));
4221  
4222 @@ -6790,7 +6792,7 @@ variant_field_index (struct type *type)
4223  static struct type *
4224  empty_record (struct objfile *objfile)
4225  {
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,
4232          nfields++;
4233      }
4234  
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)
4243          {
4244 -          TYPE_TARGET_TYPE (type0) = type = alloc_type (TYPE_OBJFILE (type0));
4245 +          TYPE_TARGET_TYPE (type0) = type = alloc_type (TYPE_OBJFILE (type0),
4246 +                                                       NULL);
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,
4251    else
4252      dval = dval0;
4253  
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)
4261          result = type0;
4262        else
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));
4266      }
4267    else
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);
4275          }
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)
4279  {
4280    return ada_to_fixed_value_create (value_type (val),
4281 -                                    VALUE_ADDRESS (val) + value_offset (val),
4282 +                                    value_address (val),
4283                                      val);
4284  }
4285  
4286 @@ -7869,7 +7872,7 @@ unwrap_value (struct value *val)
4287        return
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),
4292                                   NULL, 1));
4293      }
4294  }
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)
4297         return raw_type;
4298        else
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));
4303      }
4304 @@ -9611,7 +9614,7 @@ to_fixed_range_type (char *name, struct value *dval, struct objfile *objfile)
4305  
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;
4311        return type;
4312      }
4313 @@ -11009,9 +11012,9 @@ ada_language_arch_info (struct gdbarch *gdbarch,
4314  /* Not really used, but needed in the ada_language_defn.  */
4315  
4316  static void
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)
4319  {
4320 -  ada_emit_char (c, stream, quoter, 1);
4321 +  ada_emit_char (c, type, stream, quoter, 1);
4322  }
4323  
4324  static int
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 *,
4330  
4331                                  /* Defined in ada-lang.c */
4332  
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);
4335  
4336 -extern void ada_printchar (int, struct ui_file *);
4337 +extern void ada_printchar (int, struct type *, struct ui_file *);
4338  
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 *);
4344  
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)
4351  
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);
4356  
4357    /* Add the NUL character to close the string.  */
4358    dest[len] = '\0';
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,
4364    bitsize = 0;
4365    fprintf_filtered (stream, "array (");
4366  
4367 +  if (type == NULL)
4368 +    {
4369 +      fprintf_filtered (stream, _("<undecipherable array type>"));
4370 +      return;
4371 +    }
4372 +
4373    n_indices = -1;
4374    if (show < 0)
4375      fprintf_filtered (stream, "...");
4376    else
4377      {
4378 -      if (type == NULL)
4379 -        {
4380 -          fprintf_filtered (stream, _("<undecipherable array type>"));
4381 -          return;
4382 -        }
4383        if (ada_is_simple_array_type (type))
4384         {
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.  */
4392  
4393  void
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)
4397  {
4398    if (type_len != 2)
4399      type_len = 1;
4400 @@ -366,10 +367,10 @@ ada_print_floating (const gdb_byte *valaddr, struct type *type,
4401  }
4402  
4403  void
4404 -ada_printchar (int c, struct ui_file *stream)
4405 +ada_printchar (int c, struct type *type, struct ui_file *stream)
4406  {
4407    fputs_filtered ("'", stream);
4408 -  ada_emit_char (c, stream, '\'', 1);
4409 +  ada_emit_char (c, type, stream, '\'', 1);
4410    fputs_filtered ("'", stream);
4411  }
4412  
4413 @@ -411,7 +412,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
4414        break;
4415  
4416      case TYPE_CODE_CHAR:
4417 -      LA_PRINT_CHAR ((unsigned char) val, stream);
4418 +      LA_PRINT_CHAR ((unsigned char) val, type, stream);
4419        break;
4420  
4421      case TYPE_CODE_BOOL:
4422 @@ -454,7 +455,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
4423   */
4424  
4425  static void
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)
4430  {
4431 @@ -506,7 +507,7 @@ printstr (struct ui_file *stream, const gdb_byte *string,
4432               in_quotes = 0;
4433             }
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, '\'',
4437                          type_len);
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);
4442               in_quotes = 1;
4443             }
4444 -         ada_emit_char (char_at (string, i, type_len), stream, '"',
4445 +         ada_emit_char (char_at (string, i, type_len), elttype, stream, '"',
4446                          type_len);
4447           things_printed += 1;
4448         }
4449 @@ -544,11 +545,12 @@ printstr (struct ui_file *stream, const gdb_byte *string,
4450  }
4451  
4452  void
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)
4458  {
4459 -  printstr (stream, string, length, force_ellipses, width, options);
4460 +  printstr (stream, type, string, length, force_ellipses, TYPE_LENGTH (type),
4461 +           options);
4462  }
4463  
4464  
4465 @@ -637,7 +639,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
4466            len = temp_len;
4467          }
4468  
4469 -      printstr (stream, valaddr, len, 0, eltlen, options);
4470 +      printstr (stream, elttype, valaddr, len, 0, eltlen, options);
4471        result = len;
4472      }
4473    else
4474 @@ -688,7 +690,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4475         }
4476        else
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);
4481        return retn;
4482      }
4483 @@ -817,7 +819,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4484                 {
4485                   fputs_filtered (" ", stream);
4486                   ada_printchar ((unsigned char) unpack_long (type, valaddr),
4487 -                                stream);
4488 +                                type, stream);
4489                 }
4490             }
4491           return 0;
4492 @@ -904,7 +906,7 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
4493                                  deref_val_int));
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);
4499              }
4500            else
4501 @@ -944,7 +946,7 @@ ada_value_print (struct value *val0, struct ui_file *stream,
4502                  const struct value_print_options *options)
4503  {
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);
4507    struct type *type =
4508      ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
4509    struct value *val =
4510 diff --git a/gdb/auxv.c b/gdb/auxv.c
4511 index 5007cd0..3a51ec5 100644
4512 --- a/gdb/auxv.c
4513 +++ b/gdb/auxv.c
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");
4530           }
4531           break;
4532 diff --git a/gdb/block.c b/gdb/block.c
4533 index 8f0140c..d451769 100644
4534 --- a/gdb/block.c
4535 +++ b/gdb/block.c
4536 @@ -207,24 +207,16 @@ block_set_scope (struct block *block, const char *scope,
4537  }
4538  
4539  /* This returns the first using directives associated to BLOCK, if
4540 -   any.  */
4541 -
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.  */
4549  
4550  struct using_direct *
4551  block_using (const struct block *block)
4552  {
4553 -  const struct block *static_block = block_static_block (block);
4554 -
4555 -  if (static_block == NULL
4556 -      || BLOCK_NAMESPACE (static_block) == NULL)
4557 +  if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
4558      return NULL;
4559    else
4560 -    return BLOCK_NAMESPACE (static_block)->using;
4561 +    return BLOCK_NAMESPACE (block)->using;
4562  }
4563  
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);
4570  
4571  static void insert_breakpoint_locations (void);
4572  
4573 +static int syscall_catchpoint_p (struct breakpoint *b);
4574 +
4575  static const char *
4576  bpdisp_text (enum bpdisp disp)
4577  {
4578 @@ -341,6 +343,18 @@ set_breakpoint_count (int num)
4579                    value_from_longest (builtin_type_int32, (LONGEST) num));
4580  }
4581  
4582 +/* Used in run_command to reset syscall catchpoints fields.  */
4583 +
4584 +void
4585 +clear_syscall_catchpoints_info (void)
4586 +{
4587 +  struct breakpoint *b;
4588 +
4589 +  ALL_BREAKPOINTS (b)
4590 +    if (syscall_catchpoint_p (b))
4591 +      b->syscall_number = UNKNOWN_SYSCALL;
4592 +}
4593 +
4594  /* Used in run_command to zero the hit count when a new run starts. */
4595  
4596  void
4597 @@ -523,6 +537,53 @@ get_number_or_range (char **pp)
4598  
4599  
4600  \f
4601 +/* Set break condition of breakpoint B to EXP.  */
4602 +
4603 +void
4604 +set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty)
4605 +{
4606 +  struct bp_location *loc = b->loc;
4607 +
4608 +  for (; loc; loc = loc->next)
4609 +    {
4610 +      if (loc->cond)
4611 +       {
4612 +         xfree (loc->cond);
4613 +         loc->cond = 0;
4614 +       }
4615 +    }
4616 +
4617 +  if (b->cond_string != NULL)
4618 +    xfree (b->cond_string);
4619 +
4620 +  if (*exp == 0)
4621 +    {
4622 +      b->cond_string = NULL;
4623 +      if (from_tty)
4624 +       printf_filtered (_("Breakpoint %d now unconditional.\n"), b->number);
4625 +    }
4626 +  else
4627 +    {
4628 +      char *arg = exp;
4629 +
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)
4635 +       {
4636 +         arg = exp;
4637 +         loc->cond =
4638 +           parse_exp_1 (&arg, block_for_pc (loc->address), 0);
4639 +         if (*arg)
4640 +           error (_("Junk at end of expression"));
4641 +       }
4642 +    }
4643 +
4644 +  breakpoints_changed ();
4645 +  observer_notify_breakpoint_modified (b->number);
4646 +}
4647 +
4648  /* condition N EXP -- set break condition of breakpoint N to EXP.  */
4649  
4650  static void
4651 @@ -543,42 +604,7 @@ condition_command (char *arg, int from_tty)
4652    ALL_BREAKPOINTS (b)
4653      if (b->number == bnum)
4654        {
4655 -       struct bp_location *loc = b->loc;
4656 -       for (; loc; loc = loc->next)
4657 -         {
4658 -           if (loc->cond)
4659 -             {
4660 -               xfree (loc->cond);
4661 -               loc->cond = 0;
4662 -             }
4663 -         }
4664 -       if (b->cond_string != NULL)
4665 -         xfree (b->cond_string);
4666 -
4667 -       if (*p == 0)
4668 -         {
4669 -           b->cond_string = NULL;
4670 -           if (from_tty)
4671 -             printf_filtered (_("Breakpoint %d now unconditional.\n"), bnum);
4672 -         }
4673 -       else
4674 -         {
4675 -           arg = p;
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)
4681 -             {
4682 -               arg = p;
4683 -               loc->cond =
4684 -                 parse_exp_1 (&arg, block_for_pc (loc->address), 0);
4685 -               if (*arg)
4686 -                 error (_("Junk at end of expression"));
4687 -             }
4688 -         }
4689 -       breakpoints_changed ();
4690 -       observer_notify_breakpoint_modified (b->number);
4691 +       set_breakpoint_condition (b, p, from_tty);
4692         return;
4693        }
4694  
4695 @@ -961,7 +987,7 @@ update_watchpoint (struct breakpoint *b, int reparse)
4696                   int len, type;
4697                   struct bp_location *loc, **tmp;
4698  
4699 -                 addr = VALUE_ADDRESS (v) + value_offset (v);
4700 +                 addr = value_address (v);
4701                   len = TYPE_LENGTH (value_type (v));
4702                   type = hw_write;
4703                   if (b->type == bp_read_watchpoint)
4704 @@ -3948,8 +3974,8 @@ check_duplicates_for (CORE_ADDR address, struct obj_section *section)
4705      }
4706  
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
4709 -     duplicates.  */
4710 +     list again and declare all the other breakpoints there (except
4711 +     other permanent breakpoints) to be the duplicates.  */
4712    if (perm_bp)
4713      {
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)
4717         if (b != perm_bp)
4718           {
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;
4731    b->ops = NULL;
4732    b->condition_not_parsed = 0;
4733  
4734 @@ -4660,7 +4689,241 @@ static struct breakpoint_ops catch_vfork_breakpoint_ops =
4735    print_mention_catch_vfork
4736  };
4737  
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.  */
4742 +
4743 +/* Number of times that "any" syscall is requested.  */
4744 +static int any_syscall_count;
4745 +
4746 +/* Count of each system call.  */
4747 +static int *syscalls_counts;
4748 +
4749 +/* Number of system entries in SYSCALLS_COUNTS.  */
4750 +static int syscalls_size;
4751 +
4752 +/* This counts all syscall catch requests, so we can readily determine
4753 +   if any catching is necessary.  */
4754 +static int total_syscalls_count;
4755 +
4756 +/* Implement the "insert" breakpoint_ops method for syscall
4757 +   catchpoints.  */
4758 +
4759 +static void
4760 +insert_catch_syscall (struct breakpoint *b)
4761 +{
4762 +  ++total_syscalls_count;
4763 +  if (!b->syscalls_to_be_caught)
4764 +    ++any_syscall_count;
4765 +  else
4766 +    {
4767 +      struct syscall_filter *iter;
4768 +      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4769 +       {
4770 +         if (iter->syscall >= syscalls_size)
4771 +           {
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));
4776 +           }
4777 +         ++syscalls_counts[iter->syscall];
4778 +       }
4779 +    }
4780 +
4781 +  target_set_syscall_catchpoint (PIDGET (inferior_ptid),
4782 +                                total_syscalls_count != 0,
4783 +                                any_syscall_count,
4784 +                                syscalls_size,
4785 +                                syscalls_counts);
4786 +}
4787 +
4788 +/* Implement the "remove" breakpoint_ops method for syscall
4789 +   catchpoints.  */
4790 +
4791 +static int
4792 +remove_catch_syscall (struct breakpoint *b)
4793 +{
4794 +  --total_syscalls_count;
4795 +  if (!b->syscalls_to_be_caught)
4796 +    --any_syscall_count;
4797 +  else
4798 +    {
4799 +      struct syscall_filter *iter;
4800 +      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4801 +       {
4802 +         if (iter->syscall >= syscalls_size)
4803 +           {
4804 +             /* Shouldn't happen.  */
4805 +             continue;
4806 +           }
4807 +         --syscalls_counts[iter->syscall];
4808 +       }
4809 +    }
4810 +
4811 +  return target_set_syscall_catchpoint (PIDGET (inferior_ptid),
4812 +                                       total_syscalls_count != 0,
4813 +                                       any_syscall_count,
4814 +                                       syscalls_size,
4815 +                                       syscalls_counts);
4816 +}
4817 +
4818 +/* Implement the "breakpoint_hit" breakpoint_ops method for syscall
4819 +   catchpoints.  */
4820 +
4821 +static int
4822 +breakpoint_hit_catch_syscall (struct breakpoint *b)
4823 +{
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;
4828 +
4829 +  if (!inferior_has_called_syscall (inferior_ptid, &syscall_number))
4830 +    return 0;
4831 +
4832 +  /* Now, checking if the syscall is the same.  */
4833 +  if (b->syscalls_to_be_caught)
4834 +    {
4835 +      struct syscall_filter *iter;
4836 +      for (iter = b->syscalls_to_be_caught; iter; iter = iter->next)
4837 +       if (syscall_number == iter->syscall)
4838 +         break;
4839 +      /* Not the same.  */
4840 +      if (!iter)
4841 +       return 0;
4842 +    }
4843 +
4844 +  /* It's the same syscall.  We can update the breakpoint struct
4845 +     with the correct information.  */
4846 +  b->syscall_number = syscall_number;
4847 +
4848 +  return 1;
4849 +}
4850 +
4851 +/* Implement the "print_it" breakpoint_ops method for syscall
4852 +   catchpoints.  */
4853 +
4854 +static enum print_stop_action
4855 +print_it_catch_syscall (struct breakpoint *b)
4856 +{
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".  */
4861 +  ptid_t ptid;
4862 +  struct target_waitstatus last;
4863 +  struct syscall s;
4864 +  struct cleanup *old_chain;
4865 +  char *syscall_id;
4866 +
4867 +  gdbarch_get_syscall_by_number (current_gdbarch, b->syscall_number, &s);
4868 +
4869 +  get_last_target_status (&ptid, &last);
4870 +
4871 +  annotate_catchpoint (b->number);
4872 +
4873 +  if (s.name == NULL)
4874 +    syscall_id = xstrprintf ("%d", b->syscall_number);
4875 +  else
4876 +    syscall_id = xstrprintf ("'%s'", s.name);
4877 +
4878 +  old_chain = make_cleanup (xfree, syscall_id);
4879 +
4880 +  if (last.kind == TARGET_WAITKIND_SYSCALL_ENTRY)
4881 +    printf_filtered (_("\nCatchpoint %d (call to syscall %s), "),
4882 +                     b->number, syscall_id);
4883 +  else
4884 +    printf_filtered (_("\nCatchpoint %d (returned from syscall %s), "),
4885 +                     b->number, syscall_id);
4886 +
4887 +  do_cleanups (old_chain);
4888 +
4889 +  return PRINT_SRC_AND_LOC;
4890 +}
4891 +
4892 +/* Implement the "print_one" breakpoint_ops method for syscall
4893 +   catchpoints.  */
4894 +
4895 +static void
4896 +print_one_catch_syscall (struct breakpoint *b, CORE_ADDR *last_addr)
4897 +{
4898 +  struct value_print_options opts;
4899 +  struct syscall s;
4900 +
4901 +  gdbarch_get_syscall_by_number (current_gdbarch, b->syscall_number, &s);
4902 +
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)
4912 +    {
4913 +      if (s.name)
4914 +        ui_out_field_string (uiout, "what", s.name);
4915 +      else
4916 +        ui_out_field_int (uiout, "what", b->syscall_number);
4917 +    }
4918 +  else
4919 +    ui_out_field_string (uiout, "what", "<any syscall>");
4920 +  ui_out_text (uiout, "\" ");
4921 +}
4922 +
4923 +/* Implement the "print_mention" breakpoint_ops method for syscall
4924 +   catchpoints.  */
4925 +
4926 +static void
4927 +print_mention_catch_syscall (struct breakpoint *b)
4928 +{
4929 +  if (b->syscalls_to_be_caught)
4930 +    {
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)
4934 +        {
4935 +          struct syscall s;
4936 +          gdbarch_get_syscall_by_number (current_gdbarch, iter->syscall, &s);
4937 +            
4938 +          if (s.name)
4939 +            printf_filtered (" '%s'", s.name);
4940 +          else
4941 +            printf_filtered (" %d", iter->syscall);
4942 +        }
4943 +      printf_filtered (")");
4944 +    }
4945 +  else
4946 +    printf_filtered (_("Catchpoint %d (any syscall)"),
4947 +                     b->number);
4948 +}
4949 +
4950 +/* The breakpoint_ops structure to be used in syscall catchpoints.  */
4951 +
4952 +static struct breakpoint_ops catch_syscall_breakpoint_ops =
4953 +{
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
4960 +};
4961 +
4962 +/* Returns non-zero if 'b' is a syscall catchpoint.  */
4963 +
4964 +static int
4965 +syscall_catchpoint_p (struct breakpoint *b)
4966 +{
4967 +  return (b->ops == &catch_syscall_breakpoint_ops);
4968 +}
4969 +
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.
4974   
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.  */
4979  
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)
4985  {
4986    struct symtab_and_line sal;
4987    struct breakpoint *b;
4988  
4989    init_sal (&sal);
4990 -  sal.pc = 0;
4991 -  sal.symtab = NULL;
4992 -  sal.line = 0;
4993  
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;
4998    b->ops = ops;
4999  
5000 +  return b;
5001 +}
5002 +
5003 +/* Create a new breakpoint of the bp_catchpoint kind and return it.
5004
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.  */
5009 +
5010 +static struct breakpoint *
5011 +create_catchpoint (int tempflag, char *cond_string,
5012 +                   struct breakpoint_ops *ops)
5013 +{
5014 +  struct breakpoint *b =
5015 +    create_catchpoint_without_mention (tempflag, cond_string, ops);
5016 +
5017    mention (b);
5018    update_global_location_list (1);
5019  
5020 @@ -4775,6 +5052,23 @@ static struct breakpoint_ops catch_exec_breakpoint_ops =
5021    print_mention_catch_exec
5022  };
5023  
5024 +static void
5025 +create_syscall_event_catchpoint (int tempflag, struct syscall_filter *filter,
5026 +                                 struct breakpoint_ops *ops)
5027 +{
5028 +  struct breakpoint *b =
5029 +    create_catchpoint_without_mention (tempflag, NULL, ops);
5030 +
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;
5034 +
5035 +  /* Now, we have to mention the breakpoint and update the global
5036 +     location list.  */
5037 +  mention (b);
5038 +  update_global_location_list (1);
5039 +}
5040 +
5041  static int
5042  hw_breakpoint_used_count (void)
5043  {
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;
5048 -  int found;
5049    int i;
5050  
5051    /* If we have explicit pc, don't expand.
5052 @@ -5264,14 +5557,42 @@ expand_line_sal_maybe (struct symtab_and_line sal)
5053  
5054    if (original_pc)
5055      {
5056 -      found = 0;
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.
5062 +
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.
5067 +
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.
5074 +
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.  */
5079 +
5080 +      CORE_ADDR best = -1;
5081 +
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)
5085 -         {
5086 -           found = 1;
5087 -           break;
5088 -         }
5089 -      gdb_assert (found);
5090 +       if (expanded.sals[i].pc <= original_pc
5091 +           && (best == -1 || expanded.sals[best].pc < expanded.sals[i].pc))
5092 +         best = i;
5093 +
5094 +      if (best == -1)
5095 +       error (_("Cannot find the best address for %s out of the %d locations"),
5096 +              paddr (original_pc), expanded.nelts);
5097 +
5098 +      expanded.sals[best].pc = original_pc;
5099      }
5100  
5101    return expanded;
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);
5105      }
5106 -
5107 -  update_global_location_list (1);
5108  }
5109  
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,
5112        b->ops = ops;
5113        b->enable_state = enabled ? bp_enabled : bp_disabled;
5114  
5115 -      update_global_location_list (1);
5116        mention (b);
5117      }
5118    
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);
5123 +
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);
5128  }
5129  
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))
5134                 {
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));
5138  
5139                   if (!TARGET_REGION_OK_FOR_HW_WATCHPOINT (vaddr, len))
5140 @@ -6668,6 +6991,122 @@ catch_ada_exception_command (char *arg, int from_tty,
5141                                     from_tty);
5142  }
5143  
5144 +/* Cleanup function for a syscall filter list.  */
5145 +static void
5146 +clean_up_filters (void *arg)
5147 +{
5148 +  struct syscall_filter *iter = *(struct syscall_filter **) arg;
5149 +  while (iter)
5150 +    {
5151 +      struct syscall_filter *next = iter->next;
5152 +      xfree (iter);
5153 +      iter = next;
5154 +    }
5155 +}
5156 +
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)
5161 +{
5162 +  struct syscall_filter *result = NULL;
5163 +  struct cleanup *cleanup = make_cleanup (clean_up_filters, &result);
5164 +
5165 +  while (*arg != '\0')
5166 +    {
5167 +      int i, syscall_number;
5168 +      char *endptr;
5169 +      char cur_name[128];
5170 +      struct syscall_filter *new_filter;
5171 +      struct syscall s;
5172 +
5173 +      /* Skip whitespace.  */
5174 +      while (isspace (*arg))
5175 +        arg++;
5176 +
5177 +      for (i = 0; arg[i] && !isspace (arg[i]); ++i)
5178 +       cur_name[i] = arg[i];
5179 +      cur_name[i] = '\0';
5180 +      arg += i;
5181 +
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')
5185 +        {
5186 +          gdbarch_get_syscall_by_number (current_gdbarch,
5187 +                                         syscall_number, &s);
5188 +
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
5193 +               number.  */
5194 +            warning (_("The number '%d' does not represent a known syscall."),
5195 +                     syscall_number);
5196 +        }
5197 +      else
5198 +        {
5199 +          /* We have a name.  Let's check if it's valid and convert it
5200 +             to a number.  */
5201 +          gdbarch_get_syscall_by_name (current_gdbarch, cur_name, &s);
5202 +
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
5206 +               be caught.  */
5207 +            error (_("Unknown syscall name '%s'."), cur_name);
5208 +        }
5209 +
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;
5215 +    }
5216 +
5217 +  discard_cleanups (cleanup);
5218 +  return result;
5219 +}
5220 +
5221 +/* Implement the "catch syscall" command.  */
5222 +
5223 +static void
5224 +catch_syscall_command_1 (char *arg, int from_tty, struct cmd_list_element *command)
5225 +{
5226 +  int tempflag;
5227 +  struct syscall_filter *filter;
5228 +  struct syscall s;
5229 +
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."));
5234 +
5235 +  tempflag = get_cmd_context (command) == CATCH_TEMPORARY;
5236 +
5237 +  ep_skip_leading_whitespace (&arg);
5238 +
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);
5244 +
5245 +  /* The allowed syntax is:
5246 +     catch syscall
5247 +     catch syscall <name | number> [<name | number> ... <name | number>]
5248 +
5249 +     Let's check if there's a syscall name.  */
5250 +
5251 +  if (arg != NULL)
5252 +    filter = catch_syscall_split_args (arg);
5253 +  else
5254 +    filter = NULL;
5255 +
5256 +  create_syscall_event_catchpoint (tempflag, filter,
5257 +                                  &catch_syscall_breakpoint_ops);
5258 +}
5259 +
5260  /* Implement the "catch assert" command.  */
5261  
5262  static void
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);
5268  
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)
5272    return 0;
5273  }
5274  
5275 +/* Returns 0 if 'bp' is NOT a syscall catchpoint,
5276 +   non-zero otherwise.  */
5277 +static int
5278 +is_syscall_catchpoint_enabled (struct breakpoint *bp)
5279 +{
5280 +  if (syscall_catchpoint_p (bp)
5281 +      && bp->enable_state != bp_disabled
5282 +      && bp->enable_state != bp_call_disabled)
5283 +    return 1;
5284 +  else
5285 +    return 0;
5286 +}
5287 +
5288 +int
5289 +catch_syscall_enabled (void)
5290 +{
5291 +  return total_syscalls_count != 0;
5292 +}
5293 +
5294 +int
5295 +catching_syscall_number (int syscall_number)
5296 +{
5297 +  struct breakpoint *bp;
5298 +
5299 +  ALL_BREAKPOINTS (bp)
5300 +    if (is_syscall_catchpoint_enabled (bp))
5301 +      {
5302 +       if (bp->syscalls_to_be_caught)
5303 +         {
5304 +           struct syscall_filter *iter;
5305 +           for (iter = bp->syscalls_to_be_caught; iter; iter = iter->next)
5306 +             if (syscall_number == iter->syscall)
5307 +               return 1;
5308 +         }
5309 +       else
5310 +         return 1;
5311 +      }
5312 +
5313 +  return 0;
5314 +}
5315 +
5316 +/* Complete syscall names.  Used by "catch syscall".  */
5317 +static char **
5318 +catch_syscall_completer (struct cmd_list_element *self, char *text, char *word)
5319 +{
5320 +  const char **list =
5321 +    gdbarch_get_syscall_names (current_gdbarch);
5322 +  return (list == NULL) ? NULL : complete_on_enum (list, text, word);
5323 +}
5324 +
5325  \f
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)
5336  {
5337 @@ -8082,11 +8574,13 @@ add_catch_command (char *name, char *docstring,
5338                      &catch_cmdlist);
5339    set_cmd_sfunc (command, sfunc);
5340    set_cmd_context (command, user_data_catch);
5341 +  set_cmd_completer (command, completion_function);
5342  
5343    command = add_cmd (name, class_breakpoint, NULL, docstring,
5344                      &tcatch_cmdlist);
5345    set_cmd_sfunc (command, sfunc);
5346    set_cmd_context (command, user_data_tcatch);
5347 +  set_cmd_completer (command, completion_function);
5348  }
5349  
5350  void
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,
5355 +                     NULL,
5356                      CATCH_PERMANENT,
5357                      CATCH_TEMPORARY);
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,
5362 +                     NULL,
5363                      CATCH_PERMANENT,
5364                      CATCH_TEMPORARY);
5365    add_catch_command ("fork", _("Catch calls to fork."),
5366                      catch_fork_command_1,
5367 +                     NULL,
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,
5372 +                     NULL,
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,
5377 +                     NULL,
5378                      CATCH_PERMANENT,
5379                      CATCH_TEMPORARY);
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,
5385 +                         CATCH_PERMANENT,
5386 +                         CATCH_TEMPORARY);
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,
5391 +                     NULL,
5392                      CATCH_PERMANENT,
5393                      CATCH_TEMPORARY);
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,
5398 +                     NULL,
5399                      CATCH_PERMANENT,
5400                      CATCH_TEMPORARY);
5401  
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;
5407  
5408  #define        BREAKPOINT_MAX  16
5409  \f
5410 -/* Type of breakpoint. */
5411 +
5412 +/* Type of breakpoint.  */
5413  /* FIXME In the future, we should fold all other breakpoint-like things into
5414     here.  This includes:
5415  
5416 @@ -337,6 +338,17 @@ enum watchpoint_triggered
5417    watch_triggered_yes  
5418  };
5419  
5420 +/* A syscall filter is represented as a linked list of syscall
5421 +   numbers.  */
5422 +struct syscall_filter
5423 +{
5424 +  /* The system call to accept.  */
5425 +  int syscall;
5426 +
5427 +  /* The next filter.  */
5428 +  struct syscall_filter *next;
5429 +};
5430 +
5431  typedef struct bp_location *bp_location_p;
5432  DEF_VEC_P(bp_location_p);
5433  
5434 @@ -442,6 +454,20 @@ struct breakpoint
5435         triggered.  */
5436      char *exec_pathname;
5437  
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.
5441 +
5442 +       This field is only valid immediately after this catchpoint has
5443 +       triggered.  */
5444 +    int syscall_number;
5445 +
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;
5451 +
5452      /* Methods associated with this breakpoint.  */
5453      struct breakpoint_ops *ops;
5454  
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);
5458  
5459 +extern void clear_syscall_catchpoints_info (void);
5460 +
5461  extern void clear_breakpoint_hit_counts (void);
5462  
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);
5467  
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);
5471 +
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);
5476 +
5477  /* Tell a breakpoint to be quiet.  */
5478  extern void make_breakpoint_silent (struct breakpoint *);
5479  
5480 +/* Set break condition of breakpoint B to EXP.  */
5481 +extern void set_breakpoint_condition (struct breakpoint *b, char *exp, int from_tty);
5482 +
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,
5489        opblock = pblock;
5490      }
5491  
5492 +  block_set_using (block, using_directives, &objfile->objfile_obstack);
5493 +
5494    record_pending_block (objfile, block, opblock);
5495  
5496    return block;
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);
5500  
5501 -  /* Set up support for C++ namespace support, in case we need it.  */
5502 -
5503 -  cp_initialize_namespace ();
5504 -
5505    /* Initialize the list of sub source files with one entry for this
5506       file (the top-level source file).  */
5507  
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,
5510                     objfile);
5511        blockvector = make_blockvector (objfile);
5512 -      cp_finalize_namespace (BLOCKVECTOR_BLOCK (blockvector, STATIC_BLOCK),
5513 -                            &objfile->objfile_obstack);
5514      }
5515  
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;
5522    new->name = NULL;
5523  
5524    local_symbols = NULL;
5525    param_symbols = NULL;
5526 +  using_directives = NULL;
5527  
5528    return new;
5529  }
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;
5535  
5536  EXTERN struct pending *param_symbols;
5537  
5538 +/* using directives local to lexical context */
5539 +
5540 +EXTERN struct using_direct *using_directives;
5541 +
5542  /* Stack representing unclosed lexical contexts (that will become
5543     blocks, eventually).  */
5544  
5545 @@ -138,6 +142,10 @@ struct context_stack
5546  
5547      struct pending *params;
5548  
5549 +    /* Pending using directives at the time we entered */
5550 +
5551 +    struct using_direct *using_directives;
5552 +
5553      /* Pointer into blocklist as of entry */
5554  
5555      struct pending_block *old_blocks;
5556 diff --git a/gdb/c-exp.y b/gdb/c-exp.y
5557 index d4bbbcc..107452a 100644
5558 --- a/gdb/c-exp.y
5559 +++ b/gdb/c-exp.y
5560 @@ -119,6 +119,8 @@ static int yylex (void);
5561  
5562  void yyerror (char *);
5563  
5564 +/* Cleanup for 'nonempty_typelist' */
5565 +static struct cleanup *typelist_cleanup;
5566  %}
5567  
5568  /* Although the yacc "value" of an expression is not used,
5569 @@ -143,6 +145,7 @@ void yyerror (char *);
5570      struct symbol *sym;
5571      struct type *tval;
5572      struct stoken sval;
5573 +    struct typed_stoken tsval;
5574      struct ttype tsym;
5575      struct symtoken ssym;
5576      int voidval;
5577 @@ -150,6 +153,7 @@ void yyerror (char *);
5578      enum exp_opcode opcode;
5579      struct internalvar *ivar;
5580  
5581 +    struct stoken_vector svec;
5582      struct type **tvec;
5583      int *ivec;
5584    }
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.  */
5588  
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
5596 +%type <sval> name
5597 +%type <svec> string_exp
5598  %type <ssym> name_not_typename
5599  %type <tsym> typename
5600  
5601 @@ -399,6 +405,38 @@ arglist    :       arglist ',' exp   %prec ABOVE_COMMA
5602                         { arglist_len++; }
5603         ;
5604  
5605 +exp     :       exp '(' nonempty_typelist ')'
5606 +                       { int i;
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);
5616 +                       }
5617 +       ;
5618 +
5619 +/*
5620 +exp     :       BLOCKNAME '(' nonempty_typelist ')'
5621 +                       { int i;
5622 +                         write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP);
5623 +                         write_exp_elt_sym ($1.sym);
5624 +                         write_exp_elt_opcode (TYPE_INSTANCE_LOOKUP);
5625 +
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);
5633 +                       }
5634 +       ;
5635 +*/
5636 +
5637  rcurly :       '}'
5638                         { $$ = end_arglist () - 1; }
5639         ;
5640 @@ -524,6 +562,15 @@ exp        :       INT
5641                           write_exp_elt_opcode (OP_LONG); }
5642         ;
5643  
5644 +exp    :       CHAR
5645 +                       {
5646 +                         struct stoken_vector vec;
5647 +                         vec.len = 1;
5648 +                         vec.tokens = &$1;
5649 +                         write_exp_string_vector ($1.type, &vec);
5650 +                       }
5651 +       ;
5652 +
5653  exp    :       NAME_OR_INT
5654                         { YYSTYPE val;
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
5659                              lexer.  */
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);
5664 +                         $$.len = 1;
5665 +                         $$.tokens = vec;
5666 +
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);
5671                         }
5672  
5673         |       string_exp STRING
5674                         {
5675                           /* Note that we NUL-terminate here, but just
5676                              for convenience.  */
5677 -                         struct stoken t;
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);
5682 -                         free ($1.ptr);
5683 -                         $$ = t;
5684 +                         char *p;
5685 +                         ++$$.len;
5686 +                         $$.tokens = realloc ($$.tokens,
5687 +                                              $$.len * sizeof (struct typed_stoken));
5688 +
5689 +                         p = malloc ($2.length + 1);
5690 +                         memcpy (p, $2.ptr, $2.length + 1);
5691 +
5692 +                         $$.tokens[$$.len - 1].type = $2.type;
5693 +                         $$.tokens[$$.len - 1].length = $2.length;
5694 +                         $$.tokens[$$.len - 1].ptr = p;
5695                         }
5696                 ;
5697  
5698  exp    :       string_exp
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
5703 -                            string. */
5704 -                         char *sp = $1.ptr; int count = $1.length;
5705 -                         while (count-- > 0)
5706 +                       {
5707 +                         int i;
5708 +                         enum c_string_type type = C_STRING;
5709 +
5710 +                         for (i = 0; i < $1.len; ++i)
5711                             {
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)
5717 +                               {
5718 +                               case C_STRING:
5719 +                                 break;
5720 +                               case C_WIDE_STRING:
5721 +                               case C_STRING_16:
5722 +                               case C_STRING_32:
5723 +                                 if (type != C_STRING
5724 +                                     && type != $1.tokens[i].type)
5725 +                                   error ("Undefined string concatenation.");
5726 +                                 type = $1.tokens[i].type;
5727 +                                 break;
5728 +                               default:
5729 +                                 /* internal error */
5730 +                                 internal_error (__FILE__, __LINE__,
5731 +                                                 "unrecognized type in string concatenation");
5732 +                               }
5733                             }
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);
5742 -                         free ($1.ptr);
5743 +
5744 +                         write_exp_string_vector (type, &$1);
5745 +                         for (i = 0; i < $1.len; ++i)
5746 +                           free ($1.tokens[i].ptr);
5747 +                         free ($1.tokens);
5748                         }
5749         ;
5750  
5751 @@ -713,12 +776,13 @@ qualified_name:   typebase COLONCOLON name
5752         ;
5753  
5754  variable:      qualified_name
5755 +       |       COLONCOLON qualified_name
5756         |       COLONCOLON name
5757                         {
5758                           char *name = copy_name ($2);
5759                           struct symbol *sym;
5760                           struct minimal_symbol *msymbol;
5761 -
5762 +                         
5763                           sym =
5764                             lookup_symbol (name, (const struct block *) NULL,
5765                                            VAR_DOMAIN, (int *) NULL);
5766 @@ -856,7 +920,7 @@ array_mod:  '[' ']'
5767  func_mod:      '(' ')'
5768                         { $$ = 0; }
5769         |       '(' nonempty_typelist ')'
5770 -                       { free ($2); $$ = 0; }
5771 +                       { do_cleanups (typelist_cleanup); $$ = 0; }
5772         ;
5773  
5774  /* We used to try to recognize pointer to member types here, but
5775 @@ -1057,12 +1121,15 @@ typename:       TYPENAME
5776  nonempty_typelist
5777         :       type
5778                 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
5779 +                 typelist_cleanup = make_cleanup (free, $$);
5780                   $<ivec>$[0] = 1;      /* Number of types in vector */
5781                   $$[1] = $1;
5782                 }
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;
5789                 }
5790         ;
5791 @@ -1361,6 +1428,263 @@ parse_number (p, len, parsed_float, putithere)
5792     return INT;
5793  }
5794  
5795 +/* Temporary obstack used for holding strings.  */
5796 +static struct obstack tempbuf;
5797 +static int tempbuf_init;
5798 +
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.  */
5807 +
5808 +int
5809 +c_parse_escape (char **ptr, struct obstack *output)
5810 +{
5811 +  char *tokptr = *ptr;
5812 +  int result = 1;
5813 +
5814 +  /* Some escape sequences undergo character set conversion.  Those we
5815 +     translate here.  */
5816 +  switch (*tokptr)
5817 +    {
5818 +      /* Hex escapes do not undergo character set conversion, so keep
5819 +        the escape sequence for later.  */
5820 +    case 'x':
5821 +      if (output)
5822 +       obstack_grow_str (output, "\\x");
5823 +      ++tokptr;
5824 +      if (!isxdigit (*tokptr))
5825 +       error (_("\\x escape without a following hex digit"));
5826 +      while (isxdigit (*tokptr))
5827 +       {
5828 +         if (output)
5829 +           obstack_1grow (output, *tokptr);
5830 +         ++tokptr;
5831 +       }
5832 +      break;
5833 +
5834 +      /* Octal escapes do not undergo character set conversion, so
5835 +        keep the escape sequence for later.  */
5836 +    case '0':
5837 +    case '1':
5838 +    case '2':
5839 +    case '3':
5840 +    case '4':
5841 +    case '5':
5842 +    case '6':
5843 +    case '7':
5844 +      if (output)
5845 +       obstack_grow_str (output, "\\");
5846 +      while (isdigit (*tokptr) && *tokptr != '8' && *tokptr != '9')
5847 +       {
5848 +         if (output)
5849 +           obstack_1grow (output, *tokptr);
5850 +         ++tokptr;
5851 +       }
5852 +      break;
5853 +
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
5857 +        charset.  */
5858 +    case 'u':
5859 +    case 'U':
5860 +      {
5861 +       char c = *tokptr;
5862 +       int i, len = c == 'U' ? 8 : 4;
5863 +       if (output)
5864 +         {
5865 +           obstack_1grow (output, '\\');
5866 +           obstack_1grow (output, *tokptr);
5867 +         }
5868 +       ++tokptr;
5869 +       if (!isxdigit (*tokptr))
5870 +         error (_("\\%c escape without a following hex digit"), c);
5871 +       for (i = 0; i < len && isxdigit (*tokptr); ++i)
5872 +         {
5873 +           if (output)
5874 +             obstack_1grow (output, *tokptr);
5875 +           ++tokptr;
5876 +         }
5877 +      }
5878 +      break;
5879 +
5880 +      /* We must pass backslash through so that it does not
5881 +        cause quoting during the second expansion.  */
5882 +    case '\\':
5883 +      if (output)
5884 +       obstack_grow_str (output, "\\\\");
5885 +      ++tokptr;
5886 +      break;
5887 +
5888 +      /* Escapes which undergo conversion.  */
5889 +    case 'a':
5890 +      if (output)
5891 +       obstack_1grow (output, '\a');
5892 +      ++tokptr;
5893 +      break;
5894 +    case 'b':
5895 +      if (output)
5896 +       obstack_1grow (output, '\b');
5897 +      ++tokptr;
5898 +      break;
5899 +    case 'f':
5900 +      if (output)
5901 +       obstack_1grow (output, '\f');
5902 +      ++tokptr;
5903 +      break;
5904 +    case 'n':
5905 +      if (output)
5906 +       obstack_1grow (output, '\n');
5907 +      ++tokptr;
5908 +      break;
5909 +    case 'r':
5910 +      if (output)
5911 +       obstack_1grow (output, '\r');
5912 +      ++tokptr;
5913 +      break;
5914 +    case 't':
5915 +      if (output)
5916 +       obstack_1grow (output, '\t');
5917 +      ++tokptr;
5918 +      break;
5919 +    case 'v':
5920 +      if (output)
5921 +       obstack_1grow (output, '\v');
5922 +      ++tokptr;
5923 +      break;
5924 +
5925 +      /* GCC extension.  */
5926 +    case 'e':
5927 +      if (output)
5928 +       obstack_1grow (output, HOST_ESCAPE_CHAR);
5929 +      ++tokptr;
5930 +      break;
5931 +
5932 +      /* Backslash-newline expands to nothing at all.  */
5933 +    case '\n':
5934 +      ++tokptr;
5935 +      result = 0;
5936 +      break;
5937 +
5938 +      /* A few escapes just expand to the character itself.  */
5939 +    case '\'':
5940 +    case '\"':
5941 +    case '?':
5942 +      /* GCC extensions.  */
5943 +    case '(':
5944 +    case '{':
5945 +    case '[':
5946 +    case '%':
5947 +      /* Unrecognized escapes turn into the character itself.  */
5948 +    default:
5949 +      if (output)
5950 +       obstack_1grow (output, *tokptr);
5951 +      ++tokptr;
5952 +      break;
5953 +    }
5954 +  *ptr = tokptr;
5955 +  return result;
5956 +}
5957 +
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.  */
5964 +static int
5965 +parse_string_or_char (char *tokptr, char **outptr, struct typed_stoken *value,
5966 +                     int *host_chars)
5967 +{
5968 +  int quote, i;
5969 +  enum c_string_type type;
5970 +
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
5978 +     bytes */
5979 +
5980 +  if (!tempbuf_init)
5981 +    tempbuf_init = 1;
5982 +  else
5983 +    obstack_free (&tempbuf, NULL);
5984 +  obstack_init (&tempbuf);
5985 +
5986 +  /* Record the string type.  */
5987 +  if (*tokptr == 'L')
5988 +    {
5989 +      type = C_WIDE_STRING;
5990 +      ++tokptr;
5991 +    }
5992 +  else if (*tokptr == 'u')
5993 +    {
5994 +      type = C_STRING_16;
5995 +      ++tokptr;
5996 +    }
5997 +  else if (*tokptr == 'U')
5998 +    {
5999 +      type = C_STRING_32;
6000 +      ++tokptr;
6001 +    }
6002 +  else
6003 +    type = C_STRING;
6004 +
6005 +  /* Skip the quote.  */
6006 +  quote = *tokptr;
6007 +  if (quote == '\'')
6008 +    type |= C_CHAR;
6009 +  ++tokptr;
6010 +
6011 +  *host_chars = 0;
6012 +
6013 +  while (*tokptr)
6014 +    {
6015 +      char c = *tokptr;
6016 +      if (c == '\\')
6017 +       {
6018 +         ++tokptr;
6019 +         *host_chars += c_parse_escape (&tokptr, &tempbuf);
6020 +       }
6021 +      else if (c == quote)
6022 +       break;
6023 +      else
6024 +       {
6025 +         obstack_1grow (&tempbuf, c);
6026 +         ++tokptr;
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.  */
6030 +         ++*host_chars;
6031 +       }
6032 +    }
6033 +
6034 +  if (*tokptr != quote)
6035 +    {
6036 +      if (quote == '"')
6037 +       error ("Unterminated string in expression.");
6038 +      else
6039 +       error ("Unmatched single quote.");
6040 +    }
6041 +  ++tokptr;
6042 +
6043 +  value->type = type;
6044 +  value->ptr = obstack_base (&tempbuf);
6045 +  value->length = obstack_object_size (&tempbuf);
6046 +
6047 +  *outptr = tokptr;
6048 +
6049 +  return quote == '"' ? STRING : CHAR;
6050 +}
6051 +
6052  struct token
6053  {
6054    char *operator;
6055 @@ -1526,23 +1850,33 @@ static int last_was_structop;
6056  static int
6057  yylex ()
6058  {
6059 +  /* name_prefix stores the full qualification of a variable that is
6060 +     specified in the expression. It is used to eleminate confusion 
6061 +     during lookup.*/
6062 +  static char* name_prefix = NULL;
6063 +  static int name_prefix_len = 0;
6064 +  static int terminate_prefix = 0;
6065 +  
6066    int c;
6067    int namelen;
6068    unsigned int i;
6069    char *tokstart;
6070 -  char *tokptr;
6071 -  int tempbufindex;
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;
6077    char *copy;
6078  
6079    last_was_structop = 0;
6080 -
6081 +  
6082   retry:
6083 -
6084 +  
6085 +  if(terminate_prefix ||
6086 +     lexptr != name_prefix + name_prefix_len // Some token was skiped so clear name_prefix
6087 +   ){
6088 +    name_prefix = NULL;
6089 +    name_prefix_len = 0;
6090 +  }
6091 +    
6092 +  terminate_prefix = 1;
6093 +                 
6094    /* Check if this is a macro invocation that we need to expand.  */
6095    if (! scanning_macro_expansion ())
6096      {
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)
6100        {
6101 +       
6102 +       if(tokentab2[i].token == COLONCOLON){
6103 +         name_prefix_len += 2;
6104 +         terminate_prefix = 0;
6105 +         if(name_prefix == NULL){
6106 +           name_prefix = lexptr;
6107 +          }
6108 +       }
6109         lexptr += 2;
6110         yylval.opcode = tokentab2[i].opcode;
6111         if (in_parse_field && tokentab2[i].token == ARROW)
6112           last_was_structop = 1;
6113 +       
6114         return tokentab2[i].token;
6115        }
6116  
6117 @@ -1602,51 +1945,13 @@ yylex ()
6118          return 0;
6119  
6120      case ' ':
6121 +      name_prefix_len++;
6122 +      terminate_prefix = 0;
6123      case '\t':
6124      case '\n':
6125        lexptr++;
6126        goto retry;
6127  
6128 -    case '\'':
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++
6131 -        for example). */
6132 -      lexptr++;
6133 -      c = *lexptr++;
6134 -      if (c == '\\')
6135 -       c = parse_escape (&lexptr);
6136 -      else if (c == '\'')
6137 -       error ("Empty character constant.");
6138 -      else if (! host_char_to_target (c, &c))
6139 -        {
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 ());
6146 -        }
6147 -
6148 -      yylval.typed_val_int.val = c;
6149 -      yylval.typed_val_int.type = parse_type->builtin_char;
6150 -
6151 -      c = *lexptr++;
6152 -      if (c != '\'')
6153 -       {
6154 -         namelen = skip_quoted (tokstart) - tokstart;
6155 -         if (namelen > 2)
6156 -           {
6157 -             lexptr = tokstart + namelen;
6158 -             if (lexptr[-1] != '\'')
6159 -               error ("Unmatched single quote.");
6160 -             namelen -= 2;
6161 -             tokstart++;
6162 -             goto tryname;
6163 -           }
6164 -         error ("Invalid character constant.");
6165 -       }
6166 -      return INT;
6167 -
6168      case '(':
6169        paren_depth++;
6170        lexptr++;
6171 @@ -1764,70 +2069,33 @@ yylex ()
6172        lexptr++;
6173        return c;
6174  
6175 +    case 'L':
6176 +    case 'u':
6177 +    case 'U':
6178 +      if (tokstart[1] != '"' && tokstart[1] != '\'')
6179 +       break;
6180 +      /* Fall through.  */
6181 +    case '\'':
6182      case '"':
6183 -
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 */
6192 -
6193 -      tokptr = ++tokstart;
6194 -      tempbufindex = 0;
6195 -
6196 -      do {
6197 -        char *char_start_pos = tokptr;
6198 -
6199 -       /* Grow the static temp buffer if necessary, including allocating
6200 -          the first one on demand. */
6201 -       if (tempbufindex + 1 >= tempbufsize)
6202 -         {
6203 -           tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
6204 -         }
6205 -       switch (*tokptr)
6206 +      {
6207 +       int host_len;
6208 +       int result = parse_string_or_char (tokstart, &lexptr, &yylval.tsval,
6209 +                                          &host_len);
6210 +       if (result == CHAR)
6211           {
6212 -         case '\0':
6213 -         case '"':
6214 -           /* Do nothing, loop will terminate. */
6215 -           break;
6216 -         case '\\':
6217 -           tokptr++;
6218 -           c = parse_escape (&tokptr);
6219 -           if (c == -1)
6220 +           if (host_len == 0)
6221 +             error ("Empty character constant.");
6222 +           else if (host_len > 2 && c == '\'')
6223               {
6224 -               continue;
6225 +               ++tokstart;
6226 +               namelen = lexptr - tokstart - 1;
6227 +               goto tryname;
6228               }
6229 -           tempbuf[tempbufindex++] = c;
6230 -           break;
6231 -         default:
6232 -           c = *tokptr++;
6233 -            if (! host_char_to_target (c, &c))
6234 -              {
6235 -                int len = tokptr - char_start_pos;
6236 -                char *copy = alloca (len + 1);
6237 -                memcpy (copy, char_start_pos, len);
6238 -                copy[len] = '\0';
6239 -
6240 -                error ("There is no character corresponding to `%s' "
6241 -                       "in the target character set `%s'.",
6242 -                       copy, target_charset ());
6243 -              }
6244 -            tempbuf[tempbufindex++] = c;
6245 -           break;
6246 +           else if (host_len > 1)
6247 +             error ("Invalid character constant.");
6248           }
6249 -      } while ((*tokptr != '"') && (*tokptr != '\0'));
6250 -      if (*tokptr++ != '"')
6251 -       {
6252 -         error ("Unterminated string in expression.");
6253 -       }
6254 -      tempbuf[tempbufindex] = '\0';    /* See note above */
6255 -      yylval.sval.ptr = tempbuf;
6256 -      yylval.sval.length = tempbufindex;
6257 -      lexptr = tokptr;
6258 -      return (STRING);
6259 +       return result;
6260 +      }
6261      }
6262  
6263    if (!(c == '_' || c == '$'
6264 @@ -1836,11 +2104,13 @@ yylex ()
6265      error ("Invalid character '%c' in expression.", c);
6266  
6267    /* It's a name.  See how long it is.  */
6268 +  
6269    namelen = 0;
6270    for (c = tokstart[namelen];
6271         (c == '_' || c == '$' || (c >= '0' && c <= '9')
6272         || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
6273      {
6274 +    
6275        /* Template parameter lists are part of the name.
6276          FIXME: This mishandles `print $a<4&&$a>3'.  */
6277  
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.  */
6281    {
6282 +    char *tmp = copy;
6283      struct symbol *sym;
6284      int is_a_field_of_this = 0;
6285      int hextype;
6286  
6287 -    sym = lookup_symbol (copy, expression_context_block,
6288 +    if(name_prefix != NULL){
6289 +      tmp = savestring (name_prefix, name_prefix_len+namelen);
6290 +    }
6291 +
6292 +    sym = lookup_symbol (tmp, expression_context_block,
6293                          VAR_DOMAIN,
6294                          parse_language->la_language == language_cplus
6295                          ? &is_a_field_of_this : (int *) NULL);
6296 +                        
6297 +    /* keep this name as prefix for the next name */
6298 +    if(sym){
6299 +      if(name_prefix == NULL){
6300 +        name_prefix = tokstart;
6301 +      }
6302 +      name_prefix_len += namelen;
6303 +      terminate_prefix = 0;
6304 +    }
6305 +
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;
6313 +        
6314      return NAME;
6315    }
6316  }
6317 diff --git a/gdb/c-lang.c b/gdb/c-lang.c
6318 index 8b5410f..188755b 100644
6319 --- a/gdb/c-lang.c
6320 +++ b/gdb/c-lang.c
6321 @@ -33,48 +33,304 @@
6322  #include "demangle.h"
6323  #include "cp-abi.h"
6324  #include "cp-support.h"
6325 +#include "gdb_obstack.h"
6326 +#include <ctype.h>
6327 +#include <wchar.h>
6328 +#include <wctype.h>
6329  
6330  extern void _initialize_c_language (void);
6331 -static void c_emit_char (int c, struct ui_file * stream, int quoter);
6332 +
6333 +/* Given a C string type, STR_TYPE, return the corresponding target
6334 +   character set name.  */
6335 +
6336 +static const char *
6337 +charset_for_string_type (enum c_string_type str_type)
6338 +{
6339 +  switch (str_type & ~C_CHAR)
6340 +    {
6341 +    case C_STRING:
6342 +      return target_charset ();
6343 +    case C_WIDE_STRING:
6344 +      return target_wide_charset ();
6345 +    case C_STRING_16:
6346 +      /* FIXME: UCS-2 is not always correct.  */
6347 +      if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
6348 +       return "UCS-2BE";
6349 +      else
6350 +       return "UCS-2LE";
6351 +    case C_STRING_32:
6352 +      /* FIXME: UCS-4 is not always correct.  */
6353 +      if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
6354 +       return "UCS-4BE";
6355 +      else
6356 +       return "UCS-4LE";
6357 +    }
6358 +  internal_error (__FILE__, __LINE__, "unhandled c_string_type");
6359 +}
6360 +
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.  */
6365 +
6366 +static enum c_string_type
6367 +classify_type (struct type *elttype, const char **encoding)
6368 +{
6369 +  struct type *saved_type;
6370 +  enum c_string_type result;
6371 +
6372 +  /* We do one or two passes -- one on ELTTYPE, and then maybe a
6373 +     second one on a typedef target.  */
6374 +  do
6375 +    {
6376 +      char *name = TYPE_NAME (elttype);
6377 +
6378 +      if (TYPE_CODE (elttype) == TYPE_CODE_CHAR || !name)
6379 +       {
6380 +         result = C_CHAR;
6381 +         goto done;
6382 +       }
6383 +
6384 +      if (!strcmp (name, "wchar_t"))
6385 +       {
6386 +         result = C_WIDE_CHAR;
6387 +         goto done;
6388 +       }
6389 +
6390 +      if (!strcmp (name, "char16_t"))
6391 +       {
6392 +         result = C_CHAR_16;
6393 +         goto done;
6394 +       }
6395 +
6396 +      if (!strcmp (name, "char32_t"))
6397 +       {
6398 +         result = C_CHAR_32;
6399 +         goto done;
6400 +       }
6401 +
6402 +      saved_type = elttype;
6403 +      CHECK_TYPEDEF (elttype);
6404 +    }
6405 +  while (elttype != saved_type);
6406 +
6407 +  /* Punt.  */
6408 +  result = C_CHAR;
6409 +
6410 + done:
6411 +  *encoding = charset_for_string_type (result);
6412 +  return result;
6413 +}
6414 +
6415 +/* Return true if print_wchar can display W without resorting to a
6416 +   numeric escape, false otherwise.  */
6417 +
6418 +static int
6419 +wchar_printable (wchar_t w)
6420 +{
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');
6424 +}
6425 +
6426 +/* A helper function that converts the contents of STRING to wide
6427 +   characters and then appends them to OUTPUT.  */
6428 +
6429 +static void
6430 +append_string_as_wide (const char *string, struct obstack *output)
6431 +{
6432 +  for (; *string; ++string)
6433 +    {
6434 +      wchar_t w = btowc (*string);
6435 +      obstack_grow (output, &w, sizeof (wchar_t));
6436 +    }
6437 +}
6438 +
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.  */
6447 +
6448 +static void
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)
6452 +{
6453 +  int need_escape = *need_escapep;
6454 +  *need_escapep = 0;
6455 +  if (iswprint (w) && (!need_escape || (!iswdigit (w)
6456 +                                       && w != L'8'
6457 +                                       && w != L'9')))
6458 +    {
6459 +      if (w == btowc (quoter) || w == L'\\')
6460 +       obstack_grow_wstr (output, L"\\");
6461 +      obstack_grow (output, &w, sizeof (wchar_t));
6462 +    }
6463 +  else
6464 +    {
6465 +      switch (w)
6466 +       {
6467 +       case L'\a':
6468 +         obstack_grow_wstr (output, L"\\a");
6469 +         break;
6470 +       case L'\b':
6471 +         obstack_grow_wstr (output, L"\\b");
6472 +         break;
6473 +       case L'\f':
6474 +         obstack_grow_wstr (output, L"\\f");
6475 +         break;
6476 +       case L'\n':
6477 +         obstack_grow_wstr (output, L"\\n");
6478 +         break;
6479 +       case L'\r':
6480 +         obstack_grow_wstr (output, L"\\r");
6481 +         break;
6482 +       case L'\t':
6483 +         obstack_grow_wstr (output, L"\\t");
6484 +         break;
6485 +       case L'\v':
6486 +         obstack_grow_wstr (output, L"\\v");
6487 +         break;
6488 +       default:
6489 +         {
6490 +           int i;
6491 +
6492 +           for (i = 0; i + width <= orig_len; i += width)
6493 +             {
6494 +               char octal[30];
6495 +               ULONGEST value = extract_unsigned_integer (&orig[i], width);
6496 +               sprintf (octal, "\\%lo", (long) value);
6497 +               append_string_as_wide (octal, output);
6498 +             }
6499 +           /* If we somehow have extra bytes, print them now.  */
6500 +           while (i < orig_len)
6501 +             {
6502 +               char octal[5];
6503 +               sprintf (octal, "\\%.3o", orig[i] & 0xff);
6504 +               append_string_as_wide (octal, output);
6505 +               ++i;
6506 +             }
6507 +
6508 +           *need_escapep = 1;
6509 +         }
6510 +         break;
6511 +       }
6512 +    }
6513 +}
6514  
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. */
6518  
6519  static void
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)
6522  {
6523 -  const char *escape;
6524 -  int host_char;
6525 +  struct obstack wchar_buf, output;
6526 +  struct cleanup *cleanups;
6527 +  const char *encoding;
6528 +  gdb_byte *buf;
6529 +  struct wchar_iterator *iter;
6530 +  int need_escape = 0;
6531  
6532 -  c &= 0xFF;                   /* Avoid sign bit follies */
6533 +  classify_type (type, &encoding);
6534  
6535 -  escape = c_target_char_has_backslash_escape (c);
6536 -  if (escape)
6537 -    {
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");
6542 -      else
6543 -       fprintf_filtered (stream, "\\%s", escape);
6544 -    }
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);
6549 +
6550 +  iter = make_wchar_iterator (buf, TYPE_LENGTH (type), encoding,
6551 +                             TYPE_LENGTH (type));
6552 +  cleanups = make_cleanup_wchar_iterator (iter);
6553 +
6554 +  /* This holds the printable form of the wchar_t data.  */
6555 +  obstack_init (&wchar_buf);
6556 +  make_cleanup_obstack_free (&wchar_buf);
6557 +
6558 +  while (1)
6559      {
6560 -      if (host_char == '\\' || host_char == quoter)
6561 -        fputs_filtered ("\\", stream);
6562 -      fprintf_filtered (stream, "%c", host_char);
6563 +      int num_chars;
6564 +      wchar_t *chars;
6565 +      const gdb_byte *buf;
6566 +      size_t buflen;
6567 +      int print_escape = 1;
6568 +      enum wchar_iterate_result result;
6569 +
6570 +      num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
6571 +      if (num_chars < 0)
6572 +       break;
6573 +      if (num_chars > 0)
6574 +       {
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.  */
6580 +         int i;
6581 +
6582 +         print_escape = 0;
6583 +         for (i = 0; i < num_chars; ++i)
6584 +           if (!wchar_printable (chars[i]))
6585 +             {
6586 +               print_escape = 1;
6587 +               break;
6588 +             }
6589 +
6590 +         if (!print_escape)
6591 +           {
6592 +             for (i = 0; i < num_chars; ++i)
6593 +               print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
6594 +                            &wchar_buf, quoter, &need_escape);
6595 +           }
6596 +       }
6597 +
6598 +      /* This handles the NUM_CHARS == 0 case as well.  */
6599 +      if (print_escape)
6600 +       print_wchar (WEOF, buf, buflen, TYPE_LENGTH (type), &wchar_buf, quoter,
6601 +                    &need_escape);
6602      }
6603 -  else
6604 -    fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
6605 +
6606 +  /* The output in the host encoding.  */
6607 +  obstack_init (&output);
6608 +  make_cleanup_obstack_free (&output);
6609 +
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');
6615 +
6616 +  fputs_filtered (obstack_base (&output), stream);
6617 +
6618 +  do_cleanups (cleanups);
6619  }
6620  
6621  void
6622 -c_printchar (int c, struct ui_file *stream)
6623 +c_printchar (int c, struct type *type, struct ui_file *stream)
6624  {
6625 +  enum c_string_type str_type;
6626 +  const char *encoding;
6627 +
6628 +  str_type = classify_type (type, &encoding);
6629 +  switch (str_type)
6630 +    {
6631 +    case C_CHAR:
6632 +      break;
6633 +    case C_WIDE_CHAR:
6634 +      fputc_filtered ('L', stream);
6635 +      break;
6636 +    case C_CHAR_16:
6637 +      fputc_filtered ('u', stream);
6638 +      break;
6639 +    case C_CHAR_32:
6640 +      fputc_filtered ('U', stream);
6641 +      break;
6642 +    }
6643 +
6644    fputc_filtered ('\'', stream);
6645 -  LA_EMIT_CHAR (c, stream, '\'');
6646 +  LA_EMIT_CHAR (c, type, stream, '\'');
6647    fputc_filtered ('\'', stream);
6648  }
6649  
6650 @@ -85,87 +341,206 @@ c_printchar (int c, struct ui_file *stream)
6651     printing LENGTH characters, or if FORCE_ELLIPSES.  */
6652  
6653  void
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)
6659  {
6660    unsigned int i;
6661    unsigned int things_printed = 0;
6662    int in_quotes = 0;
6663    int need_comma = 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;
6670 +  int finished = 0;
6671 +  int need_escape = 0;
6672  
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
6675       style.  */
6676    if (!force_ellipses
6677        && length > 0
6678 -      && (extract_unsigned_integer (string + (length - 1) * width, width)
6679 -          == '\0'))
6680 +      && (extract_unsigned_integer (string + (length - 1) * width, width) == 0))
6681      length--;
6682  
6683 +  str_type = classify_type (type, &encoding) & ~C_CHAR;
6684 +  switch (str_type)
6685 +    {
6686 +    case C_STRING:
6687 +      break;
6688 +    case C_WIDE_STRING:
6689 +      fputs_filtered ("L", stream);
6690 +      break;
6691 +    case C_STRING_16:
6692 +      fputs_filtered ("u", stream);
6693 +      break;
6694 +    case C_STRING_32:
6695 +      fputs_filtered ("U", stream);
6696 +      break;
6697 +    }
6698 +
6699    if (length == 0)
6700      {
6701        fputs_filtered ("\"\"", stream);
6702        return;
6703      }
6704  
6705 -  for (i = 0; i < length && things_printed < options->print_max; ++i)
6706 +  if (length == -1)
6707 +    {
6708 +      unsigned long current_char = 1;
6709 +      for (i = 0; current_char; ++i)
6710 +       {
6711 +         QUIT;
6712 +         current_char = extract_unsigned_integer (string + i * width, width);
6713 +       }
6714 +      length = i;
6715 +    }
6716 +
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);
6720 +
6721 +  /* WCHAR_BUF is the obstack we use to represent the string in
6722 +     wchar_t form.  */
6723 +  obstack_init (&wchar_buf);
6724 +  make_cleanup_obstack_free (&wchar_buf);
6725 +
6726 +  while (!finished && things_printed < options->print_max)
6727      {
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;
6734 +      int num_chars;
6735 +      enum wchar_iterate_result result;
6736 +      wchar_t *chars;
6737 +      const gdb_byte *buf;
6738 +      size_t buflen;
6739  
6740        QUIT;
6741  
6742        if (need_comma)
6743         {
6744 -         fputs_filtered (", ", stream);
6745 +         obstack_grow_wstr (&wchar_buf, L", ");
6746           need_comma = 0;
6747         }
6748  
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
6754 +        cases.  */
6755 +      while (num_chars == 1)
6756 +       {
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;
6762  
6763 -      rep1 = i + 1;
6764 -      reps = 1;
6765 -      while (rep1 < length
6766 -            && extract_unsigned_integer (string + rep1 * width, width)
6767 -            == current_char)
6768 +         if (need_comma)
6769 +           {
6770 +             obstack_grow_wstr (&wchar_buf, L", ");
6771 +             need_comma = 0;
6772 +           }
6773 +
6774 +         while (num_chars == 1 && current_char == chars[0])
6775 +           {
6776 +             num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen);
6777 +             ++reps;
6778 +           }
6779 +
6780 +         /* Emit CURRENT_CHAR according to the repetition count and
6781 +            options.  */
6782 +         if (reps > options->repeat_count_threshold)
6783 +           {
6784 +             if (in_quotes)
6785 +               {
6786 +                 if (options->inspect_it)
6787 +                   obstack_grow_wstr (&wchar_buf, L"\\\", ");
6788 +                 else
6789 +                   obstack_grow_wstr (&wchar_buf, L"\", ");
6790 +                 in_quotes = 0;
6791 +               }
6792 +             obstack_grow_wstr (&wchar_buf, L"'");
6793 +             need_escape = 0;
6794 +             print_wchar (current_char, orig_buf, orig_len, width,
6795 +                          &wchar_buf, '\'', &need_escape);
6796 +             obstack_grow_wstr (&wchar_buf, L"'");
6797 +             {
6798 +               /* Painful gyrations.  */
6799 +               int j;
6800 +               char *s = xstrprintf (_(" <repeats %u times>"), reps);
6801 +               for (j = 0; s[j]; ++j)
6802 +                 {
6803 +                   wchar_t w = btowc (s[j]);
6804 +                   obstack_grow (&wchar_buf, &w, sizeof (wchar_t));
6805 +                 }
6806 +               xfree (s);
6807 +             }
6808 +             things_printed += options->repeat_count_threshold;
6809 +             need_comma = 1;
6810 +           }
6811 +         else
6812 +           {
6813 +             /* Saw the character one or more times, but fewer than
6814 +                the repetition threshold.  */
6815 +             if (!in_quotes)
6816 +               {
6817 +                 if (options->inspect_it)
6818 +                   obstack_grow_wstr (&wchar_buf, L"\\\"");
6819 +                 else
6820 +                   obstack_grow_wstr (&wchar_buf, L"\"");
6821 +                 in_quotes = 1;
6822 +                 need_escape = 0;
6823 +               }
6824 +
6825 +             while (reps-- > 0)
6826 +               {
6827 +                 print_wchar (current_char, orig_buf, orig_len, width,
6828 +                              &wchar_buf, '"', &need_escape);
6829 +                 ++things_printed;
6830 +               }
6831 +           }
6832 +       }
6833 +
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)
6837         {
6838 -         ++rep1;
6839 -         ++reps;
6840 +         /* Hit EOF.  */
6841 +         finished = 1;
6842 +         break;
6843         }
6844  
6845 -      if (reps > options->repeat_count_threshold)
6846 +      switch (result)
6847         {
6848 -         if (in_quotes)
6849 +       case wchar_iterate_invalid:
6850 +         if (!in_quotes)
6851             {
6852               if (options->inspect_it)
6853 -               fputs_filtered ("\\\", ", stream);
6854 +               obstack_grow_wstr (&wchar_buf, L"\\\"");
6855               else
6856 -               fputs_filtered ("\", ", stream);
6857 -             in_quotes = 0;
6858 +               obstack_grow_wstr (&wchar_buf, L"\"");
6859 +             in_quotes = 1;
6860             }
6861 -         LA_PRINT_CHAR (current_char, stream);
6862 -         fprintf_filtered (stream, _(" <repeats %u times>"), reps);
6863 -         i = rep1 - 1;
6864 -         things_printed += options->repeat_count_threshold;
6865 -         need_comma = 1;
6866 -       }
6867 -      else
6868 -       {
6869 -         if (!in_quotes)
6870 +         need_escape = 0;
6871 +         print_wchar (WEOF, buf, buflen, width, &wchar_buf, '"', &need_escape);
6872 +         break;
6873 +
6874 +       case wchar_iterate_incomplete:
6875 +         if (in_quotes)
6876             {
6877               if (options->inspect_it)
6878 -               fputs_filtered ("\\\"", stream);
6879 +               obstack_grow_wstr (&wchar_buf, L"\\\",");
6880               else
6881 -               fputs_filtered ("\"", stream);
6882 -             in_quotes = 1;
6883 +               obstack_grow_wstr (&wchar_buf, L"\",");
6884 +             in_quotes = 0;
6885             }
6886 -         LA_EMIT_CHAR (current_char, stream, '"');
6887 -         ++things_printed;
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">");
6891 +         finished = 1;
6892 +         break;
6893         }
6894      }
6895  
6896 @@ -173,13 +548,27 @@ c_printstr (struct ui_file *stream, const gdb_byte *string,
6897    if (in_quotes)
6898      {
6899        if (options->inspect_it)
6900 -       fputs_filtered ("\\\"", stream);
6901 +       obstack_grow_wstr (&wchar_buf, L"\\\"");
6902        else
6903 -       fputs_filtered ("\"", stream);
6904 +       obstack_grow_wstr (&wchar_buf, L"\"");
6905      }
6906  
6907 -  if (force_ellipses || i < length)
6908 -    fputs_filtered ("...", stream);
6909 +  if (force_ellipses || !finished)
6910 +    obstack_grow_wstr (&wchar_buf, L"...");
6911 +
6912 +  /* OUTPUT is where we collect `char's for printing.  */
6913 +  obstack_init (&output);
6914 +  make_cleanup_obstack_free (&output);
6915 +
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');
6921 +
6922 +  fputs_filtered (obstack_base (&output), stream);
6923 +
6924 +  do_cleanups (cleanup);
6925  }
6926  
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,
6929  }
6930  
6931  \f
6932 -/* Preprocessing and parsing C and C++ expressions.  */
6933 +/* Evaluating C and C++ expressions.  */
6934 +
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.  */
6940 +
6941 +static char *
6942 +convert_ucn (char *p, char *limit, const char *dest_charset,
6943 +            struct obstack *output, int length)
6944 +{
6945 +  unsigned long result = 0;
6946 +  gdb_byte data[4];
6947 +  int i;
6948 +
6949 +  for (i = 0; i < length && p < limit && isxdigit (*p); ++i, ++p)
6950 +    result = (result << 4) + host_hex_value (*p);
6951 +
6952 +  for (i = 3; i >= 0; --i)
6953 +    {
6954 +      data[i] = result & 0xff;
6955 +      result >>= 8;
6956 +    }
6957 +
6958 +  convert_between_encodings ("UCS-4BE", dest_charset, data, 4, 4, output,
6959 +                            translit_none);
6960 +
6961 +  return p;
6962 +}
6963 +
6964 +/* Emit a character, VALUE, which was specified numerically, to
6965 +   OUTPUT.  TYPE is the target character type.  */
6966 +
6967 +static void
6968 +emit_numeric_character (struct type *type, unsigned long value,
6969 +                       struct obstack *output)
6970 +{
6971 +  gdb_byte *buffer;
6972 +
6973 +  buffer = alloca (TYPE_LENGTH (type));
6974 +  pack_long (buffer, type, value);
6975 +  obstack_grow (output, buffer, TYPE_LENGTH (type));
6976 +}
6977 +
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.  */
6982 +
6983 +static char *
6984 +convert_octal (struct type *type, char *p, char *limit, struct obstack *output)
6985 +{
6986 +  unsigned long value = 0;
6987 +
6988 +  while (p < limit && isdigit (*p) && *p != '8' && *p != '9')
6989 +    {
6990 +      value = 8 * value + host_hex_value (*p);
6991 +      ++p;
6992 +    }
6993 +
6994 +  emit_numeric_character (type, value, output);
6995 +
6996 +  return p;
6997 +}
6998 +
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.  */
7003 +
7004 +static char *
7005 +convert_hex (struct type *type, char *p, char *limit, struct obstack *output)
7006 +{
7007 +  unsigned long value = 0;
7008 +
7009 +  while (p < limit && isxdigit (*p))
7010 +    {
7011 +      value = 16 * value + host_hex_value (*p);
7012 +      ++p;
7013 +    }
7014 +
7015 +  emit_numeric_character (type, value, output);
7016 +
7017 +  return p;
7018 +}
7019 +
7020 +#define ADVANCE                                        \
7021 +  do {                                         \
7022 +    ++p;                                       \
7023 +    if (p == limit)                            \
7024 +      error (_("Malformed escape sequence"));  \
7025 +  } while (0)
7026 +
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.  */
7033 +
7034 +static char *
7035 +convert_escape (struct type *type, const char *dest_charset,
7036 +               char *p, char *limit, struct obstack *output)
7037 +{
7038 +  /* Skip the backslash.  */
7039 +  ADVANCE;
7040 +
7041 +  switch (*p)
7042 +    {
7043 +    case '\\':
7044 +      obstack_1grow (output, '\\');
7045 +      ++p;
7046 +      break;
7047 +
7048 +    case 'x':
7049 +      ADVANCE;
7050 +      if (!isxdigit (*p))
7051 +       error (_("\\x used with no following hex digits."));
7052 +      p = convert_hex (type, p, limit, output);
7053 +      break;
7054 +
7055 +    case '0':
7056 +    case '1':
7057 +    case '2':
7058 +    case '3':
7059 +    case '4':
7060 +    case '5':
7061 +    case '6':
7062 +    case '7':
7063 +      p = convert_octal (type, p, limit, output);
7064 +      break;
7065 +
7066 +    case 'u':
7067 +    case 'U':
7068 +      {
7069 +       int length = *p == 'u' ? 4 : 8;
7070 +       ADVANCE;
7071 +       if (!isxdigit (*p))
7072 +         error (_("\\u used with no following hex digits"));
7073 +       p = convert_ucn (p, limit, dest_charset, output, length);
7074 +      }
7075 +    }
7076 +
7077 +  return p;
7078 +}
7079 +
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.  */
7085 +
7086 +static void
7087 +parse_one_string (struct obstack *output, char *data, int len,
7088 +                 const char *dest_charset, struct type *type)
7089 +{
7090 +  char *limit;
7091 +
7092 +  limit = data + len;
7093 +
7094 +  while (data < limit)
7095 +    {
7096 +      char *p = data;
7097 +      /* Look for next escape, or the end of the input.  */
7098 +      while (p < limit && *p != '\\')
7099 +       ++p;
7100 +      /* If we saw a run of characters, convert them all.  */
7101 +      if (p > data)
7102 +       convert_between_encodings (host_charset (), dest_charset,
7103 +                                  data, p - data, 1, output, translit_none);
7104 +      /* If we saw an escape, convert it.  */
7105 +      if (p < limit)
7106 +       p = convert_escape (type, dest_charset, p, limit, output);
7107 +      data = p;
7108 +    }
7109 +}
7110 +
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.  */
7114 +
7115 +static struct value *
7116 +evaluate_subexp_c (struct type *expect_type, struct expression *exp,
7117 +                  int *pos, enum noside noside)
7118 +{
7119 +  enum exp_opcode op = exp->elts[*pos].opcode;
7120 +
7121 +  switch (op)
7122 +    {
7123 +    case OP_STRING:
7124 +      {
7125 +       int oplen, limit;
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;
7132 +
7133 +       obstack_init (&output);
7134 +       cleanup = make_cleanup_obstack_free (&output);
7135 +
7136 +       ++*pos;
7137 +       oplen = longest_to_int (exp->elts[*pos].longconst);
7138 +
7139 +       ++*pos;
7140 +       limit = *pos + BYTES_TO_EXP_ELEM (oplen + 1);
7141 +       dest_type
7142 +         = (enum c_string_type) longest_to_int (exp->elts[*pos].longconst);
7143 +       switch (dest_type & ~C_CHAR)
7144 +         {
7145 +         case C_STRING:
7146 +           type = language_string_char_type (current_language,
7147 +                                             current_gdbarch);
7148 +           break;
7149 +         case C_WIDE_STRING:
7150 +           type = lookup_typename ("wchar_t", NULL, 0);
7151 +           break;
7152 +         case C_STRING_16:
7153 +           type = lookup_typename ("char16_t", NULL, 0);
7154 +           break;
7155 +         case C_STRING_32:
7156 +           type = lookup_typename ("char32_t", NULL, 0);
7157 +           break;
7158 +         default:
7159 +           internal_error (__FILE__, __LINE__, "unhandled c_string_type");
7160 +         }
7161 +       dest_charset = charset_for_string_type (dest_type);
7162 +
7163 +       ++*pos;
7164 +       while (*pos < limit)
7165 +         {
7166 +           int len;
7167 +
7168 +           len = longest_to_int (exp->elts[*pos].longconst);
7169 +
7170 +           ++*pos;
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);
7175 +         }
7176 +
7177 +       /* Skip the trailing length and opcode.  */
7178 +       *pos += 2;
7179 +
7180 +       if (noside == EVAL_SKIP)
7181 +         return NULL;
7182 +
7183 +       if ((dest_type & C_CHAR) != 0)
7184 +         {
7185 +           LONGEST value;
7186 +
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);
7191 +         }
7192 +       else
7193 +         {
7194 +           int i;
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),
7200 +                                        type);
7201 +         }
7202 +       do_cleanups (cleanup);
7203 +       return result;
7204 +      }
7205 +      break;
7206 +
7207 +    default:
7208 +      break;
7209 +    }
7210 +  return evaluate_subexp_standard (expect_type, exp, pos, noside);
7211 +}
7212  
7213  
7214  \f
7215 @@ -396,6 +1063,15 @@ c_language_arch_info (struct gdbarch *gdbarch,
7216    lai->bool_type_default = builtin->builtin_int;
7217  }
7218  
7219 +static const struct exp_descriptor exp_descriptor_c = 
7220 +{
7221 +  print_subexp_standard,
7222 +  operator_length_standard,
7223 +  op_name_standard,
7224 +  dump_subexp_body_standard,
7225 +  evaluate_subexp_c
7226 +};
7227 +
7228  const struct language_defn c_language_defn =
7229  {
7230    "c",                         /* Language name */
7231 @@ -405,7 +1081,7 @@ const struct language_defn c_language_defn =
7232    case_sensitive_on,
7233    array_row_major,
7234    macro_expansion_c,
7235 -  &exp_descriptor_standard,
7236 +  &exp_descriptor_c,
7237    c_parse,
7238    c_error,
7239    null_post_parser,
7240 @@ -524,7 +1200,7 @@ const struct language_defn cplus_language_defn =
7241    case_sensitive_on,
7242    array_row_major,
7243    macro_expansion_c,
7244 -  &exp_descriptor_standard,
7245 +  &exp_descriptor_c,
7246    c_parse,
7247    c_error,
7248    null_post_parser,
7249 @@ -562,7 +1238,7 @@ const struct language_defn asm_language_defn =
7250    case_sensitive_on,
7251    array_row_major,
7252    macro_expansion_c,
7253 -  &exp_descriptor_standard,
7254 +  &exp_descriptor_c,
7255    c_parse,
7256    c_error,
7257    null_post_parser,
7258 @@ -605,7 +1281,7 @@ const struct language_defn minimal_language_defn =
7259    case_sensitive_on,
7260    array_row_major,
7261    macro_expansion_c,
7262 -  &exp_descriptor_standard,
7263 +  &exp_descriptor_c,
7264    c_parse,
7265    c_error,
7266    null_post_parser,
7267 diff --git a/gdb/c-lang.h b/gdb/c-lang.h
7268 index 06c5767..ba9d996 100644
7269 --- a/gdb/c-lang.h
7270 +++ b/gdb/c-lang.h
7271 @@ -29,9 +29,38 @@ struct language_arch_info;
7272  #include "macroexp.h"
7273  
7274  
7275 -extern int c_parse (void);     /* Defined in c-exp.y */
7276 -
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
7280 +   ways.  */
7281 +enum c_string_type
7282 +  {
7283 +    /* An ordinary string: "value".  */
7284 +    C_STRING = 0,
7285 +    /* A wide string: L"value".  */
7286 +    C_WIDE_STRING = 1,
7287 +    /* A 16-bit Unicode string: u"value".  */
7288 +    C_STRING_16 = 2,
7289 +    /* A 32-bit Unicode string: U"value".  */
7290 +    C_STRING_32 = 3,
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
7293 +       value.  */
7294 +    C_CHAR = 4,
7295 +    /* A wide char: L'v'.  */
7296 +    C_WIDE_CHAR = 5,
7297 +    /* A 16-bit Unicode char: u'v'.  */
7298 +    C_CHAR_16 = 6,
7299 +    /* A 32-bit Unicode char: U'v'.  */
7300 +    C_CHAR_32 = 7
7301 +  };
7302 +
7303 +/* Defined in c-exp.y.  */
7304 +
7305 +extern int c_parse (void);
7306 +
7307 +extern void c_error (char *);
7308 +
7309 +extern int c_parse_escape (char **, struct obstack *);
7310  
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 *,
7314  
7315  /* These are in c-lang.c: */
7316  
7317 -extern void c_printchar (int, struct ui_file *);
7318 +extern void c_printchar (int, struct type *, struct ui_file *);
7319  
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,
7324                         int force_ellipses,
7325                         const struct value_print_options *options);
7326  
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);
7334  
7335 -static void c_type_print_args (struct type *, struct ui_file *);
7336 -
7337  static void cp_type_print_derivation_info (struct ui_file *, struct type *);
7338  
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");
7342  
7343    fprintf_filtered (stream, ")");
7344 +
7345 +  /* For non-static methods, read qualifiers from the type of
7346 +     THIS.  */
7347 +  if (!staticp)
7348 +    {
7349 +      struct type *domain;
7350 +
7351 +      gdb_assert (nargs > 0);
7352 +      gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR);
7353 +      domain = TYPE_TARGET_TYPE (args[0].type);
7354 +
7355 +      if (TYPE_CONST (domain))
7356 +       fprintf_filtered (stream, " const");
7357 +
7358 +      if (TYPE_VOLATILE (domain))
7359 +       fprintf_filtered (stream, " volatile");
7360 +    }
7361  }
7362  
7363  
7364 @@ -354,10 +369,12 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
7365  
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
7370 +   non-zero.  */
7371  
7372 -static void
7373 -c_type_print_args (struct type *type, struct ui_file *stream)
7374 +void
7375 +c_type_print_args (struct type *type, struct ui_file *stream,
7376 +                  int show_artificial)
7377  {
7378    int i, len;
7379    struct field *args;
7380 @@ -369,6 +386,9 @@ c_type_print_args (struct type *type, struct ui_file *stream)
7381  
7382    for (i = 0; i < TYPE_NFIELDS (type); i++)
7383      {
7384 +      if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
7385 +       continue;
7386 +
7387        if (printed_any)
7388         {
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, ")");
7392  
7393        fprintf_filtered (stream, "[");
7394 -      if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
7395 +      if (TYPE_ARRAY_BOUND_IS_DWARF_BLOCK (type, 1))
7396 +       {
7397 +         /* No _() - printed sources should not be locale dependent.  */
7398 +         fprintf_filtered (stream, "variable");
7399 +       }
7400 +      else if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
7401         && !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
7402         fprintf_filtered (stream, "%d",
7403                           (TYPE_LENGTH (type)
7404 @@ -592,7 +617,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
7405        if (passed_a_ptr)
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,
7411                                    passed_a_ptr, 0);
7412        break;
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,
7418  }
7419  
7420  
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.  */
7424 +
7425 +static int
7426 +textual_name (const char *name)
7427 +{
7428 +  return (!strcmp (name, "wchar_t")
7429 +         || !strcmp (name, "char16_t")
7430 +         || !strcmp (name, "char32_t"));
7431 +}
7432 +
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)
7439      return 1;
7440 +  /* Any other character-like types must be integral.  */
7441 +  if (TYPE_CODE (true_type) != TYPE_CODE_INT)
7442 +    return 0;
7443 +
7444 +  /* Check the names of the type and the typedef.  */
7445 +  if (TYPE_NAME (type) && textual_name (TYPE_NAME (type)))
7446 +    return 1;
7447 +  if (TYPE_NAME (true_type) && textual_name (TYPE_NAME (true_type)))
7448 +    return 1;
7449  
7450    if (format == 's')
7451      {
7452 @@ -115,7 +136,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7453  {
7454    unsigned int i = 0;  /* Number of characters printed */
7455    unsigned len;
7456 -  struct type *elttype;
7457 +  struct type *elttype, *unresolved_elttype;
7458 +  struct type *unresolved_type = type;
7459    unsigned eltlen;
7460    LONGEST val;
7461    CORE_ADDR addr;
7462 @@ -124,8 +146,9 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7463    switch (TYPE_CODE (type))
7464      {
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)
7471         {
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,
7475             }
7476  
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))
7480             {
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,
7484                 {
7485                   unsigned int temp_len;
7486  
7487 -                 /* Look for a NULL char. */
7488                   for (temp_len = 0;
7489 -                      (valaddr + embedded_offset)[temp_len]
7490 -                      && temp_len < len && temp_len < options->print_max;
7491 -                      temp_len++);
7492 +                      (temp_len < len
7493 +                       && temp_len < options->print_max
7494 +                       && extract_unsigned_integer (valaddr + embedded_offset
7495 +                                                    + temp_len * eltlen,
7496 +                                                    eltlen) == 0);
7497 +                      ++temp_len)
7498 +                   ;
7499                   len = temp_len;
7500                 }
7501  
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);
7505               i = len;
7506             }
7507           else
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);
7510           break;
7511         }
7512 -      elttype = check_typedef (TYPE_TARGET_TYPE (type));
7513 +      unresolved_elttype = TYPE_TARGET_TYPE (type);
7514 +      elttype = check_typedef (unresolved_elttype);
7515         {
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,
7519  
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... */
7523  
7524 -         if (textual_element_type (elttype, options->format)
7525 +         if (textual_element_type (unresolved_elttype, options->format)
7526               && addr != 0)
7527             {
7528 -             i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
7529 +             i = val_print_string (unresolved_elttype, addr, -1, stream,
7530                                     options);
7531             }
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,
7534                     }
7535                   else
7536                     {
7537 -                     wtype = TYPE_TARGET_TYPE (type);
7538 +                     wtype = unresolved_elttype;
7539                     }
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))
7548             {
7549               fputs_filtered (" ", stream);
7550               LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
7551 -                            stream);
7552 +                            unresolved_type, stream);
7553             }
7554         }
7555        break;
7556 @@ -468,7 +495,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
7557           else
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);
7562         }
7563        break;
7564  
7565 @@ -540,7 +567,7 @@ int
7566  c_value_print (struct value *val, struct ui_file *stream, 
7567                const struct value_print_options *options)
7568  {
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;
7573  
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.  */
7577  
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);
7584  
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)))))
7602         {
7603           /* Print nothing */
7604         }
7605 @@ -608,6 +640,7 @@ c_value_print (struct value *val, struct ui_file *stream,
7606              }
7607            type_print (type, "", stream, -1);
7608           fprintf_filtered (stream, ") ");
7609 +         val_type = type;
7610         }
7611        else
7612         {
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);
7629         }
7630        /* Otherwise, we end up at the return outside this "if" */
7631      }
7632  
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);
7639  }
7640 diff --git a/gdb/charset-list.h b/gdb/charset-list.h
7641 new file mode 100644
7642 index 0000000..59c64c5
7643 --- /dev/null
7644 +++ b/gdb/charset-list.h
7645 @@ -0,0 +1,1190 @@
7646 +/* List of character set names for GDB.
7647 +
7648 +   Copyright (C) 2009 Free Software Foundation, Inc.
7649 +
7650 +   This file is part of GDB.
7651 +
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.
7656 +
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.
7661 +
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/>.  */
7664 +
7665 +/* Note that the first entry must always be "auto".
7666 +   The remaining entries were created by running this script:
7667 +   
7668 +   iconv -l | sed -e '/[/]...*$/d' -e 's@^\(.*\)//$@"\1", \\@'
7669 +   
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
7672 +   to do that.  */
7673 +#define DEFAULT_CHARSET_NAMES \
7674 +"auto", \
7675 +"437", \
7676 +"500", \
7677 +"500V1", \
7678 +"850", \
7679 +"851", \
7680 +"852", \
7681 +"855", \
7682 +"856", \
7683 +"857", \
7684 +"860", \
7685 +"861", \
7686 +"862", \
7687 +"863", \
7688 +"864", \
7689 +"865", \
7690 +"866", \
7691 +"866NAV", \
7692 +"869", \
7693 +"874", \
7694 +"904", \
7695 +"1026", \
7696 +"1046", \
7697 +"1047", \
7698 +"8859_1", \
7699 +"8859_2", \
7700 +"8859_3", \
7701 +"8859_4", \
7702 +"8859_5", \
7703 +"8859_6", \
7704 +"8859_7", \
7705 +"8859_8", \
7706 +"8859_9", \
7707 +"10646-1:1993", \
7708 +"ANSI_X3.4-1968", \
7709 +"ANSI_X3.4-1986", \
7710 +"ANSI_X3.4", \
7711 +"ANSI_X3.110-1983", \
7712 +"ANSI_X3.110", \
7713 +"ARABIC", \
7714 +"ARABIC7", \
7715 +"ARMSCII-8", \
7716 +"ASCII", \
7717 +"ASMO-708", \
7718 +"ASMO_449", \
7719 +"BALTIC", \
7720 +"BIG-5", \
7721 +"BIG-FIVE", \
7722 +"BIG5-HKSCS", \
7723 +"BIG5", \
7724 +"BIG5HKSCS", \
7725 +"BIGFIVE", \
7726 +"BRF", \
7727 +"BS_4730", \
7728 +"CA", \
7729 +"CN-BIG5", \
7730 +"CN-GB", \
7731 +"CN", \
7732 +"CP-AR", \
7733 +"CP-GR", \
7734 +"CP-HU", \
7735 +"CP037", \
7736 +"CP038", \
7737 +"CP273", \
7738 +"CP274", \
7739 +"CP275", \
7740 +"CP278", \
7741 +"CP280", \
7742 +"CP281", \
7743 +"CP282", \
7744 +"CP284", \
7745 +"CP285", \
7746 +"CP290", \
7747 +"CP297", \
7748 +"CP367", \
7749 +"CP420", \
7750 +"CP423", \
7751 +"CP424", \
7752 +"CP437", \
7753 +"CP500", \
7754 +"CP737", \
7755 +"CP775", \
7756 +"CP803", \
7757 +"CP813", \
7758 +"CP819", \
7759 +"CP850", \
7760 +"CP851", \
7761 +"CP852", \
7762 +"CP855", \
7763 +"CP856", \
7764 +"CP857", \
7765 +"CP860", \
7766 +"CP861", \
7767 +"CP862", \
7768 +"CP863", \
7769 +"CP864", \
7770 +"CP865", \
7771 +"CP866", \
7772 +"CP866NAV", \
7773 +"CP868", \
7774 +"CP869", \
7775 +"CP870", \
7776 +"CP871", \
7777 +"CP874", \
7778 +"CP875", \
7779 +"CP880", \
7780 +"CP891", \
7781 +"CP901", \
7782 +"CP902", \
7783 +"CP903", \
7784 +"CP904", \
7785 +"CP905", \
7786 +"CP912", \
7787 +"CP915", \
7788 +"CP916", \
7789 +"CP918", \
7790 +"CP920", \
7791 +"CP921", \
7792 +"CP922", \
7793 +"CP930", \
7794 +"CP932", \
7795 +"CP933", \
7796 +"CP935", \
7797 +"CP936", \
7798 +"CP937", \
7799 +"CP939", \
7800 +"CP949", \
7801 +"CP950", \
7802 +"CP1004", \
7803 +"CP1008", \
7804 +"CP1025", \
7805 +"CP1026", \
7806 +"CP1046", \
7807 +"CP1047", \
7808 +"CP1070", \
7809 +"CP1079", \
7810 +"CP1081", \
7811 +"CP1084", \
7812 +"CP1089", \
7813 +"CP1097", \
7814 +"CP1112", \
7815 +"CP1122", \
7816 +"CP1123", \
7817 +"CP1124", \
7818 +"CP1125", \
7819 +"CP1129", \
7820 +"CP1130", \
7821 +"CP1132", \
7822 +"CP1133", \
7823 +"CP1137", \
7824 +"CP1140", \
7825 +"CP1141", \
7826 +"CP1142", \
7827 +"CP1143", \
7828 +"CP1144", \
7829 +"CP1145", \
7830 +"CP1146", \
7831 +"CP1147", \
7832 +"CP1148", \
7833 +"CP1149", \
7834 +"CP1153", \
7835 +"CP1154", \
7836 +"CP1155", \
7837 +"CP1156", \
7838 +"CP1157", \
7839 +"CP1158", \
7840 +"CP1160", \
7841 +"CP1161", \
7842 +"CP1162", \
7843 +"CP1163", \
7844 +"CP1164", \
7845 +"CP1166", \
7846 +"CP1167", \
7847 +"CP1250", \
7848 +"CP1251", \
7849 +"CP1252", \
7850 +"CP1253", \
7851 +"CP1254", \
7852 +"CP1255", \
7853 +"CP1256", \
7854 +"CP1257", \
7855 +"CP1258", \
7856 +"CP1282", \
7857 +"CP1361", \
7858 +"CP1364", \
7859 +"CP1371", \
7860 +"CP1388", \
7861 +"CP1390", \
7862 +"CP1399", \
7863 +"CP4517", \
7864 +"CP4899", \
7865 +"CP4909", \
7866 +"CP4971", \
7867 +"CP5347", \
7868 +"CP9030", \
7869 +"CP9066", \
7870 +"CP9448", \
7871 +"CP10007", \
7872 +"CP12712", \
7873 +"CP16804", \
7874 +"CPIBM861", \
7875 +"CSA7-1", \
7876 +"CSA7-2", \
7877 +"CSASCII", \
7878 +"CSA_T500-1983", \
7879 +"CSA_T500", \
7880 +"CSA_Z243.4-1985-1", \
7881 +"CSA_Z243.4-1985-2", \
7882 +"CSA_Z243.419851", \
7883 +"CSA_Z243.419852", \
7884 +"CSDECMCS", \
7885 +"CSEBCDICATDE", \
7886 +"CSEBCDICATDEA", \
7887 +"CSEBCDICCAFR", \
7888 +"CSEBCDICDKNO", \
7889 +"CSEBCDICDKNOA", \
7890 +"CSEBCDICES", \
7891 +"CSEBCDICESA", \
7892 +"CSEBCDICESS", \
7893 +"CSEBCDICFISE", \
7894 +"CSEBCDICFISEA", \
7895 +"CSEBCDICFR", \
7896 +"CSEBCDICIT", \
7897 +"CSEBCDICPT", \
7898 +"CSEBCDICUK", \
7899 +"CSEBCDICUS", \
7900 +"CSEUCKR", \
7901 +"CSEUCPKDFMTJAPANESE", \
7902 +"CSGB2312", \
7903 +"CSHPROMAN8", \
7904 +"CSIBM037", \
7905 +"CSIBM038", \
7906 +"CSIBM273", \
7907 +"CSIBM274", \
7908 +"CSIBM275", \
7909 +"CSIBM277", \
7910 +"CSIBM278", \
7911 +"CSIBM280", \
7912 +"CSIBM281", \
7913 +"CSIBM284", \
7914 +"CSIBM285", \
7915 +"CSIBM290", \
7916 +"CSIBM297", \
7917 +"CSIBM420", \
7918 +"CSIBM423", \
7919 +"CSIBM424", \
7920 +"CSIBM500", \
7921 +"CSIBM803", \
7922 +"CSIBM851", \
7923 +"CSIBM855", \
7924 +"CSIBM856", \
7925 +"CSIBM857", \
7926 +"CSIBM860", \
7927 +"CSIBM863", \
7928 +"CSIBM864", \
7929 +"CSIBM865", \
7930 +"CSIBM866", \
7931 +"CSIBM868", \
7932 +"CSIBM869", \
7933 +"CSIBM870", \
7934 +"CSIBM871", \
7935 +"CSIBM880", \
7936 +"CSIBM891", \
7937 +"CSIBM901", \
7938 +"CSIBM902", \
7939 +"CSIBM903", \
7940 +"CSIBM904", \
7941 +"CSIBM905", \
7942 +"CSIBM918", \
7943 +"CSIBM921", \
7944 +"CSIBM922", \
7945 +"CSIBM930", \
7946 +"CSIBM932", \
7947 +"CSIBM933", \
7948 +"CSIBM935", \
7949 +"CSIBM937", \
7950 +"CSIBM939", \
7951 +"CSIBM943", \
7952 +"CSIBM1008", \
7953 +"CSIBM1025", \
7954 +"CSIBM1026", \
7955 +"CSIBM1097", \
7956 +"CSIBM1112", \
7957 +"CSIBM1122", \
7958 +"CSIBM1123", \
7959 +"CSIBM1124", \
7960 +"CSIBM1129", \
7961 +"CSIBM1130", \
7962 +"CSIBM1132", \
7963 +"CSIBM1133", \
7964 +"CSIBM1137", \
7965 +"CSIBM1140", \
7966 +"CSIBM1141", \
7967 +"CSIBM1142", \
7968 +"CSIBM1143", \
7969 +"CSIBM1144", \
7970 +"CSIBM1145", \
7971 +"CSIBM1146", \
7972 +"CSIBM1147", \
7973 +"CSIBM1148", \
7974 +"CSIBM1149", \
7975 +"CSIBM1153", \
7976 +"CSIBM1154", \
7977 +"CSIBM1155", \
7978 +"CSIBM1156", \
7979 +"CSIBM1157", \
7980 +"CSIBM1158", \
7981 +"CSIBM1160", \
7982 +"CSIBM1161", \
7983 +"CSIBM1163", \
7984 +"CSIBM1164", \
7985 +"CSIBM1166", \
7986 +"CSIBM1167", \
7987 +"CSIBM1364", \
7988 +"CSIBM1371", \
7989 +"CSIBM1388", \
7990 +"CSIBM1390", \
7991 +"CSIBM1399", \
7992 +"CSIBM4517", \
7993 +"CSIBM4899", \
7994 +"CSIBM4909", \
7995 +"CSIBM4971", \
7996 +"CSIBM5347", \
7997 +"CSIBM9030", \
7998 +"CSIBM9066", \
7999 +"CSIBM9448", \
8000 +"CSIBM12712", \
8001 +"CSIBM16804", \
8002 +"CSIBM11621162", \
8003 +"CSISO4UNITEDKINGDOM", \
8004 +"CSISO10SWEDISH", \
8005 +"CSISO11SWEDISHFORNAMES", \
8006 +"CSISO14JISC6220RO", \
8007 +"CSISO15ITALIAN", \
8008 +"CSISO16PORTUGESE", \
8009 +"CSISO17SPANISH", \
8010 +"CSISO18GREEK7OLD", \
8011 +"CSISO19LATINGREEK", \
8012 +"CSISO21GERMAN", \
8013 +"CSISO25FRENCH", \
8014 +"CSISO27LATINGREEK1", \
8015 +"CSISO49INIS", \
8016 +"CSISO50INIS8", \
8017 +"CSISO51INISCYRILLIC", \
8018 +"CSISO58GB1988", \
8019 +"CSISO60DANISHNORWEGIAN", \
8020 +"CSISO60NORWEGIAN1", \
8021 +"CSISO61NORWEGIAN2", \
8022 +"CSISO69FRENCH", \
8023 +"CSISO84PORTUGUESE2", \
8024 +"CSISO85SPANISH2", \
8025 +"CSISO86HUNGARIAN", \
8026 +"CSISO88GREEK7", \
8027 +"CSISO89ASMO449", \
8028 +"CSISO90", \
8029 +"CSISO92JISC62991984B", \
8030 +"CSISO99NAPLPS", \
8031 +"CSISO103T618BIT", \
8032 +"CSISO111ECMACYRILLIC", \
8033 +"CSISO121CANADIAN1", \
8034 +"CSISO122CANADIAN2", \
8035 +"CSISO139CSN369103", \
8036 +"CSISO141JUSIB1002", \
8037 +"CSISO143IECP271", \
8038 +"CSISO150", \
8039 +"CSISO150GREEKCCITT", \
8040 +"CSISO151CUBA", \
8041 +"CSISO153GOST1976874", \
8042 +"CSISO646DANISH", \
8043 +"CSISO2022CN", \
8044 +"CSISO2022JP", \
8045 +"CSISO2022JP2", \
8046 +"CSISO2022KR", \
8047 +"CSISO2033", \
8048 +"CSISO5427CYRILLIC", \
8049 +"CSISO5427CYRILLIC1981", \
8050 +"CSISO5428GREEK", \
8051 +"CSISO10367BOX", \
8052 +"CSISOLATIN1", \
8053 +"CSISOLATIN2", \
8054 +"CSISOLATIN3", \
8055 +"CSISOLATIN4", \
8056 +"CSISOLATIN5", \
8057 +"CSISOLATIN6", \
8058 +"CSISOLATINARABIC", \
8059 +"CSISOLATINCYRILLIC", \
8060 +"CSISOLATINGREEK", \
8061 +"CSISOLATINHEBREW", \
8062 +"CSKOI8R", \
8063 +"CSKSC5636", \
8064 +"CSMACINTOSH", \
8065 +"CSNATSDANO", \
8066 +"CSNATSSEFI", \
8067 +"CSN_369103", \
8068 +"CSPC8CODEPAGE437", \
8069 +"CSPC775BALTIC", \
8070 +"CSPC850MULTILINGUAL", \
8071 +"CSPC862LATINHEBREW", \
8072 +"CSPCP852", \
8073 +"CSSHIFTJIS", \
8074 +"CSUCS4", \
8075 +"CSUNICODE", \
8076 +"CSWINDOWS31J", \
8077 +"CUBA", \
8078 +"CWI-2", \
8079 +"CWI", \
8080 +"CYRILLIC", \
8081 +"DE", \
8082 +"DEC-MCS", \
8083 +"DEC", \
8084 +"DECMCS", \
8085 +"DIN_66003", \
8086 +"DK", \
8087 +"DS2089", \
8088 +"DS_2089", \
8089 +"E13B", \
8090 +"EBCDIC-AT-DE-A", \
8091 +"EBCDIC-AT-DE", \
8092 +"EBCDIC-BE", \
8093 +"EBCDIC-BR", \
8094 +"EBCDIC-CA-FR", \
8095 +"EBCDIC-CP-AR1", \
8096 +"EBCDIC-CP-AR2", \
8097 +"EBCDIC-CP-BE", \
8098 +"EBCDIC-CP-CA", \
8099 +"EBCDIC-CP-CH", \
8100 +"EBCDIC-CP-DK", \
8101 +"EBCDIC-CP-ES", \
8102 +"EBCDIC-CP-FI", \
8103 +"EBCDIC-CP-FR", \
8104 +"EBCDIC-CP-GB", \
8105 +"EBCDIC-CP-GR", \
8106 +"EBCDIC-CP-HE", \
8107 +"EBCDIC-CP-IS", \
8108 +"EBCDIC-CP-IT", \
8109 +"EBCDIC-CP-NL", \
8110 +"EBCDIC-CP-NO", \
8111 +"EBCDIC-CP-ROECE", \
8112 +"EBCDIC-CP-SE", \
8113 +"EBCDIC-CP-TR", \
8114 +"EBCDIC-CP-US", \
8115 +"EBCDIC-CP-WT", \
8116 +"EBCDIC-CP-YU", \
8117 +"EBCDIC-CYRILLIC", \
8118 +"EBCDIC-DK-NO-A", \
8119 +"EBCDIC-DK-NO", \
8120 +"EBCDIC-ES-A", \
8121 +"EBCDIC-ES-S", \
8122 +"EBCDIC-ES", \
8123 +"EBCDIC-FI-SE-A", \
8124 +"EBCDIC-FI-SE", \
8125 +"EBCDIC-FR", \
8126 +"EBCDIC-GREEK", \
8127 +"EBCDIC-INT", \
8128 +"EBCDIC-INT1", \
8129 +"EBCDIC-IS-FRISS", \
8130 +"EBCDIC-IT", \
8131 +"EBCDIC-JP-E", \
8132 +"EBCDIC-JP-KANA", \
8133 +"EBCDIC-PT", \
8134 +"EBCDIC-UK", \
8135 +"EBCDIC-US", \
8136 +"EBCDICATDE", \
8137 +"EBCDICATDEA", \
8138 +"EBCDICCAFR", \
8139 +"EBCDICDKNO", \
8140 +"EBCDICDKNOA", \
8141 +"EBCDICES", \
8142 +"EBCDICESA", \
8143 +"EBCDICESS", \
8144 +"EBCDICFISE", \
8145 +"EBCDICFISEA", \
8146 +"EBCDICFR", \
8147 +"EBCDICISFRISS", \
8148 +"EBCDICIT", \
8149 +"EBCDICPT", \
8150 +"EBCDICUK", \
8151 +"EBCDICUS", \
8152 +"ECMA-114", \
8153 +"ECMA-118", \
8154 +"ECMA-128", \
8155 +"ECMA-CYRILLIC", \
8156 +"ECMACYRILLIC", \
8157 +"ELOT_928", \
8158 +"ES", \
8159 +"ES2", \
8160 +"EUC-CN", \
8161 +"EUC-JISX0213", \
8162 +"EUC-JP-MS", \
8163 +"EUC-JP", \
8164 +"EUC-KR", \
8165 +"EUC-TW", \
8166 +"EUCCN", \
8167 +"EUCJP-MS", \
8168 +"EUCJP-OPEN", \
8169 +"EUCJP-WIN", \
8170 +"EUCJP", \
8171 +"EUCKR", \
8172 +"EUCTW", \
8173 +"FI", \
8174 +"FR", \
8175 +"GB", \
8176 +"GB2312", \
8177 +"GB13000", \
8178 +"GB18030", \
8179 +"GBK", \
8180 +"GB_1988-80", \
8181 +"GB_198880", \
8182 +"GEORGIAN-ACADEMY", \
8183 +"GEORGIAN-PS", \
8184 +"GOST_19768-74", \
8185 +"GOST_19768", \
8186 +"GOST_1976874", \
8187 +"GREEK-CCITT", \
8188 +"GREEK", \
8189 +"GREEK7-OLD", \
8190 +"GREEK7", \
8191 +"GREEK7OLD", \
8192 +"GREEK8", \
8193 +"GREEKCCITT", \
8194 +"HEBREW", \
8195 +"HP-GREEK8", \
8196 +"HP-ROMAN8", \
8197 +"HP-ROMAN9", \
8198 +"HP-THAI8", \
8199 +"HP-TURKISH8", \
8200 +"HPGREEK8", \
8201 +"HPROMAN8", \
8202 +"HPROMAN9", \
8203 +"HPTHAI8", \
8204 +"HPTURKISH8", \
8205 +"HU", \
8206 +"IBM-803", \
8207 +"IBM-856", \
8208 +"IBM-901", \
8209 +"IBM-902", \
8210 +"IBM-921", \
8211 +"IBM-922", \
8212 +"IBM-930", \
8213 +"IBM-932", \
8214 +"IBM-933", \
8215 +"IBM-935", \
8216 +"IBM-937", \
8217 +"IBM-939", \
8218 +"IBM-943", \
8219 +"IBM-1008", \
8220 +"IBM-1025", \
8221 +"IBM-1046", \
8222 +"IBM-1047", \
8223 +"IBM-1097", \
8224 +"IBM-1112", \
8225 +"IBM-1122", \
8226 +"IBM-1123", \
8227 +"IBM-1124", \
8228 +"IBM-1129", \
8229 +"IBM-1130", \
8230 +"IBM-1132", \
8231 +"IBM-1133", \
8232 +"IBM-1137", \
8233 +"IBM-1140", \
8234 +"IBM-1141", \
8235 +"IBM-1142", \
8236 +"IBM-1143", \
8237 +"IBM-1144", \
8238 +"IBM-1145", \
8239 +"IBM-1146", \
8240 +"IBM-1147", \
8241 +"IBM-1148", \
8242 +"IBM-1149", \
8243 +"IBM-1153", \
8244 +"IBM-1154", \
8245 +"IBM-1155", \
8246 +"IBM-1156", \
8247 +"IBM-1157", \
8248 +"IBM-1158", \
8249 +"IBM-1160", \
8250 +"IBM-1161", \
8251 +"IBM-1162", \
8252 +"IBM-1163", \
8253 +"IBM-1164", \
8254 +"IBM-1166", \
8255 +"IBM-1167", \
8256 +"IBM-1364", \
8257 +"IBM-1371", \
8258 +"IBM-1388", \
8259 +"IBM-1390", \
8260 +"IBM-1399", \
8261 +"IBM-4517", \
8262 +"IBM-4899", \
8263 +"IBM-4909", \
8264 +"IBM-4971", \
8265 +"IBM-5347", \
8266 +"IBM-9030", \
8267 +"IBM-9066", \
8268 +"IBM-9448", \
8269 +"IBM-12712", \
8270 +"IBM-16804", \
8271 +"IBM037", \
8272 +"IBM038", \
8273 +"IBM256", \
8274 +"IBM273", \
8275 +"IBM274", \
8276 +"IBM275", \
8277 +"IBM277", \
8278 +"IBM278", \
8279 +"IBM280", \
8280 +"IBM281", \
8281 +"IBM284", \
8282 +"IBM285", \
8283 +"IBM290", \
8284 +"IBM297", \
8285 +"IBM367", \
8286 +"IBM420", \
8287 +"IBM423", \
8288 +"IBM424", \
8289 +"IBM437", \
8290 +"IBM500", \
8291 +"IBM775", \
8292 +"IBM803", \
8293 +"IBM813", \
8294 +"IBM819", \
8295 +"IBM848", \
8296 +"IBM850", \
8297 +"IBM851", \
8298 +"IBM852", \
8299 +"IBM855", \
8300 +"IBM856", \
8301 +"IBM857", \
8302 +"IBM860", \
8303 +"IBM861", \
8304 +"IBM862", \
8305 +"IBM863", \
8306 +"IBM864", \
8307 +"IBM865", \
8308 +"IBM866", \
8309 +"IBM866NAV", \
8310 +"IBM868", \
8311 +"IBM869", \
8312 +"IBM870", \
8313 +"IBM871", \
8314 +"IBM874", \
8315 +"IBM875", \
8316 +"IBM880", \
8317 +"IBM891", \
8318 +"IBM901", \
8319 +"IBM902", \
8320 +"IBM903", \
8321 +"IBM904", \
8322 +"IBM905", \
8323 +"IBM912", \
8324 +"IBM915", \
8325 +"IBM916", \
8326 +"IBM918", \
8327 +"IBM920", \
8328 +"IBM921", \
8329 +"IBM922", \
8330 +"IBM930", \
8331 +"IBM932", \
8332 +"IBM933", \
8333 +"IBM935", \
8334 +"IBM937", \
8335 +"IBM939", \
8336 +"IBM943", \
8337 +"IBM1004", \
8338 +"IBM1008", \
8339 +"IBM1025", \
8340 +"IBM1026", \
8341 +"IBM1046", \
8342 +"IBM1047", \
8343 +"IBM1089", \
8344 +"IBM1097", \
8345 +"IBM1112", \
8346 +"IBM1122", \
8347 +"IBM1123", \
8348 +"IBM1124", \
8349 +"IBM1129", \
8350 +"IBM1130", \
8351 +"IBM1132", \
8352 +"IBM1133", \
8353 +"IBM1137", \
8354 +"IBM1140", \
8355 +"IBM1141", \
8356 +"IBM1142", \
8357 +"IBM1143", \
8358 +"IBM1144", \
8359 +"IBM1145", \
8360 +"IBM1146", \
8361 +"IBM1147", \
8362 +"IBM1148", \
8363 +"IBM1149", \
8364 +"IBM1153", \
8365 +"IBM1154", \
8366 +"IBM1155", \
8367 +"IBM1156", \
8368 +"IBM1157", \
8369 +"IBM1158", \
8370 +"IBM1160", \
8371 +"IBM1161", \
8372 +"IBM1162", \
8373 +"IBM1163", \
8374 +"IBM1164", \
8375 +"IBM1166", \
8376 +"IBM1167", \
8377 +"IBM1364", \
8378 +"IBM1371", \
8379 +"IBM1388", \
8380 +"IBM1390", \
8381 +"IBM1399", \
8382 +"IBM4517", \
8383 +"IBM4899", \
8384 +"IBM4909", \
8385 +"IBM4971", \
8386 +"IBM5347", \
8387 +"IBM9030", \
8388 +"IBM9066", \
8389 +"IBM9448", \
8390 +"IBM12712", \
8391 +"IBM16804", \
8392 +"IEC_P27-1", \
8393 +"IEC_P271", \
8394 +"INIS-8", \
8395 +"INIS-CYRILLIC", \
8396 +"INIS", \
8397 +"INIS8", \
8398 +"INISCYRILLIC", \
8399 +"ISIRI-3342", \
8400 +"ISIRI3342", \
8401 +"ISO-2022-CN-EXT", \
8402 +"ISO-2022-CN", \
8403 +"ISO-2022-JP-2", \
8404 +"ISO-2022-JP-3", \
8405 +"ISO-2022-JP", \
8406 +"ISO-2022-KR", \
8407 +"ISO-8859-1", \
8408 +"ISO-8859-2", \
8409 +"ISO-8859-3", \
8410 +"ISO-8859-4", \
8411 +"ISO-8859-5", \
8412 +"ISO-8859-6", \
8413 +"ISO-8859-7", \
8414 +"ISO-8859-8", \
8415 +"ISO-8859-9", \
8416 +"ISO-8859-9E", \
8417 +"ISO-8859-10", \
8418 +"ISO-8859-11", \
8419 +"ISO-8859-13", \
8420 +"ISO-8859-14", \
8421 +"ISO-8859-15", \
8422 +"ISO-8859-16", \
8423 +"ISO-10646", \
8424 +"ISO-CELTIC", \
8425 +"ISO-IR-4", \
8426 +"ISO-IR-6", \
8427 +"ISO-IR-8-1", \
8428 +"ISO-IR-9-1", \
8429 +"ISO-IR-10", \
8430 +"ISO-IR-11", \
8431 +"ISO-IR-14", \
8432 +"ISO-IR-15", \
8433 +"ISO-IR-16", \
8434 +"ISO-IR-17", \
8435 +"ISO-IR-18", \
8436 +"ISO-IR-19", \
8437 +"ISO-IR-21", \
8438 +"ISO-IR-25", \
8439 +"ISO-IR-27", \
8440 +"ISO-IR-37", \
8441 +"ISO-IR-49", \
8442 +"ISO-IR-50", \
8443 +"ISO-IR-51", \
8444 +"ISO-IR-54", \
8445 +"ISO-IR-55", \
8446 +"ISO-IR-57", \
8447 +"ISO-IR-60", \
8448 +"ISO-IR-61", \
8449 +"ISO-IR-69", \
8450 +"ISO-IR-84", \
8451 +"ISO-IR-85", \
8452 +"ISO-IR-86", \
8453 +"ISO-IR-88", \
8454 +"ISO-IR-89", \
8455 +"ISO-IR-90", \
8456 +"ISO-IR-92", \
8457 +"ISO-IR-98", \
8458 +"ISO-IR-99", \
8459 +"ISO-IR-100", \
8460 +"ISO-IR-101", \
8461 +"ISO-IR-103", \
8462 +"ISO-IR-109", \
8463 +"ISO-IR-110", \
8464 +"ISO-IR-111", \
8465 +"ISO-IR-121", \
8466 +"ISO-IR-122", \
8467 +"ISO-IR-126", \
8468 +"ISO-IR-127", \
8469 +"ISO-IR-138", \
8470 +"ISO-IR-139", \
8471 +"ISO-IR-141", \
8472 +"ISO-IR-143", \
8473 +"ISO-IR-144", \
8474 +"ISO-IR-148", \
8475 +"ISO-IR-150", \
8476 +"ISO-IR-151", \
8477 +"ISO-IR-153", \
8478 +"ISO-IR-155", \
8479 +"ISO-IR-156", \
8480 +"ISO-IR-157", \
8481 +"ISO-IR-166", \
8482 +"ISO-IR-179", \
8483 +"ISO-IR-193", \
8484 +"ISO-IR-197", \
8485 +"ISO-IR-199", \
8486 +"ISO-IR-203", \
8487 +"ISO-IR-209", \
8488 +"ISO-IR-226", \
8489 +"ISO646-CA", \
8490 +"ISO646-CA2", \
8491 +"ISO646-CN", \
8492 +"ISO646-CU", \
8493 +"ISO646-DE", \
8494 +"ISO646-DK", \
8495 +"ISO646-ES", \
8496 +"ISO646-ES2", \
8497 +"ISO646-FI", \
8498 +"ISO646-FR", \
8499 +"ISO646-FR1", \
8500 +"ISO646-GB", \
8501 +"ISO646-HU", \
8502 +"ISO646-IT", \
8503 +"ISO646-JP-OCR-B", \
8504 +"ISO646-JP", \
8505 +"ISO646-KR", \
8506 +"ISO646-NO", \
8507 +"ISO646-NO2", \
8508 +"ISO646-PT", \
8509 +"ISO646-PT2", \
8510 +"ISO646-SE", \
8511 +"ISO646-SE2", \
8512 +"ISO646-US", \
8513 +"ISO646-YU", \
8514 +"ISO2022CN", \
8515 +"ISO2022CNEXT", \
8516 +"ISO2022JP", \
8517 +"ISO2022JP2", \
8518 +"ISO2022KR", \
8519 +"ISO6937", \
8520 +"ISO8859-1", \
8521 +"ISO8859-2", \
8522 +"ISO8859-3", \
8523 +"ISO8859-4", \
8524 +"ISO8859-5", \
8525 +"ISO8859-6", \
8526 +"ISO8859-7", \
8527 +"ISO8859-8", \
8528 +"ISO8859-9", \
8529 +"ISO8859-9E", \
8530 +"ISO8859-10", \
8531 +"ISO8859-11", \
8532 +"ISO8859-13", \
8533 +"ISO8859-14", \
8534 +"ISO8859-15", \
8535 +"ISO8859-16", \
8536 +"ISO11548-1", \
8537 +"ISO88591", \
8538 +"ISO88592", \
8539 +"ISO88593", \
8540 +"ISO88594", \
8541 +"ISO88595", \
8542 +"ISO88596", \
8543 +"ISO88597", \
8544 +"ISO88598", \
8545 +"ISO88599", \
8546 +"ISO88599E", \
8547 +"ISO885910", \
8548 +"ISO885911", \
8549 +"ISO885913", \
8550 +"ISO885914", \
8551 +"ISO885915", \
8552 +"ISO885916", \
8553 +"ISO_646.IRV:1991", \
8554 +"ISO_2033-1983", \
8555 +"ISO_2033", \
8556 +"ISO_5427-EXT", \
8557 +"ISO_5427", \
8558 +"ISO_5427:1981", \
8559 +"ISO_5427EXT", \
8560 +"ISO_5428", \
8561 +"ISO_5428:1980", \
8562 +"ISO_6937-2", \
8563 +"ISO_6937-2:1983", \
8564 +"ISO_6937", \
8565 +"ISO_6937:1992", \
8566 +"ISO_8859-1", \
8567 +"ISO_8859-1:1987", \
8568 +"ISO_8859-2", \
8569 +"ISO_8859-2:1987", \
8570 +"ISO_8859-3", \
8571 +"ISO_8859-3:1988", \
8572 +"ISO_8859-4", \
8573 +"ISO_8859-4:1988", \
8574 +"ISO_8859-5", \
8575 +"ISO_8859-5:1988", \
8576 +"ISO_8859-6", \
8577 +"ISO_8859-6:1987", \
8578 +"ISO_8859-7", \
8579 +"ISO_8859-7:1987", \
8580 +"ISO_8859-7:2003", \
8581 +"ISO_8859-8", \
8582 +"ISO_8859-8:1988", \
8583 +"ISO_8859-9", \
8584 +"ISO_8859-9:1989", \
8585 +"ISO_8859-9E", \
8586 +"ISO_8859-10", \
8587 +"ISO_8859-10:1992", \
8588 +"ISO_8859-14", \
8589 +"ISO_8859-14:1998", \
8590 +"ISO_8859-15", \
8591 +"ISO_8859-15:1998", \
8592 +"ISO_8859-16", \
8593 +"ISO_8859-16:2001", \
8594 +"ISO_9036", \
8595 +"ISO_10367-BOX", \
8596 +"ISO_10367BOX", \
8597 +"ISO_11548-1", \
8598 +"ISO_69372", \
8599 +"IT", \
8600 +"JIS_C6220-1969-RO", \
8601 +"JIS_C6229-1984-B", \
8602 +"JIS_C62201969RO", \
8603 +"JIS_C62291984B", \
8604 +"JOHAB", \
8605 +"JP-OCR-B", \
8606 +"JP", \
8607 +"JS", \
8608 +"JUS_I.B1.002", \
8609 +"KOI-7", \
8610 +"KOI-8", \
8611 +"KOI8-R", \
8612 +"KOI8-RU", \
8613 +"KOI8-T", \
8614 +"KOI8-U", \
8615 +"KOI8", \
8616 +"KOI8R", \
8617 +"KOI8U", \
8618 +"KSC5636", \
8619 +"L1", \
8620 +"L2", \
8621 +"L3", \
8622 +"L4", \
8623 +"L5", \
8624 +"L6", \
8625 +"L7", \
8626 +"L8", \
8627 +"L10", \
8628 +"LATIN-9", \
8629 +"LATIN-GREEK-1", \
8630 +"LATIN-GREEK", \
8631 +"LATIN1", \
8632 +"LATIN2", \
8633 +"LATIN3", \
8634 +"LATIN4", \
8635 +"LATIN5", \
8636 +"LATIN6", \
8637 +"LATIN7", \
8638 +"LATIN8", \
8639 +"LATIN10", \
8640 +"LATINGREEK", \
8641 +"LATINGREEK1", \
8642 +"MAC-CENTRALEUROPE", \
8643 +"MAC-CYRILLIC", \
8644 +"MAC-IS", \
8645 +"MAC-SAMI", \
8646 +"MAC-UK", \
8647 +"MAC", \
8648 +"MACCYRILLIC", \
8649 +"MACINTOSH", \
8650 +"MACIS", \
8651 +"MACUK", \
8652 +"MACUKRAINIAN", \
8653 +"MIK", \
8654 +"MS-ANSI", \
8655 +"MS-ARAB", \
8656 +"MS-CYRL", \
8657 +"MS-EE", \
8658 +"MS-GREEK", \
8659 +"MS-HEBR", \
8660 +"MS-MAC-CYRILLIC", \
8661 +"MS-TURK", \
8662 +"MS932", \
8663 +"MS936", \
8664 +"MSCP949", \
8665 +"MSCP1361", \
8666 +"MSMACCYRILLIC", \
8667 +"MSZ_7795.3", \
8668 +"MS_KANJI", \
8669 +"NAPLPS", \
8670 +"NATS-DANO", \
8671 +"NATS-SEFI", \
8672 +"NATSDANO", \
8673 +"NATSSEFI", \
8674 +"NC_NC0010", \
8675 +"NC_NC00-10", \
8676 +"NC_NC00-10:81", \
8677 +"NF_Z_62-010", \
8678 +"NF_Z_62-010_(1973)", \
8679 +"NF_Z_62-010_1973", \
8680 +"NF_Z_62010", \
8681 +"NF_Z_62010_1973", \
8682 +"NO", \
8683 +"NO2", \
8684 +"NS_4551-1", \
8685 +"NS_4551-2", \
8686 +"NS_45511", \
8687 +"NS_45512", \
8688 +"OS2LATIN1", \
8689 +"OSF00010001", \
8690 +"OSF00010002", \
8691 +"OSF00010003", \
8692 +"OSF00010004", \
8693 +"OSF00010005", \
8694 +"OSF00010006", \
8695 +"OSF00010007", \
8696 +"OSF00010008", \
8697 +"OSF00010009", \
8698 +"OSF0001000A", \
8699 +"OSF00010020", \
8700 +"OSF00010100", \
8701 +"OSF00010101", \
8702 +"OSF00010102", \
8703 +"OSF00010104", \
8704 +"OSF00010105", \
8705 +"OSF00010106", \
8706 +"OSF00030010", \
8707 +"OSF0004000A", \
8708 +"OSF0005000A", \
8709 +"OSF05010001", \
8710 +"OSF100201A4", \
8711 +"OSF100201A8", \
8712 +"OSF100201B5", \
8713 +"OSF100201F4", \
8714 +"OSF100203B5", \
8715 +"OSF1002011C", \
8716 +"OSF1002011D", \
8717 +"OSF1002035D", \
8718 +"OSF1002035E", \
8719 +"OSF1002035F", \
8720 +"OSF1002036B", \
8721 +"OSF1002037B", \
8722 +"OSF10010001", \
8723 +"OSF10010004", \
8724 +"OSF10010006", \
8725 +"OSF10020025", \
8726 +"OSF10020111", \
8727 +"OSF10020115", \
8728 +"OSF10020116", \
8729 +"OSF10020118", \
8730 +"OSF10020122", \
8731 +"OSF10020129", \
8732 +"OSF10020352", \
8733 +"OSF10020354", \
8734 +"OSF10020357", \
8735 +"OSF10020359", \
8736 +"OSF10020360", \
8737 +"OSF10020364", \
8738 +"OSF10020365", \
8739 +"OSF10020366", \
8740 +"OSF10020367", \
8741 +"OSF10020370", \
8742 +"OSF10020387", \
8743 +"OSF10020388", \
8744 +"OSF10020396", \
8745 +"OSF10020402", \
8746 +"OSF10020417", \
8747 +"PT", \
8748 +"PT2", \
8749 +"PT154", \
8750 +"R8", \
8751 +"R9", \
8752 +"RK1048", \
8753 +"ROMAN8", \
8754 +"ROMAN9", \
8755 +"RUSCII", \
8756 +"SE", \
8757 +"SE2", \
8758 +"SEN_850200_B", \
8759 +"SEN_850200_C", \
8760 +"SHIFT-JIS", \
8761 +"SHIFT_JIS", \
8762 +"SHIFT_JISX0213", \
8763 +"SJIS-OPEN", \
8764 +"SJIS-WIN", \
8765 +"SJIS", \
8766 +"SS636127", \
8767 +"STRK1048-2002", \
8768 +"ST_SEV_358-88", \
8769 +"T.61-8BIT", \
8770 +"T.61", \
8771 +"T.618BIT", \
8772 +"TCVN-5712", \
8773 +"TCVN", \
8774 +"TCVN5712-1", \
8775 +"TCVN5712-1:1993", \
8776 +"THAI8", \
8777 +"TIS-620", \
8778 +"TIS620-0", \
8779 +"TIS620.2529-1", \
8780 +"TIS620.2533-0", \
8781 +"TIS620", \
8782 +"TS-5881", \
8783 +"TSCII", \
8784 +"TURKISH8", \
8785 +"UCS-2", \
8786 +"UCS-2BE", \
8787 +"UCS-2LE", \
8788 +"UCS-4", \
8789 +"UCS-4BE", \
8790 +"UCS-4LE", \
8791 +"UCS2", \
8792 +"UCS4", \
8793 +"UHC", \
8794 +"UJIS", \
8795 +"UK", \
8796 +"UNICODE", \
8797 +"UNICODEBIG", \
8798 +"UNICODELITTLE", \
8799 +"US-ASCII", \
8800 +"US", \
8801 +"UTF-7", \
8802 +"UTF-8", \
8803 +"UTF-16", \
8804 +"UTF-16BE", \
8805 +"UTF-16LE", \
8806 +"UTF-32", \
8807 +"UTF-32BE", \
8808 +"UTF-32LE", \
8809 +"UTF7", \
8810 +"UTF8", \
8811 +"UTF16", \
8812 +"UTF16BE", \
8813 +"UTF16LE", \
8814 +"UTF32", \
8815 +"UTF32BE", \
8816 +"UTF32LE", \
8817 +"VISCII", \
8818 +"WCHAR_T", \
8819 +"WIN-SAMI-2", \
8820 +"WINBALTRIM", \
8821 +"WINDOWS-31J", \
8822 +"WINDOWS-874", \
8823 +"WINDOWS-936", \
8824 +"WINDOWS-1250", \
8825 +"WINDOWS-1251", \
8826 +"WINDOWS-1252", \
8827 +"WINDOWS-1253", \
8828 +"WINDOWS-1254", \
8829 +"WINDOWS-1255", \
8830 +"WINDOWS-1256", \
8831 +"WINDOWS-1257", \
8832 +"WINDOWS-1258", \
8833 +"WINSAMI2", \
8834 +"WS2", \
8835 +"YU",
8836 diff --git a/gdb/charset.c b/gdb/charset.c
8837 index 32eb9c3..4850fbf 100644
8838 --- a/gdb/charset.c
8839 +++ b/gdb/charset.c
8840 @@ -21,6 +21,9 @@
8841  #include "charset.h"
8842  #include "gdbcmd.h"
8843  #include "gdb_assert.h"
8844 +#include "gdb_obstack.h"
8845 +#include "charset-list.h"
8846 +#include "vec.h"
8847  
8848  #include <stddef.h>
8849  #include "gdb_string.h"
8850 @@ -33,15 +36,20 @@
8851  \f
8852  /* How GDB's character set support works
8853  
8854 -   GDB has two global settings:
8855 +   GDB has three global settings:
8856  
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
8861 +     change this.
8862  
8863     - The `current target character set' is the character set the
8864       program being debugged uses.
8865  
8866 +   - The `current target wide character set' is the wide character set
8867 +     the program being debugged uses, that is, the encoding used for
8868 +     wchar_t.
8869 +
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
8875       conversions),
8876  
8877 -   and so on.
8878 -
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.
8884 -
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:
8888 -
8889 -   - We maintain a global table of "translations" --- groups of
8890 -     functions specific to a particular pair of character sets.
8891 -
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
8899 -     same.  */
8900 -
8901 -\f
8902 -/* The character set and translation structures.  */
8903 -
8904 -
8905 -/* A character set GDB knows about.  GDB only supports character sets
8906 -   with stateless encodings, in which every character is one byte
8907 -   long.  */
8908 -struct charset {
8909 -
8910 -  /* A singly-linked list of all known charsets.  */
8911 -  struct charset *next;
8912 -
8913 -  /* The name of the character set.  Comparisons on character set
8914 -     names are case-sensitive.  */
8915 -  const char *name;
8916 -
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;
8921 -
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,
8925 -                                    int host_char);
8926 -  void *host_char_print_literally_baton;
8927 -
8928 -  int (*target_char_to_control_char) (void *baton,
8929 -                                      int target_char,
8930 -                                      int *target_ctrl_char);
8931 -  void *target_char_to_control_char_baton;
8932 -};
8933 -
8934 -
8935 -/* A translation from one character set to another.  */
8936 -struct translation {
8937 -
8938 -  /* A singly-linked list of all known translations.  */
8939 -  struct translation *next;
8940 -
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;
8945 -
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.  */
8951 -  
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,
8955 -                                                     int target_char);
8956 -  void *c_target_char_has_backslash_escape_baton;
8957 -
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;
8962 -
8963 -  /* This is used for the host_char_to_target and target_char_to_host
8964 -     functions.  */
8965 -  int (*convert_char) (void *baton, int from, int *to);
8966 -  void *convert_char_baton;
8967 -};
8968 -
8969 +     and so on.
8970 +     
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.  */
8974  
8975  \f
8976  /* The global lists of character sets and translations.  */
8977  
8978  
8979 -#ifndef GDB_DEFAULT_HOST_CHARSET
8980 -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
8981 -#endif
8982 -
8983  #ifndef GDB_DEFAULT_TARGET_CHARSET
8984  #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
8985  #endif
8986  
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"
8990 +#endif
8991 +
8992 +static const char *auto_host_charset_name = GDB_DEFAULT_HOST_CHARSET;
8993 +static const char *host_charset_name = "auto";
8994  static void
8995  show_host_charset_name (struct ui_file *file, int from_tty,
8996                         struct cmd_list_element *c,
8997                         const char *value)
8998  {
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);
9004 +  else
9005 +    fprintf_filtered (file, _("The host character set is \"%s\".\n"), value);
9006  }
9007  
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,
9010                     value);
9011  }
9012  
9013 -
9014 -static const char *host_charset_enum[] = 
9015 +static const char *target_wide_charset_name = GDB_DEFAULT_TARGET_WIDE_CHARSET;
9016 +static void
9017 +show_target_wide_charset_name (struct ui_file *file, int from_tty,
9018 +                              struct cmd_list_element *c, const char *value)
9019  {
9020 -  "ASCII",
9021 -  "ISO-8859-1",
9022 -  0
9023 -};
9024 +  fprintf_filtered (file, _("The target wide character set is \"%s\".\n"),
9025 +                   value);
9026 +}
9027  
9028 -static const char *target_charset_enum[] = 
9029 +static const char *default_charset_names[] =
9030  {
9031 -  "ASCII",
9032 -  "ISO-8859-1",
9033 -  "EBCDIC-US",
9034 -  "IBM1047",
9035 +  DEFAULT_CHARSET_NAMES
9036    0
9037  };
9038  
9039 -/* The global list of all the charsets GDB knows about.  */
9040 -static struct charset *all_charsets;
9041 +static const char **charset_enum;
9042  
9043 +\f
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;
9048  
9049 -static void
9050 -register_charset (struct charset *cs)
9051 -{
9052 -  struct charset **ptr;
9053 -
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)
9057 -    ;
9058 -
9059 -  cs->next = 0;
9060 -  *ptr = cs;
9061 -}
9062 -
9063 +/* A helper function for validate which sets the target wide big- and
9064 +   little-endian character set names, if possible.  */
9065  
9066 -static struct charset *
9067 -lookup_charset (const char *name)
9068 +static void
9069 +set_be_le_names (void)
9070  {
9071 -  struct charset *cs;
9072 +  int i, len;
9073  
9074 -  for (cs = all_charsets; cs; cs = cs->next)
9075 -    if (! strcmp (name, cs->name))
9076 -      return cs;
9077 +  target_wide_charset_le_name = NULL;
9078 +  target_wide_charset_be_name = NULL;
9079  
9080 -  return NULL;
9081 +  len = strlen (target_wide_charset_name);
9082 +  for (i = 0; charset_enum[i]; ++i)
9083 +    {
9084 +      if (strncmp (target_wide_charset_name, charset_enum[i], len))
9085 +       continue;
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')
9090 +       {
9091 +         if (charset_enum[i][len] == 'B')
9092 +           target_wide_charset_be_name = charset_enum[i];
9093 +         else
9094 +           target_wide_charset_le_name = charset_enum[i];
9095 +       }
9096 +    }
9097  }
9098  
9099 -
9100 -/* The global list of translations.  */
9101 -static struct translation *all_translations;
9102 -
9103 +/* 'Set charset', 'set host-charset', 'set target-charset', 'set
9104 +   target-wide-charset', 'set charset' sfunc's.  */
9105  
9106  static void
9107 -register_translation (struct translation *t)
9108 +validate (void)
9109  {
9110 -  t->next = all_translations;
9111 -  all_translations = t;
9112 -}
9113 -
9114 -
9115 -static struct translation *
9116 -lookup_translation (const char *from, const char *to)
9117 -{
9118 -  struct translation *t;
9119 -
9120 -  for (t = all_translations; t; t = t->next)
9121 -    if (! strcmp (from, t->from)
9122 -        && ! strcmp (to, t->to))
9123 -      return t;
9124 +  iconv_t desc;
9125 +  const char *host_cset = host_charset ();
9126  
9127 -  return 0;
9128 -}
9129 -
9130 -
9131 -\f
9132 -/* Constructing charsets.  */
9133 -
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,
9144 -                                                    int target_char,
9145 -                                                    int *target_ctrl_char),
9146 -                void *target_char_to_control_char_baton)
9147 -{
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);
9154  
9155 -  memset (cs, 0, sizeof (*cs));
9156 -  cs->name = name;
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);
9167  
9168 -  return cs;
9169 +  set_be_le_names ();
9170  }
9171  
9172 -
9173 -\f
9174 -/* ASCII functions.  */
9175 -
9176 -static int
9177 -ascii_print_literally (void *baton, int c)
9178 +/* This is the sfunc for the 'set charset' command.  */
9179 +static void
9180 +set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
9181  {
9182 -  c &= 0xff;
9183 -
9184 -  return (0x20 <= c && c <= 0x7e);
9185 +  /* CAREFUL: set the target charset here as well. */
9186 +  target_charset_name = host_charset_name;
9187 +  validate ();
9188  }
9189  
9190 -
9191 -static int
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.  */
9195 +static void
9196 +set_host_charset_sfunc (char *charset, int from_tty,
9197 +                       struct cmd_list_element *c)
9198  {
9199 -  *ctrl_char = (c & 037);
9200 -  return 1;
9201 +  validate ();
9202  }
9203  
9204 -\f
9205 -/* ISO-8859 family functions.  */
9206 -
9207 -
9208 -static int
9209 -iso_8859_print_literally (void *baton, int c)
9210 +/* Wrapper for the 'set target-charset' command.  */
9211 +static void
9212 +set_target_charset_sfunc (char *charset, int from_tty,
9213 +                         struct cmd_list_element *c)
9214  {
9215 -  c &= 0xff;
9216 -
9217 -  return ((0x20 <= c && c <= 0x7e) /* ascii printables */
9218 -          || (! sevenbit_strings && 0xA0 <= c)); /* iso 8859 printables */
9219 +  validate ();
9220  }
9221  
9222 -
9223 -static int
9224 -iso_8859_to_control (void *baton, int c, int *ctrl_char)
9225 +/* Wrapper for the 'set target-wide-charset' command.  */
9226 +static void
9227 +set_target_wide_charset_sfunc (char *charset, int from_tty,
9228 +                              struct cmd_list_element *c)
9229  {
9230 -  *ctrl_char = (c & 0200) | (c & 037);
9231 -  return 1;
9232 +  validate ();
9233  }
9234  
9235 -
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.  */
9240 +static void
9241 +show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
9242 +             const char *name)
9243  {
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);
9250  }
9251  
9252 -
9253  \f
9254 -/* EBCDIC family functions.  */
9255 -
9256 -
9257 -static int
9258 -ebcdic_print_literally (void *baton, int c)
9259 -{
9260 -  c &= 0xff;
9261 -
9262 -  return (64 <= c && c <= 254);
9263 -}
9264 -
9265 +/* Accessor functions.  */
9266  
9267 -static int
9268 -ebcdic_to_control (void *baton, int c, int *ctrl_char)
9269 +const char *
9270 +host_charset (void)
9271  {
9272 -  /* There are no control character equivalents in EBCDIC.  Use
9273 -     numeric escapes.  */
9274 -  return 0;
9275 +  if (!strcmp (host_charset_name, "auto"))
9276 +    return auto_host_charset_name;
9277 +  return host_charset_name;
9278  }
9279  
9280 -
9281 -/* Construct an EBCDIC-like character set.  */
9282 -static struct charset *
9283 -ebcdic_family_charset (const char *name)
9284 +const char *
9285 +target_charset (void)
9286  {
9287 -  return simple_charset (name, 0,
9288 -                         ebcdic_print_literally, 0,
9289 -                         ebcdic_to_control, 0);
9290 +  return target_charset_name;
9291  }
9292 -                
9293 -
9294 -
9295 -
9296 -\f
9297 -/* Fallback functions using iconv.  */
9298 -
9299 -#if defined(HAVE_ICONV)
9300  
9301 -struct cached_iconv {
9302 -  struct charset *from, *to;
9303 -  iconv_t i;
9304 -};
9305 -
9306 -
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.  */
9311 -static int
9312 -check_iconv_cache (struct cached_iconv *ci,
9313 -                   struct charset *from,
9314 -                   struct charset *to)
9315 +const char *
9316 +target_wide_charset (void)
9317  {
9318 -  iconv_t i;
9319 -
9320 -  /* Does the cached iconv descriptor match the conversion we're trying
9321 -     to do now?  */
9322 -  if (ci->from == from
9323 -      && ci->to == to
9324 -      && ci->i != (iconv_t) 0)
9325 -    return 0;
9326 -
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)
9331      {
9332 -      i = ci->i;
9333 -      ci->i = (iconv_t) 0;
9334 -      
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;
9341      }
9342 -
9343 -  /* Open a new iconv descriptor for the required conversion.  */
9344 -  i = iconv_open (to->name, from->name);
9345 -  if (i == (iconv_t) -1)
9346 -    return -1;
9347 -
9348 -  ci->i = i;
9349 -  ci->from = from;
9350 -  ci->to = to;
9351 -
9352 -  return 0;
9353 -}
9354 -
9355 -
9356 -/* Convert FROM_CHAR using the cached iconv conversion *CI.  Return
9357 -   non-zero if the conversion was successful, zero otherwise.  */
9358 -static int
9359 -cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
9360 -{
9361 -  char from;
9362 -  ICONV_CONST char *from_ptr = &from;
9363 -  char to, *to_ptr = &to;
9364 -  size_t from_left = sizeof (from), to_left = sizeof (to);
9365 -
9366 -  gdb_assert (ci->i != (iconv_t) 0);
9367 -
9368 -  from = from_char;
9369 -  if (iconv (ci->i, &from_ptr, &from_left, &to_ptr, &to_left)
9370 -      == (size_t) -1)
9371 +  else
9372      {
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);
9378 -
9379 -      /* This suggests a bug in the code managing *CI.  */
9380 -      gdb_assert (errno != EBADF);
9381 -
9382 -      /* This seems to mean that there is no equivalent character in
9383 -         the `to' character set.  */
9384 -      if (errno == EILSEQ)
9385 -        return 0;
9386 -
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;
9395      }
9396  
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);
9400 -
9401 -  *to_char = (unsigned char) to;
9402 -  return 1;
9403 +  return target_wide_charset_name;
9404  }
9405  
9406 -
9407 -static void
9408 -register_iconv_charsets (void)
9409 -{
9410 -  /* Here we should check whether various character sets were
9411 -     recognized by the local iconv implementation.
9412 -
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
9417 -     file.  */
9418 -}
9419 -
9420 -#endif /* defined (HAVE_ICONV) */
9421 -
9422  \f
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.  */
9426  
9427 -#if ! defined (HAVE_ICONV) 
9428 -struct cached_iconv { char nothing; };
9429 -
9430 -static int
9431 -check_iconv_cache (struct cached_iconv *ci,
9432 -                   struct charset *from,
9433 -                   struct charset *to)
9434 +char
9435 +host_letter_to_control_character (char c)
9436  {
9437 -  errno = EINVAL;
9438 -  return -1;
9439 +  if (c == '?')
9440 +    return 0177;
9441 +  return c & 0237;
9442  }
9443  
9444 -static int
9445 -cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
9446 -{
9447 -  /* This function should never be called.  */
9448 -  gdb_assert (0);
9449 -}
9450 +/* Convert a host character, C, to its hex value.  C must already have
9451 +   been validated using isxdigit.  */
9452  
9453 -static void
9454 -register_iconv_charsets (void)
9455 -{
9456 -}
9457 -
9458 -#endif /* ! defined(HAVE_ICONV) */
9459 -
9460 -\f
9461 -/* Default trivial conversion functions.  */
9462 -
9463 -static int
9464 -identity_either_char_to_other (void *baton, int either_char, int *other_char)
9465 +int
9466 +host_hex_value (char c)
9467  {
9468 -  *other_char = either_char;
9469 -  return 1;
9470 +  if (isdigit (c))
9471 +    return c - '0';
9472 +  if (c >= 'a' && c <= 'f')
9473 +    return 10 + c - 'a';
9474 +  gdb_assert (c >= 'A' && c <= 'F');
9475 +  return 10 + c - 'A';
9476  }
9477  
9478 -
9479  \f
9480 -/* Default non-trivial conversion functions.  */
9481 -
9482 -
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";
9486 -
9487 -
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)
9492 -{
9493 -  int host_char;
9494 -  const char *ix;
9495 -
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))
9499 -    return NULL;
9500 -
9501 -  ix = strchr (represented, host_char);
9502 -  if (ix)
9503 -    return backslashed[ix - represented];
9504 -  else
9505 -    return NULL;
9506 -}
9507 -
9508 -
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.  */
9511 -static int
9512 -default_c_parse_backslash (void *baton, int host_char, int *target_char)
9513 -{
9514 -  const char *ix;
9515 -
9516 -  ix = strchr (backslashable, host_char);
9517 -
9518 -  if (! ix)
9519 -    return 0;
9520 -  else
9521 -    return host_char_to_target (represented[ix - backslashable],
9522 -                                target_char);
9523 -}
9524 +/* Public character management functions.  */
9525  
9526 +/* A cleanup function which is run to close an iconv descriptor.  */
9527  
9528 -/* Convert using a cached iconv descriptor.  */
9529 -static int
9530 -iconv_convert (void *baton, int from_char, int *to_char)
9531 +static void
9532 +cleanup_iconv (void *p)
9533  {
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);
9538  }
9539  
9540 +void
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)
9545 +{
9546 +  iconv_t desc;
9547 +  struct cleanup *cleanups;
9548 +  size_t inleft;
9549 +  char *inp;
9550 +  unsigned int space_request;
9551 +
9552 +  /* Often, the host and target charsets will be the same.  */
9553 +  if (!strcmp (from, to))
9554 +    {
9555 +      obstack_grow (output, bytes, num_bytes);
9556 +      return;
9557 +    }
9558  
9559 -\f
9560 -/* Conversion tables.  */
9561 -
9562 -
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.
9568 -
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.  */
9573 -
9574 -
9575 -/* We generated these tables using iconv on a GNU/Linux machine.  */
9576 -
9577 -
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 */
9595 -};
9596 -
9597 -
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 */
9615 -};
9616 -
9617 -
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 */
9635 -};
9636 -
9637 -
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 */
9655 -};
9656 -
9657 -
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 */
9675 -};
9676 -
9677 -
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 */
9695 -};
9696 -
9697 -
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 */
9715 -};
9716 -
9717 -
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 */
9735 -};
9736 -
9737 -
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 */
9755 -};
9756 -
9757 -
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 */
9775 -};
9776 -
9777 -
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 */
9795 -};
9796 -
9797 -
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 */
9815 -};
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);
9820  
9821 +  inleft = num_bytes;
9822 +  inp = (char *) bytes;
9823  
9824 -static int
9825 -table_convert_char (void *baton, int from, int *to)
9826 -{
9827 -  int *table = (int *) baton;
9828 +  space_request = num_bytes;
9829  
9830 -  if (0 <= from && from <= 255
9831 -      && table[from] != -1)
9832 +  while (inleft > 0)
9833      {
9834 -      *to = table[from];
9835 -      return 1;
9836 +      char *outp;
9837 +      size_t outleft, r;
9838 +      int old_size;
9839 +
9840 +      old_size = obstack_object_size (output);
9841 +      obstack_blank (output, space_request);
9842 +
9843 +      outp = obstack_base (output) + old_size;
9844 +      outleft = space_request;
9845 +
9846 +      r = iconv (desc, &inp, &inleft, &outp, &outleft);
9847 +
9848 +      /* Now make sure that the object on the obstack only includes
9849 +        bytes we have converted.  */
9850 +      obstack_blank (output, - (int) outleft);
9851 +
9852 +      if (r == (size_t) -1)
9853 +       {
9854 +         switch (errno)
9855 +           {
9856 +           case EILSEQ:
9857 +             {
9858 +               int i;
9859 +
9860 +               /* Invalid input sequence.  */
9861 +               if (translit == translit_none)
9862 +                 error (_("Could not convert character to `%s' character set"),
9863 +                        to);
9864 +
9865 +               /* We emit escape sequence for the bytes, skip them,
9866 +                  and try again.  */
9867 +               for (i = 0; i < width; ++i)
9868 +                 {
9869 +                   char octal[5];
9870 +
9871 +                   sprintf (octal, "\\%.3o", *inp & 0xff);
9872 +                   obstack_grow_str (output, octal);
9873 +
9874 +                   ++inp;
9875 +                   --inleft;
9876 +                 }
9877 +             }
9878 +             break;
9879 +
9880 +           case E2BIG:
9881 +             /* We ran out of space in the output buffer.  Make it
9882 +                bigger next time around.  */
9883 +             space_request *= 2;
9884 +             break;
9885 +
9886 +           case EINVAL:
9887 +             /* Incomplete input sequence.  FIXME: ought to report this
9888 +                to the caller somehow.  */
9889 +             inleft = 0;
9890 +             break;
9891 +
9892 +           default:
9893 +             perror_with_name ("Internal error while converting character sets");
9894 +           }
9895 +       }
9896      }
9897 -  else
9898 -    return 0;
9899 -}
9900 -
9901  
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,
9908 -                                             int host_char,
9909 -                                             int *target_char),
9910 -                   void *c_parse_backslash_baton)
9911 -{
9912 -  struct translation *t = xmalloc (sizeof (*t));
9913 -
9914 -  memset (t, 0, sizeof (*t));
9915 -  t->from = from;
9916 -  t->to = to;
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;
9924 -
9925 -  return t;
9926 +  do_cleanups (cleanups);
9927  }
9928  
9929 -
9930 -static struct translation *
9931 -simple_table_translation (const char *from, const char *to, int *table)
9932 -{
9933 -  return table_translation (from, to, table, 0, 0, 0, 0);
9934 -}
9935 -
9936 -
9937  \f
9938 -/* Setting and retrieving the host and target charsets.  */
9939 -
9940 -
9941 -/* The current host and target character sets.  */
9942 -static struct charset *current_host_charset, *current_target_charset;
9943 -
9944 -/* The current functions and batons we should use for the functions in
9945 -   charset.h.  */
9946 -
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;
9950 -
9951 -static int (*c_parse_backslash_func) (void *baton,
9952 -                                      int host_char,
9953 -                                      int *target_char);
9954 -static void *c_parse_backslash_baton;
9955 -
9956 -static int (*host_char_to_target_func) (void *baton,
9957 -                                        int host_char,
9958 -                                        int *target_char);
9959 -static void *host_char_to_target_baton;
9960 -
9961 -static int (*target_char_to_host_func) (void *baton,
9962 -                                        int target_char,
9963 -                                        int *host_char);
9964 -static void *target_char_to_host_baton;
9965  
9966 -
9967 -/* Cached iconv conversions, that might be useful to fallback
9968 -   routines.  */
9969 -static struct cached_iconv cached_iconv_host_to_target;
9970 -static struct cached_iconv cached_iconv_target_to_host;
9971 -
9972 -\f
9973 -/* Charset structures manipulation functions.  */
9974 -
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
9979  {
9980 -  struct charset *cs = lookup_charset (name);
9981 +  /* The underlying iconv descriptor.  */
9982 +  iconv_t desc;
9983  
9984 -  if (! cs)
9985 -    error (_("GDB doesn't know of any character set named `%s'."), name);
9986 +  /* The input string.  This is updated as convert characters.  */
9987 +  char *input;
9988 +  /* The number of bytes remaining in the input.  */
9989 +  size_t bytes;
9990  
9991 -  return cs;
9992 -}
9993 +  /* The width of an input character.  */
9994 +  size_t width;
9995  
9996 -static void
9997 -check_valid_host_charset (struct charset *cs)
9998 -{
9999 -  if (! cs->valid_host_charset)
10000 -    error (_("GDB can't use `%s' as its host character set."), cs->name);
10001 -}
10002 +  /* The output buffer and its size.  */
10003 +  wchar_t *out;
10004 +  size_t out_size;
10005 +};
10006  
10007 -/* Set the host and target character sets to HOST and TARGET.  */
10008 -static void
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,
10013 +                    size_t width)
10014  {
10015 -  struct translation *h2t, *t2h;
10016 -
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)
10021 -    {
10022 -      current_host_charset = host;
10023 -      current_target_charset = target;
10024 -      return;
10025 -    }
10026 -
10027 -  h2t = lookup_translation (host->name, target->name);
10028 -  t2h = lookup_translation (target->name, host->name);
10029 -
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)
10033 -    {
10034 -      if (! h2t || ! h2t->convert_char)
10035 -        {
10036 -          if (check_iconv_cache (&cached_iconv_host_to_target, host, target)
10037 -              < 0)
10038 -            error (_("GDB can't convert from the `%s' character set to `%s'."),
10039 -                   host->name, target->name);
10040 -        }
10041 -      if (! t2h || ! t2h->convert_char)
10042 -        {
10043 -          if (check_iconv_cache (&cached_iconv_target_to_host, target, host)
10044 -              < 0)
10045 -            error (_("GDB can't convert from the `%s' character set to `%s'."),
10046 -                   target->name, host->name);
10047 -        }
10048 -    }
10049 -
10050 -  if (t2h && t2h->c_target_char_has_backslash_escape)
10051 -    {
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;
10056 -    }
10057 -  else
10058 -    c_target_char_has_backslash_escape_func
10059 -      = default_c_target_char_has_backslash_escape;
10060 -
10061 -  if (h2t && h2t->c_parse_backslash)
10062 -    {
10063 -      c_parse_backslash_func = h2t->c_parse_backslash;
10064 -      c_parse_backslash_baton = h2t->c_parse_backslash_baton;
10065 -    }
10066 -  else
10067 -    c_parse_backslash_func = default_c_parse_backslash;
10068 -
10069 -  if (h2t && h2t->convert_char)
10070 -    {
10071 -      host_char_to_target_func = h2t->convert_char;
10072 -      host_char_to_target_baton = h2t->convert_char_baton;
10073 -    }
10074 -  else if (host == target)
10075 -    host_char_to_target_func = identity_either_char_to_other;
10076 -  else
10077 -    {
10078 -      host_char_to_target_func = iconv_convert;
10079 -      host_char_to_target_baton = &cached_iconv_host_to_target;
10080 -    }
10081 +  struct wchar_iterator *result;
10082 +  iconv_t desc;
10083  
10084 -  if (t2h && t2h->convert_char)
10085 -    {
10086 -      target_char_to_host_func = t2h->convert_char;
10087 -      target_char_to_host_baton = t2h->convert_char_baton;
10088 -    }
10089 -  else if (host == target)
10090 -    target_char_to_host_func = identity_either_char_to_other;
10091 -  else
10092 -    {
10093 -      target_char_to_host_func = iconv_convert;
10094 -      target_char_to_host_baton = &cached_iconv_target_to_host;
10095 -    }
10096 +  desc = iconv_open ("wchar_t", charset);
10097 +  if (desc == (iconv_t) -1)
10098 +    perror_with_name ("Converting character sets");
10099  
10100 -  current_host_charset = host;
10101 -  current_target_charset = target;
10102 -}
10103 -
10104 -/* Do the real work of setting the host charset.  */
10105 -static void
10106 -set_host_charset (const char *charset)
10107 -{
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);
10111 -}
10112 +  result = XNEW (struct wchar_iterator);
10113 +  result->desc = desc;
10114 +  result->input = (char *) input;
10115 +  result->bytes = bytes;
10116 +  result->width = width;
10117  
10118 -/* Do the real work of setting the target charset.  */
10119 -static void
10120 -set_target_charset (const char *charset)
10121 -{
10122 -  struct charset *cs = lookup_charset_or_error (charset);
10123 +  result->out = XNEW (wchar_t);
10124 +  result->out_size = 1;
10125  
10126 -  set_host_and_target_charsets (current_host_charset, cs);
10127 +  return result;
10128  }
10129  
10130 -\f
10131 -/* 'Set charset', 'set host-charset', 'set target-charset', 'show
10132 -   charset' sfunc's.  */
10133 -
10134 -/* This is the sfunc for the 'set charset' command.  */
10135  static void
10136 -set_charset_sfunc (char *charset, int from_tty, struct cmd_list_element *c)
10137 +do_cleanup_iterator (void *p)
10138  {
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);
10144 -}
10145 +  struct wchar_iterator *iter = p;
10146  
10147 -/* 'set host-charset' command sfunc.  We need a wrapper here because
10148 -   the function needs to have a specific signature.  */
10149 -static void
10150 -set_host_charset_sfunc (char *charset, int from_tty,
10151 -                         struct cmd_list_element *c)
10152 -{
10153 -  set_host_charset (host_charset_name);
10154 +  iconv_close (iter->desc);
10155 +  xfree (iter->out);
10156 +  xfree (iter);
10157  }
10158  
10159 -/* Wrapper for the 'set target-charset' command.  */
10160 -static void
10161 -set_target_charset_sfunc (char *charset, int from_tty,
10162 -                           struct cmd_list_element *c)
10163 +struct cleanup *
10164 +make_cleanup_wchar_iterator (struct wchar_iterator *iter)
10165  {
10166 -  set_target_charset (target_charset_name);
10167 +  return make_cleanup (do_cleanup_iterator, iter);
10168  }
10169  
10170 -/* sfunc for the 'show charset' command.  */
10171 -static void
10172 -show_charset (struct ui_file *file, int from_tty, struct cmd_list_element *c,
10173 -             const char *name)
10174 -{
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 ());
10179 -  else
10180 +int
10181 +wchar_iterate (struct wchar_iterator *iter,
10182 +              enum wchar_iterate_result *out_result,
10183 +              wchar_t **out_chars,
10184 +              const gdb_byte **ptr,
10185 +              size_t *len)
10186 +{
10187 +  size_t out_request;
10188 +
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.  */
10194 +  out_request = 1;
10195 +  while (iter->bytes > 0)
10196      {
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);
10205 +      size_t num;
10206 +      wchar_t result;
10207 +
10208 +      size_t r = iconv (iter->desc, (char **) &iter->input, &iter->bytes,
10209 +                       &outptr, &out_avail);
10210 +      if (r == (size_t) -1)
10211 +       {
10212 +         switch (errno)
10213 +           {
10214 +           case EILSEQ:
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;
10222 +             return 0;
10223 +
10224 +           case E2BIG:
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))
10229 +               break;
10230 +
10231 +             ++out_request;
10232 +             if (out_request > iter->out_size)
10233 +               {
10234 +                 iter->out_size = out_request;
10235 +                 iter->out = xrealloc (iter->out,
10236 +                                       out_request * sizeof (wchar_t));
10237 +               }
10238 +             continue;
10239 +
10240 +           case EINVAL:
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;
10246 +             iter->bytes = 0;
10247 +             return 0;
10248 +
10249 +           default:
10250 +             perror_with_name ("Internal error while converting character sets");
10251 +           }
10252 +       }
10253 +
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;
10260 +      return num;
10261      }
10262 +
10263 +  /* Really done.  */
10264 +  *out_result = wchar_iterate_eof;
10265 +  return -1;
10266  }
10267  
10268  \f
10269 -/* Accessor functions.  */
10270 +/* The charset.c module initialization function.  */
10271  
10272 -const char *
10273 -host_charset (void)
10274 -{
10275 -  return current_host_charset->name;
10276 -}
10277 +extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
10278  
10279 -const char *
10280 -target_charset (void)
10281 -{
10282 -  return current_target_charset->name;
10283 -}
10284 +typedef char *char_ptr;
10285 +DEF_VEC_P (char_ptr);
10286  
10287 +static VEC (char_ptr) *charsets;
10288  
10289 -\f
10290 -/* Public character management functions.  */
10291 +#ifdef HAVE_ICONVLIST
10292  
10293 +/* A helper function that adds some character sets to the vector of
10294 +   all character sets.  This is a callback function for iconvlist.  */
10295  
10296 -const char *
10297 -c_target_char_has_backslash_escape (int target_char)
10298 +static int
10299 +add_one (unsigned int count, const char *const *names, void *data)
10300  {
10301 -  return ((*c_target_char_has_backslash_escape_func)
10302 -          (c_target_char_has_backslash_escape_baton, target_char));
10303 -}
10304 +  unsigned int i;
10305  
10306 +  for (i = 0; i < count; ++i)
10307 +    VEC_safe_push (char_ptr, charsets, xstrdup (names[i]));
10308  
10309 -int
10310 -c_parse_backslash (int host_char, int *target_char)
10311 -{
10312 -  return (*c_parse_backslash_func) (c_parse_backslash_baton,
10313 -                                    host_char, target_char);
10314 +  return 0;
10315  }
10316  
10317 -
10318 -int
10319 -host_char_print_literally (int host_char)
10320 +static void
10321 +find_charset_names (void)
10322  {
10323 -  return ((*current_host_charset->host_char_print_literally)
10324 -          (current_host_charset->host_char_print_literally_baton,
10325 -           host_char));
10326 +  iconvlist (add_one, NULL);
10327 +  VEC_safe_push (char_ptr, charsets, NULL);
10328  }
10329  
10330 +#else
10331  
10332 -int
10333 -target_char_to_control_char (int target_char, int *target_ctrl_char)
10334 +static void
10335 +find_charset_names (void)
10336  {
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));
10340 -}
10341 +  FILE *in;
10342  
10343 +  in = popen ("iconv -l", "r");
10344 +  /* It is ok to ignore errors; we'll fall back on a default.  */
10345 +  if (!in)
10346 +    return;
10347  
10348 -int
10349 -host_char_to_target (int host_char, int *target_char)
10350 -{
10351 -  return ((*host_char_to_target_func)
10352 -          (host_char_to_target_baton, host_char, target_char));
10353 -}
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))
10357 +    {
10358 +      /* The size of buf is chosen arbitrarily.  A character set name
10359 +        longer than this would not be very nice.  */
10360 +      char buf[80];
10361 +      int len;
10362 +      char *r = fgets (buf, sizeof (buf), in);
10363 +      if (!r)
10364 +       break;
10365 +      len = strlen (r);
10366 +      if (len <= 3)
10367 +       continue;
10368 +      if (buf[len - 2] == '/' && buf[len - 3] == '/')
10369 +       buf[len - 3] = '\0';
10370 +      VEC_safe_push (char_ptr, charsets, xstrdup (buf));
10371 +    }
10372  
10373 +  pclose (in);
10374  
10375 -int
10376 -target_char_to_host (int target_char, int *host_char)
10377 -{
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);
10381  }
10382  
10383 -
10384 -\f
10385 -/* The charset.c module initialization function.  */
10386 -
10387 -extern initialize_file_ftype _initialize_charset; /* -Wmissing-prototype */
10388 +#endif /* HAVE_ICONVLIST */
10389  
10390  void
10391  _initialize_charset (void)
10392  {
10393    struct cmd_list_element *new_cmd;
10394  
10395 -  /* Register all the character set GDB knows about.
10396 -
10397 -     You should use the same names that iconv does, where possible, to
10398 -     take advantage of the iconv-based default behaviors.
10399 -
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 ();
10414 -
10415 -  {
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 }
10429 -    };
10430 -
10431 -    int i;
10432 -
10433 -    for (i = 0; i < (sizeof (tlist) / sizeof (tlist[0])); i++)
10434 -      register_translation (simple_table_translation (tlist[i].from,
10435 -                                                      tlist[i].to,
10436 -                                                      tlist[i].table));
10437 -  }
10438 -
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 ();
10445 +
10446 +  if (VEC_length (char_ptr, charsets) > 1)
10447 +    charset_enum = default_charset_names;
10448 +  else
10449 +    charset_enum = (const char **) VEC_address (char_ptr, charsets);
10450 +
10451 +#ifdef HAVE_LANGINFO_CODESET
10452 +  auto_host_charset_name = nl_langinfo (CODESET);
10453 +  target_charset_name = auto_host_charset_name;
10454 +
10455 +  set_be_le_names ();
10456 +#endif
10457  
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);
10466  
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);
10475  
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);
10486 +
10487 +  add_setshow_enum_cmd ("target-wide-charset", class_support,
10488 +                       &charset_enum[1], &target_wide_charset_name,
10489 +                       _("\
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);
10501  }
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
10506 @@ -19,6 +19,7 @@
10507  #ifndef CHARSET_H
10508  #define CHARSET_H
10509  
10510 +#include <wchar.h>
10511  
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.
10517  
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.)
10527 -
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.
10531 -
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
10537 +   the like.  */
10538  
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
10541     it.  */
10542  const char *host_charset (void);
10543  const char *target_charset (void);
10544 -
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.
10548 -
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.  */
10553 -
10554 -
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,
10558 -   return zero.
10559 -
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);
10563 -
10564 -
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);
10570 -
10571 -
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);
10578 -
10579 -
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);
10584 -
10585 -
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);
10590 -
10591 -
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
10595 -   zero.  */
10596 -int target_char_to_control_char (int target_char, int *target_ctrl_char);
10597 -
10598 +const char *target_wide_charset (void);
10599 +
10600 +/* These values are used to specify the type of transliteration done
10601 +   by convert_between_encodings.  */
10602 +enum transliterations
10603 +  {
10604 +    /* Error on failure to convert.  */
10605 +    translit_none,
10606 +    /* Transliterate to host char.  */
10607 +    translit_char
10608 +  };
10609 +
10610 +/* Convert between two encodings.
10611 +
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
10619 +   character".
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);
10628 +
10629 +
10630 +/* These values are used by wchar_iterate to report errors.  */
10631 +enum wchar_iterate_result
10632 +  {
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,
10639 +    /* EOF.  */
10640 +    wchar_iterate_eof
10641 +  };
10642 +
10643 +/* Declaration of the opaque wchar iterator type.  */
10644 +struct wchar_iterator;
10645 +
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
10650 +   CHARSET.
10651 +   
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,
10657 +                                           size_t width);
10658 +
10659 +/* Return a new cleanup suitable for destroying the wchar iterator
10660 +   ITER.  */
10661 +struct cleanup *make_cleanup_wchar_iterator (struct wchar_iterator *iter);
10662 +
10663 +/* Perform a single iteration of a wchar_t iterator.
10664 +   
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.
10669 +
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
10672 +   converted.
10673 +
10674 +   A zero result means one of several unusual results.  *OUT_RESULT is
10675 +   set to indicate the type of un-ordinary return.
10676 +
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.
10680 +
10681 +   wchar_iterate_incomplete means that an incomplete character was
10682 +   seen at the end of the input sequence.
10683 +   
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);
10690 +
10691 +\f
10692 +
10693 +/* GDB needs to know a few details of its execution character set.
10694 +   This knowledge is isolated here and in charset.c.  */
10695 +
10696 +/* The escape character.  */
10697 +#define HOST_ESCAPE_CHAR 27
10698 +
10699 +/* Convert a letter, like 'c', to its corresponding control
10700 +   character.  */
10701 +char host_letter_to_control_character (char c);
10702 +
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);
10707  
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
10713 @@ -45,6 +45,8 @@
10714  #include "cli/cli-setshow.h"
10715  #include "cli/cli-cmds.h"
10716  
10717 +#include "python/python.h"
10718 +
10719  #ifdef TUI
10720  #include "tui/tui.h"           /* For tui_active et.al.   */
10721  #endif
10722 @@ -178,6 +180,7 @@ struct cmd_list_element *showchecklist;
10723  
10724  /* Command tracing state.  */
10725  
10726 +static int source_python = 0;
10727  int source_verbose = 0;
10728  int trace_commands = 0;
10729  \f
10730 @@ -439,6 +442,7 @@ source_script (char *file, int from_tty)
10731    struct cleanup *old_cleanups;
10732    char *full_pathname = NULL;
10733    int fd;
10734 +  int is_python;
10735  
10736    if (file == NULL || *file == 0)
10737      {
10738 @@ -471,8 +475,16 @@ source_script (char *file, int from_tty)
10739         }
10740      }
10741  
10742 +  is_python = source_python;
10743 +  if (strlen (file) > 3 && !strcmp (&file[strlen (file) - 3], ".py"))
10744 +    is_python = 1;
10745 +
10746    stream = fdopen (fd, FOPEN_RT);
10747 -  script_from_file (stream, file);
10748 +
10749 +  if (is_python)
10750 +    source_python_script (stream, file);
10751 +  else
10752 +    script_from_file (stream, file);
10753  
10754    do_cleanups (old_cleanups);
10755  }
10756 @@ -486,15 +498,30 @@ source_verbose_cleanup (void *old_value)
10757    xfree (old_value);
10758  }
10759  
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.  */
10763 +static int
10764 +find_argument (char **args)
10765 +{
10766 +  int result = 0;
10767 +  while (isspace ((*args)[0]))
10768 +    ++*args;
10769 +  if ((*args)[0] == '-' && isalpha ((*args)[1]))
10770 +    {
10771 +      result = (*args)[1];
10772 +      *args += 3;
10773 +    }
10774 +  return result;
10775 +}
10776 +
10777  static void
10778  source_command (char *args, int from_tty)
10779  {
10780    struct cleanup *old_cleanups;
10781 -  char *file = args;
10782 -  int *old_source_verbose = xmalloc (sizeof(int));
10783  
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);
10788  
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)
10792  
10793    if (args)
10794      {
10795 -      /* Make sure leading white space does not break the comparisons.  */
10796 -      while (isspace(args[0]))
10797 -       args++;
10798 -
10799 -      /* Is -v the first thing in the string?  */
10800 -      if (args[0] == '-' && args[1] == 'v' && isspace (args[2]))
10801 +      while (1)
10802         {
10803 -         source_verbose = 1;
10804 -
10805 -         /* Trim -v and whitespace from the filename.  */
10806 -         file = &args[3];
10807 -         while (isspace (file[0]))
10808 -           file++;
10809 +         int arg = find_argument (&args);
10810 +         if (!arg)
10811 +           break;
10812 +         switch (arg)
10813 +           {
10814 +           case 'v':
10815 +             source_verbose = 1;
10816 +             break;
10817 +           case 'p':
10818 +             source_python = 1;
10819 +             break;
10820 +           default:
10821 +             error (_("unrecognized option -%c"), arg);
10822 +           }
10823         }
10824      }
10825  
10826 -  source_script (file, from_tty);
10827 +  source_script (args, from_tty);
10828 +
10829 +  do_cleanups (old_cleanups);
10830  }
10831  
10832  
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)
10849  
10850        if (VALUE_LVAL (val))
10851         {
10852 -         vaddr = VALUE_ADDRESS (val);
10853 +         vaddr = value_address (val);
10854         }
10855        else
10856         {
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.  */
10863    if (type == NULL)
10864      {
10865 -      type = alloc_type (current_objfile);
10866 +      type = alloc_type (current_objfile, NULL);
10867        *type_addr = type;
10868      }
10869    return type;
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
10882 @@ -42,6 +42,12 @@
10883     language is requested. */
10884  #undef ENABLE_NLS
10885  
10886 +/* Global directory for GDB data files. */
10887 +#undef GDB_DATADIR
10888 +
10889 +/* Define if GDB datadir should be relocated when GDB is moved. */
10890 +#undef GDB_DATADIR_RELOCATABLE
10891 +
10892  /* Define to be a string naming the default host character set. */
10893  #undef GDB_DEFAULT_HOST_CHARSET
10894  
10895 @@ -169,12 +175,18 @@
10896  /* Define if you have the iconv() function. */
10897  #undef HAVE_ICONV
10898  
10899 +/* Define to 1 if you have the `iconvlist' function. */
10900 +#undef HAVE_ICONVLIST
10901 +
10902  /* Define if your compiler supports the #include_next directive. */
10903  #undef HAVE_INCLUDE_NEXT
10904  
10905  /* Define to 1 if you have the <inttypes.h> header file. */
10906  #undef HAVE_INTTYPES_H
10907  
10908 +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
10909 +#undef HAVE_LANGINFO_CODESET
10910 +
10911  /* Define if your <locale.h> file defines LC_MESSAGES. */
10912  #undef HAVE_LC_MESSAGES
10913  
10914 @@ -618,6 +630,9 @@
10915     'ptrdiff_t'. */
10916  #undef PTRDIFF_T_SUFFIX
10917  
10918 +/* Define to install path for Python sources */
10919 +#undef PYTHONDIR
10920 +
10921  /* Bug reporting address */
10922  #undef REPORT_BUGS_TO
10923  
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'
10935  ac_pwd=`pwd`
10936  
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
10942 +                          [DATADIR/gdb]
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
10957  
10958  Some influential environment variables:
10959    CC          C compiler command
10960 @@ -7130,6 +7134,75 @@ _ACEOF
10961    ;;
10962  esac
10963  
10964 +# GDB's datadir relocation
10965 +
10966 +gdbdatadir=${datadir}/gdb
10967 +
10968 +
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}"
10973 +fi;
10974 +
10975 +
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`
10980 +
10981 +cat >>confdefs.h <<_ACEOF
10982 +#define GDB_DATADIR "$ac_define_dir"
10983 +_ACEOF
10984 +
10985 +
10986 +
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
10990 +  else
10991 +    test_prefix=$prefix
10992 +  fi
10993 +else
10994 +  test_prefix=$exec_prefix
10995 +fi
10996 +
10997 +case ${gdbdatadir} in
10998 +  "${test_prefix}"|"${test_prefix}/"*|\
10999 +  '${exec_prefix}'|'${exec_prefix}/'*)
11000 +
11001 +cat >>confdefs.h <<\_ACEOF
11002 +#define GDB_DATADIR_RELOCATABLE 1
11003 +_ACEOF
11004 +
11005 +  ;;
11006 +esac
11007 +GDB_DATADIR_PATH=${gdbdatadir}
11008 +
11009 +
11010 +
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}"
11015 +else
11016 +  pythondir=no
11017 +fi;
11018 +
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'
11023 +else
11024 +
11025 +cat >>confdefs.h <<_ACEOF
11026 +#define PYTHONDIR "$pythondir"
11027 +_ACEOF
11028 +
11029 +fi
11030 +
11031 +
11032 +
11033  
11034  
11035  subdirs="$subdirs doc testsuite"
11036 @@ -9989,6 +10062,226 @@ if test "$ac_cv_search_dlgetmodinfo" != no; then
11037  fi
11038  
11039  
11040 +
11041 +
11042 +
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"
11046 +
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
11050 +    done
11051 +
11052 +fi;
11053 +
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
11058 +else
11059 +
11060 +    am_cv_func_iconv="no, consider installing GNU libiconv"
11061 +    am_cv_lib_iconv=no
11062 +    cat >conftest.$ac_ext <<_ACEOF
11063 +/* confdefs.h.  */
11064 +_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>
11070 +int
11071 +main ()
11072 +{
11073 +iconv_t cd = iconv_open("","");
11074 +       iconv(cd,NULL,NULL,NULL,NULL);
11075 +       iconv_close(cd);
11076 +  ;
11077 +  return 0;
11078 +}
11079 +_ACEOF
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
11083 +  ac_status=$?
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
11093 +  ac_status=$?
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
11099 +  ac_status=$?
11100 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
11101 +  (exit $ac_status); }; }; then
11102 +  am_cv_func_iconv=yes
11103 +else
11104 +  echo "$as_me: failed program was:" >&5
11105 +sed 's/^/| /' conftest.$ac_ext >&5
11106 +
11107 +fi
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
11114 +/* confdefs.h.  */
11115 +_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>
11121 +int
11122 +main ()
11123 +{
11124 +iconv_t cd = iconv_open("","");
11125 +         iconv(cd,NULL,NULL,NULL,NULL);
11126 +         iconv_close(cd);
11127 +  ;
11128 +  return 0;
11129 +}
11130 +_ACEOF
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
11134 +  ac_status=$?
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
11144 +  ac_status=$?
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
11150 +  ac_status=$?
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
11155 +else
11156 +  echo "$as_me: failed program was:" >&5
11157 +sed 's/^/| /' conftest.$ac_ext >&5
11158 +
11159 +fi
11160 +rm -f conftest.err conftest.$ac_objext \
11161 +      conftest$ac_exeext conftest.$ac_ext
11162 +      LIBS="$am_save_LIBS"
11163 +    fi
11164 +
11165 +fi
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
11169 +
11170 +cat >>confdefs.h <<\_ACEOF
11171 +#define HAVE_ICONV 1
11172 +_ACEOF
11173 +
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
11178 +else
11179 +
11180 +      cat >conftest.$ac_ext <<_ACEOF
11181 +/* confdefs.h.  */
11182 +_ACEOF
11183 +cat confdefs.h >>conftest.$ac_ext
11184 +cat >>conftest.$ac_ext <<_ACEOF
11185 +/* end confdefs.h.  */
11186 +
11187 +#include <stdlib.h>
11188 +#include <iconv.h>
11189 +extern
11190 +#ifdef __cplusplus
11191 +"C"
11192 +#endif
11193 +#if defined(__STDC__) || defined(__cplusplus)
11194 +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
11195 +#else
11196 +size_t iconv();
11197 +#endif
11198 +
11199 +int
11200 +main ()
11201 +{
11202 +
11203 +  ;
11204 +  return 0;
11205 +}
11206 +_ACEOF
11207 +rm -f conftest.$ac_objext
11208 +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
11209 +  (eval $ac_compile) 2>conftest.er1
11210 +  ac_status=$?
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
11220 +  ac_status=$?
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
11226 +  ac_status=$?
11227 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
11228 +  (exit $ac_status); }; }; then
11229 +  am_cv_proto_iconv_arg1=""
11230 +else
11231 +  echo "$as_me: failed program was:" >&5
11232 +sed 's/^/| /' conftest.$ac_ext >&5
11233 +
11234 +am_cv_proto_iconv_arg1="const"
11235 +fi
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);"
11238 +fi
11239 +
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
11245 +
11246 +cat >>confdefs.h <<_ACEOF
11247 +#define ICONV_CONST $am_cv_proto_iconv_arg1
11248 +_ACEOF
11249 +
11250 +  fi
11251 +  LIBICONV=
11252 +  if test "$am_cv_lib_iconv" = yes; then
11253 +    LIBICONV="-liconv"
11254 +  fi
11255 +
11256 +
11257 +
11258 +
11259 +
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)"
11270  
11271    # Flags needed to compile Python code (taken from python-config --cflags).
11272 @@ -15445,10 +15740,11 @@ fi
11273  
11274  
11275  
11276 +
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
11282  do
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
11286  done
11287  
11288  
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
11293 +else
11294 +  cat >conftest.$ac_ext <<_ACEOF
11295 +/* confdefs.h.  */
11296 +_ACEOF
11297 +cat confdefs.h >>conftest.$ac_ext
11298 +cat >>conftest.$ac_ext <<_ACEOF
11299 +/* end confdefs.h.  */
11300 +#include <langinfo.h>
11301 +int
11302 +main ()
11303 +{
11304 +char* cs = nl_langinfo(CODESET);
11305 +  ;
11306 +  return 0;
11307 +}
11308 +_ACEOF
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
11312 +  ac_status=$?
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
11322 +  ac_status=$?
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
11328 +  ac_status=$?
11329 +  echo "$as_me:$LINENO: \$? = $ac_status" >&5
11330 +  (exit $ac_status); }; }; then
11331 +  am_cv_langinfo_codeset=yes
11332 +else
11333 +  echo "$as_me: failed program was:" >&5
11334 +sed 's/^/| /' conftest.$ac_ext >&5
11335 +
11336 +am_cv_langinfo_codeset=no
11337 +fi
11338 +rm -f conftest.err conftest.$ac_objext \
11339 +      conftest$ac_exeext conftest.$ac_ext
11340 +
11341 +fi
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
11345 +
11346 +cat >>confdefs.h <<\_ACEOF
11347 +#define HAVE_LANGINFO_CODESET 1
11348 +_ACEOF
11349 +
11350 +  fi
11351 +
11352 +
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
11357  
11358  
11359  
11360 -
11361  cat >>confdefs.h <<\_ACEOF
11362 -#define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
11363 +#define GDB_DEFAULT_HOST_CHARSET "UTF-8"
11364  _ACEOF
11365  
11366  
11367 -
11368 -
11369 -
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"
11373 -
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
11377 -    done
11378 -
11379 -fi;
11380 -
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
11385 -else
11386 -
11387 -    am_cv_func_iconv="no, consider installing GNU libiconv"
11388 -    am_cv_lib_iconv=no
11389 -    cat >conftest.$ac_ext <<_ACEOF
11390 -/* confdefs.h.  */
11391 -_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>
11397 -int
11398 -main ()
11399 -{
11400 -iconv_t cd = iconv_open("","");
11401 -       iconv(cd,NULL,NULL,NULL,NULL);
11402 -       iconv_close(cd);
11403 -  ;
11404 -  return 0;
11405 -}
11406 -_ACEOF
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
11410 -  ac_status=$?
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
11420 -  ac_status=$?
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
11426 -  ac_status=$?
11427 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
11428 -  (exit $ac_status); }; }; then
11429 -  am_cv_func_iconv=yes
11430 -else
11431 -  echo "$as_me: failed program was:" >&5
11432 -sed 's/^/| /' conftest.$ac_ext >&5
11433 -
11434 -fi
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
11441 -/* confdefs.h.  */
11442 -_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>
11448 -int
11449 -main ()
11450 -{
11451 -iconv_t cd = iconv_open("","");
11452 -         iconv(cd,NULL,NULL,NULL,NULL);
11453 -         iconv_close(cd);
11454 -  ;
11455 -  return 0;
11456 -}
11457 -_ACEOF
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
11461 -  ac_status=$?
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
11471 -  ac_status=$?
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
11477 -  ac_status=$?
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
11482 -else
11483 -  echo "$as_me: failed program was:" >&5
11484 -sed 's/^/| /' conftest.$ac_ext >&5
11485 -
11486 -fi
11487 -rm -f conftest.err conftest.$ac_objext \
11488 -      conftest$ac_exeext conftest.$ac_ext
11489 -      LIBS="$am_save_LIBS"
11490 -    fi
11491 -
11492 -fi
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
11496 -
11497 -cat >>confdefs.h <<\_ACEOF
11498 -#define HAVE_ICONV 1
11499 -_ACEOF
11500 -
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
11505 -else
11506 -
11507 -      cat >conftest.$ac_ext <<_ACEOF
11508 -/* confdefs.h.  */
11509 -_ACEOF
11510 -cat confdefs.h >>conftest.$ac_ext
11511 -cat >>conftest.$ac_ext <<_ACEOF
11512 -/* end confdefs.h.  */
11513 -
11514 -#include <stdlib.h>
11515 -#include <iconv.h>
11516 -extern
11517 -#ifdef __cplusplus
11518 -"C"
11519 -#endif
11520 -#if defined(__STDC__) || defined(__cplusplus)
11521 -size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
11522 -#else
11523 -size_t iconv();
11524 -#endif
11525 -
11526 -int
11527 -main ()
11528 -{
11529 -
11530 -  ;
11531 -  return 0;
11532 -}
11533 -_ACEOF
11534 -rm -f conftest.$ac_objext
11535 -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
11536 -  (eval $ac_compile) 2>conftest.er1
11537 -  ac_status=$?
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
11547 -  ac_status=$?
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
11553 -  ac_status=$?
11554 -  echo "$as_me:$LINENO: \$? = $ac_status" >&5
11555 -  (exit $ac_status); }; }; then
11556 -  am_cv_proto_iconv_arg1=""
11557 -else
11558 -  echo "$as_me: failed program was:" >&5
11559 -sed 's/^/| /' conftest.$ac_ext >&5
11560 -
11561 -am_cv_proto_iconv_arg1="const"
11562 -fi
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);"
11565 -fi
11566 -
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
11572 -
11573 -cat >>confdefs.h <<_ACEOF
11574 -#define ICONV_CONST $am_cv_proto_iconv_arg1
11575 -_ACEOF
11576 -
11577 -  fi
11578 -  LIBICONV=
11579 -  if test "$am_cv_lib_iconv" = yes; then
11580 -    LIBICONV="-liconv"
11581 -  fi
11582 -
11583 -
11584 -
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
11599  s,@MIG@,$MIG,;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
11619 @@ -1,6 +1,6 @@
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.
11625  dnl
11626  dnl This file is part of GDB.
11627 @@ -118,6 +118,51 @@ case ${debugdir} in
11628    ;;
11629  esac
11630  
11631 +# GDB's datadir relocation
11632 +
11633 +gdbdatadir=${datadir}/gdb
11634 +
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}"])
11638 +
11639 +AC_DEFINE_DIR(GDB_DATADIR, gdbdatadir,
11640 +              [Global directory for GDB data files. ])
11641 +
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
11645 +  else
11646 +    test_prefix=$prefix
11647 +  fi
11648 +else
11649 +  test_prefix=$exec_prefix
11650 +fi
11651 +
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.])
11656 +  ;;
11657 +esac
11658 +GDB_DATADIR_PATH=${gdbdatadir}
11659 +AC_SUBST(GDB_DATADIR_PATH)
11660 +
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])
11664 +
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'
11669 +else
11670 +  AC_DEFINE_UNQUOTED(PYTHONDIR, "$pythondir",
11671 +      [Define to install path for Python sources])
11672 +fi
11673 +AC_SUBST(pythondir)
11674 +
11675 +
11676  AC_CONFIG_SUBDIRS(doc testsuite)
11677  
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])
11682  
11683 +AM_ICONV
11684 +
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)"
11695  
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
11704  
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)
11708  AC_EXEEXT
11709  
11710  dnl  Detect the character set used by this host.
11711 -
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.])
11721  
11722 -AM_ICONV
11723 -
11724  AC_OUTPUT(Makefile .gdbinit:gdbinit.in gnulib/Makefile,
11725  [
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*)
11732  alpha*-*-linux*)
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"
11737         ;;
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"
11746         ;;
11747  
11748  arm*-wince-pe | arm*-*-mingw32ce*)
11749 @@ -128,7 +128,7 @@ hppa*-*-hpux*)
11750  hppa*-*-linux*)
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"
11755         ;;
11756  hppa*-*-netbsd*)
11757         # Target: NetBSD/hppa
11758 @@ -218,7 +218,7 @@ i[34567]86-*-*)
11759  ia64-*-linux*)
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
11765         ;;
11766  ia64*-*-*)
11767 @@ -242,7 +242,8 @@ m32c-*-*)
11768  m32r*-*-linux*)
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 \
11773 +                       linux-tdep.o"
11774         gdb_sim=../sim/m32r/libsim.a
11775         build_gdbserver=yes
11776         ;;
11777 @@ -267,7 +268,7 @@ fido-*-elf*)
11778  m68*-*-linux*)
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
11784         ;;
11785  m68*-*-netbsd* | m68*-*-knetbsd*-gnu)
11786 @@ -303,7 +304,8 @@ mips*-sgi-irix6*)
11787  mips*-*-linux*)
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 \
11792 +                       linux-tdep.o"
11793         gdb_sim=../sim/mips/libsim.a
11794         build_gdbserver=yes
11795         ;;
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 \
11802 +                       linux-tdep.o"
11803         gdb_sim=../sim/ppc/libsim.a
11804         build_gdbserver=yes
11805         ;;
11806 @@ -381,7 +384,8 @@ score-*-*)
11807  sh*-*-linux*)
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 \
11812 +                       linux-tdep.o"
11813         gdb_sim=../sim/sh/libsim.a
11814         build_gdbserver=yes
11815         ;;
11816 @@ -409,13 +413,14 @@ sh*)
11817  sparc-*-linux*)
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 \
11822 +                       linux-tdep.o"
11823         ;;
11824  sparc64-*-linux*)
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
11831         ;;
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 \
11839 +                       linux-tdep.o"
11840         build_gdbserver=yes
11841         ;;
11842  xtensa*)
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
11847 @@ -1,7 +1,6 @@
11848  /* YACC parser for C++ names, for GDB.
11849  
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.
11853  
11854     Parts of the lexer are based on c-exp.y from GDB.
11855  
11856 @@ -501,7 +500,7 @@ operator    :       OPERATOR NEW
11857                 |       OPERATOR ARROW
11858                         { $$ = make_operator ("->", 2); }
11859                 |       OPERATOR '(' ')'
11860 -                       { $$ = make_operator ("()", 0); }
11861 +                       { $$ = make_operator ("()", 2); }
11862                 |       OPERATOR '[' ']'
11863                         { $$ = make_operator ("[]", 2); }
11864                 ;
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"
11872  #include "frame.h"
11873 +#include "buildsym.h"
11874  
11875  /* List of using directives that are active in the current file.  */
11876  
11877 -static struct using_direct *using_list;
11878 -
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);
11883 -
11884  static struct using_direct *cp_copy_usings (struct using_direct *using,
11885                                             struct obstack *obstack);
11886  
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,
11892 -                                             int scope_len);
11893 -
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);
11898  
11899  static void maintenance_cplus_namespace (char *args, int from_tty);
11900  
11901 -/* Set up support for dealing with C++ namespace info in the current
11902 -   symtab.  */
11903 -
11904 -void cp_initialize_namespace ()
11905 -{
11906 -  using_list = NULL;
11907 -}
11908 -
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.  */
11912 -
11913 -void
11914 -cp_finalize_namespace (struct block *static_block,
11915 -                      struct obstack *obstack)
11916 -{
11917 -  if (using_list != NULL)
11918 -    {
11919 -      block_set_using (static_block,
11920 -                      cp_copy_usings (using_list, obstack),
11921 -                      obstack);
11922 -      using_list = NULL;
11923 -    }
11924 -}
11925 -
11926  /* Check to see if SYMBOL refers to an object contained within an
11927     anonymous namespace; if so, add an appropriate using directive.  */
11928  
11929 @@ -136,14 +98,17 @@ cp_scan_for_anonymous_namespaces (const struct symbol *symbol)
11930                           "(anonymous namespace)",
11931                           ANONYMOUS_NAMESPACE_LEN) == 0)
11932             {
11933 +             int outer_len = (previous_component == 0 ? 0 : previous_component - 2);
11934 +             char outer[outer_len+1];
11935 +             
11936 +             strncpy(outer, name, outer_len);
11937 +             
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,
11946 -                                     next_component);
11947 +             cp_add_using_directive (outer, name, "", "", 0);
11948             }
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)
11952      }
11953  }
11954  
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
11960 -   twice.  */
11961 +/* Add a using directive to using_list. If the using directive in question
11962 +   has already been added, don't add it twice.  */
11963  
11964  void
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)
11969  {
11970    struct using_direct *current;
11971    struct using_direct *new;
11972  
11973    /* Has it already been added?  */
11974  
11975 -  for (current = using_list; current != NULL; current = current->next)
11976 +  for (current = using_directives; current != NULL; current = current->next)
11977      {
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)
11983         return;
11984      }
11985  
11986 -  using_list = cp_add_using (name, inner_length, outer_length,
11987 -                            using_list);
11988 +  using_directives = cp_add_using (outer, inner, alias, declaration,
11989 +      line_number,using_directives);
11990  }
11991  
11992  /* Record the namespace that the function defined by SYMBOL was
11993 @@ -230,26 +190,31 @@ cp_is_anonymous (const char *namespace)
11994           != NULL);
11995  }
11996  
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
12006     string.  */
12007  
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)
12019  {
12020    struct using_direct *retval;
12021  
12022 -  gdb_assert (outer_len < inner_len);
12023 -
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;
12032 +        
12033    retval->next = next;
12034  
12035    return retval;
12036 @@ -274,11 +239,17 @@ cp_copy_usings (struct using_direct *using,
12037        retval->inner = obsavestring (using->inner, strlen (using->inner),
12038                                     obstack);
12039        retval->outer = obsavestring (using->outer, strlen (using->outer),
12040 -                                   obstack);
12041 +                                    obstack);
12042 +      retval->alias = obsavestring (using->alias, strlen (using->alias),
12043 +                                    obstack);
12044 +      retval->declaration = obsavestring (using->declaration, strlen (using->declaration),
12045 +                                    obstack);
12046        retval->next = cp_copy_usings (using->next, obstack);
12047  
12048        xfree (using->inner);
12049        xfree (using->outer);
12050 +      xfree (using->alias);
12051 +      xfree (using->declaration);
12052        xfree (using);
12053  
12054        return retval;
12055 @@ -299,8 +270,14 @@ cp_lookup_symbol_nonlocal (const char *name,
12056                            const struct block *block,
12057                            const domain_enum domain)
12058  {
12059 -  return lookup_namespace_scope (name, linkage_name, block, domain,
12060 -                                block_scope (block), 0);
12061 +
12062 +  struct symbol* sym = lookup_namespace_scope(name, linkage_name, block,
12063 +      domain, block_scope(block), 0);
12064 +
12065 +  if (sym != NULL)
12066 +    return sym;
12067 +
12068 +  return lookup_symbol_file(name, linkage_name, block, domain, 0);
12069  }
12070  
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
12074     "x".  */
12075  
12076 -static struct symbol *
12077 +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,
12087                                      block, domain);
12088  }
12089  
12090 +/* Searches the for the given NAME in the given NAMESPACE, using import 
12091 +   statements implied by the given BLOCK, *and its' parents*. */
12092 +struct symbol *
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)
12098 +{
12099 +  struct symbol *sym;
12100 +  const struct block *global_block = block_global_block (block);
12101 +
12102 +  /* Check if either no block is specified or it's a global block.  */
12103 +
12104 +  if (global_block == NULL)
12105 +    return NULL;
12106 +
12107 +  while (block != global_block)
12108 +    {
12109 +      sym = cp_lookup_symbol_namespace (namespace, name, linkage_name, block, domain);
12110 +
12111 +      if (sym != NULL)
12112 +        return sym;
12113 +
12114 +      block = BLOCK_SUPERBLOCK (block);
12115 +    }
12116 +
12117 +  /* We've reached the global block without finding a result.  */
12118 +
12119 +  return NULL;
12120 +}
12121 +
12122 +
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)
12128  {
12129    const struct using_direct *current;
12130 -  struct symbol *sym;
12131 +  struct symbol *sym = NULL;
12132  
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,
12136         current != NULL;
12137         current = current->next)
12138      {
12139 -      if (strcmp (namespace, current->outer) == 0)
12140 +      
12141 +      int current_line = find_pc_line (get_frame_pc (get_current_frame ()), 0).line;
12142 +      
12143 +      if (strcmp (namespace, current->outer) == 0 && current->line_number < current_line)
12144         {
12145 -         sym = cp_lookup_symbol_namespace (current->inner,
12146 -                                           name,
12147 -                                           linkage_name,
12148 -                                           block,
12149 -                                           domain);
12150 -         if (sym != NULL)
12151 +         
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)
12157 +           {
12158 +           if(strcmp (name, current->declaration) == 0){
12159 +             sym = cp_lookup_symbol_namespace (current->inner,
12160 +                                               name,
12161 +                                               linkage_name,
12162 +                                               block,
12163 +                                               domain);
12164 +           }
12165 +          
12166 +           }
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 */
12171 +           {
12172 +           sym = cp_lookup_symbol_namespace (namespace,
12173 +                                             current->inner,
12174 +                                             linkage_name,
12175 +                                             block,
12176 +                                             domain);
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,
12181 +                                               name,
12182 +                                               linkage_name,
12183 +                                               block,
12184 +                                               domain);
12185 +           }
12186 +
12187 +         if (sym != NULL){
12188             return sym;
12189 +         }
12190         }
12191      }
12192  
12193 @@ -398,8 +443,10 @@ cp_lookup_symbol_namespace (const char *namespace,
12194    
12195    if (namespace[0] == '\0')
12196      {
12197 -      return lookup_symbol_file (name, linkage_name, block,
12198 -                                domain, 0);
12199 +      sym = lookup_symbol_file (name, linkage_name,
12200 +                                     block, domain, 
12201 +                                     cp_is_anonymous (namespace));
12202 +      return sym;
12203      }
12204    else
12205      {
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,
12211    return ret;
12212  }
12213  
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.  */
12217  
12218  char *
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;
12225  
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
12230 -   the list.  */
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;
12235 +   ALIAS = "C"
12236 +   DECLARATION is the name of the imported declaration, if this import 
12237 +   statement represents one. Eg:
12238 +       using A::x;
12239 +   Where x is variable in namespace A. declaration is set to x.  
12240 +*/
12241  
12242  struct using_direct
12243  {
12244    char *inner;
12245    char *outer;
12246 +  
12247 +  char *alias;
12248 +  
12249 +  char *declaration;
12250 +  
12251 +  int line_number;
12252 +  
12253    struct using_direct *next;
12254  };
12255  
12256 @@ -54,6 +68,7 @@ struct using_direct
12257  
12258  extern char *cp_canonicalize_string (const char *string);
12259  
12260 +
12261  extern char *cp_class_name_from_physname (const char *physname);
12262  
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,
12265  
12266  extern int cp_is_anonymous (const char *namespace);
12267  
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);
12276 +
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);
12283  
12284  extern void cp_initialize_namespace (void);
12285  
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);
12289  
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,
12295 +                                              int scope_len);
12296 +
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);
12302 +
12303  extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
12304                                                   const char *name,
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)
12312      {
12313        CORE_ADDR *first_dont_print;
12314 +      CORE_ADDR addr;
12315        int i;
12316  
12317        first_dont_print
12318 @@ -470,7 +471,7 @@ cp_print_static_field (struct type *type,
12319  
12320        while (--i >= 0)
12321         {
12322 -         if (VALUE_ADDRESS (val) == first_dont_print[i])
12323 +         if (value_address (val) == first_dont_print[i])
12324             {
12325               fputs_filtered ("<same as static member of an already"
12326                               " seen type>",
12327 @@ -479,12 +480,13 @@ cp_print_static_field (struct type *type,
12328             }
12329         }
12330  
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));
12335  
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);
12341        return;
12342      }
12343 @@ -492,7 +494,7 @@ cp_print_static_field (struct type *type,
12344    opts = *options;
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);
12350  }
12351  
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
12356 @@ -1,6 +1,6 @@
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.
12362  
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;
12367    int text_size;
12368 +  char *sym_name;
12369 +  int sym_len;
12370  
12371    char *namestring;
12372    int nsl;
12373 @@ -1681,6 +1683,28 @@ pos %d"),
12374           if (!p)
12375             continue;                   /* Not a debugging symbol.   */
12376  
12377 +         sym_len = 0;
12378 +         if (psymtab_language == language_cplus)
12379 +           {
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)
12385 +               {
12386 +                 sym_len = strlen (new_name);
12387 +                 sym_name = obsavestring (new_name, sym_len,
12388 +                                          &objfile->objfile_obstack);
12389 +                 xfree (new_name);
12390 +               }
12391 +           }
12392 +
12393 +         if (sym_len == 0)
12394 +           {
12395 +             sym_name = namestring;
12396 +             sym_len = p - namestring;
12397 +           }
12398 +
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,
12404                                                             namestring);
12405  
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,
12410                                    0, nlist.n_value,
12411 @@ -1710,7 +1734,7 @@ pos %d"),
12412                                          data_sect_index);
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,
12419                                    0, nlist.n_value,
12420 @@ -1728,7 +1752,7 @@ pos %d"),
12421                   || (p == namestring + 1
12422                       && namestring[0] != ' '))
12423                 {
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,
12428                                        nlist.n_value, 0,
12429 @@ -1736,7 +1760,7 @@ pos %d"),
12430                   if (p[2] == 't')
12431                     {
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,
12437                                            nlist.n_value, 0,
12438 @@ -1749,7 +1773,7 @@ pos %d"),
12439             case 't':
12440               if (p != namestring)      /* a name is there, not just :T... */
12441                 {
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,
12446                                        nlist.n_value, 0,
12447 @@ -1829,7 +1853,7 @@ pos %d"),
12448  
12449             case 'c':
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;
12459                 }
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,
12464                                    0, nlist.n_value,
12465 @@ -1961,7 +1985,7 @@ pos %d"),
12466                   pst->textlow = nlist.n_value;
12467                   textlow_not_set = 0;
12468                 }
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,
12473                                    0, nlist.n_value,
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
12481                               internal form */
12482 diff --git a/gdb/defs.h b/gdb/defs.h
12483 index 845b320..ad6e7d7 100644
12484 --- a/gdb/defs.h
12485 +++ b/gdb/defs.h
12486 @@ -151,6 +151,9 @@ extern int dbx_commands;
12487  /* System root path, used to find libraries etc.  */
12488  extern char *gdb_sysroot;
12489  
12490 +/* GDB datadir, used to store data files.  */
12491 +extern char *gdb_datadir;
12492 +
12493  /* Search path for separate debug files.  */
12494  extern char *debug_file_directory;
12495  
12496 @@ -366,6 +369,9 @@ extern struct cleanup *make_cleanup_fclose (FILE *file);
12497  
12498  extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
12499  
12500 +struct obstack;
12501 +extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
12502 +
12503  extern struct cleanup *make_cleanup_restore_integer (int *variable);
12504  
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
12510 @@ -14,8 +14,8 @@
12511  
12512  2009-02-14  Vladimir Prus  <vladimir@codesourcery.com>
12513  
12514 -        * observer.texi: Add parameter 'print_frame' to normal_stop
12515 -        observer.
12516 +       * observer.texi: Add parameter 'print_frame' to normal_stop
12517 +       observer.
12518  
12519  2009-02-07  Eli Zaretskii  <eliz@gnu.org>
12520  
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}
12528  @cindex @code{-x}
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}.
12535  
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.
12541  
12542 +@item -P
12543 +@cindex @code{-P}
12544 +@itemx --python
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.
12551 +
12552  @c resolve the situation of these eventually
12553  @item -tui
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.
12558  
12559 +@item syscall
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.
12564 +
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.
12569 +
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
12572 +calls.
12573 +
12574 +The example below illustrates how this command works if you don't provide
12575 +arguments to it:
12576 +
12577 +@smallexample
12578 +(@value{GDBP}) catch syscall
12579 +Catchpoint 1 (syscall)
12580 +(@value{GDBP}) r
12581 +Starting program: /tmp/catch-syscall
12582 +
12583 +Catchpoint 1 (call to syscall 'close'), 0xffffe424 in __kernel_vsyscall ()
12584 +(@value{GDBP}) c
12585 +Continuing.
12586 +
12587 +Catchpoint 1 (returned from syscall 'close'), 0xffffe424 in __kernel_vsyscall ()
12588 +(@value{GDBP})
12589 +@end smallexample
12590 +
12591 +Here is an example of catching a system call by name:
12592 +
12593 +@smallexample
12594 +(@value{GDBP}) catch syscall chroot
12595 +Catchpoint 1 (syscall(s) 'chroot')
12596 +(@value{GDBP}) r
12597 +Starting program: /tmp/catch-syscall
12598 +
12599 +Catchpoint 1 (call to syscall 'chroot'), 0xffffe424 in __kernel_vsyscall ()
12600 +(@value{GDBP}) c
12601 +Continuing.
12602 +
12603 +Catchpoint 1 (returned from syscall 'chroot'), 0xffffe424 in __kernel_vsyscall ()
12604 +(@value{GDBP})
12605 +@end smallexample
12606 +
12607 +And last but not least, an example of specifying a system call
12608 +numerically:
12609 +
12610 +@smallexample
12611 +(@value{GDBP}) catch syscall 252
12612 +Catchpoint 1 (syscall(s) 'exit_group')
12613 +(@value{GDBP}) r
12614 +Starting program: /tmp/catch-syscall
12615 +
12616 +Catchpoint 1 (call to syscall 'exit_group'), 0xffffe424 in __kernel_vsyscall ()
12617 +(@value{GDBP}) c
12618 +Continuing.
12619 +
12620 +Program exited normally.
12621 +(@value{GDBP})
12622 +@end smallexample
12623 +
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:
12629 +
12630 +@smallexample
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)
12636 +(@value{GDBP})
12637 +@end smallexample
12638 +
12639 +Of course, the file name will change depending on your architecture and system.
12640 +
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:
12643 +
12644 +@smallexample
12645 +(@value{GDBP}) catch syscall 252
12646 +Catchpoint 1 (syscall(s) 252)
12647 +@end smallexample
12648 +
12649 +Again, in this case @value{GDBN} would not be able to display syscall's names.
12650 +
12651  @item fork
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.
12657  
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:
12661 +
12662 +@table @code
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.
12671 +@end table
12672 +
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.
12675 +
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}.
12681  @end table
12682  
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.
12687 -
12688  @node Thread-Specific Breakpoints
12689  @subsection Thread-Specific Breakpoints
12690  
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
12694  array.
12695 +
12696 +@item r
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.
12701  @end table
12702  
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.
12707  
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
12713 +@value{GDBN}.
12714 +
12715 +@table @code
12716 +@item help function
12717 +@kindex help function
12718 +@cindex show all convenience functions
12719 +Print a list of all convenience functions.
12720 +@end table
12721 +
12722  @node Registers
12723  @section Registers
12724  
12725 @@ -7931,13 +8068,17 @@ support:
12726  @table @code
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.
12733 -@end table
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.
12737 +
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.
12744  
12745 -@table @code
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.
12751  
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
12759 +supports.
12760  
12761  @item set charset @var{charset}
12762  @kindex set charset
12763 @@ -7974,37 +8114,6 @@ Show the name of the current target charset.
12764  
12765  @end table
12766  
12767 -@value{GDBN} currently includes support for the following character
12768 -sets:
12769 -
12770 -@table @code
12771 -
12772 -@item ASCII
12773 -@cindex ASCII character set
12774 -Seven-bit U.S. @sc{ascii}.  @value{GDBN} can use this as its host
12775 -character set.
12776 -
12777 -@item ISO-8859-1
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.
12783 -
12784 -@item EBCDIC-US
12785 -@itemx IBM1047
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.
12791 -
12792 -@end table
12793 -
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.
12797 -
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.
12804  
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).
12814 +
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}:
12821 +
12822 +@smallexample
12823 +Breakpoint 1, func () at gdb.base/return-nodebug.c:29
12824 +29        return 31;
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 ());
12829 +(@value{GDBP})
12830 +@end smallexample
12831 +
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:
12840 +
12841 +@smallexample
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 ()
12849 +(@value{GDBP})
12850 +@end smallexample
12851 +
12852  @node Calling
12853  @section Calling Program Functions
12854  
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.
12858  
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.
12864 +
12865  @table @code
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
12871  @value{GDBN}.
12872 +
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.
12883 +
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
12887 +@value{GDBN}.
12888 +
12889  @end table
12890  
12891  @cindex weak alias functions
12892 @@ -17815,7 +17994,7 @@ command:
12893  @table @code
12894  @kindex source
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}.
12899  @end table
12900  
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.
12904  
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
12908 +error occurs.
12909 +
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:
12914  
12915  @smallexample
12916  (@value{GDBP}) python
12917 -Type python script
12918 -End with a line saying just "end".
12919  >print 23
12920  >end
12921  23
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
12925  disabled.
12926 +
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.
12934  @end table
12935  
12936  @node Python API
12937 @@ -18114,6 +18304,14 @@ disabled.
12938  @cindex python api
12939  @cindex programming in python
12940  
12941 +You can get quick online help for @value{GDBN}'s Python API by issuing
12942 +the command @w{@kbd{python help (gdb)}}.
12943 +
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)}}.
12948 +
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.
12953  @menu
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.
12968  @end menu
12969  
12970  @node Basic 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}.
12973  @end defun
12974  
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}.
12985 +@end defun
12986 +
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.
12991 +@end defun
12992 +
12993 +@findex gdb.objfiles
12994 +@defun objfiles
12995 +Return a sequence of all the objfiles current known to @value{GDBN}.
12996 +@xref{Objfiles In Python}.
12997 +@end defun
12998 +
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.
13005  
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}).
13008  @end defun
13009  
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.
13015 +@end defun
13016 +
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}.
13025 +
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
13029 +this.
13030 +@end defun
13031 +
13032  @findex gdb.write
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
13036  function.
13037  @end defun
13038  
13039 +@findex gdb.frames
13040 +@defun frames
13041 +Return a tuple of all frame objects.
13042 +@end defun
13043 +
13044 +@findex gdb.newest_frame
13045 +@defun newest_frame
13046 +Return the newest frame object.
13047 +@end defun
13048 +
13049 +@findex gdb.selected_frame
13050 +@defun selected_frame
13051 +Return the selected frame object.
13052 +@end defun
13053 +
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}.)
13060 +@end defun
13061 +
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.
13067 +@end defun
13068 +
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.
13075 +@end defun
13076 +
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
13091 +to search for.
13092 +@end defun
13093 +
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.
13097 +@end defun
13098 +
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
13104  traceback.
13105  
13106 +@node Auto-loading
13107 +@subsubsection Auto-loading
13108 +
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.
13116 +
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.
13120 +
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.
13126 +
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.
13130 +
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
13134 +pretty-printers.
13135 +
13136 +This feature is useful for supplying application-specific debugging
13137 +commands and scripts.  It can be disabled using @code{maint set python
13138 +auto-load}.
13139 +
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.
13143 +
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']
13148  
13149  Again, @code{bar} will also be a @code{gdb.Value} object.
13150  
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:
13154 +
13155 +@table @code
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.
13160 +@end defmethod
13161 +
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
13166 +is thrown.
13167 +@end defmethod
13168  
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}.
13173  @end defmethod
13174  
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.
13182  @end defmethod
13183  
13184 +@defmethod Value type
13185 +Return the type of this @code{gdb.Value}.  The result is a
13186 +@code{gdb.Type} object.
13187 +@end defmethod
13188 +@end table
13189 +
13190 +@node Types From Inferior
13191 +@subsubsection Types From Inferior
13192 +
13193 +@cindex gdb.Type
13194 +@value{GDBN} represents types from the inferior using the class
13195 +@code{gdb.Type}.
13196 +
13197 +The following methods are provided:
13198 +
13199 +@table @code
13200 +@defmethod Type Type [name [block]]
13201 +Construct a new instance of @code{gdb.Type}.
13202 +
13203 +If @var{name} is given, it specifies the name of a type to look up in
13204 +the inferior.
13205 +
13206 +If @var{block} is given, then @var{name} is looked up in that scope.
13207 +Otherwise, it is searched for globally.
13208 +@end defmethod
13209 +
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.
13213 +@end defmethod
13214 +
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.
13222 +
13223 +Each field is an object, with some pre-defined attributes:
13224 +@table @code
13225 +@item bitpos
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.
13228 +
13229 +@item name
13230 +The name of the field, or @code{None} for anonymous fields.
13231 +
13232 +@item artificial
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.
13236 +
13237 +@item bitsize
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.
13241 +
13242 +@item type
13243 +The type of the field.
13244 +@end table
13245 +@end defmethod
13246 +
13247 +@defmethod Type const
13248 +Return a new @code{gdb.Type} object which represents a
13249 +@code{const}-qualified variant of this type.
13250 +@end defmethod
13251 +
13252 +@defmethod Type volatile
13253 +Return a new @code{gdb.Type} object which represents a
13254 +@code{volatile}-qualified variant of this type.
13255 +@end defmethod
13256 +
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
13260 +@code{volatile}.
13261 +@end defmethod
13262 +
13263 +@defmethod Type reference
13264 +Return a new @code{gdb.Type} object which represents a reference to this
13265 +type.
13266 +@end defmethod
13267 +
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.
13272 +@end defmethod
13273 +
13274 +@defmethod Type strip_typedefs
13275 +Return a new @code{gdb.Type} that represents the real type,
13276 +after removing all layers of typedefs.
13277 +@end defmethod
13278 +
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
13283 +returned.
13284 +@end defmethod
13285 +
13286 +@defmethod Type target
13287 +Return a new @code{gdb.Type} object which represents the target type
13288 +of this type.
13289 +
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
13295 +type.
13296 +@end defmethod
13297 +
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
13301 +argument.
13302 +
13303 +If this @code{gdb.Type} is not a template type, this will throw an
13304 +exception.
13305 +
13306 +If @var{block} is given, then @var{name} is looked up in that scope.
13307 +Otherwise, it is searched for globally.
13308 +@end defmethod
13309 +@end table
13310 +
13311 +
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:
13315 +
13316 +@table @code
13317 +@findex TYPE_CODE_PTR
13318 +@findex gdb.TYPE_CODE_PTR
13319 +@item TYPE_CODE_PTR
13320 +The type is a pointer.
13321 +
13322 +@findex TYPE_CODE_ARRAY
13323 +@findex gdb.TYPE_CODE_ARRAY
13324 +@item TYPE_CODE_ARRAY
13325 +The type is an array.
13326 +
13327 +@findex TYPE_CODE_STRUCT
13328 +@findex gdb.TYPE_CODE_STRUCT
13329 +@item TYPE_CODE_STRUCT
13330 +The type is a structure.
13331 +
13332 +@findex TYPE_CODE_UNION
13333 +@findex gdb.TYPE_CODE_UNION
13334 +@item TYPE_CODE_UNION
13335 +The type is a union.
13336 +
13337 +@findex TYPE_CODE_ENUM
13338 +@findex gdb.TYPE_CODE_ENUM
13339 +@item TYPE_CODE_ENUM
13340 +The type is an enum.
13341 +
13342 +@findex TYPE_CODE_FLAGS
13343 +@findex gdb.TYPE_CODE_FLAGS
13344 +@item TYPE_CODE_FLAGS
13345 +A bit flags type.
13346 +@c FIXME: what is this?
13347 +
13348 +@findex TYPE_CODE_FUNC
13349 +@findex gdb.TYPE_CODE_FUNC
13350 +@item TYPE_CODE_FUNC
13351 +The type is a function.
13352 +
13353 +@findex TYPE_CODE_INT
13354 +@findex gdb.TYPE_CODE_INT
13355 +@item TYPE_CODE_INT
13356 +The type is an integer type.
13357 +
13358 +@findex TYPE_CODE_FLT
13359 +@findex gdb.TYPE_CODE_FLT
13360 +@item TYPE_CODE_FLT
13361 +A floating point type.
13362 +
13363 +@findex TYPE_CODE_VOID
13364 +@findex gdb.TYPE_CODE_VOID
13365 +@item TYPE_CODE_VOID
13366 +The special type @code{void}.
13367 +
13368 +@findex TYPE_CODE_SET
13369 +@findex gdb.TYPE_CODE_SET
13370 +@item TYPE_CODE_SET
13371 +A Pascal set type.
13372 +
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.
13377 +
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.
13383 +
13384 +@findex TYPE_CODE_BITSTRING
13385 +@findex gdb.TYPE_CODE_BITSTRING
13386 +@item TYPE_CODE_BITSTRING
13387 +A string of bits.
13388 +
13389 +@findex TYPE_CODE_ERROR
13390 +@findex gdb.TYPE_CODE_ERROR
13391 +@item TYPE_CODE_ERROR
13392 +An unknown or erroneous type.
13393 +
13394 +@findex TYPE_CODE_METHOD
13395 +@findex gdb.TYPE_CODE_METHOD
13396 +@item TYPE_CODE_METHOD
13397 +A C++ method type.
13398 +
13399 +@findex TYPE_CODE_METHODPTR
13400 +@findex gdb.TYPE_CODE_METHODPTR
13401 +@item TYPE_CODE_METHODPTR
13402 +A pointer-to-member-function.
13403 +
13404 +@findex TYPE_CODE_MEMBERPTR
13405 +@findex gdb.TYPE_CODE_MEMBERPTR
13406 +@item TYPE_CODE_MEMBERPTR
13407 +A pointer-to-member.
13408 +
13409 +@findex TYPE_CODE_REF
13410 +@findex gdb.TYPE_CODE_REF
13411 +@item TYPE_CODE_REF
13412 +A reference type.
13413 +
13414 +@findex TYPE_CODE_CHAR
13415 +@findex gdb.TYPE_CODE_CHAR
13416 +@item TYPE_CODE_CHAR
13417 +A character type.
13418 +
13419 +@findex TYPE_CODE_BOOL
13420 +@findex gdb.TYPE_CODE_BOOL
13421 +@item TYPE_CODE_BOOL
13422 +A boolean type.
13423 +
13424 +@findex TYPE_CODE_COMPLEX
13425 +@findex gdb.TYPE_CODE_COMPLEX
13426 +@item TYPE_CODE_COMPLEX
13427 +A complex float type.
13428 +
13429 +@findex TYPE_CODE_TYPEDEF
13430 +@findex gdb.TYPE_CODE_TYPEDEF
13431 +@item TYPE_CODE_TYPEDEF
13432 +A typedef to some other type.
13433 +
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
13440 +
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?
13446 +
13447 +@findex TYPE_CODE_NAMESPACE
13448 +@findex gdb.TYPE_CODE_NAMESPACE
13449 +@item TYPE_CODE_NAMESPACE
13450 +A C++ namespace.
13451 +
13452 +@findex TYPE_CODE_DECFLOAT
13453 +@findex gdb.TYPE_CODE_DECFLOAT
13454 +@item TYPE_CODE_DECFLOAT
13455 +A decimal floating point type.
13456 +
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.
13462 +@end table
13463 +
13464 +@node Pretty Printing
13465 +@subsubsection Pretty Printing
13466 +
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.
13469 +
13470 +A pretty-printer is an object that implements a specific interface.
13471 +There is no predefined base class for pretty-printers.
13472 +
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
13476 +@code{gdb.Value}.
13477 +@end defop
13478 +
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.
13482 +
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.
13488 +
13489 +This method is optional.  If it does not exist, @value{GDBN} will act
13490 +as though the value has no children.
13491 +@end defop
13492 +
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
13497 +being printed.
13498 +
13499 +Some display hints are predefined by @value{GDBN}:
13500 +
13501 +@table @samp
13502 +@item array
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}.
13506 +
13507 +@item map
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
13510 +values.
13511 +
13512 +@item string
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.
13519 +@end table
13520 +@end defop
13521 +
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.
13525 +
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
13528 +@code{children}.
13529 +
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.
13535 +@end defop
13536 +
13537 +@subsubsection Selecting Pretty-Printers
13538 +
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
13547 +@code{None}.
13548 +
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.
13555 +
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.
13560 +
13561 +Here is an example showing how a @code{std::string} printer might be
13562 +written:
13563 +
13564 +@smallexample
13565 +class StdStringPrinter:
13566 +    "Print a std::string"
13567 +
13568 +    def __init__ (self, val):
13569 +        self.val = val
13570 +
13571 +    def to_string (self):
13572 +        return self.val['_M_dataplus']['_M_p']
13573 +@end smallexample
13574 +
13575 +And here is an example showing how a lookup function for
13576 +the printer example above might be written. 
13577 +
13578 +@smallexample
13579 +def str_lookup_function (val):
13580 +
13581 +    lookup_tag = val.type ().tag ()
13582 +    regex = re.compile ("^std::basic_string<char,.*>$")
13583 +    if lookup_tag == None:
13584 +        return None
13585 +    if regex.match (lookup_tag):
13586 +        return StdStringPrinter (val)
13587 +    
13588 +    return None
13589 +@end smallexample
13590 +
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}.
13595 +
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.
13602 +
13603 +For example, in addition to the above, this code might appear in
13604 +@code{gdb.libstdcxx.v6}:
13605 +
13606 +@smallexample
13607 +def register_printers (objfile):
13608 +    objfile.pretty_printers.add (str_lookup_function)
13609 +@end smallexample
13610 +
13611 +And then the corresponding contents of the auto-load file would be:
13612 +
13613 +@smallexample
13614 +import gdb.libstdcxx.v6
13615 +gdb.libstdcxx.v6.register_printers (gdb.current_objfile ())
13616 +@end smallexample
13617 +
13618 +@node Threads In Python
13619 +@subsubsection Threads In Python
13620 +
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:
13624 +
13625 +@findex gdb.threads
13626 +@defun 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}.
13630 +@end defun
13631 +
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}.
13636 +@end defun
13637 +
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
13643 +exception.
13644 +@end defun
13645 +
13646  @node Commands In Python
13647  @subsubsection Commands In Python
13648  
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.
13652  
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.
13659  
13660  There is no support for multi-line commands.
13661  
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.
13666  
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.
13675  
13676 +
13677 +@node Parameters In Python
13678 +@subsubsection Parameters In Python
13679 +
13680 +@cindex parameters in python
13681 +@cindex python parameters
13682 +@tindex gdb.Parameter
13683 +@tindex 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.
13688 +
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.
13693 +
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.
13698 +
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.
13702 +
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
13706 +completion.
13707 +
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.
13711 +
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.
13714 +
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.
13718 +@end defmethod
13719 +
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
13724 +have no effect.
13725 +@end defivar
13726 +
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
13731 +have no effect.
13732 +@end defivar
13733 +
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.
13738 +@end defivar
13739 +
13740 +
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}
13743 +module:
13744 +
13745 +@table @code
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.
13751 +
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}.
13758 +
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''.
13764 +
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''.
13770 +
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
13775 +translated.
13776 +
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.
13782 +
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}.
13787 +
13788 +@findex PARAM_FILENAME
13789 +@findex gdb.PARAM_FILENAME
13790 +@item PARAM_FILENAME
13791 +The value is a filename (a string).
13792 +
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.
13798 +
13799 +@findex PARAM_ENUM
13800 +@findex gdb.PARAM_ENUM
13801 +@item PARAM_ENUM
13802 +The value is a string, which must be one of a collection string
13803 +constants provided when the parameter is created.
13804 +@end table
13805 +
13806 +@node Functions In Python
13807 +@subsubsection Writing new convenience functions
13808 +
13809 +@cindex writing convenience functions
13810 +@cindex convenience functions in python
13811 +@cindex python convenience functions
13812 +@tindex gdb.Function
13813 +@tindex 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}.
13817 +
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}.
13824 +
13825 +The documentation for the new function is taken from the documentation
13826 +string for the new class.
13827 +@end defmethod
13828 +
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.
13837 +
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.
13841 +@end defmethod
13842 +
13843 +The following code snippet shows how a trivial convenience function can
13844 +be implemented in Python:
13845 +
13846 +@smallexample
13847 +class Greet (gdb.Function):
13848 +  """Return string to greet someone.
13849 +Takes a name as argument."""
13850 +
13851 +  def __init__ (self):
13852 +    super (Greet, self).__init__ ("greet")
13853 +
13854 +  def invoke (self, name):
13855 +    return "Hello, %s!" % name.string ()
13856 +
13857 +Greet ()
13858 +@end smallexample
13859 +
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.
13864 +
13865 +@node Objfiles In Python
13866 +@subsubsection Objfiles In Python
13867 +
13868 +@cindex objfiles in python
13869 +@cindex python objfiles
13870 +@tindex gdb.Objfile
13871 +@tindex 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
13876 +@dfn{objfiles}.
13877 +
13878 +Each objfile is represented by an instance of the @code{gdb.Objfile}
13879 +class.
13880 +
13881 +@defivar Objfile filename
13882 +The file name of the objfile as a string.
13883 +@end defivar
13884 +
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.
13890 +@end defivar
13891 +
13892 +@node Breakpoints In Python
13893 +@subsubsection Manipulating breakpoints using Python
13894 +
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}
13900 +class.
13901 +
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.
13906 +@end defmethod
13907 +
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.
13913 +@end defmethod
13914 +
13915 +@defivar Breakpoint enabled
13916 +This attribute is @code{True} if the breakpoint is enabled, and
13917 +@code{False} otherwise.  This attribute is writable.
13918 +@end defivar
13919 +
13920 +@defivar Breakpoint silent
13921 +This attribute is @code{True} if the breakpoint is silent, and
13922 +@code{False} otherwise.  This attribute is writable.
13923 +
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.
13927 +@end defivar
13928 +
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.
13933 +@end defivar
13934 +
13935 +@defivar Breakpoint ignore_count
13936 +This attribute holds the ignore count for the breakpoint, an integer.
13937 +This attribute is writable.
13938 +@end defivar
13939 +
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.
13943 +@end defivar
13944 +
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.
13948 +@end defivar
13949 +
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.
13953 +@end defivar
13954 +
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.
13959 +@end defivar
13960 +
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.
13966 +@end defivar
13967 +
13968 +@node Frames In Python
13969 +@subsubsection Accessing inferior stack frames from Python.
13970 +
13971 +@cindex frames in python
13972 +@tindex gdb.Frame
13973 +@tindex Frame
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}.
13982 +
13983 +A @code{gdb.Frame} object has the following methods:
13984 +
13985 +@table @code
13986 +@defmethod Frame equals @code{frame}
13987 +Compare frames.
13988 +@end defmethod
13989 +
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.
13995 +@end defmethod
13996 +
13997 +@defmethod Frame name
13998 +Returns the function name of the frame, or @code{None} if it can't be
13999 +obtained.
14000 +@end defmethod
14001 +
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}.
14006 +@end defmethod
14007 +
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.
14012 +@end defmethod
14013 +
14014 +@defmethod Frame pc
14015 +Returns the frame's resume address.
14016 +@end defmethod
14017 +
14018 +@defmethod Frame block
14019 +Returns the frame's code block. @c (see @xref{Block,,Code Blocks and Scopes}).
14020 +@end defmethod
14021 +
14022 +@defmethod Frame address_in_block
14023 +Returns an address which falls within the frame's code block.
14024 +@end defmethod
14025 +
14026 +@defmethod Frame older
14027 +Return the frame immediately older (outer) to this frame.
14028 +@end defmethod
14029 +
14030 +@defmethod Frame newer
14031 +Return the frame immediately newer (inner) to this frame.
14032 +@end defmethod
14033 +
14034 +@defmethod Frame find_sal
14035 +Return the frame's symtab and line object. @c (see @xref{Symtab_and_line,, Symtab and line}).
14036 +@end defmethod
14037 +
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}).
14041 +@end defmethod
14042 +@end table
14043 +
14044  @node Interpreters
14045  @chapter Command Interpreters
14046  @cindex command interpreters
14047 @@ -22273,6 +23463,103 @@ Unfreezing a variable does not update it, only subsequent
14048  (gdb)
14049  @end smallexample
14050  
14051 +@subheading The @code{-var-set-visualizer} command
14052 +@findex -var-set-visualizer
14053 +@anchor{-var-set-visualizer}
14054 +
14055 +@subsubheading Synopsis
14056 +
14057 +@smallexample
14058 + -var-set-visualizer @var{name} @var{visualizer}
14059 +@end smallexample
14060 +
14061 +@subheading The @code{-var-set-child-range} command
14062 +@findex -var-set-child-range
14063 +@anchor{-var-set-child-range}
14064 +
14065 +Set a visualizer for the variable object @var{name}.
14066 +
14067 +@var{visualizer} is the visualizer to use.  The special value
14068 +@samp{None} means to disable any visualizer in use.
14069 +
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
14075 +Printing}).
14076 +
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.
14080 +
14081 +@code{gdb.default_visualizer} looks in the global dictionary named
14082 +@code{gdb.pretty_printers}.
14083 +
14084 +This feature is only available if Python support is enabled.
14085 +
14086 +@subsubheading Example
14087 +
14088 +Resetting the visualizer:
14089 +
14090 +@smallexample
14091 +(gdb)
14092 +-var-set-visualizer V None
14093 +^done
14094 +@end smallexample
14095 +
14096 +Reselecting the default (type-based) visualizer:
14097 +
14098 +@smallexample
14099 +(gdb)
14100 +-var-set-visualizer V gdb.default_visualizer
14101 +^done
14102 +@end smallexample
14103 +
14104 +Suppose @code{SomeClass} is a visualizer class.  A lambda expression
14105 +can be used to instantiate this class for a varobj:
14106 +
14107 +@smallexample
14108 +(gdb)
14109 +-var-set-visualizer V "lambda val: SomeClass()"
14110 +^done
14111 +@end smallexample
14112 +
14113 +@subsubheading Synopsis
14114 +
14115 +@smallexample
14116 + -var-set-child-range @var{name} @var{from} @var{to}
14117 +@end smallexample
14118 +
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.
14123 +
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
14126 +children.
14127 +
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.
14131 +
14132 +@subsubheading Example
14133 +
14134 +@smallexample
14135 +(gdb)
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"@}]
14140 +(gdb)
14141 + -var-set-child-range n 1 2
14142 +(gdb)
14143 + -var-list-children n
14144 + ^done,numchild=3,children=[@{name="b",numchild=0,type="int"@},
14145 + @{name="c",numchild=0,type="int"@}]
14146 +@end smallexample
14147 +
14148  
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.
14155 +@item python
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}
14159  @item thread-info
14160  Indicates presence of the @code{-thread-info} command.
14161  
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.
14165  
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}.
14173 -
14174 -GNU/Linux native asynchronous support will be disabled until you use
14175 -the @samp{maint set linux-async} command to enable it.
14176 -
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}.
14184 -
14185 -Remote asynchronous support will be disabled until you use
14186 -the @samp{maint set remote-async} command to enable it.
14187 -
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
14195 @@ -38,6 +38,7 @@
14196  
14197  #include "complaints.h"
14198  #include "dwarf2-frame.h"
14199 +#include "addrmap.h"
14200  
14201  struct comp_unit;
14202  
14203 @@ -1499,6 +1500,14 @@ dwarf2_frame_find_fde (CORE_ADDR *pc)
14204        struct dwarf2_fde *fde;
14205        CORE_ADDR offset;
14206  
14207 +      if (objfile->quick_addrmap)
14208 +       {
14209 +         if (!addrmap_find (objfile->quick_addrmap, *pc))
14210 +           continue;
14211 +       }
14212 +      /* FIXME: Read-in only .debug_frame/.eh_frame without .debug_info?  */
14213 +      require_partial_symbols (objfile);
14214 +
14215        fde = objfile_data (objfile, dwarf2_frame_objfile_data);
14216        if (fde == NULL)
14217         continue;
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;
14224           goto no_push;
14225  
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);
14231 +         break;
14232 +
14233         default:
14234           error (_("Unhandled dwarf expression opcode 0x%x"), op);
14235         }
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
14242       is complete.  */
14243    unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length);
14244 +#endif
14245  
14246    /* Return the `object address' for DW_OP_push_object_address.  */
14247    CORE_ADDR (*get_object_address) (void *baton);
14248 -#endif
14249  
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
14257  {
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;
14263  };
14264  
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));
14269      }
14270 -  else
14271 +  else if (SYMBOL_OPS (framefunc) == &dwarf2_locexpr_funcs)
14272      {
14273        struct dwarf2_locexpr_baton *symbaton;
14274 +
14275        symbaton = SYMBOL_LOCATION_BATON (framefunc);
14276 -      if (symbaton != NULL)
14277 -       {
14278 -         *length = symbaton->size;
14279 -         *start = symbaton->data;
14280 -       }
14281 -      else
14282 -       *start = NULL;
14283 +      gdb_assert (symbaton != NULL);
14284 +      *start = symbaton->data;
14285 +      *length = symbaton->size;
14286 +    }
14287 +  else if (SYMBOL_OPS (framefunc) == &dwarf2_missing_funcs)
14288 +    {
14289 +      struct dwarf2_locexpr_baton *symbaton;
14290 +
14291 +      symbaton = SYMBOL_LOCATION_BATON (framefunc);
14292 +      gdb_assert (symbaton == NULL);
14293 +      *start = NULL;
14294 +      *length = 0;     /* unused */
14295      }
14296 +  else
14297 +    internal_error (__FILE__, __LINE__,
14298 +                   _("Unsupported SYMBOL_OPS %p for \"%s\""),
14299 +                   SYMBOL_OPS (framefunc), SYMBOL_PRINT_NAME (framefunc));
14300  
14301    if (*start == NULL)
14302      error (_("Could not find the frame base for \"%s\"."),
14303 -          SYMBOL_NATURAL_NAME (framefunc));
14304 +          SYMBOL_PRINT_NAME (framefunc));
14305  }
14306  
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);
14310  }
14311  
14312 +static CORE_ADDR
14313 +dwarf_expr_object_address (void *baton)
14314 +{
14315 +  struct dwarf_expr_baton *debaton = baton;
14316 +
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"));
14320 +
14321 +  return debaton->object_address;
14322 +}
14323 +
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.  */
14327 +
14328 +static CORE_ADDR object_address;
14329 +
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.  */
14333 +
14334 +static void
14335 +object_address_cleanup (void *prev_save_voidp)
14336 +{
14337 +  CORE_ADDR *prev_save = prev_save_voidp;
14338 +
14339 +  object_address = *prev_save;
14340 +  xfree (prev_save);
14341 +}
14342 +
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.
14345 +
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).  */
14349 +
14350 +void
14351 +object_address_set (CORE_ADDR address)
14352 +{
14353 +  CORE_ADDR *prev_save;
14354 +
14355 +  prev_save = xmalloc (sizeof *prev_save);
14356 +  *prev_save = object_address;
14357 +  make_cleanup (object_address_cleanup, prev_save);
14358 +
14359 +  object_address = address;
14360 +}
14361 +
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.  */
14366 +
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)
14370 +{
14371 +  struct dwarf_expr_context *ctx;
14372 +  struct dwarf_expr_baton baton;
14373 +
14374 +  if (!frame)
14375 +    frame = get_selected_frame (NULL);
14376 +
14377 +  baton.frame = frame;
14378 +  baton.objfile = dwarf2_per_cu_objfile (per_cu);
14379 +  baton.object_address = object_address;
14380 +
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;
14390 +
14391 +  make_cleanup ((make_cleanup_ftype *) free_dwarf_expr_context, ctx);
14392 +
14393 +  dwarf_expr_eval (ctx, data, size);
14394 +
14395 +  /* It was used only during dwarf_expr_eval.  */
14396 +  ctx->baton = NULL;
14397 +
14398 +  return ctx;
14399 +}
14400 +
14401 +/* Evaluate DWARF expression at DLBATON expecting it produces exactly one
14402 +   CORE_ADDR result on the DWARF stack stack.  */
14403 +
14404 +CORE_ADDR
14405 +dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton)
14406 +{
14407 +  struct dwarf_expr_context *ctx;
14408 +  CORE_ADDR retval;
14409 +  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
14410 +
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"));
14417 +
14418 +  retval = dwarf_expr_fetch (ctx, 0);
14419 +
14420 +  do_cleanups (back_to);
14421 +
14422 +  return retval;
14423 +}
14424 +
14425  /* Evaluate a location description, starting at DATA and with length
14426     SIZE, to find the current location of variable VAR in the context
14427     of FRAME.  */
14428 @@ -200,8 +326,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14429                           struct dwarf2_per_cu_data *per_cu)
14430  {
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);
14435  
14436    if (size == 0)
14437      {
14438 @@ -211,19 +337,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14439        return retval;
14440      }
14441  
14442 -  baton.frame = frame;
14443 -  baton.objfile = dwarf2_per_cu_objfile (per_cu);
14444 +  ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
14445  
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;
14454 -
14455 -  dwarf_expr_eval (ctx, data, size);
14456    if (ctx->num_pieces > 0)
14457      {
14458        int i;
14459 @@ -261,15 +376,19 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
14460      {
14461        CORE_ADDR address = dwarf_expr_fetch (ctx, 0);
14462  
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);
14466 +
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);
14472      }
14473  
14474    set_value_initialized (retval, ctx->initialized);
14475  
14476 -  free_dwarf_expr_context (ctx);
14477 +  do_cleanups (back_to);
14478  
14479    return retval;
14480  }
14481 @@ -587,7 +706,7 @@ static int
14482  loclist_describe_location (struct symbol *symbol, struct ui_file *stream)
14483  {
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"));
14487    return 1;
14488  }
14489  
14490 @@ -603,16 +722,56 @@ loclist_tracepoint_var_ref (struct symbol * symbol, struct agent_expr * ax,
14491  
14492    data = find_location_expression (dlbaton, &size, ax->scope);
14493    if (data == NULL)
14494 -    error (_("Variable \"%s\" is not available."), SYMBOL_NATURAL_NAME (symbol));
14495 +    error (_("Variable \"%s\" is not available."), SYMBOL_PRINT_NAME (symbol));
14496  
14497    dwarf2_tracepoint_var_ref (symbol, ax, value, data, size);
14498  }
14499  
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
14508  };
14509 +
14510 +static struct value *
14511 +missing_read_variable (struct symbol *symbol, struct frame_info *frame)
14512 +{
14513 +  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
14514 +
14515 +  gdb_assert (dlbaton == NULL);
14516 +  error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
14517 +}
14518 +
14519 +static int
14520 +missing_read_needs_frame (struct symbol *symbol)
14521 +{
14522 +  return 0;
14523 +}
14524 +
14525 +static int
14526 +missing_describe_location (struct symbol *symbol, struct ui_file *stream)
14527 +{
14528 +  fprintf_filtered (stream, _("a variable we are unable to resolve"));
14529 +  return 1;
14530 +}
14531 +
14532 +static void
14533 +missing_tracepoint_var_ref (struct symbol *symbol, struct agent_expr *ax,
14534 +                           struct axs_value *value)
14535 +{
14536 +  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
14537 +
14538 +  gdb_assert (dlbaton == NULL);
14539 +  error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
14540 +}
14541 +
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
14549 +};
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
14555  
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;
14559 +
14560 +extern void object_address_set (CORE_ADDR address);
14561 +
14562 +extern CORE_ADDR dwarf_locexpr_baton_eval
14563 +  (struct dwarf2_locexpr_baton *dlbaton);
14564  
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
14570 @@ -1,8 +1,7 @@
14571  /* DWARF 2 debugging format support for GDB.
14572  
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.
14577  
14578     Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
14579     Inc.  with support from Florida State University (under contract
14580 @@ -47,6 +46,9 @@
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"
14587  
14588  #include <fcntl.h>
14589  #include "gdb_string.h"
14590 @@ -103,7 +105,7 @@ typedef struct pubnames_header
14591  _PUBNAMES_HEADER;
14592  #define _ACTUAL_PUBNAMES_HEADER_SIZE 13
14593  
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;
14602  
14603 -  /* `.debug_ranges' offset for this `DW_TAG_compile_unit' DIE.  */
14604 -  unsigned int ranges_offset;
14605 -
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;
14613 -
14614 -  /* Field `ranges_offset' is filled in; flag as the value may be zero.  */
14615 -  unsigned int has_ranges_offset : 1;
14616  };
14617  
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;
14622  
14623 -    /* Language code associated with this DIE.  This is only used
14624 -       for the compilation unit DIE.  */
14625 -    unsigned int language : 8;
14626 -
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;
14635  
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;
14639  
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.  */
14644      char *name;
14645 -    char *dirname;
14646 +
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;
14650  
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;
14656  
14657 -    /* If HAS_STMT_LIST, the offset of the Line Number Information data.  */
14658 -    unsigned int line_offset;
14659 -
14660      /* Pointers to this DIE's parent, first child, and next sibling,
14661         if any.  */
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;
14665    };
14666  
14667 +/* Additional GDB-specific attribute forms.  */
14668 +enum
14669 +  {
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
14674 +  };
14675 +
14676  /* Attributes have a name and a value */
14677  struct attribute
14678    {
14679 @@ -756,7 +755,7 @@ static void dwarf2_create_include_psymtab (char *, struct partial_symtab *,
14680                                             struct objfile *);
14681  
14682  static void dwarf2_build_include_psymtabs (struct dwarf2_cu *,
14683 -                                           struct partial_die_info *,
14684 +                                           struct die_info *,
14685                                             struct partial_symtab *);
14686  
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 *);
14691  
14692 +static gdb_byte *read_comp_unit_head (struct comp_unit_head *, gdb_byte *,
14693 +                                     bfd *);
14694 +
14695  static int pdi_needs_namespace (enum dwarf_tag tag);
14696  
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 *);
14699  
14700  static void psymtab_to_symtab_1 (struct partial_symtab *);
14701  
14702 +static gdb_byte *dwarf2_read_section_1 (struct objfile *objfile,
14703 +                                       struct obstack *obstack,
14704 +                                       asection *sectp);
14705 +
14706  gdb_byte *dwarf2_read_section (struct objfile *, asection *);
14707  
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 *);
14711  
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);
14716  
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 *);
14720  
14721  static void read_module (struct die_info *die, struct dwarf2_cu *cu);
14722  
14723 +static void read_import_statement (struct die_info *die, struct dwarf2_cu *);
14724 +
14725  static const char *namespace_name (struct die_info *die,
14726                                    int *is_anonymous, struct dwarf2_cu *);
14727  
14728 @@ -993,6 +1002,9 @@ static void process_die (struct die_info *, struct dwarf2_cu *);
14729  
14730  static char *dwarf2_linkage_name (struct die_info *, struct dwarf2_cu *);
14731  
14732 +static char *dwarf2_canonicalize_name (char *, struct dwarf2_cu *,
14733 +                                      struct obstack *);
14734 +
14735  static char *dwarf2_name (struct die_info *die, struct dwarf2_cu *);
14736  
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 *,
14739  
14740  static unsigned int dwarf2_get_ref_die_offset (struct attribute *);
14741  
14742 -static int dwarf2_get_attr_constant_value (struct attribute *, int);
14743 +enum dwarf2_get_attr_constant_value
14744 +  {
14745 +    dwarf2_attr_unknown,
14746 +    dwarf2_attr_const,
14747 +    dwarf2_attr_block
14748 +  };
14749 +static enum dwarf2_get_attr_constant_value dwarf2_get_attr_constant_value
14750 +  (struct attribute *attr, int *val_return);
14751  
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);
14755  
14756  static void free_one_cached_comp_unit (void *);
14757  
14758 +static void fetch_die_type_attrs (struct die_info *die, struct type *type,
14759 +                                 struct dwarf2_cu *cu);
14760 +
14761  static struct type *set_die_type (struct die_info *, struct type *,
14762                                   struct dwarf2_cu *);
14763  
14764 @@ -1104,19 +1126,28 @@ static void dwarf2_clear_marks (struct dwarf2_per_cu_data *);
14765  
14766  static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
14767  
14768 +static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
14769 +  (struct attribute *attr, struct dwarf2_cu *cu);
14770 +
14771  /* Try to locate the sections we need for DWARF 2 debugging
14772     information and return true if we have enough to do something.  */
14773  
14774  int
14775  dwarf2_has_info (struct objfile *objfile)
14776  {
14777 -  struct dwarf2_per_objfile *data;
14778 +  int update_sizes = 0;
14779  
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)
14787 +    {
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;
14794 +    }
14795  
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;
14803    
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);
14807  }
14808  
14809 @@ -1149,51 +1181,61 @@ section_is_p (asection *sectp, const char *name)
14810     in.  */
14811  
14812  static void
14813 -dwarf2_locate_sections (bfd *abfd, asection *sectp, void *ignore_ptr)
14814 +dwarf2_locate_sections (bfd *abfd, asection *sectp, void *user_data)
14815  {
14816 +  int update_sizes = * (int *) user_data;
14817    if (section_is_p (sectp, INFO_SECTION))
14818      {
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;
14823      }
14824    else if (section_is_p (sectp, ABBREV_SECTION))
14825      {
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;
14830      }
14831    else if (section_is_p (sectp, LINE_SECTION))
14832      {
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;
14837      }
14838    else if (section_is_p (sectp, PUBNAMES_SECTION))
14839      {
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;
14844      }
14845    else if (section_is_p (sectp, ARANGES_SECTION))
14846      {
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;
14851      }
14852    else if (section_is_p (sectp, LOC_SECTION))
14853      {
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;
14858      }
14859    else if (section_is_p (sectp, MACINFO_SECTION))
14860      {
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;
14865      }
14866    else if (section_is_p (sectp, STR_SECTION))
14867      {
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;
14872      }
14873    else if (section_is_p (sectp, FRAME_SECTION))
14874      {
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;
14879      }
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)
14884          {
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;
14889          }
14890      }
14891    else if (section_is_p (sectp, RANGES_SECTION))
14892      {
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;
14897      }
14898    
14899 @@ -1250,6 +1294,86 @@ dwarf2_resize_section (asection *sectp, bfd_size_type new_size)
14900                      sectp->name);
14901  }
14902  
14903 +/* A cleanup that frees an obstack.  */
14904 +static void
14905 +finalize_obstack (void *o)
14906 +{
14907 +  struct obstack *ob = o;
14908 +  obstack_free (o, 0);
14909 +}
14910 +
14911 +/* Read the .debug_aranges section and construct an address map.  */
14912 +
14913 +void
14914 +dwarf2_create_quick_addrmap (struct objfile *objfile)
14915 +{
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;
14922 +
14923 +  if (!dwarf_aranges_section)
14924 +    return;
14925 +
14926 +  baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
14927 +
14928 +  aranges_buffer = dwarf2_read_section_1 (objfile, NULL, dwarf_aranges_section);
14929 +  aranges_ptr = aranges_buffer;
14930 +  old = make_cleanup (xfree, aranges_buffer);
14931 +
14932 +  obstack_init (&temp_obstack);
14933 +  make_cleanup (finalize_obstack, &temp_obstack);
14934 +  mutable_map = addrmap_create_mutable (&temp_obstack);
14935 +
14936 +  while ((aranges_ptr - aranges_buffer) < dwarf2_per_objfile->aranges_size)
14937 +    {
14938 +      struct comp_unit_head cu_header;
14939 +      unsigned int bytes_read, segment_size, delta;
14940 +      LONGEST info_offset;
14941 +      struct dwarf2_cu cu;
14942 +
14943 +      cu_header.initial_length_size = 0;
14944 +      aranges_ptr = read_comp_unit_head (&cu_header, aranges_ptr, abfd);
14945 +
14946 +      segment_size = read_1_byte (abfd, aranges_ptr);
14947 +      aranges_ptr += 1;
14948 +
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;
14954 +
14955 +      memset (&cu, 0, sizeof (cu));
14956 +      cu.header.addr_size = cu_header.addr_size;
14957 +
14958 +      while (1)
14959 +       {
14960 +         CORE_ADDR address, length;
14961 +
14962 +         address = read_address (abfd, aranges_ptr, &cu, &bytes_read);
14963 +         aranges_ptr += bytes_read;
14964 +
14965 +         length = read_address (abfd, aranges_ptr, &cu, &bytes_read);
14966 +         aranges_ptr += bytes_read;
14967 +
14968 +         if (address == 0 && length == 0)
14969 +           break;
14970 +
14971 +         address += baseaddr;
14972 +
14973 +         addrmap_set_empty (mutable_map, address, address + length, objfile);
14974 +       }
14975 +    }
14976 +
14977 +  objfile->quick_addrmap = addrmap_create_fixed (mutable_map,
14978 +                                                &objfile->objfile_obstack);
14979 +  do_cleanups (old);
14980 +}
14981 +
14982 +
14983  /* Build a partial symbol table.  */
14984  
14985  void
14986 @@ -1453,22 +1577,24 @@ dwarf2_create_include_psymtab (char *name, struct partial_symtab *pst,
14987  
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.
14991 -   
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.  */
14996  
14997  static void
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)
15002  {
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;
15008  
15009 -  lh = dwarf_decode_line_header (pdi->line_offset, abfd, cu);
15010 +  attr = dwarf2_attr (die, DW_AT_stmt_list, cu);
15011 +  if (attr)
15012 +    {
15013 +      unsigned int line_offset = DW_UNSND (attr);
15014 +      lh = dwarf_decode_line_header (line_offset, abfd, cu);
15015 +    }
15016    if (lh == NULL)
15017      return;  /* No linetable, so no includes.  */
15018  
15019 @@ -1477,6 +1603,36 @@ dwarf2_build_include_psymtabs (struct dwarf2_cu *cu,
15020    free_line_header (lh);
15021  }
15022  
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.  */
15028 +
15029 +static void
15030 +dwarf2_find_base_address (struct die_info *die, struct dwarf2_cu *cu)
15031 +{
15032 +  struct attribute *attr;
15033 +
15034 +  cu->base_known = 0;
15035 +  cu->base_address = 0;
15036 +
15037 +  attr = dwarf2_attr (die, DW_AT_entry_pc, cu);
15038 +  if (attr)
15039 +    {
15040 +      cu->base_address = DW_ADDR (attr);
15041 +      cu->base_known = 1;
15042 +    }
15043 +  else
15044 +    {
15045 +      attr = dwarf2_attr (die, DW_AT_low_pc, cu);
15046 +      if (attr)
15047 +       {
15048 +         cu->base_address = DW_ADDR (attr);
15049 +         cu->base_known = 1;
15050 +       }
15051 +    }
15052 +}
15053  
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)
15066      {
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;
15076  
15077        beg_of_comp_unit = info_ptr;
15078  
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);
15081  
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,
15087 +                               &has_children);
15088  
15089 -      if (comp_unit_die.tag == DW_TAG_partial_unit)
15090 +      if (comp_unit_die->tag == DW_TAG_partial_unit)
15091         {
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)
15095         }
15096  
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);
15102 +      else
15103 +       set_cu_language (language_minimal, &cu);
15104  
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);
15111 +      else
15112 +       name = "";
15113 +      pst = start_psymtab_common (objfile, objfile->section_offsets, name,
15114                                   /* TEXTLOW and TEXTHIGH are set below.  */
15115                                   0,
15116                                   objfile->global_psymbols.next,
15117                                   objfile->static_psymbols.next);
15118  
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));
15126  
15127        pst->read_symtab_private = (char *) this_cu;
15128  
15129 @@ -1607,24 +1772,17 @@ dwarf2_build_psymtabs_hard (struct objfile *objfile, int mainline)
15130  
15131        /* Possibly set the default values of LOWPC and HIGHPC from
15132           `DW_AT_ranges'.  */
15133 -      if (cu.has_ranges_offset)
15134 -       {
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;
15138 -       }
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);
15146 +      has_pc_info = 0;
15147 +
15148 +      if (dwarf2_get_pc_bounds (comp_unit_die, &best_lowpc, &best_highpc, &cu,
15149 +                               pst))
15150 +       has_pc_info = 1;
15151 +      dwarf2_find_base_address (comp_unit_die, &cu);
15152  
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)
15158         {
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)
15162  
15163           first_die = load_partial_dies (abfd, info_ptr, 1, &cu);
15164  
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);
15168  
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)
15172  
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)
15177             {
15178 -             comp_unit_die.lowpc = lowpc;
15179 -             comp_unit_die.highpc = highpc;
15180 +             best_lowpc = lowpc;
15181 +             best_highpc = highpc;
15182             }
15183         }
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;
15188  
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;
15194  
15195 -      if (comp_unit_die.has_stmt_list)
15196 -        {
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);
15200 -        }
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);
15204  
15205        do_cleanups (back_to_inner);
15206      }
15207 @@ -1690,11 +1844,12 @@ load_comp_unit (struct dwarf2_per_cu_data *this_cu, struct objfile *objfile)
15208  {
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;
15219  
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);
15224  
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,
15230 +                           &has_children);
15231  
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);
15235 +  if (attr)
15236 +    set_cu_language (DW_UNSND (attr), cu);
15237 +  else
15238 +    set_cu_language (language_minimal, cu);
15239  
15240    /* Link this compilation unit into the compilation unit tree.  */
15241    this_cu->cu = cu;
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);
15249  
15250    do_cleanups (back_to);
15251 @@ -1948,7 +2106,7 @@ partial_die_parent_scope (struct partial_die_info *pdi,
15252          ignoring them.  */
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;
15258      }
15259  
15260 @@ -1963,12 +2121,37 @@ partial_die_full_name (struct partial_die_info *pdi,
15261                        struct dwarf2_cu *cu)
15262  {
15263    char *parent_scope;
15264 +  struct partial_die_info *real_pdi;
15265  
15266 -  parent_scope = partial_die_parent_scope (pdi, cu);
15267 -  if (parent_scope == NULL)
15268 -    return NULL;
15269 -  else
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.  */
15274 +
15275 +  real_pdi = pdi;
15276 +  while (real_pdi->has_specification)
15277 +    real_pdi = find_partial_die (real_pdi->spec_offset, cu);
15278 +
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);
15282 +
15283 +  if (!cu->has_namespace_info && pdi->linkage_name
15284 +      && !real_pdi->die_parent)
15285 +    {
15286 +      char *actual_scope
15287 +       = language_class_name_from_physname (cu->language_defn,
15288 +                                            pdi->linkage_name);
15289 +      if (actual_scope != NULL)
15290 +       {
15291 +         char *actual_name = typename_concat (NULL, actual_scope,
15292 +                                              pdi->name, cu);
15293 +         xfree (actual_scope);
15294 +         return actual_name;
15295 +       }
15296 +    }
15297 +
15298 +  return NULL;
15299  }
15300  
15301  static void
15302 @@ -1984,7 +2167,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
15303  
15304    baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
15305  
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))
15310      {
15311        actual_name = partial_die_full_name (pdi, cu);
15312        if (actual_name)
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
15316        && psym != NULL
15317 -      && SYMBOL_CPLUS_DEMANGLED_NAME (psym) != NULL)
15318 -    cp_check_possible_namespace_symbols (SYMBOL_CPLUS_DEMANGLED_NAME (psym),
15319 -                                        objfile);
15320 +      && pdi->linkage_name != NULL)
15321 +    cp_check_possible_namespace_symbols (actual_name, objfile);
15322  
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:
15331 +      return 1;
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
15336 +        class prefix.  */
15337        return 1;
15338      default:
15339        return 0;
15340 @@ -2290,11 +2482,11 @@ guess_structure_name (struct partial_die_info *struct_pdi,
15341  
15342        while (child_pdi != NULL)
15343         {
15344 -         if (child_pdi->tag == DW_TAG_subprogram)
15345 +         if (child_pdi->tag == DW_TAG_subprogram && child_pdi->linkage_name)
15346             {
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)
15352                 {
15353                   struct_pdi->name
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;
15360  
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)
15363  
15364    cu->list_in_scope = &file_symbols;
15365  
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.  */
15371 -
15372 -  cu->base_known = 0;
15373 -  cu->base_address = 0;
15374 -
15375 -  attr = dwarf2_attr (cu->dies, DW_AT_entry_pc, cu);
15376 -  if (attr)
15377 -    {
15378 -      cu->base_address = DW_ADDR (attr);
15379 -      cu->base_known = 1;
15380 -    }
15381 -  else
15382 -    {
15383 -      attr = dwarf2_attr (cu->dies, DW_AT_low_pc, cu);
15384 -      if (attr)
15385 -       {
15386 -         cu->base_address = DW_ADDR (attr);
15387 -         cu->base_known = 1;
15388 -       }
15389 -    }
15390 +  dwarf2_find_base_address (cu->dies, cu);
15391  
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)
15395  static void
15396  process_die (struct die_info *die, struct dwarf2_cu *cu)
15397  {
15398 +
15399    switch (die->tag)
15400      {
15401      case DW_TAG_padding:
15402 @@ -2849,6 +3018,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
15403  
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
15408           DW_AT_name.  */
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)
15411        break;
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
15418 -        Fortran case.  */
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);
15427        break;
15428      default:
15429        new_symbol (die, NULL, cu);
15430 @@ -2904,22 +3072,130 @@ dwarf2_full_name (struct die_info *die, struct dwarf2_cu *cu)
15431      return name;
15432  
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))
15442      return name;
15443  
15444    prefix = determine_prefix (die, cu);
15445    if (*prefix != '\0')
15446 -    name = typename_concat (&cu->objfile->objfile_obstack, prefix,
15447 -                           name, cu);
15448 +    {
15449 +      char *prefixed_name = typename_concat (NULL, prefix, name, cu);
15450 +      buf = mem_fileopen ();
15451 +      fputs_unfiltered (prefixed_name, buf);
15452 +      xfree (prefixed_name);
15453 +    }
15454 +
15455 +  if (cu->language == language_cplus && die->tag == DW_TAG_subprogram)
15456 +    {
15457 +      struct type *type = read_type_die (die, cu);
15458 +
15459 +      if (buf == NULL)
15460 +       {
15461 +         buf = mem_fileopen ();
15462 +         fputs_unfiltered (name, buf);
15463 +       }
15464 +
15465 +      c_type_print_args (type, buf, 0);
15466 +    }
15467 +
15468 +  if (buf != NULL)
15469 +    {
15470 +      long length;
15471 +      name = ui_file_obsavestring (buf, &cu->objfile->objfile_obstack,
15472 +                                  &length);
15473 +      ui_file_delete (buf);
15474 +    }
15475  
15476    return name;
15477  }
15478  
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;
15482 +
15483 +  line_attr = dwarf2_attr (die, DW_AT_decl_line, cu);
15484 +  if (line_attr){
15485 +    return  DW_UNSND (line_attr);
15486 +  }
15487 +
15488 +  return -1;
15489 +}
15490 +
15491 +/* Read the import statement specified by the given die and record it.  */ 
15492 +
15493 +static void
15494 +read_import_statement (struct die_info *die, struct dwarf2_cu *cu)
15495 +{
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;
15504 +  
15505 +  int line_number = -1;
15506 +  
15507 +  int is_anonymous = 0;
15508 +  
15509 +  import_attr = dwarf2_attr (die, DW_AT_import, cu);
15510 +  if (import_attr == NULL)
15511 +    {
15512 +      complaint (&symfile_complaints, _("Tag '%s' has no DW_AT_import"),
15513 +                dwarf_tag_name (die->tag));
15514 +      return;
15515 +    }
15516 +
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)
15520 +    {
15521 +      /* C++ imports from std:: DW_TAG_base_type with no DW_AT_name - why?  */
15522 +      return;
15523 +    }
15524 +
15525 +  /* Figure out the local name after import.  */
15526 +  import_alias = dwarf2_name(die, cu);
15527 +  if(import_alias == NULL){
15528 +    import_alias = "";
15529 +  }
15530 +  
15531 +  /* Determine the line number at which the import was made */
15532 +  line_number = dwarf2_read_decl_line(die, cu);
15533 +  
15534 +  /* Figure out where the statement is being imported to */
15535 +  import_prefix = determine_prefix (die, cu);
15536 +
15537 +  /*
15538 +   Figure out what the scope of the imported die is and prepend it
15539 +   to the name of the imported die
15540 +   */
15541 +  imported_name_prefix = determine_prefix (imported_die, cu);
15542 +  
15543 +  if(imported_die->tag != DW_TAG_namespace){
15544 +    imported_declaration = imported_name;
15545 +    canonical_name = (char*)imported_name_prefix;
15546 +  }else{
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);
15552 +    }else{
15553 +      canonical_name = alloca (strlen (imported_name) + 1);
15554 +      strcpy (canonical_name, imported_name);
15555 +    }
15556 +  }
15557 +  
15558 +  using_directives = cp_add_using (import_prefix,
15559 +                                   canonical_name,
15560 +                                   import_alias,
15561 +                                   imported_declaration,
15562 +                                   line_number,
15563 +                                   using_directives);
15564 +}
15565 +
15566  static void
15567  initialize_cu_func_list (struct dwarf2_cu *cu)
15568  {
15569 @@ -3076,6 +3352,103 @@ add_to_cu_func_list (const char *name, CORE_ADDR lowpc, CORE_ADDR highpc,
15570    cu->last_fn = thisfn;
15571  }
15572  
15573 +static int
15574 +unsigned_int_compar (const void *ap, const void *bp)
15575 +{
15576 +  unsigned int a = *(unsigned int *) ap;
15577 +  unsigned int b = *(unsigned int *) bp;
15578 +
15579 +  return (a > b) - (b > a);
15580 +}
15581 +
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;
15586 +  
15587 +  attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
15588 +  
15589 +  /* GCC currently uses DW_AT_specification to indicate die inheritence
15590 +     in the case of import statements. The following is to accommodate that */
15591 +  if(!attr){
15592 +    attr = dwarf2_attr (die, DW_AT_specification, cu);
15593 +  }
15594 +  
15595 +  if (attr)
15596 +    {
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;
15602 +
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 "
15607 +                     "tags"),
15608 +                   die->offset, origin_die->offset);
15609 +
15610 +      offsets = xmalloc (sizeof (*offsets) * die_children);
15611 +      cleanups = make_cleanup (xfree, offsets);
15612 +
15613 +      offsets_end = offsets;
15614 +      child_die = die->child;
15615 +      while (child_die && child_die->tag)
15616 +        {
15617 +          attr = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
15618 +          if (!attr)
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);
15623 +          else
15624 +            {
15625 +              struct die_info *child_origin_die;
15626 +
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;
15634 +            }
15635 +          child_die = sibling_die (child_die);
15636 +        }
15637 +      qsort (offsets, offsets_end - offsets, sizeof (*offsets),
15638 +             unsigned_int_compar);
15639 +      /* Disabled as excessively expensive - check if we may ever complain.  */
15640 +      if (0)
15641 +        {
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);
15648 +        }
15649 +
15650 +      offsetp = offsets;
15651 +      origin_child_die = origin_die->child;
15652 +      while (origin_child_die && origin_child_die->tag)
15653 +        {
15654 +          /* Is origin_child_die referenced by any of the DIE children?  */
15655 +          while (offsetp < offsets_end && *offsetp < origin_child_die->offset)
15656 +            offsetp++;
15657 +          if (offsetp >= offsets_end || *offsetp > origin_child_die->offset)
15658 +            {
15659 +              /* Found that origin_child_die is really not referenced.  */
15660 +              process_die (origin_child_die, cu);
15661 +            }
15662 +          origin_child_die = sibling_die (origin_child_die);
15663 +        }
15664 +
15665 +      do_cleanups (cleanups);
15666 +    }
15667 +  
15668 +}
15669 +
15670  static void
15671  read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15672  {
15673 @@ -3088,16 +3461,27 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15674    char *name;
15675    CORE_ADDR baseaddr;
15676    struct block *block;
15677 +  unsigned die_children = 0;
15678  
15679    baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
15680  
15681 -  name = dwarf2_linkage_name (die, cu);
15682 +  name = dwarf2_name (die, cu);
15683  
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)
15692 +      {
15693 +       child_die = sibling_die (child_die);
15694 +       die_children++;
15695 +      }
15696 +    explore_abstract_origin(die, cu, &die_children);
15697      return;
15698 -
15699 +  }
15700 +  
15701    lowpc += baseaddr;
15702    highpc += baseaddr;
15703  
15704 @@ -3124,16 +3508,91 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
15705  
15706    cu->list_in_scope = &local_symbols;
15707  
15708 -  if (die->child != NULL)
15709 +  child_die = die->child;
15710 +  die_children = 0;
15711 +  while (child_die && child_die->tag)
15712 +    {
15713 +      process_die (child_die, cu);
15714 +      child_die = sibling_die (child_die);
15715 +      die_children++;
15716 +    }
15717 +
15718 +  attr = dwarf2_attr (die, DW_AT_abstract_origin, cu);
15719 +  if (attr)
15720      {
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;
15726 +
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 "
15731 +                    "tags"),
15732 +                  die->offset, origin_die->offset);
15733 +
15734 +      offsets = xmalloc (sizeof (*offsets) * die_children);
15735 +      cleanups = make_cleanup (xfree, offsets);
15736 +
15737 +      offsets_end = offsets;
15738        child_die = die->child;
15739        while (child_die && child_die->tag)
15740         {
15741 -         process_die (child_die, cu);
15742 +         attr = dwarf2_attr (child_die, DW_AT_abstract_origin, cu);
15743 +         if (!attr)
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);
15748 +         else
15749 +           {
15750 +             struct die_info *child_origin_die;
15751 +
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;
15759 +           }
15760           child_die = sibling_die (child_die);
15761         }
15762 +      qsort (offsets, offsets_end - offsets, sizeof (*offsets),
15763 +            unsigned_int_compar);
15764 +      /* Disabled as excessively expensive - check if we may ever complain.  */
15765 +      if (0)
15766 +       {
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);
15773 +       }
15774 +
15775 +      offsetp = offsets;
15776 +      origin_child_die = origin_die->child;
15777 +      while (origin_child_die && origin_child_die->tag)
15778 +       {
15779 +         /* Is origin_child_die referenced by any of the DIE children?  */
15780 +         while (offsetp < offsets_end && *offsetp < origin_child_die->offset)
15781 +           offsetp++;
15782 +         if (offsetp >= offsets_end || *offsetp > origin_child_die->offset)
15783 +           {
15784 +             /* Found that origin_child_die is really not referenced.  */
15785 +             process_die (origin_child_die, cu);
15786 +           }
15787 +         origin_child_die = sibling_die (origin_child_die);
15788 +       }
15789 +
15790 +      do_cleanups (cleanups);
15791      }
15792  
15793 +  explore_abstract_origin(die, cu, &die_children);
15794 +
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;
15803  
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))
15812      return;
15813    lowpc += baseaddr;
15814    highpc += baseaddr;
15815 @@ -3197,7 +3657,7 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
15816      }
15817    new = pop_context ();
15818  
15819 -  if (local_symbols != NULL)
15820 +  if (local_symbols != NULL || using_directives!= NULL )
15821      {
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);
15826      }
15827    local_symbols = new->locals;
15828 +  using_directives = new->using_directives;
15829  }
15830  
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.  */
15834  static int
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)
15839  {
15840    struct attribute *attr;
15841    CORE_ADDR low = 0;
15842 @@ -3379,7 +3841,7 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE_ADDR *lowpc,
15843         {
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))
15848             return 0;
15849           /* Found discontinuous range of addresses.  */
15850           ret = -1;
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;
15854  
15855 -  if (dwarf2_get_pc_bounds (die, &low, &high, cu))
15856 +  if (dwarf2_get_pc_bounds (die, &low, &high, cu, NULL))
15857      {
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;
15863  
15864 -  if (dwarf2_get_pc_bounds (die, &current_low, &current_high, cu))
15865 +  if (dwarf2_get_pc_bounds (die, &current_low, &current_high, cu, NULL))
15866      {
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)
15871         return;
15872  
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);
15882  
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)
15887      return;
15888  
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);
15898  
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)
15909      {
15910 @@ -4110,7 +4584,7 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
15911      return NULL;
15912  
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)
15920    if (type)
15921      return type;
15922  
15923 -  type = alloc_type (objfile);
15924 +  type = alloc_type (objfile, NULL);
15925    INIT_CPLUS_SPECIFIC (type);
15926    name = dwarf2_name (die, cu);
15927    if (name != NULL)
15928 @@ -4360,7 +4834,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
15929    struct attribute *attr;
15930    const char *name;
15931  
15932 -  type = alloc_type (objfile);
15933 +  type = alloc_type (objfile, NULL);
15934  
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)
15938         {
15939           if (child->tag == DW_TAG_subprogram)
15940             {
15941 -             char *phys_prefix
15942 +             char *phys_prefix;
15943 +             char *linkage_name = dwarf2_linkage_name (child, cu);
15944 +
15945 +             if (linkage_name == NULL)
15946 +               continue;
15947 +
15948 +             phys_prefix
15949                 = language_class_name_from_physname (cu->language_defn,
15950 -                                                    dwarf2_linkage_name
15951 -                                                    (child, cu));
15952 +                                                    linkage_name);
15953  
15954               if (phys_prefix != NULL)
15955                 {
15956 @@ -4510,6 +4989,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
15957    new_symbol (die, this_type, cu);
15958  }
15959  
15960 +/* Create a new array dimension referencing its target type TYPE.
15961 +
15962 +   Multidimensional arrays are internally represented as a stack of
15963 +   singledimensional arrays being referenced by their TYPE_TARGET_TYPE.  */
15964 +
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)
15968 +{
15969 +  type = create_array_type (NULL, type, range_type);
15970 +
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);
15975 +
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);
15979 +
15980 +  return type;
15981 +}
15982 +
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
15985     arrays.  */
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;
15990 -  int ndim = 0;
15991 +  int ndim = 0, i;
15992    struct cleanup *back_to;
15993    char *name;
15994  
15995 @@ -4570,16 +5072,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
15996    type = element_type;
15997  
15998    if (read_array_order (die, cu) == DW_ORD_col_major)
15999 -    {
16000 -      int i = 0;
16001 -      while (i < ndim)
16002 -       type = create_array_type (NULL, type, range_types[i++]);
16003 -    }
16004 -  else
16005 -    {
16006 -      while (ndim-- > 0)
16007 -       type = create_array_type (NULL, type, range_types[ndim]);
16008 -    }
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);
16014  
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);
16019  }
16020  
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.  */
16026  
16027  static void
16028  read_common_block (struct die_info *die, struct dwarf2_cu *cu)
16029  {
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)
16035      }
16036    if (die->child != NULL)
16037      {
16038 +      struct objfile *objfile = cu->objfile;
16039 +      struct die_info *child_die;
16040 +      struct type *type;
16041 +      struct field *field;
16042 +      char *name;
16043 +      struct symbol *sym;
16044 +
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>";
16049 +
16050        child_die = die->child;
16051        while (child_die && child_die->tag)
16052         {
16053 +         TYPE_NFIELDS (type)++;
16054 +         child_die = sibling_die (child_die);
16055 +       }
16056 +
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));
16062 +      
16063 +      field = TYPE_FIELDS (type);
16064 +      child_die = die->child;
16065 +      while (child_die && child_die->tag)
16066 +       {
16067 +         /* Create the symbol in the DW_TAG_common_block block in the current
16068 +            symbol scope.  */
16069           sym = new_symbol (child_die, NULL, cu);
16070 +
16071 +         /* Undocumented in DWARF3, when it can be present?  */
16072           attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
16073           if (attr)
16074             {
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);
16078             }
16079 +
16080 +         if (SYMBOL_CLASS (sym) == LOC_STATIC)
16081 +           SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
16082 +         else
16083 +           SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
16084 +         FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
16085 +         FIELD_NAME (*field) = SYMBOL_NATURAL_NAME (sym);
16086 +         field++;
16087           child_die = sibling_die (child_die);
16088         }
16089 +
16090 +      /* TYPE_LENGTH (type) is left 0 - it is only a virtual structure even
16091 +        with no consecutive address space.  */
16092 +
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;
16096 +
16097 +      set_die_type (die, type, cu);
16098      }
16099  }
16100  
16101 @@ -4756,9 +5302,7 @@ read_namespace (struct die_info *die, struct dwarf2_cu *cu)
16102        if (is_anonymous)
16103         {
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));
16109         }
16110      }
16111  
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;
16117 +  int length;
16118 +
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);
16124 +
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;
16128  
16129    attr = dwarf2_attr (die, DW_AT_string_length, cu);
16130 -  if (attr)
16131 -    {
16132 -      length = DW_UNSND (attr);
16133 -    }
16134 -  else
16135 -    {
16136 -      /* check for the DW_AT_byte_size attribute */
16137 +  switch (dwarf2_get_attr_constant_value (attr, &length))
16138 +    {
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.  */
16143 +      /* PASSTHRU */
16144 +    case dwarf2_attr_unknown:
16145        attr = dwarf2_attr (die, DW_AT_byte_size, cu);
16146 -      if (attr)
16147 -        {
16148 -          length = DW_UNSND (attr);
16149 -        }
16150 -      else
16151 -        {
16152 -          length = 1;
16153 -        }
16154 +      switch (dwarf2_get_attr_constant_value (attr, &length))
16155 +       {
16156 +       case dwarf2_attr_unknown:
16157 +         length = 1;
16158 +         /* PASSTHRU */
16159 +       case dwarf2_attr_const:
16160 +         TYPE_HIGH_BOUND (range_type) = length;
16161 +         break;
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;
16167 +         break;
16168 +       }
16169 +      break;
16170 +    case dwarf2_attr_block:
16171 +      /* Security check for a size overflow.  */
16172 +      if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
16173 +       {
16174 +         TYPE_HIGH_BOUND (range_type) = 1;
16175 +         break;
16176 +       }
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
16179 +        its value.  */
16180 +      {
16181 +       struct dwarf2_locexpr_baton *length_baton;
16182 +       struct attribute *size_attr;
16183 +
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);
16191 +
16192 +       /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH specifies
16193 +          the size of an integer to fetch.  */
16194 +
16195 +       size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
16196 +       if (size_attr)
16197 +         {
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"));
16207 +         }
16208 +       else
16209 +         {
16210 +           length_baton->size = DW_BLOCK (attr)->size + 1;
16211 +           length_baton->data[DW_BLOCK (attr)->size] = DW_OP_deref;
16212 +         }
16213 +
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;
16217 +      }
16218 +      break;
16219      }
16220  
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);
16224  
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)
16228  {
16229    struct objfile *objfile = cu->objfile;
16230 -  struct attribute *attr;
16231    const char *name = NULL;
16232    struct type *this_type;
16233  
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;
16238 -  int low = 0;
16239 -  int high = -1;
16240 +  int low, high, byte_stride_int;
16241 +  enum dwarf2_get_attr_constant_value high_type;
16242    char *name;
16243    
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);
16247      }
16248  
16249 -  if (cu->language == language_fortran)
16250 -    { 
16251 -      /* FORTRAN implies a lower bound of 1, if not given.  */
16252 -      low = 1;
16253 -    }
16254 +  /* LOW_BOUND and HIGH_BOUND are set for real below.  */
16255 +  range_type = create_range_type (NULL, base_type, 0, -1);
16256  
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);
16261 -  if (attr)
16262 -    low = dwarf2_get_attr_constant_value (attr, 0);
16263 +  switch (dwarf2_get_attr_constant_value (attr, &low))
16264 +    {
16265 +    case dwarf2_attr_unknown:
16266 +      if (cu->language == language_fortran)
16267 +       {
16268 +         /* FORTRAN implies a lower bound of 1, if not given.  */
16269 +         low = 1;
16270 +       }
16271 +      else
16272 +        {
16273 +         /* According to DWARF we should assume the value 0 only for
16274 +            LANGUAGE_C and LANGUAGE_CPLUS.  */
16275 +         low = 0;
16276 +       }
16277 +      /* PASSTHRU */
16278 +    case dwarf2_attr_const:
16279 +      TYPE_LOW_BOUND (range_type) = low;
16280 +      if (low >= 0)
16281 +       TYPE_UNSIGNED (range_type) = 1;
16282 +      break;
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
16286 +                                                                    (attr, cu);
16287 +      TYPE_DYNAMIC (range_type) = 1;
16288 +      /* For setting a default if DW_AT_UPPER_BOUND would be missing.  */
16289 +      low = 0;
16290 +      break;
16291 +    }
16292  
16293    attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
16294 -  if (attr)
16295 -    {       
16296 -      if (attr->form == DW_FORM_block1)
16297 -        {
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
16302 -             length for now.
16303 -
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.  */
16309 -          high = low - 1;
16310 -        }
16311 -      else
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)
16315 +    {
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)
16320 +       {
16321 +         TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
16322 +         TYPE_DYNAMIC (range_type) = 1;
16323 +       }
16324 +      /* Pass it now as the regular DW_AT_upper_bound.  */
16325 +    }
16326 +  switch (high_type)
16327 +    {
16328 +    case dwarf2_attr_unknown:
16329 +      TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (range_type) = 1;
16330 +      high = low - 1;
16331 +      /* PASSTHRU */
16332 +    case dwarf2_attr_const:
16333 +      TYPE_HIGH_BOUND (range_type) = high;
16334 +      break;
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
16338 +                                                                    (attr, cu);
16339 +      TYPE_DYNAMIC (range_type) = 1;
16340 +      break;
16341      }
16342  
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))
16347 +    {
16348 +    case dwarf2_attr_unknown:
16349 +      break;
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;
16355 +      break;
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
16359 +                                                                    (attr, cu);
16360 +      TYPE_DYNAMIC (range_type) = 1;
16361 +      break;
16362 +    }
16363  
16364    name = dwarf2_name (die, cu);
16365    if (name)
16366 @@ -5386,10 +6043,13 @@ read_die_and_siblings (gdb_byte *info_ptr, bfd *abfd,
16367  }
16368  
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
16373 +   used.  */
16374  
16375  static void
16376 -zlib_decompress_section (struct objfile *objfile, asection *sectp,
16377 +zlib_decompress_section (struct objfile *objfile, struct obstack *obstack,
16378 +                        asection *sectp,
16379                           gdb_byte **outbuf, bfd_size_type *outsize)
16380  {
16381    bfd *abfd = objfile->obfd;
16382 @@ -5405,6 +6065,7 @@ zlib_decompress_section (struct objfile *objfile, asection *sectp,
16383    z_stream strm;
16384    int rc;
16385    int header_size = 12;
16386 +  struct cleanup *old = NULL;
16387  
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);
16396 +  if (obstack)
16397 +    uncompressed_buffer = obstack_alloc (obstack, uncompressed_size);
16398 +  else
16399 +    {
16400 +      uncompressed_buffer = xmalloc (uncompressed_size);
16401 +      old = make_cleanup (xfree, uncompressed_buffer);
16402 +    }
16403    rc = inflateInit (&strm);
16404    while (strm.avail_in > 0)
16405      {
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);
16409  
16410 +  if (old)
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,
16416  }
16417  
16418  
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.  */
16426  
16427 -gdb_byte *
16428 -dwarf2_read_section (struct objfile *objfile, asection *sectp)
16429 +static gdb_byte *
16430 +dwarf2_read_section_1 (struct objfile *objfile, struct obstack *obstack,
16431 +                      asection *sectp)
16432  {
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;
16438  
16439    if (size == 0)
16440      return 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)
16444          {
16445 -          zlib_decompress_section (objfile, sectp, &buf, &size);
16446 +          zlib_decompress_section (objfile, obstack, sectp, &buf, &size);
16447            dwarf2_resize_section (sectp, size);
16448            return buf;
16449          }
16450      }
16451  
16452    /* If we get here, we are a normal, not-compressed section.  */
16453 -  buf = obstack_alloc (&objfile->objfile_obstack, size);
16454 +  if (obstack)
16455 +    buf = obstack_alloc (obstack, size);
16456 +  else
16457 +    {
16458 +      buf = xmalloc (size);
16459 +      old = make_cleanup (xfree, buf);
16460 +    }
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)
16467 -    return retbuf;
16468 +    {
16469 +      if (old)
16470 +       discard_cleanups (old);
16471 +      return retbuf;
16472 +    }
16473  
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));
16478  
16479 +  if (old)
16480 +    discard_cleanups (old);
16481 +
16482    return buf;
16483  }
16484  
16485 +gdb_byte *
16486 +dwarf2_read_section (struct objfile *objfile, asection *sectp)
16487 +{
16488 +  return dwarf2_read_section_1 (objfile, &objfile->objfile_obstack, sectp);
16489 +}
16490 +
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;
16499 -  enum
16500 -    {
16501 -      base_address_none,
16502 -      base_address_low_pc,
16503 -      /* Overrides BASE_ADDRESS_LOW_PC.  */
16504 -      base_address_entry_pc
16505 -    }
16506 -  base_address_type = base_address_none;
16507  
16508    memset (part_die, 0, sizeof (struct partial_die_info));
16509  
16510 @@ -5945,47 +6626,35 @@ read_partial_die (struct partial_die_info *part_die,
16511        switch (attr.name)
16512         {
16513         case DW_AT_name:
16514 -
16515 -         /* Prefer DW_AT_MIPS_linkage_name over DW_AT_name.  */
16516 -         if (part_die->name == NULL)
16517 -           part_die->name = DW_STRING (&attr);
16518 -         break;
16519 -       case DW_AT_comp_dir:
16520 -         if (part_die->dirname == NULL)
16521 -           part_die->dirname = DW_STRING (&attr);
16522 +         switch (part_die->tag)
16523 +           {
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);
16532 +             break;
16533 +           default:
16534 +             part_die->name
16535 +               = dwarf2_canonicalize_name (DW_STRING (&attr), cu,
16536 +                                           &cu->comp_unit_obstack);
16537 +             break;
16538 +           }
16539           break;
16540         case DW_AT_MIPS_linkage_name:
16541 -         part_die->name = DW_STRING (&attr);
16542 +         part_die->linkage_name = DW_STRING (&attr);
16543           break;
16544         case DW_AT_low_pc:
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)
16549 -           {
16550 -             base_address = DW_ADDR (&attr);
16551 -             base_address_type = base_address_low_pc;
16552 -           }
16553           break;
16554         case DW_AT_high_pc:
16555           has_high_pc_attr = 1;
16556           part_die->highpc = DW_ADDR (&attr);
16557           break;
16558 -       case DW_AT_entry_pc:
16559 -         if (part_die->tag == DW_TAG_compile_unit
16560 -             && base_address_type < base_address_entry_pc)
16561 -           {
16562 -             base_address = DW_ADDR (&attr);
16563 -             base_address_type = base_address_entry_pc;
16564 -           }
16565 -         break;
16566 -       case DW_AT_ranges:
16567 -         if (part_die->tag == DW_TAG_compile_unit)
16568 -           {
16569 -             cu->ranges_offset = DW_UNSND (&attr);
16570 -             cu->has_ranges_offset = 1;
16571 -           }
16572 -         break;
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");
16578              }
16579           break;
16580 -       case DW_AT_language:
16581 -         part_die->language = DW_UNSND (&attr);
16582 -         break;
16583         case DW_AT_external:
16584           part_die->is_external = DW_UNSND (&attr);
16585           break;
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);
16589           break;
16590 -        case DW_AT_stmt_list:
16591 -          part_die->has_stmt_list = 1;
16592 -          part_die->line_offset = DW_UNSND (&attr);
16593 -          break;
16594          case DW_AT_byte_size:
16595            part_die->has_byte_size = 1;
16596            break;
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;
16600  
16601 -  if (base_address_type != base_address_none && !cu->base_known)
16602 -    {
16603 -      gdb_assert (part_die->tag == DW_TAG_compile_unit);
16604 -      cu->base_known = 1;
16605 -      cu->base_address = base_address;
16606 -    }
16607 -
16608    return info_ptr;
16609  }
16610  
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.  */
16614  
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))
16619      {
16620        struct partial_die_info *spec_die;
16621  
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;
16625         }
16626 +
16627 +      if (spec_die->linkage_name)
16628 +       part_die->linkage_name = spec_die->linkage_name;
16629      }
16630  
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.
16638 +     
16639 +     SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed.  */
16640  
16641 -  dwarf2_symbol_mark_computed (attr, sym, cu);
16642    SYMBOL_CLASS (sym) = LOC_COMPUTED;
16643 +  dwarf2_symbol_mark_computed (attr, sym, cu);
16644  }
16645  
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));
16649  
16650    if (die->tag != DW_TAG_namespace)
16651 -    name = dwarf2_linkage_name (die, cu);
16652 +    name = dwarf2_name (die, cu);
16653    else
16654      name = TYPE_NAME (type);
16655  
16656    if (name)
16657      {
16658 +      const char *linkagename;
16659 +
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;
16666  
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);
16670 +
16671 +      /* Cache this symbol's name and the name's demangled form (if any).  */
16672 +
16673 +      linkagename = dwarf2_linkage_name (die, cu);
16674 +      if (linkagename)
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);
16681 +      else
16682 +       {
16683 +         linkagename = dwarf2_full_name (die, cu);
16684 +
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);
16690 +       }
16691  
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)
16695           if (attr)
16696             {
16697               var_decode_location (attr, sym, cu);
16698 -             attr2 = dwarf2_attr (die, DW_AT_external, cu);
16699 +
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
16703 +                imported.  */
16704 +             if (cu->language == language_fortran)
16705 +               attr2 = NULL;
16706 +             else
16707 +               attr2 = dwarf2_attr (die, DW_AT_external, cu);
16708               if (attr2 && (DW_UNSND (attr2) != 0))
16709                 add_symbol_to_list (sym, &global_symbols);
16710               else
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);
16714           break;
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);
16719 +         break;
16720         default:
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)
16724        break;
16725      }
16726  
16727 +  if (this_type)
16728 +    finalize_type (this_type);
16729 +
16730    return this_type;
16731  }
16732  
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.  */
16736           return "";
16737 +
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.  */
16748 +       return "";
16749 +
16750        default:
16751         return determine_prefix (parent, cu);
16752        }
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);
16760    return NULL;
16761  }
16762  
16763  /* Get name of a die, return NULL if not found.  */
16764  
16765  static char *
16766 +dwarf2_canonicalize_name (char *name, struct dwarf2_cu *cu,
16767 +                         struct obstack *obstack)
16768 +{
16769 +  if (name && cu->language == language_cplus)
16770 +    {
16771 +      char *canon_name = cp_canonicalize_string (name);
16772 +
16773 +      if (canon_name != NULL)
16774 +       {
16775 +         if (strcmp (canon_name, name) != 0)
16776 +           name = obsavestring (canon_name, strlen (canon_name),
16777 +                                obstack);
16778 +         xfree (canon_name);
16779 +       }
16780 +    }
16781 +
16782 +  return name;
16783 +}
16784 +
16785 +/* Get name of a die, return NULL if not found.  */
16786 +
16787 +static char *
16788  dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
16789  {
16790    struct attribute *attr;
16791  
16792    attr = dwarf2_attr (die, DW_AT_name, cu);
16793 -  if (attr && DW_STRING (attr))
16794 -    return DW_STRING (attr);
16795 -  return NULL;
16796 +  if (!attr || !DW_STRING (attr))
16797 +    return NULL;
16798 +
16799 +  switch (die->tag)
16800 +    {
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);
16809 +    default:
16810 +      if (attr->form != GDB_FORM_cached_string)
16811 +       {
16812 +         DW_STRING (attr)
16813 +           = dwarf2_canonicalize_name (DW_STRING (attr), cu,
16814 +                                       &cu->objfile->objfile_obstack);
16815 +         attr->form = GDB_FORM_cached_string;
16816 +       }
16817 +      return DW_STRING (attr);
16818 +    }
16819  }
16820  
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";
16828      default:
16829        return "DW_FORM_<unknown>";
16830      }
16831 @@ -9248,6 +10003,7 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die)
16832           break;
16833         case DW_FORM_string:
16834         case DW_FORM_strp:
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)
16840    return result;
16841  }
16842  
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.  */
16846  
16847 -static int
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)
16851  {
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);
16862 -  else
16863      {
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;
16869      }
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)
16875 +    {
16876 +      *val_return = DW_UNSND (attr);
16877 +      return dwarf2_attr_const;
16878 +    }
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;
16887  }
16888  
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,
16891  {
16892    gdb_byte *mac_ptr, *mac_end;
16893    struct macro_source_file *current_file = 0;
16894 +  enum dwarf_macinfo_record_type macinfo_type;
16895 +
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.  */
16903 +
16904 +  int at_commandline;
16905  
16906    if (dwarf2_per_objfile->macinfo_buffer == NULL)
16907      {
16908 @@ -9970,19 +10746,24 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
16909        return;
16910      }
16911  
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
16917 +     file name.  */
16918 +
16919    mac_ptr = dwarf2_per_objfile->macinfo_buffer + offset;
16920    mac_end = dwarf2_per_objfile->macinfo_buffer
16921      + dwarf2_per_objfile->macinfo_size;
16922  
16923 -  for (;;)
16924 +  do
16925      {
16926 -      enum dwarf_macinfo_record_type macinfo_type;
16927 -
16928        /* Do we at least have room for a macinfo type byte?  */
16929        if (mac_ptr >= mac_end)
16930          {
16931           dwarf2_macros_too_long_complaint ();
16932 -          return;
16933 +         break;
16934          }
16935  
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
16939               information.  */
16940          case 0:
16941 -          return;
16942 +         break;
16943 +
16944 +       case DW_MACINFO_define:
16945 +       case DW_MACINFO_undef:
16946 +         /* Only skip the data by MAC_PTR.  */
16947 +         {
16948 +           unsigned int bytes_read;
16949 +
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;
16954 +         }
16955 +         break;
16956 +
16957 +       case DW_MACINFO_start_file:
16958 +         {
16959 +           unsigned int bytes_read;
16960 +           int line, file;
16961 +
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;
16966 +
16967 +           current_file = macro_start_file (file, line, current_file, comp_dir,
16968 +                                            lh, cu->objfile);
16969 +         }
16970 +         break;
16971 +
16972 +       case DW_MACINFO_end_file:
16973 +         /* No data to skip by MAC_PTR.  */
16974 +         break;
16975 +
16976 +       case DW_MACINFO_vendor_ext:
16977 +         /* Only skip the data by MAC_PTR.  */
16978 +         {
16979 +           unsigned int bytes_read;
16980 +
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;
16985 +         }
16986 +         break;
16987 +
16988 +       default:
16989 +         break;
16990 +       }
16991 +    } while (macinfo_type != 0 && current_file == NULL);
16992 +
16993 +  /* Here is the second pass to read in the macros starting from the ones
16994 +     defined at the command line.  */
16995 +
16996 +  mac_ptr = dwarf2_per_objfile->macinfo_buffer + offset;
16997 +  at_commandline = 1;
16998 +
16999 +  do
17000 +    {
17001 +      /* Do we at least have room for a macinfo type byte?  */
17002 +      if (mac_ptr >= mac_end)
17003 +       {
17004 +         /* Complaint is in the first pass above.  */
17005 +         break;
17006 +       }
17007 +
17008 +      macinfo_type = read_1_byte (abfd, mac_ptr);
17009 +      mac_ptr++;
17010 +
17011 +      switch (macinfo_type)
17012 +       {
17013 +         /* A zero macinfo type indicates the end of the macro
17014 +            information.  */
17015 +       case 0:
17016 +         break;
17017  
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;
17022  
17023              if (! current_file)
17024 +             {
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"),
17029 +                          macinfo_type ==
17030 +                          DW_MACINFO_define ? _("definition") : macinfo_type ==
17031 +                          DW_MACINFO_undef ? _("undefinition") :
17032 +                          "something-or-other", line, body);
17033 +               break;
17034 +             }
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"),
17040                          macinfo_type ==
17041 -                        DW_MACINFO_define ? "definition" : macinfo_type ==
17042 -                        DW_MACINFO_undef ? "undefinition" :
17043 -                        "something-or-other", body);
17044 -            else
17045 -              {
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);
17050 -              }
17051 +                        DW_MACINFO_define ? _("definition") : macinfo_type ==
17052 +                        DW_MACINFO_undef ? _("undefinition") :
17053 +                        "something-or-other",
17054 +                        line == 0 ? _("zero") : _("non-zero"), line, body);
17055 +
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);
17060            }
17061            break;
17062  
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;
17066  
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);
17076 +
17077 +           if (at_commandline)
17078 +             {
17079 +               /* This DW_MACINFO_start_file was executed in the pass one.  */
17080 +               at_commandline = 0;
17081 +             }
17082 +           else
17083 +             current_file = macro_start_file (file, line,
17084 +                                              current_file, comp_dir,
17085 +                                              lh, cu->objfile);
17086            }
17087            break;
17088  
17089 @@ -10090,7 +10970,7 @@ dwarf_decode_macros (struct line_header *lh, unsigned int offset,
17090            }
17091            break;
17092          }
17093 -    }
17094 +    } while (macinfo_type != 0);
17095  }
17096  
17097  /* Check if the attribute's form is a DW_FORM_block*
17098 @@ -10150,6 +11030,34 @@ attr_form_is_constant (struct attribute *attr)
17099      }
17100  }
17101  
17102 +/* Convert DW_BLOCK into struct dwarf2_locexpr_baton.  ATTR must be a DW_BLOCK
17103 +   attribute type.  */
17104 +
17105 +static struct dwarf2_locexpr_baton *
17106 +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
17107 +{
17108 +  struct dwarf2_locexpr_baton *baton;
17109 +
17110 +  gdb_assert (attr_form_is_block (attr));
17111 +
17112 +  baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
17113 +  baton->per_cu = cu->per_cu;
17114 +  gdb_assert (baton->per_cu);
17115 +
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);
17124 +
17125 +  return baton;
17126 +}
17127 +
17128 +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content.  */
17129 +
17130  static void
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;
17136      }
17137 +  else if (attr_form_is_block (attr))
17138 +    {
17139 +      SYMBOL_OPS (sym) = &dwarf2_locexpr_funcs;
17140 +      SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
17141 +    }
17142    else
17143      {
17144 -      struct dwarf2_locexpr_baton *baton;
17145 +      dwarf2_invalid_attrib_class_complaint ("location description",
17146 +                                            SYMBOL_NATURAL_NAME (sym));
17147  
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;
17155  
17156 -      if (attr_form_is_block (attr))
17157 -       {
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;
17165 -       }
17166 -      else
17167 -       {
17168 -         dwarf2_invalid_attrib_class_complaint ("location description",
17169 -                                                SYMBOL_NATURAL_NAME (sym));
17170 -         baton->size = 0;
17171 -         baton->data = NULL;
17172 -       }
17173 -      
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;
17180      }
17181  }
17182  
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;
17185  }
17186  
17187 +/* Fill in generic attributes applicable for type DIEs.  */
17188 +
17189 +static void
17190 +fetch_die_type_attrs (struct die_info *die, struct type *type,
17191 +                     struct dwarf2_cu *cu)
17192 +{
17193 +  struct attribute *attr;
17194 +
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,
17198 +                                                                         cu);
17199 +  gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
17200 +
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));
17205 +
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));
17210 +}
17211 +
17212  /* Set the type associated with DIE to TYPE.  Save it in CU's hash
17213     table if necessary.  For convenience, return TYPE.  */
17214  
17215 @@ -10490,6 +11412,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
17216  {
17217    struct dwarf2_offset_and_type **slot, ofs;
17218  
17219 +  fetch_die_type_attrs (die, type, cu);
17220 +
17221    if (cu->type_hash == NULL)
17222      {
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)
17229                                 str_sect->filepos,
17230                                 bfd_section_size (abfd, str_sect));
17231      }
17232 +
17233 +  if (dwarf2_has_info (objfile))
17234 +    dwarf2_create_quick_addrmap (objfile);
17235 +}
17236 +
17237 +static void
17238 +read_psyms (struct objfile *objfile)
17239 +{
17240    if (dwarf2_has_info (objfile))
17241      {
17242        /* DWARF 2 sections */
17243 -      dwarf2_build_psymtabs (objfile, mainline);
17244 +      dwarf2_build_psymtabs (objfile, 0);
17245      }
17246  
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
17258 --- a/gdb/eval.c
17259 +++ b/gdb/eval.c
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"
17269  
17270  #include "gdb_assert.h"
17271  
17272 +#include <ctype.h>
17273 +
17274  /* This is defined in valops.c */
17275  extern int overload_resolution;
17276  
17277 @@ -651,6 +657,64 @@ ptrmath_type_p (struct type *type)
17278      }
17279  }
17280  
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. */
17285 +int
17286 +compare_parameters (struct type *t1, struct type *t2)
17287 +{
17288 +  int i, has_this;
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;
17295 +  else
17296 +    has_this = 0;
17297 +
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)
17302 +    return 1;
17303 +
17304 +  if ((TYPE_NFIELDS (t1) - has_this) == TYPE_NFIELDS (t2))
17305 +    {
17306 +      for (i = has_this; i < TYPE_NFIELDS (t1); ++i)
17307 +       {
17308 +         if (rank_one_type (TYPE_FIELD_TYPE (t1, i),
17309 +                            TYPE_FIELD_TYPE (t2, i - has_this))
17310 +             != 0)
17311 +           return 0;
17312 +       }
17313 +
17314 +      return 1;
17315 +    }
17316 +
17317 +  return 0;
17318 +}
17319 +
17320 +/* Constructs a fake method with the given parameter types. */
17321 +
17322 +static struct type *
17323 +make_params (int num_types, struct type **param_types)
17324 +{
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);
17332 +
17333 +  while (num_types-- > 0)
17334 +    TYPE_FIELD_TYPE (type, num_types) = param_types[num_types];
17335 +
17336 +  return type;
17337 +}
17338 +
17339  struct value *
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,
17343    long mem_offset;
17344    struct type **arg_types;
17345    int save_pos1;
17346 +  struct cleanup *old_chain;
17347  
17348    pc = (*pos)++;
17349    op = exp->elts[pc].opcode;
17350 @@ -684,7 +749,7 @@ evaluate_subexp_standard (struct type *expect_type,
17351         goto nosideret;
17352        arg1 = value_aggregate_elt (exp->elts[pc + 1].type,
17353                                   &exp->elts[pc + 3].string,
17354 -                                 0, noside);
17355 +                                 expect_type, 0, noside);
17356        if (arg1 == NULL)
17357         error (_("There is no field named %s"), &exp->elts[pc + 3].string);
17358        return arg1;
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"));
17362             if (struct_return)
17363 -             VALUE_ADDRESS (method) = value_as_address (msg_send_stret);
17364 +             set_value_address (method, value_as_address (msg_send_stret));
17365             else
17366 -             VALUE_ADDRESS (method) = value_as_address (msg_send);
17367 +             set_value_address (method, value_as_address (msg_send));
17368             called_method = method;
17369           }
17370         else
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)
17374         {
17375 -         nargs++;
17376           /* First, evaluate the structure into arg2 */
17377           pc2 = (*pos)++;
17378  
17379 @@ -1308,21 +1372,40 @@ evaluate_subexp_standard (struct type *expect_type,
17380  
17381           arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
17382  
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 "
17386 -                    "construct"));
17387 -
17388 -         if (noside == EVAL_AVOID_SIDE_EFFECTS)
17389 +         type = check_typedef (value_type (arg1));
17390 +         switch (TYPE_CODE (type))
17391             {
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);
17397 +             else
17398 +               arg1 = cplus_method_ptr_to_value (&arg2, arg1);
17399 +
17400 +             /* Now, say which argument to start evaluating from */
17401 +             nargs++;
17402 +             tem = 2;
17403 +             argvec[1] = arg2;
17404 +             break;
17405 +
17406 +           case TYPE_CODE_MEMBERPTR:
17407 +             /* Now, convert these values to an address.  */
17408 +             arg2 = value_cast (lookup_pointer_type (TYPE_DOMAIN_TYPE (type)),
17409 +                                arg2);
17410 +
17411 +             mem_offset = value_as_long (arg1);
17412 +
17413 +             arg1 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
17414 +                                        value_as_long (arg2) + mem_offset);
17415 +             arg1 = value_ind (arg1);
17416 +             tem = 1;
17417 +             break;
17418 +
17419 +           default:
17420 +             error (_("Non-pointer-to-member value used in pointer-to-member "
17421 +                      "construct"));
17422             }
17423 -         else
17424 -           arg1 = cplus_method_ptr_to_value (&arg2, arg1);
17425  
17426 -         /* Now, say which argument to start evaluating from */
17427 -         tem = 2;
17428 +         argvec[0] = arg1;
17429         }
17430        else if (op == STRUCTOP_STRUCT || op == STRUCTOP_PTR)
17431         {
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 */
17440             }
17441 @@ -1448,8 +1531,7 @@ evaluate_subexp_standard (struct type *expect_type,
17442         }
17443        else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
17444         {
17445 -         argvec[1] = arg2;
17446 -         argvec[0] = arg1;
17447 +         /* Pointer to member.  argvec is already set up.  */
17448         }
17449        else if (op == OP_VAR_VALUE)
17450         {
17451 @@ -1512,6 +1594,9 @@ evaluate_subexp_standard (struct type *expect_type,
17452           else
17453             error (_("Expression of type other than \"Function returning ...\" used as function"));
17454         }
17455 +      if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_INTERNAL_FUNCTION)
17456 +       return call_internal_function (argvec[0], nargs, argvec + 1);
17457 +
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  */
17460  
17461 @@ -1529,7 +1614,10 @@ evaluate_subexp_standard (struct type *expect_type,
17462  
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);
17470  
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"));
17474         }
17475  
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;
17481 +
17482 +      expect_type = make_params (nargs, arg_types);
17483 +      *(pos) += 3 + nargs;
17484 +      return evaluate_subexp_standard (expect_type, exp, pos, noside);
17485 +
17486 +    case TYPE_INSTANCE_LOOKUP:
17487 +      {
17488 +       int i;
17489 +       struct symbol *sym;
17490 +       struct type **arg_types;
17491 +       (*pos) += 3;
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,
17502 +                                   &sym, NULL);
17503 +       i = 0;
17504 +      }
17505 +      break;
17506 +
17507      case BINOP_CONCAT:
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,
17511        {
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;
17520  
17521         if (nargs > MAX_FORTRAN_DIMS)
17522           error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
17523  
17524 +       old_chain = make_cleanup (null_cleanup, 0);
17525 +       object_address_set (VALUE_ADDRESS (arg1));
17526 +
17527         tmp_type = check_typedef (value_type (arg1));
17528         ndimensions = calc_f77_array_dims (type);
17529  
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);
17533  
17534 +           byte_stride_array[nargs - i - 1] =
17535 +                                       TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
17536 +
17537             array_size_array[nargs - i - 1] = upper - lower + 1;
17538  
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));
17542           }
17543  
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);
17547  
17548 -       offset_item = subscript_array[ndimensions - 1];
17549 +       /* Now let us calculate the offset for this item */
17550  
17551 -       for (i = ndimensions - 1; i > 0; --i)
17552 -         offset_item =
17553 -           array_size_array[i - 1] * offset_item + subscript_array[i - 1];
17554 +       offset_item = 0;
17555 +       offset_byte = 0;
17556  
17557 -       /* Construct a value node with the value of the offset */
17558 +       for (i = ndimensions - 1; i >= 0; --i)
17559 +         {
17560 +           offset_item *= array_size_array[i];
17561 +           if (byte_stride_array[i] == 0)
17562 +             offset_item += subscript_array[i];
17563 +           else
17564 +             offset_byte += subscript_array[i] * byte_stride_array[i];
17565 +         }
17566  
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;
17570  
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 */
17575  
17576         deprecated_set_value_type (arg1, tmp_type);
17577 -       return value_subscripted_rvalue (arg1, arg2, 0);
17578 +       return value_subscripted_rvalue (arg1, offset_byte);
17579        }
17580  
17581      case BINOP_LOGICAL_AND:
17582 @@ -2475,7 +2611,17 @@ evaluate_subexp_standard (struct type *expect_type,
17583        if (noside == EVAL_SKIP)
17584          goto nosideret;
17585        else if (noside == EVAL_AVOID_SIDE_EFFECTS)
17586 -        return allocate_value (exp->elts[pc + 1].type);
17587 +       {
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
17592 +            typedefs.  */
17593 +         check_typedef (type);
17594 +         if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
17595 +           type = TYPE_TARGET_TYPE (type);
17596 +         return allocate_value (type);
17597 +       }
17598        else
17599          error (_("Attempt to use a type name as an expression"));
17600  
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,
17605 -                              1, noside);
17606 +                              NULL, 1, noside);
17607        if (x == NULL)
17608         error (_("There is no field named %s"), &exp->elts[pc + 3].string);
17609        return x;
17610 @@ -2613,7 +2759,7 @@ evaluate_subexp_with_coercion (struct expression *exp,
17611  {
17612    enum exp_opcode op;
17613    int pc;
17614 -  struct value *val;
17615 +  struct value *val = NULL;
17616    struct symbol *var;
17617    struct type *type;
17618  
17619 @@ -2624,12 +2770,17 @@ evaluate_subexp_with_coercion (struct expression *exp,
17620      {
17621      case OP_VAR_VALUE:
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)
17630         {
17631           (*pos) += 4;
17632 -         val = address_of_variable (var, exp->elts[pc + 1].block);
17633 +         if (!val)
17634 +           val = address_of_variable (var, exp->elts[pc + 1].block);
17635           return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
17636                              val);
17637         }
17638 @@ -2681,9 +2832,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
17639  
17640      case OP_VAR_VALUE:
17641        (*pos) += 4;
17642 -      type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
17643 -      return
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));
17652  
17653      default:
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,
17664 -                        &opts);
17665 +       LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17666 +                        &exp->elts[pc + 2].string, nargs, 0, &opts);
17667        }
17668        return;
17669  
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,
17675 -                        &opts);
17676 +       LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17677 +                        &exp->elts[pc + 2].string, nargs, 0, &opts);
17678         fputs_filtered ("\"", stream);
17679        }
17680        return;
17681 @@ -291,8 +291,8 @@ print_subexp_standard (struct expression *exp, int *pos,
17682         {
17683           struct value_print_options opts;
17684           get_user_print_options (&opts);
17685 -         LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
17686 -                          &opts);
17687 +         LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
17688 +                          tempstr, nargs - 1, 0, &opts);
17689           (*pos) = pc;
17690         }
17691        else
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.  */
17698      STRUCTOP_MPTR,
17699  
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*/
17703 +    TYPE_INSTANCE,
17704 +
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,
17709 +
17710      /* end of C++.  */
17711  
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);
17716  
17717 +extern int compare_parameters (struct type *, struct type *);
17718 +
17719  /* From expprint.c */
17720  
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 *);
17725  
17726 +
17727  #endif /* !defined (EXPRESSION_H) */
17728 diff --git a/gdb/f-exp.y b/gdb/f-exp.y
17729 index d91c413..c984e85 100644
17730 --- a/gdb/f-exp.y
17731 +++ b/gdb/f-exp.y
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; }
17742         |       CHARACTER 
17743                         { $$ = parse_f_type->builtin_character; }
17744 +       |       LOGICAL_S8_KEYWORD
17745 +                       { $$ = parse_f_type->builtin_logical_s8;}
17746         |       LOGICAL_KEYWORD 
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
17759 --- a/gdb/f-lang.c
17760 +++ b/gdb/f-lang.c
17761 @@ -55,23 +55,10 @@ typedef struct saved_bf_symnum SAVED_BF, *SAVED_BF_PTR;
17762  /* Local functions */
17763  
17764  extern void _initialize_f_language (void);
17765 -#if 0
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);
17778 -#endif
17779 -
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);
17782 +
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);
17786  
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.  */
17791  
17792  static void
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)
17795  {
17796    c &= 0xFF;                   /* Avoid sign bit follies */
17797  
17798 @@ -126,10 +113,10 @@ f_emit_char (int c, struct ui_file *stream, int quoter)
17799     be replaced with a true F77version. */
17800  
17801  static void
17802 -f_printchar (int c, struct ui_file *stream)
17803 +f_printchar (int c, struct type *type, struct ui_file *stream)
17804  {
17805    fputs_filtered ("'", stream);
17806 -  LA_EMIT_CHAR (c, stream, '\'');
17807 +  LA_EMIT_CHAR (c, type, stream, '\'');
17808    fputs_filtered ("'", stream);
17809  }
17810  
17811 @@ -141,14 +128,15 @@ f_printchar (int c, struct ui_file *stream)
17812     be replaced with a true F77 version. */
17813  
17814  static void
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)
17820  {
17821    unsigned int i;
17822    unsigned int things_printed = 0;
17823    int in_quotes = 0;
17824    int need_comma = 0;
17825 +  int width = TYPE_LENGTH (type);
17826  
17827    if (length == 0)
17828      {
17829 @@ -190,7 +178,7 @@ f_printstr (struct ui_file *stream, const gdb_byte *string,
17830                 fputs_filtered ("', ", stream);
17831               in_quotes = 0;
17832             }
17833 -         f_printchar (string[i], stream);
17834 +         f_printchar (string[i], type, stream);
17835           fprintf_filtered (stream, " <repeats %u times>", reps);
17836           i = rep1 - 1;
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);
17840               in_quotes = 1;
17841             }
17842 -         LA_EMIT_CHAR (string[i], stream, '"');
17843 +         LA_EMIT_CHAR (string[i], type, stream, '"');
17844           ++things_printed;
17845         }
17846      }
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);
17867  
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);
17872 +
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)
17877  
17878    add_language (&f_language_defn);
17879  }
17880 -
17881 -#if 0
17882 -static SAVED_BF_PTR
17883 -allocate_saved_bf_node (void)
17884 -{
17885 -  SAVED_BF_PTR new;
17886 -
17887 -  new = (SAVED_BF_PTR) xmalloc (sizeof (SAVED_BF));
17888 -  return (new);
17889 -}
17890 -
17891 -static SAVED_FUNCTION *
17892 -allocate_saved_function_node (void)
17893 -{
17894 -  SAVED_FUNCTION *new;
17895 -
17896 -  new = (SAVED_FUNCTION *) xmalloc (sizeof (SAVED_FUNCTION));
17897 -  return (new);
17898 -}
17899 -
17900 -static SAVED_F77_COMMON_PTR
17901 -allocate_saved_f77_common_node (void)
17902 -{
17903 -  SAVED_F77_COMMON_PTR new;
17904 -
17905 -  new = (SAVED_F77_COMMON_PTR) xmalloc (sizeof (SAVED_F77_COMMON));
17906 -  return (new);
17907 -}
17908 -
17909 -static COMMON_ENTRY_PTR
17910 -allocate_common_entry_node (void)
17911 -{
17912 -  COMMON_ENTRY_PTR new;
17913 -
17914 -  new = (COMMON_ENTRY_PTR) xmalloc (sizeof (COMMON_ENTRY));
17915 -  return (new);
17916 -}
17917 -#endif
17918 -
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 */
17922 -
17923 -#if 0
17924 -static SAVED_BF_PTR saved_bf_list = NULL;      /* Ptr to (.bf,function) 
17925 -                                                  list */
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
17928 -                                                        */
17929 -
17930 -static SAVED_BF_PTR tmp_bf_ptr;        /* Generic temporary for use 
17931 -                                  in macros */
17932 -
17933 -/* The following function simply enters a given common block onto 
17934 -   the global common block chain */
17935 -
17936 -static void
17937 -add_common_block (char *name, CORE_ADDR offset, int secnum, char *func_stab)
17938 -{
17939 -  SAVED_F77_COMMON_PTR tmp;
17940 -  char *c, *local_copy_func_stab;
17941 -
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. */
17946 -
17947 -
17948 -  if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
17949 -      || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
17950 -    {
17951 -
17952 -      xfree (name);
17953 -      name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
17954 -      strcpy (name, BLANK_COMMON_NAME_LOCAL);
17955 -    }
17956 -
17957 -  tmp = allocate_saved_f77_common_node ();
17958 -
17959 -  local_copy_func_stab = xmalloc (strlen (func_stab) + 1);
17960 -  strcpy (local_copy_func_stab, func_stab);
17961 -
17962 -  tmp->name = xmalloc (strlen (name) + 1);
17963 -
17964 -  /* local_copy_func_stab is a stabstring, let us first extract the 
17965 -     function name from the stab by NULLing out the ':' character. */
17966 -
17967 -
17968 -  c = NULL;
17969 -  c = strchr (local_copy_func_stab, ':');
17970 -
17971 -  if (c)
17972 -    *c = '\0';
17973 -  else
17974 -    error (_("Malformed function STAB found in add_common_block()"));
17975 -
17976 -
17977 -  tmp->owning_function = xmalloc (strlen (local_copy_func_stab) + 1);
17978 -
17979 -  strcpy (tmp->owning_function, local_copy_func_stab);
17980 -
17981 -  strcpy (tmp->name, name);
17982 -  tmp->offset = offset;
17983 -  tmp->next = NULL;
17984 -  tmp->entries = NULL;
17985 -  tmp->secnum = secnum;
17986 -
17987 -  current_common = tmp;
17988 -
17989 -  if (head_common_list == NULL)
17990 -    {
17991 -      head_common_list = tail_common_list = tmp;
17992 -    }
17993 -  else
17994 -    {
17995 -      tail_common_list->next = tmp;
17996 -      tail_common_list = tmp;
17997 -    }
17998 -}
17999 -#endif
18000 -
18001 -/* The following function simply enters a given common entry onto 
18002 -   the "current_common" block that has been saved away. */
18003 -
18004 -#if 0
18005 -static void
18006 -add_common_entry (struct symbol *entry_sym_ptr)
18007 -{
18008 -  COMMON_ENTRY_PTR tmp;
18009 -
18010 -
18011 -
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 */
18015 -
18016 -  tmp = allocate_common_entry_node ();
18017 -
18018 -  tmp->next = NULL;
18019 -  tmp->symbol = entry_sym_ptr;
18020 -
18021 -  if (current_common == NULL)
18022 -    error (_("Attempt to add COMMON entry with no block open!"));
18023 -  else
18024 -    {
18025 -      if (current_common->entries == NULL)
18026 -       {
18027 -         current_common->entries = tmp;
18028 -         current_common->end_of_entries = tmp;
18029 -       }
18030 -      else
18031 -       {
18032 -         current_common->end_of_entries->next = tmp;
18033 -         current_common->end_of_entries = tmp;
18034 -       }
18035 -    }
18036 -}
18037 -#endif
18038 -
18039 -/* This routine finds the first encountred COMMON block named "name" */
18040 -
18041 -#if 0
18042 -static SAVED_F77_COMMON_PTR
18043 -find_first_common_named (char *name)
18044 -{
18045 -
18046 -  SAVED_F77_COMMON_PTR tmp;
18047 -
18048 -  tmp = head_common_list;
18049 -
18050 -  while (tmp != NULL)
18051 -    {
18052 -      if (strcmp (tmp->name, name) == 0)
18053 -       return (tmp);
18054 -      else
18055 -       tmp = tmp->next;
18056 -    }
18057 -  return (NULL);
18058 -}
18059 -#endif
18060 -
18061 -/* This routine finds the first encountred COMMON block named "name" 
18062 -   that belongs to function funcname */
18063 -
18064 -SAVED_F77_COMMON_PTR
18065 -find_common_for_function (char *name, char *funcname)
18066 -{
18067 -
18068 -  SAVED_F77_COMMON_PTR tmp;
18069 -
18070 -  tmp = head_common_list;
18071 -
18072 -  while (tmp != NULL)
18073 -    {
18074 -      if (strcmp (tmp->name, name) == 0
18075 -         && strcmp (tmp->owning_function, funcname) == 0)
18076 -       return (tmp);
18077 -      else
18078 -       tmp = tmp->next;
18079 -    }
18080 -  return (NULL);
18081 -}
18082 -
18083 -
18084 -#if 0
18085 -
18086 -/* The following function is called to patch up the offsets 
18087 -   for the statics contained in the COMMON block named
18088 -   "name."  */
18089 -
18090 -static void
18091 -patch_common_entries (SAVED_F77_COMMON_PTR blk, CORE_ADDR offset, int secnum)
18092 -{
18093 -  COMMON_ENTRY_PTR entry;
18094 -
18095 -  blk->offset = offset;                /* Keep this around for future use. */
18096 -
18097 -  entry = blk->entries;
18098 -
18099 -  while (entry != NULL)
18100 -    {
18101 -      SYMBOL_VALUE (entry->symbol) += offset;
18102 -      SYMBOL_SECTION (entry->symbol) = secnum;
18103 -
18104 -      entry = entry->next;
18105 -    }
18106 -  blk->secnum = secnum;
18107 -}
18108 -
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). */
18114 -
18115 -static void
18116 -patch_all_commons_by_name (char *name, CORE_ADDR offset, int secnum)
18117 -{
18118 -
18119 -  SAVED_F77_COMMON_PTR tmp;
18120 -
18121 -  /* For blank common blocks, change the canonical reprsentation 
18122 -     of a blank name */
18123 -
18124 -  if (strcmp (name, BLANK_COMMON_NAME_ORIGINAL) == 0
18125 -      || strcmp (name, BLANK_COMMON_NAME_MF77) == 0)
18126 -    {
18127 -      xfree (name);
18128 -      name = alloca (strlen (BLANK_COMMON_NAME_LOCAL) + 1);
18129 -      strcpy (name, BLANK_COMMON_NAME_LOCAL);
18130 -    }
18131 -
18132 -  tmp = head_common_list;
18133 -
18134 -  while (tmp != NULL)
18135 -    {
18136 -      if (COMMON_NEEDS_PATCHING (tmp))
18137 -       if (strcmp (tmp->name, name) == 0)
18138 -         patch_common_entries (tmp, offset, secnum);
18139 -
18140 -      tmp = tmp->next;
18141 -    }
18142 -}
18143 -#endif
18144 -
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. */
18152 -
18153 -#if 0
18154 -#define ADD_BF_SYMNUM(bf_sym,fcn_sym) \
18155 -  \
18156 -  if (saved_bf_list == NULL) \
18157 -{ \
18158 -    tmp_bf_ptr = allocate_saved_bf_node(); \
18159 -      \
18160 -       tmp_bf_ptr->symnum_bf = (bf_sym); \
18161 -         tmp_bf_ptr->symnum_fcn = (fcn_sym);  \
18162 -           tmp_bf_ptr->next = NULL; \
18163 -             \
18164 -               current_head_bf_list = saved_bf_list = tmp_bf_ptr; \
18165 -                 saved_bf_list_end = tmp_bf_ptr; \
18166 -                 } \
18167 -else \
18168 -{  \
18169 -     tmp_bf_ptr = allocate_saved_bf_node(); \
18170 -       \
18171 -         tmp_bf_ptr->symnum_bf = (bf_sym);  \
18172 -          tmp_bf_ptr->symnum_fcn = (fcn_sym);  \
18173 -            tmp_bf_ptr->next = NULL;  \
18174 -              \
18175 -                saved_bf_list_end->next = tmp_bf_ptr;  \
18176 -                  saved_bf_list_end = tmp_bf_ptr; \
18177 -                  }
18178 -#endif
18179 -
18180 -/* This function frees the entire (.bf,function) list */
18181 -
18182 -#if 0
18183 -static void
18184 -clear_bf_list (void)
18185 -{
18186 -
18187 -  SAVED_BF_PTR tmp = saved_bf_list;
18188 -  SAVED_BF_PTR next = NULL;
18189 -
18190 -  while (tmp != NULL)
18191 -    {
18192 -      next = tmp->next;
18193 -      xfree (tmp);
18194 -      tmp = next;
18195 -    }
18196 -  saved_bf_list = NULL;
18197 -}
18198 -#endif
18199 -
18200 -int global_remote_debug;
18201 -
18202 -#if 0
18203 -
18204 -static long
18205 -get_bf_for_fcn (long the_function)
18206 -{
18207 -  SAVED_BF_PTR tmp;
18208 -  int nprobes = 0;
18209 -
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)  */
18212 -
18213 -  if (saved_bf_list == NULL)
18214 -    internal_error (__FILE__, __LINE__,
18215 -                   _("cannot get .bf node off empty list"));
18216 -
18217 -  if (current_head_bf_list != NULL)
18218 -    if (current_head_bf_list->symnum_fcn == the_function)
18219 -      {
18220 -       if (global_remote_debug)
18221 -         fprintf_unfiltered (gdb_stderr, "*");
18222 -
18223 -       tmp = current_head_bf_list;
18224 -       current_head_bf_list = current_head_bf_list->next;
18225 -       return (tmp->symnum_bf);
18226 -      }
18227 -
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 */
18231 -
18232 -  if (global_remote_debug)
18233 -    fprintf_unfiltered (gdb_stderr, "\ndefaulting to linear scan\n");
18234 -
18235 -  nprobes = 0;
18236 -  tmp = saved_bf_list;
18237 -  while (tmp != NULL)
18238 -    {
18239 -      nprobes++;
18240 -      if (tmp->symnum_fcn == the_function)
18241 -       {
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);
18246 -       }
18247 -      tmp = tmp->next;
18248 -    }
18249 -
18250 -  return (-1);
18251 -}
18252 -
18253 -static SAVED_FUNCTION_PTR saved_function_list = NULL;
18254 -static SAVED_FUNCTION_PTR saved_function_list_end = NULL;
18255 -
18256 -static void
18257 -clear_function_list (void)
18258 -{
18259 -  SAVED_FUNCTION_PTR tmp = saved_function_list;
18260 -  SAVED_FUNCTION_PTR next = NULL;
18261 -
18262 -  while (tmp != NULL)
18263 -    {
18264 -      next = tmp->next;
18265 -      xfree (tmp);
18266 -      tmp = next;
18267 -    }
18268 -
18269 -  saved_function_list = NULL;
18270 -}
18271 -#endif
18272 diff --git a/gdb/f-lang.h b/gdb/f-lang.h
18273 index 711bdba..cd2f804 100644
18274 --- a/gdb/f-lang.h
18275 +++ b/gdb/f-lang.h
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,
18278                           int);
18279  
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);
18283 +
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)"  */
18289    };
18290  
18291 -struct common_entry
18292 -  {
18293 -    struct symbol *symbol;     /* The symbol node corresponding
18294 -                                  to this component */
18295 -    struct common_entry *next; /* The next component */
18296 -  };
18297 -
18298 -struct saved_f77_common
18299 -  {
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 
18304 -                                  this block */
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 */
18308 -  };
18309 -
18310 -typedef struct saved_f77_common SAVED_F77_COMMON, *SAVED_F77_COMMON_PTR;
18311 -
18312 -typedef struct common_entry COMMON_ENTRY, *COMMON_ENTRY_PTR;
18313 -
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 */
18317 -
18318 -extern SAVED_F77_COMMON_PTR find_common_for_function (char *, char *);
18319 -
18320 -#define UNINITIALIZED_SECNUM -1
18321 -#define COMMON_NEEDS_PATCHING(blk) ((blk)->secnum == UNINITIALIZED_SECNUM)
18322 -
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 */
18326  
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
18341 @@ -31,7 +31,7 @@
18342  #include "gdbcore.h"
18343  #include "target.h"
18344  #include "f-lang.h"
18345 -
18346 +#include "dwarf2loc.h"
18347  #include "gdb_string.h"
18348  #include <errno.h>
18349  
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);
18352  \f
18353  
18354 +const char *
18355 +f_object_address_data_valid_print_to_stream (struct type *type,
18356 +                                            struct ui_file *stream)
18357 +{
18358 +  const char *msg;
18359 +
18360 +  msg = object_address_data_not_valid (type);
18361 +  if (msg != NULL)
18362 +    {
18363 +      /* Assuming the content printed to STREAM should not be localized.  */
18364 +      fprintf_filtered (stream, "<%s>", msg);
18365 +    }
18366 +
18367 +  return msg;
18368 +}
18369 +
18370 +void
18371 +f_object_address_data_valid_or_error (struct type *type)
18372 +{
18373 +  const char *msg;
18374 +
18375 +  msg = object_address_data_not_valid (type);
18376 +  if (msg != NULL)
18377 +    {
18378 +      error (_("Cannot access it because the %s."), _(msg));
18379 +    }
18380 +}
18381 +
18382  /* LEVEL is the depth to indent lines by.  */
18383  
18384  void
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;
18388  
18389 +  if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
18390 +    return;
18391 +
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,
18396  
18397    QUIT;
18398  
18399 +  if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
18400 +    CHECK_TYPEDEF (type);
18401 +
18402    switch (TYPE_CODE (type))
18403      {
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
18409 @@ -34,10 +34,8 @@
18410  #include "gdbcore.h"
18411  #include "command.h"
18412  #include "block.h"
18413 -
18414 -#if 0
18415 -static int there_is_a_visible_common_named (char *);
18416 -#endif
18417 +#include "dictionary.h"
18418 +#include "gdb_assert.h"
18419  
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 
18424     n is 1 based. */
18425  
18426 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
18427 +#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
18428  
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. */
18431  
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])
18434  
18435  int
18436  f77_get_lowerbound (struct type *type)
18437  {
18438 +  f_object_address_data_valid_or_error (type);
18439 +
18440    if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
18441      error (_("Lower bound may not be '*' in F77"));
18442  
18443 @@ -72,14 +72,17 @@ f77_get_lowerbound (struct type *type)
18444  int
18445  f77_get_upperbound (struct type *type)
18446  {
18447 +  f_object_address_data_valid_or_error (type);
18448 +
18449    if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
18450      {
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.  */
18460  
18461 -      return f77_get_lowerbound (type);
18462 +      return f77_get_lowerbound (type) - 1;
18463      }
18464  
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);
18469  
18470 -      F77_DIM_SIZE (ndimen) = upper - lower + 1;
18471 +      F77_DIM_COUNT (ndimen) = upper - lower + 1;
18472 +
18473 +      F77_DIM_BYTE_STRIDE (ndimen) =
18474 +        TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
18475  
18476        tmp_type = TYPE_TARGET_TYPE (tmp_type);
18477        ndimen++;
18478      }
18479  
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 */
18486  
18487    ndimen--;
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)
18493      {
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;
18499      }
18500  }
18501  
18502 @@ -172,34 +180,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
18503  
18504    if (nss != ndimensions)
18505      {
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++)
18508         {
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, ") ");
18517         }
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, "...");
18521      }
18522    else
18523      {
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;
18526            i++, (*elts)++)
18527         {
18528           val_print (TYPE_TARGET_TYPE (type),
18529 -                    valaddr + i * F77_DIM_OFFSET (ndimensions),
18530 +                    valaddr + i * F77_DIM_BYTE_STRIDE (ndimensions),
18531                      0,
18532 -                    address + i * F77_DIM_OFFSET (ndimensions),
18533 +                    address + i * F77_DIM_BYTE_STRIDE (ndimensions),
18534                      stream, recurse, options, current_language);
18535  
18536 -         if (i != (F77_DIM_SIZE (nss) - 1))
18537 +         if (i != (F77_DIM_COUNT (nss) - 1))
18538             fprintf_filtered (stream, ", ");
18539  
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, "...");
18544         }
18545      }
18546 @@ -251,12 +259,16 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18547    CORE_ADDR addr;
18548    int index;
18549  
18550 +  if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
18551 +    return 0;
18552 +
18553    CHECK_TYPEDEF (type);
18554    switch (TYPE_CODE (type))
18555      {
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);
18561        break;
18562  
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')
18567               && addr != 0)
18568 -           i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
18569 +           i = val_print_string (TYPE_TARGET_TYPE (type), addr, -1, stream,
18570                                   options);
18571  
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,
18574             {
18575               fputs_filtered (" ", stream);
18576               LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr),
18577 -                            stream);
18578 +                            type, stream);
18579             }
18580         }
18581        break;
18582 @@ -464,22 +476,54 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
18583    return 0;
18584  }
18585  
18586 -static void
18587 -list_all_visible_commons (char *funname)
18588 +static int
18589 +info_common_command_for_block (struct block *block, struct frame_info *frame,
18590 +                              const char *comname)
18591  {
18592 -  SAVED_F77_COMMON_PTR tmp;
18593 -
18594 -  tmp = head_common_list;
18595 -
18596 -  printf_filtered (_("All COMMON blocks visible at this level:\n\n"));
18597 -
18598 -  while (tmp != NULL)
18599 -    {
18600 -      if (strcmp (tmp->owning_function, funname) == 0)
18601 -       printf_filtered ("%s\n", tmp->name);
18602 -
18603 -      tmp = tmp->next;
18604 -    }
18605 +  struct dict_iterator iter;
18606 +  struct symbol *sym;
18607 +  int values_printed = 0;
18608 +  const char *name;
18609 +  struct value_print_options opts;
18610 +
18611 +  get_user_print_options (&opts);
18612 +
18613 +  ALL_BLOCK_SYMBOLS (block, iter, sym)
18614 +    if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
18615 +      {
18616 +       struct type *type = SYMBOL_TYPE (sym);
18617 +       int index;
18618 +
18619 +       gdb_assert (SYMBOL_CLASS (sym) == LOC_STATIC);
18620 +       gdb_assert (TYPE_CODE (type) == TYPE_CODE_STRUCT);
18621 +
18622 +       if (comname && (!SYMBOL_LINKAGE_NAME (sym)
18623 +                       || strcmp (comname, SYMBOL_LINKAGE_NAME (sym)) != 0))
18624 +         continue;
18625 +
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));
18630 +       else
18631 +         printf_filtered (_("Contents of blank COMMON block:\n"));
18632 +       
18633 +       for (index = 0; index < TYPE_NFIELDS (type); index++)
18634 +         {
18635 +           struct value *val;
18636 +
18637 +           gdb_assert (field_is_static (&TYPE_FIELD (type, index)));
18638 +           val = value_static_field (type, index);
18639 +
18640 +           printf_filtered ("%s = ", TYPE_FIELD_NAME (type, index));
18641 +           value_print (val, gdb_stdout, &opts);
18642 +           putchar_filtered ('\n');
18643 +         }
18644 +
18645 +       putchar_filtered ('\n');
18646 +      }
18647 +
18648 +  return values_printed;
18649  }
18650  
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)
18653  static void
18654  info_common_command (char *comname, int from_tty)
18655  {
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;
18663  
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() */
18669  
18670 -  func = find_pc_function (get_frame_pc (fi));
18671 -  if (func)
18672 -    {
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
18679 -         characters).
18680 -
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) */
18686 -
18687 -      struct minimal_symbol *msymbol = 
18688 -       lookup_minimal_symbol_by_pc (get_frame_pc (fi));
18689 -
18690 -      if (msymbol != NULL
18691 -         && (SYMBOL_VALUE_ADDRESS (msymbol)
18692 -             > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
18693 -       funname = SYMBOL_LINKAGE_NAME (msymbol);
18694 -      else
18695 -       funname = SYMBOL_LINKAGE_NAME (func);
18696 -    }
18697 -  else
18698 -    {
18699 -      struct minimal_symbol *msymbol =
18700 -      lookup_minimal_symbol_by_pc (get_frame_pc (fi));
18701 -
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."));
18706 -    }
18707 -
18708 -  /* If comname is NULL, we assume the user wishes to see the 
18709 -     which COMMON blocks are visible here and then return */
18710 -
18711 -  if (comname == 0)
18712 +  block = get_frame_block (fi, 0);
18713 +  if (block == NULL)
18714      {
18715 -      list_all_visible_commons (funname);
18716 +      printf_filtered (_("No symbol table info available.\n"));
18717        return;
18718      }
18719  
18720 -  the_common = find_common_for_function (comname, funname);
18721 -
18722 -  if (the_common)
18723 +  while (block)
18724      {
18725 -      if (strcmp (comname, BLANK_COMMON_NAME_LOCAL) == 0)
18726 -       printf_filtered (_("Contents of blank COMMON block:\n"));
18727 -      else
18728 -       printf_filtered (_("Contents of F77 COMMON block '%s':\n"), comname);
18729 -
18730 -      printf_filtered ("\n");
18731 -      entry = the_common->entries;
18732 -
18733 -      while (entry != NULL)
18734 -       {
18735 -         print_variable_and_value (NULL, entry->symbol, fi, gdb_stdout, 0);
18736 -         entry = entry->next;
18737 -       }
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))
18743 +       break;
18744 +      block = BLOCK_SUPERBLOCK (block);
18745      }
18746 -  else
18747 -    printf_filtered (_("Cannot locate the common block %s in function '%s'\n"),
18748 -                    comname, funname);
18749 -}
18750 -
18751 -/* This function is used to determine whether there is a
18752 -   F77 common block visible at the current scope called 'comname'. */
18753 -
18754 -#if 0
18755 -static int
18756 -there_is_a_visible_common_named (char *comname)
18757 -{
18758 -  SAVED_F77_COMMON_PTR the_common;
18759 -  struct frame_info *fi;
18760 -  char *funname = 0;
18761 -  struct symbol *func;
18762 -
18763 -  if (comname == NULL)
18764 -    error (_("Cannot deal with NULL common name!"));
18765  
18766 -  fi = get_selected_frame (_("No frame selected"));
18767 -
18768 -  /* The following is generally ripped off from stack.c's routine 
18769 -     print_frame_info() */
18770 -
18771 -  func = find_pc_function (fi->pc);
18772 -  if (func)
18773 +  if (!values_printed)
18774      {
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
18781 -         characters).
18782 -
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) */
18788 -
18789 -      struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (fi->pc);
18790 -
18791 -      if (msymbol != NULL
18792 -         && (SYMBOL_VALUE_ADDRESS (msymbol)
18793 -             > BLOCK_START (SYMBOL_BLOCK_VALUE (func))))
18794 -       funname = SYMBOL_LINKAGE_NAME (msymbol);
18795 +      if (comname)
18796 +       printf_filtered (_("No common block '%s'.\n"), comname);
18797        else
18798 -       funname = SYMBOL_LINKAGE_NAME (func);
18799 +       printf_filtered (_("No common blocks.\n"));
18800      }
18801 -  else
18802 -    {
18803 -      struct minimal_symbol *msymbol =
18804 -      lookup_minimal_symbol_by_pc (fi->pc);
18805 -
18806 -      if (msymbol != NULL)
18807 -       funname = SYMBOL_LINKAGE_NAME (msymbol);
18808 -    }
18809 -
18810 -  the_common = find_common_for_function (comname, funname);
18811 -
18812 -  return (the_common ? 1 : 0);
18813  }
18814 -#endif
18815  
18816  void
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
18822 @@ -26,7 +26,7 @@
18823  
18824  /* Copied from bfd_put_bits.  */
18825  
18826 -static void
18827 +void
18828  put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
18829  {
18830    int i;
18831 @@ -44,6 +44,41 @@ put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p)
18832      }
18833  }
18834  
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.  */
18838 +
18839 +void
18840 +allocate_pattern_buffer (char **pattern_buf, char **pattern_buf_end,
18841 +                        ULONGEST *pattern_buf_size)
18842 +{
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;
18847 +}
18848 +
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.  */
18852 +
18853 +void
18854 +increase_pattern_buffer (char **pattern_buf, char **pattern_buf_end,
18855 +                        ULONGEST *pattern_buf_size, int val_bytes)
18856 +{
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)
18861 +      {
18862 +       size_t current_offset = *pattern_buf_end - *pattern_buf;
18863 +
18864 +       *pattern_buf_size *= 2;
18865 +       *pattern_buf = xrealloc (*pattern_buf, *pattern_buf_size);
18866 +       *pattern_buf_end = *pattern_buf + current_offset;
18867 +      }
18868 +}
18869 +
18870  /* Subroutine of find_command to simplify it.
18871     Parse the arguments of the "find" command.  */
18872  
18873 @@ -59,8 +94,7 @@ parse_find_args (char *args, ULONGEST *max_countp,
18874    char *pattern_buf;
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,
18884    if (args == NULL)
18885      error (_("Missing search parameters."));
18886  
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);
18891  
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));
18896  
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)
18901 -       {
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;
18906 -       }
18907 +      increase_pattern_buffer (&pattern_buf, &pattern_buf_end,
18908 +                              &pattern_buf_size, val_bytes);
18909  
18910        if (size != '\0')
18911         {
18912 @@ -236,6 +261,45 @@ parse_find_args (char *args, ULONGEST *max_countp,
18913    discard_cleanups (old_cleanups);
18914  }
18915  
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.
18924 +
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).  */
18927 +
18928 +int
18929 +search_memory (CORE_ADDR *start_addr, ULONGEST *search_space_len,
18930 +              const char *pattern_buf, ULONGEST pattern_len,
18931 +              CORE_ADDR *found_addr)
18932 +{
18933 +  /* Offset from start of this iteration to the next iteration.  */
18934 +  ULONGEST next_iter_incr;
18935 +  int found;
18936 +    
18937 +  found = target_search_memory (*start_addr, *search_space_len,
18938 +                               pattern_buf, pattern_len, found_addr);
18939 +  if (found <= 0)
18940 +    return found;
18941 +
18942 +  /* Begin next iteration at one byte past this match.  */
18943 +  next_iter_incr = (*found_addr - *start_addr) + 1;
18944 +
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;
18948 +  else
18949 +    *search_space_len = 0;
18950 +  *start_addr += next_iter_incr;
18951 +
18952 +  return found;
18953 +}
18954 +
18955  static void
18956  find_command (char *args, int from_tty)
18957  {
18958 @@ -264,12 +328,11 @@ find_command (char *args, int from_tty)
18959    while (search_space_len >= pattern_len
18960          && found_count < max_count)
18961      {
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);
18967 +      int found;
18968  
18969 +      found = search_memory (&start_addr, &search_space_len, pattern_buf,
18970 +                            pattern_len, &found_addr);
18971        if (found <= 0)
18972         break;
18973  
18974 @@ -277,16 +340,6 @@ find_command (char *args, int from_tty)
18975        printf_filtered ("\n");
18976        ++found_count;
18977        last_found_addr = found_addr;
18978 -
18979 -      /* Begin next iteration at one byte past this match.  */
18980 -      next_iter_incr = (found_addr - start_addr) + 1;
18981 -
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;
18985 -      else
18986 -       search_space_len = 0;
18987 -      start_addr += next_iter_incr;
18988      }
18989  
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
18995 @@ -35,6 +35,7 @@
18996  #include "user-regs.h"
18997  #include "block.h"
18998  #include "objfiles.h"
18999 +#include "dwarf2loc.h"
19000  
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.  */
19021  
19022  struct value *
19023  read_var_value (struct symbol *var, struct frame_info *frame)
19024  {
19025 -  struct value *v;
19026    struct type *type = SYMBOL_TYPE (var);
19027    CORE_ADDR addr;
19028 -  int len;
19029 -
19030 -  if (SYMBOL_CLASS (var) == LOC_COMPUTED
19031 -      || SYMBOL_CLASS (var) == LOC_REGISTER)
19032 -    /* These cases do not use V.  */
19033 -    v = NULL;
19034 -  else
19035 -    {
19036 -      v = allocate_value (type);
19037 -      VALUE_LVAL (v) = lval_memory;    /* The most likely possibility.  */
19038 -    }
19039 -
19040 -  len = TYPE_LENGTH (type);
19041  
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))
19046      {
19047      case LOC_CONST:
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;
19052 -      return v;
19053 +      {
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));
19059 +       return v;
19060 +      }
19061  
19062      case LOC_LABEL:
19063 -      /* Put the constant back in target format.  */
19064 -      if (overlay_debugging)
19065 -       {
19066 -         CORE_ADDR addr
19067 -           = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
19068 -                                       SYMBOL_OBJ_SECTION (var));
19069 -         store_typed_address (value_contents_raw (v), type, addr);
19070 -       }
19071 -      else
19072 -       store_typed_address (value_contents_raw (v), type,
19073 -                             SYMBOL_VALUE_ADDRESS (var));
19074 -      VALUE_LVAL (v) = not_lval;
19075 -      return v;
19076 +      {
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)
19081 +         {
19082 +           CORE_ADDR addr
19083 +             = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
19084 +                                         SYMBOL_OBJ_SECTION (var));
19085 +           store_typed_address (value_contents_raw (v), type, addr);
19086 +         }
19087 +       else
19088 +         store_typed_address (value_contents_raw (v), type,
19089 +                               SYMBOL_VALUE_ADDRESS (var));
19090 +       return v;
19091 +      }
19092  
19093      case LOC_CONST_BYTES:
19094        {
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));
19100         return v;
19101        }
19102  
19103 @@ -476,12 +474,23 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19104        break;
19105  
19106      case LOC_BLOCK:
19107 -      if (overlay_debugging)
19108 -       VALUE_ADDRESS (v) = symbol_overlayed_address
19109 -         (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
19110 -      else
19111 -       VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
19112 -      return v;
19113 +      {
19114 +        CORE_ADDR addr;
19115 +       struct value *v;
19116 +
19117 +       if (overlay_debugging)
19118 +         addr = symbol_overlayed_address
19119 +           (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
19120 +       else
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;
19128 +       return v;
19129 +      }
19130  
19131      case LOC_REGISTER:
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."));
19135  
19136             addr = value_as_address (regval);
19137 -           VALUE_LVAL (v) = lval_memory;
19138           }
19139         else
19140           {
19141 @@ -542,18 +550,33 @@ read_var_value (struct symbol *var, struct frame_info *frame)
19142        break;
19143  
19144      case LOC_OPTIMIZED_OUT:
19145 -      VALUE_LVAL (v) = not_lval;
19146 -      set_value_optimized_out (v, 1);
19147 -      return v;
19148 +      {
19149 +        struct value *v = allocate_value (type);
19150 +
19151 +       VALUE_LVAL (v) = not_lval;
19152 +       set_value_optimized_out (v, 1);
19153 +       return v;
19154 +      }
19155  
19156      default:
19157        error (_("Cannot look up value of a botched symbol."));
19158        break;
19159      }
19160  
19161 -  VALUE_ADDRESS (v) = addr;
19162 -  set_value_lazy (v, 1);
19163 -  return v;
19164 +  {
19165 +    struct value *v;
19166 +
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;
19173 +
19174 +    set_value_lazy (v, 1);
19175 +
19176 +    return v;
19177 +  }
19178  }
19179  
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)
19183  {
19184    struct gdbarch *gdbarch = get_frame_arch (frame);
19185 -  struct type *type1 = check_typedef (type);
19186    struct value *v;
19187  
19188 -  if (gdbarch_convert_register_p (gdbarch, regnum, type1))
19189 +  type = check_typedef (type);
19190 +
19191 +  if (gdbarch_convert_register_p (gdbarch, regnum, type))
19192      {
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));
19201      }
19202    else
19203      {
19204 diff --git a/gdb/frame.c b/gdb/frame.c
19205 index dfd6b3d..2ea37c3 100644
19206 --- a/gdb/frame.c
19207 +++ b/gdb/frame.c
19208 @@ -596,7 +596,7 @@ frame_register_unwind (struct frame_info *frame, int regnum,
19209  
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);
19215  
19216    if (bufferp)
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)));
19223           else
19224             fprintf_unfiltered (gdb_stdlog, " computed");
19225  
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,
19231  
19232        if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
19233         {
19234 -         store_unsigned_integer (valbuf, 4, VALUE_ADDRESS (arg));
19235 +         store_unsigned_integer (valbuf, 4, value_address (arg));
19236           typecode = TYPE_CODE_PTR;
19237           len = 4;
19238           val = valbuf;
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
19243 @@ -41,4 +41,8 @@
19244  # define N_(String) (String)
19245  #endif
19246  
19247 +#ifdef HAVE_LANGINFO_CODESET
19248 +#include <langinfo.h>
19249 +#endif
19250 +
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
19256 @@ -45,4 +45,7 @@
19257  #define obstack_grow_str0(OBSTACK,STRING) \
19258    obstack_grow0 (OBSTACK, STRING, strlen (STRING))
19259  
19260 +#define obstack_grow_wstr(OBSTACK, WSTRING) \
19261 +  obstack_grow (OBSTACK, WSTRING, sizeof (wchar_t) * wcslen (WSTRING))
19262 +
19263  #endif
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;
19278  };
19279  
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() */
19291  };
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);
19344  }
19345 @@ -3333,6 +3375,119 @@ set_gdbarch_record_special_symbol (struct gdbarch *gdbarch,
19346  }
19347  
19348  int
19349 +gdbarch_get_syscall_number_p (struct gdbarch *gdbarch)
19350 +{
19351 +  gdb_assert (gdbarch != NULL);
19352 +  return gdbarch->get_syscall_number != NULL;
19353 +}
19354 +
19355 +LONGEST
19356 +gdbarch_get_syscall_number (struct gdbarch *gdbarch, ptid_t ptid)
19357 +{
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);
19363 +}
19364 +
19365 +void
19366 +set_gdbarch_get_syscall_number (struct gdbarch *gdbarch,
19367 +                                gdbarch_get_syscall_number_ftype get_syscall_number)
19368 +{
19369 +  gdbarch->get_syscall_number = get_syscall_number;
19370 +}
19371 +
19372 +int
19373 +gdbarch_get_syscall_by_number_p (struct gdbarch *gdbarch)
19374 +{
19375 +  gdb_assert (gdbarch != NULL);
19376 +  return gdbarch->get_syscall_by_number != NULL;
19377 +}
19378 +
19379 +void
19380 +gdbarch_get_syscall_by_number (struct gdbarch *gdbarch, int syscall_number, struct syscall *s)
19381 +{
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);
19387 +}
19388 +
19389 +void
19390 +set_gdbarch_get_syscall_by_number (struct gdbarch *gdbarch,
19391 +                                   gdbarch_get_syscall_by_number_ftype get_syscall_by_number)
19392 +{
19393 +  gdbarch->get_syscall_by_number = get_syscall_by_number;
19394 +}
19395 +
19396 +int
19397 +gdbarch_get_syscall_by_name_p (struct gdbarch *gdbarch)
19398 +{
19399 +  gdb_assert (gdbarch != NULL);
19400 +  return gdbarch->get_syscall_by_name != NULL;
19401 +}
19402 +
19403 +void
19404 +gdbarch_get_syscall_by_name (struct gdbarch *gdbarch, const char *syscall_name, struct syscall *s)
19405 +{
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);
19411 +}
19412 +
19413 +void
19414 +set_gdbarch_get_syscall_by_name (struct gdbarch *gdbarch,
19415 +                                 gdbarch_get_syscall_by_name_ftype get_syscall_by_name)
19416 +{
19417 +  gdbarch->get_syscall_by_name = get_syscall_by_name;
19418 +}
19419 +
19420 +int
19421 +gdbarch_get_syscall_names_p (struct gdbarch *gdbarch)
19422 +{
19423 +  gdb_assert (gdbarch != NULL);
19424 +  return gdbarch->get_syscall_names != NULL;
19425 +}
19426 +
19427 +const char **
19428 +gdbarch_get_syscall_names (struct gdbarch *gdbarch)
19429 +{
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);
19435 +}
19436 +
19437 +void
19438 +set_gdbarch_get_syscall_names (struct gdbarch *gdbarch,
19439 +                               gdbarch_get_syscall_names_ftype get_syscall_names)
19440 +{
19441 +  gdbarch->get_syscall_names = get_syscall_names;
19442 +}
19443 +
19444 +const char *
19445 +gdbarch_xml_syscall_filename (struct gdbarch *gdbarch)
19446 +{
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;
19452 +}
19453 +
19454 +void
19455 +set_gdbarch_xml_syscall_filename (struct gdbarch *gdbarch,
19456 +                                  const char * xml_syscall_filename)
19457 +{
19458 +  gdbarch->xml_syscall_filename = xml_syscall_filename;
19459 +}
19460 +
19461 +int
19462  gdbarch_has_global_solist (struct gdbarch *gdbarch)
19463  {
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;
19473 +struct syscall;
19474  
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);
19480  
19481 +/* Functions for the 'catch syscall' feature.
19482 +   Get architecture-specific system calls information from registers. */
19483 +
19484 +extern int gdbarch_get_syscall_number_p (struct gdbarch *gdbarch);
19485 +
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);
19489 +
19490 +/* Fills the struct syscall (passed as argument) with the corresponding
19491 +   system call represented by syscall_number. */
19492 +
19493 +extern int gdbarch_get_syscall_by_number_p (struct gdbarch *gdbarch);
19494 +
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);
19498 +
19499 +/* Fills the struct syscall (passed as argument) with the corresponding
19500 +   system call represented by syscall_name. */
19501 +
19502 +extern int gdbarch_get_syscall_by_name_p (struct gdbarch *gdbarch);
19503 +
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);
19507 +
19508 +/* Returns the array containing the syscall names for the architecture. */
19509 +
19510 +extern int gdbarch_get_syscall_names_p (struct gdbarch *gdbarch);
19511 +
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);
19515 +
19516 +/* Stores the name of syscall's XML file. Contains NULL if the file
19517 +   was not set. */
19518 +
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);
19521 +
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);
19528  
19529 +/* Definition for an unknown syscall, used basically in error-cases. */
19530 +#define UNKNOWN_SYSCALL (-1)
19531 +
19532  extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
19533  
19534  
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
19542  
19543 +# Functions for the 'catch syscall' feature.
19544 +
19545 +# Get architecture-specific system calls information from registers.
19546 +M:LONGEST:get_syscall_number:ptid_t ptid:ptid
19547 +
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
19551 +
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
19555 +
19556 +# Returns the array containing the syscall names for the architecture.
19557 +M:const char **:get_syscall_names:void:
19558 +
19559 +# Stores the name of syscall's XML file. Contains NULL if the file
19560 +# was not set.
19561 +v:const char *:xml_syscall_filename:::0:0::0:gdbarch->xml_syscall_filename
19562 +
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;
19570 +struct syscall;
19571  
19572  extern struct gdbarch *current_gdbarch;
19573  extern struct gdbarch *target_gdbarch;
19574 @@ -911,6 +932,9 @@ done
19575  # close it off
19576  cat <<EOF
19577  
19578 +/* Definition for an unknown syscall, used basically in error-cases. */
19579 +#define UNKNOWN_SYSCALL (-1)
19580 +
19581  extern struct gdbarch_tdep *gdbarch_tdep (struct gdbarch *gdbarch);
19582  
19583  
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
19588 @@ -1,5 +1,15 @@
19589  echo Setting up the environment for debugging gdb.\n
19590  
19591 +# Set up the Python library and "require" command.
19592 +python
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)
19598 +end
19599 +source @srcdir@/python/lib/gdb/__init__.py
19600 +
19601  set complaints 1
19602  
19603  b internal_error
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);
19611  
19612 +/* Prune dead threads from the list of threads.  */
19613 +extern void prune_threads (void);
19614 +
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
19622 @@ -38,6 +38,8 @@
19623  #include "cp-abi.h"
19624  #include "gdb_assert.h"
19625  #include "hashtab.h"
19626 +#include "dwarf2expr.h"
19627 +#include "dwarf2loc.h"
19628  
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);
19636 +
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
19639 +   count.  */
19640 +struct type_refc_entry
19641 +{
19642 +  /* One type in the hierarchy.  Each type in the hierarchy gets its
19643 +     own slot.  */
19644 +  struct type *type;
19645 +
19646 +  /* A pointer to the shared reference count.  */
19647 +  int *refc;
19648 +};
19649 +
19650 +/* The hash table holding all reference counts.  */
19651 +static htab_t type_refc_table;
19652  
19653  
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).  */
19657  
19658  struct type *
19659 -alloc_type (struct objfile *objfile)
19660 +alloc_type (struct objfile *objfile, struct type *parent)
19661  {
19662    struct type *type;
19663  
19664    /* Alloc the structure and start off with all fields zeroed.  */
19665  
19666 -  if (objfile == NULL)
19667 +  switch ((long) objfile)
19668      {
19669 +    case (long) OBJFILE_INTERNAL:
19670 +    case (long) OBJFILE_MALLOC:
19671        type = XZALLOC (struct type);
19672        TYPE_MAIN_TYPE (type) = XZALLOC (struct main_type);
19673 -    }
19674 -  else
19675 -    {
19676 +      break;
19677 +    default:
19678        type = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct type);
19679        TYPE_MAIN_TYPE (type) = OBSTACK_ZALLOC (&objfile->objfile_obstack,
19680                                               struct main_type);
19681        OBJSTAT (objfile, n_types++);
19682 +      break;
19683      }
19684  
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.  */
19689  
19690 +  if (objfile == NULL)
19691 +    type_init_refc (type, parent);
19692 +
19693    return (type);
19694  }
19695  
19696 @@ -194,16 +218,24 @@ alloc_type_instance (struct type *oldtype)
19697  
19698    /* Allocate the structure.  */
19699  
19700 -  if (TYPE_OBJFILE (oldtype) == NULL)
19701 -    type = XZALLOC (struct type);
19702 -  else
19703 -    type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
19704 -                          struct type);
19705 -
19706 +  switch ((long) TYPE_OBJFILE (oldtype))
19707 +    {
19708 +    case (long) OBJFILE_INTERNAL:
19709 +    case (long) OBJFILE_MALLOC:
19710 +      type = XZALLOC (struct type);
19711 +      break;
19712 +    default:
19713 +      type = OBSTACK_ZALLOC (&TYPE_OBJFILE (oldtype)->objfile_obstack,
19714 +                            struct type);
19715 +      break;
19716 +    }
19717    TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
19718  
19719    TYPE_CHAIN (type) = type;    /* Chain back to itself for now.  */
19720  
19721 +  if (TYPE_OBJFILE (oldtype) == NULL)
19722 +    type_init_refc (type, oldtype);
19723 +
19724    return (type);
19725  }
19726  
19727 @@ -248,7 +280,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
19728  
19729    if (typeptr == 0 || *typeptr == 0)   /* We'll need to allocate one.  */
19730      {
19731 -      ntype = alloc_type (TYPE_OBJFILE (type));
19732 +      ntype = alloc_type (TYPE_OBJFILE (type), type);
19733        if (typeptr)
19734         *typeptr = ntype;
19735      }
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;
19740 +
19741 +      /* Callers may only supply storage if there is an objfile.  */
19742 +      gdb_assert (objfile);
19743      }
19744  
19745    TYPE_TARGET_TYPE (ntype) = type;
19746 @@ -328,7 +363,7 @@ make_reference_type (struct type *type, struct type **typeptr)
19747  
19748    if (typeptr == 0 || *typeptr == 0)   /* We'll need to allocate one.  */
19749      {
19750 -      ntype = alloc_type (TYPE_OBJFILE (type));
19751 +      ntype = alloc_type (TYPE_OBJFILE (type), type);
19752        if (typeptr)
19753         *typeptr = ntype;
19754      }
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;
19759 +
19760 +      /* Callers may only supply storage if there is an objfile.  */
19761 +      gdb_assert (objfile);
19762      }
19763  
19764    TYPE_TARGET_TYPE (ntype) = type;
19765 @@ -388,7 +426,7 @@ make_function_type (struct type *type, struct type **typeptr)
19766  
19767    if (typeptr == 0 || *typeptr == 0)   /* We'll need to allocate one.  */
19768      {
19769 -      ntype = alloc_type (TYPE_OBJFILE (type));
19770 +      ntype = alloc_type (TYPE_OBJFILE (type), type);
19771        if (typeptr)
19772         *typeptr = ntype;
19773      }
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;
19778 +
19779 +      /* Callers may only supply storage if there is an objfile.  */
19780 +      gdb_assert (objfile);
19781      }
19782  
19783    TYPE_TARGET_TYPE (ntype) = type;
19784 @@ -643,7 +684,7 @@ lookup_memberptr_type (struct type *type, struct type *domain)
19785  {
19786    struct type *mtype;
19787  
19788 -  mtype = alloc_type (TYPE_OBJFILE (type));
19789 +  mtype = alloc_type (TYPE_OBJFILE (type), NULL);
19790    smash_to_memberptr_type (mtype, domain, type);
19791    return (mtype);
19792  }
19793 @@ -655,7 +696,7 @@ lookup_methodptr_type (struct type *to_type)
19794  {
19795    struct type *mtype;
19796  
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)
19804  {
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;
19812    else
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;
19822  
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))
19827      {
19828      case TYPE_CODE_RANGE:
19829 +      if (TYPE_RANGE_UPPER_BOUND_IS_UNDEFINED (type) 
19830 +         || TYPE_RANGE_LOWER_BOUND_IS_UNDEFINED (type))
19831 +       return -1;
19832        *lowp = TYPE_LOW_BOUND (type);
19833        *highp = TYPE_HIGH_BOUND (type);
19834        return 1;
19835 @@ -805,30 +850,56 @@ create_array_type (struct type *result_type,
19836  
19837    if (result_type == NULL)
19838      {
19839 -      result_type = alloc_type (TYPE_OBJFILE (range_type));
19840 +      result_type = alloc_type (TYPE_OBJFILE (range_type), range_type);
19841      }
19842 +  else
19843 +    {
19844 +      /* Callers may only supply storage if there is an objfile.  */
19845 +      gdb_assert (TYPE_OBJFILE (result_type));
19846 +    }
19847 +
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;
19858 -  else
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;
19867  
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)
19877 +    {
19878 +      low_bound = 0;
19879 +      high_bound = -1;
19880 +    }
19881 +
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;
19889 +  else
19890 +    {
19891 +      CHECK_TYPEDEF (element_type);
19892 +      TYPE_LENGTH (result_type) =
19893 +       TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
19894 +    }
19895 +
19896    if (TYPE_LENGTH (result_type) == 0)
19897 -    TYPE_TARGET_STUB (result_type) = 1;
19898 +    {
19899 +      /* The real size will be computed for specific instances by
19900 +        CHECK_TYPEDEF.  */
19901 +      TYPE_TARGET_STUB (result_type) = 1;
19902 +    }
19903  
19904    return (result_type);
19905  }
19906 @@ -865,7 +936,12 @@ create_set_type (struct type *result_type, struct type *domain_type)
19907  {
19908    if (result_type == NULL)
19909      {
19910 -      result_type = alloc_type (TYPE_OBJFILE (domain_type));
19911 +      result_type = alloc_type (TYPE_OBJFILE (domain_type), domain_type);
19912 +    }
19913 +  else
19914 +    {
19915 +      /* Callers may only supply storage if there is an objfile.  */
19916 +      gdb_assert (TYPE_OBJFILE (result_type));
19917      }
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"));
19922  }
19923  
19924 +/* Calculate the memory length of array TYPE.
19925 +
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.  */
19931 +
19932 +static CORE_ADDR
19933 +type_length_get (struct type *type, struct type *target_type, int full_span)
19934 +{
19935 +  struct type *range_type;
19936 +  int count;
19937 +  CORE_ADDR byte_stride = 0;   /* `= 0' for a false GCC warning.  */
19938 +  CORE_ADDR element_size;
19939 +
19940 +  if (TYPE_CODE (type) != TYPE_CODE_ARRAY
19941 +      && TYPE_CODE (type) != TYPE_CODE_STRING)
19942 +    return TYPE_LENGTH (type);
19943 +
19944 +  /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
19945 +     Fortran arrays.  The allocated data will never be used so they can be
19946 +     zero-length.  */
19947 +  if (object_address_data_not_valid (type))
19948 +    return 0;
19949 +
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))
19953 +    return 0;
19954 +  count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
19955 +  /* It may happen for wrong DWARF annotations returning garbage data.  */
19956 +  if (count < 0)
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.  */
19961 +  if (count <= 0)
19962 +    return 0;
19963 +  if (full_span || count > 1)
19964 +    {
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)
19969 +        {
19970 +         if (target_type == NULL)
19971 +           target_type = check_typedef (TYPE_TARGET_TYPE (type));
19972 +         byte_stride = type_length_get (target_type, NULL, 1);
19973 +       }
19974 +    }
19975 +  if (full_span)
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;
19981 +}
19982 +
19983 +/* Prepare TYPE after being read in by the backend.  Currently this function
19984 +   only propagates the TYPE_DYNAMIC flag.  */
19985 +
19986 +void
19987 +finalize_type (struct type *type)
19988 +{
19989 +  int i;
19990 +
19991 +  for (i = 0; i < TYPE_NFIELDS (type); ++i)
19992 +    if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
19993 +      break;
19994 +
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;
20000 +}
20001 +
20002  /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
20003  
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?).  */
20012  
20013  struct type *
20014  check_typedef (struct type *type)
20015 @@ -1420,7 +1575,7 @@ check_typedef (struct type *type)
20016           if (sym)
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);
20021         }
20022        type = TYPE_TARGET_TYPE (type);
20023      }
20024 @@ -1494,34 +1649,37 @@ check_typedef (struct type *type)
20025          }
20026      }
20027  
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))
20032 +    {
20033 +      htab_t copied_types;
20034 +      struct type *type_old = type;
20035 +
20036 +      copied_types = create_copied_types_hash (NULL);
20037 +      type = copy_type_recursive (type, copied_types);
20038 +      htab_delete (copied_types);
20039 +
20040 +      gdb_assert (TYPE_DYNAMIC (type) == 0);
20041 +    }
20042 +
20043 +  if (!currently_reading_symtab
20044 +      && (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type)))
20045      {
20046 -      struct type *range_type;
20047        struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
20048  
20049 +      if (TYPE_DYNAMIC (type))
20050 +       TYPE_TARGET_TYPE (type) = target_type;
20051        if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
20052         {
20053           /* Empty.  */
20054         }
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)
20060         {
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);
20067 -         int nb_elements;
20068 -       
20069 -         if (high_bound < low_bound)
20070 -           nb_elements = 0;
20071 -         else
20072 -           nb_elements = high_bound - low_bound + 1;
20073 -       
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;
20078         }
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;
20083         }
20084 +      TYPE_DYNAMIC (type) = 0;
20085      }
20086 +
20087    /* Cache TYPE_LENGTH for future use.  */
20088    TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
20089 +
20090    return type;
20091  }
20092  
20093 @@ -1753,7 +1914,7 @@ init_type (enum type_code code, int length, int flags,
20094  {
20095    struct type *type;
20096  
20097 -  type = alloc_type (objfile);
20098 +  type = alloc_type (objfile, NULL);
20099    TYPE_CODE (type) = code;
20100    TYPE_LENGTH (type) = length;
20101  
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;
20105  
20106 -  if ((name != NULL) && (objfile != NULL))
20107 -    {
20108 -      TYPE_NAME (type) = obsavestring (name, strlen (name), 
20109 -                                      &objfile->objfile_obstack);
20110 -    }
20111 -  else
20112 -    {
20113 -      TYPE_NAME (type) = name;
20114 -    }
20115 +  if (name)
20116 +    switch ((long) objfile)
20117 +      {
20118 +      case (long) OBJFILE_INTERNAL:
20119 +       TYPE_NAME (type) = name;
20120 +       break;
20121 +      case (long) OBJFILE_MALLOC:
20122 +       TYPE_NAME (type) = xstrdup (name);
20123 +       break;
20124 +#if 0 /* OBJFILE_MALLOC duplication now.  */
20125 +      case (long) NULL:
20126 +       internal_error (__FILE__, __LINE__,
20127 +                       _("OBJFILE pointer NULL should be OBJFILE_* instead"));
20128 +#endif
20129 +      default:
20130 +       TYPE_NAME (type) = obsavestring (name, strlen (name), 
20131 +                                        &objfile->objfile_obstack);
20132 +      }
20133  
20134    /* C++ fancies.  */
20135  
20136 @@ -1803,6 +1973,10 @@ init_type (enum type_code code, int length, int flags,
20137      {
20138        INIT_CPLUS_SPECIFIC (type);
20139      }
20140 +
20141 +  if (!objfile)
20142 +    type_incref (type);
20143 +
20144    return (type);
20145  }
20146  
20147 @@ -2916,33 +3090,47 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
20148  }
20149  
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.   */
20154  
20155  htab_t
20156  create_copied_types_hash (struct objfile *objfile)
20157  {
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)
20163 +    {
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);
20168 +    }
20169 +  else
20170 +    {
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);
20177 +    }
20178  }
20179  
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.  */
20189  
20190 -struct type *
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)
20199  {
20200    struct type_pair *stored, pair;
20201    void **slot;
20202    struct type *new_type;
20203  
20204 -  if (TYPE_OBJFILE (type) == NULL)
20205 +  if (TYPE_OBJFILE (type) == OBJFILE_INTERNAL
20206 +      || (objfile == OBJFILE_MALLOC && !TYPE_DYNAMIC (type)))
20207      return type;
20208  
20209    /* This type shouldn't be pointing to any types in other objfiles;
20210 @@ -2954,11 +3142,15 @@ copy_type_recursive (struct objfile *objfile,
20211    if (*slot != NULL)
20212      return ((struct type_pair *) *slot)->new;
20213  
20214 -  new_type = alloc_type (NULL);
20215 +  new_type = alloc_type (OBJFILE_MALLOC, *representative);
20216 +  if (!*representative)
20217 +    *representative = new_type;
20218  
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;
20228    *slot = stored;
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;
20232  
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;
20239 +
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);
20246  
20247 +  if (TYPE_ALLOCATED (new_type))
20248 +    {
20249 +      gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
20250 +
20251 +      if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
20252 +        TYPE_NOT_ALLOCATED (new_type) = 1;
20253 +      TYPE_ALLOCATED (new_type) = NULL;
20254 +    }
20255 +
20256 +  if (TYPE_ASSOCIATED (new_type))
20257 +    {
20258 +      gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
20259 +
20260 +      if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
20261 +        TYPE_NOT_ASSOCIATED (new_type) = 1;
20262 +      TYPE_ASSOCIATED (new_type) = NULL;
20263 +    }
20264 +
20265 +  if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
20266 +      && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
20267 +    {
20268 +      if (TYPE_NOT_ALLOCATED (new_type)
20269 +          || TYPE_NOT_ASSOCIATED (new_type))
20270 +       TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
20271 +      else
20272 +       {
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));
20276 +       }
20277 +    }
20278 +
20279    /* Copy the fields.  */
20280    if (TYPE_NFIELDS (type))
20281      {
20282        int i, nfields;
20283  
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++)
20288         {
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),
20294 -                                    copied_types);
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,
20302                                                                        i)));
20303               break;
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);
20310 +             else
20311 +               SET_FIELD_BITPOS (TYPE_FIELD (new_type, i),
20312 +                  dwarf_locexpr_baton_eval (TYPE_FIELD_DWARF_BLOCK (type, i)));
20313 +             break;
20314             default:
20315               internal_error (__FILE__, __LINE__,
20316                               _("Unexpected type field location kind: %d"),
20317 @@ -3018,17 +3260,32 @@ copy_type_recursive (struct objfile *objfile,
20318         }
20319      }
20320  
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))
20324 +    {
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;
20328 +    }
20329 +
20330 +  /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
20331 +     possibly converted.  */
20332 +  TYPE_DYNAMIC (new_type) = 0;
20333 +
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),
20339 -                          copied_types);
20340 +      copy_type_recursive_1 (objfile, 
20341 +                            TYPE_TARGET_TYPE (type),
20342 +                            copied_types,
20343 +                            representative);
20344    if (TYPE_VPTR_BASETYPE (type))
20345      TYPE_VPTR_BASETYPE (new_type) = 
20346 -      copy_type_recursive (objfile,
20347 -                          TYPE_VPTR_BASETYPE (type),
20348 -                          copied_types);
20349 +      copy_type_recursive_1 (objfile,
20350 +                            TYPE_VPTR_BASETYPE (type),
20351 +                            copied_types,
20352 +                            representative);
20353    /* Maybe copy the type_specific bits.
20354  
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,
20357    return new_type;
20358  }
20359  
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.  */
20363 +
20364 +struct type *
20365 +copy_type_recursive (struct type *type,
20366 +                    htab_t copied_types)
20367 +{
20368 +  struct type *representative = NULL;
20369 +
20370 +  return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types,
20371 +                               &representative);
20372 +}
20373 +
20374  /* Make a copy of the given TYPE, except that the pointer & reference
20375     types are not preserved.
20376     
20377 @@ -3059,7 +3330,7 @@ copy_type (const struct type *type)
20378  
20379    gdb_assert (TYPE_OBJFILE (type) != NULL);
20380  
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)
20387    return new_type;
20388  }
20389  
20390 +static void delete_type (struct type *type);
20391 +
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.  */
20394 +
20395 +static void
20396 +delete_main_type (struct main_type *main_type)
20397 +{
20398 +  int i;
20399 +  void **slot;
20400 +  struct
20401 +    {
20402 +      struct main_type *main_type;
20403 +    } type_local = { main_type }, *type = &type_local;
20404 +
20405 +  gdb_assert (TYPE_OBJFILE (type) == OBJFILE_MALLOC);
20406 +
20407 +  xfree (TYPE_NAME (type));
20408 +  xfree (TYPE_TAG_NAME (type));
20409 +
20410 +  for (i = 0; i < TYPE_NFIELDS (type); ++i)
20411 +    {
20412 +      xfree (TYPE_FIELD_NAME (type, i));
20413 +
20414 +      if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
20415 +       xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
20416 +    }
20417 +  xfree (TYPE_FIELDS (type));
20418 +
20419 +  /* Strangely, HAVE_CPLUS_STRUCT will return true when there isn't
20420 +     one at all.  */
20421 +  gdb_assert (!HAVE_CPLUS_STRUCT (type) || !TYPE_CPLUS_SPECIFIC (type));
20422 +
20423 +  xfree (TYPE_MAIN_TYPE (type));
20424 +}
20425 +
20426 +/* Store `struct main_type *' entries which got `struct type *' deleted.  */
20427 +
20428 +static htab_t deleted_main_types_hash;
20429 +
20430 +/* To be called before any call of delete_type.  */
20431 +
20432 +static void
20433 +delete_type_begin (void)
20434 +{
20435 +  gdb_assert (deleted_main_types_hash == NULL);
20436 +
20437 +  deleted_main_types_hash = htab_create_alloc (10, htab_hash_pointer,
20438 +                           htab_eq_pointer, NULL, xcalloc, xfree);
20439 +}
20440 +
20441 +/* Helper for delete_type_finish.  */
20442 +
20443 +static int
20444 +delete_type_finish_traverse (void **slot, void *unused)
20445 +{
20446 +  struct main_type *main_type = *slot;
20447 +
20448 +  delete_main_type (main_type);
20449 +
20450 +  return 1;
20451 +}
20452 +
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.  */
20455 +
20456 +static void
20457 +delete_type_finish (void)
20458 +{
20459 +  htab_traverse (deleted_main_types_hash, delete_type_finish_traverse, NULL);
20460 +
20461 +  htab_delete (deleted_main_types_hash);
20462 +  deleted_main_types_hash = NULL;
20463 +}
20464 +
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.  */
20468 +
20469 +static void
20470 +delete_type (struct type *type)
20471 +{
20472 +  void **slot;
20473 +
20474 +  if (!type)
20475 +    return;
20476 +
20477 +  if (TYPE_OBJFILE (type) == OBJFILE_INTERNAL)
20478 +    return;
20479 +  gdb_assert (TYPE_OBJFILE (type) == OBJFILE_MALLOC);
20480 +
20481 +  slot = htab_find_slot (deleted_main_types_hash, TYPE_MAIN_TYPE (type),
20482 +                        INSERT);
20483 +  gdb_assert (!*slot);
20484 +  *slot = TYPE_MAIN_TYPE (type);
20485 +
20486 +  xfree (type);
20487 +}
20488 +
20489 +/* Hash function for type_refc_table.  */
20490 +
20491 +static hashval_t
20492 +type_refc_hash (const void *p)
20493 +{
20494 +  const struct type_refc_entry *entry = p;
20495 +  return htab_hash_pointer (entry->type);
20496 +}
20497 +
20498 +/* Equality function for type_refc_table.  */
20499 +
20500 +static int
20501 +type_refc_equal (const void *a, const void *b)
20502 +{
20503 +  const struct type_refc_entry *left = a;
20504 +  const struct type_refc_entry *right = b;
20505 +  return left->type == right->type;
20506 +}
20507 +
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
20513 +   to one.  */
20514 +
20515 +static void
20516 +type_init_refc (struct type *new_type, struct type *parent_type)
20517 +{
20518 +  int *refc;
20519 +  void **slot;
20520 +  struct type_refc_entry *new_entry;
20521 +
20522 +  if (TYPE_OBJFILE (new_type))
20523 +    return;
20524 +
20525 +  if (parent_type)
20526 +    {
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;
20532 +    }
20533 +  else
20534 +    {
20535 +      refc = xmalloc (sizeof (int));
20536 +      *refc = 0;
20537 +    }
20538 +
20539 +  new_entry = XNEW (struct type_refc_entry);
20540 +  new_entry->type = new_type;
20541 +  new_entry->refc = refc;
20542 +
20543 +  slot = htab_find_slot (type_refc_table, new_entry, INSERT);
20544 +  gdb_assert (!*slot);
20545 +  *slot = new_entry;
20546 +}
20547 +
20548 +/* Increment the reference count for TYPE.  */
20549 +
20550 +void
20551 +type_incref (struct type *type)
20552 +{
20553 +  struct type_refc_entry entry, *found;
20554 +
20555 +  if (TYPE_OBJFILE (type))
20556 +    return;
20557 +
20558 +  entry.type = type;
20559 +  found = htab_find (type_refc_table, &entry);
20560 +  gdb_assert (found);
20561 +  ++*(found->refc);
20562 +}
20563 +
20564 +/* A traverse callback for type_refc_table which removes any entry
20565 +   whose reference count is zero (unused entry).  */
20566 +
20567 +static int
20568 +type_refc_remove (void **slot, void *unused)
20569 +{
20570 +  struct type_refc_entry *entry = *slot;
20571 +
20572 +  if (*entry->refc == 0)
20573 +    {
20574 +      delete_type (entry->type);
20575 +
20576 +      xfree (entry);
20577 +      htab_clear_slot (type_refc_table, slot);
20578 +    }
20579 +
20580 +  return 1;
20581 +}
20582 +
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.  */
20587 +
20588 +void
20589 +type_decref (struct type *type)
20590 +{
20591 +  struct type_refc_entry entry, *found;
20592 +
20593 +  if (TYPE_OBJFILE (type))
20594 +    return;
20595 +
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);
20601 +}
20602 +
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.  */
20607 +
20608 +void
20609 +free_all_types (void)
20610 +{
20611 +  delete_type_begin ();
20612 +  htab_traverse (type_refc_table, type_refc_remove, NULL);
20613 +  delete_type_finish ();
20614 +}
20615 +
20616  static struct type *
20617  build_flt (int bit, char *name, const struct floatformat **floatformats)
20618  {
20619 @@ -3105,7 +3602,7 @@ build_complex (int bit, char *name, struct type *target_type)
20620        return builtin_type_error;
20621      }
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;
20626    return t;
20627  }
20628 @@ -3119,56 +3616,56 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
20629    builtin_type->builtin_void =
20630      init_type (TYPE_CODE_VOID, 1,
20631                0,
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,
20636                (TYPE_FLAG_NOSIGN
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,
20642                0,
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,
20700                0,
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,
20705                0,
20706 -              "bool", (struct objfile *) NULL);
20707 +              "bool", OBJFILE_INTERNAL);
20708  
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,
20713                 0,
20714 -              "_Decimal32", (struct objfile *) NULL);
20715 +              "_Decimal32", OBJFILE_INTERNAL);
20716    builtin_type->builtin_decdouble
20717      = init_type (TYPE_CODE_DECFLOAT, 64 / 8,
20718                0,
20719 -              "_Decimal64", (struct objfile *) NULL);
20720 +              "_Decimal64", OBJFILE_INTERNAL);
20721    builtin_type->builtin_declong
20722      = init_type (TYPE_CODE_DECFLOAT, 128 / 8,
20723                0,
20724 -              "_Decimal128", (struct objfile *) NULL);
20725 +              "_Decimal128", OBJFILE_INTERNAL);
20726  
20727    /* Pointer/Address types.  */
20728  
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);
20735  
20736  
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);
20760  
20761    return builtin_type;
20762  }
20763 @@ -3276,6 +3774,9 @@ _initialize_gdbtypes (void)
20764  {
20765    gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
20766  
20767 +  type_refc_table = htab_create_alloc (20, type_refc_hash, type_refc_equal,
20768 +                                      NULL, xcalloc, xfree);
20769 +
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,
20776                0,
20777 -              "int0_t", (struct objfile *) NULL);
20778 +              "int0_t", OBJFILE_INTERNAL);
20779    builtin_type_int8 =
20780      init_type (TYPE_CODE_INT, 8 / 8,
20781                TYPE_FLAG_NOTTEXT,
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,
20791                0,
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,
20801                0,
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,
20811                0,
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,
20821                0,
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);
20829  
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,
20835                0,
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,
20840                0,
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);
20848  
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
20856  
20857      TYPE_CODE_NAMESPACE,       /* C++ namespace.  */
20858  
20859 -    TYPE_CODE_DECFLOAT         /* Decimal floating point.  */
20860 +    TYPE_CODE_DECFLOAT,                /* Decimal floating point.  */
20861 +
20862 +    /* Internal function type.  */
20863 +    TYPE_CODE_INTERNAL_FUNCTION
20864    };
20865  
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
20868  
20869  #define TYPE_TARGET_STUB(t)    (TYPE_MAIN_TYPE (t)->flag_target_stub)
20870  
20871 +/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
20872 +   sticky.  */
20873 +
20874 +#define TYPE_DYNAMIC(t)                (TYPE_MAIN_TYPE (t)->flag_dynamic)
20875 +
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
20880  
20881  #define TYPE_NOTTEXT(t)                (TYPE_MAIN_TYPE (t)->flag_nottext)
20882  
20883 +/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)?  */
20884 +
20885 +#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
20886 +  (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
20887 +
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.  */
20892 +
20893 +#define TYPE_NOT_ALLOCATED(t)  (TYPE_MAIN_TYPE (t)->flag_not_allocated)
20894 +
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.  */
20899 +
20900 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
20901 +
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.  */
20909 +
20910 +#define TYPE_DATA_LOCATION_IS_ADDR(t) \
20911 +  (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
20912 +
20913  /* Constant type.  If this is set, the corresponding type has a
20914   * const modifier.
20915   */
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;
20925  
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
20929  
20930    struct type *target_type;
20931  
20932 +  /* For DW_AT_data_location.  */
20933 +  union
20934 +    {
20935 +      struct dwarf2_locexpr_baton *dwarf_block;
20936 +      CORE_ADDR addr;
20937 +    }
20938 +  data_location;
20939 +
20940 +  /* For DW_AT_allocated.  */
20941 +  struct dwarf2_locexpr_baton *allocated;
20942 +
20943 +  /* For DW_AT_associated.  */
20944 +  struct dwarf2_locexpr_baton *associated;
20945 +
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
20970  
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)
20974 -
20975 -/* Moto-specific stuff for FORTRAN arrays */
20976 -
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)
20980 +
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)
20988 +
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))
20996 -
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))
21002  
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)))
21014  
21015  /* C++ */
21016  
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)))
21020  
21021 +/* Virtual OBJFILE used for builtin types.  */
21022 +#define OBJFILE_INTERNAL ((struct objfile *) 1L)
21023 +
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)
21027 +
21028 +#define OBJFILE_IS_VIRTUAL(objfile) ((objfile) == OBJFILE_INTERNAL     \
21029 +                                    || (objfile) == OBJFILE_MALLOC)
21030 +
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. */
21037  
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))
21046  
21047 -#define TYPE_ZALLOC(t,size)  \
21048 -   (TYPE_OBJFILE (t) != NULL  \
21049 -    ? memset (obstack_alloc (&TYPE_OBJFILE (t)->objfile_obstack, size),  \
21050 -             0, 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),        \
21056 +             0, size))
21057  
21058 -extern struct type *alloc_type (struct objfile *);
21059 +extern struct type *alloc_type (struct objfile *, struct type *);
21060  
21061  extern struct type *init_type (enum type_code, int, int, char *,
21062                                struct objfile *);
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 *,
21065                                        struct type *);
21066  
21067 +extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
21068 +                                               int fieldno);
21069 +
21070 +extern int type_range_high_bound_internal (struct type *range_type);
21071 +
21072 +extern int type_range_count_bound_internal (struct type *range_type);
21073 +
21074 +extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
21075 +                                                 struct type *element_type);
21076 +
21077 +extern void finalize_type (struct type *type);
21078 +
21079  extern struct type *create_string_type (struct type *, struct type *);
21080  
21081  extern struct type *create_set_type (struct type *, struct type *);
21082 @@ -1263,10 +1363,15 @@ extern void maintenance_print_type (char *, int);
21083  
21084  extern htab_t create_copied_types_hash (struct objfile *objfile);
21085  
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);
21090  
21091  extern struct type *copy_type (const struct type *type);
21092  
21093 +extern void type_incref (struct type *type);
21094 +
21095 +extern void type_decref (struct type *type);
21096 +
21097 +extern void free_all_types (void);
21098 +
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
21107    */
21108 -  if (VALUE_ADDRESS (value_field (v, known_type_vptr_fieldno)) == 0)
21109 +  if (value_address (value_field (v, known_type_vptr_fieldno)) == 0)
21110      return NULL;
21111  
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,
21118    
21119    /* Find the linker symbol for this vtable.  */
21120    vtable_symbol
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)
21126      return NULL;
21127 @@ -487,10 +486,8 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
21128                       LONGEST adjustment)
21129  {
21130    int i;
21131 -  const char *physname;
21132  
21133    /* Search this class first.  */
21134 -  physname = NULL;
21135    if (adjustment == 0)
21136      {
21137        int len;
21138 @@ -615,13 +612,15 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
21139         {
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);
21146 +         else
21147             {
21148 -             fprintf_filtered (stream, "&virtual ");
21149               fputs_filtered (demangled_name, stream);
21150               xfree (demangled_name);
21151 -             return;
21152             }
21153 +         return;
21154         }
21155      }
21156  
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,
21162  {
21163    int pid = PIDGET (ptid);
21164  
21165 -  int request = PTRACE_CONT;
21166 +  int request;
21167 +
21168 +  if (target_passed_by_entrypoint () > 0
21169 +      && catch_syscall_enabled () > 0)
21170 +   request = PTRACE_SYSCALL;
21171 +  else
21172 +    request = PTRACE_CONT;
21173  
21174    if (step)
21175      {
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
21180 @@ -37,6 +37,10 @@
21181  #include "symtab.h"
21182  #include "arch-utils.h"
21183  #include "regset.h"
21184 +#include "linux-tdep.h"
21185 +
21186 +/* The syscall's XML filename for i386.  */
21187 +#define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml"
21188  
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)
21192  }
21193  \f
21194  
21195 +static LONGEST
21196 +i386_linux_get_syscall_number (struct gdbarch *gdbarch,
21197 +                               ptid_t ptid)
21198 +{
21199 +  struct regcache *regcache = get_thread_regcache (ptid);
21200 +  /* The content of a register.  */
21201 +  gdb_byte buf[4];
21202 +  /* The result.  */
21203 +  LONGEST ret;
21204 +
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);
21209 +
21210 +  ret = extract_signed_integer (buf, 4);
21211 +
21212 +  return ret;
21213 +}
21214 +
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)
21219  {
21220    struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
21221  
21222 +  /* Initializing common functions.  */
21223 +  linux_tdep_init (gdbarch);
21224 +
21225    /* GNU/Linux uses ELF.  */
21226    i386_elf_init_abi (info, gdbarch);
21227  
21228 @@ -472,6 +499,11 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
21229                                         displaced_step_at_entry_point);
21230  
21231    set_gdbarch_get_siginfo_type (gdbarch, linux_get_siginfo_type);
21232 +
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);
21237  }
21238  
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)
21245  }
21246  
21247  static int
21248 +inf_child_set_syscall_catchpoint (int pid, int needed, int any_count,
21249 +                                 int table_size, int *table)
21250 +{
21251 +  /* This version of Unix doesn't support notification of syscall
21252 +     events.  */
21253 +  return 0;
21254 +}
21255 +
21256 +static int
21257  inf_child_can_run (void)
21258  {
21259    return 1;
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)
21274  {
21275    pid_t pid = ptid_get_pid (ptid);
21276 -  int request = PT_CONTINUE;
21277 +  int request;
21278  
21279    if (pid == -1)
21280      /* Resume all threads.  Traditionally ptrace() only supports
21281         single-threaded processes, so simply resume the inferior.  */
21282      pid = ptid_get_pid (inferior_ptid);
21283  
21284 +  if (target_passed_by_entrypoint () > 0
21285 +      && catch_syscall_enabled () > 0)
21286 +    request = PT_SYSCALL;
21287 +  else
21288 +    request = PT_CONTINUE;
21289 +
21290    if (step)
21291      {
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"),
21298                     value);
21299  }
21300  
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.
21309 +
21310 +   The default is to unwind the frame if a std::terminate call is made.. */
21311 +
21312 +static int unwind_on_terminating_exception_p = 1;
21313 +static void
21314 +show_unwind_on_terminating_exception_p (struct ui_file *file, int from_tty,
21315 +                                       struct cmd_list_element *c,
21316 +                                       const char *value)
21317 +
21318 +{
21319 +  fprintf_filtered (file, _("\
21320 +Unwind stack if a C++ exception is unhandled while in a call dummy is %s.\n"),
21321 +                   value);
21322 +}
21323  
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)
21329      {
21330 -      funaddr = VALUE_ADDRESS (function);
21331 +      funaddr = value_address (function);
21332        value_type = TYPE_TARGET_TYPE (ftype);
21333      }
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;
21343    const char *name;
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;
21347    }
21348 +  
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)
21362 +     {
21363 +       tm = lookup_minimal_symbol ("std::terminate()", NULL, NULL); 
21364 +       if (tm != NULL) 
21365 +        {
21366 +         terminate_bp = set_momentary_breakpoint_at_pc
21367 +           (SYMBOL_VALUE_ADDRESS (tm),  bp_breakpoint);
21368 +         make_cleanup_delete_breakpoint (terminate_bp);
21369 +       }
21370 +     }
21371  
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."),
21375                name);
21376      }
21377  
21378 +  if (! target_has_execution)
21379 +    {
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);
21384 +      error (_("\
21385 +The program being debugged exited while in a function called from GDB."));
21386 +    }
21387 +
21388    if (stopped_by_random_signal || !stop_stack_dummy)
21389      {
21390        const char *name = get_function_name (funaddr,
21391 @@ -884,6 +941,38 @@ When the function is done executing, GDB will silently stop."),
21392  
21393        if (!stop_stack_dummy)
21394         {
21395 +         
21396 +         /* Check if unwind on terminating exception behaviour is on */
21397 +         if (unwind_on_terminating_exception_p)
21398 +           {
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 */
21402 +             
21403 +             if ((terminate_bp != NULL) &&
21404 +                 (inferior_thread()->stop_bpstat->breakpoint_at->address
21405 +                  == terminate_bp->loc->address)) 
21406 +               
21407 +               
21408 +               {
21409 +                 
21410 +                 /* We must get back to the frame we were before the
21411 +                    dummy call.  */
21412 +                 dummy_frame_pop (dummy_id);
21413 +                 
21414 +                 /* We also need to restore inferior status to that before the
21415 +                    dummy call.  */
21416 +                 restore_inferior_status (inf_status);
21417 +                 
21418 +                 error (_("\
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."), 
21424 +                        name);
21425 +               }
21426 +           } 
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."),
21431                            NULL,
21432                            show_unwind_on_signal_p,
21433                            &setlist, &showlist);
21434 +
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."),
21445 +                          NULL,
21446 +                          show_unwind_on_terminating_exception_p,
21447 +                          &setlist, &showlist);
21448 +
21449  }
21450 diff --git a/gdb/infcmd.c b/gdb/infcmd.c
21451 index 0a17dab..d48f4b1 100644
21452 --- a/gdb/infcmd.c
21453 +++ b/gdb/infcmd.c
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 ();
21457  
21458 +  /* If we already caught a syscall catchpoint, then reset its
21459 +     syscall_number information because we are starting all over
21460 +     again.  */
21461 +  clear_syscall_catchpoints_info ();
21462 +
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
21468 --- a/gdb/infrun.c
21469 +++ b/gdb/infrun.c
21470 @@ -1046,7 +1046,7 @@ a command like `return' or `jump' to continue execution."));
21471          }
21472      }
21473  
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)
21478      {
21479 @@ -1069,6 +1069,11 @@ a command like `return' or `jump' to continue execution."));
21480        pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
21481        break;
21482  
21483 +    case TARGET_WAITKIND_SYSCALL_ENTRY:
21484 +    case TARGET_WAITKIND_SYSCALL_RETURN:
21485 +      pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
21486 +      break;
21487 +
21488      default:
21489        break;
21490      }
21491 @@ -1509,7 +1514,7 @@ init_wait_for_inferior (void)
21492  
21493    breakpoint_init_inferior (inf_starting);
21494  
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. */
21498  
21499    clear_proceed_status ();
21500 @@ -2155,6 +2160,50 @@ ensure_not_running (void)
21501      error_is_running ();
21502  }
21503  
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
21507 +   processed.  */
21508 +static int
21509 +deal_with_syscall_event (struct execution_control_state *ecs)
21510 +{
21511 +  int syscall_number = gdbarch_get_syscall_number (current_gdbarch,
21512 +                                                   ecs->ptid);
21513 +  if (catch_syscall_enabled () > 0
21514 +      && catching_syscall_number (syscall_number) > 0)
21515 +    {
21516 +      ecs->event_thread->stop_signal = TARGET_SIGNAL_TRAP;
21517 +      pending_follow.kind = ecs->ws.kind;
21518 +
21519 +      if (!ptid_equal (ecs->ptid, inferior_ptid))
21520 +        {
21521 +          context_switch (ecs->ptid);
21522 +          reinit_frame_cache ();
21523 +        }
21524 +
21525 +      stop_pc = read_pc ();
21526 +
21527 +      ecs->event_thread->stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
21528 +
21529 +      ecs->random_signal = !bpstat_explains_signal (ecs->event_thread->stop_bpstat);
21530 +
21531 +      /* If no catchpoint triggered for this, then keep going.  */
21532 +      if (ecs->random_signal)
21533 +        {
21534 +          ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
21535 +          keep_going (ecs);
21536 +          return 1;
21537 +        }
21538 +      return 0;
21539 +    }
21540 +  else
21541 +    {
21542 +      resume (0, TARGET_SIGNAL_0);
21543 +      prepare_to_wait (ecs);
21544 +      return 1;
21545 +    }
21546 +}
21547 +
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:
21553        if (debug_infrun)
21554          fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SYSCALL_ENTRY\n");
21555 -      resume (0, TARGET_SIGNAL_0);
21556 -      prepare_to_wait (ecs);
21557 -      return;
21558 +      /* Getting the current syscall number */
21559 +      if (deal_with_syscall_event (ecs) != 0)
21560 +        return;
21561 +      goto process_event_stop_test;
21562 +      break;
21563  
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:
21568        if (debug_infrun)
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);
21572 -      return;
21573 +      if (deal_with_syscall_event (ecs) != 0)
21574 +        return;
21575 +      goto process_event_stop_test;
21576 +      break;
21577  
21578      case TARGET_WAITKIND_STOPPED:
21579        if (debug_infrun)
21580 @@ -5166,6 +5218,25 @@ inferior_has_execd (ptid_t pid, char **execd_pathname)
21581    return 1;
21582  }
21583  
21584 +int
21585 +inferior_has_called_syscall (ptid_t pid, int *syscall_number)
21586 +{
21587 +  struct target_waitstatus last;
21588 +  ptid_t last_ptid;
21589 +
21590 +  get_last_target_status (&last_ptid, &last);
21591 +
21592 +  if (last.kind != TARGET_WAITKIND_SYSCALL_ENTRY &&
21593 +      last.kind != TARGET_WAITKIND_SYSCALL_RETURN)
21594 +    return 0;
21595 +
21596 +  if (!ptid_equal (last_ptid, pid))
21597 +    return 0;
21598 +
21599 +  *syscall_number = last.value.syscall_number;
21600 +  return 1;
21601 +}
21602 +
21603  /* Oft used ptids */
21604  ptid_t null_ptid;
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);
21613  
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);
21617  
21618  static char *java_class_name_from_physname (const char *physname);
21619  
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)
21631         return NULL;
21632        clas = value_ind (clas);
21633      }
21634 -  addr = VALUE_ADDRESS (clas) + value_offset (clas);
21635 +  addr = value_address (clas);
21636  
21637  #if 0
21638    get_java_class_symtab ();
21639 @@ -302,7 +302,7 @@ type_from_class (struct value *clas)
21640    if (type != NULL)
21641      return type;
21642  
21643 -  type = alloc_type (objfile);
21644 +  type = alloc_type (objfile, NULL);
21645    TYPE_CODE (type) = TYPE_CODE_STRUCT;
21646    INIT_CPLUS_SPECIFIC (type);
21647  
21648 @@ -422,7 +422,7 @@ java_link_class_type (struct type *type, struct value *clas)
21649    fields = NULL;
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)
21658         }
21659        else
21660         {                       /* Re-use field value for next field. */
21661 -         VALUE_ADDRESS (field) += TYPE_LENGTH (value_type (field));
21662 +         CORE_ADDR addr
21663 +           = value_address (field) + TYPE_LENGTH (value_type (field));
21664 +         set_value_address (field, addr);
21665           set_value_lazy (field, 1);
21666         }
21667        temp = field;
21668 @@ -509,7 +511,9 @@ java_link_class_type (struct type *type, struct value *clas)
21669         }
21670        else
21671         {                       /* Re-use method value for next method. */
21672 -         VALUE_ADDRESS (method) += TYPE_LENGTH (value_type (method));
21673 +         CORE_ADDR addr
21674 +           = value_address (method) + TYPE_LENGTH (value_type (method));
21675 +         set_value_address (method, addr);
21676           set_value_lazy (method, 1);
21677         }
21678  
21679 @@ -796,7 +800,7 @@ java_value_string (char *ptr, int len)
21680     characters and strings is language specific. */
21681  
21682  static void
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)
21685  {
21686    switch (c)
21687      {
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;
21694  
21695    type = value_type (val);
21696 -  address = VALUE_ADDRESS (val) + value_offset (val);
21697 +  address = value_address (val);
21698  
21699    if (is_object_type (type))
21700      {
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);
21704  
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));
21709  
21710           while (i < length && things_printed < options->print_max)
21711             {
21712 @@ -230,7 +230,7 @@ java_value_print (struct value *val, struct ui_file *stream,
21713  
21714        value_free_to_mark (mark);       /* Release unnecessary values */
21715  
21716 -      val_print_string (data + boffset, count, 2, stream, options);
21717 +      val_print_string (java_char_type, data + boffset, count, stream, options);
21718  
21719        return 0;
21720      }
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);
21727        else
21728         val_print_type_code_int (type, valaddr, stream);
21729        break;
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);
21735  
21736  static void set_type_range_case (void);
21737  
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);
21741  
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);
21745  
21746  static void unk_lang_print_type (struct type *, char *, struct ui_file *,
21747                                  int, int);
21748 @@ -1065,20 +1067,22 @@ unk_lang_error (char *msg)
21749  }
21750  
21751  static void
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,
21754 +                   int quoter)
21755  {
21756    error (_("internal error - unimplemented function unk_lang_emit_char called."));
21757  }
21758  
21759  static void
21760 -unk_lang_printchar (int c, struct ui_file *stream)
21761 +unk_lang_printchar (int c, struct type *type, struct ui_file *stream)
21762  {
21763    error (_("internal error - unimplemented function unk_lang_printchar called."));
21764  }
21765  
21766  static void
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)
21773  {
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
21780  
21781      void (*la_post_parser) (struct expression ** expp, int void_context_p);
21782  
21783 -    void (*la_printchar) (int ch, struct ui_file * stream);
21784 +    void (*la_printchar) (int ch, struct type *chtype, struct ui_file * stream);
21785  
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 *);
21792  
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);
21796  
21797      /* Print a type using syntax appropriate for this language. */
21798  
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))
21802  
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))
21818  
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,
21824      }
21825    else if (paren_pointer != NULL)
21826      {
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)
21835 +       {
21836 +         char *a, *b;
21837 +         a = paren_pointer - 4;
21838 +         b = paren_pointer;
21839 +         while ((*(a++) = *(b++)) != '\0') ;
21840 +         *a = '\0';
21841 +         p = paren_pointer - 3;
21842 +       }
21843 +      else
21844 +       p = paren_pointer + 1;
21845      }
21846    else
21847      {
21848        p = skip_quoted (*argptr);
21849      }
21850  
21851 +  /* Make sure we keep important kewords like "const" */
21852 +  if (strncmp (p, " const", 6) == 0)
21853 +    p += 6;
21854 +
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
21862 @@ -61,6 +61,10 @@
21863  # endif
21864  #endif /* HAVE_PERSONALITY */
21865  
21866 +/* To be used when one needs to know wether a
21867 +   WSTOPSIG (status) is a syscall */
21868 +#define TRAP_IS_SYSCALL (SIGTRAP | 0x80)
21869 +
21870  /* This comment documents high-level logic of this file. 
21871  
21872  Waiting for events in sync mode
21873 @@ -281,17 +285,29 @@ struct simple_pid_list *stopped_pids;
21874  
21875  static int linux_supports_tracefork_flag = -1;
21876  
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.  */
21879 +
21880 +static int linux_supports_tracesysgood_flag = -1;
21881 +
21882  /* If we have PTRACE_O_TRACEFORK, this flag indicates whether we also have
21883     PTRACE_O_TRACEVFORKDONE.  */
21884  
21885  static int linux_supports_tracevforkdone_flag = -1;
21886  
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;
21890 +
21891  /* Async mode support */
21892  
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;
21896  
21897 +/* Stores the current used ptrace() options.  */
21898 +static int current_ptrace_options = 0;
21899 +
21900  /* The read/write ends of the pipe registered as waitable file in the
21901     event loop.  */
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);
21905  }
21906  
21907 +/* Determine if PTRACE_O_TRACESYSGOOD can be used to follow syscalls.
21908 +
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.  */
21912 +
21913 +static void
21914 +linux_test_for_tracesysgood (int original_pid)
21915 +{
21916 +  int ret;
21917 +  enum sigchld_state async_events_original_state;
21918 +
21919 +  async_events_original_state = linux_nat_async_events (sigchld_sync);
21920 +
21921 +  linux_supports_tracesysgood_flag = 0;
21922 +
21923 +  ret = ptrace (PTRACE_SETOPTIONS, original_pid, 0, PTRACE_O_TRACESYSGOOD);
21924 +  if (ret != 0)
21925 +    return;
21926 +
21927 +  linux_supports_tracesysgood_flag = 1;
21928 +  linux_nat_async_events (async_events_original_state);
21929 +}
21930 +
21931 +/* Determine wether we support PTRACE_O_TRACESYSGOOD option available.
21932 +   This function also sets linux_supports_tracesysgood_flag.  */
21933 +
21934 +static int
21935 +linux_supports_tracesysgood (int pid)
21936 +{
21937 +  if (linux_supports_tracesysgood_flag == -1)
21938 +    linux_test_for_tracesysgood (pid);
21939 +  return linux_supports_tracesysgood_flag;
21940 +}
21941 +
21942  /* Return non-zero iff we have tracefork functionality available.
21943     This function also sets linux_supports_tracefork_flag.  */
21944  
21945 @@ -655,12 +706,34 @@ linux_supports_tracevforkdone (int pid)
21946    return linux_supports_tracevforkdone_flag;
21947  }
21948  
21949 +static void
21950 +linux_enable_tracesysgood (ptid_t ptid)
21951 +{
21952 +  int pid = ptid_get_lwp (ptid);
21953 +
21954 +  if (pid == 0)
21955 +    pid = ptid_get_pid (ptid);
21956 +
21957 +  if (linux_supports_tracesysgood (pid) == 0)
21958 +    return;
21959 +
21960 +  current_ptrace_options |= PTRACE_O_TRACESYSGOOD;
21961 +  linux_passed_by_entrypoint_flag = 1;
21962 +
21963 +  ptrace (PTRACE_SETOPTIONS, pid, 0, current_ptrace_options);
21964 +}
21965 +
21966 +static int
21967 +linux_passed_by_entrypoint (void)
21968 +{
21969 +  return linux_passed_by_entrypoint_flag;
21970 +}
21971 +
21972  \f
21973  void
21974  linux_enable_event_reporting (ptid_t ptid)
21975  {
21976    int pid = ptid_get_lwp (ptid);
21977 -  int options;
21978  
21979    if (pid == 0)
21980      pid = ptid_get_pid (ptid);
21981 @@ -668,15 +741,16 @@ linux_enable_event_reporting (ptid_t ptid)
21982    if (! linux_supports_tracefork (pid))
21983      return;
21984  
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;
21989 +
21990    if (linux_supports_tracevforkdone (pid))
21991 -    options |= PTRACE_O_TRACEVFORKDONE;
21992 +    current_ptrace_options |= PTRACE_O_TRACEVFORKDONE;
21993  
21994    /* Do not enable PTRACE_O_TRACEEXIT until GDB is more prepared to support
21995       read-only process state.  */
21996  
21997 -  ptrace (PTRACE_SETOPTIONS, pid, 0, options);
21998 +  ptrace (PTRACE_SETOPTIONS, pid, 0, current_ptrace_options);
21999  }
22000  
22001  static void
22002 @@ -684,6 +758,7 @@ linux_child_post_attach (int pid)
22003  {
22004    linux_enable_event_reporting (pid_to_ptid (pid));
22005    check_for_thread_db ();
22006 +  linux_enable_tracesysgood (pid_to_ptid (pid));
22007  }
22008  
22009  static void
22010 @@ -691,6 +766,7 @@ linux_child_post_startup_inferior (ptid_t ptid)
22011  {
22012    linux_enable_event_reporting (ptid);
22013    check_for_thread_db ();
22014 +  linux_enable_tracesysgood (ptid);
22015  }
22016  
22017  static int
22018 @@ -931,6 +1007,16 @@ linux_child_insert_exec_catchpoint (int pid)
22019      error (_("Your system does not support exec catchpoints."));
22020  }
22021  
22022 +static int
22023 +linux_child_set_syscall_catchpoint (int pid, int needed, int any_count,
22024 +                                   int table_size, int *table)
22025 +{
22026 +  if (! linux_supports_tracesysgood (pid))
22027 +    error (_("Your system does not support syscall catchpoints."));
22028 +  /* We ignore the arguments.  */
22029 +  return 0;
22030 +}
22031 +
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 */
22038  
22039 +  /* We are sarting, so we still have not passed through our entrypoint.  */
22040 +  linux_passed_by_entrypoint_flag = 0;
22041 +
22042    /* The fork_child mechanism is synchronous and calls target_wait, so
22043       we have to mask the async mode.  */
22044  
22045 @@ -1996,6 +2085,26 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
22046        return 0;
22047      }
22048  
22049 +  /* Used for 'catch syscall' feature.  */
22050 +  if (WSTOPSIG (status) == TRAP_IS_SYSCALL)
22051 +    {
22052 +      if (catch_syscall_enabled () == 0)
22053 +          ourstatus->kind = TARGET_WAITKIND_IGNORE;
22054 +      else
22055 +        {
22056 +          struct regcache *regcache = get_thread_regcache (lp->ptid);
22057 +          struct gdbarch *gdbarch = get_regcache_arch (regcache);
22058 +
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);
22065 +        }
22066 +      return 0;
22067 +    }
22068 +
22069    internal_error (__FILE__, __LINE__,
22070                   _("unknown ptrace event %d"), event);
22071  }
22072 @@ -2606,11 +2715,16 @@ linux_nat_filter_event (int lwpid, int status, int options)
22073      }
22074  
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))
22079      save_siginfo (lp);
22080  
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)))
22089      {
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;
22104  
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;
22114  
22115 +  /* Signal wether we are in a SYSCALL_ENTRY or
22116 +     in a SYSCALL_RETURN event.
22117 +     Values:
22118 +     - TARGET_WAITKIND_SYSCALL_ENTRY
22119 +     - TARGET_WAITKIND_SYSCALL_RETURN */
22120 +  int syscall_state;
22121 +
22122    /* Next LWP in list.  */
22123    struct lwp_info *next;
22124  };
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
22129 @@ -20,6 +20,8 @@
22130  #include "defs.h"
22131  #include "gdbtypes.h"
22132  #include "linux-tdep.h"
22133 +#include "xml-syscall.h"
22134 +#include "target.h"
22135  
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)
22139  
22140    return siginfo_type;
22141  }
22142 +
22143 +/* Structure used to store information about the available syscalls in
22144 +   the system.  */
22145 +static const struct syscalls_info *sysinfo = NULL;
22146 +
22147 +/* A flag to tell if we already initialized the structure above.  */
22148 +static int have_initialized_sysinfo = 0;
22149 +
22150 +/* The filename of the syscall's XML.  */
22151 +static const char *xml_syscall_file = NULL;
22152 +
22153 +/* Initializes the syscalls_info structure according to the
22154 +   architecture.  */
22155 +static void
22156 +init_sysinfo (struct gdbarch *gdbarch)
22157 +{
22158 +  /* Did we already try to initialize the structure?  */
22159 +  if (have_initialized_sysinfo)
22160 +    return;
22161 +
22162 +  if (xml_syscall_file == NULL)
22163 +    xml_syscall_file = gdbarch_xml_syscall_filename (gdbarch);
22164 +
22165 +  sysinfo = xml_init_syscalls_info (xml_syscall_file);
22166 +
22167 +  have_initialized_sysinfo = 1;
22168 +
22169 +  if (sysinfo == NULL)
22170 +    {
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);
22176 +      else
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."));
22180 +    }
22181 +}
22182 +
22183 +static void
22184 +linux_get_syscall_by_number (struct gdbarch *gdbarch,
22185 +                             int syscall_number,
22186 +                             struct syscall *s)
22187 +{
22188 +  init_sysinfo (gdbarch);
22189 +
22190 +  s->number = syscall_number;
22191 +  s->name = xml_get_syscall_name (sysinfo, syscall_number);
22192 +}
22193 +
22194 +static void
22195 +linux_get_syscall_by_name (struct gdbarch *gdbarch,
22196 +                           const char *syscall_name,
22197 +                           struct syscall *s)
22198 +{
22199 +  init_sysinfo (gdbarch);
22200 +
22201 +  s->number = xml_get_syscall_number (sysinfo, syscall_name);
22202 +  s->name = syscall_name;
22203 +}
22204 +
22205 +static const char **
22206 +linux_get_syscall_names (struct gdbarch *gdbarch)
22207 +{
22208 +  init_sysinfo (gdbarch);
22209 +
22210 +  return xml_list_of_syscalls (sysinfo);
22211 +}
22212 +
22213 +void
22214 +linux_tdep_init (struct gdbarch *gdbarch)
22215 +{
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);
22219 +}
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
22224 @@ -22,4 +22,6 @@
22225  
22226  struct type *linux_get_siginfo_type (struct gdbarch *);
22227  
22228 +extern void linux_tdep_init (struct gdbarch *gdbarch);
22229 +
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
22235 @@ -29,8 +29,8 @@
22236  #include "valprint.h"
22237  
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);
22243  
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.  */
22248  
22249  static void
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)
22252  {
22253  
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.  */
22257  
22258  static void
22259 -m2_printchar (int c, struct ui_file *stream)
22260 +m2_printchar (int c, struct type *type, struct ui_file *stream)
22261  {
22262    fputs_filtered ("'", stream);
22263 -  LA_EMIT_CHAR (c, stream, '\'');
22264 +  LA_EMIT_CHAR (c, type, stream, '\'');
22265    fputs_filtered ("'", stream);
22266  }
22267  
22268 @@ -103,14 +103,15 @@ m2_printchar (int c, struct ui_file *stream)
22269     be replaced with a true Modula version.  */
22270  
22271  static void
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)
22277  {
22278    unsigned int i;
22279    unsigned int things_printed = 0;
22280    int in_quotes = 0;
22281    int need_comma = 0;
22282 +  int width = TYPE_LENGTH (type);
22283  
22284    if (length == 0)
22285      {
22286 @@ -152,7 +153,7 @@ m2_printstr (struct ui_file *stream, const gdb_byte *string,
22287                 fputs_filtered ("\", ", stream);
22288               in_quotes = 0;
22289             }
22290 -         m2_printchar (string[i], stream);
22291 +         m2_printchar (string[i], type, stream);
22292           fprintf_filtered (stream, " <repeats %u times>", reps);
22293           i = rep1 - 1;
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);
22297               in_quotes = 1;
22298             }
22299 -         LA_EMIT_CHAR (string[i], stream, '"');
22300 +         LA_EMIT_CHAR (string[i], type, stream, '"');
22301           ++things_printed;
22302         }
22303      }
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')
22311        && addr != 0)
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);
22315    
22316    return 0;
22317  }
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);
22324        else
22325         {
22326           fprintf_filtered (stream, "{");
22327 @@ -359,7 +360,8 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
22328                   len = temp_len;
22329                 }
22330  
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,
22334                                options);
22335               i = len;
22336             }
22337 @@ -547,7 +549,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
22338           else
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);
22343         }
22344        break;
22345  
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,
22351        if (len > 8
22352           && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
22353         {
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;
22357           len = 4;
22358           val = valbuf;
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
22363 @@ -23,6 +23,7 @@
22364  #include "macrotab.h"
22365  #include "macroexp.h"
22366  #include "gdb_assert.h"
22367 +#include "c-lang.h"
22368  
22369  
22370  \f
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] == '\''))
22376 +      || (p + 2 <= end
22377 +         && (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
22378 +         && p[1] == '\''))
22379      {
22380        char *tok_start = p;
22381        char *body_start;
22382 +      int char_count = 0;
22383  
22384        if (*p == '\'')
22385          p++;
22386 -      else if (*p == 'L')
22387 +      else if (*p == 'L' || *p == 'u' || *p == 'U')
22388          p += 2;
22389        else
22390          gdb_assert (0);
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 == '\'')
22394              {
22395 -              if (p == body_start)
22396 +              if (!char_count)
22397                  error (_("A character constant must contain at least one "
22398                         "character."));
22399                p++;
22400 @@ -348,10 +352,13 @@ get_character_constant (struct macro_buffer *tok, char *p, char *end)
22401            else if (*p == '\\')
22402              {
22403                p++;
22404 -              parse_escape (&p);
22405 +             char_count += c_parse_escape (&p, NULL);
22406              }
22407            else
22408 -            p++;
22409 +           {
22410 +             p++;
22411 +             char_count++;
22412 +           }
22413          }
22414  
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)
22418  {
22419    if ((p + 1 <= end
22420 -       && *p == '\"')
22421 +       && *p == '"')
22422        || (p + 2 <= end
22423 -          && p[0] == 'L'
22424 -          && p[1] == '\"'))
22425 +          && (p[0] == 'L' || p[0] == 'u' || p[0] == 'U')
22426 +          && p[1] == '"'))
22427      {
22428        char *tok_start = p;
22429  
22430 -      if (*p == '\"')
22431 +      if (*p == '"')
22432          p++;
22433 -      else if (*p == 'L')
22434 +      else if (*p == 'L' || *p == 'u' || *p == 'U')
22435          p += 2;
22436        else
22437          gdb_assert (0);
22438 @@ -388,7 +395,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
22439          {
22440            if (p >= end)
22441              error (_("Unterminated string in expression."));
22442 -          else if (*p == '\"')
22443 +          else if (*p == '"')
22444              {
22445                p++;
22446                break;
22447 @@ -399,7 +406,7 @@ get_string_literal (struct macro_buffer *tok, char *p, char *end)
22448            else if (*p == '\\')
22449              {
22450                p++;
22451 -              parse_escape (&p);
22452 +              c_parse_escape (&p, NULL);
22453              }
22454            else
22455              p++;
22456 diff --git a/gdb/main.c b/gdb/main.c
22457 index 5d4640b..6f9e61b 100644
22458 --- a/gdb/main.c
22459 +++ b/gdb/main.c
22460 @@ -40,6 +40,8 @@
22461  #include "interps.h"
22462  #include "main.h"
22463  
22464 +#include "python/python.h"
22465 +
22466  /* If nonzero, display time usage both at startup and for each command.  */
22467  
22468  int display_time;
22469 @@ -62,6 +64,9 @@ int dbx_commands = 0;
22470  /* System root path, used to find libraries etc.  */
22471  char *gdb_sysroot = 0;
22472  
22473 +/* GDB datadir, used to store data files.  */
22474 +char *gdb_datadir = 0;
22475 +
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;
22482  
22483 +  int python_script = 0;
22484 +
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)
22489         }
22490      }
22491  
22492 +#ifdef GDB_DATADIR_RELOCATABLE
22493 +  gdb_datadir = make_relative_prefix (argv[0], BINDIR, GDB_DATADIR);
22494 +  if (gdb_datadir)
22495 +    {
22496 +      struct stat s;
22497 +      int res = 0;
22498 +
22499 +      if (stat (gdb_datadir, &s) == 0)
22500 +       if (S_ISDIR (s.st_mode))
22501 +         res = 1;
22502 +
22503 +      if (res == 0)
22504 +       {
22505 +         xfree (gdb_datadir);
22506 +         gdb_datadir = xstrdup (GDB_DATADIR);
22507 +       }
22508 +    }
22509 +  else
22510 +    gdb_datadir = xstrdup (GDB_DATADIR);
22511 +#else
22512 +  gdb_datadir = xstrdup (GDB_DATADIR);
22513 +#endif /* GDB_DATADIR_RELOCATABLE */
22514 +
22515 +  /* Canonicalize the GDB's datadir path.  */
22516 +  if (*gdb_datadir)
22517 +    {
22518 +      char *canon_debug = lrealpath (gdb_datadir);
22519 +      if (canon_debug)
22520 +       {
22521 +         xfree (gdb_datadir);
22522 +         gdb_datadir = canon_debug;
22523 +       }
22524 +    }
22525 +
22526    get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
22527  
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},
22533 +#if HAVE_PYTHON
22534 +      {"python", no_argument, 0, 'P'},
22535 +      {"P", no_argument, 0, 'P'},
22536 +#endif
22537        {0, no_argument, 0, 0}
22538      };
22539  
22540 -    while (1)
22541 +    while (!python_script)
22542        {
22543         int option_index;
22544  
22545 @@ -462,6 +507,9 @@ captured_main (void *data)
22546           case 0:
22547             /* Long option that just sets a flag.  */
22548             break;
22549 +         case 'P':
22550 +           python_script = 1;
22551 +           break;
22552           case OPT_SE:
22553             symarg = optarg;
22554             execarg = optarg;
22555 @@ -638,7 +686,31 @@ extern int gdbtk_test (char *);
22556         use_windows = 0;
22557        }
22558  
22559 -    if (set_args)
22560 +    if (python_script)
22561 +      {
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)
22566 +         {
22567 +           fprintf_unfiltered (gdb_stderr,
22568 +                               _("%s: Python script file name required\n"),
22569 +                               argv[0]);
22570 +           exit (1);
22571 +         }
22572 +
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.  */
22577 +       quiet = 1;
22578 +       /* FIXME: should read .gdbinit if, and only if, a prompt is
22579 +          requested by the script.  Though... maybe this is not
22580 +          ideal?  */
22581 +       /* FIXME: likewise, reading in history.  */
22582 +       inhibit_gdbinit = 1;
22583 +      }
22584 +    else if (set_args)
22585        {
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."));
22589    xfree (cmdarg);
22590  
22591    /* Read in the old history after all the command files have been read. */
22592 -  init_history ();
22593 +  if (!python_script)
22594 +    init_history ();
22595  
22596    if (batch)
22597      {
22598 @@ -895,13 +968,25 @@ Can't attach to process and specify a core file at the same time."));
22599  #endif
22600      }
22601  
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. */
22606 -  while (1)
22607 +#if HAVE_PYTHON
22608 +  if (python_script)
22609      {
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]);
22614 +      return 1;
22615 +    }
22616 +  else
22617 +#endif
22618 +    {
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. */
22623 +      while (1)
22624 +       {
22625 +         catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
22626 +       }
22627      }
22628    /* No exit -- exit is through quit_command.  */
22629  }
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);
22636 +#if HAVE_PYTHON
22637 +  fputs_unfiltered (_("\
22638 +    gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream);
22639 +#endif
22640 +  fputs_unfiltered (_("\n\
22641  Options:\n\n\
22642  "), stream);
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);
22650 +#if HAVE_PYTHON
22651 +  fputs_unfiltered (_("\
22652 +  --python, -P       Following argument is Python script file; remaining\n\
22653 +                     arguments are passed to script.\n"), stream);
22654 +#endif
22655 +  fputs_unfiltered (_("\
22656    --quiet            Do not print version number on startup.\n\
22657    --readnow          Fully read symbol files on first access.\n\
22658  "), stream);
22659 diff --git a/gdb/maint.c b/gdb/maint.c
22660 index 56cafe9..1b57ff5 100644
22661 --- a/gdb/maint.c
22662 +++ b/gdb/maint.c
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."),
22670 +                           _("\
22671 +When set, GDB uses the specified path to search for data files."),
22672 +                           NULL, NULL,
22673 +                           &maintenance_set_cmdlist,
22674 +                           &maintenance_show_cmdlist);
22675  }
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)
22681  {
22682    struct type *t;
22683  
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;
22688    return t;
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)
22694  }
22695  
22696  void
22697 +mi_cmd_var_set_visualizer (char *command, char **argv, int argc)
22698 +{
22699 +  struct varobj *var;
22700 +
22701 +  if (argc != 2)
22702 +    error ("Usage: NAME VISUALIZER_FUNCTION.");
22703 +
22704 +  var = varobj_get_handle (argv[0]);
22705 +
22706 +  if (var == NULL)
22707 +    error ("Variable object not found");
22708 +
22709 +  varobj_set_visualizer (var, argv[1]);
22710 +}
22711 +
22712 +void
22713 +mi_cmd_var_set_child_range (char *command, char **argv, int argc)
22714 +{
22715 +  struct varobj *var;
22716 +  int from, to;
22717 +
22718 +  if (argc != 3)
22719 +    error (_("-var-set-child-range: NAME FROM TO"));
22720 +
22721 +  var = varobj_get_handle (argv[0]);
22722 +  if (var == NULL)
22723 +    error (_("Variable object not found"));
22724 +
22725 +  from = atoi (argv[1]);
22726 +  to = atoi (argv[2]);
22727 +
22728 +  varobj_set_child_range (var, from, to);
22729 +}
22730 +
22731 +void
22732  mi_cmd_var_set_frozen (char *command, char **argv, int argc)
22733  {
22734    struct varobj *var;
22735 @@ -369,6 +404,8 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
22736    int numchild;
22737    enum print_values print_values;
22738    int ix;
22739 +  int from, to;
22740 +  char *display_hint;
22741  
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)
22745    else
22746      print_values = PRINT_NO_VALUES;
22747  
22748 -  if (VEC_length (varobj_p, children) == 0)
22749 +  varobj_get_child_range (var, children, &from, &to);
22750 +  if (from >= to)
22751      return;
22752  
22753 +  display_hint = varobj_get_display_hint (var);
22754 +  if (display_hint)
22755 +    {
22756 +      ui_out_field_string (uiout, "displayhint", display_hint);
22757 +      xfree (display_hint);
22758 +    }
22759 +
22760    if (mi_version (uiout) == 1)
22761      cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
22762    else
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)
22766      {
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,
22770    
22771    for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i)
22772      {
22773 +      char *display_hint;
22774 +
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));
22781         }
22782 +
22783 +      display_hint = varobj_get_display_hint (var);
22784 +      if (display_hint)
22785 +       {
22786 +         ui_out_field_string (uiout, "displayhint", display_hint);
22787 +         xfree (display_hint);
22788 +       }
22789 +
22790 +      if (r->children_changed)
22791 +       {
22792 +         int ix, from, to;
22793 +         struct varobj *child;
22794 +         struct cleanup *cleanup =
22795 +           make_cleanup_ui_out_list_begin_end (uiout, "children");
22796 +
22797 +         VEC (varobj_p)* children = varobj_list_children (r->varobj);
22798 +         varobj_get_child_range (r->varobj, children, &from, &to);
22799 +
22800 +         for (ix = from;
22801 +              ix < to && VEC_iterate (varobj_p, children, ix, child);
22802 +              ++ix)
22803 +           {
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);
22808 +           }
22809 +
22810 +         do_cleanups (cleanup);
22811 +       }
22812    
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);
22854  
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");
22860 +
22861 +#if HAVE_PYTHON
22862 +      ui_out_field_string (uiout, NULL, "python");
22863 +#endif
22864        
22865        do_cleanups (cleanup);
22866        return;
22867 @@ -1317,6 +1321,7 @@ mi_cmd_execute (struct mi_parse *parse)
22868    struct cleanup *cleanup;
22869    int i;
22870    free_all_values ();
22871 +  free_all_types ();
22872  
22873    current_token = xstrdup (parse->token);
22874    cleanup = make_cleanup (free_current_contents, &current_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
22879 @@ -48,6 +48,8 @@
22880  #include "value.h"
22881  #include "cp-abi.h"
22882  #include "target.h"
22883 +#include "cp-support.h"
22884 +#include "language.h"
22885  
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;
22891  
22892 +  int needtofreename = 0;
22893 +  const char *modified_name;
22894 +
22895    if (sfile != NULL)
22896      {
22897        char *p = strrchr (sfile, '/');
22898 @@ -194,6 +199,18 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22899         sfile = p + 1;
22900      }
22901  
22902 +  /* For C++, canonicalize the input name. */
22903 +  modified_name = name;
22904 +  if (current_language->la_language == language_cplus)
22905 +    {
22906 +      char *cname = cp_canonicalize_string (name);
22907 +      if (cname)
22908 +       {
22909 +         modified_name = cname;
22910 +         needtofreename = 1;
22911 +       }
22912 +    }
22913 +
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,
22918                   int match;
22919  
22920                   if (pass == 1)
22921 -                   match = strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0;
22922 +                   {
22923 +                     match = strcmp (SYMBOL_LINKAGE_NAME (msymbol),
22924 +                                     modified_name) == 0;
22925 +                   }
22926                   else
22927 -                   match = SYMBOL_MATCHES_SEARCH_NAME (msymbol, name);
22928 +                   {
22929 +                     match = SYMBOL_MATCHES_SEARCH_NAME (msymbol,
22930 +                                                         modified_name);
22931 +                   }
22932 +
22933                   if (match)
22934                     {
22935                      switch (MSYMBOL_TYPE (msymbol))
22936 @@ -259,6 +283,10 @@ lookup_minimal_symbol (const char *name, const char *sfile,
22937             }
22938         }
22939      }
22940 +
22941 +  if (needtofreename)
22942 +    xfree ((void *) modified_name);
22943 +
22944    /* External symbols are best.  */
22945    if (found_symbol)
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,
22952        if (len > regsize
22953           && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
22954         {
22955 -         store_unsigned_integer (valbuf, regsize, VALUE_ADDRESS (arg));
22956 +         store_unsigned_integer (valbuf, regsize, value_address (arg));
22957           typecode = TYPE_CODE_PTR;
22958           len = regsize;
22959           val = valbuf;
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));
22982           val = &valbuf[0];
22983         }
22984        else
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.  */
22991  
22992  static void
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)
22995  {
22996  
22997    c &= 0xFF;                   /* Avoid sign bit follies.  */
22998 @@ -326,10 +326,10 @@ objc_emit_char (int c, struct ui_file *stream, int quoter)
22999  }
23000  
23001  static void
23002 -objc_printchar (int c, struct ui_file *stream)
23003 +objc_printchar (int c, struct type *type, struct ui_file *stream)
23004  {
23005    fputs_filtered ("'", stream);
23006 -  objc_emit_char (c, stream, '\'');
23007 +  objc_emit_char (c, type, stream, '\'');
23008    fputs_filtered ("'", stream);
23009  }
23010  
23011 @@ -340,14 +340,16 @@ objc_printchar (int c, struct ui_file *stream)
23012     FORCE_ELLIPSES.  */
23013  
23014  static void
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)
23021  {
23022    unsigned int i;
23023    unsigned int things_printed = 0;
23024    int in_quotes = 0;
23025    int need_comma = 0;
23026 +  int width = TYPE_LENGTH (type);
23027  
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);
23032               in_quotes = 0;
23033             }
23034 -         objc_printchar (string[i], stream);
23035 +         objc_printchar (string[i], type, stream);
23036           fprintf_filtered (stream, " <repeats %u times>", reps);
23037           i = rep1 - 1;
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);
23041               in_quotes = 1;
23042             }
23043 -         objc_emit_char (string[i], stream, '"');
23044 +         objc_emit_char (string[i], type, stream, '"');
23045           ++things_printed;
23046         }
23047      }
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)
23053         return 1;
23054        }
23055    }
23056 +
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)
23062 +  {
23063 +    require_partial_symbols (ofp);
23064 +    if (ofp->psymtabs != NULL)
23065 +      {
23066 +       return 1;
23067 +      }
23068 +  }
23069 +
23070    return 0;
23071  }
23072  
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
23078  
23079      struct partial_symtab *psymtabs;
23080  
23081 +    /* An address map that can be used to quickly determine if an
23082 +       address comes from this objfile.  This can be NULL.  */
23083 +
23084 +    struct addrmap *quick_addrmap;
23085 +
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 */
23091  
23092  
23093 +/* Set if we have tried to read partial symtabs for this objfile.
23094 +   This is used to allow lazy reading of partial symtabs.  */
23095 +
23096 +#define OBJF_SYMTABS_READ (1 << 6)
23097 +
23098 +/* This flag is set for the main objfile.  */
23099 +
23100 +#define OBJF_MAIN (1 << 7)
23101 +
23102  /* The object file that the main symbol table was loaded from (e.g. the
23103     argument to the "symbol-file" or "file" command).  */
23104  
23105 @@ -556,6 +570,13 @@ extern void *objfile_data (struct objfile *objfile,
23106    ALL_OBJFILES (objfile)        \
23107      ALL_OBJFILE_PSYMTABS (objfile, p)
23108  
23109 +/* Like ALL_PSYMTABS, but ensure that partial symbols have been read
23110 +   before examining the objfile.  */
23111 +
23112 +#define ALL_PSYMTABS_REQUIRED(objfile, p)                      \
23113 +  ALL_OBJFILES (objfile)                                       \
23114 +    ALL_OBJFILE_PSYMTABS (require_partial_symbols (objfile), p)
23115 +
23116  /* Traverse all minimal symbols in all objfiles.  */
23117  
23118  #define        ALL_MSYMBOLS(objfile, m) \
23119 diff --git a/gdb/p-lang.c b/gdb/p-lang.c
23120 index 41da3e0..e743a6f 100644
23121 --- a/gdb/p-lang.c
23122 +++ b/gdb/p-lang.c
23123 @@ -97,7 +97,8 @@ pascal_main_name (void)
23124     but this does not happen for Free Pascal nor for GPC.  */
23125  int
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,
23130                        char **arrayname)
23131  {
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));
23135            if (string_pos)
23136             *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
23137 -          if (char_size)
23138 -           *char_size = 1;
23139 +          if (char_type)
23140 +           *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
23141           if (arrayname)
23142             *arrayname = TYPE_FIELDS (type)[1].name;
23143           return 2;
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)
23147          {
23148 -         struct type *char_type;
23149           if (length_pos)
23150             *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
23151           if (length_size)
23152 @@ -134,13 +134,12 @@ is_pascal_string_type (struct type *type,int *length_pos,
23153           if (string_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)
23158 +          if (char_type)
23159             {
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);
23164             }
23165 -         else if (char_size)
23166 -           *char_size = 1;
23167           if (arrayname)
23168             *arrayname = TYPE_FIELDS (type)[2].name;
23169           return 3;
23170 @@ -182,14 +181,15 @@ pascal_one_char (int c, struct ui_file *stream, int *in_quotes)
23171      }
23172  }
23173  
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);
23177  
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. */
23181  
23182  static void
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)
23185  {
23186    int in_quotes = 0;
23187    pascal_one_char (c, stream, &in_quotes);
23188 @@ -198,7 +198,7 @@ pascal_emit_char (int c, struct ui_file *stream, int quoter)
23189  }
23190  
23191  void
23192 -pascal_printchar (int c, struct ui_file *stream)
23193 +pascal_printchar (int c, struct type *type, struct ui_file *stream)
23194  {
23195    int in_quotes = 0;
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.  */
23199  
23200  void
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)
23207  {
23208    unsigned int i;
23209    unsigned int things_printed = 0;
23210    int in_quotes = 0;
23211    int need_comma = 0;
23212 +  int width = TYPE_LENGTH (type);
23213  
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);
23218               in_quotes = 0;
23219             }
23220 -         pascal_printchar (current_char, stream);
23221 +         pascal_printchar (current_char, type, stream);
23222           fprintf_filtered (stream, " <repeats %u times>", reps);
23223           i = rep1 - 1;
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
23227 --- a/gdb/p-lang.h
23228 +++ b/gdb/p-lang.h
23229 @@ -48,12 +48,13 @@ extern void pascal_type_print_method_args (char *, char *,
23230  /* These are in p-lang.c: */
23231  
23232  extern int 
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 **);
23236  
23237 -extern void pascal_printchar (int, struct ui_file *);
23238 +extern void pascal_printchar (int, struct type *, struct ui_file *);
23239  
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 *);
23245  
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;
23253    unsigned eltlen;
23254    int length_pos, length_size, string_pos;
23255 -  int char_size;
23256 +  struct type *char_type;
23257    LONGEST val;
23258    CORE_ADDR addr;
23259  
23260 @@ -100,8 +100,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23261                   len = temp_len;
23262                 }
23263  
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,
23268 +                              options);
23269               i = len;
23270             }
23271           else
23272 @@ -175,8 +176,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23273               && addr != 0)
23274             {
23275               /* no wide string yet */
23276 -             i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, 
23277 -                   options);
23278 +             i = val_print_string (elttype, addr, -1, stream, options);
23279             }
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)
23288               && addr != 0)
23289             {
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);
23294                xfree (buffer);
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);
23297             }
23298           else if (pascal_object_is_vtbl_member (type))
23299             {
23300 @@ -298,10 +298,10 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
23301        else
23302         {
23303            if (is_pascal_string_type (type, &length_pos, &length_size,
23304 -                                     &string_pos, &char_size, NULL))
23305 +                                     &string_pos, &char_type, NULL))
23306             {
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);
23310             }
23311           else
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,
23314           else
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);
23319         }
23320        break;
23321  
23322 @@ -931,7 +931,7 @@ pascal_object_print_static_field (struct value *val,
23323  
23324    if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
23325      {
23326 -      CORE_ADDR *first_dont_print;
23327 +      CORE_ADDR *first_dont_print, addr;
23328        int i;
23329  
23330        first_dont_print
23331 @@ -941,7 +941,7 @@ pascal_object_print_static_field (struct value *val,
23332  
23333        while (--i >= 0)
23334         {
23335 -         if (VALUE_ADDRESS (val) == first_dont_print[i])
23336 +         if (value_address (val) == first_dont_print[i])
23337             {
23338               fputs_filtered ("<same as static member of an already seen type>",
23339                               stream);
23340 @@ -949,11 +949,12 @@ pascal_object_print_static_field (struct value *val,
23341             }
23342         }
23343  
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));
23348  
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);
23353        return;
23354      }
23355 diff --git a/gdb/parse.c b/gdb/parse.c
23356 index eee1f8e..66aaf6a 100644
23357 --- a/gdb/parse.c
23358 +++ b/gdb/parse.c
23359 @@ -306,7 +306,7 @@ write_exp_elt_intern (struct internalvar *expelt)
23360     strings with embedded null bytes, as is required for some languages.
23361  
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);
23370  }
23371  
23372 +/* Add a vector of string constants to the end of the expression.
23373 +
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.
23377 +   
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.
23381 +   
23382 +   Next, each string in VEC is written.  The length is written as a
23383 +   long constant, followed by the contents of the string.  */
23384 +
23385 +void
23386 +write_exp_string_vector (int type, struct stoken_vector *vec)
23387 +{
23388 +  int i, n_slots, len;
23389 +
23390 +  /* Compute the size.  We compute the size in number of slots to
23391 +     avoid issues with string padding.  */
23392 +  n_slots = 0;
23393 +  for (i = 0; i < vec->len; ++i)
23394 +    {
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);
23398 +    }
23399 +
23400 +  /* One more slot for the type of the string.  */
23401 +  ++n_slots;
23402 +
23403 +  /* Now compute a phony string length.  */
23404 +  len = EXP_ELEM_TO_BYTES (n_slots) - 1;
23405 +
23406 +  n_slots += 4;
23407 +  if ((expout_ptr + n_slots) >= expout_size)
23408 +    {
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)));
23413 +    }
23414 +
23415 +  write_exp_elt_opcode (OP_STRING);
23416 +  write_exp_elt_longcst (len);
23417 +  write_exp_elt_longcst (type);
23418 +
23419 +  for (i = 0; i < vec->len; ++i)
23420 +    {
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);
23425 +    }
23426 +
23427 +  write_exp_elt_longcst (len);
23428 +  write_exp_elt_opcode (OP_STRING);
23429 +}
23430 +
23431  /* Add a bitstring constant to the end of the expression.
23432  
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);
23436        break;
23437  
23438 +    case TYPE_INSTANCE:
23439 +      oplen = 4 + longest_to_int (expr->elts[endpos - 2].longconst);
23440 +      args = 1;
23441 +      break;
23442 +
23443 +    case TYPE_INSTANCE_LOOKUP:
23444 +      oplen = 3;
23445 +      break;
23446 +
23447      case OP_OBJC_MSGCALL:      /* Objective C message (method) call */
23448        oplen = 4;
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
23455      int length;
23456    };
23457  
23458 +struct typed_stoken
23459 +  {
23460 +    /* A language-specific type field.  */
23461 +    int type;
23462 +    /* Pointer to first byte of char-string or first bit of bit-string */
23463 +    char *ptr;
23464 +    /* Length of string in bytes for char-string or bits for bit-string */
23465 +    int length;
23466 +  };
23467 +
23468 +struct stoken_vector
23469 +  {
23470 +    int len;
23471 +    struct typed_stoken *tokens;
23472 +  };
23473 +
23474  struct ttype
23475    {
23476      struct stoken stoken;
23477 @@ -130,6 +146,8 @@ extern void write_exp_elt_intern (struct internalvar *);
23478  
23479  extern void write_exp_string (struct stoken);
23480  
23481 +void write_exp_string_vector (int type, struct stoken_vector *vec);
23482 +
23483  extern void write_exp_bitstring (struct stoken);
23484  
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
23490 @@ -38,6 +38,7 @@
23491  #include "trad-frame.h"
23492  #include "frame-unwind.h"
23493  #include "tramp-frame.h"
23494 +#include "linux-tdep.h"
23495  
23496  #include "features/rs6000/powerpc-32l.c"
23497  #include "features/rs6000/powerpc-altivec32l.c"
23498 @@ -53,6 +54,9 @@
23499  #include "features/rs6000/powerpc-isa205-vsx64l.c"
23500  #include "features/rs6000/powerpc-e500l.c"
23501  
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"
23505  
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;
23510  }
23511  
23512 +/* Return the current system call's number present in the
23513 +   r0 register.  When the function fails, it returns -1.  */
23514 +static LONGEST
23515 +ppc_linux_get_syscall_number (struct gdbarch *gdbarch,
23516 +                              ptid_t ptid)
23517 +{
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 */
23522 +  gdb_byte *buf;
23523 +  /* The result */
23524 +  LONGEST ret;
23525 +
23526 +  /* Make sure we're in a 32- or 64-bit machine */
23527 +  gdb_assert (tdep->wordsize == 4 || tdep->wordsize == 8);
23528 +
23529 +  buf = (gdb_byte *) xmalloc (tdep->wordsize * sizeof (gdb_byte));
23530 +
23531 +  cleanbuf = make_cleanup (xfree, buf);
23532 +
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);
23537 +
23538 +  ret = extract_signed_integer (buf, tdep->wordsize);
23539 +  do_cleanups (cleanbuf);
23540 +
23541 +  return ret;
23542 +}
23543 +
23544  static void
23545  ppc_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
23546  {
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;
23550  
23551 +  /* Initializing common methods.  */
23552 +  linux_tdep_init (gdbarch);
23553 +
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);
23560  
23561 +  /* Get the syscall number from the arch's register.  */
23562 +  set_gdbarch_get_syscall_number (gdbarch, ppc_linux_get_syscall_number);
23563 +
23564    if (tdep->wordsize == 4)
23565      {
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);
23570  
23571 +      /* Setting the correct XML syscall filename.  */
23572 +      set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_PPC);
23573 +
23574        /* Trampolines.  */
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);
23580  
23581 +      /* Setting the correct XML syscall filename.  */
23582 +      set_gdbarch_xml_syscall_filename (gdbarch, XML_SYSCALL_FILENAME_PPC64);
23583 +
23584        /* Trampolines.  */
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
23591 @@ -43,6 +43,7 @@
23592  #include "disasm.h"
23593  #include "dfp.h"
23594  #include "valprint.h"
23595 +#include "charset.h"
23596  
23597  #ifdef TUI
23598  #include "tui/tui.h"           /* For tui_active et.al.   */
23599 @@ -62,11 +63,15 @@ struct format_data
23600      int count;
23601      char format;
23602      char size;
23603 +
23604 +    /* True if the value should be printed raw -- that is, bypassing
23605 +       python-based formatters.  */
23606 +    unsigned char raw;
23607    };
23608  
23609  /* Last specified output format.  */
23610  
23611 -static char last_format = 'x';
23612 +static char last_format = 0;
23613  
23614  /* Last specified examination size.  'b', 'h', 'w' or `q'.  */
23615  
23616 @@ -175,6 +180,7 @@ decode_format (char **string_ptr, int oformat, int osize)
23617    val.format = '?';
23618    val.size = '?';
23619    val.count = 1;
23620 +  val.raw = 0;
23621  
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)
23625      {
23626        if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
23627         val.size = *p++;
23628 +      else if (*p == 'r')
23629 +       {
23630 +         val.raw = 1;
23631 +         p++;
23632 +       }
23633        else if (*p >= 'a' && *p <= 'z')
23634         val.format = *p++;
23635        else
23636 @@ -264,24 +275,27 @@ print_formatted (struct value *val, int size,
23637    int len = TYPE_LENGTH (type);
23638  
23639    if (VALUE_LVAL (val) == lval_memory)
23640 -    next_address = VALUE_ADDRESS (val) + len;
23641 +    next_address = value_address (val) + len;
23642  
23643    if (size)
23644      {
23645        switch (options->format)
23646         {
23647         case 's':
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,
23651 -                               options);
23652 +         {
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));
23658 +         }
23659           return;
23660  
23661         case 'i':
23662           /* We often wrap here if there are long symbolic names.  */
23663           wrap_here ("    ");
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));
23669           return;
23670         }
23671 @@ -369,7 +383,7 @@ print_scalar_formatted (const void *valaddr, struct type *type,
23672           print_hex_chars (stream, valaddr, len, byte_order);
23673           return;
23674         case 'c':
23675 -         print_char_chars (stream, valaddr, len, byte_order);
23676 +         print_char_chars (stream, type, valaddr, len, byte_order);
23677           return;
23678         default:
23679           break;
23680 @@ -865,6 +879,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
23681        fmt.count = 1;
23682        fmt.format = 0;
23683        fmt.size = 0;
23684 +      fmt.raw = 0;
23685      }
23686  
23687    if (exp && *exp)
23688 @@ -878,6 +893,11 @@ print_command_1 (char *exp, int inspect, int voidprint)
23689    else
23690      val = access_value_history (0);
23691  
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.  */
23696 +
23697    if (voidprint || (val && value_type (val) &&
23698                     TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
23699      {
23700 @@ -900,6 +920,7 @@ print_command_1 (char *exp, int inspect, int voidprint)
23701  
23702        get_formatted_print_options (&opts, format);
23703        opts.inspect_it = inspect;
23704 +      opts.raw = fmt.raw;
23705  
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;
23710  
23711    fmt.size = 0;
23712 +  fmt.raw = 0;
23713  
23714    if (exp && *exp == '/')
23715      {
23716 @@ -967,6 +989,7 @@ output_command (char *exp, int from_tty)
23717    annotate_value_begin (value_type (val));
23718  
23719    get_formatted_print_options (&opts, format);
23720 +  opts.raw = fmt.raw;
23721    print_formatted (val, fmt.size, &opts, gdb_stdout);
23722  
23723    annotate_value_end ();
23724 @@ -1287,9 +1310,10 @@ x_command (char *exp, int from_tty)
23725    struct cleanup *old_chain;
23726    struct value *val;
23727  
23728 -  fmt.format = last_format;
23729 +  fmt.format = last_format ? last_format : 'x';
23730    fmt.size = last_size;
23731    fmt.count = 1;
23732 +  fmt.raw = 0;
23733  
23734    if (exp && *exp == '/')
23735      {
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);
23742        else
23743         next_address = value_as_address (val);
23744        do_cleanups (old_chain);
23745 @@ -1393,6 +1417,7 @@ display_command (char *exp, int from_tty)
23746           fmt.format = 0;
23747           fmt.size = 0;
23748           fmt.count = 0;
23749 +         fmt.raw = 0;
23750         }
23751  
23752        innermost_block = 0;
23753 @@ -1585,6 +1610,7 @@ do_one_display (struct display *d)
23754        annotate_display_expression ();
23755  
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)
23762  
23763      enum argclass
23764        {
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
23769        };
23770      enum argclass *argclass;
23771 @@ -1997,8 +2024,8 @@ printf_command (char *arg, int from_tty)
23772               break;
23773  
23774             case 'c':
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)
23779                 bad = 1;
23780               if (seen_prec || seen_zero || seen_space || seen_plus)
23781                 bad = 1;
23782 @@ -2013,8 +2040,8 @@ printf_command (char *arg, int from_tty)
23783               break;
23784  
23785             case 's':
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)
23790                 bad = 1;
23791               if (seen_zero || seen_space || seen_plus)
23792                 bad = 1;
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;
23796             }
23797 +         else if (this_argclass == wide_string_arg
23798 +                  || this_argclass == wide_char_arg)
23799 +           {
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;
23805 +           }
23806           else
23807             {
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);
23811             }
23812             break;
23813 +         case wide_string_arg:
23814 +           {
23815 +             gdb_byte *str;
23816 +             CORE_ADDR tem;
23817 +             int j;
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;
23823 +
23824 +             tem = value_as_address (val_args[i]);
23825 +
23826 +             /* This is a %s argument.  Find the length of the string.  */
23827 +             for (j = 0;; j += wcwidth)
23828 +               {
23829 +                 QUIT;
23830 +                 read_memory (tem + j, buf, wcwidth);
23831 +                 if (extract_unsigned_integer (buf, wcwidth) == 0)
23832 +                   break;
23833 +               }
23834 +
23835 +             /* Copy the string contents into a string inside GDB.  */
23836 +             str = (gdb_byte *) alloca (j + wcwidth);
23837 +             if (j != 0)
23838 +               read_memory (tem, str, j);
23839 +             memset (&str[j], 0, wcwidth);
23840 +
23841 +             obstack_init (&output);
23842 +             inner_cleanup = make_cleanup_obstack_free (&output);
23843 +
23844 +             convert_between_encodings (target_wide_charset (),
23845 +                                        host_charset (),
23846 +                                        str, j, wcwidth,
23847 +                                        &output, translit_char);
23848 +             obstack_grow_str0 (&output, "");
23849 +
23850 +             printf_filtered (current_substring, obstack_base (&output));
23851 +             do_cleanups (inner_cleanup);
23852 +           }
23853 +           break;
23854 +         case wide_char_arg:
23855 +           {
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;
23861 +
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"));
23866 +
23867 +             bytes = value_contents (val_args[i]);
23868 +
23869 +             obstack_init (&output);
23870 +             inner_cleanup = make_cleanup_obstack_free (&output);
23871 +
23872 +             convert_between_encodings (target_wide_charset (),
23873 +                                        host_charset (),
23874 +                                        bytes, TYPE_LENGTH (valtype),
23875 +                                        TYPE_LENGTH (valtype),
23876 +                                        &output, translit_char);
23877 +             obstack_grow_str0 (&output, "");
23878 +
23879 +             printf_filtered (current_substring, obstack_base (&output));
23880 +             do_cleanups (inner_cleanup);
23881 +           }
23882 +           break;
23883           case double_arg:
23884             {
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
23889 --- /dev/null
23890 +++ b/gdb/python/lib/gdb/FrameIterator.py
23891 @@ -0,0 +1,33 @@
23892 +# Iterator over frames.
23893 +
23894 +# Copyright (C) 2008 Free Software Foundation, Inc.
23895 +
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.
23900 +#
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.
23905 +#
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/>.
23908 +
23909 +class FrameIterator:
23910 +    """An iterator that iterates over frames."""
23911 +
23912 +    def __init__ (self, frame):
23913 +        "Initialize a FrameIterator.  FRAME is the starting frame."
23914 +        self.frame = frame
23915 +
23916 +    def __iter__ (self):
23917 +        return self
23918 +
23919 +    def next (self):
23920 +        result = self.frame
23921 +        if result == None:
23922 +            raise StopIteration
23923 +        self.frame = result.older ()
23924 +        return result
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
23928 --- /dev/null
23929 +++ b/gdb/python/lib/gdb/__init__.py
23930 @@ -0,0 +1,19 @@
23931 +# Startup code.
23932 +
23933 +# Copyright (C) 2008 Free Software Foundation, Inc.
23934 +
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.
23939 +#
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.
23944 +#
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/>.
23947 +
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
23953 --- /dev/null
23954 +++ b/gdb/python/lib/gdb/backtrace.py
23955 @@ -0,0 +1,42 @@
23956 +# Filtering backtrace.
23957 +
23958 +# Copyright (C) 2008 Free Software Foundation, Inc.
23959 +
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.
23964 +#
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.
23969 +#
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/>.
23972 +
23973 +import gdb
23974 +import itertools
23975 +
23976 +# Our only exports.
23977 +__all__ = ['push_frame_filter', 'create_frame_filter']
23978 +
23979 +frame_filter = None
23980 +
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
23989 +    else:
23990 +        frame_filter = lambda iterator: constructor (frame_filter (iterator))
23991 +
23992 +def create_frame_filter (iter):
23993 +    global frame_filter
23994 +    if frame_filter is None:
23995 +        return iter
23996 +    return frame_filter (iter)
23997 +
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
24001 --- /dev/null
24002 +++ b/gdb/python/lib/gdb/command/__init__.py
24003 @@ -0,0 +1 @@
24004 +
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
24008 --- /dev/null
24009 +++ b/gdb/python/lib/gdb/command/alias.py
24010 @@ -0,0 +1,59 @@
24011 +# Alias command.
24012 +
24013 +# Copyright (C) 2008 Free Software Foundation, Inc.
24014 +
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.
24019 +#
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.
24024 +#
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/>.
24027 +
24028 +import gdb
24029 +
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)
24037 +        self.real = real
24038 +
24039 +    def invoke(self, arg, from_tty):
24040 +        gdb.execute (self.real + ' ' + arg, from_tty)
24041 +
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."""
24048 +
24049 +    def __init__ (self):
24050 +        # Completion is not quite right here.
24051 +        super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
24052 +                                             gdb.COMPLETE_COMMAND)
24053 +
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()
24059 +        try:
24060 +            start = args.index ('=')
24061 +            end = start + 1
24062 +        except ValueError:
24063 +            start = 1
24064 +            end = 1
24065 +        target = " ".join(args[end:])
24066 +        AliasImplementation (" ".join (args[0:start]), target,
24067 +                             "This command is an alias for '%s'." % target)
24068 +
24069 +AliasCommand()
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
24073 --- /dev/null
24074 +++ b/gdb/python/lib/gdb/command/backtrace.py
24075 @@ -0,0 +1,197 @@
24076 +# New backtrace command.
24077 +
24078 +# Copyright (C) 2008 Free Software Foundation, Inc.
24079 +
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.
24084 +#
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.
24089 +#
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/>.
24092 +
24093 +import gdb
24094 +import gdb.backtrace
24095 +import itertools
24096 +from gdb.FrameIterator import FrameIterator
24097 +import sys
24098 +
24099 +class FrameWrapper:
24100 +    def __init__ (self, frame):
24101 +        self.frame = frame;
24102 +
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:
24107 +                sym = nsym
24108 +
24109 +        stream.write (sym.print_name + "=")
24110 +        try:
24111 +            val = self.frame.read_var (sym)
24112 +            if val != None:
24113 +                val = str (val)
24114 +        # FIXME: would be nice to have a more precise exception here.
24115 +        except RuntimeError, text:
24116 +            val = text
24117 +        if val == None:
24118 +            stream.write ("???")
24119 +        else:
24120 +            stream.write (str (val))
24121 +
24122 +    def print_frame_locals (self, stream, func):
24123 +        if not func:
24124 +            return
24125 +
24126 +        first = True
24127 +        block = func.value
24128 +
24129 +        for sym in block:
24130 +            if sym.is_argument:
24131 +                continue;
24132 +
24133 +            self.write_symbol (stream, sym, block)
24134 +            stream.write ('\n')
24135 +
24136 +    def print_frame_args (self, stream, func):
24137 +        if not func:
24138 +            return
24139 +
24140 +        first = True
24141 +        block = func.value
24142 +
24143 +        for sym in block:
24144 +            if not sym.is_argument:
24145 +                continue;
24146 +
24147 +            if not first:
24148 +                stream.write (", ")
24149 +
24150 +            self.write_symbol (stream, sym, block)
24151 +            first = False
24152 +
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")
24160 +        else:
24161 +            sal = self.frame.find_sal ()
24162 +            pc = self.frame.pc ()
24163 +            name = self.frame.name ()
24164 +            if not name:
24165 +                name = "??"
24166 +            if pc != sal.pc or not sal.symtab:
24167 +                stream.write (" 0x%08x in" % pc)
24168 +            stream.write (" " + name + " (")
24169 +
24170 +            func = gdb.find_pc_function (self.frame.addr_in_block ())
24171 +            self.print_frame_args (stream, func)
24172 +
24173 +            stream.write (")")
24174 +
24175 +            if sal.symtab and sal.symtab.filename:
24176 +                stream.write (" at " + sal.symtab.filename)
24177 +                stream.write (":" + str (sal.line))
24178 +
24179 +            if not self.frame.name () or (not sal.symtab or not sal.symtab.filename):
24180 +                lib = gdb.solib_address (pc)
24181 +                if lib:
24182 +                    stream.write (" from " + lib)
24183 +
24184 +            stream.write ("\n")
24185 +
24186 +            if full:
24187 +                self.print_frame_locals (stream, func)
24188 +
24189 +    def __getattr__ (self, name):
24190 +        return getattr (self.frame, name)
24191 +
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."""
24196 +
24197 +    set_doc = "Enable or disable reverse backtraces."
24198 +    show_doc = "Show whether backtraces will be printed in reverse order."
24199 +
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
24205 +
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.
24211 +"""
24212 +
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()
24218 +
24219 +    def reverse_iter (self, iter):
24220 +        result = []
24221 +        for item in iter:
24222 +            result.append (item)
24223 +        result.reverse()
24224 +        return result
24225 +
24226 +    def final_n (self, iter, x):
24227 +        result = []
24228 +        for item in iter:
24229 +            result.append (item)
24230 +        return result[x:]
24231 +
24232 +    def invoke (self, arg, from_tty):
24233 +        i = 0
24234 +        count = 0
24235 +        filter = True
24236 +        full = False
24237 +
24238 +        for word in arg.split (" "):
24239 +            if word == '':
24240 +                continue
24241 +            elif word == 'raw':
24242 +                filter = False
24243 +            elif word == 'full':
24244 +                full = True
24245 +            else:
24246 +                count = int (word)
24247 +
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 ()))
24252 +        if filter:
24253 +            iter = gdb.backtrace.create_frame_filter (iter)
24254 +
24255 +        # Now wrap in an iterator that numbers the frames.
24256 +        iter = itertools.izip (itertools.count (0), iter)
24257 +
24258 +        # Reverse if the user wanted that.
24259 +        if self.reverse.value:
24260 +            iter = self.reverse_iter (iter)
24261 +
24262 +        # Extract sub-range user wants.
24263 +        if count < 0:
24264 +            iter = self.final_n (iter, count)
24265 +        elif count > 0:
24266 +            iter = itertools.islice (iter, 0, count)
24267 +
24268 +        for pair in iter:
24269 +            sys.stdout.write ("#%-2d" % pair[0])
24270 +            pair[1].describe (sys.stdout, full)
24271 +
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
24276 --- /dev/null
24277 +++ b/gdb/python/lib/gdb/command/ignore_errors.py
24278 @@ -0,0 +1,37 @@
24279 +# Ignore errors in user commands.
24280 +
24281 +# Copyright (C) 2008 Free Software Foundation, Inc.
24282 +
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.
24287 +#
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.
24292 +#
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/>.
24295 +
24296 +import gdb
24297 +
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."""
24302 +
24303 +    def __init__ (self):
24304 +        super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
24305 +                                                    gdb.COMMAND_OBSCURE,
24306 +                                                    # FIXME...
24307 +                                                    gdb.COMPLETE_COMMAND)
24308 +
24309 +    def invoke (self, arg, from_tty):
24310 +        try:
24311 +            gdb.execute (arg, from_tty)
24312 +        except:
24313 +            pass
24314 +
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
24319 --- /dev/null
24320 +++ b/gdb/python/lib/gdb/command/pahole.py
24321 @@ -0,0 +1,81 @@
24322 +# pahole command for gdb
24323 +
24324 +# Copyright (C) 2008 Free Software Foundation, Inc.
24325 +
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.
24330 +#
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.
24335 +#
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/>.
24338 +
24339 +import gdb
24340 +
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."""
24345 +
24346 +    def __init__ (self):
24347 +        super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
24348 +                                       gdb.COMPLETE_SYMBOL)
24349 +
24350 +    @staticmethod
24351 +    def strip (type):
24352 +        while type.code () == gdb.TYPE_CODE_TYPEDEF:
24353 +            type = type.target ()
24354 +        return type
24355 +
24356 +    def pahole (self, type, level, name):
24357 +        if name is None:
24358 +            name = ''
24359 +        tag = type.tag ()
24360 +        if tag is None:
24361 +            tag = ''
24362 +        print '%sstruct %s {' % (' ' * (2 * level), tag)
24363 +        bitpos = 0
24364 +        for field in type.fields ():
24365 +            # Skip static fields.
24366 +            if not hasattr (field, ('bitpos')):
24367 +                continue
24368 +
24369 +            ftype = self.strip (field.type)
24370 +
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
24377 +            else:
24378 +                # TARGET_CHAR_BIT here...
24379 +                fieldsize = 8 * ftype.sizeof ()
24380 +
24381 +            # TARGET_CHAR_BIT
24382 +            print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
24383 +            bitpos = bitpos + fieldsize
24384 +
24385 +            if ftype.code () == gdb.TYPE_CODE_STRUCT:
24386 +                self.pahole (ftype, level + 1, field.name)
24387 +            else:
24388 +                print ' ' * (2 + 2 * level),
24389 +                print '%s %s' % (str (ftype), field.name)
24390 +
24391 +        print ' ' * (14 + 2 * level),
24392 +        print '} %s' % name
24393 +
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
24399 +        print ' ' * 14,
24400 +        self.pahole (type, 0, '')
24401 +
24402 +Pahole()
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
24406 --- /dev/null
24407 +++ b/gdb/python/lib/gdb/command/require.py
24408 @@ -0,0 +1,57 @@
24409 +# Demand-loading commands.
24410 +
24411 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24412 +
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.
24417 +#
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.
24422 +#
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/>.
24425 +
24426 +import gdb
24427 +import os
24428 +
24429 +class RequireCommand (gdb.Command):
24430 +    """Prefix command for requiring features."""
24431 +
24432 +    def __init__ (self):
24433 +        super (RequireCommand, self).__init__ ("require",
24434 +                                               gdb.COMMAND_SUPPORT,
24435 +                                               gdb.COMPLETE_NONE,
24436 +                                               True)
24437 +
24438 +class RequireSubcommand (gdb.Command):
24439 +    """Demand-load a command by name."""
24440 +
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)
24445 +        self.name = name
24446 +
24447 +    def invoke (self, arg, from_tty):
24448 +        for cmd in arg.split():
24449 +            exec ('import gdb.' + self.name + '.' + cmd, globals ())
24450 +
24451 +    def complete (self, text, word):
24452 +        dir = gdb.pythondir + '/gdb/' + self.name
24453 +        result = []
24454 +        for file in os.listdir(dir):
24455 +            if not file.startswith (word) or not file.endswith ('.py'):
24456 +                continue
24457 +            feature = file[0:-3]
24458 +            if feature == 'require' or feature == '__init__':
24459 +                continue
24460 +            result.append (feature)
24461 +        return result
24462 +
24463 +RequireCommand()
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
24469 --- /dev/null
24470 +++ b/gdb/python/lib/gdb/command/save_breakpoints.py
24471 @@ -0,0 +1,65 @@
24472 +# Save breakpoints.
24473 +
24474 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24475 +
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.
24480 +#
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.
24485 +#
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/>.
24488 +
24489 +from __future__ import with_statement
24490 +import gdb
24491 +
24492 +class SavePrefixCommand (gdb.Command):
24493 +  "Prefix command for saving things."
24494 +
24495 +  def __init__ (self):
24496 +    super (SavePrefixCommand, self).__init__ ("save",
24497 +                                              gdb.COMMAND_SUPPORT,
24498 +                                              gdb.COMPLETE_NONE, True)
24499 +
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."""
24504 +
24505 +    def __init__ (self):
24506 +        super (SaveBreakpointsCommand, self).__init__ ("save breakpoints",
24507 +                                                       gdb.COMMAND_SUPPORT,
24508 +                                                       gdb.COMPLETE_FILENAME)
24509 +
24510 +    def invoke (self, arg, from_tty):
24511 +        self.dont_repeat ()
24512 +        bps = gdb.breakpoints ()
24513 +        if bps is None:
24514 +            raise RuntimeError, 'No breakpoints to save'
24515 +        with open (arg.strip (), 'w') as f:
24516 +            for bp in bps:
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,
24522 +                print >> f
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"
24533 +                print >> f
24534 +
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
24540 --- /dev/null
24541 +++ b/gdb/python/lib/gdb/function/__init__.py
24542 @@ -0,0 +1 @@
24543 +
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
24547 --- /dev/null
24548 +++ b/gdb/python/lib/gdb/function/caller_is.py
24549 @@ -0,0 +1,58 @@
24550 +# Caller-is functions.
24551 +
24552 +# Copyright (C) 2008 Free Software Foundation, Inc.
24553 +
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.
24558 +#
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.
24563 +#
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/>.
24566 +
24567 +import gdb
24568 +import re
24569 +
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."""
24577 +
24578 +    def __init__ (self):
24579 +        super (CallerIs, self).__init__ ("caller_is")
24580 +
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 ()
24587 +
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."""
24595 +
24596 +    def __init__ (self):
24597 +        super (CallerMatches, self).__init__ ("caller_matches")
24598 +
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
24605 +
24606 +CallerIs()
24607 +CallerMatches()
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
24611 --- /dev/null
24612 +++ b/gdb/python/lib/gdb/function/in_scope.py
24613 @@ -0,0 +1,47 @@
24614 +# In-scope function.
24615 +
24616 +# Copyright (C) 2008 Free Software Foundation, Inc.
24617 +
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.
24622 +#
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.
24627 +#
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/>.
24630 +
24631 +import gdb
24632 +
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."""
24636 +
24637 +    def __init__ (self):
24638 +       super (InScope, self).__init__ ("in_scope")
24639 +
24640 +    def invoke (self, *vars):
24641 +        if len (vars) == 0:
24642 +           raise TypeError, "in_scope takes at least one argument"
24643 +
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))
24647 +       found = set ()
24648 +       block = gdb.selected_frame ().block ()
24649 +       while 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)
24655 +
24656 +           block = block.superblock
24657 +
24658 +       return wanted == found
24659 +
24660 +InScope ()
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
24664 --- /dev/null
24665 +++ b/gdb/python/lib/gdb/libstdcxx/__init__.py
24666 @@ -0,0 +1 @@
24667 +
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
24671 --- /dev/null
24672 +++ b/gdb/python/lib/gdb/libstdcxx/v6/__init__.py
24673 @@ -0,0 +1 @@
24674 +
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
24678 --- /dev/null
24679 +++ b/gdb/python/lib/gdb/libstdcxx/v6/hook.in
24680 @@ -0,0 +1,27 @@
24681 +# -*- python -*-
24682 +# Copyright (C) 2009 Free Software Foundation, Inc.
24683 +
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.
24688 +#
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.
24693 +#
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/>.
24696 +
24697 +import sys
24698 +import gdb
24699 +
24700 +# Update module path.
24701 +dir = '@dir@'
24702 +if not dir in sys.path:
24703 +    sys.path.insert(0, dir)
24704 +
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
24711 --- /dev/null
24712 +++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
24713 @@ -0,0 +1,629 @@
24714 +# Pretty-printers for libstc++.
24715 +
24716 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
24717 +
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.
24722 +#
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.
24727 +#
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/>.
24730 +
24731 +import gdb
24732 +import itertools
24733 +import re
24734 +
24735 +class StdPointerPrinter:
24736 +    "Print a smart pointer of some kind"
24737 +
24738 +    def __init__ (self, typename, val):
24739 +        self.typename = typename
24740 +        self.val = val
24741 +
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'])
24746 +
24747 +class UniquePointerPrinter:
24748 +    "Print a unique_ptr"
24749 +
24750 +    def __init__ (self, val):
24751 +        self.val = val
24752 +
24753 +    def to_string (self):
24754 +        return self.val['_M_t']
24755 +
24756 +class StdListPrinter:
24757 +    "Print a std::list"
24758 +
24759 +    class _iterator:
24760 +        def __init__(self, nodetype, head):
24761 +            self.nodetype = nodetype
24762 +            self.base = head['_M_next']
24763 +            self.head = head.address()
24764 +            self.count = 0
24765 +
24766 +        def __iter__(self):
24767 +            return self
24768 +
24769 +        def next(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'])
24777 +
24778 +    def __init__(self, val):
24779 +        self.val = val
24780 +
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'])
24785 +
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'
24790 +
24791 +class StdListIteratorPrinter:
24792 +    "Print std::list::iterator"
24793 +
24794 +    def __init__(self, val):
24795 +        self.val = val
24796 +
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']
24801 +
24802 +class StdSlistPrinter:
24803 +    "Print a __gnu_cxx::slist"
24804 +
24805 +    class _iterator:
24806 +        def __init__(self, nodetype, head):
24807 +            self.nodetype = nodetype
24808 +            self.base = head['_M_head']['_M_next']
24809 +            self.count = 0
24810 +
24811 +        def __iter__(self):
24812 +            return self
24813 +
24814 +        def next(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'])
24822 +
24823 +    def __init__(self, val):
24824 +        self.val = val
24825 +
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)
24830 +
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'
24835 +
24836 +class StdSlistIteratorPrinter:
24837 +    "Print __gnu_cxx::slist::iterator"
24838 +
24839 +    def __init__(self, val):
24840 +        self.val = val
24841 +
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']
24846 +
24847 +class StdVectorPrinter:
24848 +    "Print a std::vector"
24849 +
24850 +    class _iterator:
24851 +        def __init__ (self, start, finish):
24852 +            self.item = start
24853 +            self.finish = finish
24854 +            self.count = 0
24855 +
24856 +        def __iter__(self):
24857 +            return self
24858 +
24859 +        def next(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)
24867 +
24868 +    def __init__(self, val):
24869 +        self.val = val
24870 +
24871 +    def children(self):
24872 +        return self._iterator(self.val['_M_impl']['_M_start'],
24873 +                              self.val['_M_impl']['_M_finish'])
24874 +
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)))
24881 +
24882 +    def display_hint(self):
24883 +        return 'array'
24884 +
24885 +class StdVectorIteratorPrinter:
24886 +    "Print std::vector::iterator"
24887 +
24888 +    def __init__(self, val):
24889 +        self.val = val
24890 +
24891 +    def to_string(self):
24892 +        return self.val['_M_current'].dereference()
24893 +
24894 +class StdStackOrQueuePrinter:
24895 +    "Print a std::stack or std::queue"
24896 +
24897 +    def __init__ (self, typename, val):
24898 +        self.typename = typename
24899 +        self.visualizer = gdb.default_visualizer(val['c'])
24900 +
24901 +    def children (self):
24902 +        return self.visualizer.children()
24903 +
24904 +    def to_string (self):
24905 +        return '%s wrapping: %s' % (self.typename,
24906 +                                    self.visualizer.to_string())
24907 +
24908 +    def display_hint (self):
24909 +        if hasattr (self.visualizer, 'display_hint'):
24910 +            return self.visualizer.display_hint ()
24911 +        return None
24912 +
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']
24917 +        self.count = 0
24918 +
24919 +    def __iter__(self):
24920 +        return self
24921 +
24922 +    def __len__(self):
24923 +        return int (self.size)
24924 +
24925 +    def next(self):
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.
24932 +            node = self.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']
24937 +            else:
24938 +                parent = node.dereference()['_M_parent']
24939 +                while node == parent.dereference()['_M_right']:
24940 +                    node = parent
24941 +                    parent = parent.dereference()['_M_parent']
24942 +                if node.dereference()['_M_right'] != parent:
24943 +                    node = parent
24944 +            self.node = node
24945 +        return result
24946 +
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
24949 +# class above.
24950 +class StdRbtreeIteratorPrinter:
24951 +    "Print std::map::iterator"
24952 +
24953 +    def __init__ (self, val):
24954 +        self.val = val
24955 +
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']
24961 +
24962 +
24963 +class StdMapPrinter:
24964 +    "Print a std::map or std::multimap"
24965 +
24966 +    # Turn an RbtreeIterator into a pretty-print iterator.
24967 +    class _iter:
24968 +        def __init__(self, rbiter, type):
24969 +            self.rbiter = rbiter
24970 +            self.count = 0
24971 +            self.type = type
24972 +
24973 +        def __iter__(self):
24974 +            return self
24975 +
24976 +        def next(self):
24977 +            if self.count % 2 == 0:
24978 +                n = self.rbiter.next()
24979 +                n = n.cast(self.type).dereference()['_M_value_field']
24980 +                self.pair = n
24981 +                item = n['first']
24982 +            else:
24983 +                item = self.pair['second']
24984 +            result = ('[%d]' % self.count, item)
24985 +            self.count = self.count + 1
24986 +            return result
24987 +
24988 +    def __init__ (self, typename, val):
24989 +        self.typename = typename
24990 +        self.val = val
24991 +        self.iter = RbtreeIterator (val)
24992 +
24993 +    def to_string (self):
24994 +        return '%s with %d elements' % (self.typename, len (self.iter))
24995 +
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)
25002 +
25003 +    def display_hint (self):
25004 +        return 'map'
25005 +
25006 +class StdSetPrinter:
25007 +    "Print a std::set or std::multiset"
25008 +
25009 +    # Turn an RbtreeIterator into a pretty-print iterator.
25010 +    class _iter:
25011 +        def __init__(self, rbiter, type):
25012 +            self.rbiter = rbiter
25013 +            self.count = 0
25014 +            self.type = type
25015 +
25016 +        def __iter__(self):
25017 +            return self
25018 +
25019 +        def next(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
25026 +            return result
25027 +
25028 +    def __init__ (self, typename, val):
25029 +        self.typename = typename
25030 +        self.val = val
25031 +        self.iter = RbtreeIterator (val)
25032 +
25033 +    def to_string (self):
25034 +        return '%s with %d elements' % (self.typename, len (self.iter))
25035 +
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)
25040 +
25041 +class StdBitsetPrinter:
25042 +    "Print a std::bitset"
25043 +
25044 +    def __init__(self, val):
25045 +        self.val = val
25046 +
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'
25051 +
25052 +    def children (self):
25053 +        words = self.val['_M_w']
25054 +        wtype = words.type()
25055 +
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 ()
25061 +        else:
25062 +            words = [words]
25063 +            tsize = wtype.sizeof () 
25064 +
25065 +        nwords = wtype.sizeof() / tsize
25066 +        result = []
25067 +        byte = 0
25068 +        while byte < nwords:
25069 +            w = words[byte]
25070 +            bit = 0
25071 +            while w != 0:
25072 +                if (w & 1) != 0:
25073 +                    # Another spot where we could use 'set'?
25074 +                    result.append(('[%d]' % (byte * tsize * 8 + bit), 1))
25075 +                bit = bit + 1
25076 +                w = w >> 1
25077 +            byte = byte + 1
25078 +        return result
25079 +
25080 +class StdDequePrinter:
25081 +    "Print a std::deque"
25082 +
25083 +    class _iter:
25084 +        def __init__(self, node, start, end, last, buffer_size):
25085 +            self.node = node
25086 +            self.p = start
25087 +            self.end = end
25088 +            self.last = last
25089 +            self.buffer_size = buffer_size
25090 +            self.count = 0
25091 +
25092 +        def __iter__(self):
25093 +            return self
25094 +
25095 +        def next(self):
25096 +            if self.p == self.last:
25097 +                raise StopIteration
25098 +
25099 +            result = ('[%d]' % self.count, self.p.dereference())
25100 +            self.count = self.count + 1
25101 +
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
25106 +                # next bucket.
25107 +                self.node = self.node + 1
25108 +                self.p = self.node[0]
25109 +                self.end = self.p + self.buffer_size
25110 +
25111 +            return result
25112 +
25113 +    def __init__(self, val):
25114 +        self.val = val
25115 +        self.elttype = val.type().template_argument(0)
25116 +        size = self.elttype.sizeof ()
25117 +        if size < 512:
25118 +            self.buffer_size = int (512 / size)
25119 +        else:
25120 +            self.buffer_size = 1
25121 +
25122 +    def to_string(self):
25123 +        start = self.val['_M_impl']['_M_start']
25124 +        end = self.val['_M_impl']['_M_finish']
25125 +
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']
25129 +
25130 +        size = self.buffer_size * delta_n + delta_s + delta_e
25131 +
25132 +        return 'std::deque with %d elements' % long (size)
25133 +
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)
25139 +
25140 +    def display_hint (self):
25141 +        return 'array'
25142 +
25143 +class StdDequeIteratorPrinter:
25144 +    "Print std::deque::iterator"
25145 +
25146 +    def __init__(self, val):
25147 +        self.val = val
25148 +
25149 +    def to_string(self):
25150 +        return self.val['_M_cur'].dereference()
25151 +
25152 +class StdStringPrinter:
25153 +    "Print a std::basic_string of some kind"
25154 +
25155 +    def __init__(self, encoding, val):
25156 +        self.encoding = encoding
25157 +        self.val = val
25158 +
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)
25165 +
25166 +    def display_hint (self):
25167 +        return 'string'
25168 +
25169 +class Tr1HashtableIterator:
25170 +    def __init__ (self, hash):
25171 +        self.count = 0
25172 +        self.n_buckets = hash['_M_element_count']
25173 +        if self.n_buckets == 0:
25174 +            self.node = False
25175 +        else:
25176 +            self.bucket = hash['_M_buckets']
25177 +            self.node = self.bucket[0]
25178 +            self.update ()
25179 +
25180 +    def __iter__ (self):
25181 +        return self
25182 +
25183 +    def update (self):
25184 +        # If we advanced off the end of the chain, move to the next
25185 +        # bucket.
25186 +        while self.node == 0:
25187 +            self.bucket = self.bucket + 1
25188 +            self.node = self.bucket[0]
25189 +
25190 +       # If we advanced off the end of the bucket array, then
25191 +       # we're done.
25192 +        if self.count == self.n_buckets:
25193 +            self.node = False
25194 +        else:
25195 +            self.count = self.count + 1
25196 +
25197 +    def next (self):
25198 +        if not self.node:
25199 +            raise StopIteration
25200 +        result = self.node.dereference()['_M_v']
25201 +        self.node = self.node.dereference()['_M_next']
25202 +        self.update ()
25203 +        return result
25204 +
25205 +class Tr1UnorderedSetPrinter:
25206 +    "Print a tr1::unordered_set"
25207 +
25208 +    def __init__ (self, typename, val):
25209 +        self.typename = typename
25210 +        self.val = val
25211 +
25212 +    def to_string (self):
25213 +        return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
25214 +
25215 +    @staticmethod
25216 +    def format_count (i):
25217 +        return '[%d]' % i
25218 +
25219 +    def children (self):
25220 +        counter = itertools.imap (self.format_count, itertools.count())
25221 +        return itertools.izip (counter, Tr1HashtableIterator (self.val))
25222 +
25223 +class Tr1UnorderedMapPrinter:
25224 +    "Print a tr1::unordered_map"
25225 +
25226 +    def __init__ (self, typename, val):
25227 +        self.typename = typename
25228 +        self.val = val
25229 +
25230 +    def to_string (self):
25231 +        return '%s with %d elements' % (self.typename, self.val['_M_element_count'])
25232 +
25233 +    @staticmethod
25234 +    def flatten (list):
25235 +        for elt in list:
25236 +            for i in elt:
25237 +                yield i
25238 +
25239 +    @staticmethod
25240 +    def format_one (elt):
25241 +        return (elt['first'], elt['second'])
25242 +
25243 +    @staticmethod
25244 +    def format_count (i):
25245 +        return '[%d]' % i
25246 +
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)
25253 +
25254 +    def display_hint (self):
25255 +        return 'map'
25256 +
25257 +def register_libstdcxx_printers (obj):
25258 +    "Register libstdc++ pretty-printers with objfile Obj."
25259 +
25260 +    if obj == None:
25261 +        obj = gdb
25262 +
25263 +    obj.pretty_printers.append (lookup_function)
25264 +
25265 +def lookup_function (val):
25266 +    "Look-up and return a pretty-printer that can print val."
25267 +
25268 +    # Get the type.
25269 +    type = val.type ();
25270 +
25271 +    # If it points to a reference, get the reference.
25272 +    if type.code () == gdb.TYPE_CODE_REF:
25273 +        type = type.target ()
25274 +
25275 +    # Get the unqualified type, stripped of typedefs.
25276 +    type = type.unqualified ().strip_typedefs ()
25277 +
25278 +    # Get the type name.    
25279 +    typename = type.tag ()
25280 +    if typename == None:
25281 +        return None
25282 +
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)
25289 +        
25290 +    # Cannot find a pretty printer.  Return None.
25291 +    return None
25292 +
25293 +def build_libstdcxx_dictionary ():
25294 +    # libstdc++ objects requiring pretty-printing.
25295 +    # In order from:
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
25313 +    # vector<bool>
25314 +
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)
25323 +
25324 +
25325 +    # Extensions.
25326 +    pretty_printers_dict[re.compile('^__gnu_cxx::slist<.*>$')] = StdSlistPrinter
25327 +
25328 +    if True:
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)
25339 +
25340 +pretty_printers_dict = {}
25341 +
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
25346 --- /dev/null
25347 +++ b/gdb/python/python-block.c
25348 @@ -0,0 +1,265 @@
25349 +/* Python interface to blocks.
25350 +
25351 +   Copyright (C) 2008 Free Software Foundation, Inc.
25352 +
25353 +   This file is part of GDB.
25354 +
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.
25359 +
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.
25364 +
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/>.  */
25367 +
25368 +#include "defs.h"
25369 +#include "block.h"
25370 +#include "dictionary.h"
25371 +#include "symtab.h"
25372 +#include "python-internal.h"
25373 +
25374 +typedef struct {
25375 +  PyObject_HEAD
25376 +  struct block *block;
25377 +} block_object;
25378 +
25379 +typedef struct {
25380 +  PyObject_HEAD
25381 +  struct dictionary *dict;
25382 +  struct dict_iterator iter;
25383 +  int initialized_p;
25384 +} block_syms_iterator_object;
25385 +
25386 +static PyTypeObject block_syms_iterator_object_type;
25387 +
25388 +static PyObject *
25389 +blpy_iter (PyObject *self)
25390 +{
25391 +  block_syms_iterator_object *block_iter_obj;
25392 +
25393 +  block_iter_obj = PyObject_New (block_syms_iterator_object,
25394 +                           &block_syms_iterator_object_type);
25395 +  if (block_iter_obj == NULL)
25396 +    {
25397 +      PyErr_SetString (PyExc_MemoryError,
25398 +                      "Could not allocate iterator object.");
25399 +      return NULL;
25400 +    }
25401 +
25402 +  block_iter_obj->dict = BLOCK_DICT (((block_object *) self)->block);
25403 +  block_iter_obj->initialized_p = 0;
25404 +
25405 +  return (PyObject *) block_iter_obj;
25406 +}
25407 +
25408 +static PyObject *
25409 +blpy_get_start (PyObject *self, void *closure)
25410 +{
25411 +  block_object *self_block = (block_object *) self;
25412 +
25413 +  return PyLong_FromUnsignedLongLong (BLOCK_START (self_block->block));
25414 +}
25415 +
25416 +static PyObject *
25417 +blpy_get_end (PyObject *self, void *closure)
25418 +{
25419 +  block_object *self_block = (block_object *) self;
25420 +
25421 +  return PyLong_FromUnsignedLongLong (BLOCK_END (self_block->block));
25422 +}
25423 +
25424 +static PyObject *
25425 +blpy_get_function (PyObject *self, void *closure)
25426 +{
25427 +  block_object *self_block = (block_object *) self;
25428 +  struct symbol *sym;
25429 +
25430 +  sym = BLOCK_FUNCTION (self_block->block);
25431 +  if (sym)
25432 +    return symbol_to_symbol_object (sym);
25433 +
25434 +  Py_RETURN_NONE;
25435 +}
25436 +
25437 +static PyObject *
25438 +blpy_get_superblock (PyObject *self, void *closure)
25439 +{
25440 +  block_object *self_block = (block_object *) self;
25441 +  struct block *block;
25442 +
25443 +  block = BLOCK_SUPERBLOCK (self_block->block);
25444 +  if (block)
25445 +    return block_to_block_object (block);
25446 +
25447 +  Py_RETURN_NONE;
25448 +}
25449 +
25450 +PyObject *
25451 +block_to_block_object (struct block *block)
25452 +{
25453 +  block_object *block_obj;
25454 +
25455 +  block_obj = PyObject_New (block_object, &block_object_type);
25456 +  if (block_obj == NULL)
25457 +    {
25458 +      PyErr_SetString (PyExc_MemoryError, "Could not allocate block object.");
25459 +      return NULL;
25460 +    }
25461 +
25462 +  block_obj->block = block;
25463 +
25464 +  return (PyObject *) block_obj;
25465 +}
25466 +
25467 +struct block *
25468 +block_object_to_block (PyObject *obj)
25469 +{
25470 +  if (! PyObject_TypeCheck (obj, &block_object_type))
25471 +    return NULL;
25472 +  return ((block_object *) obj)->block;
25473 +}
25474 +
25475 +static PyObject *
25476 +blpy_block_syms_iter (PyObject *self)
25477 +{
25478 +  return self;
25479 +}
25480 +
25481 +static PyObject *
25482 +blpy_block_syms_iternext (PyObject *self)
25483 +{
25484 +  block_syms_iterator_object *iter_obj = (block_syms_iterator_object *) self;
25485 +  struct symbol *sym;
25486 +
25487 +  if (!iter_obj->initialized_p)
25488 +    {
25489 +      sym = dict_iterator_first (iter_obj->dict,  &(iter_obj->iter));
25490 +      iter_obj->initialized_p = 1;
25491 +    }
25492 +  else
25493 +    sym = dict_iterator_next (&(iter_obj->iter));
25494 +
25495 +  return (sym == NULL)? NULL : symbol_to_symbol_object (sym);
25496 +}
25497 +
25498 +/* Return the innermost lexical block containing the specified pc value,
25499 +   or 0 if there is none.  */
25500 +
25501 +PyObject *
25502 +gdbpy_block_for_pc (PyObject *self, PyObject *args)
25503 +{
25504 +  unsigned PY_LONG_LONG pc;
25505 +  struct block *block;
25506 +  PyObject *sym_obj;
25507 +
25508 +  if (!PyArg_ParseTuple (args, "K", &pc))
25509 +    return NULL;
25510 +
25511 +  block = block_for_pc (pc);
25512 +  if (block)
25513 +    return block_to_block_object (block);
25514 +
25515 +  Py_RETURN_NONE;
25516 +}
25517 +
25518 +void
25519 +gdbpy_initialize_blocks (void)
25520 +{
25521 +  block_object_type.tp_new = PyType_GenericNew;
25522 +  if (PyType_Ready (&block_object_type) < 0)
25523 +    return;
25524 +
25525 +  block_syms_iterator_object_type.tp_new = PyType_GenericNew;
25526 +  if (PyType_Ready (&block_syms_iterator_object_type) < 0)
25527 +    return;
25528 +
25529 +  Py_INCREF (&block_object_type);
25530 +  PyModule_AddObject (gdb_module, "Block", (PyObject *) &block_object_type);
25531 +
25532 +  Py_INCREF (&block_syms_iterator_object_type);
25533 +  PyModule_AddObject (gdb_module, "BlockIterator",
25534 +                     (PyObject *) &block_syms_iterator_object_type);
25535 +}
25536 +
25537 +\f
25538 +
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 */
25547 +};
25548 +
25549 +PyTypeObject block_object_type = {
25550 +  PyObject_HEAD_INIT (NULL)
25551 +  0,                             /*ob_size*/
25552 +  "gdb.Block",                   /*tp_name*/
25553 +  sizeof (block_object),         /*tp_basicsize*/
25554 +  0,                             /*tp_itemsize*/
25555 +  0,                             /*tp_dealloc*/
25556 +  0,                             /*tp_print*/
25557 +  0,                             /*tp_getattr*/
25558 +  0,                             /*tp_setattr*/
25559 +  0,                             /*tp_compare*/
25560 +  0,                             /*tp_repr*/
25561 +  0,                             /*tp_as_number*/
25562 +  0,                             /*tp_as_sequence*/
25563 +  0,                             /*tp_as_mapping*/
25564 +  0,                             /*tp_hash */
25565 +  0,                             /*tp_call*/
25566 +  0,                             /*tp_str*/
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 */
25581 +};
25582 +
25583 +static PyTypeObject block_syms_iterator_object_type = {
25584 +  PyObject_HEAD_INIT (NULL)
25585 +  0,                             /*ob_size*/
25586 +  "gdb.BlockIterator",           /*tp_name*/
25587 +  sizeof (block_syms_iterator_object),       /*tp_basicsize*/
25588 +  0,                             /*tp_itemsize*/
25589 +  0,                             /*tp_dealloc*/
25590 +  0,                             /*tp_print*/
25591 +  0,                             /*tp_getattr*/
25592 +  0,                             /*tp_setattr*/
25593 +  0,                             /*tp_compare*/
25594 +  0,                             /*tp_repr*/
25595 +  0,                             /*tp_as_number*/
25596 +  0,                             /*tp_as_sequence*/
25597 +  0,                             /*tp_as_mapping*/
25598 +  0,                             /*tp_hash */
25599 +  0,                             /*tp_call*/
25600 +  0,                             /*tp_str*/
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 */
25613 +};
25614 diff --git a/gdb/python/python-breakpoint.c b/gdb/python/python-breakpoint.c
25615 new file mode 100644
25616 index 0000000..ec80419
25617 --- /dev/null
25618 +++ b/gdb/python/python-breakpoint.c
25619 @@ -0,0 +1,665 @@
25620 +/* Python interface to breakpoints
25621 +
25622 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
25623 +
25624 +   This file is part of GDB.
25625 +
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.
25630 +
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.
25635 +
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/>.  */
25638 +
25639 +#include "defs.h"
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"
25648 +
25649 +
25650 +/* From breakpoint.c.  */
25651 +extern struct breakpoint *breakpoint_chain;
25652 +
25653 +
25654 +typedef struct breakpoint_object breakpoint_object;
25655 +
25656 +static PyTypeObject breakpoint_object_type;
25657 +
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
25663 +   breakpoint.  */
25664 +static breakpoint_object **bppy_breakpoints;
25665 +
25666 +/* Number of slots in bppy_breakpoints.  */
25667 +static int bppy_slots;
25668 +
25669 +/* Number of live breakpoints.  */
25670 +static int bppy_live;
25671 +
25672 +/* Variables used to pass information between the Breakpoint
25673 +   constructor and the breakpoint-created hook function.  */
25674 +static breakpoint_object *bppy_pending_object;
25675 +
25676 +struct breakpoint_object
25677 +{
25678 +  PyObject_HEAD
25679 +
25680 +  /* The breakpoint number according to gdb.  */
25681 +  int number;
25682 +
25683 +  /* The gdb breakpoint object, or NULL if the breakpoint has been
25684 +     deleted.  */
25685 +  struct breakpoint *bp;
25686 +};
25687 +
25688 +/* Evaluate to true if the breakpoint NUM is valid, false otherwise.  */
25689 +#define BPPY_VALID_P(Num)                      \
25690 +    ((Num) >= 0                                        \
25691 +     && (Num) < bppy_slots                     \
25692 +     && bppy_breakpoints[Num] != NULL)
25693 +
25694 +/* Require that BREAKPOINT be a valid breakpoint ID; throw a Python
25695 +   exception if it is invalid.  */
25696 +#define BPPY_REQUIRE_VALID(Breakpoint)                                 \
25697 +    do {                                                               \
25698 +      if (! BPPY_VALID_P ((Breakpoint)->number))                       \
25699 +       return PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
25700 +                            (Breakpoint)->number);                     \
25701 +    } while (0)
25702 +
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)                             \
25706 +    do {                                                               \
25707 +      if (! BPPY_VALID_P ((Breakpoint)->number))                       \
25708 +        {                                                              \
25709 +         PyErr_Format (PyExc_RuntimeError, "breakpoint %d is invalid", \
25710 +                       (Breakpoint)->number);                          \
25711 +         return -1;                                                    \
25712 +       }                                                               \
25713 +    } while (0)
25714 +
25715 +/* Python function which checks the validity of a breakpoint object.  */
25716 +static PyObject *
25717 +bppy_is_valid (PyObject *self, PyObject *args)
25718 +{
25719 +  if (((breakpoint_object *) self)->bp)
25720 +    Py_RETURN_TRUE;
25721 +  Py_RETURN_FALSE;
25722 +}
25723 +
25724 +/* Python function to test whether or not the breakpoint is enabled.  */
25725 +static PyObject *
25726 +bppy_get_enabled (PyObject *self, void *closure)
25727 +{
25728 +  if (! ((breakpoint_object *) self)->bp)
25729 +    Py_RETURN_FALSE;
25730 +  /* Not clear what we really want here.  */
25731 +  if (((breakpoint_object *) self)->bp->enable_state == bp_enabled)
25732 +    Py_RETURN_TRUE;
25733 +  Py_RETURN_FALSE;
25734 +}
25735 +
25736 +/* Python function to test whether or not the breakpoint is silent.  */
25737 +static PyObject *
25738 +bppy_get_silent (PyObject *self, void *closure)
25739 +{
25740 +  BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25741 +  if (((breakpoint_object *) self)->bp->silent)
25742 +    Py_RETURN_TRUE;
25743 +  Py_RETURN_FALSE;
25744 +}
25745 +
25746 +/* Python function to set the enabled state of a breakpoint.  */
25747 +static int
25748 +bppy_set_enabled (PyObject *self, PyObject *newvalue, void *closure)
25749 +{
25750 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25751 +  int cmp;
25752 +
25753 +  BPPY_SET_REQUIRE_VALID (self_bp);
25754 +
25755 +  if (newvalue == NULL)
25756 +    {
25757 +      PyErr_SetString (PyExc_TypeError, "cannot delete `enabled' attribute");
25758 +      return -1;
25759 +    }
25760 +  else if (! PyBool_Check (newvalue))
25761 +    {
25762 +      PyErr_SetString (PyExc_TypeError,
25763 +                      "the value of `enabled' must be a boolean");
25764 +      return -1;
25765 +    }
25766 +
25767 +  cmp = PyObject_IsTrue (newvalue);
25768 +  if (cmp < 0)
25769 +    return -1;
25770 +  else if (cmp == 1)
25771 +    enable_breakpoint (self_bp->bp);
25772 +  else 
25773 +    disable_breakpoint (self_bp->bp);
25774 +  return 0;
25775 +}
25776 +
25777 +/* Python function to set the 'silent' state of a breakpoint.  */
25778 +static int
25779 +bppy_set_silent (PyObject *self, PyObject *newvalue, void *closure)
25780 +{
25781 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25782 +  int cmp;
25783 +
25784 +  BPPY_SET_REQUIRE_VALID (self_bp);
25785 +
25786 +  if (newvalue == NULL)
25787 +    {
25788 +      PyErr_SetString (PyExc_TypeError, "cannot delete `silent' attribute");
25789 +      return -1;
25790 +    }
25791 +  else if (! PyBool_Check (newvalue))
25792 +    {
25793 +      PyErr_SetString (PyExc_TypeError,
25794 +                      "the value of `silent' must be a boolean");
25795 +      return -1;
25796 +    }
25797 +
25798 +  cmp = PyObject_IsTrue (newvalue);
25799 +  if (cmp < 0)
25800 +    return -1;
25801 +  else
25802 +    self_bp->bp->silent = cmp;
25803 +
25804 +  return 0;
25805 +}
25806 +
25807 +/* Python function to set the thread of a breakpoint.  */
25808 +static int
25809 +bppy_set_thread (PyObject *self, PyObject *newvalue, void *closure)
25810 +{
25811 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25812 +  int id;
25813 +
25814 +  BPPY_SET_REQUIRE_VALID (self_bp);
25815 +
25816 +  if (newvalue == NULL)
25817 +    {
25818 +      PyErr_SetString (PyExc_TypeError, "cannot delete `thread' attribute");
25819 +      return -1;
25820 +    }
25821 +  else if (PyInt_Check (newvalue))
25822 +    {
25823 +      id = (int) PyInt_AsLong (newvalue);
25824 +      if (! valid_thread_id (id))
25825 +       {
25826 +         PyErr_SetString (PyExc_RuntimeError, "invalid thread id");
25827 +         return -1;
25828 +       }
25829 +    }
25830 +  else if (newvalue == Py_None)
25831 +    id = -1;
25832 +  else
25833 +    {
25834 +      PyErr_SetString (PyExc_TypeError,
25835 +                      "the value of `thread' must be an integer or None");
25836 +      return -1;
25837 +    }
25838 +
25839 +  self_bp->bp->thread = id;
25840 +
25841 +  return 0;
25842 +}
25843 +
25844 +/* Python function to set the ignore count of a breakpoint.  */
25845 +static int
25846 +bppy_set_ignore_count (PyObject *self, PyObject *newvalue, void *closure)
25847 +{
25848 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25849 +  long value;
25850 +
25851 +  BPPY_SET_REQUIRE_VALID (self_bp);
25852 +
25853 +  if (newvalue == NULL)
25854 +    {
25855 +      PyErr_SetString (PyExc_TypeError,
25856 +                      "cannot delete `ignore_count' attribute");
25857 +      return -1;
25858 +    }
25859 +  else if (! PyInt_Check (newvalue))
25860 +    {
25861 +      PyErr_SetString (PyExc_TypeError,
25862 +                      "the value of `ignore_count' must be an integer");
25863 +      return -1;
25864 +    }
25865 +
25866 +  value = PyInt_AsLong (newvalue);
25867 +  if (value < 0)
25868 +    value = 0;
25869 +  set_ignore_count (self_bp->number, (int) value, 0);
25870 +
25871 +  return 0;
25872 +}
25873 +
25874 +/* Python function to set the hit count of a breakpoint.  */
25875 +static int
25876 +bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
25877 +{
25878 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25879 +
25880 +  BPPY_SET_REQUIRE_VALID (self_bp);
25881 +
25882 +  if (newvalue == NULL)
25883 +    {
25884 +      PyErr_SetString (PyExc_TypeError, "cannot delete `hit_count' attribute");
25885 +      return -1;
25886 +    }
25887 +  else if (! PyInt_Check (newvalue) || PyInt_AsLong (newvalue) != 0)
25888 +    {
25889 +      PyErr_SetString (PyExc_AttributeError,
25890 +                      "the value of `hit_count' must be zero");
25891 +      return -1;
25892 +    }
25893 +
25894 +  self_bp->bp->hit_count = 0;
25895 +
25896 +  return 0;
25897 +}
25898 +
25899 +/* Python function to get the location of a breakpoint.  */
25900 +static PyObject *
25901 +bppy_get_location (PyObject *self, void *closure)
25902 +{
25903 +  char *str;
25904 +
25905 +  BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25906 +  str = ((breakpoint_object *) self)->bp->addr_string;
25907 +  /* FIXME: watchpoints?  tracepoints?  */
25908 +  if (! str)
25909 +    str = "";
25910 +  return PyString_Decode (str, strlen (str), host_charset (), NULL);
25911 +}
25912 +
25913 +/* Python function to get the condition expression of a breakpoint.  */
25914 +static PyObject *
25915 +bppy_get_condition (PyObject *self, void *closure)
25916 +{
25917 +  char *str;
25918 +  BPPY_REQUIRE_VALID ((breakpoint_object *) self);
25919 +
25920 +  str = ((breakpoint_object *) self)->bp->cond_string;
25921 +  if (! str)
25922 +    Py_RETURN_NONE;
25923 +  return PyString_Decode (str, strlen (str), host_charset (), NULL);
25924 +}
25925 +
25926 +static int
25927 +bppy_set_condition (PyObject *self, PyObject *newvalue, void *closure)
25928 +{
25929 +  char *exp;
25930 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25931 +  volatile struct gdb_exception except;
25932 +
25933 +  BPPY_SET_REQUIRE_VALID (self_bp);
25934 +
25935 +  if (newvalue == NULL)
25936 +    {
25937 +      PyErr_SetString (PyExc_TypeError, "cannot delete `condition' attribute");
25938 +      return -1;
25939 +    }
25940 +  else if (newvalue == Py_None)
25941 +    exp = "";
25942 +  else
25943 +    {
25944 +      exp = python_string_to_host_string (newvalue);
25945 +      if (exp == NULL)
25946 +       return -1;
25947 +    }
25948 +
25949 +  TRY_CATCH (except, RETURN_MASK_ALL)
25950 +    {
25951 +      set_breakpoint_condition (self_bp->bp, exp, 0);
25952 +    }
25953 +  GDB_PY_SET_HANDLE_EXCEPTION (except);
25954 +
25955 +  return 0;
25956 +}
25957 +
25958 +/* Python function to get the commands attached to a breakpoint.  */
25959 +static PyObject *
25960 +bppy_get_commands (PyObject *self, void *closure)
25961 +{
25962 +  breakpoint_object *self_bp = (breakpoint_object *) self;
25963 +  long length;
25964 +  volatile struct gdb_exception except;
25965 +  struct ui_file *string_file;
25966 +  struct cleanup *chain;
25967 +  PyObject *result;
25968 +  char *cmdstr;
25969 +
25970 +  BPPY_REQUIRE_VALID (self_bp);
25971 +
25972 +  if (! self_bp->bp->commands)
25973 +    Py_RETURN_NONE;
25974 +
25975 +  string_file = mem_fileopen ();
25976 +  chain = make_cleanup_ui_file_delete (string_file);
25977 +
25978 +  TRY_CATCH (except, RETURN_MASK_ALL)
25979 +    {
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);
25985 +    }
25986 +  cmdstr = ui_file_xstrdup (string_file, &length);
25987 +  GDB_PY_HANDLE_EXCEPTION (except);
25988 +
25989 +  result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
25990 +  do_cleanups (chain);
25991 +  xfree (cmdstr);
25992 +  return result;
25993 +}
25994 +
25995 +/* Python function to get the breakpoint's number.  */
25996 +static PyObject *
25997 +bppy_get_number (PyObject *self, void *closure)
25998 +{
25999 +  breakpoint_object *self_bp = (breakpoint_object *) self;
26000 +
26001 +  BPPY_REQUIRE_VALID (self_bp);
26002 +
26003 +  return PyInt_FromLong (self_bp->number);
26004 +}
26005 +
26006 +/* Python function to get the breakpoint's thread ID.  */
26007 +static PyObject *
26008 +bppy_get_thread (PyObject *self, void *closure)
26009 +{
26010 +  breakpoint_object *self_bp = (breakpoint_object *) self;
26011 +
26012 +  BPPY_REQUIRE_VALID (self_bp);
26013 +
26014 +  if (self_bp->bp->thread == -1)
26015 +    Py_RETURN_NONE;
26016 +
26017 +  return PyInt_FromLong (self_bp->bp->thread);
26018 +}
26019 +
26020 +/* Python function to get the breakpoint's hit count.  */
26021 +static PyObject *
26022 +bppy_get_hit_count (PyObject *self, void *closure)
26023 +{
26024 +  breakpoint_object *self_bp = (breakpoint_object *) self;
26025 +
26026 +  BPPY_REQUIRE_VALID (self_bp);
26027 +
26028 +  return PyInt_FromLong (self_bp->bp->hit_count);
26029 +}
26030 +
26031 +/* Python function to get the breakpoint's ignore count.  */
26032 +static PyObject *
26033 +bppy_get_ignore_count (PyObject *self, void *closure)
26034 +{
26035 +  breakpoint_object *self_bp = (breakpoint_object *) self;
26036 +
26037 +  BPPY_REQUIRE_VALID (self_bp);
26038 +
26039 +  return PyInt_FromLong (self_bp->bp->ignore_count);
26040 +}
26041 +
26042 +/* Python function to create a new breakpoint.  */
26043 +static PyObject *
26044 +bppy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
26045 +{
26046 +  PyObject *result;
26047 +  char *spec;
26048 +  volatile struct gdb_exception except;
26049 +
26050 +  /* FIXME: allow condition, thread, temporary, ... ? */
26051 +  if (! PyArg_ParseTuple (args, "s", &spec))
26052 +    return NULL;
26053 +  result = subtype->tp_alloc (subtype, 0);
26054 +  if (! result)
26055 +    return NULL;
26056 +  bppy_pending_object = (breakpoint_object *) result;
26057 +  bppy_pending_object->number = -1;
26058 +  bppy_pending_object->bp = NULL;
26059 +
26060 +  TRY_CATCH (except, RETURN_MASK_ALL)
26061 +    {
26062 +      set_breakpoint (spec, NULL, 0, 0, -1, 0, AUTO_BOOLEAN_TRUE,
26063 +                     1 /*enabled*/);
26064 +    }
26065 +  if (except.reason < 0)
26066 +    {
26067 +      subtype->tp_free (result);
26068 +      return PyErr_Format (except.reason == RETURN_QUIT
26069 +                            ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
26070 +                            "%s", except.message);
26071 +    }
26072 +
26073 +  BPPY_REQUIRE_VALID ((breakpoint_object *) result);
26074 +  return result;
26075 +}
26076 +
26077 +\f
26078 +
26079 +/* Static function to return a tuple holding all breakpoints.  */
26080 +
26081 +PyObject *
26082 +gdbpy_breakpoints (PyObject *self, PyObject *args)
26083 +{
26084 +  PyObject *result;
26085 +
26086 +  if (bppy_live == 0)
26087 +    Py_RETURN_NONE;
26088 +
26089 +  result = PyTuple_New (bppy_live);
26090 +  if (result)
26091 +    {
26092 +      int i, out = 0;
26093 +      for (i = 0; out < bppy_live; ++i)
26094 +       {
26095 +         if (! bppy_breakpoints[i])
26096 +           continue;
26097 +         Py_INCREF (bppy_breakpoints[i]);
26098 +         PyTuple_SetItem (result, out, (PyObject *) bppy_breakpoints[i]);
26099 +         ++out;
26100 +       }
26101 +    }
26102 +  return result;
26103 +}
26104 +
26105 +\f
26106 +
26107 +/* Event callback functions.  */
26108 +
26109 +/* Callback that is used when a breakpoint is created.  This function
26110 +   will create a new Python breakpoint object.  */
26111 +static void
26112 +gdbpy_breakpoint_created (int num)
26113 +{
26114 +  breakpoint_object *newbp;
26115 +  struct breakpoint *bp;
26116 +  PyGILState_STATE state;
26117 +
26118 +  if (num < 0)
26119 +    return;
26120 +
26121 +  for (bp = breakpoint_chain; bp; bp = bp->next)
26122 +    if (bp->number == num)
26123 +      break;
26124 +  if (! bp)
26125 +    return;
26126 +
26127 +  if (num >= bppy_slots)
26128 +    {
26129 +      int old = bppy_slots;
26130 +      bppy_slots = bppy_slots * 2 + 10;
26131 +      bppy_breakpoints
26132 +       = (breakpoint_object **) xrealloc (bppy_breakpoints,
26133 +                                          (bppy_slots
26134 +                                           * sizeof (breakpoint_object *)));
26135 +      memset (&bppy_breakpoints[old], 0,
26136 +             (bppy_slots - old) * sizeof (PyObject *));
26137 +    }
26138 +
26139 +  ++bppy_live;
26140 +
26141 +  state = PyGILState_Ensure ();
26142 +
26143 +  if (bppy_pending_object)
26144 +    {
26145 +      newbp = bppy_pending_object;
26146 +      bppy_pending_object = NULL;
26147 +    }
26148 +  else
26149 +    newbp = PyObject_New (breakpoint_object, &breakpoint_object_type);
26150 +  if (newbp)
26151 +    {
26152 +      PyObject *hookfn;
26153 +
26154 +      newbp->number = num;
26155 +      newbp->bp = bp;
26156 +      bppy_breakpoints[num] = newbp;
26157 +
26158 +      hookfn = gdbpy_get_hook_function ("new_breakpoint");
26159 +      if (hookfn)
26160 +       {
26161 +         PyObject *result;
26162 +         result = PyObject_CallFunctionObjArgs (hookfn, newbp, NULL);
26163 +         if (result)
26164 +           {
26165 +             Py_DECREF (result);
26166 +           }
26167 +         Py_DECREF (hookfn);
26168 +       }
26169 +    }
26170 +
26171 +  /* Just ignore errors here.  */
26172 +  PyErr_Clear ();
26173 +
26174 +  PyGILState_Release (state);
26175 +}
26176 +
26177 +/* Callback that is used when a breakpoint is deleted.  This will
26178 +   invalidate the corresponding Python object.  */
26179 +static void
26180 +gdbpy_breakpoint_deleted (int num)
26181 +{
26182 +  PyGILState_STATE state;
26183 +
26184 +  state = PyGILState_Ensure ();
26185 +  if (BPPY_VALID_P (num))
26186 +    {
26187 +      bppy_breakpoints[num]->bp = NULL;
26188 +      Py_DECREF (bppy_breakpoints[num]);
26189 +      bppy_breakpoints[num] = NULL;
26190 +      --bppy_live;
26191 +    }
26192 +  PyGILState_Release (state);
26193 +}
26194 +
26195 +\f
26196 +
26197 +/* Initialize the Python breakpoint code.  */
26198 +void
26199 +gdbpy_initialize_breakpoints (void)
26200 +{
26201 +  breakpoint_object_type.tp_new = bppy_new;
26202 +  if (PyType_Ready (&breakpoint_object_type) < 0)
26203 +    return;
26204 +
26205 +  Py_INCREF (&breakpoint_object_type);
26206 +  PyModule_AddObject (gdb_module, "Breakpoint",
26207 +                     (PyObject *) &breakpoint_object_type);
26208 +
26209 +  observer_attach_breakpoint_created (gdbpy_breakpoint_created);
26210 +  observer_attach_breakpoint_deleted (gdbpy_breakpoint_deleted);
26211 +}
26212 +
26213 +\f
26214 +
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.",
26227 +    NULL },
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.  */
26242 +};
26243 +
26244 +static PyMethodDef breakpoint_object_methods[] =
26245 +{
26246 +  { "is_valid", bppy_is_valid, METH_NOARGS,
26247 +    "Return true if this breakpoint is valid, false if not." },
26248 +  { NULL } /* Sentinel.  */
26249 +};
26250 +
26251 +static PyTypeObject breakpoint_object_type =
26252 +{
26253 +  PyObject_HEAD_INIT (NULL)
26254 +  0,                             /*ob_size*/
26255 +  "gdb.Breakpoint",              /*tp_name*/
26256 +  sizeof (breakpoint_object),    /*tp_basicsize*/
26257 +  0,                             /*tp_itemsize*/
26258 +  0,                             /*tp_dealloc*/
26259 +  0,                             /*tp_print*/
26260 +  0,                             /*tp_getattr*/
26261 +  0,                             /*tp_setattr*/
26262 +  0,                             /*tp_compare*/
26263 +  0,                             /*tp_repr*/
26264 +  0,                             /*tp_as_number*/
26265 +  0,                             /*tp_as_sequence*/
26266 +  0,                             /*tp_as_mapping*/
26267 +  0,                             /*tp_hash */
26268 +  0,                             /*tp_call*/
26269 +  0,                             /*tp_str*/
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 */
26279 +  0,                             /* tp_iter */
26280 +  0,                             /* tp_iternext */
26281 +  breakpoint_object_methods,     /* tp_methods */
26282 +  0,                             /* tp_members */
26283 +  breakpoint_object_getset       /* tp_getset */
26284 +};
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[] =
26290  
26291  #define N_COMPLETERS (sizeof (completers) / sizeof (completers[0]))
26292  
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
26297  {
26298    PyObject_HEAD
26299 @@ -68,7 +67,6 @@ typedef struct cmdpy_object cmdpy_object;
26300  
26301  static PyTypeObject cmdpy_object_type;
26302  
26303 -
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
26309     *sub-commands.
26310     
26311 +   START_LIST is the list in which the search starts.
26312 +   
26313     This function returns the xmalloc()d name of the new command.  On
26314     error sets the Python error and returns NULL.  */
26315 -static char *
26316 -parse_command_name (char *text, struct cmd_list_element ***base_list)
26317 +char *
26318 +gdbpy_parse_command_name (char *text, struct cmd_list_element ***base_list,
26319 +                         struct cmd_list_element **start_list)
26320  {
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)
26324      ;
26325    if (i < 0)
26326      {
26327 -      *base_list = &cmdlist;
26328 +      *base_list = start_list;
26329        return result;
26330      }
26331  
26332 @@ -310,7 +311,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26333    prefix_text[i + 1] = '\0';
26334  
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)
26339      {
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)
26342  
26343  /* Object initializer; sets up gdb-side structures for command.
26344  
26345 -   Use: __init__(NAME, CMDCLASS, [COMPLETERCLASS, [PREFIX]]).
26346 +   Use: __init__(NAME, COMMAND_CLASS, [COMPLETER_CLASS, [PREFIX]]).
26347  
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.
26351  
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.
26355  
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.
26360  
26361 @@ -356,7 +357,7 @@ parse_command_name (char *text, struct cmd_list_element ***base_list)
26362     
26363  */
26364  static int
26365 -cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26366 +cmdpy_init (PyObject *self, PyObject *args, PyObject *kw)
26367  {
26368    cmdpy_object *obj = (cmdpy_object *) self;
26369    char *name;
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;
26377    int cmp;
26378  
26379 @@ -378,7 +381,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26380        return -1;
26381      }
26382  
26383 -  if (! PyArg_ParseTuple (args, "si|iO", &name, &cmdtype,
26384 +  if (! PyArg_ParseTupleAndKeywords (args, kw, "si|iO", keywords, &name, &cmdtype,
26385                           &completetype, &is_prefix))
26386      return -1;
26387  
26388 @@ -399,7 +402,7 @@ cmdpy_init (PyObject *self, PyObject *args, PyObject *kwds)
26389        return -1;
26390      }
26391  
26392 -  cmd_name = parse_command_name (name, &cmd_list);
26393 +  cmd_name = gdbpy_parse_command_name (name, &cmd_list, &cmdlist);
26394    if (! cmd_name)
26395      return -1;
26396  
26397 diff --git a/gdb/python/python-frame.c b/gdb/python/python-frame.c
26398 new file mode 100644
26399 index 0000000..c257ac3
26400 --- /dev/null
26401 +++ b/gdb/python/python-frame.c
26402 @@ -0,0 +1,686 @@
26403 +/* Python interface to stack frames
26404 +
26405 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
26406 +
26407 +   This file is part of GDB.
26408 +
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.
26413 +
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.
26418 +
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/>.  */
26421 +
26422 +#include "defs.h"
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"
26431 +
26432 +typedef struct {
26433 +  PyObject_HEAD
26434 +  struct frame_id frame_id;
26435 +  struct gdbarch *gdbarch;
26436 +
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;
26446 +} frame_object;
26447 +
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)          \
26451 +    do {                                               \
26452 +      frame = frame_object_to_frame_info (frame_obj);  \
26453 +      if (frame == NULL)                               \
26454 +       error ("Frame is invalid.");                    \
26455 +    } while (0)
26456 +
26457 +static PyTypeObject frame_object_type;
26458 +
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.  */
26462 +
26463 +static struct frame_info *
26464 +frame_object_to_frame_info (frame_object *frame_obj)
26465 +{
26466 +  struct frame_info *frame;
26467 +
26468 +  frame = frame_find_by_id (frame_obj->frame_id);
26469 +  if (frame == NULL)
26470 +    return NULL;
26471 +
26472 +  if (frame_obj->frame_id_is_next)
26473 +    frame = get_prev_frame (frame);
26474 +
26475 +  return frame;
26476 +}
26477 +
26478 +/* Called by the Python interpreter to obtain string representation
26479 +   of the object.  */
26480 +
26481 +static PyObject *
26482 +frapy_str (PyObject *self)
26483 +{
26484 +  char *s;
26485 +  long len;
26486 +  PyObject *result;
26487 +  struct ui_file *strfile;
26488 +  
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);
26493 +  xfree (s);
26494 +
26495 +  return result;
26496 +}
26497 +
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.  */
26501 +
26502 +static PyObject *
26503 +frapy_is_valid (PyObject *self, PyObject *args)
26504 +{
26505 +  struct frame_info *frame;
26506 +
26507 +  frame = frame_object_to_frame_info ((frame_object *) self);
26508 +  if (frame == NULL)
26509 +    Py_RETURN_FALSE;
26510 +
26511 +  Py_RETURN_TRUE;
26512 +}
26513 +
26514 +/* Implementation of gdb.Frame.equals (self, other) -> Boolean. */
26515 +
26516 +static PyObject *
26517 +frapy_equal_p (PyObject *self, PyObject *args)
26518 +{
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;
26523 +
26524 +  if (!PyArg_ParseTuple (args, "O!", &frame_object_type, &other))
26525 +    return NULL;
26526 +
26527 +  TRY_CATCH (except, RETURN_MASK_ALL)
26528 +    {
26529 +      equalp = frame_id_eq (self_frame->frame_id, other->frame_id);
26530 +    }
26531 +  GDB_PY_HANDLE_EXCEPTION (except);
26532 +
26533 +  if (equalp)
26534 +    Py_RETURN_TRUE;
26535 +
26536 +  Py_RETURN_FALSE;
26537 +}
26538 +
26539 +/* Implementation of gdb.Frame.name (self) -> String.
26540 +   Returns the name of the function corresponding to this frame.  */
26541 +
26542 +static PyObject *
26543 +frapy_name (PyObject *self, PyObject *args)
26544 +{
26545 +  struct frame_info *frame;
26546 +  char *name;
26547 +  enum language lang;
26548 +  PyObject *result;
26549 +  volatile struct gdb_exception except;
26550 +
26551 +  TRY_CATCH (except, RETURN_MASK_ALL)
26552 +    {
26553 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26554 +
26555 +      find_frame_funname (frame, &name, &lang);
26556 +    }
26557 +  GDB_PY_HANDLE_EXCEPTION (except);
26558 +
26559 +  if (name)
26560 +    result = target_string_to_unicode (name, strlen (name));
26561 +  else
26562 +    {
26563 +      result = Py_None;
26564 +      Py_INCREF (Py_None);
26565 +    }
26566 +
26567 +  return result;
26568 +}
26569 +
26570 +/* Implementation of gdb.Frame.type (self) -> Integer.
26571 +   Returns the frame type, namely one of the gdb.*_FRAME constants.  */
26572 +
26573 +static PyObject *
26574 +frapy_type (PyObject *self, PyObject *args)
26575 +{
26576 +  struct frame_info *frame;
26577 +  enum frame_type type = NORMAL_FRAME;/* Initialize to appease gcc warning.  */
26578 +  volatile struct gdb_exception except;
26579 +
26580 +  TRY_CATCH (except, RETURN_MASK_ALL)
26581 +    {
26582 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26583 +
26584 +      type = get_frame_type (frame);
26585 +    }
26586 +  GDB_PY_HANDLE_EXCEPTION (except);
26587 +
26588 +  return PyInt_FromLong (type);
26589 +}
26590 +
26591 +/* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
26592 +   Returns one of the gdb.FRAME_UNWIND_* constants.  */
26593 +
26594 +static PyObject *
26595 +frapy_unwind_stop_reason (PyObject *self, PyObject *args)
26596 +{
26597 +  struct frame_info *frame = NULL;    /* Initialize to appease gcc warning.  */
26598 +  volatile struct gdb_exception except;
26599 +  enum unwind_stop_reason stop_reason;
26600 +
26601 +  TRY_CATCH (except, RETURN_MASK_ALL)
26602 +    {
26603 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26604 +    }
26605 +  GDB_PY_HANDLE_EXCEPTION (except);
26606 +
26607 +  stop_reason = get_frame_unwind_stop_reason (frame);
26608 +
26609 +  return PyInt_FromLong (stop_reason);
26610 +}
26611 +
26612 +/* Implementation of gdb.Frame.pc (self) -> Long.
26613 +   Returns the frame's resume address.  */
26614 +
26615 +static PyObject *
26616 +frapy_pc (PyObject *self, PyObject *args)
26617 +{
26618 +  CORE_ADDR pc = 0;          /* Initialize to appease gcc warning.  */
26619 +  struct frame_info *frame;
26620 +  volatile struct gdb_exception except;
26621 +
26622 +  TRY_CATCH (except, RETURN_MASK_ALL)
26623 +    {
26624 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26625 +
26626 +      pc = get_frame_pc (frame);
26627 +    }
26628 +  GDB_PY_HANDLE_EXCEPTION (except);
26629 +
26630 +  return PyLong_FromUnsignedLongLong (pc);
26631 +}
26632 +
26633 +/* Implementation of gdb.Frame.block (self) -> gdb.Block.
26634 +   Returns the frame's code block.  */
26635 +
26636 +static PyObject *
26637 +frapy_block (PyObject *self, PyObject *args)
26638 +{
26639 +  struct frame_info *frame;
26640 +  struct block *block = NULL;
26641 +  volatile struct gdb_exception except;
26642 +
26643 +  TRY_CATCH (except, RETURN_MASK_ALL)
26644 +    {
26645 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26646 +
26647 +      block = block_for_pc (get_frame_address_in_block (frame));
26648 +    }
26649 +  GDB_PY_HANDLE_EXCEPTION (except);
26650 +
26651 +  if (block)
26652 +    return block_to_block_object (block);
26653 +
26654 +  Py_RETURN_NONE;
26655 +}
26656 +
26657 +
26658 +/* Implementation of gdb.Frame.addr_in_block (self) -> Long.
26659 +   Returns an address which falls within the frame's code block.  */
26660 +
26661 +static PyObject *
26662 +frapy_addr_in_block (PyObject *self, PyObject *args)
26663 +{
26664 +  CORE_ADDR pc = 0;          /* Initialize to appease gcc warning.  */
26665 +  struct frame_info *frame;
26666 +  volatile struct gdb_exception except;
26667 +
26668 +  TRY_CATCH (except, RETURN_MASK_ALL)
26669 +    {
26670 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26671 +
26672 +      pc = get_frame_address_in_block (frame);
26673 +    }
26674 +  GDB_PY_HANDLE_EXCEPTION (except);
26675 +
26676 +  return PyLong_FromUnsignedLongLong (pc);
26677 +}
26678 +
26679 +/* Convert a frame_info struct to a Python Frame object.
26680 +   Sets a Python exception and returns NULL on error.  */
26681 +
26682 +static frame_object *
26683 +frame_info_to_frame_object (struct frame_info *frame)
26684 +{
26685 +  frame_object *frame_obj;
26686 +
26687 +  frame_obj = PyObject_New (frame_object, &frame_object_type);
26688 +  if (frame_obj == NULL)
26689 +    {
26690 +      PyErr_SetString (PyExc_MemoryError, "Could not allocate frame object.");
26691 +      return NULL;
26692 +    }
26693 +
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)
26700 +    {
26701 +      frame_obj->frame_id = get_frame_id (get_next_frame (frame));
26702 +      frame_obj->frame_id_is_next = 1;
26703 +    }
26704 +  else
26705 +    {
26706 +      frame_obj->frame_id = get_frame_id (frame);
26707 +      frame_obj->frame_id_is_next = 0;
26708 +    }
26709 +
26710 +  frame_obj->gdbarch = get_frame_arch (frame);
26711 +
26712 +  return frame_obj;
26713 +}
26714 +
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.  */
26718 +
26719 +static PyObject *
26720 +frapy_older (PyObject *self, PyObject *args)
26721 +{
26722 +  struct frame_info *frame, *prev;
26723 +  volatile struct gdb_exception except;
26724 +  PyObject *prev_obj = NULL;   /* Initialize to appease gcc warning.  */
26725 +
26726 +  TRY_CATCH (except, RETURN_MASK_ALL)
26727 +    {
26728 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26729 +
26730 +      prev = get_prev_frame (frame);
26731 +      if (prev)
26732 +       prev_obj = (PyObject *) frame_info_to_frame_object (prev);
26733 +      else
26734 +       {
26735 +         Py_INCREF (Py_None);
26736 +         prev_obj = Py_None;
26737 +       }
26738 +    }
26739 +  GDB_PY_HANDLE_EXCEPTION (except);
26740 +
26741 +  return prev_obj;
26742 +}
26743 +
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.  */
26747 +
26748 +static PyObject *
26749 +frapy_newer (PyObject *self, PyObject *args)
26750 +{
26751 +  struct frame_info *frame, *next;
26752 +  volatile struct gdb_exception except;
26753 +  PyObject *next_obj = NULL;   /* Initialize to appease gcc warning.  */
26754 +
26755 +  TRY_CATCH (except, RETURN_MASK_ALL)
26756 +    {
26757 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26758 +
26759 +      next = get_next_frame (frame);
26760 +      if (next)
26761 +       next_obj = (PyObject *) frame_info_to_frame_object (next);
26762 +      else
26763 +       {
26764 +         Py_INCREF (Py_None);
26765 +         next_obj = Py_None;
26766 +       }
26767 +    }
26768 +  GDB_PY_HANDLE_EXCEPTION (except);
26769 +
26770 +  return next_obj;
26771 +}
26772 +
26773 +/* Implementation of gdb.Frame.find_sal (self) -> gdb.Symtab_and_line.
26774 +   Returns the frame's symtab and line.  */
26775 +
26776 +static PyObject *
26777 +frapy_find_sal (PyObject *self, PyObject *args)
26778 +{
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.  */
26783 +
26784 +  TRY_CATCH (except, RETURN_MASK_ALL)
26785 +    {
26786 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26787 +
26788 +      find_frame_sal (frame, &sal);
26789 +      sal_obj = symtab_and_line_to_sal_object (sal);
26790 +    }
26791 +  GDB_PY_HANDLE_EXCEPTION (except);
26792 +
26793 +  return sal_obj;
26794 +}
26795 +
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.  */
26800 +
26801 +static PyObject *
26802 +frapy_read_var (PyObject *self, PyObject *args)
26803 +{
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;
26809 +
26810 +  if (!PyArg_ParseTuple (args, "O", &sym_obj))
26811 +    return NULL;
26812 +
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))
26816 +    {
26817 +      char *var_name;
26818 +      struct block *block = NULL;
26819 +      struct cleanup *cleanup;
26820 +      volatile struct gdb_exception except;
26821 +
26822 +      var_name = python_string_to_target_string (sym_obj);
26823 +      if (!var_name)
26824 +       return NULL;
26825 +      cleanup = make_cleanup (xfree, var_name);
26826 +
26827 +      TRY_CATCH (except, RETURN_MASK_ALL)
26828 +       {
26829 +         FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26830 +
26831 +         block = block_for_pc (get_frame_address_in_block (frame));
26832 +         var = lookup_symbol (var_name, block, VAR_DOMAIN, NULL);
26833 +       }
26834 +      GDB_PY_HANDLE_EXCEPTION (except);
26835 +
26836 +      if (!var)
26837 +       {
26838 +         PyErr_Format (PyExc_ValueError,
26839 +                       _("variable '%s' not found"), var_name);
26840 +         do_cleanups (cleanup);
26841 +
26842 +         return NULL;
26843 +       }
26844 +
26845 +      do_cleanups (cleanup);
26846 +    }
26847 +  else
26848 +    {
26849 +      PyErr_SetString (PyExc_TypeError,
26850 +                      _("argument must be a symbol or string"));
26851 +      return NULL;
26852 +    }
26853 +
26854 +  TRY_CATCH (except, RETURN_MASK_ALL)
26855 +    {
26856 +      FRAPY_REQUIRE_VALID ((frame_object *) self, frame);
26857 +
26858 +      val = read_var_value (var, frame);
26859 +    }
26860 +  GDB_PY_HANDLE_EXCEPTION (except);
26861 +
26862 +  if (val)
26863 +    return value_to_value_object (val);
26864 +
26865 +  Py_RETURN_NONE;
26866 +}
26867 +
26868 +/* Implementation of gdb.frames () -> (gdb.Frame, ...).
26869 +   Returns a tuple of all frame objects.  */
26870 +
26871 +PyObject *
26872 +gdbpy_frames (PyObject *self, PyObject *args)
26873 +{
26874 +  int result = 0;
26875 +  struct frame_info *frame;
26876 +  frame_object *frame_obj;
26877 +  PyObject *list, *tuple;
26878 +  volatile struct gdb_exception except;
26879 +
26880 +  list = PyList_New (0);
26881 +  if (list == NULL)
26882 +    {
26883 +      PyErr_SetString (PyExc_MemoryError, "Could not allocate frames list.");
26884 +      return NULL;
26885 +    }
26886 +
26887 +  TRY_CATCH (except, RETURN_MASK_ALL)
26888 +    {
26889 +      for (frame = get_current_frame (); frame; frame = get_prev_frame (frame))
26890 +       {
26891 +         frame_obj = frame_info_to_frame_object (frame);
26892 +         if (frame_obj == NULL)
26893 +           {
26894 +             Py_DECREF (list);
26895 +             list = NULL;
26896 +             break;
26897 +           }
26898 +
26899 +         PyList_Append (list, (PyObject *) frame_obj);
26900 +       }
26901 +    }
26902 +  if (except.reason < 0)
26903 +    {
26904 +      Py_DECREF (list);
26905 +      return PyErr_Format (except.reason == RETURN_QUIT
26906 +                          ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
26907 +                          "%s", except.message);
26908 +    }
26909 +
26910 +  if (list)
26911 +    {
26912 +      tuple = PyList_AsTuple (list);
26913 +      Py_DECREF (list);
26914 +    }
26915 +  else
26916 +    tuple = NULL;
26917 +
26918 +  return tuple;
26919 +}
26920 +
26921 +/* Implementation of gdb.newest_frame () -> gdb.Frame.
26922 +   Returns the newest frame object.  */
26923 +
26924 +PyObject *
26925 +gdbpy_newest_frame (PyObject *self, PyObject *args)
26926 +{
26927 +  struct frame_info *frame;
26928 +  frame_object *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
26929 +  volatile struct gdb_exception except;
26930 +
26931 +  TRY_CATCH (except, RETURN_MASK_ALL)
26932 +    {
26933 +      frame = get_current_frame ();
26934 +      frame_obj = frame_info_to_frame_object (frame);
26935 +    }
26936 +  GDB_PY_HANDLE_EXCEPTION (except);
26937 +
26938 +  return (PyObject *) frame_obj;
26939 +}
26940 +
26941 +/* Implementation of gdb.selected_frame () -> gdb.Frame.
26942 +   Returns the selected frame object.  */
26943 +
26944 +PyObject *
26945 +gdbpy_selected_frame (PyObject *self, PyObject *args)
26946 +{
26947 +  struct frame_info *frame;
26948 +  frame_object *frame_obj = NULL;   /* Initialize to appease gcc warning.  */
26949 +  volatile struct gdb_exception except;
26950 +
26951 +  TRY_CATCH (except, RETURN_MASK_ALL)
26952 +    {
26953 +      frame = get_selected_frame ("No frame is currently selected.");
26954 +      frame_obj = frame_info_to_frame_object (frame);
26955 +    }
26956 +  GDB_PY_HANDLE_EXCEPTION (except);
26957 +
26958 +  return (PyObject *) frame_obj;
26959 +}
26960 +
26961 +/* Implementation of gdb.stop_reason_string (Integer) -> String.
26962 +   Return a string explaining the unwind stop reason.  */
26963 +
26964 +PyObject *
26965 +gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args)
26966 +{
26967 +  int reason;
26968 +  const char *str;
26969 +
26970 +  if (!PyArg_ParseTuple (args, "i", &reason))
26971 +    return NULL;
26972 +
26973 +  if (reason < 0 || reason > UNWIND_NO_SAVED_PC)
26974 +    {
26975 +      PyErr_SetString (PyExc_ValueError, "Invalid frame stop reason.");
26976 +      return NULL;
26977 +    }
26978 +
26979 +  str = frame_stop_reason_string (reason);
26980 +  return PyUnicode_Decode (str, strlen (str), host_charset (), NULL);
26981 +}
26982 +
26983 +/* Sets up the Frame API in the gdb module.  */
26984 +
26985 +void
26986 +gdbpy_initialize_frames (void)
26987 +{
26988 +  frame_object_type.tp_new = PyType_GenericNew;
26989 +  if (PyType_Ready (&frame_object_type) < 0)
26990 +    return;
26991 +
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);
27011 +
27012 +  Py_INCREF (&frame_object_type);
27013 +  PyModule_AddObject (gdb_module, "Frame", (PyObject *) &frame_object_type);
27014 +}
27015 +
27016 +\f
27017 +
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 */
27056 +};
27057 +
27058 +static PyTypeObject frame_object_type = {
27059 +  PyObject_HEAD_INIT (NULL)
27060 +  0,                             /* ob_size */
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 */
27069 +  0,                             /* tp_repr */
27070 +  0,                             /* tp_as_number */
27071 +  0,                             /* tp_as_sequence */
27072 +  0,                             /* tp_as_mapping */
27073 +  0,                             /* tp_hash  */
27074 +  0,                             /* tp_call */
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 */
27085 +  0,                             /* tp_iter */
27086 +  0,                             /* tp_iternext */
27087 +  frame_object_methods           /* tp_methods */
27088 +};
27089 diff --git a/gdb/python/python-function.c b/gdb/python/python-function.c
27090 new file mode 100644
27091 index 0000000..4a85a33
27092 --- /dev/null
27093 +++ b/gdb/python/python-function.c
27094 @@ -0,0 +1,180 @@
27095 +/* Convenience functions implemented in Python.
27096 +
27097 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27098 +
27099 +   This file is part of GDB.
27100 +
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.
27105 +
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.
27110 +
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/>.  */
27113 +
27114 +
27115 +#include "defs.h"
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"
27124 +
27125 +static PyTypeObject fnpy_object_type;
27126 +
27127 +\f
27128 +
27129 +static PyObject *
27130 +convert_values_to_python (int argc, struct value **argv)
27131 +{
27132 +  int i;
27133 +  PyObject *result = PyTuple_New (argc);
27134 +  for (i = 0; i < argc; ++i)
27135 +    {
27136 +      PyObject *elt = value_to_value_object (argv[i]);
27137 +      if (! elt)
27138 +       {
27139 +         Py_DECREF (result);
27140 +         error (_("Could not convert value to Python object."));
27141 +       }
27142 +      PyTuple_SetItem (result, i, elt);
27143 +    }
27144 +  return result;
27145 +}
27146 +
27147 +/* Call a Python function object's invoke method.  */
27148 +
27149 +static struct value *
27150 +fnpy_call (void *cookie, int argc, struct value **argv)
27151 +{
27152 +  int i;
27153 +  struct value *value = NULL;
27154 +  PyObject *result, *callable, *args;
27155 +  struct cleanup *cleanup;
27156 +  PyGILState_STATE state;
27157 +
27158 +  state = PyGILState_Ensure ();
27159 +  cleanup = make_cleanup_py_restore_gil (&state);
27160 +
27161 +  args = convert_values_to_python (argc, argv);
27162 +
27163 +  callable = PyObject_GetAttrString ((PyObject *) cookie, "invoke");
27164 +  if (! callable)
27165 +    {
27166 +      Py_DECREF (args);
27167 +      error (_("No method named 'invoke' in object."));
27168 +    }
27169 +
27170 +  result = PyObject_Call (callable, args, NULL);
27171 +  Py_DECREF (callable);
27172 +  Py_DECREF (args);
27173 +
27174 +  if (!result)
27175 +    {
27176 +      gdbpy_print_stack ();
27177 +      error (_("Error while executing Python code."));
27178 +    }
27179 +
27180 +  value = convert_value_from_python (result);
27181 +  if (value == NULL)
27182 +    {
27183 +      Py_DECREF (result);
27184 +      gdbpy_print_stack ();
27185 +      error (_("Error while executing Python code."));
27186 +    }
27187 +
27188 +  Py_DECREF (result);
27189 +  do_cleanups (cleanup);
27190 +
27191 +  return value;
27192 +}
27193 +
27194 +/* Initializer for a Function object.  It takes one argument, the name
27195 +   of the function.  */
27196 +
27197 +static int
27198 +fnpy_init (PyObject *self, PyObject *args, PyObject *kwds)
27199 +{
27200 +  char *name, *docstring = NULL;
27201 +  if (! PyArg_ParseTuple (args, "s", &name))
27202 +    return -1;
27203 +  Py_INCREF (self);
27204 +
27205 +  if (PyObject_HasAttrString (self, "__doc__"))
27206 +    {
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);
27211 +    }
27212 +  if (! docstring)
27213 +    docstring = _("This function is not documented.");
27214 +
27215 +  add_internal_function (name, docstring, fnpy_call, self);
27216 +  return 0;
27217 +}
27218 +
27219 +/* Initialize internal function support.  */
27220 +
27221 +void
27222 +gdbpy_initialize_functions (void)
27223 +{
27224 +  if (PyType_Ready (&fnpy_object_type) < 0)
27225 +    return;
27226 +
27227 +  Py_INCREF (&fnpy_object_type);
27228 +  PyModule_AddObject (gdb_module, "Function", (PyObject *) &fnpy_object_type);
27229 +}
27230 +
27231 +\f
27232 +
27233 +static PyTypeObject fnpy_object_type =
27234 +{
27235 +  PyObject_HEAD_INIT (NULL)
27236 +  0,                             /*ob_size*/
27237 +  "gdb.Function",                /*tp_name*/
27238 +  sizeof (PyObject),             /*tp_basicsize*/
27239 +  0,                             /*tp_itemsize*/
27240 +  0,                             /*tp_dealloc*/
27241 +  0,                             /*tp_print*/
27242 +  0,                             /*tp_getattr*/
27243 +  0,                             /*tp_setattr*/
27244 +  0,                             /*tp_compare*/
27245 +  0,                             /*tp_repr*/
27246 +  0,                             /*tp_as_number*/
27247 +  0,                             /*tp_as_sequence*/
27248 +  0,                             /*tp_as_mapping*/
27249 +  0,                             /*tp_hash */
27250 +  0,                             /*tp_call*/
27251 +  0,                             /*tp_str*/
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 */
27261 +  0,                             /* tp_iter */
27262 +  0,                             /* tp_iternext */
27263 +  0,                             /* tp_methods */
27264 +  0,                             /* tp_members */
27265 +  0,                             /* tp_getset */
27266 +  0,                             /* tp_base */
27267 +  0,                             /* tp_dict */
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 */
27274 +};
27275 diff --git a/gdb/python/python-hooks.c b/gdb/python/python-hooks.c
27276 new file mode 100644
27277 index 0000000..a3140bc
27278 --- /dev/null
27279 +++ b/gdb/python/python-hooks.c
27280 @@ -0,0 +1,50 @@
27281 +/* Notifications from gdb to Python
27282 +
27283 +   Copyright (C) 2008 Free Software Foundation, Inc.
27284 +
27285 +   This file is part of GDB.
27286 +
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.
27291 +
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.
27296 +
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/>.  */
27299 +
27300 +#include "defs.h"
27301 +#include "cli/cli-decode.h"
27302 +#include "charset.h"
27303 +#include "python.h"
27304 +#include "python-internal.h"
27305 +#include "observer.h"
27306 +
27307 +PyObject *
27308 +gdbpy_get_hook_function (const char *name)
27309 +{
27310 +  PyObject *hooks;
27311 +  PyObject *result;
27312 +
27313 +  if (! PyObject_HasAttrString (gdb_module, "hooks"))
27314 +    return NULL;
27315 +  hooks = PyObject_GetAttrString (gdb_module, "hooks");
27316 +  if (! hooks)
27317 +    return NULL;
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))
27321 +    {
27322 +      Py_DECREF (hooks);
27323 +      return NULL;
27324 +    }
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);
27329 +  return result;
27330 +}
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
27335 @@ -33,6 +33,7 @@
27336  
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
27343 @@ -40,8 +41,10 @@
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"
27351  #else
27352  #error "Unable to find usable Python.h"
27353  #endif
27354 @@ -58,23 +61,69 @@ typedef int Py_ssize_t;
27355  #define PyEval_ReleaseLock() 0
27356  #endif
27357  
27358 +#include "command.h"
27359 +
27360 +struct block;
27361 +struct symbol;
27362 +struct symtab_and_line;
27363  struct value;
27364  
27365  extern PyObject *gdb_module;
27366 +extern PyTypeObject block_object_type;
27367  extern PyTypeObject value_object_type;
27368 +extern PyTypeObject symbol_object_type;
27369  
27370  PyObject *gdbpy_history (PyObject *self, PyObject *args);
27371 -
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);
27381 +
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 *);
27389  
27390 +PyObject *objfpy_get_printers (PyObject *, void *);
27391 +
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);
27397 +
27398 +PyObject *gdbpy_get_hook_function (const char *);
27399  
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);
27412  
27413  struct cleanup *make_cleanup_py_decref (PyObject *py);
27414  struct cleanup *make_cleanup_py_restore_gil (PyGILState_STATE *state);
27415  
27416 +char *gdbpy_parse_command_name (char *text,
27417 +                               struct cmd_list_element ***base_list,
27418 +                               struct cmd_list_element **start_list);
27419 +
27420 +PyObject *gdbpy_parameter_value (enum var_types, void *);
27421 +
27422  /* Use this after a TRY_EXCEPT to throw the appropriate Python
27423     exception.  */
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);                  \
27427      } while (0)
27428  
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)                         \
27432 +    do {                                                               \
27433 +      if (Exception.reason < 0)                                                \
27434 +        {                                                              \
27435 +         PyErr_Format (Exception.reason == RETURN_QUIT                 \
27436 +                       ? PyExc_KeyboardInterrupt : PyExc_RuntimeError, \
27437 +                       "%s", Exception.message);                       \
27438 +         return -1;                                                    \
27439 +       }                                                               \
27440 +    } while (0)
27441 +
27442  
27443  void gdbpy_print_stack (void);
27444  
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);
27448  
27449 +int gdbpy_is_value_object (PyObject *obj);
27450 +
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);
27458 +
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;
27463  
27464 +int get_addr_from_python (PyObject *obj, CORE_ADDR *addr);
27465 +
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
27470 --- /dev/null
27471 +++ b/gdb/python/python-membuf.c
27472 @@ -0,0 +1,243 @@
27473 +/* Python interface to the inferior memory.
27474 +
27475 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27476 +
27477 +   This file is part of GDB.
27478 +
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.
27483 +
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.
27488 +
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/>.  */
27491 +
27492 +#include "defs.h"
27493 +#include "exceptions.h"
27494 +#include "gdbcore.h"
27495 +#include "python-internal.h"
27496 +
27497 +typedef struct {
27498 +  PyObject_HEAD
27499 +  void *buffer;
27500 +
27501 +  /* These are kept just for mbpy_str.  */
27502 +  CORE_ADDR addr;
27503 +  CORE_ADDR length;
27504 +} membuf_object;
27505 +
27506 +static PyTypeObject membuf_object_type;
27507 +
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.  */
27511 +
27512 +PyObject *
27513 +gdbpy_read_memory (PyObject *self, PyObject *args)
27514 +{
27515 +  CORE_ADDR addr, length;
27516 +  void *buffer;
27517 +  membuf_object *membuf_obj;
27518 +  struct cleanup *cleanups;
27519 +  volatile struct gdb_exception except;
27520 +
27521 +  /* Assume CORE_ADDR corresponds to unsigned long.  */
27522 +  if (! PyArg_ParseTuple (args, "kk", &addr, &length))
27523 +    return NULL;
27524 +
27525 +  buffer = xmalloc (length);
27526 +  cleanups = make_cleanup (xfree, buffer);
27527 +
27528 +  TRY_CATCH (except, RETURN_MASK_ALL)
27529 +    {
27530 +      read_memory (addr, buffer, length);
27531 +    }
27532 +  GDB_PY_HANDLE_EXCEPTION (except);
27533 +
27534 +  discard_cleanups (cleanups);
27535 +
27536 +  membuf_obj = PyObject_New (membuf_object, &membuf_object_type);
27537 +  if (membuf_obj == NULL)
27538 +    {
27539 +      xfree (buffer);
27540 +      PyErr_SetString (PyExc_MemoryError,
27541 +                      "Could not allocate memory buffer object.");
27542 +      return NULL;
27543 +    }
27544 +
27545 +  membuf_obj->buffer = buffer;
27546 +
27547 +  membuf_obj->addr = addr;
27548 +  membuf_obj->length = length;
27549 +
27550 +  return PyBuffer_FromReadWriteObject ((PyObject *) membuf_obj, 0, Py_END_OF_BUFFER);
27551 +}
27552 +
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.  */
27558 +
27559 +PyObject *
27560 +gdbpy_write_memory (PyObject *self, PyObject *args)
27561 +{
27562 +  int buf_len;
27563 +  const char *buffer;
27564 +  long length = -1;
27565 +  CORE_ADDR addr;
27566 +  volatile struct gdb_exception except;
27567 +
27568 +  /* Assume CORE_ADDR corresponds to unsigned long.  */
27569 +  if (! PyArg_ParseTuple (args, "ks#|l", &addr, &buffer, &buf_len, &length))
27570 +    return NULL;
27571 +
27572 +  if (length == -1)
27573 +    length = buf_len;
27574 +
27575 +  TRY_CATCH (except, RETURN_MASK_ALL)
27576 +    {
27577 +      write_memory (addr, buffer, length);
27578 +    }
27579 +  GDB_PY_HANDLE_EXCEPTION (except);
27580 +
27581 +  Py_RETURN_NONE;
27582 +}
27583 +
27584 +/* Destructor of Membuf objects.  */
27585 +
27586 +static void
27587 +mbpy_dealloc (PyObject *self)
27588 +{
27589 +  xfree (((membuf_object *) self)->buffer);
27590 +  self->ob_type->tp_free (self);
27591 +}
27592 +
27593 +/* Return a description of the Membuf object.  */
27594 +
27595 +static PyObject *
27596 +mbpy_str (PyObject *self)
27597 +{
27598 +  membuf_object *membuf_obj = (membuf_object *) self;
27599 +
27600 +  return PyString_FromFormat ("memory buffer for address %s, %s bytes long",
27601 +                             paddress (membuf_obj->addr),
27602 +                             pulongest (membuf_obj->length));
27603 +}
27604 +
27605 +static Py_ssize_t
27606 +get_read_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
27607 +{
27608 +  membuf_object *membuf_obj = (membuf_object *) self;
27609 +
27610 +  if (segment)
27611 +    {
27612 +      PyErr_SetString (PyExc_SystemError,
27613 +                      "The memory buffer supports only one segment.");
27614 +      return -1;
27615 +    }
27616 +
27617 +  *ptrptr = membuf_obj->buffer;
27618 +
27619 +  return membuf_obj->length;
27620 +}
27621 +
27622 +static Py_ssize_t
27623 +get_write_buffer (PyObject *self, Py_ssize_t segment, void **ptrptr)
27624 +{
27625 +  return get_read_buffer (self, segment, ptrptr);
27626 +}
27627 +
27628 +static Py_ssize_t
27629 +get_seg_count (PyObject *self, Py_ssize_t *lenp)
27630 +{
27631 +  if (lenp)
27632 +    *lenp = ((membuf_object *) self)->length;
27633 +
27634 +  return 1;
27635 +}
27636 +
27637 +static Py_ssize_t
27638 +get_char_buffer (PyObject *self, Py_ssize_t segment, char **ptrptr)
27639 +{
27640 +  void *ptr = NULL;
27641 +  Py_ssize_t ret;
27642 +
27643 +  ret = get_read_buffer (self, segment, &ptr);
27644 +  *ptrptr = (char *) ptr;
27645 +
27646 +  return ret;
27647 +}
27648 +
27649 +/* Python doesn't provide a decent way to get compatibility here.  */
27650 +#if HAVE_LIBPYTHON2_4
27651 +#define CHARBUFFERPROC_NAME getcharbufferproc
27652 +#else
27653 +#define CHARBUFFERPROC_NAME charbufferproc
27654 +#endif
27655 +
27656 +static PyBufferProcs buffer_procs = {
27657 +  get_read_buffer,
27658 +  get_write_buffer,
27659 +  get_seg_count,
27660 +  /* The cast here works around a difference between Python 2.4 and
27661 +     Python 2.5.  */
27662 +  (CHARBUFFERPROC_NAME) get_char_buffer
27663 +};
27664 +
27665 +static PyTypeObject membuf_object_type = {
27666 +  PyObject_HEAD_INIT (NULL)
27667 +  0,                             /*ob_size*/
27668 +  "gdb.Membuf",                          /*tp_name*/
27669 +  sizeof (membuf_object),        /*tp_basicsize*/
27670 +  0,                             /*tp_itemsize*/
27671 +  mbpy_dealloc,                          /*tp_dealloc*/
27672 +  0,                             /*tp_print*/
27673 +  0,                             /*tp_getattr*/
27674 +  0,                             /*tp_setattr*/
27675 +  0,                             /*tp_compare*/
27676 +  0,                             /*tp_repr*/
27677 +  0,                             /*tp_as_number*/
27678 +  0,                             /*tp_as_sequence*/
27679 +  0,                             /*tp_as_mapping*/
27680 +  0,                             /*tp_hash */
27681 +  0,                             /*tp_call*/
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 */
27692 +  0,                             /* tp_iter */
27693 +  0,                             /* tp_iternext */
27694 +  0,                             /* tp_methods */
27695 +  0,                             /* tp_members */
27696 +  0,                             /* tp_getset */
27697 +  0,                             /* tp_base */
27698 +  0,                             /* tp_dict */
27699 +  0,                             /* tp_descr_get */
27700 +  0,                             /* tp_descr_set */
27701 +  0,                             /* tp_dictoffset */
27702 +  0,                             /* tp_init */
27703 +  0,                             /* tp_alloc */
27704 +  PyType_GenericNew              /* tp_new */
27705 +};
27706 +
27707 +void
27708 +gdbpy_initialize_membuf (void)
27709 +{
27710 +  if (PyType_Ready (&membuf_object_type) < 0)
27711 +    return;
27712 +
27713 +  Py_INCREF (&membuf_object_type);
27714 +  PyModule_AddObject (gdb_module, "Membuf", (PyObject *) &membuf_object_type);
27715 +}
27716 diff --git a/gdb/python/python-objfile.c b/gdb/python/python-objfile.c
27717 new file mode 100644
27718 index 0000000..e97d3a2
27719 --- /dev/null
27720 +++ b/gdb/python/python-objfile.c
27721 @@ -0,0 +1,221 @@
27722 +/* Python interface to objfiles.
27723 +
27724 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27725 +
27726 +   This file is part of GDB.
27727 +
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.
27732 +
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.
27737 +
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/>.  */
27740 +
27741 +#include "defs.h"
27742 +#include "python-internal.h"
27743 +#include "charset.h"
27744 +#include "objfiles.h"
27745 +
27746 +typedef struct
27747 +{
27748 +  PyObject_HEAD
27749 +
27750 +  /* The corresponding objfile.  */
27751 +  struct objfile *objfile;
27752 +
27753 +  /* The pretty-printer list of functions.  */
27754 +  PyObject *printers;
27755 +} objfile_object;
27756 +
27757 +static PyTypeObject objfile_object_type;
27758 +
27759 +static const struct objfile_data *objfpy_objfile_data_key;
27760 +
27761 +\f
27762 +
27763 +/* An Objfile method which returns the objfile's file name, or None.  */
27764 +static PyObject *
27765 +objfpy_get_filename (PyObject *self, void *closure)
27766 +{
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);
27771 +  Py_RETURN_NONE;
27772 +}
27773 +
27774 +static void
27775 +objfpy_dealloc (PyObject *o)
27776 +{
27777 +  objfile_object *self = (objfile_object *) o;
27778 +  Py_XDECREF (self->printers);
27779 +  self->ob_type->tp_free ((PyObject *) self);
27780 +}
27781 +
27782 +static PyObject *
27783 +objfpy_new (PyTypeObject *type, PyObject *args, PyObject *keywords)
27784 +{
27785 +  objfile_object *self = (objfile_object *) type->tp_alloc (type, 0);
27786 +  if (self)
27787 +    {
27788 +      self->objfile = NULL;
27789 +
27790 +      self->printers = PyList_New (0);
27791 +      if (!self->printers)
27792 +       {
27793 +         Py_DECREF (self);
27794 +         return NULL;
27795 +       }
27796 +    }
27797 +  return (PyObject *) self;
27798 +}
27799 +
27800 +PyObject *
27801 +objfpy_get_printers (PyObject *o, void *ignore)
27802 +{
27803 +  objfile_object *self = (objfile_object *) o;
27804 +  Py_INCREF (self->printers);
27805 +  return self->printers;
27806 +}
27807 +
27808 +static int
27809 +objfpy_set_printers (PyObject *o, PyObject *value, void *ignore)
27810 +{
27811 +  objfile_object *self = (objfile_object *) o;
27812 +  if (! value)
27813 +    {
27814 +      PyErr_SetString (PyExc_TypeError,
27815 +                      "cannot delete the pretty_printers attribute");
27816 +      return -1;
27817 +    }
27818 +
27819 +  if (! PyList_Check (value))
27820 +    {
27821 +      PyErr_SetString (PyExc_TypeError,
27822 +                      "the pretty_printers attribute must be a list");
27823 +      return -1;
27824 +    }
27825 +
27826 +  Py_XDECREF (self->printers);
27827 +  Py_INCREF (value);
27828 +  self->printers = value;
27829 +
27830 +  return 0;
27831 +}
27832 +
27833 +\f
27834 +
27835 +/* Clear the OBJFILE pointer in an Objfile object and remove the
27836 +   reference.  */
27837 +static void
27838 +clean_up_objfile (struct objfile *objfile, void *datum)
27839 +{
27840 +  objfile_object *object = datum;
27841 +  object->objfile = NULL;
27842 +  Py_DECREF ((PyObject *) object);
27843 +}
27844 +
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.  */
27848 +PyObject *
27849 +objfile_to_objfile_object (struct objfile *objfile)
27850 +{
27851 +  objfile_object *object;
27852 +
27853 +  object = objfile_data (objfile, objfpy_objfile_data_key);
27854 +  if (!object)
27855 +    {
27856 +      object = PyObject_New (objfile_object, &objfile_object_type);
27857 +      if (object)
27858 +       {
27859 +         PyObject *dict;
27860 +
27861 +         object->objfile = objfile;
27862 +
27863 +         object->printers = PyList_New (0);
27864 +         if (!object->printers)
27865 +           {
27866 +             Py_DECREF (object);
27867 +             return NULL;
27868 +           }
27869 +
27870 +         set_objfile_data (objfile, objfpy_objfile_data_key, object);
27871 +       }
27872 +    }
27873 +
27874 +  return (PyObject *) object;
27875 +}
27876 +
27877 +void
27878 +gdbpy_initialize_objfile (void)
27879 +{
27880 +  objfpy_objfile_data_key
27881 +    = register_objfile_data_with_cleanup (clean_up_objfile);
27882 +
27883 +  if (PyType_Ready (&objfile_object_type) < 0)
27884 +    return;
27885 +
27886 +  Py_INCREF (&objfile_object_type);
27887 +  PyModule_AddObject (gdb_module, "Objfile", (PyObject *) &objfile_object_type);
27888 +}
27889 +
27890 +\f
27891 +
27892 +static PyGetSetDef objfile_getset[] =
27893 +{
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 },
27898 +  { NULL }
27899 +};
27900 +
27901 +static PyTypeObject objfile_object_type =
27902 +{
27903 +  PyObject_HEAD_INIT (NULL)
27904 +  0,                             /*ob_size*/
27905 +  "gdb.Objfile",                 /*tp_name*/
27906 +  sizeof (objfile_object),       /*tp_basicsize*/
27907 +  0,                             /*tp_itemsize*/
27908 +  objfpy_dealloc,                /*tp_dealloc*/
27909 +  0,                             /*tp_print*/
27910 +  0,                             /*tp_getattr*/
27911 +  0,                             /*tp_setattr*/
27912 +  0,                             /*tp_compare*/
27913 +  0,                             /*tp_repr*/
27914 +  0,                             /*tp_as_number*/
27915 +  0,                             /*tp_as_sequence*/
27916 +  0,                             /*tp_as_mapping*/
27917 +  0,                             /*tp_hash */
27918 +  0,                             /*tp_call*/
27919 +  0,                             /*tp_str*/
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 */
27929 +  0,                             /* tp_iter */
27930 +  0,                             /* tp_iternext */
27931 +  0,                             /* tp_methods */
27932 +  0,                             /* tp_members */
27933 +  objfile_getset,                /* tp_getset */
27934 +  0,                             /* tp_base */
27935 +  0,                             /* tp_dict */
27936 +  0,                             /* tp_descr_get */
27937 +  0,                             /* tp_descr_set */
27938 +  0,                             /* tp_dictoffset */
27939 +  0,                             /* tp_init */
27940 +  0,                             /* tp_alloc */
27941 +  objfpy_new,                    /* tp_new */
27942 +};
27943 diff --git a/gdb/python/python-param.c b/gdb/python/python-param.c
27944 new file mode 100644
27945 index 0000000..1f591a8
27946 --- /dev/null
27947 +++ b/gdb/python/python-param.c
27948 @@ -0,0 +1,606 @@
27949 +/* gdb parameters implemented in Python
27950 +
27951 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
27952 +
27953 +   This file is part of GDB.
27954 +
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.
27959 +
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.
27964 +
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/>.  */
27967 +
27968 +
27969 +#include "defs.h"
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"
27977 +
27978 +/* Parameter constants and their values.  */
27979 +struct parm_constant
27980 +{
27981 +  char *name;
27982 +  int value;
27983 +};
27984 +
27985 +struct parm_constant parm_constants[] =
27986 +{
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 },
27997 +  { NULL, 0 }
27998 +};
27999 +
28000 +/* A union that can hold anything described by enum var_types.  */
28001 +union parmpy_variable
28002 +{
28003 +  /* Hold an integer value, for boolean and integer types.  */
28004 +  int intval;
28005 +
28006 +  /* Hold an auto_boolean.  */
28007 +  enum auto_boolean autoboolval;
28008 +
28009 +  /* Hold an unsigned integer value, for uinteger.  */
28010 +  unsigned int uintval;
28011 +
28012 +  /* Hold a string, for the various string types.  */
28013 +  char *stringval;
28014 +
28015 +  /* Hold a string, for enums.  */
28016 +  const char *cstringval;
28017 +};
28018 +
28019 +/* A gdb parameter.  */
28020 +struct parmpy_object
28021 +{
28022 +  PyObject_HEAD
28023 +
28024 +  /* The type of the parameter.  */
28025 +  enum var_types type;
28026 +
28027 +  /* The value of the parameter.  */
28028 +  union parmpy_variable value;
28029 +
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;
28034 +};
28035 +
28036 +typedef struct parmpy_object parmpy_object;
28037 +
28038 +static PyTypeObject parmpy_object_type;
28039 +
28040 +/* Some handy string constants.  */
28041 +static PyObject *set_doc_cst;
28042 +static PyObject *show_doc_cst;
28043 +
28044 +\f
28045 +
28046 +/* Get an attribute.  */
28047 +static PyObject *
28048 +get_attr (PyObject *obj, PyObject *attr_name)
28049 +{
28050 +  if (PyString_Check (attr_name)
28051 +      && ! strcmp (PyString_AsString (attr_name), "value"))
28052 +    {
28053 +      parmpy_object *self = (parmpy_object *) obj;
28054 +      return gdbpy_parameter_value (self->type, &self->value);
28055 +    }
28056 +
28057 +  return PyObject_GenericGetAttr (obj, attr_name);
28058 +}
28059 +
28060 +/* Set a parameter value from a Python value.  Return 0 on success, -1
28061 +   on failure.  */
28062 +static int
28063 +set_parameter_value (parmpy_object *self, PyObject *value)
28064 +{
28065 +  int cmp;
28066 +
28067 +  switch (self->type)
28068 +    {
28069 +    case var_string:
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))
28076 +       {
28077 +         PyErr_SetString (PyExc_RuntimeError, "string required");
28078 +         return -1;
28079 +       }
28080 +      if (self->value.stringval)
28081 +       xfree (self->value.stringval);
28082 +      if (value == Py_None)
28083 +       {
28084 +         if (self->type == var_optional_filename)
28085 +           self->value.stringval = xstrdup ("");
28086 +         else
28087 +           self->value.stringval = NULL;
28088 +       }
28089 +      else
28090 +       self->value.stringval = python_string_to_host_string (value);
28091 +      break;
28092 +
28093 +    case var_enum:
28094 +      {
28095 +       int i;
28096 +       char *str;
28097 +
28098 +       if (! gdbpy_is_string (value))
28099 +         {
28100 +           PyErr_SetString (PyExc_RuntimeError, "string required");
28101 +           return -1;
28102 +         }
28103 +
28104 +       str = python_string_to_host_string (value);
28105 +       for (i = 0; self->enumeration[i]; ++i)
28106 +         if (! strcmp (self->enumeration[i], str))
28107 +           break;
28108 +       xfree (str);
28109 +       if (! self->enumeration[i])
28110 +         {
28111 +           PyErr_SetString (PyExc_RuntimeError,
28112 +                            "value must be member of enumeration");
28113 +           return -1;
28114 +         }
28115 +       self->value.cstringval = self->enumeration[i];
28116 +       break;
28117 +      }
28118 +
28119 +    case var_boolean:
28120 +      if (! PyBool_Check (value))
28121 +       {
28122 +         PyErr_SetString (PyExc_RuntimeError, "boolean required");
28123 +         return -1;
28124 +       }
28125 +      cmp = PyObject_IsTrue (value);
28126 +      if (cmp < 0) 
28127 +         return -1;
28128 +      self->value.intval = cmp;
28129 +      break;
28130 +
28131 +    case var_auto_boolean:
28132 +      if (! PyBool_Check (value) && value != Py_None)
28133 +       {
28134 +         PyErr_SetString (PyExc_RuntimeError,
28135 +                          "boolean or None required");
28136 +         return -1;
28137 +       }
28138 +
28139 +      if (value == Py_None)
28140 +       self->value.autoboolval = AUTO_BOOLEAN_AUTO;
28141 +      else
28142 +       {
28143 +         cmp = PyObject_IsTrue (value);
28144 +         if (cmp < 0 )
28145 +           return -1;    
28146 +         if (cmp == 1)
28147 +           self->value.autoboolval = AUTO_BOOLEAN_TRUE;
28148 +         else 
28149 +           self->value.autoboolval = AUTO_BOOLEAN_FALSE;
28150 +
28151 +         break;
28152 +       }
28153 +
28154 +    case var_integer:
28155 +    case var_zinteger:
28156 +    case var_uinteger:
28157 +      {
28158 +       long l;
28159 +       int ok;
28160 +
28161 +       if (! PyInt_Check (value))
28162 +         {
28163 +           PyErr_SetString (PyExc_RuntimeError, "value must be integer");
28164 +           return -1;
28165 +         }
28166 +
28167 +       l = PyInt_AsLong (value);
28168 +       if (self->type == var_uinteger)
28169 +         {
28170 +           ok = (l >= 0 && l <= UINT_MAX);
28171 +           if (l == 0)
28172 +             l = UINT_MAX;
28173 +         }
28174 +       else if (self->type == var_integer)
28175 +         {
28176 +           ok = (l >= INT_MIN && l <= INT_MAX);
28177 +           if (l == 0)
28178 +             l = INT_MAX;
28179 +         }
28180 +       else
28181 +         ok = (l >= INT_MIN && l <= INT_MAX);
28182 +
28183 +       if (! ok)
28184 +         {
28185 +           PyErr_SetString (PyExc_RuntimeError, "range exceeded");
28186 +           return -1;
28187 +         }
28188 +
28189 +       self->value.intval = (int) l;
28190 +       break;
28191 +      }
28192 +
28193 +    default:
28194 +      PyErr_SetString (PyExc_RuntimeError, "programmer error: unhandled type");
28195 +      return -1;
28196 +    }
28197 +
28198 +  return 0;
28199 +}
28200 +
28201 +/* Set an attribute.  */
28202 +static int
28203 +set_attr (PyObject *obj, PyObject *attr_name, PyObject *val)
28204 +{
28205 +  if (PyString_Check (attr_name)
28206 +      && ! strcmp (PyString_AsString (attr_name), "value"))
28207 +    {
28208 +      if (!val)
28209 +       {
28210 +         PyErr_SetString (PyExc_RuntimeError,
28211 +                          "cannot delete a parameter's value");
28212 +         return -1;
28213 +       }
28214 +      return set_parameter_value ((parmpy_object *) obj, val);
28215 +    }
28216 +
28217 +  return PyObject_GenericSetAttr (obj, attr_name, val);
28218 +}
28219 +
28220 +\f
28221 +
28222 +/* A helper function that dispatches to the appropriate add_setshow
28223 +   function.  */
28224 +static void
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)
28230 +{
28231 +  switch (parmclass)
28232 +    {
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);
28237 +      break;
28238 +
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);
28244 +      break;
28245 +
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);
28250 +      break;
28251 +
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);
28256 +      break;
28257 +
28258 +    case var_string:
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);
28262 +      break;
28263 +
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);
28269 +      break;
28270 +
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);
28276 +      break;
28277 +
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);
28282 +      break;
28283 +
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);
28288 +      break;
28289 +
28290 +    case var_enum:
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];
28297 +      break;
28298 +    }
28299 +}
28300 +
28301 +/* A helper which computes enum values.  Returns 1 on success, 0 on
28302 +   error.  */
28303 +static int
28304 +compute_enum_values (parmpy_object *self, PyObject *enum_values)
28305 +{
28306 +  Py_ssize_t size, i;
28307 +
28308 +  if (! enum_values)
28309 +    {
28310 +      PyErr_SetString (PyExc_RuntimeError,
28311 +                      "enumeration required for PARAM_ENUM");
28312 +      return 0;
28313 +    }
28314 +
28315 +  if (! PySequence_Check (enum_values))
28316 +    {
28317 +      PyErr_SetString (PyExc_RuntimeError, "enumeration is not a sequence");
28318 +      return 0;
28319 +    }
28320 +
28321 +  size = PySequence_Size (enum_values);
28322 +  if (size < 0)
28323 +    return 0;
28324 +  if (size == 0)
28325 +    {
28326 +      PyErr_SetString (PyExc_RuntimeError, "empty enumeration");
28327 +      return 0;
28328 +    }
28329 +
28330 +  self->enumeration = xmalloc ((size + 1) * sizeof (char *));
28331 +  memset (self->enumeration, 0, (size + 1) * sizeof (char *));
28332 +
28333 +  for (i = 0; i < size; ++i)
28334 +    {
28335 +      PyObject *item = PySequence_GetItem (enum_values, i);
28336 +      if (! item)
28337 +       return 0;
28338 +      if (! gdbpy_is_string (item))
28339 +       {
28340 +         PyErr_SetString (PyExc_RuntimeError, "enumeration item not a string");
28341 +         return 0;
28342 +       }
28343 +      self->enumeration[i] = python_string_to_host_string (item);
28344 +    }
28345 +
28346 +  return 1;
28347 +}
28348 +
28349 +/* A helper function which returns a documentation string for an
28350 +   object.  */
28351 +static char *
28352 +get_doc_string (PyObject *object, PyObject *attr)
28353 +{
28354 +  char *result = NULL;
28355 +  if (PyObject_HasAttr (object, attr))
28356 +    {
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);
28360 +    }
28361 +  if (! result)
28362 +    result = xstrdup ("This command is not documented.");
28363 +  return result;
28364 +}
28365 +
28366 +/* Object initializer; sets up gdb-side structures for command.
28367 +
28368 +   Use: __init__(NAME, CMDCLASS, PARMCLASS, [ENUM])
28369 +
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.
28373 +
28374 +   CMDCLASS is the kind of command.  It should be one of the COMMAND_*
28375 +   constants defined in the gdb module.
28376 +
28377 +   PARMCLASS is the type of the parameter.  It should be one of the
28378 +   PARAM_* constants defined in the gdb module.
28379 +
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
28382 +   parameter.
28383 +
28384 +   The documentation for the parameter is taken from the doc string
28385 +   for the python class.
28386 +   
28387 +*/
28388 +static int
28389 +parmpy_init (PyObject *self, PyObject *args, PyObject *kwds)
28390 +{
28391 +  parmpy_object *obj = (parmpy_object *) self;
28392 +  char *name;
28393 +  char *set_doc, *show_doc, *doc;
28394 +  char *cmd_name;
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;
28400 +
28401 +  if (! PyArg_ParseTuple (args, "sii|O", &name, &cmdtype, &parmclass,
28402 +                         &enum_values))
28403 +    return -1;
28404 +
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)
28411 +    {
28412 +      PyErr_Format (PyExc_RuntimeError, "invalid command class argument");
28413 +      return -1;
28414 +    }
28415 +
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)
28421 +    {
28422 +      PyErr_SetString (PyExc_RuntimeError, "invalid parameter class argument");
28423 +      return -1;
28424 +    }
28425 +
28426 +  if (enum_values && parmclass != var_enum)
28427 +    {
28428 +      PyErr_SetString (PyExc_RuntimeError,
28429 +                      "only PARAM_ENUM accepts a fourth argument");
28430 +      return -1;
28431 +    }
28432 +  if (parmclass == var_enum)
28433 +    {
28434 +      if (! compute_enum_values (obj, enum_values))
28435 +       return -1;
28436 +    }
28437 +
28438 +  obj->type = (enum var_types) parmclass;
28439 +  memset (&obj->value, 0, sizeof (obj->value));
28440 +  obj->enumeration = NULL;
28441 +
28442 +  cmd_name = gdbpy_parse_command_name (name, &set_list, &setlist);
28443 +  if (! cmd_name)
28444 +    return -1;
28445 +  xfree (cmd_name);
28446 +  cmd_name = gdbpy_parse_command_name (name, &show_list, &showlist);
28447 +  if (! cmd_name)
28448 +    return -1;
28449 +
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);
28455 +
28456 +  Py_INCREF (self);
28457 +
28458 +  TRY_CATCH (except, RETURN_MASK_ALL)
28459 +    {
28460 +      add_setshow_generic (parmclass, (enum command_class) cmdtype,
28461 +                          cmd_name, obj,
28462 +                          set_doc, show_doc,
28463 +                          doc, set_list, show_list);
28464 +    }
28465 +  if (except.reason < 0)
28466 +    {
28467 +      xfree (cmd_name);
28468 +      xfree (set_doc);
28469 +      xfree (show_doc);
28470 +      xfree (doc);
28471 +      Py_DECREF (self);
28472 +      PyErr_Format (except.reason == RETURN_QUIT
28473 +                   ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
28474 +                   "%s", except.message);
28475 +      return -1;
28476 +    }
28477 +  return 0;
28478 +}
28479 +
28480 +\f
28481 +
28482 +/* Initialize the 'parameters' module.  */
28483 +void
28484 +gdbpy_initialize_parameters (void)
28485 +{
28486 +  int i;
28487 +
28488 +  if (PyType_Ready (&parmpy_object_type) < 0)
28489 +    return;
28490 +
28491 +  set_doc_cst = PyString_FromString ("set_doc");
28492 +  if (! set_doc_cst)
28493 +    return;
28494 +  show_doc_cst = PyString_FromString ("show_doc");
28495 +  if (! show_doc_cst)
28496 +    return;
28497 +
28498 +  for (i = 0; parm_constants[i].name; ++i)
28499 +    {
28500 +      if (PyModule_AddIntConstant (gdb_module,
28501 +                                  parm_constants[i].name,
28502 +                                  parm_constants[i].value) < 0)
28503 +       return;
28504 +    }
28505 +
28506 +  Py_INCREF (&parmpy_object_type);
28507 +  PyModule_AddObject (gdb_module, "Parameter",
28508 +                     (PyObject *) &parmpy_object_type);
28509 +}
28510 +
28511 +\f
28512 +
28513 +static PyTypeObject parmpy_object_type =
28514 +{
28515 +  PyObject_HEAD_INIT (NULL)
28516 +  0,                             /*ob_size*/
28517 +  "gdb.Parameter",               /*tp_name*/
28518 +  sizeof (parmpy_object),        /*tp_basicsize*/
28519 +  0,                             /*tp_itemsize*/
28520 +  0,                             /*tp_dealloc*/
28521 +  0,                             /*tp_print*/
28522 +  0,                             /*tp_getattr*/
28523 +  0,                             /*tp_setattr*/
28524 +  0,                             /*tp_compare*/
28525 +  0,                             /*tp_repr*/
28526 +  0,                             /*tp_as_number*/
28527 +  0,                             /*tp_as_sequence*/
28528 +  0,                             /*tp_as_mapping*/
28529 +  0,                             /*tp_hash */
28530 +  0,                             /*tp_call*/
28531 +  0,                             /*tp_str*/
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 */
28541 +  0,                             /* tp_iter */
28542 +  0,                             /* tp_iternext */
28543 +  0,                             /* tp_methods */
28544 +  0,                             /* tp_members */
28545 +  0,                             /* tp_getset */
28546 +  0,                             /* tp_base */
28547 +  0,                             /* tp_dict */
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 */
28554 +};
28555 diff --git a/gdb/python/python-symbol.c b/gdb/python/python-symbol.c
28556 new file mode 100644
28557 index 0000000..c7fda5c
28558 --- /dev/null
28559 +++ b/gdb/python/python-symbol.c
28560 @@ -0,0 +1,337 @@
28561 +/* Python interface to symbols.
28562 +
28563 +   Copyright (C) 2008 Free Software Foundation, Inc.
28564 +
28565 +   This file is part of GDB.
28566 +
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.
28571 +
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.
28576 +
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/>.  */
28579 +
28580 +#include "defs.h"
28581 +#include "block.h"
28582 +#include "exceptions.h"
28583 +#include "frame.h"
28584 +#include "symtab.h"
28585 +#include "python-internal.h"
28586 +
28587 +typedef struct {
28588 +  PyObject_HEAD
28589 +  struct symbol *symbol;
28590 +} symbol_object;
28591 +
28592 +
28593 +static PyObject *
28594 +sympy_str (PyObject *self)
28595 +{
28596 +  int ret;
28597 +  char *s;
28598 +  PyObject *result;
28599 +
28600 +  ret = asprintf (&s, "symbol for %s",
28601 +                 SYMBOL_PRINT_NAME (((symbol_object *) self)->symbol));
28602 +  if (ret < 0)
28603 +    Py_RETURN_NONE;
28604 +
28605 +  result = PyString_FromString (s);
28606 +  xfree (s);
28607 +
28608 +  return result;
28609 +}
28610 +
28611 +static PyObject *
28612 +sympy_get_value (PyObject *self, void *closure)
28613 +{
28614 +  symbol_object *self_sym = (symbol_object *) self;
28615 +
28616 +  switch (SYMBOL_CLASS (self_sym->symbol))
28617 +    {
28618 +    case LOC_BLOCK:
28619 +      return block_to_block_object (SYMBOL_BLOCK_VALUE (self_sym->symbol));
28620 +    }
28621 +
28622 +  PyErr_SetString (PyExc_NotImplementedError,
28623 +                  "Symbol type not yet supported in Python scripts.");
28624 +  return NULL;
28625 +}
28626 +
28627 +static PyObject *
28628 +sympy_get_symtab (PyObject *self, void *closure)
28629 +{
28630 +  symbol_object *self_sym = (symbol_object *) self;
28631 +
28632 +  return symtab_to_symtab_object (SYMBOL_SYMTAB (self_sym->symbol));
28633 +}
28634 +
28635 +static PyObject *
28636 +sympy_get_name (PyObject *self, void *closure)
28637 +{
28638 +  symbol_object *self_sym = (symbol_object *) self;
28639 +
28640 +  return PyString_FromString (SYMBOL_NATURAL_NAME (self_sym->symbol));
28641 +}
28642 +
28643 +static PyObject *
28644 +sympy_get_linkage_name (PyObject *self, void *closure)
28645 +{
28646 +  symbol_object *self_sym = (symbol_object *) self;
28647 +
28648 +  return PyString_FromString (SYMBOL_LINKAGE_NAME (self_sym->symbol));
28649 +}
28650 +
28651 +static PyObject *
28652 +sympy_get_print_name (PyObject *self, void *closure)
28653 +{
28654 +  symbol_object *self_sym = (symbol_object *) self;
28655 +
28656 +  return PyString_FromString (SYMBOL_PRINT_NAME (self_sym->symbol));
28657 +}
28658 +
28659 +static PyObject *
28660 +sympy_get_addr_class (PyObject *self, void *closure)
28661 +{
28662 +  symbol_object *self_sym = (symbol_object *) self;
28663 +
28664 +  return PyInt_FromLong (SYMBOL_CLASS (self_sym->symbol));
28665 +}
28666 +
28667 +static PyObject *
28668 +sympy_is_argument (PyObject *self, void *closure)
28669 +{
28670 +  symbol_object *self_sym = (symbol_object *) self;
28671 +
28672 +  return PyBool_FromLong (SYMBOL_IS_ARGUMENT (self_sym->symbol));
28673 +}
28674 +
28675 +static PyObject *
28676 +sympy_is_constant (PyObject *self, void *closure)
28677 +{
28678 +  symbol_object *self_sym = (symbol_object *) self;
28679 +  enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28680 +
28681 +  return PyBool_FromLong (class == LOC_CONST || class == LOC_CONST_BYTES);
28682 +}
28683 +
28684 +static PyObject *
28685 +sympy_is_function (PyObject *self, void *closure)
28686 +{
28687 +  symbol_object *self_sym = (symbol_object *) self;
28688 +  enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28689 +
28690 +  return PyBool_FromLong (class == LOC_BLOCK);
28691 +}
28692 +
28693 +static PyObject *
28694 +sympy_is_variable (PyObject *self, void *closure)
28695 +{
28696 +  symbol_object *self_sym = (symbol_object *) self;
28697 +  enum address_class class = SYMBOL_CLASS (self_sym->symbol);
28698 +
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));
28702 +}
28703 +
28704 +PyObject *
28705 +symbol_to_symbol_object (struct symbol *sym)
28706 +{
28707 +  symbol_object *sym_obj;
28708 +
28709 +  sym_obj = PyObject_New (symbol_object, &symbol_object_type);
28710 +  if (sym_obj == NULL)
28711 +    {
28712 +      PyErr_SetString (PyExc_MemoryError, "Could not allocate symbol object.");
28713 +      return NULL;
28714 +    }
28715 +
28716 +  sym_obj->symbol = sym;
28717 +
28718 +  return (PyObject *) sym_obj;
28719 +}
28720 +
28721 +struct symbol *
28722 +symbol_object_to_symbol (PyObject *obj)
28723 +{
28724 +  if (! PyObject_TypeCheck (obj, &symbol_object_type))
28725 +    return NULL;
28726 +  return ((symbol_object *) obj)->symbol;
28727 +}
28728 +
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).  */
28734 +
28735 +PyObject *gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
28736 +{
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;
28743 +
28744 +  if (! PyArg_ParseTupleAndKeywords (args, kw, "s|O!i", keywords, &name,
28745 +                                    &block_object_type, &block_obj, &domain))
28746 +    return NULL;
28747 +
28748 +  if (block_obj)
28749 +    block = block_object_to_block (block_obj);
28750 +  else
28751 +    {
28752 +      struct frame_info *selected_frame;
28753 +      volatile struct gdb_exception except;
28754 +
28755 +      TRY_CATCH (except, RETURN_MASK_ALL)
28756 +       {
28757 +         selected_frame  = get_selected_frame (_("No frame selected."));
28758 +         block = block_for_pc (get_frame_address_in_block (selected_frame));
28759 +       }
28760 +      GDB_PY_HANDLE_EXCEPTION (except);
28761 +    }
28762 +
28763 +  symbol = lookup_symbol (name, block, domain, &is_a_field_of_this);
28764 +
28765 +  ret_tuple = PyTuple_New (2);
28766 +  if (!ret_tuple)
28767 +    {
28768 +      PyErr_SetString (PyExc_MemoryError, "Could not allocate tuple object.");
28769 +      return NULL;
28770 +    }
28771 +
28772 +  if (symbol)
28773 +    {
28774 +      sym_obj = symbol_to_symbol_object (symbol);
28775 +      if (!sym_obj)
28776 +       {
28777 +         Py_DECREF (ret_tuple);
28778 +         return NULL;
28779 +       }
28780 +    }
28781 +  else
28782 +    {
28783 +      sym_obj = Py_None;
28784 +      Py_INCREF (Py_None);
28785 +    }
28786 +  PyTuple_SET_ITEM (ret_tuple, 0, sym_obj);
28787 +
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);
28791 +
28792 +  return ret_tuple;
28793 +}
28794 +
28795 +void
28796 +gdbpy_initialize_symbols (void)
28797 +{
28798 +  symbol_object_type.tp_new = PyType_GenericNew;
28799 +  if (PyType_Ready (&symbol_object_type) < 0)
28800 +    return;
28801 +
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);
28834 +
28835 +  Py_INCREF (&symbol_object_type);
28836 +  PyModule_AddObject (gdb_module, "Symbol", (PyObject *) &symbol_object_type);
28837 +}
28838 +
28839 +\f
28840 +
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 */
28863 +};
28864 +
28865 +PyTypeObject symbol_object_type = {
28866 +  PyObject_HEAD_INIT (NULL)
28867 +  0,                             /*ob_size*/
28868 +  "gdb.Symbol",                          /*tp_name*/
28869 +  sizeof (symbol_object),        /*tp_basicsize*/
28870 +  0,                             /*tp_itemsize*/
28871 +  0,                             /*tp_dealloc*/
28872 +  0,                             /*tp_print*/
28873 +  0,                             /*tp_getattr*/
28874 +  0,                             /*tp_setattr*/
28875 +  0,                             /*tp_compare*/
28876 +  0,                             /*tp_repr*/
28877 +  0,                             /*tp_as_number*/
28878 +  0,                             /*tp_as_sequence*/
28879 +  0,                             /*tp_as_mapping*/
28880 +  0,                             /*tp_hash */
28881 +  0,                             /*tp_call*/
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 */
28892 +  0,                             /* tp_iter */
28893 +  0,                             /* tp_iternext */
28894 +  0,                             /* tp_methods */
28895 +  0,                             /* tp_members */
28896 +  symbol_object_getset           /* tp_getset */
28897 +};
28898 diff --git a/gdb/python/python-symtab.c b/gdb/python/python-symtab.c
28899 new file mode 100644
28900 index 0000000..a48c38c
28901 --- /dev/null
28902 +++ b/gdb/python/python-symtab.c
28903 @@ -0,0 +1,311 @@
28904 +/* Python interface to symbol tables.
28905 +
28906 +   Copyright (C) 2008 Free Software Foundation, Inc.
28907 +
28908 +   This file is part of GDB.
28909 +
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.
28914 +
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.
28919 +
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/>.  */
28922 +
28923 +#include "defs.h"
28924 +#include "charset.h"
28925 +#include "symtab.h"
28926 +#include "source.h"
28927 +#include "python-internal.h"
28928 +
28929 +typedef struct {
28930 +  PyObject_HEAD
28931 +  struct symtab *symtab;
28932 +} symtab_object;
28933 +
28934 +static PyTypeObject symtab_object_type;
28935 +
28936 +typedef struct {
28937 +  PyObject_HEAD
28938 +  symtab_object *symtab;
28939 +  struct symtab_and_line *sal;
28940 +} sal_object;
28941 +
28942 +static PyTypeObject sal_object_type;
28943 +
28944 +
28945 +static PyObject *
28946 +stpy_str (PyObject *self)
28947 +{
28948 +  int ret;
28949 +  char *s;
28950 +  PyObject *result;
28951 +
28952 +  ret = asprintf (&s, "symbol table for %s",
28953 +                 ((symtab_object *) self)->symtab->filename);
28954 +  if (ret < 0)
28955 +    Py_RETURN_NONE;
28956 +
28957 +  result = PyString_FromString (s);
28958 +  xfree (s);
28959 +
28960 +  return result;
28961 +}
28962 +
28963 +static PyObject *
28964 +stpy_get_filename (PyObject *self, void *closure)
28965 +{
28966 +  symtab_object *self_symtab = (symtab_object *) self;
28967 +  PyObject *str_obj;
28968 +
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);
28974 +  else
28975 +    {
28976 +      str_obj = Py_None;
28977 +      Py_INCREF (Py_None);
28978 +    }
28979 +
28980 +  return str_obj;
28981 +}
28982 +
28983 +static PyObject *
28984 +stpy_fullname (PyObject *self, PyObject *args)
28985 +{
28986 +  char *fullname;
28987 +
28988 +  fullname = symtab_to_fullname (((symtab_object *) self)->symtab);
28989 +  if (fullname)
28990 +    return PyString_Decode (fullname, strlen (fullname), host_charset (), NULL);
28991 +
28992 +  Py_RETURN_NONE;
28993 +}
28994 +
28995 +static PyObject *
28996 +salpy_str (PyObject *self)
28997 +{
28998 +  int ret;
28999 +  char *s, *filename;
29000 +  sal_object *sal_obj;
29001 +  PyObject *result;
29002 +
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);
29008 +  if (ret < 0)
29009 +    Py_RETURN_NONE;
29010 +
29011 +  result = PyString_FromString (s);
29012 +  xfree (s);
29013 +
29014 +  return result;
29015 +}
29016 +
29017 +static PyObject *
29018 +salpy_get_pc (PyObject *self, void *closure)
29019 +{
29020 +  return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->pc);
29021 +}
29022 +
29023 +static PyObject *
29024 +salpy_get_line (PyObject *self, void *closure)
29025 +{
29026 +  return PyLong_FromUnsignedLongLong (((sal_object *) self)->sal->line);
29027 +}
29028 +
29029 +static PyObject *
29030 +salpy_get_symtab (PyObject *self, void *closure)
29031 +{
29032 +  sal_object *self_sal = (sal_object *) self;
29033 +
29034 +  Py_INCREF (self_sal->symtab);
29035 +
29036 +  return (PyObject *) self_sal->symtab;
29037 +}
29038 +
29039 +static void 
29040 +salpy_dealloc (PyObject *self)
29041 +{
29042 +  sal_object *self_sal = (sal_object *) self;
29043 +
29044 +  Py_DECREF (self_sal->symtab);
29045 +  xfree (self_sal->sal);
29046 +  self_sal->ob_type->tp_free (self);
29047 +}
29048 +
29049 +PyObject *
29050 +symtab_and_line_to_sal_object (struct symtab_and_line sal)
29051 +{
29052 +  sal_object *sal_obj;
29053 +  symtab_object *symtab_obj;
29054 +
29055 +  sal_obj = PyObject_New (sal_object, &sal_object_type);
29056 +  if (sal_obj == NULL)
29057 +    {
29058 +      PyErr_SetString (PyExc_MemoryError,
29059 +                      "Could not allocate Symtab_and_line object.");
29060 +      return NULL;
29061 +    }
29062 +
29063 +  if (sal.symtab)
29064 +    {
29065 +      symtab_obj = (symtab_object *) symtab_to_symtab_object (sal.symtab);
29066 +      if (symtab_obj == NULL)
29067 +       {
29068 +         Py_DECREF (sal_obj);
29069 +         return NULL;
29070 +       }
29071 +
29072 +      symtab_obj->symtab = sal.symtab;
29073 +    }
29074 +  else
29075 +    {
29076 +      symtab_obj = (symtab_object *) Py_None;
29077 +      Py_INCREF (Py_None);
29078 +    }
29079 +
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;
29084 +
29085 +  return (PyObject *) sal_obj;
29086 +}
29087 +
29088 +PyObject *
29089 +symtab_to_symtab_object (struct symtab *symtab)
29090 +{
29091 +  symtab_object *symtab_obj;
29092 +  
29093 +  symtab_obj = PyObject_New (symtab_object, &symtab_object_type);
29094 +  if (symtab_obj == NULL)
29095 +    {
29096 +      PyErr_SetString (PyExc_MemoryError,
29097 +         "Could not allocate Symtab object.");
29098 +
29099 +      return NULL;
29100 +    }
29101 +
29102 +  symtab_obj->symtab = symtab;
29103 +
29104 +  return (PyObject *) symtab_obj;
29105 +}
29106 +
29107 +void
29108 +gdbpy_initialize_symtabs (void)
29109 +{
29110 +  symtab_object_type.tp_new = PyType_GenericNew;
29111 +  if (PyType_Ready (&symtab_object_type) < 0)
29112 +    return;
29113 +
29114 +  sal_object_type.tp_new = PyType_GenericNew;
29115 +  if (PyType_Ready (&sal_object_type) < 0)
29116 +    return;
29117 +
29118 +  Py_INCREF (&symtab_object_type);
29119 +  PyModule_AddObject (gdb_module, "Symtab", (PyObject *) &symtab_object_type);
29120 +
29121 +  Py_INCREF (&sal_object_type);
29122 +  PyModule_AddObject (gdb_module, "Symtab_and_line",
29123 +                     (PyObject *) &sal_object_type);
29124 +}
29125 +
29126 +\f
29127 +
29128 +static PyGetSetDef symtab_object_getset[] = {
29129 +  { "filename", stpy_get_filename, NULL,
29130 +    "The symbol table's source filename.", NULL },
29131 +  {NULL}  /* Sentinel */
29132 +};
29133 +
29134 +static PyMethodDef symtab_object_methods[] = {
29135 +  { "fullname", stpy_fullname, METH_NOARGS,
29136 +    "Return the symtab's full source filename." },
29137 +  {NULL}  /* Sentinel */
29138 +};
29139 +
29140 +static PyTypeObject symtab_object_type = {
29141 +  PyObject_HEAD_INIT (NULL)
29142 +  0,                             /*ob_size*/
29143 +  "gdb.Symtab",                          /*tp_name*/
29144 +  sizeof (symtab_object),        /*tp_basicsize*/
29145 +  0,                             /*tp_itemsize*/
29146 +  0,                             /*tp_dealloc*/
29147 +  0,                             /*tp_print*/
29148 +  0,                             /*tp_getattr*/
29149 +  0,                             /*tp_setattr*/
29150 +  0,                             /*tp_compare*/
29151 +  0,                             /*tp_repr*/
29152 +  0,                             /*tp_as_number*/
29153 +  0,                             /*tp_as_sequence*/
29154 +  0,                             /*tp_as_mapping*/
29155 +  0,                             /*tp_hash */
29156 +  0,                             /*tp_call*/
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 */
29167 +  0,                             /* tp_iter */
29168 +  0,                             /* tp_iternext */
29169 +  symtab_object_methods,         /* tp_methods */
29170 +  0,                             /* tp_members */
29171 +  symtab_object_getset           /* tp_getset */
29172 +};
29173 +
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 */
29180 +};
29181 +
29182 +static PyTypeObject sal_object_type = {
29183 +  PyObject_HEAD_INIT (NULL)
29184 +  0,                             /*ob_size*/
29185 +  "gdb.Symtab_and_line",         /*tp_name*/
29186 +  sizeof (sal_object),           /*tp_basicsize*/
29187 +  0,                             /*tp_itemsize*/
29188 +  salpy_dealloc,                 /*tp_dealloc*/
29189 +  0,                             /*tp_print*/
29190 +  0,                             /*tp_getattr*/
29191 +  0,                             /*tp_setattr*/
29192 +  0,                             /*tp_compare*/
29193 +  0,                             /*tp_repr*/
29194 +  0,                             /*tp_as_number*/
29195 +  0,                             /*tp_as_sequence*/
29196 +  0,                             /*tp_as_mapping*/
29197 +  0,                             /*tp_hash */
29198 +  0,                             /*tp_call*/
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 */
29209 +  0,                             /* tp_iter */
29210 +  0,                             /* tp_iternext */
29211 +  0,                             /* tp_methods */
29212 +  0,                             /* tp_members */
29213 +  sal_object_getset              /* tp_getset */
29214 +};
29215 diff --git a/gdb/python/python-type.c b/gdb/python/python-type.c
29216 new file mode 100644
29217 index 0000000..772a011
29218 --- /dev/null
29219 +++ b/gdb/python/python-type.c
29220 @@ -0,0 +1,821 @@
29221 +/* Python interface to types.
29222 +
29223 +   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
29224 +
29225 +   This file is part of GDB.
29226 +
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.
29231 +
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.
29236 +
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/>.  */
29239 +
29240 +#include "defs.h"
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"
29250 +
29251 +typedef struct pyty_type_object
29252 +{
29253 +  PyObject_HEAD
29254 +  struct type *type;
29255 +
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;
29261 +} type_object;
29262 +
29263 +static PyTypeObject type_object_type;
29264 +
29265 +/* A Field object.  */
29266 +typedef struct pyty_field_object
29267 +{
29268 +  PyObject_HEAD
29269 +
29270 +  /* Dictionary holding our attributes.  */
29271 +  PyObject *dict;
29272 +} field_object;
29273 +
29274 +static PyTypeObject field_object_type;
29275 +
29276 +/* This is used to initialize various gdb.TYPE_ constants.  */
29277 +struct pyty_code
29278 +{
29279 +  /* The code.  */
29280 +  enum type_code code;
29281 +  /* The name.  */
29282 +  const char *name;
29283 +};
29284 +
29285 +#define ENTRY(X) { X, #X }
29286 +
29287 +static struct pyty_code pyty_codes[] =
29288 +{
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 }
29318 +};
29319 +
29320 +\f
29321 +
29322 +static void
29323 +field_dealloc (PyObject *obj)
29324 +{
29325 +  field_object *f = (field_object *) obj;
29326 +  Py_XDECREF (f->dict);
29327 +}
29328 +
29329 +static PyObject *
29330 +field_new (void)
29331 +{
29332 +  field_object *result = PyObject_New (field_object, &field_object_type);
29333 +  if (result)
29334 +    {
29335 +      result->dict = PyDict_New ();
29336 +      if (!result->dict)
29337 +       {
29338 +         Py_DECREF (result);
29339 +         result = NULL;
29340 +       }
29341 +    }
29342 +  return (PyObject *) result;
29343 +}
29344 +
29345 +\f
29346 +
29347 +/* Return the code for this type.  */
29348 +static PyObject *
29349 +typy_code (PyObject *self, PyObject *args)
29350 +{
29351 +  struct type *type = ((type_object *) self)->type;
29352 +  return PyInt_FromLong (TYPE_CODE (type));
29353 +}
29354 +
29355 +/* Helper function for typy_fields which converts a single field to a
29356 +   dictionary.  Returns NULL on error.  */
29357 +static PyObject *
29358 +convert_field (struct type *type, int field)
29359 +{
29360 +  PyObject *result = field_new ();
29361 +  PyObject *arg;
29362 +
29363 +  if (!result)
29364 +    return NULL;
29365 +
29366 +  if (!field_is_static (&TYPE_FIELD (type, field)))
29367 +    {
29368 +      arg = PyLong_FromLong (TYPE_FIELD_BITPOS (type, field));
29369 +      if (!arg)
29370 +       goto fail;
29371 +
29372 +      if (PyObject_SetAttrString (result, "bitpos", arg) < 0)
29373 +       goto failarg;
29374 +    }
29375 +
29376 +  if (TYPE_FIELD_NAME (type, field))
29377 +    arg = PyString_FromString (TYPE_FIELD_NAME (type, field));
29378 +  else
29379 +    {
29380 +      arg = Py_None;
29381 +      Py_INCREF (arg);
29382 +    }
29383 +  if (!arg)
29384 +    goto fail;
29385 +  if (PyObject_SetAttrString (result, "name", arg) < 0)
29386 +    goto failarg;
29387 +
29388 +  arg = TYPE_FIELD_ARTIFICIAL (type, field) ? Py_True : Py_False;
29389 +  Py_INCREF (arg);
29390 +  if (PyObject_SetAttrString (result, "artificial", arg) < 0)
29391 +    goto failarg;
29392 +
29393 +  arg = PyLong_FromLong (TYPE_FIELD_BITSIZE (type, field));
29394 +  if (!arg)
29395 +    goto fail;
29396 +  if (PyObject_SetAttrString (result, "bitsize", arg) < 0)
29397 +    goto failarg;
29398 +
29399 +  arg = type_to_type_object (TYPE_FIELD_TYPE (type, field));
29400 +  if (!arg)
29401 +    goto fail;
29402 +  if (PyObject_SetAttrString (result, "type", arg) < 0)
29403 +    goto failarg;
29404 +
29405 +  return result;
29406 +
29407 + failarg:
29408 +  Py_DECREF (arg);
29409 + fail:
29410 +  Py_DECREF (result);
29411 +  return NULL;
29412 +}
29413 +
29414 +/* Return a sequence of all fields.  Each field is a dictionary with
29415 +   some pre-defined keys.  */
29416 +static PyObject *
29417 +typy_fields (PyObject *self, PyObject *args)
29418 +{
29419 +  PyObject *result;
29420 +  int i;
29421 +  struct type *type = ((type_object *) self)->type;
29422 +
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);
29427 +
29428 +  for (i = 0; i < TYPE_NFIELDS (type); ++i)
29429 +    {
29430 +      PyObject *dict = convert_field (type, i);
29431 +      if (!dict)
29432 +       {
29433 +         Py_DECREF (result);
29434 +         return NULL;
29435 +       }
29436 +      if (PyList_Append (result, dict))
29437 +       {
29438 +         Py_DECREF (dict);
29439 +         Py_DECREF (result);
29440 +         return NULL;
29441 +       }
29442 +    }
29443 +
29444 +  return result;
29445 +}
29446 +
29447 +/* Return the type's tag, or None.  */
29448 +static PyObject *
29449 +typy_tag (PyObject *self, PyObject *args)
29450 +{
29451 +  struct type *type = ((type_object *) self)->type;
29452 +  if (!TYPE_TAG_NAME (type))
29453 +    Py_RETURN_NONE;
29454 +  return PyString_FromString (TYPE_TAG_NAME (type));
29455 +}
29456 +
29457 +/* Return the type, stripped of typedefs. */
29458 +static PyObject *
29459 +typy_strip_typedefs (PyObject *self, PyObject *args)
29460 +{
29461 +  struct type *type = ((type_object *) self)->type;
29462 +
29463 +  return type_to_type_object (check_typedef (type));
29464 +}
29465 +
29466 +/* Return a Type object which represents a pointer to SELF.  */
29467 +static PyObject *
29468 +typy_pointer (PyObject *self, PyObject *args)
29469 +{
29470 +  struct type *type = ((type_object *) self)->type;
29471 +  volatile struct gdb_exception except;
29472 +
29473 +  TRY_CATCH (except, RETURN_MASK_ALL)
29474 +    {
29475 +      type = lookup_pointer_type (type);
29476 +    }
29477 +  GDB_PY_HANDLE_EXCEPTION (except);
29478 +
29479 +  return type_to_type_object (type);
29480 +}
29481 +
29482 +/* Return a Type object which represents a reference to SELF.  */
29483 +static PyObject *
29484 +typy_reference (PyObject *self, PyObject *args)
29485 +{
29486 +  struct type *type = ((type_object *) self)->type;
29487 +  volatile struct gdb_exception except;
29488 +
29489 +  TRY_CATCH (except, RETURN_MASK_ALL)
29490 +    {
29491 +      type = lookup_reference_type (type);
29492 +    }
29493 +  GDB_PY_HANDLE_EXCEPTION (except);
29494 +
29495 +  return type_to_type_object (type);
29496 +}
29497 +
29498 +/* Return a Type object which represents the target type of SELF.  */
29499 +static PyObject *
29500 +typy_target (PyObject *self, PyObject *args)
29501 +{
29502 +  struct type *type = ((type_object *) self)->type;
29503 +
29504 +  if (!TYPE_TARGET_TYPE (type))
29505 +    {
29506 +      PyErr_SetString (PyExc_RuntimeError, "type does not have a target");
29507 +      return NULL;
29508 +    }
29509 +
29510 +  return type_to_type_object (TYPE_TARGET_TYPE (type));
29511 +}
29512 +
29513 +/* Return a const-qualified type variant.  */
29514 +static PyObject *
29515 +typy_const (PyObject *self, PyObject *args)
29516 +{
29517 +  struct type *type = ((type_object *) self)->type;
29518 +  volatile struct gdb_exception except;
29519 +
29520 +  TRY_CATCH (except, RETURN_MASK_ALL)
29521 +    {
29522 +      type = make_cv_type (1, 0, type, NULL);
29523 +    }
29524 +  GDB_PY_HANDLE_EXCEPTION (except);
29525 +
29526 +  return type_to_type_object (type);
29527 +}
29528 +
29529 +/* Return a volatile-qualified type variant.  */
29530 +static PyObject *
29531 +typy_volatile (PyObject *self, PyObject *args)
29532 +{
29533 +  struct type *type = ((type_object *) self)->type;
29534 +  volatile struct gdb_exception except;
29535 +
29536 +  TRY_CATCH (except, RETURN_MASK_ALL)
29537 +    {
29538 +      type = make_cv_type (0, 1, type, NULL);
29539 +    }
29540 +  GDB_PY_HANDLE_EXCEPTION (except);
29541 +
29542 +  return type_to_type_object (type);
29543 +}
29544 +
29545 +/* Return an unqualified type variant.  */
29546 +static PyObject *
29547 +typy_unqualified (PyObject *self, PyObject *args)
29548 +{
29549 +  struct type *type = ((type_object *) self)->type;
29550 +  volatile struct gdb_exception except;
29551 +
29552 +  TRY_CATCH (except, RETURN_MASK_ALL)
29553 +    {
29554 +      type = make_cv_type (0, 0, type, NULL);
29555 +    }
29556 +  GDB_PY_HANDLE_EXCEPTION (except);
29557 +
29558 +  return type_to_type_object (type);
29559 +}
29560 +
29561 +/* Return the size of the type represented by SELF, in bytes.  */
29562 +static PyObject *
29563 +typy_sizeof (PyObject *self, PyObject *args)
29564 +{
29565 +  struct type *type = ((type_object *) self)->type;
29566 +  volatile struct gdb_exception except;
29567 +
29568 +  TRY_CATCH (except, RETURN_MASK_ALL)
29569 +    {
29570 +      CHECK_TYPEDEF (type);
29571 +    }
29572 +  GDB_PY_HANDLE_EXCEPTION (except);
29573 +
29574 +  return PyLong_FromLong (TYPE_LENGTH (type));
29575 +}
29576 +
29577 +static struct type *
29578 +typy_lookup_typename (char *type_name, struct block *block)
29579 +{
29580 +  struct type *type = NULL;
29581 +  volatile struct gdb_exception except;
29582 +  TRY_CATCH (except, RETURN_MASK_ALL)
29583 +    {
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);
29590 +      else
29591 +       type = lookup_typename (type_name, block, 0);
29592 +    }
29593 +  if (except.reason < 0)
29594 +    {
29595 +      PyErr_Format (except.reason == RETURN_QUIT
29596 +                   ? PyExc_KeyboardInterrupt : PyExc_RuntimeError,
29597 +                   "%s", except.message);
29598 +      return NULL;
29599 +    }
29600 +
29601 +  return type;
29602 +}
29603 +
29604 +static struct type *
29605 +typy_lookup_type (struct demangle_component *demangled,
29606 +                 struct block *block)
29607 +{
29608 +  struct type *type;
29609 +  char *type_name;
29610 +  enum demangle_component_type demangled_type;
29611 +
29612 +  /* Save the type: typy_lookup_type() may (indirectly) overwrite
29613 +     memory pointed by demangled.  */
29614 +  demangled_type = demangled->type;
29615 +
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)
29620 +    {
29621 +      type = typy_lookup_type (demangled->u.s_binary.left, block);
29622 +      if (! type)
29623 +       return NULL;
29624 +
29625 +      switch (demangled_type)
29626 +       {
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);
29635 +       }
29636 +    }
29637 +
29638 +  type_name = cp_comp_to_string (demangled, 10);
29639 +  type = typy_lookup_typename (type_name, block);
29640 +  xfree (type_name);
29641 +
29642 +  return type;
29643 +}
29644 +
29645 +static PyObject *
29646 +typy_template_argument (PyObject *self, PyObject *args)
29647 +{
29648 +  int i, argno, n_pointers;
29649 +  struct type *type = ((type_object *) self)->type;
29650 +  struct demangle_component *demangled;
29651 +  const char *err;
29652 +  struct type *argtype;
29653 +  struct block *block = NULL;
29654 +  PyObject *block_obj = NULL;
29655 +
29656 +  if (! PyArg_ParseTuple (args, "i|O", &argno, &block_obj))
29657 +    return NULL;
29658 +
29659 +  if (block_obj)
29660 +    {
29661 +      block = block_object_to_block (block_obj);
29662 +      if (! block)
29663 +       {
29664 +         PyErr_SetString (PyExc_RuntimeError,
29665 +                          "second argument must be block");
29666 +         return NULL;
29667 +       }
29668 +    }
29669 +
29670 +  type = check_typedef (type);
29671 +  if (TYPE_CODE (type) == TYPE_CODE_REF)
29672 +    type = check_typedef (TYPE_TARGET_TYPE (type));
29673 +
29674 +  if (TYPE_NAME (type) == NULL)
29675 +    {
29676 +      PyErr_SetString (PyExc_RuntimeError, "null type name");
29677 +      return NULL;
29678 +    }
29679 +
29680 +  /* Note -- this is not thread-safe.  */
29681 +  demangled = cp_demangled_name_to_comp (TYPE_NAME (type), &err);
29682 +  if (! demangled)
29683 +    {
29684 +      PyErr_SetString (PyExc_RuntimeError, err);
29685 +      return NULL;
29686 +    }
29687 +
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;
29692 +
29693 +  if (demangled->type != DEMANGLE_COMPONENT_TEMPLATE)
29694 +    {
29695 +      PyErr_SetString (PyExc_RuntimeError, "type is not a template");
29696 +      return NULL;
29697 +    }
29698 +
29699 +  /* Skip from the template to the arguments.  */
29700 +  demangled = demangled->u.s_binary.right;
29701 +
29702 +  for (i = 0; demangled && i < argno; ++i)
29703 +    demangled = demangled->u.s_binary.right;
29704 +
29705 +  if (! demangled)
29706 +    {
29707 +      PyErr_Format (PyExc_RuntimeError, "no argument %d in template",
29708 +                   argno);
29709 +      return NULL;
29710 +    }
29711 +
29712 +  argtype = typy_lookup_type (demangled->u.s_binary.left, block);
29713 +  if (! argtype)
29714 +    return NULL;
29715 +
29716 +  return type_to_type_object (argtype);
29717 +}
29718 +
29719 +static PyObject *
29720 +typy_str (PyObject *self)
29721 +{
29722 +  volatile struct gdb_exception except;
29723 +  char *thetype = NULL;
29724 +  PyObject *result;
29725 +
29726 +  TRY_CATCH (except, RETURN_MASK_ALL)
29727 +    {
29728 +      struct cleanup *old_chain;
29729 +      struct ui_file *stb;
29730 +      long length;
29731 +
29732 +      stb = mem_fileopen ();
29733 +      old_chain = make_cleanup_ui_file_delete (stb);
29734 +
29735 +      type_print (type_object_to_type (self), "", stb, -1);
29736 +
29737 +      thetype = ui_file_xstrdup (stb, &length);
29738 +      do_cleanups (old_chain);
29739 +    }
29740 +  if (except.reason < 0)
29741 +    {
29742 +      xfree (thetype);
29743 +      GDB_PY_HANDLE_EXCEPTION (except);
29744 +    }
29745 +
29746 +  result = PyUnicode_Decode (thetype, strlen (thetype), host_charset (), NULL);
29747 +  xfree (thetype);
29748 +
29749 +  return result;
29750 +}
29751 +
29752 +\f
29753 +
29754 +static const struct objfile_data *typy_objfile_data_key;
29755 +
29756 +static void
29757 +clean_up_objfile_types (struct objfile *objfile, void *datum)
29758 +{
29759 +  type_object *obj = datum;
29760 +  htab_t copied_types;
29761 +  struct cleanup *cleanup;
29762 +  PyGILState_STATE state;
29763 +
29764 +  /* This prevents another thread from freeing the objects we're
29765 +     operating on.  */
29766 +  state = PyGILState_Ensure ();
29767 +  cleanup = make_cleanup_py_restore_gil (&state);
29768 +
29769 +  copied_types = create_copied_types_hash (objfile);
29770 +
29771 +  while (obj)
29772 +    {
29773 +      type_object *next = obj->next;
29774 +
29775 +      htab_empty (copied_types);
29776 +
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);
29782 +
29783 +      obj->next = NULL;
29784 +      obj->prev = NULL;
29785 +
29786 +      obj = next;
29787 +    }
29788 +
29789 +  htab_delete (copied_types);
29790 +
29791 +  do_cleanups (cleanup);
29792 +}
29793 +
29794 +static void
29795 +set_type (type_object *obj, struct type *type)
29796 +{
29797 +  obj->type = type;
29798 +  type_incref (type);
29799 +  obj->prev = NULL;
29800 +  if (type && !OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (type)))
29801 +    {
29802 +      struct objfile *objfile = TYPE_OBJFILE (type);
29803 +
29804 +      obj->next = objfile_data (objfile, typy_objfile_data_key);
29805 +      if (obj->next)
29806 +       obj->next->prev = obj;
29807 +      set_objfile_data (objfile, typy_objfile_data_key, obj);
29808 +    }
29809 +  else
29810 +    obj->next = NULL;
29811 +}
29812 +
29813 +static PyObject *
29814 +typy_new (PyTypeObject *subtype, PyObject *args, PyObject *kwargs)
29815 +{
29816 +  char *type_name = NULL;
29817 +  struct type *type = NULL;
29818 +  type_object *result;
29819 +  PyObject *block_obj = NULL;
29820 +  struct block *block = NULL;
29821 +
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))
29825 +    return NULL;
29826 +
29827 +  if (block_obj)
29828 +    {
29829 +      block = block_object_to_block (block_obj);
29830 +      if (! block)
29831 +       {
29832 +         PyErr_SetString (PyExc_RuntimeError,
29833 +                          "second argument must be block");
29834 +         return NULL;
29835 +       }
29836 +    }
29837 +
29838 +  if (type_name)
29839 +    {
29840 +      type = typy_lookup_typename (type_name, block);
29841 +      if (! type)
29842 +       return NULL;
29843 +    }
29844 +
29845 +  result = (type_object *) subtype->tp_alloc (subtype, 1);
29846 +  if (! result)
29847 +    return NULL;
29848 +
29849 +  set_type (result, type);
29850 +
29851 +  return (PyObject *) result;
29852 +}
29853 +
29854 +static void
29855 +typy_dealloc (PyObject *obj)
29856 +{
29857 +  type_object *type = (type_object *) obj;
29858 +
29859 +  if (type->type)
29860 +    type_decref (type->type);
29861 +
29862 +  if (type->prev)
29863 +    type->prev->next = type->next;
29864 +  else if (type->type && !OBJFILE_IS_VIRTUAL (TYPE_OBJFILE (type->type)))
29865 +    {
29866 +      /* Must reset head of list.  */
29867 +      struct objfile *objfile = TYPE_OBJFILE (type->type);
29868 +      if (objfile)
29869 +       set_objfile_data (objfile, typy_objfile_data_key, type->next);
29870 +    }
29871 +  if (type->next)
29872 +    type->next->prev = type->prev;
29873 +
29874 +  type->ob_type->tp_free (type);
29875 +}
29876 +
29877 +/* Create a new Type referring to TYPE.  */
29878 +PyObject *
29879 +type_to_type_object (struct type *type)
29880 +{
29881 +  type_object *type_obj;
29882 +
29883 +  type_obj = PyObject_New (type_object, &type_object_type);
29884 +  if (type_obj)
29885 +    set_type (type_obj, type);
29886 +
29887 +  return (PyObject *) type_obj;
29888 +}
29889 +
29890 +struct type *
29891 +type_object_to_type (PyObject *obj)
29892 +{
29893 +  if (! PyObject_TypeCheck (obj, &type_object_type))
29894 +    return NULL;
29895 +  return ((type_object *) obj)->type;
29896 +}
29897 +
29898 +\f
29899 +
29900 +void
29901 +gdbpy_initialize_types (void)
29902 +{
29903 +  int i;
29904 +
29905 +  typy_objfile_data_key
29906 +    = register_objfile_data_with_cleanup (clean_up_objfile_types);
29907 +
29908 +  if (PyType_Ready (&type_object_type) < 0)
29909 +    return;
29910 +  if (PyType_Ready (&field_object_type) < 0)
29911 +    return;
29912 +
29913 +  for (i = 0; pyty_codes[i].name; ++i)
29914 +    {
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)
29919 +       return;
29920 +    }
29921 +
29922 +  Py_INCREF (&type_object_type);
29923 +  PyModule_AddObject (gdb_module, "Type", (PyObject *) &type_object_type);
29924 +
29925 +  Py_INCREF (&field_object_type);
29926 +  PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
29927 +}
29928 +
29929 +\f
29930 +
29931 +static PyMethodDef type_object_methods[] =
29932 +{
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" },
29954 +  { NULL }
29955 +};
29956 +
29957 +static PyTypeObject type_object_type =
29958 +{
29959 +  PyObject_HEAD_INIT (NULL)
29960 +  0,                             /*ob_size*/
29961 +  "gdb.Type",                    /*tp_name*/
29962 +  sizeof (type_object),                  /*tp_basicsize*/
29963 +  0,                             /*tp_itemsize*/
29964 +  typy_dealloc,                          /*tp_dealloc*/
29965 +  0,                             /*tp_print*/
29966 +  0,                             /*tp_getattr*/
29967 +  0,                             /*tp_setattr*/
29968 +  0,                             /*tp_compare*/
29969 +  0,                             /*tp_repr*/
29970 +  0,                             /*tp_as_number*/
29971 +  0,                             /*tp_as_sequence*/
29972 +  0,                             /*tp_as_mapping*/
29973 +  0,                             /*tp_hash */
29974 +  0,                             /*tp_call*/
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 */
29985 +  0,                             /* tp_iter */
29986 +  0,                             /* tp_iternext */
29987 +  type_object_methods,           /* tp_methods */
29988 +  0,                             /* tp_members */
29989 +  0,                             /* tp_getset */
29990 +  0,                             /* tp_base */
29991 +  0,                             /* tp_dict */
29992 +  0,                             /* tp_descr_get */
29993 +  0,                             /* tp_descr_set */
29994 +  0,                             /* tp_dictoffset */
29995 +  0,                             /* tp_init */
29996 +  0,                             /* tp_alloc */
29997 +  typy_new,                      /* tp_new */
29998 +};
29999 +
30000 +static PyTypeObject field_object_type =
30001 +{
30002 +  PyObject_HEAD_INIT (NULL)
30003 +  0,                             /*ob_size*/
30004 +  "gdb.Field",                   /*tp_name*/
30005 +  sizeof (field_object),         /*tp_basicsize*/
30006 +  0,                             /*tp_itemsize*/
30007 +  field_dealloc,                 /*tp_dealloc*/
30008 +  0,                             /*tp_print*/
30009 +  0,                             /*tp_getattr*/
30010 +  0,                             /*tp_setattr*/
30011 +  0,                             /*tp_compare*/
30012 +  0,                             /*tp_repr*/
30013 +  0,                             /*tp_as_number*/
30014 +  0,                             /*tp_as_sequence*/
30015 +  0,                             /*tp_as_mapping*/
30016 +  0,                             /*tp_hash */
30017 +  0,                             /*tp_call*/
30018 +  0,                             /*tp_str*/
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 */
30028 +  0,                             /* tp_iter */
30029 +  0,                             /* tp_iternext */
30030 +  0,                             /* tp_methods */
30031 +  0,                             /* tp_members */
30032 +  0,                             /* tp_getset */
30033 +  0,                             /* tp_base */
30034 +  0,                             /* tp_dict */
30035 +  0,                             /* tp_descr_get */
30036 +  0,                             /* tp_descr_set */
30037 +  offsetof (field_object, dict),  /* tp_dictoffset */
30038 +  0,                             /* tp_init */
30039 +  0,                             /* tp_alloc */
30040 +  0,                             /* tp_new */
30041 +};
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
30046 @@ -19,6 +19,7 @@
30047  
30048  #include "defs.h"
30049  #include "charset.h"
30050 +#include "value.h"
30051  #include "python-internal.h"
30052  
30053  
30054 @@ -99,8 +100,8 @@ python_string_to_unicode (PyObject *obj)
30055  }
30056  
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.
30062  
30063     The caller is responsible for xfree'ing the string.  */
30064  static char *
30065 @@ -191,3 +192,48 @@ gdbpy_is_string (PyObject *obj)
30066  {
30067    return PyString_Check (obj) || PyUnicode_Check (obj);
30068  }
30069 +
30070 +/* Converts OBJ to a CORE_ADDR value.
30071 +
30072 +   Returns 1 on success or 0 on failure, with a Python exception set.  This
30073 +   function can also throw GDB exceptions.  */
30074 +
30075 +int
30076 +get_addr_from_python (PyObject *obj, CORE_ADDR *addr)
30077 +{
30078 +  if (gdbpy_is_value_object (obj))
30079 +    *addr = value_as_address (value_object_to_value (obj));
30080 +  else if (PyLong_Check (obj))
30081 +    {
30082 +      /* Assume CORE_ADDR corresponds to unsigned long.  */
30083 +      *addr = PyLong_AsUnsignedLong (obj);
30084 +      if (PyErr_Occurred () != NULL)
30085 +       return 0;
30086 +    }
30087 +  else if (PyInt_Check (obj))
30088 +    {
30089 +      long val;
30090 +
30091 +      /* Assume CORE_ADDR corresponds to unsigned long.  */
30092 +      val = PyInt_AsLong (obj);
30093 +
30094 +      if (val >= 0)
30095 +       *addr = val;
30096 +      else
30097 +      {
30098 +       /* If no error ocurred, VAL is indeed negative.  */
30099 +       if (PyErr_Occurred () != NULL)
30100 +         return 0;
30101 +
30102 +       PyErr_SetString (PyExc_ValueError, "negative address");
30103 +       return 0;
30104 +      }
30105 +    }
30106 +  else
30107 +    {
30108 +      PyErr_SetString (PyExc_TypeError, "invalid type for address");
30109 +      return 0;
30110 +    }
30111 +
30112 +  return 1;
30113 +}
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
30121  
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
30125 +
30126  #define builtin_type_pybool \
30127    language_bool_type (current_language, current_gdbarch)
30128  
30129 @@ -143,10 +147,19 @@ valpy_address (PyObject *self, PyObject *args)
30130    return value_to_value_object (res_val);
30131  }
30132  
30133 -/* Return Unicode string with value contents (assumed to be encoded in the
30134 -   target's charset).  */
30135 +/* Return type of the value.  */
30136 +static PyObject *
30137 +valpy_type (PyObject *self, PyObject *args)
30138 +{
30139 +  struct value *value = ((value_object *) self)->value;
30140 +  return type_to_type_object (value_type (value));
30141 +}
30142 +
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.  */
30146  static PyObject *
30147 -valpy_string (PyObject *self, PyObject *args)
30148 +valpy_string (PyObject *self, PyObject *args, PyObject *kw)
30149  {
30150    int length, ret = 0;
30151    gdb_byte *buffer;
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" };
30157  
30158 -  if (!PyArg_ParseTuple (args, "|ss", &user_encoding, &errors))
30159 +  if (!PyArg_ParseTupleAndKeywords (args, kw, "|ss", keywords,
30160 +                                   &user_encoding, &errors))
30161      return NULL;
30162  
30163    TRY_CATCH (except, RETURN_MASK_ALL)
30164 @@ -174,6 +189,34 @@ valpy_string (PyObject *self, PyObject *args)
30165    return unicode;
30166  }
30167  
30168 +/* Cast a value to a given type.  */
30169 +static PyObject *
30170 +valpy_cast (PyObject *self, PyObject *args)
30171 +{
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;
30176 +
30177 +  if (! PyArg_ParseTuple (args, "O", &type_obj))
30178 +    return NULL;
30179 +
30180 +  type = type_object_to_type (type_obj);
30181 +  if (! type)
30182 +    {
30183 +      PyErr_SetString (PyExc_RuntimeError, "argument must be a Type");
30184 +      return NULL;
30185 +    }
30186 +
30187 +  TRY_CATCH (except, RETURN_MASK_ALL)
30188 +    {
30189 +      res_val = value_cast (type, ((value_object *) self)->value);
30190 +    }
30191 +  GDB_PY_HANDLE_EXCEPTION (except);
30192 +
30193 +  return value_to_value_object (res_val);
30194 +}
30195 +
30196  static Py_ssize_t
30197  valpy_length (PyObject *self)
30198  {
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);
30202        if (arg1 == NULL)
30203 -       return NULL;
30204 +       break;
30205  
30206        arg2 = convert_value_from_python (other);
30207        if (arg2 == NULL)
30208 -       return NULL;
30209 +       break;
30210  
30211        switch (opcode)
30212         {
30213 @@ -387,7 +430,7 @@ valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
30214      }
30215    GDB_PY_HANDLE_EXCEPTION (except);
30216  
30217 -  return value_to_value_object (res_val);
30218 +  return res_val ? value_to_value_object (res_val) : NULL;
30219  }
30220  
30221  static PyObject *
30222 @@ -718,6 +761,17 @@ value_to_value_object (struct value *val)
30223    return (PyObject *) val_obj;
30224  }
30225  
30226 +/* Returns value structure corresponding to the given value object.  */
30227 +struct value *
30228 +value_object_to_value (PyObject *self)
30229 +{
30230 +  value_object *real;
30231 +  if (! PyObject_TypeCheck (self, &value_object_type))
30232 +    return NULL;
30233 +  real = (value_object *) self;
30234 +  return real->value;
30235 +}
30236 +
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.  */
30239  
30240 @@ -751,7 +805,34 @@ convert_value_from_python (PyObject *obj)
30241         {
30242           LONGEST l = PyLong_AsLongLong (obj);
30243  
30244 -         if (! PyErr_Occurred ())
30245 +         if (PyErr_Occurred ())
30246 +           {
30247 +             /* If the error was an overflow, we can try converting to
30248 +                ULONGEST instead.  */
30249 +             if (PyErr_ExceptionMatches (PyExc_OverflowError))
30250 +               {
30251 +                 PyObject *etype, *evalue, *etraceback, *zero;
30252 +
30253 +                 PyErr_Fetch (&etype, &evalue, &etraceback);
30254 +                 zero = PyInt_FromLong (0);
30255 +
30256 +                 /* Check whether obj is positive.  */
30257 +                 if (PyObject_RichCompareBool (obj, zero, Py_GT) > 0)
30258 +                   {
30259 +                     ULONGEST ul;
30260 +
30261 +                     ul = PyLong_AsUnsignedLongLong (obj);
30262 +                     if (! PyErr_Occurred ())
30263 +                       value = value_from_ulongest (builtin_type_upylong, ul);
30264 +                   }
30265 +                 else
30266 +                   /* There's nothing we can do.  */
30267 +                   PyErr_Restore (etype, evalue, etraceback);
30268 +
30269 +                 Py_DECREF (zero);
30270 +               }
30271 +           }
30272 +         else
30273             value = value_from_longest (builtin_type_pylong, l);
30274         }
30275        else if (PyFloat_Check (obj))
30276 @@ -774,7 +855,7 @@ convert_value_from_python (PyObject *obj)
30277             }
30278         }
30279        else if (PyObject_TypeCheck (obj, &value_object_type))
30280 -       value = ((value_object *) obj)->value;
30281 +       value = value_copy (((value_object *) obj)->value);
30282        else
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);
30287  }
30288  
30289 +/* Returns 1 in OBJ is a gdb.Value object, 0 otherwise.  */
30290 +
30291 +int
30292 +gdbpy_is_value_object (PyObject *obj)
30293 +{
30294 +  return PyObject_TypeCheck (obj, &value_object_type);
30295 +}
30296 +
30297  void
30298  gdbpy_initialize_values (void)
30299  {
30300 @@ -822,11 +911,16 @@ gdbpy_initialize_values (void)
30301    values_in_python = NULL;
30302  }
30303  
30304 +\f
30305 +
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 */
30317  };
30318  
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
30323 @@ -22,6 +22,12 @@
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"
30333  
30334  #include <ctype.h>
30335  
30336 @@ -29,6 +35,10 @@
30337     false otherwise.  */
30338  static int gdbpy_should_print_stack = 1;
30339  
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;
30343 +
30344  #ifdef HAVE_PYTHON
30345  
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"
30350  #include "top.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"
30363 +
30364 +static PyMethodDef GdbMethods[];
30365  
30366  static PyMethodDef GdbMethods[];
30367  
30368  PyObject *gdb_module;
30369  
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;
30375  
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
30379     get_parameter.  */
30380  
30381 -static PyObject *
30382 -parameter_to_python (struct cmd_list_element *cmd)
30383 +PyObject *
30384 +gdbpy_parameter_value (enum var_types type, void *var)
30385  {
30386 -  switch (cmd->var_type)
30387 +  switch (type)
30388      {
30389      case var_string:
30390      case var_string_noescape:
30391 @@ -154,7 +177,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30392      case var_filename:
30393      case var_enum:
30394        {
30395 -       char *str = * (char **) cmd->var;
30396 +       char *str = * (char **) var;
30397         if (! str)
30398           str = "";
30399         return PyString_Decode (str, strlen (str), host_charset (), NULL);
30400 @@ -162,7 +185,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30401  
30402      case var_boolean:
30403        {
30404 -       if (* (int *) cmd->var)
30405 +       if (* (int *) var)
30406           Py_RETURN_TRUE;
30407         else
30408           Py_RETURN_FALSE;
30409 @@ -170,7 +193,7 @@ parameter_to_python (struct cmd_list_element *cmd)
30410  
30411      case var_auto_boolean:
30412        {
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)
30416           Py_RETURN_TRUE;
30417         else if (ab == AUTO_BOOLEAN_FALSE)
30418 @@ -180,15 +203,15 @@ parameter_to_python (struct cmd_list_element *cmd)
30419        }
30420  
30421      case var_integer:
30422 -      if ((* (int *) cmd->var) == INT_MAX)
30423 +      if ((* (int *) var) == INT_MAX)
30424         Py_RETURN_NONE;
30425        /* Fall through.  */
30426      case var_zinteger:
30427 -      return PyLong_FromLong (* (int *) cmd->var);
30428 +      return PyLong_FromLong (* (int *) var);
30429  
30430      case var_uinteger:
30431        {
30432 -       unsigned int val = * (unsigned int *) cmd->var;
30433 +       unsigned int val = * (unsigned int *) var;
30434         if (val == UINT_MAX)
30435           Py_RETURN_NONE;
30436         return PyLong_FromUnsignedLong (val);
30437 @@ -202,10 +225,11 @@ parameter_to_python (struct cmd_list_element *cmd)
30438     value.  */
30439  
30440  static PyObject *
30441 -get_parameter (PyObject *self, PyObject *args)
30442 +gdbpy_parameter (PyObject *self, PyObject *args)
30443  {
30444    struct cmd_list_element *alias, *prefix, *cmd;
30445    char *arg, *newarg;
30446 +  int found = -1;
30447    volatile struct gdb_exception except;
30448  
30449    if (! PyArg_ParseTuple (args, "s", &arg))
30450 @@ -215,19 +239,17 @@ get_parameter (PyObject *self, PyObject *args)
30451  
30452    TRY_CATCH (except, RETURN_MASK_ALL)
30453      {
30454 -      if (! lookup_cmd_composition (newarg, &alias, &prefix, &cmd))
30455 -       {
30456 -         xfree (newarg);
30457 -         return PyErr_Format (PyExc_RuntimeError,
30458 -                              "could not find variable `%s'", arg);
30459 -       }
30460 +      found = lookup_cmd_composition (newarg, &alias, &prefix, &cmd);
30461      }
30462    xfree (newarg);
30463    GDB_PY_HANDLE_EXCEPTION (except);
30464 +  if (!found)
30465 +    return PyErr_Format (PyExc_RuntimeError,
30466 +                        "could not find parameter `%s'", arg);
30467  
30468    if (! cmd->var)
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);
30473  }
30474  
30475  /* A Python function which evaluates a string using the gdb CLI.  */
30476 @@ -266,6 +288,570 @@ execute_gdb_command (PyObject *self, PyObject *args)
30477    Py_RETURN_NONE;
30478  }
30479  
30480 +/* Implementation of gdb.solib_address (Long) -> String.
30481 +   Returns the name of the shared library holding a given address, or None.  */
30482 +
30483 +static PyObject *
30484 +gdbpy_solib_address (PyObject *self, PyObject *args)
30485 +{
30486 +  unsigned long long pc;
30487 +  char *soname;
30488 +  PyObject *str_obj;
30489 +
30490 +  if (!PyArg_ParseTuple (args, "K", &pc))
30491 +    return NULL;
30492 +
30493 +  soname = solib_address (pc);
30494 +  if (soname)
30495 +    str_obj = PyString_Decode (soname, strlen (soname), host_charset (), NULL);
30496 +  else
30497 +    {
30498 +      str_obj = Py_None;
30499 +      Py_INCREF (Py_None);
30500 +    }
30501 +
30502 +  return str_obj;
30503 +}
30504 +
30505 +static PyObject *
30506 +gdbpy_find_pc_function (PyObject *self, PyObject *args)
30507 +{
30508 +  unsigned long long pc;
30509 +  struct symbol *sym;
30510 +  PyObject *sym_obj;
30511 +
30512 +  if (!PyArg_ParseTuple (args, "K", &pc))
30513 +    return NULL;
30514 +
30515 +  sym = find_pc_function (pc);
30516 +  if (sym)
30517 +    return symbol_to_symbol_object (sym);
30518 +
30519 +  Py_RETURN_NONE;
30520 +}
30521 +
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.  */
30526 +
30527 +static void
30528 +add_value_pattern (struct value *v, int size, char **pattern_buf,
30529 +                  char **pattern_buf_end, ULONGEST *pattern_buf_size)
30530 +{
30531 +  int val_bytes;
30532 +
30533 +  if (size)
30534 +    {
30535 +      LONGEST x = value_as_long (v);
30536 +
30537 +      if (size == 1)
30538 +       *(*pattern_buf_end)++ = x;
30539 +      else
30540 +       {
30541 +         put_bits (x, *pattern_buf_end, size * 8,
30542 +                   gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG);
30543 +         *pattern_buf_end += size;
30544 +       }
30545 +    }
30546 +  else
30547 +   {
30548 +     val_bytes = TYPE_LENGTH (value_type (v));
30549 +
30550 +     increase_pattern_buffer (pattern_buf, pattern_buf_end,
30551 +                             pattern_buf_size, val_bytes);
30552 +
30553 +     memcpy (*pattern_buf_end, value_contents_raw (v), val_bytes);
30554 +     *pattern_buf_end += val_bytes;
30555 +   }
30556 +}
30557 +
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.
30569 +
30570 +   Returns 1 on success or 0 on failure, with a Python exception set.  This
30571 +   function can also throw GDB exceptions.  */
30572 +
30573 +static int
30574 +add_pattern_element (PyObject *obj, int size, char **pattern_buf,
30575 +                    char **pattern_buf_end, ULONGEST *pattern_buf_size)
30576 +{
30577 +  if (PyObject_CheckReadBuffer (obj))
30578 +    {
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.  */
30582 +
30583 +      Py_ssize_t val_bytes;
30584 +      const void *buffer;
30585 +
30586 +      if (PyObject_AsReadBuffer (obj, &buffer, &val_bytes) == -1)
30587 +       return 0;
30588 +
30589 +      increase_pattern_buffer (pattern_buf, pattern_buf_end,
30590 +                              pattern_buf_size, val_bytes);
30591 +
30592 +      memcpy (*pattern_buf_end, buffer, val_bytes);
30593 +      *pattern_buf_end += val_bytes;
30594 +    }
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))
30599 +    {
30600 +      /* Handle lists and tuples.  */
30601 +
30602 +      Py_ssize_t i, num_objs;
30603 +
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))
30609 +         return 0;
30610 +    }
30611 +  else
30612 +    {
30613 +      /* See if we can convert from a Python object to a GDB value.  */
30614 +
30615 +      struct value *v = convert_value_from_python (obj);
30616 +
30617 +      if (v)
30618 +       add_value_pattern (v, size, pattern_buf, pattern_buf_end,
30619 +                          pattern_buf_size);
30620 +      else
30621 +       return 0;
30622 +    }
30623 +
30624 +  return 1;
30625 +}
30626 +
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.
30630 +
30631 +   Returns 1 on success or 0 on failure, with a Python exception set.  This
30632 +   function can also throw GDB exceptions.  */
30633 +
30634 +static int
30635 +get_search_pattern (PyObject *obj, int size, char **pattern_bufp,
30636 +                   ULONGEST *pattern_lenp)
30637 +{
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;
30646 +
30647 +  allocate_pattern_buffer (&pattern_buf, &pattern_buf_end, &pattern_buf_size);
30648 +  old_cleanups = make_cleanup (free_current_contents, &pattern_buf);
30649 +
30650 +  if (!add_pattern_element (obj, size, &pattern_buf, &pattern_buf_end,
30651 +                           &pattern_buf_size))
30652 +    {
30653 +      do_cleanups (old_cleanups);
30654 +
30655 +      return 0;
30656 +    }
30657 +
30658 +  *pattern_bufp = pattern_buf;
30659 +  *pattern_lenp = pattern_buf_end - pattern_buf;
30660 +
30661 +  discard_cleanups (old_cleanups);
30662 +
30663 +  return 1;
30664 +}
30665 +
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.  */
30671 +
30672 +PyObject *
30673 +gdbpy_search_memory (PyObject *self, PyObject *args, PyObject *kw)
30674 +{
30675 +  int size = 0;
30676 +  long length;
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;
30686 +
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))
30691 +    return NULL;
30692 +
30693 +  if (!max_count)
30694 +    max_count = LONG_MAX;
30695 +
30696 +  if (!length)
30697 +    {
30698 +      PyErr_SetString (PyExc_ValueError, "empty search range");
30699 +      return NULL;
30700 +    }
30701 +  else if (length < 0)
30702 +    {
30703 +      PyErr_SetString (PyExc_ValueError, "invalid search range");
30704 +      return NULL;
30705 +    }
30706 +  else
30707 +    {
30708 +      /* Watch for overflows.  */
30709 +      if (length > CORE_ADDR_MAX
30710 +         || (start_addr + length - 1) < start_addr)
30711 +       {
30712 +         PyErr_SetString (PyExc_ValueError, "search range too large");
30713 +         return NULL;
30714 +       }
30715 +
30716 +      search_space_len = length;
30717 +    }
30718 +
30719 +  if (size != 0 && size != 1 && size != 2 && size != 4 && size != 8)
30720 +    {
30721 +      PyErr_SetString (PyExc_ValueError, "invalid pattern size");
30722 +      return NULL;
30723 +    }
30724 +
30725 +  TRY_CATCH (except, RETURN_MASK_ALL)
30726 +    {
30727 +      if (get_addr_from_python (start_addr_obj, &start_addr))
30728 +       {
30729 +         if (get_search_pattern (pattern, size, &pattern_buf, &pattern_len))
30730 +           {
30731 +             /* Any cleanups get automatically executed on an exception.  */
30732 +             struct cleanup *cleanups = make_cleanup (xfree, pattern_buf);
30733 +
30734 +             list = PyList_New (0);
30735 +
30736 +             while (search_space_len >= pattern_len && found_count < max_count)
30737 +               {
30738 +                 CORE_ADDR found_addr;
30739 +                 int found;
30740 +
30741 +                 found = search_memory (&start_addr, &search_space_len,
30742 +                                        pattern_buf, pattern_len, &found_addr);
30743 +                 if (found <= 0)
30744 +                   break;
30745 +
30746 +                 PyList_Append (list, PyLong_FromUnsignedLong (found_addr));
30747 +                 ++found_count;
30748 +               }
30749 +
30750 +             do_cleanups (cleanups);
30751 +           }
30752 +       }
30753 +    }
30754 +  GDB_PY_HANDLE_EXCEPTION (except);
30755 +
30756 +  return list;
30757 +}
30758 +
30759 +/* A Python function which is a wrapper for decode_line_1.  */
30760 +
30761 +static PyObject *
30762 +gdbpy_decode_line (PyObject *self, PyObject *args)
30763 +{
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;
30770 +
30771 +  if (! PyArg_ParseTuple (args, "|s", &arg))
30772 +    return NULL;
30773 +
30774 +  TRY_CATCH (except, RETURN_MASK_ALL)
30775 +    {
30776 +      if (arg)
30777 +       {
30778 +         char *copy;
30779 +
30780 +         arg = strdup (arg);
30781 +         copy = arg;
30782 +
30783 +         sals = decode_line_1 (&copy, 0, 0, 0, 0, 0);
30784 +         free_sals = 1;
30785 +       }
30786 +      else
30787 +       {
30788 +         set_default_source_symtab_and_line ();
30789 +         sal = get_current_source_symtab_and_line ();
30790 +         sals.sals = &sal;
30791 +         sals.nelts = 1;
30792 +       }
30793 +    }
30794 +  if (arg)
30795 +    xfree (arg);
30796 +
30797 +  if (except.reason < 0)
30798 +    {
30799 +      if (free_sals)
30800 +       xfree (sals.sals);
30801 +      /* We know this will always throw.  */
30802 +      GDB_PY_HANDLE_EXCEPTION (except);
30803 +    }
30804 +
30805 +  if (sals.nelts)
30806 +    {
30807 +      result = PyTuple_New (sals.nelts);
30808 +      for (i = 0; i < sals.nelts; ++i)
30809 +       {
30810 +         PyObject *obj;
30811 +         char *str;
30812 +
30813 +         obj = symtab_and_line_to_sal_object (sals.sals[i]);
30814 +         if (! obj)
30815 +           {
30816 +             Py_DECREF (result);
30817 +             result = NULL;
30818 +             break;
30819 +           }
30820 +
30821 +         PyTuple_SetItem (result, i, obj);
30822 +       }
30823 +    }
30824 +
30825 +  if (free_sals)
30826 +    xfree (sals.sals);
30827 +
30828 +  if (result)
30829 +    return result;
30830 +  Py_RETURN_NONE;
30831 +}
30832 +
30833 +/* Parse a string and evaluate it as an expression.  */
30834 +static PyObject *
30835 +gdbpy_parse_and_eval (PyObject *self, PyObject *args)
30836 +{
30837 +  char *expr_str;
30838 +  struct value *result = NULL;
30839 +  volatile struct gdb_exception except;
30840 +
30841 +  if (!PyArg_ParseTuple (args, "s", &expr_str))
30842 +    return NULL;
30843 +
30844 +  TRY_CATCH (except, RETURN_MASK_ALL)
30845 +    {
30846 +      result = parse_and_eval (expr_str);
30847 +    }
30848 +  GDB_PY_HANDLE_EXCEPTION (except);
30849 +
30850 +  return value_to_value_object (result);
30851 +}
30852 +
30853 +\f
30854 +
30855 +/* Posting and handling events.  */
30856 +
30857 +/* A single event.  */
30858 +struct gdbpy_event
30859 +{
30860 +  /* The Python event.  This is just a callable object.  */
30861 +  PyObject *event;
30862 +  /* The next event.  */
30863 +  struct gdbpy_event *next;
30864 +};
30865 +
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;
30870 +
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];
30874 +
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.  */
30878 +static void
30879 +gdbpy_run_events (int err, gdb_client_data ignore)
30880 +{
30881 +  PyGILState_STATE state;
30882 +  char buffer[100];
30883 +  int r;
30884 +
30885 +  state = PyGILState_Ensure ();
30886 +
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));
30890 +
30891 +  while (gdbpy_event_list)
30892 +    {
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;
30899 +
30900 +      /* Ignore errors.  */
30901 +      PyObject_CallObject (item->event, NULL);
30902 +
30903 +      Py_DECREF (item->event);
30904 +      xfree (item);
30905 +    }
30906 +
30907 +  PyGILState_Release (state);
30908 +}
30909 +
30910 +/* Submit an event to the gdb thread.  */
30911 +static PyObject *
30912 +gdbpy_post_event (PyObject *self, PyObject *args)
30913 +{
30914 +  struct gdbpy_event *event;
30915 +  PyObject *func;
30916 +  int wakeup;
30917 +
30918 +  if (!PyArg_ParseTuple (args, "O", &func))
30919 +    return NULL;
30920 +
30921 +  if (!PyCallable_Check (func))
30922 +    {
30923 +      PyErr_SetString (PyExc_RuntimeError, "Posted event is not callable");
30924 +      return NULL;
30925 +    }
30926 +
30927 +  Py_INCREF (func);
30928 +
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;
30932 +
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;
30938 +
30939 +  /* Wake up gdb when needed.  */
30940 +  if (wakeup)
30941 +    {
30942 +      char c = 'q';            /* Anything. */
30943 +      if (write (gdbpy_event_fds[1], &c, 1) != 1)
30944 +        return PyErr_SetFromErrno (PyExc_IOError);
30945 +    }
30946 +
30947 +  Py_RETURN_NONE;
30948 +}
30949 +
30950 +/* Initialize the Python event handler.  */
30951 +static void
30952 +gdbpy_initialize_events (void)
30953 +{
30954 +  if (!pipe (gdbpy_event_fds))
30955 +    {
30956 +      gdbpy_event_list_end = &gdbpy_event_list;
30957 +      add_file_handler (gdbpy_event_fds[0], gdbpy_run_events, NULL);
30958 +    }
30959 +}
30960 +
30961 +\f
30962 +
30963 +/* Threads.  */
30964 +
30965 +/* Callback function for use with iterate_over_threads.  This function
30966 +   just counts the number of threads.  */
30967 +
30968 +static int
30969 +count_callback (struct thread_info *info, void *user_data)
30970 +{
30971 +  int *count = (int *) user_data;
30972 +  ++*count;
30973 +  return 0;
30974 +}
30975 +
30976 +/* Structure for storing some state when iterating over threads.  */
30977 +
30978 +struct set_thread_info
30979 +{
30980 +  PyObject *tuple;
30981 +  int index;
30982 +};
30983 +
30984 +/* Callback function for use with iterate_over_threads.  This function
30985 +   stores the thread ID into a Python tuple.  */
30986 +
30987 +static int
30988 +update_tuple_callback (struct thread_info *info, void *user_data)
30989 +{
30990 +  struct set_thread_info *tinfo = (struct set_thread_info *) user_data;
30991 +  PyTuple_SetItem (tinfo->tuple, tinfo->index, PyInt_FromLong (info->num));
30992 +  ++tinfo->index;
30993 +  return 0;
30994 +}
30995 +
30996 +/* Python function which yields a tuple holding all valid thread IDs.  */
30997 +
30998 +static PyObject *
30999 +gdbpy_threads (PyObject *unused1, PyObject *unused2)
31000 +{
31001 +  int thread_count = 0;
31002 +  struct set_thread_info info;
31003 +  PyObject *result;
31004 +
31005 +  prune_threads ();
31006 +  target_find_new_threads ();
31007 +
31008 +  iterate_over_threads (count_callback, &thread_count);
31009 +
31010 +  if (!thread_count)
31011 +    Py_RETURN_NONE;
31012 +
31013 +  result = PyTuple_New (thread_count);
31014 +  info.tuple = result;
31015 +  info.index = 0;
31016 +  iterate_over_threads (update_tuple_callback, &info);
31017 +  return result;
31018 +}
31019 +
31020 +/* Python function that returns the current thread's ID.  */
31021 +
31022 +static PyObject *
31023 +gdbpy_current_thread (PyObject *unused1, PyObject *unused2)
31024 +{
31025 +  if (PIDGET (inferior_ptid) == 0)
31026 +    Py_RETURN_NONE;
31027 +  return PyInt_FromLong (pid_to_thread_id (inferior_ptid));
31028 +}
31029 +
31030 +/* Python function for switching to a given thread.  */
31031 +
31032 +static PyObject *
31033 +gdbpy_switch_to_thread (PyObject *self, PyObject *args)
31034 +{
31035 +  int id;
31036 +  if (! PyArg_ParseTuple (args, "i", &id))
31037 +    return NULL;
31038 +  if (! valid_thread_id (id))
31039 +    return PyErr_Format (PyExc_RuntimeError, "invalid thread id");
31040 +  switch_to_thread (thread_id_to_pid (id));
31041 +  Py_RETURN_NONE;
31042 +}
31043 +
31044  \f
31045  
31046  /* Printing.  */
31047 @@ -302,6 +888,769 @@ gdbpy_print_stack (void)
31048      PyErr_Clear ();
31049  }
31050  
31051 +\f
31052 +
31053 +/* Script interface.  */
31054 +
31055 +/* True if 'gdb -P' was used, false otherwise.  */
31056 +static int running_python_script;
31057 +
31058 +/* True if we are currently in a call to 'gdb.cli', false otherwise.  */
31059 +static int in_cli;
31060 +
31061 +/* Enter the command loop.  */
31062 +
31063 +static PyObject *
31064 +gdbpy_cli (PyObject *unused1, PyObject *unused2)
31065 +{
31066 +  if (! running_python_script || in_cli)
31067 +    return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
31068 +
31069 +  in_cli = 1;
31070 +  cli_command_loop ();
31071 +  in_cli = 0;
31072 +
31073 +  Py_RETURN_NONE;
31074 +}
31075 +
31076 +/* Set up the Python argument vector and evaluate a script.  This is
31077 +   used to implement 'gdb -P'.  */
31078 +
31079 +void
31080 +run_python_script (int argc, char **argv)
31081 +{
31082 +  FILE *input;
31083 +  PyGILState_STATE state;
31084 +
31085 +  /* We never free this, since we plan to exit at the end.  */
31086 +  state = PyGILState_Ensure ();
31087 +
31088 +  running_python_script = 1;
31089 +  PySys_SetArgv (argc - 1, argv + 1);
31090 +  input = fopen (argv[0], "r");
31091 +  if (! input)
31092 +    {
31093 +      fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno));
31094 +      exit (1);
31095 +    }
31096 +  PyRun_SimpleFile (input, argv[0]);
31097 +  fclose (input);
31098 +  exit (0);
31099 +}
31100 +
31101 +void
31102 +source_python_script (FILE *stream, char *file)
31103 +{
31104 +  PyGILState_STATE state;
31105 +
31106 +  state = PyGILState_Ensure ();
31107 +
31108 +  PyRun_SimpleFile (stream, file);
31109 +
31110 +  fclose (stream);
31111 +  PyGILState_Release (state);
31112 +}
31113 +
31114 +\f
31115 +
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;
31120 +
31121 +/* The file name we attempt to read.  */
31122 +#define GDBPY_AUTO_FILENAME "-gdb.py"
31123 +
31124 +/* This is a new_objfile observer callback which loads python code
31125 +   based on the path to the objfile.  */
31126 +static void
31127 +gdbpy_new_objfile (struct objfile *objfile)
31128 +{
31129 +  char *realname;
31130 +  char *filename, *debugfile;
31131 +  int len;
31132 +  FILE *input;
31133 +  PyGILState_STATE state;
31134 +  struct cleanup *cleanups;
31135 +
31136 +  if (!gdbpy_auto_load || !objfile || !objfile->name)
31137 +    return;
31138 +
31139 +  state = PyGILState_Ensure ();
31140 +
31141 +  gdbpy_current_objfile = objfile;
31142 +
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);
31148 +
31149 +  input = fopen (filename, "r");
31150 +  debugfile = filename;
31151 +
31152 +  cleanups = make_cleanup (xfree, filename);
31153 +  make_cleanup (xfree, realname);
31154 +
31155 +  if (!input && debug_file_directory)
31156 +    {
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);
31163 +
31164 +      make_cleanup (xfree, debugfile);
31165 +      input = fopen (debugfile, "r");
31166 +    }
31167 +
31168 +  if (!input && gdb_datadir)
31169 +    {
31170 +      /* Also try the same file in a subdirectory of gdb's data
31171 +        directory.  */
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);
31178 +
31179 +      make_cleanup (xfree, debugfile);
31180 +      input = fopen (debugfile, "r");
31181 +    }
31182 +
31183 +  if (input)
31184 +    {
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 ();
31189 +      fclose (input);
31190 +    }
31191 +
31192 +  do_cleanups (cleanups);
31193 +  gdbpy_current_objfile = NULL;
31194 +
31195 +  PyGILState_Release (state);
31196 +}
31197 +
31198 +/* Return the current Objfile, or None if there isn't one.  */
31199 +static PyObject *
31200 +gdbpy_get_current_objfile (PyObject *unused1, PyObject *unused2)
31201 +{
31202 +  PyObject *result;
31203 +
31204 +  if (! gdbpy_current_objfile)
31205 +    Py_RETURN_NONE;
31206 +
31207 +  result = objfile_to_objfile_object (gdbpy_current_objfile);
31208 +  if (result)
31209 +    Py_INCREF (result);
31210 +  return result;
31211 +}
31212 +
31213 +/* Return a sequence holding all the Objfiles.  */
31214 +static PyObject *
31215 +gdbpy_objfiles (PyObject *unused1, PyObject *unused2)
31216 +{
31217 +  struct objfile *objf;
31218 +  PyObject *list;
31219 +
31220 +  list = PyList_New (0);
31221 +  if (!list)
31222 +    return NULL;
31223 +
31224 +  ALL_OBJFILES (objf)
31225 +  {
31226 +    PyObject *item = objfile_to_objfile_object (objf);
31227 +    if (!item || PyList_Append (list, item) == -1)
31228 +      {
31229 +       Py_DECREF (list);
31230 +       return NULL;
31231 +      }
31232 +  }
31233 +
31234 +  return list;
31235 +}
31236 +
31237 +\f
31238 +
31239 +/* Helper function for find_pretty_printer which iterates over a
31240 +   list, calls each function and inspects output.  */
31241 +static PyObject *
31242 +search_pp_list (PyObject *list, PyObject *value)
31243 +{
31244 +  Py_ssize_t pp_list_size, list_index;
31245 +  PyObject *function, *printer = NULL;
31246 +  
31247 +  pp_list_size = PyList_Size (list);
31248 +  for (list_index = 0; list_index < pp_list_size; list_index++)
31249 +    {
31250 +      function = PyList_GetItem (list, list_index);
31251 +      if (! function)
31252 +       return NULL;
31253 +
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);
31259 +      if (! printer)
31260 +       return NULL;
31261 +      else if (printer != Py_None)
31262 +       return printer;
31263 +
31264 +      Py_DECREF (printer);
31265 +    }
31266 +
31267 +  Py_RETURN_NONE;
31268 +}
31269 +
31270 +/* Find the pretty-printing constructor function for TYPE.  If no
31271 +   pretty-printer exists, return NULL.  If one exists, return a new
31272 +   reference.  */
31273 +static PyObject *
31274 +find_pretty_printer (PyObject *value)
31275 +{
31276 +  PyObject *pp_list = NULL;
31277 +  PyObject *function = NULL;
31278 +  struct objfile *obj;
31279 +  volatile struct gdb_exception except;
31280 +
31281 +  /* Look at the pretty-printer dictionary for each objfile.  */
31282 +  ALL_OBJFILES (obj)
31283 +  {
31284 +    PyObject *objf = objfile_to_objfile_object (obj);
31285 +    if (!objf)
31286 +      continue;
31287 +
31288 +    pp_list = objfpy_get_printers (objf, NULL);
31289 +    function = search_pp_list (pp_list, value);
31290 +
31291 +    /* If there is an error in any objfile list, abort the search and
31292 +       exit.  */
31293 +    if (! function)
31294 +      {
31295 +       Py_XDECREF (pp_list);
31296 +       return NULL;
31297 +      }
31298 +
31299 +    if (function != Py_None)
31300 +      goto done;
31301 +    
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);
31307 +  }
31308 +
31309 +  pp_list = NULL;
31310 +  /* Fetch the global pretty printer dictionary.  */
31311 +  if (! PyObject_HasAttrString (gdb_module, "pretty_printers"))
31312 +    goto done;
31313 +  pp_list = PyObject_GetAttrString (gdb_module, "pretty_printers");
31314 +  if (! pp_list)
31315 +    goto done;
31316 +  if (! PyList_Check (pp_list))
31317 +    goto done;
31318 +
31319 +  function = search_pp_list (pp_list, value);
31320 +
31321 + done:
31322 +  Py_XDECREF (pp_list);
31323 +  
31324 +  return function;
31325 +}
31326 +
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.  */
31332 +static char *
31333 +pretty_print_one_value (PyObject *printer, struct value **out_value)
31334 +{
31335 +  char *output = NULL;
31336 +  volatile struct gdb_exception except;
31337 +
31338 +  TRY_CATCH (except, RETURN_MASK_ALL)
31339 +    {
31340 +      PyObject *result;
31341 +
31342 +      result = PyObject_CallMethodObjArgs (printer, gdbpy_to_string_cst, NULL);
31343 +      if (result)
31344 +       {
31345 +         if (gdbpy_is_string (result))
31346 +           output = python_string_to_host_string (result);
31347 +         else if (PyObject_TypeCheck (result, &value_object_type))
31348 +           {
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);
31354 +           }
31355 +         else
31356 +           *out_value = convert_value_from_python (result);
31357 +         Py_DECREF (result);
31358 +       }
31359 +    }
31360 +
31361 +  return output;
31362 +}
31363 +
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 */
31367 +PyObject *
31368 +gdbpy_instantiate_printer (PyObject *cons, PyObject *value)
31369 +{
31370 +  PyObject *result;
31371 +  result = PyObject_CallFunctionObjArgs (cons, value, NULL);
31372 +  return result;
31373 +}
31374 +
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.  */
31379 +char *
31380 +gdbpy_get_display_hint (PyObject *printer)
31381 +{
31382 +  PyObject *hint;
31383 +  char *result = NULL;
31384 +
31385 +  if (! PyObject_HasAttr (printer, gdbpy_display_hint_cst))
31386 +    return NULL;
31387 +
31388 +  hint = PyObject_CallMethodObjArgs (printer, gdbpy_display_hint_cst, NULL);
31389 +  if (gdbpy_is_string (hint))
31390 +    result = python_string_to_host_string (hint);
31391 +  if (hint)
31392 +    Py_DECREF (hint);
31393 +  else
31394 +    gdbpy_print_stack ();
31395 +
31396 +  return result;
31397 +}
31398 +
31399 +/* Helper for apply_val_pretty_printer which calls to_string and
31400 +   formats the result.  */
31401 +static void
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)
31406 +{
31407 +  char *output;
31408 +  struct value *replacement = NULL;
31409 +
31410 +  output = pretty_print_one_value (printer, &replacement);
31411 +  if (output)
31412 +    {
31413 +      if (hint && !strcmp (hint, "string"))
31414 +       {
31415 +         struct type *string_char_type;
31416 +
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);
31422 +       }
31423 +      else
31424 +       fputs_filtered (output, stream);
31425 +      xfree (output);
31426 +    }
31427 +  else if (replacement)
31428 +    common_val_print (replacement, stream, recurse, options, language);
31429 +  else
31430 +    gdbpy_print_stack ();
31431 +}
31432 +
31433 +static void
31434 +py_restore_tstate (void *p)
31435 +{
31436 +  PyFrameObject *frame = p;
31437 +  PyThreadState *tstate = PyThreadState_GET ();
31438 +  tstate->frame = frame;
31439 +}
31440 +
31441 +/* Create a dummy PyFrameObject, needed to work around
31442 +   a Python-2.4 bug with generators.  */
31443 +static PyObject *
31444 +push_dummy_python_frame ()
31445 +{
31446 +  PyObject *empty_string, *null_tuple, *globals;
31447 +  PyCodeObject *code;
31448 +  PyFrameObject *frame;
31449 +  PyThreadState *tstate;
31450 +
31451 +  empty_string = PyString_FromString ("");
31452 +  if (!empty_string)
31453 +    return NULL;
31454 +
31455 +  null_tuple = PyTuple_New (0);
31456 +  if (!null_tuple)
31457 +    {
31458 +      Py_DECREF (empty_string);
31459 +      return NULL;
31460 +    }
31461 +
31462 +  code = PyCode_New (0,                        /* argcount */
31463 +                    0,                 /* nlocals */
31464 +                    0,                 /* stacksize */
31465 +                    0,                 /* flags */
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 */
31473 +#endif
31474 +                    empty_string,      /* filename */
31475 +                    empty_string,      /* name */
31476 +                    1,                 /* firstlineno */
31477 +                    empty_string       /* lnotab */
31478 +                   );
31479 +
31480 +  Py_DECREF (empty_string);
31481 +  Py_DECREF (null_tuple);
31482 +
31483 +  if (!code)
31484 +    return NULL;
31485 +
31486 +  globals = PyDict_New ();
31487 +  if (!globals)
31488 +    {
31489 +      Py_DECREF (code);
31490 +      return NULL;
31491 +    }
31492 +
31493 +  tstate = PyThreadState_GET ();
31494 +
31495 +  frame = PyFrame_New (tstate, code, globals, NULL);
31496 +
31497 +  Py_DECREF (globals);
31498 +  Py_DECREF (code);
31499 +
31500 +  if (!frame)
31501 +    return NULL;
31502 +
31503 +  tstate->frame = frame;
31504 +  make_cleanup (py_restore_tstate, frame->f_back);
31505 +  return (PyObject *) frame;
31506 +}
31507 +
31508 +/* Helper for apply_val_pretty_printer that formats children of the
31509 +   printer, if any exist.  */
31510 +static void
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)
31515 +{
31516 +  int is_map, is_array, done_flag, pretty;
31517 +  unsigned int i;
31518 +  PyObject *children, *iter, *frame;
31519 +  struct cleanup *cleanups;
31520 +
31521 +  if (! PyObject_HasAttr (printer, gdbpy_children_cst))
31522 +    return;
31523 +
31524 +  /* If we are printing a map or an array, we want some special
31525 +     formatting.  */
31526 +  is_map = hint && ! strcmp (hint, "map");
31527 +  is_array = hint && ! strcmp (hint, "array");
31528 +
31529 +  children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
31530 +                                        NULL);
31531 +  if (! children)
31532 +    {
31533 +      gdbpy_print_stack ();
31534 +      return;
31535 +    }
31536 +
31537 +  cleanups = make_cleanup_py_decref (children);
31538 +
31539 +  iter = PyObject_GetIter (children);
31540 +  if (!iter)
31541 +    {
31542 +      gdbpy_print_stack ();
31543 +      goto done;
31544 +    }
31545 +  make_cleanup_py_decref (iter);
31546 +
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;
31550 +
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 ();
31555 +  if (!frame)
31556 +    {
31557 +      gdbpy_print_stack ();
31558 +      goto done;
31559 +    }
31560 +  make_cleanup_py_decref (frame);
31561 +
31562 +  done_flag = 0;
31563 +  for (i = 0; i < options->print_max; ++i)
31564 +    {
31565 +      PyObject *py_v, *item = PyIter_Next (iter);
31566 +      char *name;
31567 +      struct cleanup *inner_cleanup;
31568 +
31569 +      if (! item)
31570 +       {
31571 +         if (PyErr_Occurred ())
31572 +           gdbpy_print_stack ();
31573 +         /* Set a flag so we can know whether we printed all the
31574 +            available elements.  */
31575 +         else    
31576 +           done_flag = 1;
31577 +         break;
31578 +       }
31579 +
31580 +      if (! PyArg_ParseTuple (item, "sO", &name, &py_v))
31581 +       {
31582 +         gdbpy_print_stack ();
31583 +         Py_DECREF (item);
31584 +         continue;
31585 +       }
31586 +      inner_cleanup = make_cleanup_py_decref (item);
31587 +
31588 +      /* Print initial "{".  For other elements, there are three
31589 +        cases:
31590 +        1. Maps.  Print a "," after each value element.
31591 +        2. Arrays.  Always print a ",".
31592 +        3. Other.  Always print a ",".  */
31593 +      if (i == 0)
31594 +       fputs_filtered (" = {", stream);
31595 +      else if (! is_map || i % 2 == 0)
31596 +       fputs_filtered (pretty ? "," : ", ", stream);
31597 +
31598 +      /* In summary mode, we just want to print "= {...}" if there is
31599 +        a value.  */
31600 +      if (options->summary)
31601 +       {
31602 +         /* This increment tricks the post-loop logic to print what
31603 +            we want.  */
31604 +         ++i;
31605 +         /* Likewise.  */
31606 +         pretty = 0;
31607 +         break;
31608 +       }
31609 +
31610 +      if (! is_map || i % 2 == 0)
31611 +       {
31612 +         if (pretty)
31613 +           {
31614 +             fputs_filtered ("\n", stream);
31615 +             print_spaces_filtered (2 + 2 * recurse, stream);
31616 +           }
31617 +         else
31618 +           wrap_here (n_spaces (2 + 2 *recurse));
31619 +       }
31620 +
31621 +      if (is_map && i % 2 == 0)
31622 +       fputs_filtered ("[", stream);
31623 +      else if (is_array)
31624 +       {
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);
31629 +       }
31630 +      else if (! is_map)
31631 +       {
31632 +         fputs_filtered (name, stream);
31633 +         fputs_filtered (" = ", stream);
31634 +       }
31635 +
31636 +      if (gdbpy_is_string (py_v))
31637 +       {
31638 +         char *text = python_string_to_host_string (py_v);
31639 +         if (! text)
31640 +           gdbpy_print_stack ();
31641 +         else
31642 +           {
31643 +             fputs_filtered (text, stream);
31644 +             xfree (text);
31645 +           }
31646 +       }
31647 +      else
31648 +       {
31649 +         struct value *value = convert_value_from_python (py_v);
31650 +
31651 +         if (value == NULL)
31652 +           {
31653 +             gdbpy_print_stack ();
31654 +             error (_("Error while executing Python code."));
31655 +           }
31656 +         else
31657 +           common_val_print (value, stream, recurse + 1, options, language);
31658 +       }
31659 +
31660 +      if (is_map && i % 2 == 0)
31661 +       fputs_filtered ("] = ", stream);
31662 +
31663 +      do_cleanups (inner_cleanup);
31664 +    }
31665 +
31666 +  if (i)
31667 +    {
31668 +      if (!done_flag)
31669 +       {
31670 +         if (pretty)
31671 +           {
31672 +             fputs_filtered ("\n", stream);
31673 +             print_spaces_filtered (2 + 2 * recurse, stream);
31674 +           }
31675 +         fputs_filtered ("...", stream);
31676 +       }
31677 +      if (pretty)
31678 +       {
31679 +         fputs_filtered ("\n", stream);
31680 +         print_spaces_filtered (2 * recurse, stream);
31681 +       }
31682 +      fputs_filtered ("}", stream);
31683 +    }
31684 +
31685 + done:
31686 +  do_cleanups (cleanups);
31687 +}
31688 +
31689 +int
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)
31695 +{
31696 +  PyObject *printer = NULL;
31697 +  PyObject *val_obj = NULL;
31698 +  struct value *value;
31699 +  char *hint = NULL;
31700 +  struct cleanup *cleanups;
31701 +  int result = 0;
31702 +  PyGILState_STATE state;
31703 +
31704 +  state = PyGILState_Ensure ();
31705 +  cleanups = make_cleanup_py_restore_gil (&state);
31706 +
31707 +  /* Instantiate the printer.  */
31708 +  if (valaddr)
31709 +    valaddr += embedded_offset;
31710 +  value = value_from_contents_and_address (type, valaddr, address);
31711 +
31712 +  val_obj = value_to_value_object (value);
31713 +  if (! val_obj)
31714 +    goto done;
31715 +  
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)
31721 +    goto done;
31722 +
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);
31726 +
31727 +  /* Print the section */
31728 +  print_string_repr (printer, hint, stream, recurse, options, language);
31729 +  print_children (printer, hint, stream, recurse, options, language);
31730 +  result = 1;
31731 +
31732 +
31733 + done:
31734 +  if (PyErr_Occurred ())
31735 +    gdbpy_print_stack ();
31736 +  do_cleanups (cleanups);
31737 +  return result;
31738 +}
31739 +
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.  */
31748 +char *
31749 +apply_varobj_pretty_printer (PyObject *printer_obj,
31750 +                            struct value **replacement)
31751 +{
31752 +  char *result;
31753 +  PyGILState_STATE state = PyGILState_Ensure ();
31754 +
31755 +  *replacement = NULL;
31756 +  result = pretty_print_one_value (printer_obj, replacement);
31757 +  if (result == NULL);
31758 +    gdbpy_print_stack ();
31759 +  PyGILState_Release (state);
31760 +
31761 +  return result;
31762 +}
31763 +
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.  */
31768 +PyObject *
31769 +gdbpy_get_varobj_pretty_printer (struct value *value)
31770 +{
31771 +  PyObject *val_obj;
31772 +  PyObject *pretty_printer = NULL;
31773 +  volatile struct gdb_exception except;
31774 +
31775 +  TRY_CATCH (except, RETURN_MASK_ALL)
31776 +    {
31777 +      value = value_copy (value);
31778 +    }
31779 +  GDB_PY_HANDLE_EXCEPTION (except);
31780 +  
31781 +  val_obj = value_to_value_object (value);
31782 +  if (! val_obj)
31783 +    return NULL;
31784 +
31785 +  pretty_printer = find_pretty_printer (val_obj);
31786 +  Py_DECREF (val_obj);
31787 +  return pretty_printer;
31788 +}
31789 +
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.  */
31794 +static PyObject *
31795 +gdbpy_default_visualizer (PyObject *self, PyObject *args)
31796 +{
31797 +  PyObject *val_obj;
31798 +  PyObject *cons, *printer = NULL;
31799 +  struct value *value;
31800 +
31801 +  if (! PyArg_ParseTuple (args, "O", &val_obj))
31802 +    return NULL;
31803 +  value = value_object_to_value (val_obj);
31804 +  if (! value)
31805 +    {
31806 +      PyErr_SetString (PyExc_TypeError, "argument must be a gdb.Value");
31807 +      return NULL;
31808 +    }
31809 +
31810 +  cons = find_pretty_printer (val_obj);
31811 +  return cons;
31812 +}
31813 +
31814  #else /* HAVE_PYTHON */
31815  
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."));
31819  }
31820  
31821 +int
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)
31828 +{
31829 +  return 0;
31830 +}
31831 +
31832 +void
31833 +source_python_script (FILE *stream)
31834 +{
31835 +  fclose (stream);
31836 +  error (_("Python scripting is not supported in this copy of GDB."));
31837 +}
31838 +
31839  #endif /* HAVE_PYTHON */
31840  
31841  \f
31842 @@ -355,9 +1722,6 @@ show_python (char *args, int from_tty)
31843  
31844  /* Initialize the Python code.  */
31845  
31846 -/* Provide a prototype to silence -Wmissing-prototypes.  */
31847 -extern initialize_file_ftype _initialize_python;
31848 -
31849  void
31850  _initialize_python (void)
31851  {
31852 @@ -400,6 +1764,15 @@ Enables or disables printing of Python stack traces."),
31853                            &set_python_list,
31854                            &show_python_list);
31855  
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."),
31861 +                          NULL, NULL,
31862 +                          &set_python_list,
31863 +                          &show_python_list);
31864 +
31865  #ifdef HAVE_PYTHON
31866    Py_Initialize ();
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);
31872 +#ifdef PYTHONDIR
31873 +  PyModule_AddStringConstant (gdb_module, "pythondir", PYTHONDIR);
31874 +#else
31875 +  if (gdb_datadir)
31876 +    PyModule_AddStringConstant (gdb_module, "datadir", gdb_datadir);
31877 +#endif
31878  
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 ();
31892  
31893    PyRun_SimpleString ("import gdb");
31894 +  PyRun_SimpleString ("gdb.pretty_printers = []");
31895 +
31896 +  observer_attach_new_objfile (gdbpy_new_objfile);
31897 +
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__");
31902  
31903    gdbpy_doc_cst = PyString_FromString ("__doc__");
31904  
31905 @@ -442,6 +1840,15 @@ class GdbOutputFile:\n\
31906  \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\
31918  ");
31919  
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" },
31930  
31931 +  { "breakpoints", gdbpy_breakpoints, METH_NOARGS,
31932 +    "Return a tuple of all breakpoint objects" },
31933 +
31934 +  { "default_visualizer", gdbpy_default_visualizer, METH_VARARGS,
31935 +    "Find the default visualizer for a Value." },
31936 +
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." },
31941 +
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." },
31954 +
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." },
31964 +
31965 +  { "find_pc_function", gdbpy_find_pc_function, METH_VARARGS,
31966 +    "Return the function containing the given pc value, or None." },
31967 +
31968 +  { "block_for_pc", gdbpy_block_for_pc, METH_VARARGS,
31969 +    "Return the block containing the given pc value, or None." },
31970 +
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." },
31975 +
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." },
31982 +
31983 +  { "parse_and_eval", gdbpy_parse_and_eval, METH_VARARGS,
31984 +    "Parse a string as an expression, evaluate it, and return the result." },
31985 +
31986 +  { "post_event", gdbpy_post_event, METH_VARARGS,
31987 +    "Post an event into gdb's event loop." },
31988 +
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." },
31998 +
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;
32007  
32008  void eval_python_from_control_command (struct command_line *);
32009  
32010 +void source_python_script (FILE *stream, char *file);
32011 +
32012 +void run_python_script (int argc, char **argv);
32013 +
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);
32019 +
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;
32027  
32028  void
32029 -scm_printchar (int c, struct ui_file *stream)
32030 +scm_printchar (int c, struct type *type, struct ui_file *stream)
32031  {
32032    fprintf_filtered (stream, "#\\%c", c);
32033  }
32034  
32035  static void
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)
32041  {
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,
32048  
32049  extern int is_scmvalue_type (struct type *);
32050  
32051 -extern void scm_printchar (int, struct ui_file *);
32052 +extern void scm_printchar (int, struct type *, struct ui_file *);
32053  
32054  extern struct value *scm_evaluate_string (char *, int);
32055  
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))
32062         {
32063           svalue = SCM_ICHR (svalue);
32064 -         scm_printchar (svalue, stream);
32065 +         scm_printchar (svalue, builtin_type (current_gdbarch)->builtin_char,
32066 +                        stream);
32067           break;
32068         }
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)
32075  
32076    if (typenums[0] == -1)
32077      {
32078 -      return (alloc_type (objfile));
32079 +      return (alloc_type (objfile, NULL));
32080      }
32081  
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)
32086      {
32087 -      *type_addr = alloc_type (objfile);
32088 +      *type_addr = alloc_type (objfile, NULL);
32089      }
32090  
32091    return (*type_addr);
32092 @@ -589,6 +589,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
32093    int deftype;
32094    int synonym = 0;
32095    int i;
32096 +  char *new_name = NULL;
32097  
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,
32101      {
32102      normal:
32103        SYMBOL_LANGUAGE (sym) = current_subfile->language;
32104 -      SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32105 +      if (current_subfile->language == language_cplus)
32106 +       {
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);
32111 +       }
32112 +
32113 +      if (new_name != NULL)
32114 +       {
32115 +         SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
32116 +         xfree (new_name);
32117 +       }
32118 +      else
32119 +       SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32120 +
32121        if (SYMBOL_LANGUAGE (sym) == language_cplus)
32122 -       cp_scan_for_anonymous_namespaces (sym);
32123 +       {
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);
32129 +       }
32130 +      if (new_name != NULL)
32131 +       {
32132 +         SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
32133 +         xfree (new_name);
32134 +       }
32135 +      else
32136 +       SYMBOL_SET_NAMES (sym, string, p - string, objfile);
32137      }
32138    p++;
32139  
32140 @@ -1519,18 +1548,35 @@ again:
32141               if (*p != ':')
32142                 return error_type (pp, objfile);
32143             }
32144 -         to = type_name =
32145 -           (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
32146 -
32147 -         /* Copy the name.  */
32148 -         from = *pp + 1;
32149 -         while (from < p)
32150 -           *to++ = *from++;
32151 -         *to = '\0';
32152 +         type_name = NULL;
32153 +         if (current_subfile->language == language_cplus)
32154 +           {
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)
32160 +               {
32161 +                 type_name = obsavestring (new_name, strlen (new_name),
32162 +                                           &objfile->objfile_obstack);
32163 +                 xfree (new_name);
32164 +               }
32165 +           }
32166 +         if (type_name == NULL)
32167 +           {
32168 +             to = type_name =
32169 +               (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
32170 +
32171 +             /* Copy the name.  */
32172 +             from = *pp + 1;
32173 +             while (from < p)
32174 +               *to++ = *from++;
32175 +             *to = '\0';
32176 +           }
32177  
32178           /* Set the pointer ahead of the name which we just read, and
32179              the colon.  */
32180 -         *pp = from + 1;
32181 +         *pp = p + 1;
32182         }
32183  
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
32187 --- a/gdb/stack.c
32188 +++ b/gdb/stack.c
32189 @@ -380,6 +380,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
32190  
32191                   get_raw_print_options (&opts);
32192                   opts.deref_ref = 0;
32193 +                 opts.summary = 1;
32194                   common_val_print (val, stb->stream, 2,
32195                                     &opts, language);
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);
32199  }
32200  
32201 -static void
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
32206 +   to FRAME.  */
32207 +void
32208 +find_frame_funname (struct frame_info *frame, char **funname,
32209 +                   enum language *funlang)
32210  {
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;
32217  
32218 -  stb = ui_out_stream_new (uiout);
32219 -  old_chain = make_cleanup_ui_out_stream_delete (stb);
32220 +  *funname = NULL;
32221 +  *funlang = language_unknown;
32222  
32223    func = find_pc_function (get_frame_address_in_block (frame));
32224    if (func)
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.  */
32228           func = 0;
32229 -         funname = SYMBOL_PRINT_NAME (msymbol);
32230 -         funlang = SYMBOL_LANGUAGE (msymbol);
32231 +         *funname = SYMBOL_PRINT_NAME (msymbol);
32232 +         *funlang = SYMBOL_LANGUAGE (msymbol);
32233         }
32234        else
32235         {
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)
32242             {
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);
32250               if (func_only)
32251                 {
32252 -                 funname = func_only;
32253 +                 *funname = func_only;
32254                   make_cleanup (xfree, func_only);
32255                 }
32256             }
32257 @@ -655,10 +652,27 @@ print_frame (struct frame_info *frame, int print_level,
32258  
32259        if (msymbol != NULL)
32260         {
32261 -         funname = SYMBOL_PRINT_NAME (msymbol);
32262 -         funlang = SYMBOL_LANGUAGE (msymbol);
32263 +         *funname = SYMBOL_PRINT_NAME (msymbol);
32264 +         *funlang = SYMBOL_LANGUAGE (msymbol);
32265         }
32266      }
32267 +}
32268 +
32269 +static void
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)
32273 +{
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;
32279 +
32280 +  stb = ui_out_stream_new (uiout);
32281 +  old_chain = make_cleanup_ui_out_stream_delete (stb);
32282 +
32283 +  find_frame_funname (frame, &funname, &funlang);
32284  
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)
32297    else
32298      count = -1;
32299  
32300 -  if (info_verbose)
32301 -    {
32302 -      struct partial_symtab *ps;
32303 -
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.  */
32309 -      i = count;
32310 -      for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi))
32311 -       {
32312 -         QUIT;
32313 -         ps = find_pc_psymtab (get_frame_address_in_block (fi));
32314 -         if (ps)
32315 -           PSYMTAB_TO_SYMTAB (ps); /* Force syms to come in.  */
32316 -       }
32317 -    }
32318 +  {
32319 +    struct partial_symtab *ps;
32320 +
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.  */
32327 +    i = count;
32328 +    for (fi = trailing; fi != NULL && i--; fi = get_prev_frame (fi))
32329 +      {
32330 +       QUIT;
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.  */
32334 +      }
32335 +  }
32336  
32337    for (i = 0, fi = trailing; fi && count--; i++, fi = get_prev_frame (fi))
32338      {
32339 @@ -1373,6 +1387,8 @@ print_block_frame_locals (struct block *b, struct frame_info *frame,
32340         case LOC_COMPUTED:
32341           if (SYMBOL_IS_ARGUMENT (sym))
32342             break;
32343 +         if (SYMBOL_DOMAIN (sym) == COMMON_BLOCK_DOMAIN)
32344 +           break;
32345           values_printed = 1;
32346           print_variable_and_value (NULL, sym, frame, stream, 4 * num_tabs);
32347           break;
32348 @@ -1796,18 +1812,27 @@ return_command (char *retval_exp, int from_tty)
32349       message.  */
32350    if (retval_exp)
32351      {
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;
32355  
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);
32360  
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;
32367 +       {
32368 +         if (retval_expr->elts[0].opcode != UNOP_CAST)
32369 +           error (_("Return value type not available for selected "
32370 +                    "stack frame.\n"
32371 +                    "Please use an explicit cast of the value to return."));
32372 +         return_type = value_type (return_value);
32373 +       }
32374 +      do_cleanups (old_chain);
32375        CHECK_TYPEDEF (return_type);
32376        return_value = value_cast (return_type, return_value);
32377  
32378 diff --git a/gdb/stack.h b/gdb/stack.h
32379 index 973a57f..56b1d91 100644
32380 --- a/gdb/stack.h
32381 +++ b/gdb/stack.h
32382 @@ -22,4 +22,9 @@
32383  
32384  void select_frame_command (char *level_exp, int from_tty);
32385  
32386 +/* Attempt to obtain the FUNNAME and FUNLANG of the function corresponding
32387 +   to FRAME.  */
32388 +void find_frame_funname (struct frame_info *frame, char **funname,
32389 +                        enum language *funlang);
32390 +
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);
32398  }
32399  
32400 +/* A helper function which returns true if OBJFILE has any debug
32401 +   symbols, and false otherwise.  */
32402 +static int
32403 +has_any_debug_symbols (struct objfile *objfile)
32404 +{
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)));
32409 +}
32410 +
32411  /* Process a symbol file, as either the main file or as a dynamically
32412     loaded file.
32413  
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.  */
32417  
32418 -  if ((have_full_symbols () || have_partial_symbols ())
32419 -      && mainline
32420 +  if (mainline
32421        && from_tty
32422 +      && (have_full_symbols () || have_partial_symbols ())
32423        && !query (_("Load new symbol table from \"%s\"? "), name))
32424      error (_("Not confirmed."));
32425  
32426    objfile = allocate_objfile (abfd, flags);
32427 +  if (mainline)
32428 +    objfile->flags |= OBJF_MAIN;
32429    discard_cleanups (my_cleanups);
32430  
32431    if (addrs)
32432 @@ -1007,6 +1020,8 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32433  
32434    if ((flags & OBJF_READNOW) || readnow_symbol_files)
32435      {
32436 +      require_partial_symbols (objfile);
32437 +
32438        if ((from_tty || info_verbose) && print_symbol_loading)
32439         {
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);
32448    if (debugfile)
32449      {
32450 @@ -1049,8 +1064,10 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd, int from_tty,
32451        xfree (debugfile);
32452      }
32453  
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)
32460      {
32461        wrap_here ("");
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))
32469                 {
32470                   wrap_here ("");
32471                   printf_unfiltered (_("(no debugging symbols found)\n"));
32472                   wrap_here ("");
32473                 }
32474  
32475 +             objfile->flags &= ~OBJF_SYMTABS_READ;
32476 +
32477               /* We're done reading the symbol file; finish off complaints.  */
32478               clear_complaints (&symfile_complaints, 0, 1);
32479  
32480 @@ -2726,7 +2745,7 @@ allocate_symtab (char *filename, struct objfile *objfile)
32481  }
32482  
32483  struct partial_symtab *
32484 -allocate_psymtab (char *filename, struct objfile *objfile)
32485 +allocate_psymtab (const char *filename, struct objfile *objfile)
32486  {
32487    struct partial_symtab *psymtab;
32488  
32489 @@ -3040,7 +3059,8 @@ again2:
32490  
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)
32498  {
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
32504  
32505    void (*sym_read) (struct objfile *, int);
32506  
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
32509 +     symbols.  */
32510 +
32511 +  void (*sym_read_psymbols) (struct objfile *);
32512 +
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 *);
32517  
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 **);
32524  
32525 @@ -300,7 +306,7 @@ extern int auto_solib_limit;
32526  
32527  extern void set_initial_language (void);
32528  
32529 -extern struct partial_symtab *allocate_psymtab (char *, struct objfile *);
32530 +extern struct partial_symtab *allocate_psymtab (const char *, struct objfile *);
32531  
32532  extern void discard_psymtab (struct partial_symtab *);
32533  
32534 @@ -369,7 +375,7 @@ void free_symfile_segment_data (struct symfile_segment_data *data);
32535  /* From dwarf2read.c */
32536  
32537  extern int dwarf2_has_info (struct objfile *);
32538 -
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 *);
32542  
32543 diff --git a/gdb/symtab.c b/gdb/symtab.c
32544 index d2ba1f3..b4da8c1 100644
32545 --- a/gdb/symtab.c
32546 +++ b/gdb/symtab.c
32547 @@ -42,6 +42,7 @@
32548  #include "ada-lang.h"
32549  #include "p-lang.h"
32550  #include "addrmap.h"
32551 +#include "cp-support.h"
32552  
32553  #include "hashtab.h"
32554  
32555 @@ -55,6 +56,7 @@
32556  #include "gdb_stat.h"
32557  #include <ctype.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);
32565      }
32566  
32567 -  ALL_PSYMTABS (objfile, pst)
32568 +  ALL_PSYMTABS_REQUIRED (objfile, pst)
32569    {
32570      if (FILENAME_CMP (name, pst->filename) == 0)
32571        {
32572 @@ -870,7 +872,13 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
32573       than the later used TEXTLOW/TEXTHIGH one.  */
32574  
32575    ALL_OBJFILES (objfile)
32576 -    if (objfile->psymtabs_addrmap != NULL)
32577 +  {
32578 +    if (objfile->quick_addrmap)
32579 +      {
32580 +       if (!addrmap_find (objfile->quick_addrmap, pc))
32581 +         continue;
32582 +      }
32583 +    if (require_partial_symbols (objfile)->psymtabs_addrmap != NULL)
32584        {
32585         struct partial_symtab *pst;
32586  
32587 @@ -903,6 +911,7 @@ find_pc_sect_psymtab (CORE_ADDR pc, struct obj_section *section)
32588             return pst;
32589           }
32590        }
32591 +  }
32592  
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)
32596    return psym;
32597  }
32598  
32599 +/* Ensure that the partial symbols for OBJFILE have been loaded.  This
32600 +   function always returns its argument, as a convenience.  */
32601 +
32602 +struct objfile *
32603 +require_partial_symbols (struct objfile *objfile)
32604 +{
32605 +  if ((objfile->flags & OBJF_SYMTABS_READ) == 0)
32606 +    {
32607 +      objfile->flags |= OBJF_SYMTABS_READ;
32608 +
32609 +      if (objfile->sf->sym_read_psymbols)
32610 +       (*objfile->sf->sym_read_psymbols) (objfile);
32611 +    }
32612 +  return objfile;
32613 +}
32614 +
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;
32621  
32622 +  if(strncmp(name, "::", 2) == 0){/* this must be a global name */
32623 +    name = name+2;
32624 +    block = NULL;
32625 +  }
32626 +  
32627    modified_name = name;
32628  
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;
32633         }
32634 +      else
32635 +       {
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)
32640 +           {
32641 +             modified_name = demangled_name;
32642 +             needtofreename = 1;
32643 +           }
32644 +       }
32645      }
32646    else if (lang == language_java)
32647      {
32648 @@ -1296,13 +1337,15 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
32649        && block != NULL)
32650      {
32651        struct symbol *sym = NULL;
32652 +      const struct block *function_block = block;
32653 +
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));
32660  
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,
32665                                    NULL, VAR_DOMAIN);
32666        if (sym)
32667         {
32668 @@ -1361,22 +1404,24 @@ lookup_symbol_aux_local (const char *name, const char *linkage_name,
32669                          const domain_enum domain)
32670  {
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;
32675  
32676    /* Check if either no block is specified or it's a global block.  */
32677  
32678 -  if (static_block == NULL)
32679 +  if (global_block == NULL)
32680      return NULL;
32681  
32682 -  while (block != static_block)
32683 +  while (block_iterator != global_block)
32684      {
32685 -      sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
32686 +      sym = lookup_symbol_aux_block (name, linkage_name, block_iterator, domain);
32687        if (sym != NULL)
32688         return sym;
32689 -      block = BLOCK_SUPERBLOCK (block);
32690 +    
32691 +      block_iterator = BLOCK_SUPERBLOCK (block_iterator);
32692      }
32693  
32694 -  /* We've reached the static block without finding a result.  */
32695 +  /* We've reached the global block without finding a result.  */
32696  
32697    return NULL;
32698  }
32699 @@ -1450,6 +1495,7 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile,
32700    }
32701  
32702    /* Now go through psymtabs.  */
32703 +  require_partial_symbols ((struct objfile *) objfile);
32704    ALL_OBJFILE_PSYMTABS (objfile, ps)
32705    {
32706      if (!ps->readin
32707 @@ -1520,7 +1566,7 @@ lookup_symbol_aux_psymtabs (int block_index, const char *name,
32708    struct symtab *s;
32709    const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
32710  
32711 -  ALL_PSYMTABS (objfile, ps)
32712 +  ALL_PSYMTABS_REQUIRED (objfile, ps)
32713    {
32714      if (!ps->readin
32715         && lookup_partial_symbol (ps, name, linkage_name,
32716 @@ -1805,7 +1851,11 @@ basic_lookup_transparent_type (const char *name)
32717        }
32718    }
32719  
32720 -  ALL_PSYMTABS (objfile, ps)
32721 +  /* FIXME: .debug_pubnames should be read in.
32722 +     
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)
32726    {
32727      if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
32728                                               1, STRUCT_DOMAIN))
32729 @@ -1853,7 +1903,12 @@ basic_lookup_transparent_type (const char *name)
32730        }
32731    }
32732  
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.
32736 +     
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)
32740    {
32741      if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_DOMAIN))
32742        {
32743 @@ -1894,7 +1949,21 @@ find_main_psymtab (void)
32744    struct partial_symtab *pst;
32745    struct objfile *objfile;
32746  
32747 -  ALL_PSYMTABS (objfile, pst)
32748 +  ALL_OBJFILES (objfile)
32749 +  {
32750 +    if ((objfile->flags & OBJF_MAIN) == 0)
32751 +      continue;
32752 +    require_partial_symbols (objfile);
32753 +    ALL_OBJFILE_PSYMTABS (objfile, pst)
32754 +    {
32755 +      if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
32756 +       {
32757 +         return pst;
32758 +       }
32759 +    }
32760 +  }
32761 +
32762 +  ALL_PSYMTABS_REQUIRED (objfile, pst)
32763    {
32764      if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
32765        {
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. */
32769  
32770 -  ALL_PSYMTABS (objfile, ps)
32771 +  ALL_PSYMTABS_REQUIRED (objfile, ps)
32772    {
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
32777 --- a/gdb/symtab.h
32778 +++ b/gdb/symtab.h
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
32782  
32783 -#define SYMBOL_CPLUS_DEMANGLED_NAME(symbol)    \
32784 -  (symbol)->ginfo.language_specific.cplus_specific.demangled_name
32785 -
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
32790    FUNCTIONS_DOMAIN,
32791  
32792    /* All defined types */
32793 -  TYPES_DOMAIN
32794 +  TYPES_DOMAIN,
32795 +
32796 +  /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.  */
32797 +  COMMON_BLOCK_DOMAIN
32798  }
32799  domain_enum;
32800  
32801 @@ -1027,6 +1027,8 @@ extern void clear_pc_function_cache (void);
32802  
32803  /* from symtab.c: */
32804  
32805 +struct objfile *require_partial_symbols (struct objfile *);
32806 +
32807  /* lookup partial symbol table by filename */
32808  
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
32813 --- /dev/null
32814 +++ b/gdb/syscalls/gdb-syscalls.dtd
32815 @@ -0,0 +1,21 @@
32816 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
32817 +
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.  -->
32821 +
32822 +<!-- The root element of a syscall info is <syscalls_info>.  -->
32823 +
32824 +<!ELEMENT syscalls_info                (syscall*)>
32825 +
32826 +<!-- Maybe the 'number' attribute will have to be changed from
32827 +     ID to CDATA.  -->
32828 +<!ELEMENT syscall              EMPTY>
32829 +<!ATTLIST syscall
32830 +       name                    CDATA   #REQUIRED
32831 +       number                  ID      #REQUIRED>
32832 +
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
32840 --- /dev/null
32841 +++ b/gdb/syscalls/i386-linux.xml
32842 @@ -0,0 +1,334 @@
32843 +<?xml version="1.0"?>
32844 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
32845 +
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.  -->
32849 +
32850 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
32851 +
32852 +<syscalls_info>
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"/>
33176 +</syscalls_info>
33177 diff --git a/gdb/syscalls/ppc-linux.xml b/gdb/syscalls/ppc-linux.xml
33178 new file mode 100644
33179 index 0000000..f09fabd
33180 --- /dev/null
33181 +++ b/gdb/syscalls/ppc-linux.xml
33182 @@ -0,0 +1,304 @@
33183 +<?xml version="1.0"?>
33184 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
33185 +
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.  -->
33189 +
33190 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
33191 +
33192 +<syscalls_info>
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"/>
33486 +</syscalls_info>
33487 diff --git a/gdb/syscalls/ppc64-linux.xml b/gdb/syscalls/ppc64-linux.xml
33488 new file mode 100644
33489 index 0000000..7ee929c
33490 --- /dev/null
33491 +++ b/gdb/syscalls/ppc64-linux.xml
33492 @@ -0,0 +1,289 @@
33493 +<?xml version="1.0"?>
33494 +<!-- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
33495 +
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.  -->
33499 +
33500 +<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
33501 +
33502 +<syscalls_info>
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"/>
33781 +</syscalls_info>
33782 diff --git a/gdb/target.c b/gdb/target.c
33783 index b89d551..831070c 100644
33784 --- a/gdb/target.c
33785 +++ b/gdb/target.c
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,
33797             (void (*) (int))
33798             tcomplain);
33799 +  de_fault (to_passed_by_entrypoint,
33800 +            (int (*) (void))
33801 +            tcomplain);
33802    de_fault (to_remove_exec_catchpoint,
33803             (int (*) (int))
33804             tcomplain);
33805 +  de_fault (to_set_syscall_catchpoint,
33806 +           (int (*) (int, int, int, int, int *))
33807 +           tcomplain);
33808    de_fault (to_has_exited,
33809             (int (*) (int, int, int *))
33810             return_zero);
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
33825 --- a/gdb/target.h
33826 +++ b/gdb/target.h
33827 @@ -140,18 +140,34 @@ struct target_waitstatus
33828    {
33829      enum target_waitkind kind;
33830  
33831 -    /* Forked child pid, execd pathname, exit status or signal number.  */
33832 +    /* Forked child pid, execd pathname, exit status, signal number or
33833 +       syscall name.  */
33834      union
33835        {
33836         int integer;
33837         enum target_signal sig;
33838         ptid_t related_pid;
33839         char *execd_pathname;
33840 -       int syscall_id;
33841 +       int syscall_number;
33842        }
33843      value;
33844    };
33845  
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.
33849 +   
33850 +   It's also good to mention that its fields represent everything
33851 +   that we currently know about a syscall in GDB.  */
33852 +struct syscall
33853 +  {
33854 +    /* The syscall number.  */
33855 +    int number;
33856 +
33857 +    /* The syscall name.  */
33858 +    const char *name;
33859 +  };
33860 +
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);
33874  
33875  extern int inferior_has_execd (ptid_t pid, char **execd_pathname);
33876  
33877 +extern int inferior_has_called_syscall (ptid_t pid, int *syscall_number);
33878 +
33879  /* From exec.c */
33880  
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)
33885  
33886 +/* Has the inferior already passed through its entrypoint? */
33887 +#define target_passed_by_entrypoint() \
33888 +     (*current_target.to_passed_by_entrypoint) ()
33889 +
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.  */
33896 +
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)
33900 +
33901  /* Returns TRUE if PID has exited.  And, also sets EXIT_STATUS to the
33902     exit code of PID, if any.  */
33903  
33904 @@ -1146,6 +1181,20 @@ extern int target_search_memory (CORE_ADDR start_addr,
33905                                   ULONGEST pattern_len,
33906                                   CORE_ADDR *found_addrp);
33907  
33908 +/* Utility functions which can be used by search_memory implementations.  */
33909 +
33910 +void allocate_pattern_buffer (char **pattern_bufp, char **pattern_buf_end,
33911 +                             ULONGEST *pattern_buf_size);
33912 +
33913 +void increase_pattern_buffer (char **pattern_bufp, char **pattern_buf_end,
33914 +                             ULONGEST *pattern_buf_size, int val_bytes);
33915 +
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);
33919 +
33920 +void put_bits (bfd_uint64_t data, char *buf, int bits, bfd_boolean big_p);
33921 +
33922  /* Command logging facility.  */
33923  
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
33929 @@ -1,3 +1,7 @@
33930 +2009-03-05  Pedro Alves  <pedro@codesourcery.com>
33931 +
33932 +       * gdb.arch/i386-permbkpt.S, gdb.arch/i386-permbkpt.exp: New.
33933 +
33934  2009-02-18  Jan Kratochvil  <jan.kratochvil@redhat.com>
33935  
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
33941 @@ -1,7 +1,7 @@
33942  #                                                       -*- Autoconf -*-
33943  # Process this file with autoconf to produce a configure script.
33944  
33945 -# Copyright 2002, 2003, 2004, 2005
33946 +# Copyright 2002, 2003, 2004, 2005, 2008
33947  # Free Software Foundation, Inc.
33948  #
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
33953 --- /dev/null
33954 +++ b/gdb/testsuite/gdb.arch/i386-permbkpt.S
33955 @@ -0,0 +1,30 @@
33956 +/* Copyright 2009 Free Software Foundation, Inc.
33957 +
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.
33962 +
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.
33967 +
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/>.
33970 +
33971 +   This file is part of the gdb testsuite.  */
33972 +
33973 +#define CONCAT1(a, b) CONCAT2(a, b)
33974 +#define CONCAT2(a, b) a ## b
33975 +
33976 +#ifdef SYMBOL_PREFIX
33977 +# define SYMBOL(str)     CONCAT1(SYMBOL_PREFIX, str)
33978 +#else
33979 +# define SYMBOL(str)     str
33980 +#endif
33981 +
33982 +       .global SYMBOL(main)
33983 +SYMBOL(main):
33984 +       int3
33985 +       ret
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
33989 --- /dev/null
33990 +++ b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
33991 @@ -0,0 +1,52 @@
33992 +# Copyright (C) 2009 Free Software Foundation, Inc.
33993 +
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.
33998 +#
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.
34003 +#
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/>.
34006 +
34007 +
34008 +# This file is part of the gdb testsuite.
34009 +
34010 +if $tracelevel {
34011 +    strace $tracelevel
34012 +}
34013 +
34014 +# Test inserting breakpoints over permanent breakpoints on i386 and amd64.
34015 +
34016 +if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
34017 +    verbose "Skipping i386 test for multi break at permanent breakpoint location."
34018 +    return
34019 +}
34020 +
34021 +set testfile "i386-permbkpt"
34022 +set srcfile ${testfile}.S
34023 +set binfile ${objdir}/${subdir}/${testfile}
34024 +
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=_"
34030 +}
34031 +
34032 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
34033 +    untested i386-permbkpt.exp
34034 +    return -1
34035 +}
34036 +
34037 +gdb_exit
34038 +gdb_start
34039 +gdb_reinitialize_dir $srcdir/$subdir
34040 +gdb_load ${binfile}
34041 +
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
34047 --- /dev/null
34048 +++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp
34049 @@ -0,0 +1,166 @@
34050 +# Copyright 2009 Free Software Foundation, Inc.
34051 +
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.
34056 +#
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.
34061 +#
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.  
34065 +
34066 +# Test PowerPC Power7 instructions disassembly.
34067 +
34068 +if {![istarget "powerpc*-*-*"]} then {
34069 +    verbose "Skipping PowerPC Power7 instructions disassembly."
34070 +    return
34071 +}
34072 +
34073 +set testfile "powerpc-power7"
34074 +set srcfile ${testfile}.s
34075 +set objfile ${objdir}/${subdir}/${testfile}.o
34076 +
34077 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}] != "" } {
34078 +    untested "PowerPC Power7 instructions disassembly"
34079 +    return -1
34080 +}
34081 +
34082 +
34083 +gdb_exit
34084 +gdb_start
34085 +gdb_reinitialize_dir $srcdir/$subdir
34086 +gdb_load ${objfile}
34087
34088 +
34089 +# Disassemble the function.
34090 +
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)
34095 +       pass $test
34096 +    }
34097 +}
34098 +
34099 +proc func_check {offset instr} {
34100 +    global func
34101 +
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] {
34106 +       pass $test
34107 +    } else {
34108 +       fail $test
34109 +    }
34110 +}
34111 +
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
34219 --- /dev/null
34220 +++ b/gdb/testsuite/gdb.arch/powerpc-power7.s
34221 @@ -0,0 +1,107 @@
34222 +       .text
34223 +       .globl  func
34224 +func:
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
34332 --- /dev/null
34333 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
34334 @@ -0,0 +1,455 @@
34335 +       .file   "x86_64-vla-typedef.c"
34336 +       .section        .debug_abbrev,"",@progbits
34337 +.Ldebug_abbrev0:
34338 +       .section        .debug_info,"",@progbits
34339 +.Ldebug_info0:
34340 +       .section        .debug_line,"",@progbits
34341 +.Ldebug_line0:
34342 +       .text
34343 +.Ltext0:
34344 +.globl foo
34345 +       .type   foo, @function
34346 +foo:
34347 +.LFB2:
34348 +       .file 1 "x86_64-vla-typedef.c"
34349 +       .loc 1 22 0
34350 +       pushq   %rbp
34351 +.LCFI0:
34352 +       movq    %rsp, %rbp
34353 +.LCFI1:
34354 +       subq    $64, %rsp
34355 +.LCFI2:
34356 +       movl    %edi, -36(%rbp)
34357 +       .loc 1 22 0
34358 +       movq    %rsp, %rax
34359 +       movq    %rax, -48(%rbp)
34360 +       .loc 1 23 0
34361 +       movl    -36(%rbp), %edx
34362 +       movslq  %edx,%rax
34363 +       subq    $1, %rax
34364 +       movq    %rax, -24(%rbp)
34365 +       .loc 1 24 0
34366 +       movslq  %edx,%rax
34367 +       addq    $15, %rax
34368 +       addq    $15, %rax
34369 +       shrq    $4, %rax
34370 +       salq    $4, %rax
34371 +       subq    %rax, %rsp
34372 +       movq    %rsp, -56(%rbp)
34373 +       movq    -56(%rbp), %rax
34374 +       addq    $15, %rax
34375 +       shrq    $4, %rax
34376 +       salq    $4, %rax
34377 +       movq    %rax, -56(%rbp)
34378 +       movq    -56(%rbp), %rax
34379 +       movq    %rax, -16(%rbp)
34380 +       .loc 1 27 0
34381 +       movl    $0, -4(%rbp)
34382 +       jmp     .L2
34383 +.L3:
34384 +       .loc 1 28 0
34385 +       movl    -4(%rbp), %esi
34386 +       movl    -4(%rbp), %eax
34387 +       movl    %eax, %ecx
34388 +       movq    -16(%rbp), %rdx
34389 +       movslq  %esi,%rax
34390 +       movb    %cl, (%rdx,%rax)
34391 +       .loc 1 27 0
34392 +       addl    $1, -4(%rbp)
34393 +.L2:
34394 +       movl    -4(%rbp), %eax
34395 +       cmpl    -36(%rbp), %eax
34396 +       jl      .L3
34397 +       .loc 1 30 0
34398 +       .globl  break_here
34399 +break_here:
34400 +       movq    -16(%rbp), %rax
34401 +       movb    $0, (%rax)
34402 +       movq    -48(%rbp), %rsp
34403 +       .loc 1 31 0
34404 +       leave
34405 +       ret
34406 +.LFE2:
34407 +       .size   foo, .-foo
34408 +       .section        .debug_frame,"",@progbits
34409 +.Lframe0:
34410 +       .long   .LECIE0-.LSCIE0
34411 +.LSCIE0:
34412 +       .long   0xffffffff
34413 +       .byte   0x1
34414 +       .string ""
34415 +       .uleb128 0x1
34416 +       .sleb128 -8
34417 +       .byte   0x10
34418 +       .byte   0xc
34419 +       .uleb128 0x7
34420 +       .uleb128 0x8
34421 +       .byte   0x90
34422 +       .uleb128 0x1
34423 +       .align 8
34424 +.LECIE0:
34425 +.LSFDE0:
34426 +       .long   .LEFDE0-.LASFDE0
34427 +.LASFDE0:
34428 +       .long   .Lframe0
34429 +       .quad   .LFB2
34430 +       .quad   .LFE2-.LFB2
34431 +       .byte   0x4
34432 +       .long   .LCFI0-.LFB2
34433 +       .byte   0xe
34434 +       .uleb128 0x10
34435 +       .byte   0x86
34436 +       .uleb128 0x2
34437 +       .byte   0x4
34438 +       .long   .LCFI1-.LCFI0
34439 +       .byte   0xd
34440 +       .uleb128 0x6
34441 +       .align 8
34442 +.LEFDE0:
34443 +       .section        .eh_frame,"a",@progbits
34444 +.Lframe1:
34445 +       .long   .LECIE1-.LSCIE1
34446 +.LSCIE1:
34447 +       .long   0x0
34448 +       .byte   0x1
34449 +       .string "zR"
34450 +       .uleb128 0x1
34451 +       .sleb128 -8
34452 +       .byte   0x10
34453 +       .uleb128 0x1
34454 +       .byte   0x3
34455 +       .byte   0xc
34456 +       .uleb128 0x7
34457 +       .uleb128 0x8
34458 +       .byte   0x90
34459 +       .uleb128 0x1
34460 +       .align 8
34461 +.LECIE1:
34462 +.LSFDE1:
34463 +       .long   .LEFDE1-.LASFDE1
34464 +.LASFDE1:
34465 +       .long   .LASFDE1-.Lframe1
34466 +       .long   .LFB2
34467 +       .long   .LFE2-.LFB2
34468 +       .uleb128 0x0
34469 +       .byte   0x4
34470 +       .long   .LCFI0-.LFB2
34471 +       .byte   0xe
34472 +       .uleb128 0x10
34473 +       .byte   0x86
34474 +       .uleb128 0x2
34475 +       .byte   0x4
34476 +       .long   .LCFI1-.LCFI0
34477 +       .byte   0xd
34478 +       .uleb128 0x6
34479 +       .align 8
34480 +.LEFDE1:
34481 +       .text
34482 +.Letext0:
34483 +       .section        .debug_loc,"",@progbits
34484 +.Ldebug_loc0:
34485 +.LLST0:
34486 +       .quad   .LFB2-.Ltext0
34487 +       .quad   .LCFI0-.Ltext0
34488 +       .value  0x2
34489 +       .byte   0x77
34490 +       .sleb128 8
34491 +       .quad   .LCFI0-.Ltext0
34492 +       .quad   .LCFI1-.Ltext0
34493 +       .value  0x2
34494 +       .byte   0x77
34495 +       .sleb128 16
34496 +       .quad   .LCFI1-.Ltext0
34497 +       .quad   .LFE2-.Ltext0
34498 +       .value  0x2
34499 +       .byte   0x76
34500 +       .sleb128 16
34501 +       .quad   0x0
34502 +       .quad   0x0
34503 +       .section        .debug_info
34504 +       .long   .Ldebug_end - .Ldebug_start
34505 +.Ldebug_start:
34506 +       .value  0x2
34507 +       .long   .Ldebug_abbrev0
34508 +       .byte   0x8
34509 +       .uleb128 0x1
34510 +       .long   .LASF2
34511 +       .byte   0x1
34512 +       .long   .LASF3
34513 +       .long   .LASF4
34514 +       .quad   .Ltext0
34515 +       .quad   .Letext0
34516 +       .long   .Ldebug_line0
34517 +       .uleb128 0x2
34518 +       .byte   0x1
34519 +       .string "foo"
34520 +       .byte   0x1
34521 +       .byte   0x16
34522 +       .byte   0x1
34523 +       .quad   .LFB2
34524 +       .quad   .LFE2
34525 +       .long   .LLST0
34526 +       .long   0x83
34527 +       .uleb128 0x3
34528 +       .long   .LASF5
34529 +       .byte   0x1
34530 +       .byte   0x15
34531 +       .long   0x83
34532 +       .byte   0x2
34533 +       .byte   0x91
34534 +       .sleb128 -52
34535 +.Ltag_typedef:
34536 +       .uleb128 0x4
34537 +       .long   .LASF6
34538 +       .byte   0x1
34539 +       .byte   0x17
34540 +       .long   .Ltag_array_type - .debug_info
34541 +       .uleb128 0x5    /* Abbrev Number: 5 (DW_TAG_variable) */
34542 +       .long   .LASF0
34543 +       .byte   0x1
34544 +       .byte   0x18
34545 +#if 1
34546 +       .long   .Ltag_typedef - .debug_info
34547 +#else
34548 +       /* Debugging only: Skip the typedef indirection.  */
34549 +       .long   .Ltag_array_type - .debug_info
34550 +#endif
34551 +       /* DW_AT_location: DW_FORM_block1: start */
34552 +       .byte   0x3
34553 +       .byte   0x91
34554 +       .sleb128 -32
34555 +#if 0
34556 +       .byte   0x6     /* DW_OP_deref */
34557 +#else
34558 +       .byte   0x96    /* DW_OP_nop */
34559 +#endif
34560 +       /* DW_AT_location: DW_FORM_block1: end */
34561 +       .uleb128 0x6
34562 +       .string "i"
34563 +       .byte   0x1
34564 +       .byte   0x19
34565 +       .long   0x83
34566 +       .byte   0x2
34567 +       .byte   0x91
34568 +       .sleb128 -20
34569 +       .byte   0x0
34570 +       .uleb128 0x7
34571 +       .byte   0x4
34572 +       .byte   0x5
34573 +       .string "int"
34574 +.Ltag_array_type:
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 */
34580 +3:
34581 +       .byte   0x97    /* DW_OP_push_object_address */
34582 +       .byte   0x6     /* DW_OP_deref */
34583 +2:     /* DW_AT_data_location: DW_FORM_block1: end */
34584 +       .uleb128 0x9
34585 +       .long   0x9d + (2b - 1b)        /* DW_AT_type: DW_FORM_ref4 */
34586 +       .byte   0x3
34587 +       .byte   0x91
34588 +       .sleb128 -40
34589 +       .byte   0x6
34590 +       .byte   0x0
34591 +       .uleb128 0xa
34592 +       .byte   0x8
34593 +       .byte   0x7
34594 +       .uleb128 0xb
34595 +       .byte   0x1
34596 +       .byte   0x6
34597 +       .long   .LASF1
34598 +       .byte   0x0
34599 +.Ldebug_end:
34600 +       .section        .debug_abbrev
34601 +       .uleb128 0x1
34602 +       .uleb128 0x11
34603 +       .byte   0x1
34604 +       .uleb128 0x25
34605 +       .uleb128 0xe
34606 +       .uleb128 0x13
34607 +       .uleb128 0xb
34608 +       .uleb128 0x3
34609 +       .uleb128 0xe
34610 +       .uleb128 0x1b
34611 +       .uleb128 0xe
34612 +       .uleb128 0x11
34613 +       .uleb128 0x1
34614 +       .uleb128 0x12
34615 +       .uleb128 0x1
34616 +       .uleb128 0x10
34617 +       .uleb128 0x6
34618 +       .byte   0x0
34619 +       .byte   0x0
34620 +       .uleb128 0x2
34621 +       .uleb128 0x2e
34622 +       .byte   0x1
34623 +       .uleb128 0x3f
34624 +       .uleb128 0xc
34625 +       .uleb128 0x3
34626 +       .uleb128 0x8
34627 +       .uleb128 0x3a
34628 +       .uleb128 0xb
34629 +       .uleb128 0x3b
34630 +       .uleb128 0xb
34631 +       .uleb128 0x27
34632 +       .uleb128 0xc
34633 +       .uleb128 0x11
34634 +       .uleb128 0x1
34635 +       .uleb128 0x12
34636 +       .uleb128 0x1
34637 +       .uleb128 0x40
34638 +       .uleb128 0x6
34639 +       .uleb128 0x1
34640 +       .uleb128 0x13
34641 +       .byte   0x0
34642 +       .byte   0x0
34643 +       .uleb128 0x3
34644 +       .uleb128 0x5
34645 +       .byte   0x0
34646 +       .uleb128 0x3
34647 +       .uleb128 0xe
34648 +       .uleb128 0x3a
34649 +       .uleb128 0xb
34650 +       .uleb128 0x3b
34651 +       .uleb128 0xb
34652 +       .uleb128 0x49
34653 +       .uleb128 0x13
34654 +       .uleb128 0x2
34655 +       .uleb128 0xa
34656 +       .byte   0x0
34657 +       .byte   0x0
34658 +       .uleb128 0x4
34659 +       .uleb128 0x16
34660 +       .byte   0x0
34661 +       .uleb128 0x3
34662 +       .uleb128 0xe
34663 +       .uleb128 0x3a
34664 +       .uleb128 0xb
34665 +       .uleb128 0x3b
34666 +       .uleb128 0xb
34667 +       .uleb128 0x49
34668 +       .uleb128 0x13
34669 +       .byte   0x0
34670 +       .byte   0x0
34671 +       .uleb128 0x5
34672 +       .uleb128 0x34
34673 +       .byte   0x0
34674 +       .uleb128 0x3
34675 +       .uleb128 0xe
34676 +       .uleb128 0x3a
34677 +       .uleb128 0xb
34678 +       .uleb128 0x3b
34679 +       .uleb128 0xb
34680 +       .uleb128 0x49
34681 +       .uleb128 0x13
34682 +       .uleb128 0x2
34683 +       .uleb128 0xa
34684 +       .byte   0x0
34685 +       .byte   0x0
34686 +       .uleb128 0x6
34687 +       .uleb128 0x34
34688 +       .byte   0x0
34689 +       .uleb128 0x3
34690 +       .uleb128 0x8
34691 +       .uleb128 0x3a
34692 +       .uleb128 0xb
34693 +       .uleb128 0x3b
34694 +       .uleb128 0xb
34695 +       .uleb128 0x49
34696 +       .uleb128 0x13
34697 +       .uleb128 0x2
34698 +       .uleb128 0xa
34699 +       .byte   0x0
34700 +       .byte   0x0
34701 +       .uleb128 0x7
34702 +       .uleb128 0x24
34703 +       .byte   0x0
34704 +       .uleb128 0xb
34705 +       .uleb128 0xb
34706 +       .uleb128 0x3e
34707 +       .uleb128 0xb
34708 +       .uleb128 0x3
34709 +       .uleb128 0x8
34710 +       .byte   0x0
34711 +       .byte   0x0
34712 +       .uleb128 0x8    /* Abbrev Number: 8 (DW_TAG_array_type) */
34713 +       .uleb128 0x1
34714 +       .byte   0x1
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 */
34721 +       .byte   0x0
34722 +       .byte   0x0
34723 +       .uleb128 0x9
34724 +       .uleb128 0x21
34725 +       .byte   0x0
34726 +       .uleb128 0x49   /* DW_AT_type */
34727 +       .uleb128 0x13   /* DW_FORM_ref4 */
34728 +       .uleb128 0x2f
34729 +       .uleb128 0xa
34730 +       .byte   0x0
34731 +       .byte   0x0
34732 +       .uleb128 0xa
34733 +       .uleb128 0x24
34734 +       .byte   0x0
34735 +       .uleb128 0xb
34736 +       .uleb128 0xb
34737 +       .uleb128 0x3e
34738 +       .uleb128 0xb
34739 +       .byte   0x0
34740 +       .byte   0x0
34741 +       .uleb128 0xb
34742 +       .uleb128 0x24
34743 +       .byte   0x0
34744 +       .uleb128 0xb
34745 +       .uleb128 0xb
34746 +       .uleb128 0x3e
34747 +       .uleb128 0xb
34748 +       .uleb128 0x3
34749 +       .uleb128 0xe
34750 +       .byte   0x0
34751 +       .byte   0x0
34752 +       .byte   0x0
34753 +       .section        .debug_pubnames,"",@progbits
34754 +       .long   0x16
34755 +       .value  0x2
34756 +       .long   .Ldebug_info0
34757 +       .long   0xa8
34758 +       .long   0x2d
34759 +       .string "foo"
34760 +       .long   0x0
34761 +       .section        .debug_aranges,"",@progbits
34762 +       .long   0x2c
34763 +       .value  0x2
34764 +       .long   .Ldebug_info0
34765 +       .byte   0x8
34766 +       .byte   0x0
34767 +       .value  0x0
34768 +       .value  0x0
34769 +       .quad   .Ltext0
34770 +       .quad   .Letext0-.Ltext0
34771 +       .quad   0x0
34772 +       .quad   0x0
34773 +       .section        .debug_str,"MS",@progbits,1
34774 +.LASF0:
34775 +       .string "array"
34776 +.LASF5:
34777 +       .string "size"
34778 +.LASF3:
34779 +       .string "x86_64-vla-typedef.c"
34780 +.LASF6:
34781 +       .string "array_t"
34782 +.LASF1:
34783 +       .string "char"
34784 +.LASF4:
34785 +       .string "gdb.arch"
34786 +.LASF2:
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
34793 --- /dev/null
34794 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
34795 @@ -0,0 +1,43 @@
34796 +/* This testcase is part of GDB, the GNU debugger.
34797 +
34798 +   Copyright 2008 Free Software Foundation, Inc.
34799 +
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.
34804 +
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.
34809 +
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/>.  */
34812 +
34813 +#if 0
34814 +
34815 +void
34816 +foo (int size)
34817 +{
34818 +  typedef char array_t[size];
34819 +  array_t array;
34820 +  int i;
34821 +
34822 +  for (i = 0; i < size; i++)
34823 +    array[i] = i;
34824 +
34825 +  array[0] = 0;        /* break-here */
34826 +}
34827 +
34828 +#else
34829 +
34830 +int
34831 +main (void)
34832 +{
34833 +  foo (26);
34834 +  foo (78);
34835 +  return 0;
34836 +}
34837 +
34838 +#endif
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
34842 --- /dev/null
34843 +++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
34844 @@ -0,0 +1,64 @@
34845 +# Copyright 2009 Free Software Foundation, Inc.
34846 +
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.
34851 +#
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.
34856 +#
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/>.
34859 +
34860 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
34861 +
34862 +if ![istarget "x86_64-*-*"] then {
34863 +    verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
34864 +    return
34865 +}
34866 +
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"
34874 +    return -1
34875 +}
34876 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
34877 +    untested "Couldn't compile test program"
34878 +    return -1
34879 +}
34880 +
34881 +gdb_exit
34882 +gdb_start
34883 +gdb_reinitialize_dir $srcdir/$subdir
34884 +gdb_load ${binfile}
34885 +
34886 +if ![runto_main] {
34887 +    untested x86_64-vla-typedef
34888 +    return -1
34889 +}
34890 +
34891 +gdb_breakpoint "break_here"
34892 +
34893 +gdb_continue_to_breakpoint "break_here"
34894 +
34895 +gdb_test "whatis array" "type = array_t" "first: whatis array"
34896 +
34897 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
34898 +
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'"
34903 +
34904 +gdb_continue_to_breakpoint "break_here"
34905 +
34906 +gdb_test "whatis array" "type = array_t" "second: whatis array"
34907 +
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
34919  
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)"] && \
34927  
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'\\}"
34932  }
34933  
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
34951 --- /dev/null
34952 +++ b/gdb/testsuite/gdb.base/catch-syscall.c
34953 @@ -0,0 +1,25 @@
34954 +/* This file is used to test the 'catch syscall' feature on GDB.
34955
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.
34959 +
34960 +   Written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
34961 +   September, 2008 */
34962 +
34963 +#include <unistd.h>
34964 +#include <fcntl.h>
34965 +#include <sys/stat.h>
34966 +
34967 +int
34968 +main (void)
34969 +{
34970 +       /* A close() with a wrong argument.  We are only
34971 +          interested in the syscall.  */
34972 +       close (-1);
34973 +
34974 +       chroot (".");
34975 +
34976 +       /* The last syscall.  Do not change this.  */
34977 +       _exit (0);
34978 +}
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
34982 --- /dev/null
34983 +++ b/gdb/testsuite/gdb.base/catch-syscall.exp
34984 @@ -0,0 +1,386 @@
34985 +#   Copyright 1997, 1999, 2007, 2008 Free Software Foundation, Inc.
34986 +
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.
34991 +#
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.
34996 +#
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/>.
34999 +
35000 +
35001 +# This program tests the 'catch syscall' functionality.
35002 +#
35003 +# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
35004 +# on September/2008.
35005 +
35006 +if { [is_remote target] || ![isnative] } then {
35007 +    continue
35008 +}
35009 +
35010 +set prms_id 0
35011 +set bug_id 0
35012 +
35013 +global srcfile
35014 +set testfile "catch-syscall"
35015 +set srcfile ${testfile}.c
35016 +set binfile ${objdir}/${subdir}/${testfile}
35017 +
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"
35025 +
35026 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
35027 +     untested catch-syscall.exp
35028 +     return -1
35029 +}
35030 +
35031 +# Until "catch syscall" is implemented on other targets...
35032 +if {![istarget "hppa*-hp-hpux*"] && ![istarget "*-linux*"]} then {
35033 +    continue
35034 +}
35035 +
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*"] } {
35041 +     continue
35042 +}
35043 +
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
35049 +
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
35054 +}
35055 +
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
35060 +
35061 +    set thistest "syscall $syscall appears in 'info breakpoints'"
35062 +    gdb_test "info breakpoints" ".*catchpoint.*keep y.*syscall (.)?${syscall}(.)?.*" $thistest
35063 +}
35064 +
35065 +# This procedure checks if there was a call to a syscall.
35066 +proc check_call_to_syscall { syscall } {
35067 +    global gdb_prompt
35068 +
35069 +    set thistest "program has called $syscall"
35070 +    gdb_test "continue" "Catchpoint .*(call to syscall .?${syscall}.?).*" $thistest
35071 +
35072 +    # Checking if the syscall is reported to be caught in
35073 +    # 'info breakpoints'.
35074 +    check_info_breakpoints "$syscall"
35075 +}
35076 +
35077 +# This procedure checks if the syscall returned.
35078 +proc check_return_from_syscall { syscall } {
35079 +    global gdb_prompt
35080 +
35081 +    set thistest "syscall $syscall has returned"
35082 +    gdb_test "continue" "Catchpoint .*(returned from syscall (.)?${syscall}(.)?).*" $thistest
35083 +
35084 +    # Checking if the syscall is reported to be caught in
35085 +    # 'info breakpoints'.
35086 +    check_info_breakpoints "$syscall"
35087 +}
35088 +
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
35093 +
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.
35098 +
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
35103 +}
35104 +
35105 +# Inserts a syscall catchpoint with an argument.
35106 +proc insert_catch_syscall_with_arg { syscall } {
35107 +    global gdb_prompt
35108 +
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
35112 +}
35113 +
35114 +proc check_for_program_end {} {
35115 +    global gdb_prompt
35116 +
35117 +    # Deleting the catchpoints
35118 +    delete_breakpoints
35119 +
35120 +    set thistest "successful program end"
35121 +    gdb_test "continue" "Program exited normally.*" $thistest
35122 +
35123 +}
35124 +
35125 +proc test_catch_syscall_without_args {} {
35126 +    global gdb_prompt all_syscalls last_syscall
35127 +
35128 +    # Trying to set the syscall
35129 +    set thistest "setting catch syscall without arguments"
35130 +    gdb_test "catch syscall" "Catchpoint .*(syscall).*" $thistest
35131 +
35132 +    check_init_info_breakpoints
35133 +
35134 +    # We have to check every syscall
35135 +    foreach name $all_syscalls {
35136 +        check_continue $name
35137 +    }
35138 +
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
35142 +
35143 +    # Now let's see if the inferior correctly finishes.
35144 +    check_for_program_end
35145 +}
35146 +
35147 +proc test_catch_syscall_with_args {} {
35148 +    global gdb_prompt
35149 +    set syscall_name "close"
35150 +
35151 +    insert_catch_syscall_with_arg $syscall_name 
35152 +    check_init_info_breakpoints
35153 +
35154 +    # Can we continue until we catch the syscall?
35155 +    check_continue $syscall_name
35156 +
35157 +    # Now let's see if the inferior correctly finishes.
35158 +    check_for_program_end
35159 +}
35160 +
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"
35165 +
35166 +    insert_catch_syscall_with_arg $syscall_name
35167 +    check_init_info_breakpoints
35168 +
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
35174 +}
35175 +
35176 +proc test_catch_syscall_restarting_inferior {} {
35177 +    global gdb_prompt
35178 +    set syscall_name "chroot"
35179 +
35180 +    insert_catch_syscall_with_arg $syscall_name
35181 +    check_init_info_breakpoints
35182 +
35183 +    # Let's first reach the call of the syscall.
35184 +    check_call_to_syscall $syscall_name
35185 +
35186 +    # Now, restart the program
35187 +    rerun_to_main
35188 +
35189 +    # And check for call/return
35190 +    check_continue $syscall_name
35191 +
35192 +    # Can we finish?
35193 +    check_for_program_end
35194 +}
35195 +
35196 +proc do_syscall_tests {} {
35197 +    global gdb_prompt srcdir
35198 +
35199 +    # First, we need to set GDB datadir.
35200 +    send_gdb "maintenance set gdb_datadir $srcdir/..\n"
35201 +    gdb_expect 10 {
35202 +       -re "$gdb_prompt $" {
35203 +           verbose "Setting GDB datadir to $srcdir/..." 2
35204 +       }
35205 +       timeout {
35206 +           error "Couldn't set GDB datadir."
35207 +       }
35208 +    }
35209 +
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
35213 +
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
35217 +
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 }
35221 +
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 }
35225 +
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 }
35229 +
35230 +    # Testing the 'catch' syscall command during a restart of
35231 +    # the inferior.
35232 +    if [runto_main] then { test_catch_syscall_restarting_inferior }
35233 +}
35234 +
35235 +proc test_catch_syscall_fail_noxml {} {
35236 +    global gdb_prompt
35237 +
35238 +    # Sanitizing.
35239 +    delete_breakpoints
35240 +
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
35245 +
35246 +    # Since the catchpoint was set, we must check if it's present at
35247 +    # "info breakpoints"
35248 +    check_init_info_breakpoints
35249 +
35250 +    # Sanitizing.
35251 +    delete_breakpoints
35252 +}
35253 +
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
35259 +
35260 +    delete_breakpoints
35261 +
35262 +    set thistest "Catch syscall without arguments and without XML support"
35263 +    gdb_test "catch syscall" "Catchpoint .*(syscall).*"
35264 +
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\]*"
35273 +    }
35274 +
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\]*"
35278 +
35279 +    delete_breakpoints
35280 +}
35281 +
35282 +proc test_catch_syscall_with_args_noxml {} {
35283 +    global gdb_prompt
35284 +
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"
35293 +    } else {
35294 +        set close_number "6"
35295 +    }
35296 +
35297 +    delete_breakpoints
35298 +
35299 +    insert_catch_syscall_with_arg $close_number
35300 +    check_init_info_breakpoints
35301 +
35302 +    check_continue $close_number
35303 +
35304 +    delete_breakpoints
35305 +}
35306 +
35307 +proc test_catch_syscall_with_wrong_args_noxml {} {
35308 +    global gdb_prompt
35309 +
35310 +    delete_breakpoints
35311 +
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
35316 +
35317 +    delete_breakpoints
35318 +}
35319 +
35320 +proc do_syscall_tests_without_xml {} {
35321 +    global gdb_prompt srcdir
35322 +
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.
35326 +
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
35330 +
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 }
35334 +
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).
35338 +    #
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 }
35345 +
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 }
35349 +}
35350 +
35351 +# Start with a fresh gdb
35352 +
35353 +gdb_exit
35354 +gdb_start
35355 +gdb_reinitialize_dir $srcdir/$subdir
35356 +gdb_load ${binfile}
35357 +
35358 +# Execute the tests, using XML support
35359 +do_syscall_tests
35360 +
35361 +# Restart gdb
35362 +
35363 +gdb_exit
35364 +gdb_start
35365 +gdb_reinitialize_dir $srcdir/$subdir
35366 +gdb_load ${binfile}
35367 +
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
35375 @@ -20,11 +20,6 @@
35376     Please email any bugs, comments, and/or additions to this file to:
35377     bug-gdb@gnu.org  */
35378  
35379 -#include <stdio.h>
35380 -#include <stdlib.h>
35381 -#include <string.h>
35382 -
35383 -
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];
35390  
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];
35396 +
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;
35402 +
35403 +/* Make sure to use the typedefs.  */
35404 +char16_t uvar;
35405 +char32_t Uvar;
35406  
35407  void
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)
35412  {
35413 -  memset (string, x, NUM_CHARS);
35414 +  int i;
35415 +
35416 +  for (i = 0; i < NUM_CHARS; ++i)
35417 +    string[i] = x;
35418    string[0] = alert;
35419    string[1] = backspace;
35420    string[2] = form_feed;
35421 @@ -85,13 +98,21 @@ fill_run (char string[], int start, int len, int first)
35422  }
35423  
35424  
35425 +void
35426 +init_ucs4 ()
35427 +{
35428 +  int i;
35429 +
35430 +  for (i = 0; i < NUM_CHARS; ++i)
35431 +    ucs_4_string[i] = iso_8859_1_string[i] & 0xff;
35432 +}
35433 +
35434  int main ()
35435  {
35436  #ifdef usestubs
35437    set_debug_traps();
35438    breakpoint();
35439  #endif
35440 -  (void) malloc (1);
35441    /* Initialize ascii_string.  */
35442    init_string (ascii_string,
35443                 120,
35444 @@ -146,5 +167,7 @@ int main ()
35445    /* The digits, at least, are contiguous.  */
35446    fill_run (ibm1047_string, 59, 10, 240);
35447  
35448 -  puts ("All set!");            /* all strings initialized */
35449 +  init_ucs4 ();
35450 +
35451 +  return 0;            /* all strings initialized */
35452  }
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} {
35458      global gdb_prompt
35459  
35460      gdb_expect {
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]
35465 -            pass $testname
35466 -        }
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} {
35473  }
35474  
35475  
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.
35480  
35481  send_gdb "show charset\n"
35482  set show_charset [parse_show_charset_output "show charset"]
35483  
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]
35488  
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'"
35492  } else {
35493      fail "check `show target-charset' against `show charset'"
35494  }
35495  
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]
35500  
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'"
35504  } else {
35505      fail "check `show host-charset' against `show charset'"
35506  }
35507  
35508 -
35509 -# Get the list of supported (host) charsets as possible completions.
35510 -send_gdb "set charset \t\t"
35511 -
35512 -# Check that we can at least use ASCII as a host character set.
35513 -sleep 1
35514 -gdb_expect {
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.
35520 -        send_gdb "\n"
35521 -        gdb_expect {
35522 -           -re ".*Requires an argument.*$gdb_prompt $" {
35523 -               pass "get valid character sets"
35524 -           }
35525 -           -re ".*$gdb_prompt $" {
35526 -               send_gdb "\n"
35527 -               gdb_expect {
35528 -                   -re ".*$gdb_prompt $" {
35529 -                       fail "get valid character sets"
35530 -                   }
35531 -               }
35532 -           }
35533 -           timeout {
35534 -               fail "(timeout) get valid character sets"
35535 -           }
35536 -       }
35537 -    }
35538 -    -re ".*$gdb_prompt $" {
35539 -       # We got some output that ended with a regular prompt
35540 -        fail "get valid character sets"
35541 -    }
35542 -    -re ".*$gdb_prompt set charset.*$" {
35543 -       # We got some other output, send a cntrl-c to gdb to get us back
35544 -        # to the prompt.
35545 -       send_gdb "\003"
35546 -        fail "get valid character sets"
35547 -    }
35548 -    timeout {
35549 -        fail "get valid character sets (timeout)"
35550 -    }
35551 -}
35552 -
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'"
35559  
35560  # Try using `set host-charset' on an invalid character set.
35561 @@ -244,8 +194,10 @@ gdb_expect {
35562      }
35563  }
35564  
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]} {
35572  
35573          set testname "try `set host-charset $host_charset'"
35574 @@ -279,7 +231,7 @@ foreach host_charset [all_charset_names] {
35575  
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"
35582              gdb_expect {
35583 @@ -404,23 +356,42 @@ gdb_expect {
35584  }
35585  
35586  
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]
35590 +set wchar_ok 0
35591 +if {$wchar_size == 2} {
35592 +    lappend charset_subset UCS-2
35593 +    set wchar_ok 1
35594 +} elseif {$wchar_size == 4} {
35595 +    lappend charset_subset UCS-4
35596 +    set wchar_ok 1
35597 +}
35598 +
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
35605 +       set L L
35606 +    } else {
35607 +       set param target-charset
35608 +       set L ""
35609 +    }
35610 +    send_gdb "set $param $target_charset\n" 
35611      gdb_expect {
35612          -re "$gdb_prompt $" {
35613 -            pass "set target-charset $target_charset"
35614 +            pass "set $param $target_charset"
35615          }
35616          timeout {
35617 -            fail "set target-charset $target_charset (timeout)"
35618 +            fail "set $param $target_charset (timeout)"
35619          }
35620      }
35621  
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"
35626      gdb_expect {
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}"
35630          }
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
35642 +    } else {
35643 +       set var_name [string tolower "${target_charset}_string"]
35644 +       regsub -all -- "\[^a-z0-9_\]" $var_name "_" var_name
35645 +    }
35646      
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\]+"
35655  
35656      send_gdb "print $var_name\n"
35657      # ${escapes}${uppercase}${lowercase}${digits}${octal}${octal}
35658      gdb_expect {
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"
35662          }
35663          -re "$gdb_prompt $" {
35664 @@ -461,22 +438,22 @@ foreach target_charset [all_charset_names] {
35665      }
35666  
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}"
35673  
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\]" \
35677               " = 1" \
35678               "check value of parsed character literal in ${target_charset}"
35679  
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}"
35686  
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\]" \
35690               " = 1" \
35691               "check value of parsed string literal in ${target_charset}"
35692  
35693 @@ -509,7 +486,7 @@ foreach target_charset [all_charset_names] {
35694          send_gdb "print $var_name\[$i\]\n"
35695          set have_escape 1
35696          gdb_expect {
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}"
35700              }
35701              -re "= \[0-9-\]+ 'x'\[\r\n\]+$gdb_prompt $" {
35702 @@ -527,12 +504,12 @@ foreach target_charset [all_charset_names] {
35703          if {$have_escape} {
35704  
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\]" \
35708                       " = 1" \
35709                       "check value of '\\${escape}' in ${target_charset}"
35710  
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\]" \
35714                       " = 1" \
35715                       "check value of \"\\${escape}\" in ${target_charset}"
35716          }
35717 @@ -540,10 +517,73 @@ foreach target_charset [all_charset_names] {
35718  
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"
35727  }
35728  
35729 +# Reset the target charset.
35730 +gdb_test "set target-charset UTF-8" ""
35731 +
35732 +# \242 is not a valid UTF-8 character.
35733 +gdb_test "print \"\\242\"" " = \"\\\\242\"" \
35734 +  "non-representable target character"
35735 +
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'"
35739 +
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"
35756 +
35757 +    gdb_test "print $L'a'" "= \[0-9\]+ $L'a'" \
35758 +      "basic $name character"
35759 +}
35760 +
35761 +if {$wchar_ok} {
35762 +    test_wide_or_unicode L wide
35763 +}
35764 +
35765 +set ucs2_ok [expr {[get_sizeof char16_t 99] == 2}]
35766 +if {$ucs2_ok} {
35767 +    test_wide_or_unicode u UCS-2
35768 +}
35769 +
35770 +set ucs4_ok [expr {[get_sizeof char32_t 99] == 4}]
35771 +if {$ucs4_ok} {
35772 +    test_wide_or_unicode U UCS-4
35773 +}
35774 +
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"
35780 +}
35781 +
35782 +if {$wchar_ok && $ucs2_ok} {
35783 +    test_combination L wide u UCS-2
35784 +}
35785 +if {$wchar_ok && $ucs4_ok} {
35786 +    test_combination L wide U UCS-4
35787 +}
35788 +if {$ucs2_ok && $ucs4_ok} {
35789 +    test_combination u UCS-2 U UCS-4
35790 +}
35791 +
35792  gdb_exit 
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"
35829  
35830  # play with "print", too
35831  #
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"
35840  
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"
35849  # test help source
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"
35853  # test help stack
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
35859 --- /dev/null
35860 +++ b/gdb/testsuite/gdb.base/lineno-makeup-func.c
35861 @@ -0,0 +1,21 @@
35862 +/* This testcase is part of GDB, the GNU debugger.
35863 +
35864 +   Copyright 2009 Free Software Foundation, Inc.
35865 +
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.
35870 +
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.
35875 +
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/>.  */
35878 +
35879 +void
35880 +func (void)
35881 +{
35882 +}
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
35886 --- /dev/null
35887 +++ b/gdb/testsuite/gdb.base/lineno-makeup.c
35888 @@ -0,0 +1,35 @@
35889 +/* This testcase is part of GDB, the GNU debugger.
35890 +
35891 +   Copyright 2009 Free Software Foundation, Inc.
35892 +
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.
35897 +
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.
35902 +
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/>.  */
35905 +
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.
35908 +   
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.
35911 +   
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'.  */
35914 +
35915 +extern void func (void);
35916 +asm ("func: .incbin \"gdb.base/lineno-makeup-func.bin\"");
35917 +
35918 +int
35919 +main (void)
35920 +{
35921 +  func ();
35922 +  return 0;
35923 +}
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
35927 --- /dev/null
35928 +++ b/gdb/testsuite/gdb.base/lineno-makeup.exp
35929 @@ -0,0 +1,78 @@
35930 +# Copyright 2009 Free Software Foundation, Inc.
35931 +
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.
35936 +#
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.
35941 +#
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/>.
35944 +
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}
35951 +
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."
35954 +}
35955 +
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."
35960 +}
35961 +set binfuncfilesize [file size $binfuncfile]
35962 +verbose -log "file size $binfuncfile = $binfuncfilesize"
35963 +
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."
35966 +}
35967 +
35968 +gdb_exit
35969 +gdb_start
35970 +gdb_reinitialize_dir $srcdir/$subdir
35971 +gdb_load ${binfile}
35972 +
35973 +set b_addr ""
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)
35978 +       pass $test
35979 +    }
35980 +    -re "Breakpoint \[0-9\]+ at (0x\[0-9a-f\]+): .*\r\n$gdb_prompt $" {
35981 +       set b_addr $expect_out(1,string)
35982 +       fail $test
35983 +    }
35984 +}
35985 +verbose -log "b_addr=<$b_addr>"
35986 +
35987 +set p_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)
35992 +       pass $test
35993 +    }
35994 +}
35995 +verbose -log "p_addr=<$p_addr>"
35996 +
35997 +set test "break address belongs to func"
35998 +if {$b_addr == $p_addr} {
35999 +    pass "$test (exact match)"
36000 +} else {
36001 +    set skip [expr $b_addr - $p_addr]
36002 +    if {$skip > 0 && $skip < $binfuncfilesize} {
36003 +       pass "$test (prologue skip by $skip bytes)"
36004 +    } else {
36005 +       fail $test
36006 +    }
36007 +}
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'"
36018  
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"
36029  } else {
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"
36038  } else {
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"
36046  
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"
36055  
36056  gdb_exit
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}
36064  
36065 -set options { debug }
36066 +set options { debug additional_flags=-DFROM_COMMANDLINE=ARG}
36067  
36068  get_compiler_info ${binfile}
36069  if [test_compiler_info gcc*] {
36070      lappend options additional_flags=-g3
36071  }
36072  
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"
36078 +    }
36079 +}
36080 +
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} {
36085  
36086      if {$debug_me} {exp_internal 1}
36087      gdb_expect {
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
36091              # this message.
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)"
36097 +               }
36098                  exp_continue
36099              } else {
36100                  # Exit this expect loop, with a result indicating failure.
36101 @@ -198,6 +210,8 @@ proc list_and_check_macro {func macro expected} {
36102  }
36103  
36104  
36105 +list_and_check_macro main FROM_COMMANDLINE "macscp1.c:0 ARG"
36106 +
36107  if {[list_and_check_macro main WHERE {macscp1.c {before macscp1_3}}]} {
36108      return 0
36109  }
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
36115  
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.
36118 -#
36119 +
36120 +set exit_bp_loc [gdb_get_line_number "Set exit breakpoint here."]
36121 +
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.
36126 +
36127 +proc continue_to_exit_bp_loc {} {
36128 +    global exit_bp_loc decimal gdb_prompt
36129 +
36130 +    gdb_breakpoint $exit_bp_loc
36131 +
36132 +    send_gdb "continue\n"
36133 +
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.
36137 +    set seen_done 0
36138 +    set seen_break 0
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.
36148 +       gdb_expect {
36149 +           -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
36150 +               if {[info exists expect_out(1,string)]} {
36151 +                   incr seen_done
36152 +               } elseif {[info exists expect_out(2,string)]} {
36153 +                   set seen_break 1
36154 +               } elseif {[info exists expect_out(3,string)]} {
36155 +                   set seen_prompt 1
36156 +               }
36157 +               array unset expect_out
36158 +           }
36159 +           timeout { set seen_timeout 1 }
36160 +       }
36161 +    }
36162 +
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)"
36171 +    } else {
36172 +       pass "run to exit 2"
36173 +    }
36174 +}
36175  
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.
36180  
36181  runto_main
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" "" ""
36185 -
36186 -send_gdb "continue\n"
36187 -gdb_expect {
36188 -    -re ".*Break.* main .*$gdb_prompt.*$" {}
36189 -    -re ".*$gdb_prompt $" {fail "run to exit 1"}
36190 -    default {fail "run to exit 1 (timeout)"}
36191 -}
36192 +gdb_test "set follow child"
36193 +continue_to_exit_bp_loc
36194  
36195  gdb_test "print pids" "\\$.* = \\{0, 0, 0, 0\\}.*" "follow child, print pids"
36196  
36197  # Now set gdb to follow the parent.
36198  # Result should be that none of the 4 forks returns zero.
36199  
36200 -delete_breakpoints
36201  runto_main
36202 -gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" "Break at exit"
36203  gdb_test "set follow parent" "" ""
36204 -
36205 -send_gdb "continue\n"
36206 -
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.
36210 -set seen_done 0
36211 -set seen_break 0
36212 -set seen_prompt 0
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.
36221 -    gdb_expect {
36222 -        -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
36223 -            if {[info exists expect_out(1,string)]} {
36224 -                incr seen_done
36225 -            } elseif {[info exists expect_out(2,string)]} {
36226 -                set seen_break 1
36227 -            } elseif {[info exists expect_out(3,string)]} {
36228 -                set seen_prompt 1
36229 -            }
36230 -            array unset expect_out
36231 -        }
36232 -        timeout { set seen_timeout 1 }
36233 -    }
36234 -}
36235 -
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)"
36244 -} else {
36245 -    pass "run to exit 2"
36246 -}
36247 +continue_to_exit_bp_loc
36248  
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" \
36252  #
36253  
36254  runto_main
36255 -gdb_test "break $exit_bp_loc" "Breakpoint.* at .*" ""
36256 +gdb_breakpoint $exit_bp_loc
36257  
36258  gdb_test "help set detach-on-fork" "whether gdb will detach the child.*" \
36259      "help set detach"
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 {
36265  
36266  send_gdb "print *pUC\n"
36267  gdb_expect {
36268 -    -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" {
36269 +    -re ".\[0-9\]* = 21 \'.25\'.*$gdb_prompt $" {
36270          pass "print value of *pUC"
36271        }
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 {} {
36278      global gdb_prompt
36279  
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 {} {
36358      set timeout 60;
36359  
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
36369 --- /dev/null
36370 +++ b/gdb/testsuite/gdb.base/return-nodebug.c
36371 @@ -0,0 +1,49 @@
36372 +/* This testcase is part of GDB, the GNU debugger.
36373 +
36374 +   Copyright 2009 Free Software Foundation, Inc.
36375 +
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.
36380 +
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.
36385 +
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/>.  */
36388 +
36389 +#include <stdio.h>
36390 +
36391 +static TYPE
36392 +init (void)
36393 +{
36394 +  return 0;
36395 +}
36396 +
36397 +static TYPE
36398 +func (void)
36399 +{
36400 +  return 31;
36401 +}
36402 +
36403 +static void
36404 +marker (void)
36405 +{
36406 +}
36407 +
36408 +int
36409 +main (void)
36410 +{
36411 +  /* Preinitialize registers to 0 to avoid false PASS by leftover garbage.  */
36412 +  init ();
36413 +
36414 +  printf ("result=" FORMAT "\n", CAST func ());
36415 +
36416 +  /* Cannot `next' with no debug info.  */
36417 +  marker ();
36418 +
36419 +  return 0;
36420 +}
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
36424 --- /dev/null
36425 +++ b/gdb/testsuite/gdb.base/return-nodebug.exp
36426 @@ -0,0 +1,61 @@
36427 +# Copyright (C) 2009 Free Software Foundation, Inc.
36428 +
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.
36433 +#
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.
36438 +#
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/>.
36441 +
36442 +proc do_test {type} {
36443 +    set typenospace [string map {{ } -} $type]
36444 +
36445 +    global pf_prefix
36446 +    set old_prefix $pf_prefix
36447 +    lappend pf_prefix "$typenospace:"
36448 +
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'.
36453 +
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"
36457 +
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"
36462 +
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"
36466 +    }
36467 +
36468 +    set pf_prefix $old_prefix
36469 +}
36470 +
36471 +foreach case {{{signed char} %d (int)} \
36472 +             {{short}       %d (int)}  \
36473 +             {{int}         %d}        \
36474 +             {{long}        %ld}       \
36475 +             {{long long}   %lld}}     {
36476 +    set type [lindex $case 0]
36477 +    set format [lindex $case 1]
36478 +    set cast [lindex $case 2]
36479 +
36480 +    set typeesc [string map {{ } {\ }} $type]
36481 +    set typenospace [string map {{ } -} $type]
36482 +
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} {
36485 +       do_test $type
36486 +    }
36487 +}
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 } {
36493  #    
36494  
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"
36503  #    
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"
36512  #
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}"
36525  }
36526  
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}"
36534  }
36535  
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
36544 --- /dev/null
36545 +++ b/gdb/testsuite/gdb.base/valgrind-attach.c
36546 @@ -0,0 +1,28 @@
36547 +/* This testcase is part of GDB, the GNU debugger.
36548 +
36549 +   Copyright 2009 Free Software Foundation, Inc.
36550 +
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.
36555 +
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.
36560 +
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/>.  */
36563 +
36564 +#include <stdlib.h>
36565 +
36566 +int
36567 +main (void)
36568 +{
36569 +  int *a = malloc (1);
36570 +
36571 +  a[10] = 0;           /* crash-here */
36572 +
36573 +  return 0;
36574 +}
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
36578 --- /dev/null
36579 +++ b/gdb/testsuite/gdb.base/valgrind-attach.exp
36580 @@ -0,0 +1,94 @@
36581 +# Copyright 2009 Free Software Foundation, Inc.
36582 +
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.
36587 +#
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.
36592 +#
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/>.
36595 +
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"
36602 +    return -1
36603 +}
36604 +
36605 +gdb_exit
36606 +gdb_stop_suppressing_tests;
36607 +
36608 +set VALGRIND "valgrind"
36609 +
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]"
36612 +
36613 +set test "spawn valgrind"
36614 +verbose "Spawning $VALGRIND_SPAWN"
36615 +
36616 +if [info exists gdb_spawn_id] {
36617 +    fail $test
36618 +    return -1
36619 +}
36620 +
36621 +if ![is_remote host] {
36622 +    if { [which $VALGRIND] == 0 } then {
36623 +       untested "Couldn't find $VALGRIND"
36624 +       return -1
36625 +    }
36626 +}
36627 +set res [remote_spawn host "$VALGRIND_SPAWN"]
36628 +if { $res < 0 || $res == "" } {
36629 +    perror "Spawning $VALGRIND_SPAWN failed."
36630 +    return -1
36631 +}
36632 +set gdb_spawn_id -1;
36633 +
36634 +gdb_expect {
36635 +    -re "---- Attach to debugger \\? --- \\\[Return/N/n/Y/y/C/c\\\] ---- $" {
36636 +       pass $test
36637 +    }
36638 +    eof {
36639 +       perror "(eof) $VALGRIND never initialized"
36640 +       remote_close host
36641 +       return -1
36642 +    }
36643 +    timeout {
36644 +       perror "(timeout) $VALGRIND never initialized"
36645 +       remote_close host
36646 +       return -1
36647 +    }
36648 +}
36649 +send_gdb "y\n"
36650 +
36651 +set test "spawn gdb"
36652 +set test2 "crash line caught"
36653 +gdb_expect {
36654 +    -re "starting debugger with cmd:.* in main .* crash-here .*\[\r\n\]$gdb_prompt $" {
36655 +       pass $test
36656 +       pass $test2
36657 +    }
36658 +    -re "starting debugger with cmd:.*\[\r\n\]$gdb_prompt $" {
36659 +       pass $test
36660 +       fail $test2
36661 +    }
36662 +    eof {
36663 +       perror "(eof) $GDB never initialized"
36664 +       remote_close host
36665 +       return -1
36666 +    }
36667 +    timeout {
36668 +       perror "(timeout) $GDB never initialized"
36669 +       remote_close host
36670 +       return -1
36671 +    }
36672 +}
36673 +
36674 +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
36678 --- /dev/null
36679 +++ b/gdb/testsuite/gdb.base/valgrind-attach.sh
36680 @@ -0,0 +1,20 @@
36681 +#! /bin/sh
36682 +
36683 +# Copyright 2009 Free Software Foundation, Inc.
36684 +
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.
36689 +#
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.
36694 +#
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/>.
36697 +
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
36704 --- /dev/null
36705 +++ b/gdb/testsuite/gdb.base/vla-overflow.c
36706 @@ -0,0 +1,30 @@
36707 +/* This testcase is part of GDB, the GNU debugger.
36708 +
36709 +   Copyright 2008 Free Software Foundation, Inc.
36710 +
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.
36715 +
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.
36720 +
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/>.  */
36723 +
36724 +#include <stdlib.h>
36725 +
36726 +int
36727 +main (int argc, char **argv)
36728 +{
36729 +  int array[argc];
36730 +
36731 +  array[0] = array[0];
36732 +
36733 +  abort ();
36734 +
36735 +  return 0;
36736 +}
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
36740 --- /dev/null
36741 +++ b/gdb/testsuite/gdb.base/vla-overflow.exp
36742 @@ -0,0 +1,108 @@
36743 +# Copyright 2008 Free Software Foundation, Inc.
36744 +
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.
36749 +#
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.
36754 +#
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/>.
36757 +
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
36767 +# ...
36768 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
36769 +# ...
36770 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
36771 +
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"
36778 +    return -1
36779 +}
36780 +
36781 +set f [open "|getconf PAGESIZE" "r"]
36782 +gets $f pagesize
36783 +close $f
36784 +
36785 +gdb_exit
36786 +gdb_start
36787 +gdb_reinitialize_dir $srcdir/$subdir
36788 +gdb_load ${binfile}
36789 +
36790 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
36791 +
36792 +if { [runto_main] < 0 } {
36793 +    untested vla-overflow
36794 +    return -1
36795 +}
36796 +
36797 +# Get the GDB memory size when we stay at main.
36798 +
36799 +proc memory_v_pages_get {} {
36800 +    global pid_of_gdb pagesize
36801 +    set fd [open "/proc/$pid_of_gdb/statm"]
36802 +    gets $fd line
36803 +    close $fd
36804 +    # number of pages of virtual memory
36805 +    scan $line "%d" drs
36806 +    return $drs
36807 +}
36808 +
36809 +set pages_found [memory_v_pages_get]
36810 +
36811 +set mb_reserve 10
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"
36816 +
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 \"\$@\""
36822 +close $f
36823 +remote_exec host "chmod +x $shfile"
36824 +
36825 +gdb_exit
36826 +set GDBold $GDB
36827 +set GDB "$shfile"
36828 +gdb_start
36829 +set GDB $GDBold
36830 +
36831 +gdb_reinitialize_dir $srcdir/$subdir
36832 +gdb_load ${binfile}
36833 +
36834 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
36835 +
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.
36838 +
36839 +gdb_run_cmd
36840 +
36841 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
36842 +
36843 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
36844 +
36845 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
36846 +
36847 +# `abort' can get expressed as `*__GI_abort'.
36848 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
36849 +
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
36854 --- /dev/null
36855 +++ b/gdb/testsuite/gdb.base/vla.c
36856 @@ -0,0 +1,55 @@
36857 +/* This testcase is part of GDB, the GNU debugger.
36858 +
36859 +   Copyright 2008 Free Software Foundation, Inc.
36860 +
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.
36865 +
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.
36870 +
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/>.  */
36873 +
36874 +#include <string.h>
36875 +
36876 +void
36877 +marker (void)
36878 +{
36879 +}
36880 +
36881 +void
36882 +bar (char *a, char *b, char *c, int size)
36883 +{
36884 +  memset (a, '1', size);
36885 +  memset (b, '2', size);
36886 +  memset (c, '3', 48);
36887 +}
36888 +
36889 +void
36890 +foo (int size)
36891 +{
36892 +  char temp1[size];
36893 +  char temp3[48];
36894 +
36895 +  temp1[size - 1] = '\0';
36896 +  {
36897 +    char temp2[size];
36898 +
36899 +    bar (temp1, temp2, temp3, size);
36900 +
36901 +    marker (); /* break-here */
36902 +  }
36903 +}
36904 +
36905 +int
36906 +main (void)
36907 +{
36908 +  foo (26);
36909 +  foo (78);
36910 +  return 0;
36911 +}
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
36915 --- /dev/null
36916 +++ b/gdb/testsuite/gdb.base/vla.exp
36917 @@ -0,0 +1,62 @@
36918 +# Copyright 2008 Free Software Foundation, Inc.
36919 +
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.
36924 +#
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.
36929 +#
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/>.
36932 +
36933 +set testfile vla
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"
36938 +    return -1
36939 +}
36940 +
36941 +gdb_exit
36942 +gdb_start
36943 +gdb_reinitialize_dir $srcdir/$subdir
36944 +gdb_load ${binfile}
36945 +
36946 +if ![runto_main] {
36947 +    untested vla
36948 +    return -1
36949 +}
36950 +
36951 +gdb_breakpoint [gdb_get_line_number "break-here"]
36952 +
36953 +gdb_continue_to_breakpoint "break-here"
36954 +
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"
36958 +
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"
36962 +
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"
36966 +
36967 +gdb_continue_to_breakpoint "break-here"
36968 +
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"
36972 +
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"
36976 +
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 
36990  
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
36996 --- /dev/null
36997 +++ b/gdb/testsuite/gdb.cp/abstract-origin.cc
36998 @@ -0,0 +1,42 @@
36999 +/* This testcase is part of GDB, the GNU debugger.
37000 +
37001 +   Copyright 2008 Free Software Foundation, Inc.
37002 +
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.
37007 +
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.
37012 +
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/>.
37015 +   */
37016 +
37017 +extern void f (int *);
37018 +
37019 +class A
37020 +{
37021 +public:
37022 +  A(int i);
37023 +};
37024 +
37025 +A::A(int i)
37026 +{
37027 +  static int *problem = new int(i);
37028 +  f (problem);                         /* break-here */
37029 +}
37030 +
37031 +void f (int *)
37032 +{
37033 +}
37034 +
37035 +int
37036 +main (void)
37037 +{
37038 +  A a(42);
37039 +  return 0;
37040 +}
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
37044 --- /dev/null
37045 +++ b/gdb/testsuite/gdb.cp/abstract-origin.exp
37046 @@ -0,0 +1,40 @@
37047 +# Copyright 2008 Free Software Foundation, Inc.
37048 +
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.
37053 +#
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.
37058 +#
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/>.
37061 +
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"
37067 +    return -1
37068 +}
37069 +
37070 +# Get things started.
37071 +
37072 +gdb_exit
37073 +gdb_start
37074 +gdb_reinitialize_dir $srcdir/$subdir
37075 +gdb_load ${binfile}
37076 +
37077 +if ![runto_main] {
37078 +    untested abstract-origin
37079 +    return -1
37080 +}
37081 +
37082 +gdb_breakpoint [gdb_get_line_number "break-here"]
37083 +gdb_continue_to_breakpoint "break-here"
37084 +
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*"
37111  
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.
37117 +
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
37125 +
37126  proc probe_demangler { } {
37127      global gdb_prompt
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
37143  
37144      send_gdb "print &'foo::operator,(foo&)'\n"
37145      gdb_expect {
37146 @@ -97,6 +118,26 @@ proc probe_demangler { } {
37147         }
37148      }
37149  
37150 +    send_gdb "print &'foo::operator char*()'\n"
37151 +    gdb_expect {
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"
37157 +       }
37158 +       -re ".*foo::operator char\\*\\(\\).*\r\n$gdb_prompt $" {
37159 +           # v3 demangler
37160 +           pass "detect dm_operator_char_star"
37161 +       }
37162 +       -re ".*$gdb_prompt $" {
37163 +           fail "detect dm_operator_char_star"
37164 +       }
37165 +       timeout {
37166 +           fail "detect dm_operator_char_star"
37167 +       }
37168 +    }
37169 +
37170      send_gdb "print &'dm_type_char_star'\n"
37171      gdb_expect {
37172         -re ".*dm_type_char_star\\(char \\*\\).*\r\n$gdb_prompt $" {
37173 @@ -166,6 +207,11 @@ proc probe_demangler { } {
37174             # v3 demangler
37175             pass "detect dm_type_long_star"
37176         }
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"
37181 +       }
37182         -re ".*$gdb_prompt $" {
37183             fail "detect dm_type_long_star"
37184         }
37185 @@ -230,6 +276,101 @@ proc probe_demangler { } {
37186             fail "detect dm_type_void_star (timeout)"
37187         }
37188      }
37189 +
37190 +    send_gdb "print &'dm_type_short'\n"
37191 +    gdb_expect {
37192 +       -re ".*dm_type_short\\(short\\).*\r\n$gdb_prompt $" {
37193 +           # v2 and v3 demanglers
37194 +           pass "detect dm_type_short"
37195 +       }
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"
37200 +       }
37201 +       -re ".*$gdb_prompt $" {
37202 +           fail "detect dm_type_short"
37203 +       }
37204 +       timeout {
37205 +           fail "detect dm_type_short (timeout)"
37206 +       }
37207 +    }
37208 +
37209 +    send_gdb "print &'dm_type_unsigned_short'\n"
37210 +    gdb_expect {
37211 +       -re ".*dm_type_unsigned_short\\(unsigned short\\).*\r\n$gdb_prompt $" {
37212 +           # v2 and v3 demanglers
37213 +           pass "detect dm_type_unsigned_short"
37214 +       }
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"
37219 +       }
37220 +       -re ".*$gdb_prompt $" {
37221 +           fail "detect dm_type_unsigned_short"
37222 +       }
37223 +       timeout {
37224 +           fail "detect dm_type_unsigned_short (timeout)"
37225 +       }
37226 +    }
37227 +
37228 +    send_gdb "print &'dm_type_long'\n"
37229 +    gdb_expect {
37230 +       -re ".*dm_type_long\\(long\\).*\r\n$gdb_prompt $" {
37231 +           # v2 and v3 demanglers
37232 +           pass "detect dm_type_long"
37233 +       }
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"
37238 +       }
37239 +       -re ".*$gdb_prompt $" {
37240 +           fail "detect dm_type_long"
37241 +       }
37242 +       timeout {
37243 +           fail "detect dm_type_long (timeout)"
37244 +       }
37245 +    }
37246 +
37247 +    send_gdb "print &'dm_type_unsigned_long'\n"
37248 +    gdb_expect {
37249 +       -re ".*dm_type_unsigned_long\\(unsigned long\\).*\r\n$gdb_prompt $" {
37250 +           # v2 and v3 demanglers
37251 +           pass "detect dm_type_unsigned_long"
37252 +       }
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"
37257 +       }
37258 +       -re ".*$gdb_prompt $" {
37259 +           fail "detect dm_type_unsigned_long"
37260 +       }
37261 +       timeout {
37262 +           fail "detect dm_type_unsigned_long (timeout)"
37263 +       }
37264 +    }
37265 +
37266 +    send_gdb "print &'dm_type_typedef'\n"
37267 +    gdb_expect {
37268 +       -re ".*dm_type_typedef\\(int\\).*\r\n$gdb_prompt $" {
37269 +           # v2 and v3 demanglers
37270 +           pass "detect dm_type_typedef"
37271 +       }
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"
37276 +       }
37277 +       -re ".*$gdb_prompt $" {
37278 +           fail "detect dm_type_typedef"
37279 +       }
37280 +       timeout {
37281 +           fail "detect dm_type_typedef (timeout)"
37282 +       }
37283 +    }
37284  }
37285  
37286  #
37287 @@ -345,8 +486,9 @@ proc print_addr { name } {
37288  
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 {} {
37299  
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);"
37306  
37307  }
37308  
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
37314  
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 {} {
37318      }
37319  
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)"
37323  }
37324  
37325  #
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
37334  
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)"
37351  
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
37357  
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)))"
37362 -
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"
37368 +
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)))"
37373 +
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"
37379 +    } else {
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)"
37383 +
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)"
37389 +    }
37390  }
37391  
37392  proc do_tests {} {
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
37396 --- /dev/null
37397 +++ b/gdb/testsuite/gdb.cp/expand-sals.cc
37398 @@ -0,0 +1,53 @@
37399 +/* This testcase is part of GDB, the GNU debugger.
37400 +
37401 +   Copyright (C) 2009 Free Software Foundation, Inc.
37402 +
37403 +   This file is part of GDB.
37404 +
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.
37409 +
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.
37414 +
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/>.  */
37417 +
37418 +int
37419 +func ()
37420 +{
37421 +  return 42;   /* func-line */
37422 +}
37423 +
37424 +volatile int global_x;
37425 +
37426 +class A
37427 +{
37428 +public:
37429 +  A ()
37430 +    {
37431 +      global_x = func ();      /* caller-line */
37432 +    }
37433 +};
37434 +
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.  */
37439 +
37440 +class B : public A
37441 +{
37442 +};
37443 +
37444 +int
37445 +main (void)
37446 +{
37447 +  A a;
37448 +  B b;
37449 +
37450 +  return 0;    /* exit-line */
37451 +}
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
37455 --- /dev/null
37456 +++ b/gdb/testsuite/gdb.cp/expand-sals.exp
37457 @@ -0,0 +1,100 @@
37458 +# Copyright 2009 Free Software Foundation, Inc.
37459 +
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.
37464 +#
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.
37469 +#
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/>.
37472 +
37473 +if { [skip_cplus_tests] } { continue }
37474 +
37475 +set srcfile expand-sals.cc
37476 +if { [prepare_for_testing expand-sals.exp expand-sals $srcfile {debug c++}] } {
37477 +    return -1
37478 +}
37479 +if ![runto_main] {
37480 +    return -1
37481 +}
37482 +
37483 +gdb_breakpoint [gdb_get_line_number "exit-line"]
37484 +
37485 +gdb_breakpoint [gdb_get_line_number "func-line"]
37486 +gdb_continue_to_breakpoint "func" ".*func-line.*"
37487 +
37488 +gdb_test "up" "caller-line.*"
37489 +
37490 +# PC should not be at the boundary of source lines to make the original bug
37491 +# exploitable.
37492 +
37493 +set test "p/x \$pc"
37494 +set 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)
37498 +       pass $test
37499 +    }
37500 +}
37501 +
37502 +set test "info line"
37503 +set end {}
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)
37507 +       pass $test
37508 +    }
37509 +}
37510 +
37511 +set test "caller line has trailing code"
37512 +if {$pc != $end} {
37513 +    pass $test
37514 +} else {
37515 +    fail $test
37516 +}
37517 +
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.
37520 +set test "break"
37521 +gdb_test_multiple $test $test {
37522 +    -re "Breakpoint \[0-9\]+ at .*, line \[0-9\]+\\. \\(\[2-9\] locations\\)\r\n$gdb_prompt $" {
37523 +       pass $test
37524 +    }
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 *-*-*
37528 +       fail $test
37529 +       return 0
37530 +    }
37531 +}
37532 +
37533 +gdb_continue_to_breakpoint "caller" ".*caller-line.*"
37534 +
37535 +# Test GDB caught this return call and not the next one through B::B()
37536 +gdb_test "bt" \
37537 +        "#0 \[^\r\n\]* (A::)?A \[^\r\n\]*\r\n#1 \[^\r\n\]* main \[^\r\n\]*" \
37538 +        "bt from A"
37539 +
37540 +gdb_continue_to_breakpoint "next caller instance" ".*caller-line.*"
37541 +
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.
37547 +
37548 +gdb_test "bt" \
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"
37551 +
37552 +gdb_continue_to_breakpoint "next caller func" ".*func-line.*"
37553 +
37554 +# Verify GDB really could not catch the originally intended point of the return
37555 +# from func.
37556 +
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  ".*"
37563  
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
37581 --- /dev/null
37582 +++ b/gdb/testsuite/gdb.cp/gdb2495.cc
37583 @@ -0,0 +1,90 @@
37584 +/* This testcase is part of GDB, the GNU debugger.
37585 +
37586 +   Copyright 2008 Free Software Foundation, Inc.
37587 +
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.
37592 +
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.
37597 +
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/>.
37600 +   */
37601 +
37602 +#include <iostream>
37603 +#include <signal.h>
37604 +
37605 +using namespace std;
37606 +
37607 +class SimpleException 
37608 +{
37609 +
37610 +public:
37611 +
37612 +  void raise_signal (int dummy) 
37613 +  {
37614 +    if (dummy > 0)
37615 +      raise(SIGABRT);
37616 +  }
37617 +
37618 +  int  no_throw_function () 
37619 +  {
37620 +    return 1;
37621 +  }
37622 +  
37623 +  void throw_function () 
37624 +  {
37625 +    throw 1;
37626 +  }
37627 +  
37628 +  int throw_function_with_handler () 
37629 +  {
37630 +    try
37631 +      {
37632 +       throw 1;
37633 +      }
37634 +    catch (...)
37635 +      {
37636 +       cout << "Handled" << endl;
37637 +      } 
37638 +    
37639 +    return 2;
37640 +  }
37641 +  
37642 +  void call_throw_function_no_handler () 
37643 +  {
37644 +    throw_function ();
37645 +  }
37646 +  
37647 +  void call_throw_function_handler () 
37648 +  {
37649 +    throw_function_with_handler ();
37650 +  }
37651 +};
37652 +SimpleException exceptions;
37653 +
37654 +int 
37655 +main()
37656 +{
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 ();
37663 +  try 
37664 +    {
37665 +      exceptions.throw_function ();
37666 +      exceptions.call_throw_function_no_handler ();
37667 +    }
37668 +  catch (...)
37669 +    {
37670 +    }
37671 +  return 0;
37672 +}
37673 +
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
37677 --- /dev/null
37678 +++ b/gdb/testsuite/gdb.cp/gdb2495.exp
37679 @@ -0,0 +1,160 @@
37680 +# Copyright 2008 Free Software Foundation, Inc.
37681 +
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.
37686 +#
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.
37691 +#
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/>.
37694 +
37695 +
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
37707 +# functionality.
37708 +
37709 +# This test is largley based off gdb.base/callfuncs.exp.
37710 +
37711 +if $tracelevel then {
37712 +    strace $tracelevel
37713 +}
37714 +
37715 +if { [skip_cplus_tests] } { continue }
37716 +
37717 +set prms_id 2495
37718 +set bug_id 0
37719 +
37720 +set testfile "gdb2495"
37721 +set srcfile ${testfile}.cc
37722 +set binfile $objdir/$subdir/$testfile
37723 +
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++"] {
37727 +    return -1
37728 +}
37729 +
37730 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
37731 +     untested gdb2495.exp
37732 +     return -1
37733 +}
37734 +
37735 +# Some targets can't do function calls, so don't even bother with this
37736 +# test.
37737 +if [target_info exists gdb,cannot_call_functions] {
37738 +    setup_xfail "*-*-*" 2416
37739 +    fail "This target can not call functions"
37740 +    continue
37741 +}
37742 +
37743 +gdb_exit
37744 +gdb_start
37745 +gdb_reinitialize_dir $srcdir/$subdir
37746 +gdb_load ${binfile}
37747 +
37748 +if ![runto_main] then {
37749 +    perror "couldn't run to main"
37750 +    continue
37751 +} 
37752 +
37753 +# See http://sources.redhat.com/gdb/bugs/2495
37754 +
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.
37761 +
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."
37767 +
37768 +# Make sure that after rewinding we are back at the call parent.
37769 +gdb_test "bt" \
37770 +    "#0  main.*" \
37771 +    "bt after returning from a popped frame"
37772 +
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
37775 +# cleaned-up.
37776 +gdb_test "info breakpoints" \
37777 +    "gdb.cp/gdb2495\.cc.*"
37778 +
37779 +# Turn off this new behaviour ...
37780 +send_gdb "set unwind-on-terminating-exception off\n" 
37781 +gdb_expect {
37782 +    -re "$gdb_prompt $" {pass "set unwind-on-terminating-exception"}
37783 +    timeout {fail "(timeout) set  unwind-on-terminating-exception"}
37784 +}
37785 +
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"
37790 +
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.."
37795 +
37796 +
37797 +# Restart back at main
37798 +if ![runto_main] then {
37799 +    perror "couldn't run to main"
37800 +    continue
37801 +} 
37802 +
37803 +
37804 +# Check to see if our new behaviour alters the unwind signal
37805 +# behaviour. It should not. Test both on and off states.
37806 +
37807 +# Turn on unwind on signal  behaviour ...
37808 +send_gdb "set unwindonsignal on\n" 
37809 +gdb_expect {
37810 +    -re "$gdb_prompt $" {pass "set unwindonsignal on"}
37811 +    timeout {fail "(timeout) set  unwindonsignal on"}
37812 +}
37813 +
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"
37818 +
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\".*"
37823 +
37824 +# And reverse. Turn off
37825 +send_gdb "set unwindonsignal off\n" 
37826 +gdb_expect {
37827 +    -re "$gdb_prompt $" {pass "set unwindonsignal off"}
37828 +    timeout {fail "(timeout) set  unwindonsignal off"}
37829 +}
37830 +
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"
37835 +
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
37845  {
37846  public:
37847    virtual int vget_base ();
37848 +  int (*func_ptr) (int);
37849  };
37850  
37851  int Diamond::vget_base ()
37852 @@ -145,6 +146,12 @@ int Diamond::vget_base ()
37853    return this->Left::x + 2000;
37854  }
37855  
37856 +int
37857 +func (int x)
37858 +{
37859 +  return 19 + x;
37860 +}
37861 +
37862  int main ()
37863  {
37864    A a;
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);
37870  
37871    PMI null_pmi;
37872    PMF null_pmf;
37873 @@ -179,6 +187,7 @@ int main ()
37874  
37875    diamond.Left::x = 77;
37876    diamond.Right::x = 88;
37877 +  diamond.func_ptr = func;
37878  
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;
37884  
37885 +  /* A pointer to data member, where the member is itself a pointer to
37886 +     a function.  */
37887 +  diamond_pfunc_ptr = (int (* Diamond::*) (int)) &Diamond::func_ptr;
37888 +
37889    null_pmi = NULL;
37890    null_pmf = NULL;
37891  
37892    pmi = NULL; /* Breakpoint 1 here.  */
37893  
37894 +  // Invalid (uses diamond_pfunc_ptr as a function):
37895 +  // diamond.*diamond_pfunc_ptr (20);
37896 +  (diamond.*diamond_pfunc_ptr) (20);
37897 +
37898    k = (a.*pmf)(3);
37899  
37900    pmi = &A::jj;
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 {
37906      }
37907  }
37908  
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.
37912 +
37913 +gdb_test "ptype diamond_pfunc_ptr" \
37914 +    "type = int \\(\\*Diamond::\\*\\)\\(int\\)"
37915 +
37916 +gdb_test "ptype diamond.*diamond_pfunc_ptr" \
37917 +    "type = int \\(\\*\\)\\(int\\)"
37918 +
37919 +# This one is invalid; () binds more tightly than .*, so it tries to
37920 +# call the member pointer as a normal pointer-to-function.
37921 +
37922 +gdb_test "print diamond.*diamond_pfunc_ptr (20)" \
37923 +    "Invalid data type for function to be called."
37924 +
37925 +# With parentheses, it is valid.
37926 +
37927 +gdb_test "print (diamond.*diamond_pfunc_ptr) (20)" \
37928 +    "$vhn = 39"
37929 +
37930 +# Make sure that we do not interpret this as either a member pointer
37931 +# call or a member function call.
37932 +
37933 +gdb_test "print diamond.func_ptr (20)" \
37934 +    "$vhn = 39"
37935 +
37936  # ==========================
37937  # pointer to member function
37938  # ==========================
37939 @@ -608,6 +635,9 @@ gdb_test_multiple "print (a.*pmf)(3)" $name {
37940      }
37941  }
37942  
37943 +gdb_test "ptype a.*pmf" "type = int \\(A \\*, int\\)"
37944 +gdb_test "ptype (a.*pmf)(3)" "type = int"
37945 +
37946  # Print out a pointer to data member which requires looking into
37947  # a base class.
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
37952 --- /dev/null
37953 +++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.cc
37954 @@ -0,0 +1,20 @@
37955 +namespace A {
37956 +  int x = 11;
37957 +  namespace{
37958 +    int xx = 22;
37959 +  }
37960 +}
37961 +
37962 +using namespace A;
37963 +
37964 +namespace{
37965 +  int xxx = 33;
37966 +};
37967 +
37968 +int main()
37969 +{
37970 +  x;
37971 +  xx;
37972 +  xxx;
37973 +  return 0;
37974 +}
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
37978 --- /dev/null
37979 +++ b/gdb/testsuite/gdb.cp/namespace-multiple-imports.exp
37980 @@ -0,0 +1,49 @@
37981 +# Copyright 2008 Free Software Foundation, Inc.
37982 +
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.
37987 +#
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.
37992 +#
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/>.
37995 +
37996 +if $tracelevel then {
37997 +    strace $tracelevel
37998 +}
37999 +
38000 +set prms_id 0
38001 +set bug_id 0
38002 +
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"
38008 +    return -1
38009 +}
38010 +
38011 +# Get things started.
38012 +
38013 +gdb_exit
38014 +gdb_start
38015 +gdb_reinitialize_dir $srcdir/$subdir
38016 +gdb_load ${binfile}
38017 +
38018 +############################################
38019 +# test printing of namespace imported within
38020 +# the function.
38021 +
38022 +if ![runto_main] then {
38023 +    perror "couldn't run to breakpoint main"
38024 +    continue
38025 +}
38026 +
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
38033 --- /dev/null
38034 +++ b/gdb/testsuite/gdb.cp/namespace-using.cc
38035 @@ -0,0 +1,131 @@
38036 +//--------------------------
38037 +namespace M{
38038 +  int x = 911;
38039 +}
38040 +
38041 +namespace N{
38042 +  int x = 912;
38043 +}
38044 +
38045 +int marker10(){
38046 +  using namespace M;
38047 +  int y = x+1;       // marker10 stop
38048 +  using namespace N;
38049 +  return y;
38050 +}
38051 +//--------------------------
38052 +namespace J {
38053 +    int jx = 44;
38054 +}
38055 +
38056 +namespace K{
38057 +  int marker9(){
38058 +    //x;
38059 +    return marker10();
38060 +  }
38061 +}
38062 +
38063 +namespace L{
38064 +  using namespace J;
38065 +  int marker8(){
38066 +    jx;
38067 +    return K::marker9();
38068 +  }
38069 +}
38070 +//--------------------------
38071 +
38072 +//--------------------------
38073 +namespace G{
38074 +  namespace H  {
38075 +    int ghx = 6;
38076 +  }
38077 +}
38078 +
38079 +namespace I{
38080 +  
38081 +  int marker7(){
38082 +    using namespace G::H;
38083 +    ghx;
38084 +    return L::marker8();
38085 +  }
38086 +}
38087 +//--------------------------
38088 +
38089 +//--------------------------
38090 +namespace E{
38091 +  namespace F{
38092 +    int efx = 5;
38093 +  }
38094 +}
38095 +using namespace E::F;
38096 +int marker6(){
38097 +  efx;
38098 +  return I::marker7();
38099 +}
38100 +//--------------------------
38101 +
38102 +namespace A
38103 +{
38104 +  int _a = 1;
38105 +  int x = 2;
38106 +    
38107 +}
38108 +
38109 +namespace C
38110 +{
38111 +  int cc = 3;
38112 +}
38113 +
38114 +namespace D
38115 +{
38116 +  int dx = 4;
38117 +}
38118 +
38119 +using namespace C;
38120 +int marker5()
38121 +{
38122 +  cc;
38123 +  return marker6();
38124 +}
38125 +
38126 +int marker4()
38127 +{
38128 +  using D::dx;
38129 +  return marker5();
38130 +}
38131 +
38132 +int marker3()
38133 +{
38134 +  return marker4();
38135 +}
38136 +
38137 +int marker2()
38138 +{
38139 +  namespace B = A;
38140 +  B::_a;
38141 +  return marker3();
38142 +}
38143 +
38144 +int marker1()
38145 +{
38146 +  int total = 0;
38147 +    {
38148 +      int b = 1;
38149 +        {
38150 +          using namespace A;
38151 +          int c = 2;
38152 +            {
38153 +              int d = 3;
38154 +              total = _a + b + c + d + marker2(); // marker1 stop
38155 +            }
38156 +        }
38157 +    }
38158 +  return total;
38159 +}
38160 +
38161 +int main()
38162 +{
38163 +  using namespace A;
38164 +  _a;
38165 +  return marker1();
38166 +}
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
38170 --- /dev/null
38171 +++ b/gdb/testsuite/gdb.cp/namespace-using.exp
38172 @@ -0,0 +1,183 @@
38173 +# Copyright 2008 Free Software Foundation, Inc.
38174 +
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.
38179 +#
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.
38184 +#
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/>.
38187 +
38188 +if $tracelevel then {
38189 +    strace $tracelevel
38190 +}
38191 +
38192 +set prms_id 0
38193 +set bug_id 0
38194 +
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"
38200 +    return -1
38201 +}
38202 +
38203 +# Get things started.
38204 +
38205 +gdb_exit
38206 +gdb_start
38207 +gdb_reinitialize_dir $srcdir/$subdir
38208 +gdb_load ${binfile}
38209 +
38210 +############################################
38211 +# test printing of namespace imported within
38212 +# the function.
38213 +
38214 +if ![runto_main] then {
38215 +    perror "couldn't run to breakpoint main"
38216 +    continue
38217 +}
38218 +
38219 +gdb_test "print _a" "= 1"
38220 +
38221 +# Test that names are not printed when they 
38222 +# are not imported
38223 +
38224 +gdb_breakpoint marker3
38225 +gdb_continue_to_breakpoint "marker3"
38226 +
38227 +#send_gdb "break marker3\n"
38228 +#send_gdb "continue\n"
38229 +
38230 +gdb_test "print _a" "No symbol \"_a\" in current context." "Print _a without import"
38231 +
38232 +gdb_exit
38233 +gdb_start
38234 +gdb_reinitialize_dir $srcdir/$subdir
38235 +gdb_load ${binfile}
38236 +
38237 +
38238 +############################################
38239 +# test printing of namespace imported into 
38240 +# a scope containing the pc.
38241 +
38242 +if ![runto_main] then {
38243 +    perror "couldn't run to breakpoint main"
38244 +    continue
38245 +}
38246 +
38247 +gdb_breakpoint [gdb_get_line_number "marker1 stop"]
38248 +gdb_continue_to_breakpoint "marker1 stop"
38249 +
38250 +gdb_test "print _a" "= 1" "print _a in a nested scope"
38251 +
38252 +
38253 +gdb_exit
38254 +gdb_start
38255 +gdb_reinitialize_dir $srcdir/$subdir
38256 +gdb_load ${binfile}
38257 +
38258 +############################################
38259 +# test printing of namespace imported into 
38260 +# file scope.
38261 +
38262 +
38263 +if ![runto marker5] then {
38264 +    perror "couldn't run to breakpoint marker5"
38265 +    continue
38266 +}
38267 +
38268 +gdb_test "print cc" "= 3"
38269 +
38270 +gdb_exit
38271 +gdb_start
38272 +gdb_reinitialize_dir $srcdir/$subdir
38273 +gdb_load ${binfile}
38274 +
38275 +
38276 +############################################
38277 +# Test printing of namespace aliases
38278 +
38279 +if ![runto marker2] then {
38280 +    perror "couldn't run to breakpoint marker2"
38281 +    continue
38282 +}
38283 +
38284 +gdb_test "print B::_a" "= 1"
38285 +
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"
38288 +
38289 +gdb_exit
38290 +gdb_start
38291 +gdb_reinitialize_dir $srcdir/$subdir
38292 +gdb_load ${binfile}
38293 +
38294 +
38295 +############################################
38296 +# Test printing of namespace aliases
38297 +
38298 +if ![runto marker4] then {
38299 +    perror "couldn't run to breakpoint marker4"
38300 +    continue
38301 +}
38302 +
38303 +gdb_test "print dx" "= 4"
38304 +
38305 +############################################
38306 +# Test printing of namespace aliases
38307 +
38308 +if ![runto marker6] then {
38309 +    perror "couldn't run to breakpoint marker6"
38310 +    continue
38311 +}
38312 +
38313 +gdb_test "print efx" "= 5"
38314 +
38315 +############################################
38316 +# Test printing of variables imported from
38317 +# nested namespaces
38318 +
38319 +if ![runto I::marker7] then {
38320 +    perror "couldn't run to breakpoint I::marker7"
38321 +    continue
38322 +}
38323 +
38324 +gdb_test "print ghx" "= 6"
38325 +
38326 +############################################
38327 +# Test that variables are not printed in a namespace
38328 +# that is sibling to the namespace containing an import
38329 +
38330 +if ![runto L::marker8] then {
38331 +    perror "couldn't run to breakpoint L::marker8"
38332 +    continue
38333 +}
38334 +
38335 +gdb_test "print jx" "= 44"
38336 +
38337 +gdb_breakpoint "K::marker9"
38338 +gdb_continue_to_breakpoint "K::marker9"
38339 +
38340 +gdb_test "print jx" "No symbol \"jx\" in current context."
38341 +
38342 +############################################
38343 +# Test that variables are only printed after the line
38344 +# containing the import
38345 +
38346 +if ![runto_main] then {
38347 +    perror "couldn't run to breakpoint main"
38348 +    continue
38349 +}
38350 +
38351 +gdb_breakpoint [gdb_get_line_number "marker10 stop"]
38352 +gdb_continue_to_breakpoint "marker10 stop"
38353 +
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
38360 @@ -24,6 +24,7 @@
38361  # for namespaces.
38362  # Note: As of 2000-06-03, they passed under g++ - djb
38363  
38364 +load_lib "cp-support.exp"
38365  
38366  if $tracelevel then {
38367          strace $tracelevel
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" \
38379 +       {
38380 +           { field public "int x;" }
38381 +       }
38382 +cp_test_ptype_class \
38383 +       "ptype ::C::CClass::NestedClass" "" "class" "C::CClass::NestedClass" \
38384 +       {
38385 +           { field public "int y;" }
38386 +       }
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\"
38391  
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" \
38398 +       {
38399 +           { field public "int z;" }
38400 +       }
38401  gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"."
38402  
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} {
38430  }
38431  
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++.
38436  
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 "> $"
38453  
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
38457  
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 {
38480  
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 {
38524  
38525  send_gdb "print UC\n"
38526  gdb_expect {
38527 -    -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
38528 +    -re ".\[0-9\]* = 21 '\.25'\.*$gdb_prompt $" {
38529          pass "print value of UC"
38530        }
38531      -re ".*$gdb_prompt $" { fail "print value of UC" }
38532 @@ -557,7 +557,7 @@ gdb_expect {
38533  
38534  send_gdb "print rUC\n"
38535  gdb_expect {
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"
38539        }
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 {
38546  
38547  send_gdb "print Foo<volatile char *>::foo\n"   
38548  gdb_expect {   
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 $"
38552      {
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
38555 -       # heads.
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"
38559      }
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 {
38563  
38564  send_gdb "print Foo<volatile char*>::foo\n"   
38565  gdb_expect {   
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 $"
38569      {
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
38572 -       # heads.
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"
38576      }
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"
38580  gdb_expect {   
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"
38587     }
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
38591 --- /dev/null
38592 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
38593 @@ -0,0 +1,42 @@
38594 +/* This testcase is part of GDB, the GNU debugger.
38595 +
38596 +   Copyright 2004 Free Software Foundation, Inc.
38597 +
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.
38602 +
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.
38607
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,
38611 +   USA.  */
38612 +
38613 +
38614 +/* The function `func1' traced into must have debug info on offset > 0;
38615 +   (DW_UNSND (attr)).  This is the reason of `func0' existence.  */
38616 +
38617 +void
38618 +func0(int a, int b)
38619 +{
38620 +}
38621 +
38622 +/* `func1' being traced into must have some arguments to dump.  */
38623 +
38624 +void
38625 +func1(int a, int b)
38626 +{
38627 +  func0 (a,b);
38628 +}
38629 +
38630 +int
38631 +main(void)
38632 +{
38633 +  func1 (1, 2);
38634 +  return 0;
38635 +}
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
38639 --- /dev/null
38640 +++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
38641 @@ -0,0 +1,79 @@
38642 +# Copyright 2006 Free Software Foundation, Inc.
38643 +
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.
38648 +# 
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.
38653 +# 
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.
38657 +
38658 +# Minimal DWARF-2 unit test
38659 +
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*]} {
38668 +    return 0  
38669 +}
38670 +
38671 +set testfile "dw2-stripped"
38672 +set srcfile ${testfile}.c
38673 +set binfile ${objdir}/${subdir}/${testfile}.x
38674 +
38675 +remote_exec build "rm -f ${binfile}"
38676 +
38677 +# get the value of gcc_compiled
38678 +if [get_compiler_info ${binfile}] {
38679 +    return -1
38680 +}
38681 +
38682 +# This test can only be run on gcc as we use additional_flags=FIXME
38683 +if {$gcc_compiled == 0} {
38684 +    return 0
38685 +}
38686 +
38687 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
38688 +    return -1
38689 +}
38690 +
38691 +remote_exec build "objcopy -R .debug_loc ${binfile}"
38692 +set strip_output [remote_exec build "objdump -h ${binfile}"]
38693 +
38694 +set test "stripping test file preservation"
38695 +if [ regexp ".debug_info " $strip_output]  {
38696 +    pass "$test (.debug_info preserved)"
38697 +} else {
38698 +    fail "$test (.debug_info got also stripped)"
38699 +}
38700 +
38701 +set test "stripping test file functionality"
38702 +if [ regexp ".debug_loc " $strip_output]  {
38703 +    fail "$test (.debug_loc still present)"
38704 +} else {
38705 +    pass "$test (.debug_loc stripped)"
38706 +}
38707 +
38708 +gdb_exit
38709 +gdb_start
38710 +gdb_reinitialize_dir $srcdir/$subdir
38711 +gdb_load ${binfile}
38712 +
38713 +# For C programs, "start" should stop in main().
38714 +
38715 +gdb_test "start" \
38716 +         ".*main \\(\\) at .*" \
38717 +         "start"
38718 +gdb_test "step" \
38719 +         "func.* \\(.*\\) at .*" \
38720 +         "step"
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
38725 @@ -28,7 +28,8 @@
38726         /* CU die */
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++) -  */
38732  
38733  .Larray_type:
38734         .uleb128        2                       /* Abbrev: DW_TAG_array_type */
38735 @@ -60,6 +61,10 @@
38736  .Lconst_type:
38737         .uleb128        6                       /* Abbrev: DW_TAG_const_type */
38738         .4byte          .Larray_type-.Lcu1_begin/* DW_AT_type */
38739 +
38740 +       .uleb128        7                       /* Abbrev: DW_TAG_variable (name "") */
38741 +       .4byte          .Lemptyname             /* DW_AT_name */
38742 +
38743         .byte           0                       /* End of children of CU */
38744  .Lcu1_end:
38745  
38746 @@ -126,6 +131,15 @@
38747         .uleb128        0x13                    /* DW_FORM_ref4 */
38748         .byte           0x0                     /* Terminator */
38749         .byte           0x0                     /* Terminator */
38750 +
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 */
38758 +
38759         .byte           0x0                     /* Terminator */
38760  
38761  /* String table */
38762 @@ -140,3 +154,5 @@
38763         .string         "a_string"
38764  .Lvarcontents:
38765         .string         "hello world!\n"
38766 +.Lemptyname:
38767 +       .string         ""
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
38771 --- /dev/null
38772 +++ b/gdb/testsuite/gdb.fortran/common-block.exp
38773 @@ -0,0 +1,101 @@
38774 +# Copyright 2008 Free Software Foundation, Inc.
38775 +
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.
38780 +# 
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.
38785 +# 
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.  
38789 +
38790 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
38791 +
38792 +set testfile "common-block"
38793 +set srcfile ${testfile}.f90
38794 +set binfile ${objdir}/${subdir}/${testfile}
38795 +
38796 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
38797 +    untested "Couldn't compile ${srcfile}"
38798 +    return -1
38799 +}
38800 +
38801 +gdb_exit
38802 +gdb_start
38803 +gdb_reinitialize_dir $srcdir/$subdir
38804 +gdb_load ${binfile}
38805 +
38806 +if ![runto MAIN__] then {
38807 +    perror "couldn't run to breakpoint MAIN__"
38808 +    continue
38809 +}
38810 +
38811 +gdb_breakpoint [gdb_get_line_number "stop-here-out"]
38812 +gdb_continue_to_breakpoint "stop-here-out"
38813 +
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
38818 +#set suffix "_"
38819 +set suffix ""
38820 +
38821 +set int4 {(integer\(kind=4\)|INTEGER\(4\))}
38822 +set real4 {(real\(kind=4\)|REAL\(4\))}
38823 +set real8 {(real\(kind=8\)|REAL\(8\))}
38824 +
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."
38831 +
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"
38834 +
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"
38841 +
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"
38848 +
38849 +gdb_breakpoint [gdb_get_line_number "stop-here-in"]
38850 +gdb_continue_to_breakpoint "stop-here-in"
38851 +
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"
38858 +
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"
38861 +
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"
38868 +
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
38878 --- /dev/null
38879 +++ b/gdb/testsuite/gdb.fortran/common-block.f90
38880 @@ -0,0 +1,67 @@
38881 +! Copyright 2008 Free Software Foundation, Inc.
38882 +!
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.
38887 +!
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.
38892 +!
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.
38896 +!
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>.
38900 +
38901 +subroutine in
38902 +
38903 +   INTEGER*4            ix
38904 +   REAL*4               iy2
38905 +   REAL*8               iz
38906 +
38907 +   INTEGER*4            ix_x
38908 +   REAL*4               iy_y
38909 +   REAL*8               iz_z2
38910 +
38911 +   common /fo_o/ix,iy2,iz
38912 +   common /foo/ix_x,iy_y,iz_z2
38913 +
38914 +   iy = 5
38915 +   iz_z = 55
38916 +
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
38919 +
38920 +   ix = 0                                      ! stop-here-in
38921 +
38922 +end subroutine in
38923 +
38924 +program common_test
38925 +
38926 +   INTEGER*4            ix
38927 +   REAL*4               iy
38928 +   REAL*8               iz
38929 +
38930 +   INTEGER*4            ix_x
38931 +   REAL*4               iy_y
38932 +   REAL*8               iz_z
38933 +
38934 +   common /foo/ix,iy,iz
38935 +   common /fo_o/ix_x,iy_y,iz_z
38936 +
38937 +   ix = 1
38938 +   iy = 2.0
38939 +   iz = 3.0
38940 +
38941 +   ix_x = 11
38942 +   iy_y = 22.0
38943 +   iz_z = 33.0
38944 +
38945 +   call in                                     ! stop-here-out
38946 +
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
38951 --- /dev/null
38952 +++ b/gdb/testsuite/gdb.fortran/dynamic.exp
38953 @@ -0,0 +1,156 @@
38954 +# Copyright 2007 Free Software Foundation, Inc.
38955 +
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.
38960 +# 
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.
38965 +# 
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.  
38969 +
38970 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
38971 +
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
38976 +
38977 +set testfile "dynamic"
38978 +set srcfile ${testfile}.f90
38979 +set binfile ${objdir}/${subdir}/${testfile}
38980 +
38981 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
38982 +    untested "Couldn't compile ${srcfile}"
38983 +    return -1
38984 +}
38985 +
38986 +gdb_exit
38987 +gdb_start
38988 +gdb_reinitialize_dir $srcdir/$subdir
38989 +gdb_load ${binfile}
38990 +
38991 +if ![runto MAIN__] then {
38992 +    perror "couldn't run to breakpoint MAIN__"
38993 +    continue
38994 +}
38995 +
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"
39003 +
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"
39010 +
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"
39020 +
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"
39030 +
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"
39035 +
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\\."
39044 +
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"
39052 +
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, .\]*\\)"
39057 +
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, .\]*\\)"
39066 +
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"
39080 +
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"
39097 +
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\\) " {
39101 +       pass $test
39102 +    }
39103 +}
39104 +set test "quit #2"
39105 +gdb_test_multiple "y" $test {
39106 +    eof {
39107 +       pass $test
39108 +    }
39109 +}
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
39113 --- /dev/null
39114 +++ b/gdb/testsuite/gdb.fortran/dynamic.f90
39115 @@ -0,0 +1,98 @@
39116 +! Copyright 2007 Free Software Foundation, Inc.
39117 +!
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.
39122 +!
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.
39127 +!
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.
39131 +!
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>.
39135 +
39136 +subroutine baz
39137 +  real, target, allocatable :: varx (:, :, :)
39138 +  real, pointer :: varv (:, :, :)
39139 +  real, target :: varu (1, 2, 3)
39140 +  logical :: l
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)
39163 +  varv => varu
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
39172 +  vary(1, 1) = 8
39173 +  vary(2, 2) = 9
39174 +  vary(1, 3) = 10
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)
39180 +  real :: varz (*)
39181 +  real :: vart (2:11, 7:*)
39182 +  varz(1:3) = 4
39183 +  varz(2) = 5                                   ! varz-almostfilled
39184 +  vart(2,7) = vart(2,7)
39185 +end subroutine bar
39186 +program test
39187 +  interface
39188 +    subroutine foo (vary, varw)
39189 +    real :: vary (:, :)
39190 +    real :: varw (:, :, :)
39191 +    end subroutine
39192 +  end interface
39193 +  interface
39194 +    subroutine bar (varz, vart)
39195 +    real :: varz (*)
39196 +    real :: vart (2:11, 7:*)
39197 +    end subroutine
39198 +  end interface
39199 +  real :: x (10, 10), y (5), z(8, 8, 8)
39200 +  x(:,:) = 1
39201 +  y(:) = 2
39202 +  z(:,:,:) = 3
39203 +  call baz
39204 +  call foo (x, z(2:6, 4:7, 6:8))
39205 +  call bar (y, x)
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
39213 +end
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
39217 --- /dev/null
39218 +++ b/gdb/testsuite/gdb.fortran/logical.exp
39219 @@ -0,0 +1,44 @@
39220 +# Copyright 2007 Free Software Foundation, Inc.
39221 +
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.
39226 +# 
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.
39231 +# 
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.  
39235 +
39236 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
39237 +
39238 +set testfile "logical"
39239 +set srcfile ${testfile}.f90
39240 +set binfile ${objdir}/${subdir}/${testfile}
39241 +
39242 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
39243 +    untested "Couldn't compile ${srcfile}"
39244 +    return -1
39245 +}
39246 +
39247 +gdb_exit
39248 +gdb_start
39249 +gdb_reinitialize_dir $srcdir/$subdir
39250 +gdb_load ${binfile}
39251 +
39252 +if ![runto MAIN__] then {
39253 +    perror "couldn't run to breakpoint MAIN__"
39254 +    continue
39255 +}
39256 +
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
39267 --- /dev/null
39268 +++ b/gdb/testsuite/gdb.fortran/logical.f90
39269 @@ -0,0 +1,33 @@
39270 +! Copyright 2008 Free Software Foundation, Inc.
39271 +!
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.
39276 +!
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.
39281 +!
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.
39285 +!
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>.
39289 +
39290 +program test
39291 +  logical :: l
39292 +  logical (kind=1) :: l1
39293 +  logical (kind=2) :: l2
39294 +  logical (kind=4) :: l4
39295 +  logical (kind=8) :: l8
39296 +  l = .TRUE.
39297 +  l1 = .TRUE.
39298 +  l2 = .TRUE.
39299 +  l4 = .TRUE.
39300 +  l8 = .TRUE.
39301 +  l = .FALSE.                                  ! stop-here
39302 +end
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
39306 --- /dev/null
39307 +++ b/gdb/testsuite/gdb.fortran/string.exp
39308 @@ -0,0 +1,72 @@
39309 +# Copyright 2008 Free Software Foundation, Inc.
39310 +
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.
39315 +# 
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.
39320 +# 
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.  
39324 +
39325 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
39326 +
39327 +# This file is part of the gdb testsuite.  It contains tests for Fortran
39328 +# strings with dynamic length.
39329 +
39330 +set testfile "string"
39331 +set srcfile ${testfile}.f90
39332 +set binfile ${objdir}/${subdir}/${testfile}
39333 +
39334 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
39335 +    untested "Couldn't compile ${srcfile}"
39336 +    return -1
39337 +}
39338 +
39339 +gdb_exit
39340 +gdb_start
39341 +gdb_reinitialize_dir $srcdir/$subdir
39342 +gdb_load ${binfile}
39343 +
39344 +if ![runto MAIN__] then {
39345 +    perror "couldn't run to breakpoint MAIN__"
39346 +    continue
39347 +}
39348 +
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."
39363 +
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"
39368 +
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\\) " {
39372 +       pass $test
39373 +    }
39374 +}
39375 +set test "quit #2"
39376 +gdb_test_multiple "y" $test {
39377 +    eof {
39378 +       pass $test
39379 +    }
39380 +}
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
39384 --- /dev/null
39385 +++ b/gdb/testsuite/gdb.fortran/string.f90
39386 @@ -0,0 +1,37 @@
39387 +! Copyright 2008 Free Software Foundation, Inc.
39388 +!
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.
39393 +!
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.
39398 +!
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.
39402 +!
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>.
39406 +
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)
39412 +  c = 'c'
39413 +  d = 'd'
39414 +  e = 'e'                                       ! var-init
39415 +  f = 'f'
39416 +  f(1,9) = 'f2'
39417 +  c = 'c'                                       ! var-finish
39418 +end subroutine foo
39419 +  character (len=4) :: g, h (1:7, 8:10)
39420 +  g = 'g'
39421 +  h = 'h'
39422 +  call foo (g, h)
39423 +end
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"
39430                 set command "step"
39431             }
39432 +           -re ".*python_script = 0.*$gdb_prompt $" {
39433 +               set description "step over python_script initialization"
39434 +               set command "step"
39435 +           }
39436             -re ".*time_at_startup = get_run_time.*$gdb_prompt $" {
39437                 set description "next over get_run_time and everything it calls"
39438                 set command "next"
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
39442 --- /dev/null
39443 +++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
39444 @@ -0,0 +1,22 @@
39445 +/* This file is part of GDB, the GNU debugger.
39446 +
39447 +   Copyright 2009 Free Software Foundation, Inc.
39448 +
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.
39453 +
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.
39458 +
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/>.  */
39461 +
39462 +int
39463 +func (int *arr)
39464 +{
39465 +  return arr[0];
39466 +}
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
39470 --- /dev/null
39471 +++ b/gdb/testsuite/gdb.opt/array-from-register.c
39472 @@ -0,0 +1,28 @@
39473 +/* This file is part of GDB, the GNU debugger.
39474 +
39475 +   Copyright 2009 Free Software Foundation, Inc.
39476 +
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.
39481 +
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.
39486 +
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/>.  */
39489 +
39490 +extern int func (int *arr);
39491 +
39492 +int
39493 +main (void)
39494 +{
39495 +  int arr[] = { 42 };
39496 +
39497 +  func (arr);
39498 +
39499 +  return 0;
39500 +}
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
39504 --- /dev/null
39505 +++ b/gdb/testsuite/gdb.opt/array-from-register.exp
39506 @@ -0,0 +1,33 @@
39507 +# Copyright 2009 Free Software Foundation, Inc.
39508 +#
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.
39513 +#
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.
39518 +#
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.
39522 +#
39523 +# This file is part of the gdb testsuite.
39524 +
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}] } {
39528 +    return -1
39529 +}
39530 +
39531 +if ![runto func] then {
39532 +    return -1
39533 +}
39534 +
39535 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
39536 +
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
39544 @@ -1,7 +1,7 @@
39545  VPATH = @srcdir@
39546  srcdir = @srcdir@
39547  
39548 -EXECUTABLES = python-value
39549 +EXECUTABLES = python-value python-prettyprint python-template
39550  
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
39556 --- /dev/null
39557 +++ b/gdb/testsuite/gdb.python/find.c
39558 @@ -0,0 +1,64 @@
39559 +/* Testcase for the search_memory Python function.
39560 +   This testcase is part of GDB, the GNU debugger.
39561 +
39562 +   Copyright 2009 Free Software Foundation, Inc.
39563 +
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.
39568 +
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.
39573 +
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/>.
39576 +
39577 +   Please email any bugs, comments, and/or additions to this file to:
39578 +   bug-gdb@gnu.org  */
39579 +
39580 +/* Based on the gdb.base/find.c testcase.  */
39581 +
39582 +#include <stdlib.h>
39583 +#include <stdint.h>
39584 +
39585 +#define CHUNK_SIZE 16000 /* same as findcmd.c's */
39586 +#define BUF_SIZE (2 * CHUNK_SIZE) /* at least two chunks */
39587 +
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];
39592 +
39593 +static char *search_buf;
39594 +static int search_buf_size;
39595 +
39596 +static int x;
39597 +
39598 +static void
39599 +stop_here ()
39600 +{
39601 +  x = 1; // stop here
39602 +}
39603 +
39604 +static void
39605 +init_bufs ()
39606 +{
39607 +  search_buf_size = BUF_SIZE;
39608 +  search_buf = malloc (search_buf_size);
39609 +  if (search_buf == NULL)
39610 +    exit (1);
39611 +  memset (search_buf, 'x', search_buf_size);
39612 +}
39613 +
39614 +int
39615 +main ()
39616 +{
39617 +  init_bufs ();
39618 +
39619 +  stop_here ();
39620 +
39621 +  return 0;
39622 +}
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
39626 --- /dev/null
39627 +++ b/gdb/testsuite/gdb.python/find.exp
39628 @@ -0,0 +1,203 @@
39629 +# Copyright 2008, 2009 Free Software Foundation, Inc.
39630 +
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.
39635 +#
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.
39640 +#
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/>.
39643 +
39644 +# This tests the search_memory Python function.
39645 +# Based on the gdb.base/find.exp testcase.
39646 +
39647 +if $tracelevel then {
39648 +    strace $tracelevel
39649 +}
39650 +
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"
39661 +           }
39662 +       }]} {
39663 +           return 1
39664 +       }
39665 +    }
39666 +    return 0
39667 +}
39668 +
39669 +set testfile "find"
39670 +set srcfile ${testfile}.c
39671 +set binfile ${objdir}/${subdir}/${testfile}
39672 +
39673 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } {
39674 +    untested find.exp
39675 +    return -1
39676 +}
39677 +
39678 +gdb_exit
39679 +gdb_start
39680 +gdb_reinitialize_dir $srcdir/$subdir
39681 +gdb_load ${binfile}
39682 +
39683 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
39684 +    -re "not supported.*$gdb_prompt $" {
39685 +      unsupported "python support is disabled"
39686 +      return -1
39687 +    }
39688 +    -re "$gdb_prompt $"        {}
39689 +}
39690 +
39691 +gdb_test "break $srcfile:stop_here" \
39692 +    "Breakpoint.*at.* file .*$srcfile, line.*" \
39693 +    "breakpoint function in file"
39694 +
39695 +gdb_run_cmd
39696 +gdb_expect {
39697 +    -re "Breakpoint \[0-9\]+,.*stop_here.* at .*$srcfile:.*$gdb_prompt $" {
39698 +       pass "run until function breakpoint"
39699 +    }
39700 +    -re "$gdb_prompt $" {
39701 +       fail "run until function breakpoint"
39702 +    }
39703 +    timeout {
39704 +       fail "run until function breakpoint (timeout)"
39705 +    }
39706 +}
39707 +
39708 +# We've now got the target program in a state where we can test "find".
39709 +
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]"
39717 +
39718 +# Test string pattern.
39719 +
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 ()" "" ""
39724 +
39725 +gdb_test "py print gdb.search_memory (start_addr, length, 'aaa')" \
39726 +  "${two_patterns_found}" "find string pattern"
39727 +
39728 +# Test not finding pattern because search range too small, with
39729 +# potential find at the edge of the range.
39730 +
39731 +gdb_test "py print gdb.search_memory (start_addr, 10+3, 'aaaa')" \
39732 +  "${pattern_not_found}" "pattern not found at end of range"
39733 +
39734 +# Increase the search range by 1 and we should find the pattern.
39735 +
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"
39738 +
39739 +# Test max-count with size, with different parameter position
39740 +
39741 +gdb_test "py print gdb.search_memory (start_addr, length, \[0x61, 0x61\], 1, 1)" \
39742 +  "${one_pattern_found}" "size = 1, max_count = 1"
39743 +
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"
39746 +
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"
39749 +
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"
39752 +
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"
39755 +
39756 +# Test 16-bit pattern.
39757 +
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')" "" ""
39763 +
39764 +gdb_test "py print gdb.search_memory (start_addr, length, 0x1234, 2)" \
39765 +  "${one_pattern_found}" "find 16-bit pattern, with python pattern"
39766 +
39767 +gdb_test "py print gdb.search_memory (start_addr, length, pattern)" \
39768 +  "${one_pattern_found}" "find 16-bit pattern, with value pattern"
39769 +
39770 +# Test 32-bit pattern.
39771 +
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')" "" ""
39777 +
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"
39782 +
39783 +# Test 64-bit pattern.
39784 +
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')" "" ""
39790 +
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"
39795 +
39796 +# Test mixed-sized patterns.
39797 +
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')" "" ""
39806 +
39807 +gdb_test "py print gdb.search_memory (start_addr, 100, \[pattern1, pattern2, pattern3\])" \
39808 +    "${one_pattern_found}" "find mixed-sized pattern"
39809 +
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.
39813 +
39814 +set CHUNK_SIZE 16000 ;
39815 +
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')" "" ""
39820 +
39821 +gdb_test "py print gdb.search_memory (start_addr, length, 0x12345678, 4)" \
39822 +  "${two_patterns_found}" "search spanning large range"
39823 +
39824 +# For native targets, test a pattern straddling a chunk boundary.
39825 +
39826 +if [isnative] {
39827 +    gdb_test "set *(int32_t*) &search_buf\[${CHUNK_SIZE}-1\] = 0xfdb97531" "" ""
39828 +
39829 +    gdb_test "py print gdb.search_memory (start_addr, length, 0xfdb97531, 4)" \
39830 +      "${one_pattern_found}" "find pattern straddling chunk boundary"
39831 +}
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" \
39837  
39838  gdb_test "prefix_cmd subcmd ugh" "subcmd output, arg = ugh" "call subcmd"
39839  
39840 +# Test prefix command using keyword arguments.
39841 +
39842 +gdb_py_test_multiple "input prefix command, keyword arguments" \
39843 +  "python" "" \
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 ()" "" \
39850 +  "end" ""
39851 +
39852 +gdb_test "prefix_cmd2 argh" "prefix_cmd2 output, arg = argh" "call prefix command, keyword arguments"
39853 +
39854 +gdb_py_test_multiple "input subcommand under prefix_cmd2" \
39855 +  "python" "" \
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" "" \
39861 +  "subcmd ()" "" \
39862 +  "end" ""
39863 +
39864 +gdb_test "prefix_cmd2 subcmd ugh" "subcmd output, arg = ugh" "call subcmd under prefix_cmd2"
39865 +
39866  # Test a subcommand in an existing GDB prefix.
39867  
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
39872 --- /dev/null
39873 +++ b/gdb/testsuite/gdb.python/python-frame.c
39874 @@ -0,0 +1,14 @@
39875 +int f2 (int a)
39876 +{
39877 +  return ++a;
39878 +}
39879 +
39880 +int f1 (int a, int b)
39881 +{
39882 +  return f2(a) + b;
39883 +}
39884 +
39885 +int main (int argc, char *argv[])
39886 +{
39887 +  return f1 (1, 2);
39888 +}
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
39892 --- /dev/null
39893 +++ b/gdb/testsuite/gdb.python/python-frame.exp
39894 @@ -0,0 +1,92 @@
39895 +# Copyright (C) 2009 Free Software Foundation, Inc.
39896 +
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.
39901 +#
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.
39906 +#
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/>.
39909 +
39910 +# This file is part of the GDB testsuite.  It tests the mechanism
39911 +# exposing values to Python.
39912 +
39913 +if $tracelevel then {
39914 +    strace $tracelevel
39915 +}
39916 +
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}"
39922 +    return -1
39923 +}
39924 +
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
39929 +
39930 +  gdb_test_multiple $cmd $name {
39931 +      -re "Traceback.*$gdb_prompt $"  { fail $name }
39932 +      -re "$gdb_prompt $"            { if $report_pass { pass $name } }
39933 +  }
39934 +}
39935 +
39936 +# Start with a fresh gdb.
39937 +
39938 +gdb_exit
39939 +gdb_start
39940 +gdb_reinitialize_dir $srcdir/$subdir
39941 +gdb_load ${binfile}
39942 +
39943 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
39944 +    -re "not supported.*$gdb_prompt $" {
39945 +      unsupported "python support is disabled"
39946 +      return -1
39947 +    }
39948 +    -re "$gdb_prompt $"        {}
39949 +}
39950 +
39951 +# The following tests require execution.
39952 +
39953 +if ![runto_main] then {
39954 +    fail "Can't run to main"
39955 +    return 0
39956 +}
39957 +
39958 +gdb_breakpoint "f2"
39959 +gdb_continue_to_breakpoint "breakpoint at f2"
39960 +gdb_test "up" "" ""
39961 +
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
39966 +
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"
39982 +
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"
39985 +
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
39990 --- /dev/null
39991 +++ b/gdb/testsuite/gdb.python/python-function.exp
39992 @@ -0,0 +1,79 @@
39993 +# Copyright (C) 2009 Free Software Foundation, Inc.
39994 +
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.
39999 +#
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.
40004 +#
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/>.
40007 +
40008 +# This file is part of the GDB testsuite.  It tests the mechanism
40009 +# exposing convenience functions to Python.
40010 +
40011 +if $tracelevel then {
40012 +    strace $tracelevel
40013 +}
40014 +
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"
40025 +           }
40026 +       }]} {
40027 +           return 1
40028 +       }
40029 +    }
40030 +    return 0
40031 +}
40032 +
40033 +# Start with a fresh gdb.
40034 +
40035 +gdb_exit
40036 +gdb_start
40037 +gdb_reinitialize_dir $srcdir/$subdir
40038 +
40039 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
40040 +    -re "not supported.*$gdb_prompt $" {
40041 +      unsupported "python support is disabled"
40042 +      return -1
40043 +    }
40044 +    -re "$gdb_prompt $"        {}
40045 +}
40046 +
40047 +gdb_py_test_multiple "input convenience function" \
40048 +  "python" "" \
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 ()" "" \
40055 +  "end" ""
40056 +
40057 +gdb_test "print \$test_func (\"ugh\")" "= \"test_func output, arg = ugh\"" "call function"
40058 +
40059 +# Test returning a gdb.Value from the function. This segfaulted GDB at one point.
40060 +
40061 +gdb_py_test_multiple "input value-returning convenience function" \
40062 +  "python" "" \
40063 +  "class Double (gdb.Function):" "" \
40064 +  "  def __init__ (self):" "" \
40065 +  "    super (Double, self).__init__ (\"double\")" "" \
40066 +  "  def invoke (self, n):" "" \
40067 +  "    return n*2" "" \
40068 +  "Double ()" "" \
40069 +  "end" ""
40070 +
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
40075 --- /dev/null
40076 +++ b/gdb/testsuite/gdb.python/python-mi.exp
40077 @@ -0,0 +1,124 @@
40078 +# Copyright (C) 2008 Free Software Foundation, Inc.
40079 +
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.
40084 +#
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.
40089 +#
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/>.
40092 +
40093 +# This file is part of the GDB testsuite.  It tests Python-based
40094 +# pretty-printing for MI.
40095 +
40096 +load_lib mi-support.exp
40097 +set MIFLAGS "-i=mi2"
40098 +
40099 +gdb_exit
40100 +if [mi_gdb_start] {
40101 +    continue
40102 +}
40103 +
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
40109 +    return -1
40110 +}
40111 +
40112 +mi_delete_breakpoints
40113 +mi_gdb_reinitialize_dir $srcdir/$subdir
40114 +mi_gdb_load ${binfile}
40115 +
40116 +if {[lsearch -exact [mi_get_features] python] < 0} {
40117 +    unsupported "python support is disabled"
40118 +    return -1
40119 +}
40120 +
40121 +mi_runto main
40122 +
40123 +mi_gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" ""
40124 +
40125 +mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${testfile}.c] \
40126 +  "step to breakpoint"
40127 +
40128 +mi_create_floating_varobj container c "create container varobj"
40129 +
40130 +mi_list_varobj_children container {
40131 +} "examine container children=0"
40132 +
40133 +mi_next "next over update 1"
40134 +
40135 +mi_varobj_update_dynamic container {
40136 +    { {container.\[0\]} {\[0\]} 0 int }
40137 +} "varobj update 1"
40138 +
40139 +mi_next "next over update 2"
40140 +
40141 +mi_varobj_update_dynamic container {
40142 +    { {container.\[0\]} {\[0\]} 0 int }
40143 +    { {container.\[1\]} {\[1\]} 0 int }
40144 +} "varobj update 2"
40145 +
40146 +mi_gdb_test "-var-set-visualizer container None" \
40147 +  "\\^done" \
40148 +  "clear visualizer"
40149 +
40150 +mi_gdb_test "-var-update container" \
40151 +  "\\^done,changelist=\\\[\\\]" \
40152 +  "varobj update after clearing"
40153 +
40154 +mi_gdb_test "-var-set-visualizer container gdb.default_visualizer" \
40155 +  "\\^done" \
40156 +  "choose default visualizer"
40157 +
40158 +mi_varobj_update_dynamic container {
40159 +    { {container.\[0\]} {\[0\]} 0 int }
40160 +    { {container.\[1\]} {\[1\]} 0 int }
40161 +} "varobj update after choosing default"
40162 +
40163 +mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
40164 +  "\\^done" \
40165 +  "choose visualizer using expression"
40166 +
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"
40171 +
40172 +mi_gdb_test "-var-set-child-range container 1 2" \
40173 +  "\\^done" \
40174 +  "select child range"
40175 +
40176 +mi_gdb_test "-var-update container" \
40177 +  "\\^done,changelist=\\\[\\\]" \
40178 +  "varobj update after selecting child range"
40179 +
40180 +mi_list_varobj_children_range container 2 {
40181 +    { {container.\[1\]} {\[1\]} 0 int }
40182 +} "list varobj children after selecting child range"
40183 +
40184 +mi_gdb_test "-var-set-child-range container -1 -1" \
40185 +  "\\^done" \
40186 +  "reset child range"
40187 +
40188 +mi_gdb_test "-var-update container" \
40189 +  "\\^done,changelist=\\\[\\\]" \
40190 +  "varobj update after resetting child range"
40191 +
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"
40196 +
40197 +mi_continue_to_line \
40198 +    [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \
40199 +    "step to second breakpoint"
40200 +
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
40205 --- /dev/null
40206 +++ b/gdb/testsuite/gdb.python/python-prettyprint.c
40207 @@ -0,0 +1,159 @@
40208 +/* This testcase is part of GDB, the GNU debugger.
40209 +
40210 +   Copyright 2008 Free Software Foundation, Inc.
40211 +
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.
40216 +
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.
40221 +
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/>.  */
40224 +
40225 +struct s
40226 +{
40227 +  int a;
40228 +  int *b;
40229 +};
40230 +
40231 +struct ss
40232 +{
40233 +  struct s a;
40234 +  struct s b;
40235 +};
40236 +
40237 +#ifdef __cplusplus
40238 +struct S : public s {
40239 +  int zs;
40240 +};
40241 +
40242 +struct SS {
40243 +  int zss;
40244 +  S s;
40245 +};
40246 +
40247 +struct SSS
40248 +{
40249 +  SSS (int x, const S& r);
40250 +  int a;
40251 +  const S &b;
40252 +};
40253 +SSS::SSS (int x, const S& r) : a(x), b(r) { }
40254 +#endif
40255 +
40256 +typedef struct string_repr
40257 +{
40258 +  struct whybother
40259 +  {
40260 +    const char *contents;
40261 +  } whybother;
40262 +} string;
40263 +
40264 +/* This lets us avoid malloc.  */
40265 +int array[100];
40266 +
40267 +struct container
40268 +{
40269 +  string name;
40270 +  int len;
40271 +  int *elements;
40272 +};
40273 +
40274 +typedef struct container zzz_type;
40275 +
40276 +string
40277 +make_string (const char *s)
40278 +{
40279 +  string result;
40280 +  result.whybother.contents = s;
40281 +  return result;
40282 +}
40283 +
40284 +zzz_type
40285 +make_container (const char *s)
40286 +{
40287 +  zzz_type result;
40288 +
40289 +  result.name = make_string (s);
40290 +  result.len = 0;
40291 +  result.elements = 0;
40292 +
40293 +  return result;
40294 +}
40295 +
40296 +void
40297 +add_item (zzz_type *c, int val)
40298 +{
40299 +  if (c->len == 0)
40300 +    c->elements = array;
40301 +  c->elements[c->len] = val;
40302 +  ++c->len;
40303 +}
40304 +
40305 +void init_s(struct s *s, int a)
40306 +{
40307 +  s->a = a;
40308 +  s->b = &s->a;
40309 +}
40310 +
40311 +void init_ss(struct ss *s, int a, int b)
40312 +{
40313 +  init_s(&s->a, a);
40314 +  init_s(&s->b, b);
40315 +}
40316 +
40317 +void do_nothing(void)
40318 +{
40319 +  int c;
40320 +
40321 +  c = 23;                      /* Another MI breakpoint */
40322 +}
40323 +
40324 +int
40325 +main ()
40326 +{
40327 +  struct ss  ss;
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" } };
40332 +
40333 +  init_ss(&ss, 1, 2);
40334 +  init_ss(ssa+0, 3, 4);
40335 +  init_ss(ssa+1, 5, 6);
40336 +
40337 +#ifdef __cplusplus
40338 +  S cps;
40339 +
40340 +  cps.zs = 7;
40341 +  init_s(&cps, 8);
40342 +
40343 +  SS cpss;
40344 +  cpss.zss = 9;
40345 +  init_s(&cpss.s, 10);
40346 +
40347 +  SS cpssa[2];
40348 +  cpssa[0].zss = 11;
40349 +  init_s(&cpssa[0].s, 12);
40350 +  cpssa[1].zss = 13;
40351 +  init_s(&cpssa[1].s, 14);
40352 +
40353 +  SSS sss(15, cps);
40354 +
40355 +  SSS& ref (sss);
40356 +#endif
40357 +
40358 +  add_item (&c, 23);           /* MI breakpoint here */
40359 +  add_item (&c, 72);
40360 +
40361 +#ifdef MI
40362 +  do_nothing ();
40363 +#endif
40364 +
40365 +  return 0;      /* break to inspect struct and union */
40366 +}
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
40370 --- /dev/null
40371 +++ b/gdb/testsuite/gdb.python/python-prettyprint.exp
40372 @@ -0,0 +1,90 @@
40373 +# Copyright (C) 2008 Free Software Foundation, Inc.
40374 +
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.
40379 +#
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.
40384 +#
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/>.
40387 +
40388 +# This file is part of the GDB testsuite.  It tests Python-based
40389 +# pretty-printing for the CLI.
40390 +
40391 +if $tracelevel then {
40392 +    strace $tracelevel
40393 +}
40394 +
40395 +set testfile "python-prettyprint"
40396 +set srcfile ${testfile}.c
40397 +set binfile ${objdir}/${subdir}/${testfile}
40398 +
40399 +# Start with a fresh gdb.
40400 +gdb_exit
40401 +gdb_start
40402 +gdb_test_multiple "python print 'hello, world!'" "verify python support" {
40403 +    -re "not supported.*$gdb_prompt $" {
40404 +      unsupported "python support is disabled"
40405 +      return -1
40406 +    }
40407 +    -re "$gdb_prompt $"        {}
40408 +}
40409 +
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"
40414 +       return -1
40415 +    }
40416 +
40417 +    set nl "\[\r\n\]+"
40418 +
40419 +    # Start with a fresh gdb.
40420 +    gdb_exit
40421 +    gdb_start
40422 +    gdb_reinitialize_dir $srcdir/$subdir
40423 +    gdb_load ${binfile}
40424 +
40425 +
40426 +    if ![runto_main ] then {
40427 +       perror "couldn't run to breakpoint"
40428 +       return
40429 +    }
40430 +
40431 +    gdb_test "set print pretty on" ""
40432 +
40433 +    gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
40434 +       ".*Breakpoint.*"
40435 +    gdb_test "continue" ".*Breakpoint.*"
40436 +    
40437 +    gdb_test "python execfile ('${srcdir}/${subdir}/${testfile}.py')" ""
40438 +    
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>>}"
40442 +    
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>>"
40451 +    }
40452 +
40453 +    gdb_test "print x" " = $hex \"this is x\""
40454 +    gdb_test "print cstring" " = $hex \"const string\""
40455 +
40456 +    gdb_test "print c" " = container $hex \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
40457 +
40458 +    gdb_test "continue" "Program exited normally\."
40459 +}
40460 +
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
40466 --- /dev/null
40467 +++ b/gdb/testsuite/gdb.python/python-prettyprint.py
40468 @@ -0,0 +1,134 @@
40469 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
40470 +
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.
40475 +#
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.
40480 +#
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/>.
40483 +
40484 +# This file is part of the GDB testsuite.  It tests python pretty
40485 +# printers.
40486 +
40487 +import re
40488 +
40489 +# Test returning a Value from a printer.
40490 +class string_print:
40491 +    def __init__(self, val):
40492 +        self.val = val
40493 +
40494 +    def to_string(self):
40495 +        return self.val['whybother']['contents']
40496 +
40497 +# Test a class-based printer.
40498 +class ContainerPrinter:
40499 +    class _iterator:
40500 +        def __init__ (self, pointer, len):
40501 +            self.start = pointer
40502 +            self.pointer = pointer
40503 +            self.end = pointer + len
40504 +
40505 +        def __iter__(self):
40506 +            return self
40507 +
40508 +        def next(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())
40514 +
40515 +    def __init__(self, val):
40516 +        self.val = val
40517 +
40518 +    def to_string(self):
40519 +        return 'container %s with %d elements' % (self.val['name'], self.val['len'])
40520 +
40521 +    def children(self):
40522 +        return self._iterator(self.val['elements'], self.val['len'])
40523 +
40524 +class pp_s:
40525 +    def __init__(self, val):
40526 +        self.val = val
40527 +
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"]) + ">"
40534 +
40535 +class pp_ss:
40536 +    def __init__(self, val):
40537 +        self.val = val
40538 +
40539 +    def to_string(self):
40540 +        return "a=<" + str(self.val["a"]) + "> b=<" + str(self.val["b"]) + ">"
40541 +
40542 +class pp_sss:
40543 +    def __init__(self, val):
40544 +        self.val = val
40545 +
40546 +    def to_string(self):
40547 +        return "a=<" + str(self.val['a']) + "> b=<" + str(self.val["b"]) + ">"
40548 +
40549 +def lookup_function (val):
40550 +    "Look-up and return a pretty-printer that can print val."
40551 +
40552 +    # Get the type.
40553 +    type = val.type ();
40554 +
40555 +    # If it points to a reference, get the reference.
40556 +    if type.code () == gdb.TYPE_CODE_REF:
40557 +        type = type.target ()
40558 +
40559 +    # Get the unqualified type, stripped of typedefs.
40560 +    type = type.unqualified ().strip_typedefs ()
40561 +
40562 +    # Get the type name.    
40563 +    typename = type.tag ()
40564 +
40565 +    if typename == None:
40566 +        return None
40567 +
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)
40574 +        
40575 +    # Cannot find a pretty printer.  Return None.
40576 +
40577 +    return None
40578 +
40579 +
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
40584 +
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
40589 +    
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
40598 +    
40599 +pretty_printers_dict = {}
40600 +
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
40606 --- /dev/null
40607 +++ b/gdb/testsuite/gdb.python/python-template.cc
40608 @@ -0,0 +1,30 @@
40609 +/* This testcase is part of GDB, the GNU debugger.
40610 +
40611 +   Copyright 2008 Free Software Foundation, Inc.
40612 +
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.
40617 +
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.
40622 +
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/>.  */
40625 +
40626 +template <typename T>
40627 +struct Foo {
40628 +};
40629 +
40630 +#ifndef TYPE
40631 +#define TYPE int
40632 +#endif
40633 +
40634 +int main()
40635 +{
40636 +  Foo<TYPE> foo;
40637 +  return 0; // break here
40638 +}
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
40642 --- /dev/null
40643 +++ b/gdb/testsuite/gdb.python/python-template.exp
40644 @@ -0,0 +1,75 @@
40645 +# Copyright (C) 2008 Free Software Foundation, Inc.
40646 +
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.
40651 +#
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.
40656 +#
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/>.
40659 +
40660 +# This file is part of the GDB testsuite.  It tests the mechanism
40661 +# exposing values to Python.
40662 +
40663 +if $tracelevel then {
40664 +    strace $tracelevel
40665 +}
40666 +
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}"
40673 +    return -1
40674 +}
40675 +
40676 +# Start with a fresh gdb.
40677 +
40678 +gdb_exit
40679 +gdb_start
40680 +gdb_reinitialize_dir $srcdir/$subdir
40681 +
40682 +gdb_test_multiple "python print 23" "verify python support" {
40683 +    -re "not supported.*$gdb_prompt $" {
40684 +      unsupported "python support is disabled"
40685 +      return -1
40686 +    }
40687 +    -re "$gdb_prompt $"        {}
40688 +}
40689 +
40690 +proc test_template_arg {type} {
40691 +    global testfile srcdir subdir srcfile binfile
40692 +    if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
40693 +               executable \
40694 +               [list debug c++ additional_flags="-DTYPE=$type"]] != "" } {
40695 +       untested $type
40696 +       return -1
40697 +    }
40698 +    gdb_load ${binfile}
40699 +    if ![runto_main ] then {
40700 +       perror "couldn't run to breakpoint"
40701 +       return
40702 +    }
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)" ""
40706 +
40707 +    # Replace '*' with '\*' in regex.
40708 +    regsub -all {\*} $type {\*} t
40709 +    gdb_test "python print foo.type().template_argument(0)" $t $type
40710 +}
40711 +
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
40725      TWO = 2
40726    };
40727  
40728 +typedef struct s *PTR;
40729 +
40730  enum e evalue = TWO;
40731  
40732  int
40733  main (int argc, char *argv[])
40734  {
40735 +  char *cp = argv[0]; /* Prevent gcc from optimizing argv[] out.  */
40736    struct s s;
40737    union u u;
40738 +  PTR x = &s;
40739  
40740    s.a = 3;
40741    s.b = 5;
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"
40748  }
40749  
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
40754 +
40755 +  # Check the type has the expected name.
40756 +  gdb_test "python print ptrtype" "PTR" \
40757 +    "check initial PTR type"
40758 +
40759 +  # Kill the inferior and remove the symbols.
40760 +  gdb_test "kill" "" "kill the inferior" \
40761 +    "Kill the program being debugged. .y or n. $" \
40762 +    "y"
40763 +  gdb_test "file" "" "Discard the symbols" \
40764 +    "Discard symbol table from.*y or n. $" \
40765 +    "y"
40766 +
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
40771 +
40772 +  # Make sure the type is deleted.
40773 +  gdb_py_test_silent_cmd "python ptrtype = None" \
40774 +    "delete PTR type" 1
40775 +
40776 +  # Now see if the value's type is still valid.
40777 +  gdb_test "python print castval.type()" "PTR \\*" \
40778 +    "print value's type"
40779 +}
40780 +
40781  
40782  # Start with a fresh gdb.
40783  
40784 @@ -256,3 +287,4 @@ if ![runto_main] then {
40785  }
40786  
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 {
40794  
40795      set parse_okay 0
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 $" {
40799             set parse_okay          1
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)
40804         }
40805      }
40806 +    
40807      if { ! $parse_okay } then { return }
40808  
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 { } {
40815      global gdb_prompt
40816      global timeout
40817      global gdb_spawn_id;
40818 +    global env
40819  
40820      gdb_stop_suppressing_tests;
40821  
40822 +    set env(LC_CTYPE) C
40823 +
40824      verbose "Spawning $GDB $INTERNAL_GDBFLAGS $GDBFLAGS"
40825  
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
40833  }
40834  
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
40837 +# of the test.
40838 +proc mi_varobj_update_dynamic {name children testname} {
40839 +    set children_exp_j [mi_child_regexp $children 0]
40840 +
40841 +    set er "\\^done,changelist=\\\["
40842 +
40843 +    append er "{name=\"$name\",in_scope=\"true\",type_changed=\"false\""
40844 +    append er ",children=\\\[$children_exp_j.*\\\]}\\\]"
40845 +
40846 +    verbose -log "Expecting: $er"
40847 +    mi_gdb_test "-var-update $name" $er $testname
40848 +}
40849 +
40850  proc mi_check_varobj_value { name value testname } {
40851  
40852      mi_gdb_test "-var-evaluate-expression $name" \
40853 @@ -1244,6 +1259,42 @@ proc mi_check_varobj_value { name value testname } {
40854         $testname
40855  }
40856  
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 "\"\[^\"\]+\""
40862 +
40863 +    if {$add_child} {
40864 +       set pre "child="
40865 +    } else {
40866 +       set pre ""
40867 +    }
40868 +
40869 +    foreach item $children {
40870 +
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]
40877 +
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]
40882 +
40883 +            lappend children_exp\
40884 +                "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40885 +        } else {
40886 +            lappend children_exp\
40887 +                "$pre{name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
40888 +        }
40889 +    }
40890 +    return [join $children_exp ","]
40891 +}
40892 +
40893  # Check the results of the:
40894  #
40895  #   -var-list-children VARNAME
40896 @@ -1265,39 +1316,23 @@ proc mi_check_varobj_value { name value testname } {
40897  # have no value.
40898  #
40899  proc mi_list_varobj_children { varname children testname } {
40900 +    mi_list_varobj_children_range $varname [llength $children] $children \
40901 +      $testname
40902 +}
40903  
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
40906 +# of children.
40907 +proc mi_list_varobj_children_range {varname numchildren children testname} {
40908      set options ""
40909      if {[llength $varname] == 2} {
40910          set options [lindex $varname 1]
40911          set varname [lindex $varname 0]
40912      }
40913  
40914 -    set numchildren [llength $children]
40915 -    set children_exp {}
40916      set whatever "\"\[^\"\]+\""
40917  
40918 -    foreach item $children {
40919 -
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]
40926 -
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]
40931 -
40932 -            lappend children_exp\
40933 -                "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\",type=\"$type\"\(,thread-id=\"\[0-9\]+\")?}"
40934 -        } else {
40935 -            lappend children_exp\
40936 -                "child={name=\"$name\",exp=\"$exp\",numchild=\"$numchild\"(,thread-id=\"\[0-9\]+\")?}"
40937 -        }
40938 -    }
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.*\\\]"
40943      } {
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
40947  }
40948 +
40949 +# Return a list of MI features supported by this gdb.
40950 +proc mi_get_features {} {
40951 +    global expect_out mi_gdb_prompt
40952 +
40953 +    send_gdb "-list-features\n"
40954 +
40955 +    gdb_expect {
40956 +       -re "\\^done,features=\\\[(.*)\\\]\r\n$mi_gdb_prompt$" {
40957 +           regsub -all -- \" $expect_out(1,string) "" features
40958 +           return [split $features ,]
40959 +       }
40960 +       -re ".*\r\n$mi_gdb_prompt$" {
40961 +           verbose -log "got $expect_out(buffer)"
40962 +           return ""
40963 +       }
40964 +       timeout {
40965 +           verbose -log "timeout in mi_gdb_prompt"
40966 +           return ""
40967 +       }
40968 +    }
40969 +}
40970 diff --git a/gdb/thread.c b/gdb/thread.c
40971 index 9dea7c2..326e44e 100644
40972 --- a/gdb/thread.c
40973 +++ b/gdb/thread.c
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);
40979  
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)
40983    return 1;
40984  }
40985  
40986 -static void
40987 +void
40988  prune_threads (void)
40989  {
40990 -  struct thread_info *tp, *next;
40991 +  struct thread_info *tp;
40992 +  struct thread_info **prevp = &thread_list;
40993  
40994 -  for (tp = thread_list; tp; tp = next)
40995 +  for (tp = *prevp; tp; tp = *prevp)
40996      {
40997 -      next = tp->next;
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);
41002 +       {
41003 +         *prevp = tp->next;
41004 +         free_thread (tp);
41005 +       }
41006 +      else
41007 +       prevp = &tp->next;
41008      }
41009  }
41010  
41011 diff --git a/gdb/top.c b/gdb/top.c
41012 index d676f02..d6b17f0 100644
41013 --- a/gdb/top.c
41014 +++ b/gdb/top.c
41015 @@ -377,6 +377,7 @@ execute_command (char *p, int from_tty)
41016      }
41017    
41018    free_all_values ();
41019 +  free_all_types ();
41020  
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;
41025  
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);
41030  
41031    /* Give all pushed targets a chance to do minimal cleanup, and pop
41032       them all out.  */
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,
41038                     case UNOP_MEMVAL:
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);
41045                       break;
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
41050 @@ -35,6 +35,7 @@
41051  #include "gdb_string.h"
41052  #include "exceptions.h"
41053  #include "valprint.h"
41054 +#include "dwarf2loc.h"
41055  #include <errno.h>
41056  
41057  extern void _initialize_typeprint (void);
41058 @@ -76,6 +77,9 @@ void
41059  type_print (struct type *type, char *varstring, struct ui_file *stream,
41060             int show)
41061  {
41062 +  if (show >= 0)
41063 +    type = check_typedef (type);
41064 +
41065    LA_PRINT_TYPE (type, varstring, stream, show, 0);
41066  }
41067  
41068 @@ -115,7 +119,8 @@ whatis_exp (char *exp, int show)
41069  {
41070    struct expression *expr;
41071    struct value *val;
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;
41076    struct type *type;
41077    int full = 0;
41078 @@ -126,12 +131,13 @@ whatis_exp (char *exp, int show)
41079    if (exp)
41080      {
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);
41085      }
41086    else
41087      val = access_value_history (0);
41088  
41089 +  object_address_set (VALUE_ADDRESS (val));
41090    type = value_type (val);
41091  
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");
41096  
41097 -  if (exp)
41098 -    do_cleanups (old_chain);
41099 +  do_cleanups (old_chain);
41100  }
41101  
41102  static void
41103 @@ -236,7 +241,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
41104        break;
41105  
41106      case TYPE_CODE_CHAR:
41107 -      LA_PRINT_CHAR ((unsigned char) val, stream);
41108 +      LA_PRINT_CHAR ((unsigned char) val, type, stream);
41109        break;
41110  
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 *);
41117  
41118  void c_type_print_varspec_suffix (struct type *, struct ui_file *, int,
41119                                   int, int);
41120 +
41121 +void c_type_print_args (struct type *, struct ui_file *, int);
41122  #endif
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
41127 @@ -22,6 +22,7 @@
41128  
41129  #include "defs.h"
41130  #include "ui-file.h"
41131 +#include "gdb_obstack.h"
41132  #include "gdb_string.h"
41133  
41134  #include <errno.h>
41135 @@ -263,7 +264,7 @@ set_ui_file_data (struct ui_file *file, void *data,
41136  }
41137  
41138  /* ui_file utility function for converting a ``struct ui_file'' into
41139 -   a memory buffer''. */
41140 +   a memory buffer. */
41141  
41142  struct accumulated_ui_file
41143  {
41144 @@ -297,6 +298,23 @@ ui_file_xstrdup (struct ui_file *file,
41145    *length = acc.length;
41146    return acc.buffer;
41147  }
41148 +
41149 +static void
41150 +do_ui_file_obsavestring (void *context, const char *buffer, long length)
41151 +{
41152 +  struct obstack *obstack = (struct obstack *) context;
41153 +  obstack_grow (obstack, buffer, length);
41154 +}
41155 +
41156 +char *
41157 +ui_file_obsavestring (struct ui_file *file, struct obstack *obstack,
41158 +                     long *length)
41159 +{
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);
41164 +}
41165  \f
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
41172 @@ -19,6 +19,7 @@
41173  #ifndef UI_FILE_H
41174  #define UI_FILE_H
41175  
41176 +struct obstack;
41177  struct ui_file;
41178  
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
41181     appended NUL. */
41182  extern char *ui_file_xstrdup (struct ui_file *file, long *length);
41183  
41184 -
41185 +/* Similar to ui_file_xstrdup, but return a new string allocated on
41186 +   OBSTACK.  */
41187 +extern char *ui_file_obsavestring (struct ui_file *file,
41188 +                                  struct obstack *obstack, long *length);
41189  
41190  extern long ui_file_read (struct ui_file *file, char *buf, long length_buf);
41191  
41192 diff --git a/gdb/utils.c b/gdb/utils.c
41193 index 9224839..88a9a39 100644
41194 --- a/gdb/utils.c
41195 +++ b/gdb/utils.c
41196 @@ -272,6 +272,19 @@ make_cleanup_fclose (FILE *file)
41197  }
41198  
41199  static void
41200 +do_obstack_free (void *arg)
41201 +{
41202 +  struct obstack *ob = arg;
41203 +  obstack_free (ob, NULL);
41204 +}
41205 +
41206 +struct cleanup *
41207 +make_cleanup_obstack_free (struct obstack *obstack)
41208 +{
41209 +  return make_cleanup (do_obstack_free, obstack);
41210 +}
41211 +
41212 +static void
41213  do_ui_file_delete (void *arg)
41214  {
41215    ui_file_delete (arg);
41216 @@ -1554,21 +1567,33 @@ query (const char *ctlstr, ...)
41217    va_end (args);
41218  }
41219  
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.  */
41230 +
41231 +static int
41232 +host_char_to_target (int c, int *target_c)
41233  {
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;
41239 +  int result = 0;
41240 +
41241 +  obstack_init (&host_data);
41242 +  cleanups = make_cleanup_obstack_free (&host_data);
41243 +
41244 +  convert_between_encodings (target_charset (), host_charset (),
41245 +                            &the_char, 1, 1, &host_data, translit_none);
41246  
41247 -  memcpy (copy, start, len);
41248 -  copy[len] = '\0';
41249 +  if (obstack_object_size (&host_data) == 1)
41250 +    {
41251 +      result = 1;
41252 +      *target_c = *(char *) obstack_base (&host_data);
41253 +    }
41254  
41255 -  error (_("There is no control character `\\%s' in the `%s' character set."),
41256 -        copy, target_charset ());
41257 +  do_cleanups (cleanups);
41258 +  return result;
41259  }
41260  
41261  /* Parse a C escape sequence.  STRING_PTR points to a variable
41262 @@ -1591,53 +1616,13 @@ parse_escape (char **string_ptr)
41263  {
41264    int target_char;
41265    int c = *(*string_ptr)++;
41266 -  if (c_parse_backslash (c, &target_char))
41267 -    return target_char;
41268 -  else
41269 -    switch (c)
41270 -      {
41271 +  switch (c)
41272 +    {
41273        case '\n':
41274         return -2;
41275        case 0:
41276         (*string_ptr)--;
41277         return 0;
41278 -      case '^':
41279 -       {
41280 -         /* Remember where this escape sequence started, for reporting
41281 -            errors.  */
41282 -         char *sequence_start_pos = *string_ptr - 1;
41283 -
41284 -         c = *(*string_ptr)++;
41285 -
41286 -         if (c == '?')
41287 -           {
41288 -             /* XXXCHARSET: What is `delete' in the host character set?  */
41289 -             c = 0177;
41290 -
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 ());
41294 -
41295 -             return target_char;
41296 -           }
41297 -         else if (c == '\\')
41298 -           target_char = parse_escape (string_ptr);
41299 -         else
41300 -           {
41301 -             if (!host_char_to_target (c, &target_char))
41302 -               no_control_char_error (sequence_start_pos, *string_ptr);
41303 -           }
41304 -
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);
41309 -
41310 -         return target_char;
41311 -       }
41312 -
41313 -       /* XXXCHARSET: we need to use isdigit and value-of-digit
41314 -          methods of the host character set here.  */
41315  
41316        case '0':
41317        case '1':
41318 @@ -1648,16 +1633,16 @@ parse_escape (char **string_ptr)
41319        case '6':
41320        case '7':
41321         {
41322 -         int i = c - '0';
41323 +         int i = host_hex_value (c);
41324           int count = 0;
41325           while (++count < 3)
41326             {
41327               c = (**string_ptr);
41328 -             if (c >= '0' && c <= '7')
41329 +             if (isdigit (c) && c != '8' && c != '9')
41330                 {
41331                   (*string_ptr)++;
41332                   i *= 8;
41333 -                 i += c - '0';
41334 +                 i += host_hex_value (c);
41335                 }
41336               else
41337                 {
41338 @@ -1666,14 +1651,39 @@ parse_escape (char **string_ptr)
41339             }
41340           return i;
41341         }
41342 -      default:
41343 -       if (!host_char_to_target (c, &target_char))
41344 -         error
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;
41349 -      }
41350 +
41351 +    case 'a':
41352 +      c = '\a';
41353 +      break;
41354 +    case 'b':
41355 +      c = '\b';
41356 +      break;
41357 +    case 'f':
41358 +      c = '\f';
41359 +      break;
41360 +    case 'n':
41361 +      c = '\n';
41362 +      break;
41363 +    case 'r':
41364 +      c = '\r';
41365 +      break;
41366 +    case 't':
41367 +      c = '\t';
41368 +      break;
41369 +    case 'v':
41370 +      c = '\v';
41371 +      break;
41372 +
41373 +    default:
41374 +      break;
41375 +    }
41376 +
41377 +  if (!host_char_to_target (c, &target_char))
41378 +    error
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;
41383  }
41384  \f
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)
41393         {
41394 -         store_unsigned_integer (valbuf, 4, VALUE_ADDRESS (*args));
41395 +         store_unsigned_integer (valbuf, 4, value_address (*args));
41396           len = 4;
41397           val = valbuf;
41398         }
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."));
41404  struct value *
41405  value_subscript (struct value *array, struct value *idx)
41406  {
41407 -  struct value *bound;
41408    int c_style = current_language->c_style_arrays;
41409    struct type *tarray;
41410 +  LONGEST index = value_as_long (idx);
41411  
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);
41416  
41417        if (VALUE_LVAL (array) != lval_memory)
41418 -       return value_subscripted_rvalue (array, idx, lowerbound);
41419 +       {
41420 +         if (index >= lowerbound && index <= upperbound)
41421 +           {
41422 +             CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
41423 +             CORE_ADDR offset = (index - lowerbound) * element_size;
41424 +
41425 +             return value_subscripted_rvalue (array, offset);
41426 +           }
41427 +         error (_("array or string index out of range"));
41428 +       }
41429  
41430        if (c_style == 0)
41431         {
41432 -         LONGEST index = value_as_long (idx);
41433           if (index >= lowerbound && index <= upperbound)
41434 -           return value_subscripted_rvalue (array, idx, lowerbound);
41435 +           {
41436 +             CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
41437 +             CORE_ADDR offset = (index - lowerbound) * element_size;
41438 +
41439 +             return value_subscripted_rvalue (array, offset);
41440 +           }
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)
41445           c_style = 1;
41446         }
41447  
41448 -      if (lowerbound != 0)
41449 -       {
41450 -         bound = value_from_longest (value_type (idx), (LONGEST) lowerbound);
41451 -         idx = value_binop (idx, bound, BINOP_SUB);
41452 -       }
41453 -
41454 +      index -= lowerbound;
41455        array = value_coerce_array (array);
41456      }
41457  
41458    if (c_style)
41459 -    return value_ind (value_ptradd (array, idx));
41460 +    {
41461 +      struct value *idx;
41462 +
41463 +      idx = value_from_longest (builtin_type_int32, index);
41464 +      return value_ind (value_ptradd (array, idx));
41465 +    }
41466    else
41467      error (_("not an array or string"));
41468  }
41469  
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)).  */
41478  
41479  struct value *
41480 -value_subscripted_rvalue (struct value *array, struct value *idx, int lowerbound)
41481 +value_subscripted_rvalue (struct value *array, CORE_ADDR offset)
41482  {
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);
41488    struct value *v;
41489  
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.  */
41495  
41496    v = allocate_value (elt_type);
41497    if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
41498      set_value_lazy (v, 1);
41499    else
41500 -    memcpy (value_contents_writeable (v),
41501 -           value_contents (array) + elt_offs, elt_size);
41502 +    {
41503 +      unsigned int elt_size = TYPE_LENGTH (elt_type);
41504 +      memcpy (value_contents_writeable (v),
41505 +             value_contents (array) + offset, elt_size);
41506 +    }
41507  
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);
41513    return v;
41514  }
41515  
41516 diff --git a/gdb/valops.c b/gdb/valops.c
41517 index 9810f2b..14c562e 100644
41518 --- a/gdb/valops.c
41519 +++ b/gdb/valops.c
41520 @@ -38,6 +38,7 @@
41521  #include "cp-support.h"
41522  #include "dfp.h"
41523  #include "user-regs.h"
41524 +#include "dwarf2loc.h"
41525  
41526  #include <errno.h>
41527  #include "gdb_string.h"
41528 @@ -254,9 +255,8 @@ value_cast_structs (struct type *type, struct value *v2)
41529        if (v)
41530         {
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);
41539         }
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),
41548                                           low_bound,
41549 @@ -511,7 +509,7 @@ value_cast (struct type *type, struct value *arg2)
41550      }
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)
41556      {
41557        return value_zero (builtin_type_void, not_lval);
41558 @@ -568,6 +566,64 @@ value_one (struct type *type, enum lval_type lv)
41559    return val;
41560  }
41561  
41562 +/* object_address_set must be already called before this function.  */
41563 +
41564 +const char *
41565 +object_address_data_not_valid (struct type *type)
41566 +{
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);
41571 +
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");
41577 +
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");
41582 +
41583 +  return NULL;
41584 +}
41585 +
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.  */
41592 +
41593 +int
41594 +object_address_get_data (struct type *type, CORE_ADDR *address_return)
41595 +{
41596 +  gdb_assert (address_return != NULL);
41597 +
41598 +  object_address_set (*address_return);
41599 +
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);
41603 +
41604 +  if (object_address_data_not_valid (type) != NULL)
41605 +    {
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).  */
41608 +      return 0;
41609 +    }
41610 +
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)
41614 +    *address_return
41615 +      = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type));
41616 +
41617 +  return 1;
41618 +}
41619 +
41620  /* Return a value with type TYPE located at ADDR.
41621  
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));
41625  
41626    VALUE_LVAL (val) = lval_memory;
41627 -  VALUE_ADDRESS (val) = addr;
41628 +  set_value_address (val, addr);
41629  
41630    return val;
41631  }
41632 @@ -611,7 +667,7 @@ value_at_lazy (struct type *type, CORE_ADDR addr)
41633    val = allocate_value_lazy (type);
41634  
41635    VALUE_LVAL (val) = lval_memory;
41636 -  VALUE_ADDRESS (val) = addr;
41637 +  set_value_address (val, addr);
41638  
41639    return val;
41640  }
41641 @@ -637,11 +693,19 @@ value_fetch_lazy (struct value *val)
41642    allocate_value_contents (val);
41643    if (VALUE_LVAL (val) == lval_memory)
41644      {
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);
41648 +
41649 +      if (object_address_get_data (value_type (val), &addr))
41650 +       {
41651 +         struct type *type = value_enclosing_type (val);
41652 +         int length = TYPE_LENGTH (check_typedef (type));
41653  
41654 -      if (length)
41655 -       read_memory (addr, value_contents_all_raw (val), length);
41656 +         if (length)
41657 +           {
41658 +             addr += value_offset (val);
41659 +             read_memory (addr, value_contents_all_raw (val), length);
41660 +           }
41661 +       }
41662      }
41663    else if (VALUE_LVAL (val) == lval_register)
41664      {
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)));
41671               else
41672                 fprintf_unfiltered (gdb_stdlog, " computed");
41673  
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);
41677  
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;
41686           }
41687         else
41688           {
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);
41693           }
41694 @@ -985,11 +1048,11 @@ value_repeat (struct value *arg1, int count)
41695  
41696    val = allocate_repeat_value (value_enclosing_type (arg1), count);
41697  
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));
41705  
41706    return val;
41707  }
41708 @@ -1036,10 +1099,11 @@ address_of_variable (struct symbol *var, struct block *b)
41709  
41710    val = value_of_variable (var, b);
41711  
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)
41716      {
41717 -      CORE_ADDR addr = VALUE_ADDRESS (val);
41718 +      CORE_ADDR addr = value_address (val);
41719        return value_from_pointer (lookup_pointer_type (type), addr);
41720      }
41721  
41722 @@ -1145,6 +1209,7 @@ struct value *
41723  value_coerce_array (struct value *arg1)
41724  {
41725    struct type *type = check_typedef (value_type (arg1));
41726 +  CORE_ADDR address;
41727  
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."));
41733  
41734 +  address = VALUE_ADDRESS (arg1);
41735 +  if (!object_address_get_data (type, &address))
41736 +    error (_("Attempt to take address of non-valid value."));
41737 +
41738    return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
41739 -                            (VALUE_ADDRESS (arg1) + value_offset (arg1)));
41740 +                            address + value_offset (arg1));
41741  }
41742  
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."));
41746  
41747    retval = value_from_pointer (lookup_pointer_type (value_type (arg1)),
41748 -                              (VALUE_ADDRESS (arg1) + value_offset (arg1)));
41749 +                              (value_address (arg1)));
41750    return retval;
41751  }
41752  
41753 @@ -1205,8 +1274,7 @@ value_addr (struct value *arg1)
41754  
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)));
41761  
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)
41764    return val;
41765  }
41766  
41767 +struct value *
41768 +value_typed_string (char *ptr, int len, struct type *char_type)
41769 +{
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,
41775 +                                             lowbound, 
41776 +                                             highbound + lowbound - 1);
41777 +  struct type *stringtype
41778 +    = create_array_type ((struct type *) NULL, char_type, rangetype);
41779 +
41780 +  val = allocate_value (stringtype);
41781 +  memcpy (value_contents_raw (val), ptr, len);
41782 +  return val;
41783 +}
41784 +
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,
41789  
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);
41795           if (boffset == -1)
41796             error (_("virtual baseclass botch"));
41797  
41798 @@ -1616,13 +1701,13 @@ search_struct_field (char *name, struct value *arg1, int offset,
41799  
41800               v2  = allocate_value (basetype);
41801               base_addr = 
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);
41811             }
41812           else
41813             {
41814 @@ -1745,8 +1830,7 @@ search_struct_method (char *name, struct value **arg1p,
41815           if (offset < 0 || offset >= TYPE_LENGTH (type))
41816             {
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;
41826  
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"));
41833         }
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"));
41842         }
41843 @@ -2083,12 +2166,25 @@ find_overload_match (struct type **arg_types, int nargs,
41844    if (method)
41845      {
41846        gdb_assert (obj);
41847 +
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)));
41858 +
41859 +      /* First check whether this is a data member, e.g. a pointer to
41860 +        a function.  */
41861 +      if (TYPE_CODE (check_typedef (value_type (obj))) == TYPE_CODE_STRUCT)
41862 +       {
41863 +         *valp = search_struct_field (name, obj, 0,
41864 +                                      check_typedef (value_type (obj)), 0);
41865 +         if (*valp)
41866 +           {
41867 +             *staticp = 1;
41868 +             return 0;
41869 +           }
41870 +       }
41871  
41872        fns_ptr = value_find_oload_method_list (&temp, name, 
41873                                               0, &num_fns, 
41874 @@ -2108,16 +2204,29 @@ find_overload_match (struct type **arg_types, int nargs,
41875      }
41876    else
41877      {
41878 -      const char *qualified_name = SYMBOL_CPLUS_DEMANGLED_NAME (fsym);
41879 +      const char *qualified_name = SYMBOL_NATURAL_NAME (fsym);
41880  
41881 -      /* If we have a C++ name, try to extract just the function
41882 -        part.  */
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)
41890 +       {
41891 +         func_name = cp_func_name (qualified_name);
41892 +
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)
41897 +           {
41898 +             xfree (func_name);
41899 +             func_name = NULL;
41900 +           }
41901 +       }
41902  
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)
41910          {
41911           *symp = fsym;
41912 @@ -2558,8 +2667,8 @@ check_field (struct type *type, const char *name)
41913     the comment before value_struct_elt_for_reference.  */
41914  
41915  struct value *
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)
41921  {
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, 
41927 -                                            name, NULL,
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,
41933           if (intype)
41934             {
41935               while (j--)
41936 -               if (TYPE_FN_FIELD_TYPE (f, j) == intype)
41937 +               if (compare_parameters (TYPE_FN_FIELD_TYPE (f, j), intype))
41938                   break;
41939               if (j < 0)
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);
41947                 }
41948             }
41949           return result;
41950 @@ -2791,7 +2900,7 @@ value_maybe_namespace_elt (const struct type *curtype,
41951    struct symbol *sym;
41952    struct value *result;
41953  
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), 
41957                                     VAR_DOMAIN);
41958  
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"));
41971  
41972 -  /* FIXME-type-allocation: need a way to free this type when we are
41973 -     done with it.  */
41974    slice_range_type = create_range_type ((struct type *) NULL,
41975                                         TYPE_TARGET_TYPE (range_type),
41976                                         lowbound, 
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
41981 @@ -34,6 +34,7 @@
41982  #include "doublest.h"
41983  #include "exceptions.h"
41984  #include "dfp.h"
41985 +#include "python/python.h"
41986  
41987  #include <errno.h>
41988  
41989 @@ -80,7 +81,9 @@ struct value_print_options user_print_options =
41990    0,                           /* print_array_indexes */
41991    0,                           /* deref_ref */
41992    1,                           /* static_field_print */
41993 -  1                            /* pascal_static_field_print */
41994 +  1,                           /* pascal_static_field_print */
41995 +  0,                           /* raw */
41996 +  0                            /* summary */
41997  };
41998  
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,
42001        return (0);
42002      }
42003  
42004 +  if (!options->raw)
42005 +    {
42006 +      ret = apply_val_pretty_printer (type, valaddr, embedded_offset,
42007 +                                     address, stream, recurse, options,
42008 +                                     language);
42009 +      if (ret)
42010 +       return ret;
42011 +    }
42012 +
42013    TRY_CATCH (except, RETURN_MASK_ERROR)
42014      {
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)
42017        return 0;
42018      }
42019  
42020 +  if (TYPE_CODE (value_type (val)) == TYPE_CODE_INTERNAL_FUNCTION)
42021 +    {
42022 +      fprintf_filtered (stream, _("<internal function %s>"),
42023 +                       value_internal_function_name (val));
42024 +      return 0;
42025 +    }
42026 +
42027    return 1;
42028  }
42029  
42030 @@ -308,7 +327,7 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse,
42031      return 0;
42032  
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);
42037  }
42038  
42039 @@ -324,6 +343,18 @@ value_print (struct value *val, struct ui_file *stream,
42040    if (!value_check_printable (val, stream))
42041      return 0;
42042  
42043 +  if (!options->raw)
42044 +    {
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);
42051 +      if (r)
42052 +       return r;
42053 +    }
42054 +
42055    return LA_VALUE_PRINT (val, stream, options);
42056  }
42057  
42058 @@ -919,7 +950,8 @@ print_hex_chars (struct ui_file *stream, const gdb_byte *valaddr,
42059     Omit any leading zero chars.  */
42060  
42061  void
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)
42066  {
42067    const gdb_byte *p;
42068 @@ -932,7 +964,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
42069  
42070        while (p < valaddr + len)
42071         {
42072 -         LA_EMIT_CHAR (*p, stream, '\'');
42073 +         LA_EMIT_CHAR (*p, type, stream, '\'');
42074           ++p;
42075         }
42076      }
42077 @@ -944,7 +976,7 @@ print_char_chars (struct ui_file *stream, const gdb_byte *valaddr,
42078  
42079        while (p >= valaddr)
42080         {
42081 -         LA_EMIT_CHAR (*p, stream, '\'');
42082 +         LA_EMIT_CHAR (*p, type, stream, '\'');
42083           --p;
42084         }
42085      }
42086 @@ -1085,6 +1117,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42087  
42088    for (; i < len && things_printed < options->print_max; i++)
42089      {
42090 +      size_t elt_offset = i * eltlen;
42091        if (i != 0)
42092         {
42093           if (options->prettyprint_arrays)
42094 @@ -1104,7 +1137,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42095        rep1 = i + 1;
42096        reps = 1;
42097        while ((rep1 < len) &&
42098 -            !memcmp (valaddr + i * eltlen, valaddr + rep1 * eltlen, eltlen))
42099 +            !memcmp (valaddr + elt_offset, valaddr + rep1 * eltlen, eltlen))
42100         {
42101           ++reps;
42102           ++rep1;
42103 @@ -1112,7 +1145,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
42104  
42105        if (reps > options->repeat_count_threshold)
42106         {
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,
42113         }
42114        else
42115         {
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);
42119           annotate_elt ();
42120           things_printed++;
42121 @@ -1315,7 +1348,8 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
42122     whichever is smaller.  */
42123  
42124  int
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)
42129  {
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,
42132    int bytes_read;
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);
42136  
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,
42140         {
42141           fputs_filtered (" ", stream);
42142         }
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);
42145      }
42146  
42147    if (errcode != 0)
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;
42156 +
42157 +  /* Controls Python pretty-printing.  */
42158 +  int raw;
42159 +
42160 +  /* If nonzero, print the value in "summary" form.  */
42161 +  int summary;
42162  };
42163  
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);
42168  
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);
42173  
42174  int read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
42175                  gdb_byte **buffer, int *bytes_read);
42176 +
42177  #endif
42178 diff --git a/gdb/value.c b/gdb/value.c
42179 index 4d4329e..5c81d83 100644
42180 --- a/gdb/value.c
42181 +++ b/gdb/value.c
42182 @@ -36,6 +36,7 @@
42183  #include "block.h"
42184  #include "dfp.h"
42185  #include "objfiles.h"
42186 +#include "cli/cli-decode.h"
42187  #include "valprint.h"
42188  
42189  #include "python/python.h"
42190 @@ -44,6 +45,23 @@
42191  
42192  void _initialize_values (void);
42193  
42194 +/* Definition of a user function.  */
42195 +struct internal_function
42196 +{
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.  */
42200 +  char *name;
42201 +
42202 +  /* The handler.  */
42203 +  internal_function_fn handler;
42204 +
42205 +  /* User data for the handler.  */
42206 +  void *cookie;
42207 +};
42208 +
42209 +static struct cmd_list_element *functionlist;
42210 +
42211  struct value
42212  {
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;
42216  
42217  static int value_history_count;        /* Abs number of last entry stored */
42218 +
42219 +/* The type of internal functions.  */
42220 +
42221 +static struct type *internal_fn_type;
42222  \f
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;
42227    all_values = val;
42228    val->type = type;
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;
42236    val->offset = 0;
42237    val->bitpos = 0;
42238 @@ -269,13 +293,9 @@ struct value *
42239  allocate_repeat_value (struct type *type, int count)
42240  {
42241    int low_bound = current_language->string_lower_bound;                /* ??? */
42242 -  /* FIXME-type-allocation: need a way to free this type when we are
42243 -     done with it.  */
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
42248 -     done with it.  */
42249    return allocate_value (create_array_type ((struct type *) NULL,
42250                                             type, range_type));
42251  }
42252 @@ -335,6 +355,8 @@ value_type (struct value *value)
42253  void
42254  deprecated_set_value_type (struct value *value, struct type *type)
42255  {
42256 +  type_incref (type);
42257 +  type_decref (value->type);
42258    value->type = type;
42259  }
42260  
42261 @@ -509,6 +531,32 @@ deprecated_value_address_hack (struct value *value)
42262    return &value->location.address;
42263  }
42264  
42265 +CORE_ADDR
42266 +value_address (struct value *value)
42267 +{
42268 +  if (value->lval == lval_internalvar
42269 +      || value->lval == lval_internalvar_component)
42270 +    return 0;
42271 +  return value->location.address + value->offset;
42272 +}
42273 +
42274 +CORE_ADDR
42275 +value_raw_address (struct value *value)
42276 +{
42277 +  if (value->lval == lval_internalvar
42278 +      || value->lval == lval_internalvar_component)
42279 +    return 0;
42280 +  return value->location.address;
42281 +}
42282 +
42283 +void
42284 +set_value_address (struct value *value, CORE_ADDR addr)
42285 +{
42286 +  gdb_assert (value->lval != lval_internalvar
42287 +             && value->lval != lval_internalvar_component);
42288 +  value->location.address = addr;
42289 +}
42290 +
42291  struct internalvar **
42292  deprecated_value_internalvar_hack (struct value *value)
42293  {
42294 @@ -547,11 +595,16 @@ value_mark (void)
42295    return all_values;
42296  }
42297  
42298 +/* Deallocate a value and run destructors if needed.  */
42299 +
42300  void
42301  value_free (struct value *val)
42302  {
42303    if (val)
42304      {
42305 +      type_decref (val->type);
42306 +      type_decref (val->enclosing_type);
42307 +
42308        if (VALUE_LVAL (val) == lval_computed)
42309         {
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);
42313    else
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);
42322  
42323    component->location = whole->location;
42324 +
42325    if (VALUE_LVAL (whole) == lval_computed)
42326      {
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);
42331      }
42332 +
42333 +  object_address_get_data (value_type (whole), &VALUE_ADDRESS (component));
42334  }
42335  
42336  \f
42337 @@ -830,6 +888,25 @@ show_values (char *num_exp, int from_tty)
42338        num_exp[1] = '\0';
42339      }
42340  }
42341 +
42342 +/* Sanity check for memory leaks and proper types reference counting.  */
42343 +
42344 +static void
42345 +value_history_cleanup (void *unused)
42346 +{
42347 +  while (value_history_chain)
42348 +    {
42349 +      struct value_history_chunk *chunk = value_history_chain;
42350 +      int i;
42351 +
42352 +      for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
42353 +       value_free (chunk->values[i]);
42354 +
42355 +      value_history_chain = chunk->next;
42356 +      xfree (chunk);
42357 +    }
42358 +  value_history_count = 0;
42359 +}
42360  \f
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.  */
42365  
42366  struct internalvar *
42367 -lookup_only_internalvar (char *name)
42368 +lookup_only_internalvar (const char *name)
42369  {
42370    struct internalvar *var;
42371  
42372 @@ -894,7 +971,7 @@ lookup_only_internalvar (char *name)
42373     NAME should not normally include a dollar sign.  */
42374  
42375  struct internalvar *
42376 -create_internalvar (char *name)
42377 +create_internalvar (const char *name)
42378  {
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.  */
42391  
42392  struct internalvar *
42393 -lookup_internalvar (char *name)
42394 +lookup_internalvar (const char *name)
42395  {
42396    struct internalvar *var;
42397  
42398 @@ -1031,6 +1109,9 @@ set_internalvar (struct internalvar *var, struct value *val)
42399  {
42400    struct value *newval;
42401  
42402 +  if (var->canonical)
42403 +    error (_("Cannot overwrite convenience function %s"), var->name);
42404 +
42405    newval = value_copy (val);
42406    newval->modifiable = 1;
42407  
42408 @@ -1042,7 +1123,7 @@ set_internalvar (struct internalvar *var, struct value *val)
42409  
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
42416       long.  */
42417 @@ -1059,6 +1140,76 @@ internalvar_name (struct internalvar *var)
42418    return var->name;
42419  }
42420  
42421 +static struct value *
42422 +value_create_internal_function (const char *name,
42423 +                               internal_function_fn handler,
42424 +                               void *cookie)
42425 +{
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;
42433 +  *fnp = ifn;
42434 +  return result;
42435 +}
42436 +
42437 +char *
42438 +value_internal_function_name (struct value *val)
42439 +{
42440 +  gdb_byte *addr = value_contents_writeable (val);
42441 +  struct internal_function *ifn = * (struct internal_function **) addr;
42442 +  return ifn->name;
42443 +}
42444 +
42445 +struct value *
42446 +call_internal_function (struct value *func, int argc, struct value **argv)
42447 +{
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);
42451 +}
42452 +
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.  */
42457 +static void
42458 +function_command (char *command, int from_tty)
42459 +{
42460 +  /* Do nothing.  */
42461 +}
42462 +
42463 +/* Clean up if an internal function's command is destroyed.  */
42464 +static void
42465 +function_destroyer (struct cmd_list_element *self, void *ignore)
42466 +{
42467 +  xfree (self->name);
42468 +  xfree (self->doc);
42469 +}
42470 +
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
42475 +   data".  */
42476 +void
42477 +add_internal_function (const char *name, const char *doc,
42478 +                      internal_function_fn handler, void *cookie)
42479 +{
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;
42485 +
42486 +  cmd = add_cmd (xstrdup (name), no_class, function_command, (char *) doc,
42487 +                &functionlist);
42488 +  cmd->destroyer = function_destroyer;
42489 +}
42490 +
42491  /* Update VALUE before discarding OBJFILE.  COPIED_TYPES is used to
42492     prevent cycles / duplicates.  */
42493  
42494 @@ -1067,12 +1218,21 @@ preserve_one_value (struct value *value, struct objfile *objfile,
42495                     htab_t copied_types)
42496  {
42497    if (TYPE_OBJFILE (value->type) == objfile)
42498 -    value->type = copy_type_recursive (objfile, value->type, copied_types);
42499 +    {
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);
42504 +    }
42505  
42506    if (TYPE_OBJFILE (value->enclosing_type) == objfile)
42507 -    value->enclosing_type = copy_type_recursive (objfile,
42508 -                                                value->enclosing_type,
42509 -                                                copied_types);
42510 +    {
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,
42514 +                                                  copied_types);
42515 +      type_incref (value->enclosing_type);
42516 +    }
42517  }
42518  
42519  /* Update the internal variables and value history when OBJFILE is
42520 @@ -1196,7 +1356,7 @@ value_as_address (struct value *val)
42521  
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);
42535  
42536    val = coerce_array (val);
42537  
42538 @@ -1447,7 +1607,7 @@ value_static_field (struct type *type, int fieldno)
42539         }
42540        if (retval && VALUE_LVAL (retval) == lval_memory)
42541         SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
42542 -                           VALUE_ADDRESS (retval));
42543 +                           value_address (retval));
42544      }
42545    return retval;
42546  }
42547 @@ -1465,6 +1625,8 @@ value_change_enclosing_type (struct value *val, struct type *new_encl_type)
42548      val->contents =
42549        (gdb_byte *) xrealloc (val->contents, TYPE_LENGTH (new_encl_type));
42550  
42551 +  type_incref (new_encl_type);
42552 +  type_decref (val->enclosing_type);
42553    val->enclosing_type = new_encl_type;
42554    return val;
42555  }
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)));
42559         }
42560 +      type_incref (type);
42561 +      type_decref (v->type);
42562        v->type = 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);
42567    if (sym)
42568      {
42569 -      VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));
42570 +      set_value_address (v, BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
42571      }
42572    else
42573      {
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);
42577  
42578 -      VALUE_ADDRESS (v)
42579 -       = gdbarch_convert_from_func_ptr_addr
42580 -          (gdbarch, SYMBOL_VALUE_ADDRESS (msym), &current_target);
42581 +      set_value_address (v,
42582 +       gdbarch_convert_from_func_ptr_addr
42583 +          (gdbarch, SYMBOL_VALUE_ADDRESS (msym), &current_target));
42584      }
42585  
42586    if (arg1p)
42587 @@ -1750,6 +1914,41 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
42588  }
42589  
42590  
42591 +/* Pack NUM into BUF using a target format of TYPE.  */
42592 +
42593 +void
42594 +pack_unsigned_long (gdb_byte *buf, struct type *type, ULONGEST num)
42595 +{
42596 +  int len;
42597 +
42598 +  type = check_typedef (type);
42599 +  len = TYPE_LENGTH (type);
42600 +
42601 +  switch (TYPE_CODE (type))
42602 +    {
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);
42611 +      break;
42612 +
42613 +    case TYPE_CODE_REF:
42614 +    case TYPE_CODE_PTR:
42615 +      store_typed_address (buf, type, (CORE_ADDR) num);
42616 +      break;
42617 +
42618 +    default:
42619 +      error (_("\
42620 +Unexpected type (%d) encountered for unsigned integer constant."),
42621 +            TYPE_CODE (type));
42622 +    }
42623 +}
42624 +
42625 +
42626  /* Convert C numbers into newly allocated values.  */
42627  
42628  struct value *
42629 @@ -1763,6 +1962,19 @@ value_from_longest (struct type *type, LONGEST num)
42630  }
42631  
42632  
42633 +/* Convert C unsigned numbers into newly allocated values.  */
42634 +
42635 +struct value *
42636 +value_from_ulongest (struct type *type, ULONGEST num)
42637 +{
42638 +  struct value *val = allocate_value (type);
42639 +
42640 +  pack_unsigned_long (value_contents_raw (val), type, num);
42641 +
42642 +  return val;
42643 +}
42644 +
42645 +
42646  /* Create a value representing a pointer of type TYPE to the address
42647     ADDR.  */
42648  struct value *
42649 @@ -1816,8 +2028,9 @@ value_from_contents_and_address (struct type *type,
42650      set_value_lazy (v, 1);
42651    else
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;
42658    return v;
42659  }
42660  
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."));
42665 +
42666 +  add_prefix_cmd ("function", no_class, function_command, _("\
42667 +Placeholder command for showing help on convenience functions."),
42668 +                 &functionlist, "function ", 0, &cmdlist);
42669 +
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>";
42674 +
42675 +  make_final_cleanup (value_history_cleanup, NULL);
42676  }
42677 diff --git a/gdb/value.h b/gdb/value.h
42678 index aa43365..1ad3c75 100644
42679 --- a/gdb/value.h
42680 +++ b/gdb/value.h
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))
42684  
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
42687 -   structure.  */
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))
42691  
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 *);
42697 +
42698 +/* Like value_address, except the result does not include value's
42699 +   offset.  */
42700 +extern CORE_ADDR value_raw_address (struct value *);
42701 +
42702 +/* Set the address of a value.  */
42703 +extern void set_value_address (struct value *, CORE_ADDR);
42704 +
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;
42711    int endian;
42712 +  /* True if this internalvar is the canonical name for a convenience
42713 +     function.  */
42714 +  int canonical;
42715  };
42716  
42717  \f
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);
42720  
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);
42728  
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);
42732 +
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);
42735  
42736 @@ -388,6 +407,8 @@ extern struct value *value_mark (void);
42737  
42738  extern void value_free_to_mark (struct value *mark);
42739  
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);
42744  
42745 @@ -435,6 +456,7 @@ extern struct value *value_struct_elt (struct value **argp,
42746  
42747  extern struct value *value_aggregate_elt (struct type *curtype,
42748                                           char *name,
42749 +                                         struct type *expect_type,
42750                                           int want_address,
42751                                           enum noside noside);
42752  
42753 @@ -533,14 +555,14 @@ extern void set_internalvar_component (struct internalvar *var,
42754                                        int bitpos, int bitsize,
42755                                        struct value *newvalue);
42756  
42757 -extern struct internalvar *lookup_only_internalvar (char *name);
42758 +extern struct internalvar *lookup_only_internalvar (const char *name);
42759  
42760 -extern struct internalvar *create_internalvar (char *name);
42761 +extern struct internalvar *create_internalvar (const char *name);
42762  
42763  extern struct internalvar *
42764    create_internalvar_type_lazy (char *name, internalvar_make_value fun);
42765  
42766 -extern struct internalvar *lookup_internalvar (char *name);
42767 +extern struct internalvar *lookup_internalvar (const char *name);
42768  
42769  extern int value_equal (struct value *arg1, struct value *arg2);
42770  
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);
42774  
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);
42779  
42780 @@ -658,5 +680,22 @@ extern struct value *value_allocate_space_in_inferior (int);
42781  
42782  extern struct value *value_of_local (const char *name, int complain);
42783  
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);
42787 +
42788 +/* User function handler.  */
42789 +
42790 +typedef struct value *(*internal_function_fn) (void *cookie,
42791 +                                              int argc,
42792 +                                              struct value **argv);
42793 +
42794 +void add_internal_function (const char *name, const char *doc,
42795 +                           internal_function_fn handler,
42796 +                           void *cookie);
42797 +
42798 +struct value *call_internal_function (struct value *function,
42799 +                                     int argc, struct value **argv);
42800 +
42801 +char *value_internal_function_name (struct value *);
42802 +
42803  #endif /* !defined (VALUE_H) */
42804 diff --git a/gdb/varobj.c b/gdb/varobj.c
42805 index 2ec6d90..1237c96 100644
42806 --- a/gdb/varobj.c
42807 +++ b/gdb/varobj.c
42808 @@ -29,11 +29,20 @@
42809  
42810  #include "gdb_assert.h"
42811  #include "gdb_string.h"
42812 +#include "gdb_regex.h"
42813  
42814  #include "varobj.h"
42815  #include "vec.h"
42816  #include "gdbthread.h"
42817  #include "inferior.h"
42818 +#include "valprint.h"
42819 +
42820 +#if HAVE_PYTHON
42821 +#include "python/python.h"
42822 +#include "python/python-internal.h"
42823 +#else
42824 +typedef int PyObject;
42825 +#endif
42826  
42827  /* Non-zero if we want to see trace of varobj level stuff.  */
42828  
42829 @@ -138,6 +147,12 @@ struct varobj
42830    /* Children of this object.  */
42831    VEC (varobj_p) *children;
42832  
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;
42838 +
42839    /* Description of the root variable. Points to root variable for children. */
42840    struct varobj_root *root;
42841  
42842 @@ -159,6 +174,16 @@ struct varobj
42843       not fetched if either the variable is frozen, or any parents is
42844       frozen.  */
42845    int not_fetched;
42846 +
42847 +  /* Sub-range of children which the MI consumer has requested.  If
42848 +     FROM < 0 or TO < 0, means that all children have been
42849 +     requested.  */
42850 +  int from;
42851 +  int to;
42852 +
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;
42856  };
42857  
42858  struct cpstack
42859 @@ -190,6 +215,10 @@ static void uninstall_variable (struct varobj *);
42860  
42861  static struct varobj *create_child (struct varobj *, int, char *);
42862  
42863 +static struct varobj *
42864 +create_child_with_value (struct varobj *parent, int index, const char *name,
42865 +                        struct value *value);
42866 +
42867  /* Utility routines */
42868  
42869  static struct varobj *new_variable (void);
42870 @@ -200,6 +229,8 @@ static void free_variable (struct varobj *var);
42871  
42872  static struct cleanup *make_cleanup_free_variable (struct varobj *var);
42873  
42874 +static struct cleanup *make_cleanup_uninstall_variable (struct varobj *var);
42875 +
42876  static struct type *get_type (struct varobj *var);
42877  
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, 
42881                               int initial);
42882  
42883 +static void install_default_visualizer (struct varobj *var);
42884 +
42885  /* Language-specific routines. */
42886  
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);
42891  
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);
42897  
42898  static int varobj_value_is_changeable_p (struct varobj *var);
42899  
42900  static int is_root_p (struct varobj *var);
42901  
42902 +static struct varobj *
42903 +varobj_add_child (struct varobj *var, const char *name, struct value *value);
42904 +
42905  /* C implementation */
42906  
42907  static int c_number_of_children (struct varobj *var);
42908 @@ -570,8 +607,10 @@ varobj_create (char *objname,
42909           do_cleanups (old_chain);
42910           return NULL;
42911         }
42912 +      make_cleanup_uninstall_variable (var);
42913      }
42914  
42915 +  install_default_visualizer (var);
42916    discard_cleanups (old_chain);
42917    return var;
42918  }
42919 @@ -678,6 +717,33 @@ varobj_delete (struct varobj *var, char ***dellist, int only_children)
42920    return delcount;
42921  }
42922  
42923 +/* Convenience function for varobj_set_visualizer.  Instantiate a
42924 +   pretty-printer for a given value.  */
42925 +static PyObject *
42926 +instantiate_pretty_printer (PyObject *constructor, struct value *value)
42927 +{
42928 +#if HAVE_PYTHON
42929 +  PyObject *val_obj = NULL; 
42930 +  PyObject *printer;
42931 +  volatile struct gdb_exception except;
42932 +
42933 +  TRY_CATCH (except, RETURN_MASK_ALL)
42934 +    {
42935 +      value = value_copy (value);
42936 +    }
42937 +  GDB_PY_HANDLE_EXCEPTION (except);
42938 +  val_obj = value_to_value_object (value);
42939 +
42940 +  if (! val_obj)
42941 +    return NULL;
42942 +
42943 +  printer = gdbpy_instantiate_printer (constructor, val_obj);
42944 +  Py_DECREF (val_obj);
42945 +  return printer;
42946 +#endif
42947 +  return NULL;
42948 +}
42949 +
42950  /* Set/Get variable object display format */
42951  
42952  enum varobj_display_formats
42953 @@ -702,7 +768,8 @@ varobj_set_display_format (struct varobj *var,
42954        && var->value && !value_lazy (var->value))
42955      {
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);
42960      }
42961  
42962    return var->format;
42963 @@ -714,6 +781,21 @@ varobj_get_display_format (struct varobj *var)
42964    return var->format;
42965  }
42966  
42967 +char *
42968 +varobj_get_display_hint (struct varobj *var)
42969 +{
42970 +  char *result = NULL;
42971 +
42972 +#if HAVE_PYTHON
42973 +  PyGILState_STATE state = PyGILState_Ensure ();
42974 +  if (var->pretty_printer)
42975 +    result = gdbpy_get_display_hint (var->pretty_printer);
42976 +  PyGILState_Release (state);
42977 +#endif
42978 +
42979 +  return result;
42980 +}
42981 +
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;
42987  }
42988  
42989 +static int
42990 +update_dynamic_varobj_children (struct varobj *var,
42991 +                               VEC (varobj_p) **changed,
42992 +                               VEC (varobj_p) **new_and_unchanged,
42993 +                               int *cchanged)
42994 +
42995 +{
42996 +#if HAVE_PYTHON
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;
43003 +  int i;
43004 +  int children_changed = 0;
43005 +  PyObject *printer = var->pretty_printer;
43006 +  PyGILState_STATE state;
43007 +
43008 +  state = PyGILState_Ensure ();
43009 +  back_to = make_cleanup_py_restore_gil (&state);
43010 +
43011 +  *cchanged = 0;
43012 +  if (!PyObject_HasAttr (printer, gdbpy_children_cst))
43013 +    {
43014 +      do_cleanups (back_to);
43015 +      return 0;
43016 +    }
43017 +
43018 +  children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
43019 +                                        NULL);
43020 +
43021 +  if (!children)
43022 +    {
43023 +      gdbpy_print_stack ();
43024 +      error ("Null value returned for children");
43025 +    }
43026 +
43027 +  make_cleanup_py_decref (children);
43028 +
43029 +  if (!PyIter_Check (children))
43030 +    error ("Returned value is not iterable");
43031 +
43032 +  iterator = PyObject_GetIter (children);
43033 +  if (!iterator)
43034 +    {
43035 +      gdbpy_print_stack ();
43036 +      error ("Could not get children iterator");
43037 +    }
43038 +  make_cleanup_py_decref (iterator);
43039 +
43040 +  for (i = 0; ; ++i)
43041 +    {
43042 +      PyObject *item = PyIter_Next (iterator);
43043 +      PyObject *py_v;
43044 +      struct value *v;
43045 +      char *name;
43046 +      struct cleanup *inner;
43047 +      
43048 +      if (!item)
43049 +       break;
43050 +      inner = make_cleanup_py_decref (item);
43051 +
43052 +      if (!PyArg_ParseTuple (item, "sO", &name, &py_v))
43053 +       error ("Invalid item from the child list");
43054 +      
43055 +      if (PyObject_TypeCheck (py_v, &value_object_type))
43056 +       {
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);
43062 +       }
43063 +      else
43064 +       v = convert_value_from_python (py_v);
43065 +
43066 +      /* TODO: This assume the name of the i-th child never changes.  */
43067 +
43068 +      /* Now see what to do here.  */
43069 +      if (VEC_length (varobj_p, var->children) < i + 1)
43070 +       {
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;
43076 +       }
43077 +      else 
43078 +       {
43079 +         varobj_p existing = VEC_index (varobj_p, var->children, i);
43080 +         if (install_new_value (existing, v, 0) && changed)
43081 +           {
43082 +             if (changed)
43083 +               VEC_safe_push (varobj_p, *changed, existing);
43084 +           }
43085 +         else
43086 +           {
43087 +             if (new_and_unchanged)
43088 +               VEC_safe_push (varobj_p, *new_and_unchanged, existing);
43089 +           }
43090 +       }
43091 +
43092 +      do_cleanups (inner);
43093 +    }
43094 +
43095 +  if (i < VEC_length (varobj_p, var->children))
43096 +    {
43097 +      int i;
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);
43101 +    }
43102 +  VEC_truncate (varobj_p, var->children, i);
43103 +  var->num_children = VEC_length (varobj_p, var->children);
43104
43105 +  do_cleanups (back_to);
43106 +
43107 +  *cchanged = children_changed;
43108 +  return 1;
43109 +#else
43110 +  gdb_assert (0 && "should never be called if Python is not enabled");
43111 +#endif
43112 +}
43113  
43114  int
43115  varobj_get_num_children (struct varobj *var)
43116  {
43117    if (var->num_children == -1)
43118 -    var->num_children = number_of_children (var);
43119 +    {
43120 +      int changed;
43121 +      if (!var->pretty_printer
43122 +         || !update_dynamic_varobj_children (var, NULL, NULL, &changed))
43123 +       var->num_children = number_of_children (var);
43124 +    }
43125  
43126    return var->num_children;
43127  }
43128 @@ -764,7 +975,16 @@ varobj_list_children (struct varobj *var)
43129  {
43130    struct varobj *child;
43131    char *name;
43132 -  int i;
43133 +  int i, children_changed;
43134 +
43135 +  var->children_requested = 1;
43136 +
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;
43143  
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);
43151         }
43152      }
43153  
43154    return var->children;
43155  }
43156  
43157 +static struct varobj *
43158 +varobj_add_child (struct varobj *var, const char *name, struct value *value)
43159 +{
43160 +  varobj_p v = create_child_with_value (var, 
43161 +                                       VEC_length (varobj_p, var->children), 
43162 +                                       name, value);
43163 +  VEC_safe_push (varobj_p, var->children, v);
43164 +  install_default_visualizer (v);
43165 +  return v;
43166 +}
43167 +
43168  /* Obtain the type of an object Variable as a string similar to the one gdb
43169     prints on the console */
43170  
43171 @@ -1002,6 +1234,13 @@ install_new_value (struct varobj *var, struct value *value, int initial)
43172       a type. */
43173    gdb_assert (var->type || CPLUS_FAKE_CHILD (var));
43174    changeable = varobj_value_is_changeable_p (var);
43175 +
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)
43180 +    changeable = 1;
43181 +
43182    need_to_fetch = changeable;
43183  
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)
43186         }
43187      }
43188  
43189 +
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);
43198  
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)
43202    return changed;
43203  }
43204  
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.  */
43211 +void
43212 +varobj_get_child_range (struct varobj *var, VEC (varobj_p) *children,
43213 +                       int *from, int *to)
43214 +{
43215 +  if (var->from < 0 || var->to < 0)
43216 +    {
43217 +      *from = 0;
43218 +      *to = VEC_length (varobj_p, children);
43219 +    }
43220 +  else
43221 +    {
43222 +      *from = var->from;
43223 +      if (*from > VEC_length (varobj_p, children))
43224 +       *from = VEC_length (varobj_p, children);
43225 +      *to = var->to;
43226 +      if (*to > VEC_length (varobj_p, children))
43227 +       *to = VEC_length (varobj_p, children);
43228 +    }
43229 +}
43230 +
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.  */
43234 +void
43235 +varobj_set_child_range (struct varobj *var, int from, int to)
43236 +{
43237 +  var->from = from;
43238 +  var->to = to;
43239 +}
43240 +
43241 +static void
43242 +install_visualizer (struct varobj *var, PyObject *visualizer)
43243 +{
43244 +#if HAVE_PYTHON
43245 +  /* If there are any children now, wipe them.  */
43246 +  varobj_delete (var, NULL, 1 /* children only */);
43247 +  var->num_children = -1;
43248 +
43249 +  Py_XDECREF (var->pretty_printer);
43250 +  var->pretty_printer = visualizer;
43251 +
43252 +  install_new_value (var, var->value, 1);
43253 +
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);
43260 +#else
43261 +  error ("Python support required");
43262 +#endif
43263 +}
43264 +
43265 +static void
43266 +install_default_visualizer (struct varobj *var)
43267 +{
43268 +#if HAVE_PYTHON
43269 +  struct cleanup *cleanup;
43270 +  PyGILState_STATE state;
43271 +  PyObject *pretty_printer = NULL;
43272 +
43273 +  state = PyGILState_Ensure ();
43274 +  cleanup = make_cleanup_py_restore_gil (&state);
43275 +
43276 +  if (var->value)
43277 +    {
43278 +      pretty_printer = gdbpy_get_varobj_pretty_printer (var->value);
43279 +      if (! pretty_printer)
43280 +       {
43281 +         gdbpy_print_stack ();
43282 +         error (_("Cannot instantiate printer for default visualizer"));
43283 +       }
43284 +    }
43285 +      
43286 +  if (pretty_printer == Py_None)
43287 +    {
43288 +      Py_DECREF (pretty_printer);
43289 +      pretty_printer = NULL;
43290 +    }
43291 +  
43292 +  install_visualizer (var, pretty_printer);
43293 +  do_cleanups (cleanup);
43294 +#else
43295 +  /* No error is right as this function is inserted just as a hook.  */
43296 +#endif
43297 +}
43298 +
43299 +void 
43300 +varobj_set_visualizer (struct varobj *var, const char *visualizer)
43301 +{
43302 +#if HAVE_PYTHON
43303 +  PyObject *mainmod, *globals, *pretty_printer, *constructor;
43304 +  struct cleanup *back_to, *value;
43305 +  PyGILState_STATE state;
43306 +
43307 +
43308 +  state = PyGILState_Ensure ();
43309 +  back_to = make_cleanup_py_restore_gil (&state);
43310 +
43311 +  mainmod = PyImport_AddModule ("__main__");
43312 +  globals = PyModule_GetDict (mainmod);
43313 +  Py_INCREF (globals);
43314 +  make_cleanup_py_decref (globals);
43315 +
43316 +  constructor = PyRun_String (visualizer, Py_eval_input, globals, globals);
43317 +  
43318 +  /* Do not instantiate NoneType. */
43319 +  if (constructor == Py_None)
43320 +    {
43321 +      pretty_printer = Py_None;
43322 +      Py_INCREF (pretty_printer);
43323 +    }
43324 +  else
43325 +    pretty_printer = instantiate_pretty_printer (constructor, var->value);
43326 +
43327 +  Py_XDECREF (constructor);
43328 +
43329 +  if (! pretty_printer)
43330 +    {
43331 +      gdbpy_print_stack ();
43332 +      error ("Could not evaluate visualizer expression: %s", visualizer);
43333 +    }
43334 +
43335 +  if (pretty_printer == Py_None)
43336 +    {
43337 +      Py_DECREF (pretty_printer);
43338 +      pretty_printer = NULL;
43339 +    }
43340 +
43341 +  install_visualizer (var, pretty_printer);
43342 +
43343 +  do_cleanups (back_to);
43344 +#else
43345 +  error ("Python support required");
43346 +#endif
43347 +}
43348 +
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;
43355    struct value *new;
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;
43360  
43361 @@ -1187,20 +1572,85 @@ VEC(varobj_update_result) *varobj_update (struct varobj **varp, int explicit)
43362        
43363        if (new == NULL)
43364         r.status = VAROBJ_NOT_IN_SCOPE;
43365 -
43366 -      if (r.type_changed || r.changed)
43367 -       VEC_safe_push (varobj_update_result, result, &r);
43368 +      r.value_installed = 1;
43369  
43370        if (r.status == VAROBJ_NOT_IN_SCOPE)
43371 -       return result;
43372 +       {
43373 +         VEC_safe_push (varobj_update_result, result, &r);
43374 +         return result;
43375 +       }
43376 +            
43377 +      VEC_safe_push (varobj_update_result, stack, &r);
43378 +    }
43379 +  else
43380 +    {
43381 +      varobj_update_result r = {*varp};
43382 +      VEC_safe_push (varobj_update_result, stack, &r);
43383      }
43384 -
43385 -  VEC_safe_push (varobj_p, stack, *varp);
43386  
43387    /* Walk through the children, reconstructing them all.  */
43388 -  while (!VEC_empty (varobj_p, stack))
43389 +  while (!VEC_empty (varobj_update_result, stack))
43390      {
43391 -      v = VEC_pop (varobj_p, stack);
43392 +      varobj_update_result r = *(VEC_last (varobj_update_result, stack));
43393 +      struct varobj *v = r.varobj;
43394 +
43395 +      VEC_pop (varobj_update_result, stack);
43396 +
43397 +      /* Update this variable, unless it's a root, which is already
43398 +        updated.  */
43399 +      if (!r.value_installed)
43400 +       {         
43401 +         new = value_of_child (v->parent, v->index);
43402 +         if (install_new_value (v, new, 0 /* type not changed */))
43403 +           {
43404 +             r.changed = 1;
43405 +             v->updated = 0;
43406 +           }
43407 +       }
43408 +
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)
43414 +       {
43415 +         VEC (varobj_p) *changed = 0, *new_and_unchanged = 0;
43416 +         int i, children_changed;
43417 +         varobj_p tmp;
43418 +
43419 +         if (!v->children_requested)
43420 +           continue;
43421 +
43422 +         if (v->frozen)
43423 +           continue;
43424 +
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))
43429 +           {
43430 +             if (children_changed)
43431 +               r.children_changed = 1;
43432 +             for (i = 0; VEC_iterate (varobj_p, changed, i, tmp); ++i)
43433 +               {
43434 +                 varobj_update_result r = {tmp};
43435 +                 r.changed = 1;
43436 +                 r.value_installed = 1;
43437 +                 VEC_safe_push (varobj_update_result, stack, &r);
43438 +               }
43439 +             for (i = 0;
43440 +                  VEC_iterate (varobj_p, new_and_unchanged, i, tmp);
43441 +                  ++i)
43442 +               {
43443 +                 varobj_update_result r = {tmp};
43444 +                 r.value_installed = 1;
43445 +                 VEC_safe_push (varobj_update_result, stack, &r);
43446 +               }
43447 +             if (r.changed || r.children_changed)
43448 +               VEC_safe_push (varobj_update_result, result, &r);
43449 +             continue;
43450 +           }
43451 +       }
43452  
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);
43460 -       }
43461 -
43462 -      /* Update this variable, unless it's a root, which is already
43463 -        updated.  */
43464 -      if (v->root->rootvar != v)
43465 -       {         
43466 -         new = value_of_child (v->parent, v->index);
43467 -         if (install_new_value (v, new, 0 /* type not changed */))
43468             {
43469 -             /* Note that it's changed */
43470 -             varobj_update_result r = {v};
43471 -             r.changed = 1;
43472 -             VEC_safe_push (varobj_update_result, result, &r);
43473 -             v->updated = 0;
43474 +             varobj_update_result r = {c};
43475 +             VEC_safe_push (varobj_update_result, stack, &r);
43476             }
43477         }
43478 +
43479 +      if (r.changed || r.type_changed)
43480 +       VEC_safe_push (varobj_update_result, result, &r);
43481      }
43482  
43483 -  VEC_free (varobj_p, stack);
43484 +  VEC_free (varobj_update_result, stack);
43485 +
43486    return result;
43487  }
43488  \f
43489 @@ -1429,16 +1871,23 @@ uninstall_variable (struct varobj *var)
43490  static struct varobj *
43491  create_child (struct varobj *parent, int index, char *name)
43492  {
43493 +  return create_child_with_value (parent, index, name, 
43494 +                                 value_of_child (parent, index));
43495 +}
43496 +
43497 +static struct varobj *
43498 +create_child_with_value (struct varobj *parent, int index, const char *name,
43499 +                        struct value *value)
43500 +{
43501    struct varobj *child;
43502    char *childs_name;
43503 -  struct value *value;
43504  
43505    child = new_variable ();
43506  
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;
43518    var->frozen = 0;
43519    var->not_fetched = 0;
43520 +  var->children_requested = 0;
43521 +  var->from = -1;
43522 +  var->to = -1;
43523 +  var->pretty_printer = 0;
43524  
43525    return var;
43526  }
43527 @@ -1519,6 +1972,14 @@ free_variable (struct varobj *var)
43528        xfree (var->root);
43529      }
43530  
43531 +#if HAVE_PYTHON
43532 +  {
43533 +    PyGILState_STATE state = PyGILState_Ensure ();
43534 +    Py_XDECREF (var->pretty_printer);
43535 +    PyGILState_Release (state);
43536 +  }
43537 +#endif
43538 +
43539    xfree (var->name);
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);
43544  }
43545  
43546 +static void
43547 +do_uninstall_variable_cleanup (void *var)
43548 +{
43549 +  uninstall_variable (var);
43550 +}
43551 +
43552 +static struct cleanup *
43553 +make_cleanup_uninstall_variable (struct varobj *var)
43554 +{
43555 +  return make_cleanup (do_uninstall_variable_cleanup, var);
43556 +}
43557 +
43558  /* This returns the type of the variable. It also skips past typedefs
43559     to return the real type of the variable.
43560  
43561 @@ -1792,24 +2265,71 @@ my_value_of_variable (struct varobj *var, enum varobj_display_formats format)
43562      return NULL;
43563  }
43564  
43565 -static char *
43566 -value_get_print_value (struct value *value, enum varobj_display_formats format)
43567 +char *
43568 +value_get_print_value (struct value *value, enum varobj_display_formats format,
43569 +                      PyObject *value_formatter)
43570  {
43571    long dummy;
43572    struct ui_file *stb;
43573    struct cleanup *old_chain;
43574 -  char *thevalue;
43575 +  char *thevalue = NULL;
43576    struct value_print_options opts;
43577  
43578    if (value == NULL)
43579      return NULL;
43580  
43581 +#if HAVE_PYTHON
43582 +  {
43583 +    PyGILState_STATE state = PyGILState_Ensure ();
43584 +    if (value_formatter && PyObject_HasAttr (value_formatter,
43585 +                                            gdbpy_to_string_cst))
43586 +      {
43587 +       char *hint;
43588 +       struct value *replacement;
43589 +       int string_print = 0;
43590 +
43591 +       hint = gdbpy_get_display_hint (value_formatter);
43592 +       if (hint)
43593 +         {
43594 +           if (!strcmp (hint, "string"))
43595 +             string_print = 1;
43596 +           xfree (hint);
43597 +         }
43598 +
43599 +       thevalue = apply_varobj_pretty_printer (value_formatter,
43600 +                                               &replacement);
43601 +       if (thevalue && !string_print)
43602 +         {
43603 +           PyGILState_Release (state);
43604 +           return thevalue;
43605 +         }
43606 +       if (replacement)
43607 +         value = replacement;
43608 +      }
43609 +    PyGILState_Release (state);
43610 +  }
43611 +#endif
43612 +
43613    stb = mem_fileopen ();
43614    old_chain = make_cleanup_ui_file_delete (stb);
43615  
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);
43619 +  opts.raw = 1;
43620 +  if (thevalue)
43621 +    {
43622 +      struct type *string_char_type;
43623 +
43624 +      make_cleanup (xfree, thevalue);
43625 +      
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);
43631 +    }
43632 +  else
43633 +    common_val_print (value, stb, 0, &opts, current_language);
43634    thevalue = ui_file_xstrdup (stb, &dummy);
43635  
43636    do_cleanups (old_chain);
43637 @@ -1900,7 +2420,7 @@ varobj_floating_p (struct varobj *var)
43638     value is not known.  
43639  
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.  */
43644  static void
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);
43649  
43650 +  /* If we have a custom formatter, return whatever string it has
43651 +     produced.  */
43652 +  if (var->pretty_printer && var->print_value)
43653 +    return xstrdup (var->print_value);
43654 +  
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);
43661             else
43662 -             return value_get_print_value (var->value, format);
43663 +             return value_get_print_value (var->value, format, 
43664 +                                           var->pretty_printer);
43665           }
43666        }
43667      }
43668 diff --git a/gdb/varobj.h b/gdb/varobj.h
43669 index f2cdcf8..10758d6 100644
43670 --- a/gdb/varobj.h
43671 +++ b/gdb/varobj.h
43672 @@ -72,7 +72,12 @@ typedef struct varobj_update_result_t
43673    struct varobj *varobj;
43674    int type_changed;
43675    int changed;
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;
43683  
43684  DEF_VEC_O (varobj_update_result);
43685 @@ -107,6 +112,14 @@ extern void varobj_set_frozen (struct varobj *var, int frozen);
43686  
43687  extern int varobj_get_frozen (struct varobj *var);
43688  
43689 +extern void varobj_get_child_range (struct varobj *var,
43690 +                                   VEC (varobj_p) *children,
43691 +                                   int *from, int *to);
43692 +
43693 +extern void varobj_set_child_range (struct varobj *var, int from, int to);
43694 +
43695 +extern char *varobj_get_display_hint (struct varobj *var);
43696 +
43697  extern int varobj_get_num_children (struct varobj *var);
43698  
43699  /* Return the list of children of VAR.  The returned vector
43700 @@ -141,4 +154,13 @@ extern int varobj_editable_p (struct varobj *var);
43701  
43702  extern int varobj_floating_p (struct varobj *var);
43703  
43704 +extern void 
43705 +varobj_set_visualizer (struct varobj *var, const char *visualizer);
43706 +
43707 +extern void 
43708 +varobj_clear_type_visualizers ();
43709 +
43710 +extern void 
43711 +varobj_set_visualizer (struct varobj *var, const char *visualizer);
43712 +
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
43729 --- /dev/null
43730 +++ b/gdb/xml-syscall.c
43731 @@ -0,0 +1,423 @@
43732 +/* Functions that provide the mechanism to parse a syscall XML file
43733 +   and get its values.
43734 +
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.
43738 +
43739 +   This file is part of GDB.
43740 +
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.
43745 +
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.
43750 +
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/>.  */
43753 +
43754 +#include "defs.h"
43755 +#include "gdbtypes.h"
43756 +#include "xml-support.h"
43757 +#include "xml-syscall.h"
43758 +
43759 +#include "filenames.h"
43760 +
43761 +#include "gdb_assert.h"
43762 +
43763 +#ifndef HAVE_LIBEXPAT
43764 +
43765 +/* Dummy functions to indicate that there's no support for fetching
43766 +   syscalls information.  */
43767 +
43768 +static void
43769 +syscall_warn_user (void)
43770 +{
43771 +  static int have_warned = 0;
43772 +  if (!have_warned)
43773 +    {
43774 +      have_warned = 1;
43775 +      warning (_("Can not parse XML syscalls information; XML support was "
43776 +                "disabled at compile time"));
43777 +    }
43778 +}
43779 +
43780 +const struct syscalls_info *
43781 +xml_init_syscalls_info (const char *filename)
43782 +{
43783 +  syscall_warn_user ();
43784 +  return NULL;
43785 +}
43786 +
43787 +int
43788 +xml_get_syscall_number (const struct syscalls_info *sysinfo,
43789 +                        const char *syscall_name)
43790 +{
43791 +  syscall_warn_user ();
43792 +  return UNKNOWN_SYSCALL;
43793 +}
43794 +
43795 +const char *
43796 +xml_get_syscall_name (const struct syscalls_info *sysinfo,
43797 +                      int syscall_number)
43798 +{
43799 +  syscall_warn_user ();
43800 +  return NULL;
43801 +}
43802 +
43803 +int
43804 +xml_number_of_syscalls (const struct syscalls_info *sysinfo)
43805 +{
43806 +  syscall_warn_user ();
43807 +  return 0;
43808 +}
43809 +
43810 +const char **
43811 +xml_list_of_syscalls (const struct syscalls_info *sysinfo)
43812 +{
43813 +  syscall_warn_user ();
43814 +  return NULL;
43815 +}
43816 +
43817 +#else
43818 +
43819 +/* Structure which describes a syscall.  */
43820 +
43821 +typedef struct syscall_desc
43822 +{
43823 +  /* The syscall number.  */
43824 +
43825 +  int number;
43826 +
43827 +  /* The syscall name.  */
43828 +
43829 +  char *name;
43830 +} *syscall_desc_p;
43831 +DEF_VEC_P(syscall_desc_p);
43832 +
43833 +/* Structure that represents syscalls information.  */
43834 +
43835 +struct syscalls_info
43836 +{
43837 +  /* The syscalls.  */
43838 +
43839 +  VEC(syscall_desc_p) *syscalls;
43840 +};
43841 +
43842 +/* Callback data for syscall information parsing.  */
43843 +
43844 +struct syscall_parsing_data
43845 +{
43846 +  /* The syscalls_info we are building.  */
43847 +
43848 +  struct syscalls_info *sysinfo;
43849 +};
43850 +
43851 +
43852 +static struct syscalls_info *
43853 +allocate_syscalls_info (void)
43854 +{
43855 +  return XZALLOC (struct syscalls_info);
43856 +}
43857 +
43858 +static void
43859 +sysinfo_free_syscalls_desc (struct syscall_desc *sd)
43860 +{
43861 +  xfree (sd->name);
43862 +}
43863 +
43864 +static void
43865 +free_syscalls_info (void *arg)
43866 +{
43867 +  struct syscalls_info *sysinfo = arg;
43868 +  struct syscall_desc *sysdesc;
43869 +  int i;
43870 +
43871 +  for (i = 0;
43872 +       VEC_iterate (syscall_desc_p, sysinfo->syscalls, i, sysdesc);
43873 +       i++)
43874 +    sysinfo_free_syscalls_desc (sysdesc);
43875 +  VEC_free (syscall_desc_p, sysinfo->syscalls);
43876 +
43877 +  xfree (sysinfo);
43878 +}
43879 +
43880 +struct cleanup *
43881 +make_cleanup_free_syscalls_info (struct syscalls_info *sysinfo)
43882 +{
43883 +  return make_cleanup (free_syscalls_info, sysinfo);
43884 +}
43885 +
43886 +/* Open FILENAME, read all its text into memory, close it, and return
43887 +   the text.  If something goes wrong, return NULL and warn.  */
43888 +
43889 +static char *
43890 +fetch_xml_from_file (const char *filename, void *baton)
43891 +{
43892 +  const char *dirname = baton;
43893 +  FILE *file;
43894 +  struct cleanup *back_to;
43895 +  char *text;
43896 +  size_t len, offset;
43897 +
43898 +  if (dirname && *dirname)
43899 +    {
43900 +      char *fullname = concat (dirname, "/", filename, (char *) NULL);
43901 +      if (fullname == NULL)
43902 +       nomem (0);
43903 +      file = fopen (fullname, FOPEN_RT);
43904 +      xfree (fullname);
43905 +    }
43906 +  else
43907 +    file = fopen (filename, FOPEN_RT);
43908 +
43909 +  if (file == NULL)
43910 +    return NULL;
43911 +
43912 +  back_to = make_cleanup_fclose (file);
43913 +
43914 +  /* Read in the whole file, one chunk at a time.  */
43915 +  len = 4096;
43916 +  offset = 0;
43917 +  text = xmalloc (len);
43918 +  make_cleanup (free_current_contents, &text);
43919 +  while (1)
43920 +    {
43921 +      size_t bytes_read;
43922 +
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))
43927 +       {
43928 +         warning (_("Read error from \"%s\""), filename);
43929 +         do_cleanups (back_to);
43930 +         return NULL;
43931 +       }
43932 +
43933 +      offset += bytes_read;
43934 +
43935 +      if (feof (file))
43936 +       break;
43937 +
43938 +      len = len * 2;
43939 +      text = xrealloc (text, len);
43940 +    }
43941 +
43942 +  fclose (file);
43943 +  discard_cleanups (back_to);
43944 +
43945 +  text[offset] = '\0';
43946 +  return text;
43947 +}
43948 +
43949 +static void
43950 +syscall_create_syscall_desc (struct syscalls_info *sysinfo,
43951 +                             const char *name, int number)
43952 +{
43953 +  struct syscall_desc *sysdesc = XZALLOC (struct syscall_desc);
43954 +
43955 +  sysdesc->name = xstrdup (name);
43956 +  sysdesc->number = number;
43957 +
43958 +  VEC_safe_push (syscall_desc_p, sysinfo->syscalls, sysdesc);
43959 +}
43960 +
43961 +/* Handle the start of a <syscalls_info> element.  */
43962 +
43963 +static void
43964 +syscall_start_syscalls_info (struct gdb_xml_parser *parser,
43965 +                             const struct gdb_xml_element *element,
43966 +                             void *user_data,
43967 +                             VEC(gdb_xml_value_s) *attributes)
43968 +{
43969 +  struct syscall_parsing_data *data = user_data;
43970 +  struct syscalls_info *sysinfo = data->sysinfo;
43971 +}
43972 +
43973 +/* Handle the start of a <syscall> element.  */
43974 +
43975 +static void
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)
43979 +{
43980 +  struct syscall_parsing_data *data = user_data;
43981 +  struct gdb_xml_value *attrs = VEC_address (gdb_xml_value_s, attributes);
43982 +  int len, i;
43983 +  /* syscall info.  */
43984 +  char *name = NULL;
43985 +  int number = 0;
43986 +
43987 +  len = VEC_length (gdb_xml_value_s, attributes);
43988 +
43989 +  for (i = 0; i < len; i++)
43990 +    {
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;
43995 +      else
43996 +        internal_error (__FILE__, __LINE__,
43997 +                        _("Unknown attribute name '%s'."), attrs[i].name);
43998 +    }
43999 +
44000 +  syscall_create_syscall_desc (data->sysinfo, name, number);
44001 +}
44002 +
44003 +
44004 +/* The elements and attributes of an XML syscall document.  */
44005 +
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 }
44010 +};
44011 +
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 }
44017 +};
44018 +
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 }
44023 +};
44024 +
44025 +static struct syscalls_info *
44026 +syscall_parse_xml (const char *document, xml_fetch_another fetcher,
44027 +                   void *fetcher_baton)
44028 +{
44029 +  struct cleanup *result_cleanup;
44030 +  struct gdb_xml_parser *parser;
44031 +  struct syscall_parsing_data data;
44032 +  char *expanded_text;
44033 +  int i;
44034 +
44035 +  parser = gdb_xml_create_parser_and_cleanup (_("syscalls info"),
44036 +                                             syselements, &data);
44037 +
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);
44041 +
44042 +  if (gdb_xml_parse (parser, document) == 0)
44043 +    {
44044 +      /* Parsed successfully.  */
44045 +      discard_cleanups (result_cleanup);
44046 +      return data.sysinfo;
44047 +    }
44048 +  else
44049 +    {
44050 +      warning (_("Could not load XML syscalls info; ignoring"));
44051 +      do_cleanups (result_cleanup);
44052 +      return NULL;
44053 +    }
44054 +}
44055 +
44056 +const struct syscalls_info *
44057 +xml_init_syscalls_info (const char *filename)
44058 +{
44059 +  char *full_file;
44060 +  char *dirname;
44061 +  struct syscalls_info *sysinfo;
44062 +  struct cleanup *back_to;
44063 +
44064 +  full_file = fetch_xml_from_file (filename, gdb_datadir);
44065 +  if (full_file == NULL)
44066 +    {
44067 +      warning (_("Could not open \"%s\""), filename);
44068 +      return NULL;
44069 +    }
44070 +
44071 +  back_to = make_cleanup (xfree, full_file);
44072 +
44073 +  dirname = ldirname (filename);
44074 +  if (dirname != NULL)
44075 +    make_cleanup (xfree, dirname);
44076 +
44077 +  sysinfo = syscall_parse_xml (full_file, fetch_xml_from_file, dirname);
44078 +  do_cleanups (back_to);
44079 +
44080 +  return sysinfo;
44081 +}
44082 +
44083 +int
44084 +xml_get_syscall_number (const struct syscalls_info *sysinfo,
44085 +                        const char *syscall_name)
44086 +{
44087 +  struct syscall_desc *sysdesc;
44088 +  int i;
44089 +
44090 +  if (sysinfo == NULL
44091 +      || syscall_name == NULL)
44092 +    return UNKNOWN_SYSCALL;
44093 +
44094 +  for (i = 0;
44095 +       VEC_iterate(syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44096 +       i++)
44097 +    if (strcmp (sysdesc->name, syscall_name) == 0)
44098 +      return sysdesc->number;
44099 +
44100 +  return UNKNOWN_SYSCALL;
44101 +}
44102 +
44103 +const char *
44104 +xml_get_syscall_name (const struct syscalls_info *sysinfo,
44105 +                      int syscall_number)
44106 +{
44107 +  struct syscall_desc *sysdesc;
44108 +  int i;
44109 +
44110 +  if (sysinfo == NULL
44111 +      || syscall_number < 0)
44112 +    return NULL;
44113 +
44114 +  for (i = 0;
44115 +       VEC_iterate(syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44116 +       i++)
44117 +    if (sysdesc->number == syscall_number)
44118 +      return sysdesc->name;
44119 +
44120 +  return NULL;
44121 +}
44122 +
44123 +int
44124 +xml_number_of_syscalls (const struct syscalls_info *sysinfo)
44125 +{
44126 +  return (sysinfo == NULL ? 0 : VEC_length(syscall_desc_p,
44127 +                                           sysinfo->syscalls));
44128 +}
44129 +
44130 +const char **
44131 +xml_list_of_syscalls (const struct syscalls_info *sysinfo)
44132 +{
44133 +  struct syscall_desc *sysdesc;
44134 +  const char **names = NULL;
44135 +  int nsyscalls;
44136 +  int i;
44137 +
44138 +  if (sysinfo == NULL)
44139 +    return NULL;
44140 +
44141 +  nsyscalls = VEC_length (syscall_desc_p, sysinfo->syscalls);
44142 +  names = xmalloc ((nsyscalls + 1) * sizeof (char *));
44143 +
44144 +  for (i = 0;
44145 +       VEC_iterate (syscall_desc_p, sysinfo->syscalls, i, sysdesc);
44146 +       i++)
44147 +    names[i] = sysdesc->name;
44148 +
44149 +  names[i] = NULL;
44150 +
44151 +  return names;
44152 +}
44153 +
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
44158 --- /dev/null
44159 +++ b/gdb/xml-syscall.h
44160 @@ -0,0 +1,64 @@
44161 +/* Functions that provide the mechanism to parse a syscall XML file
44162 +   and get its values.
44163 +
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.
44167 +
44168 +   This file is part of GDB.
44169 +
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.
44174 +
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.
44179 +
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/>.  */
44182 +
44183 +#ifndef XML_SYSCALL_H
44184 +#define XML_SYSCALL_H 1
44185 +
44186 +/* Structure that stores information about the system's
44187 +   syscalls.  */
44188 +
44189 +struct syscalls_info;
44190 +
44191 +
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.
44195 +   
44196 +   Returns the struct syscalls_info if the file is valid, NULL otherwise.  */
44197 +
44198 +const struct syscalls_info *xml_init_syscalls_info (const char *);
44199 +
44200 +/* Function that retrieves the syscall number corresponding to the given
44201 +   name.
44202 +
44203 +   Returns the syscall number if found, or  otherwise.  */
44204 +
44205 +int xml_get_syscall_number (const struct syscalls_info *, const char *);
44206 +
44207 +/* Function that retrieves the syscall name corresponding to the given
44208 +   number.
44209 +
44210 +   Returns the syscall name if found, NULL otherwise.  */
44211 +const char *xml_get_syscall_name (const struct syscalls_info *, int);
44212 +
44213 +/* Function that returns the number of syscalls defined in the system.
44214 +
44215 +   Returns the number of syscalls, or zero otherwise.  */
44216 +int xml_number_of_syscalls (const struct syscalls_info *);
44217 +
44218 +/* Function used to retrieve the list of syscalls in the system.  This list
44219 +   is returned as an array of strings.
44220 +
44221 +   Returns the list of syscalls in the system, or NULL otherwise.  */
44222 +const char **xml_list_of_syscalls (const struct syscalls_info *sysinfo);
44223 +
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
44236     nice things.  */
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
44241 @@ -1,13 +1,14 @@
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.
44249  #
44250  msgid ""
44251  msgstr ""
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"
44265  
44266  #: arc-opc.c:668
44267 -msgid "to many shimms in load"
44268 +msgid "too many shimms in load"
44269  msgstr "demasiados shimms en load"
44270  
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"
44275  
44276 -#: arm-dis.c:4226
44277 +#: arm-dis.c:4238
44278  #, c-format
44279  msgid ""
44280  "\n"
44281 @@ -196,14 +197,14 @@ msgstr "La lista de registros no es v
44282  
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
44287  #, c-format
44288  msgid "Unrecognized field %d while parsing.\n"
44289  msgstr "No se reconoció el campo %d durante la decodificación.\n"
44290  
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"
44297  
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
44308  
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
44313  #, c-format
44314  msgid "syntax error (expected char `%c', found `%c')"
44315  msgstr "error sintáctico (se esperaba el carácter `%c', se encontró `%c')"
44316  
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
44321  #, c-format
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)"
44324  
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"
44331  
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"
44338  
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
44343  #, c-format
44344  msgid "bad instruction `%.50s...'"
44345  msgstr "instrucción errónea `%.50s...'"
44346  
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
44351  #, c-format
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*"
44357  
44358 -#: i386-dis.c:3196
44359 +#: i386-dis.c:9545
44360  msgid "<internal disassembler error>"
44361  msgstr "<error interno del desensamblador>"
44362  
44363 -#: i386-dis.c:3423
44364 +#: i386-dis.c:9776
44365  #, c-format
44366  msgid ""
44367  "\n"
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"
44371  
44372 -#: i386-dis.c:3427
44373 +#: i386-dis.c:9780
44374  #, c-format
44375  msgid "  x86-64      Disassemble in 64bit mode\n"
44376  msgstr "  x86-64      Desensambla en modo 64bit\n"
44377  
44378 -#: i386-dis.c:3428
44379 +#: i386-dis.c:9781
44380  #, c-format
44381  msgid "  i386        Disassemble in 32bit mode\n"
44382  msgstr "  i386        Desensambla en modo 32bit\n"
44383  
44384 -#: i386-dis.c:3429
44385 +#: i386-dis.c:9782
44386  #, c-format
44387  msgid "  i8086       Disassemble in 16bit mode\n"
44388  msgstr "  i8086       Desensambla en modo 16bit\n"
44389  
44390 -#: i386-dis.c:3430
44391 +#: i386-dis.c:9783
44392  #, c-format
44393  msgid "  att         Display instruction in AT&T syntax\n"
44394  msgstr "  att         Muestra las instrucciones con sintaxis AT&T\n"
44395  
44396 -#: i386-dis.c:3431
44397 +#: i386-dis.c:9784
44398  #, c-format
44399  msgid "  intel       Display instruction in Intel syntax\n"
44400  msgstr "  intel       Muestra las instrucciones con sintaxis Intel\n"
44401  
44402 -#: i386-dis.c:3432
44403 +#: i386-dis.c:9785
44404 +#, c-format
44405 +msgid ""
44406 +"  att-mnemonic\n"
44407 +"              Display instruction in AT&T mnemonic\n"
44408 +msgstr ""
44409 +"  att-mnemonic\n"
44410 +"              Muestra las instrucciones con mnemónicos AT&T\n"
44411 +
44412 +#: i386-dis.c:9787
44413 +#, c-format
44414 +msgid ""
44415 +"  intel-mnemonic\n"
44416 +"              Display instruction in Intel mnemonic\n"
44417 +msgstr ""
44418 +"  intel-mnemonic\n"
44419 +"              Muestra las instrucciones con mnemónicos Intel\n"
44420 +
44421 +#: i386-dis.c:9789
44422  #, c-format
44423  msgid "  addr64      Assume 64bit address size\n"
44424  msgstr "  addr64      Asume un tamaño de dirección de 64bit\n"
44425  
44426 -#: i386-dis.c:3433
44427 +#: i386-dis.c:9790
44428  #, c-format
44429  msgid "  addr32      Assume 32bit address size\n"
44430  msgstr "  addr32      Asume un tamaño de dirección de 32bit\n"
44431  
44432 -#: i386-dis.c:3434
44433 +#: i386-dis.c:9791
44434  #, c-format
44435  msgid "  addr16      Assume 16bit address size\n"
44436  msgstr "  addr16      Asume un tamaño de dirección de 16bit\n"
44437  
44438 -#: i386-dis.c:3435
44439 +#: i386-dis.c:9792
44440  #, c-format
44441  msgid "  data32      Assume 32bit data size\n"
44442  msgstr "  data32      Asume un tamaño de datos de 32bit\n"
44443  
44444 -#: i386-dis.c:3436
44445 +#: i386-dis.c:9793
44446  #, c-format
44447  msgid "  data16      Assume 16bit data size\n"
44448  msgstr "  data16      Asume un tamaño de datos de 16bit\n"
44449  
44450 -#: i386-dis.c:3437
44451 +#: i386-dis.c:9794
44452  #, c-format
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"
44455  
44456 -#: i386-gen.c:42 ia64-gen.c:307
44457 +#: i386-gen.c:411 ia64-gen.c:307
44458  #, c-format
44459  msgid "%s: Error: "
44460  msgstr "%s: Error: "
44461  
44462 -#: i386-gen.c:109
44463 -msgid "can't find i386-opc.tbl for reading\n"
44464 -msgstr "no se puede encontrar i386-opc.tbl para lectura\n"
44465 +#: i386-gen.c:510
44466 +#, c-format
44467 +msgid "%s: %d: Unknown bitfield: %s\n"
44468 +msgstr "%s: %d: Campo de bits desconocido: %s\n"
44469 +
44470 +#: i386-gen.c:674
44471 +#, c-format
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"
44474  
44475 -#: i386-gen.c:260
44476 -msgid "can't find i386-reg.tbl for reading\n"
44477 -msgstr "no se puede encontrar i386-reg.tbl para lectura\n"
44478 +#: i386-gen.c:851
44479 +#, c-format
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"
44482 +
44483 +#: i386-gen.c:943
44484 +#, c-format
44485 +msgid "can't create i386-init.h, errno = %s\n"
44486 +msgstr "no se puede crear i386-init.h, errno = %s\n"
44487  
44488 -#: i386-gen.c:386 ia64-gen.c:2841
44489 +#: i386-gen.c:1032 ia64-gen.c:2850
44490  #, c-format
44491  msgid "unable to change directory to \"%s\", errno = %s\n"
44492  msgstr "no se puede cambiar el directorio a \"%s\", errno = %s\n"
44493  
44494 +#: i386-gen.c:1039
44495 +#, c-format
44496 +msgid "%d unused bits in i386_cpu_flags.\n"
44497 +msgstr "%d bits sin usar en i386_cpu_flags.\n"
44498 +
44499 +#: i386-gen.c:1046
44500 +#, c-format
44501 +msgid "%d unused bits in i386_operand_type.\n"
44502 +msgstr "%d bits sin usar en i386_operand_type.\n"
44503 +
44504 +#: i386-gen.c:1060
44505 +#, c-format
44506 +msgid "can't create i386-tbl.h, errno = %s\n"
44507 +msgstr "no se puede crear i386-tbl.h, errno = %s\n"
44508 +
44509  #: ia64-gen.c:320
44510  #, c-format
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"
44515  
44516 -#: ia64-gen.c:1455
44517 +#: ia64-gen.c:1459
44518  #, c-format
44519  msgid "don't know how to specify %% dependency %s\n"
44520  msgstr "no se sabe cómo especificar la dependencia %% %s\n"
44521  
44522 -#: ia64-gen.c:1477
44523 +#: ia64-gen.c:1481
44524  #, c-format
44525  msgid "Don't know how to specify # dependency %s\n"
44526  msgstr "No se sabe cómo especificar la dependencia # %s\n"
44527  
44528 -#: ia64-gen.c:1516
44529 +#: ia64-gen.c:1520
44530  #, c-format
44531  msgid "IC:%s [%s] has no terminals or sub-classes\n"
44532  msgstr "IC:%s [%s] no tiene terminales o sub-clases\n"
44533  
44534 -#: ia64-gen.c:1519
44535 +#: ia64-gen.c:1523
44536  #, c-format
44537  msgid "IC:%s has no terminals or sub-classes\n"
44538  msgstr "IC:%s no tiene terminales o sub-clases\n"
44539  
44540 -#: ia64-gen.c:1528
44541 +#: ia64-gen.c:1532
44542  #, c-format
44543  msgid "no insns mapped directly to terminal IC %s [%s]"
44544  msgstr "no hay insns mapeadas directamente al IC terminal %s [%s]"
44545  
44546 -#: ia64-gen.c:1531
44547 +#: ia64-gen.c:1535
44548  #, c-format
44549  msgid "no insns mapped directly to terminal IC %s\n"
44550  msgstr "no hay insns mapeadas directamente al IC terminal %s\n"
44551  
44552 -#: ia64-gen.c:1542
44553 +#: ia64-gen.c:1546
44554  #, c-format
44555  msgid "class %s is defined but not used\n"
44556  msgstr "se define la clase %s pero no se utiliza\n"
44557  
44558 -#: ia64-gen.c:1553
44559 +#: ia64-gen.c:1559
44560  #, c-format
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"
44565  
44566 -#: ia64-gen.c:1557
44567 +#: ia64-gen.c:1562
44568 +#, c-format
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"
44571 +
44572 +#: ia64-gen.c:1566
44573  #, c-format
44574  msgid "rsrc %s (%s) has no regs\n"
44575  msgstr "el rsrc %s (%s) no tiene registros\n"
44576  
44577 -#: ia64-gen.c:2469
44578 +#: ia64-gen.c:2478
44579  #, c-format
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"
44582  
44583 -#: ia64-gen.c:2497
44584 +#: ia64-gen.c:2506
44585  #, c-format
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"
44588  
44589 -#: ia64-gen.c:2511
44590 +#: ia64-gen.c:2520
44591  #, c-format
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í"
44597  
44598 -#: mips-dis.c:745
44599 +#: mips-dis.c:781
44600  msgid "# internal error, incomplete extension sequence (+)"
44601  msgstr "# error interno, secuencia de extensión incompleta (+)"
44602  
44603 -#: mips-dis.c:852
44604 +#: mips-dis.c:915
44605  #, c-format
44606  msgid "# internal error, undefined extension sequence (+%c)"
44607  msgstr "# error interno, secuencia de extensión sin definir (+%c)"
44608  
44609 -#: mips-dis.c:1211
44610 +#: mips-dis.c:1274
44611  #, c-format
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"
44616  
44617 -#: mips-dis.c:1818
44618 +#: mips-dis.c:1881
44619  #, c-format
44620  msgid "# internal disassembler error, unrecognised modifier (%c)"
44621  msgstr "# error interno del desensamblador, no se reconoce el modificador (%c)"
44622  
44623 -#: mips-dis.c:2049
44624 +#: mips-dis.c:2112
44625  #, c-format
44626  msgid ""
44627  "\n"
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"
44631  
44632 -#: mips-dis.c:2053
44633 +#: mips-dis.c:2116
44634  #, c-format
44635  msgid ""
44636  "\n"
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"
44640  
44641 -#: mips-dis.c:2057
44642 +#: mips-dis.c:2120
44643  #, c-format
44644  msgid ""
44645  "\n"
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"
44649  
44650 -#: mips-dis.c:2061
44651 +#: mips-dis.c:2124
44652  #, c-format
44653  msgid ""
44654  "\n"
44655 @@ -804,7 +855,7 @@ msgstr ""
44656  "                           la arquitectura especificada.\n"
44657  "                           Por defecto: basado en el binario a desensamblar.\n"
44658  
44659 -#: mips-dis.c:2066
44660 +#: mips-dis.c:2129
44661  #, c-format
44662  msgid ""
44663  "\n"
44664 @@ -817,7 +868,7 @@ msgstr ""
44665  "                           especificada.\n"
44666  "                           Por defecto: basado en el binario a desensamblar.\n"
44667  
44668 -#: mips-dis.c:2071
44669 +#: mips-dis.c:2134
44670  #, c-format
44671  msgid ""
44672  "\n"
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"
44676  
44677 -#: mips-dis.c:2075
44678 +#: mips-dis.c:2138
44679  #, c-format
44680  msgid ""
44681  "\n"
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"
44685  
44686 -#: mips-dis.c:2079
44687 +#: mips-dis.c:2142
44688  #, c-format
44689  msgid ""
44690  "\n"
44691 @@ -850,12 +901,12 @@ msgstr ""
44692  "  Para las opciones anteriores, se admiten los siguientes valores de \"ABI\":\n"
44693  "   "
44694  
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
44697  #, c-format
44698  msgid "\n"
44699  msgstr "\n"
44700  
44701 -#: mips-dis.c:2086
44702 +#: mips-dis.c:2149
44703  #, c-format
44704  msgid ""
44705  "\n"
44706 @@ -894,9 +945,8 @@ msgid "Biiiig Trouble in parse_imm16!"
44707  msgstr "¡Graaaan Problema en parse_imm16!"
44708  
44709  #: mt-asm.c:157
44710 -#, c-format
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"
44715  
44716  #: mt-asm.c:395
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>"
44721  
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"
44726  
44727 -#: ppc-opc.c:812
44728 +#: ppc-opc.c:892
44729  msgid "attempt to set y bit when using + or - modifier"
44730  msgstr "intento de establecer el bit y cuando se usaba el modificador + ó -"
44731  
44732 -#: ppc-opc.c:844
44733 +#: ppc-opc.c:924
44734  msgid "invalid mask field"
44735  msgstr "campo de máscara inválido"
44736  
44737 -#: ppc-opc.c:870
44738 +#: ppc-opc.c:950
44739  msgid "ignoring invalid mfcr mask"
44740  msgstr "se descarta la máscara mfcr inválida"
44741  
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"
44746  
44747 -#: ppc-opc.c:1075
44748 +#: ppc-opc.c:1155
44749  msgid "index register in load range"
44750  msgstr "registro índice en el rango de carga"
44751  
44752 -#: ppc-opc.c:1091
44753 +#: ppc-opc.c:1171
44754  msgid "source and target register operands must be different"
44755  msgstr "los operandos de registros fuente y objetivo deben ser diferentes"
44756  
44757 -#: ppc-opc.c:1106
44758 +#: ppc-opc.c:1186
44759  msgid "invalid register operand when updating"
44760  msgstr "operando de registro inválido mientras se actualizaba"
44761  
44762 -#: ppc-opc.c:1188
44763 +#: ppc-opc.c:1265
44764  msgid "invalid sprg number"
44765  msgstr "número sprg inválido"
44766  
44767 +#: s390-dis.c:276
44768 +#, c-format
44769 +msgid ""
44770 +"\n"
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"
44773 +msgstr ""
44774 +"\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"
44778 +
44779 +#: s390-dis.c:280
44780 +#, c-format
44781 +msgid "  esa         Disassemble in ESA architecture mode\n"
44782 +msgstr "  esa         Desensambla en modo de arquitectura ESA\n"
44783 +
44784 +#: s390-dis.c:281
44785 +#, c-format
44786 +msgid "  zarch       Disassemble in z/Architecture mode\n"
44787 +msgstr "  zarch       Desensambla en modo de z/Architecture\n"
44788 +
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"
44795  
44796 -#: xc16x-asm.c:65
44797 +#: xc16x-asm.c:66
44798  msgid "Missing '#' prefix"
44799  msgstr "Falta el prefijo '#'"
44800  
44801 -#: xc16x-asm.c:81
44802 +#: xc16x-asm.c:82
44803  msgid "Missing '.' prefix"
44804  msgstr "Falta el prefijo '.'"
44805  
44806 -#: xc16x-asm.c:97
44807 +#: xc16x-asm.c:98
44808  msgid "Missing 'pof:' prefix"
44809  msgstr "Falta el prefijo 'pof:'"
44810  
44811 -#: xc16x-asm.c:113
44812 +#: xc16x-asm.c:114
44813  msgid "Missing 'pag:' prefix"
44814  msgstr "Falta el prefijo 'pag:'"
44815  
44816 -#: xc16x-asm.c:129
44817 +#: xc16x-asm.c:130
44818  msgid "Missing 'sof:' prefix"
44819  msgstr "Falta el prefijo 'sof:'"
44820  
44821 -#: xc16x-asm.c:145
44822 +#: xc16x-asm.c:146
44823  msgid "Missing 'seg:' prefix"
44824  msgstr "Falta el prefijo 'seg:'"
44825  
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"
44829  
44830 +#~ msgid "%operator operand is not a symbol"
44831 +#~ msgstr "el operando %operator no es un símbolo"
44832 +
44833  #~ msgid "offset not a multiple of 16"
44834  #~ msgstr "el desplazamiento no es un múltiplo de 16"
44835  
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
44840 @@ -1,46 +1,133 @@
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.
44848  #
44849  msgid ""
44850  msgstr ""
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"
44865  
44866 -#: alpha-opc.c:335
44867 +#: alpha-opc.c:155
44868  msgid "branch operand unaligned"
44869  msgstr "operand cabang tidak rata"
44870  
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"
44875  
44876 -#: arc-dis.c:52
44877 +#: arc-dis.c:77
44878  msgid "Illegal limm reference in last instruction!\n"
44879  msgstr "referensi limm ilegal dalam instruksi terakhir!\n"
44880  
44881 -#: arm-dis.c:502
44882 +#: arc-opc.c:386
44883 +msgid "unable to fit different valued constants into instruction"
44884 +msgstr "tidak dapat memasukan nilai konstanta berbeda kedalam instruksi"
44885 +
44886 +#: arc-opc.c:395
44887 +msgid "auxiliary register not allowed here"
44888 +msgstr "register tambahan tidak diperbolehkan disini"
44889 +
44890 +#: arc-opc.c:401 arc-opc.c:418
44891 +msgid "attempt to set readonly register"
44892 +msgstr "mencoba untuk menset register baca-saja"
44893 +
44894 +#: arc-opc.c:406 arc-opc.c:423
44895 +msgid "attempt to read writeonly register"
44896 +msgstr "mencoba untuk membaca register tulis-saja"
44897 +
44898 +#: arc-opc.c:428
44899 +#, c-format
44900 +msgid "invalid register number `%d'"
44901 +msgstr "nomor register tidak valid `%d'"
44902 +
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"
44906 +
44907 +#: arc-opc.c:668
44908 +msgid "too many shimms in load"
44909 +msgstr "terlalu banyak shimm dalam load"
44910 +
44911 +#. Do we have a limm already?
44912 +#: arc-opc.c:781
44913 +msgid "impossible store"
44914 +msgstr "store tidak memungkinkan"
44915 +
44916 +#: arc-opc.c:814
44917 +msgid "st operand error"
44918 +msgstr "operand st error"
44919 +
44920 +#: arc-opc.c:818 arc-opc.c:860
44921 +msgid "address writeback not allowed"
44922 +msgstr "alamat writeback tidak diijinkan"
44923 +
44924 +#: arc-opc.c:822
44925 +msgid "store value must be zero"
44926 +msgstr "nilai simpan harus nol"
44927 +
44928 +#: arc-opc.c:847
44929 +msgid "invalid load/shimm insn"
44930 +msgstr "insn load/shimm tidak valid"
44931 +
44932 +#: arc-opc.c:856
44933 +msgid "ld operand error"
44934 +msgstr "operand ld error"
44935 +
44936 +#: arc-opc.c:943
44937 +msgid "jump flags, but no .f seen"
44938 +msgstr "tanda jump, tetapi tidak ada .f yang terlihat"
44939 +
44940 +#: arc-opc.c:946
44941 +msgid "jump flags, but no limm addr"
44942 +msgstr "tanda jump, tetapi tidak ada alamat limm"
44943 +
44944 +#: arc-opc.c:949
44945 +msgid "flag bits of jump address limm lost"
44946 +msgstr "tanda bit dari alamat jump limm hilang"
44947 +
44948 +#: arc-opc.c:952
44949 +msgid "attempt to set HR bits"
44950 +msgstr "mencoba menset bit HR"
44951 +
44952 +#: arc-opc.c:955
44953 +msgid "bad jump flags value"
44954 +msgstr "nilai tanda jump buruk"
44955 +
44956 +#: arc-opc.c:988
44957 +msgid "branch address not on 4 byte boundary"
44958 +msgstr "alamat cabang tidak dalam kelipatan 4 byte"
44959 +
44960 +#: arc-opc.c:1024
44961 +msgid "must specify .jd or no nullify suffix"
44962 +msgstr "harus menspesifikasikan .jd atau tidak ada akhiran nullify"
44963 +
44964 +#: arm-dis.c:1808
44965  msgid "<illegal precision>"
44966  msgstr "<presisi ilegal>"
44967  
44968 -#: arm-dis.c:1012
44969 +#. XXX - should break 'option' at following delimiter.
44970 +#: arm-dis.c:3818
44971  #, c-format
44972  msgid "Unrecognised register name set: %s\n"
44973  msgstr "Set nama register tidak dikenal: %s\n"
44974  
44975 -#: arm-dis.c:1019
44976 +#. XXX - should break 'option' at following delimiter.
44977 +#: arm-dis.c:3826
44978  #, c-format
44979  msgid "Unrecognised disassembler option: %s\n"
44980  msgstr "Option disasembler tidak dikenal: %s\n"
44981  
44982 -#: arm-dis.c:1191
44983 +#: arm-dis.c:4238
44984 +#, c-format
44985  msgid ""
44986  "\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"
44990  "switch -M:\n"
44991  
44992 -#: avr-dis.c:118 avr-dis.c:128
44993 +#: avr-dis.c:115 avr-dis.c:125
44994 +#, c-format
44995  msgid "undefined"
44996  msgstr "tidak didefinisikan"
44997  
44998 -#: avr-dis.c:180
44999 +#: avr-dis.c:187
45000 +#, c-format
45001  msgid "Internal disassembler error"
45002  msgstr "Kesalahan disasembler internal"
45003  
45004 -#: avr-dis.c:228
45005 +#: avr-dis.c:236
45006  #, c-format
45007  msgid "unknown constraint `%c'"
45008  msgstr "konstrain tidak dikenal `%c'"
45009  
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
45014  #, c-format
45015  msgid "operand out of range (%ld not between %ld and %ld)"
45016  msgstr "operand keluar batas (%ld tidak antara %ld dan %ld)"
45017  
45018 -#: cgen-asm.c:367
45019 +#: cgen-asm.c:358
45020  #, c-format
45021  msgid "operand out of range (%lu not between %lu and %lu)"
45022  msgstr "operand keluar batas (%lu tidak antara %lu dan %lu)"
45023  
45024 -#: d30v-dis.c:312
45025 +#: d30v-dis.c:255
45026  #, c-format
45027  msgid "<unknown register %d>"
45028  msgstr "<register tidak dikenal %d>"
45029  
45030  #. Can't happen.
45031 -#: dis-buf.c:57
45032 +#: dis-buf.c:59
45033  #, c-format
45034  msgid "Unknown error %d\n"
45035  msgstr "Kesalahan tidak dikenal %d\n"
45036  
45037 -#: dis-buf.c:62
45038 +#: dis-buf.c:68
45039  #, c-format
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"
45044  
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"
45049 +
45050 +#: fr30-asm.c:95
45051 +msgid "Register must be between r0 and r7"
45052 +msgstr "Register harus berada diantara r0 dan r7"
45053 +
45054 +#: fr30-asm.c:97
45055 +msgid "Register must be between r8 and r15"
45056 +msgstr "Register harus berada diantara r8 dan r15"
45057 +
45058 +#: fr30-asm.c:116 m32c-asm.c:915
45059 +msgid "Register list is not valid"
45060 +msgstr "Daftar register tidak valid"
45061 +
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
45065  #, c-format
45066  msgid "Unrecognized field %d while parsing.\n"
45067  msgstr "Field tidak dikenal %d saat parsing.\n"
45068  
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"
45075  
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"
45091  
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
45096  #, c-format
45097  msgid "syntax error (expected char `%c', found `%c')"
45098  msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan `%c')"
45099  
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
45104  #, c-format
45105  msgid "syntax error (expected char `%c', found end of instruction)"
45106  msgstr "kesalahan sintaks (diharapkan karakter `%c', ditemukan akhir instruksi)"
45107  
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"
45114  
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"
45121  
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
45126  #, c-format
45127  msgid "bad instruction `%.50s...'"
45128  msgstr "instruksi buruk `%.50s...'"
45129  
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
45134  #, c-format
45135  msgid "bad instruction `%.50s'"
45136  msgstr "instruksi buruk `%.50s'"
45137  
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
45143  msgid "*unknown*"
45144  msgstr "*tidak dikenal*"
45145  
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
45150  #, c-format
45151  msgid "Unrecognized field %d while printing insn.\n"
45152  msgstr "Field tidak dikenal %d saat mencetak insn.\n"
45153  
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
45158  #, c-format
45159  msgid "operand out of range (%ld not between %ld and %lu)"
45160  msgstr "operand di luar batas (%ld tidak antara %ld dan %lu)"
45161  
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
45166  #, c-format
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)"
45171  
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
45176  #, c-format
45177  msgid "Unrecognized field %d while building insn.\n"
45178  msgstr "Field tidak dikenal %d saat membuild insn.\n"
45179  
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
45184  #, c-format
45185  msgid "Unrecognized field %d while decoding insn.\n"
45186  msgstr "Field tidak dikenal %d saat mendekode insn.\n"
45187  
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
45192  #, c-format
45193  msgid "Unrecognized field %d while getting int operand.\n"
45194  msgstr "Field tidak dikenal %d saat memperoleh operand int.\n"
45195  
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
45200  #, c-format
45201  msgid "Unrecognized field %d while getting vma operand.\n"
45202  msgstr "Field tidak dikenal %d saat memperoleh operand vma.\n"
45203  
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
45208  #, c-format
45209  msgid "Unrecognized field %d while setting int operand.\n"
45210  msgstr "Field tidak dikenal %d saat menset operand int.\n"
45211  
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
45216  #, c-format
45217  msgid "Unrecognized field %d while setting vma operand.\n"
45218  msgstr "Field tidak dikenal %d saat menset operand vma.\n"
45219  
45220 -#: h8300-dis.c:384
45221 +#: frv-asm.c:608
45222 +msgid "missing `]'"
45223 +msgstr "hilang `]'"
45224 +
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"
45228 +
45229 +#: frv-asm.c:908
45230 +msgid "Value of A operand must be 0 or 1"
45231 +msgstr "Nilai dari operand A harus berupa 0 atau 1"
45232 +
45233 +#: frv-asm.c:944
45234 +msgid "register number must be even"
45235 +msgstr "nomor register harus genap"
45236 +
45237 +#. -- assembler routines inserted here.
45238 +#. -- asm.c
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 `)'"
45244 +
45245 +#: h8300-dis.c:327
45246  #, c-format
45247 -msgid "Hmmmm %x"
45248 -msgstr "Hmmmm %x"
45249 +msgid "Hmmmm 0x%x"
45250 +msgstr "Hmmmm 0x%x"
45251  
45252 -#: h8300-dis.c:395
45253 +#: h8300-dis.c:708
45254  #, c-format
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"
45259  
45260 -#: h8500-dis.c:143
45261 +#: h8500-dis.c:124
45262  #, c-format
45263  msgid "can't cope with insert %d\n"
45264  msgstr "tidak dapat menangani insert %d\n"
45265  
45266  #. Couldn't understand anything.
45267 -#: h8500-dis.c:350
45268 +#: h8500-dis.c:324
45269  #, c-format
45270  msgid "%02x\t\t*unknown*"
45271  msgstr "%02x\t\t*tidak dikenal*"
45272  
45273 -#: i386-dis.c:1649
45274 +#: i386-dis.c:9545
45275  msgid "<internal disassembler error>"
45276  msgstr "<kesalahan asembler internal>"
45277  
45278 -#: m10200-dis.c:199
45279 +#: i386-dis.c:9776
45280 +#, c-format
45281 +msgid ""
45282 +"\n"
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"
45285 +msgstr ""
45286 +"\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"
45289 +
45290 +#: i386-dis.c:9780
45291 +#, c-format
45292 +msgid "  x86-64      Disassemble in 64bit mode\n"
45293 +msgstr "  x86-64      Disasemble dalam mode 64bit\n"
45294 +
45295 +#: i386-dis.c:9781
45296 +#, c-format
45297 +msgid "  i386        Disassemble in 32bit mode\n"
45298 +msgstr "  i386        Disassemble dalam mode 32bit\n"
45299 +
45300 +#: i386-dis.c:9782
45301 +#, c-format
45302 +msgid "  i8086       Disassemble in 16bit mode\n"
45303 +msgstr "  i8086       Disassemble dalam mode 16bit\n"
45304 +
45305 +#: i386-dis.c:9783
45306 +#, c-format
45307 +msgid "  att         Display instruction in AT&T syntax\n"
45308 +msgstr "  att         Tampilkan instruksi dalam sintaks AT&T\n"
45309 +
45310 +#: i386-dis.c:9784
45311 +#, c-format
45312 +msgid "  intel       Display instruction in Intel syntax\n"
45313 +msgstr "  intel       Tampilkan instruksi dalam sintaks Intel\n"
45314 +
45315 +#: i386-dis.c:9785
45316 +#, c-format
45317 +msgid ""
45318 +"  att-mnemonic\n"
45319 +"              Display instruction in AT&T mnemonic\n"
45320 +msgstr ""
45321 +"  att-mnemonic\n"
45322 +"              Tampilkan instruksi dalam mnemonic AT&T\n"
45323 +
45324 +#: i386-dis.c:9787
45325 +#, c-format
45326 +msgid ""
45327 +"  intel-mnemonic\n"
45328 +"              Display instruction in Intel mnemonic\n"
45329 +msgstr ""
45330 +"  intel-mnemonic\n"
45331 +"              Tampilkan instruksi dalam mnemonic Intel\n"
45332 +
45333 +#: i386-dis.c:9789
45334 +#, c-format
45335 +msgid "  addr64      Assume 64bit address size\n"
45336 +msgstr "  addr64      Asumsikan ukuran alamat 64bit\n"
45337 +
45338 +#: i386-dis.c:9790
45339 +#, c-format
45340 +msgid "  addr32      Assume 32bit address size\n"
45341 +msgstr "  addr32      Asumsikan ukuran alamat 32bit\n"
45342 +
45343 +#: i386-dis.c:9791
45344 +#, c-format
45345 +msgid "  addr16      Assume 16bit address size\n"
45346 +msgstr "  addr16      Asumsikan ukuran alamat 16bit\n"
45347 +
45348 +#: i386-dis.c:9792
45349  #, c-format
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"
45354  
45355 -#: m10200-dis.c:339
45356 +#: i386-dis.c:9793
45357 +#, c-format
45358 +msgid "  data16      Assume 16bit data size\n"
45359 +msgstr "  data16      Asumsikan ukuran data 16bit\n"
45360 +
45361 +#: i386-dis.c:9794
45362 +#, c-format
45363 +msgid "  suffix      Always display instruction suffix in AT&T syntax\n"
45364 +msgstr "  akhiran     Selalu tampilkan akhiran instruksi dalam sintaks AT&T\n"
45365 +
45366 +#: i386-gen.c:411 ia64-gen.c:307
45367 +#, c-format
45368 +msgid "%s: Error: "
45369 +msgstr "%s: Error: "
45370 +
45371 +#: i386-gen.c:510
45372 +#, c-format
45373 +msgid "%s: %d: Unknown bitfield: %s\n"
45374 +msgstr "%s: %d: bitfield tidak diketahui: %s\n"
45375 +
45376 +#: i386-gen.c:674
45377 +#, c-format
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"
45380 +
45381 +#: i386-gen.c:851
45382 +#, c-format
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"
45385 +
45386 +#: i386-gen.c:943
45387 +#, c-format
45388 +msgid "can't create i386-init.h, errno = %s\n"
45389 +msgstr "tidak dapat membuat i386-init.h, nomor error = %s\n"
45390 +
45391 +#: i386-gen.c:1032 ia64-gen.c:2850
45392 +#, c-format
45393 +msgid "unable to change directory to \"%s\", errno = %s\n"
45394 +msgstr "tidak dapat mengubah direktori ke \"%s\", nomor error = %s\n"
45395 +
45396 +#: i386-gen.c:1039
45397 +#, c-format
45398 +msgid "%d unused bits in i386_cpu_flags.\n"
45399 +msgstr "%d bit tidak digunakan dalam i386_cpu_flags.\n"
45400 +
45401 +#: i386-gen.c:1046
45402 +#, c-format
45403 +msgid "%d unused bits in i386_operand_type.\n"
45404 +msgstr "%d bit tidak digunakan dalam i386_operand_type.\n"
45405 +
45406 +#: i386-gen.c:1060
45407 +#, c-format
45408 +msgid "can't create i386-tbl.h, errno = %s\n"
45409 +msgstr "tidak dapat membuat i386-tbl.h, nomor error = %s\n"
45410 +
45411 +#: ia64-gen.c:320
45412 +#, c-format
45413 +msgid "%s: Warning: "
45414 +msgstr "%s: Peringatan: "
45415 +
45416 +#: ia64-gen.c:506 ia64-gen.c:740
45417 +#, c-format
45418 +msgid "multiple note %s not handled\n"
45419 +msgstr "catatan ganda %s tidak ditangani\n"
45420 +
45421 +#: ia64-gen.c:617
45422 +msgid "can't find ia64-ic.tbl for reading\n"
45423 +msgstr "tidak dapat menemukan ia64-ic.tbl untuk pembacaan\n"
45424 +
45425 +#: ia64-gen.c:822
45426 +#, c-format
45427 +msgid "can't find %s for reading\n"
45428 +msgstr "tidak dapat menemukan %s untuk pembacaan\n"
45429 +
45430 +#: ia64-gen.c:1046
45431 +#, c-format
45432 +msgid ""
45433 +"most recent format '%s'\n"
45434 +"appears more restrictive than '%s'\n"
45435 +msgstr ""
45436 +"format paling baru '%s'\n"
45437 +"tampak lebih terbatas dari '%s'\n"
45438 +
45439 +#: ia64-gen.c:1057
45440 +#, c-format
45441 +msgid "overlapping field %s->%s\n"
45442 +msgstr "daerah saling menimpa %s->%s\n"
45443 +
45444 +#: ia64-gen.c:1254
45445 +#, c-format
45446 +msgid "overwriting note %d with note %d (IC:%s)\n"
45447 +msgstr "catatan saling menulis %d dengan catatan %d (IC:%s)\n"
45448 +
45449 +#: ia64-gen.c:1459
45450 +#, c-format
45451 +msgid "don't know how to specify %% dependency %s\n"
45452 +msgstr "tidak tahu bagaimana menspesifikasikan %% ketergantungan %s\n"
45453 +
45454 +#: ia64-gen.c:1481
45455 +#, c-format
45456 +msgid "Don't know how to specify # dependency %s\n"
45457 +msgstr "Tidak tahu bagaimana menspesifikasikan # ketergantungan %s\n"
45458 +
45459 +#: ia64-gen.c:1520
45460 +#, c-format
45461 +msgid "IC:%s [%s] has no terminals or sub-classes\n"
45462 +msgstr "IC:%s [%s] tidak memiliki terminal atau sub-kelas\n"
45463 +
45464 +#: ia64-gen.c:1523
45465 +#, c-format
45466 +msgid "IC:%s has no terminals or sub-classes\n"
45467 +msgstr "IC:%s tidak memiliki terminal atau sub-kelas\n"
45468 +
45469 +#: ia64-gen.c:1532
45470 +#, c-format
45471 +msgid "no insns mapped directly to terminal IC %s [%s]"
45472 +msgstr "tidak ada insns terpetakan secara langsung ke terminal IC %s [%s]"
45473 +
45474 +#: ia64-gen.c:1535
45475 +#, c-format
45476 +msgid "no insns mapped directly to terminal IC %s\n"
45477 +msgstr "tidak ada insns terpetakan langsung ke terminal IC %s\n"
45478 +
45479 +#: ia64-gen.c:1546
45480 +#, c-format
45481 +msgid "class %s is defined but not used\n"
45482 +msgstr "kelas %s didefinisikan tetapi tidak digunakan\n"
45483 +
45484 +#: ia64-gen.c:1559
45485 +#, c-format
45486 +msgid "Warning: rsrc %s (%s) has no chks\n"
45487 +msgstr "Peringatan: rsrc %s (%s) tidak memiliki chks\n"
45488 +
45489 +#: ia64-gen.c:1562
45490 +#, c-format
45491 +msgid "Warning: rsrc %s (%s) has no chks or regs\n"
45492 +msgstr "Peringatan: rsrc %s (%s) tidak memiliki chks atau regs\n"
45493 +
45494 +#: ia64-gen.c:1566
45495 +#, c-format
45496 +msgid "rsrc %s (%s) has no regs\n"
45497 +msgstr "rsrc %s (%s) tidak memiliki regs\n"
45498 +
45499 +#: ia64-gen.c:2478
45500 +#, c-format
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"
45503 +
45504 +#: ia64-gen.c:2506
45505 +#, c-format
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"
45508 +
45509 +#: ia64-gen.c:2520
45510 +#, c-format
45511 +msgid "opcode %s has no class (ops %d %d %d)\n"
45512 +msgstr "opcode %s tidak memiliki kelas (ops %d %d %d)\n"
45513 +
45514 +#. We've been passed a w.  Return with an error message so that
45515 +#. cgen will try the next parsing option.
45516 +#: ip2k-asm.c:81
45517 +msgid "W keyword invalid in FR operand slot."
45518 +msgstr "W kata kunci tidak valid dalam FR operand slot."
45519 +
45520 +#. Invalid offset present.
45521 +#: ip2k-asm.c:106
45522 +msgid "offset(IP) is not a valid form"
45523 +msgstr "offset(IP) bukan sebuah bentuk valid"
45524 +
45525 +#. Found something there in front of (DP) but it's out
45526 +#. of range.
45527 +#: ip2k-asm.c:154
45528 +msgid "(DP) offset out of range."
45529 +msgstr "(DP) ofset di luar batas."
45530 +
45531 +#. Found something there in front of (SP) but it's out
45532 +#. of range.
45533 +#: ip2k-asm.c:195
45534 +msgid "(SP) offset out of range."
45535 +msgstr "(SP) ofset di luar batas."
45536 +
45537 +#: ip2k-asm.c:211
45538 +msgid "illegal use of parentheses"
45539 +msgstr "penggunaan tidak legal dari tanda petik"
45540 +
45541 +#: ip2k-asm.c:218
45542 +msgid "operand out of range (not between 1 and 255)"
45543 +msgstr "operand di luar batas (tidak antara 1 dan 255)"
45544 +
45545 +#. Something is very wrong. opindex has to be one of the above.
45546 +#: ip2k-asm.c:242
45547 +msgid "parse_addr16: invalid opindex."
45548 +msgstr "parse_addr16: opindex tidak valid."
45549 +
45550 +#: ip2k-asm.c:296
45551 +msgid "Byte address required. - must be even."
45552 +msgstr "Alamat byte dibutuhkan. - harus genap."
45553 +
45554 +#: ip2k-asm.c:305
45555 +msgid "cgen_parse_address returned a symbol. Literal required."
45556 +msgstr "cgen_parse_address mengembalikan sebuah simbol. Literal dibutuhkan."
45557 +
45558 +#: ip2k-asm.c:360
45559 +msgid "percent-operator operand is not a symbol"
45560 +msgstr "percent-operator operand bukan sebuah simbol"
45561 +
45562 +#: ip2k-asm.c:413
45563 +msgid "Attempt to find bit index of 0"
45564 +msgstr "Mencoba untuk menemukan bit index dari 0"
45565 +
45566 +#: iq2000-asm.c:112 iq2000-asm.c:142
45567 +msgid "immediate value cannot be register"
45568 +msgstr "nilai langsung tidak dapat berupa register"
45569 +
45570 +#: iq2000-asm.c:123 iq2000-asm.c:153
45571 +msgid "immediate value out of range"
45572 +msgstr "nilai langsung di luar batas"
45573 +
45574 +#: iq2000-asm.c:182
45575 +msgid "21-bit offset out of range"
45576 +msgstr "21-bit ofset di luar batas"
45577 +
45578 +#: m10200-dis.c:158 m10300-dis.c:582
45579  #, c-format
45580  msgid "unknown\t0x%04lx"
45581  msgstr "tidak dikenal\t0x%04lx"
45582  
45583 -#: m10300-dis.c:685
45584 +#: m10200-dis.c:328
45585  #, c-format
45586 -msgid "unknown\t0x%04x"
45587 -msgstr "tidak dikenal\t0x%04x"
45588 +msgid "unknown\t0x%02lx"
45589 +msgstr "tidak dikenal\t0x%02lx"
45590 +
45591 +#: m32c-asm.c:117
45592 +msgid "imm:6 immediate is out of range"
45593 +msgstr "imm:6 nilai langsung di luar batas"
45594  
45595 -#: m68k-dis.c:429
45596 +#: m32c-asm.c:147
45597  #, c-format
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"
45602 +
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"
45606 +
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"
45610 +
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"
45614 +
45615 +#: m32c-asm.c:285
45616 +#, c-format
45617 +msgid "%dsp16() takes a symbolic address, not a number"
45618 +msgstr "%dsp16() mengambil sebuah alamat simbolik, tetapi bukan sebuah angka"
45619 +
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"
45623 +
45624 +#: m32c-asm.c:404
45625 +msgid "dsp:20 immediate is out of range"
45626 +msgstr "dsp:20 nilai langsung di luar batas"
45627 +
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"
45631 +
45632 +#: m32c-asm.c:483
45633 +msgid "immediate is out of range 1-2"
45634 +msgstr "nilai langsung di luar dari jangkauan 1-2"
45635 +
45636 +#: m32c-asm.c:501
45637 +msgid "immediate is out of range 1-8"
45638 +msgstr "nilai langsung di luar dari jangkauan 1-8"
45639 +
45640 +#: m32c-asm.c:519
45641 +msgid "immediate is out of range 0-7"
45642 +msgstr "nilai langsung di luar dari jangkauan 0-7"
45643 +
45644 +#: m32c-asm.c:555
45645 +msgid "immediate is out of range 2-9"
45646 +msgstr "nilai langsung di luar dari jangkauan 2-9"
45647  
45648 -#: m68k-dis.c:1007
45649 +#: m32c-asm.c:573
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"
45652 +
45653 +#: m32c-asm.c:611 m32c-asm.c:667
45654 +msgid "bit,base is out of range"
45655 +msgstr "bit,bas di luar batas"
45656 +
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"
45660 +
45661 +#: m32c-asm.c:807
45662 +msgid "not a valid r0l/r0h pair"
45663 +msgstr "bukan sebuah valid pasangan r0l/r0h"
45664 +
45665 +#: m32c-asm.c:837
45666 +msgid "Invalid size specifier"
45667 +msgstr "Ukuran penspesifikasi tidak valid"
45668 +
45669 +#: m68k-dis.c:1163
45670  #, c-format
45671  msgid "<function code %d>"
45672  msgstr "<kode fungsi %d>"
45673  
45674 -#: m88k-dis.c:255
45675 +#: m68k-dis.c:1320
45676 +#, c-format
45677 +msgid "<internal error in opcode table: %s %s>\n"
45678 +msgstr "<kesalahan internal dalam tabel opcode: %s %s>\n"
45679 +
45680 +#: m88k-dis.c:679
45681 +#, c-format
45682 +msgid "# <dis error: %08lx>"
45683 +msgstr "# <kesalahan dis: %08lx>"
45684 +
45685 +#: mep-asm.c:114
45686 +msgid "Only $tp or $13 allowed for this opcode"
45687 +msgstr "Hanya $tp atau $13 diperbolehkan untuk opcode ini"
45688 +
45689 +#: mep-asm.c:128
45690 +msgid "Only $sp or $15 allowed for this opcode"
45691 +msgstr "Hanya $sp atau $15 diperbolehkan untuk opcode ini"
45692 +
45693 +#: mep-asm.c:299 mep-asm.c:455
45694 +#, c-format
45695 +msgid "invalid %function() here"
45696 +msgstr "%function disini tidak valid"
45697 +
45698 +#: mips-dis.c:781
45699 +msgid "# internal error, incomplete extension sequence (+)"
45700 +msgstr "# internal error, urutan ekstensi (+) tidak lengkap"
45701 +
45702 +#: mips-dis.c:915
45703  #, c-format
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)"
45708  
45709 -#: mips-dis.c:290
45710 +#: mips-dis.c:1274
45711  #, c-format
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)"
45716  
45717 -#: mips-dis.c:1154
45718 +#: mips-dis.c:1881
45719  #, c-format
45720  msgid "# internal disassembler error, unrecognised modifier (%c)"
45721  msgstr "# kesalahan internal disasembler, modifier tidak dikenal (%c)"
45722  
45723 -#: mmix-dis.c:34
45724 +#: mips-dis.c:2112
45725 +#, c-format
45726 +msgid ""
45727 +"\n"
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"
45730 +msgstr ""
45731 +"\n"
45732 +"Pilihan disablembler khusus MIPS berikut ini didukung untuk digunakan dengan\n"
45733 +"pilihan -M (pilihan ganda seharusnya dipisahkan dengan koma):\n"
45734 +
45735 +#: mips-dis.c:2116
45736 +#, c-format
45737 +msgid ""
45738 +"\n"
45739 +"  gpr-names=ABI            Print GPR names according to  specified ABI.\n"
45740 +"                           Default: based on binary being disassembled.\n"
45741 +msgstr ""
45742 +"\n"
45743 +"  gpr-names=ABI            Tampilkan nama GPR menurut ABI yang dispesifikasikan.\n"
45744 +"                           Baku: berdasar dari binari yang sedang diassembled.\n"
45745 +
45746 +#: mips-dis.c:2120
45747 +#, c-format
45748 +msgid ""
45749 +"\n"
45750 +"  fpr-names=ABI            Print FPR names according to specified ABI.\n"
45751 +"                           Default: numeric.\n"
45752 +msgstr ""
45753 +"\n"
45754 +"  fpr-names=ABI            Tampilkan nama FPR menurut ABI yang dispesifikasikan.\n"
45755 +"                           Baku: numerik.\n"
45756 +
45757 +#: mips-dis.c:2124
45758 +#, c-format
45759 +msgid ""
45760 +"\n"
45761 +"  cp0-names=ARCH           Print CP0 register names according to\n"
45762 +"                           specified architecture.\n"
45763 +"                           Default: based on binary being disassembled.\n"
45764 +msgstr ""
45765 +"\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"
45769 +
45770 +#: mips-dis.c:2129
45771 +#, c-format
45772 +msgid ""
45773 +"\n"
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"
45777 +msgstr ""
45778 +"\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"
45782 +
45783 +#: mips-dis.c:2134
45784 +#, c-format
45785 +msgid ""
45786 +"\n"
45787 +"  reg-names=ABI            Print GPR and FPR names according to\n"
45788 +"                           specified ABI.\n"
45789 +msgstr ""
45790 +"\n"
45791 +"  reg-names=ABI            Tampilkan nama GPR dan FPR menurut ABI yang\n"
45792 +"                           dispesifikasikan.\n"
45793 +
45794 +#: mips-dis.c:2138
45795 +#, c-format
45796 +msgid ""
45797 +"\n"
45798 +"  reg-names=ARCH           Print CP0 register and HWR names according to\n"
45799 +"                           specified architecture.\n"
45800 +msgstr ""
45801 +"\n"
45802 +"  reg-names=ARCH           Tampilkan nama register CP0 dan HWR menurut\n"
45803 +"                           arsitektur yang dispesifikasikan.\n"
45804 +
45805 +#: mips-dis.c:2142
45806 +#, c-format
45807 +msgid ""
45808 +"\n"
45809 +"  For the options above, the following values are supported for \"ABI\":\n"
45810 +"   "
45811 +msgstr ""
45812 +"\n"
45813 +"  Untuk pilihan diatas, nilai berikut didukung untuk \"ABI\":\n"
45814 +"   "
45815 +
45816 +#: mips-dis.c:2147 mips-dis.c:2155 mips-dis.c:2157
45817 +#, c-format
45818 +msgid "\n"
45819 +msgstr "\n"
45820 +
45821 +#: mips-dis.c:2149
45822 +#, c-format
45823 +msgid ""
45824 +"\n"
45825 +"  For the options above, The following values are supported for \"ARCH\":\n"
45826 +"   "
45827 +msgstr ""
45828 +"\n"
45829 +"  Untuk pilihan diatas, nilai berikut didukung untuk \"ARCH\":\n"
45830 +"   "
45831 +
45832 +#: mmix-dis.c:35
45833  #, c-format
45834  msgid "Bad case %d (%s) in %s:%d\n"
45835  msgstr "Case buruk %d (%s) dalam %s:%d\n"
45836  
45837 -#: mmix-dis.c:44
45838 +#: mmix-dis.c:45
45839  #, c-format
45840  msgid "Internal: Non-debugged code (test-case missing): %s:%d"
45841  msgstr "Internal: Kode belum didebug (tidak ada test-case): %s:%d"
45842  
45843 -#: mmix-dis.c:53
45844 +#: mmix-dis.c:54
45845  msgid "(unknown)"
45846  msgstr "(tidak dikenal)"
45847  
45848 -#: mmix-dis.c:517
45849 +#: mmix-dis.c:513
45850  #, c-format
45851  msgid "*unknown operands type: %d*"
45852  msgstr "*tipe operand tidak dikenal: %d*"
45853  
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."
45857 +
45858 +#: mt-asm.c:149
45859 +msgid "Biiiig Trouble in parse_imm16!"
45860 +msgstr "Masalah BESAR dalam parse_imm16!"
45861 +
45862 +#: mt-asm.c:157
45863 +msgid "The percent-operator's operand is not a symbol"
45864 +msgstr "Operand percent-operator bukan sebuah simbol"
45865 +
45866 +#: mt-asm.c:395
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."
45869 +
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
45874 -#. * anyway!
45875 -#.
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
45880 +#. anyway!
45881 +#: ns32k-dis.c:534
45882 +#, c-format
45883  msgid "$<undefined>"
45884  msgstr "$<tidak didefinisikan>"
45885  
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"
45890  
45891 -#: ppc-opc.c:800
45892 +#: ppc-opc.c:892
45893  msgid "attempt to set y bit when using + or - modifier"
45894  msgstr "berusaha menset bit y saat menggunakan modifier + atau -"
45895  
45896 -#: ppc-opc.c:832 ppc-opc.c:884
45897 -msgid "offset not a multiple of 4"
45898 -msgstr "offset bukan kelipatan 4"
45899 -
45900 -#: ppc-opc.c:857
45901 -msgid "offset not between -2048 and 2047"
45902 -msgstr "offset tidak berada antara -2048 dan 2047"
45903 -
45904 -#: ppc-opc.c:882
45905 -msgid "offset not between -8192 and 8191"
45906 -msgstr "offset tidak berada antara -8192 dan 8191"
45907 +#: ppc-opc.c:924
45908 +msgid "invalid mask field"
45909 +msgstr "topeng daerah tidak valid"
45910  
45911 -#: ppc-opc.c:910
45912 -msgid "ignoring least significant bits in branch offset"
45913 -msgstr "mengabaikan least significant bit dalam offset cabang"
45914 +#: ppc-opc.c:950
45915 +msgid "ignoring invalid mfcr mask"
45916 +msgstr "mengabaikan topeng mfcr tidak valid"
45917  
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"
45922  
45923 -#: ppc-opc.c:1054
45924 -msgid "value out of range"
45925 -msgstr "nilai di luar batas"
45926 -
45927 -#: ppc-opc.c:1130
45928 +#: ppc-opc.c:1155
45929  msgid "index register in load range"
45930  msgstr "register indeks dalam daerah pemuatan"
45931  
45932 -#: ppc-opc.c:1146
45933 +#: ppc-opc.c:1171
45934 +msgid "source and target register operands must be different"
45935 +msgstr "sumber dan target operand register harus berbeda"
45936 +
45937 +#: ppc-opc.c:1186
45938  msgid "invalid register operand when updating"
45939  msgstr "operand register tidak valid saat mengupdate"
45940  
45941 -#. Mark as non-valid instruction
45942 -#: sparc-dis.c:750
45943 -msgid "unknown"
45944 -msgstr "tidak dikenal"
45945 +#: ppc-opc.c:1265
45946 +msgid "invalid sprg number"
45947 +msgstr "nomor sprg tidak valid"
45948 +
45949 +#: s390-dis.c:276
45950 +#, c-format
45951 +msgid ""
45952 +"\n"
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"
45955 +msgstr ""
45956 +"\n"
45957 +"Pilihan disablembler khusus S/390 berikut ini didukung untuk digunakan dengan\n"
45958 +"pilihan -M (pilihan ganda seharusnya dipisahkan dengan koma):\n"
45959 +
45960 +#: s390-dis.c:280
45961 +#, c-format
45962 +msgid "  esa         Disassemble in ESA architecture mode\n"
45963 +msgstr "  esa         Disassemble dalam mode arsitektur ESA\n"
45964  
45965 -#: sparc-dis.c:825
45966 +#: s390-dis.c:281
45967 +#, c-format
45968 +msgid "  zarch       Disassemble in z/Architecture mode\n"
45969 +msgstr "  zarch       Disassemble dalam mode z/Architecture\n"
45970 +
45971 +#: score-dis.c:220 score-dis.c:383
45972 +msgid "<illegal instruction>"
45973 +msgstr "<instruksi tidak legal>"
45974 +
45975 +#: sparc-dis.c:282
45976  #, c-format
45977  msgid "Internal error:  bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
45978  msgstr "Kesalahan internal:  sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
45979  
45980 -#: sparc-dis.c:836
45981 +#: sparc-dis.c:293
45982  #, c-format
45983  msgid "Internal error: bad sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n"
45984  msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\", %#.8lx, %#.8lx\n"
45985  
45986 -#: sparc-dis.c:885
45987 +#: sparc-dis.c:343
45988  #, c-format
45989  msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n"
45990  msgstr "Kesalahan internal: sparc-opcode.h buruk: \"%s\" == \"%s\"\n"
45991  
45992 -#: v850-dis.c:224
45993 +#. Mark as non-valid instruction.
45994 +#: sparc-dis.c:1013
45995 +msgid "unknown"
45996 +msgstr "tidak dikenal"
45997 +
45998 +#: v850-dis.c:239
45999  #, c-format
46000  msgid "unknown operand shift: %x\n"
46001  msgstr "shift operand tidak dikenal: %x\n"
46002  
46003 -#: v850-dis.c:236
46004 +#: v850-dis.c:253
46005  #, c-format
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.
46012 -#: v850-opc.c:68
46013 +#: v850-opc.c:48
46014  msgid "displacement value is not in range and is not aligned"
46015  msgstr "nilai displacement tidak dalam jangkauan dan tidak rata"
46016  
46017 -#: v850-opc.c:69
46018 +#: v850-opc.c:49
46019  msgid "displacement value is out of range"
46020  msgstr "nilai displacement di luar batas"
46021  
46022 -#: v850-opc.c:70
46023 +#: v850-opc.c:50
46024  msgid "displacement value is not aligned"
46025  msgstr "nilai displacement tidak rata"
46026  
46027 -#: v850-opc.c:72
46028 +#: v850-opc.c:52
46029  msgid "immediate value is out of range"
46030  msgstr "nilai langsung di luar batas"
46031  
46032 -#: v850-opc.c:83
46033 +#: v850-opc.c:60
46034  msgid "branch value not in range and to odd offset"
46035  msgstr "nilai cabang tidak dalam jangkauan"
46036  
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"
46041  
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"
46046  
46047 -#: v850-opc.c:115
46048 +#: v850-opc.c:87
46049  msgid "branch value not in range and to an odd offset"
46050  msgstr "nilai cabang di luar jangkauan dan offset ganjil"
46051  
46052 -#: v850-opc.c:346
46053 +#: v850-opc.c:279
46054  msgid "invalid register for stack adjustment"
46055  msgstr "register tidak valid untuk penyesuaian stack"
46056  
46057 -#: v850-opc.c:370
46058 +#: v850-opc.c:299
46059  msgid "immediate value not in range and not even"
46060  msgstr "nilai langsung tidak dalam jangkauan dan tidak genap"
46061  
46062 -#: v850-opc.c:375
46063 +#: v850-opc.c:304
46064  msgid "immediate value must be even"
46065  msgstr "nilai langsung harus genap"
46066  
46067 -#: xstormy16-asm.c:74
46068 +#: xc16x-asm.c:66
46069 +msgid "Missing '#' prefix"
46070 +msgstr "Hilang awalan '#'"
46071 +
46072 +#: xc16x-asm.c:82
46073 +msgid "Missing '.' prefix"
46074 +msgstr "Hilang awalan '.'"
46075 +
46076 +#: xc16x-asm.c:98
46077 +msgid "Missing 'pof:' prefix"
46078 +msgstr "Hilang awalan 'pof:'"
46079 +
46080 +#: xc16x-asm.c:114
46081 +msgid "Missing 'pag:' prefix"
46082 +msgstr "Hilang awalan 'pag:'"
46083 +
46084 +#: xc16x-asm.c:130
46085 +msgid "Missing 'sof:' prefix"
46086 +msgstr "Hilang awalan 'sof:'"
46087 +
46088 +#: xc16x-asm.c:146
46089 +msgid "Missing 'seg:' prefix"
46090 +msgstr "Hilanga awalan 'seg:'"
46091 +
46092 +#: xstormy16-asm.c:71
46093  msgid "Bad register in preincrement"
46094  msgstr "register buruk dalam preinkremen"
46095  
46096 -#: xstormy16-asm.c:79
46097 +#: xstormy16-asm.c:76
46098  msgid "Bad register in postincrement"
46099  msgstr "Register buruk dalam pascainkremen"
46100  
46101 -#: xstormy16-asm.c:81
46102 +#: xstormy16-asm.c:78
46103  msgid "Bad register name"
46104  msgstr "Nama register buruk"
46105  
46106 -#: xstormy16-asm.c:85
46107 +#: xstormy16-asm.c:82
46108  msgid "Label conflicts with register name"
46109  msgstr "Label konflik dengan nama register"
46110  
46111 -#: xstormy16-asm.c:89
46112 +#: xstormy16-asm.c:86
46113  msgid "Label conflicts with `Rx'"
46114  msgstr "Label konflik dengan `Rx'"
46115  
46116 -#: xstormy16-asm.c:91
46117 +#: xstormy16-asm.c:88
46118  msgid "Bad immediate expression"
46119  msgstr "Ekspresi langsung yang buruk"
46120  
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"
46125 +
46126 +#: xstormy16-asm.c:119
46127  msgid "Small operand was not an immediate number"
46128  msgstr "Operand kecil bukan sebuah angka immediate"
46129 +
46130 +#: xstormy16-asm.c:157
46131 +msgid "Operand is not a symbol"
46132 +msgstr "Operand bukan sebuah simbol"
46133 +
46134 +#: xstormy16-asm.c:165
46135 +msgid "Syntax error: No trailing ')'"
46136 +msgstr "Sintaks error: Tidak ada akhiran ')'"
46137 +
46138 +#~ msgid "unknown\t0x%04x"
46139 +#~ msgstr "tidak dikenal\t0x%04x"
46140 +
46141 +#~ msgid "offset not between -2048 and 2047"
46142 +#~ msgstr "offset tidak berada antara -2048 dan 2047"
46143 +
46144 +#~ msgid "offset not between -8192 and 8191"
46145 +#~ msgstr "offset tidak berada antara -8192 dan 8191"
46146 +
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[] = {
46154  
46155  {"lhbrx",      X(31,790),      X_MASK,      COM,       PPCNONE,        {RT, RA0, RB}},
46156  
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}},
46160  
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[] = {
46164  
46165  {"sthbrx",     X(31,918),      X_MASK,      COM,       PPCNONE,        {RS, RA0, RB}},
46166  
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}},
46170  
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[] = {
46174  
46175  {"psq_l",      OP(56),         OP_MASK,     PPCPS,     PPCNONE,        {FRT,PSD,RA,PSW,PSQ}},
46176  
46177 +{"lfdp",       OP(57),         OP_MASK,     POWER6,    POWER7,         {FRT, D, RA0}},
46178 +
46179  {"lfqu",       OP(57),         OP_MASK,     POWER2,    PPCNONE,        {FRT, D, RA0}},
46180  
46181  {"psq_lu",     OP(57),         OP_MASK,     PPCPS,     PPCNONE,        {FRT,PSD,RA,PSW,PSQ}},
46182  
46183 -{"lfdp",       OP(57),         OP_MASK,     POWER6,    POWER7,         {FRT, D, RA0}},
46184 -
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}},
46191  
46192 -{"stfq",       OP(60),         OP_MASK,     POWER2,    PPCNONE,        {FRS, D, RA}},
46193 -
46194 -{"psq_st",     OP(60),         OP_MASK,     PPCPS,     PPCNONE,        {FRS,PSD,RA,PSW,PSQ}},
46195 -
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}},
46202  
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}},
46205  
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}},
46208  
46209  {"stfdp",      OP(61),         OP_MASK,     POWER6,    PPCNONE,        {FRT, D, RA0}},
46210  
46211 +{"stfqu",      OP(61),         OP_MASK,     POWER2,    PPCNONE,        {FRS, D, RA}},
46212 +
46213 +{"psq_stu",    OP(61),         OP_MASK,     PPCPS,     PPCNONE,        {FRS,PSD,RA,PSW,PSQ}},
46214 +
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}},
This page took 5.893315 seconds and 3 git commands to generate.