]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-archer.patch
- up to 7.3.1
[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 42fbc89fd3a797da9880ecbc467c32f282acf31f
6
7 branch `archer' - the merge of branches:
8 archer-jankratochvil-vla
9 archer-jankratochvil-watchpoint3
10 archer-tromey-python
11 archer-sergiodj-stap-fedora15jk
12
13
14 Index: gdb-7.2.90.20110703/bfd/elf-bfd.h
15 ===================================================================
16 --- gdb-7.2.90.20110703.orig/bfd/elf-bfd.h      2011-03-14 16:54:57.000000000 +0100
17 +++ gdb-7.2.90.20110703/bfd/elf-bfd.h   2011-07-03 10:33:11.000000000 +0200
18 @@ -1476,6 +1476,15 @@ enum
19    Tag_compatibility = 32
20  };
21  
22 +/* The following struct stores information about every SystemTap section
23 +   found in the object file.  */
24 +struct sdt_note
25 +{
26 +  struct sdt_note *next;
27 +  bfd_size_type size;
28 +  bfd_byte data[1];
29 +};
30 +
31  /* Some private data is stashed away for future use using the tdata pointer
32     in the bfd structure.  */
33  
34 @@ -1633,6 +1642,11 @@ struct elf_obj_tdata
35    bfd_size_type build_id_size;
36    bfd_byte *build_id;
37  
38 +  /* Linked-list containing information about every Systemtap section
39 +     found in the object file.  Each section corresponds to one entry
40 +     in the list.  */
41 +  struct sdt_note *sdt_note_head;
42 +
43    /* True if the bfd contains symbols that have the STT_GNU_IFUNC
44       symbol type.  Used to set the osabi field in the ELF header
45       structure.  */
46 Index: gdb-7.2.90.20110703/bfd/elf.c
47 ===================================================================
48 --- gdb-7.2.90.20110703.orig/bfd/elf.c  2011-03-14 16:54:58.000000000 +0100
49 +++ gdb-7.2.90.20110703/bfd/elf.c       2011-07-03 10:33:11.000000000 +0200
50 @@ -8416,6 +8416,37 @@ elfobj_grok_gnu_note (bfd *abfd, Elf_Int
51      }
52  }
53  
54 +#define SDT_NOTE_TYPE 3
55 +
56 +static bfd_boolean
57 +elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
58 +{
59 +  struct sdt_note *cur =
60 +    (struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
61 +                                  + note->descsz);
62 +
63 +  cur->next = (struct sdt_note *) (elf_tdata (abfd))->sdt_note_head;
64 +  cur->size = (bfd_size_type) note->descsz;
65 +  memcpy (cur->data, note->descdata, note->descsz);
66 +
67 +  elf_tdata (abfd)->sdt_note_head = cur;
68 +
69 +  return TRUE;
70 +}
71 +
72 +static bfd_boolean
73 +elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
74 +{
75 +  switch (note->type)
76 +    {
77 +    case SDT_NOTE_TYPE:
78 +      return elfobj_grok_stapsdt_note_1 (abfd, note);
79 +
80 +    default:
81 +      return TRUE;
82 +    }
83 +}
84 +
85  static bfd_boolean
86  elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
87  {
88 @@ -9189,6 +9220,12 @@ elf_parse_notes (bfd *abfd, char *buf, s
89               if (! elfobj_grok_gnu_note (abfd, &in))
90                 return FALSE;
91             }
92 +         else if (in.namesz == sizeof "stapsdt"
93 +                  && strcmp (in.namedata, "stapsdt") == 0)
94 +           {
95 +             if (! elfobj_grok_stapsdt_note (abfd, &in))
96 +               return FALSE;
97 +           }
98           break;
99         }
100  
101 Index: gdb-7.2.90.20110703/gdb/Makefile.in
102 ===================================================================
103 --- gdb-7.2.90.20110703.orig/gdb/Makefile.in    2011-03-30 08:55:39.000000000 +0200
104 +++ gdb-7.2.90.20110703/gdb/Makefile.in 2011-07-03 10:33:11.000000000 +0200
105 @@ -721,8 +721,8 @@ SFILES = ada-exp.y ada-lang.c ada-typepr
106         sentinel-frame.c \
107         serial.c ser-base.c ser-unix.c \
108         solib.c solib-target.c source.c \
109 -       stabsread.c stack.c std-regs.c symfile.c symfile-mem.c symmisc.c \
110 -       symtab.c \
111 +       stabsread.c stack.c stap-probe.c std-regs.c \
112 +       symfile.c symfile-mem.c symmisc.c symtab.c \
113         target.c target-descriptions.c target-memory.c \
114         thread.c top.c tracepoint.c \
115         trad-frame.c \
116 @@ -814,7 +814,7 @@ osdata.h procfs.h python/py-event.h pyth
117  python/python-internal.h python/python.h ravenscar-thread.h record.h \
118  solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \
119  gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \
120 -gnulib/stddef.in.h inline-frame.h
121 +gnulib/stddef.in.h inline-frame.h stap-probe.h
122  
123  # Header files that already have srcdir in them, or which are in objdir.
124  
125 @@ -899,7 +899,7 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $
126         prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o \
127         target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \
128         inferior.o osdata.o gdb_usleep.o record.o gcore.o \
129 -       jit.o progspace.o
130 +       jit.o progspace.o stap-probe.o
131  
132  TSOBS = inflow.o
133  
134 @@ -1320,6 +1320,12 @@ stamp-h: $(srcdir)/config.in config.stat
135           CONFIG_LINKS= \
136           $(SHELL) config.status
137  
138 +.gdbinit: $(srcdir)/gdbinit.in config.status
139 +       CONFIG_FILES=".gdbinit:gdbinit.in" \
140 +         CONFIG_COMMANDS= \
141 +         CONFIG_HEADERS= \
142 +         $(SHELL) config.status
143 +
144  config.status: $(srcdir)/configure configure.tgt configure.host
145         $(SHELL) config.status --recheck
146  
147 Index: gdb-7.2.90.20110703/gdb/NEWS
148 ===================================================================
149 --- gdb-7.2.90.20110703.orig/gdb/NEWS   2011-03-31 16:32:48.000000000 +0200
150 +++ gdb-7.2.90.20110703/gdb/NEWS        2011-07-03 10:33:11.000000000 +0200
151 @@ -36,6 +36,10 @@
152    Initial support for the OpenCL C language (http://www.khronos.org/opencl)
153    has been integrated into GDB.
154  
155 +* GDB now has support for SystemTap <sys/sdt.h> probes.  You can set a
156 +  breakpoint using the new "probe:" linespec and inspect the probe
157 +  arguments using the new $_probe_arg family of convenience variables.
158 +
159  * Python scripting
160  
161    ** The function gdb.Write now accepts an optional keyword 'stream'.
162 Index: gdb-7.2.90.20110703/gdb/ada-lang.c
163 ===================================================================
164 --- gdb-7.2.90.20110703.orig/gdb/ada-lang.c     2011-05-17 23:26:08.000000000 +0200
165 +++ gdb-7.2.90.20110703/gdb/ada-lang.c  2011-07-03 10:33:11.000000000 +0200
166 @@ -11421,6 +11421,7 @@ ada_operator_length (const struct expres
167  
168  static int
169  ada_operator_check (struct expression *exp, int pos,
170 +                   int (*type_func) (struct type *type, void *data),
171                     int (*objfile_func) (struct objfile *objfile, void *data),
172                     void *data)
173  {
174 @@ -11435,12 +11436,15 @@ ada_operator_check (struct expression *e
175         break;
176  
177        default:
178 -       return operator_check_standard (exp, pos, objfile_func, data);
179 +       return operator_check_standard (exp, pos, type_func, objfile_func,
180 +                                       data);
181      }
182  
183    /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL.  */
184  
185 -  if (type && TYPE_OBJFILE (type)
186 +  if (type && type_func && (*type_func) (type, data))
187 +    return 1;
188 +  if (type && TYPE_OBJFILE (type) && objfile_func
189        && (*objfile_func) (TYPE_OBJFILE (type), data))
190      return 1;
191  
192 Index: gdb-7.2.90.20110703/gdb/amd64-linux-nat.c
193 ===================================================================
194 --- gdb-7.2.90.20110703.orig/gdb/amd64-linux-nat.c      2011-01-07 20:36:15.000000000 +0100
195 +++ gdb-7.2.90.20110703/gdb/amd64-linux-nat.c   2011-07-03 10:33:11.000000000 +0200
196 @@ -265,18 +265,11 @@ amd64_linux_store_inferior_registers (st
197  \f
198  /* Support for debug registers.  */
199  
200 -static unsigned long amd64_linux_dr[DR_CONTROL + 1];
201 -
202  static unsigned long
203 -amd64_linux_dr_get (ptid_t ptid, int regnum)
204 +amd64_linux_dr_get (int tid, int regnum)
205  {
206 -  int tid;
207    unsigned long value;
208  
209 -  tid = TIDGET (ptid);
210 -  if (tid == 0)
211 -    tid = PIDGET (ptid);
212 -
213    /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
214       ptrace call fails breaks debugging remote targets.  The correct
215       way to fix this is to add the hardware breakpoint and watchpoint
216 @@ -298,14 +291,8 @@ amd64_linux_dr_get (ptid_t ptid, int reg
217  /* Set debug register REGNUM to VALUE in only the one LWP of PTID.  */
218  
219  static void
220 -amd64_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
221 +amd64_linux_dr_set (int tid, int regnum, unsigned long value)
222  {
223 -  int tid;
224 -
225 -  tid = TIDGET (ptid);
226 -  if (tid == 0)
227 -    tid = PIDGET (ptid);
228 -
229    errno = 0;
230    ptrace (PTRACE_POKEUSER, tid,
231           offsetof (struct user, u_debugreg[regnum]), value);
232 @@ -313,35 +300,96 @@ amd64_linux_dr_set (ptid_t ptid, int reg
233      perror_with_name (_("Couldn't write debug register"));
234  }
235  
236 -/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST.  */
237 +/* Helper for amd64_linux_dr_set_control.  */
238 +
239 +static void
240 +amd64_linux_dr_set_control_callback (int tid, void *control_voidp)
241 +{
242 +  unsigned long control = *(unsigned long *) control_voidp;
243 +
244 +  amd64_linux_dr_set (tid, DR_CONTROL, control);
245 +}
246 +
247 +static void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr);
248 +
249 +/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR.  */
250  
251  static void
252  amd64_linux_dr_set_control (unsigned long control)
253  {
254 -  struct lwp_info *lp;
255 -  ptid_t ptid;
256 +  int inferior_pid = ptid_get_pid (inferior_ptid);
257 +  struct inferior *inf = current_inferior ();
258 +
259 +  /* Are we detaching breakpoints from a fork-ed child?
260 +     See linux_nat_iterate_watchpoint_lwps for the fork-ed child description.
261 +     The i386 counterpart is i386_linux_dr_set_control.  */
262 +  if (inf->pid != inferior_pid)
263 +    {
264 +      struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
265 +      int i;
266 +
267 +      /* There were two changes in Linux kernel 2.6.33 by the commit:
268 +         72f674d203cd230426437cdcf7dd6f681dad8b0d
269 +
270 +         (1) After fork/vfork/clone the new task no longer inherits the debug
271 +        registers.  It has them zeroed instead.  Either case is OK for GDB as
272 +        GDB already registers a fix up by linux_nat_set_new_thread.
273 +
274 +        (2) If you enable a breakpoint by the CONTROL bits you have already
275 +        written its ADDRESS.  Otherwise Linux kernel will report EINVAL.
276 +        For this case the workaround here ensures that during resetting
277 +        (detaching) watchpoints for a fork-ed child we can set CONTROL
278 +        arbitrarily as the addresses get pre-set here just to be sure.
279 +
280 +        The second issue is hopefully going to be fixed in Linux kernel:
281 +        https://bugzilla.redhat.com/show_bug.cgi?id=660204  */
282 +
283 +      if (!dr_mirror->addr_preset)
284 +       {
285 +         dr_mirror->addr_preset = 1;
286 +
287 +         for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
288 +           amd64_linux_dr_set_addr (i, dr_mirror->addr[i]);
289 +       }
290 +    }
291 +
292 +  linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_control_callback,
293 +                                    &control);
294 +}
295 +
296 +/* Helper for amd64_linux_dr_set_addr.  */
297 +
298 +struct amd64_linux_dr_set_addr_data
299 +  {
300 +    int regnum;
301 +    CORE_ADDR addr;
302 +  };
303 +
304 +static void
305 +amd64_linux_dr_set_addr_callback (int tid, void *datap_voidp)
306 +{
307 +  const struct amd64_linux_dr_set_addr_data *datap = datap_voidp;
308  
309 -  amd64_linux_dr[DR_CONTROL] = control;
310 -  ALL_LWPS (lp, ptid)
311 -    amd64_linux_dr_set (ptid, DR_CONTROL, control);
312 +  amd64_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
313  }
314  
315 -/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST.  */
316 +/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
317 +   */
318  
319  static void
320  amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr)
321  {
322 -  struct lwp_info *lp;
323 -  ptid_t ptid;
324 +  struct amd64_linux_dr_set_addr_data data;
325  
326    gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
327  
328 -  amd64_linux_dr[DR_FIRSTADDR + regnum] = addr;
329 -  ALL_LWPS (lp, ptid)
330 -    amd64_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
331 +  data.regnum = regnum;
332 +  data.addr = addr;
333 +  linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_addr_callback, &data);
334  }
335  
336 -/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST.  */
337 +/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR.
338 +   */
339  
340  static void
341  amd64_linux_dr_reset_addr (int regnum)
342 @@ -354,37 +402,54 @@ amd64_linux_dr_reset_addr (int regnum)
343  static unsigned long
344  amd64_linux_dr_get_status (void)
345  {
346 -  return amd64_linux_dr_get (inferior_ptid, DR_STATUS);
347 +  int tid;
348 +
349 +  tid = TIDGET (inferior_ptid);
350 +  if (tid == 0)
351 +    tid = PIDGET (inferior_ptid);
352 +
353 +  return amd64_linux_dr_get (tid, DR_STATUS);
354  }
355  
356 -/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST.  */
357 +/* Helper for amd64_linux_dr_unset_status.  */
358  
359  static void
360 -amd64_linux_dr_unset_status (unsigned long mask)
361 +amd64_linux_dr_unset_status_callback (int tid, void *mask_voidp)
362  {
363 -  struct lwp_info *lp;
364 -  ptid_t ptid;
365 -
366 -  ALL_LWPS (lp, ptid)
367 -    {
368 -      unsigned long value;
369 +  unsigned long mask = *(unsigned long *) mask_voidp;
370 +  unsigned long value;
371        
372 -      value = amd64_linux_dr_get (ptid, DR_STATUS);
373 -      value &= ~mask;
374 -      amd64_linux_dr_set (ptid, DR_STATUS, value);
375 -    }
376 +  value = amd64_linux_dr_get (tid, DR_STATUS);
377 +  value &= ~mask;
378 +  amd64_linux_dr_set (tid, DR_STATUS, value);
379  }
380  
381 +/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR.  */
382 +
383 +static void
384 +amd64_linux_dr_unset_status (unsigned long mask)
385 +{
386 +  linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_unset_status_callback,
387 +                                    &mask);
388 +}
389  
390  static void
391  amd64_linux_new_thread (ptid_t ptid)
392  {
393 -  int i;
394 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
395 +  int i, tid;
396 +
397 +  /* Verify DR_MIRROR is valid.  */
398 +  gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
399 +
400 +  tid = TIDGET (ptid);
401 +  if (tid == 0)
402 +    tid = PIDGET (ptid);
403  
404 -  for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
405 -    amd64_linux_dr_set (ptid, i, amd64_linux_dr[i]);
406 +  for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
407 +    amd64_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]);
408  
409 -  amd64_linux_dr_set (ptid, DR_CONTROL, amd64_linux_dr[DR_CONTROL]);
410 +  amd64_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
411  }
412  \f
413  
414 Index: gdb-7.2.90.20110703/gdb/ax-gdb.c
415 ===================================================================
416 --- gdb-7.2.90.20110703.orig/gdb/ax-gdb.c       2011-02-24 08:39:47.000000000 +0100
417 +++ gdb-7.2.90.20110703/gdb/ax-gdb.c    2011-07-03 10:33:11.000000000 +0200
418 @@ -2001,7 +2001,8 @@ gen_expr (struct expression *exp, union 
419  
420      case OP_INTERNALVAR:
421        {
422 -       const char *name = internalvar_name ((*pc)[1].internalvar);
423 +       struct internalvar *var = (*pc)[1].internalvar;
424 +       const char *name = internalvar_name (var);
425         struct trace_state_variable *tsv;
426  
427         (*pc) += 3;
428 @@ -2015,7 +2016,7 @@ gen_expr (struct expression *exp, union 
429             value->kind = axs_rvalue;
430             value->type = builtin_type (exp->gdbarch)->builtin_long_long;
431           }
432 -       else
433 +       else if (! compile_internalvar_to_ax (var, ax, value))
434           error (_("$%s is not a trace state variable; GDB agent "
435                    "expressions cannot use convenience variables."), name);
436        }
437 Index: gdb-7.2.90.20110703/gdb/block.c
438 ===================================================================
439 --- gdb-7.2.90.20110703.orig/gdb/block.c        2011-01-01 16:32:57.000000000 +0100
440 +++ gdb-7.2.90.20110703/gdb/block.c     2011-07-03 10:33:11.000000000 +0200
441 @@ -322,3 +322,21 @@ allocate_block (struct obstack *obstack)
442  
443    return bl;
444  }
445 +
446 +/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for
447 +   whatever reason.  */
448 +
449 +struct objfile *
450 +block_objfile (const struct block *block)
451 +{
452 +  struct symbol *func;
453 +
454 +  if (block == NULL)
455 +    return NULL;
456 +
457 +  func = block_linkage_function (block);
458 +  if (func == NULL)
459 +    return NULL;
460 +
461 +  return SYMBOL_SYMTAB (func)->objfile;
462 +}
463 Index: gdb-7.2.90.20110703/gdb/block.h
464 ===================================================================
465 --- gdb-7.2.90.20110703.orig/gdb/block.h        2011-01-01 16:32:57.000000000 +0100
466 +++ gdb-7.2.90.20110703/gdb/block.h     2011-07-03 10:33:11.000000000 +0200
467 @@ -167,4 +167,6 @@ extern const struct block *block_global_
468  
469  extern struct block *allocate_block (struct obstack *obstack);
470  
471 +extern struct objfile *block_objfile (const struct block *block);
472 +
473  #endif /* BLOCK_H */
474 Index: gdb-7.2.90.20110703/gdb/breakpoint.c
475 ===================================================================
476 --- gdb-7.2.90.20110703.orig/gdb/breakpoint.c   2011-07-02 21:33:09.000000000 +0200
477 +++ gdb-7.2.90.20110703/gdb/breakpoint.c        2011-07-03 10:35:09.000000000 +0200
478 @@ -63,6 +63,8 @@
479  #include "jit.h"
480  #include "xml-syscall.h"
481  #include "parser-defs.h"
482 +#include "gdb_regex.h"
483 +#include "stap-probe.h"
484  #include "cli/cli-utils.h"
485  
486  /* readline include files */
487 @@ -107,6 +109,9 @@ static void break_command_1 (char *, int
488  
489  static void mention (struct breakpoint *);
490  
491 +static struct bp_location *add_location_to_breakpoint (struct breakpoint *b,
492 +                                            const struct symtab_and_line *sal);
493 +
494  /* This function is used in gdbtk sources and thus can not be made
495     static.  */
496  struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
497 @@ -1249,6 +1254,9 @@ update_watchpoint (struct breakpoint *b,
498    if (!watchpoint_in_thread_scope (b))
499      return;
500  
501 +  if (b->pspace != current_program_space)
502 +    return;
503 +
504    if (b->disposition == disp_del_at_next_stop)
505      return;
506   
507 @@ -1520,6 +1528,40 @@ should_be_inserted (struct bp_location *
508    return 1;
509  }
510  
511 +/* See the comment in breakpoint.h.  */
512 +
513 +void
514 +modify_semaphore (struct bp_location *loc, int set)
515 +{
516 +  struct gdbarch *arch = loc->gdbarch;
517 +  gdb_byte bytes[sizeof (LONGEST)];
518 +  /* The ABI specifies "unsigned short".  */
519 +  struct type *type = builtin_type (arch)->builtin_unsigned_short;
520 +  CORE_ADDR address = loc->semaphore;
521 +  ULONGEST value;
522 +
523 +  if (address == 0)
524 +    return;
525 +
526 +  /* Swallow errors.  */
527 +  if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
528 +    return;
529 +
530 +  value = extract_unsigned_integer (bytes, TYPE_LENGTH (type),
531 +                                   gdbarch_byte_order (arch));
532 +  /* Note that we explicitly don't worry about overflow or
533 +     underflow.  */
534 +  if (set)
535 +    ++value;
536 +  else
537 +    --value;
538 +
539 +  store_unsigned_integer (bytes, TYPE_LENGTH (type),
540 +                         gdbarch_byte_order (arch), value);
541 +
542 +  target_write_memory (address, bytes, TYPE_LENGTH (type));
543 +}
544 +
545  /* Insert a low-level "breakpoint" of some type.  BL is the breakpoint
546     location.  Any error messages are printed to TMP_ERROR_STREAM; and
547     DISABLED_BREAKS, and HW_BREAKPOINT_ERROR are used to report problems.
548 @@ -1616,6 +1658,8 @@ insert_bp_location (struct bp_location *
549           else
550             val = target_insert_breakpoint (bl->gdbarch,
551                                             &bl->target_info);
552 +
553 +         modify_semaphore (bl, 1);
554         }
555        else
556         {
557 @@ -1870,6 +1914,7 @@ insert_breakpoint_locations (void)
558    int val = 0;
559    int disabled_breaks = 0;
560    int hw_breakpoint_error = 0;
561 +  struct program_space *saved_current_program_space = current_program_space;
562  
563    struct ui_file *tmp_error_stream = mem_fileopen ();
564    struct cleanup *cleanups = make_cleanup_ui_file_delete (tmp_error_stream);
565 @@ -1897,9 +1942,13 @@ insert_breakpoint_locations (void)
566        /* For targets that support global breakpoints, there's no need
567          to select an inferior to insert breakpoint to.  In fact, even
568          if we aren't attached to any process yet, we should still
569 -        insert breakpoints.  */
570 +        insert breakpoints.
571 +
572 +        Also inserting breakpoints into inappropriate inferior must be
573 +        prevented.  */
574        if (!gdbarch_has_global_breakpoints (target_gdbarch)
575 -         && ptid_equal (inferior_ptid, null_ptid))
576 +         && (ptid_equal (inferior_ptid, null_ptid)
577 +             || bl->pspace != saved_current_program_space))
578         continue;
579  
580        val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks,
581 @@ -1923,13 +1972,19 @@ insert_breakpoint_locations (void)
582  
583        if (bpt->disposition == disp_del_at_next_stop)
584         continue;
585 -      
586 +
587        for (loc = bpt->loc; loc; loc = loc->next)
588 -       if (!loc->inserted && should_be_inserted (loc))
589 -         {
590 -           some_failed = 1;
591 -           break;
592 -         }
593 +       {
594 +         /* Verify the first loop above really tried to insert this LOC.  */
595 +         if (!loc->inserted && should_be_inserted (loc)
596 +             && (gdbarch_has_global_breakpoints (target_gdbarch)
597 +                 || (!ptid_equal (inferior_ptid, null_ptid)
598 +                     && loc->pspace == saved_current_program_space)))
599 +           {
600 +             some_failed = 1;
601 +             break;
602 +           }
603 +       }
604        if (some_failed)
605         {
606           for (loc = bpt->loc; loc; loc = loc->next)
607 @@ -2111,15 +2166,24 @@ struct breakpoint_objfile_data
608    /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any).  */
609    struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES];
610  
611 +  /* SystemTap probe point for longjmp (if any).  */
612 +  const struct stap_probe *longjmp_probe;
613 +
614    /* Minimal symbol for "std::terminate()" (if any).  */
615    struct minimal_symbol *terminate_msym;
616  
617    /* Minimal symbol for "_Unwind_DebugHook" (if any).  */
618    struct minimal_symbol *exception_msym;
619 +
620 +  /* SystemTap probe point for unwinding (if any).  */
621 +  const struct stap_probe *exception_probe;
622  };
623  
624  static const struct objfile_data *breakpoint_objfile_key;
625  
626 +/* SystemTap probe not found sentinel.  */
627 +static const struct stap_probe probe_not_found;
628 +
629  /* Minimal symbol not found sentinel.  */
630  static struct minimal_symbol msym_not_found;
631  
632 @@ -2227,6 +2291,29 @@ create_longjmp_master_breakpoint (void)
633  
634        bp_objfile_data = get_breakpoint_objfile_data (objfile);
635  
636 +      if (bp_objfile_data->longjmp_probe != &probe_not_found)
637 +       {
638 +         if (bp_objfile_data->longjmp_probe == NULL)
639 +           bp_objfile_data->longjmp_probe
640 +             = find_probe_in_objfile (objfile, "libc", "longjmp");
641 +
642 +         if (bp_objfile_data->longjmp_probe)
643 +           {
644 +             struct breakpoint *b;
645 +             struct gdbarch *gdbarch = get_objfile_arch (objfile);
646 +
647 +             b = create_internal_breakpoint (gdbarch,
648 +                                             bp_objfile_data->longjmp_probe->address,
649 +                                             bp_longjmp_master);
650 +             b->addr_string = xstrdup ("probe:libc:longjmp");
651 +             b->enable_state = bp_disabled;
652 +
653 +             continue;
654 +           }
655 +         else
656 +           bp_objfile_data->longjmp_probe = &probe_not_found;
657 +       }
658 +
659        for (i = 0; i < NUM_LONGJMP_NAMES; i++)
660         {
661           struct breakpoint *b;
662 @@ -2335,6 +2422,31 @@ create_exception_master_breakpoint (void
663  
664        bp_objfile_data = get_breakpoint_objfile_data (objfile);
665  
666 +      /* We prefer the SystemTap probe point if it exists.  */
667 +      if (bp_objfile_data->exception_probe != &probe_not_found)
668 +       {
669 +         if (bp_objfile_data->exception_probe == NULL)
670 +           bp_objfile_data->exception_probe
671 +             = find_probe_in_objfile (objfile, "libgcc", "unwind");
672 +
673 +         if (bp_objfile_data->exception_probe)
674 +           {
675 +             struct breakpoint *b;
676 +             struct gdbarch *gdbarch = get_objfile_arch (objfile);
677 +
678 +             b = create_internal_breakpoint (gdbarch,
679 +                                             bp_objfile_data->exception_probe->address,
680 +                                             bp_exception_master);
681 +             b->addr_string = xstrdup ("probe:libgcc:unwind");
682 +             b->enable_state = bp_disabled;
683 +             continue;
684 +           }
685 +         else
686 +           bp_objfile_data->exception_probe = &probe_not_found;
687 +       }
688 +
689 +      /* Otherwise, try the hook function.  */
690 +
691        if (msym_not_found_p (bp_objfile_data->exception_msym))
692         continue;
693  
694 @@ -2553,6 +2665,8 @@ remove_breakpoint_1 (struct bp_location 
695             val = target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info);
696           else
697             val = target_remove_breakpoint (bl->gdbarch, &bl->target_info);
698 +
699 +         modify_semaphore (bl, 0);
700         }
701        else
702         {
703 @@ -5902,6 +6016,7 @@ set_raw_breakpoint (struct gdbarch *gdba
704    b->loc->requested_address = sal.pc;
705    b->loc->address = adjusted_address;
706    b->loc->pspace = sal.pspace;
707 +  b->loc->semaphore = sal.semaphore;
708  
709    /* Store the program space that was used to set the breakpoint, for
710       breakpoint resetting.  */
711 @@ -7056,6 +7171,7 @@ clone_momentary_breakpoint (struct break
712    copy->loc->address = orig->loc->address;
713    copy->loc->section = orig->loc->section;
714    copy->loc->pspace = orig->loc->pspace;
715 +  copy->loc->semaphore = orig->loc->semaphore;
716  
717    if (orig->source_file == NULL)
718      copy->source_file = NULL;
719 @@ -7279,6 +7395,7 @@ add_location_to_breakpoint (struct break
720    loc->address = adjust_breakpoint_address (loc->gdbarch,
721                                             loc->requested_address, b->type);
722    loc->pspace = sal->pspace;
723 +  loc->semaphore = sal->semaphore;
724    gdb_assert (loc->pspace != NULL);
725    loc->section = sal->section;
726  
727 @@ -7628,6 +7745,16 @@ create_breakpoints_sal (struct gdbarch *
728  {
729    int i;
730  
731 +  if (canonical->pre_expanded)
732 +    {
733 +      create_breakpoint_sal (gdbarch, sals, canonical->canonical[0],
734 +                            cond_string, type, disposition,
735 +                            thread, task, ignore_count, ops,
736 +                            from_tty, enabled, internal,
737 +                            canonical->special_display);
738 +      return;
739 +    }
740 +
741    for (i = 0; i < sals.nelts; ++i)
742      {
743        struct symtabs_and_lines expanded = 
744 @@ -8148,7 +8275,7 @@ create_breakpoint (struct gdbarch *gdbar
745          mention (b);
746      }
747    
748 -  if (sals.nelts > 1)
749 +  if (sals.nelts > 1 && !canonical.pre_expanded)
750      {
751        warning (_("Multiple breakpoints were set.\nUse the "
752                  "\"delete\" command to delete unwanted breakpoints."));
753 @@ -9020,6 +9147,7 @@ watch_command_1 (char *arg, int accessfl
754    b = set_raw_breakpoint_without_location (NULL, bp_type);
755    set_breakpoint_number (internal, b);
756    b->thread = thread;
757 +  b->pspace = current_program_space;
758    b->disposition = disp_donttouch;
759    b->exp = exp;
760    b->exp_valid_block = exp_valid_block;
761 @@ -10182,6 +10310,9 @@ update_global_location_list (int should_
762        int keep_in_target = 0;
763        int removed = 0;
764  
765 +      if (old_loc->pspace != current_program_space)
766 +       continue;
767 +
768        /* Skip LOCP entries which will definitely never be needed.
769          Stop either at or being the one matching OLD_LOC.  */
770        while (locp < bp_location + bp_location_count
771 @@ -10946,12 +11077,14 @@ update_breakpoint_locations (struct brea
772     On return, FOUND will be 1 if any SaL was found, zero otherwise.  */
773  
774  static struct symtabs_and_lines
775 -addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
776 +addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found,
777 +                    int *pre_expanded)
778  {
779    char *s;
780    int marker_spec;
781    struct symtabs_and_lines sals = {0};
782    struct gdb_exception e;
783 +  int my_pre_expanded = 0;
784  
785    s = addr_string;
786    marker_spec = b->type == bp_static_tracepoint && is_marker_spec (s);
787 @@ -10970,7 +11103,27 @@ addr_string_to_sals (struct breakpoint *
788             error (_("marker %s not found"), b->static_trace_marker_id);
789         }
790        else
791 -       sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL);
792 +       {
793 +         struct linespec_result canonical;
794 +
795 +         init_linespec_result (&canonical);
796 +         sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0,
797 +                               &canonical);
798 +
799 +         /* We don't need the contents.  */
800 +         if (canonical.canonical)
801 +           {
802 +             int i;
803 +
804 +             for (i = 0; i < sals.nelts; ++i)
805 +               xfree (canonical.canonical[i]);
806 +             xfree (canonical.canonical);
807 +           }
808 +
809 +         my_pre_expanded = canonical.pre_expanded;
810 +         if (pre_expanded)
811 +           *pre_expanded = my_pre_expanded;
812 +       }
813      }
814    if (e.reason < 0)
815      {
816 @@ -11003,7 +11156,7 @@ addr_string_to_sals (struct breakpoint *
817  
818    if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
819      {
820 -      gdb_assert (sals.nelts == 1);
821 +      gdb_assert (my_pre_expanded || sals.nelts == 1);
822  
823        resolve_sal_pc (&sals.sals[0]);
824        if (b->condition_not_parsed && s && s[0])
825 @@ -11044,22 +11197,27 @@ re_set_breakpoint (struct breakpoint *b)
826    struct symtabs_and_lines expanded = {0};
827    struct symtabs_and_lines expanded_end = {0};
828    struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
829 +  int pre_expanded = 0;
830  
831    input_radix = b->input_radix;
832    save_current_space_and_thread ();
833    switch_to_program_space_and_thread (b->pspace);
834    set_language (b->language);
835  
836 -  sals = addr_string_to_sals (b, b->addr_string, &found);
837 +  sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded);
838    if (found)
839      {
840        make_cleanup (xfree, sals.sals);
841 -      expanded = expand_line_sal_maybe (sals.sals[0]);
842 +      if (pre_expanded)
843 +       expanded = sals;
844 +      else
845 +       expanded = expand_line_sal_maybe (sals.sals[0]);
846      }
847  
848    if (b->addr_string_range_end)
849      {
850 -      sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found);
851 +      sals_end = addr_string_to_sals (b, b->addr_string_range_end, &found,
852 +                                     NULL);
853        if (found)
854         {
855           make_cleanup (xfree, sals_end.sals);
856 @@ -12496,6 +12654,24 @@ all_tracepoints (void)
857    return tp_vec;
858  }
859  
860 +#if 0
861 +/* Call type_mark_used for any TYPEs referenced from this GDB source file.  */
862 +
863 +static void
864 +breakpoint_types_mark_used (void)
865 +{
866 +  struct breakpoint *b;
867 +
868 +  ALL_BREAKPOINTS (b)
869 +    {
870 +      if (b->exp)
871 +       exp_types_mark_used (b->exp);
872 +      if (b->val)
873 +       type_mark_used (value_type (b->val));
874 +    }
875 +}
876 +#endif
877 +
878  \f
879  /* This help string is used for the break, hbreak, tbreak and thbreak
880     commands.  It is defined as a macro to prevent duplication.
881 @@ -13131,4 +13307,7 @@ range (including START-LOCATION and END-
882    automatic_hardware_breakpoints = 1;
883  
884    observer_attach_about_to_proceed (breakpoint_about_to_proceed);
885 +#if 0
886 +  observer_attach_mark_used (breakpoint_types_mark_used);
887 +#endif
888  }
889 Index: gdb-7.2.90.20110703/gdb/breakpoint.h
890 ===================================================================
891 --- gdb-7.2.90.20110703.orig/gdb/breakpoint.h   2011-05-17 23:25:56.000000000 +0200
892 +++ gdb-7.2.90.20110703/gdb/breakpoint.h        2011-07-03 10:33:11.000000000 +0200
893 @@ -363,6 +363,11 @@ struct bp_location
894       processor's architectual constraints.  */
895    CORE_ADDR requested_address;
896  
897 +  /* If the location comes from a SystemTap probe point, and the probe
898 +     has an associated semaphore variable, then this is the address of
899 +     the semaphore.  Otherwise, this is zero.  */
900 +  CORE_ADDR semaphore;
901 +
902    char *function_name;
903  
904    /* Details of the placed breakpoint, when inserted.  */
905 @@ -1237,4 +1242,11 @@ extern struct breakpoint *iterate_over_b
906  
907  extern int user_breakpoint_p (struct breakpoint *);
908  
909 +/* Set or clear a SystemTap semaphore.  LOC is the location which may
910 +   hold a semaphore.  SET is non-zero if the semaphore should be set,
911 +   or zero if the semaphore should be cleared.  Semaphores act as
912 +   reference counters, so calls to this function must be paired.  */
913 +
914 +extern void modify_semaphore (struct bp_location *location, int set);
915 +
916  #endif /* !defined (BREAKPOINT_H) */
917 Index: gdb-7.2.90.20110703/gdb/c-typeprint.c
918 ===================================================================
919 --- gdb-7.2.90.20110703.orig/gdb/c-typeprint.c  2011-03-22 18:35:22.000000000 +0100
920 +++ gdb-7.2.90.20110703/gdb/c-typeprint.c       2011-07-03 10:33:11.000000000 +0200
921 @@ -625,9 +625,14 @@ c_type_print_varspec_suffix (struct type
922           fprintf_filtered (stream, ")");
923  
924         fprintf_filtered (stream, "[");
925 -       if (get_array_bounds (type, &low_bound, &high_bound))
926 -         fprintf_filtered (stream, "%d", 
927 -                           (int) (high_bound - low_bound + 1));
928 +       if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind
929 +           != RANGE_BOUND_KIND_CONSTANT)
930 +         {
931 +           /* No _() - printed sources should not be locale dependent.  */
932 +           fprintf_filtered (stream, "variable");
933 +         }
934 +       else if (get_array_bounds (type, &low_bound, &high_bound))
935 +         fprintf_filtered (stream, "%d", (int) (high_bound - low_bound + 1));
936         fprintf_filtered (stream, "]");
937  
938         c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream,
939 Index: gdb-7.2.90.20110703/gdb/cli/cli-utils.c
940 ===================================================================
941 --- gdb-7.2.90.20110703.orig/gdb/cli/cli-utils.c        2011-03-16 22:12:12.000000000 +0100
942 +++ gdb-7.2.90.20110703/gdb/cli/cli-utils.c     2011-07-03 10:33:11.000000000 +0200
943 @@ -245,3 +245,32 @@ remove_trailing_whitespace (const char *
944  
945    return s;
946  }
947 +
948 +/* See documentation in cli-utils.h.  */
949 +
950 +char *
951 +extract_arg (char **arg)
952 +{
953 +  char *result, *copy;
954 +
955 +  if (!*arg)
956 +    return NULL;
957 +
958 +  /* Find the start of the argument.  */
959 +  *arg = skip_spaces (*arg);
960 +  if (! **arg)
961 +    return NULL;
962 +  result = *arg;
963 +
964 +  /* Find the end of the argument.  */
965 +  *arg = skip_to_space (*arg + 1);
966 +
967 +  if (result == *arg)
968 +    return NULL;
969 +
970 +  copy = xmalloc (*arg - result + 1);
971 +  memcpy (copy, result, *arg - result);
972 +  copy[*arg - result] = '\0';
973 +
974 +  return copy;
975 +}
976 Index: gdb-7.2.90.20110703/gdb/cli/cli-utils.h
977 ===================================================================
978 --- gdb-7.2.90.20110703.orig/gdb/cli/cli-utils.h        2011-03-16 22:12:12.000000000 +0100
979 +++ gdb-7.2.90.20110703/gdb/cli/cli-utils.h     2011-07-03 10:33:11.000000000 +0200
980 @@ -103,4 +103,11 @@ extern char *skip_to_space (char *inp);
981     START.  */
982  
983  extern char *remove_trailing_whitespace (const char *start, char *s);
984 +
985 +/* A helper function to extract an argument from *ARG.  An argument is
986 +   delimited by whitespace.  The return value is either NULL if no
987 +   argument was found, or an xmalloc'd string.  */
988 +
989 +extern char *extract_arg (char **arg);
990 +
991  #endif /* CLI_UTILS_H */
992 Index: gdb-7.2.90.20110703/gdb/coffread.c
993 ===================================================================
994 --- gdb-7.2.90.20110703.orig/gdb/coffread.c     2011-03-17 14:19:23.000000000 +0100
995 +++ gdb-7.2.90.20110703/gdb/coffread.c  2011-07-03 10:33:11.000000000 +0200
996 @@ -2193,6 +2193,7 @@ static const struct sym_fns coff_sym_fns
997  
998    default_symfile_relocate,    /* sym_relocate: Relocate a debug
999                                    section.  */
1000 +  NULL,                                /* sym_probe_fns */
1001    &psym_functions
1002  };
1003  
1004 Index: gdb-7.2.90.20110703/gdb/data-directory/Makefile.in
1005 ===================================================================
1006 --- gdb-7.2.90.20110703.orig/gdb/data-directory/Makefile.in     2011-02-04 19:34:41.000000000 +0100
1007 +++ gdb-7.2.90.20110703/gdb/data-directory/Makefile.in  2011-07-03 10:33:11.000000000 +0200
1008 @@ -52,11 +52,23 @@ SYSCALLS_FILES = \
1009  PYTHON_DIR = python
1010  PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR)
1011  PYTHON_FILES = \
1012 +       gdb/FrameIterator.py \
1013 +       gdb/FrameWrapper.py \
1014         gdb/__init__.py \
1015 -       gdb/types.py \
1016 -       gdb/printing.py \
1017 +       gdb/backtrace.py \
1018         gdb/command/__init__.py \
1019 -       gdb/command/pretty_printers.py
1020 +       gdb/command/alias.py \
1021 +       gdb/command/backtrace.py \
1022 +       gdb/command/ignore_errors.py \
1023 +       gdb/command/pahole.py \
1024 +       gdb/command/pretty_printers.py \
1025 +       gdb/command/require.py \
1026 +       gdb/command/upto.py \
1027 +       gdb/function/__init__.py \
1028 +       gdb/function/caller_is.py \
1029 +       gdb/function/in_scope.py \
1030 +       gdb/printing.py \
1031 +       gdb/types.py
1032  
1033  FLAGS_TO_PASS = \
1034         "prefix=$(prefix)" \
1035 Index: gdb-7.2.90.20110703/gdb/dbxread.c
1036 ===================================================================
1037 --- gdb-7.2.90.20110703.orig/gdb/dbxread.c      2011-03-23 19:23:54.000000000 +0100
1038 +++ gdb-7.2.90.20110703/gdb/dbxread.c   2011-07-03 10:33:11.000000000 +0200
1039 @@ -1,6 +1,6 @@
1040  /* Read dbx symbol tables and convert to internal format, for GDB.
1041     Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1042 -   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010.
1043 +   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2008, 2009, 2010, 2011.
1044     Free Software Foundation, Inc.
1045  
1046     This file is part of GDB.
1047 @@ -3587,6 +3587,7 @@ static const struct sym_fns aout_sym_fns
1048    default_symfile_segments,    /* Get segment information from a file.  */
1049    NULL,
1050    default_symfile_relocate,    /* Relocate a debug section.  */
1051 +  NULL,                                /* sym_probe_fns */
1052    &psym_functions
1053  };
1054  
1055 Index: gdb-7.2.90.20110703/gdb/defs.h
1056 ===================================================================
1057 --- gdb-7.2.90.20110703.orig/gdb/defs.h 2011-03-31 16:32:48.000000000 +0200
1058 +++ gdb-7.2.90.20110703/gdb/defs.h      2011-07-03 10:33:11.000000000 +0200
1059 @@ -398,6 +398,8 @@ extern struct cleanup *make_cleanup_rest
1060  extern struct cleanup *
1061    set_batch_flag_and_make_cleanup_restore_page_info (void);
1062  
1063 +extern struct cleanup *make_cleanup_restore_selected_frame (void);
1064 +
1065  extern char *gdb_realpath (const char *);
1066  extern char *xfullpath (const char *);
1067  
1068 Index: gdb-7.2.90.20110703/gdb/doc/gdb.texinfo
1069 ===================================================================
1070 --- gdb-7.2.90.20110703.orig/gdb/doc/gdb.texinfo        2011-07-02 21:59:29.000000000 +0200
1071 +++ gdb-7.2.90.20110703/gdb/doc/gdb.texinfo     2011-07-03 10:33:11.000000000 +0200
1072 @@ -1177,6 +1177,16 @@ for remote debugging.
1073  Run using @var{device} for your program's standard input and output.
1074  @c FIXME: kingdon thinks there is more to -tty.  Investigate.
1075  
1076 +@item -P
1077 +@cindex @code{-P}
1078 +@itemx --python
1079 +@cindex @code{--python}
1080 +Change interpretation of command line so that the argument immediately
1081 +following this switch is taken to be the name of a Python script file.
1082 +This option stops option processing; subsequent options are passed to
1083 +Python as @code{sys.argv}.  This option is only available if Python
1084 +scripting support was enabled when @value{GDBN} was configured.
1085 +
1086  @c resolve the situation of these eventually
1087  @item -tui
1088  @cindex @code{--tui}
1089 @@ -3286,6 +3296,7 @@ all breakpoints in that range are operat
1090  * Conditions::                  Break conditions
1091  * Break Commands::              Breakpoint command lists
1092  * Save Breakpoints::            How to save breakpoints in a file
1093 +* Static Probe Points::         Listing static probe points
1094  * Error in Breakpoints::        ``Cannot insert breakpoints''
1095  * Breakpoint-related Warnings:: ``Breakpoint address adjusted...''
1096  @end menu
1097 @@ -4499,6 +4510,50 @@ and remove the breakpoint definitions yo
1098  that can no longer be recreated.
1099  @end table
1100  
1101 +@node Static Probe Points
1102 +@subsection Static Probe Points
1103 +
1104 +@cindex SystemTap static probe point
1105 +@cindex sdt-probe
1106 +The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
1107 +applications to embed static probes, using @file{sys/sdt.h}.  @value{GDBN}
1108 +can list the available probes, and you can put breakpoints at the
1109 +probe points (@pxref{Specify Location}).
1110 +
1111 +You can examine the available @code{SystemTap} static probes using
1112 +@code{info probes}:
1113 +
1114 +@table @code
1115 +@kindex info probes
1116 +@item info probes [@var{provider} [@var{name} [@var{objfile}]]]
1117 +List the available @code{SystemTap} static probes.
1118 +
1119 +If given, @var{provider} is a regular expression used to select which
1120 +providers to list.  If omitted, all providers are listed.
1121 +
1122 +If given, @var{name} is a regular expression used to select which
1123 +probes to list.  If omitted, all probes are listed.
1124 +
1125 +If given, @var{objfile} is a regular expression used to select which
1126 +object files (executable or shared libraries) to examine.  If not
1127 +given, all object files are considered.
1128 +@end table
1129 +
1130 +@vindex $_probe_arg@r{, convenience variable}
1131 +A probe may specify up to ten arguments.  These are available at the
1132 +point at which the probe is defined---that is, when the current PC is
1133 +at the probe's location.  The arguments are available using the
1134 +convenience variables (@pxref{Convenience Vars})
1135 +@code{$_probe_arg0}@dots{}@code{$_probe_arg9}.  Each probe argument is
1136 +an integer of the appropriate size; types are not preserved.  The
1137 +convenience variable @code{$_probe_argc} holds the number of arguments
1138 +at the current probe point.
1139 +
1140 +These variables are always available, but attempts to access them at
1141 +any location other than a probe point will cause @value{GDBN} to give
1142 +an error.
1143 +
1144 +
1145  @c  @ifclear BARETARGET
1146  @node Error in Breakpoints
1147  @subsection ``Cannot insert breakpoints''
1148 @@ -6414,6 +6469,29 @@ specify the function unambiguously, e.g.
1149  functions with identical names in different source files.
1150  @end table
1151  
1152 +@cindex SystemTap static probe point
1153 +@item probe:@r{[}@var{objfile}:@r{]}@r{[}@var{provider}:@r{]}@var{name}
1154 +The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
1155 +applications to embed static probes.  This form of linespec specifies
1156 +the location of such a static probe.  See
1157 +@uref{http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps}
1158 +for more information on static probes.
1159 +
1160 +If @var{objfile} is given, only probes coming from that shared library
1161 +or executable are considered.  If @var{provider} is given, then only
1162 +probes from that provider are considered.
1163 +
1164 +@xref{Static Probe Points}, for more information on finding and using
1165 +static probes.
1166 +
1167 +Some probes have an associated semaphore variable; for instance, this
1168 +happens automatically if you defined your probe using a DTrace-style
1169 +@file{.d} file.  If your probe has a semaphore, @value{GDBN} will
1170 +automatically enable it when you specify a breakpoint using the
1171 +@samp{probe:} notation.  But, if you put a breakpoint at a probe's
1172 +location by some other method (e.g., @code{break file:line}), then
1173 +@value{GDBN} will not automatically set the semaphore.
1174 +
1175  @end table
1176  
1177  
1178 @@ -8500,6 +8578,10 @@ to match the format in which the data wa
1179  The variable @code{$_exitcode} is automatically set to the exit code when
1180  the program being debugged terminates.
1181  
1182 +@item $_probe_argc
1183 +@itemx $_probe_arg0@dots{}$_probe_arg9
1184 +Arguments to a SystemTap static probe.  @xref{Static Probe Points}.
1185 +
1186  @item $_sdata
1187  @vindex $_sdata@r{, inspect, convenience variable}
1188  The variable @code{$_sdata} contains extra collected static tracepoint
1189 @@ -10219,6 +10301,16 @@ Collect all function arguments.
1190  @item $locals
1191  Collect all local variables.
1192  
1193 +@item $_probe_argc
1194 +Collects the number of arguments from the @code{SystemTap} probe at
1195 +which the tracepoint is located.
1196 +@xref{Static Probe Points,,Static Probe Points}
1197 +
1198 +@item $_probe_arg@var{N}
1199 +Where @var{N} varies from 0 to 9.  Collects the @var{N}th argument
1200 +from the @code{SystemTap} probe at which the tracepoint is located.
1201 +@xref{Static Probe Points,,Static Probe Points}
1202 +
1203  @item $_sdata
1204  @vindex $_sdata@r{, collect}
1205  Collect static tracepoint marker specific data.  Only available for
1206 @@ -20720,8 +20812,6 @@ containing @code{end}.  For example:
1207  
1208  @smallexample
1209  (@value{GDBP}) python
1210 -Type python script
1211 -End with a line saying just "end".
1212  >print 23
1213  >end
1214  23
1215 @@ -20734,6 +20824,14 @@ in a Python script.  This can be control
1216  python print-stack}: if @code{on}, the default, then Python stack
1217  printing is enabled; if @code{off}, then Python stack printing is
1218  disabled.
1219 +
1220 +@kindex maint set python auto-load
1221 +@item maint set python auto-load
1222 +By default, @value{GDBN} will attempt to automatically load Python
1223 +code when an object file is opened.  This can be controlled using
1224 +@code{maint set python auto-load}: if @code{on}, the default, then
1225 +Python auto-loading is enabled; if @code{off}, then Python
1226 +auto-loading is disabled.
1227  @end table
1228  
1229  It is also possible to execute a Python script from the @value{GDBN}
1230 @@ -20755,6 +20853,14 @@ and thus is always available.
1231  @cindex python api
1232  @cindex programming in python
1233  
1234 +You can get quick online help for @value{GDBN}'s Python API by issuing
1235 +the command @w{@kbd{python help (gdb)}}.
1236 +
1237 +Functions and methods which have two or more optional arguments allow
1238 +them to be specified using keyword syntax.  This allows passing some
1239 +optional arguments while skipping others.  Example:
1240 +@w{@code{gdb.some_function ('foo', bar = 1, baz = 2)}}.
1241 +
1242  @cindex python stdout
1243  @cindex python pagination
1244  At startup, @value{GDBN} overrides Python's @code{sys.stdout} and
1245 Index: gdb-7.2.90.20110703/gdb/doc/gdbint.texinfo
1246 ===================================================================
1247 --- gdb-7.2.90.20110703.orig/gdb/doc/gdbint.texinfo     2011-02-04 20:10:12.000000000 +0100
1248 +++ gdb-7.2.90.20110703/gdb/doc/gdbint.texinfo  2011-07-03 10:33:11.000000000 +0200
1249 @@ -2104,6 +2104,18 @@ time, and so we attempt to handle symbol
1250  we create @dfn{partial symbol tables} consisting of only selected
1251  symbols, and only expand them to full symbol tables when necessary.
1252  
1253 +@menu
1254 +* Symbol Reading::
1255 +* Partial Symbol Tables::
1256 +* Types::
1257 +* Object File Formats::
1258 +* Debugging File Formats::
1259 +* Adding a New Symbol Reader to GDB::
1260 +* Memory Management for Symbol Files::
1261 +* Memory Management for Types::
1262 +@end menu
1263 +
1264 +@node Symbol Reading
1265  @section Symbol Reading
1266  
1267  @cindex symbol reading
1268 @@ -2196,6 +2208,7 @@ symtab.  Upon return, @code{pst->readin}
1269  zero if there were no symbols in that part of the symbol file.
1270  @end table
1271  
1272 +@node Partial Symbol Tables
1273  @section Partial Symbol Tables
1274  
1275  @value{GDBN} has three types of symbol tables:
1276 @@ -2297,6 +2310,7 @@ and partial symbol tables behind a set o
1277  the @dfn{quick symbol functions}.  These are documented in
1278  @file{symfile.h}.
1279  
1280 +@node Types
1281  @section Types
1282  
1283  @unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}).
1284 @@ -2319,6 +2333,7 @@ types map to one @code{TYPE_CODE_*} type
1285  other members of the type struct, such as whether the type is signed
1286  or unsigned, and how many bits it uses.
1287  
1288 +@anchor{Builtin Types}
1289  @unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}).
1290  
1291  These are instances of type structs that roughly correspond to
1292 @@ -2333,6 +2348,7 @@ only one instance exists, while @file{c-
1293  @code{TYPE_CODE_INT} types as needed, with each one associated with
1294  some particular objfile.
1295  
1296 +@node Object File Formats
1297  @section Object File Formats
1298  @cindex object file formats
1299  
1300 @@ -2418,6 +2434,7 @@ SOM, which is a cross-language ABI).
1301  
1302  The SOM reader is in @file{somread.c}.
1303  
1304 +@node Debugging File Formats
1305  @section Debugging File Formats
1306  
1307  This section describes characteristics of debugging information that
1308 @@ -2489,6 +2506,7 @@ DWARF 3 is an improved version of DWARF 
1309  @cindex SOM debugging info
1310  Like COFF, the SOM definition includes debugging information.
1311  
1312 +@node Adding a New Symbol Reader to GDB
1313  @section Adding a New Symbol Reader to @value{GDBN}
1314  
1315  @cindex adding debugging info reader
1316 @@ -2511,6 +2529,7 @@ will only ever be implemented by one obj
1317  directly.  This interface should be described in a file
1318  @file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}.
1319  
1320 +@node Memory Management for Symbol Files
1321  @section Memory Management for Symbol Files
1322  
1323  Most memory associated with a loaded symbol file is stored on
1324 @@ -2522,10 +2541,45 @@ released when the objfile is unloaded or
1325  objfile must not reference symbol or type data from another objfile;
1326  they could be unloaded at different times.
1327  
1328 -User convenience variables, et cetera, have associated types.  Normally
1329 -these types live in the associated objfile.  However, when the objfile
1330 -is unloaded, those types are deep copied to global memory, so that
1331 -the values of the user variables and history items are not lost.
1332 +@node Memory Management for Types
1333 +@section Memory Management for Types
1334 +@cindex memory management for types
1335 +
1336 +@findex TYPE_OBJFILE
1337 +@code{TYPE_OBJFILE} macro indicates the current memory owner of the type.
1338 +Non-@code{NULL} value indicates it is owned by an objfile (specifically by its
1339 +obstack) and in such case the type remains valid till the objfile is unloaded
1340 +or reloaded.  For such types with an associated objfile no reference counting
1341 +is being made.
1342 +
1343 +User convenience variables, et cetera, have associated types.  Normally these
1344 +types live in the associated objfile.  However, when the objfile is unloaded,
1345 +those types are deep copied to global memory, so that the values of the user
1346 +variables and history items are not lost.  During the copy they will get their
1347 +@code{TYPE_OBJFILE} set to @code{NULL} and become so-called @dfn{reclaimable}
1348 +types.
1349 +
1350 +Types with null @code{TYPE_OBJFILE} can be either permanent types
1351 +(@pxref{Builtin Types}) or reclaimable types which will be deallocated at the
1352 +first idle @value{GDBN} moment if the last object referencing them is removed.
1353 +Permanent types are allocated by the function @code{alloc_type} (and its
1354 +derivations like @code{init_type}) specifying objfile as @code{NULL}.  The
1355 +reclaimable types are created the same way but moreover they need to have
1356 +@code{type_init_group} called to start their tracking as being possibly
1357 +deallocatable.
1358 +
1359 +@findex free_all_types
1360 +When @value{GDBN} gets idle it always calls the @code{free_all_types} function
1361 +which deallocates any unused types.  All types currently not owned by an
1362 +objfile must be marked as used on each @code{free_all_types} call as they would
1363 +get deallocated as unused otherwise.
1364 +
1365 +@code{free_all_types} automatically checks for any cross-type references such
1366 +as through @code{TYPE_TARGET_TYPE}, @code{TYPE_POINTER_TYPE} etc.@: and
1367 +prevents early deallocation for any such existing references.  Reclaimable
1368 +types may reference any other reclaimable types or even permanent types.  But
1369 +permanent types must not reference reclaimable types (nor an objfile associated
1370 +type).
1371  
1372  
1373  @node Language Support
1374 Index: gdb-7.2.90.20110703/gdb/doc/observer.texi
1375 ===================================================================
1376 --- gdb-7.2.90.20110703.orig/gdb/doc/observer.texi      2011-01-05 06:09:54.000000000 +0100
1377 +++ gdb-7.2.90.20110703/gdb/doc/observer.texi   2011-07-03 10:33:11.000000000 +0200
1378 @@ -223,6 +223,11 @@ Bytes from @var{data} to @var{data} + @v
1379  to the current inferior at @var{addr}.
1380  @end deftypefun
1381  
1382 +@c @deftypefun void mark_used (void)
1383 +@c Mark any possibly reclaimable objects as used during a mark-and-sweep garbage
1384 +@c collector pass.  Currently only @code{type_mark_used} marker is supported.
1385 +@c @end deftypefun
1386 +
1387  @deftypefun void test_notification (int @var{somearg})
1388  This observer is used for internal testing.  Do not use.  
1389  See testsuite/gdb.gdb/observer.exp.
1390 Index: gdb-7.2.90.20110703/gdb/dwarf2expr.c
1391 ===================================================================
1392 --- gdb-7.2.90.20110703.orig/gdb/dwarf2expr.c   2011-05-13 20:54:47.000000000 +0200
1393 +++ gdb-7.2.90.20110703/gdb/dwarf2expr.c        2011-07-03 10:33:11.000000000 +0200
1394 @@ -912,6 +912,13 @@ execute_stack_op (struct dwarf_expr_cont
1395           ctx->num_pieces = 0;
1396           goto abort_expression;
1397  
1398 +       case DW_OP_push_object_address:
1399 +         if (ctx->get_object_address == NULL)
1400 +           error (_("DWARF-2 expression error: DW_OP_push_object_address must "
1401 +                  "have a value to push."));
1402 +         result = (ctx->get_object_address) (ctx->baton);
1403 +         break;
1404 +
1405         default:
1406           error (_("Unhandled dwarf expression opcode 0x%x"), op);
1407         }
1408 Index: gdb-7.2.90.20110703/gdb/dwarf2expr.h
1409 ===================================================================
1410 --- gdb-7.2.90.20110703.orig/gdb/dwarf2expr.h   2011-02-27 17:25:37.000000000 +0100
1411 +++ gdb-7.2.90.20110703/gdb/dwarf2expr.h        2011-07-03 10:33:11.000000000 +0200
1412 @@ -114,9 +114,15 @@ struct dwarf_expr_context
1413  #if 0
1414    /* Not yet implemented.  */
1415  
1416 +  /* Return the location expression for the dwarf expression
1417 +     subroutine in the die at OFFSET in the current compilation unit.
1418 +     The result must be live until the current expression evaluation
1419 +     is complete.  */
1420 +  unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length);
1421 +#endif
1422 +
1423    /* Return the `object address' for DW_OP_push_object_address.  */
1424    CORE_ADDR (*get_object_address) (void *baton);
1425 -#endif
1426  
1427    /* The current depth of dwarf expression recursion, via DW_OP_call*,
1428       DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum
1429 Index: gdb-7.2.90.20110703/gdb/dwarf2loc.c
1430 ===================================================================
1431 --- gdb-7.2.90.20110703.orig/gdb/dwarf2loc.c    2011-03-22 22:06:33.000000000 +0100
1432 +++ gdb-7.2.90.20110703/gdb/dwarf2loc.c 2011-07-03 10:33:11.000000000 +0200
1433 @@ -134,6 +134,9 @@ struct dwarf_expr_baton
1434  {
1435    struct frame_info *frame;
1436    struct dwarf2_per_cu_data *per_cu;
1437 +  /* From DW_TAG_variable's DW_AT_location (not DW_TAG_type's
1438 +     DW_AT_data_location) for DW_OP_push_object_address.  */
1439 +  CORE_ADDR object_address;
1440  };
1441  
1442  /* Helper functions for dwarf2_evaluate_loc_desc.  */
1443 @@ -202,23 +205,33 @@ dwarf_expr_frame_base_1 (struct symbol *
1444        symbaton = SYMBOL_LOCATION_BATON (framefunc);
1445        *start = dwarf2_find_location_expression (symbaton, length, pc);
1446      }
1447 -  else
1448 +  else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs)
1449      {
1450        struct dwarf2_locexpr_baton *symbaton;
1451  
1452        symbaton = SYMBOL_LOCATION_BATON (framefunc);
1453 -      if (symbaton != NULL)
1454 -       {
1455 -         *length = symbaton->size;
1456 -         *start = symbaton->data;
1457 -       }
1458 -      else
1459 -       *start = NULL;
1460 +      gdb_assert (symbaton != NULL);
1461 +      *start = symbaton->data;
1462 +      *length = symbaton->size;
1463 +    }
1464 +  else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_missing_funcs)
1465 +    {
1466 +      struct dwarf2_locexpr_baton *symbaton;
1467 +
1468 +      symbaton = SYMBOL_LOCATION_BATON (framefunc);
1469 +      gdb_assert (symbaton == NULL);
1470 +      *start = NULL;
1471 +      *length = 0;     /* unused */
1472      }
1473 +  else
1474 +    internal_error (__FILE__, __LINE__,
1475 +                   _("Unsupported SYMBOL_COMPUTED_OPS %p for \"%s\""),
1476 +                   SYMBOL_COMPUTED_OPS (framefunc),
1477 +                   SYMBOL_PRINT_NAME (framefunc));
1478  
1479    if (*start == NULL)
1480      error (_("Could not find the frame base for \"%s\"."),
1481 -          SYMBOL_NATURAL_NAME (framefunc));
1482 +          SYMBOL_PRINT_NAME (framefunc));
1483  }
1484  
1485  /* Helper function for dwarf2_evaluate_loc_desc.  Computes the CFA for
1486 @@ -286,6 +299,172 @@ dwarf_expr_dwarf_call (struct dwarf_expr
1487                      ctx->get_frame_pc, ctx->baton);
1488  }
1489  
1490 +static CORE_ADDR
1491 +dwarf_expr_object_address (void *baton)
1492 +{
1493 +  struct dwarf_expr_baton *debaton = baton;
1494 +
1495 +  /* The message is suppressed in DWARF_BLOCK_EXEC.  */
1496 +  if (debaton->object_address == 0)
1497 +    error (_("Cannot resolve DW_OP_push_object_address for a missing object"));
1498 +
1499 +  return debaton->object_address;
1500 +}
1501 +
1502 +/* Address of the variable we are currently referring to.  It is set from
1503 +   DW_TAG_variable's DW_AT_location (not DW_TAG_type's DW_AT_data_location) for
1504 +   DW_OP_push_object_address.  */
1505 +
1506 +static CORE_ADDR object_address;
1507 +
1508 +/* Callers use object_address_set while their callers use the result set so we
1509 +   cannot run the cleanup at the local block of our direct caller.  Still we
1510 +   should reset OBJECT_ADDRESS at least for the next GDB command.  */
1511 +
1512 +static void
1513 +object_address_cleanup (void *prev_save_voidp)
1514 +{
1515 +  CORE_ADDR *prev_save = prev_save_voidp;
1516 +
1517 +  object_address = *prev_save;
1518 +  xfree (prev_save);
1519 +}
1520 +
1521 +/* Set the base address - DW_AT_location - of a variable.  It is being later
1522 +   used to derive other object addresses by DW_OP_push_object_address.
1523 +
1524 +   It would be useful to sanity check ADDRESS - such as for some objects with
1525 +   unset value_raw_address - but some valid addresses may be zero (such as first
1526 +   objects in relocatable .o files).  */
1527 +
1528 +void
1529 +object_address_set (CORE_ADDR address)
1530 +{
1531 +  CORE_ADDR *prev_save;
1532 +
1533 +  prev_save = xmalloc (sizeof *prev_save);
1534 +  *prev_save = object_address;
1535 +  make_cleanup (object_address_cleanup, prev_save);
1536 +
1537 +  object_address = address;
1538 +}
1539 +
1540 +/* Evaluate DWARF expression at DATA ... DATA + SIZE with its result readable
1541 +   by dwarf_expr_fetch (RETVAL, 0).  FRAME parameter can be NULL to call
1542 +   get_selected_frame to find it.  Returned dwarf_expr_context freeing is
1543 +   pushed on the cleanup chain.  */
1544 +
1545 +static struct dwarf_expr_context *
1546 +dwarf_expr_prep_ctx (struct frame_info *frame, const gdb_byte *data,
1547 +                    size_t size, struct dwarf2_per_cu_data *per_cu)
1548 +{
1549 +  struct dwarf_expr_context *ctx;
1550 +  struct dwarf_expr_baton baton;
1551 +  struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
1552 +  volatile struct gdb_exception ex;
1553 +
1554 +  baton.frame = frame;
1555 +  baton.per_cu = per_cu;
1556 +  baton.object_address = object_address;
1557 +
1558 +  ctx = new_dwarf_expr_context ();
1559 +  make_cleanup_free_dwarf_expr_context (ctx);
1560 +
1561 +  ctx->gdbarch = get_objfile_arch (objfile);
1562 +  ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
1563 +  ctx->offset = dwarf2_per_cu_text_offset (per_cu);
1564 +  ctx->baton = &baton;
1565 +  ctx->read_reg = dwarf_expr_read_reg;
1566 +  ctx->read_mem = dwarf_expr_read_mem;
1567 +  ctx->get_frame_base = dwarf_expr_frame_base;
1568 +  ctx->get_frame_cfa = dwarf_expr_frame_cfa;
1569 +  ctx->get_frame_pc = dwarf_expr_frame_pc;
1570 +  ctx->get_tls_address = dwarf_expr_tls_address;
1571 +  ctx->dwarf_call = dwarf_expr_dwarf_call;
1572 +  ctx->get_object_address = dwarf_expr_object_address;
1573 +
1574 +  TRY_CATCH (ex, RETURN_MASK_ERROR)
1575 +    {
1576 +      dwarf_expr_eval (ctx, data, size);
1577 +    }
1578 +  if (ex.reason < 0)
1579 +    {
1580 +      if (ex.error == NOT_AVAILABLE_ERROR)
1581 +       return NULL;
1582 +      else
1583 +       throw_exception (ex);
1584 +    }
1585 +
1586 +  /* It was used only during dwarf_expr_eval.  */
1587 +  ctx->baton = NULL;
1588 +
1589 +  return ctx;
1590 +}
1591 +
1592 +/* Evaluate DWARF expression at DLBATON expecting it produces exactly one
1593 +   CORE_ADDR result on the DWARF stack stack.  */
1594 +
1595 +CORE_ADDR
1596 +dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton)
1597 +{
1598 +  struct dwarf_expr_context *ctx;
1599 +  CORE_ADDR retval;
1600 +  struct cleanup *back_to = make_cleanup (null_cleanup, 0);
1601 +
1602 +  ctx = dwarf_expr_prep_ctx (get_selected_frame (NULL), dlbaton->data,
1603 +                            dlbaton->size, dlbaton->per_cu);
1604 +  if (ctx == NULL)
1605 +    throw_error (NOT_AVAILABLE_ERROR, _("Value not available"));
1606 +  if (ctx->num_pieces > 0)
1607 +    error (_("DW_OP_*piece is unsupported for DW_FORM_block"));
1608 +
1609 +  retval = dwarf_expr_fetch (ctx, 0);
1610 +
1611 +  if (ctx->location == DWARF_VALUE_REGISTER)
1612 +    {
1613 +      /* Inlined dwarf_expr_read_reg as we no longer have the baton. */
1614 +
1615 +      int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (ctx->gdbarch, retval);
1616 +      struct type *type = builtin_type (ctx->gdbarch)->builtin_data_ptr;
1617 +      struct frame_info *frame = get_selected_frame (NULL);
1618 +
1619 +      retval = address_from_register (type, gdb_regnum, frame);
1620 +    }
1621 +
1622 +  do_cleanups (back_to);
1623 +
1624 +  return retval;
1625 +}
1626 +
1627 +/* Evaluate DWARF location list at DLLBATON expecting it produces exactly one
1628 +   CORE_ADDR result stored to *ADDRP on the DWARF stack stack.  If the result
1629 +   could not be found return zero and keep *ADDRP unchanged.  */
1630 +
1631 +int
1632 +dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
1633 +                         struct type *type, CORE_ADDR *addrp)
1634 +{
1635 +  struct frame_info *frame = get_selected_frame (NULL);
1636 +  const gdb_byte *data;
1637 +  size_t size;
1638 +  struct value *val;
1639 +
1640 +  if (!dllbaton)
1641 +    return 0;
1642 +
1643 +  data = dwarf2_find_location_expression (dllbaton, &size,
1644 +                                         get_frame_address_in_block (frame));
1645 +  if (data == NULL)
1646 +    return 0;
1647 +
1648 +  val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu);
1649 +  if (value_optimized_out (val))
1650 +    return 0;
1651 +
1652 +  *addrp = value_as_address (val);
1653 +  return 1;
1654 +}
1655 +
1656  struct piece_closure
1657  {
1658    /* Reference count.  */
1659 @@ -1072,11 +1251,8 @@ dwarf2_evaluate_loc_desc_full (struct ty
1660                                LONGEST byte_offset)
1661  {
1662    struct value *retval;
1663 -  struct dwarf_expr_baton baton;
1664    struct dwarf_expr_context *ctx;
1665    struct cleanup *old_chain;
1666 -  struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
1667 -  volatile struct gdb_exception ex;
1668  
1669    if (byte_offset < 0)
1670      invalid_synthetic_pointer ();
1671 @@ -1089,38 +1265,14 @@ dwarf2_evaluate_loc_desc_full (struct ty
1672        return retval;
1673      }
1674  
1675 -  baton.frame = frame;
1676 -  baton.per_cu = per_cu;
1677 -
1678 -  ctx = new_dwarf_expr_context ();
1679 -  old_chain = make_cleanup_free_dwarf_expr_context (ctx);
1680 -
1681 -  ctx->gdbarch = get_objfile_arch (objfile);
1682 -  ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
1683 -  ctx->offset = dwarf2_per_cu_text_offset (per_cu);
1684 -  ctx->baton = &baton;
1685 -  ctx->read_reg = dwarf_expr_read_reg;
1686 -  ctx->read_mem = dwarf_expr_read_mem;
1687 -  ctx->get_frame_base = dwarf_expr_frame_base;
1688 -  ctx->get_frame_cfa = dwarf_expr_frame_cfa;
1689 -  ctx->get_frame_pc = dwarf_expr_frame_pc;
1690 -  ctx->get_tls_address = dwarf_expr_tls_address;
1691 -  ctx->dwarf_call = dwarf_expr_dwarf_call;
1692 +  old_chain = make_cleanup (null_cleanup, 0);
1693  
1694 -  TRY_CATCH (ex, RETURN_MASK_ERROR)
1695 -    {
1696 -      dwarf_expr_eval (ctx, data, size);
1697 -    }
1698 -  if (ex.reason < 0)
1699 +  ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
1700 +  if (ctx == NULL)
1701      {
1702 -      if (ex.error == NOT_AVAILABLE_ERROR)
1703 -       {
1704 -         retval = allocate_value (type);
1705 -         mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
1706 -         return retval;
1707 -       }
1708 -      else
1709 -       throw_exception (ex);
1710 +      retval = allocate_value (type);
1711 +      mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
1712 +      return retval;
1713      }
1714  
1715    if (ctx->num_pieces > 0)
1716 @@ -1166,6 +1318,15 @@ dwarf2_evaluate_loc_desc_full (struct ty
1717             CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
1718             int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
1719  
1720 +           /* Frame may be needed for check_typedef of TYPE_DYNAMIC.  */
1721 +           make_cleanup_restore_selected_frame ();
1722 +           select_frame (frame);
1723 +
1724 +           /* object_address_set called here is required in ALLOCATE_VALUE's
1725 +              CHECK_TYPEDEF for the object's possible
1726 +              DW_OP_push_object_address.  */
1727 +           object_address_set (address);
1728 +
1729             retval = allocate_value_lazy (type);
1730             VALUE_LVAL (retval) = lval_memory;
1731             if (in_stack_memory)
1732 @@ -2855,11 +3016,51 @@ loclist_tracepoint_var_ref (struct symbo
1733                                dlbaton->per_cu);
1734  }
1735  
1736 -/* The set of location functions used with the DWARF-2 expression
1737 -   evaluator and location lists.  */
1738 +/* The set of location functions used with the DWARF-2 location lists.  */
1739  const struct symbol_computed_ops dwarf2_loclist_funcs = {
1740    loclist_read_variable,
1741    loclist_read_needs_frame,
1742    loclist_describe_location,
1743    loclist_tracepoint_var_ref
1744  };
1745 +
1746 +static struct value *
1747 +missing_read_variable (struct symbol *symbol, struct frame_info *frame)
1748 +{
1749 +  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1750 +
1751 +  gdb_assert (dlbaton == NULL);
1752 +  error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
1753 +}
1754 +
1755 +static int
1756 +missing_read_needs_frame (struct symbol *symbol)
1757 +{
1758 +  return 0;
1759 +}
1760 +
1761 +static void
1762 +missing_describe_location (struct symbol *symbol, CORE_ADDR addr,
1763 +                          struct ui_file *stream)
1764 +{
1765 +  fprintf_filtered (stream, _("a variable we are unable to resolve"));
1766 +}
1767 +
1768 +static void
1769 +missing_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
1770 +                           struct agent_expr *ax, struct axs_value *value)
1771 +{
1772 +  struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1773 +
1774 +  gdb_assert (dlbaton == NULL);
1775 +  error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
1776 +}
1777 +
1778 +/* The set of location functions used with the DWARF-2 evaluator when we are
1779 +   unable to resolve the symbols.  */
1780 +const struct symbol_computed_ops dwarf2_missing_funcs = {
1781 +  missing_read_variable,
1782 +  missing_read_needs_frame,
1783 +  missing_describe_location,
1784 +  missing_tracepoint_var_ref
1785 +};
1786 Index: gdb-7.2.90.20110703/gdb/dwarf2loc.h
1787 ===================================================================
1788 --- gdb-7.2.90.20110703.orig/gdb/dwarf2loc.h    2011-02-17 17:20:44.000000000 +0100
1789 +++ gdb-7.2.90.20110703/gdb/dwarf2loc.h 2011-07-03 10:33:11.000000000 +0200
1790 @@ -107,6 +107,15 @@ struct dwarf2_loclist_baton
1791  
1792  extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
1793  extern const struct symbol_computed_ops dwarf2_loclist_funcs;
1794 +extern const struct symbol_computed_ops dwarf2_missing_funcs;
1795 +
1796 +extern void object_address_set (CORE_ADDR address);
1797 +
1798 +extern CORE_ADDR dwarf_locexpr_baton_eval
1799 +  (struct dwarf2_locexpr_baton *dlbaton);
1800 +
1801 +extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
1802 +                                    struct type *type, CORE_ADDR *addrp);
1803  
1804  /* Compile a DWARF location expression to an agent expression.
1805     
1806 Index: gdb-7.2.90.20110703/gdb/dwarf2read.c
1807 ===================================================================
1808 --- gdb-7.2.90.20110703.orig/gdb/dwarf2read.c   2011-07-02 21:59:29.000000000 +0200
1809 +++ gdb-7.2.90.20110703/gdb/dwarf2read.c        2011-07-03 10:33:11.000000000 +0200
1810 @@ -1222,6 +1222,9 @@ static void fill_in_loclist_baton (struc
1811                                    struct dwarf2_loclist_baton *baton,
1812                                    struct attribute *attr);
1813  
1814 +static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton
1815 +  (struct attribute *attr, struct dwarf2_cu *cu);
1816 +
1817  static void dwarf2_symbol_mark_computed (struct attribute *attr,
1818                                          struct symbol *sym,
1819                                          struct dwarf2_cu *cu);
1820 @@ -1256,6 +1259,9 @@ static void age_cached_comp_units (void)
1821  
1822  static void free_one_cached_comp_unit (void *);
1823  
1824 +static void fetch_die_type_attrs (struct die_info *die, struct type *type,
1825 +                                 struct dwarf2_cu *cu);
1826 +
1827  static struct type *set_die_type (struct die_info *, struct type *,
1828                                   struct dwarf2_cu *);
1829  
1830 @@ -1280,6 +1286,9 @@ static struct type *get_die_type_at_offs
1831  
1832  static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
1833  
1834 +static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
1835 +  (struct attribute *attr, struct dwarf2_cu *cu);
1836 +
1837  static void dwarf2_release_queue (void *dummy);
1838  
1839  static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
1840 @@ -7542,6 +7551,29 @@ process_enumeration_scope (struct die_in
1841    new_symbol (die, this_type, cu);
1842  }
1843  
1844 +/* Create a new array dimension referencing its target type TYPE.
1845 +
1846 +   Multidimensional arrays are internally represented as a stack of
1847 +   singledimensional arrays being referenced by their TYPE_TARGET_TYPE.  */
1848 +
1849 +static struct type *
1850 +create_single_array_dimension (struct type *type, struct type *range_type,
1851 +                              struct die_info *die, struct dwarf2_cu *cu)
1852 +{
1853 +  type = create_array_type (NULL, type, range_type);
1854 +
1855 +  /* These generic type attributes need to be fetched by
1856 +     evaluate_subexp_standard <multi_f77_subscript>'s call of
1857 +     value_subscripted_rvalue only for the innermost array type.  */
1858 +  fetch_die_type_attrs (die, type, cu);
1859 +
1860 +  /* These generic type attributes are checked for allocated/associated
1861 +     validity while accessing FIELD_LOC_KIND_DWARF_BLOCK.  */
1862 +  fetch_die_type_attrs (die, range_type, cu);
1863 +
1864 +  return type;
1865 +}
1866 +
1867  /* Extract all information from a DW_TAG_array_type DIE and put it in
1868     the DIE's type field.  For now, this only handles one dimensional
1869     arrays.  */
1870 @@ -7555,7 +7587,7 @@ read_array_type (struct die_info *die, s
1871    struct type *element_type, *range_type, *index_type;
1872    struct type **range_types = NULL;
1873    struct attribute *attr;
1874 -  int ndim = 0;
1875 +  int ndim = 0, i;
1876    struct cleanup *back_to;
1877    char *name;
1878  
1879 @@ -7608,17 +7640,19 @@ read_array_type (struct die_info *die, s
1880    type = element_type;
1881  
1882    if (read_array_order (die, cu) == DW_ORD_col_major)
1883 -    {
1884 -      int i = 0;
1885 -
1886 -      while (i < ndim)
1887 -       type = create_array_type (NULL, type, range_types[i++]);
1888 -    }
1889 -  else
1890 -    {
1891 -      while (ndim-- > 0)
1892 -       type = create_array_type (NULL, type, range_types[ndim]);
1893 -    }
1894 +    for (i = 0; i < ndim; i++)
1895 +      type = create_single_array_dimension (type, range_types[i], die, cu);
1896 +  else /* (read_array_order (die, cu) == DW_ORD_row_major) */
1897 +    for (i = ndim - 1; i >= 0; i--)
1898 +      type = create_single_array_dimension (type, range_types[i], die, cu);
1899 +
1900 +  /* Data locations should be set only for the outermost dimension as they
1901 +     would be confusing for the dereferenced offset on the inner ones.  */
1902 +  attr = dwarf2_attr (die, DW_AT_data_location, cu);
1903 +  if (attr_form_is_block (attr))
1904 +    TYPE_DATA_LOCATION_DWARF_BLOCK (type)
1905 +      = dwarf2_attr_to_locexpr_baton (attr, cu);
1906 +  gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
1907  
1908    /* Understand Dwarf2 support for vector types (like they occur on
1909       the PowerPC w/ AltiVec).  Gcc just adds another attribute to the
1910 @@ -8102,29 +8136,114 @@ read_tag_string_type (struct die_info *d
1911    struct gdbarch *gdbarch = get_objfile_arch (objfile);
1912    struct type *type, *range_type, *index_type, *char_type;
1913    struct attribute *attr;
1914 -  unsigned int length;
1915 +  int length;
1916 +
1917 +  index_type = objfile_type (objfile)->builtin_int;
1918 +  /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type.  */
1919 +  range_type = alloc_type (objfile);
1920 +  /* LOW_BOUND and HIGH_BOUND are set for real below.  */
1921 +  range_type = create_range_type (range_type, index_type, 0, -1);
1922 +
1923 +  /* C/C++ should probably have the low bound 0 but C/C++ does not use
1924 +     DW_TAG_string_type.  */
1925 +  TYPE_LOW_BOUND (range_type) = 1;
1926  
1927    attr = dwarf2_attr (die, DW_AT_string_length, cu);
1928 -  if (attr)
1929 +  if (attr && attr_form_is_block (attr))
1930      {
1931 -      length = DW_UNSND (attr);
1932 +      /* Security check for a size overflow.  */
1933 +      if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
1934 +       TYPE_HIGH_BOUND (range_type) = 1;
1935 +      /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size
1936 +        instruction as DW_AT_string_length specifies the length location, not
1937 +        its value.  */
1938 +      else
1939 +       {
1940 +         struct dwarf2_locexpr_baton *length_baton = NULL;
1941 +         struct dwarf_block *blk = DW_BLOCK (attr);
1942 +
1943 +         /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing
1944 +            DW_OP_deref* in such case.  */
1945 +
1946 +         if (blk->size == 1 && blk->data[0] >= DW_OP_reg0
1947 +             && blk->data[0] <= DW_OP_reg31)
1948 +           length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
1949 +         else if (blk->size > 1 && blk->data[0] == DW_OP_regx)
1950 +           {
1951 +             ULONGEST ulongest;
1952 +             const gdb_byte *end;
1953 +
1954 +             end = read_uleb128 (&blk->data[1], &blk->data[blk->size],
1955 +                                 &ulongest);
1956 +             if (end == &blk->data[blk->size])
1957 +               length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
1958 +           }
1959 +
1960 +         if (length_baton == NULL)
1961 +           {
1962 +             struct attribute *size_attr;
1963 +             gdb_byte *data;
1964 +
1965 +             length_baton = obstack_alloc (&cu->comp_unit_obstack,
1966 +                                           sizeof (*length_baton));
1967 +             length_baton->per_cu = cu->per_cu;
1968 +             length_baton->size = DW_BLOCK (attr)->size + 2;
1969 +             data = obstack_alloc (&cu->comp_unit_obstack,
1970 +                                   length_baton->size);
1971 +             length_baton->data = data;
1972 +             memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
1973 +
1974 +             /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH
1975 +                specifies the size of an integer to fetch.  */
1976 +             size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
1977 +             if (size_attr)
1978 +               {
1979 +                 data[DW_BLOCK (attr)->size] = DW_OP_deref_size;
1980 +                 data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr);
1981 +                 if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr))
1982 +                   complaint (&symfile_complaints,
1983 +                              _("DW_AT_string_length's DW_AT_byte_size "
1984 +                                "integer exceeds the byte size storage"));
1985 +               }
1986 +             else
1987 +               {
1988 +                 data[DW_BLOCK (attr)->size] = DW_OP_deref;
1989 +                 data[DW_BLOCK (attr)->size + 1] = DW_OP_nop;
1990 +               }
1991 +           }
1992 +
1993 +         TYPE_RANGE_DATA (range_type)->high.kind
1994 +           = RANGE_BOUND_KIND_DWARF_BLOCK;
1995 +         TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton;
1996 +         TYPE_DYNAMIC (range_type) = 1;
1997 +       }
1998      }
1999    else
2000      {
2001 -      /* Check for the DW_AT_byte_size attribute.  */
2002 +      if (attr && attr_form_is_constant (attr))
2003 +       {
2004 +         /* We currently do not support a constant address where the location
2005 +            should be read from - attr_form_is_block is expected instead.  See
2006 +            DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference.
2007 +            */
2008 +         /* PASSTHRU */
2009 +       }
2010 +
2011        attr = dwarf2_attr (die, DW_AT_byte_size, cu);
2012 -      if (attr)
2013 -        {
2014 -          length = DW_UNSND (attr);
2015 -        }
2016 +      if (attr && attr_form_is_block (attr))
2017 +       {
2018 +         TYPE_RANGE_DATA (range_type)->high.kind
2019 +           = RANGE_BOUND_KIND_DWARF_BLOCK;
2020 +         TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
2021 +                                       dwarf2_attr_to_locexpr_baton (attr, cu);
2022 +         TYPE_DYNAMIC (range_type) = 1;
2023 +       }
2024 +      else if (attr && attr_form_is_constant (attr))
2025 +       TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0);
2026        else
2027 -        {
2028 -          length = 1;
2029 -        }
2030 +       TYPE_HIGH_BOUND (range_type) = 1;
2031      }
2032  
2033 -  index_type = objfile_type (objfile)->builtin_int;
2034 -  range_type = create_range_type (NULL, index_type, 1, length);
2035    char_type = language_string_char_type (cu->language_defn, gdbarch);
2036    type = create_string_type (NULL, char_type, range_type);
2037  
2038 @@ -8409,8 +8528,7 @@ read_subrange_type (struct die_info *die
2039    struct type *base_type;
2040    struct type *range_type;
2041    struct attribute *attr;
2042 -  LONGEST low = 0;
2043 -  LONGEST high = -1;
2044 +  LONGEST low;
2045    char *name;
2046    LONGEST negative_mask;
2047  
2048 @@ -8423,53 +8541,126 @@ read_subrange_type (struct die_info *die
2049    if (range_type)
2050      return range_type;
2051  
2052 -  if (cu->language == language_fortran)
2053 +  /* LOW_BOUND and HIGH_BOUND are set for real below.  */
2054 +  range_type = create_range_type (NULL, base_type, 0, -1);
2055 +  TYPE_UNSIGNED (range_type) = 0;
2056 +
2057 +  negative_mask = 
2058 +    (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
2059 +
2060 +  /* Exclude language_ada from any TYPE_DYNAMIC constructs below.  GDB Ada
2061 +     supports implements the dynamic bounds in a non-DWARF way and the
2062 +     existing DWARF dynamic bounds are invalid, leading to memory access
2063 +     errors.  */
2064 +
2065 +  attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
2066 +  if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2067      {
2068 -      /* FORTRAN implies a lower bound of 1, if not given.  */
2069 -      low = 1;
2070 +      TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
2071 +      TYPE_RANGE_DATA (range_type)->low.u.dwarf_block =
2072 +                                       dwarf2_attr_to_locexpr_baton (attr, cu);
2073 +      TYPE_DYNAMIC (range_type) = 1;
2074 +      /* For setting a default if DW_AT_UPPER_BOUND would be missing.  */
2075 +      low = 0;
2076      }
2077 +  else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2078 +    {
2079 +      struct die_info *target_die;
2080 +      struct dwarf2_cu *target_cu = cu;
2081 +      struct attribute *target_loc_attr;
2082  
2083 -  /* FIXME: For variable sized arrays either of these could be
2084 -     a variable rather than a constant value.  We'll allow it,
2085 -     but we don't know how to handle it.  */
2086 -  attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
2087 -  if (attr)
2088 -    low = dwarf2_get_attr_constant_value (attr, 0);
2089 +      target_die = follow_die_ref_or_sig (die, attr, &target_cu);
2090 +      gdb_assert (target_cu->objfile == cu->objfile);
2091 +      target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
2092  
2093 -  attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
2094 -  if (attr)
2095 +      TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
2096 +      TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist
2097 +        = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
2098 +      TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type
2099 +        = die_type (target_die, target_cu);
2100 +      TYPE_DYNAMIC (range_type) = 1;
2101 +      /* For setting a default if DW_AT_UPPER_BOUND would be missing.  */
2102 +      low = 0;
2103 +    }
2104 +  else
2105      {
2106 -      if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
2107 -        {
2108 -          /* GCC encodes arrays with unspecified or dynamic length
2109 -             with a DW_FORM_block1 attribute or a reference attribute.
2110 -             FIXME: GDB does not yet know how to handle dynamic
2111 -             arrays properly, treat them as arrays with unspecified
2112 -             length for now.
2113 -
2114 -             FIXME: jimb/2003-09-22: GDB does not really know
2115 -             how to handle arrays of unspecified length
2116 -             either; we just represent them as zero-length
2117 -             arrays.  Choose an appropriate upper bound given
2118 -             the lower bound we've computed above.  */
2119 -          high = low - 1;
2120 -        }
2121 +      if (attr && attr_form_is_constant (attr))
2122 +       low = dwarf2_get_attr_constant_value (attr, 0);
2123        else
2124 -        high = dwarf2_get_attr_constant_value (attr, 1);
2125 +       {
2126 +         if (cu->language == language_fortran)
2127 +           {
2128 +             /* FORTRAN implies a lower bound of 1, if not given.  */
2129 +             low = 1;
2130 +           }
2131 +         else
2132 +           {
2133 +             /* According to DWARF we should assume the value 0 only for
2134 +                LANGUAGE_C and LANGUAGE_CPLUS.  */
2135 +             low = 0;
2136 +           }
2137 +       }
2138 +      if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
2139 +       low |= negative_mask;
2140 +      TYPE_LOW_BOUND (range_type) = low;
2141 +      if (low >= 0)
2142 +       TYPE_UNSIGNED (range_type) = 1;
2143      }
2144 -  else
2145 +
2146 +  attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
2147 +  if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr)
2148 +               && !is_ref_attr (attr)))
2149      {
2150        attr = dwarf2_attr (die, DW_AT_count, cu);
2151 -      if (attr)
2152 -       {
2153 -         int count = dwarf2_get_attr_constant_value (attr, 1);
2154 -         high = low + count - 1;
2155 +      /* It does not hurt but it is needlessly ineffective in check_typedef.  */
2156 +      if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr)))
2157 +       {
2158 +         TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
2159 +         TYPE_DYNAMIC (range_type) = 1;
2160         }
2161 +      /* Pass it now as the regular DW_AT_upper_bound.  */
2162 +    }
2163 +
2164 +  if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2165 +    {
2166 +      TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
2167 +      TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
2168 +                                       dwarf2_attr_to_locexpr_baton (attr, cu);
2169 +      TYPE_DYNAMIC (range_type) = 1;
2170 +    }
2171 +  else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2172 +    {
2173 +      struct die_info *target_die;
2174 +      struct dwarf2_cu *target_cu = cu;
2175 +      struct attribute *target_loc_attr;
2176 +
2177 +      target_die = follow_die_ref_or_sig (die, attr, &target_cu);
2178 +      gdb_assert (target_cu->objfile == cu->objfile);
2179 +      target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
2180 +
2181 +      TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
2182 +      TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist
2183 +        = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
2184 +      TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type
2185 +        = die_type (target_die, target_cu);
2186 +      TYPE_DYNAMIC (range_type) = 1;
2187 +    }
2188 +  else
2189 +    {
2190 +      LONGEST high;
2191 +
2192 +      if (attr && attr_form_is_constant (attr))
2193 +       high = dwarf2_get_attr_constant_value (attr, 0);
2194        else
2195         {
2196 -         /* Unspecified array length.  */
2197 +         /* Ada expects an empty array on no boundary attributes.  */
2198 +         if (cu->language != language_ada)
2199 +           TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
2200           high = low - 1;
2201         }
2202 +      if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
2203 +       high |= negative_mask;
2204 +      TYPE_HIGH_BOUND (range_type) = high;
2205      }
2206  
2207    /* Dwarf-2 specifications explicitly allows to create subrange types
2208 @@ -8510,24 +8701,41 @@ read_subrange_type (struct die_info *die
2209         }
2210      }
2211  
2212 -  negative_mask =
2213 -    (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
2214 -  if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
2215 -    low |= negative_mask;
2216 -  if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
2217 -    high |= negative_mask;
2218 -
2219 -  range_type = create_range_type (NULL, base_type, low, high);
2220 -
2221 -  /* Mark arrays with dynamic length at least as an array of unspecified
2222 -     length.  GDB could check the boundary but before it gets implemented at
2223 -     least allow accessing the array elements.  */
2224 -  if (attr && attr->form == DW_FORM_block1)
2225 -    TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
2226 -
2227 -  /* Ada expects an empty array on no boundary attributes.  */
2228 -  if (attr == NULL && cu->language != language_ada)
2229 -    TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
2230 +  /* DW_AT_bit_stride is currently unsupported as we count in bytes.  */
2231 +  attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
2232 +  if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2233 +    {
2234 +      TYPE_RANGE_DATA (range_type)->byte_stride.kind
2235 +        = RANGE_BOUND_KIND_DWARF_BLOCK;
2236 +      TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block =
2237 +                                       dwarf2_attr_to_locexpr_baton (attr, cu);
2238 +      TYPE_DYNAMIC (range_type) = 1;
2239 +    }
2240 +  else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2241 +    {
2242 +      struct die_info *target_die;
2243 +      struct dwarf2_cu *target_cu = cu;
2244 +      struct attribute *target_loc_attr;
2245 +
2246 +      target_die = follow_die_ref_or_sig (die, attr, &target_cu);
2247 +      gdb_assert (target_cu->objfile == cu->objfile);
2248 +      target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
2249 +
2250 +      TYPE_RANGE_DATA (range_type)->byte_stride.kind
2251 +        = RANGE_BOUND_KIND_DWARF_LOCLIST;
2252 +      TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist
2253 +        = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
2254 +      TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type
2255 +        = die_type (target_die, target_cu);
2256 +      TYPE_DYNAMIC (range_type) = 1;
2257 +    }
2258 +  else if (attr && attr_form_is_constant (attr))
2259 +    {
2260 +      TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0);
2261 +      if (TYPE_BYTE_STRIDE (range_type) == 0)
2262 +       complaint (&symfile_complaints,
2263 +                  _("Found DW_AT_byte_stride with unsupported value 0"));
2264 +    }
2265  
2266    name = dwarf2_name (die, cu);
2267    if (name)
2268 @@ -11072,10 +11280,12 @@ var_decode_location (struct attribute *a
2269       (i.e. when the value of a register or memory location is
2270       referenced, or a thread-local block, etc.).  Then again, it might
2271       not be worthwhile.  I'm assuming that it isn't unless performance
2272 -     or memory numbers show me otherwise.  */
2273 +     or memory numbers show me otherwise.
2274 +     
2275 +     SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed.  */
2276  
2277 -  dwarf2_symbol_mark_computed (attr, sym, cu);
2278    SYMBOL_CLASS (sym) = LOC_COMPUTED;
2279 +  dwarf2_symbol_mark_computed (attr, sym, cu);
2280  
2281    if (SYMBOL_COMPUTED_OPS (sym) == &dwarf2_loclist_funcs)
2282      cu->has_loclist = 1;
2283 @@ -11116,6 +11326,8 @@ new_symbol_full (struct die_info *die, s
2284        else
2285         sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
2286        OBJSTAT (objfile, n_syms++);
2287 +      /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity.  */
2288 +      SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
2289  
2290        /* Cache this symbol's name and the name's demangled form (if any).  */
2291        SYMBOL_SET_LANGUAGE (sym, cu->language);
2292 @@ -11888,6 +12100,9 @@ read_type_die_1 (struct die_info *die, s
2293        break;
2294      }
2295  
2296 +  if (this_type)
2297 +    finalize_type (this_type);
2298 +
2299    return this_type;
2300  }
2301  
2302 @@ -14742,61 +14957,99 @@ fill_in_loclist_baton (struct dwarf2_cu 
2303    baton->base_address = cu->base_address;
2304  }
2305  
2306 -static void
2307 -dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
2308 -                            struct dwarf2_cu *cu)
2309 +/* Convert DW_BLOCK into struct dwarf2_locexpr_baton.  ATTR must be a DW_BLOCK
2310 +   attribute type.  */
2311 +
2312 +static struct dwarf2_locexpr_baton *
2313 +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
2314  {
2315 -  if (attr_form_is_section_offset (attr)
2316 -      /* ".debug_loc" may not exist at all, or the offset may be outside
2317 -        the section.  If so, fall through to the complaint in the
2318 -        other branch.  */
2319 -      && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
2320 -                                               &dwarf2_per_objfile->loc))
2321 -    {
2322 -      struct dwarf2_loclist_baton *baton;
2323 +  struct dwarf2_locexpr_baton *baton;
2324  
2325 -      baton = obstack_alloc (&cu->objfile->objfile_obstack,
2326 -                            sizeof (struct dwarf2_loclist_baton));
2327 +  gdb_assert (attr_form_is_block (attr));
2328  
2329 -      fill_in_loclist_baton (cu, baton, attr);
2330 +  baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
2331 +  baton->per_cu = cu->per_cu;
2332 +  gdb_assert (baton->per_cu);
2333  
2334 -      if (cu->base_known == 0)
2335 -       complaint (&symfile_complaints,
2336 -                  _("Location list used without "
2337 -                    "specifying the CU base address."));
2338 +  /* Note that we're just copying the block's data pointer
2339 +     here, not the actual data.  We're still pointing into the
2340 +     info_buffer for SYM's objfile; right now we never release
2341 +     that buffer, but when we do clean up properly this may
2342 +     need to change.  */
2343 +  baton->size = DW_BLOCK (attr)->size;
2344 +  baton->data = DW_BLOCK (attr)->data;
2345 +  gdb_assert (baton->size == 0 || baton->data != NULL);
2346 +
2347 +  return baton;
2348 +}
2349  
2350 +static struct dwarf2_loclist_baton *
2351 +dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu)
2352 +{
2353 +  struct dwarf2_loclist_baton *baton;
2354 +
2355 +  /* DW_AT_location of the referenced DIE may be missing if the referenced
2356 +     variable has been optimized out.  */
2357 +  if (!attr)
2358 +    return NULL;
2359 +
2360 +  dwarf2_read_section (dwarf2_per_objfile->objfile,
2361 +                      &dwarf2_per_objfile->loc);
2362 +
2363 +  if (!(attr_form_is_section_offset (attr)
2364 +       /* ".debug_loc" may not exist at all, or the offset may be outside
2365 +          the section.  If so, fall through to the complaint in the
2366 +          other branch.  */
2367 +       && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
2368 +                                                 &dwarf2_per_objfile->loc)))
2369 +    return NULL;
2370 +
2371 +  baton = obstack_alloc (&cu->objfile->objfile_obstack,
2372 +                        sizeof (struct dwarf2_loclist_baton));
2373 +
2374 +  fill_in_loclist_baton (cu, baton, attr);
2375 +
2376 +  if (cu->base_known == 0)
2377 +    complaint (&symfile_complaints,
2378 +              _("Location list used without "
2379 +                "specifying the CU base address."));
2380 +
2381 +  return baton;
2382 +}
2383 +
2384 +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content.  */
2385 +
2386 +static void
2387 +dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
2388 +                            struct dwarf2_cu *cu)
2389 +{
2390 +  struct dwarf2_loclist_baton *loclist_baton;
2391 +
2392 +  loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu);
2393 +  if (loclist_baton)
2394 +    {
2395        SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
2396 -      SYMBOL_LOCATION_BATON (sym) = baton;
2397 +      SYMBOL_LOCATION_BATON (sym) = loclist_baton;
2398 +    }
2399 +  else if (attr_form_is_block (attr))
2400 +    {
2401 +      SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
2402 +      SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
2403      }
2404    else
2405      {
2406 -      struct dwarf2_locexpr_baton *baton;
2407 +      dwarf2_invalid_attrib_class_complaint ("location description",
2408 +                                            SYMBOL_NATURAL_NAME (sym));
2409  
2410 -      baton = obstack_alloc (&cu->objfile->objfile_obstack,
2411 -                            sizeof (struct dwarf2_locexpr_baton));
2412 -      baton->per_cu = cu->per_cu;
2413 -      gdb_assert (baton->per_cu);
2414 +      /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity.  */
2415  
2416 -      if (attr_form_is_block (attr))
2417 -       {
2418 -         /* Note that we're just copying the block's data pointer
2419 -            here, not the actual data.  We're still pointing into the
2420 -            info_buffer for SYM's objfile; right now we never release
2421 -            that buffer, but when we do clean up properly this may
2422 -            need to change.  */
2423 -         baton->size = DW_BLOCK (attr)->size;
2424 -         baton->data = DW_BLOCK (attr)->data;
2425 -       }
2426 -      else
2427 -       {
2428 -         dwarf2_invalid_attrib_class_complaint ("location description",
2429 -                                                SYMBOL_NATURAL_NAME (sym));
2430 -         baton->size = 0;
2431 -         baton->data = NULL;
2432 -       }
2433 +      SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
2434 +      SYMBOL_LOCATION_BATON (sym) = NULL;
2435  
2436 -      SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
2437 -      SYMBOL_LOCATION_BATON (sym) = baton;
2438 +      /* For functions a missing DW_AT_frame_base does not optimize out the
2439 +        whole function definition, only its frame base resolving.  */
2440 +      if (attr->name == DW_AT_location)
2441 +       SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
2442      }
2443  }
2444  
2445 @@ -15145,6 +15398,25 @@ offset_and_type_eq (const void *item_lhs
2446    return ofs_lhs->offset == ofs_rhs->offset;
2447  }
2448  
2449 +/* Fill in generic attributes applicable for type DIEs.  */
2450 +
2451 +static void
2452 +fetch_die_type_attrs (struct die_info *die, struct type *type,
2453 +                     struct dwarf2_cu *cu)
2454 +{
2455 +  struct attribute *attr;
2456 +
2457 +  attr = dwarf2_attr (die, DW_AT_allocated, cu);
2458 +  if (attr_form_is_block (attr))
2459 +    TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
2460 +  gdb_assert (!TYPE_NOT_ALLOCATED (type));
2461 +
2462 +  attr = dwarf2_attr (die, DW_AT_associated, cu);
2463 +  if (attr_form_is_block (attr))
2464 +    TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
2465 +  gdb_assert (!TYPE_NOT_ASSOCIATED (type));
2466 +}
2467 +
2468  /* Set the type associated with DIE to TYPE.  Save it in CU's hash
2469     table if necessary.  For convenience, return TYPE.
2470  
2471 @@ -15170,6 +15442,8 @@ set_die_type (struct die_info *die, stru
2472    struct objfile *objfile = cu->objfile;
2473    htab_t *type_hash_ptr;
2474  
2475 +  fetch_die_type_attrs (die, type, cu);
2476 +
2477    /* For Ada types, make sure that the gnat-specific data is always
2478       initialized (if not already set).  There are a few types where
2479       we should not be doing so, because the type-specific area is
2480 Index: gdb-7.2.90.20110703/gdb/elfread.c
2481 ===================================================================
2482 --- gdb-7.2.90.20110703.orig/gdb/elfread.c      2011-05-03 18:25:20.000000000 +0200
2483 +++ gdb-7.2.90.20110703/gdb/elfread.c   2011-07-03 10:33:11.000000000 +0200
2484 @@ -43,6 +43,12 @@
2485  #include "infcall.h"
2486  #include "gdbthread.h"
2487  #include "regcache.h"
2488 +#include "stap-probe.h"
2489 +#include "arch-utils.h"
2490 +#include "value.h"
2491 +#include "infcall.h"
2492 +#include "gdbthread.h"
2493 +#include "regcache.h"
2494  
2495  extern void _initialize_elfread (void);
2496  
2497 @@ -61,6 +67,21 @@ struct elfinfo
2498      asection *mdebugsect;      /* Section pointer for .mdebug section */
2499    };
2500  
2501 +/* Per-objfile data for SystemTap probe info.  */
2502 +
2503 +static const struct objfile_data *stap_probe_key = NULL;
2504 +
2505 +/* Per-objfile data about SystemTap probes.  */
2506 +
2507 +struct stap_probe_per_objfile
2508 +  {
2509 +    /* The number of probes in this objfile.  */
2510 +    int stap_num_probes;
2511 +
2512 +    /* The probes themselves.  */
2513 +    struct stap_probe *probes;
2514 +  };
2515 +
2516  static void free_elfinfo (void *);
2517  
2518  /* Minimal symbols located at the GOT entries for .plt - that is the real
2519 @@ -1553,7 +1574,266 @@ elfstab_offset_sections (struct objfile 
2520      complaint (&symfile_complaints,
2521                _("elf/stab section information missing for %s"), filename);
2522  }
2523 +
2524 +/* Helper function that parses the information contained in a
2525 +   SystemTap's probe.  Basically, the information consists in:
2526 +
2527 +   - Probe's PC address;
2528 +   - Link-time section address of `.stapsdt.base' section;
2529 +   - Link-time address of the semaphore variable, or ZERO if the
2530 +     probe doesn't have an associated semaphore;
2531 +   - Probe's provider name;
2532 +   - Probe's name;
2533 +   - Probe's argument format.  */
2534 +
2535 +static void
2536 +handle_probe (struct objfile *objfile, struct sdt_note *el,
2537 +             struct stap_probe *ret, CORE_ADDR base)
2538 +{
2539 +  bfd *abfd = objfile->obfd;
2540 +  int size = bfd_get_arch_size (abfd) / 8;
2541 +  struct gdbarch *gdbarch = get_objfile_arch (objfile);
2542 +  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
2543 +  CORE_ADDR base_ref;
2544 +
2545 +  /* Provider and the name of the probe.  */
2546 +  ret->provider = (const char *) &el->data[3 * size];
2547 +  ret->name = memchr (ret->provider, '\0',
2548 +                     (unsigned long *) el->data
2549 +                     + el->size - (unsigned long *) ret->provider);
2550 +  /* Making sure there is a name.  */
2551 +  if (!ret->name)
2552 +    complaint (&symfile_complaints, _("corrupt probe when reading `%s'"),
2553 +              objfile->name);
2554 +  else
2555 +    ++ret->name;
2556 +
2557 +  /* Retrieving the probe's address.  */
2558 +  ret->address = extract_typed_address ((const gdb_byte *) &el->data[0],
2559 +                                       ptr_type);
2560 +  /* Link-time sh_addr of `.stapsdt.base' section.  */
2561 +  base_ref = extract_typed_address ((const gdb_byte *) &el->data[size],
2562 +                                   ptr_type);
2563 +  /* Semaphore address.  */
2564 +  ret->sem_addr = extract_typed_address ((const gdb_byte *) &el->data[2 * size],
2565 +                                        ptr_type);
2566 +
2567 +  ret->address += (ANOFFSET (objfile->section_offsets,
2568 +                            SECT_OFF_TEXT (objfile))
2569 +                  + base - base_ref);
2570 +  if (ret->sem_addr)
2571 +    ret->sem_addr += (ANOFFSET (objfile->section_offsets,
2572 +                               SECT_OFF_DATA (objfile))
2573 +                     + base - base_ref);
2574 +
2575 +  /* Arguments.  We can only extract the argument format if there is a valid
2576 +     name for this probe.  */
2577 +  if (ret->name)
2578 +    {
2579 +      ret->args = memchr (ret->name, '\0',
2580 +                         (unsigned long *) el->data
2581 +                         + el->size - (unsigned long *) ret->name);
2582 +
2583 +      if (ret->args++ != NULL
2584 +         || memchr (ret->args, '\0', (unsigned long *) el->data
2585 +                    + el->size - (unsigned long *) ret->name)
2586 +         != el->data + el->size - 1)
2587 +       complaint (&symfile_complaints, _("corrupt probe when reading `%s'"),
2588 +                  objfile->name);
2589 +    }
2590 +  else
2591 +    ret->args = NULL;
2592 +}
2593 +
2594 +/* The name of the SystemTap section where we will find information about
2595 +   the probes.  */
2596 +
2597 +#define STAP_BASE_SECTION_NAME ".stapsdt.base"
2598 +
2599 +/* Helper function which tries to find the base address of the SystemTap
2600 +   base section named STAP_BASE_SECTION_NAME.  */
2601 +
2602 +static void
2603 +get_base_address_1 (bfd *abfd, asection *sect, void *obj)
2604 +{
2605 +  bfd_vma *base = (bfd_vma *) obj;
2606 +
2607 +  if (*base == (bfd_vma) -1
2608 +      && (sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
2609 +      && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
2610 +    *base = sect->vma;
2611 +}
2612 +
2613 +/* Helper function which iterates over every section in the BFD file,
2614 +   trying to find the base address of the SystemTap base section.
2615 +   Returns the section address if found, or -1 otherwise.  */
2616 +
2617 +static bfd_vma
2618 +get_base_address (bfd *obfd)
2619 +{
2620 +  bfd_vma base = (bfd_vma) -1;
2621 +
2622 +  bfd_map_over_sections (obfd, get_base_address_1, (void *) &base);
2623 +
2624 +  return base;
2625 +}
2626 +
2627 +/* Implementation of `sym_get_probes', as documented in symfile.h.  */
2628 +
2629 +static const struct stap_probe *
2630 +elf_get_probes (struct objfile *objfile, int *num_probes)
2631 +{
2632 +  struct stap_probe *ret = NULL;
2633 +  struct stap_probe_per_objfile *probes_per_objfile;
2634 +
2635 +  /* Initially, no probes.  */
2636 +  *num_probes = 0;
2637 +
2638 +  /* Have we parsed this objfile's probes already?  */
2639 +  probes_per_objfile
2640 +    = (struct stap_probe_per_objfile *) objfile_data (objfile,
2641 +                                                     stap_probe_key);
2642 +
2643 +  if (!probes_per_objfile)
2644 +    {
2645 +      /* If we are here, then this is the first time we are parsing the
2646 +        probe's information.  We basically have to count how many probes
2647 +        the objfile has, and then fill in the necessary information
2648 +        for each one.  */
2649 +
2650 +      bfd *obfd = objfile->obfd;
2651 +      bfd_vma base = get_base_address (obfd);
2652 +      struct sdt_note *iter;
2653 +      int i;
2654 +      int n = 0;
2655 +
2656 +      if (! elf_tdata (obfd)->sdt_note_head)
2657 +       /* There isn't any probe here.  */
2658 +       return NULL;
2659 +
2660 +      /* Allocating space for probe info.  */
2661 +      for (iter = elf_tdata (obfd)->sdt_note_head;
2662 +          iter;
2663 +          iter = iter->next, ++n);
2664 +
2665 +      ret = xcalloc (n, sizeof (struct stap_probe));
2666 +
2667 +      /* Parsing each probe's information.  */
2668 +      for (iter = elf_tdata (obfd)->sdt_note_head, i = 0;
2669 +          iter;
2670 +          iter = iter->next, i++)
2671 +       /* We first have to handle all the information about the
2672 +          probe which is present in the section.  */
2673 +       handle_probe (objfile, iter, &ret[i], base);
2674 +
2675 +      /* Creating a cache for these probes in the objfile's registry.  */
2676 +      probes_per_objfile = xmalloc (sizeof (struct stap_probe_per_objfile));
2677 +
2678 +      probes_per_objfile->stap_num_probes = n;
2679 +      probes_per_objfile->probes = ret;
2680 +
2681 +      set_objfile_data (objfile, stap_probe_key, probes_per_objfile);
2682 +    }
2683 +  else
2684 +    ret = probes_per_objfile->probes;
2685 +
2686 +  *num_probes = probes_per_objfile->stap_num_probes;
2687 +
2688 +  return ret;
2689 +}
2690 +
2691 +/* Implementation of `sym_get_probe_argument_count', as documented in
2692 +   symfile.h.  */
2693 +
2694 +static int
2695 +elf_get_probe_argument_count (struct objfile *objfile,
2696 +                             const struct stap_probe *probe)
2697 +{
2698 +  const char *pargs = probe->args;
2699 +
2700 +  if (!pargs || !*pargs || *pargs == ':')
2701 +    /* No arguments.  */
2702 +    return 0;
2703 +
2704 +  return stap_get_probe_argument_count (probe);
2705 +}
2706 +
2707 +/* Implementation of `sym_evaluate_probe_argument', as documented in
2708 +   symfile.h.  */
2709 +
2710 +static struct value *
2711 +elf_evaluate_probe_argument (struct objfile *objfile,
2712 +                            const struct stap_probe *probe,
2713 +                            struct frame_info *frame,
2714 +                            int n)
2715 +{
2716 +  return stap_evaluate_probe_argument (objfile, probe, frame, n);
2717 +}
2718 +
2719 +/* Implementation of `sym_compile_to_ax', as documented in symfile.h.  */
2720 +
2721 +static void
2722 +elf_compile_to_ax (struct objfile *objfile,
2723 +                  const struct stap_probe *probe,
2724 +                  struct agent_expr *expr,
2725 +                  struct axs_value *value,
2726 +                  int n)
2727 +{
2728 +  stap_compile_to_ax (objfile, probe, expr, value, n);
2729 +}
2730 +
2731 +/* Implementation of `sym_relocate_probe', as documented in symfile.h.  */
2732 +
2733 +static void
2734 +elf_symfile_relocate_probe (struct objfile *objfile,
2735 +                           struct section_offsets *new_offsets,
2736 +                           struct section_offsets *delta)
2737 +{
2738 +  int i;
2739 +  struct stap_probe_per_objfile *p
2740 +    = (struct stap_probe_per_objfile *) objfile_data (objfile,
2741 +                                                     stap_probe_key);
2742 +
2743 +  if (!p)
2744 +    /* No probe to relocate.  */
2745 +    return;
2746 +
2747 +  for (i = 0; i < p->stap_num_probes; i++)
2748 +    {
2749 +      p->probes[i].address += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
2750 +      if (p->probes[i].sem_addr)
2751 +       p->probes[i].sem_addr += ANOFFSET (delta, SECT_OFF_DATA (objfile));
2752 +    }
2753 +}
2754 +
2755 +/* Helper function used to free the space allocated for storing SystemTap
2756 +   probe information.  */
2757 +
2758 +static void
2759 +stap_probe_key_free (struct objfile *objfile, void *d)
2760 +{
2761 +  int i;
2762 +  struct stap_probe_per_objfile *data = (struct stap_probe_per_objfile *) d;
2763 +
2764 +  for (i = 0; i < data->stap_num_probes; i++)
2765 +    stap_free_parsed_args (data->probes[i].parsed_args);
2766 +  xfree (data->probes);
2767 +  xfree (data);
2768 +}
2769 +
2770  \f
2771 +
2772 +/* Implementation `sym_probe_fns', as documented in symfile.h.  */
2773 +
2774 +static const struct sym_probe_fns elf_probe_fns =
2775 +{
2776 +  elf_get_probes,              /* sym_get_probes */
2777 +  elf_get_probe_argument_count,        /* sym_get_probe_argument_count */
2778 +  elf_evaluate_probe_argument, /* sym_evaluate_probe_argument */
2779 +  elf_compile_to_ax,           /* sym_compile_to_ax */
2780 +  elf_symfile_relocate_probe,  /* sym_relocate_probe */
2781 +};
2782 +
2783  /* Register that we are able to handle ELF object file formats.  */
2784  
2785  static const struct sym_fns elf_sym_fns =
2786 @@ -1568,6 +1848,7 @@ static const struct sym_fns elf_sym_fns 
2787    elf_symfile_segments,                /* Get segment information from a file.  */
2788    NULL,
2789    default_symfile_relocate,    /* Relocate a debug section.  */
2790 +  &elf_probe_fns,              /* sym_probe_fns */
2791    &psym_functions
2792  };
2793  
2794 @@ -1586,6 +1867,7 @@ static const struct sym_fns elf_sym_fns_
2795    elf_symfile_segments,                /* Get segment information from a file.  */
2796    NULL,
2797    default_symfile_relocate,    /* Relocate a debug section.  */
2798 +  &elf_probe_fns,              /* sym_probe_fns */
2799    &psym_functions
2800  };
2801  
2802 @@ -1603,6 +1885,7 @@ static const struct sym_fns elf_sym_fns_
2803    elf_symfile_segments,                /* Get segment information from a file.  */
2804    NULL,
2805    default_symfile_relocate,    /* Relocate a debug section.  */
2806 +  &elf_probe_fns,              /* sym_probe_fns */
2807    &dwarf2_gdb_index_functions
2808  };
2809  
2810 @@ -1619,6 +1902,8 @@ static const struct gnu_ifunc_fns elf_gn
2811  void
2812  _initialize_elfread (void)
2813  {
2814 +  stap_probe_key
2815 +    = register_objfile_data_with_cleanup (NULL, stap_probe_key_free);
2816    add_symtab_fns (&elf_sym_fns);
2817  
2818    elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
2819 Index: gdb-7.2.90.20110703/gdb/eval.c
2820 ===================================================================
2821 --- gdb-7.2.90.20110703.orig/gdb/eval.c 2011-03-28 22:21:03.000000000 +0200
2822 +++ gdb-7.2.90.20110703/gdb/eval.c      2011-07-03 10:33:11.000000000 +0200
2823 @@ -44,6 +44,7 @@
2824  #include "objfiles.h"
2825  #include "python/python.h"
2826  #include "wrapper.h"
2827 +#include "dwarf2loc.h"
2828  
2829  #include "gdb_assert.h"
2830  
2831 @@ -489,27 +490,217 @@ init_array_element (struct value *array,
2832  }
2833  
2834  static struct value *
2835 -value_f90_subarray (struct value *array,
2836 -                   struct expression *exp, int *pos, enum noside noside)
2837 +value_f90_subarray (struct value *array, struct expression *exp, int *pos,
2838 +                   int nargs, enum noside noside)
2839  {
2840 -  int pc = (*pos) + 1;
2841 -  LONGEST low_bound, high_bound;
2842 -  struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
2843 -  enum f90_range_type range_type = longest_to_int (exp->elts[pc].longconst);
2844
2845 -  *pos += 3;
2846 +  /* Type to use for the newly allocated value ARRAY.  */
2847 +  struct type *new_array_type;
2848  
2849 -  if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
2850 -    low_bound = TYPE_LOW_BOUND (range);
2851 +  /* Type being iterated for each dimension.  */
2852 +  struct type *type, *type_last_target;
2853 +
2854 +  /* Pointer in the last holder to the type of current dimension.  */
2855 +  struct type **typep = &new_array_type;
2856 +
2857 +  struct subscript_index
2858 +    {
2859 +      enum { SUBSCRIPT_RANGE, SUBSCRIPT_NUMBER } kind;
2860 +      union
2861 +       {
2862 +         struct subscript_range
2863 +           {
2864 +             enum f90_range_type f90_range_type;
2865 +             LONGEST low_bound, high_bound;
2866 +           }
2867 +         range;
2868 +         LONGEST number;
2869 +       };
2870 +    }
2871 +  *subscript_array;
2872 +  struct type **type_array;
2873 +  int i;
2874 +  struct cleanup *old_chain;
2875 +  CORE_ADDR value_byte_address, value_byte_offset = 0;
2876 +  htab_t copied_types;
2877 +  struct value *saved_array;
2878 +
2879 +  old_chain = make_cleanup (null_cleanup, 0);
2880 +  object_address_set (value_raw_address (array));
2881 +
2882 +  if (value_optimized_out (array)
2883 +      || (VALUE_LVAL (array) != not_lval
2884 +          && VALUE_LVAL (array) != lval_memory
2885 +         && VALUE_LVAL (array) != lval_internalvar_component
2886 +         && VALUE_LVAL (array) != lval_internalvar))
2887 +    error (_("value being subranged must be in memory"));
2888 +  type = check_typedef (value_type (array));
2889 +  f_object_address_data_valid_or_error (type);
2890 +
2891 +  copied_types = create_copied_types_hash (NULL);
2892 +  type = copy_type_recursive (type, copied_types);
2893 +  htab_delete (copied_types);
2894 +
2895 +  if (nargs != calc_f77_array_dims (type))
2896 +    error (_("Wrong number of subscripts"));
2897 +
2898 +  if (TYPE_DATA_LOCATION_IS_ADDR (type))
2899 +    {
2900 +      value_byte_address = (TYPE_DATA_LOCATION_ADDR (type)
2901 +                           + value_offset (array));
2902 +      TYPE_DATA_LOCATION_IS_ADDR (type) = 0;
2903 +      TYPE_DATA_LOCATION_DWARF_BLOCK (type) = NULL;
2904 +    }
2905    else
2906 -    low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
2907 +    {
2908 +      gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL);
2909 +      value_byte_address = value_address (array);
2910 +    }
2911 +
2912 +  new_array_type = type;
2913 +
2914 +  subscript_array = alloca (sizeof (*subscript_array) * nargs);
2915 +
2916 +  gdb_assert (nargs > 0);
2917 +
2918 +  /* Now that we know we have a legal array subscript expression 
2919 +     let us actually find out where this element exists in the array.  */
2920 +
2921 +  /* Take array indices left to right.  */
2922 +  for (i = 0; i < nargs; i++)
2923 +    {
2924 +      struct subscript_index *index = &subscript_array[i];
2925 +
2926 +      if (exp->elts[*pos].opcode == OP_F90_RANGE)
2927 +       {
2928 +         int pc = (*pos) + 1;
2929 +         struct subscript_range *range;
2930 +
2931 +         index->kind = SUBSCRIPT_RANGE;
2932 +         range = &index->range;
2933 +
2934 +         *pos += 3;
2935 +         range->f90_range_type = longest_to_int (exp->elts[pc].longconst);
2936 +
2937 +         if (range->f90_range_type == HIGH_BOUND_DEFAULT
2938 +             || range->f90_range_type == NONE_BOUND_DEFAULT)
2939 +           range->low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp,
2940 +                                                              pos, noside));
2941 +
2942 +         if (range->f90_range_type == LOW_BOUND_DEFAULT
2943 +             || range->f90_range_type == NONE_BOUND_DEFAULT)
2944 +           range->high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp,
2945 +                                                               pos, noside));
2946 +       }
2947 +      else
2948 +       {
2949 +         struct value *val;
2950 +
2951 +         index->kind = SUBSCRIPT_NUMBER;
2952  
2953 -  if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
2954 -    high_bound = TYPE_HIGH_BOUND (range);
2955 +         /* Evaluate each subscript; it must be a legal integer in F77.  */
2956 +         val = evaluate_subexp_with_coercion (exp, pos, noside);
2957 +         index->number = value_as_long (val);
2958 +       }
2959 +    }
2960 +
2961 +  /* Internal type of array is arranged right to left.  */
2962 +  for (i = nargs - 1; i >= 0; i--)
2963 +    {
2964 +      struct subscript_index *index = &subscript_array[i];
2965 +      struct type *range_type = TYPE_INDEX_TYPE (type);
2966 +
2967 +      switch (index->kind)
2968 +       {
2969 +       case SUBSCRIPT_RANGE:
2970 +         {
2971 +           struct subscript_range *range = &index->range;
2972 +           CORE_ADDR byte_offset;
2973 +
2974 +           if (range->f90_range_type == LOW_BOUND_DEFAULT
2975 +               || range->f90_range_type == BOTH_BOUND_DEFAULT)
2976 +             range->low_bound = TYPE_LOW_BOUND (range_type);
2977 +
2978 +           if (range->f90_range_type == HIGH_BOUND_DEFAULT
2979 +               || range->f90_range_type == BOTH_BOUND_DEFAULT)
2980 +             range->high_bound = TYPE_HIGH_BOUND (range_type);
2981 +
2982 +           if (range->low_bound < TYPE_LOW_BOUND (range_type)
2983 +               || (!TYPE_HIGH_BOUND_UNDEFINED (range_type)
2984 +                   && range->high_bound > TYPE_HIGH_BOUND (range_type)))
2985 +             error (_("slice out of range"));
2986 +
2987 +           byte_offset = ((range->low_bound - TYPE_LOW_BOUND (range_type))
2988 +                          * TYPE_ARRAY_BYTE_STRIDE_VALUE (type));
2989 +           TYPE_LOW_BOUND (range_type) = range->low_bound;
2990 +           TYPE_HIGH_BOUND (range_type) = range->high_bound;
2991 +           if (range->f90_range_type == LOW_BOUND_DEFAULT
2992 +               || range->f90_range_type == NONE_BOUND_DEFAULT)
2993 +             TYPE_HIGH_BOUND_UNDEFINED (range_type) = 0;
2994 +
2995 +           typep = &TYPE_TARGET_TYPE (type);
2996 +           value_byte_offset += byte_offset;
2997 +           type = TYPE_TARGET_TYPE (type);
2998 +         }
2999 +         break;
3000 +
3001 +       case SUBSCRIPT_NUMBER:
3002 +         {
3003 +           CORE_ADDR byte_offset;
3004 +
3005 +           if (index->number < TYPE_LOW_BOUND (range_type)
3006 +               || (!TYPE_HIGH_BOUND_UNDEFINED (range_type)
3007 +                   && index->number > TYPE_HIGH_BOUND (range_type)))
3008 +             error (_("no such vector element"));
3009 +
3010 +           byte_offset = ((index->number - TYPE_LOW_BOUND (range_type))
3011 +                          * TYPE_ARRAY_BYTE_STRIDE_VALUE (type));
3012 +
3013 +           type = TYPE_TARGET_TYPE (type);
3014 +           *typep = type;
3015 +           value_byte_offset += byte_offset;
3016 +         }
3017 +         break;
3018 +       }
3019 +    }
3020 +
3021 +  type_last_target = type;
3022 +  type_array = alloca (sizeof (*type_array) * nargs);
3023 +  i = 0;
3024 +  for (type = new_array_type; type != type_last_target;
3025 +       type = TYPE_TARGET_TYPE (type))
3026 +    type_array[i++] = type;
3027 +  while (i > 0)
3028 +    {
3029 +      struct type *type = type_array[--i];
3030 +
3031 +      /* Force TYPE_LENGTH (type) recalculation.  */
3032 +      TYPE_TARGET_STUB (type) = 1;
3033 +      check_typedef (type);
3034 +    }
3035 +
3036 +  saved_array = array;
3037 +  array = allocate_value_lazy (new_array_type);
3038 +  VALUE_LVAL (array) = VALUE_LVAL (saved_array);
3039 +  if (VALUE_LVAL (saved_array) == lval_internalvar_component)
3040 +    VALUE_LVAL (array) = lval_internalvar;
3041    else
3042 -    high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
3043 +    VALUE_LVAL (array) = VALUE_LVAL (saved_array);
3044 +  VALUE_FRAME_ID (array) = VALUE_FRAME_ID (saved_array);
3045 +  if (VALUE_LVAL (array) != lval_internalvar)
3046 +    set_value_address (array, value_byte_address + value_byte_offset);
3047  
3048 -  return value_slice (array, low_bound, high_bound - low_bound + 1);
3049 +  if (!value_lazy (saved_array))
3050 +    {
3051 +      allocate_value_contents (array);
3052 +      set_value_lazy (array, 0);
3053 +
3054 +      memcpy (value_contents_writeable (array),
3055 +             value_contents (saved_array) + value_byte_offset,
3056 +             TYPE_LENGTH (new_array_type));
3057 +    }
3058 +
3059 +  do_cleanups (old_chain);
3060 +  return array;
3061  }
3062  
3063  
3064 @@ -790,6 +981,7 @@ evaluate_subexp_standard (struct type *e
3065    int save_pos1;
3066    struct symbol *function = NULL;
3067    char *function_name = NULL;
3068 +  struct cleanup *old_chain;
3069  
3070    pc = (*pos)++;
3071    op = exp->elts[pc].opcode;
3072 @@ -1862,6 +2054,8 @@ evaluate_subexp_standard (struct type *e
3073  
3074        /* First determine the type code we are dealing with.  */
3075        arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
3076 +      old_chain = make_cleanup (null_cleanup, 0);
3077 +      object_address_set (value_raw_address (arg1));
3078        type = check_typedef (value_type (arg1));
3079        code = TYPE_CODE (type);
3080  
3081 @@ -1882,23 +2076,13 @@ evaluate_subexp_standard (struct type *e
3082               code = TYPE_CODE (type);
3083             }
3084         } 
3085 +      do_cleanups (old_chain);
3086  
3087        switch (code)
3088         {
3089         case TYPE_CODE_ARRAY:
3090 -         if (exp->elts[*pos].opcode == OP_F90_RANGE)
3091 -           return value_f90_subarray (arg1, exp, pos, noside);
3092 -         else
3093 -           goto multi_f77_subscript;
3094 -
3095         case TYPE_CODE_STRING:
3096 -         if (exp->elts[*pos].opcode == OP_F90_RANGE)
3097 -           return value_f90_subarray (arg1, exp, pos, noside);
3098 -         else
3099 -           {
3100 -             arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
3101 -             return value_subscript (arg1, value_as_long (arg2));
3102 -           }
3103 +         return value_f90_subarray (arg1, exp, pos, nargs, noside);
3104  
3105         case TYPE_CODE_PTR:
3106         case TYPE_CODE_FUNC:
3107 @@ -2337,49 +2521,6 @@ evaluate_subexp_standard (struct type *e
3108         }
3109        return (arg1);
3110  
3111 -    multi_f77_subscript:
3112 -      {
3113 -       LONGEST subscript_array[MAX_FORTRAN_DIMS];
3114 -       int ndimensions = 1, i;
3115 -       struct value *array = arg1;
3116 -
3117 -       if (nargs > MAX_FORTRAN_DIMS)
3118 -         error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
3119 -
3120 -       ndimensions = calc_f77_array_dims (type);
3121 -
3122 -       if (nargs != ndimensions)
3123 -         error (_("Wrong number of subscripts"));
3124 -
3125 -       gdb_assert (nargs > 0);
3126 -
3127 -       /* Now that we know we have a legal array subscript expression 
3128 -          let us actually find out where this element exists in the array.  */
3129 -
3130 -       /* Take array indices left to right.  */
3131 -       for (i = 0; i < nargs; i++)
3132 -         {
3133 -           /* Evaluate each subscript; it must be a legal integer in F77.  */
3134 -           arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
3135 -
3136 -           /* Fill in the subscript array.  */
3137 -
3138 -           subscript_array[i] = value_as_long (arg2);
3139 -         }
3140 -
3141 -       /* Internal type of array is arranged right to left.  */
3142 -       for (i = nargs; i > 0; i--)
3143 -         {
3144 -           struct type *array_type = check_typedef (value_type (array));
3145 -           LONGEST index = subscript_array[i - 1];
3146 -
3147 -           lower = f77_get_lowerbound (array_type);
3148 -           array = value_subscripted_rvalue (array, index, lower);
3149 -         }
3150 -
3151 -       return array;
3152 -      }
3153 -
3154      case BINOP_LOGICAL_AND:
3155        arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
3156        if (noside == EVAL_SKIP)
3157 @@ -2611,15 +2752,23 @@ evaluate_subexp_standard (struct type *e
3158        if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
3159         expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type));
3160        arg1 = evaluate_subexp (expect_type, exp, pos, noside);
3161 +      old_chain = make_cleanup (null_cleanup, 0);
3162 +      object_address_set (value_raw_address (arg1));
3163        type = check_typedef (value_type (arg1));
3164        if (TYPE_CODE (type) == TYPE_CODE_METHODPTR
3165           || TYPE_CODE (type) == TYPE_CODE_MEMBERPTR)
3166         error (_("Attempt to dereference pointer "
3167                  "to member without an object"));
3168        if (noside == EVAL_SKIP)
3169 -       goto nosideret;
3170 +       {
3171 +         do_cleanups (old_chain);
3172 +         goto nosideret;
3173 +       }
3174        if (unop_user_defined_p (op, arg1))
3175 -       return value_x_unop (arg1, op, noside);
3176 +       {
3177 +         do_cleanups (old_chain);
3178 +         return value_x_unop (arg1, op, noside);
3179 +       }
3180        else if (noside == EVAL_AVOID_SIDE_EFFECTS)
3181         {
3182           type = check_typedef (value_type (arg1));
3183 @@ -2628,12 +2777,18 @@ evaluate_subexp_standard (struct type *e
3184           /* In C you can dereference an array to get the 1st elt.  */
3185               || TYPE_CODE (type) == TYPE_CODE_ARRAY
3186             )
3187 -           return value_zero (TYPE_TARGET_TYPE (type),
3188 -                              lval_memory);
3189 +           {
3190 +             do_cleanups (old_chain);
3191 +             return value_zero (TYPE_TARGET_TYPE (type),
3192 +                                lval_memory);
3193 +           }
3194           else if (TYPE_CODE (type) == TYPE_CODE_INT)
3195 -           /* GDB allows dereferencing an int.  */
3196 -           return value_zero (builtin_type (exp->gdbarch)->builtin_int,
3197 -                              lval_memory);
3198 +           {
3199 +             do_cleanups (old_chain);
3200 +             /* GDB allows dereferencing an int.  */
3201 +             return value_zero (builtin_type (exp->gdbarch)->builtin_int,
3202 +                                lval_memory);
3203 +           }
3204           else
3205             error (_("Attempt to take contents of a non-pointer value."));
3206         }
3207 @@ -2643,9 +2798,14 @@ evaluate_subexp_standard (struct type *e
3208          do.  "long long" variables are rare enough that
3209          BUILTIN_TYPE_LONGEST would seem to be a mistake.  */
3210        if (TYPE_CODE (type) == TYPE_CODE_INT)
3211 -       return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
3212 -                             (CORE_ADDR) value_as_address (arg1));
3213 -      return value_ind (arg1);
3214 +       {
3215 +         do_cleanups (old_chain);
3216 +         return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
3217 +                               (CORE_ADDR) value_as_address (arg1));
3218 +       }
3219 +      arg1 = value_ind (arg1);
3220 +      do_cleanups (old_chain);
3221 +      return arg1;
3222  
3223      case UNOP_ADDR:
3224        /* C++: check for and handle pointer to members.  */
3225 @@ -2991,7 +3151,7 @@ evaluate_subexp_with_coercion (struct ex
3226  {
3227    enum exp_opcode op;
3228    int pc;
3229 -  struct value *val;
3230 +  struct value *val = NULL;
3231    struct symbol *var;
3232    struct type *type;
3233  
3234 @@ -3002,13 +3162,18 @@ evaluate_subexp_with_coercion (struct ex
3235      {
3236      case OP_VAR_VALUE:
3237        var = exp->elts[pc + 2].symbol;
3238 +      /* address_of_variable will call object_address_set for check_typedef.
3239 +        Call it only if required as it can error-out on VAR in register.  */
3240 +      if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
3241 +       val = address_of_variable (var, exp->elts[pc + 1].block);
3242        type = check_typedef (SYMBOL_TYPE (var));
3243        if (TYPE_CODE (type) == TYPE_CODE_ARRAY
3244           && !TYPE_VECTOR (type)
3245           && CAST_IS_CONVERSION (exp->language_defn))
3246         {
3247           (*pos) += 4;
3248 -         val = address_of_variable (var, exp->elts[pc + 1].block);
3249 +         if (!val)
3250 +           val = address_of_variable (var, exp->elts[pc + 1].block);
3251           return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
3252                              val);
3253         }
3254 @@ -3060,9 +3225,13 @@ evaluate_subexp_for_sizeof (struct expre
3255  
3256      case OP_VAR_VALUE:
3257        (*pos) += 4;
3258 -      type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
3259 -      return
3260 -       value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
3261 +      /* We do not need to call read_var_value but the object evaluation may
3262 +        need to have executed object_address_set which needs valid
3263 +        SYMBOL_VALUE_ADDRESS of the symbol.  Still VALUE returned by
3264 +        read_var_value we left as lazy.  */
3265 +      type = value_type (read_var_value (exp->elts[pc + 2].symbol,
3266 +                                       deprecated_safe_get_selected_frame ()));
3267 +      return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
3268  
3269      default:
3270        val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
3271 @@ -3093,18 +3262,25 @@ parse_and_eval_type (char *p, int length
3272  int
3273  calc_f77_array_dims (struct type *array_type)
3274  {
3275 -  int ndimen = 1;
3276 -  struct type *tmp_type;
3277 +  switch (TYPE_CODE (array_type))
3278 +    {
3279 +    case TYPE_CODE_STRING:
3280 +      return 1;
3281  
3282 -  if ((TYPE_CODE (array_type) != TYPE_CODE_ARRAY))
3283 -    error (_("Can't get dimensions for a non-array type"));
3284 +    case TYPE_CODE_ARRAY:
3285 +      {
3286 +       int ndimen = 1;
3287  
3288 -  tmp_type = array_type;
3289 +       while ((array_type = TYPE_TARGET_TYPE (array_type)))
3290 +         {
3291 +           if (TYPE_CODE (array_type) == TYPE_CODE_ARRAY)
3292 +             ++ndimen;
3293 +         }
3294 +       return ndimen;
3295 +      }
3296  
3297 -  while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
3298 -    {
3299 -      if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
3300 -       ++ndimen;
3301 +    default:
3302 +      error (_("Can't get dimensions for a non-array/non-string type"));
3303      }
3304 -  return ndimen;
3305 +
3306  }
3307 Index: gdb-7.2.90.20110703/gdb/f-exp.y
3308 ===================================================================
3309 --- gdb-7.2.90.20110703.orig/gdb/f-exp.y        2011-03-18 14:51:41.000000000 +0100
3310 +++ gdb-7.2.90.20110703/gdb/f-exp.y     2011-07-03 10:33:11.000000000 +0200
3311 @@ -293,7 +293,9 @@ arglist :   subrange
3312                         { arglist_len = 1; }
3313         ;
3314     
3315 -arglist        :       arglist ',' exp   %prec ABOVE_COMMA
3316 +arglist        :       arglist ',' exp       %prec ABOVE_COMMA
3317 +                       { arglist_len++; }
3318 +       |       arglist ',' subrange  %prec ABOVE_COMMA
3319                         { arglist_len++; }
3320         ;
3321  
3322 Index: gdb-7.2.90.20110703/gdb/f-lang.h
3323 ===================================================================
3324 --- gdb-7.2.90.20110703.orig/gdb/f-lang.h       2011-01-07 20:36:16.000000000 +0100
3325 +++ gdb-7.2.90.20110703/gdb/f-lang.h    2011-07-03 10:33:11.000000000 +0200
3326 @@ -28,6 +28,10 @@ extern void f_error (char *);        /* Defined
3327  extern void f_print_type (struct type *, const char *, struct ui_file *, int,
3328                           int);
3329  
3330 +extern const char *f_object_address_data_valid_print_to_stream
3331 +  (struct type *type, struct ui_file *stream);
3332 +extern void f_object_address_data_valid_or_error (struct type *type);
3333 +
3334  extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
3335                         struct ui_file *, int,
3336                         const struct value *,
3337 Index: gdb-7.2.90.20110703/gdb/f-typeprint.c
3338 ===================================================================
3339 --- gdb-7.2.90.20110703.orig/gdb/f-typeprint.c  2011-01-07 20:36:16.000000000 +0100
3340 +++ gdb-7.2.90.20110703/gdb/f-typeprint.c       2011-07-03 10:33:11.000000000 +0200
3341 @@ -32,7 +32,7 @@
3342  #include "gdbcore.h"
3343  #include "target.h"
3344  #include "f-lang.h"
3345 -
3346 +#include "dwarf2loc.h"
3347  #include "gdb_string.h"
3348  #include <errno.h>
3349  
3350 @@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct
3351  void f_type_print_base (struct type *, struct ui_file *, int, int);
3352  \f
3353  
3354 +const char *
3355 +f_object_address_data_valid_print_to_stream (struct type *type,
3356 +                                            struct ui_file *stream)
3357 +{
3358 +  const char *msg;
3359 +
3360 +  msg = object_address_data_not_valid (type);
3361 +  if (msg != NULL)
3362 +    {
3363 +      /* Assuming the content printed to STREAM should not be localized.  */
3364 +      fprintf_filtered (stream, "<%s>", msg);
3365 +    }
3366 +
3367 +  return msg;
3368 +}
3369 +
3370 +void
3371 +f_object_address_data_valid_or_error (struct type *type)
3372 +{
3373 +  const char *msg;
3374 +
3375 +  msg = object_address_data_not_valid (type);
3376 +  if (msg != NULL)
3377 +    {
3378 +      error (_("Cannot access it because the %s."), _(msg));
3379 +    }
3380 +}
3381 +
3382  /* LEVEL is the depth to indent lines by.  */
3383  
3384  void
3385 @@ -58,6 +86,9 @@ f_print_type (struct type *type, const c
3386    enum type_code code;
3387    int demangled_args;
3388  
3389 +  if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
3390 +    return;
3391 +
3392    f_type_print_base (type, stream, show, level);
3393    code = TYPE_CODE (type);
3394    if ((varstring != NULL && *varstring != '\0')
3395 @@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type
3396  
3397    QUIT;
3398  
3399 +  if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
3400 +    CHECK_TYPEDEF (type);
3401 +
3402    switch (TYPE_CODE (type))
3403      {
3404      case TYPE_CODE_ARRAY:
3405 Index: gdb-7.2.90.20110703/gdb/f-valprint.c
3406 ===================================================================
3407 --- gdb-7.2.90.20110703.orig/gdb/f-valprint.c   2011-02-07 18:49:32.000000000 +0100
3408 +++ gdb-7.2.90.20110703/gdb/f-valprint.c        2011-07-03 10:33:11.000000000 +0200
3409 @@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM
3410  /* The following macro gives us the size of the nth dimension, Where 
3411     n is 1 based.  */
3412  
3413 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
3414 +#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
3415  
3416 -/* The following gives us the offset for row n where n is 1-based.  */
3417 +/* The following gives us the element size for row n where n is 1-based.  */
3418  
3419 -#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
3420 +#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
3421  
3422  int
3423  f77_get_lowerbound (struct type *type)
3424  {
3425 +  f_object_address_data_valid_or_error (type);
3426 +
3427    if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
3428      error (_("Lower bound may not be '*' in F77"));
3429  
3430 @@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type)
3431  int
3432  f77_get_upperbound (struct type *type)
3433  {
3434 +  f_object_address_data_valid_or_error (type);
3435 +
3436    if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
3437      {
3438 -      /* We have an assumed size array on our hands.  Assume that
3439 -        upper_bound == lower_bound so that we show at least 1 element.
3440 -        If the user wants to see more elements, let him manually ask for 'em
3441 -        and we'll subscript the array and show him.  */
3442 +      /* We have an assumed size array on our hands.  As type_length_get
3443 +        already assumes a length zero of arrays with underfined bounds VALADDR
3444 +        passed to the Fortran functions does not contained the real inferior
3445 +        memory content.  User should request printing of specific array
3446 +        elements instead.  */
3447  
3448 -      return f77_get_lowerbound (type);
3449 +      return f77_get_lowerbound (type) - 1;
3450      }
3451  
3452    return TYPE_ARRAY_UPPER_BOUND_VALUE (type);
3453 @@ -135,24 +140,29 @@ f77_create_arrayprint_offset_tbl (struct
3454        upper = f77_get_upperbound (tmp_type);
3455        lower = f77_get_lowerbound (tmp_type);
3456  
3457 -      F77_DIM_SIZE (ndimen) = upper - lower + 1;
3458 +      F77_DIM_COUNT (ndimen) = upper - lower + 1;
3459 +
3460 +      F77_DIM_BYTE_STRIDE (ndimen) =
3461 +        TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
3462  
3463        tmp_type = TYPE_TARGET_TYPE (tmp_type);
3464        ndimen++;
3465      }
3466  
3467 -  /* Now we multiply eltlen by all the offsets, so that later we 
3468 +  /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we
3469       can print out array elements correctly.  Up till now we 
3470 -     know an offset to apply to get the item but we also 
3471 +     know an eltlen to apply to get the item but we also 
3472       have to know how much to add to get to the next item.  */
3473  
3474    ndimen--;
3475    eltlen = TYPE_LENGTH (tmp_type);
3476 -  F77_DIM_OFFSET (ndimen) = eltlen;
3477 +  if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
3478 +    F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
3479    while (--ndimen > 0)
3480      {
3481 -      eltlen *= F77_DIM_SIZE (ndimen + 1);
3482 -      F77_DIM_OFFSET (ndimen) = eltlen;
3483 +      eltlen *= F77_DIM_COUNT (ndimen + 1);
3484 +      if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
3485 +       F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
3486      }
3487  }
3488  
3489 @@ -174,37 +184,35 @@ f77_print_array_1 (int nss, int ndimensi
3490  
3491    if (nss != ndimensions)
3492      {
3493 -      for (i = 0;
3494 -          (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
3495 -          i++)
3496 +      for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++)
3497         {
3498           fprintf_filtered (stream, "( ");
3499           f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
3500                              valaddr,
3501 -                            embedded_offset + i * F77_DIM_OFFSET (nss),
3502 +                            embedded_offset + i * F77_DIM_BYTE_STRIDE (nss),
3503                              address,
3504                              stream, recurse, val, options, elts);
3505           fprintf_filtered (stream, ") ");
3506         }
3507 -      if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) 
3508 +      if (*elts >= options->print_max && i < F77_DIM_COUNT (nss))
3509         fprintf_filtered (stream, "...");
3510      }
3511    else
3512      {
3513 -      for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
3514 +      for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max;
3515            i++, (*elts)++)
3516         {
3517           val_print (TYPE_TARGET_TYPE (type),
3518                      valaddr,
3519 -                    embedded_offset + i * F77_DIM_OFFSET (ndimensions),
3520 +                    embedded_offset + i * F77_DIM_BYTE_STRIDE (ndimensions),
3521                      address, stream, recurse,
3522                      val, options, current_language);
3523  
3524 -         if (i != (F77_DIM_SIZE (nss) - 1))
3525 +         if (i != (F77_DIM_COUNT (nss) - 1))
3526             fprintf_filtered (stream, ", ");
3527  
3528           if ((*elts == options->print_max - 1)
3529 -             && (i != (F77_DIM_SIZE (nss) - 1)))
3530 +             && (i != (F77_DIM_COUNT (nss) - 1)))
3531             fprintf_filtered (stream, "...");
3532         }
3533      }
3534 @@ -260,6 +268,9 @@ f_val_print (struct type *type, const gd
3535    CORE_ADDR addr;
3536    int index;
3537  
3538 +  if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
3539 +    return 0;
3540 +
3541    CHECK_TYPEDEF (type);
3542    switch (TYPE_CODE (type))
3543      {
3544 Index: gdb-7.2.90.20110703/gdb/findvar.c
3545 ===================================================================
3546 --- gdb-7.2.90.20110703.orig/gdb/findvar.c      2011-03-18 19:42:41.000000000 +0100
3547 +++ gdb-7.2.90.20110703/gdb/findvar.c   2011-07-03 10:33:11.000000000 +0200
3548 @@ -35,6 +35,7 @@
3549  #include "user-regs.h"
3550  #include "block.h"
3551  #include "objfiles.h"
3552 +#include "dwarf2loc.h"
3553  
3554  /* Basic byte-swapping routines.  All 'extract' functions return a
3555     host-format integer from a target-format integer at ADDR which is
3556 @@ -408,8 +409,11 @@ symbol_read_needs_frame (struct symbol *
3557  
3558  /* Given a struct symbol for a variable,
3559     and a stack frame id, read the value of the variable
3560 -   and return a (pointer to a) struct value containing the value.
3561 -   If the variable cannot be found, return a zero pointer.  */
3562 +   and return a (pointer to a) struct value containing the value. 
3563 +   If the variable cannot be found, return a zero pointer.
3564 +   We have to first find the address of the variable before allocating struct
3565 +   value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly
3566 +   used by its type.  */
3567  
3568  struct value *
3569  read_var_value (struct symbol *var, struct frame_info *frame)
3570 @@ -417,16 +421,6 @@ read_var_value (struct symbol *var, stru
3571    struct value *v;
3572    struct type *type = SYMBOL_TYPE (var);
3573    CORE_ADDR addr;
3574 -  int len;
3575 -
3576 -  /* Call check_typedef on our type to make sure that, if TYPE is
3577 -     a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
3578 -     instead of zero.  However, we do not replace the typedef type by the
3579 -     target type, because we want to keep the typedef in order to be able to
3580 -     set the returned value type description correctly.  */
3581 -  check_typedef (type);
3582 -
3583 -  len = TYPE_LENGTH (type);
3584  
3585    if (symbol_read_needs_frame (var))
3586      gdb_assert (frame);
3587 @@ -436,7 +430,7 @@ read_var_value (struct symbol *var, stru
3588      case LOC_CONST:
3589        /* Put the constant back in target format.  */
3590        v = allocate_value (type);
3591 -      store_signed_integer (value_contents_raw (v), len,
3592 +      store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
3593                             gdbarch_byte_order (get_type_arch (type)),
3594                             (LONGEST) SYMBOL_VALUE (var));
3595        VALUE_LVAL (v) = not_lval;
3596 @@ -461,12 +455,12 @@ read_var_value (struct symbol *var, stru
3597  
3598      case LOC_CONST_BYTES:
3599        v = allocate_value (type);
3600 -      memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len);
3601 +      memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
3602 +             TYPE_LENGTH (type));
3603        VALUE_LVAL (v) = not_lval;
3604        return v;
3605  
3606      case LOC_STATIC:
3607 -      v = allocate_value_lazy (type);
3608        if (overlay_debugging)
3609         addr = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
3610                                          SYMBOL_OBJ_SECTION (var));
3611 @@ -479,7 +473,6 @@ read_var_value (struct symbol *var, stru
3612        if (!addr)
3613         return 0;
3614        addr += SYMBOL_VALUE (var);
3615 -      v = allocate_value_lazy (type);
3616        break;
3617  
3618      case LOC_REF_ARG:
3619 @@ -493,14 +486,12 @@ read_var_value (struct symbol *var, stru
3620         argref += SYMBOL_VALUE (var);
3621         ref = value_at (lookup_pointer_type (type), argref);
3622         addr = value_as_address (ref);
3623 -       v = allocate_value_lazy (type);
3624         break;
3625        }
3626  
3627      case LOC_LOCAL:
3628        addr = get_frame_locals_address (frame);
3629        addr += SYMBOL_VALUE (var);
3630 -      v = allocate_value_lazy (type);
3631        break;
3632  
3633      case LOC_TYPEDEF:
3634 @@ -508,7 +499,6 @@ read_var_value (struct symbol *var, stru
3635        break;
3636  
3637      case LOC_BLOCK:
3638 -      v = allocate_value_lazy (type);
3639        if (overlay_debugging)
3640         addr = symbol_overlayed_address
3641           (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
3642 @@ -533,7 +523,6 @@ read_var_value (struct symbol *var, stru
3643               error (_("Value of register variable not available."));
3644  
3645             addr = value_as_address (regval);
3646 -           v = allocate_value_lazy (type);
3647           }
3648         else
3649           {
3650 @@ -572,7 +561,6 @@ read_var_value (struct symbol *var, stru
3651         if (obj_section
3652             && (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
3653           addr = target_translate_tls_address (obj_section->objfile, addr);
3654 -       v = allocate_value_lazy (type);
3655        }
3656        break;
3657  
3658 @@ -587,6 +575,10 @@ read_var_value (struct symbol *var, stru
3659        break;
3660      }
3661  
3662 +  /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
3663 +     DW_OP_PUSH_OBJECT_ADDRESS.  */
3664 +  object_address_set (addr);
3665 +  v = allocate_value_lazy (type);
3666    VALUE_LVAL (v) = lval_memory;
3667    set_value_address (v, addr);
3668    return v;
3669 @@ -626,11 +618,12 @@ struct value *
3670  value_from_register (struct type *type, int regnum, struct frame_info *frame)
3671  {
3672    struct gdbarch *gdbarch = get_frame_arch (frame);
3673 -  struct type *type1 = check_typedef (type);
3674    struct value *v;
3675    int optim, unavail, ok;
3676  
3677 -  if (gdbarch_convert_register_p (gdbarch, regnum, type1))
3678 +  type = check_typedef (type);
3679 +
3680 +  if (gdbarch_convert_register_p (gdbarch, regnum, type))
3681      {
3682        /* The ISA/ABI need to something weird when obtaining the
3683           specified value from this register.  It might need to
3684 @@ -643,7 +636,7 @@ value_from_register (struct type *type, 
3685        VALUE_LVAL (v) = lval_register;
3686        VALUE_FRAME_ID (v) = get_frame_id (frame);
3687        VALUE_REGNUM (v) = regnum;
3688 -      ok = gdbarch_register_to_value (gdbarch, frame, regnum, type1,
3689 +      ok = gdbarch_register_to_value (gdbarch, frame, regnum, type,
3690                                       value_contents_raw (v), &optim,
3691                                       &unavail);
3692      }
3693 Index: gdb-7.2.90.20110703/gdb/gdbinit.in
3694 ===================================================================
3695 --- gdb-7.2.90.20110703.orig/gdb/gdbinit.in     2009-10-05 15:46:52.000000000 +0200
3696 +++ gdb-7.2.90.20110703/gdb/gdbinit.in  2011-07-03 10:33:11.000000000 +0200
3697 @@ -1,5 +1,15 @@
3698  echo Setting up the environment for debugging gdb.\n
3699  
3700 +# Set up the Python library and "require" command.
3701 +python
3702 +from os.path import abspath
3703 +gdb.datadir = abspath ('@srcdir@/python/lib')
3704 +gdb.pythonlibdir = gdb.datadir
3705 +gdb.__path__ = [gdb.datadir + '/gdb']
3706 +sys.path.insert(0, gdb.datadir)
3707 +end
3708 +source @srcdir@/python/lib/gdb/__init__.py
3709 +
3710  set complaints 1
3711  
3712  b internal_error
3713 Index: gdb-7.2.90.20110703/gdb/gdbtypes.c
3714 ===================================================================
3715 --- gdb-7.2.90.20110703.orig/gdb/gdbtypes.c     2011-03-28 22:21:03.000000000 +0200
3716 +++ gdb-7.2.90.20110703/gdb/gdbtypes.c  2011-07-03 10:33:11.000000000 +0200
3717 @@ -39,6 +39,9 @@
3718  #include "cp-abi.h"
3719  #include "gdb_assert.h"
3720  #include "hashtab.h"
3721 +#include "observer.h"
3722 +#include "dwarf2expr.h"
3723 +#include "dwarf2loc.h"
3724  
3725  
3726  /* Initialize BADNESS constants.  */
3727 @@ -144,7 +147,16 @@ static void print_bit_vector (B_TYPE *, 
3728  static void print_arg_types (struct field *, int, int);
3729  static void dump_fn_fieldlists (struct type *, int);
3730  static void print_cplus_stuff (struct type *, int);
3731 +static LONGEST type_length_get (struct type *type, struct type *target_type,
3732 +                               int full_span);
3733  
3734 +#if 0
3735 +/* The hash table holding all discardable `struct type *' references.  */
3736 +static htab_t type_discardable_table;
3737 +
3738 +/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE.  */
3739 +static int type_discardable_age_current;
3740 +#endif
3741  
3742  /* Allocate a new OBJFILE-associated type structure and fill it
3743     with some defaults.  Space for the type structure is allocated
3744 @@ -175,6 +187,43 @@ alloc_type (struct objfile *objfile)
3745    return type;
3746  }
3747  
3748 +#if 0
3749 +/* Declare TYPE as discardable on next garbage collection by free_all_types.
3750 +   You must call type_mark_used during each free_all_types to protect TYPE from
3751 +   being deallocated.  */
3752 +
3753 +static void
3754 +set_type_as_discardable (struct type *type)
3755 +{
3756 +  void **slot;
3757 +
3758 +  gdb_assert (!TYPE_DISCARDABLE (type));
3759 +
3760 +  TYPE_DISCARDABLE (type) = 1;
3761 +  TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
3762 +
3763 +  slot = htab_find_slot (type_discardable_table, type, INSERT);
3764 +  gdb_assert (!*slot);
3765 +  *slot = type;
3766 +}
3767 +#endif
3768 +
3769 +/* Allocate a new type like alloc_type but preserve for it the discardability
3770 +   state of PARENT_TYPE.  */
3771 +
3772 +static struct type *
3773 +alloc_type_as_parent (struct type *parent_type)
3774 +{
3775 +  struct type *new_type = alloc_type_copy (parent_type);
3776 +
3777 +#if 0
3778 +  if (TYPE_DISCARDABLE (parent_type))
3779 +    set_type_as_discardable (new_type);
3780 +#endif
3781 +
3782 +  return new_type;
3783 +}
3784 +
3785  /* Allocate a new GDBARCH-associated type structure and fill it
3786     with some defaults.  Space for the type structure is allocated
3787     on the heap.  */
3788 @@ -300,7 +349,7 @@ make_pointer_type (struct type *type, st
3789  
3790    if (typeptr == 0 || *typeptr == 0)   /* We'll need to allocate one.  */
3791      {
3792 -      ntype = alloc_type_copy (type);
3793 +      ntype = alloc_type_as_parent (type);
3794        if (typeptr)
3795         *typeptr = ntype;
3796      }
3797 @@ -377,7 +426,7 @@ make_reference_type (struct type *type, 
3798  
3799    if (typeptr == 0 || *typeptr == 0)   /* We'll need to allocate one.  */
3800      {
3801 -      ntype = alloc_type_copy (type);
3802 +      ntype = alloc_type_as_parent (type);
3803        if (typeptr)
3804         *typeptr = ntype;
3805      }
3806 @@ -748,6 +797,7 @@ create_range_type (struct type *result_t
3807      TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
3808    TYPE_LOW_BOUND (result_type) = low_bound;
3809    TYPE_HIGH_BOUND (result_type) = high_bound;
3810 +  TYPE_BYTE_STRIDE (result_type) = 0;
3811  
3812    if (low_bound >= 0)
3813      TYPE_UNSIGNED (result_type) = 1;
3814 @@ -891,26 +941,31 @@ create_array_type (struct type *result_t
3815  
3816    TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
3817    TYPE_TARGET_TYPE (result_type) = element_type;
3818 -  if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
3819 -    low_bound = high_bound = 0;
3820 -  CHECK_TYPEDEF (element_type);
3821 -  /* Be careful when setting the array length.  Ada arrays can be
3822 -     empty arrays with the high_bound being smaller than the low_bound.
3823 -     In such cases, the array length should be zero.  */
3824 -  if (high_bound < low_bound)
3825 -    TYPE_LENGTH (result_type) = 0;
3826 -  else
3827 -    TYPE_LENGTH (result_type) =
3828 -      TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
3829    TYPE_NFIELDS (result_type) = 1;
3830    TYPE_FIELDS (result_type) =
3831      (struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
3832    TYPE_INDEX_TYPE (result_type) = range_type;
3833    TYPE_VPTR_FIELDNO (result_type) = -1;
3834  
3835 -  /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays.  */
3836 +  /* DWARF blocks may depend on runtime information like
3837 +     DW_OP_PUSH_OBJECT_ADDRESS not being available during the
3838 +     CREATE_ARRAY_TYPE time.  */
3839 +  if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT
3840 +      || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT
3841 +      || TYPE_DYNAMIC (element_type))
3842 +    TYPE_LENGTH (result_type) = 0;
3843 +  else
3844 +    {
3845 +      CHECK_TYPEDEF (element_type);
3846 +      TYPE_LENGTH (result_type) = type_length_get (result_type, element_type,
3847 +                                                  0);
3848 +    }
3849    if (TYPE_LENGTH (result_type) == 0)
3850 -    TYPE_TARGET_STUB (result_type) = 1;
3851 +    {
3852 +      /* The real size will be computed for specific instances by
3853 +        CHECK_TYPEDEF.  */
3854 +      TYPE_TARGET_STUB (result_type) = 1;
3855 +    }
3856  
3857    return result_type;
3858  }
3859 @@ -1413,6 +1468,105 @@ stub_noname_complaint (void)
3860    complaint (&symfile_complaints, _("stub type has NULL name"));
3861  }
3862  
3863 +/* Calculate the memory length of array TYPE.
3864 +
3865 +   TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as
3866 +   a performance hint.  Feel free to pass NULL.  Set FULL_SPAN to return the
3867 +   size incl. the possible padding of the last element - it may differ from the
3868 +   cleared FULL_SPAN return value (the expected SIZEOF) for non-zero
3869 +   TYPE_BYTE_STRIDE values.  */
3870 +
3871 +static LONGEST
3872 +type_length_get (struct type *type, struct type *target_type, int full_span)
3873 +{
3874 +  struct type *range_type;
3875 +  LONGEST byte_stride = 0;     /* `= 0' for a false GCC warning.  */
3876 +  LONGEST count, element_size, retval;
3877 +
3878 +  if (TYPE_CODE (type) != TYPE_CODE_ARRAY
3879 +      && TYPE_CODE (type) != TYPE_CODE_STRING)
3880 +    return TYPE_LENGTH (type);
3881 +
3882 +  /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
3883 +     Fortran arrays.  The allocated data will never be used so they can be
3884 +     zero-length.  */
3885 +  if (object_address_data_not_valid (type))
3886 +    return 0;
3887 +
3888 +  range_type = TYPE_INDEX_TYPE (type);
3889 +  if (TYPE_LOW_BOUND_UNDEFINED (range_type)
3890 +      || TYPE_HIGH_BOUND_UNDEFINED (range_type))
3891 +    return 0;
3892 +  count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
3893 +  /* It may happen for wrong DWARF annotations returning garbage data.  */
3894 +  if (count < 0)
3895 +    warning (_("Range for type %s has invalid bounds %s..%s"),
3896 +            TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
3897 +            plongest (TYPE_HIGH_BOUND (range_type)));
3898 +  /* The code below does not handle count == 0 right.  */
3899 +  if (count <= 0)
3900 +    return 0;
3901 +  if (full_span || count > 1)
3902 +    {
3903 +      /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to
3904 +         force FULL_SPAN to 1.  */
3905 +      byte_stride = TYPE_BYTE_STRIDE (range_type);
3906 +      if (byte_stride == 0)
3907 +        {
3908 +         if (target_type == NULL)
3909 +           target_type = check_typedef (TYPE_TARGET_TYPE (type));
3910 +         byte_stride = type_length_get (target_type, NULL, 1);
3911 +       }
3912 +    }
3913 +
3914 +  /* For now, we conservatively take the array length to be 0 if its length
3915 +     exceeds UINT_MAX.  The code below assumes that for x < 0,
3916 +     (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed
3917 +     by C, but is usually true (because it would be true if x were unsigned
3918 +     with its high-order bit on). It uses the fact that high_bound-low_bound is
3919 +     always representable in ULONGEST and that if high_bound-low_bound+1
3920 +     overflows, it overflows to 0.  We must change these tests if we decide to
3921 +     increase the representation of TYPE_LENGTH from unsigned int to ULONGEST.
3922 +     */
3923 +
3924 +  if (full_span)
3925 +    {
3926 +      retval = count * byte_stride;
3927 +      if (count == 0 || retval / count != byte_stride || retval > UINT_MAX)
3928 +       retval = 0;
3929 +      return retval;
3930 +    }
3931 +  if (target_type == NULL)
3932 +    target_type = check_typedef (TYPE_TARGET_TYPE (type));
3933 +  element_size = type_length_get (target_type, NULL, 1);
3934 +  retval = (count - 1) * byte_stride + element_size;
3935 +  if (retval < element_size
3936 +      || (byte_stride != 0
3937 +          && (retval - element_size) / byte_stride != count - 1)
3938 +      || retval > UINT_MAX)
3939 +    retval = 0;
3940 +  return retval;
3941 +}
3942 +
3943 +/* Prepare TYPE after being read in by the backend.  Currently this function
3944 +   only propagates the TYPE_DYNAMIC flag.  */
3945 +
3946 +void
3947 +finalize_type (struct type *type)
3948 +{
3949 +  int i;
3950 +
3951 +  for (i = 0; i < TYPE_NFIELDS (type); ++i)
3952 +    if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
3953 +      break;
3954 +
3955 +  /* FIXME: cplus_stuff is ignored here.  */
3956 +  if (i < TYPE_NFIELDS (type)
3957 +      || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
3958 +      || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
3959 +    TYPE_DYNAMIC (type) = 1;
3960 +}
3961 +
3962  /* Find the real type of TYPE.  This function returns the real type,
3963     after removing all layers of typedefs, and completing opaque or stub
3964     types.  Completion changes the TYPE argument, but stripping of
3965 @@ -1575,52 +1729,37 @@ check_typedef (struct type *type)
3966          }
3967      }
3968  
3969 -  if (TYPE_TARGET_STUB (type))
3970 +  /* copy_type_recursive automatically makes the resulting type containing only
3971 +     constant values expected by the callers of this function.  */
3972 +  if (TYPE_DYNAMIC (type))
3973 +    {
3974 +      htab_t copied_types;
3975 +
3976 +      copied_types = create_copied_types_hash (NULL);
3977 +      type = copy_type_recursive (type, copied_types);
3978 +      htab_delete (copied_types);
3979 +
3980 +      gdb_assert (TYPE_DYNAMIC (type) == 0);
3981 +      /* Force TYPE_LENGTH (type) recalculation.  */
3982 +      TYPE_DYNAMIC (type) = 1;
3983 +    }
3984 +
3985 +  if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))
3986      {
3987 -      struct type *range_type;
3988        struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
3989  
3990 +      if (TYPE_DYNAMIC (type))
3991 +       TYPE_TARGET_TYPE (type) = target_type;
3992        if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
3993         {
3994           /* Nothing we can do.  */
3995         }
3996        else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
3997 -              && TYPE_NFIELDS (type) == 1
3998 -              && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type))
3999 -                  == TYPE_CODE_RANGE))
4000 +              || TYPE_CODE (type) == TYPE_CODE_STRING)
4001         {
4002           /* Now recompute the length of the array type, based on its
4003 -            number of elements and the target type's length.
4004 -            Watch out for Ada null Ada arrays where the high bound
4005 -            is smaller than the low bound.  */
4006 -         const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
4007 -         const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
4008 -         ULONGEST len;
4009 -
4010 -         if (high_bound < low_bound)
4011 -           len = 0;
4012 -         else
4013 -           {
4014 -             /* For now, we conservatively take the array length to be 0
4015 -                if its length exceeds UINT_MAX.  The code below assumes
4016 -                that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1,
4017 -                which is technically not guaranteed by C, but is usually true
4018 -                (because it would be true if x were unsigned with its
4019 -                high-order bit on).  It uses the fact that
4020 -                high_bound-low_bound is always representable in
4021 -                ULONGEST and that if high_bound-low_bound+1 overflows,
4022 -                it overflows to 0.  We must change these tests if we 
4023 -                decide to increase the representation of TYPE_LENGTH
4024 -                from unsigned int to ULONGEST.  */
4025 -             ULONGEST ulow = low_bound, uhigh = high_bound;
4026 -             ULONGEST tlen = TYPE_LENGTH (target_type);
4027 -
4028 -             len = tlen * (uhigh - ulow + 1);
4029 -             if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh 
4030 -                 || len > UINT_MAX)
4031 -               len = 0;
4032 -           }
4033 -         TYPE_LENGTH (type) = len;
4034 +            number of elements and the target type's length.  */
4035 +         TYPE_LENGTH (type) = type_length_get (type, target_type, 0);
4036           TYPE_TARGET_STUB (type) = 0;
4037         }
4038        else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
4039 @@ -1628,6 +1767,7 @@ check_typedef (struct type *type)
4040           TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
4041           TYPE_TARGET_STUB (type) = 0;
4042         }
4043 +      TYPE_DYNAMIC (type) = 0;
4044      }
4045  
4046    type = make_qualified_type (type, instance_flags, NULL);
4047 @@ -3266,33 +3406,42 @@ type_pair_eq (const void *item_lhs, cons
4048  }
4049  
4050  /* Allocate the hash table used by copy_type_recursive to walk
4051 -   types without duplicates.  We use OBJFILE's obstack, because
4052 -   OBJFILE is about to be deleted.  */
4053 +   types without duplicates.   */
4054  
4055  htab_t
4056  create_copied_types_hash (struct objfile *objfile)
4057  {
4058 -  return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
4059 -                              NULL, &objfile->objfile_obstack,
4060 -                              hashtab_obstack_allocate,
4061 -                              dummy_obstack_deallocate);
4062 +  if (objfile == NULL)
4063 +    {
4064 +      /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in
4065 +        OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN.  Table
4066 +        element entries get allocated by xmalloc - so use xfree.  */
4067 +      return htab_create (1, type_pair_hash, type_pair_eq, xfree);
4068 +    }
4069 +  else
4070 +    {
4071 +      /* Use OBJFILE's obstack, because OBJFILE is about to be deleted.  Table
4072 +        element entries get allocated by xmalloc - so use xfree.  */
4073 +      return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
4074 +                                  xfree, &objfile->objfile_obstack,
4075 +                                  hashtab_obstack_allocate,
4076 +                                  dummy_obstack_deallocate);
4077 +    }
4078  }
4079  
4080 -/* Recursively copy (deep copy) TYPE, if it is associated with
4081 -   OBJFILE.  Return a new type allocated using malloc, a saved type if
4082 -   we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
4083 -   not associated with OBJFILE.  */
4084 +/* A helper for copy_type_recursive.  This does all the work.  OBJFILE is used
4085 +   only for an assertion checking.  */
4086  
4087 -struct type *
4088 -copy_type_recursive (struct objfile *objfile, 
4089 -                    struct type *type,
4090 -                    htab_t copied_types)
4091 +static struct type *
4092 +copy_type_recursive_1 (struct objfile *objfile, 
4093 +                      struct type *type,
4094 +                      htab_t copied_types)
4095  {
4096    struct type_pair *stored, pair;
4097    void **slot;
4098    struct type *new_type;
4099  
4100 -  if (! TYPE_OBJFILE_OWNED (type))
4101 +  if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type))
4102      return type;
4103  
4104    /* This type shouldn't be pointing to any types in other objfiles;
4105 @@ -3307,9 +3456,10 @@ copy_type_recursive (struct objfile *obj
4106    new_type = alloc_type_arch (get_type_arch (type));
4107  
4108    /* We must add the new type to the hash table immediately, in case
4109 -     we encounter this type again during a recursive call below.  */
4110 -  stored
4111 -    = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
4112 +     we encounter this type again during a recursive call below.  Memory could
4113 +     be allocated from OBJFILE in the case we will be removing OBJFILE, this
4114 +     optimization is missed and xfree is called for it from COPIED_TYPES.  */
4115 +  stored = xmalloc (sizeof (*stored));
4116    stored->old = type;
4117    stored->new = new_type;
4118    *slot = stored;
4119 @@ -3320,6 +3470,21 @@ copy_type_recursive (struct objfile *obj
4120    TYPE_OBJFILE_OWNED (new_type) = 0;
4121    TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
4122  
4123 +#if 0
4124 +  /* TYPE_MAIN_TYPE memory copy above rewrote the TYPE_DISCARDABLE flag so we
4125 +     need to initialize it again.  And even if TYPE was already discardable
4126 +     NEW_TYPE so far is not registered in TYPE_DISCARDABLE_TABLE.  */
4127 +  TYPE_DISCARDABLE (new_type) = 0;
4128 +  set_type_as_discardable (new_type);
4129 +#endif
4130 +
4131 +  /* Pre-clear the fields processed by delete_main_type.  If DWARF block
4132 +     evaluations below call error we would leave an unfreeable TYPE.  */
4133 +  TYPE_TARGET_TYPE (new_type) = NULL;
4134 +  TYPE_VPTR_BASETYPE (new_type) = NULL;
4135 +  TYPE_NFIELDS (new_type) = 0;
4136 +  TYPE_FIELDS (new_type) = NULL;
4137 +
4138    if (TYPE_NAME (type))
4139      TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
4140    if (TYPE_TAG_NAME (type))
4141 @@ -3328,12 +3493,48 @@ copy_type_recursive (struct objfile *obj
4142    TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
4143    TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
4144  
4145 +  if (TYPE_ALLOCATED (new_type))
4146 +    {
4147 +      gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
4148 +
4149 +      if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
4150 +        TYPE_NOT_ALLOCATED (new_type) = 1;
4151 +      TYPE_ALLOCATED (new_type) = NULL;
4152 +    }
4153 +
4154 +  if (TYPE_ASSOCIATED (new_type))
4155 +    {
4156 +      gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
4157 +
4158 +      if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
4159 +        TYPE_NOT_ASSOCIATED (new_type) = 1;
4160 +      TYPE_ASSOCIATED (new_type) = NULL;
4161 +    }
4162 +
4163 +  if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
4164 +      && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
4165 +    {
4166 +      if (TYPE_NOT_ALLOCATED (new_type)
4167 +          || TYPE_NOT_ASSOCIATED (new_type))
4168 +       TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
4169 +      else
4170 +       {
4171 +         TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1;
4172 +         TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval
4173 +                                   (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type));
4174 +       }
4175 +    }
4176 +
4177    /* Copy the fields.  */
4178    if (TYPE_NFIELDS (type))
4179      {
4180        int i, nfields;
4181  
4182 +      /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS.  */
4183 +      gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE);
4184 +
4185        nfields = TYPE_NFIELDS (type);
4186 +      TYPE_NFIELDS (new_type) = nfields;
4187        TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
4188        for (i = 0; i < nfields; i++)
4189         {
4190 @@ -3342,8 +3543,8 @@ copy_type_recursive (struct objfile *obj
4191           TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
4192           if (TYPE_FIELD_TYPE (type, i))
4193             TYPE_FIELD_TYPE (new_type, i)
4194 -             = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
4195 -                                    copied_types);
4196 +             = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
4197 +                                      copied_types);
4198           if (TYPE_FIELD_NAME (type, i))
4199             TYPE_FIELD_NAME (new_type, i) = 
4200               xstrdup (TYPE_FIELD_NAME (type, i));
4201 @@ -3370,24 +3571,184 @@ copy_type_recursive (struct objfile *obj
4202         }
4203      }
4204  
4205 +  /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
4206 +     possibly converted.  */
4207 +  TYPE_DYNAMIC (new_type) = 0;
4208 +
4209    /* For range types, copy the bounds information.  */
4210 -  if (TYPE_CODE (type) == TYPE_CODE_RANGE)
4211 +  if (TYPE_CODE (new_type) == TYPE_CODE_RANGE)
4212      {
4213        TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
4214        *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
4215 +
4216 +      switch (TYPE_RANGE_DATA (new_type)->low.kind)
4217 +       {
4218 +       case RANGE_BOUND_KIND_CONSTANT:
4219 +         break;
4220 +       case RANGE_BOUND_KIND_DWARF_BLOCK:
4221 +         /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
4222 +            it is expected to be made constant by CHECK_TYPEDEF.
4223 +            TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4224 +            */
4225 +         if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4226 +             || ! has_stack_frames ())
4227 +           {
4228 +             /* We should set 1 for Fortran but how to find the language?  */
4229 +             TYPE_LOW_BOUND (new_type) = 0;
4230 +             TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
4231 +           }
4232 +         else
4233 +           {
4234 +             TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval
4235 +                               (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block);
4236 +             if (TYPE_LOW_BOUND (new_type) >= 0)
4237 +               TYPE_UNSIGNED (new_type) = 1;
4238 +           }
4239 +         TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
4240 +         break;
4241 +       case RANGE_BOUND_KIND_DWARF_LOCLIST:
4242 +         {
4243 +           CORE_ADDR addr;
4244 +
4245 +           /* `struct dwarf2_loclist_baton' is too bound to its objfile so
4246 +              it is expected to be made constant by CHECK_TYPEDEF.
4247 +              TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4248 +              */
4249 +           if (! TYPE_NOT_ALLOCATED (new_type)
4250 +               && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
4251 +               && dwarf_loclist_baton_eval
4252 +                 (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist,
4253 +                  TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr))
4254 +             {
4255 +               TYPE_LOW_BOUND (new_type) = addr;
4256 +               if (TYPE_LOW_BOUND (new_type) >= 0)
4257 +                 TYPE_UNSIGNED (new_type) = 1;
4258 +             }
4259 +           else
4260 +             {
4261 +               /* We should set 1 for Fortran but how to find the language?  */
4262 +               TYPE_LOW_BOUND (new_type) = 0;
4263 +               TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
4264 +             }
4265 +           TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
4266 +         }
4267 +         break;
4268 +       }
4269 +
4270 +      switch (TYPE_RANGE_DATA (new_type)->high.kind)
4271 +       {
4272 +       case RANGE_BOUND_KIND_CONSTANT:
4273 +         break;
4274 +       case RANGE_BOUND_KIND_DWARF_BLOCK:
4275 +         /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
4276 +            it is expected to be made constant by CHECK_TYPEDEF.
4277 +            TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4278 +            */
4279 +         if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4280 +             || ! has_stack_frames ())
4281 +           {
4282 +             TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
4283 +             TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
4284 +           }
4285 +         else
4286 +           TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval
4287 +                              (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block);
4288 +         TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
4289 +         break;
4290 +       case RANGE_BOUND_KIND_DWARF_LOCLIST:
4291 +         {
4292 +           CORE_ADDR addr;
4293 +
4294 +           /* `struct dwarf2_loclist_baton' is too bound to its objfile so
4295 +              it is expected to be made constant by CHECK_TYPEDEF.
4296 +              TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4297 +              */
4298 +           if (! TYPE_NOT_ALLOCATED (new_type)
4299 +               && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
4300 +               && dwarf_loclist_baton_eval
4301 +                     (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist,
4302 +                      TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type,
4303 +                      &addr))
4304 +             TYPE_HIGH_BOUND (new_type) = addr;
4305 +           else
4306 +             {
4307 +               TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
4308 +               TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
4309 +             }
4310 +           TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
4311 +         }
4312 +         break;
4313 +       }
4314 +
4315 +      switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind)
4316 +       {
4317 +       case RANGE_BOUND_KIND_CONSTANT:
4318 +         break;
4319 +       case RANGE_BOUND_KIND_DWARF_BLOCK:
4320 +         /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
4321 +            it is expected to be made constant by CHECK_TYPEDEF.
4322 +            TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4323 +            */
4324 +         if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4325 +             || ! has_stack_frames ())
4326 +           TYPE_BYTE_STRIDE (new_type) = 0;
4327 +         else
4328 +           TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval
4329 +                       (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block);
4330 +         TYPE_RANGE_DATA (new_type)->byte_stride.kind
4331 +           = RANGE_BOUND_KIND_CONSTANT;
4332 +         break;
4333 +       case RANGE_BOUND_KIND_DWARF_LOCLIST:
4334 +         {
4335 +           CORE_ADDR addr = 0;
4336 +
4337 +           /* `struct dwarf2_loclist_baton' is too bound to its objfile so
4338 +              it is expected to be made constant by CHECK_TYPEDEF.
4339 +              TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
4340 +              */
4341 +           if (! TYPE_NOT_ALLOCATED (new_type)
4342 +               && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ())
4343 +             dwarf_loclist_baton_eval
4344 +              (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist,
4345 +               TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type,
4346 +               &addr);
4347 +           TYPE_BYTE_STRIDE (new_type) = addr;
4348 +           TYPE_RANGE_DATA (new_type)->byte_stride.kind
4349 +             = RANGE_BOUND_KIND_CONSTANT;
4350 +         }
4351 +         break;
4352 +       }
4353 +
4354 +      /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound.  */
4355 +      if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type))
4356 +       {
4357 +         TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type)
4358 +                                      + TYPE_HIGH_BOUND (new_type) - 1;
4359 +         TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0;
4360 +       }
4361      }
4362  
4363    /* Copy pointers to other types.  */
4364    if (TYPE_TARGET_TYPE (type))
4365      TYPE_TARGET_TYPE (new_type) = 
4366 -      copy_type_recursive (objfile, 
4367 -                          TYPE_TARGET_TYPE (type),
4368 -                          copied_types);
4369 +      copy_type_recursive_1 (objfile, 
4370 +                            TYPE_TARGET_TYPE (type),
4371 +                            copied_types);
4372    if (TYPE_VPTR_BASETYPE (type))
4373      TYPE_VPTR_BASETYPE (new_type) = 
4374 -      copy_type_recursive (objfile,
4375 -                          TYPE_VPTR_BASETYPE (type),
4376 -                          copied_types);
4377 +      copy_type_recursive_1 (objfile,
4378 +                            TYPE_VPTR_BASETYPE (type),
4379 +                            copied_types);
4380 +
4381 +  if (TYPE_CODE (new_type) == TYPE_CODE_ARRAY)
4382 +    {
4383 +      struct type *new_index_type = TYPE_INDEX_TYPE (new_type);
4384 +
4385 +      if (TYPE_BYTE_STRIDE (new_index_type) == 0)
4386 +       TYPE_BYTE_STRIDE (new_index_type)
4387 +         = TYPE_LENGTH (TYPE_TARGET_TYPE (new_type));
4388 +    }
4389 +
4390    /* Maybe copy the type_specific bits.
4391  
4392       NOTE drow/2005-12-09: We do not copy the C++-specific bits like
4393 @@ -3404,6 +3765,17 @@ copy_type_recursive (struct objfile *obj
4394    return new_type;
4395  }
4396  
4397 +/* Recursively copy (deep copy) TYPE.  Return a new type allocated using
4398 +   malloc, a saved type if we have already visited TYPE (using COPIED_TYPES),
4399 +   or TYPE if it is not associated with OBJFILE.  */
4400 +
4401 +struct type *
4402 +copy_type_recursive (struct type *type,
4403 +                    htab_t copied_types)
4404 +{
4405 +  return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types);
4406 +}
4407 +
4408  /* Make a copy of the given TYPE, except that the pointer & reference
4409     types are not preserved.
4410     
4411 @@ -3426,6 +3798,201 @@ copy_type (const struct type *type)
4412    return new_type;
4413  }
4414  
4415 +#if 0
4416 +/* Callback type for main_type_crawl.  */
4417 +typedef int (*main_type_crawl_iter) (struct type *type, void *data);
4418 +
4419 +/* Iterate all main_type structures reachable through any `struct type *' from
4420 +   TYPE.  ITER will be called only for one type of each main_type, use
4421 +   TYPE_CHAIN traversal to find all the type instances.  ITER is being called
4422 +   for each main_type found.  ITER returns non-zero if main_type_crawl should
4423 +   depth-first enter the specific type.  ITER must provide some detection for
4424 +   reentering the same main_type as this function would otherwise endlessly
4425 +   loop.  */
4426 +
4427 +static void
4428 +main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data)
4429 +{
4430 +  struct type *type_iter;
4431 +  int i;
4432 +
4433 +  if (!type)
4434 +    return;
4435 +
4436 +  gdb_assert (TYPE_OBJFILE (type) == NULL);
4437 +
4438 +  /* `struct cplus_struct_type' handling is unsupported by this function.  */
4439 +  gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT
4440 +              && TYPE_CODE (type) != TYPE_CODE_UNION)
4441 +             || !HAVE_CPLUS_STRUCT (type));
4442 +
4443 +  if (!(*iter) (type, data))
4444 +    return;
4445 +
4446 +  /* Iterate all the type instances of this main_type.  */
4447 +  type_iter = type;
4448 +  do
4449 +    {
4450 +      gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type));
4451 +
4452 +      main_type_crawl (TYPE_POINTER_TYPE (type), iter, data);
4453 +      main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data);
4454 +
4455 +      type_iter = TYPE_CHAIN (type_iter);
4456 +    }
4457 +  while (type_iter != type);
4458 +
4459 +  for (i = 0; i < TYPE_NFIELDS (type); i++)
4460 +    main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data);
4461 +
4462 +  main_type_crawl (TYPE_TARGET_TYPE (type), iter, data);
4463 +  main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data);
4464 +}
4465 +
4466 +/* A helper for delete_type which deletes a main_type and the things to which
4467 +   it refers.  TYPE is a type whose main_type we wish to destroy.  */
4468 +
4469 +static void
4470 +delete_main_type (struct type *type)
4471 +{
4472 +  int i;
4473 +
4474 +  gdb_assert (TYPE_DISCARDABLE (type));
4475 +  gdb_assert (TYPE_OBJFILE (type) == NULL);
4476 +
4477 +  xfree (TYPE_NAME (type));
4478 +  xfree (TYPE_TAG_NAME (type));
4479 +
4480 +  for (i = 0; i < TYPE_NFIELDS (type); ++i)
4481 +    {
4482 +      xfree (TYPE_FIELD_NAME (type, i));
4483 +
4484 +      if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
4485 +       xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
4486 +    }
4487 +  xfree (TYPE_FIELDS (type));
4488 +
4489 +  gdb_assert (!HAVE_CPLUS_STRUCT (type));
4490 +
4491 +  xfree (TYPE_MAIN_TYPE (type));
4492 +}
4493 +
4494 +/* Delete all the instances on TYPE_CHAIN of TYPE, including their referenced
4495 +   main_type.  TYPE must be a reclaimable type - neither permanent nor objfile
4496 +   associated.  */
4497 +
4498 +static void
4499 +delete_type_chain (struct type *type)
4500 +{
4501 +  struct type *type_iter, *type_iter_to_free;
4502 +
4503 +  gdb_assert (TYPE_DISCARDABLE (type));
4504 +  gdb_assert (TYPE_OBJFILE (type) == NULL);
4505 +
4506 +  delete_main_type (type);
4507 +
4508 +  type_iter = type;
4509 +  do
4510 +    {
4511 +      type_iter_to_free = type_iter;
4512 +      type_iter = TYPE_CHAIN (type_iter);
4513 +      xfree (type_iter_to_free);
4514 +    }
4515 +  while (type_iter != type);
4516 +}
4517 +
4518 +/* Hash function for type_discardable_table.  */
4519 +
4520 +static hashval_t
4521 +type_discardable_hash (const void *p)
4522 +{
4523 +  const struct type *type = p;
4524 +
4525 +  return htab_hash_pointer (TYPE_MAIN_TYPE (type));
4526 +}
4527 +
4528 +/* Equality function for type_discardable_table.  */
4529 +
4530 +static int
4531 +type_discardable_equal (const void *a, const void *b)
4532 +{
4533 +  const struct type *left = a;
4534 +  const struct type *right = b;
4535 +
4536 +  return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right);
4537 +}
4538 +
4539 +/* A helper for type_mark_used.  */
4540 +
4541 +static int
4542 +type_mark_used_crawl (struct type *type, void *unused)
4543 +{
4544 +  if (!TYPE_DISCARDABLE (type))
4545 +    return 0;
4546 +
4547 +  if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current)
4548 +    return 0;
4549 +
4550 +  TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
4551 +
4552 +  /* Continue the traversal.  */
4553 +  return 1;
4554 +}
4555 +
4556 +/* Mark TYPE and its connected types as used in this free_all_types pass.  */
4557 +
4558 +void
4559 +type_mark_used (struct type *type)
4560 +{
4561 +  if (type == NULL)
4562 +    return;
4563 +
4564 +  if (!TYPE_DISCARDABLE (type))
4565 +    return;
4566 +
4567 +  main_type_crawl (type, type_mark_used_crawl, NULL);
4568 +}
4569 +
4570 +/* A traverse callback for type_discardable_table which removes any
4571 +   type_discardable whose reference count is now zero (unused link).  */
4572 +
4573 +static int
4574 +type_discardable_remove (void **slot, void *unused)
4575 +{
4576 +  struct type *type = *slot;
4577 +
4578 +  gdb_assert (TYPE_DISCARDABLE (type));
4579 +
4580 +  if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current)
4581 +    {
4582 +      delete_type_chain (type);
4583 +
4584 +      htab_clear_slot (type_discardable_table, slot);
4585 +    }
4586 +
4587 +  return 1;
4588 +}
4589 +
4590 +/* Free all the reclaimable types that have been allocated and that have
4591 +   currently zero reference counter.
4592 +
4593 +   This function is called after each command, successful or not.  Use this
4594 +   cleanup only in the GDB idle state as GDB only marks those types used by
4595 +   globally tracked objects (with no autovariable references tracking).  */
4596 +
4597 +void
4598 +free_all_types (void)
4599 +{
4600 +  /* Mark a new pass.  As GDB checks all the entries were visited after each
4601 +     pass there cannot be any stale entries already containing the changed
4602 +     value.  */
4603 +  type_discardable_age_current ^= 1;
4604 +
4605 +  observer_notify_mark_used ();
4606 +
4607 +  htab_traverse (type_discardable_table, type_discardable_remove, NULL);
4608 +}
4609 +#endif
4610  
4611  /* Helper functions to initialize architecture-specific types.  */
4612  
4613 @@ -3955,6 +4522,13 @@ void
4614  _initialize_gdbtypes (void)
4615  {
4616    gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
4617 +
4618 +#if 0
4619 +  type_discardable_table = htab_create_alloc (20, type_discardable_hash,
4620 +                                            type_discardable_equal, NULL,
4621 +                                            xcalloc, xfree);
4622 +#endif
4623 +
4624    objfile_type_data = register_objfile_data ();
4625  
4626    add_setshow_zinteger_cmd ("overload", no_class, &overload_debug,
4627 Index: gdb-7.2.90.20110703/gdb/gdbtypes.h
4628 ===================================================================
4629 --- gdb-7.2.90.20110703.orig/gdb/gdbtypes.h     2011-03-28 22:21:03.000000000 +0200
4630 +++ gdb-7.2.90.20110703/gdb/gdbtypes.h  2011-07-03 10:33:11.000000000 +0200
4631 @@ -215,6 +215,11 @@ enum type_instance_flag_value
4632  
4633  #define TYPE_TARGET_STUB(t)    (TYPE_MAIN_TYPE (t)->flag_target_stub)
4634  
4635 +/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
4636 +   sticky.  */
4637 +
4638 +#define TYPE_DYNAMIC(t)                (TYPE_MAIN_TYPE (t)->flag_dynamic)
4639 +
4640  /* Static type.  If this is set, the corresponding type had 
4641     a static modifier.
4642     Note: This may be unnecessary, since static data members
4643 @@ -292,6 +297,50 @@ enum type_instance_flag_value
4644  
4645  #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
4646  
4647 +#if 0
4648 +/* Define this type as being reclaimable during free_all_types.  Type is
4649 +   required to be have TYPE_OBJFILE set to NULL.  Setting this flag requires
4650 +   initializing TYPE_DISCARDABLE_AGE, see alloc_type_discardable.  */
4651 +
4652 +#define TYPE_DISCARDABLE(t)    (TYPE_MAIN_TYPE (t)->flag_discardable)
4653 +
4654 +/* Marker this type has been visited by the type_mark_used by this
4655 +   mark-and-sweep types garbage collecting pass.  Current pass is represented
4656 +   by TYPE_DISCARDABLE_AGE_CURRENT.  */
4657 +
4658 +#define TYPE_DISCARDABLE_AGE(t)        (TYPE_MAIN_TYPE (t)->flag_discardable_age)
4659 +#endif
4660 +
4661 +/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)?  */
4662 +
4663 +#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
4664 +  (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
4665 +
4666 +/* Not allocated.  TYPE_ALLOCATED(t) must be NULL in such case.  If this flag
4667 +   is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated.  If this
4668 +   flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block
4669 +   determines the actual allocation state.  */
4670 +
4671 +#define TYPE_NOT_ALLOCATED(t)  (TYPE_MAIN_TYPE (t)->flag_not_allocated)
4672 +
4673 +/* Not associated.  TYPE_ASSOCIATED(t) must be NULL in such case.  If this flag
4674 +   is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated.  If
4675 +   this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block
4676 +   determines the actual association state.  */
4677 +
4678 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
4679 +
4680 +/* Address of the actual data as for DW_AT_data_location.  Its dwarf block must
4681 +   not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are
4682 +   false.  If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value
4683 +   is the actual data address value.  If unset and
4684 +   TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal
4685 +   value_raw_address.  If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL
4686 +   then its DWARF block determines the actual data address.  */
4687 +
4688 +#define TYPE_DATA_LOCATION_IS_ADDR(t) \
4689 +  (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
4690 +
4691  /* Constant type.  If this is set, the corresponding type has a
4692     const modifier.  */
4693  
4694 @@ -400,6 +449,15 @@ struct main_type
4695    /* True if this type was declared with "class" rather than
4696       "struct".  */
4697    unsigned int flag_declared_class : 1;
4698 +#if 0
4699 +  unsigned int flag_discardable : 1;
4700 +  unsigned int flag_discardable_age : 1;
4701 +#endif
4702 +  unsigned int flag_dynamic : 1;
4703 +  unsigned int flag_range_high_bound_is_count : 1;
4704 +  unsigned int flag_not_allocated : 1;
4705 +  unsigned int flag_not_associated : 1;
4706 +  unsigned int flag_data_location_is_addr : 1;
4707  
4708    /* A discriminant telling us which field of the type_specific union
4709       is being used for this type, if any.  */
4710 @@ -473,6 +531,20 @@ struct main_type
4711  
4712    struct type *target_type;
4713  
4714 +  /* For DW_AT_data_location.  */
4715 +  union
4716 +    {
4717 +      struct dwarf2_locexpr_baton *dwarf_block;
4718 +      CORE_ADDR addr;
4719 +    }
4720 +  data_location;
4721 +
4722 +  /* For DW_AT_allocated.  */
4723 +  struct dwarf2_locexpr_baton *allocated;
4724 +
4725 +  /* For DW_AT_associated.  */
4726 +  struct dwarf2_locexpr_baton *associated;
4727 +
4728    /* For structure and union types, a description of each field.
4729       For set and pascal array types, there is one "field",
4730       whose type is the domain type of the set or array.
4731 @@ -547,13 +619,34 @@ struct main_type
4732  
4733      struct range_bounds
4734      {
4735 +      struct
4736 +       {
4737 +         union
4738 +           {
4739 +             LONGEST constant;
4740 +             struct dwarf2_locexpr_baton *dwarf_block;
4741 +             struct
4742 +               {
4743 +                 struct dwarf2_loclist_baton *loclist;
4744 +                 struct type *type;
4745 +               }
4746 +             dwarf_loclist;
4747 +           }
4748 +         u;
4749 +         enum range_bound_kind
4750 +           {
4751 +             RANGE_BOUND_KIND_CONSTANT,
4752 +             RANGE_BOUND_KIND_DWARF_BLOCK,
4753 +             RANGE_BOUND_KIND_DWARF_LOCLIST
4754 +           }
4755 +         kind;
4756 +       }
4757        /* Low bound of range.  */
4758 -
4759 -      LONGEST low;
4760 -
4761 +      low,
4762        /* High bound of range.  */
4763 -
4764 -      LONGEST high;
4765 +      high,
4766 +      /* Byte stride of range.  */
4767 +      byte_stride;
4768  
4769        /* Flags indicating whether the values of low and high are
4770           valid.  When true, the respective range value is
4771 @@ -926,9 +1019,9 @@ extern void allocate_gnat_aux_type (stru
4772  #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
4773  #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
4774  #define TYPE_CHAIN(thistype) (thistype)->chain
4775 -/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
4776 -   But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
4777 -   so you only have to call check_typedef once.  Since allocate_value
4778 +/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call
4779 +   check_typedef.  But check_typedef does set the TYPE_LENGTH of the TYPEDEF
4780 +   type, so you only have to call check_typedef once.  Since allocate_value
4781     calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe.  */
4782  #define TYPE_LENGTH(thistype) (thistype)->length
4783  /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real
4784 @@ -936,11 +1029,16 @@ extern void allocate_gnat_aux_type (stru
4785  #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
4786  #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
4787  #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
4788 +#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block
4789 +#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr
4790 +#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated
4791 +#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
4792  
4793  #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
4794  #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
4795 -#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
4796 -#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
4797 +#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant
4798 +#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant
4799 +#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant
4800  #define TYPE_LOW_BOUND_UNDEFINED(range_type) \
4801     TYPE_RANGE_DATA(range_type)->low_undefined
4802  #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
4803 @@ -957,7 +1055,14 @@ extern void allocate_gnat_aux_type (stru
4804     (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
4805  
4806  #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
4807 -   (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
4808 +  TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
4809 +
4810 +/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
4811 +   element size if no specific stride value is known.  */
4812 +#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype)                \
4813 +  (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
4814 +   ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype))                \
4815 +   : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
4816  
4817  /* C++ */
4818  
4819 @@ -1379,6 +1484,18 @@ extern struct type *create_array_type (s
4820                                        struct type *);
4821  extern struct type *lookup_array_range_type (struct type *, int, int);
4822  
4823 +extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
4824 +                                               int fieldno);
4825 +
4826 +extern int type_range_high_bound_internal (struct type *range_type);
4827 +
4828 +extern int type_range_count_bound_internal (struct type *range_type);
4829 +
4830 +extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
4831 +                                                 struct type *element_type);
4832 +
4833 +extern void finalize_type (struct type *type);
4834 +
4835  extern struct type *create_string_type (struct type *, struct type *,
4836                                         struct type *);
4837  extern struct type *lookup_string_range_type (struct type *, int, int);
4838 @@ -1424,6 +1541,10 @@ extern int is_public_ancestor (struct ty
4839  
4840  extern int is_unique_ancestor (struct type *, struct value *);
4841  
4842 +#if 0
4843 +extern void type_mark_used (struct type *type);
4844 +#endif
4845 +
4846  /* Overload resolution */
4847  
4848  #define LENGTH_MATCH(bv) ((bv)->rank[0])
4849 @@ -1496,10 +1617,13 @@ extern void maintenance_print_type (char
4850  
4851  extern htab_t create_copied_types_hash (struct objfile *objfile);
4852  
4853 -extern struct type *copy_type_recursive (struct objfile *objfile,
4854 -                                        struct type *type,
4855 +extern struct type *copy_type_recursive (struct type *type,
4856                                          htab_t copied_types);
4857  
4858  extern struct type *copy_type (const struct type *type);
4859  
4860 +#if 0
4861 +extern void free_all_types (void);
4862 +#endif
4863 +
4864  #endif /* GDBTYPES_H */
4865 Index: gdb-7.2.90.20110703/gdb/i386-linux-nat.c
4866 ===================================================================
4867 --- gdb-7.2.90.20110703.orig/gdb/i386-linux-nat.c       2011-02-27 17:25:37.000000000 +0100
4868 +++ gdb-7.2.90.20110703/gdb/i386-linux-nat.c    2011-07-03 10:33:11.000000000 +0200
4869 @@ -649,22 +649,13 @@ i386_linux_store_inferior_registers (str
4870  }
4871  \f
4872  
4873 -/* Support for debug registers.  */
4874 -
4875 -static unsigned long i386_linux_dr[DR_CONTROL + 1];
4876 -
4877  /* Get debug register REGNUM value from only the one LWP of PTID.  */
4878  
4879  static unsigned long
4880 -i386_linux_dr_get (ptid_t ptid, int regnum)
4881 +i386_linux_dr_get (int tid, int regnum)
4882  {
4883 -  int tid;
4884    unsigned long value;
4885  
4886 -  tid = TIDGET (ptid);
4887 -  if (tid == 0)
4888 -    tid = PIDGET (ptid);
4889 -
4890    /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
4891       ptrace call fails breaks debugging remote targets.  The correct
4892       way to fix this is to add the hardware breakpoint and watchpoint
4893 @@ -686,14 +677,8 @@ i386_linux_dr_get (ptid_t ptid, int regn
4894  /* Set debug register REGNUM to VALUE in only the one LWP of PTID.  */
4895  
4896  static void
4897 -i386_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
4898 +i386_linux_dr_set (int tid, int regnum, unsigned long value)
4899  {
4900 -  int tid;
4901 -
4902 -  tid = TIDGET (ptid);
4903 -  if (tid == 0)
4904 -    tid = PIDGET (ptid);
4905 -
4906    errno = 0;
4907    ptrace (PTRACE_POKEUSER, tid,
4908           offsetof (struct user, u_debugreg[regnum]), value);
4909 @@ -701,35 +686,78 @@ i386_linux_dr_set (ptid_t ptid, int regn
4910      perror_with_name (_("Couldn't write debug register"));
4911  }
4912  
4913 -/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST.  */
4914 +/* Helper for i386_linux_dr_set_control.  */
4915 +
4916 +static void
4917 +i386_linux_dr_set_control_callback (int tid, void *control_voidp)
4918 +{
4919 +  unsigned long control = *(unsigned long *) control_voidp;
4920 +
4921 +  i386_linux_dr_set (tid, DR_CONTROL, control);
4922 +}
4923 +
4924 +static void i386_linux_dr_set_addr (int regnum, CORE_ADDR addr);
4925 +
4926 +/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR.  */
4927  
4928  static void
4929  i386_linux_dr_set_control (unsigned long control)
4930  {
4931 -  struct lwp_info *lp;
4932 -  ptid_t ptid;
4933 +  int inferior_pid = ptid_get_pid (inferior_ptid);
4934 +  struct inferior *inf = current_inferior ();
4935 +
4936 +  /* The amd64 counterpart and description is amd64_linux_dr_set_control.  */
4937 +  if (inf->pid != inferior_pid)
4938 +    {
4939 +      struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
4940 +      int i;
4941 +
4942 +      if (!dr_mirror->addr_preset)
4943 +       {
4944 +         dr_mirror->addr_preset = 1;
4945  
4946 -  i386_linux_dr[DR_CONTROL] = control;
4947 -  ALL_LWPS (lp, ptid)
4948 -    i386_linux_dr_set (ptid, DR_CONTROL, control);
4949 +         for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
4950 +           i386_linux_dr_set_addr (i, dr_mirror->addr[i]);
4951 +       }
4952 +    }
4953 +
4954 +  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_control_callback,
4955 +                                    &control);
4956  }
4957  
4958 -/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST.  */
4959 +/* Helper for i386_linux_dr_set_addr.  */
4960 +
4961 +struct i386_linux_dr_set_addr_data
4962 +  {
4963 +    int regnum;
4964 +    CORE_ADDR addr;
4965 +  };
4966 +
4967 +static void
4968 +i386_linux_dr_set_addr_callback (int tid, void *datap_voidp)
4969 +{
4970 +  const struct i386_linux_dr_set_addr_data *datap = datap_voidp;
4971 +
4972 +  i386_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
4973 +}
4974 +
4975 +/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
4976 +   */
4977  
4978  static void
4979  i386_linux_dr_set_addr (int regnum, CORE_ADDR addr)
4980  {
4981 -  struct lwp_info *lp;
4982 -  ptid_t ptid;
4983 +  struct i386_linux_dr_set_addr_data data;
4984  
4985    gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
4986  
4987 -  i386_linux_dr[DR_FIRSTADDR + regnum] = addr;
4988 -  ALL_LWPS (lp, ptid)
4989 -    i386_linux_dr_set (ptid, DR_FIRSTADDR + regnum, addr);
4990 +  data.regnum = regnum;
4991 +  data.addr = addr;
4992 +  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_addr_callback, &data);
4993  }
4994  
4995 -/* Set address REGNUM (zero based) to zero in all LWPs of LWP_LIST.  */
4996 +/* Set address REGNUM (zero based) to zero in all LWPs of CURRENT_INFERIOR.
4997 +   */
4998  
4999  static void
5000  i386_linux_dr_reset_addr (int regnum)
5001 @@ -742,36 +770,54 @@ i386_linux_dr_reset_addr (int regnum)
5002  static unsigned long
5003  i386_linux_dr_get_status (void)
5004  {
5005 -  return i386_linux_dr_get (inferior_ptid, DR_STATUS);
5006 +  int tid;
5007 +
5008 +  tid = TIDGET (inferior_ptid);
5009 +  if (tid == 0)
5010 +    tid = PIDGET (inferior_ptid);
5011 +
5012 +  return i386_linux_dr_get (tid, DR_STATUS);
5013  }
5014  
5015 -/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST.  */
5016 +/* Helper for i386_linux_dr_unset_status.  */
5017  
5018  static void
5019 -i386_linux_dr_unset_status (unsigned long mask)
5020 +i386_linux_dr_unset_status_callback (int tid, void *mask_voidp)
5021  {
5022 -  struct lwp_info *lp;
5023 -  ptid_t ptid;
5024 -
5025 -  ALL_LWPS (lp, ptid)
5026 -    {
5027 -      unsigned long value;
5028 +  unsigned long mask = *(unsigned long *) mask_voidp;
5029 +  unsigned long value;
5030        
5031 -      value = i386_linux_dr_get (ptid, DR_STATUS);
5032 -      value &= ~mask;
5033 -      i386_linux_dr_set (ptid, DR_STATUS, value);
5034 -    }
5035 +  value = i386_linux_dr_get (tid, DR_STATUS);
5036 +  value &= ~mask;
5037 +  i386_linux_dr_set (tid, DR_STATUS, value);
5038 +}
5039 +
5040 +/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR.  */
5041 +
5042 +static void
5043 +i386_linux_dr_unset_status (unsigned long mask)
5044 +{
5045 +  linux_nat_iterate_watchpoint_lwps (i386_linux_dr_unset_status_callback,
5046 +                                    &mask);
5047  }
5048  
5049  static void
5050  i386_linux_new_thread (ptid_t ptid)
5051  {
5052 -  int i;
5053 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5054 +  int i, tid;
5055 +
5056 +  /* Verify DR_MIRROR is valid.  */
5057 +  gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
5058 +
5059 +  tid = TIDGET (ptid);
5060 +  if (tid == 0)
5061 +    tid = PIDGET (ptid);
5062  
5063 -  for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
5064 -    i386_linux_dr_set (ptid, i, i386_linux_dr[i]);
5065 +  for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
5066 +    i386_linux_dr_set (tid, DR_FIRSTADDR + i, dr_mirror->addr[i]);
5067  
5068 -  i386_linux_dr_set (ptid, DR_CONTROL, i386_linux_dr[DR_CONTROL]);
5069 +  i386_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
5070  }
5071  \f
5072  
5073 Index: gdb-7.2.90.20110703/gdb/i386-nat.c
5074 ===================================================================
5075 --- gdb-7.2.90.20110703.orig/gdb/i386-nat.c     2011-02-26 23:04:51.000000000 +0100
5076 +++ gdb-7.2.90.20110703/gdb/i386-nat.c  2011-07-03 10:33:11.000000000 +0200
5077 @@ -25,6 +25,7 @@
5078  #include "gdbcmd.h"
5079  #include "target.h"
5080  #include "gdb_assert.h"
5081 +#include "inferior.h"
5082  
5083  /* Support for hardware watchpoints and breakpoints using the i386
5084     debug registers.
5085 @@ -44,7 +45,6 @@ struct i386_dr_low_type i386_dr_low;
5086  #define TARGET_HAS_DR_LEN_8 (i386_dr_low.debug_register_length == 8)
5087  
5088  /* Debug registers' indices.  */
5089 -#define DR_NADDR       4       /* The number of debug address registers.  */
5090  #define DR_STATUS      6       /* Index of debug status register (DR6).  */
5091  #define DR_CONTROL     7       /* Index of debug control register (DR7).  */
5092  
5093 @@ -111,49 +111,60 @@ struct i386_dr_low_type i386_dr_low;
5094  
5095  /* The I'th debug register is vacant if its Local and Global Enable
5096     bits are reset in the Debug Control register.  */
5097 -#define I386_DR_VACANT(i) \
5098 -  ((dr_control_mirror & (3 << (DR_ENABLE_SIZE * (i)))) == 0)
5099 +
5100 +static inline int
5101 +i386_dr_vacant (struct i386_dr_mirror *dr_mirror, int i)
5102 +{
5103 +  return (dr_mirror->control & (3 << (DR_ENABLE_SIZE * i))) == 0;
5104 +}
5105  
5106  /* Locally enable the break/watchpoint in the I'th debug register.  */
5107 -#define I386_DR_LOCAL_ENABLE(i) \
5108 -  dr_control_mirror |= (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
5109  
5110 -/* Globally enable the break/watchpoint in the I'th debug register.  */
5111 -#define I386_DR_GLOBAL_ENABLE(i) \
5112 -  dr_control_mirror |= (1 << (DR_GLOBAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
5113 +static inline void
5114 +i386_dr_local_enable (struct i386_dr_mirror *dr_mirror, int i)
5115 +{
5116 +  dr_mirror->control |= 1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * i);
5117 +}
5118  
5119  /* Disable the break/watchpoint in the I'th debug register.  */
5120 -#define I386_DR_DISABLE(i) \
5121 -  dr_control_mirror &= ~(3 << (DR_ENABLE_SIZE * (i)))
5122 +
5123 +static inline void
5124 +i386_dr_disable (struct i386_dr_mirror *dr_mirror, int i)
5125 +{
5126 +  dr_mirror->control &= ~(3 << (DR_ENABLE_SIZE * i));
5127 +}
5128  
5129  /* Set in DR7 the RW and LEN fields for the I'th debug register.  */
5130 -#define I386_DR_SET_RW_LEN(i,rwlen) \
5131 -  do { \
5132 -    dr_control_mirror &= ~(0x0f << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i)));   \
5133 -    dr_control_mirror |= ((rwlen) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
5134 -  } while (0)
5135 +
5136 +static inline void
5137 +i386_dr_set_rw_len (struct i386_dr_mirror *dr_mirror, int i, unsigned rwlen)
5138 +{
5139 +  dr_mirror->control &= ~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i));
5140 +  dr_mirror->control |= rwlen << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i);
5141 +}
5142  
5143  /* Get from DR7 the RW and LEN fields for the I'th debug register.  */
5144 -#define I386_DR_GET_RW_LEN(i) \
5145 -  ((dr_control_mirror >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * (i))) & 0x0f)
5146 +
5147 +static inline unsigned
5148 +i386_dr_get_rw_len (struct i386_dr_mirror *dr_mirror, int i)
5149 +{
5150 +  return ((dr_mirror->control >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i))
5151 +         & 0x0f);
5152 +}
5153  
5154  /* Mask that this I'th watchpoint has triggered.  */
5155  #define I386_DR_WATCH_MASK(i)  (1 << (i))
5156  
5157  /* Did the watchpoint whose address is in the I'th register break?  */
5158 -#define I386_DR_WATCH_HIT(i)   (dr_status_mirror & I386_DR_WATCH_MASK (i))
5159 +static inline int
5160 +i386_dr_watch_hit (struct i386_dr_mirror *dr_mirror, int i)
5161 +{
5162 +  return (dr_mirror->status & I386_DR_WATCH_MASK (i)) != 0;
5163 +}
5164  
5165  /* A macro to loop over all debug registers.  */
5166  #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++)
5167  
5168 -/* Mirror the inferior's DRi registers.  We keep the status and
5169 -   control registers separated because they don't hold addresses.  */
5170 -static CORE_ADDR dr_mirror[DR_NADDR];
5171 -static unsigned long dr_status_mirror, dr_control_mirror;
5172 -
5173 -/* Reference counts for each debug register.  */
5174 -static int dr_ref_count[DR_NADDR];
5175 -
5176  /* Whether or not to print the mirrored debug registers.  */
5177  static int maint_show_dr;
5178  
5179 @@ -195,21 +206,80 @@ static int i386_handle_nonaligned_watchp
5180  
5181  /* Implementation.  */
5182  
5183 +/* Per-inferior data key.  */
5184 +static const struct inferior_data *i386_inferior_data;
5185 +
5186 +struct i386_inferior_data
5187 +  {
5188 +    /* Copy of i386 hardware debug registers for performance reasons.  */
5189 +    struct i386_dr_mirror dr_mirror;
5190 +  };
5191 +
5192 +static void
5193 +i386_inferior_data_cleanup (struct inferior *inf, void *arg)
5194 +{
5195 +  struct i386_inferior_data *inf_data = arg;
5196 +
5197 +  xfree (inf_data);
5198 +}
5199 +
5200 +static struct i386_inferior_data *
5201 +i386_inferior_data_get (void)
5202 +{
5203 +  struct inferior *inf = current_inferior ();
5204 +  struct i386_inferior_data *inf_data;
5205 +
5206 +  inf_data = inferior_data (inf, i386_inferior_data);
5207 +  if (inf_data == NULL)
5208 +    {
5209 +      inf_data = xzalloc (sizeof (*inf_data));
5210 +      set_inferior_data (current_inferior (), i386_inferior_data, inf_data);
5211 +    }
5212 +
5213 +  if (inf->pid != ptid_get_pid (inferior_ptid))
5214 +    {
5215 +      static struct i386_inferior_data detached_inf_data_local;
5216 +      static int detached_inf_pid = -1;
5217 +
5218 +      if (detached_inf_pid != ptid_get_pid (inferior_ptid))
5219 +       {
5220 +         detached_inf_pid = ptid_get_pid (inferior_ptid);
5221 +
5222 +         /* Forked processes get a copy of the debug registers.  */
5223 +         memcpy (&detached_inf_data_local, inf_data,
5224 +                 sizeof (detached_inf_data_local));
5225 +         detached_inf_data_local.dr_mirror.addr_preset = 0;
5226 +       }
5227 +
5228 +      return &detached_inf_data_local;
5229 +    }
5230 +
5231 +  return inf_data;
5232 +}
5233 +
5234  /* Clear the reference counts and forget everything we knew about the
5235     debug registers.  */
5236  
5237 +struct i386_dr_mirror *
5238 +i386_dr_mirror_get (void)
5239 +{
5240 +  return &i386_inferior_data_get ()->dr_mirror;
5241 +}
5242 +
5243  void
5244  i386_cleanup_dregs (void)
5245  {
5246 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5247    int i;
5248  
5249    ALL_DEBUG_REGISTERS(i)
5250      {
5251 -      dr_mirror[i] = 0;
5252 -      dr_ref_count[i] = 0;
5253 +      dr_mirror->addr[i] = 0;
5254 +      dr_mirror->ref_count[i] = 0;
5255      }
5256 -  dr_control_mirror = 0;
5257 -  dr_status_mirror  = 0;
5258 +  dr_mirror->addr_preset = 0;
5259 +  dr_mirror->control = 0;
5260 +  dr_mirror->status = 0;
5261  }
5262  
5263  /* Print the values of the mirrored debug registers.  This is called
5264 @@ -220,6 +290,7 @@ static void
5265  i386_show_dr (const char *func, CORE_ADDR addr,
5266               int len, enum target_hw_bp_type type)
5267  {
5268 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5269    int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
5270    int i;
5271  
5272 @@ -239,13 +310,16 @@ i386_show_dr (const char *func, CORE_ADD
5273                                 : "??unknown??"))));
5274    puts_unfiltered (":\n");
5275    printf_unfiltered ("\tCONTROL (DR7): %s          STATUS (DR6): %s\n",
5276 -                    phex (dr_control_mirror, 8), phex (dr_status_mirror, 8));
5277 +                    phex (dr_mirror->control, 8),
5278 +                    phex (dr_mirror->status, 8));
5279    ALL_DEBUG_REGISTERS(i)
5280      {
5281        printf_unfiltered ("\
5282  \tDR%d: addr=0x%s, ref.count=%d  DR%d: addr=0x%s, ref.count=%d\n",
5283 -                i, phex (dr_mirror[i], addr_size), dr_ref_count[i],
5284 -                i+1, phex (dr_mirror[i+1], addr_size), dr_ref_count[i+1]);
5285 +                        i, phex (dr_mirror->addr[i], addr_size),
5286 +                        dr_mirror->ref_count[i], i + 1,
5287 +                        phex (dr_mirror->addr[i + 1], addr_size),
5288 +                        dr_mirror->ref_count[i + 1]);
5289        i++;
5290      }
5291  }
5292 @@ -313,6 +387,7 @@ Invalid hardware breakpoint length %d in
5293  static int
5294  i386_insert_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
5295  {
5296 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5297    int i;
5298  
5299    if (!i386_dr_low.set_addr || !i386_dr_low.set_control)
5300 @@ -323,11 +398,10 @@ i386_insert_aligned_watchpoint (CORE_ADD
5301       reuse it for this watchpoint as well (and save a register).  */
5302    ALL_DEBUG_REGISTERS(i)
5303      {
5304 -      if (!I386_DR_VACANT (i)
5305 -         && dr_mirror[i] == addr
5306 -         && I386_DR_GET_RW_LEN (i) == len_rw_bits)
5307 +      if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr
5308 +         && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits)
5309         {
5310 -         dr_ref_count[i]++;
5311 +         dr_mirror->ref_count[i]++;
5312           return 0;
5313         }
5314      }
5315 @@ -335,7 +409,7 @@ i386_insert_aligned_watchpoint (CORE_ADD
5316    /* Next, look for a vacant debug register.  */
5317    ALL_DEBUG_REGISTERS(i)
5318      {
5319 -      if (I386_DR_VACANT (i))
5320 +      if (i386_dr_vacant (dr_mirror, i))
5321         break;
5322      }
5323  
5324 @@ -346,9 +420,9 @@ i386_insert_aligned_watchpoint (CORE_ADD
5325    /* Now set up the register I to watch our region.  */
5326  
5327    /* Record the info in our local mirrored array.  */
5328 -  dr_mirror[i] = addr;
5329 -  dr_ref_count[i] = 1;
5330 -  I386_DR_SET_RW_LEN (i, len_rw_bits);
5331 +  dr_mirror->addr[i] = addr;
5332 +  dr_mirror->ref_count[i] = 1;
5333 +  i386_dr_set_rw_len (dr_mirror, i, len_rw_bits);
5334    /* Note: we only enable the watchpoint locally, i.e. in the current
5335       task.  Currently, no i386 target allows or supports global
5336       watchpoints; however, if any target would want that in the
5337 @@ -356,13 +430,13 @@ i386_insert_aligned_watchpoint (CORE_ADD
5338       to enable watchpoints globally or locally, and the code below
5339       should use global or local enable and slow-down flags as
5340       appropriate.  */
5341 -  I386_DR_LOCAL_ENABLE (i);
5342 -  dr_control_mirror |= DR_LOCAL_SLOWDOWN;
5343 -  dr_control_mirror &= I386_DR_CONTROL_MASK;
5344 +  i386_dr_local_enable (dr_mirror, i);
5345 +  dr_mirror->control |= DR_LOCAL_SLOWDOWN;
5346 +  dr_mirror->control &= I386_DR_CONTROL_MASK;
5347  
5348    /* Finally, actually pass the info to the inferior.  */
5349    i386_dr_low.set_addr (i, addr);
5350 -  i386_dr_low.set_control (dr_control_mirror);
5351 +  i386_dr_low.set_control (dr_mirror->control);
5352  
5353    /* Only a sanity check for leftover bits (set possibly only by inferior).  */
5354    if (i386_dr_low.unset_status)
5355 @@ -380,21 +454,21 @@ i386_insert_aligned_watchpoint (CORE_ADD
5356  static int
5357  i386_remove_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
5358  {
5359 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5360    int i, retval = -1;
5361  
5362    ALL_DEBUG_REGISTERS(i)
5363      {
5364 -      if (!I386_DR_VACANT (i)
5365 -         && dr_mirror[i] == addr
5366 -         && I386_DR_GET_RW_LEN (i) == len_rw_bits)
5367 +      if (!i386_dr_vacant (dr_mirror, i) && dr_mirror->addr[i] == addr
5368 +         && i386_dr_get_rw_len (dr_mirror, i) == len_rw_bits)
5369         {
5370 -         if (--dr_ref_count[i] == 0) /* no longer in use?  */
5371 +         if (--dr_mirror->ref_count[i] == 0) /* no longer in use?  */
5372             {
5373               /* Reset our mirror.  */
5374 -             dr_mirror[i] = 0;
5375 -             I386_DR_DISABLE (i);
5376 +             dr_mirror->addr[i] = 0;
5377 +             i386_dr_disable (dr_mirror, i);
5378               /* Reset it in the inferior.  */
5379 -             i386_dr_low.set_control (dr_control_mirror);
5380 +             i386_dr_low.set_control (dr_mirror->control);
5381               if (i386_dr_low.reset_addr)
5382                 i386_dr_low.reset_addr (i);
5383             }
5384 @@ -556,26 +630,27 @@ i386_region_ok_for_watchpoint (CORE_ADDR
5385  static int
5386  i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
5387  {
5388 +  struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5389    CORE_ADDR addr = 0;
5390    int i;
5391    int rc = 0;
5392  
5393 -  dr_status_mirror = i386_dr_low.get_status ();
5394 +  dr_mirror->status = i386_dr_low.get_status ();
5395  
5396    ALL_DEBUG_REGISTERS(i)
5397      {
5398 -      if (I386_DR_WATCH_HIT (i)
5399 +      if (i386_dr_watch_hit (dr_mirror, i)
5400           /* This second condition makes sure DRi is set up for a data
5401              watchpoint, not a hardware breakpoint.  The reason is
5402              that GDB doesn't call the target_stopped_data_address
5403              method except for data watchpoints.  In other words, I'm
5404              being paranoiac.  */
5405 -         && I386_DR_GET_RW_LEN (i) != 0
5406 +         && i386_dr_get_rw_len (dr_mirror, i) != 0
5407           /* This third condition makes sure DRi is not vacant, this
5408              avoids false positives in windows-nat.c.  */
5409 -         && !I386_DR_VACANT (i))
5410 +         && !i386_dr_vacant (dr_mirror, i))
5411         {
5412 -         addr = dr_mirror[i];
5413 +         addr = dr_mirror->addr[i];
5414           rc = 1;
5415           if (maint_show_dr)
5416             i386_show_dr ("watchpoint_hit", addr, -1, hw_write);
5417 @@ -689,6 +764,10 @@ i386_use_watchpoints (struct target_ops 
5418    t->to_remove_watchpoint = i386_remove_watchpoint;
5419    t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
5420    t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
5421 +
5422 +  if (i386_inferior_data == NULL)
5423 +    i386_inferior_data
5424 +      = register_inferior_data_with_cleanup (i386_inferior_data_cleanup);
5425  }
5426  
5427  void
5428 Index: gdb-7.2.90.20110703/gdb/i386-nat.h
5429 ===================================================================
5430 --- gdb-7.2.90.20110703.orig/gdb/i386-nat.h     2011-01-09 04:08:56.000000000 +0100
5431 +++ gdb-7.2.90.20110703/gdb/i386-nat.h  2011-07-03 10:33:11.000000000 +0200
5432 @@ -78,6 +78,28 @@ struct i386_dr_low_type 
5433  
5434  extern struct i386_dr_low_type i386_dr_low;
5435  
5436 +/* The number of debug address registers.  */
5437 +#define DR_NADDR       4
5438 +
5439 +/* Copy of hardware debug registers for performance reasons.  */
5440 +
5441 +struct i386_dr_mirror
5442 +  {
5443 +    /* Mirror the inferior's DRi registers.  We keep the status and
5444 +       control registers separated because they don't hold addresses.  */
5445 +    CORE_ADDR addr[DR_NADDR];
5446 +
5447 +    /* All the ADDR hardware registers have been written at least once.  */
5448 +    unsigned addr_preset : 1;
5449 +
5450 +    /* Reference counts for each debug register.  */
5451 +    int ref_count[DR_NADDR];
5452 +
5453 +    unsigned long status, control;
5454 +  };
5455 +
5456 +extern struct i386_dr_mirror *i386_dr_mirror_get (void);
5457 +
5458  /* Use this function to set i386_dr_low debug_register_length field
5459     rather than setting it directly to check that the length is only
5460     set once.  It also enables the 'maint set/show show-debug-regs' 
5461 Index: gdb-7.2.90.20110703/gdb/infrun.c
5462 ===================================================================
5463 --- gdb-7.2.90.20110703.orig/gdb/infrun.c       2011-06-03 17:32:13.000000000 +0200
5464 +++ gdb-7.2.90.20110703/gdb/infrun.c    2011-07-03 10:33:11.000000000 +0200
5465 @@ -54,6 +54,8 @@
5466  #include "inline-frame.h"
5467  #include "jit.h"
5468  #include "tracepoint.h"
5469 +#include "stap-probe.h"
5470 +#include "objfiles.h"
5471  
5472  /* Prototypes for local functions */
5473  
5474 @@ -2247,7 +2249,7 @@ static void insert_step_resume_breakpoin
5475                                                   struct frame_id);
5476  static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
5477  static void check_exception_resume (struct execution_control_state *,
5478 -                                   struct frame_info *, struct symbol *);
5479 +                                   struct frame_info *);
5480  
5481  static void stop_stepping (struct execution_control_state *ecs);
5482  static void prepare_to_wait (struct execution_control_state *ecs);
5483 @@ -4169,9 +4171,17 @@ process_event_stop_test:
5484  
5485         if (what.is_longjmp)
5486           {
5487 -           if (!gdbarch_get_longjmp_target_p (gdbarch)
5488 -               || !gdbarch_get_longjmp_target (gdbarch,
5489 -                                               frame, &jmp_buf_pc))
5490 +           struct value *arg_value;
5491 +
5492 +           /* If we set the longjmp breakpoint via a SystemTap probe,
5493 +              then use it to extract the arguments.  The destination
5494 +              PC is the third argument to the probe.  */
5495 +           arg_value = stap_safe_evaluate_at_pc (frame, 2);
5496 +           if (arg_value)
5497 +             jmp_buf_pc = value_as_address (arg_value);
5498 +           else if (!gdbarch_get_longjmp_target_p (gdbarch)
5499 +                    || !gdbarch_get_longjmp_target (gdbarch,
5500 +                                                    frame, &jmp_buf_pc))
5501               {
5502                 if (debug_infrun)
5503                   fprintf_unfiltered (gdb_stdlog,
5504 @@ -4189,12 +4199,7 @@ process_event_stop_test:
5505             insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
5506           }
5507         else
5508 -         {
5509 -           struct symbol *func = get_frame_function (frame);
5510 -
5511 -           if (func)
5512 -             check_exception_resume (ecs, frame, func);
5513 -         }
5514 +         check_exception_resume (ecs, frame);
5515         keep_going (ecs);
5516         return;
5517  
5518 @@ -5268,15 +5273,65 @@ insert_exception_resume_breakpoint (stru
5519      }
5520  }
5521  
5522 +/* A helper for check_exception_resume that sets an
5523 +   exception-breakpoint based on a SystemTap probe.  */
5524 +
5525 +static void
5526 +insert_exception_resume_from_probe (struct thread_info *tp,
5527 +                                   const struct stap_probe *probe,
5528 +                                   struct objfile *objfile,
5529 +                                   struct frame_info *frame)
5530 +{
5531 +  struct value *arg_value;
5532 +  CORE_ADDR handler;
5533 +  struct breakpoint *bp;
5534 +
5535 +  arg_value = stap_safe_evaluate_at_pc (frame, 1);
5536 +  if (!arg_value)
5537 +    return;
5538 +
5539 +  handler = value_as_address (arg_value);
5540 +
5541 +  if (debug_infrun)
5542 +    fprintf_unfiltered (gdb_stdlog,
5543 +                       "infrun: exception resume at %s\n",
5544 +                       paddress (get_objfile_arch (objfile),
5545 +                                 handler));
5546 +
5547 +  bp = set_momentary_breakpoint_at_pc (get_frame_arch (frame),
5548 +                                      handler, bp_exception_resume);
5549 +  bp->thread = tp->num;
5550 +  inferior_thread ()->control.exception_resume_breakpoint = bp;
5551 +}
5552 +
5553  /* This is called when an exception has been intercepted.  Check to
5554     see whether the exception's destination is of interest, and if so,
5555     set an exception resume breakpoint there.  */
5556  
5557  static void
5558  check_exception_resume (struct execution_control_state *ecs,
5559 -                       struct frame_info *frame, struct symbol *func)
5560 +                       struct frame_info *frame)
5561  {
5562    struct gdb_exception e;
5563 +  struct objfile *objfile;
5564 +  const struct stap_probe *probe;
5565 +  struct symbol *func;
5566 +
5567 +  /* First see if this exception unwinding breakpoint was set via a
5568 +     SystemTap probe point.  If so, the probe has two arguments: the
5569 +     CFA and the HANDLER.  We ignore the CFA, extract the handler, and
5570 +     set a breakpoint there.  */
5571 +  probe = find_probe_by_pc (get_frame_pc (frame), &objfile);
5572 +  if (probe)
5573 +    {
5574 +      insert_exception_resume_from_probe (ecs->event_thread, probe,
5575 +                                         objfile, frame);
5576 +      return;
5577 +    }
5578 +
5579 +  func = get_frame_function (frame);
5580 +  if (!func)
5581 +    return;
5582  
5583    TRY_CATCH (e, RETURN_MASK_ERROR)
5584      {
5585 @@ -6258,7 +6313,8 @@ static struct lval_funcs siginfo_value_f
5586     if there's no object available.  */
5587  
5588  static struct value *
5589 -siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
5590 +siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
5591 +                   void *ignore)
5592  {
5593    if (target_has_stack
5594        && !ptid_equal (inferior_ptid, null_ptid)
5595 @@ -6826,6 +6882,15 @@ show_schedule_multiple (struct ui_file *
5596                             "of all processes is %s.\n"), value);
5597  }
5598  
5599 +/* Implementation of `siginfo' variable.  */
5600 +
5601 +static const struct internalvar_funcs siginfo_funcs =
5602 +{
5603 +  siginfo_make_value,
5604 +  NULL,
5605 +  NULL
5606 +};
5607 +
5608  void
5609  _initialize_infrun (void)
5610  {
5611 @@ -7098,7 +7163,7 @@ Tells gdb whether to detach the child of
5612       value with a void typed value, and when we get here, gdbarch
5613       isn't initialized yet.  At this point, we're quite sure there
5614       isn't another convenience variable of the same name.  */
5615 -  create_internalvar_type_lazy ("_siginfo", siginfo_make_value);
5616 +  create_internalvar_type_lazy ("_siginfo", &siginfo_funcs, NULL);
5617  
5618    add_setshow_boolean_cmd ("observer", no_class,
5619                            &observer_mode_1, _("\
5620 Index: gdb-7.2.90.20110703/gdb/linespec.c
5621 ===================================================================
5622 --- gdb-7.2.90.20110703.orig/gdb/linespec.c     2011-07-02 22:13:08.000000000 +0200
5623 +++ gdb-7.2.90.20110703/gdb/linespec.c  2011-07-03 10:33:11.000000000 +0200
5624 @@ -43,6 +43,7 @@
5625  #include "arch-utils.h"
5626  #include <ctype.h>
5627  #include "cli/cli-utils.h"
5628 +#include "stap-probe.h"
5629  
5630  /* We share this one with symtab.c, but it is not exported widely.  */
5631  
5632 @@ -786,6 +787,7 @@ keep_name_info (char *p, int on_boundary
5633     PC returned is 0.
5634     FILE:FUNCTION -- likewise, but prefer functions in that file.
5635     *EXPR -- line in which address EXPR appears.
5636 +   probe:[OBJFILE:][PROVIDER:]NAME -- a systemtap static probe
5637  
5638     This may all be followed by an "if EXPR", which we ignore.
5639  
5640 @@ -854,6 +856,9 @@ decode_line_1 (char **argptr, int funfir
5641    if (**argptr == '*')
5642      return decode_indirect (argptr);
5643  
5644 +  if (strncmp (*argptr, "probe:", 6) == 0)
5645 +    return parse_stap_probe (argptr, canonical);
5646 +
5647    is_quoted = (strchr (get_gdb_completer_quote_characters (),
5648                        **argptr) != NULL);
5649  
5650 Index: gdb-7.2.90.20110703/gdb/linespec.h
5651 ===================================================================
5652 --- gdb-7.2.90.20110703.orig/gdb/linespec.h     2011-07-02 21:33:09.000000000 +0200
5653 +++ gdb-7.2.90.20110703/gdb/linespec.h  2011-07-03 10:33:11.000000000 +0200
5654 @@ -30,6 +30,10 @@ struct linespec_result
5655       display mechanism would do the wrong thing.  */
5656    int special_display;
5657  
5658 +  /* If non-zero, the linespec result should be considered to be a
5659 +     "pre-expanded" multi-location linespec.  */
5660 +  int pre_expanded;
5661 +
5662    /* If non-NULL, an array of canonical names for returned
5663       symtab_and_line objects.  The array has as many elements as the
5664       `nelts' field in the symtabs_and_line returned by decode_line_1.
5665 Index: gdb-7.2.90.20110703/gdb/linux-nat.c
5666 ===================================================================
5667 --- gdb-7.2.90.20110703.orig/gdb/linux-nat.c    2011-04-29 18:02:10.000000000 +0200
5668 +++ gdb-7.2.90.20110703/gdb/linux-nat.c 2011-07-03 10:33:11.000000000 +0200
5669 @@ -1272,6 +1272,64 @@ iterate_over_lwps (ptid_t filter,
5670    return NULL;
5671  }
5672  
5673 +/* Helper for linux_nat_iterate_watchpoint_lwps.  */
5674 +
5675 +struct iterate_watchpoint_lwps_data
5676 +  {
5677 +    linux_nat_iterate_watchpoint_lwps_ftype callback;
5678 +    void *callback_data;
5679 +  };
5680 +
5681 +static int
5682 +iterate_watchpoint_lwps_callback (struct lwp_info *lp, void *datap_voidp)
5683 +{
5684 +  struct iterate_watchpoint_lwps_data *datap = datap_voidp;
5685 +  int tid;
5686 +
5687 +  tid = TIDGET (lp->ptid);
5688 +  if (tid == 0)
5689 +    tid = PIDGET (lp->ptid);
5690 +
5691 +  datap->callback (tid, datap->callback_data);
5692 +
5693 +  /* Continue the traversal.  */
5694 +  return 0;
5695 +}
5696 +
5697 +/* Iterate like iterate_over_lwps does except when forking-off a child call
5698 +   CALLBACK with CALLBACK_DATA specifically only for that new child PID.
5699 +
5700 +   During `set follow-fork-mode child' the call is also made for the new child
5701 +   PID; parent watchpoints get detached elsewhere (during target_detach).  */
5702 +
5703 +void
5704 +linux_nat_iterate_watchpoint_lwps
5705 +  (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data)
5706 +{
5707 +  struct iterate_watchpoint_lwps_data data;
5708 +  int inferior_pid = ptid_get_pid (inferior_ptid);
5709 +  struct inferior *inf = current_inferior ();
5710 +
5711 +  data.callback = callback;
5712 +  data.callback_data = callback_data;
5713 +
5714 +  if (inf->pid == inferior_pid)
5715 +    {
5716 +      /* Standard mode.  Iterate all the threads of the current inferior.
5717 +        Without specifying INFERIOR_PID it would iterate all the threads of
5718 +        all the inferiors, which is inappropriate for watchpoints.  */
5719 +
5720 +      iterate_over_lwps (pid_to_ptid (inferior_pid),
5721 +                        iterate_watchpoint_lwps_callback, &data);
5722 +    }
5723 +  else
5724 +    {
5725 +      /* Detaching a new child PID temporarily present in INFERIOR_PID.  */
5726 +
5727 +      callback (inferior_pid, callback_data);
5728 +    }
5729 +}
5730 +
5731  /* Update our internal state when changing from one checkpoint to
5732     another indicated by NEW_PTID.  We can only switch single-threaded
5733     applications, so we only create one new LWP, and the previous list
5734 Index: gdb-7.2.90.20110703/gdb/linux-nat.h
5735 ===================================================================
5736 --- gdb-7.2.90.20110703.orig/gdb/linux-nat.h    2011-01-05 23:22:49.000000000 +0100
5737 +++ gdb-7.2.90.20110703/gdb/linux-nat.h 2011-07-03 10:33:11.000000000 +0200
5738 @@ -140,6 +140,11 @@ struct lwp_info *iterate_over_lwps (ptid
5739                                                      void *), 
5740                                     void *data);
5741  
5742 +typedef void (*linux_nat_iterate_watchpoint_lwps_ftype) (int tid, void *data);
5743 +
5744 +extern void linux_nat_iterate_watchpoint_lwps
5745 +  (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data);
5746 +
5747  /* Create a prototype generic GNU/Linux target.  The client can
5748     override it with local methods.  */
5749  struct target_ops * linux_target (void);
5750 Index: gdb-7.2.90.20110703/gdb/machoread.c
5751 ===================================================================
5752 --- gdb-7.2.90.20110703.orig/gdb/machoread.c    2011-03-07 17:17:29.000000000 +0100
5753 +++ gdb-7.2.90.20110703/gdb/machoread.c 2011-07-03 10:33:11.000000000 +0200
5754 @@ -849,6 +849,7 @@ static const struct sym_fns macho_sym_fn
5755    default_symfile_segments,    /* Get segment information from a file.  */
5756    NULL,
5757    macho_symfile_relocate,      /* Relocate a debug section.  */
5758 +  NULL,                                /* sym_get_probes */
5759    &psym_functions
5760  };
5761  
5762 Index: gdb-7.2.90.20110703/gdb/main.c
5763 ===================================================================
5764 --- gdb-7.2.90.20110703.orig/gdb/main.c 2011-03-07 19:34:31.000000000 +0100
5765 +++ gdb-7.2.90.20110703/gdb/main.c      2011-07-03 10:33:11.000000000 +0200
5766 @@ -39,6 +39,7 @@
5767  
5768  #include "interps.h"
5769  #include "main.h"
5770 +#include "python/python.h"
5771  #include "source.h"
5772  #include "cli/cli-cmds.h"
5773  #include "python/python.h"
5774 @@ -260,6 +261,8 @@ captured_main (void *data)
5775    char *cdarg = NULL;
5776    char *ttyarg = NULL;
5777  
5778 +  int python_script = 0;
5779 +
5780    /* These are static so that we can take their address in an
5781       initializer.  */
5782    static int print_help;
5783 @@ -451,10 +454,14 @@ captured_main (void *data)
5784        {"args", no_argument, &set_args, 1},
5785        {"l", required_argument, 0, 'l'},
5786        {"return-child-result", no_argument, &return_child_result, 1},
5787 +#if HAVE_PYTHON
5788 +      {"python", no_argument, 0, 'P'},
5789 +      {"P", no_argument, 0, 'P'},
5790 +#endif
5791        {0, no_argument, 0, 0}
5792      };
5793  
5794 -    while (1)
5795 +    while (!python_script)
5796        {
5797         int option_index;
5798  
5799 @@ -472,6 +479,9 @@ captured_main (void *data)
5800           case 0:
5801             /* Long option that just sets a flag.  */
5802             break;
5803 +         case 'P':
5804 +           python_script = 1;
5805 +           break;
5806           case OPT_SE:
5807             symarg = optarg;
5808             execarg = optarg;
5809 @@ -667,7 +677,31 @@ captured_main (void *data)
5810  
5811    /* Now that gdb_init has created the initial inferior, we're in
5812       position to set args for that inferior.  */
5813 -  if (set_args)
5814 +  if (python_script)
5815 +    {
5816 +      /* The first argument is a python script to evaluate, and
5817 +        subsequent arguments are passed to the script for
5818 +        processing there.  */
5819 +      if (optind >= argc)
5820 +       {
5821 +         fprintf_unfiltered (gdb_stderr,
5822 +                             _("%s: Python script file name required\n"),
5823 +                             argv[0]);
5824 +         exit (1);
5825 +       }
5826 +
5827 +      /* FIXME: should handle inferior I/O intelligently here.
5828 +        E.g., should be possible to run gdb in pipeline and have
5829 +        Python (and gdb) output go to stderr or file; and if a
5830 +        prompt is needed, open the tty.  */
5831 +      quiet = 1;
5832 +      /* FIXME: should read .gdbinit if, and only if, a prompt is
5833 +        requested by the script.  Though... maybe this is not
5834 +        ideal?  */
5835 +      /* FIXME: likewise, reading in history.  */
5836 +      inhibit_gdbinit = 1;
5837 +    }
5838 +  else if (set_args)
5839      {
5840        /* The remaining options are the command-line options for the
5841          inferior.  The first one is the sym/exec file, and the rest
5842 @@ -916,7 +950,8 @@ captured_main (void *data)
5843  
5844    /* Read in the old history after all the command files have been
5845       read.  */
5846 -  init_history ();
5847 +  if (!python_script)
5848 +    init_history ();
5849  
5850    if (batch_flag)
5851      {
5852 @@ -927,13 +962,25 @@ captured_main (void *data)
5853    /* Show time and/or space usage.  */
5854    do_cleanups (pre_stat_chain);
5855  
5856 -  /* NOTE: cagney/1999-11-07: There is probably no reason for not
5857 -     moving this loop and the code found in captured_command_loop()
5858 -     into the command_loop() proper.  The main thing holding back that
5859 -     change - SET_TOP_LEVEL() - has been eliminated.  */
5860 -  while (1)
5861 +#if HAVE_PYTHON
5862 +  if (python_script)
5863      {
5864 -      catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
5865 +      extern int pagination_enabled;
5866 +      pagination_enabled = 0;
5867 +      run_python_script (argc - optind, &argv[optind]);
5868 +      return 1;
5869 +    }
5870 +  else
5871 +#endif
5872 +    {
5873 +      /* NOTE: cagney/1999-11-07: There is probably no reason for not
5874 +        moving this loop and the code found in captured_command_loop()
5875 +        into the command_loop() proper.  The main thing holding back that
5876 +        change - SET_TOP_LEVEL() - has been eliminated. */
5877 +      while (1)
5878 +       {
5879 +         catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
5880 +       }
5881      }
5882    /* No exit -- exit is through quit_command.  */
5883  }
5884 @@ -965,7 +1012,12 @@ print_gdb_help (struct ui_file *stream)
5885    fputs_unfiltered (_("\
5886  This is the GNU debugger.  Usage:\n\n\
5887      gdb [options] [executable-file [core-file or process-id]]\n\
5888 -    gdb [options] --args executable-file [inferior-arguments ...]\n\n\
5889 +    gdb [options] --args executable-file [inferior-arguments ...]\n"), stream);
5890 +#if HAVE_PYTHON
5891 +  fputs_unfiltered (_("\
5892 +    gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream);
5893 +#endif
5894 +  fputs_unfiltered (_("\n\
5895  Options:\n\n\
5896  "), stream);
5897    fputs_unfiltered (_("\
5898 @@ -1003,7 +1055,13 @@ Options:\n\n\
5899    --nw              Do not use a window interface.\n\
5900    --nx               Do not read "), stream);
5901    fputs_unfiltered (gdbinit, stream);
5902 -  fputs_unfiltered (_(" file.\n\
5903 +  fputs_unfiltered (_(" file.\n"), stream);
5904 +#if HAVE_PYTHON
5905 +  fputs_unfiltered (_("\
5906 +  --python, -P       Following argument is Python script file; remaining\n\
5907 +                     arguments are passed to script.\n"), stream);
5908 +#endif
5909 +  fputs_unfiltered (_("\
5910    --quiet            Do not print version number on startup.\n\
5911    --readnow          Fully read symbol files on first access.\n\
5912  "), stream);
5913 Index: gdb-7.2.90.20110703/gdb/mi/mi-cmd-var.c
5914 ===================================================================
5915 --- gdb-7.2.90.20110703.orig/gdb/mi/mi-cmd-var.c        2011-01-12 22:09:39.000000000 +0100
5916 +++ gdb-7.2.90.20110703/gdb/mi/mi-cmd-var.c     2011-07-03 10:33:11.000000000 +0200
5917 @@ -707,7 +707,6 @@ mi_cmd_var_update (char *command, char *
5918      }
5919    else
5920      {
5921 -      /* Get varobj handle, if a valid var obj name was specified */
5922        struct varobj *var = varobj_get_handle (name);
5923  
5924        varobj_update_one (var, print_values, 1 /* explicit */);
5925 Index: gdb-7.2.90.20110703/gdb/mipsread.c
5926 ===================================================================
5927 --- gdb-7.2.90.20110703.orig/gdb/mipsread.c     2011-03-07 17:17:29.000000000 +0100
5928 +++ gdb-7.2.90.20110703/gdb/mipsread.c  2011-07-03 10:33:11.000000000 +0200
5929 @@ -402,6 +402,7 @@ static const struct sym_fns ecoff_sym_fn
5930    default_symfile_segments,    /* Get segment information from a file.  */
5931    NULL,
5932    default_symfile_relocate,    /* Relocate a debug section.  */
5933 +  NULL,                                /* sym_probe_fns */
5934    &psym_functions
5935  };
5936  
5937 Index: gdb-7.2.90.20110703/gdb/objfiles.c
5938 ===================================================================
5939 --- gdb-7.2.90.20110703.orig/gdb/objfiles.c     2011-04-25 23:25:18.000000000 +0200
5940 +++ gdb-7.2.90.20110703/gdb/objfiles.c  2011-07-03 10:33:11.000000000 +0200
5941 @@ -846,6 +846,11 @@ objfile_relocate1 (struct objfile *objfi
5942                                 obj_section_addr (s));
5943      }
5944  
5945 +  /* Relocating SystemTap probes.  */
5946 +  if (objfile->sf && objfile->sf->sym_probe_fns)
5947 +    objfile->sf->sym_probe_fns->sym_relocate_probe (objfile,
5948 +                                                   new_offsets, delta);
5949 +
5950    /* Data changed.  */
5951    return 1;
5952  }
5953 Index: gdb-7.2.90.20110703/gdb/p-valprint.c
5954 ===================================================================
5955 --- gdb-7.2.90.20110703.orig/gdb/p-valprint.c   2011-03-15 17:00:56.000000000 +0100
5956 +++ gdb-7.2.90.20110703/gdb/p-valprint.c        2011-07-03 10:33:11.000000000 +0200
5957 @@ -39,6 +39,7 @@
5958  #include "cp-abi.h"
5959  #include "cp-support.h"
5960  #include "exceptions.h"
5961 +#include "dwarf2loc.h"
5962  \f
5963  
5964  /* See val_print for a description of the various parameters of this
5965 @@ -63,8 +64,31 @@ pascal_val_print (struct type *type, con
5966    struct type *char_type;
5967    LONGEST val;
5968    CORE_ADDR addr;
5969 +  struct cleanup *back_to;
5970 +  struct type *saved_type = type;
5971 +  CORE_ADDR saved_address = address;
5972 +  
5973 +  back_to = make_cleanup (null_cleanup, 0);
5974 +  address += embedded_offset;
5975 +  type = object_address_get_data (type, &address);
5976 +  if (type == NULL)
5977 +    {
5978 +      fputs_filtered (object_address_data_not_valid (saved_type), stream);
5979 +      gdb_flush (stream);
5980 +      do_cleanups (back_to);
5981 +      return 0;
5982 +    }
5983 +  if (address != saved_address + embedded_offset)
5984 +    {
5985 +      size_t length = TYPE_LENGTH (type);
5986  
5987 -  CHECK_TYPEDEF (type);
5988 +      valaddr = xmalloc (length);
5989 +      make_cleanup (xfree, (gdb_byte *) valaddr);
5990 +      read_memory (address, (gdb_byte *) valaddr, length);
5991 +      embedded_offset = 0;
5992 +    }
5993 +  else
5994 +    address -= embedded_offset;
5995    switch (TYPE_CODE (type))
5996      {
5997      case TYPE_CODE_ARRAY:
5998 @@ -120,8 +144,8 @@ pascal_val_print (struct type *type, con
5999                 {
6000                   i = 0;
6001                 }
6002 -             val_print_array_elements (type, valaddr, embedded_offset,
6003 -                                       address, stream, recurse,
6004 +             val_print_array_elements (saved_type, valaddr, embedded_offset,
6005 +                                       saved_address, stream, recurse,
6006                                         original_value, options, i);
6007               fprintf_filtered (stream, "}");
6008             }
6009 @@ -160,6 +184,7 @@ pascal_val_print (struct type *type, con
6010           /* Try to print what function it points to.  */
6011           print_address_demangle (gdbarch, addr, stream, demangle);
6012           /* Return value is irrelevant except for string pointers.  */
6013 +         do_cleanups (back_to);
6014           return (0);
6015         }
6016  
6017 @@ -251,6 +276,7 @@ pascal_val_print (struct type *type, con
6018        /* Return number of characters printed, including the terminating
6019          '\0' if we reached the end.  val_print_string takes care including
6020          the terminating '\0' if necessary.  */
6021 +      do_cleanups (back_to);
6022        return i;
6023  
6024        break;
6025 @@ -567,6 +593,7 @@ pascal_val_print (struct type *type, con
6026              TYPE_CODE (type));
6027      }
6028    gdb_flush (stream);
6029 +  do_cleanups (back_to);
6030    return (0);
6031  }
6032  \f
6033 Index: gdb-7.2.90.20110703/gdb/parse.c
6034 ===================================================================
6035 --- gdb-7.2.90.20110703.orig/gdb/parse.c        2011-03-28 22:21:03.000000000 +0200
6036 +++ gdb-7.2.90.20110703/gdb/parse.c     2011-07-03 10:33:11.000000000 +0200
6037 @@ -1502,6 +1502,7 @@ parser_fprintf (FILE *x, const char *y, 
6038  
6039  int
6040  operator_check_standard (struct expression *exp, int pos,
6041 +                        int (*type_func) (struct type *type, void *data),
6042                          int (*objfile_func) (struct objfile *objfile,
6043                                               void *data),
6044                          void *data)
6045 @@ -1543,7 +1544,7 @@ operator_check_standard (struct expressi
6046             struct type *type = elts[pos + 2 + arg].type;
6047             struct objfile *objfile = TYPE_OBJFILE (type);
6048  
6049 -           if (objfile && (*objfile_func) (objfile, data))
6050 +           if (objfile && objfile_func && (*objfile_func) (objfile, data))
6051               return 1;
6052           }
6053        }
6054 @@ -1561,7 +1562,8 @@ operator_check_standard (struct expressi
6055  
6056         /* Check objfile where the variable itself is placed.
6057            SYMBOL_OBJ_SECTION (symbol) may be NULL.  */
6058 -       if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
6059 +       if (objfile_func
6060 +           && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
6061           return 1;
6062  
6063         /* Check objfile where is placed the code touching the variable.  */
6064 @@ -1574,24 +1576,27 @@ operator_check_standard (struct expressi
6065  
6066    /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL.  */
6067  
6068 -  if (type && TYPE_OBJFILE (type)
6069 +  if (type && type_func && (*type_func) (type, data))
6070 +    return 1;
6071 +  if (type && TYPE_OBJFILE (type) && objfile_func
6072        && (*objfile_func) (TYPE_OBJFILE (type), data))
6073      return 1;
6074 -  if (objfile && (*objfile_func) (objfile, data))
6075 +  if (objfile && objfile_func && (*objfile_func) (objfile, data))
6076      return 1;
6077  
6078    return 0;
6079  }
6080  
6081 -/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP.
6082 -   The functions are never called with NULL OBJFILE.  Functions get passed an
6083 -   arbitrary caller supplied DATA pointer.  If any of the functions returns
6084 -   non-zero value then (any other) non-zero value is immediately returned to
6085 -   the caller.  Otherwise zero is returned after iterating through whole EXP.
6086 -   */
6087 +/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being
6088 +   referenced by EXP.  The functions are never called with NULL TYPE or NULL
6089 +   OBJFILE.  Functions get passed an arbitrary caller supplied DATA pointer.
6090 +   If any of the functions returns non-zero value then (any other) non-zero
6091 +   value is immediately returned to the caller.  Otherwise zero is returned
6092 +   after iterating through whole EXP.  */
6093  
6094  static int
6095  exp_iterate (struct expression *exp,
6096 +            int (*type_func) (struct type *type, void *data),
6097              int (*objfile_func) (struct objfile *objfile, void *data),
6098              void *data)
6099  {
6100 @@ -1606,7 +1611,9 @@ exp_iterate (struct expression *exp,
6101  
6102        pos = endpos - oplen;
6103        if (exp->language_defn->la_exp_desc->operator_check (exp, pos,
6104 -                                                          objfile_func, data))
6105 +                                                          type_func,
6106 +                                                          objfile_func,
6107 +                                                          data))
6108         return 1;
6109  
6110        endpos = pos;
6111 @@ -1637,8 +1644,29 @@ exp_uses_objfile (struct expression *exp
6112  {
6113    gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
6114  
6115 -  return exp_iterate (exp, exp_uses_objfile_iter, objfile);
6116 +  return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile);
6117 +}
6118 +
6119 +/* Helper for exp_types_mark_used.  */
6120 +
6121 +#if 0
6122 +static int
6123 +exp_types_mark_used_iter (struct type *type, void *unused)
6124 +{
6125 +  type_mark_used (type);
6126 +
6127 +  /* Continue the traversal.  */
6128 +  return 0;
6129 +}
6130 +
6131 +/* Call type_mark_used for any type contained in EXP.  */
6132 +
6133 +void
6134 +exp_types_mark_used (struct expression *exp)
6135 +{
6136 +  exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL);
6137  }
6138 +#endif
6139  
6140  void
6141  _initialize_parse (void)
6142 Index: gdb-7.2.90.20110703/gdb/parser-defs.h
6143 ===================================================================
6144 --- gdb-7.2.90.20110703.orig/gdb/parser-defs.h  2011-01-10 21:38:49.000000000 +0100
6145 +++ gdb-7.2.90.20110703/gdb/parser-defs.h       2011-07-03 10:33:11.000000000 +0200
6146 @@ -194,6 +194,8 @@ extern void operator_length_standard (co
6147                                       int *);
6148  
6149  extern int operator_check_standard (struct expression *exp, int pos,
6150 +                                   int (*type_func) (struct type *type,
6151 +                                                     void *data),
6152                                     int (*objfile_func)
6153                                       (struct objfile *objfile, void *data),
6154                                     void *data);
6155 @@ -291,6 +293,7 @@ struct exp_descriptor
6156         value should be immediately returned to the caller.  Otherwise zero
6157         should be returned.  */
6158      int (*operator_check) (struct expression *exp, int pos,
6159 +                          int (*type_func) (struct type *type, void *data),
6160                            int (*objfile_func) (struct objfile *objfile,
6161                                                 void *data),
6162                            void *data);
6163 @@ -329,4 +332,10 @@ extern void parser_fprintf (FILE *, cons
6164  
6165  extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
6166  
6167 +extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
6168 +
6169 +#if 0
6170 +extern void exp_types_mark_used (struct expression *exp);
6171 +#endif
6172 +
6173  #endif /* PARSER_DEFS_H */
6174 Index: gdb-7.2.90.20110703/gdb/ppc-linux-nat.c
6175 ===================================================================
6176 --- gdb-7.2.90.20110703.orig/gdb/ppc-linux-nat.c        2011-04-18 23:29:18.000000000 +0200
6177 +++ gdb-7.2.90.20110703/gdb/ppc-linux-nat.c     2011-07-03 10:33:11.000000000 +0200
6178 @@ -1637,6 +1637,14 @@ booke_remove_point (struct ppc_hw_breakp
6179    hw_breaks[i].hw_break = NULL;
6180  }
6181  
6182 +static void
6183 +booke_insert_point_callback (int tid, void *pp_voidp)
6184 +{
6185 +  struct ppc_hw_breakpoint *pp = pp_voidp;
6186 +
6187 +  booke_insert_point (pp, tid);
6188 +}
6189 +
6190  /* Return the number of registers needed for a ranged breakpoint.  */
6191  
6192  static int
6193 @@ -1654,8 +1662,6 @@ static int
6194  ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
6195                                   struct bp_target_info *bp_tgt)
6196  {
6197 -  ptid_t ptid;
6198 -  struct lwp_info *lp;
6199    struct ppc_hw_breakpoint p;
6200  
6201    if (!have_ptrace_booke_interface ())
6202 @@ -1681,18 +1687,23 @@ ppc_linux_insert_hw_breakpoint (struct g
6203        p.addr2 = 0;
6204      }
6205  
6206 -  ALL_LWPS (lp, ptid)
6207 -    booke_insert_point (&p, TIDGET (ptid));
6208 +  linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
6209  
6210    return 0;
6211  }
6212  
6213 +static void
6214 +booke_remove_point_callback (int tid, void *pp_voidp)
6215 +{
6216 +  struct ppc_hw_breakpoint *pp = pp_voidp;
6217 +
6218 +  booke_remove_point (pp, tid);
6219 +}
6220 +
6221  static int
6222  ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
6223                                   struct bp_target_info *bp_tgt)
6224  {
6225 -  ptid_t ptid;
6226 -  struct lwp_info *lp;
6227    struct ppc_hw_breakpoint p;
6228  
6229    if (!have_ptrace_booke_interface ())
6230 @@ -1718,8 +1729,7 @@ ppc_linux_remove_hw_breakpoint (struct g
6231        p.addr2 = 0;
6232      }
6233  
6234 -  ALL_LWPS (lp, ptid)
6235 -    booke_remove_point (&p, TIDGET (ptid));
6236 +  linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
6237  
6238    return 0;
6239  }
6240 @@ -1946,6 +1956,15 @@ ppc_linux_can_accel_watchpoint_condition
6241           && check_condition (addr, cond, &data_value, &len));
6242  }
6243  
6244 +static void
6245 +set_saved_dabr_value_callback (int tid, void *retp_voidp)
6246 +{
6247 +  int *retp = retp_voidp;
6248 +
6249 +  if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value) < 0)
6250 +    *retp = -1;
6251 +}
6252 +
6253  /* Set up P with the parameters necessary to request a watchpoint covering
6254     LEN bytes starting at ADDR and if possible with condition expression COND
6255     evaluated by hardware.  INSERT tells if we are creating a request for
6256 @@ -2000,8 +2019,6 @@ static int
6257  ppc_linux_insert_watchpoint (CORE_ADDR addr, int len, int rw,
6258                              struct expression *cond)
6259  {
6260 -  struct lwp_info *lp;
6261 -  ptid_t ptid;
6262    int ret = -1;
6263  
6264    if (have_ptrace_booke_interface ())
6265 @@ -2010,8 +2027,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
6266  
6267        create_watchpoint_request (&p, addr, len, rw, cond, 1);
6268  
6269 -      ALL_LWPS (lp, ptid)
6270 -       booke_insert_point (&p, TIDGET (ptid));
6271 +      linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
6272  
6273        ret = 0;
6274      }
6275 @@ -2054,12 +2070,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
6276  
6277        saved_dabr_value = dabr_value;
6278  
6279 -      ALL_LWPS (lp, ptid)
6280 -       if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
6281 -                   saved_dabr_value) < 0)
6282 -         return -1;
6283 -
6284        ret = 0;
6285 +      linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret);
6286      }
6287  
6288    return ret;
6289 @@ -2069,8 +2081,6 @@ static int
6290  ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
6291                              struct expression *cond)
6292  {
6293 -  struct lwp_info *lp;
6294 -  ptid_t ptid;
6295    int ret = -1;
6296  
6297    if (have_ptrace_booke_interface ())
6298 @@ -2079,20 +2089,16 @@ ppc_linux_remove_watchpoint (CORE_ADDR a
6299  
6300        create_watchpoint_request (&p, addr, len, rw, cond, 0);
6301  
6302 -      ALL_LWPS (lp, ptid)
6303 -       booke_remove_point (&p, TIDGET (ptid));
6304 +      linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
6305  
6306        ret = 0;
6307      }
6308    else
6309      {
6310        saved_dabr_value = 0;
6311 -      ALL_LWPS (lp, ptid)
6312 -       if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
6313 -                   saved_dabr_value) < 0)
6314 -         return -1;
6315  
6316        ret = 0;
6317 +      linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret);
6318      }
6319  
6320    return ret;
6321 Index: gdb-7.2.90.20110703/gdb/printcmd.c
6322 ===================================================================
6323 --- gdb-7.2.90.20110703.orig/gdb/printcmd.c     2011-03-22 15:39:40.000000000 +0100
6324 +++ gdb-7.2.90.20110703/gdb/printcmd.c  2011-07-03 10:33:11.000000000 +0200
6325 @@ -975,6 +975,11 @@ print_command_1 (char *exp, int inspect,
6326    else
6327      val = access_value_history (0);
6328  
6329 +  /* Do not try to OBJECT_ADDRESS_SET here anything.  We are interested in the
6330 +     source variable base addresses as found by READ_VAR_VALUE.  The value here
6331 +     can be already a calculated expression address inappropriate for
6332 +     DW_OP_push_object_address.  */
6333 +
6334    if (voidprint || (val && value_type (val) &&
6335                     TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
6336      {
6337 @@ -1476,6 +1481,24 @@ x_command (char *exp, int from_tty)
6338         set_internalvar (lookup_internalvar ("__"), last_examine_value);
6339      }
6340  }
6341 +
6342 +#if 0
6343 +/* Call type_mark_used for any TYPEs referenced from this GDB source file.  */
6344 +
6345 +static void
6346 +print_types_mark_used (void)
6347 +{
6348 +  struct display *d;
6349 +
6350 +  if (last_examine_value)
6351 +    type_mark_used (value_type (last_examine_value));
6352 +
6353 +  for (d = display_chain; d; d = d->next)
6354 +    if (d->exp)
6355 +      exp_types_mark_used (d->exp);
6356 +}
6357 +#endif
6358 +
6359  \f
6360  
6361  /* Add an expression to the auto-display chain.
6362 @@ -2870,4 +2893,8 @@ Show printing of source filename and lin
6363    add_com ("eval", no_class, eval_command, _("\
6364  Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
6365  a command line, and call it."));
6366 +
6367 +#if 0
6368 +  observer_attach_mark_used (print_types_mark_used);
6369 +#endif
6370  }
6371 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameIterator.py
6372 ===================================================================
6373 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6374 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameIterator.py     2011-07-03 10:33:11.000000000 +0200
6375 @@ -0,0 +1,33 @@
6376 +# Iterator over frames.
6377 +
6378 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
6379 +
6380 +# This program is free software; you can redistribute it and/or modify
6381 +# it under the terms of the GNU General Public License as published by
6382 +# the Free Software Foundation; either version 3 of the License, or
6383 +# (at your option) any later version.
6384 +#
6385 +# This program is distributed in the hope that it will be useful,
6386 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6387 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6388 +# GNU General Public License for more details.
6389 +#
6390 +# You should have received a copy of the GNU General Public License
6391 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6392 +
6393 +class FrameIterator:
6394 +    """An iterator that iterates over frames."""
6395 +
6396 +    def __init__ (self, frame):
6397 +        "Initialize a FrameIterator.  FRAME is the starting frame."
6398 +        self.frame = frame
6399 +
6400 +    def __iter__ (self):
6401 +        return self
6402 +
6403 +    def next (self):
6404 +        result = self.frame
6405 +        if result is None:
6406 +            raise StopIteration
6407 +        self.frame = result.older ()
6408 +        return result
6409 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameWrapper.py
6410 ===================================================================
6411 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6412 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/FrameWrapper.py      2011-07-03 10:33:11.000000000 +0200
6413 @@ -0,0 +1,112 @@
6414 +# Wrapper API for frames.
6415 +
6416 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
6417 +
6418 +# This program is free software; you can redistribute it and/or modify
6419 +# it under the terms of the GNU General Public License as published by
6420 +# the Free Software Foundation; either version 3 of the License, or
6421 +# (at your option) any later version.
6422 +#
6423 +# This program is distributed in the hope that it will be useful,
6424 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6425 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6426 +# GNU General Public License for more details.
6427 +#
6428 +# You should have received a copy of the GNU General Public License
6429 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6430 +
6431 +import gdb
6432 +
6433 +# FIXME: arguably all this should be on Frame somehow.
6434 +class FrameWrapper:
6435 +    def __init__ (self, frame):
6436 +        self.frame = frame;
6437 +
6438 +    def write_symbol (self, stream, sym, block):
6439 +        if len (sym.linkage_name):
6440 +            nsym, is_field_of_this = gdb.lookup_symbol (sym.linkage_name, block)
6441 +            if nsym.addr_class != gdb.SYMBOL_LOC_REGISTER:
6442 +                sym = nsym
6443 +
6444 +        stream.write (sym.print_name + "=")
6445 +        try:
6446 +            val = self.read_var (sym)
6447 +            if val != None:
6448 +                val = str (val)
6449 +        # FIXME: would be nice to have a more precise exception here.
6450 +        except RuntimeError, text:
6451 +            val = text
6452 +        if val == None:
6453 +            stream.write ("???")
6454 +        else:
6455 +            stream.write (str (val))
6456 +
6457 +    def print_frame_locals (self, stream, func):
6458 +        if not func:
6459 +            return
6460 +
6461 +        first = True
6462 +        block = func.value
6463 +
6464 +        for sym in block:
6465 +            if sym.is_argument:
6466 +                continue;
6467 +
6468 +            self.write_symbol (stream, sym, block)
6469 +            stream.write ('\n')
6470 +
6471 +    def print_frame_args (self, stream, func):
6472 +        if not func:
6473 +            return
6474 +
6475 +        first = True
6476 +        block = func.value
6477 +
6478 +        for sym in block:
6479 +            if not sym.is_argument:
6480 +                continue;
6481 +
6482 +            if not first:
6483 +                stream.write (", ")
6484 +
6485 +            self.write_symbol (stream, sym, block)
6486 +            first = False
6487 +
6488 +    # FIXME: this should probably just be a method on gdb.Frame.
6489 +    # But then we need stream wrappers.
6490 +    def describe (self, stream, full):
6491 +        if self.type () == gdb.DUMMY_FRAME:
6492 +            stream.write (" <function called from gdb>\n")
6493 +        elif self.type () == gdb.SIGTRAMP_FRAME:
6494 +            stream.write (" <signal handler called>\n")
6495 +        else:
6496 +            sal = self.find_sal ()
6497 +            pc = self.pc ()
6498 +            name = self.name ()
6499 +            if not name:
6500 +                name = "??"
6501 +            if pc != sal.pc or not sal.symtab:
6502 +                stream.write (" 0x%08x in" % pc)
6503 +            stream.write (" " + name + " (")
6504 +
6505 +            func = self.function ()
6506 +            self.print_frame_args (stream, func)
6507 +
6508 +            stream.write (")")
6509 +
6510 +            if sal.symtab and sal.symtab.filename:
6511 +                stream.write (" at " + sal.symtab.filename)
6512 +                stream.write (":" + str (sal.line))
6513 +
6514 +            if not self.name () or (not sal.symtab or not sal.symtab.filename):
6515 +                lib = gdb.solib_address (pc)
6516 +                if lib:
6517 +                    stream.write (" from " + lib)
6518 +
6519 +            stream.write ("\n")
6520 +
6521 +            if full:
6522 +                self.print_frame_locals (stream, func)
6523 +
6524 +    def __getattr__ (self, name):
6525 +        return getattr (self.frame, name)
6526 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/backtrace.py
6527 ===================================================================
6528 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6529 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/backtrace.py 2011-07-03 10:33:11.000000000 +0200
6530 @@ -0,0 +1,42 @@
6531 +# Filtering backtrace.
6532 +
6533 +# Copyright (C) 2008, 2011 Free Software Foundation, Inc.
6534 +
6535 +# This program is free software; you can redistribute it and/or modify
6536 +# it under the terms of the GNU General Public License as published by
6537 +# the Free Software Foundation; either version 3 of the License, or
6538 +# (at your option) any later version.
6539 +#
6540 +# This program is distributed in the hope that it will be useful,
6541 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6542 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6543 +# GNU General Public License for more details.
6544 +#
6545 +# You should have received a copy of the GNU General Public License
6546 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6547 +
6548 +import gdb
6549 +import itertools
6550 +
6551 +# Our only exports.
6552 +__all__ = ['push_frame_filter', 'create_frame_filter']
6553 +
6554 +frame_filter = None
6555 +
6556 +def push_frame_filter (constructor):
6557 +    """Register a new backtrace filter class with the 'backtrace' command.
6558 +The filter will be passed an iterator as an argument.  The iterator
6559 +will return gdb.Frame-like objects.  The filter should in turn act as
6560 +an iterator returning such objects."""
6561 +    global frame_filter
6562 +    if frame_filter == None:
6563 +        frame_filter = constructor
6564 +    else:
6565 +        frame_filter = lambda iterator, filter = frame_filter: constructor (filter (iterator))
6566 +
6567 +def create_frame_filter (iter):
6568 +    global frame_filter
6569 +    if frame_filter is None:
6570 +        return iter
6571 +    return frame_filter (iter)
6572 +
6573 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/alias.py
6574 ===================================================================
6575 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6576 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/alias.py     2011-07-03 10:33:11.000000000 +0200
6577 @@ -0,0 +1,59 @@
6578 +# Alias command.
6579 +
6580 +# Copyright (C) 2008 Free Software Foundation, Inc.
6581 +
6582 +# This program is free software; you can redistribute it and/or modify
6583 +# it under the terms of the GNU General Public License as published by
6584 +# the Free Software Foundation; either version 3 of the License, or
6585 +# (at your option) any later version.
6586 +#
6587 +# This program is distributed in the hope that it will be useful,
6588 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6589 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6590 +# GNU General Public License for more details.
6591 +#
6592 +# You should have received a copy of the GNU General Public License
6593 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6594 +
6595 +import gdb
6596 +
6597 +class AliasImplementation (gdb.Command):
6598 +    def __init__ (self, name, real, doc):
6599 +        # Have to set __doc__ before the super init call.
6600 +        # It would be nice if gdb's help looked up __doc__ dynamically.
6601 +        self.__doc__ = doc
6602 +        # Note: no good way to complete :(
6603 +        super (AliasImplementation, self).__init__ (name, gdb.COMMAND_NONE)
6604 +        self.real = real
6605 +
6606 +    def invoke(self, arg, from_tty):
6607 +        gdb.execute (self.real + ' ' + arg, from_tty)
6608 +
6609 +class AliasCommand (gdb.Command):
6610 +    """Alias one command to another.
6611 +In the simplest form, the first word is the name of the alias, and
6612 +the remaining words are the the expansion.
6613 +An '=' by itself can be used to define a multi-word alias; words
6614 +before the '=' are the name of the new command."""
6615 +
6616 +    def __init__ (self):
6617 +        # Completion is not quite right here.
6618 +        super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
6619 +                                             gdb.COMPLETE_COMMAND)
6620 +
6621 +    def invoke (self, arg, from_tty):
6622 +        self.dont_repeat ()
6623 +        # Without some form of quoting we can't alias a multi-word
6624 +        # command to another command.
6625 +        args = arg.split()
6626 +        try:
6627 +            start = args.index ('=')
6628 +            end = start + 1
6629 +        except ValueError:
6630 +            start = 1
6631 +            end = 1
6632 +        target = " ".join(args[end:])
6633 +        AliasImplementation (" ".join (args[0:start]), target,
6634 +                             "This command is an alias for '%s'." % target)
6635 +
6636 +AliasCommand()
6637 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/backtrace.py
6638 ===================================================================
6639 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6640 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/backtrace.py 2011-07-03 10:33:11.000000000 +0200
6641 @@ -0,0 +1,106 @@
6642 +# New backtrace command.
6643 +
6644 +# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
6645 +
6646 +# This program is free software; you can redistribute it and/or modify
6647 +# it under the terms of the GNU General Public License as published by
6648 +# the Free Software Foundation; either version 3 of the License, or
6649 +# (at your option) any later version.
6650 +#
6651 +# This program is distributed in the hope that it will be useful,
6652 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6653 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6654 +# GNU General Public License for more details.
6655 +#
6656 +# You should have received a copy of the GNU General Public License
6657 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6658 +
6659 +import gdb
6660 +import gdb.backtrace
6661 +import itertools
6662 +from gdb.FrameIterator import FrameIterator
6663 +from gdb.FrameWrapper import FrameWrapper
6664 +import sys
6665 +
6666 +class ReverseBacktraceParameter (gdb.Parameter):
6667 +    """The new-backtrace command can show backtraces in 'reverse' order.
6668 +This means that the innermost frame will be printed last.
6669 +Note that reverse backtraces are more expensive to compute."""
6670 +
6671 +    set_doc = "Enable or disable reverse backtraces."
6672 +    show_doc = "Show whether backtraces will be printed in reverse order."
6673 +
6674 +    def __init__(self):
6675 +        gdb.Parameter.__init__ (self, "reverse-backtrace",
6676 +                                gdb.COMMAND_STACK, gdb.PARAM_BOOLEAN)
6677 +        # Default to compatibility with gdb.
6678 +        self.value = False
6679 +
6680 +class FilteringBacktrace (gdb.Command):
6681 +    """Print backtrace of all stack frames, or innermost COUNT frames.
6682 +With a negative argument, print outermost -COUNT frames.
6683 +Use of the 'full' qualifier also prints the values of the local variables.
6684 +Use of the 'raw' qualifier avoids any filtering by loadable modules.
6685 +"""
6686 +
6687 +    def __init__ (self):
6688 +        # FIXME: this is not working quite well enough to replace
6689 +        # "backtrace" yet.
6690 +        gdb.Command.__init__ (self, "new-backtrace", gdb.COMMAND_STACK)
6691 +        self.reverse = ReverseBacktraceParameter()
6692 +
6693 +    def reverse_iter (self, iter):
6694 +        result = []
6695 +        for item in iter:
6696 +            result.append (item)
6697 +        result.reverse()
6698 +        return result
6699 +
6700 +    def final_n (self, iter, x):
6701 +        result = []
6702 +        for item in iter:
6703 +            result.append (item)
6704 +        return result[x:]
6705 +
6706 +    def invoke (self, arg, from_tty):
6707 +        i = 0
6708 +        count = 0
6709 +        filter = True
6710 +        full = False
6711 +
6712 +        for word in arg.split (" "):
6713 +            if word == '':
6714 +                continue
6715 +            elif word == 'raw':
6716 +                filter = False
6717 +            elif word == 'full':
6718 +                full = True
6719 +            else:
6720 +                count = int (word)
6721 +
6722 +        # FIXME: provide option to start at selected frame
6723 +        # However, should still number as if starting from newest
6724 +        newest_frame = gdb.newest_frame()
6725 +        iter = itertools.imap (FrameWrapper,
6726 +                               FrameIterator (newest_frame))
6727 +        if filter:
6728 +            iter = gdb.backtrace.create_frame_filter (iter)
6729 +
6730 +        # Now wrap in an iterator that numbers the frames.
6731 +        iter = itertools.izip (itertools.count (0), iter)
6732 +
6733 +        # Reverse if the user wanted that.
6734 +        if self.reverse.value:
6735 +            iter = self.reverse_iter (iter)
6736 +
6737 +        # Extract sub-range user wants.
6738 +        if count < 0:
6739 +            iter = self.final_n (iter, count)
6740 +        elif count > 0:
6741 +            iter = itertools.islice (iter, 0, count)
6742 +
6743 +        for pair in iter:
6744 +            sys.stdout.write ("#%-2d" % pair[0])
6745 +            pair[1].describe (sys.stdout, full)
6746 +
6747 +FilteringBacktrace()
6748 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/ignore_errors.py
6749 ===================================================================
6750 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6751 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/ignore_errors.py     2011-07-03 10:33:11.000000000 +0200
6752 @@ -0,0 +1,37 @@
6753 +# Ignore errors in user commands.
6754 +
6755 +# Copyright (C) 2008 Free Software Foundation, Inc.
6756 +
6757 +# This program is free software; you can redistribute it and/or modify
6758 +# it under the terms of the GNU General Public License as published by
6759 +# the Free Software Foundation; either version 3 of the License, or
6760 +# (at your option) any later version.
6761 +#
6762 +# This program is distributed in the hope that it will be useful,
6763 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6764 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6765 +# GNU General Public License for more details.
6766 +#
6767 +# You should have received a copy of the GNU General Public License
6768 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6769 +
6770 +import gdb
6771 +
6772 +class IgnoreErrorsCommand (gdb.Command):
6773 +    """Execute a single command, ignoring all errors.
6774 +Only one-line commands are supported.
6775 +This is primarily useful in scripts."""
6776 +
6777 +    def __init__ (self):
6778 +        super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
6779 +                                                    gdb.COMMAND_OBSCURE,
6780 +                                                    # FIXME...
6781 +                                                    gdb.COMPLETE_COMMAND)
6782 +
6783 +    def invoke (self, arg, from_tty):
6784 +        try:
6785 +            gdb.execute (arg, from_tty)
6786 +        except:
6787 +            pass
6788 +
6789 +IgnoreErrorsCommand ()
6790 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/pahole.py
6791 ===================================================================
6792 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6793 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/pahole.py    2011-07-03 10:33:11.000000000 +0200
6794 @@ -0,0 +1,75 @@
6795 +# pahole command for gdb
6796 +
6797 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
6798 +
6799 +# This program is free software; you can redistribute it and/or modify
6800 +# it under the terms of the GNU General Public License as published by
6801 +# the Free Software Foundation; either version 3 of the License, or
6802 +# (at your option) any later version.
6803 +#
6804 +# This program is distributed in the hope that it will be useful,
6805 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6806 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6807 +# GNU General Public License for more details.
6808 +#
6809 +# You should have received a copy of the GNU General Public License
6810 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6811 +
6812 +import gdb
6813 +
6814 +class Pahole (gdb.Command):
6815 +    """Show the holes in a structure.
6816 +This command takes a single argument, a type name.
6817 +It prints the type and displays comments showing where holes are."""
6818 +
6819 +    def __init__ (self):
6820 +        super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
6821 +                                       gdb.COMPLETE_SYMBOL)
6822 +
6823 +    def pahole (self, type, level, name):
6824 +        if name is None:
6825 +            name = ''
6826 +        tag = type.tag
6827 +        if tag is None:
6828 +            tag = ''
6829 +        print '%sstruct %s {' % (' ' * (2 * level), tag)
6830 +        bitpos = 0
6831 +        for field in type.fields ():
6832 +            # Skip static fields.
6833 +            if not hasattr (field, ('bitpos')):
6834 +                continue
6835 +
6836 +            ftype = field.type.strip_typedefs()
6837 +
6838 +            if bitpos != field.bitpos:
6839 +                hole = field.bitpos - bitpos
6840 +                print '  /* XXX %d bit hole, try to pack */' % hole
6841 +                bitpos = field.bitpos
6842 +            if field.bitsize > 0:
6843 +                fieldsize = field.bitsize
6844 +            else:
6845 +                # TARGET_CHAR_BIT here...
6846 +                fieldsize = 8 * ftype.sizeof
6847 +
6848 +            # TARGET_CHAR_BIT
6849 +            print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
6850 +            bitpos = bitpos + fieldsize
6851 +
6852 +            if ftype.code == gdb.TYPE_CODE_STRUCT:
6853 +                self.pahole (ftype, level + 1, field.name)
6854 +            else:
6855 +                print ' ' * (2 + 2 * level),
6856 +                print '%s %s' % (str (ftype), field.name)
6857 +
6858 +        print ' ' * (14 + 2 * level),
6859 +        print '} %s' % name
6860 +
6861 +    def invoke (self, arg, from_tty):
6862 +        type = gdb.lookup_type (arg)
6863 +        type = type.strip_typedefs ()
6864 +        if type.code != gdb.TYPE_CODE_STRUCT:
6865 +            raise TypeError, '%s is not a struct type' % arg
6866 +        print ' ' * 14,
6867 +        self.pahole (type, 0, '')
6868 +
6869 +Pahole()
6870 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/require.py
6871 ===================================================================
6872 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6873 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/require.py   2011-07-03 10:33:11.000000000 +0200
6874 @@ -0,0 +1,57 @@
6875 +# Demand-loading commands.
6876 +
6877 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
6878 +
6879 +# This program is free software; you can redistribute it and/or modify
6880 +# it under the terms of the GNU General Public License as published by
6881 +# the Free Software Foundation; either version 3 of the License, or
6882 +# (at your option) any later version.
6883 +#
6884 +# This program is distributed in the hope that it will be useful,
6885 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6886 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6887 +# GNU General Public License for more details.
6888 +#
6889 +# You should have received a copy of the GNU General Public License
6890 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6891 +
6892 +import gdb
6893 +import os
6894 +
6895 +class RequireCommand (gdb.Command):
6896 +    """Prefix command for requiring features."""
6897 +
6898 +    def __init__ (self):
6899 +        super (RequireCommand, self).__init__ ("require",
6900 +                                               gdb.COMMAND_SUPPORT,
6901 +                                               gdb.COMPLETE_NONE,
6902 +                                               True)
6903 +
6904 +class RequireSubcommand (gdb.Command):
6905 +    """Demand-load a command by name."""
6906 +
6907 +    def __init__ (self, name):
6908 +        self.__doc__ = "Demand-load a %s by name." % name
6909 +        super (RequireSubcommand, self).__init__ ("require %s" % name,
6910 +                                                  gdb.COMMAND_SUPPORT)
6911 +        self.name = name
6912 +
6913 +    def invoke (self, arg, from_tty):
6914 +        for cmd in arg.split():
6915 +            exec ('import gdb.' + self.name + '.' + cmd, globals ())
6916 +
6917 +    def complete (self, text, word):
6918 +        dir = gdb.pythondir + '/gdb/' + self.name
6919 +        result = []
6920 +        for file in os.listdir(dir):
6921 +            if not file.startswith (word) or not file.endswith ('.py'):
6922 +                continue
6923 +            feature = file[0:-3]
6924 +            if feature == 'require' or feature == '__init__':
6925 +                continue
6926 +            result.append (feature)
6927 +        return result
6928 +
6929 +RequireCommand()
6930 +RequireSubcommand("command")
6931 +RequireSubcommand("function")
6932 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/command/upto.py
6933 ===================================================================
6934 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
6935 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/command/upto.py      2011-07-03 10:33:11.000000000 +0200
6936 @@ -0,0 +1,129 @@
6937 +# upto command.
6938 +
6939 +# Copyright (C) 2009 Free Software Foundation, Inc.
6940 +
6941 +# This program is free software; you can redistribute it and/or modify
6942 +# it under the terms of the GNU General Public License as published by
6943 +# the Free Software Foundation; either version 3 of the License, or
6944 +# (at your option) any later version.
6945 +#
6946 +# This program is distributed in the hope that it will be useful,
6947 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6948 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6949 +# GNU General Public License for more details.
6950 +#
6951 +# You should have received a copy of the GNU General Public License
6952 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
6953 +
6954 +import gdb
6955 +import re
6956 +from gdb.FrameIterator import FrameIterator
6957 +from gdb.FrameWrapper import FrameWrapper
6958 +
6959 +class UptoPrefix (gdb.Command):
6960 +    def __init__ (self):
6961 +        super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK,
6962 +                                           prefix = True)
6963 +
6964 +class UptoImplementation (gdb.Command):
6965 +    def __init__ (self, subcommand):
6966 +        super (UptoImplementation, self).__init__ ("upto " + subcommand,
6967 +                                                   gdb.COMMAND_STACK)
6968 +
6969 +    def search (self):
6970 +        saved = gdb.selected_frame ()
6971 +        iter = FrameIterator (saved)
6972 +        found = False
6973 +        try:
6974 +            for frame in iter:
6975 +                frame.select ()
6976 +                try:
6977 +                    if self.filter (frame):
6978 +                        wrapper = FrameWrapper (frame)
6979 +                        wrapper.describe (sys.stdout, False)
6980 +                        return
6981 +                except:
6982 +                    pass
6983 +        except:
6984 +            pass
6985 +        saved.select ()
6986 +        raise RuntimeError, 'Could not find a matching frame'
6987 +
6988 +    def invoke (self, arg, from_tty):
6989 +        self.rx = re.compile (arg)
6990 +        self.search ()
6991 +
6992 +class UptoSymbolCommand (UptoImplementation):
6993 +    """Select and print some calling stack frame, based on symbol.
6994 +The argument is a regular expression.  This command moves up the
6995 +stack, stopping at the first frame whose symbol matches the regular
6996 +expression."""
6997 +
6998 +    def __init__ (self):
6999 +        super (UptoSymbolCommand, self).__init__ ("symbol")
7000 +
7001 +    def filter (self, frame):
7002 +        name = frame.name ()
7003 +        if name is not None:
7004 +            if self.rx.search (name) is not None:
7005 +                return True
7006 +        return False
7007 +
7008 +class UptoSourceCommand (UptoImplementation):
7009 +    """Select and print some calling stack frame, based on source file.
7010 +The argument is a regular expression.  This command moves up the
7011 +stack, stopping at the first frame whose source file name matches the
7012 +regular expression."""
7013 +
7014 +    def __init__ (self):
7015 +        super (UptoSourceCommand, self).__init__ ("source")
7016 +
7017 +    def filter (self, frame):
7018 +        name = frame.find_sal ().symtab.filename
7019 +        if name is not None:
7020 +            if self.rx.search (name) is not None:
7021 +                return True
7022 +        return False
7023 +
7024 +class UptoObjectCommand (UptoImplementation):
7025 +    """Select and print some calling stack frame, based on object file.
7026 +The argument is a regular expression.  This command moves up the
7027 +stack, stopping at the first frame whose object file name matches the
7028 +regular expression."""
7029 +
7030 +    def __init__ (self):
7031 +        super (UptoObjectCommand, self).__init__ ("object")
7032 +
7033 +    def filter (self, frame):
7034 +        name = frame.find_sal ().symtab.objfile.filename
7035 +        if name is not None:
7036 +            if self.rx.search (name) is not None:
7037 +                return True
7038 +        return False
7039 +
7040 +class UptoWhereCommand (UptoImplementation):
7041 +    """Select and print some calling stack frame, based on expression.
7042 +The argument is an expression.  This command moves up the stack,
7043 +parsing and evaluating the expression in each frame.  This stops when
7044 +the expression evaluates to a non-zero (true) value."""
7045 +
7046 +    def __init__ (self):
7047 +        super (UptoWhereCommand, self).__init__ ("where")
7048 +
7049 +    def filter (self, frame):
7050 +        try:
7051 +            if gdb.parse_and_eval (self.expression):
7052 +                return True
7053 +        except:
7054 +            pass
7055 +        return False
7056 +
7057 +    def invoke (self, arg, from_tty):
7058 +        self.expression = arg
7059 +        self.search ()
7060 +
7061 +UptoPrefix ()
7062 +UptoSymbolCommand ()
7063 +UptoSourceCommand ()
7064 +UptoObjectCommand ()
7065 +UptoWhereCommand ()
7066 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/__init__.py
7067 ===================================================================
7068 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
7069 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/__init__.py 2011-07-03 10:33:11.000000000 +0200
7070 @@ -0,0 +1 @@
7071 +
7072 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/caller_is.py
7073 ===================================================================
7074 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
7075 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/caller_is.py        2011-07-03 10:33:11.000000000 +0200
7076 @@ -0,0 +1,58 @@
7077 +# Caller-is functions.
7078 +
7079 +# Copyright (C) 2008 Free Software Foundation, Inc.
7080 +
7081 +# This program is free software; you can redistribute it and/or modify
7082 +# it under the terms of the GNU General Public License as published by
7083 +# the Free Software Foundation; either version 3 of the License, or
7084 +# (at your option) any later version.
7085 +#
7086 +# This program is distributed in the hope that it will be useful,
7087 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
7088 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7089 +# GNU General Public License for more details.
7090 +#
7091 +# You should have received a copy of the GNU General Public License
7092 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7093 +
7094 +import gdb
7095 +import re
7096 +
7097 +class CallerIs (gdb.Function):
7098 +    """Return True if the calling function's name is equal to a string.
7099 +This function takes one or two arguments.
7100 +The first argument is the name of a function; if the calling function's
7101 +name is equal to this argument, this function returns True.
7102 +The optional second argument tells this function how many stack frames
7103 +to traverse to find the calling function.  The default is 1."""
7104 +
7105 +    def __init__ (self):
7106 +        super (CallerIs, self).__init__ ("caller_is")
7107 +
7108 +    def invoke (self, name, nframes = 1):
7109 +        frame = gdb.selected_frame ()
7110 +        while nframes > 0:
7111 +            frame = frame.older ()
7112 +            nframes = nframes - 1
7113 +        return frame.name () == name.string ()
7114 +
7115 +class CallerMatches (gdb.Function):
7116 +    """Return True if the calling function's name matches a string.
7117 +This function takes one or two arguments.
7118 +The first argument is a regular expression; if the calling function's
7119 +name is matched by this argument, this function returns True.
7120 +The optional second argument tells this function how many stack frames
7121 +to traverse to find the calling function.  The default is 1."""
7122 +
7123 +    def __init__ (self):
7124 +        super (CallerMatches, self).__init__ ("caller_matches")
7125 +
7126 +    def invoke (self, name, nframes = 1):
7127 +        frame = gdb.selected_frame ()
7128 +        while nframes > 0:
7129 +            frame = frame.older ()
7130 +            nframes = nframes - 1
7131 +        return re.match (name.string (), frame.name ()) is not None
7132 +
7133 +CallerIs()
7134 +CallerMatches()
7135 Index: gdb-7.2.90.20110703/gdb/python/lib/gdb/function/in_scope.py
7136 ===================================================================
7137 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
7138 +++ gdb-7.2.90.20110703/gdb/python/lib/gdb/function/in_scope.py 2011-07-03 10:33:11.000000000 +0200
7139 @@ -0,0 +1,47 @@
7140 +# In-scope function.
7141 +
7142 +# Copyright (C) 2008 Free Software Foundation, Inc.
7143 +
7144 +# This program is free software; you can redistribute it and/or modify
7145 +# it under the terms of the GNU General Public License as published by
7146 +# the Free Software Foundation; either version 3 of the License, or
7147 +# (at your option) any later version.
7148 +#
7149 +# This program is distributed in the hope that it will be useful,
7150 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
7151 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7152 +# GNU General Public License for more details.
7153 +#
7154 +# You should have received a copy of the GNU General Public License
7155 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7156 +
7157 +import gdb
7158 +
7159 +class InScope (gdb.Function):
7160 +    """Return True if all the given variables or macros are in scope.
7161 +Takes one argument for each variable name to be checked."""
7162 +
7163 +    def __init__ (self):
7164 +       super (InScope, self).__init__ ("in_scope")
7165 +
7166 +    def invoke (self, *vars):
7167 +        if len (vars) == 0:
7168 +           raise TypeError, "in_scope takes at least one argument"
7169 +
7170 +        # gdb.Value isn't hashable so it can't be put in a map.
7171 +       # Convert to string first.
7172 +       wanted = set (map (lambda x: x.string (), vars))
7173 +       found = set ()
7174 +       block = gdb.selected_frame ().block ()
7175 +       while block:
7176 +           for sym in block:
7177 +               if (sym.is_argument or sym.is_constant
7178 +                     or sym.is_function or sym.is_variable):
7179 +                   if sym.name in wanted:
7180 +                       found.add (sym.name)
7181 +
7182 +           block = block.superblock
7183 +
7184 +       return wanted == found
7185 +
7186 +InScope ()
7187 Index: gdb-7.2.90.20110703/gdb/python/py-type.c
7188 ===================================================================
7189 --- gdb-7.2.90.20110703.orig/gdb/python/py-type.c       2011-01-26 21:53:45.000000000 +0100
7190 +++ gdb-7.2.90.20110703/gdb/python/py-type.c    2011-07-03 10:33:11.000000000 +0200
7191 @@ -29,6 +29,8 @@
7192  #include "language.h"
7193  #include "vec.h"
7194  #include "bcache.h"
7195 +#include "observer.h"
7196 +#include "gdb_assert.h"
7197  
7198  typedef struct pyty_type_object
7199  {
7200 @@ -37,11 +39,19 @@ typedef struct pyty_type_object
7201  
7202    /* If a Type object is associated with an objfile, it is kept on a
7203       doubly-linked list, rooted in the objfile.  This lets us copy the
7204 -     underlying struct type when the objfile is deleted.  */
7205 +     underlying struct type when the objfile is deleted.
7206 +
7207 +     With NULL objfile Type still can be doubly-linked in the list
7208 +     PYTY_OBJECTS_DISCARDABLE.  */
7209    struct pyty_type_object *prev;
7210    struct pyty_type_object *next;
7211  } type_object;
7212  
7213 +#if 0
7214 +/* First element of a doubly-linked list of TYPE_DISCARDABLE Types.  */
7215 +static type_object *pyty_objects_discardable;
7216 +#endif
7217 +
7218  static PyTypeObject type_object_type;
7219  
7220  /* A Field object.  */
7221 @@ -919,8 +929,63 @@ typy_richcompare (PyObject *self, PyObje
7222  
7223  \f
7224  
7225 +/* Key associated with each objfile pointing to the first element of
7226 +   a doubly-linked list of Types associated with this objfile.  */
7227  static const struct objfile_data *typy_objfile_data_key;
7228  
7229 +/* Link TYPE_OBJ to its appropriate list.  Either to its objfile associated one
7230 +   or at least to the global list for TYPE_DISCARDABLE Types.  Permanent types
7231 +   do not get linked anywhere.  */
7232 +static void
7233 +typy_link (type_object *type_obj)
7234 +{
7235 +  type_obj->prev = NULL;
7236 +
7237 +  if (type_obj->type && TYPE_OBJFILE (type_obj->type))
7238 +    {
7239 +      struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
7240 +
7241 +      type_obj->next = objfile_data (objfile, typy_objfile_data_key);
7242 +      if (type_obj->next)
7243 +       type_obj->next->prev = type_obj;
7244 +      set_objfile_data (objfile, typy_objfile_data_key, type_obj);
7245 +    }
7246 +#if 0
7247 +  else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type))
7248 +    {
7249 +      type_obj->next = pyty_objects_discardable;
7250 +      if (type_obj->next)
7251 +       type_obj->next->prev = type_obj;
7252 +      pyty_objects_discardable = type_obj;
7253 +    }
7254 +#endif
7255 +  else
7256 +    type_obj->next = NULL;
7257 +}
7258 +
7259 +/* Unlink TYPE_OBJ from its current list.  Permanent types are not linked
7260 +   anywhere and this function has no effect on them.  */
7261 +static void
7262 +typy_unlink (type_object *type_obj)
7263 +{
7264 +  if (type_obj->prev)
7265 +    type_obj->prev->next = type_obj->next;
7266 +  else if (type_obj->type && TYPE_OBJFILE (type_obj->type))
7267 +    {
7268 +      /* Must reset head of list.  */
7269 +      struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
7270 +
7271 +      set_objfile_data (objfile, typy_objfile_data_key, type_obj->next);
7272 +    }
7273 +#if 0
7274 +  else if (pyty_objects_discardable == type_obj)
7275 +    pyty_objects_discardable = type_obj->next;
7276 +#endif
7277 +
7278 +  if (type_obj->next)
7279 +    type_obj->next->prev = type_obj->prev;
7280 +}
7281 +
7282  static void
7283  save_objfile_types (struct objfile *objfile, void *datum)
7284  {
7285 @@ -938,12 +1003,13 @@ save_objfile_types (struct objfile *objf
7286      {
7287        type_object *next = obj->next;
7288  
7289 -      htab_empty (copied_types);
7290 +      gdb_assert (TYPE_OBJFILE (obj->type) == objfile);
7291 +      typy_unlink (obj);
7292  
7293 -      obj->type = copy_type_recursive (objfile, obj->type, copied_types);
7294 +      obj->type = copy_type_recursive (obj->type, copied_types);
7295  
7296 -      obj->next = NULL;
7297 -      obj->prev = NULL;
7298 +      gdb_assert (TYPE_OBJFILE (obj->type) == NULL);
7299 +      typy_link (obj);
7300  
7301        obj = next;
7302      }
7303 @@ -954,43 +1020,28 @@ save_objfile_types (struct objfile *objf
7304  }
7305  
7306  static void
7307 -set_type (type_object *obj, struct type *type)
7308 +typy_dealloc (PyObject *obj)
7309  {
7310 -  obj->type = type;
7311 -  obj->prev = NULL;
7312 -  if (type && TYPE_OBJFILE (type))
7313 -    {
7314 -      struct objfile *objfile = TYPE_OBJFILE (type);
7315 -
7316 -      obj->next = objfile_data (objfile, typy_objfile_data_key);
7317 -      if (obj->next)
7318 -       obj->next->prev = obj;
7319 -      set_objfile_data (objfile, typy_objfile_data_key, obj);
7320 -    }
7321 -  else
7322 -    obj->next = NULL;
7323 +  type_object *type_obj = (type_object *) obj;
7324 +
7325 +  typy_unlink (type_obj);
7326 +
7327 +  type_obj->ob_type->tp_free (obj);
7328  }
7329  
7330 +#if 0
7331 +/* Call type_mark_used for any TYPEs referenced from this GDB source file.  */
7332  static void
7333 -typy_dealloc (PyObject *obj)
7334 +typy_types_mark_used (void)
7335  {
7336 -  type_object *type = (type_object *) obj;
7337 -
7338 -  if (type->prev)
7339 -    type->prev->next = type->next;
7340 -  else if (type->type && TYPE_OBJFILE (type->type))
7341 -    {
7342 -      /* Must reset head of list.  */
7343 -      struct objfile *objfile = TYPE_OBJFILE (type->type);
7344 -
7345 -      if (objfile)
7346 -       set_objfile_data (objfile, typy_objfile_data_key, type->next);
7347 -    }
7348 -  if (type->next)
7349 -    type->next->prev = type->prev;
7350 +  type_object *type_obj;
7351  
7352 -  type->ob_type->tp_free (type);
7353 +  for (type_obj = pyty_objects_discardable;
7354 +       type_obj != NULL;
7355 +       type_obj = type_obj->next)
7356 +    type_mark_used (type_obj->type);
7357  }
7358 +#endif
7359  
7360  /* Create a new Type referring to TYPE.  */
7361  PyObject *
7362 @@ -1000,7 +1051,10 @@ type_to_type_object (struct type *type)
7363  
7364    type_obj = PyObject_New (type_object, &type_object_type);
7365    if (type_obj)
7366 -    set_type (type_obj, type);
7367 +    {
7368 +      type_obj->type = type;
7369 +      typy_link (type_obj);
7370 +    }
7371  
7372    return (PyObject *) type_obj;
7373  }
7374 @@ -1074,6 +1128,10 @@ gdbpy_initialize_types (void)
7375  
7376    Py_INCREF (&field_object_type);
7377    PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
7378 +
7379 +#if 0
7380 +  observer_attach_mark_used (typy_types_mark_used);
7381 +#endif
7382  }
7383  
7384  \f
7385 Index: gdb-7.2.90.20110703/gdb/python/py-value.c
7386 ===================================================================
7387 --- gdb-7.2.90.20110703.orig/gdb/python/py-value.c      2011-03-18 17:09:57.000000000 +0100
7388 +++ gdb-7.2.90.20110703/gdb/python/py-value.c   2011-07-03 10:33:11.000000000 +0200
7389 @@ -28,6 +28,7 @@
7390  #include "infcall.h"
7391  #include "expression.h"
7392  #include "cp-abi.h"
7393 +#include "observer.h"
7394  
7395  #ifdef HAVE_PYTHON
7396  
7397 @@ -1210,6 +1211,19 @@ gdbpy_is_value_object (PyObject *obj)
7398    return PyObject_TypeCheck (obj, &value_object_type);
7399  }
7400  
7401 +#if 0
7402 +/* Call type_mark_used for any TYPEs referenced from this GDB source file.  */
7403 +
7404 +static void
7405 +python_types_mark_used (void)
7406 +{
7407 +  value_object *iter;
7408 +
7409 +  for (iter = values_in_python; iter; iter = iter->next)
7410 +    type_mark_used (value_type (iter->value));
7411 +}
7412 +#endif
7413 +
7414  void
7415  gdbpy_initialize_values (void)
7416  {
7417 @@ -1220,6 +1234,10 @@ gdbpy_initialize_values (void)
7418    PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
7419  
7420    values_in_python = NULL;
7421 +
7422 +#if 0
7423 +  observer_attach_mark_used (python_types_mark_used);
7424 +#endif
7425  }
7426  
7427  \f
7428 Index: gdb-7.2.90.20110703/gdb/python/python.c
7429 ===================================================================
7430 --- gdb-7.2.90.20110703.orig/gdb/python/python.c        2011-07-02 21:33:10.000000000 +0200
7431 +++ gdb-7.2.90.20110703/gdb/python/python.c     2011-07-03 10:33:11.000000000 +0200
7432 @@ -49,8 +49,11 @@ static int gdbpy_should_print_stack = 1;
7433  #include "linespec.h"
7434  #include "source.h"
7435  #include "version.h"
7436 +#include "inferior.h"
7437 +#include "gdbthread.h"
7438  #include "target.h"
7439  #include "gdbthread.h"
7440 +#include "event-top.h"
7441  
7442  static PyMethodDef GdbMethods[];
7443  
7444 @@ -769,6 +772,53 @@ gdbpy_print_stack (void)
7445  
7446  /* Return the current Progspace.
7447     There always is one.  */
7448 +/* True if 'gdb -P' was used, false otherwise.  */
7449 +static int running_python_script;
7450 +
7451 +/* True if we are currently in a call to 'gdb.cli', false otherwise.  */
7452 +static int in_cli;
7453 +
7454 +/* Enter the command loop.  */
7455 +
7456 +static PyObject *
7457 +gdbpy_cli (PyObject *unused1, PyObject *unused2)
7458 +{
7459 +  if (! running_python_script || in_cli)
7460 +    return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
7461 +
7462 +  in_cli = 1;
7463 +  cli_command_loop ();
7464 +  in_cli = 0;
7465 +
7466 +  Py_RETURN_NONE;
7467 +}
7468 +
7469 +/* Set up the Python argument vector and evaluate a script.  This is
7470 +   used to implement 'gdb -P'.  */
7471 +
7472 +void
7473 +run_python_script (int argc, char **argv)
7474 +{
7475 +  FILE *input;
7476 +
7477 +  /* We never free this, since we plan to exit at the end.  */
7478 +  ensure_python_env (get_current_arch (), current_language);
7479 +
7480 +  running_python_script = 1;
7481 +  PySys_SetArgv (argc - 1, argv + 1);
7482 +  input = fopen (argv[0], "r");
7483 +  if (! input)
7484 +    {
7485 +      fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno));
7486 +      exit (1);
7487 +    }
7488 +  PyRun_SimpleFile (input, argv[0]);
7489 +  fclose (input);
7490 +  exit (0);
7491 +}
7492 +
7493 +\f
7494 +
7495  
7496  static PyObject *
7497  gdbpy_get_current_progspace (PyObject *unused1, PyObject *unused2)
7498 @@ -1194,6 +1244,8 @@ static PyMethodDef GdbMethods[] =
7499      "Get a value from history" },
7500    { "execute", (PyCFunction) execute_gdb_command, METH_VARARGS | METH_KEYWORDS,
7501      "Execute a gdb command" },
7502 +  { "cli", gdbpy_cli, METH_NOARGS,
7503 +    "Enter the gdb CLI" },
7504    { "parameter", gdbpy_parameter, METH_VARARGS,
7505      "Return a gdb parameter's value" },
7506  
7507 Index: gdb-7.2.90.20110703/gdb/python/python.h
7508 ===================================================================
7509 --- gdb-7.2.90.20110703.orig/gdb/python/python.h        2011-03-14 17:09:54.000000000 +0100
7510 +++ gdb-7.2.90.20110703/gdb/python/python.h     2011-07-03 10:33:11.000000000 +0200
7511 @@ -32,6 +32,8 @@ void eval_python_from_control_command (s
7512  
7513  void source_python_script (FILE *stream, const char *file);
7514  
7515 +void run_python_script (int argc, char **argv);
7516 +
7517  int apply_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
7518                               int embedded_offset, CORE_ADDR address,
7519                               struct ui_file *stream, int recurse,
7520 Index: gdb-7.2.90.20110703/gdb/somread.c
7521 ===================================================================
7522 --- gdb-7.2.90.20110703.orig/gdb/somread.c      2011-03-07 17:17:29.000000000 +0100
7523 +++ gdb-7.2.90.20110703/gdb/somread.c   2011-07-03 10:33:11.000000000 +0200
7524 @@ -439,6 +439,7 @@ static const struct sym_fns som_sym_fns 
7525    default_symfile_segments,    /* Get segment information from a file.  */
7526    NULL,
7527    default_symfile_relocate,    /* Relocate a debug section.  */
7528 +  NULL,                                /* sym_get_probes */
7529    &psym_functions
7530  };
7531  
7532 Index: gdb-7.2.90.20110703/gdb/stack.c
7533 ===================================================================
7534 --- gdb-7.2.90.20110703.orig/gdb/stack.c        2011-03-18 19:48:56.000000000 +0100
7535 +++ gdb-7.2.90.20110703/gdb/stack.c     2011-07-03 10:33:11.000000000 +0200
7536 @@ -366,6 +366,7 @@ print_frame_args (struct symbol *func, s
7537                 {
7538                    const struct language_defn *language;
7539                   struct value_print_options opts;
7540 +                 struct cleanup *old_chain;
7541  
7542                    /* Use the appropriate language to display our symbol,
7543                       unless the user forced the language to a specific
7544 @@ -378,7 +379,13 @@ print_frame_args (struct symbol *func, s
7545                   get_raw_print_options (&opts);
7546                   opts.deref_ref = 0;
7547                   opts.summary = summary;
7548 +
7549 +                 /* Frame may be needed for check_typedef of TYPE_DYNAMIC.  */
7550 +                 old_chain = make_cleanup_restore_selected_frame ();
7551 +                 select_frame (frame);
7552                   common_val_print (val, stb->stream, 2, &opts, language);
7553 +                 do_cleanups (old_chain);
7554 +
7555                   ui_out_field_stream (uiout, "value", stb);
7556                 }
7557               else
7558 Index: gdb-7.2.90.20110703/gdb/stap-probe.c
7559 ===================================================================
7560 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
7561 +++ gdb-7.2.90.20110703/gdb/stap-probe.c        2011-07-03 10:33:11.000000000 +0200
7562 @@ -0,0 +1,2041 @@
7563 +/* SystemTap probe support for GDB.
7564 +
7565 +   Copyright (C) 2011 Free Software Foundation, Inc.
7566 +
7567 +   This file is part of GDB.
7568 +
7569 +   This program is free software; you can redistribute it and/or modify
7570 +   it under the terms of the GNU General Public License as published by
7571 +   the Free Software Foundation; either version 3 of the License, or
7572 +   (at your option) any later version.
7573 +
7574 +   This program is distributed in the hope that it will be useful,
7575 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
7576 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7577 +   GNU General Public License for more details.
7578 +
7579 +   You should have received a copy of the GNU General Public License
7580 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7581 +
7582 +#include "defs.h"
7583 +#include "stap-probe.h"
7584 +#include "vec.h"
7585 +#include "ui-out.h"
7586 +#include "gdb_regex.h"
7587 +#include "objfiles.h"
7588 +#include "arch-utils.h"
7589 +#include "command.h"
7590 +#include "filenames.h"
7591 +#include "value.h"
7592 +#include "exceptions.h"
7593 +#include "ax.h"
7594 +#include "ax-gdb.h"
7595 +#include "user-regs.h"
7596 +#include "complaints.h"
7597 +#include "cli/cli-utils.h"
7598 +#include "linespec.h"
7599 +
7600 +#include <ctype.h>
7601 +
7602 +/* This define is used to inform whether we are compiling an agent
7603 +   expression or not.  */
7604 +
7605 +#define STAP_COMPILING_AGENT_EXPR_P(eval_info) \
7606 +  (eval_info->aexpr != NULL)
7607 +
7608 +/* The various possibilities of bitness defined for a probe's argument.
7609 +
7610 +   The relationship is:
7611 +
7612 +   - STAP_ARG_BITNESS_UNDEFINED:  The user hasn't specified the bitness.
7613 +   - STAP_ARG_BITNESS_32BIT_UNSIGNED:  argument string starts with `4@'.
7614 +   - STAP_ARG_BITNESS_32BIT_SIGNED:  argument string starts with `-4@'.
7615 +   - STAP_ARG_BITNESS_64BIT_UNSIGNED:  argument string starts with `8@'.
7616 +   - STAP_ARG_BITNESS_64BIT_SIGNED:  argument string starts with `-8@'.  */
7617 +
7618 +enum stap_arg_bitness
7619 +{
7620 +  STAP_ARG_BITNESS_UNDEFINED,
7621 +  STAP_ARG_BITNESS_32BIT_UNSIGNED,
7622 +  STAP_ARG_BITNESS_32BIT_SIGNED,
7623 +  STAP_ARG_BITNESS_64BIT_UNSIGNED,
7624 +  STAP_ARG_BITNESS_64BIT_SIGNED,
7625 +};
7626 +
7627 +/* The following structure represents a single argument for the probe.  */
7628 +
7629 +struct stap_probe_arg
7630 +{
7631 +  /* The bitness of this argument.  */
7632 +  enum stap_arg_bitness bitness;
7633 +
7634 +  /* The string representing this argument.  */
7635 +  char *arg_str;
7636 +};
7637 +
7638 +/* The maximum number of arguments that a probe can have,
7639 +   as defined in <sys/sdt.h>.  */
7640 +
7641 +#define STAP_MAX_ARGS 10
7642 +
7643 +/* Structure that holds information about all arguments of a probe.  */
7644 +
7645 +struct stap_args_info
7646 +{
7647 +  /* The number of valid parsed arguments.  */
7648 +  int n_args;
7649 +
7650 +  /* The probe to which these arguments belong.  */
7651 +  struct stap_probe *probe;
7652 +
7653 +  /* Information about each argument.  */
7654 +  struct stap_probe_arg *arg;
7655 +};
7656 +
7657 +/* Structure that contains all the necessary information to evaluate
7658 +   an expression.  */
7659 +
7660 +struct stap_evaluation_info
7661 +{
7662 +  /* The constant pointer which holds the expression. This is primarily
7663 +     used for printing error messages.  Evaluation functions should
7664 +     not modify this pointer directly; instead, they should use the
7665 +     EXP_BUFFER pointer below.  */
7666 +  const char *saved_expr;
7667 +
7668 +  /* Modifiable version of the above pointer.  */
7669 +  char *exp_buf;
7670 +
7671 +  /* The pointer to the current gdbarch.  */
7672 +  struct gdbarch *gdbarch;
7673 +
7674 +  /* The pointer to the current frame, used when accessing registers'
7675 +     contents.  */
7676 +  struct frame_info *frame;
7677 +
7678 +  /* The bitness specified for this argument.  */
7679 +  enum stap_arg_bitness bitness;
7680 +
7681 +  /* If the above flag is true (one), this field will contain the
7682 +     pointer to the agent expression.  */
7683 +  struct agent_expr *aexpr;
7684 +
7685 +  /* The value we are modifying (for agent expression).  */
7686 +  struct axs_value *avalue;
7687 +};
7688 +
7689 +/* This dummy variable is used when parsing a probe's argument fails.
7690 +   In this case, the number of arguments for this probe is zero, so that's
7691 +   why this variable is useful.  */
7692 +
7693 +static struct stap_args_info dummy_stap_args_info =
7694 +  { 0, NULL, NULL };
7695 +
7696 +static struct value *stap_evaluate_probe_argument_2
7697 +  (struct stap_evaluation_info *eval_info,
7698 +   struct value *lhs, int prec);
7699 +
7700 +static struct value *stap_evaluate_conditionally
7701 +  (struct stap_evaluation_info *eval_info);
7702 +
7703 +/* Helper function which decides to skip whitespaces or not in a probe's
7704 +   argument string.  Basically, if we are inside a parenthesis expression
7705 +   (i.e., inside a subexpression), we can skip whitespaces; otherwise we
7706 +   cannot.  */
7707 +
7708 +static void
7709 +stap_skip_whitespace_cond (char **s, int inside_paren)
7710 +{
7711 +  if (inside_paren)
7712 +    *s = skip_spaces (*s);
7713 +}
7714 +
7715 +/* Helper function which parses a single argument in a probe's argument
7716 +   string, based on various rules (which can be learned from the `gas'
7717 +   manual).  It returns 1 on success, or 0 otherwise.  */
7718 +
7719 +static int
7720 +stap_parse_arg (const char **p)
7721 +{
7722 +  char *cur = (char *) *p;
7723 +  int done = 0;
7724 +  int paren_open = 0;
7725 +
7726 +  while (!done)
7727 +    {
7728 +      switch (*cur)
7729 +       {
7730 +       case ' ': case 0:
7731 +         /* If we're here, then we have already parsed everything
7732 +            from this argument.  */
7733 +         if (paren_open)
7734 +           return 0;
7735 +         done = 1;
7736 +         break;
7737 +
7738 +       case '(':
7739 +         ++paren_open;
7740 +         ++cur;
7741 +         stap_skip_whitespace_cond (&cur, paren_open);
7742 +         break;
7743 +
7744 +       case ')':
7745 +         if (!paren_open)
7746 +           return 0;
7747 +
7748 +         --paren_open;
7749 +         ++cur;
7750 +         if (paren_open)
7751 +           cur = skip_spaces (cur);
7752 +         break;
7753 +
7754 +       case '+': case '-':
7755 +       case '*': case '/':
7756 +       case '>': case '<': case '|': case '&':
7757 +       case '^': case '!':
7758 +           {
7759 +             char c = *cur;
7760 +
7761 +             ++cur;
7762 +             switch (*cur)
7763 +               {
7764 +               case '>':
7765 +                 if (c != '<' && c != '>')
7766 +                   return 0;
7767 +
7768 +                 ++cur;
7769 +                 break;
7770 +
7771 +               case '<':
7772 +                 if (c != '<')
7773 +                   return 0;
7774 +
7775 +                 ++cur;
7776 +                 break;
7777 +
7778 +               case '=':
7779 +                 if (c != '=' && c != '<' && c != '>' && c != '!')
7780 +                   return 0;
7781 +
7782 +                 ++cur;
7783 +                 break;
7784 +
7785 +               case '|':
7786 +                 if (c != '|')
7787 +                   return 0;
7788 +
7789 +                 ++cur;
7790 +                 break;
7791 +
7792 +               case '&':
7793 +                 if (c != '&')
7794 +                   return 0;
7795 +
7796 +                 ++cur;
7797 +                 break;
7798 +
7799 +               default:
7800 +                 break;
7801 +               }
7802 +             /* Infix operators take two arguments, one on either
7803 +                side.  Skipping the whitespaces that may happen on the
7804 +                right side.  */
7805 +             stap_skip_whitespace_cond (&cur, paren_open);
7806 +           }
7807 +         break;
7808 +
7809 +       case '%':
7810 +           {
7811 +             ++cur;
7812 +             stap_skip_whitespace_cond (&cur, paren_open);
7813 +             if (*cur >= 'a' && *cur <= 'z')
7814 +               {
7815 +                 /* We're dealing with a register name.  */
7816 +                 while (isalnum (*cur))
7817 +                   ++cur;
7818 +
7819 +                 stap_skip_whitespace_cond (&cur, paren_open);
7820 +
7821 +                 /* Some registers (e.g. floating-point register stack
7822 +                    registers on Intel i386) have the following syntax:
7823 +
7824 +                    `%st(0)', `%st(1)', and so on.
7825 +
7826 +                    So it's ok to expect parenthesis here.  */
7827 +                 if (*cur == '(')
7828 +                   {
7829 +                     ++cur;
7830 +                     stap_skip_whitespace_cond (&cur, paren_open);
7831 +                     if (!isdigit (*cur))
7832 +                       /* This is an error, since we only expect numbers
7833 +                          inside this parenthesis.  */
7834 +                       return 0;
7835 +                     ++cur;
7836 +                     stap_skip_whitespace_cond (&cur, paren_open);
7837 +                     if (*cur != ')')
7838 +                       /* We only expect one number.  */
7839 +                       return 0;
7840 +                     ++cur;
7841 +                     stap_skip_whitespace_cond (&cur, paren_open);
7842 +                   }
7843 +               }
7844 +           }
7845 +         break;
7846 +
7847 +       case '$':
7848 +           {
7849 +             /* This is an integer constant.  */
7850 +             ++cur;
7851 +             stap_skip_whitespace_cond (&cur, paren_open);
7852 +
7853 +             while (isdigit (*cur))
7854 +               ++cur;
7855 +
7856 +             stap_skip_whitespace_cond (&cur, paren_open);
7857 +           }
7858 +         break;
7859 +
7860 +       case '0': case '1': case '2': case '3': case '4':
7861 +       case '5': case '6': case '7': case '8': case '9':
7862 +           {
7863 +             char *old = cur;
7864 +
7865 +             /* Number.  */
7866 +             while (isdigit (*cur))
7867 +               ++cur;
7868 +
7869 +             /* We have to do a lookahead here, because the user may
7870 +                input `2 + 2' (with spaces), and this is not an error.  */
7871 +             cur = skip_spaces (cur);
7872 +
7873 +             switch (*cur)
7874 +               {
7875 +               case '+': case '-':
7876 +                 /* We may find the `@' sign, and it means that the
7877 +                    argument has finished, so we shouldn't advance the
7878 +                    pointer.  */
7879 +                 if (cur[1] && (cur[1] == '4' || cur[1] == '8')
7880 +                     && cur[2] && cur[2] == '@')
7881 +                   {
7882 +                     cur = old;
7883 +                     goto fin;
7884 +                   }
7885 +                 break;
7886 +
7887 +               case '*': case '/': case '>': case '<':
7888 +               case '|': case '&': case '^': case '!':
7889 +                 /* This is a binary operation, which means we'll
7890 +                    have to find another number after the operator.  */
7891 +                 break;
7892 +
7893 +               case '(':
7894 +                 /* We may also have sentences in the form:
7895 +
7896 +                    `4 (%rax)'  */
7897 +                 break;
7898 +               }
7899 +           }
7900 +fin:
7901 +         break;
7902 +       }
7903 +    }
7904 +
7905 +  *p = cur;
7906 +
7907 +  return 1;
7908 +}
7909 +
7910 +/* Helper function which is responsible for freeing the space allocated to
7911 +   hold information about a probe's arguments.  */
7912 +
7913 +static void
7914 +stap_free_args_info (void *args_info_ptr)
7915 +{
7916 +  struct stap_args_info *a = (struct stap_args_info *) args_info_ptr;
7917 +  int i;
7918 +
7919 +  for (i = 0; i < a->n_args; i++)
7920 +    {
7921 +      xfree (a->arg[i].arg_str);
7922 +    }
7923 +
7924 +  xfree (a->arg);
7925 +  xfree (a);
7926 +}
7927 +
7928 +/* Function which parses an argument string from PROBE, correctly splitting
7929 +   the arguments and storing their information in properly ways.  This function
7930 +   only separates the arguments, but does not evaluate them.
7931 +
7932 +   Consider the following argument string:
7933 +
7934 +   `4@%eax 4@$10'
7935 +
7936 +   We have two arguments, `%eax' and `$10', both with 32-bit unsigned bitness.
7937 +   This function basically handles them, properly filling some structures with
7938 +   this information.  */
7939 +
7940 +static void
7941 +stap_parse_probe_arguments (struct stap_probe *probe)
7942 +{
7943 +  struct stap_args_info *args_info;
7944 +  struct cleanup *back_to;
7945 +  const char *cur = probe->args;
7946 +  int current_arg = -1;
7947 +  /* This is a state-machine parser, which means we will always be
7948 +     in a known state when parsing an argument.  The state could be
7949 +     either `NEW_ARG' if we are parsing a new argument, `BITNESS' if
7950 +     we are parsing the bitness-definition part (i.e., `4@'), or
7951 +     `PARSE_ARG' if we are actually parsing the argument part.  */
7952 +  enum
7953 +    {
7954 +      NEW_ARG,
7955 +      BITNESS,
7956 +      PARSE_ARG,
7957 +    } current_state;
7958 +
7959 +  /* For now, we assume everything is not going to work.  */
7960 +  probe->parsed_args = &dummy_stap_args_info;
7961 +
7962 +  if (!cur || !*cur || *cur == ':')
7963 +    return;
7964 +
7965 +  args_info = xmalloc (sizeof (struct stap_args_info));
7966 +  back_to = make_cleanup (stap_free_args_info, args_info);
7967 +  args_info->arg = xcalloc (STAP_MAX_ARGS, sizeof (struct stap_probe_arg));
7968 +
7969 +  /* Ok, let's start.  */
7970 +  current_state = NEW_ARG;
7971 +
7972 +  while (*cur)
7973 +    {
7974 +      switch (current_state)
7975 +       {
7976 +       case NEW_ARG:
7977 +         ++current_arg;
7978 +
7979 +         if (current_arg >= STAP_MAX_ARGS)
7980 +           {
7981 +             complaint (&symfile_complaints,
7982 +                        _("probe `%s' has more arguments than the maximum "
7983 +                          "allowed"), probe->name);
7984 +             do_cleanups (back_to);
7985 +             return;
7986 +           }
7987 +
7988 +         current_state = BITNESS;
7989 +         break;
7990 +
7991 +       case BITNESS:
7992 +           {
7993 +             enum stap_arg_bitness b;
7994 +             int got_minus = 0;
7995 +
7996 +             /* We expect to find something like:
7997 +
7998 +                N@OP
7999 +
8000 +                Where `N' can be [+,-][4,8].  This is not mandatory, so
8001 +                we check it here.  If we don't find it, go to the next
8002 +                state.  */
8003 +             if ((*cur == '-' && cur[1] && cur[2] != '@')
8004 +                 && cur[1] != '@')
8005 +               {
8006 +                 current_state = PARSE_ARG;
8007 +                 args_info->arg[current_arg].bitness
8008 +                   = STAP_ARG_BITNESS_UNDEFINED;
8009 +                 break;
8010 +               }
8011 +
8012 +             if (*cur == '-')
8013 +               {
8014 +                 /* Discard the `-'.  */
8015 +                 ++cur;
8016 +                 got_minus = 1;
8017 +               }
8018 +
8019 +             if (*cur == '4')
8020 +               b = got_minus ? STAP_ARG_BITNESS_32BIT_SIGNED
8021 +                 : STAP_ARG_BITNESS_32BIT_UNSIGNED;
8022 +             else if (*cur == '8')
8023 +               b = got_minus ? STAP_ARG_BITNESS_64BIT_SIGNED
8024 +                 : STAP_ARG_BITNESS_64BIT_UNSIGNED;
8025 +             else
8026 +               {
8027 +                 /* We have an error, because we don't expect anything
8028 +                    except 4 and 8.  */
8029 +                 complaint (&symfile_complaints,
8030 +                            _("unrecognized bitness `%c' for probe `%s'"),
8031 +                            *cur, probe->name);
8032 +                 do_cleanups (back_to);
8033 +                 return;
8034 +               }
8035 +
8036 +             args_info->arg[current_arg].bitness = b;
8037 +             /* Discard the number and the `@' sign.  */
8038 +             cur += 2;
8039 +             /* Move on.  */
8040 +             current_state = PARSE_ARG;
8041 +           }
8042 +         break;
8043 +
8044 +       case PARSE_ARG:
8045 +           {
8046 +             const char *start = cur;
8047 +
8048 +             if (!stap_parse_arg (&cur))
8049 +               {
8050 +                 /* We have tried to parse this argument, but it's
8051 +                    malformed.  This is an error.  */
8052 +                 do_cleanups (back_to);
8053 +                 return;
8054 +               }
8055 +
8056 +             args_info->arg[current_arg].arg_str
8057 +               = savestring (start, cur - start);
8058 +             /* Start it over again.  */
8059 +             cur = skip_spaces ((char *) cur);
8060 +             current_state = NEW_ARG;
8061 +           }
8062 +         break;
8063 +       }
8064 +
8065 +      if (!*cur && current_state != NEW_ARG)
8066 +       {
8067 +         /* We reached the end of the argument string, but we're
8068 +            still in the middle of the process of parsing an argument.
8069 +            It means the argument string is malformed.  */
8070 +         complaint (&symfile_complaints,
8071 +                    _("malformed argument for probe `%s'"),
8072 +                    probe->name);
8073 +         do_cleanups (back_to);
8074 +         return;
8075 +       }
8076 +    }
8077 +
8078 +  args_info->n_args = current_arg + 1;
8079 +  args_info->arg = xrealloc (args_info->arg,
8080 +                             args_info->n_args
8081 +                             * sizeof (struct stap_probe_arg));
8082 +  args_info->probe = probe;
8083 +
8084 +  probe->parsed_args = args_info;
8085 +
8086 +  discard_cleanups (back_to);
8087 +}
8088 +
8089 +/* See definition in stap-probe.h.  */
8090 +
8091 +int
8092 +stap_get_probe_argument_count (const struct stap_probe *probe)
8093 +{
8094 +  if (!probe->parsed_args)
8095 +    stap_parse_probe_arguments ((struct stap_probe *) probe);
8096 +
8097 +  return probe->parsed_args->n_args;
8098 +}
8099 +
8100 +/* Returns the operator precedence level of OP, or zero if the operator
8101 +   code was not recognized.
8102 +   The levels were taken from the gas manual.  */
8103 +
8104 +static int
8105 +stap_get_operator_prec (enum exp_opcode op)
8106 +{
8107 +  switch (op)
8108 +    {
8109 +    case BINOP_LOGICAL_OR:
8110 +      return 1;
8111 +
8112 +    case BINOP_LOGICAL_AND:
8113 +      return 2;
8114 +
8115 +    case BINOP_ADD: case BINOP_SUB:
8116 +    case BINOP_EQUAL: case BINOP_NOTEQUAL:
8117 +    case BINOP_LESS: case BINOP_LEQ:
8118 +    case BINOP_GTR: case BINOP_GEQ:
8119 +      return 3;
8120 +
8121 +    case BINOP_BITWISE_IOR: case BINOP_BITWISE_AND:
8122 +    case BINOP_BITWISE_XOR: case UNOP_LOGICAL_NOT:
8123 +      return 4;
8124 +
8125 +    case BINOP_MUL: case BINOP_DIV: case BINOP_REM:
8126 +    case BINOP_LSH: case BINOP_RSH:
8127 +      return 5;
8128 +
8129 +    default:
8130 +      return 0;
8131 +    }
8132 +}
8133 +
8134 +/* Given S, this function reads the operator in it and fills the OP
8135 +   pointer with its code.  Returns 1 on success, zero if the operator
8136 +   was not recognized.  */
8137 +
8138 +static int
8139 +stap_get_opcode (char **s, enum exp_opcode *op)
8140 +{
8141 +  char c = **s;
8142 +  int ret = 1;
8143 +
8144 +  *s += 1;
8145 +
8146 +  switch (c)
8147 +    {
8148 +    case '*':
8149 +      *op = BINOP_MUL;
8150 +      break;
8151 +
8152 +    case '/':
8153 +      *op = BINOP_DIV;
8154 +      break;
8155 +
8156 +    case '%':
8157 +      {
8158 +       if (isalpha (**s))
8159 +         {
8160 +           /* Dealing with a register name.  */
8161 +           ret = 0;
8162 +           break;
8163 +         }
8164 +
8165 +       *op = BINOP_REM;
8166 +      }
8167 +    break;
8168 +
8169 +    case '<':
8170 +      *op = BINOP_LESS;
8171 +      if (**s == '<')
8172 +       {
8173 +         *s += 1;
8174 +         *op = BINOP_LSH;
8175 +       }
8176 +      else if (**s == '=')
8177 +       {
8178 +         *s += 1;
8179 +         *op = BINOP_LEQ;
8180 +       }
8181 +      else if (**s == '>')
8182 +       {
8183 +         *s += 1;
8184 +         *op = BINOP_NOTEQUAL;
8185 +       }
8186 +    break;
8187 +
8188 +    case '>':
8189 +      *op = BINOP_GTR;
8190 +      if (**s == '>')
8191 +       {
8192 +         *s += 1;
8193 +         *op = BINOP_RSH;
8194 +       }
8195 +      else if (**s == '=')
8196 +       {
8197 +         *s += 1;
8198 +         *op = BINOP_GEQ;
8199 +       }
8200 +    break;
8201 +
8202 +    case '|':
8203 +      *op = BINOP_BITWISE_IOR;
8204 +      if (**s == '|')
8205 +       {
8206 +         *s += 1;
8207 +         *op = BINOP_LOGICAL_OR;
8208 +       }
8209 +    break;
8210 +
8211 +    case '&':
8212 +      *op = BINOP_BITWISE_AND;
8213 +      if (**s == '&')
8214 +       {
8215 +         *s += 1;
8216 +         *op = BINOP_LOGICAL_AND;
8217 +       }
8218 +    break;
8219 +
8220 +    case '^':
8221 +      *op = BINOP_BITWISE_XOR;
8222 +      break;
8223 +
8224 +    case '!':
8225 +      *op = UNOP_LOGICAL_NOT;
8226 +      break;
8227 +
8228 +    case '+':
8229 +      *op = BINOP_ADD;
8230 +      break;
8231 +
8232 +    case '-':
8233 +      *op = BINOP_SUB;
8234 +      break;
8235 +
8236 +    case '=':
8237 +      if (**s != '=')
8238 +       {
8239 +         ret = 0;
8240 +         break;
8241 +       }
8242 +      *op = BINOP_EQUAL;
8243 +      break;
8244 +
8245 +    default:
8246 +      /* We didn't find any operator.  */
8247 +      *s -= 1;
8248 +      return 0;
8249 +    }
8250 +
8251 +  return ret;
8252 +}
8253 +
8254 +/* Given the operator OPCODE, this function generates agent bytecode
8255 +   for it.  */
8256 +
8257 +static void
8258 +stap_opcode_to_ax (struct stap_evaluation_info *eval_info,
8259 +                  enum exp_opcode opcode)
8260 +{
8261 +  struct agent_expr *expr = eval_info->aexpr;
8262 +
8263 +  switch (opcode)
8264 +    {
8265 +    case BINOP_MUL:
8266 +      ax_simple (expr, aop_mul);
8267 +      break;
8268 +
8269 +    case BINOP_DIV:
8270 +      ax_simple (expr, aop_div_signed);
8271 +      break;
8272 +
8273 +    case BINOP_REM:
8274 +      ax_simple (expr, aop_rem_unsigned);
8275 +      break;
8276 +
8277 +    case BINOP_LESS:
8278 +      ax_simple (expr, aop_less_signed);
8279 +      break;
8280 +
8281 +    case BINOP_LEQ:
8282 +      /* A <= B is !(B < A) */
8283 +      ax_simple (expr, aop_swap);
8284 +      ax_simple (expr, aop_less_signed);
8285 +      ax_simple (expr, aop_log_not);
8286 +      break;
8287 +
8288 +    case BINOP_GTR:
8289 +      /* A > B is B < A */
8290 +      ax_simple (expr, aop_swap);
8291 +      ax_simple (expr, aop_less_signed);
8292 +      break;
8293 +
8294 +    case BINOP_GEQ:
8295 +      /* A >= B is !(A < B) */
8296 +      ax_simple (expr, aop_less_signed);
8297 +      ax_simple (expr, aop_log_not);
8298 +      break;
8299 +
8300 +    case BINOP_NOTEQUAL:
8301 +      ax_simple (expr, aop_equal);
8302 +      ax_simple (expr, aop_log_not);
8303 +      break;
8304 +
8305 +    case BINOP_LSH:
8306 +      ax_simple (expr, aop_lsh);
8307 +      break;
8308 +
8309 +    case BINOP_RSH:
8310 +      ax_simple (expr, aop_rsh_unsigned);
8311 +      break;
8312 +
8313 +    case BINOP_BITWISE_IOR:
8314 +      ax_simple (expr, aop_bit_or);
8315 +      break;
8316 +     
8317 +    case BINOP_LOGICAL_OR:
8318 +      error (_("Operator logical-or (`||') not supported yet."));
8319 +      break;
8320 +
8321 +    case BINOP_BITWISE_AND:
8322 +      ax_simple (expr, aop_bit_and);
8323 +      break;
8324 +
8325 +    case BINOP_LOGICAL_AND:
8326 +      error (_("Operator logical-and (`&&') not supported yet."));
8327 +      break;
8328 +
8329 +    case BINOP_BITWISE_XOR:
8330 +      ax_simple (expr, aop_bit_xor);
8331 +      break;
8332 +
8333 +    case UNOP_LOGICAL_NOT:
8334 +      ax_simple (expr, aop_log_not);
8335 +      break;
8336 +
8337 +    case BINOP_ADD:
8338 +      ax_simple (expr, aop_add);
8339 +      break;
8340 +
8341 +    case BINOP_SUB:
8342 +      ax_simple (expr, aop_sub);
8343 +      break;
8344 +
8345 +    case BINOP_EQUAL:
8346 +      ax_simple (expr, aop_equal);
8347 +      break;
8348 +
8349 +    default:
8350 +      error (_("Invalid operator."));
8351 +    }
8352 +}
8353 +
8354 +/* Returns 1 if *S is an operator, zero otherwise.  */
8355 +
8356 +static int
8357 +stap_is_operator (char *s)
8358 +{
8359 +  char op;
8360 +
8361 +  if (!s || !*s)
8362 +    return 0;
8363 +
8364 +  op = *s;
8365 +
8366 +  if (*s == '%' && isalpha (s[1]))
8367 +    /* Register name.  */
8368 +    return 0;
8369 +
8370 +  return (op == '+' || op == '-' || op == '*' || op == '/'
8371 +         || op == '>' || op == '<' || op == '!' || op == '^'
8372 +         || op == '|' || op == '&' || op == '%' || op == '=');
8373 +}
8374 +
8375 +/* This function fetches the value of the register whose
8376 +   name starts in the expression buffer.  It also applies any register
8377 +   displacements (e.g., `-4(%eax)'), and indirects the contents of the
8378 +   register (e.g., `(%eax)').  It returns RET if the operation has succeeded,
8379 +   or calls `error' otherwise.  */
8380 +
8381 +static struct value *
8382 +stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
8383 +                     struct value *displacement)
8384 +{
8385 +  const char *start;
8386 +  char *s = eval_info->exp_buf;
8387 +  struct gdbarch *gdbarch = eval_info->gdbarch;
8388 +  struct frame_info *frame = eval_info->frame;
8389 +  enum stap_arg_bitness bitness = eval_info->bitness;
8390 +  char *regname;
8391 +  int len, regnum, indirect_p = 0;
8392 +  struct value *ret = NULL;
8393 +  
8394 +  /* The function which called us did not check if the expression
8395 +     buffer was empty.  */
8396 +  gdb_assert (s && *s);
8397 +
8398 +  if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8399 +    /* If we are compiling, we cannot return NULL because that would
8400 +       lead to errors in future evaluations.  That's why we just make
8401 +       this dummy value, representing that the return value of this
8402 +       function is not NULL.  */
8403 +    ret = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
8404 +
8405 +  /* Valid register name on x86 platforms are:
8406 +
8407 +     [paren]%{a-z0-9}[paren]
8408 +
8409 +     Let's check for that here.  */
8410 +  if (*s == '(')
8411 +    {
8412 +      ++s;
8413 +      if (!*s || *s != '%'
8414 +         || (*s == '%' && !isalpha (s[1])))
8415 +       error (_("Invalid register name on expression `%s'."),
8416 +              eval_info->saved_expr);
8417 +      ++s;
8418 +      /* The presence of parenthesis means that we want to indirect
8419 +        the register.  */
8420 +      indirect_p = 1;
8421 +    }
8422 +  else if (*s == '%')
8423 +    {
8424 +      ++s;
8425 +      if (!*s || !isalpha (*s))
8426 +       error (_("Invalid register name on expression `%s'."),
8427 +              eval_info->saved_expr);
8428 +    }
8429 +  else
8430 +    error (_("Invalid register name on expression `%s'."),
8431 +          eval_info->saved_expr);
8432 +
8433 +  if (displacement && !indirect_p)
8434 +    /* We cannot apply displacement to non-indirect register access.  */
8435 +    error (_("Trying to apply displacement without indirecting register "
8436 +            "on expression `%s'."), eval_info->saved_expr);
8437 +
8438 +  /* Ok, let's calculate the size of the register name.  */
8439 +  start = s;
8440 +  while (isalnum (*s))
8441 +    ++s;
8442 +
8443 +  len = s - start;
8444 +
8445 +  if (indirect_p && *s == ')')
8446 +    ++s;
8447 +
8448 +  regname = alloca (len + 1);
8449 +  strncpy (regname, start, len);
8450 +  regname[len] = '\0';
8451 +
8452 +  /* Translating the register name into the corresponding number.  */
8453 +  regnum = user_reg_map_name_to_regnum (gdbarch, regname, len);
8454 +
8455 +  if (regnum == -1)
8456 +    error (_("Invalid register name `%s' on expression `%s'."),
8457 +          regname, eval_info->saved_expr);
8458 +
8459 +  if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8460 +    ax_reg (eval_info->aexpr, regnum);
8461 +  else
8462 +    ret = value_of_register (regnum, frame);
8463 +
8464 +  if (indirect_p)
8465 +    {
8466 +      struct type *t = NULL;
8467 +      enum agent_op aop = aop_ref32;
8468 +
8469 +      /* If the user has specified that the register must be indirected,
8470 +        we should know what's the correct type to cast it before making
8471 +        the indirection.  This type corresponds to the bitness specified
8472 +        before the `@' sign on the argument string, or it defaults to
8473 +        `unsigned long' if the `@' were not present.  */
8474 +
8475 +      switch (bitness)
8476 +       {
8477 +       case STAP_ARG_BITNESS_UNDEFINED:
8478 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8479 +           {
8480 +             if (gdbarch_addr_bit (gdbarch) == 32)
8481 +               aop = aop_ref32;
8482 +             else
8483 +               aop = aop_ref64;
8484 +           }
8485 +         else
8486 +           {
8487 +             if (gdbarch_addr_bit (gdbarch) == 32)
8488 +               t = lookup_pointer_type
8489 +                 (builtin_type (gdbarch)->builtin_uint32);
8490 +             else
8491 +               t = lookup_pointer_type
8492 +                 (builtin_type (gdbarch)->builtin_uint64);
8493 +           }
8494 +         break;
8495 +
8496 +       case STAP_ARG_BITNESS_32BIT_SIGNED:
8497 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8498 +           aop = aop_ref32;
8499 +         else
8500 +           t = lookup_pointer_type
8501 +             (builtin_type (gdbarch)->builtin_int32);
8502 +         break;
8503 +
8504 +       case STAP_ARG_BITNESS_32BIT_UNSIGNED:
8505 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8506 +           aop = aop_ref32;
8507 +         else
8508 +           t = lookup_pointer_type
8509 +             (builtin_type (gdbarch)->builtin_uint32);
8510 +         break;
8511 +
8512 +       case STAP_ARG_BITNESS_64BIT_SIGNED:
8513 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8514 +           aop = aop_ref64;
8515 +         else
8516 +           t = lookup_pointer_type
8517 +             (builtin_type (gdbarch)->builtin_int64);
8518 +         break;
8519 +
8520 +       case STAP_ARG_BITNESS_64BIT_UNSIGNED:
8521 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8522 +           aop = aop_ref64;
8523 +         else
8524 +           t = lookup_pointer_type
8525 +             (builtin_type (gdbarch)->builtin_uint64);
8526 +         break;
8527 +
8528 +       default:
8529 +         internal_error (__FILE__, __LINE__,
8530 +                         _("Undefined bitness for probe."));
8531 +         break;
8532 +       }
8533 +
8534 +      if (displacement)
8535 +       {
8536 +         if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8537 +           {
8538 +             ax_const_l (eval_info->aexpr, value_as_long (displacement));
8539 +             ax_simple (eval_info->aexpr, aop_add);
8540 +           }
8541 +         else
8542 +           ret = value_ptradd (ret, value_as_long (displacement));
8543 +       }
8544 +
8545 +      if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8546 +       {
8547 +         if (trace_kludge)
8548 +           {
8549 +             gdb_assert (aop == aop_ref32 || aop == aop_ref64);
8550 +             ax_trace_quick (eval_info->aexpr, aop == aop_ref32 ? 4 : 8);
8551 +           }
8552 +         ax_simple (eval_info->aexpr, aop);
8553 +       }
8554 +      else
8555 +       {
8556 +         ret = value_cast (t, ret);
8557 +         ret = value_ind (ret);
8558 +       }
8559 +    }
8560 +
8561 +  /* Updating the expression buffer pointer, because we have made
8562 +     some modifications to it before.  */
8563 +  eval_info->exp_buf = s;
8564 +
8565 +  return ret;
8566 +}
8567 +
8568 +/* This function tries to evaluate a single operand of the expression.
8569 +
8570 +   Single operands can be:
8571 +
8572 +   - unary operators `-' and `~';
8573 +   - integer constants (beginning with `$');
8574 +   - register access, with/out displacement and indirection.  */
8575 +
8576 +static struct value *
8577 +stap_evaluate_single_operand (struct stap_evaluation_info *eval_info)
8578 +{
8579 +  struct gdbarch *gdbarch = eval_info->gdbarch;
8580 +  struct frame_info *frame = eval_info->frame;
8581 +  enum stap_arg_bitness bitness = eval_info->bitness;
8582 +  struct value *res = NULL;
8583 +
8584 +  if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8585 +    /* If we are compiling, we cannot return NULL because that would
8586 +       lead to errors in future evaluations.  That's why we just make
8587 +       this dummy value, representing that the return value of this
8588 +       function is not NULL.  */
8589 +    res = value_from_longest (builtin_type (gdbarch)->builtin_int, 0);
8590 +
8591 +  switch (*eval_info->exp_buf)
8592 +    {
8593 +    case '-': case '~':
8594 +       {
8595 +         char c = *eval_info->exp_buf;
8596 +
8597 +         /* This is an unary operator (either `-' or `~').
8598 +
8599 +            If it is followed by a parenthesis, and this parenthesis
8600 +            is NOT followed by a `%', then we are dealing with an expression
8601 +            like `-(2 + 3)' or `~(2 + 3)'.  We just have to treat separately
8602 +            and return the result after applying the operation (`-' or `~').
8603 +
8604 +            If it is followed by a digit, then we have only one choice:  it
8605 +            is a displacement argument for a register access, like
8606 +            `-4(%eax)'.  It also means that the operator can *only* be `-',
8607 +            and the characters immediately after the number *must* be `(%'.
8608 +
8609 +            If it is followed by a `$', then it is an integer constant, and
8610 +            we should apply the correct operation to it.  */
8611 +
8612 +         ++eval_info->exp_buf;
8613 +         eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8614 +         if (*eval_info->exp_buf
8615 +             && *eval_info->exp_buf == '('
8616 +             && eval_info->exp_buf[1] != '%')
8617 +           {
8618 +             struct value *tmp_res;
8619 +
8620 +             /* We're not dealing with a register name, but with an
8621 +                expression like `-(2 + 3)' or `~(2 + 3)'.  We first have
8622 +                to evaluate the right side of the expression (i.e., the
8623 +                parenthesis), and then apply the specified operation
8624 +                (either `-' or `~') to it.  */
8625 +             tmp_res = stap_evaluate_conditionally (eval_info);
8626 +
8627 +             if (c == '-')
8628 +               {
8629 +                 if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8630 +                   {
8631 +                     /* We have to add `-1' to the stack, and multiply
8632 +                        the two values.  */
8633 +                     ax_const_l (eval_info->aexpr, -1);
8634 +                     ax_simple (eval_info->aexpr, aop_mul);
8635 +                   }
8636 +                 else
8637 +                   res = value_neg (tmp_res);
8638 +               }
8639 +             else
8640 +               {
8641 +                 if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8642 +                   ax_simple (eval_info->aexpr, aop_bit_not);
8643 +                 else
8644 +                   res = value_complement (tmp_res);
8645 +               }
8646 +           }
8647 +         else if (isdigit (*eval_info->exp_buf))
8648 +           {
8649 +             int number;
8650 +
8651 +             /* This is a number, so it MUST be a register displacement.
8652 +                The only operator allowed here is `-', it MUST be
8653 +                followed by a number, and the number MUST be followed by
8654 +                `(%'.  */
8655 +             if (c != '-')
8656 +               error (_("Invalid operator `%c' for register displacement "
8657 +                        "on expression `%s'."), c, eval_info->saved_expr);
8658 +
8659 +             number = strtol (eval_info->exp_buf,
8660 +                              &eval_info->exp_buf, 0) * -1;
8661 +
8662 +             if (!*eval_info->exp_buf
8663 +                 || *eval_info->exp_buf != '('
8664 +                 || (*eval_info->exp_buf == '('
8665 +                     && eval_info->exp_buf[1] != '%'))
8666 +               error (_("Invalid method of indirecting a register on "
8667 +                        "expression `%s'."), eval_info->saved_expr);
8668 +
8669 +             res
8670 +               = value_from_longest (builtin_type (gdbarch)->builtin_int,
8671 +                                     number);
8672 +
8673 +             res = stap_fetch_reg_value (eval_info, res);
8674 +           }
8675 +         else if (*eval_info->exp_buf == '$')
8676 +           {
8677 +             int number;
8678 +
8679 +             /* Last case.  We are dealing with an integer constant, so
8680 +                we must read it and then apply the necessary operation,
8681 +                either `-' or `~'.  */
8682 +             ++eval_info->exp_buf;
8683 +             number = strtol (eval_info->exp_buf,
8684 +                              &eval_info->exp_buf, 0);
8685 +
8686 +             if (!STAP_COMPILING_AGENT_EXPR_P (eval_info))
8687 +               res
8688 +                 = value_from_longest (builtin_type (gdbarch)->builtin_int,
8689 +                                       number);
8690 +             else
8691 +               ax_const_l (eval_info->aexpr, number);
8692 +
8693 +             eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8694 +
8695 +             if (c == '-')
8696 +               {
8697 +                 if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8698 +                   ax_simple (eval_info->aexpr, aop_log_not);
8699 +                 else
8700 +                   res = value_neg (res);
8701 +               }
8702 +             else
8703 +               {
8704 +                 if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8705 +                   ax_simple (eval_info->aexpr, aop_bit_not);
8706 +                 else
8707 +                   res = value_complement (res);
8708 +               }
8709 +           }
8710 +         else
8711 +           error (_("Invalid operand to unary operator `%c' on "
8712 +                    "expression `%s'."), c, eval_info->saved_expr);
8713 +       }
8714 +      break;
8715 +
8716 +    case '0': case '1': case '2': case '3': case '4':
8717 +    case '5': case '6': case '7': case '8': case '9':
8718 +      {
8719 +       int number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
8720 +
8721 +       /* This is a register displacement with a positive value.  We read
8722 +          the number, and then check for the mandatory `(%' part.  */
8723 +       if (!*eval_info->exp_buf
8724 +           || !(*eval_info->exp_buf == '('
8725 +                && eval_info->exp_buf[1] == '%'))
8726 +         error (_("Invalid register access on expression `%s'."),
8727 +                eval_info->saved_expr);
8728 +
8729 +       res = value_from_longest (builtin_type (gdbarch)->builtin_int,
8730 +                                 number);
8731 +
8732 +       res = stap_fetch_reg_value (eval_info, res);
8733 +      }
8734 +    break;
8735 +
8736 +    case '$':
8737 +      {
8738 +       int number;
8739 +
8740 +       /* This is an integer constant.  We just have to read the number
8741 +          and return it.  */
8742 +       ++eval_info->exp_buf;
8743 +       eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8744 +
8745 +       number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
8746 +
8747 +       if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8748 +         ax_const_l (eval_info->aexpr, number);
8749 +       else
8750 +         res = value_from_longest (builtin_type (gdbarch)->builtin_int,
8751 +                                   number);
8752 +
8753 +       eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8754 +      }
8755 +    break;
8756 +
8757 +    case '(': case '%':
8758 +      {
8759 +       /* Register access, with or without indirection.  */
8760 +       res = stap_fetch_reg_value (eval_info, /*displacement=*/NULL);
8761 +       eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8762 +      }
8763 +    break;
8764 +
8765 +    default:
8766 +      {
8767 +       error (_("Operator `%c' not recognized on expression `%s'."),
8768 +              *eval_info->exp_buf, eval_info->saved_expr);
8769 +      }
8770 +    }
8771 +
8772 +  return res;
8773 +}
8774 +
8775 +/* This function is responsible for checking the necessary type of evaluation
8776 +   depending on what is the next "thing" in the buffer.  Valid values are:
8777 +
8778 +   - Unary operators;
8779 +   - Integer constants;
8780 +   - Register displacement, indirection, and direct access;
8781 +   - Parenthesized operand.  */
8782 +
8783 +static struct value *
8784 +stap_evaluate_conditionally (struct stap_evaluation_info *eval_info)
8785 +{
8786 +  char *s = eval_info->exp_buf;
8787 +  struct value *ret = NULL;
8788 +
8789 +  if (*s == '-' || *s == '~' /* Unary operators.  */
8790 +      || *s == '$' /* Number (integer constant).  */
8791 +      || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement.  */
8792 +      || (*s == '(' && s[1] == '%') /* Register indirection.  */
8793 +      || (*s == '%' && isalpha (s[1]))) /* Register value.  */
8794 +    /* This is a single operand, so just evaluate it and return.  */
8795 +    ret = stap_evaluate_single_operand (eval_info);
8796 +  else if (*s == '(')
8797 +    {
8798 +      /* We are dealing with a parenthesized operand.  It means we
8799 +        have to evaluate it as it was a separate expression, without
8800 +        left-side or precedence.  */
8801 +      ++eval_info->exp_buf;
8802 +      eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8803 +
8804 +      ret = stap_evaluate_probe_argument_2 (eval_info,
8805 +                                           /*lhs=*/NULL, /*prec=*/0);
8806 +
8807 +      if (*eval_info->exp_buf != ')')
8808 +       error (_("Missign close-paren on expression `%s'."),
8809 +              eval_info->saved_expr);
8810 +
8811 +      ++eval_info->exp_buf;
8812 +      eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8813 +    }
8814 +  else
8815 +    error (_("Cannot evaluate expression `%s'."),
8816 +          eval_info->saved_expr);
8817 +
8818 +  return ret;
8819 +}
8820 +
8821 +/* Evaluation function for probe's argument expressions.  LHS represents
8822 +   the left side of the expression, and PREC is the precedence of the
8823 +   last operator identified before calling the function.  */
8824 +
8825 +static struct value *
8826 +stap_evaluate_probe_argument_2 (struct stap_evaluation_info *eval_info,
8827 +                               struct value *lhs, int prec)
8828 +{
8829 +  struct value *rhs = NULL;
8830 +  int compiling_p = STAP_COMPILING_AGENT_EXPR_P (eval_info);
8831 +
8832 +  /* This is an operator-precedence parser and evaluator.
8833 +
8834 +     We work with left- and right-sides of expressions, and
8835 +     evaluate them depending on the precedence of the operators
8836 +     we find.  */
8837 +
8838 +  eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8839 +
8840 +  if (!lhs)
8841 +    /* We were called without a left-side, either because this is the
8842 +       first call, or because we were called to evaluate a parenthesized
8843 +       expression.  It doesn't really matter; we have to evaluate the
8844 +       left-side in order to continue the process.  */
8845 +    lhs = stap_evaluate_conditionally (eval_info);
8846 +
8847 +  /* Start to evaluate the right-side, and to "join" left and right sides
8848 +     depending on the operation specified.
8849 +
8850 +     This loop shall continue until we run out of characters in the input,
8851 +     or until we find a close-parenthesis, which means that we've reached
8852 +     the end of a sub-expression.  */
8853 +  while (eval_info->exp_buf
8854 +        && *eval_info->exp_buf
8855 +        && *eval_info->exp_buf != ')')
8856 +    {
8857 +      char *tmp_exp_buf;
8858 +      enum exp_opcode opcode;
8859 +      int cur_prec;
8860 +
8861 +      if (!stap_is_operator (eval_info->exp_buf))
8862 +       error (_("Invalid operator `%c' on expression `%s'."),
8863 +              *eval_info->exp_buf, eval_info->saved_expr);
8864 +
8865 +      /* We have to save the current value of the expression buffer because
8866 +        the `stap_get_opcode' modifies it in order to get the current
8867 +        operator.  If this operator's precedence is lower than PREC, we
8868 +        should return and not advance the expression buffer pointer.  */
8869 +      tmp_exp_buf = eval_info->exp_buf;
8870 +      stap_get_opcode (&tmp_exp_buf, &opcode);
8871 +
8872 +      cur_prec = stap_get_operator_prec (opcode);
8873 +      if (cur_prec < prec)
8874 +       /* If the precedence of the operator that we are seeing now is
8875 +          lower than the precedence of the first operator seen before
8876 +          this evaluation process began, it means we should stop evaluating
8877 +          and return.  */
8878 +       break;
8879 +
8880 +      eval_info->exp_buf = tmp_exp_buf;
8881 +      eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8882 +
8883 +      /* Evaluate the right-side of the expression.  */
8884 +      rhs = stap_evaluate_conditionally (eval_info);
8885 +
8886 +      /* While we still have operators, try to evaluate another
8887 +        right-side, but using the current right-side as a left-side.  */
8888 +      while (*eval_info->exp_buf
8889 +            && stap_is_operator (eval_info->exp_buf))
8890 +       {
8891 +         enum exp_opcode lookahead_opcode;
8892 +         int lookahead_prec;
8893 +
8894 +         /* Saving the current expression buffer position.  The explanation
8895 +            is the same as above.  */
8896 +         tmp_exp_buf = eval_info->exp_buf;
8897 +         stap_get_opcode (&tmp_exp_buf, &lookahead_opcode);
8898 +         lookahead_prec = stap_get_operator_prec (lookahead_opcode);
8899 +
8900 +         if (lookahead_prec <= prec)
8901 +           /* If we are dealing with an operator whose precedence is lower
8902 +              than the first one, just abandon the attempt.  */
8903 +           break;
8904 +
8905 +         rhs = stap_evaluate_probe_argument_2 (eval_info,
8906 +                                               rhs, lookahead_prec);
8907 +       }
8908 +
8909 +      /* Now, "join" both left and right sides into one left-side, using
8910 +        the specified operator.  */
8911 +      if (compiling_p)
8912 +       stap_opcode_to_ax (eval_info, opcode);
8913 +      else
8914 +       lhs = value_binop (lhs, rhs, opcode);
8915 +    }
8916 +
8917 +  return lhs;
8918 +}
8919 +
8920 +/* This function fills the necessary arguments for the evaluation function
8921 +   to work.  */
8922 +
8923 +static struct value *
8924 +stap_evaluate_probe_argument_1 (struct objfile *objfile,
8925 +                               const struct stap_probe *probe,
8926 +                               struct frame_info *frame,
8927 +                               int n)
8928 +{
8929 +  struct stap_evaluation_info eval_info;
8930 +  char *s = (char *) probe->parsed_args->arg[n].arg_str;
8931 +  struct value *res, *vs[4];
8932 +
8933 +  /* Filling necessary information for evaluation function.  */
8934 +  eval_info.saved_expr = s;
8935 +  eval_info.exp_buf = s;
8936 +  eval_info.gdbarch = get_objfile_arch (objfile);
8937 +  eval_info.frame = frame;
8938 +  eval_info.bitness = probe->parsed_args->arg[n].bitness;
8939 +  /* We are not compiling to an agent expression.  */
8940 +  eval_info.aexpr = NULL;
8941 +  eval_info.avalue = NULL;
8942 +
8943 +  res = stap_evaluate_probe_argument_2 (&eval_info,
8944 +                                       /*lhs=*/NULL, /*prec=*/0);
8945 +
8946 +  if (!res)
8947 +    error (_("Could not evaluate expression `%s'."),
8948 +          eval_info.saved_expr);
8949 +
8950 +  return res;
8951 +}
8952 +
8953 +/* See definition in stap-probe.h.  */
8954 +
8955 +struct value *
8956 +stap_evaluate_probe_argument (struct objfile *objfile,
8957 +                             const struct stap_probe *probe,
8958 +                             struct frame_info *frame,
8959 +                             int n)
8960 +{
8961 +  if (!probe->parsed_args)
8962 +    stap_parse_probe_arguments ((struct stap_probe *) probe);
8963 +
8964 +  if (!probe->parsed_args->arg
8965 +      || n >= probe->parsed_args->n_args)
8966 +    return NULL;
8967 +
8968 +  return stap_evaluate_probe_argument_1 (objfile, probe, frame, n);
8969 +}
8970 +
8971 +/* Helper function which compiles the probe's argument N into an
8972 +   agent expression, suitable for using with tracepoints.  */
8973 +
8974 +static void
8975 +stap_compile_to_ax_1 (struct objfile *objfile,
8976 +                     const struct stap_probe *probe,
8977 +                     struct agent_expr *expr,
8978 +                     struct axs_value *value,
8979 +                     int n)
8980 +{
8981 +  struct stap_evaluation_info eval_info;
8982 +  struct gdbarch *gdbarch = expr->gdbarch;
8983 +  char *s = (char *) probe->parsed_args->arg[n].arg_str;
8984 +
8985 +  /* Filling necessary information for evaluation function.  */
8986 +  eval_info.saved_expr = s;
8987 +  eval_info.exp_buf = s;
8988 +  eval_info.gdbarch = expr->gdbarch;
8989 +  eval_info.frame = NULL;
8990 +  eval_info.bitness = probe->parsed_args->arg[n].bitness;
8991 +  /* We are compiling to an agent expression.  */
8992 +  eval_info.aexpr = expr;
8993 +  eval_info.avalue = value;
8994 +
8995 +  /* We can always use this kind.  */
8996 +  value->kind = axs_rvalue;
8997 +
8998 +  /* Figuring out the correct type for this axs_value.  */
8999 +  switch (eval_info.bitness)
9000 +    {
9001 +    case STAP_ARG_BITNESS_UNDEFINED:
9002 +      if (gdbarch_addr_bit (gdbarch) == 32)
9003 +       value->type = builtin_type (gdbarch)->builtin_uint32;
9004 +      else
9005 +       value->type = builtin_type (gdbarch)->builtin_uint64;
9006 +      break;
9007 +
9008 +    case STAP_ARG_BITNESS_32BIT_SIGNED:
9009 +      value->type = builtin_type (gdbarch)->builtin_int32;
9010 +      break;
9011 +
9012 +    case STAP_ARG_BITNESS_32BIT_UNSIGNED:
9013 +      value->type = builtin_type (gdbarch)->builtin_uint32;
9014 +      break;
9015 +
9016 +    case STAP_ARG_BITNESS_64BIT_SIGNED:
9017 +      value->type = builtin_type (gdbarch)->builtin_int64;
9018 +      break;
9019 +
9020 +    case STAP_ARG_BITNESS_64BIT_UNSIGNED:
9021 +      value->type = builtin_type (gdbarch)->builtin_uint64;
9022 +      break;
9023 +
9024 +    default:
9025 +      internal_error (__FILE__, __LINE__,
9026 +                     _("Undefined bitness for probe."));
9027 +      break;
9028 +    }
9029 +
9030 +  stap_evaluate_probe_argument_2 (&eval_info,
9031 +                                 /*lhs=*/NULL, /*prec=*/0);
9032 +}
9033 +
9034 +/* See definition in stap-probe.h.  */
9035 +
9036 +void
9037 +stap_compile_to_ax (struct objfile *objfile,
9038 +                   const struct stap_probe *probe,
9039 +                   struct agent_expr *expr,
9040 +                   struct axs_value *value,
9041 +                   int n)
9042 +{
9043 +  if (!probe->parsed_args)
9044 +    stap_parse_probe_arguments ((struct stap_probe *) probe);
9045 +
9046 +  if (!probe->parsed_args->arg
9047 +      || n >= probe->parsed_args->n_args)
9048 +    return;
9049 +
9050 +  stap_compile_to_ax_1 (objfile, probe, expr, value, n);
9051 +}
9052 +
9053 +struct value *
9054 +stap_safe_evaluate_at_pc (struct frame_info *frame, int n)
9055 +{
9056 +  const struct stap_probe *probe;
9057 +  struct objfile *objfile;
9058 +  int n_probes;
9059 +
9060 +  probe = find_probe_by_pc (get_frame_pc (frame), &objfile);
9061 +  if (!probe)
9062 +    return NULL;
9063 +  gdb_assert (objfile->sf && objfile->sf->sym_probe_fns);
9064 +
9065 +  n_probes
9066 +    = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9067 +                                                               probe);
9068 +  if (n >= n_probes)
9069 +    return NULL;
9070 +
9071 +  return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
9072 +                                                                 probe,
9073 +                                                                 frame,
9074 +                                                                 n);
9075 +}
9076 +
9077 +/* This function frees the space allocated to hold information about
9078 +   the probe's parsed arguments.  */
9079 +
9080 +void
9081 +stap_free_parsed_args (struct stap_args_info *parsed_args)
9082 +{
9083 +  int i;
9084 +
9085 +  if (!parsed_args
9086 +      || parsed_args == &dummy_stap_args_info
9087 +      || parsed_args->n_args == 0)
9088 +    return;
9089 +
9090 +  for (i = 0; i < parsed_args->n_args; i++)
9091 +    xfree (parsed_args->arg);
9092 +
9093 +  xfree (parsed_args);
9094 +}
9095 +
9096 +/* A utility structure.  A VEC of these is built when handling "info
9097 +   probes".  */
9098 +
9099 +struct stap_probe_and_objfile
9100 +{
9101 +  /* The probe.  */
9102 +  const struct stap_probe *probe;
9103 +  /* The probe's objfile.  */
9104 +  struct objfile *objfile;
9105 +};
9106 +
9107 +typedef struct stap_probe_and_objfile stap_entry;
9108 +DEF_VEC_O (stap_entry);
9109 +
9110 +/* A helper function for collect_probes that compiles a regexp and
9111 +   throws an exception on error.  This installs a cleanup to free the
9112 +   resulting pattern on success.  If RX is NULL, this does nothing.  */
9113 +
9114 +static void
9115 +compile_rx_or_error (regex_t *pattern, const char *rx, const char *message)
9116 +{
9117 +  int code;
9118 +
9119 +  if (!rx)
9120 +    return;
9121 +
9122 +  code = regcomp (pattern, rx, REG_NOSUB);
9123 +  if (code == 0)
9124 +    make_regfree_cleanup (pattern);
9125 +  else
9126 +    {
9127 +      char *err = get_regcomp_error (code, pattern);
9128 +
9129 +      make_cleanup (xfree, err);
9130 +      error (_("%s: %s"), message, err);
9131 +    }
9132 +}
9133 +
9134 +/* Make a vector of probes matching OBJNAME, PROVIDER, and PROBE.
9135 +   Each argument is a regexp, or NULL, which matches anything.  */
9136 +
9137 +static VEC (stap_entry) *
9138 +collect_probes (char *objname, char *provider, char *probe)
9139 +{
9140 +  struct objfile *objfile;
9141 +  VEC (stap_entry) *result = NULL;
9142 +  struct cleanup *cleanup;
9143 +  regex_t obj_pat, prov_pat, probe_pat;
9144 +
9145 +  cleanup = make_cleanup (VEC_cleanup (stap_entry), &result);
9146 +
9147 +  compile_rx_or_error (&prov_pat, provider, _("Invalid provider regexp"));
9148 +  compile_rx_or_error (&probe_pat, probe, _("Invalid probe regexp"));
9149 +  compile_rx_or_error (&obj_pat, objname, _("Invalid object file regexp"));
9150 +
9151 +  ALL_OBJFILES (objfile)
9152 +  {
9153 +    const struct stap_probe *probes;
9154 +    int i, num_probes;
9155 +
9156 +    if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9157 +      continue;
9158 +
9159 +    if (objname)
9160 +      {
9161 +       if (regexec (&obj_pat, objfile->name, 0, NULL, 0) != 0)
9162 +         continue;
9163 +      }
9164 +
9165 +    probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9166 +    for (i = 0; i < num_probes; ++i)
9167 +      {
9168 +       stap_entry entry;
9169 +
9170 +       if (provider)
9171 +         {
9172 +           if (regexec (&prov_pat, probes[i].provider, 0, NULL, 0) != 0)
9173 +             continue;
9174 +         }
9175 +
9176 +       if (probe)
9177 +         {
9178 +           if (regexec (&probe_pat, probes[i].name, 0, NULL, 0) != 0)
9179 +             continue;
9180 +         }
9181 +
9182 +       entry.probe = &probes[i];
9183 +       entry.objfile = objfile;
9184 +       VEC_safe_push (stap_entry, result, &entry);
9185 +      }
9186 +  }
9187 +
9188 +  discard_cleanups (cleanup);
9189 +  return result;
9190 +}
9191 +
9192 +/* A qsort comparison function for stap_entry objects.  */
9193 +
9194 +static int
9195 +compare_entries (const void *a, const void *b)
9196 +{
9197 +  const stap_entry *ea = a;
9198 +  const stap_entry *eb = b;
9199 +  int v;
9200 +
9201 +  v = strcmp (ea->probe->provider, eb->probe->provider);
9202 +  if (v)
9203 +    return v;
9204 +
9205 +  v = strcmp (ea->probe->name, eb->probe->name);
9206 +  if (v)
9207 +    return v;
9208 +
9209 +  if (ea->probe->address < eb->probe->address)
9210 +    return -1;
9211 +  if (ea->probe->address > eb->probe->address)
9212 +    return 1;
9213 +
9214 +  return strcmp (ea->objfile->name, eb->objfile->name);
9215 +}
9216 +
9217 +/* Implementation of the "info probes" command.  */
9218 +
9219 +static void
9220 +info_probes_command (char *arg, int from_tty)
9221 +{
9222 +  char *provider, *probe = NULL, *objname = NULL;
9223 +  struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
9224 +  VEC (stap_entry) *items;
9225 +  int i, addr_width, any_found;
9226 +  stap_entry *entry;
9227 +
9228 +  provider = extract_arg (&arg);
9229 +  if (provider)
9230 +    {
9231 +      make_cleanup (xfree, provider);
9232 +
9233 +      probe = extract_arg (&arg);
9234 +      if (probe)
9235 +       {
9236 +         make_cleanup (xfree, probe);
9237 +
9238 +         objname = extract_arg (&arg);
9239 +         if (objname)
9240 +           make_cleanup (xfree, objname);
9241 +       }
9242 +    }
9243 +
9244 +  items = collect_probes (objname, provider, probe);
9245 +  make_cleanup (VEC_cleanup (stap_entry), &items);
9246 +  make_cleanup_ui_out_table_begin_end (uiout, 5,
9247 +                                      VEC_length (stap_entry, items),
9248 +                                      "SystemTapProbes");
9249 +
9250 +  if (! VEC_empty (stap_entry, items))
9251 +    qsort (VEC_address (stap_entry, items),
9252 +          VEC_length (stap_entry, items),
9253 +          sizeof (stap_entry),
9254 +          compare_entries);
9255 +
9256 +  addr_width = 4 + (gdbarch_ptr_bit (get_current_arch ()) / 4);
9257 +
9258 +  ui_out_table_header (uiout, 10, ui_left, "provider", _("Provider"));
9259 +  ui_out_table_header (uiout, 10, ui_left, "name", _("Name"));
9260 +  ui_out_table_header (uiout, addr_width - 1, ui_left, "addr", _("Where"));
9261 +  ui_out_table_header (uiout, addr_width - 1, ui_left, "semaphore",
9262 +                      _("Semaphore"));
9263 +  ui_out_table_header (uiout, 30, ui_left, "object", _("Object"));
9264 +  ui_out_table_body (uiout);
9265 +
9266 +  for (i = 0; VEC_iterate (stap_entry, items, i, entry); ++i)
9267 +    {
9268 +      struct cleanup *inner;
9269 +
9270 +      inner = make_cleanup_ui_out_tuple_begin_end (uiout, "probe");
9271 +
9272 +      ui_out_field_string (uiout, "provider", entry->probe->provider);
9273 +      ui_out_field_string (uiout, "name", entry->probe->name);
9274 +      ui_out_field_core_addr (uiout, "addr", get_current_arch (),
9275 +                             entry->probe->address);
9276 +      if (entry->probe->sem_addr == 0)
9277 +       ui_out_field_skip (uiout, "semaphore");
9278 +      else
9279 +      ui_out_field_core_addr (uiout, "semaphore", get_current_arch (),
9280 +                             entry->probe->sem_addr);
9281 +      ui_out_field_string (uiout, "object", entry->objfile->name);
9282 +      ui_out_text (uiout, "\n");
9283 +
9284 +      do_cleanups (inner);
9285 +    }
9286 +
9287 +  any_found = ! VEC_empty (stap_entry, items);
9288 +  do_cleanups (cleanup);
9289 +
9290 +  if (! any_found)
9291 +    ui_out_message (uiout, 0, _("No probes matched.\n"));
9292 +}
9293 +
9294 +\f
9295 +
9296 +/* See definition in stap-probe.h.  */
9297 +
9298 +const struct stap_probe *
9299 +find_probe_in_objfile (struct objfile *objfile,
9300 +                      const char *provider,
9301 +                      const char *name)
9302 +{
9303 +  const struct stap_probe *probes;
9304 +  int i, num_probes;
9305 +
9306 +  if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9307 +    return NULL;
9308 +
9309 +  probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9310 +  for (i = 0; i < num_probes; ++i)
9311 +    {
9312 +      if (strcmp (probes[i].provider, provider) != 0)
9313 +       continue;
9314 +
9315 +      if (strcmp (probes[i].name, name) != 0)
9316 +       continue;
9317 +
9318 +      return &probes[i];
9319 +    }
9320 +
9321 +  return NULL;
9322 +}
9323 +
9324 +/* See definition in stap-probe.h.  */
9325 +
9326 +struct symtabs_and_lines
9327 +parse_stap_probe (char **argptr, struct linespec_result *canonical)
9328 +{
9329 +  char *full_arg = extract_arg (argptr);
9330 +  char *arg = xstrdup (full_arg);
9331 +  char *objfile_name = NULL, *provider = NULL, *name, *p;
9332 +  struct cleanup *cleanup;
9333 +  struct symtabs_and_lines result;
9334 +  struct objfile *objfile;
9335 +
9336 +  result.sals = NULL;
9337 +  result.nelts = 0;
9338 +
9339 +  /* The caller ensured that this starts with 'probe:'.  */
9340 +  gdb_assert (arg && strncmp (arg, "probe:", 6) == 0);
9341 +  cleanup = make_cleanup (xfree, arg);
9342 +  make_cleanup (xfree, full_arg);
9343 +  arg += 6;
9344 +
9345 +  /* Extract each word from the argument, separated by ":"s.  */
9346 +  p = strchr (arg, ':');
9347 +  if (p == NULL)
9348 +    {
9349 +      /* This is `probe:name'.  */
9350 +      name = arg;
9351 +    }
9352 +  else
9353 +    {
9354 +      char *hold = p + 1;
9355 +
9356 +      *p = '\0';
9357 +      p = strchr (hold, ':');
9358 +      if (p == NULL)
9359 +       {
9360 +         /* This is `probe:provider:name'.  */
9361 +         provider = arg;
9362 +         name = hold;
9363 +       }
9364 +      else
9365 +       {
9366 +         /* This is `probe:objfile:provider:name'.  */
9367 +         *p = '\0';
9368 +         objfile_name = arg;
9369 +         provider = hold;
9370 +         name = p + 1;
9371 +       }
9372 +    }
9373 +
9374 +  if (*name == '\0')
9375 +    error (_("no probe name specified"));
9376 +  if (provider && *provider == '\0')
9377 +    error (_("invalid provider name"));
9378 +  if (objfile_name && *objfile_name == '\0')
9379 +    error (_("invalid objfile name"));
9380 +
9381 +  if (canonical)
9382 +    canonical->canonical = NULL;
9383 +
9384 +  ALL_OBJFILES (objfile)
9385 +  {
9386 +    const struct stap_probe *probes;
9387 +    int i, num_probes;
9388 +
9389 +    if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9390 +      continue;
9391 +
9392 +    if (objfile_name
9393 +       && FILENAME_CMP (objfile->name, objfile_name) != 0
9394 +       && FILENAME_CMP (lbasename (objfile->name), objfile_name) != 0)
9395 +      continue;
9396 +
9397 +    probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9398 +    for (i = 0; i < num_probes; ++i)
9399 +      {
9400 +       struct symtab_and_line *sal;
9401 +
9402 +       if (provider && strcmp (probes[i].provider, provider) != 0)
9403 +         continue;
9404 +
9405 +       if (strcmp (probes[i].name, name) != 0)
9406 +         continue;
9407 +
9408 +       ++result.nelts;
9409 +       result.sals = xrealloc (result.sals,
9410 +                               result.nelts * sizeof (struct symtab_and_line));
9411 +       sal = &result.sals[result.nelts - 1];
9412 +
9413 +       init_sal (sal);
9414 +
9415 +       sal->pc = probes[i].address;
9416 +       sal->explicit_pc = 1;
9417 +       sal->section = find_pc_overlay (sal->pc);
9418 +       sal->pspace = current_program_space;
9419 +       sal->semaphore = probes[i].sem_addr;
9420 +
9421 +       if (canonical)
9422 +         {
9423 +           canonical->canonical = xrealloc (canonical->canonical,
9424 +                                            result.nelts * sizeof (char **));
9425 +           canonical->canonical[result.nelts - 1] = xstrdup (full_arg);
9426 +         }
9427 +      }
9428 +  }
9429 +
9430 +  if (result.nelts == 0)
9431 +    {
9432 +      throw_error (NOT_FOUND_ERROR,
9433 +                  _("No probe matching objfile=`%s', provider=`%s', name=`%s'"),
9434 +                  objfile_name ? objfile_name : _("<any>"),
9435 +                  provider ? provider : _("<any>"),
9436 +                  name);
9437 +    }
9438 +
9439 +  if (canonical)
9440 +    {
9441 +      canonical->special_display = 1;
9442 +      canonical->pre_expanded = 1;
9443 +    }
9444 +
9445 +  do_cleanups (cleanup);
9446 +
9447 +  return result;
9448 +}
9449 +
9450 +\f
9451 +
9452 +/* See definition in stap-probe.h.  */
9453 +
9454 +const struct stap_probe *
9455 +find_probe_by_pc (CORE_ADDR pc, struct objfile **objfile_out)
9456 +{
9457 +  struct objfile *objfile;
9458 +
9459 +  ALL_OBJFILES (objfile)
9460 +  {
9461 +    const struct stap_probe *probes;
9462 +    int i, num_probes;
9463 +    stap_entry entry;
9464 +
9465 +    if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9466 +      continue;
9467 +
9468 +    /* If this proves too inefficient, we can replace with a hash.  */
9469 +    probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9470 +    for (i = 0; i < num_probes; ++i)
9471 +      {
9472 +       if (probes[i].address == pc)
9473 +         {
9474 +           *objfile_out = objfile;
9475 +           return &probes[i];
9476 +         }
9477 +      }
9478 +  }
9479 +
9480 +  return NULL;
9481 +}
9482 +
9483 +/* This is called to compute the value of one of the $_probe_arg*
9484 +   convenience variables.  */
9485 +
9486 +static struct value *
9487 +compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
9488 +                  void *data)
9489 +{
9490 +  struct frame_info *frame = get_selected_frame (_("No frame selected"));
9491 +  CORE_ADDR pc = get_frame_pc (frame);
9492 +  int sel = (int) (uintptr_t) data;
9493 +  struct objfile *objfile;
9494 +  const struct stap_probe *pc_probe;
9495 +  int n_probes;
9496 +
9497 +  /* SEL==10 means "_probe_argc".  */
9498 +  gdb_assert (sel >= 0 && sel <= STAP_MAX_ARGS);
9499 +
9500 +  pc_probe = find_probe_by_pc (pc, &objfile);
9501 +  if (pc_probe == NULL)
9502 +    error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
9503 +
9504 +  n_probes
9505 +    = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9506 +                                                               pc_probe);
9507 +  if (sel == 10)
9508 +    return value_from_longest (builtin_type (arch)->builtin_int, n_probes);
9509 +
9510 +  if (sel >= n_probes)
9511 +    error (_("Invalid probe argument %d -- probe has %d arguments available"),
9512 +          sel, n_probes);
9513 +
9514 +  return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
9515 +                                                                 pc_probe,
9516 +                                                                 frame, sel);
9517 +}
9518 +
9519 +/* This is called to compile one of the $_probe_arg* convenience
9520 +   variables into an agent expression.  */
9521 +
9522 +static void
9523 +compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
9524 +                  struct axs_value *value, void *data)
9525 +{
9526 +  CORE_ADDR pc = expr->scope;
9527 +  int sel = (int) (uintptr_t) data;
9528 +  struct objfile *objfile;
9529 +  const struct stap_probe *pc_probe;
9530 +  int n_probes;
9531 +
9532 +  /* SEL==10 means "_probe_argc".  */
9533 +  gdb_assert (sel >= 0 && sel <= 10);
9534 +
9535 +  pc_probe = find_probe_by_pc (pc, &objfile);
9536 +  if (pc_probe == NULL)
9537 +    error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
9538 +
9539 +  n_probes
9540 +    = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9541 +                                                               pc_probe);
9542 +  if (sel == 10)
9543 +    {
9544 +      value->kind = axs_rvalue;
9545 +      value->type = builtin_type (expr->gdbarch)->builtin_int;
9546 +      ax_const_l (expr, n_probes);
9547 +      return;
9548 +    }
9549 +
9550 +  gdb_assert (sel >= 0);
9551 +  if (sel >= n_probes)
9552 +    error (_("Invalid probe argument %d -- probe has %d arguments available"),
9553 +          sel, n_probes);
9554 +
9555 +  objfile->sf->sym_probe_fns->sym_compile_to_ax (objfile, pc_probe,
9556 +                                                expr, value, sel);
9557 +}
9558 +
9559 +\f
9560 +
9561 +/* Implementation of `$_probe_arg*' set of variables.  */
9562 +
9563 +static const struct internalvar_funcs probe_funcs =
9564 +{
9565 +  compute_probe_arg,
9566 +  compile_probe_arg,
9567 +  NULL
9568 +};
9569 +
9570 +void
9571 +_initialize_stap_probe (void)
9572 +{
9573 +  add_info ("probes", info_probes_command, _("\
9574 +Show available static probes.\n\
9575 +Usage: info probes [PROVIDER [NAME [OBJECT]]]\n\
9576 +Each argument is a regular expression, used to select probes.\n\
9577 +PROVIDER matches probe provider names.\n\
9578 +NAME matches the probe names.\n\
9579 +OBJECT match the executable or shared library name."));
9580 +
9581 +  create_internalvar_type_lazy ("_probe_argc", &probe_funcs,
9582 +                               (void *) (uintptr_t) 10);
9583 +  create_internalvar_type_lazy ("_probe_arg0", &probe_funcs,
9584 +                               (void *) (uintptr_t) 0);
9585 +  create_internalvar_type_lazy ("_probe_arg1", &probe_funcs,
9586 +                               (void *) (uintptr_t) 1);
9587 +  create_internalvar_type_lazy ("_probe_arg2", &probe_funcs,
9588 +                               (void *) (uintptr_t) 2);
9589 +  create_internalvar_type_lazy ("_probe_arg3", &probe_funcs,
9590 +                               (void *) (uintptr_t) 3);
9591 +  create_internalvar_type_lazy ("_probe_arg4", &probe_funcs,
9592 +                               (void *) (uintptr_t) 4);
9593 +  create_internalvar_type_lazy ("_probe_arg5", &probe_funcs,
9594 +                               (void *) (uintptr_t) 5);
9595 +  create_internalvar_type_lazy ("_probe_arg6", &probe_funcs,
9596 +                               (void *) (uintptr_t) 6);
9597 +  create_internalvar_type_lazy ("_probe_arg7", &probe_funcs,
9598 +                               (void *) (uintptr_t) 7);
9599 +  create_internalvar_type_lazy ("_probe_arg8", &probe_funcs,
9600 +                               (void *) (uintptr_t) 8);
9601 +  create_internalvar_type_lazy ("_probe_arg9", &probe_funcs,
9602 +                               (void *) (uintptr_t) 9);
9603 +}
9604 Index: gdb-7.2.90.20110703/gdb/stap-probe.h
9605 ===================================================================
9606 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
9607 +++ gdb-7.2.90.20110703/gdb/stap-probe.h        2011-07-03 10:33:11.000000000 +0200
9608 @@ -0,0 +1,109 @@
9609 +/* SystemTap probe support for GDB.
9610 +
9611 +   Copyright (C) 2011 Free Software Foundation, Inc.
9612 +
9613 +   This file is part of GDB.
9614 +
9615 +   This program is free software; you can redistribute it and/or modify
9616 +   it under the terms of the GNU General Public License as published by
9617 +   the Free Software Foundation; either version 3 of the License, or
9618 +   (at your option) any later version.
9619 +
9620 +   This program is distributed in the hope that it will be useful,
9621 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
9622 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9623 +   GNU General Public License for more details.
9624 +
9625 +   You should have received a copy of the GNU General Public License
9626 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
9627 +
9628 +#if !defined (STAP_PROBE_H)
9629 +#define STAP_PROBE_H 1
9630 +
9631 +struct stap_args_info;
9632 +struct axs_value;
9633 +struct linespec_result;
9634 +
9635 +/* Main structure which holds information about a SystemTap probe.  */
9636 +
9637 +struct stap_probe
9638 +{
9639 +  /* The provider of this probe.  */
9640 +  const char *provider;
9641 +
9642 +  /* The name of the probe.  */
9643 +  const char *name;
9644 +
9645 +  /* The address where the probe is inserted.  */
9646 +  CORE_ADDR address;
9647 +
9648 +  /* The address of the probe's semaphore, or 0 if this probe does not
9649 +     have an associated semaphore.  */
9650 +  CORE_ADDR sem_addr;
9651 +
9652 +  /* Probe's arguments.  Users should generally not examine this, but
9653 +     should instead extract information about the arguments using the
9654 +     methods provided in sym_probe_fns.  */
9655 +  const char *args;
9656 +
9657 +  /* Probe's arguments after parsing.  This is an opaque structure that
9658 +     will hold information about the arguments pointed by ARGS.  */
9659 +  struct stap_args_info *parsed_args;
9660 +};
9661 +
9662 +
9663 +/* A helper for linespec that decodes a stap probe specification.  It
9664 +   returns a symtabs_and_lines object and updates *ARGPTR or throws an
9665 +   error.  */
9666 +
9667 +extern struct symtabs_and_lines parse_stap_probe (char **argptr,
9668 +                                                 struct linespec_result *canon);
9669 +
9670 +/* Search OBJFILE for a probe with the given PROVIDER and NAME.  If a
9671 +   probe is found, return it.  If no probe is found, return NULL.  */
9672 +
9673 +extern const struct stap_probe *find_probe_in_objfile (struct objfile *objfile,
9674 +                                                      const char *provider,
9675 +                                                      const char *name);
9676 +
9677 +/* Given a PC, find an associated SystemTap probe.  If a probe is
9678 +   found, set *OBJFILE_OUT to the probe's objfile, and return the
9679 +   probe.  If no probe is found, return NULL.  */
9680 +
9681 +extern const struct stap_probe *find_probe_by_pc (CORE_ADDR pc,
9682 +                                                 struct objfile **objfile_out);
9683 +
9684 +/* Given PROBE, returns the number of arguments present in that probe's
9685 +   argument string.  */
9686 +
9687 +extern int stap_get_probe_argument_count (const struct stap_probe *probe);
9688 +
9689 +/* Given PARSED_ARGS, frees the space allocated to hold information about
9690 +   the probe's parsed arguments.  */
9691 +
9692 +extern void stap_free_parsed_args (struct stap_args_info *parsed_args);
9693 +
9694 +/* Evaluates the probe's argument N, returning a value corresponding
9695 +   to it.  */
9696 +
9697 +extern struct value *stap_evaluate_probe_argument (struct objfile *objfile,
9698 +                                                  const struct stap_probe *probe,
9699 +                                                  struct frame_info *frame,
9700 +                                                  int n);
9701 +
9702 +/* Compile the probe's argument N to agent expression.  */
9703 +
9704 +extern void stap_compile_to_ax (struct objfile *objfile,
9705 +                               const struct stap_probe *probe,
9706 +                               struct agent_expr *expr,
9707 +                               struct axs_value *value,
9708 +                               int n);
9709 +
9710 +/* A convenience function that finds a probe at the PC in FRAME and
9711 +   evaluates argument N.  If there is no probe at that location, or if
9712 +   the probe does not have enough arguments, this returns NULL.  */
9713 +
9714 +extern struct value *stap_safe_evaluate_at_pc (struct frame_info *frame,
9715 +                                              int n);
9716 +
9717 +#endif /* !defined (STAP_PROBE_H) */
9718 Index: gdb-7.2.90.20110703/gdb/symfile.h
9719 ===================================================================
9720 --- gdb-7.2.90.20110703.orig/gdb/symfile.h      2011-04-25 23:25:18.000000000 +0200
9721 +++ gdb-7.2.90.20110703/gdb/symfile.h   2011-07-03 10:33:11.000000000 +0200
9722 @@ -31,6 +31,11 @@ struct objfile;
9723  struct obj_section;
9724  struct obstack;
9725  struct block;
9726 +struct stap_probe;
9727 +struct value;
9728 +struct frame_info;
9729 +struct agent_expr;
9730 +struct axs_value;
9731  
9732  /* Comparison function for symbol look ups.  */
9733  
9734 @@ -290,6 +295,52 @@ struct quick_symbol_functions
9735                                 void *data);
9736  };
9737  
9738 +/* Structure of functions used for SystemTap probe support.  If one of
9739 +   these functions is provided, all must be.  */
9740 +
9741 +struct sym_probe_fns
9742 +{
9743 +  /* If non-NULL, return an array of SystemTap probe objects.  The
9744 +     number of objects is returned in *NUM_PROBES.  */
9745 +  const struct stap_probe *(*sym_get_probes) (struct objfile *,
9746 +                                             int *num_probes);
9747 +
9748 +  /* Return the number of arguments available to PROBE.  PROBE will
9749 +     have come from a call to this objfile's sym_get_probes method.
9750 +     If you provide an implementation of sym_get_probes, you must
9751 +     implement this method as well.  */
9752 +  int (*sym_get_probe_argument_count) (struct objfile *objfile,
9753 +                                      const struct stap_probe *probe);
9754 +
9755 +  /* Evaluate the Nth argument available to PROBE.  PROBE will have
9756 +     come from a call to this objfile's sym_get_probes method.  N will
9757 +     be between 0 and the number of arguments available to this probe.
9758 +     FRAME is the frame in which the evaluation is done; the frame's
9759 +     PC will match the address of the probe.  If you provide an
9760 +     implementation of sym_get_probes, you must implement this method
9761 +     as well.  */
9762 +  struct value *(*sym_evaluate_probe_argument) (struct objfile *objfile,
9763 +                                               const struct stap_probe *probe,
9764 +                                               struct frame_info *frame,
9765 +                                               int n);
9766 +
9767 +  /* Compile the Nth probe argument to an agent expression.  PROBE
9768 +     will have come from a call to this objfile's sym_get_probes
9769 +     method.  N will be between 0 and the number of arguments
9770 +     available to this probe.  EXPR and VALUE are the agent expression
9771 +     that is being updated.  */
9772 +  void (*sym_compile_to_ax) (struct objfile *objfile,
9773 +                            const struct stap_probe *probe,
9774 +                            struct agent_expr *expr,
9775 +                            struct axs_value *value,
9776 +                            int n);
9777 +
9778 +  /* Relocate the probe section of OBJFILE.  */
9779 +  void (*sym_relocate_probe) (struct objfile *objfile,
9780 +                             struct section_offsets *new_offsets,
9781 +                             struct section_offsets *delta);
9782 +};
9783 +
9784  /* Structure to keep track of symbol reading functions for various
9785     object file types.  */
9786  
9787 @@ -360,6 +411,10 @@ struct sym_fns
9788  
9789    bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf);
9790  
9791 +  /* If non-NULL, this objfile has probe support, and all the probe
9792 +     functions referred to here will be non-NULL.  */
9793 +  const struct sym_probe_fns *sym_probe_fns;
9794 +
9795    /* The "quick" (aka partial) symbol functions for this symbol
9796       reader.  */
9797    const struct quick_symbol_functions *qf;
9798 Index: gdb-7.2.90.20110703/gdb/symtab.c
9799 ===================================================================
9800 --- gdb-7.2.90.20110703.orig/gdb/symtab.c       2011-07-02 22:03:43.000000000 +0200
9801 +++ gdb-7.2.90.20110703/gdb/symtab.c    2011-07-03 10:33:11.000000000 +0200
9802 @@ -770,6 +770,7 @@ init_sal (struct symtab_and_line *sal)
9803    sal->end = 0;
9804    sal->explicit_pc = 0;
9805    sal->explicit_line = 0;
9806 +  sal->semaphore = 0;
9807  }
9808  \f
9809  
9810 Index: gdb-7.2.90.20110703/gdb/symtab.h
9811 ===================================================================
9812 --- gdb-7.2.90.20110703.orig/gdb/symtab.h       2011-05-06 17:13:37.000000000 +0200
9813 +++ gdb-7.2.90.20110703/gdb/symtab.h    2011-07-03 10:33:11.000000000 +0200
9814 @@ -1118,6 +1118,10 @@ struct symtab_and_line
9815    CORE_ADDR end;
9816    int explicit_pc;
9817    int explicit_line;
9818 +
9819 +  /* If non-zero, the semaphore location associated with a SystemTap
9820 +     probe.  */
9821 +  CORE_ADDR semaphore;
9822  };
9823  
9824  extern void init_sal (struct symtab_and_line *sal);
9825 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
9826 ===================================================================
9827 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
9828 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S 2011-07-03 10:33:11.000000000 +0200
9829 @@ -0,0 +1,457 @@
9830 +       .file   "x86_64-vla-pointer.c"
9831 +       .section        .debug_abbrev,"",@progbits
9832 +.Ldebug_abbrev0:
9833 +       .section        .debug_info,"",@progbits
9834 +.Ldebug_info0:
9835 +       .section        .debug_line,"",@progbits
9836 +.Ldebug_line0:
9837 +       .text
9838 +.Ltext0:
9839 +.globl foo
9840 +       .type   foo, @function
9841 +foo:
9842 +.LFB2:
9843 +       .file 1 "x86_64-vla-pointer.c"
9844 +       .loc 1 22 0
9845 +       pushq   %rbp
9846 +.LCFI0:
9847 +       movq    %rsp, %rbp
9848 +.LCFI1:
9849 +       subq    $64, %rsp
9850 +.LCFI2:
9851 +       movl    %edi, -36(%rbp)
9852 +       .loc 1 22 0
9853 +       movq    %rsp, %rax
9854 +       movq    %rax, -48(%rbp)
9855 +       .loc 1 23 0
9856 +       movl    -36(%rbp), %edx
9857 +       movslq  %edx,%rax
9858 +       subq    $1, %rax
9859 +       movq    %rax, -24(%rbp)
9860 +       .loc 1 24 0
9861 +       movslq  %edx,%rax
9862 +       addq    $15, %rax
9863 +       addq    $15, %rax
9864 +       shrq    $4, %rax
9865 +       salq    $4, %rax
9866 +       subq    %rax, %rsp
9867 +       movq    %rsp, -56(%rbp)
9868 +       movq    -56(%rbp), %rax
9869 +       addq    $15, %rax
9870 +       shrq    $4, %rax
9871 +       salq    $4, %rax
9872 +       movq    %rax, -56(%rbp)
9873 +       movq    -56(%rbp), %rax
9874 +       movq    %rax, -16(%rbp)
9875 +       .loc 1 27 0
9876 +       movl    $0, -4(%rbp)
9877 +       jmp     .L2
9878 +.L3:
9879 +       .loc 1 28 0
9880 +       movl    -4(%rbp), %esi
9881 +       movl    -4(%rbp), %eax
9882 +       movl    %eax, %ecx
9883 +       movq    -16(%rbp), %rdx
9884 +       movslq  %esi,%rax
9885 +       movb    %cl, (%rdx,%rax)
9886 +       .loc 1 27 0
9887 +       addl    $1, -4(%rbp)
9888 +.L2:
9889 +       movl    -4(%rbp), %eax
9890 +       cmpl    -36(%rbp), %eax
9891 +       jl      .L3
9892 +       .loc 1 30 0
9893 +       .globl  break_here
9894 +break_here:
9895 +       movq    -16(%rbp), %rax
9896 +       movb    $0, (%rax)
9897 +       movq    -48(%rbp), %rsp
9898 +       .loc 1 31 0
9899 +       leave
9900 +       ret
9901 +.LFE2:
9902 +       .size   foo, .-foo
9903 +       .section        .debug_frame,"",@progbits
9904 +.Lframe0:
9905 +       .long   .LECIE0-.LSCIE0
9906 +.LSCIE0:
9907 +       .long   0xffffffff
9908 +       .byte   0x1
9909 +       .string ""
9910 +       .uleb128 0x1
9911 +       .sleb128 -8
9912 +       .byte   0x10
9913 +       .byte   0xc
9914 +       .uleb128 0x7
9915 +       .uleb128 0x8
9916 +       .byte   0x90
9917 +       .uleb128 0x1
9918 +       .align 8
9919 +.LECIE0:
9920 +.LSFDE0:
9921 +       .long   .LEFDE0-.LASFDE0
9922 +.LASFDE0:
9923 +       .long   .Lframe0
9924 +       .quad   .LFB2
9925 +       .quad   .LFE2-.LFB2
9926 +       .byte   0x4
9927 +       .long   .LCFI0-.LFB2
9928 +       .byte   0xe
9929 +       .uleb128 0x10
9930 +       .byte   0x86
9931 +       .uleb128 0x2
9932 +       .byte   0x4
9933 +       .long   .LCFI1-.LCFI0
9934 +       .byte   0xd
9935 +       .uleb128 0x6
9936 +       .align 8
9937 +.LEFDE0:
9938 +       .section        .eh_frame,"a",@progbits
9939 +.Lframe1:
9940 +       .long   .LECIE1-.LSCIE1
9941 +.LSCIE1:
9942 +       .long   0x0
9943 +       .byte   0x1
9944 +       .string "zR"
9945 +       .uleb128 0x1
9946 +       .sleb128 -8
9947 +       .byte   0x10
9948 +       .uleb128 0x1
9949 +       .byte   0x3
9950 +       .byte   0xc
9951 +       .uleb128 0x7
9952 +       .uleb128 0x8
9953 +       .byte   0x90
9954 +       .uleb128 0x1
9955 +       .align 8
9956 +.LECIE1:
9957 +.LSFDE1:
9958 +       .long   .LEFDE1-.LASFDE1
9959 +.LASFDE1:
9960 +       .long   .LASFDE1-.Lframe1
9961 +       .long   .LFB2
9962 +       .long   .LFE2-.LFB2
9963 +       .uleb128 0x0
9964 +       .byte   0x4
9965 +       .long   .LCFI0-.LFB2
9966 +       .byte   0xe
9967 +       .uleb128 0x10
9968 +       .byte   0x86
9969 +       .uleb128 0x2
9970 +       .byte   0x4
9971 +       .long   .LCFI1-.LCFI0
9972 +       .byte   0xd
9973 +       .uleb128 0x6
9974 +       .align 8
9975 +.LEFDE1:
9976 +       .text
9977 +.Letext0:
9978 +       .section        .debug_loc,"",@progbits
9979 +.Ldebug_loc0:
9980 +.LLST0:
9981 +       .quad   .LFB2-.Ltext0
9982 +       .quad   .LCFI0-.Ltext0
9983 +       .value  0x2
9984 +       .byte   0x77
9985 +       .sleb128 8
9986 +       .quad   .LCFI0-.Ltext0
9987 +       .quad   .LCFI1-.Ltext0
9988 +       .value  0x2
9989 +       .byte   0x77
9990 +       .sleb128 16
9991 +       .quad   .LCFI1-.Ltext0
9992 +       .quad   .LFE2-.Ltext0
9993 +       .value  0x2
9994 +       .byte   0x76
9995 +       .sleb128 16
9996 +       .quad   0x0
9997 +       .quad   0x0
9998 +       .section        .debug_info
9999 +.Ldebug_relative:
10000 +       .long   .Ldebug_end - .Ldebug_start
10001 +.Ldebug_start:
10002 +       .value  0x2
10003 +       .long   .Ldebug_abbrev0
10004 +       .byte   0x8
10005 +       .uleb128 0x1
10006 +       .long   .LASF2
10007 +       .byte   0x1
10008 +       .long   .LASF3
10009 +       .long   .LASF4
10010 +       .quad   .Ltext0
10011 +       .quad   .Letext0
10012 +       .long   .Ldebug_line0
10013 +       .uleb128 0x2
10014 +       .byte   0x1
10015 +       .string "foo"
10016 +       .byte   0x1
10017 +       .byte   0x16
10018 +       .byte   0x1
10019 +       .quad   .LFB2
10020 +       .quad   .LFE2
10021 +       .long   .LLST0
10022 +       .long   .Ltype_int - .Ldebug_relative
10023 +       .uleb128 0x3
10024 +       .long   .LASF5
10025 +       .byte   0x1
10026 +       .byte   0x15
10027 +       .long   .Ltype_int - .Ldebug_relative
10028 +       .byte   0x2
10029 +       .byte   0x91
10030 +       .sleb128 -52
10031 +.Ltag_pointer:
10032 +       .uleb128 0x4
10033 +       .byte   0x8     /* DW_AT_byte_size */
10034 +       .long   .Ltag_array_type - .debug_info  /* DW_AT_type */
10035 +       .uleb128 0x5    /* Abbrev Number: 5 (DW_TAG_variable) */
10036 +       .long   .LASF0
10037 +       .byte   0x1
10038 +       .byte   0x18
10039 +#if 1
10040 +       .long   .Ltag_pointer - .debug_info
10041 +#else
10042 +       /* Debugging only: Skip the typedef indirection.  */
10043 +       .long   .Ltag_array_type - .debug_info
10044 +#endif
10045 +       /* DW_AT_location: DW_FORM_block1: start */
10046 +       .byte   0x3
10047 +       .byte   0x91
10048 +       .sleb128 -32
10049 +#if 0
10050 +       .byte   0x6     /* DW_OP_deref */
10051 +#else
10052 +       .byte   0x96    /* DW_OP_nop */
10053 +#endif
10054 +       /* DW_AT_location: DW_FORM_block1: end */
10055 +       .uleb128 0x6
10056 +       .string "i"
10057 +       .byte   0x1
10058 +       .byte   0x19
10059 +       .long   .Ltype_int - .Ldebug_relative
10060 +       .byte   0x2
10061 +       .byte   0x91
10062 +       .sleb128 -20
10063 +       .byte   0x0
10064 +.Ltype_int:
10065 +       .uleb128 0x7
10066 +       .byte   0x4
10067 +       .byte   0x5
10068 +       .string "int"
10069 +.Ltag_array_type:
10070 +       .uleb128 0x8    /* Abbrev Number: 8 (DW_TAG_array_type) */
10071 +       .long   .Ltype_char - .Ldebug_relative
10072 +       .long   .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */
10073 +1:     /* DW_AT_data_location: DW_FORM_block1: start */
10074 +       .byte   2f - 3f /* length */
10075 +3:
10076 +       .byte   0x97    /* DW_OP_push_object_address */
10077 +#if 1
10078 +       .byte   0x6     /* DW_OP_deref */
10079 +#else
10080 +       .byte   0x96    /* DW_OP_nop */
10081 +#endif
10082 +2:     /* DW_AT_data_location: DW_FORM_block1: end */
10083 +       .uleb128 0x9
10084 +       .long   .Ltype_char - .Ldebug_relative  /* DW_AT_type: DW_FORM_ref4 */
10085 +       .byte   0x3
10086 +       .byte   0x91
10087 +       .sleb128 -40
10088 +       .byte   0x6
10089 +       .byte   0x0
10090 +.Ltype_ulong:
10091 +       .uleb128 0xa
10092 +       .byte   0x8
10093 +       .byte   0x7
10094 +.Ltype_char:
10095 +       .uleb128 0xb
10096 +       .byte   0x1
10097 +       .byte   0x6
10098 +       .long   .LASF1
10099 +       .byte   0x0
10100 +.Ldebug_end:
10101 +       .section        .debug_abbrev
10102 +       .uleb128 0x1
10103 +       .uleb128 0x11
10104 +       .byte   0x1
10105 +       .uleb128 0x25
10106 +       .uleb128 0xe
10107 +       .uleb128 0x13
10108 +       .uleb128 0xb
10109 +       .uleb128 0x3
10110 +       .uleb128 0xe
10111 +       .uleb128 0x1b
10112 +       .uleb128 0xe
10113 +       .uleb128 0x11
10114 +       .uleb128 0x1
10115 +       .uleb128 0x12
10116 +       .uleb128 0x1
10117 +       .uleb128 0x10
10118 +       .uleb128 0x6
10119 +       .byte   0x0
10120 +       .byte   0x0
10121 +       .uleb128 0x2
10122 +       .uleb128 0x2e
10123 +       .byte   0x1
10124 +       .uleb128 0x3f
10125 +       .uleb128 0xc
10126 +       .uleb128 0x3
10127 +       .uleb128 0x8
10128 +       .uleb128 0x3a
10129 +       .uleb128 0xb
10130 +       .uleb128 0x3b
10131 +       .uleb128 0xb
10132 +       .uleb128 0x27
10133 +       .uleb128 0xc
10134 +       .uleb128 0x11
10135 +       .uleb128 0x1
10136 +       .uleb128 0x12
10137 +       .uleb128 0x1
10138 +       .uleb128 0x40
10139 +       .uleb128 0x6
10140 +       .uleb128 0x1
10141 +       .uleb128 0x13
10142 +       .byte   0x0
10143 +       .byte   0x0
10144 +       .uleb128 0x3
10145 +       .uleb128 0x5
10146 +       .byte   0x0
10147 +       .uleb128 0x3
10148 +       .uleb128 0xe
10149 +       .uleb128 0x3a
10150 +       .uleb128 0xb
10151 +       .uleb128 0x3b
10152 +       .uleb128 0xb
10153 +       .uleb128 0x49
10154 +       .uleb128 0x13
10155 +       .uleb128 0x2
10156 +       .uleb128 0xa
10157 +       .byte   0x0
10158 +       .byte   0x0
10159 +       .uleb128 0x4    /* .Ltag_pointer abbrev */
10160 +       .uleb128 0x0f   /* DW_TAG_pointer_type */
10161 +       .byte   0x0
10162 +       .uleb128 0x0b
10163 +       .uleb128 0xb
10164 +       .uleb128 0x49
10165 +       .uleb128 0x13
10166 +       .byte   0x0
10167 +       .byte   0x0
10168 +       .uleb128 0x5
10169 +       .uleb128 0x34
10170 +       .byte   0x0
10171 +       .uleb128 0x3
10172 +       .uleb128 0xe
10173 +       .uleb128 0x3a
10174 +       .uleb128 0xb
10175 +       .uleb128 0x3b
10176 +       .uleb128 0xb
10177 +       .uleb128 0x49
10178 +       .uleb128 0x13
10179 +       .uleb128 0x2
10180 +       .uleb128 0xa
10181 +       .byte   0x0
10182 +       .byte   0x0
10183 +       .uleb128 0x6
10184 +       .uleb128 0x34
10185 +       .byte   0x0
10186 +       .uleb128 0x3
10187 +       .uleb128 0x8
10188 +       .uleb128 0x3a
10189 +       .uleb128 0xb
10190 +       .uleb128 0x3b
10191 +       .uleb128 0xb
10192 +       .uleb128 0x49
10193 +       .uleb128 0x13
10194 +       .uleb128 0x2
10195 +       .uleb128 0xa
10196 +       .byte   0x0
10197 +       .byte   0x0
10198 +       .uleb128 0x7
10199 +       .uleb128 0x24
10200 +       .byte   0x0
10201 +       .uleb128 0xb
10202 +       .uleb128 0xb
10203 +       .uleb128 0x3e
10204 +       .uleb128 0xb
10205 +       .uleb128 0x3
10206 +       .uleb128 0x8
10207 +       .byte   0x0
10208 +       .byte   0x0
10209 +       .uleb128 0x8    /* Abbrev Number: 8 (DW_TAG_array_type) */
10210 +       .uleb128 0x1
10211 +       .byte   0x1
10212 +       .uleb128 0x49   /* DW_AT_type */
10213 +       .uleb128 0x13   /* DW_FORM_ref4 */
10214 +       .uleb128 0x1    /* DW_AT_sibling */
10215 +       .uleb128 0x13   /* DW_FORM_ref4 */
10216 +       .uleb128 0x50   /* DW_AT_data_location */
10217 +       .uleb128 0xa    /* DW_FORM_block1 */
10218 +       .byte   0x0
10219 +       .byte   0x0
10220 +       .uleb128 0x9
10221 +       .uleb128 0x21
10222 +       .byte   0x0
10223 +       .uleb128 0x49   /* DW_AT_type */
10224 +       .uleb128 0x13   /* DW_FORM_ref4 */
10225 +       .uleb128 0x2f
10226 +       .uleb128 0xa
10227 +       .byte   0x0
10228 +       .byte   0x0
10229 +       .uleb128 0xa
10230 +       .uleb128 0x24
10231 +       .byte   0x0
10232 +       .uleb128 0xb
10233 +       .uleb128 0xb
10234 +       .uleb128 0x3e
10235 +       .uleb128 0xb
10236 +       .byte   0x0
10237 +       .byte   0x0
10238 +       .uleb128 0xb
10239 +       .uleb128 0x24
10240 +       .byte   0x0
10241 +       .uleb128 0xb
10242 +       .uleb128 0xb
10243 +       .uleb128 0x3e
10244 +       .uleb128 0xb
10245 +       .uleb128 0x3
10246 +       .uleb128 0xe
10247 +       .byte   0x0
10248 +       .byte   0x0
10249 +       .byte   0x0
10250 +       .section        .debug_pubnames,"",@progbits
10251 +       .long   0x16
10252 +       .value  0x2
10253 +       .long   .Ldebug_info0
10254 +       .long   0xa8
10255 +       .long   0x2d
10256 +       .string "foo"
10257 +       .long   0x0
10258 +       .section        .debug_aranges,"",@progbits
10259 +       .long   0x2c
10260 +       .value  0x2
10261 +       .long   .Ldebug_info0
10262 +       .byte   0x8
10263 +       .byte   0x0
10264 +       .value  0x0
10265 +       .value  0x0
10266 +       .quad   .Ltext0
10267 +       .quad   .Letext0-.Ltext0
10268 +       .quad   0x0
10269 +       .quad   0x0
10270 +       .section        .debug_str,"MS",@progbits,1
10271 +.LASF0:
10272 +       .string "array"
10273 +.LASF5:
10274 +       .string "size"
10275 +.LASF3:
10276 +       .string "x86_64-vla-pointer.c"
10277 +.LASF6:
10278 +       .string "array_t"
10279 +.LASF1:
10280 +       .string "char"
10281 +.LASF4:
10282 +       .string "gdb.arch"
10283 +.LASF2:
10284 +       .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
10285 +       .ident  "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
10286 +       .section        .note.GNU-stack,"",@progbits
10287 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
10288 ===================================================================
10289 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10290 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c     2011-07-03 10:33:11.000000000 +0200
10291 @@ -0,0 +1,43 @@
10292 +/* This testcase is part of GDB, the GNU debugger.
10293 +
10294 +   Copyright 2009 Free Software Foundation, Inc.
10295 +
10296 +   This program is free software; you can redistribute it and/or modify
10297 +   it under the terms of the GNU General Public License as published by
10298 +   the Free Software Foundation; either version 3 of the License, or
10299 +   (at your option) any later version.
10300 +
10301 +   This program is distributed in the hope that it will be useful,
10302 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
10303 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10304 +   GNU General Public License for more details.
10305 +
10306 +   You should have received a copy of the GNU General Public License
10307 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
10308 +
10309 +#if 0
10310 +
10311 +void
10312 +foo (int size)
10313 +{
10314 +  typedef char array_t[size];
10315 +  array_t array;
10316 +  int i;
10317 +
10318 +  for (i = 0; i < size; i++)
10319 +    array[i] = i;
10320 +
10321 +  array[0] = 0;        /* break-here */
10322 +}
10323 +
10324 +#else
10325 +
10326 +int
10327 +main (void)
10328 +{
10329 +  foo (26);
10330 +  foo (78);
10331 +  return 0;
10332 +}
10333 +
10334 +#endif
10335 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
10336 ===================================================================
10337 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10338 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp   2011-07-03 10:33:11.000000000 +0200
10339 @@ -0,0 +1,66 @@
10340 +# Copyright 2009 Free Software Foundation, Inc.
10341 +
10342 +# This program is free software; you can redistribute it and/or modify
10343 +# it under the terms of the GNU General Public License as published by
10344 +# the Free Software Foundation; either version 3 of the License, or
10345 +# (at your option) any later version.
10346 +#
10347 +# This program is distributed in the hope that it will be useful,
10348 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
10349 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10350 +# GNU General Public License for more details.
10351 +#
10352 +# You should have received a copy of the GNU General Public License
10353 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
10354 +
10355 +if ![istarget "x86_64-*-*"] then {
10356 +    verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
10357 +    return
10358 +}
10359 +
10360 +set testfile x86_64-vla-pointer
10361 +set srcasmfile ${testfile}-foo.S
10362 +set srcfile ${testfile}.c
10363 +set binfile ${objdir}/${subdir}/${testfile}
10364 +set binobjfile ${objdir}/${subdir}/${testfile}-foo.o
10365 +if  { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
10366 +    untested "Couldn't compile test program"
10367 +    return -1
10368 +}
10369 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
10370 +    untested "Couldn't compile test program"
10371 +    return -1
10372 +}
10373 +
10374 +gdb_exit
10375 +gdb_start
10376 +gdb_reinitialize_dir $srcdir/$subdir
10377 +gdb_load ${binfile}
10378 +
10379 +if ![runto_main] {
10380 +    untested x86_64-vla-pointer
10381 +    return -1
10382 +}
10383 +
10384 +gdb_breakpoint "break_here"
10385 +
10386 +gdb_continue_to_breakpoint "break_here"
10387 +
10388 +gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array"
10389 +gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array"
10390 +
10391 +gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array"
10392 +gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array"
10393 +
10394 +gdb_test "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
10395 +gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
10396 +gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
10397 +gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
10398 +
10399 +gdb_continue_to_breakpoint "break_here"
10400 +
10401 +gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array"
10402 +gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array"
10403 +
10404 +gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array"
10405 +gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array"
10406 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
10407 ===================================================================
10408 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10409 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S 2011-07-03 10:33:11.000000000 +0200
10410 @@ -0,0 +1,455 @@
10411 +       .file   "x86_64-vla-typedef.c"
10412 +       .section        .debug_abbrev,"",@progbits
10413 +.Ldebug_abbrev0:
10414 +       .section        .debug_info,"",@progbits
10415 +.Ldebug_info0:
10416 +       .section        .debug_line,"",@progbits
10417 +.Ldebug_line0:
10418 +       .text
10419 +.Ltext0:
10420 +.globl foo
10421 +       .type   foo, @function
10422 +foo:
10423 +.LFB2:
10424 +       .file 1 "x86_64-vla-typedef.c"
10425 +       .loc 1 22 0
10426 +       pushq   %rbp
10427 +.LCFI0:
10428 +       movq    %rsp, %rbp
10429 +.LCFI1:
10430 +       subq    $64, %rsp
10431 +.LCFI2:
10432 +       movl    %edi, -36(%rbp)
10433 +       .loc 1 22 0
10434 +       movq    %rsp, %rax
10435 +       movq    %rax, -48(%rbp)
10436 +       .loc 1 23 0
10437 +       movl    -36(%rbp), %edx
10438 +       movslq  %edx,%rax
10439 +       subq    $1, %rax
10440 +       movq    %rax, -24(%rbp)
10441 +       .loc 1 24 0
10442 +       movslq  %edx,%rax
10443 +       addq    $15, %rax
10444 +       addq    $15, %rax
10445 +       shrq    $4, %rax
10446 +       salq    $4, %rax
10447 +       subq    %rax, %rsp
10448 +       movq    %rsp, -56(%rbp)
10449 +       movq    -56(%rbp), %rax
10450 +       addq    $15, %rax
10451 +       shrq    $4, %rax
10452 +       salq    $4, %rax
10453 +       movq    %rax, -56(%rbp)
10454 +       movq    -56(%rbp), %rax
10455 +       movq    %rax, -16(%rbp)
10456 +       .loc 1 27 0
10457 +       movl    $0, -4(%rbp)
10458 +       jmp     .L2
10459 +.L3:
10460 +       .loc 1 28 0
10461 +       movl    -4(%rbp), %esi
10462 +       movl    -4(%rbp), %eax
10463 +       movl    %eax, %ecx
10464 +       movq    -16(%rbp), %rdx
10465 +       movslq  %esi,%rax
10466 +       movb    %cl, (%rdx,%rax)
10467 +       .loc 1 27 0
10468 +       addl    $1, -4(%rbp)
10469 +.L2:
10470 +       movl    -4(%rbp), %eax
10471 +       cmpl    -36(%rbp), %eax
10472 +       jl      .L3
10473 +       .loc 1 30 0
10474 +       .globl  break_here
10475 +break_here:
10476 +       movq    -16(%rbp), %rax
10477 +       movb    $0, (%rax)
10478 +       movq    -48(%rbp), %rsp
10479 +       .loc 1 31 0
10480 +       leave
10481 +       ret
10482 +.LFE2:
10483 +       .size   foo, .-foo
10484 +       .section        .debug_frame,"",@progbits
10485 +.Lframe0:
10486 +       .long   .LECIE0-.LSCIE0
10487 +.LSCIE0:
10488 +       .long   0xffffffff
10489 +       .byte   0x1
10490 +       .string ""
10491 +       .uleb128 0x1
10492 +       .sleb128 -8
10493 +       .byte   0x10
10494 +       .byte   0xc
10495 +       .uleb128 0x7
10496 +       .uleb128 0x8
10497 +       .byte   0x90
10498 +       .uleb128 0x1
10499 +       .align 8
10500 +.LECIE0:
10501 +.LSFDE0:
10502 +       .long   .LEFDE0-.LASFDE0
10503 +.LASFDE0:
10504 +       .long   .Lframe0
10505 +       .quad   .LFB2
10506 +       .quad   .LFE2-.LFB2
10507 +       .byte   0x4
10508 +       .long   .LCFI0-.LFB2
10509 +       .byte   0xe
10510 +       .uleb128 0x10
10511 +       .byte   0x86
10512 +       .uleb128 0x2
10513 +       .byte   0x4
10514 +       .long   .LCFI1-.LCFI0
10515 +       .byte   0xd
10516 +       .uleb128 0x6
10517 +       .align 8
10518 +.LEFDE0:
10519 +       .section        .eh_frame,"a",@progbits
10520 +.Lframe1:
10521 +       .long   .LECIE1-.LSCIE1
10522 +.LSCIE1:
10523 +       .long   0x0
10524 +       .byte   0x1
10525 +       .string "zR"
10526 +       .uleb128 0x1
10527 +       .sleb128 -8
10528 +       .byte   0x10
10529 +       .uleb128 0x1
10530 +       .byte   0x3
10531 +       .byte   0xc
10532 +       .uleb128 0x7
10533 +       .uleb128 0x8
10534 +       .byte   0x90
10535 +       .uleb128 0x1
10536 +       .align 8
10537 +.LECIE1:
10538 +.LSFDE1:
10539 +       .long   .LEFDE1-.LASFDE1
10540 +.LASFDE1:
10541 +       .long   .LASFDE1-.Lframe1
10542 +       .long   .LFB2
10543 +       .long   .LFE2-.LFB2
10544 +       .uleb128 0x0
10545 +       .byte   0x4
10546 +       .long   .LCFI0-.LFB2
10547 +       .byte   0xe
10548 +       .uleb128 0x10
10549 +       .byte   0x86
10550 +       .uleb128 0x2
10551 +       .byte   0x4
10552 +       .long   .LCFI1-.LCFI0
10553 +       .byte   0xd
10554 +       .uleb128 0x6
10555 +       .align 8
10556 +.LEFDE1:
10557 +       .text
10558 +.Letext0:
10559 +       .section        .debug_loc,"",@progbits
10560 +.Ldebug_loc0:
10561 +.LLST0:
10562 +       .quad   .LFB2-.Ltext0
10563 +       .quad   .LCFI0-.Ltext0
10564 +       .value  0x2
10565 +       .byte   0x77
10566 +       .sleb128 8
10567 +       .quad   .LCFI0-.Ltext0
10568 +       .quad   .LCFI1-.Ltext0
10569 +       .value  0x2
10570 +       .byte   0x77
10571 +       .sleb128 16
10572 +       .quad   .LCFI1-.Ltext0
10573 +       .quad   .LFE2-.Ltext0
10574 +       .value  0x2
10575 +       .byte   0x76
10576 +       .sleb128 16
10577 +       .quad   0x0
10578 +       .quad   0x0
10579 +       .section        .debug_info
10580 +       .long   .Ldebug_end - .Ldebug_start
10581 +.Ldebug_start:
10582 +       .value  0x2
10583 +       .long   .Ldebug_abbrev0
10584 +       .byte   0x8
10585 +       .uleb128 0x1
10586 +       .long   .LASF2
10587 +       .byte   0x1
10588 +       .long   .LASF3
10589 +       .long   .LASF4
10590 +       .quad   .Ltext0
10591 +       .quad   .Letext0
10592 +       .long   .Ldebug_line0
10593 +       .uleb128 0x2
10594 +       .byte   0x1
10595 +       .string "foo"
10596 +       .byte   0x1
10597 +       .byte   0x16
10598 +       .byte   0x1
10599 +       .quad   .LFB2
10600 +       .quad   .LFE2
10601 +       .long   .LLST0
10602 +       .long   0x83
10603 +       .uleb128 0x3
10604 +       .long   .LASF5
10605 +       .byte   0x1
10606 +       .byte   0x15
10607 +       .long   0x83
10608 +       .byte   0x2
10609 +       .byte   0x91
10610 +       .sleb128 -52
10611 +.Ltag_typedef:
10612 +       .uleb128 0x4
10613 +       .long   .LASF6
10614 +       .byte   0x1
10615 +       .byte   0x17
10616 +       .long   .Ltag_array_type - .debug_info
10617 +       .uleb128 0x5    /* Abbrev Number: 5 (DW_TAG_variable) */
10618 +       .long   .LASF0
10619 +       .byte   0x1
10620 +       .byte   0x18
10621 +#if 1
10622 +       .long   .Ltag_typedef - .debug_info
10623 +#else
10624 +       /* Debugging only: Skip the typedef indirection.  */
10625 +       .long   .Ltag_array_type - .debug_info
10626 +#endif
10627 +       /* DW_AT_location: DW_FORM_block1: start */
10628 +       .byte   0x3
10629 +       .byte   0x91
10630 +       .sleb128 -32
10631 +#if 0
10632 +       .byte   0x6     /* DW_OP_deref */
10633 +#else
10634 +       .byte   0x96    /* DW_OP_nop */
10635 +#endif
10636 +       /* DW_AT_location: DW_FORM_block1: end */
10637 +       .uleb128 0x6
10638 +       .string "i"
10639 +       .byte   0x1
10640 +       .byte   0x19
10641 +       .long   0x83
10642 +       .byte   0x2
10643 +       .byte   0x91
10644 +       .sleb128 -20
10645 +       .byte   0x0
10646 +       .uleb128 0x7
10647 +       .byte   0x4
10648 +       .byte   0x5
10649 +       .string "int"
10650 +.Ltag_array_type:
10651 +       .uleb128 0x8    /* Abbrev Number: 8 (DW_TAG_array_type) */
10652 +       .long   0xa0 + (2f - 1f)        /* DW_AT_type: DW_FORM_ref4 */
10653 +       .long   0x9d + (2f - 1f)        /* DW_AT_sibling: DW_FORM_ref4 */
10654 +1:     /* DW_AT_data_location: DW_FORM_block1: start */
10655 +       .byte   2f - 3f /* length */
10656 +3:
10657 +       .byte   0x97    /* DW_OP_push_object_address */
10658 +       .byte   0x6     /* DW_OP_deref */
10659 +2:     /* DW_AT_data_location: DW_FORM_block1: end */
10660 +       .uleb128 0x9
10661 +       .long   0x9d + (2b - 1b)        /* DW_AT_type: DW_FORM_ref4 */
10662 +       .byte   0x3
10663 +       .byte   0x91
10664 +       .sleb128 -40
10665 +       .byte   0x6
10666 +       .byte   0x0
10667 +       .uleb128 0xa
10668 +       .byte   0x8
10669 +       .byte   0x7
10670 +       .uleb128 0xb
10671 +       .byte   0x1
10672 +       .byte   0x6
10673 +       .long   .LASF1
10674 +       .byte   0x0
10675 +.Ldebug_end:
10676 +       .section        .debug_abbrev
10677 +       .uleb128 0x1
10678 +       .uleb128 0x11
10679 +       .byte   0x1
10680 +       .uleb128 0x25
10681 +       .uleb128 0xe
10682 +       .uleb128 0x13
10683 +       .uleb128 0xb
10684 +       .uleb128 0x3
10685 +       .uleb128 0xe
10686 +       .uleb128 0x1b
10687 +       .uleb128 0xe
10688 +       .uleb128 0x11
10689 +       .uleb128 0x1
10690 +       .uleb128 0x12
10691 +       .uleb128 0x1
10692 +       .uleb128 0x10
10693 +       .uleb128 0x6
10694 +       .byte   0x0
10695 +       .byte   0x0
10696 +       .uleb128 0x2
10697 +       .uleb128 0x2e
10698 +       .byte   0x1
10699 +       .uleb128 0x3f
10700 +       .uleb128 0xc
10701 +       .uleb128 0x3
10702 +       .uleb128 0x8
10703 +       .uleb128 0x3a
10704 +       .uleb128 0xb
10705 +       .uleb128 0x3b
10706 +       .uleb128 0xb
10707 +       .uleb128 0x27
10708 +       .uleb128 0xc
10709 +       .uleb128 0x11
10710 +       .uleb128 0x1
10711 +       .uleb128 0x12
10712 +       .uleb128 0x1
10713 +       .uleb128 0x40
10714 +       .uleb128 0x6
10715 +       .uleb128 0x1
10716 +       .uleb128 0x13
10717 +       .byte   0x0
10718 +       .byte   0x0
10719 +       .uleb128 0x3
10720 +       .uleb128 0x5
10721 +       .byte   0x0
10722 +       .uleb128 0x3
10723 +       .uleb128 0xe
10724 +       .uleb128 0x3a
10725 +       .uleb128 0xb
10726 +       .uleb128 0x3b
10727 +       .uleb128 0xb
10728 +       .uleb128 0x49
10729 +       .uleb128 0x13
10730 +       .uleb128 0x2
10731 +       .uleb128 0xa
10732 +       .byte   0x0
10733 +       .byte   0x0
10734 +       .uleb128 0x4
10735 +       .uleb128 0x16
10736 +       .byte   0x0
10737 +       .uleb128 0x3
10738 +       .uleb128 0xe
10739 +       .uleb128 0x3a
10740 +       .uleb128 0xb
10741 +       .uleb128 0x3b
10742 +       .uleb128 0xb
10743 +       .uleb128 0x49
10744 +       .uleb128 0x13
10745 +       .byte   0x0
10746 +       .byte   0x0
10747 +       .uleb128 0x5
10748 +       .uleb128 0x34
10749 +       .byte   0x0
10750 +       .uleb128 0x3
10751 +       .uleb128 0xe
10752 +       .uleb128 0x3a
10753 +       .uleb128 0xb
10754 +       .uleb128 0x3b
10755 +       .uleb128 0xb
10756 +       .uleb128 0x49
10757 +       .uleb128 0x13
10758 +       .uleb128 0x2
10759 +       .uleb128 0xa
10760 +       .byte   0x0
10761 +       .byte   0x0
10762 +       .uleb128 0x6
10763 +       .uleb128 0x34
10764 +       .byte   0x0
10765 +       .uleb128 0x3
10766 +       .uleb128 0x8
10767 +       .uleb128 0x3a
10768 +       .uleb128 0xb
10769 +       .uleb128 0x3b
10770 +       .uleb128 0xb
10771 +       .uleb128 0x49
10772 +       .uleb128 0x13
10773 +       .uleb128 0x2
10774 +       .uleb128 0xa
10775 +       .byte   0x0
10776 +       .byte   0x0
10777 +       .uleb128 0x7
10778 +       .uleb128 0x24
10779 +       .byte   0x0
10780 +       .uleb128 0xb
10781 +       .uleb128 0xb
10782 +       .uleb128 0x3e
10783 +       .uleb128 0xb
10784 +       .uleb128 0x3
10785 +       .uleb128 0x8
10786 +       .byte   0x0
10787 +       .byte   0x0
10788 +       .uleb128 0x8    /* Abbrev Number: 8 (DW_TAG_array_type) */
10789 +       .uleb128 0x1
10790 +       .byte   0x1
10791 +       .uleb128 0x49   /* DW_AT_type */
10792 +       .uleb128 0x13   /* DW_FORM_ref4 */
10793 +       .uleb128 0x1    /* DW_AT_sibling */
10794 +       .uleb128 0x13   /* DW_FORM_ref4 */
10795 +       .uleb128 0x50   /* DW_AT_data_location */
10796 +       .uleb128 0xa    /* DW_FORM_block1 */
10797 +       .byte   0x0
10798 +       .byte   0x0
10799 +       .uleb128 0x9
10800 +       .uleb128 0x21
10801 +       .byte   0x0
10802 +       .uleb128 0x49   /* DW_AT_type */
10803 +       .uleb128 0x13   /* DW_FORM_ref4 */
10804 +       .uleb128 0x2f
10805 +       .uleb128 0xa
10806 +       .byte   0x0
10807 +       .byte   0x0
10808 +       .uleb128 0xa
10809 +       .uleb128 0x24
10810 +       .byte   0x0
10811 +       .uleb128 0xb
10812 +       .uleb128 0xb
10813 +       .uleb128 0x3e
10814 +       .uleb128 0xb
10815 +       .byte   0x0
10816 +       .byte   0x0
10817 +       .uleb128 0xb
10818 +       .uleb128 0x24
10819 +       .byte   0x0
10820 +       .uleb128 0xb
10821 +       .uleb128 0xb
10822 +       .uleb128 0x3e
10823 +       .uleb128 0xb
10824 +       .uleb128 0x3
10825 +       .uleb128 0xe
10826 +       .byte   0x0
10827 +       .byte   0x0
10828 +       .byte   0x0
10829 +       .section        .debug_pubnames,"",@progbits
10830 +       .long   0x16
10831 +       .value  0x2
10832 +       .long   .Ldebug_info0
10833 +       .long   0xa8
10834 +       .long   0x2d
10835 +       .string "foo"
10836 +       .long   0x0
10837 +       .section        .debug_aranges,"",@progbits
10838 +       .long   0x2c
10839 +       .value  0x2
10840 +       .long   .Ldebug_info0
10841 +       .byte   0x8
10842 +       .byte   0x0
10843 +       .value  0x0
10844 +       .value  0x0
10845 +       .quad   .Ltext0
10846 +       .quad   .Letext0-.Ltext0
10847 +       .quad   0x0
10848 +       .quad   0x0
10849 +       .section        .debug_str,"MS",@progbits,1
10850 +.LASF0:
10851 +       .string "array"
10852 +.LASF5:
10853 +       .string "size"
10854 +.LASF3:
10855 +       .string "x86_64-vla-typedef.c"
10856 +.LASF6:
10857 +       .string "array_t"
10858 +.LASF1:
10859 +       .string "char"
10860 +.LASF4:
10861 +       .string "gdb.arch"
10862 +.LASF2:
10863 +       .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
10864 +       .ident  "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
10865 +       .section        .note.GNU-stack,"",@progbits
10866 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
10867 ===================================================================
10868 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10869 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c     2011-07-03 10:33:11.000000000 +0200
10870 @@ -0,0 +1,43 @@
10871 +/* This testcase is part of GDB, the GNU debugger.
10872 +
10873 +   Copyright 2008 Free Software Foundation, Inc.
10874 +
10875 +   This program is free software; you can redistribute it and/or modify
10876 +   it under the terms of the GNU General Public License as published by
10877 +   the Free Software Foundation; either version 3 of the License, or
10878 +   (at your option) any later version.
10879 +
10880 +   This program is distributed in the hope that it will be useful,
10881 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
10882 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10883 +   GNU General Public License for more details.
10884 +
10885 +   You should have received a copy of the GNU General Public License
10886 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
10887 +
10888 +#if 0
10889 +
10890 +void
10891 +foo (int size)
10892 +{
10893 +  typedef char array_t[size];
10894 +  array_t array;
10895 +  int i;
10896 +
10897 +  for (i = 0; i < size; i++)
10898 +    array[i] = i;
10899 +
10900 +  array[0] = 0;        /* break-here */
10901 +}
10902 +
10903 +#else
10904 +
10905 +int
10906 +main (void)
10907 +{
10908 +  foo (26);
10909 +  foo (78);
10910 +  return 0;
10911 +}
10912 +
10913 +#endif
10914 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
10915 ===================================================================
10916 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10917 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp   2011-07-03 10:33:11.000000000 +0200
10918 @@ -0,0 +1,64 @@
10919 +# Copyright 2009 Free Software Foundation, Inc.
10920 +
10921 +# This program is free software; you can redistribute it and/or modify
10922 +# it under the terms of the GNU General Public License as published by
10923 +# the Free Software Foundation; either version 3 of the License, or
10924 +# (at your option) any later version.
10925 +#
10926 +# This program is distributed in the hope that it will be useful,
10927 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
10928 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10929 +# GNU General Public License for more details.
10930 +#
10931 +# You should have received a copy of the GNU General Public License
10932 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
10933 +
10934 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
10935 +
10936 +if ![istarget "x86_64-*-*"] then {
10937 +    verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
10938 +    return
10939 +}
10940 +
10941 +set testfile x86_64-vla-typedef
10942 +set srcasmfile ${testfile}-foo.S
10943 +set srcfile ${testfile}.c
10944 +set binfile ${objdir}/${subdir}/${testfile}
10945 +set binobjfile ${objdir}/${subdir}/${testfile}-foo.o
10946 +if  { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
10947 +    untested "Couldn't compile test program"
10948 +    return -1
10949 +}
10950 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
10951 +    untested "Couldn't compile test program"
10952 +    return -1
10953 +}
10954 +
10955 +gdb_exit
10956 +gdb_start
10957 +gdb_reinitialize_dir $srcdir/$subdir
10958 +gdb_load ${binfile}
10959 +
10960 +if ![runto_main] {
10961 +    untested x86_64-vla-typedef
10962 +    return -1
10963 +}
10964 +
10965 +gdb_breakpoint "break_here"
10966 +
10967 +gdb_continue_to_breakpoint "break_here"
10968 +
10969 +gdb_test "whatis array" "type = array_t" "first: whatis array"
10970 +
10971 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
10972 +
10973 +gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
10974 +gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
10975 +gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
10976 +gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
10977 +
10978 +gdb_continue_to_breakpoint "break_here"
10979 +
10980 +gdb_test "whatis array" "type = array_t" "second: whatis array"
10981 +
10982 +gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
10983 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.c
10984 ===================================================================
10985 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/arrayidx.c  2011-01-01 16:33:40.000000000 +0100
10986 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.c       2011-07-03 10:33:11.000000000 +0200
10987 @@ -17,6 +17,13 @@
10988  
10989  int array[] = {1, 2, 3, 4};
10990  
10991 +#ifdef __GNUC__
10992 +struct
10993 +  {
10994 +    int a[0];
10995 +  } unbound;
10996 +#endif
10997 +
10998  int
10999  main (void)
11000  {
11001 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.exp
11002 ===================================================================
11003 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/arrayidx.exp        2011-01-01 16:33:40.000000000 +0100
11004 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/arrayidx.exp     2011-07-03 10:33:11.000000000 +0200
11005 @@ -57,4 +57,12 @@ gdb_test "print array" \
11006           "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
11007           "Print array with array-indexes on"
11008  
11009 -
11010 +set test "p unbound.a == &unbound.a\[0\]"
11011 +gdb_test_multiple $test $test {
11012 +    -re " = 1\r\n$gdb_prompt $" {
11013 +       pass $test
11014 +    }
11015 +    -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
11016 +       unsupported "$test (no GCC)"
11017 +    }
11018 +}
11019 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/default.exp
11020 ===================================================================
11021 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.base/default.exp 2011-02-15 22:17:52.000000000 +0100
11022 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/default.exp      2011-07-03 10:33:11.000000000 +0200
11023 @@ -607,6 +607,17 @@ gdb_test_list_exact "show convenience" "
11024         {$_sdata = void} \
11025         {$_siginfo = void} \
11026         {$_thread = 0} \
11027 +       {$_probe_argc = <error: No frame selected>} \
11028 +       {$_probe_arg0 = <error: No frame selected>} \
11029 +       {$_probe_arg1 = <error: No frame selected>} \
11030 +       {$_probe_arg2 = <error: No frame selected>} \
11031 +       {$_probe_arg3 = <error: No frame selected>} \
11032 +       {$_probe_arg4 = <error: No frame selected>} \
11033 +       {$_probe_arg5 = <error: No frame selected>} \
11034 +       {$_probe_arg6 = <error: No frame selected>} \
11035 +       {$_probe_arg7 = <error: No frame selected>} \
11036 +       {$_probe_arg8 = <error: No frame selected>} \
11037 +       {$_probe_arg9 = <error: No frame selected>} \
11038      }
11039  
11040  #test show directories
11041 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.c
11042 ===================================================================
11043 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11044 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.c     2011-07-03 10:33:11.000000000 +0200
11045 @@ -0,0 +1,20 @@
11046 +/* This testcase is part of GDB, the GNU debugger.
11047 +
11048 +   Copyright 2009 Free Software Foundation, Inc.
11049 +
11050 +   This program is free software; you can redistribute it and/or modify
11051 +   it under the terms of the GNU General Public License as published by
11052 +   the Free Software Foundation; either version 3 of the License, or
11053 +   (at your option) any later version.
11054 +
11055 +   This program is distributed in the hope that it will be useful,
11056 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11057 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11058 +   GNU General Public License for more details.
11059 +
11060 +   You should have received a copy of the GNU General Public License
11061 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
11062 +
11063 +struct {
11064 +  int field;
11065 +} staticstruct = { 1 };
11066 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.exp
11067 ===================================================================
11068 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11069 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/internal-var-field-address.exp   2011-07-03 10:33:11.000000000 +0200
11070 @@ -0,0 +1,26 @@
11071 +# Copyright 2009 Free Software Foundation, Inc.
11072 +
11073 +# This program is free software; you can redistribute it and/or modify
11074 +# it under the terms of the GNU General Public License as published by
11075 +# the Free Software Foundation; either version 3 of the License, or
11076 +# (at your option) any later version.
11077 +#
11078 +# This program is distributed in the hope that it will be useful,
11079 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11080 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11081 +# GNU General Public License for more details.
11082 +#
11083 +# You should have received a copy of the GNU General Public License
11084 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11085 +
11086 +set test internal-var-field-address
11087 +set binfile ${test}.x
11088 +if  { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } {
11089 +    untested "Couldn't compile test program"
11090 +    return -1
11091 +}
11092 +
11093 +clean_restart $binfile
11094 +
11095 +gdb_test {set $varstruct = staticstruct}
11096 +gdb_test {p $varstruct.field} " = 1"
11097 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.c
11098 ===================================================================
11099 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11100 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.c     2011-07-03 10:33:11.000000000 +0200
11101 @@ -0,0 +1,69 @@
11102 +/* This testcase is part of GDB, the GNU debugger.
11103 +
11104 +   Copyright 2011 Free Software Foundation, Inc.
11105 +
11106 +   This program is free software; you can redistribute it and/or modify
11107 +   it under the terms of the GNU General Public License as published by
11108 +   the Free Software Foundation; either version 3 of the License, or
11109 +   (at your option) any later version.
11110 +
11111 +   This program is distributed in the hope that it will be useful,
11112 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11113 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11114 +   GNU General Public License for more details.
11115 +
11116 +   You should have received a copy of the GNU General Public License
11117 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
11118 +
11119 +#if USE_PROBES
11120 +
11121 +#define _SDT_HAS_SEMAPHORES
11122 +__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
11123 +#define TEST teste_user_semaphore
11124 +
11125 +__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
11126 +#define TEST2 teste_two_semaphore
11127 +
11128 +#else
11129 +
11130 +#define TEST 1
11131 +#define TEST2 1
11132 +
11133 +#endif
11134 +
11135 +#include <sys/sdt.h>
11136 +
11137 +/* We only support SystemTap and only the v3 form.  */
11138 +#if _SDT_NOTE_TYPE != 3
11139 +#error "not using SystemTap v3 probes"
11140 +#endif
11141 +
11142 +void
11143 +m1 (void)
11144 +{
11145 +  if (TEST2)
11146 +    STAP_PROBE (teste, two);
11147 +}
11148 +
11149 +void
11150 +m2 (void)
11151 +{
11152 +  if (TEST2)
11153 +    STAP_PROBE (teste, two);
11154 +}
11155 +
11156 +int
11157 +f (int x)
11158 +{
11159 +  if (TEST)
11160 +    STAP_PROBE1(teste, user, x);
11161 +  return x+5;
11162 +}
11163 +
11164 +int
11165 +main()
11166 +{
11167 +  f(f(23));
11168 +  m1();
11169 +  m2();
11170 +}
11171 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.exp
11172 ===================================================================
11173 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11174 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/stap-probe.exp   2011-07-03 10:33:11.000000000 +0200
11175 @@ -0,0 +1,72 @@
11176 +# Copyright (C) 2011 Free Software Foundation, Inc.
11177 +
11178 +# This program is free software; you can redistribute it and/or modify
11179 +# it under the terms of the GNU General Public License as published by
11180 +# the Free Software Foundation; either version 3 of the License, or
11181 +# (at your option) any later version.
11182 +#
11183 +# This program is distributed in the hope that it will be useful,
11184 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11185 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11186 +# GNU General Public License for more details.
11187 +#
11188 +# You should have received a copy of the GNU General Public License
11189 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11190 +
11191 +set testfile stap-probe
11192 +
11193 +# Run the tests.  We run the tests two different ways: once with a
11194 +# plain probe, and once with a probe that has an associated semaphore.
11195 +# This returns -1 on failure to compile or start, 0 otherwise.
11196 +proc stap_test {{arg ""}} {
11197 +    global testfile hex
11198 +
11199 +    if {$arg != ""} {
11200 +       set arg "additional_flags=$arg"
11201 +       set addendum ", with semaphore"
11202 +    } else {
11203 +       set addendum ", no semaphore"
11204 +    }
11205 +
11206 +    if {[prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c \
11207 +          [concat $arg debug]]} {
11208 +       return -1
11209 +    }
11210 +
11211 +    if ![runto_main] {
11212 +       return -1
11213 +    }
11214 +
11215 +    gdb_test "print \$_probe_argc" "No SystemTap probe at PC $hex" \
11216 +       "check argument not at probe point$addendum"
11217 +
11218 +    gdb_test "info probes" \
11219 +       "teste *user *$hex .*" \
11220 +       "info probes$addendum"
11221 +    
11222 +    if {[runto "probe:teste:user"]} {
11223 +       pass "run to probe:teste:user$addendum"
11224 +    } else {
11225 +       fail "run to probe:teste:user$addendum"
11226 +    }
11227 +
11228 +    # Test probe arguments.
11229 +    gdb_test "print \$_probe_argc" " = 1" "print \$_probe_argc$addendum"
11230 +    gdb_test "print \$_probe_arg0 == x" " = 1" "check \$_probe_arg0$addendum"
11231 +    gdb_test "print \$_probe_arg1" \
11232 +       "Invalid probe argument 1 -- probe has 1 arguments available" \
11233 +       "check \$_probe_arg1$addendum"
11234 +
11235 +    # Set a breakpoint with multiple probe locations.
11236 +    gdb_test "break probe:teste:two" \
11237 +       "Breakpoint .* at $hex.*2 locations.*" \
11238 +       "set multi-location probe breakpoint$addendum"
11239 +
11240 +    return 0
11241 +}
11242 +
11243 +if {[stap_test] == -1} {
11244 +    untested stap-probe.exp
11245 +    return -1
11246 +}
11247 +stap_test "-DUSE_PROBES"
11248 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.c
11249 ===================================================================
11250 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11251 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.c   2011-07-03 10:33:11.000000000 +0200
11252 @@ -0,0 +1,30 @@
11253 +/* This testcase is part of GDB, the GNU debugger.
11254 +
11255 +   Copyright 2008 Free Software Foundation, Inc.
11256 +
11257 +   This program is free software; you can redistribute it and/or modify
11258 +   it under the terms of the GNU General Public License as published by
11259 +   the Free Software Foundation; either version 3 of the License, or
11260 +   (at your option) any later version.
11261 +
11262 +   This program is distributed in the hope that it will be useful,
11263 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11264 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11265 +   GNU General Public License for more details.
11266 +
11267 +   You should have received a copy of the GNU General Public License
11268 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
11269 +
11270 +#include <stdlib.h>
11271 +
11272 +int
11273 +main (int argc, char **argv)
11274 +{
11275 +  int array[argc];
11276 +
11277 +  array[0] = array[0];
11278 +
11279 +  abort ();
11280 +
11281 +  return 0;
11282 +}
11283 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.exp
11284 ===================================================================
11285 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11286 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla-overflow.exp 2011-07-03 10:33:11.000000000 +0200
11287 @@ -0,0 +1,109 @@
11288 +# Copyright 2008 Free Software Foundation, Inc.
11289 +
11290 +# This program is free software; you can redistribute it and/or modify
11291 +# it under the terms of the GNU General Public License as published by
11292 +# the Free Software Foundation; either version 3 of the License, or
11293 +# (at your option) any later version.
11294 +#
11295 +# This program is distributed in the hope that it will be useful,
11296 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11297 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11298 +# GNU General Public License for more details.
11299 +#
11300 +# You should have received a copy of the GNU General Public License
11301 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11302 +
11303 +# We could crash in:
11304 +# #0  block_linkage_function (bl=0x0) at ../../gdb/block.c:69
11305 +# #1  in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
11306 +#   97   framefunc = block_linkage_function (get_frame_block (frame, NULL));
11307 +# #2  in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
11308 +# #3  in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
11309 +# #4  dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
11310 +# #5  in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
11311 +# #6  in create_array_type (...) at ../../gdb/gdbtypes.c:840
11312 +# ...
11313 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
11314 +# ...
11315 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
11316 +
11317 +set testfile vla-overflow
11318 +set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
11319 +set srcfile ${testfile}.c
11320 +set binfile ${objdir}/${subdir}/${testfile}
11321 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
11322 +    untested "Couldn't compile test program"
11323 +    return -1
11324 +}
11325 +
11326 +set f [open "|getconf PAGESIZE" "r"]
11327 +gets $f pagesize
11328 +close $f
11329 +
11330 +gdb_exit
11331 +gdb_start
11332 +gdb_reinitialize_dir $srcdir/$subdir
11333 +gdb_load ${binfile}
11334 +
11335 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
11336 +
11337 +if { [runto_main] < 0 } {
11338 +    untested vla-overflow
11339 +    return -1
11340 +}
11341 +
11342 +# Get the GDB memory size when we stay at main.
11343 +
11344 +proc memory_v_pages_get {} {
11345 +    global pid_of_gdb pagesize
11346 +    set fd [open "/proc/$pid_of_gdb/statm"]
11347 +    gets $fd line
11348 +    close $fd
11349 +    # number of pages of virtual memory
11350 +    scan $line "%d" drs
11351 +    return $drs
11352 +}
11353 +
11354 +set pages_found [memory_v_pages_get]
11355 +
11356 +# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
11357 +set mb_reserve 40
11358 +verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
11359 +set kb_found [expr $pages_found * $pagesize / 1024]
11360 +set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
11361 +verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
11362 +
11363 +# Create the ulimit wrapper.
11364 +set f [open $shfile "w"]
11365 +puts $f "#! /bin/sh"
11366 +puts $f "ulimit -v $kb_permit"
11367 +puts $f "exec $GDB \"\$@\""
11368 +close $f
11369 +remote_exec host "chmod +x $shfile"
11370 +
11371 +gdb_exit
11372 +set GDBold $GDB
11373 +set GDB "$shfile"
11374 +gdb_start
11375 +set GDB $GDBold
11376 +
11377 +gdb_reinitialize_dir $srcdir/$subdir
11378 +gdb_load ${binfile}
11379 +
11380 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
11381 +
11382 +# Check the size again after the second run.
11383 +# We must not stop in main as it would cache `array' and never crash later.
11384 +
11385 +gdb_run_cmd
11386 +
11387 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
11388 +
11389 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
11390 +
11391 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
11392 +
11393 +# `abort' can get expressed as `*__GI_abort'.
11394 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
11395 +
11396 +verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
11397 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.c
11398 ===================================================================
11399 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11400 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.c    2011-07-03 10:33:11.000000000 +0200
11401 @@ -0,0 +1,55 @@
11402 +/* This testcase is part of GDB, the GNU debugger.
11403 +
11404 +   Copyright 2008 Free Software Foundation, Inc.
11405 +
11406 +   This program is free software; you can redistribute it and/or modify
11407 +   it under the terms of the GNU General Public License as published by
11408 +   the Free Software Foundation; either version 3 of the License, or
11409 +   (at your option) any later version.
11410 +
11411 +   This program is distributed in the hope that it will be useful,
11412 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11413 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11414 +   GNU General Public License for more details.
11415 +
11416 +   You should have received a copy of the GNU General Public License
11417 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
11418 +
11419 +#include <string.h>
11420 +
11421 +void
11422 +marker (void)
11423 +{
11424 +}
11425 +
11426 +void
11427 +bar (char *a, char *b, char *c, int size)
11428 +{
11429 +  memset (a, '1', size);
11430 +  memset (b, '2', size);
11431 +  memset (c, '3', 48);
11432 +}
11433 +
11434 +void
11435 +foo (int size)
11436 +{
11437 +  char temp1[size];
11438 +  char temp3[48];
11439 +
11440 +  temp1[size - 1] = '\0';
11441 +  {
11442 +    char temp2[size];
11443 +
11444 +    bar (temp1, temp2, temp3, size);
11445 +
11446 +    marker (); /* break-here */
11447 +  }
11448 +}
11449 +
11450 +int
11451 +main (void)
11452 +{
11453 +  foo (26);
11454 +  foo (78);
11455 +  return 0;
11456 +}
11457 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.exp
11458 ===================================================================
11459 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11460 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.base/vla.exp  2011-07-03 10:33:11.000000000 +0200
11461 @@ -0,0 +1,62 @@
11462 +# Copyright 2008 Free Software Foundation, Inc.
11463 +
11464 +# This program is free software; you can redistribute it and/or modify
11465 +# it under the terms of the GNU General Public License as published by
11466 +# the Free Software Foundation; either version 3 of the License, or
11467 +# (at your option) any later version.
11468 +#
11469 +# This program is distributed in the hope that it will be useful,
11470 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11471 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11472 +# GNU General Public License for more details.
11473 +#
11474 +# You should have received a copy of the GNU General Public License
11475 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11476 +
11477 +set testfile vla
11478 +set srcfile ${testfile}.c
11479 +set binfile ${objdir}/${subdir}/${testfile}
11480 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
11481 +    untested "Couldn't compile test program"
11482 +    return -1
11483 +}
11484 +
11485 +gdb_exit
11486 +gdb_start
11487 +gdb_reinitialize_dir $srcdir/$subdir
11488 +gdb_load ${binfile}
11489 +
11490 +if ![runto_main] {
11491 +    untested vla
11492 +    return -1
11493 +}
11494 +
11495 +gdb_breakpoint [gdb_get_line_number "break-here"]
11496 +
11497 +gdb_continue_to_breakpoint "break-here"
11498 +
11499 +gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1"
11500 +gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2"
11501 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
11502 +
11503 +gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
11504 +gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
11505 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
11506 +
11507 +gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
11508 +gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
11509 +gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
11510 +
11511 +gdb_continue_to_breakpoint "break-here"
11512 +
11513 +gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1"
11514 +gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2"
11515 +gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
11516 +
11517 +gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
11518 +gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
11519 +gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
11520 +
11521 +gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
11522 +gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
11523 +gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
11524 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.cp/nextoverthrow.exp
11525 ===================================================================
11526 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.cp/nextoverthrow.exp     2011-01-01 16:33:44.000000000 +0100
11527 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.cp/nextoverthrow.exp  2011-07-03 10:33:11.000000000 +0200
11528 @@ -53,6 +53,17 @@ gdb_test_multiple "print _Unwind_DebugHo
11529      }
11530  }
11531  if {!$ok} {
11532 +    gdb_test_multiple "info probe" "check for stap probe in unwinder" {
11533 +       -re ".*libgcc.*unwind.*\r\n$gdb_prompt $" {
11534 +           pass "check for stap probe in unwinder"
11535 +           set ok 1
11536 +       }
11537 +       -re "\r\n$gdb_prompt $" {
11538 +       }
11539 +    }
11540 +}
11541 +
11542 +if {!$ok} {
11543      unsupported "nextoverthrow.exp could not find _Unwind_DebugHook"
11544      return -1
11545  }
11546 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
11547 ===================================================================
11548 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11549 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S    2011-07-03 10:33:11.000000000 +0200
11550 @@ -0,0 +1,246 @@
11551 +/* This testcase is part of GDB, the GNU debugger.
11552 +
11553 +   Copyright 2010 Free Software Foundation, Inc.
11554 +
11555 +   This program is free software; you can redistribute it and/or modify
11556 +   it under the terms of the GNU General Public License as published by
11557 +   the Free Software Foundation; either version 3 of the License, or
11558 +   (at your option) any later version.
11559 +
11560 +   This program is distributed in the hope that it will be useful,
11561 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11562 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11563 +   GNU General Public License for more details.
11564 +
11565 +   You should have received a copy of the GNU General Public License
11566 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
11567 +
11568 +/* Debug information */
11569 +
11570 +/* We will `break *main' at the very first instruction.  */
11571 +#define main_length 1
11572 +
11573 +       .section        .data
11574 +vardata:
11575 +       /* See DW_OP_lit3 + 1 (0-based).  */
11576 +       .string         "seennotseen"
11577 +
11578 +       .section        .debug_info
11579 +.Lcu1_begin:
11580 +       .4byte          .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
11581 +.Lcu1_start:
11582 +       .2byte          2                       /* DWARF version number */
11583 +       .4byte          .Ldebug_abbrev0         /* Offset Into Abbrev. Section */
11584 +       .byte           4                       /* Pointer Size (in bytes) */
11585 +
11586 +       /* CU die */
11587 +       .uleb128        1                       /* Abbrev: DW_TAG_compile_unit */
11588 +       .4byte          .Lproducer              /* DW_AT_producer */
11589 +       /* Use C++ to exploit a bug in parsing DW_AT_name "".  */
11590 +       .byte           4                       /* DW_AT_language (C++) -  */
11591 +       .4byte          main                    /* DW_AT_low_pc */
11592 +       .byte           main_length             /* DW_AT_high_pc */
11593 +
11594 +.Larray_type:
11595 +       .uleb128        2                       /* Abbrev: DW_TAG_array_type */
11596 +       .4byte          .Lchar_type-.Lcu1_begin /* DW_AT_type */
11597 +
11598 +       .uleb128        3                       /* Abbrev: DW_TAG_subrange_type */
11599 +       .4byte          .Luint_type-.Lcu1_begin /* DW_AT_type */
11600 +       .byte           0                       /* DW_AT_lower_bound */
11601 +       .4byte          .Llen_var-.Lcu1_begin   /* DW_AT_upper_bound */
11602 +       .byte           0                       /* End of children of die */
11603 +
11604 +       /* DW_AT_upper_bound is referencing an optimized-out variable.  */
11605 +.Larrayb_type:
11606 +       .uleb128        2                       /* Abbrev: DW_TAG_array_type */
11607 +       .4byte          .Lchar_type-.Lcu1_begin /* DW_AT_type */
11608 +
11609 +       .uleb128        3                       /* Abbrev: DW_TAG_subrange_type */
11610 +       .4byte          .Luint_type-.Lcu1_begin /* DW_AT_type */
11611 +       .byte           0                       /* DW_AT_lower_bound */
11612 +       .4byte          .Llenb_var-.Lcu1_begin  /* DW_AT_upper_bound */
11613 +       .byte           0                       /* End of children of die */
11614 +
11615 +       /* DW_AT_upper_bound is referencing register.  */
11616 +.Larrayreg_type:
11617 +       .uleb128        2                       /* Abbrev: DW_TAG_array_type */
11618 +       .4byte          .Lchar_type-.Lcu1_begin /* DW_AT_type */
11619 +
11620 +       .uleb128        8                       /* Abbrev: DW_TAG_subrange_type with block */
11621 +       .4byte          .Luint_type-.Lcu1_begin /* DW_AT_type */
11622 +       .byte           0                       /* DW_AT_lower_bound */
11623 +       .byte           2f - 1f                 /* DW_AT_upper_bound */
11624 +1:     .byte           0x50                    /* DW_OP_reg0 */
11625 +2:
11626 +       .byte           0                       /* End of children of die */
11627 +
11628 +.Luint_type:
11629 +       .uleb128        4                       /* Abbrev: DW_TAG_base_type */
11630 +       .4byte          .Luint_str              /* DW_AT_name */
11631 +       .byte           4                       /* DW_AT_byte_size */
11632 +       .byte           7                       /* DW_AT_encoding */
11633 +
11634 +.Lchar_type:
11635 +       .uleb128        4                       /* Abbrev: DW_TAG_base_type */
11636 +       .4byte          .Lchar_str              /* DW_AT_name */
11637 +       .byte           1                       /* DW_AT_byte_size */
11638 +       .byte           6                       /* DW_AT_encoding */
11639 +
11640 +.Llen_var:
11641 +       .uleb128        5                       /* Abbrev: DW_TAG_variable artificial */
11642 +       .byte           1                       /* DW_AT_artificial */
11643 +       .4byte          .Luint_type-.Lcu1_begin /* DW_AT_type */
11644 +       .4byte          .Llen_loclist-.Lloclist /* DW_AT_location */
11645 +
11646 +       /* optimized-out variable for b_string.  */
11647 +.Llenb_var:
11648 +       .uleb128        7                       /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
11649 +       .byte           1                       /* DW_AT_artificial */
11650 +       .4byte          .Luint_type-.Lcu1_begin /* DW_AT_type */
11651 +
11652 +       .uleb128        6                       /* Abbrev: DW_TAG_variable DW_FORM_string */
11653 +       .string         "a_string"              /* DW_AT_name */
11654 +       .4byte          .Larray_type-.Lcu1_begin /* DW_AT_type */
11655 +       .byte           2f - 1f                 /* DW_AT_location */
11656 +1:     .byte           3                       /*   DW_OP_addr */
11657 +       .4byte          vardata                 /*   <addr> */
11658 +2:
11659 +
11660 +       /* DW_AT_upper_bound is referencing an optimized-out variable.  */
11661 +       .uleb128        6                       /* Abbrev: DW_TAG_variable DW_FORM_string */
11662 +       .string         "b_string"              /* DW_AT_name */
11663 +       .4byte          .Larrayb_type-.Lcu1_begin /* DW_AT_type */
11664 +       .byte           2f - 1f                 /* DW_AT_location */
11665 +1:     .byte           3                       /*   DW_OP_addr */
11666 +       .4byte          vardata                 /*   <addr> */
11667 +2:
11668 +
11669 +       /* DW_AT_upper_bound is referencing register.  */
11670 +       .uleb128        6                       /* Abbrev: DW_TAG_variable DW_FORM_string */
11671 +       .string         "reg_string"            /* DW_AT_name */
11672 +       .4byte          .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
11673 +       .byte           2f - 1f                 /* DW_AT_location */
11674 +1:     .byte           3                       /*   DW_OP_addr */
11675 +       .4byte          vardata                 /*   <addr> */
11676 +2:
11677 +
11678 +       .byte           0                       /* End of children of CU */
11679 +.Lcu1_end:
11680 +
11681 +       .section        .debug_loc
11682 +.Lloclist:
11683 +.Llen_loclist:
11684 +       .4byte  0                       # Location list begin address
11685 +       .4byte  main_length             # Location list end address
11686 +       .value  2f-1f   # Location expression size
11687 +1:     .byte   0x33    # DW_OP_lit3
11688 +       .byte   0x9f    # DW_OP_stack_value
11689 +2:
11690 +       .quad   0x0     # Location list terminator begin (*.LLST2)
11691 +       .quad   0x0     # Location list terminator end (*.LLST2)
11692 +
11693 +       .section .debug_abbrev
11694 +.Ldebug_abbrev0:
11695 +       .uleb128        1                       /* Abbrev code */
11696 +       .uleb128        0x11                    /* DW_TAG_compile_unit */
11697 +       .byte           0x1                     /* has_children */
11698 +       .uleb128        0x25                    /* DW_AT_producer */
11699 +       .uleb128        0xe                     /* DW_FORM_strp */
11700 +       .uleb128        0x13                    /* DW_AT_language */
11701 +       .uleb128        0xb                     /* DW_FORM_data1 */
11702 +       .uleb128        0x11                    /* DW_AT_low_pc */
11703 +       .uleb128        0x1                     /* DW_FORM_addr */
11704 +       .uleb128        0x12                    /* DW_AT_high_pc */
11705 +       .uleb128        0xb                     /* DW_FORM_data1 */
11706 +       .byte           0x0                     /* Terminator */
11707 +       .byte           0x0                     /* Terminator */
11708 +
11709 +       .uleb128        2                       /* Abbrev code */
11710 +       .uleb128        0x1                     /* TAG: DW_TAG_array_type */
11711 +       .byte           0x1                     /* DW_children_yes */
11712 +       .uleb128        0x49                    /* DW_AT_type */
11713 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11714 +       .byte           0x0                     /* Terminator */
11715 +       .byte           0x0                     /* Terminator */
11716 +
11717 +       .uleb128        3                       /* Abbrev code */
11718 +       .uleb128        0x21                    /* DW_TAG_subrange_type */
11719 +       .byte           0x0                     /* no children */
11720 +       .uleb128        0x49                    /* DW_AT_type */
11721 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11722 +       .uleb128        0x22                    /* DW_AT_lower_bound */
11723 +       .uleb128        0xb                     /* DW_FORM_data1 */
11724 +       .uleb128        0x2f                    /* DW_AT_upper_bound */
11725 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11726 +       .byte           0x0                     /* Terminator */
11727 +       .byte           0x0                     /* Terminator */
11728 +
11729 +       .uleb128        4                       /* Abbrev code */
11730 +       .uleb128        0x24                    /* DW_TAG_base_type */
11731 +       .byte           0x0                     /* no_children */
11732 +       .uleb128        0x3                     /* DW_AT_name */
11733 +       .uleb128        0xe                     /* DW_FORM_strp */
11734 +       .uleb128        0xb                     /* DW_AT_byte_size */
11735 +       .uleb128        0xb                     /* DW_FORM_data1 */
11736 +       .uleb128        0x3e                    /* DW_AT_encoding */
11737 +       .uleb128        0xb                     /* DW_FORM_data1 */
11738 +       .byte           0x0                     /* Terminator */
11739 +       .byte           0x0                     /* Terminator */
11740 +
11741 +       .uleb128        5                       /* Abbrev code */
11742 +       .uleb128        0x34                    /* DW_TAG_variable */
11743 +       .byte           0x0                     /* no_children */
11744 +       .uleb128        0x34                    /* DW_AT_artificial */
11745 +       .uleb128        0x0c                    /* DW_FORM_flag */
11746 +       .uleb128        0x49                    /* DW_AT_type */
11747 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11748 +       .uleb128        0x02                    /* DW_AT_location */
11749 +       .uleb128        0x06                    /* DW_FORM_data4 */
11750 +       .byte           0x0                     /* Terminator */
11751 +       .byte           0x0                     /* Terminator */
11752 +
11753 +       .uleb128        6                       /* Abbrev code */
11754 +       .uleb128        0x34                    /* DW_TAG_variable */
11755 +       .byte           0x0                     /* no_children */
11756 +       .uleb128        0x3                     /* DW_AT_name */
11757 +       .uleb128        0x8                     /* DW_FORM_string */
11758 +       .uleb128        0x49                    /* DW_AT_type */
11759 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11760 +       .uleb128        0x2                     /* DW_AT_location */
11761 +       .uleb128        0xa                     /* DW_FORM_block1 */
11762 +       .byte           0x0                     /* Terminator */
11763 +       .byte           0x0                     /* Terminator */
11764 +
11765 +       .uleb128        7                       /* Abbrev code */
11766 +       .uleb128        0x34                    /* DW_TAG_variable */
11767 +       .byte           0x0                     /* no_children */
11768 +       .uleb128        0x34                    /* DW_AT_artificial */
11769 +       .uleb128        0x0c                    /* DW_FORM_flag */
11770 +       .uleb128        0x49                    /* DW_AT_type */
11771 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11772 +       .byte           0x0                     /* Terminator */
11773 +       .byte           0x0                     /* Terminator */
11774 +
11775 +       .uleb128        8                       /* Abbrev code */
11776 +       .uleb128        0x21                    /* DW_TAG_subrange_type with block */
11777 +       .byte           0x0                     /* no children */
11778 +       .uleb128        0x49                    /* DW_AT_type */
11779 +       .uleb128        0x13                    /* DW_FORM_ref4 */
11780 +       .uleb128        0x22                    /* DW_AT_lower_bound */
11781 +       .uleb128        0xb                     /* DW_FORM_data1 */
11782 +       .uleb128        0x2f                    /* DW_AT_upper_bound */
11783 +       .uleb128        0xa                     /* DW_FORM_block1 */
11784 +       .byte           0x0                     /* Terminator */
11785 +       .byte           0x0                     /* Terminator */
11786 +
11787 +       .byte           0x0                     /* Terminator */
11788 +
11789 +/* String table */
11790 +       .section .debug_str
11791 +.Lproducer:
11792 +       .string         "GNU C 3.3.3"
11793 +.Lchar_str:
11794 +       .string         "char"
11795 +.Luint_str:
11796 +       .string         "unsigned int"
11797 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
11798 ===================================================================
11799 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11800 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp  2011-07-03 10:33:11.000000000 +0200
11801 @@ -0,0 +1,54 @@
11802 +# Copyright 2010 Free Software Foundation, Inc.
11803 +
11804 +# This program is free software; you can redistribute it and/or modify
11805 +# it under the terms of the GNU General Public License as published by
11806 +# the Free Software Foundation; either version 3 of the License, or
11807 +# (at your option) any later version.
11808 +#
11809 +# This program is distributed in the hope that it will be useful,
11810 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11811 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11812 +# GNU General Public License for more details.
11813 +#
11814 +# You should have received a copy of the GNU General Public License
11815 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
11816 +
11817 +# Test printing variable with dynamic bounds which reference a different
11818 +# (artificial in the GCC case) variable containing loclist as its location.
11819 +# This testcase uses value (not address) of the referenced variable:
11820 +# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
11821 +
11822 +# This test can only be run on targets which support DWARF-2 and use gas.
11823 +# For now pick a sampling of likely targets.
11824 +if {![istarget *-*-linux*]
11825 +    && ![istarget *-*-gnu*]
11826 +    && ![istarget *-*-elf*]
11827 +    && ![istarget *-*-openbsd*]
11828 +    && ![istarget arm-*-eabi*]
11829 +    && ![istarget powerpc-*-eabi*]} {
11830 +    return 0
11831 +}
11832 +
11833 +set testfile dw2-bound-loclist
11834 +if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
11835 +    return -1
11836 +}
11837 +
11838 +# Verify it behaves at least as an unbound array without inferior.
11839 +
11840 +gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"}
11841 +gdb_test "ptype a_string" {type = char \[\]}
11842 +
11843 +# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
11844 +if ![runto "*main"] {
11845 +    return -1
11846 +}
11847 +
11848 +gdb_test "p a_string" { = "seen"}
11849 +gdb_test "ptype a_string" {type = char \[4\]}
11850 +
11851 +gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
11852 +gdb_test "ptype b_string" {type = char \[\]}
11853 +
11854 +# The register contains unpredictable value - the array size.
11855 +gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
11856 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
11857 ===================================================================
11858 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11859 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.c 2011-07-03 10:33:11.000000000 +0200
11860 @@ -0,0 +1,42 @@
11861 +/* This testcase is part of GDB, the GNU debugger.
11862 +
11863 +   Copyright 2004 Free Software Foundation, Inc.
11864 +
11865 +   This program is free software; you can redistribute it and/or modify
11866 +   it under the terms of the GNU General Public License as published by
11867 +   the Free Software Foundation; either version 2 of the License, or
11868 +   (at your option) any later version.
11869 +
11870 +   This program is distributed in the hope that it will be useful,
11871 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
11872 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11873 +   GNU General Public License for more details.
11874
11875 +   You should have received a copy of the GNU General Public License
11876 +   along with this program; if not, write to the Free Software
11877 +   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
11878 +   USA.  */
11879 +
11880 +
11881 +/* The function `func1' traced into must have debug info on offset > 0;
11882 +   (DW_UNSND (attr)).  This is the reason of `func0' existence.  */
11883 +
11884 +void
11885 +func0(int a, int b)
11886 +{
11887 +}
11888 +
11889 +/* `func1' being traced into must have some arguments to dump.  */
11890 +
11891 +void
11892 +func1(int a, int b)
11893 +{
11894 +  func0 (a,b);
11895 +}
11896 +
11897 +int
11898 +main(void)
11899 +{
11900 +  func1 (1, 2);
11901 +  return 0;
11902 +}
11903 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
11904 ===================================================================
11905 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11906 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp       2011-07-03 10:33:11.000000000 +0200
11907 @@ -0,0 +1,79 @@
11908 +# Copyright 2006 Free Software Foundation, Inc.
11909 +
11910 +# This program is free software; you can redistribute it and/or modify
11911 +# it under the terms of the GNU General Public License as published by
11912 +# the Free Software Foundation; either version 2 of the License, or
11913 +# (at your option) any later version.
11914 +# 
11915 +# This program is distributed in the hope that it will be useful,
11916 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
11917 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11918 +# GNU General Public License for more details.
11919 +# 
11920 +# You should have received a copy of the GNU General Public License
11921 +# along with this program; if not, write to the Free Software
11922 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11923 +
11924 +# Minimal DWARF-2 unit test
11925 +
11926 +# This test can only be run on targets which support DWARF-2.
11927 +# For now pick a sampling of likely targets.
11928 +if {![istarget *-*-linux*]
11929 +    && ![istarget *-*-gnu*]
11930 +    && ![istarget *-*-elf*]
11931 +    && ![istarget *-*-openbsd*]
11932 +    && ![istarget arm-*-eabi*]
11933 +    && ![istarget powerpc-*-eabi*]} {
11934 +    return 0  
11935 +}
11936 +
11937 +set testfile "dw2-stripped"
11938 +set srcfile ${testfile}.c
11939 +set binfile ${objdir}/${subdir}/${testfile}.x
11940 +
11941 +remote_exec build "rm -f ${binfile}"
11942 +
11943 +# get the value of gcc_compiled
11944 +if [get_compiler_info ${binfile}] {
11945 +    return -1
11946 +}
11947 +
11948 +# This test can only be run on gcc as we use additional_flags=FIXME
11949 +if {$gcc_compiled == 0} {
11950 +    return 0
11951 +}
11952 +
11953 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
11954 +    return -1
11955 +}
11956 +
11957 +remote_exec build "objcopy -R .debug_loc ${binfile}"
11958 +set strip_output [remote_exec build "objdump -h ${binfile}"]
11959 +
11960 +set test "stripping test file preservation"
11961 +if [ regexp ".debug_info " $strip_output]  {
11962 +    pass "$test (.debug_info preserved)"
11963 +} else {
11964 +    fail "$test (.debug_info got also stripped)"
11965 +}
11966 +
11967 +set test "stripping test file functionality"
11968 +if [ regexp ".debug_loc " $strip_output]  {
11969 +    fail "$test (.debug_loc still present)"
11970 +} else {
11971 +    pass "$test (.debug_loc stripped)"
11972 +}
11973 +
11974 +gdb_exit
11975 +gdb_start
11976 +gdb_reinitialize_dir $srcdir/$subdir
11977 +gdb_load ${binfile}
11978 +
11979 +# For C programs, "start" should stop in main().
11980 +
11981 +gdb_test "start" \
11982 +         ".*main \\(\\) at .*" \
11983 +         "start"
11984 +gdb_test "step" \
11985 +         "func.* \\(.*\\) at .*" \
11986 +         "step"
11987 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
11988 ===================================================================
11989 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
11990 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S      2011-07-03 10:33:11.000000000 +0200
11991 @@ -0,0 +1,83 @@
11992 +/* This testcase is part of GDB, the GNU debugger.
11993 +
11994 +   Copyright 2009 Free Software Foundation, Inc.
11995 +
11996 +   This program is free software; you can redistribute it and/or modify
11997 +   it under the terms of the GNU General Public License as published by
11998 +   the Free Software Foundation; either version 3 of the License, or
11999 +   (at your option) any later version.
12000 +
12001 +   This program is distributed in the hope that it will be useful,
12002 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
12003 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12004 +   GNU General Public License for more details.
12005 +
12006 +   You should have received a copy of the GNU General Public License
12007 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
12008 +
12009 +/* Debug information */
12010 +
12011 +       .section .debug_info
12012 +.Lcu1_begin:
12013 +       /* CU header */
12014 +       .4byte  .Lcu1_end - .Lcu1_start         /* Length of Compilation Unit */
12015 +.Lcu1_start:
12016 +       .2byte  2                               /* DWARF Version */
12017 +       .4byte  .Labbrev1_begin                 /* Offset into abbrev section */
12018 +       .byte   4                               /* Pointer size */
12019 +
12020 +       /* CU die */
12021 +       .uleb128 1                              /* Abbrev: DW_TAG_compile_unit */
12022 +       .ascii  "dw2-struct-member-data-location.c\0"   /* DW_AT_name */
12023 +       .ascii  "GNU C 4.3.2\0"                 /* DW_AT_producer */
12024 +       .byte   1                               /* DW_AT_language (C) */
12025 +
12026 +.Ltype_uchar:
12027 +       .uleb128        2                       /* Abbrev: DW_TAG_structure_type */
12028 +       .ascii          "some_struct\0"         /* DW_AT_name */
12029 +
12030 +       .uleb128        3                       /* Abbrev: DW_TAG_member */
12031 +       .ascii          "field\0"               /* DW_AT_name */
12032 +       .byte           0                       /* DW_AT_data_member_location */
12033 +
12034 +       .byte           0                       /* End of children of some_struct */
12035 +
12036 +       .byte           0                       /* End of children of CU */
12037 +
12038 +.Lcu1_end:
12039 +
12040 +/* Abbrev table */
12041 +       .section .debug_abbrev
12042 +.Labbrev1_begin:
12043 +       .uleb128        1                       /* Abbrev code */
12044 +       .uleb128        0x11                    /* DW_TAG_compile_unit */
12045 +       .byte           1                       /* has_children */
12046 +       .uleb128        0x3                     /* DW_AT_name */
12047 +       .uleb128        0x8                     /* DW_FORM_string */
12048 +       .uleb128        0x25                    /* DW_AT_producer */
12049 +       .uleb128        0x8                     /* DW_FORM_string */
12050 +       .uleb128        0x13                    /* DW_AT_language */
12051 +       .uleb128        0xb                     /* DW_FORM_data1 */
12052 +       .byte           0x0                     /* Terminator */
12053 +       .byte           0x0                     /* Terminator */
12054 +
12055 +       .uleb128        2                       /* Abbrev code */
12056 +       .uleb128        0x13                    /* DW_TAG_structure_type */
12057 +       .byte           1                       /* has_children */
12058 +       .uleb128        0x3                     /* DW_AT_name */
12059 +       .uleb128        0x8                     /* DW_FORM_string */
12060 +       .byte           0x0                     /* Terminator */
12061 +       .byte           0x0                     /* Terminator */
12062 +
12063 +       .uleb128        3                       /* Abbrev code */
12064 +       .uleb128        0x0d                    /* DW_TAG_member */
12065 +       .byte           0                       /* has_children */
12066 +       .uleb128        0x3                     /* DW_AT_name */
12067 +       .uleb128        0x8                     /* DW_FORM_string */
12068 +       .uleb128        0x38                    /* DW_AT_data_member_location */
12069 +       .uleb128        0x0b                    /* DW_FORM_data1 */
12070 +       .byte           0x0                     /* Terminator */
12071 +       .byte           0x0                     /* Terminator */
12072 +
12073 +       .byte           0x0                     /* Terminator */
12074 +       .byte           0x0                     /* Terminator */
12075 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
12076 ===================================================================
12077 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12078 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp    2011-07-03 10:33:11.000000000 +0200
12079 @@ -0,0 +1,37 @@
12080 +# Copyright 2009 Free Software Foundation, Inc.
12081 +
12082 +# This program is free software; you can redistribute it and/or modify
12083 +# it under the terms of the GNU General Public License as published by
12084 +# the Free Software Foundation; either version 3 of the License, or
12085 +# (at your option) any later version.
12086 +#
12087 +# This program is distributed in the hope that it will be useful,
12088 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12089 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12090 +# GNU General Public License for more details.
12091 +#
12092 +# You should have received a copy of the GNU General Public License
12093 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
12094 +
12095 +# This test can only be run on targets which support DWARF-2 and use gas.
12096 +# For now pick a sampling of likely targets.
12097 +if {![istarget *-*-linux*]
12098 +    && ![istarget *-*-gnu*]
12099 +    && ![istarget *-*-elf*]
12100 +    && ![istarget *-*-openbsd*]
12101 +    && ![istarget arm-*-eabi*]
12102 +    && ![istarget powerpc-*-eabi*]} {
12103 +    return 0  
12104 +}
12105 +
12106 +set testfile "dw2-struct-member-data-location"
12107 +set srcfile ${testfile}.S
12108 +set binfile ${testfile}.x
12109 +
12110 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } {
12111 +    return -1
12112 +}
12113 +
12114 +clean_restart $binfile
12115 +
12116 +gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
12117 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.exp
12118 ===================================================================
12119 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12120 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.exp      2011-07-03 10:33:11.000000000 +0200
12121 @@ -0,0 +1,42 @@
12122 +# Copyright 2009 Free Software Foundation, Inc.
12123 +
12124 +# This program is free software; you can redistribute it and/or modify
12125 +# it under the terms of the GNU General Public License as published by
12126 +# the Free Software Foundation; either version 2 of the License, or
12127 +# (at your option) any later version.
12128 +# 
12129 +# This program is distributed in the hope that it will be useful,
12130 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12131 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12132 +# GNU General Public License for more details.
12133 +# 
12134 +# You should have received a copy of the GNU General Public License
12135 +# along with this program; if not, write to the Free Software
12136 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
12137 +
12138 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
12139 +
12140 +# This file is part of the gdb testsuite.  Array element stride must not be
12141 +# specified in the number of elements but in a number of bytes instead.
12142 +# Original problem:
12143 +# (gdb) p c40pt(1)
12144 +# $1 = '0-hello', ' ' <repeats 33 times>
12145 +# (gdb) p c40pt(2)
12146 +# warning: Fortran array stride not divisible by the element size
12147 +
12148 +set testfile dwarf-stride
12149 +set srcfile ${testfile}.f90
12150 +
12151 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
12152 +    return -1
12153 +}
12154 +
12155 +if ![runto MAIN__] then {
12156 +    perror "couldn't run to breakpoint MAIN__"
12157 +    continue
12158 +}
12159 +
12160 +gdb_breakpoint [gdb_get_line_number "break-here"]
12161 +gdb_continue_to_breakpoint "break-here" ".*break-here.*"
12162 +gdb_test "p c40pt(1)" " = '0-hello.*"
12163 +gdb_test "p c40pt(2)" " = '1-hello.*"
12164 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.f90
12165 ===================================================================
12166 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12167 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dwarf-stride.f90      2011-07-03 10:33:11.000000000 +0200
12168 @@ -0,0 +1,40 @@
12169 +! Copyright 2009 Free Software Foundation, Inc.
12170 +!
12171 +! This program is free software; you can redistribute it and/or modify
12172 +! it under the terms of the GNU General Public License as published by
12173 +! the Free Software Foundation; either version 2 of the License, or
12174 +! (at your option) any later version.
12175 +!
12176 +! This program is distributed in the hope that it will be useful,
12177 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12178 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12179 +! GNU General Public License for more details.
12180 +!
12181 +! You should have received a copy of the GNU General Public License
12182 +! along with this program; if not, write to the Free Software
12183 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12184 +!
12185 +! File written by Alan Matsuoka.
12186 +
12187 +program repro
12188 +
12189 +  type small_stride
12190 +     character*40 long_string
12191 +     integer      small_pad
12192 +  end type small_stride
12193 +
12194 +  type(small_stride), dimension (20), target :: unpleasant
12195 +  character*40, pointer, dimension(:):: c40pt
12196 +
12197 +  integer i
12198 +
12199 +  do i = 0,19
12200 +     unpleasant(i+1)%small_pad = i+1
12201 +     unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
12202 +  end do
12203 +
12204 +  c40pt => unpleasant%long_string
12205 +
12206 +  print *, c40pt  ! break-here
12207 +
12208 +end program repro
12209 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90
12210 ===================================================================
12211 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12212 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame-stub.f90  2011-07-03 10:33:11.000000000 +0200
12213 @@ -0,0 +1,24 @@
12214 +! Copyright 2010 Free Software Foundation, Inc.
12215 +!
12216 +! This program is free software; you can redistribute it and/or modify
12217 +! it under the terms of the GNU General Public License as published by
12218 +! the Free Software Foundation; either version 2 of the License, or
12219 +! (at your option) any later version.
12220 +!
12221 +! This program is distributed in the hope that it will be useful,
12222 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12223 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12224 +! GNU General Public License for more details.
12225 +!
12226 +! You should have received a copy of the GNU General Public License
12227 +! along with this program; if not, write to the Free Software
12228 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12229 +!
12230 +! Ihis file is the Fortran source file for dynamic.exp.
12231 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
12232 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
12233 +
12234 +subroutine bar
12235 +  real :: dummy
12236 +  dummy = 1
12237 +end subroutine bar
12238 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp
12239 ===================================================================
12240 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12241 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.exp       2011-07-03 10:33:11.000000000 +0200
12242 @@ -0,0 +1,37 @@
12243 +# Copyright 2010 Free Software Foundation, Inc.
12244 +
12245 +# This program is free software; you can redistribute it and/or modify
12246 +# it under the terms of the GNU General Public License as published by
12247 +# the Free Software Foundation; either version 2 of the License, or
12248 +# (at your option) any later version.
12249 +# 
12250 +# This program is distributed in the hope that it will be useful,
12251 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12252 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12253 +# GNU General Public License for more details.
12254 +# 
12255 +# You should have received a copy of the GNU General Public License
12256 +# along with this program; if not, write to the Free Software
12257 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
12258 +
12259 +set testfile "dynamic-other-frame"
12260 +set srcfile1 ${testfile}.f90
12261 +set srcfile2 ${testfile}-stub.f90
12262 +set objfile2 ${objdir}/${subdir}/${testfile}-stub.o
12263 +set executable ${testfile}
12264 +set binfile ${objdir}/${subdir}/${executable}
12265 +
12266 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${objfile2}" object {f77}] != ""
12267 +     || [gdb_compile "${srcdir}/${subdir}/${srcfile1} ${objfile2}" "${binfile}" executable {debug f77}] != "" } {
12268 +    untested "Couldn't compile ${srcfile1} or ${srcfile2}"
12269 +    return -1
12270 +}
12271 +
12272 +clean_restart ${executable}
12273 +
12274 +if ![runto bar_] then {
12275 +    perror "couldn't run to bar_"
12276 +    continue
12277 +}
12278 +
12279 +gdb_test "bt" {foo \(string='hello'.*}
12280 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90
12281 ===================================================================
12282 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12283 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic-other-frame.f90       2011-07-03 10:33:11.000000000 +0200
12284 @@ -0,0 +1,36 @@
12285 +! Copyright 2010 Free Software Foundation, Inc.
12286 +!
12287 +! This program is free software; you can redistribute it and/or modify
12288 +! it under the terms of the GNU General Public License as published by
12289 +! the Free Software Foundation; either version 2 of the License, or
12290 +! (at your option) any later version.
12291 +!
12292 +! This program is distributed in the hope that it will be useful,
12293 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12294 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12295 +! GNU General Public License for more details.
12296 +!
12297 +! You should have received a copy of the GNU General Public License
12298 +! along with this program; if not, write to the Free Software
12299 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12300 +!
12301 +! Ihis file is the Fortran source file for dynamic.exp.
12302 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
12303 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
12304 +
12305 +subroutine foo (string)
12306 +  interface
12307 +    subroutine bar
12308 +    end subroutine
12309 +  end interface
12310 +  character string*(*)
12311 +  call bar                                ! stop-here
12312 +end subroutine foo
12313 +program test
12314 +  interface
12315 +    subroutine foo (string)
12316 +    character string*(*)
12317 +    end subroutine
12318 +  end interface
12319 +  call foo ('hello')
12320 +end
12321 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.exp
12322 ===================================================================
12323 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12324 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.exp   2011-07-03 10:33:11.000000000 +0200
12325 @@ -0,0 +1,145 @@
12326 +# Copyright 2007 Free Software Foundation, Inc.
12327 +
12328 +# This program is free software; you can redistribute it and/or modify
12329 +# it under the terms of the GNU General Public License as published by
12330 +# the Free Software Foundation; either version 2 of the License, or
12331 +# (at your option) any later version.
12332 +# 
12333 +# This program is distributed in the hope that it will be useful,
12334 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12335 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12336 +# GNU General Public License for more details.
12337 +# 
12338 +# You should have received a copy of the GNU General Public License
12339 +# along with this program; if not, write to the Free Software
12340 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
12341 +
12342 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
12343 +
12344 +# This file is part of the gdb testsuite.  It contains tests for dynamically
12345 +# allocated Fortran arrays.
12346 +# It depends on the GCC dynamic Fortran arrays DWARF support:
12347 +#      http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
12348 +
12349 +set testfile "dynamic"
12350 +set srcfile ${testfile}.f90
12351 +set binfile ${objdir}/${subdir}/${testfile}
12352 +
12353 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
12354 +    untested "Couldn't compile ${srcfile}"
12355 +    return -1
12356 +}
12357 +
12358 +gdb_exit
12359 +gdb_start
12360 +gdb_reinitialize_dir $srcdir/$subdir
12361 +gdb_load ${binfile}
12362 +
12363 +if ![runto MAIN__] then {
12364 +    perror "couldn't run to breakpoint MAIN__"
12365 +    continue
12366 +}
12367 +
12368 +gdb_breakpoint [gdb_get_line_number "varx-init"]
12369 +gdb_continue_to_breakpoint "varx-init"
12370 +gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated"
12371 +gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated"
12372 +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"
12373 +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"
12374 +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"
12375 +
12376 +gdb_breakpoint [gdb_get_line_number "varx-allocated"]
12377 +gdb_continue_to_breakpoint "varx-allocated"
12378 +# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
12379 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
12380 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
12381 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
12382 +
12383 +gdb_breakpoint [gdb_get_line_number "varx-filled"]
12384 +gdb_continue_to_breakpoint "varx-filled"
12385 +gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
12386 +gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
12387 +gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
12388 +gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
12389 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
12390 +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"
12391 +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"
12392 +
12393 +gdb_breakpoint [gdb_get_line_number "varv-associated"]
12394 +gdb_continue_to_breakpoint "varv-associated"
12395 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
12396 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
12397 +# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
12398 +gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
12399 +gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
12400 +# Intel Fortran Compiler 10.1.008 uses the pointer type.
12401 +gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
12402 +
12403 +gdb_breakpoint [gdb_get_line_number "varv-filled"]
12404 +gdb_continue_to_breakpoint "varv-filled"
12405 +gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
12406 +gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
12407 +
12408 +gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
12409 +gdb_continue_to_breakpoint "varv-deassociated"
12410 +# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
12411 +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"
12412 +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"
12413 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
12414 +gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
12415 +gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
12416 +
12417 +gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
12418 +gdb_continue_to_breakpoint "varx-deallocated"
12419 +gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated"
12420 +gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated"
12421 +gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
12422 +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"
12423 +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"
12424 +
12425 +gdb_breakpoint [gdb_get_line_number "vary-passed"]
12426 +gdb_continue_to_breakpoint "vary-passed"
12427 +# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
12428 +gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
12429 +
12430 +gdb_breakpoint [gdb_get_line_number "vary-filled"]
12431 +gdb_continue_to_breakpoint "vary-filled"
12432 +gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
12433 +gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
12434 +gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
12435 +gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
12436 +# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
12437 +gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
12438 +
12439 +gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
12440 +gdb_continue_to_breakpoint "varw-almostfilled"
12441 +gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
12442 +gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
12443 +# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
12444 +gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
12445 +# "up" works with GCC but other Fortran compilers may copy the values into the
12446 +# outer function only on the exit of the inner function.
12447 +# We need both variants as depending on the arch we optionally may still be
12448 +# executing the caller line or not after `finish'.
12449 +gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
12450 +gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
12451 +gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
12452 +gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
12453 +gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
12454 +
12455 +gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
12456 +gdb_continue_to_breakpoint "varz-almostfilled"
12457 +# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
12458 +gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
12459 +# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
12460 +# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
12461 +gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
12462 +gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
12463 +gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
12464 +gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
12465 +# maps to foo::vary(1,1)
12466 +gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
12467 +# maps to foo::vary(2,2)
12468 +gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
12469 +# maps to foo::vary(1,3)
12470 +gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
12471 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.f90
12472 ===================================================================
12473 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12474 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/dynamic.f90   2011-07-03 10:33:11.000000000 +0200
12475 @@ -0,0 +1,98 @@
12476 +! Copyright 2007 Free Software Foundation, Inc.
12477 +!
12478 +! This program is free software; you can redistribute it and/or modify
12479 +! it under the terms of the GNU General Public License as published by
12480 +! the Free Software Foundation; either version 2 of the License, or
12481 +! (at your option) any later version.
12482 +!
12483 +! This program is distributed in the hope that it will be useful,
12484 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12485 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12486 +! GNU General Public License for more details.
12487 +!
12488 +! You should have received a copy of the GNU General Public License
12489 +! along with this program; if not, write to the Free Software
12490 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12491 +!
12492 +! Ihis file is the Fortran source file for dynamic.exp.
12493 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
12494 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
12495 +
12496 +subroutine baz
12497 +  real, target, allocatable :: varx (:, :, :)
12498 +  real, pointer :: varv (:, :, :)
12499 +  real, target :: varu (1, 2, 3)
12500 +  logical :: l
12501 +  allocate (varx (1:6, 5:15, 17:28))            ! varx-init
12502 +  l = allocated (varx)
12503 +  varx(:, :, :) = 6                             ! varx-allocated
12504 +  varx(1, 5, 17) = 7
12505 +  varx(2, 6, 18) = 8
12506 +  varx(6, 15, 28) = 9
12507 +  varv => varx                                  ! varx-filled
12508 +  l = associated (varv)
12509 +  varv(3, 7, 19) = 10                           ! varv-associated
12510 +  varv => null ()                               ! varv-filled
12511 +  l = associated (varv)
12512 +  deallocate (varx)                             ! varv-deassociated
12513 +  l = allocated (varx)
12514 +  varu(:, :, :) = 10                            ! varx-deallocated
12515 +  allocate (varv (1:6, 5:15, 17:28))
12516 +  l = associated (varv)
12517 +  varv(:, :, :) = 6
12518 +  varv(1, 5, 17) = 7
12519 +  varv(2, 6, 18) = 8
12520 +  varv(6, 15, 28) = 9
12521 +  deallocate (varv)
12522 +  l = associated (varv)
12523 +  varv => varu
12524 +  varv(1, 1, 1) = 6
12525 +  varv(1, 2, 3) = 7
12526 +  l = associated (varv)
12527 +end subroutine baz
12528 +subroutine foo (vary, varw)
12529 +  real :: vary (:, :)
12530 +  real :: varw (:, :, :)
12531 +  vary(:, :) = 4                                ! vary-passed
12532 +  vary(1, 1) = 8
12533 +  vary(2, 2) = 9
12534 +  vary(1, 3) = 10
12535 +  varw(:, :, :) = 5                             ! vary-filled
12536 +  varw(1, 1, 1) = 6
12537 +  varw(2, 2, 2) = 7                             ! varw-almostfilled
12538 +end subroutine foo
12539 +subroutine bar (varz, vart)
12540 +  real :: varz (*)
12541 +  real :: vart (2:11, 7:*)
12542 +  varz(1:3) = 4
12543 +  varz(2) = 5                                   ! varz-almostfilled
12544 +  vart(2,7) = vart(2,7)
12545 +end subroutine bar
12546 +program test
12547 +  interface
12548 +    subroutine foo (vary, varw)
12549 +    real :: vary (:, :)
12550 +    real :: varw (:, :, :)
12551 +    end subroutine
12552 +  end interface
12553 +  interface
12554 +    subroutine bar (varz, vart)
12555 +    real :: varz (*)
12556 +    real :: vart (2:11, 7:*)
12557 +    end subroutine
12558 +  end interface
12559 +  real :: x (10, 10), y (5), z(8, 8, 8)
12560 +  x(:,:) = 1
12561 +  y(:) = 2
12562 +  z(:,:,:) = 3
12563 +  call baz
12564 +  call foo (x, z(2:6, 4:7, 6:8))
12565 +  call bar (y, x)
12566 +  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
12567 +  if (x (1, 3) .ne. 10) call abort
12568 +  if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
12569 +  if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
12570 +  call foo (transpose (x), z)
12571 +  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
12572 +  if (x (3, 1) .ne. 10) call abort
12573 +end
12574 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.exp
12575 ===================================================================
12576 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12577 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.exp    2011-07-03 10:33:11.000000000 +0200
12578 @@ -0,0 +1,59 @@
12579 +# Copyright 2008 Free Software Foundation, Inc.
12580 +
12581 +# This program is free software; you can redistribute it and/or modify
12582 +# it under the terms of the GNU General Public License as published by
12583 +# the Free Software Foundation; either version 2 of the License, or
12584 +# (at your option) any later version.
12585 +# 
12586 +# This program is distributed in the hope that it will be useful,
12587 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12588 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12589 +# GNU General Public License for more details.
12590 +# 
12591 +# You should have received a copy of the GNU General Public License
12592 +# along with this program; if not, write to the Free Software
12593 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
12594 +
12595 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
12596 +
12597 +# This file is part of the gdb testsuite.  It contains tests for Fortran
12598 +# strings with dynamic length.
12599 +
12600 +set testfile "string"
12601 +set srcfile ${testfile}.f90
12602 +set binfile ${objdir}/${subdir}/${testfile}
12603 +
12604 +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
12605 +    untested "Couldn't compile ${srcfile}"
12606 +    return -1
12607 +}
12608 +
12609 +gdb_exit
12610 +gdb_start
12611 +gdb_reinitialize_dir $srcdir/$subdir
12612 +gdb_load ${binfile}
12613 +
12614 +if ![runto MAIN__] then {
12615 +    perror "couldn't run to breakpoint MAIN__"
12616 +    continue
12617 +}
12618 +
12619 +gdb_breakpoint [gdb_get_line_number "var-init"]
12620 +gdb_continue_to_breakpoint "var-init"
12621 +gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
12622 +gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
12623 +gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
12624 +gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
12625 +gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
12626 +gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
12627 +gdb_test "p c" "\\$\[0-9\]* = 'c'"
12628 +gdb_test "p d" "\\$\[0-9\]* = 'd       '"
12629 +gdb_test "p e" "\\$\[0-9\]* = 'g   '"
12630 +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   '\\) \\)"
12631 +gdb_test "p *e" "Attempt to take contents of a non-pointer value."
12632 +gdb_test "p *f" "Attempt to take contents of a non-pointer value."
12633 +
12634 +gdb_breakpoint [gdb_get_line_number "var-finish"]
12635 +gdb_continue_to_breakpoint "var-finish"
12636 +gdb_test "p e" "\\$\[0-9\]* = 'e   '" "p e re-set"
12637 +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"
12638 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.f90
12639 ===================================================================
12640 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12641 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/string.f90    2011-07-03 10:33:11.000000000 +0200
12642 @@ -0,0 +1,37 @@
12643 +! Copyright 2008 Free Software Foundation, Inc.
12644 +!
12645 +! This program is free software; you can redistribute it and/or modify
12646 +! it under the terms of the GNU General Public License as published by
12647 +! the Free Software Foundation; either version 2 of the License, or
12648 +! (at your option) any later version.
12649 +!
12650 +! This program is distributed in the hope that it will be useful,
12651 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12652 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12653 +! GNU General Public License for more details.
12654 +!
12655 +! You should have received a copy of the GNU General Public License
12656 +! along with this program; if not, write to the Free Software
12657 +! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12658 +!
12659 +! Ihis file is the Fortran source file for dynamic.exp.
12660 +! Original file written by Jakub Jelinek <jakub@redhat.com>.
12661 +! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
12662 +
12663 +subroutine foo (e, f)
12664 +  character (len=1) :: c
12665 +  character (len=8) :: d
12666 +  character (len=*) :: e
12667 +  character (len=*) :: f (1:7, 8:10)
12668 +  c = 'c'
12669 +  d = 'd'
12670 +  e = 'e'                                       ! var-init
12671 +  f = 'f'
12672 +  f(1,9) = 'f2'
12673 +  c = 'c'                                       ! var-finish
12674 +end subroutine foo
12675 +  character (len=4) :: g, h (1:7, 8:10)
12676 +  g = 'g'
12677 +  h = 'h'
12678 +  call foo (g, h)
12679 +end
12680 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.exp
12681 ===================================================================
12682 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12683 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.exp  2011-07-03 10:33:11.000000000 +0200
12684 @@ -0,0 +1,60 @@
12685 +# Copyright 2011 Free Software Foundation, Inc.
12686 +
12687 +# This program is free software; you can redistribute it and/or modify
12688 +# it under the terms of the GNU General Public License as published by
12689 +# the Free Software Foundation; either version 3 of the License, or
12690 +# (at your option) any later version.
12691 +#
12692 +# This program is distributed in the hope that it will be useful,
12693 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12694 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12695 +# GNU General Public License for more details.
12696 +#
12697 +# You should have received a copy of the GNU General Public License
12698 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
12699 +
12700 +if { [skip_fortran_tests] } { return -1 }
12701 +
12702 +set testfile "subrange"
12703 +set srcfile ${testfile}.f90
12704 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
12705 +    return -1
12706 +}
12707 +
12708 +if ![runto MAIN__] {
12709 +    perror "Couldn't run to MAIN__"
12710 +    continue
12711 +}
12712 +
12713 +# Depending on the compiler version being used, the name of the 4-byte integer
12714 +# and real types can be printed differently.  For instance, gfortran-4.1 uses
12715 +# "int4" whereas gfortran-4.3 uses "int(kind=4)".
12716 +set int4 "(int4|integer\\(kind=4\\))"
12717 +
12718 +gdb_breakpoint [gdb_get_line_number "break-static"]
12719 +gdb_continue_to_breakpoint "break-static" ".*break-static.*"
12720 +
12721 +foreach var {a alloc ptr} {
12722 +    global pf_prefix
12723 +    set old_prefix $pf_prefix
12724 +    lappend pf_prefix "$var:"
12725 +
12726 +    gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
12727 +    gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
12728 +    gdb_test "p $var (1, 2:)" { = \(21, 31\)}
12729 +    gdb_test "p $var (2, :2)" { = \(12, 22\)}
12730 +    gdb_test "p $var (3, 2:2)" { = \(23\)}
12731 +    gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
12732 +    gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
12733 +    gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
12734 +    gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
12735 +    gdb_test "p $var (:)" "Wrong number of subscripts"
12736 +    gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
12737 +
12738 +    set pf_prefix $old_prefix
12739 +}
12740 +
12741 +gdb_test_no_output {set $a=a}
12742 +delete_breakpoints
12743 +gdb_unload
12744 +gdb_test {p $a (3, 2:2)} { = \(23\)}
12745 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.f90
12746 ===================================================================
12747 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12748 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.fortran/subrange.f90  2011-07-03 10:33:11.000000000 +0200
12749 @@ -0,0 +1,28 @@
12750 +! Copyright 2011 Free Software Foundation, Inc.
12751 +!
12752 +! This program is free software; you can redistribute it and/or modify
12753 +! it under the terms of the GNU General Public License as published by
12754 +! the Free Software Foundation; either version 3 of the License, or
12755 +! (at your option) any later version.
12756 +! 
12757 +! This program is distributed in the hope that it will be useful,
12758 +! but WITHOUT ANY WARRANTY; without even the implied warranty of
12759 +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12760 +! GNU General Public License for more details.
12761 +! 
12762 +! You should have received a copy of the GNU General Public License
12763 +! along with this program.  If not, see <http://www.gnu.org/licenses/>.
12764 +
12765 +program test
12766 +  integer, target :: a (4, 3)
12767 +  integer, allocatable :: alloc (:, :)
12768 +  integer, pointer :: ptr (:, :)
12769 +  do 1 i = 1, 4
12770 +  do 1 j = 1, 3
12771 +    a (i, j) = j * 10 + i
12772 +1 continue
12773 +  allocate (alloc (4, 3))
12774 +  alloc = a
12775 +  ptr => a
12776 +  write (*,*) a                 ! break-static
12777 +end
12778 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.gdb/selftest.exp
12779 ===================================================================
12780 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.gdb/selftest.exp 2011-07-03 10:33:07.000000000 +0200
12781 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.gdb/selftest.exp      2011-07-03 10:33:11.000000000 +0200
12782 @@ -92,6 +92,10 @@ proc do_steps_and_nexts {} {
12783                 set description "step over ttyarg initialization"
12784                 set command "step"
12785             }
12786 +           -re ".*python_script = 0.*$gdb_prompt $" {
12787 +               set description "step over python_script initialization"
12788 +               set command "step"
12789 +           }
12790             -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" {
12791                 set description "next over make_command_stats_cleanup and everything it calls"
12792                 set command "next"
12793 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
12794 ===================================================================
12795 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12796 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.c       2011-07-03 10:33:11.000000000 +0200
12797 @@ -0,0 +1,26 @@
12798 +/* Copyright 2011 Free Software Foundation, Inc.
12799 +
12800 +   This file is part of GDB.
12801 +
12802 +   This program is free software; you can redistribute it and/or modify
12803 +   it under the terms of the GNU General Public License as published by
12804 +   the Free Software Foundation; either version 3 of the License, or
12805 +   (at your option) any later version.
12806 +
12807 +   This program is distributed in the hope that it will be useful,
12808 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
12809 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12810 +   GNU General Public License for more details.
12811 +
12812 +   You should have received a copy of the GNU General Public License
12813 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
12814 +
12815 +int
12816 +main (int argc, char **argv)
12817 +{
12818 +  char vla[argc];
12819 +
12820 +  vla[0] = 0;  /* break-here */
12821 +
12822 +  return 0;
12823 +}
12824 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
12825 ===================================================================
12826 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12827 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp     2011-07-03 10:33:11.000000000 +0200
12828 @@ -0,0 +1,57 @@
12829 +# Copyright 2011 Free Software Foundation, Inc.
12830 +#
12831 +# This program is free software; you can redistribute it and/or modify
12832 +# it under the terms of the GNU General Public License as published by
12833 +# the Free Software Foundation; either version 3 of the License, or
12834 +# (at your option) any later version.
12835 +#
12836 +# This program is distributed in the hope that it will be useful,
12837 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12838 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12839 +# GNU General Public License for more details.
12840 +#
12841 +# You should have received a copy of the GNU General Public License
12842 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
12843 +
12844 +load_lib mi-support.exp
12845 +set MIFLAGS "-i=mi2"
12846 +
12847 +gdb_exit
12848 +if [mi_gdb_start] {
12849 +    continue
12850 +}
12851 +
12852 +set testfile "mi2-var-stale-type"
12853 +set srcfile ${testfile}.c
12854 +set binfile ${objdir}/${subdir}/${testfile}
12855 +if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
12856 +    return -1
12857 +}
12858 +
12859 +mi_delete_breakpoints
12860 +mi_gdb_reinitialize_dir $srcdir/$subdir
12861 +mi_gdb_load ${binfile}
12862 +
12863 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
12864 +  {\^done} \
12865 +  "maintenance set internal-error quit yes"
12866 +
12867 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
12868 +  {\^done} \
12869 +  "maintenance set internal-error corefile yes"
12870 +
12871 +set line [gdb_get_line_number "break-here"]
12872 +set func "main"
12873 +
12874 +mi_gdb_test "-break-insert -t $srcfile:$line" \
12875 +  "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",line=\"$line\",times=\"0\",original-location=\".*\"\}" \
12876 +  "breakpoint at $func"
12877 +
12878 +if { [mi_run_cmd] < 0 } {
12879 +    return -1
12880 +}
12881 +mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
12882 +
12883 +mi_create_varobj "vla" "vla" "create local variable vla"
12884 +
12885 +mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
12886 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.c
12887 ===================================================================
12888 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12889 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.c      2011-07-03 10:33:11.000000000 +0200
12890 @@ -0,0 +1,59 @@
12891 +/* This testcase is part of GDB, the GNU debugger.
12892 +
12893 +   Copyright 2010 Free Software Foundation, Inc.
12894 +
12895 +   This program is free software; you can redistribute it and/or modify
12896 +   it under the terms of the GNU General Public License as published by
12897 +   the Free Software Foundation; either version 3 of the License, or
12898 +   (at your option) any later version.
12899 +
12900 +   This program is distributed in the hope that it will be useful,
12901 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
12902 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12903 +   GNU General Public License for more details.
12904 +
12905 +   You should have received a copy of the GNU General Public License
12906 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
12907 +
12908 +#include <pthread.h>
12909 +#include <assert.h>
12910 +
12911 +static volatile int a, b, c;
12912 +
12913 +static void
12914 +marker_exit1 (void)
12915 +{
12916 +  a = 1;
12917 +}
12918 +
12919 +/* Workaround PR breakpoints/12272 by two different breakpoint locations.  */
12920 +static void
12921 +marker_exit2 (void)
12922 +{
12923 +  a = 1;
12924 +}
12925 +
12926 +static void *
12927 +start (void *arg)
12928 +{
12929 +  b = 2;
12930 +  c = 3;
12931 +
12932 +  return NULL;
12933 +}
12934 +
12935 +int
12936 +main (void)
12937 +{
12938 +  pthread_t thread;
12939 +  int i;
12940 +
12941 +  i = pthread_create (&thread, NULL, start, NULL);
12942 +  assert (i == 0);
12943 +  i = pthread_join (thread, NULL);
12944 +  assert (i == 0);
12945 +
12946 +  marker_exit1 ();
12947 +  marker_exit2 ();
12948 +  return 0;
12949 +}
12950 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.exp
12951 ===================================================================
12952 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
12953 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.multi/watchpoint-multi.exp    2011-07-03 10:33:11.000000000 +0200
12954 @@ -0,0 +1,113 @@
12955 +# Copyright 2010 Free Software Foundation, Inc.
12956 +
12957 +# This program is free software; you can redistribute it and/or modify
12958 +# it under the terms of the GNU General Public License as published by
12959 +# the Free Software Foundation; either version 3 of the License, or
12960 +# (at your option) any later version.
12961 +#
12962 +# This program is distributed in the hope that it will be useful,
12963 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
12964 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12965 +# GNU General Public License for more details.
12966 +#
12967 +# You should have received a copy of the GNU General Public License
12968 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
12969 +
12970 +if { [is_remote target] || ![isnative] } then {
12971 +    continue
12972 +}
12973 +
12974 +set testfile "watchpoint-multi"
12975 +
12976 +set executable ${testfile}
12977 +set srcfile ${testfile}.c
12978 +set binfile ${objdir}/${subdir}/${executable}
12979 +
12980 +if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
12981 +    untested ${testfile}.exp
12982 +    return -1
12983 +}
12984 +
12985 +clean_restart $executable
12986 +
12987 +if ![runto_main] {
12988 +    return
12989 +}
12990 +# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug.
12991 +delete_breakpoints
12992 +
12993 +gdb_test "add-inferior" "Added inferior 2"
12994 +gdb_test "inferior 2" "witching to inferior 2 .*"
12995 +gdb_load $binfile
12996 +
12997 +if ![runto_main] {
12998 +    return
12999 +}
13000 +delete_breakpoints
13001 +
13002 +# Simulate non-stop+target-async which also uses breakpoint always-inserted.
13003 +gdb_test_no_output "set breakpoint always-inserted on"
13004 +# displaced-stepping is also needed as other GDB sometimes still removes the
13005 +# breakpoints, even with always-inserted on.
13006 +gdb_test_no_output "set displaced-stepping on"
13007 +
13008 +# Debugging of this testcase:
13009 +#gdb_test_no_output "maintenance set show-debug-regs on"
13010 +#gdb_test_no_output "set debug infrun 1"
13011 +
13012 +# Do not use simple hardware watchpoint ("watch") as its false hit may be
13013 +# unnoticed by GDB if it reads it still has the same value.
13014 +gdb_test "awatch c" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c"
13015 +# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug.
13016 +# Use `*' to workaround a multi-inferior bug.
13017 +set test "hbreak *marker_exit2"
13018 +gdb_test_multiple $test $test {
13019 +    -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
13020 +       pass $test
13021 +    }
13022 +    -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
13023 +       pass $test
13024 +       untested ${testfile}.exp
13025 +       return
13026 +    }
13027 +}
13028 +
13029 +gdb_test "inferior 1" "witching to inferior 1 .*"
13030 +
13031 +gdb_test "awatch b" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b"
13032 +gdb_test "hbreak *marker_exit1" {Hardware assisted breakpoint [0-9]+ at .*}
13033 +
13034 +gdb_test "inferior 2" "witching to inferior 2 .*"
13035 +
13036 +# FAIL would be a hit on watchpoint for `b' - that one is for the other
13037 +# inferior.
13038 +gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nOld value = 0\r\nNew value = 3\r\n.*" "catch c"
13039 +
13040 +set test "catch marker_exit2"
13041 +gdb_test_multiple "continue" $test {
13042 +    -re "Breakpoint \[0-9\]+, marker_exit2 .*\r\n$gdb_prompt $" {
13043 +       setup_kfail breakpoints/12312 *-*-*
13044 +       pass $test
13045 +    }
13046 +    -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: c\r\n\r\nValue = 3\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" {
13047 +       setup_kfail breakpoints/12312 *-*-*
13048 +       fail $test
13049 +    }
13050 +}
13051 +
13052 +gdb_test "inferior 1" "witching to inferior 1 .*"
13053 +
13054 +gdb_test "continue" "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nOld value = 0\r\nNew value = 2\r\n.*" "catch b"
13055 +
13056 +set test "catch marker_exit1"
13057 +gdb_test_multiple "continue" $test {
13058 +    -re "Breakpoint \[0-9\]+, marker_exit1 .*\r\n$gdb_prompt $" {
13059 +       setup_kfail breakpoints/12312 *-*-*
13060 +       pass $test
13061 +    }
13062 +    -re "Hardware access \\(read/write\\) watchpoint \[0-9\]+: b\r\n\r\nValue = 2\r\n(.* in )?\\*?(__GI_)?__nptl_death_event .*\r\n$gdb_prompt $" {
13063 +       setup_kfail breakpoints/12312 *-*-*
13064 +       fail $test
13065 +    }
13066 +}
13067 +
13068 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register-func.c
13069 ===================================================================
13070 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13071 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register-func.c        2011-07-03 10:33:11.000000000 +0200
13072 @@ -0,0 +1,22 @@
13073 +/* This file is part of GDB, the GNU debugger.
13074 +
13075 +   Copyright 2009 Free Software Foundation, Inc.
13076 +
13077 +   This program is free software; you can redistribute it and/or modify
13078 +   it under the terms of the GNU General Public License as published by
13079 +   the Free Software Foundation; either version 3 of the License, or
13080 +   (at your option) any later version.
13081 +
13082 +   This program is distributed in the hope that it will be useful,
13083 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13084 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13085 +   GNU General Public License for more details.
13086 +
13087 +   You should have received a copy of the GNU General Public License
13088 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
13089 +
13090 +int
13091 +func (int *arr)
13092 +{
13093 +  return arr[0];
13094 +}
13095 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.c
13096 ===================================================================
13097 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13098 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.c     2011-07-03 10:33:11.000000000 +0200
13099 @@ -0,0 +1,28 @@
13100 +/* This file is part of GDB, the GNU debugger.
13101 +
13102 +   Copyright 2009 Free Software Foundation, Inc.
13103 +
13104 +   This program is free software; you can redistribute it and/or modify
13105 +   it under the terms of the GNU General Public License as published by
13106 +   the Free Software Foundation; either version 3 of the License, or
13107 +   (at your option) any later version.
13108 +
13109 +   This program is distributed in the hope that it will be useful,
13110 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13111 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13112 +   GNU General Public License for more details.
13113 +
13114 +   You should have received a copy of the GNU General Public License
13115 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
13116 +
13117 +extern int func (int *arr);
13118 +
13119 +int
13120 +main (void)
13121 +{
13122 +  int arr[] = { 42 };
13123 +
13124 +  func (arr);
13125 +
13126 +  return 0;
13127 +}
13128 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.exp
13129 ===================================================================
13130 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13131 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.opt/array-from-register.exp   2011-07-03 10:33:11.000000000 +0200
13132 @@ -0,0 +1,33 @@
13133 +# Copyright 2009 Free Software Foundation, Inc.
13134 +#
13135 +# This program is free software; you can redistribute it and/or modify
13136 +# it under the terms of the GNU General Public License as published by
13137 +# the Free Software Foundation; either version 2 of the License, or
13138 +# (at your option) any later version.
13139 +#
13140 +# This program is distributed in the hope that it will be useful,
13141 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
13142 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13143 +# GNU General Public License for more details.
13144 +#
13145 +# You should have received a copy of the GNU General Public License
13146 +# along with this program; if not, write to the Free Software
13147 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13148 +#
13149 +# This file is part of the gdb testsuite.
13150 +
13151 +if { [prepare_for_testing array-from-register.exp "array-from-register"      \
13152 +                         {array-from-register.c array-from-register-func.c} \
13153 +                         {debug optimize=-O2}] } {
13154 +    return -1
13155 +}
13156 +
13157 +if ![runto func] then {
13158 +    return -1
13159 +}
13160 +
13161 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
13162 +
13163 +# Seen regression:
13164 +# Address requested for identifier "arr" which is in register $rdi
13165 +gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
13166 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.exp
13167 ===================================================================
13168 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13169 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.exp     2011-07-03 10:33:11.000000000 +0200
13170 @@ -0,0 +1,104 @@
13171 +# Copyright 2008, 2009 Free Software Foundation, Inc.
13172 +#
13173 +# This program is free software; you can redistribute it and/or modify
13174 +# it under the terms of the GNU General Public License as published by
13175 +# the Free Software Foundation; either version 3 of the License, or
13176 +# (at your option) any later version.
13177 +#
13178 +# This program is distributed in the hope that it will be useful,
13179 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
13180 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13181 +# GNU General Public License for more details.
13182 +#
13183 +# You should have received a copy of the GNU General Public License
13184 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13185 +
13186 +if $tracelevel then {
13187 +    strace $tracelevel
13188 +}
13189 +
13190 +load_lib "pascal.exp"
13191 +
13192 +set testfile "arrays"
13193 +set srcfile ${testfile}.pas
13194 +set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
13195 +
13196 +# These tests only work with fpc, using the -gw3 compile-option
13197 +pascal_init
13198 +if { $pascal_compiler_is_fpc != 1 } {
13199 +  return -1
13200 +}
13201 +
13202 +# Detect if the fpc version is below 2.3.0
13203 +set fpc_generates_dwarf_for_dynamic_arrays 1
13204 +if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))}  {
13205 +  set fpc_generates_dwarf_for_dynamic_arrays 0
13206 +}
13207 +
13208 +
13209 +if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
13210 +  return -1
13211 +}
13212 +
13213 +gdb_exit
13214 +gdb_start
13215 +gdb_reinitialize_dir $srcdir/$subdir
13216 +gdb_load ${binfile}
13217 +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
13218 +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
13219 +
13220 +
13221 +if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
13222 +    pass "setting breakpoint 1"
13223 +}
13224 +if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
13225 +    pass "setting breakpoint 2"
13226 +}
13227 +
13228 +# Verify that "start" lands inside the right procedure.
13229 +if { [gdb_start_cmd] < 0 } {
13230 +    untested start
13231 +    return -1
13232 +}
13233 +
13234 +gdb_test "" ".* at .*${srcfile}.*" "start"
13235 +
13236 +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
13237 +
13238 +gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
13239 +gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
13240 +
13241 +gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
13242 +
13243 +gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
13244 +gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer"
13245 +
13246 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13247 +  setup_xfail "*-*-*"
13248 +}
13249 +gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
13250 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13251 +  setup_xfail "*-*-*"
13252 +}
13253 +gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
13254 +
13255 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13256 +  setup_xfail "*-*-*"
13257 +}
13258 +gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
13259 +
13260 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13261 +  setup_xfail "*-*-*"
13262 +}
13263 +gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
13264 +
13265 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13266 +  setup_xfail "*-*-*"
13267 +}
13268 +gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
13269 +
13270 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13271 +  setup_xfail "*-*-*"
13272 +}
13273 +gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
13274 +
13275 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.pas
13276 ===================================================================
13277 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13278 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.pascal/arrays.pas     2011-07-03 10:33:11.000000000 +0200
13279 @@ -0,0 +1,82 @@
13280 +{
13281 + Copyright 2008, 2009 Free Software Foundation, Inc.
13282 +
13283 + This program is free software; you can redistribute it and/or modify
13284 + it under the terms of the GNU General Public License as published by
13285 + the Free Software Foundation; either version 3 of the License, or
13286 + (at your option) any later version.
13287 +
13288 + This program is distributed in the hope that it will be useful,
13289 + but WITHOUT ANY WARRANTY; without even the implied warranty of
13290 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13291 + GNU General Public License for more details.
13292 +
13293 + You should have received a copy of the GNU General Public License
13294 + along with this program.  If not, see <http://www.gnu.org/licenses/>.
13295 +}
13296 +
13297 +program arrays;
13298 +
13299 +{$mode objfpc}{$h+}
13300 +
13301 +uses sysutils;
13302 +
13303 +type TStatArrInt= array[0..11] of integer;
13304 +     TDynArrInt= array of integer;
13305 +     TStatArrStr= array[0..12] of string;
13306 +     TDynArrStr= array of string;
13307 +     TDynArrChar = array of char;
13308 +     TStatArrChar = array [0..11] of char;
13309 +
13310 +     TStat2dArrInt = array[0..11,0..4] of integer;
13311 +
13312 +var StatArrInt: TStatArrInt;
13313 +    StatArrInt_: Array[0..11] of integer;
13314 +    DynArrInt:  TDynArrInt;
13315 +    DynArrInt_: Array of integer;
13316 +    StatArrStr: TStatArrStr;
13317 +    DynArrStr: TDynArrStr;
13318 +    StatArrChar: TStatArrChar;
13319 +    DynArrChar: TDynArrChar;
13320 +
13321 +    Stat2dArrInt: TStat2dArrInt;
13322 +
13323 +    s: string;
13324 +       
13325 +    i,j : integer;
13326 +
13327 +begin
13328 +  for i := 0 to 11 do
13329 +    begin
13330 +    StatArrInt[i]:= i+50;
13331 +    StatArrInt_[i]:= i+50;
13332 +    StatArrChar[i]:= chr(ord('a')+i);
13333 +    for j := 0 to 4 do
13334 +      Stat2dArrInt[i,j]:=i+j;
13335 +    end;
13336 +  writeln(StatArrInt_[0]);
13337 +  writeln(StatArrInt[0]); { set breakpoint 1 here }
13338 +  writeln(StatArrChar[0]);
13339 +  writeln(Stat2dArrInt[0,0]);
13340 +
13341 +  setlength(DynArrInt,13);
13342 +  setlength(DynArrInt_,13);
13343 +  setlength(DynArrStr,13);
13344 +  setlength(DynArrChar,13);
13345 +  for i := 0 to 12 do
13346 +    begin
13347 +    DynArrInt[i]:= i+50;
13348 +    DynArrInt_[i]:= i+50;
13349 +    DynArrChar[i]:= chr(ord('a')+i);
13350 +    StatArrStr[i]:='str'+inttostr(i);
13351 +    DynArrStr[i]:='dstr'+inttostr(i);
13352 +    end;
13353 +  writeln(DynArrInt_[1]);
13354 +  writeln(DynArrInt[1]); 
13355 +  writeln(DynArrStr[1]); 
13356 +  writeln(StatArrStr[1]);
13357 +  writeln(DynArrChar[1]);
13358 +
13359 +  s := 'test'#0'string';
13360 +  writeln(s); { set breakpoint 2 here }
13361 +end.
13362 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-frame.exp
13363 ===================================================================
13364 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.python/py-frame.exp      2011-02-26 15:06:28.000000000 +0100
13365 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-frame.exp   2011-07-03 10:33:11.000000000 +0200
13366 @@ -78,8 +78,6 @@ gdb_test "python print bframe == gdb.new
13367  
13368  gdb_test "python print 'result =', f0 == f1" " = False" "test equality comparison (false)"
13369  gdb_test "python print 'result =', f0 == f0" " = True" "test equality comparison (true)"
13370 -gdb_test "python print 'result =', f0 != f1" " = True" "test inequality comparison (true)"
13371 -gdb_test "python print 'result =', f0 != f0" " = False" "test inequality comparison (false)"
13372  gdb_test "python print 'result =', f0.is_valid ()" " = True" "test Frame.is_valid"
13373  gdb_test "python print 'result =', f0.name ()" " = f2" "test Frame.name"
13374  gdb_test "python print 'result =', f0.type () == gdb.NORMAL_FRAME" " = True" "test Frame.type"
13375 @@ -94,3 +92,5 @@ gdb_test "python print 'result =', f0.re
13376  gdb_test "python print 'result =', f0.read_var ('a')" " = 1" "test Frame.read_var - success"
13377  
13378  gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame"
13379 +
13380 +gdb_test "python print 'result =', f0.block ()" "<gdb.Block object at 0x\[\[:xdigit:\]\]+>" "test Frame.block"
13381 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-value.exp
13382 ===================================================================
13383 --- gdb-7.2.90.20110703.orig/gdb/testsuite/gdb.python/py-value.exp      2011-01-01 16:33:49.000000000 +0100
13384 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.python/py-value.exp   2011-07-03 10:33:11.000000000 +0200
13385 @@ -318,6 +318,15 @@ proc test_value_after_death {} {
13386      "print value's type"
13387  }
13388  
13389 +# Regression test for a cast failure.  The bug was that if we cast a
13390 +# value to its own type, gdb could crash.  This happened because we
13391 +# could end up double-freeing a struct value.
13392 +proc test_cast_regression {} {
13393 +  gdb_test "python v = gdb.Value(5)" "" "create value for cast test"
13394 +  gdb_test "python v = v.cast(v.type)" "" "cast value for cast test"
13395 +  gdb_test "python print v" "5" "print value for cast test"
13396 +}
13397 +
13398  # Regression test for invalid subscript operations.  The bug was that
13399  # the type of the value was not being checked before allowing a
13400  # subscript operation to proceed.
13401 @@ -455,6 +464,7 @@ test_value_in_inferior
13402  test_inferior_function_call
13403  test_lazy_strings
13404  test_value_after_death
13405 +test_cast_regression
13406  
13407  # The following test recompiles the binary to test either C or C++
13408  # values. 
13409 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-child.c
13410 ===================================================================
13411 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13412 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-child.c       2011-07-03 10:33:11.000000000 +0200
13413 @@ -0,0 +1,127 @@
13414 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13415 +
13416 +   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13417 +
13418 +   This file is part of GDB.
13419 +
13420 +   This program is free software; you can redistribute it and/or modify
13421 +   it under the terms of the GNU General Public License as published by
13422 +   the Free Software Foundation; either version 2 of the License, or
13423 +   (at your option) any later version.
13424 +
13425 +   This program is distributed in the hope that it will be useful,
13426 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13427 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13428 +   GNU General Public License for more details.
13429 +
13430 +   You should have received a copy of the GNU General Public License
13431 +   along with this program; if not, write to the Free Software
13432 +   Foundation, Inc., 59 Temple Place - Suite 330,
13433 +   Boston, MA 02111-1307, USA.  */
13434 +
13435 +#include <string.h>
13436 +#include <errno.h>
13437 +#include <unistd.h>
13438 +#include <assert.h>
13439 +#include <signal.h>
13440 +#include <stdio.h>
13441 +
13442 +#include "watchpoint-fork.h"
13443 +
13444 +static volatile int usr1_got;
13445 +
13446 +static void
13447 +handler_usr1 (int signo)
13448 +{
13449 +  usr1_got++;
13450 +}
13451 +
13452 +void
13453 +forkoff (int nr)
13454 +{
13455 +  pid_t child, save_parent = getpid ();
13456 +  int i;
13457 +  struct sigaction act, oldact;
13458 +#ifdef THREAD
13459 +  void *thread_result;
13460 +#endif
13461 +
13462 +  memset (&act, 0, sizeof act);
13463 +  act.sa_flags = SA_RESTART;
13464 +  act.sa_handler = handler_usr1;
13465 +  sigemptyset (&act.sa_mask);
13466 +  i = sigaction (SIGUSR1, &act, &oldact);
13467 +  assert (i == 0);
13468 +
13469 +  child = fork ();
13470 +  switch (child)
13471 +    {
13472 +    case -1:
13473 +      assert (0);
13474 +    default:
13475 +      printf ("parent%d: %d\n", nr, (int) child);
13476 +
13477 +      /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB
13478 +        tracing the child fork with no longer valid thread/lwp entries of the
13479 +        parent.  */
13480 +
13481 +      i = sleep (2);
13482 +      assert (i == 0);
13483 +
13484 +      /* We must not get caught here (against a forgotten breakpoint).  */
13485 +
13486 +      var++;
13487 +      marker ();
13488 +
13489 +#ifdef THREAD
13490 +      /* And neither got caught our thread.  */
13491 +
13492 +      step = 99;
13493 +      i = pthread_join (thread, &thread_result);
13494 +      assert (i == 0);
13495 +      assert (thread_result == (void *) 99UL);
13496 +#endif
13497 +
13498 +      /* Be sure our child knows we did not get caught above.  */
13499 +
13500 +      i = kill (child, SIGUSR1);
13501 +      assert (i == 0);
13502 +
13503 +      /* Sleep for a while to check GDB's `info threads' no longer tracks us in
13504 +        the child fork.  */
13505 +
13506 +      i = sleep (2);
13507 +      assert (i == 0);
13508 +
13509 +      _exit (0);
13510 +    case 0:
13511 +      printf ("child%d: %d\n", nr, (int) getpid ());
13512 +
13513 +      /* Let the parent signal us about its success.  Be careful of races.  */
13514 +
13515 +      for (;;)
13516 +       {
13517 +         /* Parent either died (and USR1_GOT is zero) or it succeeded.  */
13518 +         if (getppid () != save_parent)
13519 +           break;
13520 +         if (kill (getppid (), 0) != 0)
13521 +           break;
13522 +         /* Parent succeeded?  */
13523 +         if (usr1_got)
13524 +           break;
13525 +
13526 +#ifdef THREAD
13527 +         i = pthread_yield ();
13528 +         assert (i == 0);
13529 +#endif
13530 +       }
13531 +      assert (usr1_got);
13532 +
13533 +      /* We must get caught here (against a false watchpoint removal).  */
13534 +
13535 +      marker ();
13536 +    }
13537 +
13538 +  i = sigaction (SIGUSR1, &oldact, NULL);
13539 +  assert (i == 0);
13540 +}
13541 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
13542 ===================================================================
13543 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13544 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c  2011-07-03 10:33:11.000000000 +0200
13545 @@ -0,0 +1,174 @@
13546 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13547 +
13548 +   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13549 +
13550 +   This file is part of GDB.
13551 +
13552 +   This program is free software; you can redistribute it and/or modify
13553 +   it under the terms of the GNU General Public License as published by
13554 +   the Free Software Foundation; either version 2 of the License, or
13555 +   (at your option) any later version.
13556 +
13557 +   This program is distributed in the hope that it will be useful,
13558 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13559 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13560 +   GNU General Public License for more details.
13561 +
13562 +   You should have received a copy of the GNU General Public License
13563 +   along with this program; if not, write to the Free Software
13564 +   Foundation, Inc., 59 Temple Place - Suite 330,
13565 +   Boston, MA 02111-1307, USA.  */
13566 +
13567 +#include <assert.h>
13568 +#include <unistd.h>
13569 +#include <sys/wait.h>
13570 +#include <stdio.h>
13571 +#include <stdlib.h>
13572 +#include <pthread.h>
13573 +
13574 +#include <asm/unistd.h>
13575 +#include <unistd.h>
13576 +#define gettid() syscall (__NR_gettid)
13577 +
13578 +#include "watchpoint-fork.h"
13579 +
13580 +/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
13581 +   variable.  Hit-comments need to be duplicite there to catch both at-stops
13582 +   and behind-stops, depending on the target.  */
13583 +
13584 +volatile int var;
13585 +
13586 +void
13587 +marker (void)
13588 +{
13589 +}
13590 +
13591 +static void
13592 +empty (void)
13593 +{
13594 +}
13595 +
13596 +static void
13597 +mark_exit (void)
13598 +{
13599 +}
13600 +
13601 +pthread_t thread;
13602 +volatile int step;
13603 +
13604 +static void *
13605 +start (void *arg)
13606 +{
13607 +  int i;
13608 +
13609 +  if (step >= 3)
13610 +    goto step_3;
13611 +
13612 +  while (step != 1)
13613 +    {
13614 +      i = pthread_yield ();
13615 +      assert (i == 0);
13616 +    }
13617 +
13618 +  var++;       /* validity-thread-B */
13619 +  empty ();    /* validity-thread-B */
13620 +  step = 2;
13621 +  while (step != 3)
13622 +    {
13623 +      if (step == 99)
13624 +       goto step_99;
13625 +
13626 +      i = pthread_yield ();
13627 +      assert (i == 0);
13628 +    }
13629 +
13630 +step_3:
13631 +  if (step >= 5)
13632 +    goto step_5;
13633 +
13634 +  var++;       /* after-fork1-B */
13635 +  empty ();    /* after-fork1-B */
13636 +  step = 4;
13637 +  while (step != 5)
13638 +    {
13639 +      if (step == 99)
13640 +       goto step_99;
13641 +
13642 +      i = pthread_yield ();
13643 +      assert (i == 0);
13644 +    }
13645 +
13646 +step_5:
13647 +  var++;       /* after-fork2-B */
13648 +  empty ();    /* after-fork2-B */
13649 +  return (void *) 5UL;
13650 +
13651 +step_99:
13652 +  /* We must not get caught here (against a forgotten breakpoint).  */
13653 +  var++;
13654 +  marker ();
13655 +  return (void *) 99UL;
13656 +}
13657 +
13658 +int
13659 +main (void)
13660 +{
13661 +  int i;
13662 +  void *thread_result;
13663 +
13664 +  setbuf (stdout, NULL);
13665 +  printf ("main: %d\n", (int) gettid ());
13666 +
13667 +  /* General hardware breakpoints and watchpoints validity.  */
13668 +  marker ();
13669 +  var++;       /* validity-first */
13670 +  empty ();    /* validity-first */
13671 +
13672 +  i = pthread_create (&thread, NULL, start, NULL);
13673 +  assert (i == 0);
13674 +
13675 +  var++;       /* validity-thread-A */
13676 +  empty ();    /* validity-thread-A */
13677 +  step = 1;
13678 +  while (step != 2)
13679 +    {
13680 +      i = pthread_yield ();
13681 +      assert (i == 0);
13682 +    }
13683 +
13684 +  /* Hardware watchpoints got disarmed here.  */
13685 +  forkoff (1);
13686 +
13687 +  var++;       /* after-fork1-A */
13688 +  empty ();    /* after-fork1-A */
13689 +  step = 3;
13690 +#ifdef FOLLOW_CHILD
13691 +  /* Spawn new thread as it was deleted in the child of FORK.  */
13692 +  i = pthread_create (&thread, NULL, start, NULL);
13693 +  assert (i == 0);
13694 +#endif
13695 +  while (step != 4)
13696 +    {
13697 +      i = pthread_yield ();
13698 +      assert (i == 0);
13699 +    }
13700 +
13701 +  /* A sanity check for double hardware watchpoints removal.  */
13702 +  forkoff (2);
13703 +
13704 +  var++;       /* after-fork2-A */
13705 +  empty ();    /* after-fork2-A */
13706 +  step = 5;
13707 +#ifdef FOLLOW_CHILD
13708 +  /* Spawn new thread as it was deleted in the child of FORK.  */
13709 +  i = pthread_create (&thread, NULL, start, NULL);
13710 +  assert (i == 0);
13711 +#endif
13712 +
13713 +  i = pthread_join (thread, &thread_result);
13714 +  assert (i == 0);
13715 +  assert (thread_result == (void *) 5UL);
13716 +
13717 +  mark_exit ();
13718 +  return 0;
13719 +}
13720 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c
13721 ===================================================================
13722 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13723 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-parent.c      2011-07-03 10:33:11.000000000 +0200
13724 @@ -0,0 +1,74 @@
13725 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13726 +
13727 +   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13728 +
13729 +   This file is part of GDB.
13730 +
13731 +   This program is free software; you can redistribute it and/or modify
13732 +   it under the terms of the GNU General Public License as published by
13733 +   the Free Software Foundation; either version 2 of the License, or
13734 +   (at your option) any later version.
13735 +
13736 +   This program is distributed in the hope that it will be useful,
13737 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13738 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13739 +   GNU General Public License for more details.
13740 +
13741 +   You should have received a copy of the GNU General Public License
13742 +   along with this program; if not, write to the Free Software
13743 +   Foundation, Inc., 59 Temple Place - Suite 330,
13744 +   Boston, MA 02111-1307, USA.  */
13745 +
13746 +#include <string.h>
13747 +#include <errno.h>
13748 +#include <sys/types.h>
13749 +#include <unistd.h>
13750 +#include <assert.h>
13751 +#include <stdio.h>
13752 +#include <sys/wait.h>
13753 +
13754 +#include "watchpoint-fork.h"
13755 +
13756 +void
13757 +forkoff (int nr)
13758 +{
13759 +  pid_t child, pid_got;
13760 +  int exit_code = 42 + nr;
13761 +  int status, i;
13762 +
13763 +  child = fork ();
13764 +  switch (child)
13765 +    {
13766 +    case -1:
13767 +      assert (0);
13768 +    case 0:
13769 +      printf ("child%d: %d\n", nr, (int) getpid ());
13770 +      /* Delay to get both the "child%d" and "parent%d" message printed without
13771 +        a race breaking expect by its endless wait on `$gdb_prompt$':
13772 +        Breakpoint 3, marker () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33
13773 +        33      }
13774 +        (gdb) parent2: 14223  */
13775 +      i = sleep (1);
13776 +      assert (i == 0);
13777 +
13778 +      /* We must not get caught here (against a forgotten breakpoint).  */
13779 +      var++;
13780 +      marker ();
13781 +
13782 +      _exit (exit_code);
13783 +    default:
13784 +      printf ("parent%d: %d\n", nr, (int) child);
13785 +      /* Delay to get both the "child%d" and "parent%d" message printed, see
13786 +        above.  */
13787 +      i = sleep (1);
13788 +      assert (i == 0);
13789 +
13790 +      pid_got = wait (&status);
13791 +      assert (pid_got == child);
13792 +      assert (WIFEXITED (status));
13793 +      assert (WEXITSTATUS (status) == exit_code);
13794 +
13795 +      /* We must get caught here (against a false watchpoint removal).  */
13796 +      marker ();
13797 +    }
13798 +}
13799 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-st.c
13800 ===================================================================
13801 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13802 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork-st.c  2011-07-03 10:33:11.000000000 +0200
13803 @@ -0,0 +1,61 @@
13804 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13805 +
13806 +   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13807 +
13808 +   This file is part of GDB.
13809 +
13810 +   This program is free software; you can redistribute it and/or modify
13811 +   it under the terms of the GNU General Public License as published by
13812 +   the Free Software Foundation; either version 2 of the License, or
13813 +   (at your option) any later version.
13814 +
13815 +   This program is distributed in the hope that it will be useful,
13816 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
13817 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13818 +   GNU General Public License for more details.
13819 +
13820 +   You should have received a copy of the GNU General Public License
13821 +   along with this program; if not, write to the Free Software
13822 +   Foundation, Inc., 59 Temple Place - Suite 330,
13823 +   Boston, MA 02111-1307, USA.  */
13824 +
13825 +#include <assert.h>
13826 +#include <unistd.h>
13827 +#include <sys/wait.h>
13828 +#include <stdio.h>
13829 +#include <stdlib.h>
13830 +
13831 +#include "watchpoint-fork.h"
13832 +
13833 +volatile int var;
13834 +
13835 +void
13836 +marker (void)
13837 +{
13838 +}
13839 +
13840 +static void
13841 +mark_exit (void)
13842 +{
13843 +}
13844 +
13845 +int
13846 +main (void)
13847 +{
13848 +  setbuf (stdout, NULL);
13849 +  printf ("main: %d\n", (int) getpid ());
13850 +
13851 +  /* General hardware breakpoints and watchpoints validity.  */
13852 +  marker ();
13853 +  var++;
13854 +  /* Hardware watchpoints got disarmed here.  */
13855 +  forkoff (1);
13856 +  /* This watchpoint got lost before.  */
13857 +  var++;
13858 +  /* A sanity check for double hardware watchpoints removal.  */
13859 +  forkoff (2);
13860 +  var++;
13861 +
13862 +  mark_exit ();
13863 +  return 0;
13864 +}
13865 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.exp
13866 ===================================================================
13867 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
13868 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.exp   2011-07-03 10:33:11.000000000 +0200
13869 @@ -0,0 +1,149 @@
13870 +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13871 +
13872 +# This program is free software; you can redistribute it and/or modify
13873 +# it under the terms of the GNU General Public License as published by
13874 +# the Free Software Foundation; either version 3 of the License, or
13875 +# (at your option) any later version.
13876 +#
13877 +# This program is distributed in the hope that it will be useful,
13878 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
13879 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13880 +# GNU General Public License for more details.
13881 +#
13882 +# You should have received a copy of the GNU General Public License
13883 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
13884 +
13885 +# Test case for forgotten hw-watchpoints after fork()-off of a process.
13886 +
13887 +proc test {type symbol} {
13888 +    global objdir subdir srcdir gdb_prompt
13889 +
13890 +    set testfile watchpoint-fork
13891 +
13892 +    global pf_prefix
13893 +    set prefix_test $pf_prefix
13894 +    lappend pf_prefix "$type:"
13895 +    set prefix_mt $pf_prefix
13896 +
13897 +    set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c
13898 +
13899 +
13900 +    # no threads
13901 +
13902 +    set pf_prefix $prefix_mt
13903 +    lappend pf_prefix "singlethreaded:"
13904 +
13905 +    set executable ${testfile}-${type}-st
13906 +    set srcfile_main ${srcdir}/${subdir}/${testfile}-st.c
13907 +    if { [gdb_compile "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
13908 +       untested ${testfile}.exp
13909 +       return
13910 +    }
13911 +    clean_restart $executable
13912 +
13913 +    gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on\\."
13914 +    gdb_test_no_output "set follow-fork-mode $type"
13915 +    gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"\\."
13916 +    # Testcase uses it for the `follow-fork-mode child' type.
13917 +    gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
13918 +
13919 +    if ![runto_main] {
13920 +       return
13921 +    }
13922 +
13923 +    gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
13924 +
13925 +    # It is never hit but it should not be left over in the fork()ed-off child.
13926 +    set hbreak "hbreak"
13927 +    set test "hbreak marker"
13928 +    gdb_test_multiple $test $test {
13929 +       -re "Hardware assisted breakpoint \[0-9\]+ at .*\r\n$gdb_prompt $" {
13930 +           pass $test
13931 +       }
13932 +       -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
13933 +           pass $test
13934 +           set hbreak "break"
13935 +           gdb_test "break marker"
13936 +       }
13937 +    }
13938 +
13939 +    gdb_breakpoint "mark_exit"
13940 +
13941 +    gdb_test "continue" \
13942 +            "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work"
13943 +    gdb_test "continue" \
13944 +            "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work"
13945 +    gdb_test "continue" \
13946 +            "reakpoint \[0-9\]+, marker.*" "breakpoint after the first fork"
13947 +    gdb_test "continue" \
13948 +            "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork"
13949 +    gdb_test "continue" \
13950 +            "reakpoint \[0-9\]+, marker.*" "breakpoint after the second fork"
13951 +    gdb_test "continue" \
13952 +            "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*mark_exit \\(\\);" "watchpoint after the second fork"
13953 +    gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish"
13954 +
13955 +
13956 +    # threads
13957 +
13958 +    set pf_prefix $prefix_mt
13959 +    lappend pf_prefix "multithreaded:"
13960 +
13961 +    set executable ${testfile}-${type}-mt
13962 +    set srcfile_main ${srcdir}/${subdir}/${testfile}-mt.c
13963 +    if { [gdb_compile_pthreads "${srcfile_main} ${srcfile_type}" ${objdir}/${subdir}/${executable} executable [list debug "additional_flags=-D$symbol -DTHREAD"]] != "" } {
13964 +       untested ${testfile}.exp
13965 +       return
13966 +    }
13967 +    clean_restart $executable
13968 +
13969 +    gdb_test_no_output "set follow-fork-mode $type"
13970 +    # Testcase uses it for the `follow-fork-mode child' type.
13971 +    gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
13972 +
13973 +    if ![runto_main] {
13974 +       return
13975 +    }
13976 +
13977 +    gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
13978 +
13979 +    # It should not be left over in the fork()ed-off child.
13980 +    gdb_test "$hbreak marker" {reakpoint [0-9]+.*}
13981 +
13982 +    gdb_breakpoint "mark_exit"
13983 +
13984 +    gdb_test "continue" \
13985 +            "reakpoint \[0-9\]+, marker.*" "hardware breakpoints work"
13986 +    gdb_test "continue" \
13987 +            "atchpoint \[0-9\]+: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work"
13988 +    gdb_test "continue" \
13989 +            "atchpoint \[0-9\]+: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A"
13990 +    gdb_test "continue" \
13991 +            "atchpoint \[0-9\]+: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B"
13992 +    gdb_test "continue" \
13993 +            "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the first fork"
13994 +    gdb_test "continue" \
13995 +            "atchpoint \[0-9\]+: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork"
13996 +    gdb_test "continue" \
13997 +            "atchpoint \[0-9\]+: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork"
13998 +    gdb_test "continue" \
13999 +            "reakpoint \[0-9\]+, marker.*" "breakpoint (A) after the second fork"
14000 +    gdb_test "continue" \
14001 +            "atchpoint \[0-9\]+: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork"
14002 +    gdb_test "continue" \
14003 +            "atchpoint \[0-9\]+: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork"
14004 +    gdb_test "continue" "Continuing\\..*\r\nBreakpoint \[0-9\]+, mark_exit .*" "finish"
14005 +
14006 +
14007 +    # cleanup
14008 +    set pf_prefix $prefix_test
14009 +}
14010 +
14011 +test parent FOLLOW_PARENT
14012 +
14013 +# Only GNU/Linux is known to support `set follow-fork-mode child'.
14014 +if {[istarget "*-*-linux*"] && ![is_remote target]} {
14015 +    test child FOLLOW_CHILD
14016 +} else {
14017 +    untested "child"
14018 +}
14019 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.h
14020 ===================================================================
14021 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
14022 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.threads/watchpoint-fork.h     2011-07-03 10:33:11.000000000 +0200
14023 @@ -0,0 +1,32 @@
14024 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
14025 +
14026 +   Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
14027 +
14028 +   This file is part of GDB.
14029 +
14030 +   This program is free software; you can redistribute it and/or modify
14031 +   it under the terms of the GNU General Public License as published by
14032 +   the Free Software Foundation; either version 2 of the License, or
14033 +   (at your option) any later version.
14034 +
14035 +   This program is distributed in the hope that it will be useful,
14036 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
14037 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14038 +   GNU General Public License for more details.
14039 +
14040 +   You should have received a copy of the GNU General Public License
14041 +   along with this program; if not, write to the Free Software
14042 +   Foundation, Inc., 59 Temple Place - Suite 330,
14043 +   Boston, MA 02111-1307, USA.  */
14044 +
14045 +#ifdef THREAD
14046 +#include <pthread.h>
14047 +
14048 +extern volatile int step;
14049 +extern pthread_t thread;
14050 +#endif /* THREAD */
14051 +
14052 +extern volatile int var;
14053 +
14054 +extern void marker (void);
14055 +extern void forkoff (int nr);
14056 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.c
14057 ===================================================================
14058 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
14059 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.c    2011-07-03 10:33:11.000000000 +0200
14060 @@ -0,0 +1,71 @@
14061 +/* This testcase is part of GDB, the GNU debugger.
14062 +
14063 +   Copyright 2011 Free Software Foundation, Inc.
14064 +
14065 +   This program is free software; you can redistribute it and/or modify
14066 +   it under the terms of the GNU General Public License as published by
14067 +   the Free Software Foundation; either version 3 of the License, or
14068 +   (at your option) any later version.
14069 +
14070 +   This program is distributed in the hope that it will be useful,
14071 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
14072 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14073 +   GNU General Public License for more details.
14074 +
14075 +   You should have received a copy of the GNU General Public License
14076 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
14077 +
14078 +#if USE_PROBES
14079 +
14080 +#define _SDT_HAS_SEMAPHORES
14081 +__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
14082 +#define TEST teste_user_semaphore
14083 +
14084 +__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
14085 +#define TEST2 teste_two_semaphore
14086 +
14087 +#else
14088 +
14089 +#define TEST 1
14090 +#define TEST2 1
14091 +
14092 +#endif /* USE_PROBES */
14093 +
14094 +#include <sys/sdt.h>
14095 +
14096 +/* We only support SystemTap and only the v3 form.  */
14097 +#if _SDT_NOTE_TYPE != 3
14098 +#error "not using SystemTap v3 probes"
14099 +#endif
14100 +
14101 +void
14102 +m1 (int x)
14103 +{
14104 +  if (TEST2)
14105 +    STAP_PROBE1 (teste, two, x);
14106 +}
14107 +
14108 +int
14109 +f (int x)
14110 +{
14111 +  if (TEST)
14112 +    STAP_PROBE1(teste, user, x);
14113 +  return x+5;
14114 +}
14115 +
14116 +void
14117 +nothing (void)
14118 +{
14119 +  int a = 1 + 1;
14120 +  return;
14121 +}
14122 +
14123 +int
14124 +main()
14125 +{
14126 +  f (f (23));
14127 +  m1 (46);
14128 +  nothing (); /* end-here */
14129 +
14130 +  return 0;
14131 +}
14132 Index: gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.exp
14133 ===================================================================
14134 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
14135 +++ gdb-7.2.90.20110703/gdb/testsuite/gdb.trace/stap-trace.exp  2011-07-03 10:33:11.000000000 +0200
14136 @@ -0,0 +1,129 @@
14137 +# Copyright 2011
14138 +# Free Software Foundation, Inc.
14139 +
14140 +# This program is free software; you can redistribute it and/or modify
14141 +# it under the terms of the GNU General Public License as published by
14142 +# the Free Software Foundation; either version 3 of the License, or
14143 +# (at your option) any later version.
14144 +#
14145 +# This program is distributed in the hope that it will be useful,
14146 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
14147 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14148 +# GNU General Public License for more details.
14149 +#
14150 +# You should have received a copy of the GNU General Public License
14151 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
14152 +
14153 +load_lib "trace-support.exp"
14154 +
14155 +if $tracelevel then {
14156 +       strace $tracelevel
14157 +}
14158 +
14159 +set testfile "stap-trace"
14160 +set srcfile ${testfile}.c
14161 +set executable $testfile
14162 +set binfile $objdir/$subdir/$executable
14163 +
14164 +set ws "\[\r\n\t \]+"
14165 +set cr "\[\r\n\]+"
14166 +
14167 +# Only x86 and x86_64 targets are supported for now.
14168 +
14169 +if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } {
14170 +    continue
14171 +}
14172 +
14173 +proc compile_stap_bin {{ arg "" }} {
14174 +    global srcfile
14175 +    global binfile
14176 +    global srcdir
14177 +    global subdir
14178 +
14179 +    if { $arg != "" } {
14180 +       set arg "additional_flags=$arg"
14181 +    }
14182 +
14183 +    if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
14184 +           executable [concat $arg debug nowarnings]] != "" } {
14185 +       untested "Could not compile ${srcfile}"
14186 +       return -1
14187 +    }
14188 +}
14189 +
14190 +proc prepare_for_trace_test {} {
14191 +    global executable
14192 +
14193 +    clean_restart $executable
14194 +
14195 +    if { ![runto_main] } {
14196 +       perror "Could not run to `main'."
14197 +       continue
14198 +    }
14199 +
14200 +    gdb_breakpoint [gdb_get_line_number "end-here"]
14201 +}
14202 +
14203 +proc run_trace_experiment { test_probe msg } {
14204 +    global gdb_prompt
14205 +
14206 +    set test "collect $msg: start trace experiment"
14207 +    gdb_test_multiple "tstart" "$test" {
14208 +       -re "^tstart\r\n$gdb_prompt $" {
14209 +           pass "$test"
14210 +       }
14211 +    }
14212 +
14213 +    gdb_test "continue" \
14214 +           "Continuing.*Breakpoint \[0-9\]+.*" \
14215 +           "collect $msg: run trace experiment"
14216 +    gdb_test "tstop" \
14217 +           "\[\r\n\]+" \
14218 +           "collect $msg: stop trace experiment"
14219 +    gdb_test "tfind start" \
14220 +           "#0 .*" \
14221 +           "collect $msg: tfind test frame"
14222 +}
14223 +
14224 +proc gdb_collect_probe_arg { msg probe val_arg0 } {
14225 +    global gdb_prompt
14226 +    global cr
14227 +
14228 +    prepare_for_trace_test
14229 +
14230 +    gdb_test "trace $probe" \
14231 +           "Tracepoint \[0-9\]+ at .*" \
14232 +           "collect $msg: set tracepoint"
14233 +    gdb_trace_setactions "collect $msg: define actions" \
14234 +           "" \
14235 +           "collect \$_probe_arg0" "^$"
14236 +
14237 +    # Begin the test.
14238 +    run_trace_experiment $msg $probe
14239 +
14240 +    gdb_test "print \$_probe_arg0" \
14241 +           "\\$\[0-9\]+ = $val_arg0$cr" \
14242 +           "collect $msg: collected probe arg0"
14243 +}
14244 +
14245 +compile_stap_bin ""
14246 +
14247 +clean_restart $executable
14248 +if { ![runto_main] } {
14249 +    perror "Could not run to `main'."
14250 +    continue
14251 +}
14252 +
14253 +if { ![gdb_target_supports_trace] } {
14254 +    # Test cannot run on this target.
14255 +    return 1;
14256 +}
14257 +
14258 +gdb_collect_probe_arg "probe args without semaphore" "probe:user" "23"
14259 +gdb_exit
14260 +
14261 +compile_stap_bin "-DUSE_PROBES"
14262 +gdb_collect_probe_arg "probe args with semaphore" "probe:two" "46"
14263 +
14264 +# Finished!
14265 +gdb_test "tfind none" ".*" ""
14266 Index: gdb-7.2.90.20110703/gdb/testsuite/lib/gdb.exp
14267 ===================================================================
14268 --- gdb-7.2.90.20110703.orig/gdb/testsuite/lib/gdb.exp  2011-03-25 14:08:11.000000000 +0100
14269 +++ gdb-7.2.90.20110703/gdb/testsuite/lib/gdb.exp       2011-07-03 10:33:11.000000000 +0200
14270 @@ -141,6 +141,11 @@ proc gdb_unload {} {
14271             send_gdb "y\n"
14272             exp_continue
14273         }
14274 +       -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
14275 +           { send_gdb "y\n"
14276 +               verbose "\t\tUnloading symbols for program being debugged"
14277 +           exp_continue
14278 +       }
14279         -re "Discard symbol table from .*y or n.*$" {
14280             send_gdb "y\n"
14281             exp_continue
14282 Index: gdb-7.2.90.20110703/gdb/testsuite/lib/pascal.exp
14283 ===================================================================
14284 --- gdb-7.2.90.20110703.orig/gdb/testsuite/lib/pascal.exp       2011-01-01 16:33:52.000000000 +0100
14285 +++ gdb-7.2.90.20110703/gdb/testsuite/lib/pascal.exp    2011-07-03 10:33:11.000000000 +0200
14286 @@ -37,6 +37,9 @@ proc pascal_init {} {
14287      global pascal_compiler_is_fpc
14288      global gpc_compiler
14289      global fpc_compiler
14290 +    global fpcversion_major
14291 +    global fpcversion_minor
14292 +    global fpcversion_release
14293      global env
14294   
14295      if { $pascal_init_done == 1 } {
14296 @@ -64,6 +67,20 @@ proc pascal_init {} {
14297             set pascal_compiler_is_fpc 1
14298             verbose -log "Free Pascal compiler found"
14299         }
14300 +
14301 +       # Detect the fpc-version
14302 +       if { $pascal_compiler_is_fpc == 1 } {
14303 +           set fpcversion_major 1
14304 +           set fpcversion_minor 0
14305 +           set fpcversion_release 0
14306 +           set fpcversion [ remote_exec host $fpc_compiler "-iV" ] 
14307 +           if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
14308 +              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
14309 +              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
14310 +              regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
14311 +           }
14312 +            verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
14313 +       }
14314      }
14315      set pascal_init_done 1
14316  }   
14317 Index: gdb-7.2.90.20110703/gdb/thread.c
14318 ===================================================================
14319 --- gdb-7.2.90.20110703.orig/gdb/thread.c       2011-04-19 17:24:49.000000000 +0200
14320 +++ gdb-7.2.90.20110703/gdb/thread.c    2011-07-03 10:33:11.000000000 +0200
14321 @@ -1438,7 +1438,8 @@ update_thread_list (void)
14322     no thread is selected, or no threads exist.  */
14323  
14324  static struct value *
14325 -thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var)
14326 +thread_id_make_value (struct gdbarch *gdbarch, struct internalvar *var,
14327 +                     void *ignore)
14328  {
14329    struct thread_info *tp = find_thread_ptid (inferior_ptid);
14330  
14331 @@ -1449,6 +1450,15 @@ thread_id_make_value (struct gdbarch *gd
14332  /* Commands with a prefix of `thread'.  */
14333  struct cmd_list_element *thread_cmd_list = NULL;
14334  
14335 +/* Implementation of `thread' variable.  */
14336 +
14337 +static struct internalvar_funcs thread_funcs =
14338 +{
14339 +  thread_id_make_value,
14340 +  NULL,
14341 +  NULL
14342 +};
14343 +
14344  void
14345  _initialize_thread (void)
14346  {
14347 @@ -1494,5 +1504,5 @@ Show printing of thread events (such as 
14348           show_print_thread_events,
14349           &setprintlist, &showprintlist);
14350  
14351 -  create_internalvar_type_lazy ("_thread", thread_id_make_value);
14352 +  create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
14353  }
14354 Index: gdb-7.2.90.20110703/gdb/top.c
14355 ===================================================================
14356 --- gdb-7.2.90.20110703.orig/gdb/top.c  2011-03-12 23:59:24.000000000 +0100
14357 +++ gdb-7.2.90.20110703/gdb/top.c       2011-07-03 10:33:11.000000000 +0200
14358 @@ -343,6 +343,9 @@ void
14359  prepare_execute_command (void)
14360  {
14361    free_all_values ();
14362 +#if 0
14363 +  free_all_types ();
14364 +#endif
14365  
14366    /* With multiple threads running while the one we're examining is
14367       stopped, the dcache can get stale without us being able to detect
14368 Index: gdb-7.2.90.20110703/gdb/tracepoint.c
14369 ===================================================================
14370 --- gdb-7.2.90.20110703.orig/gdb/tracepoint.c   2011-07-02 21:33:10.000000000 +0200
14371 +++ gdb-7.2.90.20110703/gdb/tracepoint.c        2011-07-03 10:33:11.000000000 +0200
14372 @@ -1603,6 +1603,8 @@ start_tracing (void)
14373  
14374    for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
14375      {
14376 +      struct bp_location *loc;
14377 +
14378        if ((t->type == bp_fast_tracepoint
14379            ? !may_insert_fast_tracepoints
14380            : !may_insert_tracepoints))
14381 @@ -1611,6 +1613,9 @@ start_tracing (void)
14382        t->number_on_target = 0;
14383        target_download_tracepoint (t);
14384        t->number_on_target = t->number;
14385 +
14386 +      for (loc = t->loc; loc; loc = loc->next)
14387 +       modify_semaphore (loc, 1);
14388      }
14389    VEC_free (breakpoint_p, tp_vec);
14390  
14391 @@ -1672,7 +1677,28 @@ trace_stop_command (char *args, int from
14392  void
14393  stop_tracing (void)
14394  {
14395 +  VEC(breakpoint_p) *tp_vec = NULL;
14396 +  int ix;
14397 +  struct breakpoint *t;
14398 +
14399    target_trace_stop ();
14400 +
14401 +  tp_vec = all_tracepoints ();
14402 +  for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
14403 +    {
14404 +      struct bp_location *loc;
14405 +
14406 +      if ((t->type == bp_fast_tracepoint
14407 +          ? !may_insert_fast_tracepoints
14408 +          : !may_insert_tracepoints))
14409 +       continue;
14410 +
14411 +      for (loc = t->loc; loc; loc = loc->next)
14412 +       modify_semaphore (loc, 0);
14413 +    }
14414 +
14415 +  VEC_free (breakpoint_p, tp_vec);
14416 +
14417    /* Should change in response to reply?  */
14418    current_trace_status ()->running = 0;
14419  }
14420 @@ -4515,7 +4541,8 @@ info_static_tracepoint_markers_command (
14421     available.  */
14422  
14423  static struct value *
14424 -sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var)
14425 +sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
14426 +                 void *ignore)
14427  {
14428    LONGEST size;
14429    gdb_byte *buf;
14430 @@ -4694,6 +4721,15 @@ traceframe_available_memory (VEC(mem_ran
14431    return 0;
14432  }
14433  
14434 +/* Implementation of `sdata' variable.  */
14435 +
14436 +static const struct internalvar_funcs sdata_funcs =
14437 +{
14438 +  sdata_make_value,
14439 +  NULL,
14440 +  NULL
14441 +};
14442 +
14443  /* module initialization */
14444  void
14445  _initialize_tracepoint (void)
14446 @@ -4704,7 +4740,7 @@ _initialize_tracepoint (void)
14447       value with a void typed value, and when we get here, gdbarch
14448       isn't initialized yet.  At this point, we're quite sure there
14449       isn't another convenience variable of the same name.  */
14450 -  create_internalvar_type_lazy ("_sdata", sdata_make_value);
14451 +  create_internalvar_type_lazy ("_sdata", &sdata_funcs, NULL);
14452  
14453    traceframe_number = -1;
14454    tracepoint_number = -1;
14455 Index: gdb-7.2.90.20110703/gdb/typeprint.c
14456 ===================================================================
14457 --- gdb-7.2.90.20110703.orig/gdb/typeprint.c    2011-01-11 22:53:25.000000000 +0100
14458 +++ gdb-7.2.90.20110703/gdb/typeprint.c 2011-07-03 10:33:11.000000000 +0200
14459 @@ -36,6 +36,7 @@
14460  #include "gdb_string.h"
14461  #include "exceptions.h"
14462  #include "valprint.h"
14463 +#include "dwarf2loc.h"
14464  #include <errno.h>
14465  
14466  extern void _initialize_typeprint (void);
14467 @@ -77,6 +78,9 @@ void
14468  type_print (struct type *type, char *varstring, struct ui_file *stream,
14469             int show)
14470  {
14471 +  if (show >= 0)
14472 +    type = check_typedef (type);
14473 +
14474    LA_PRINT_TYPE (type, varstring, stream, show, 0);
14475  }
14476  
14477 @@ -115,7 +119,8 @@ whatis_exp (char *exp, int show)
14478  {
14479    struct expression *expr;
14480    struct value *val;
14481 -  struct cleanup *old_chain = NULL;
14482 +  /* Required at least for the object_address_set call.  */
14483 +  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
14484    struct type *real_type = NULL;
14485    struct type *type;
14486    int full = 0;
14487 @@ -126,12 +131,13 @@ whatis_exp (char *exp, int show)
14488    if (exp)
14489      {
14490        expr = parse_expression (exp);
14491 -      old_chain = make_cleanup (free_current_contents, &expr);
14492 +      make_cleanup (free_current_contents, &expr);
14493        val = evaluate_type (expr);
14494      }
14495    else
14496      val = access_value_history (0);
14497  
14498 +  object_address_set (value_raw_address (val));
14499    type = value_type (val);
14500  
14501    get_user_print_options (&opts);
14502 @@ -168,8 +174,7 @@ whatis_exp (char *exp, int show)
14503    type_print (type, "", gdb_stdout, show);
14504    printf_filtered ("\n");
14505  
14506 -  if (exp)
14507 -    do_cleanups (old_chain);
14508 +  do_cleanups (old_chain);
14509  }
14510  
14511  static void
14512 Index: gdb-7.2.90.20110703/gdb/utils.c
14513 ===================================================================
14514 --- gdb-7.2.90.20110703.orig/gdb/utils.c        2011-05-17 23:26:28.000000000 +0200
14515 +++ gdb-7.2.90.20110703/gdb/utils.c     2011-07-03 10:33:11.000000000 +0200
14516 @@ -2243,6 +2243,36 @@ set_batch_flag_and_make_cleanup_restore_
14517    return back_to;
14518  }
14519  
14520 +/* Helper for make_cleanup_restore_page_info.  */
14521 +
14522 +static void
14523 +do_restore_selected_frame_cleanup (void *arg)
14524 +{
14525 +  struct frame_id *frame_idp = arg;
14526 +
14527 +  select_frame (frame_find_by_id (*frame_idp));
14528 +
14529 +  xfree (frame_idp);
14530 +}
14531 +
14532 +/* Provide cleanup for restoring currently selected frame.  Use frame_id for
14533 +   the case the current frame becomes stale in the meantime.  */
14534 +
14535 +struct cleanup *
14536 +make_cleanup_restore_selected_frame (void)
14537 +{
14538 +  struct frame_id *frame_idp;
14539 +
14540 +  /* get_selected_frame->get_current_frame would error otherwise.  */
14541 +  if (!has_stack_frames ())
14542 +    return make_cleanup (null_cleanup, NULL);
14543 +
14544 +  frame_idp = xmalloc (sizeof (*frame_idp));
14545 +  *frame_idp = get_frame_id (get_selected_frame (NULL));
14546 +
14547 +  return make_cleanup (do_restore_selected_frame_cleanup, frame_idp);
14548 +}
14549 +
14550  /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE.  */
14551  
14552  static void
14553 Index: gdb-7.2.90.20110703/gdb/valarith.c
14554 ===================================================================
14555 --- gdb-7.2.90.20110703.orig/gdb/valarith.c     2011-02-18 20:10:46.000000000 +0100
14556 +++ gdb-7.2.90.20110703/gdb/valarith.c  2011-07-03 10:33:11.000000000 +0200
14557 @@ -198,7 +198,10 @@ value_subscripted_rvalue (struct value *
14558    struct type *array_type = check_typedef (value_type (array));
14559    struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
14560    unsigned int elt_size = TYPE_LENGTH (elt_type);
14561 -  unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
14562 +  unsigned int elt_stride
14563 +    = (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)) == 0
14564 +       ? elt_size : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (array_type)));
14565 +  unsigned int elt_offs = elt_stride * longest_to_int (index - lowerbound);
14566    struct value *v;
14567  
14568    if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
14569 @@ -298,6 +301,10 @@ int
14570  binop_user_defined_p (enum exp_opcode op,
14571                       struct value *arg1, struct value *arg2)
14572  {
14573 +  /* FIXME: We should support user defined ops for dynamic types.  */
14574 +  if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2)))
14575 +    return 0;
14576 +
14577    return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2));
14578  }
14579  
14580 Index: gdb-7.2.90.20110703/gdb/valops.c
14581 ===================================================================
14582 --- gdb-7.2.90.20110703.orig/gdb/valops.c       2011-03-29 19:04:30.000000000 +0200
14583 +++ gdb-7.2.90.20110703/gdb/valops.c    2011-07-03 10:33:11.000000000 +0200
14584 @@ -47,6 +47,7 @@
14585  #include "objfiles.h"
14586  #include "symtab.h"
14587  #include "exceptions.h"
14588 +#include "dwarf2loc.h"
14589  
14590  extern int overload_debug;
14591  /* Local functions.  */
14592 @@ -915,6 +916,65 @@ value_one (struct type *type, enum lval_
14593    return val;
14594  }
14595  
14596 +/* object_address_set must be already called before this function.  */
14597 +
14598 +const char *
14599 +object_address_data_not_valid (struct type *type)
14600 +{
14601 +  /* Attributes are present only at the target type of a typedef.  Make the
14602 +     call conditional as it would otherwise loop through type_length_get.  */
14603 +  if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
14604 +    CHECK_TYPEDEF (type);
14605 +
14606 +  /* DW_AT_associated has a preference over DW_AT_allocated.  */
14607 +  if (TYPE_NOT_ASSOCIATED (type)
14608 +      || (TYPE_ASSOCIATED (type) != NULL
14609 +         && 0 == dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (type))))
14610 +    return N_("object is not associated");
14611 +
14612 +  if (TYPE_NOT_ALLOCATED (type)
14613 +      || (TYPE_ALLOCATED (type) != NULL
14614 +         && 0 == dwarf_locexpr_baton_eval (TYPE_ALLOCATED (type))))
14615 +    return N_("object is not allocated");
14616 +
14617 +  return NULL;
14618 +}
14619 +
14620 +/* Return non-NULL check_typedef result on TYPE if the variable is valid.  If
14621 +   it is valid the function may store the data address (DW_AT_DATA_LOCATION) of
14622 +   TYPE at *ADDRESS_RETURN.  You must set *ADDRESS_RETURN from
14623 +   value_raw_address (VAL) before calling this function.  If no
14624 +   DW_AT_DATA_LOCATION is present for TYPE the address at *ADDRESS_RETURN is
14625 +   left unchanged.  ADDRESS_RETURN must not be NULL, use
14626 +   object_address_data_not_valid () for just the data validity check.  */
14627 +
14628 +struct type *
14629 +object_address_get_data (struct type *type, CORE_ADDR *address_return)
14630 +{
14631 +  gdb_assert (address_return != NULL);
14632 +
14633 +  object_address_set (*address_return);
14634 +
14635 +  /* TYPE_DATA_LOCATION_DWARF_BLOCK / TYPE_DATA_LOCATION_ADDR are present only
14636 +     at the target type of a typedef.  */
14637 +  CHECK_TYPEDEF (type);
14638 +
14639 +  if (object_address_data_not_valid (type) != NULL)
14640 +    {
14641 +      /* Do not try to evaluate DW_AT_data_location as it may even crash
14642 +        (it would just return the value zero in the gfortran case).  */
14643 +      return NULL;
14644 +    }
14645 +
14646 +  if (TYPE_DATA_LOCATION_IS_ADDR (type))
14647 +    *address_return = TYPE_DATA_LOCATION_ADDR (type);
14648 +  else if (TYPE_DATA_LOCATION_DWARF_BLOCK (type) != NULL)
14649 +    *address_return
14650 +      = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type));
14651 +
14652 +  return type;
14653 +}
14654 +
14655  /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack.  */
14656  
14657  static struct value *
14658 @@ -1011,12 +1071,20 @@ value_fetch_lazy (struct value *val)
14659      }
14660    else if (VALUE_LVAL (val) == lval_memory)
14661      {
14662 -      CORE_ADDR addr = value_address (val);
14663 -      int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
14664 +      CORE_ADDR addr = value_raw_address (val);
14665  
14666 -      if (length)
14667 -       read_value_memory (val, 0, value_stack (val),
14668 -                          addr, value_contents_all_raw (val), length);
14669 +      if (object_address_get_data (value_type (val), &addr))
14670 +       {
14671 +         struct type *type = value_enclosing_type (val);
14672 +         int length = TYPE_LENGTH (check_typedef (type));
14673 +
14674 +         if (length)
14675 +           {
14676 +             addr += value_offset (val);
14677 +             read_value_memory (val, 0, value_stack (val),
14678 +                                addr, value_contents_all_raw (val), length);
14679 +           }
14680 +       }
14681      }
14682    else if (VALUE_LVAL (val) == lval_register)
14683      {
14684 @@ -1528,7 +1596,18 @@ address_of_variable (struct symbol *var,
14685    if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
14686        || TYPE_CODE (type) == TYPE_CODE_FUNC)
14687      {
14688 -      CORE_ADDR addr = value_address (val);
14689 +      CORE_ADDR addr;
14690 +
14691 +      if (VALUE_LVAL (val) == lval_memory)
14692 +       {
14693 +         addr = value_raw_address (val);
14694 +         if (!object_address_get_data (type, &addr))
14695 +           error (_("Can't take address of memory lvalue \"%s\"."),
14696 +                  SYMBOL_PRINT_NAME (var));
14697 +         set_value_address (val, addr);
14698 +       }
14699 +
14700 +      addr = value_address (val);
14701  
14702        return value_from_pointer (lookup_pointer_type (type), addr);
14703      }
14704 @@ -1635,6 +1714,7 @@ struct value *
14705  value_coerce_array (struct value *arg1)
14706  {
14707    struct type *type = check_typedef (value_type (arg1));
14708 +  CORE_ADDR address;
14709  
14710    /* If the user tries to do something requiring a pointer with an
14711       array that has not yet been pushed to the target, then this would
14712 @@ -1644,8 +1724,12 @@ value_coerce_array (struct value *arg1)
14713    if (VALUE_LVAL (arg1) != lval_memory)
14714      error (_("Attempt to take address of value not located in memory."));
14715  
14716 +  address = value_raw_address (arg1);
14717 +  if (!object_address_get_data (type, &address))
14718 +    error (_("Attempt to take address of non-valid value."));
14719 +
14720    return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
14721 -                            value_address (arg1));
14722 +                            address + value_offset (arg1));
14723  }
14724  
14725  /* Given a value which is a function, return a value which is a pointer
14726 @@ -3695,6 +3779,8 @@ value_slice (struct value *array, int lo
14727                                         TYPE_TARGET_TYPE (range_type),
14728                                         lowbound, 
14729                                         lowbound + length - 1);
14730 +  TYPE_BYTE_STRIDE (slice_range_type) = TYPE_BYTE_STRIDE (range_type);
14731 +
14732    if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING)
14733      {
14734        int i;
14735 Index: gdb-7.2.90.20110703/gdb/valprint.c
14736 ===================================================================
14737 --- gdb-7.2.90.20110703.orig/gdb/valprint.c     2011-04-29 21:23:05.000000000 +0200
14738 +++ gdb-7.2.90.20110703/gdb/valprint.c  2011-07-03 10:33:11.000000000 +0200
14739 @@ -36,6 +36,7 @@
14740  #include "dfp.h"
14741  #include "python/python.h"
14742  #include "ada-lang.h"
14743 +#include "dwarf2loc.h"
14744  
14745  #include <errno.h>
14746  
14747 @@ -239,7 +240,6 @@ scalar_type_p (struct type *type)
14748      case TYPE_CODE_STRUCT:
14749      case TYPE_CODE_UNION:
14750      case TYPE_CODE_SET:
14751 -    case TYPE_CODE_STRING:
14752      case TYPE_CODE_BITSTRING:
14753        return 0;
14754      default:
14755 @@ -1193,6 +1193,7 @@ val_print_array_elements (struct type *t
14756  {
14757    unsigned int things_printed = 0;
14758    unsigned len;
14759 +  struct type *saved_type = type;
14760    struct type *elttype, *index_type;
14761    unsigned eltlen;
14762    /* Position of the array element we are examining to see
14763 @@ -1201,9 +1202,33 @@ val_print_array_elements (struct type *t
14764    /* Number of repetitions we have detected so far.  */
14765    unsigned int reps;
14766    LONGEST low_bound, high_bound;
14767 +  struct cleanup *back_to;
14768 +  CORE_ADDR saved_address = address;
14769 +  
14770 +  back_to = make_cleanup (null_cleanup, 0);
14771 +  type = object_address_get_data (type, &address);
14772 +  if (!type)
14773 +    {
14774 +      fputs_filtered (object_address_data_not_valid (type), stream);
14775 +      do_cleanups (back_to);
14776 +      return;
14777 +    }
14778 +  if (address != saved_address)
14779 +    {
14780 +      size_t length = TYPE_LENGTH (type);
14781  
14782 -  elttype = TYPE_TARGET_TYPE (type);
14783 -  eltlen = TYPE_LENGTH (check_typedef (elttype));
14784 +      valaddr = xmalloc (length);
14785 +      make_cleanup (xfree, (gdb_byte *) valaddr);
14786 +      read_memory (address, (gdb_byte *) valaddr, length);
14787 +    }
14788 +
14789 +  /* Skip typedefs but do not resolve TYPE_DYNAMIC.  */
14790 +  elttype = saved_type;
14791 +  while (TYPE_CODE (elttype) == TYPE_CODE_TYPEDEF)
14792 +    elttype = TYPE_TARGET_TYPE (elttype);
14793 +  elttype = TYPE_TARGET_TYPE (elttype);
14794 +
14795 +  eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type);
14796    index_type = TYPE_INDEX_TYPE (type);
14797  
14798    if (get_array_bounds (type, &low_bound, &high_bound))
14799 @@ -1290,6 +1315,8 @@ val_print_array_elements (struct type *t
14800      {
14801        fprintf_filtered (stream, "...");
14802      }
14803 +
14804 +  do_cleanups (back_to);
14805  }
14806  
14807  /* Read LEN bytes of target memory at address MEMADDR, placing the
14808 Index: gdb-7.2.90.20110703/gdb/value.c
14809 ===================================================================
14810 --- gdb-7.2.90.20110703.orig/gdb/value.c        2011-02-27 21:57:15.000000000 +0100
14811 +++ gdb-7.2.90.20110703/gdb/value.c     2011-07-03 10:33:11.000000000 +0200
14812 @@ -43,6 +43,7 @@
14813  #include "python/python.h"
14814  #include <ctype.h>
14815  #include "tracepoint.h"
14816 +#include "observer.h"
14817  
14818  /* Prototypes for exported functions.  */
14819  
14820 @@ -1339,12 +1340,15 @@ void
14821  set_value_component_location (struct value *component,
14822                               const struct value *whole)
14823  {
14824 +  CORE_ADDR addr;
14825 +
14826    if (whole->lval == lval_internalvar)
14827      VALUE_LVAL (component) = lval_internalvar_component;
14828    else
14829      VALUE_LVAL (component) = whole->lval;
14830  
14831    component->location = whole->location;
14832 +
14833    if (whole->lval == lval_computed)
14834      {
14835        struct lval_funcs *funcs = whole->location.computed.funcs;
14836 @@ -1352,6 +1356,12 @@ set_value_component_location (struct val
14837        if (funcs->copy_closure)
14838          component->location.computed.closure = funcs->copy_closure (whole);
14839      }
14840 +
14841 +  addr = value_raw_address (component);
14842 +  object_address_get_data (value_type (whole), &addr);
14843 +  if (component->lval != lval_internalvar
14844 +      && component->lval != lval_internalvar_component)
14845 +    set_value_address (component, addr);
14846  }
14847  
14848  \f
14849 @@ -1485,6 +1495,31 @@ show_values (char *num_exp, int from_tty
14850        num_exp[1] = '\0';
14851      }
14852  }
14853 +
14854 +/* Sanity check for memory leaks and proper types reference counting.  */
14855 +
14856 +static void
14857 +value_history_cleanup (void *unused)
14858 +{
14859 +  while (value_history_chain)
14860 +    {
14861 +      struct value_history_chunk *chunk = value_history_chain;
14862 +      int i;
14863 +
14864 +      for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
14865 +       value_free (chunk->values[i]);
14866 +
14867 +      value_history_chain = chunk->next;
14868 +      xfree (chunk);
14869 +    }
14870 +  value_history_count = 0;
14871 +
14872 +  /* Free the unreferenced types above.  */
14873 +  free_all_values ();
14874 +#if 0
14875 +  free_all_types ();
14876 +#endif
14877 +}
14878  \f
14879  /* Internal variables.  These are variables within the debugger
14880     that hold values assigned by debugger commands.
14881 @@ -1530,7 +1565,14 @@ struct internalvar
14882        struct value *value;
14883  
14884        /* The call-back routine used with INTERNALVAR_MAKE_VALUE.  */
14885 -      internalvar_make_value make_value;
14886 +      struct
14887 +        {
14888 +         /* The functions to call.  */
14889 +         const struct internalvar_funcs *functions;
14890 +
14891 +         /* The function's user-data.  */
14892 +         void *data;
14893 +        } make_value;
14894  
14895        /* The internal function used with INTERNALVAR_FUNCTION.  */
14896        struct
14897 @@ -1629,18 +1671,39 @@ create_internalvar (const char *name)
14898  /* Create an internal variable with name NAME and register FUN as the
14899     function that value_of_internalvar uses to create a value whenever
14900     this variable is referenced.  NAME should not normally include a
14901 -   dollar sign.  */
14902 +   dollar sign.  DATA is passed uninterpreted to FUN when it is
14903 +   called.  CLEANUP, if not NULL, is called when the internal variable
14904 +   is destroyed.  It is passed DATA as its only argument.  */
14905  
14906  struct internalvar *
14907 -create_internalvar_type_lazy (char *name, internalvar_make_value fun)
14908 +create_internalvar_type_lazy (const char *name,
14909 +                             const struct internalvar_funcs *funcs,
14910 +                             void *data)
14911  {
14912    struct internalvar *var = create_internalvar (name);
14913  
14914    var->kind = INTERNALVAR_MAKE_VALUE;
14915 -  var->u.make_value = fun;
14916 +  var->u.make_value.functions = funcs;
14917 +  var->u.make_value.data = data;
14918    return var;
14919  }
14920  
14921 +/* See documentation in value.h.  */
14922 +
14923 +int
14924 +compile_internalvar_to_ax (struct internalvar *var,
14925 +                          struct agent_expr *expr,
14926 +                          struct axs_value *value)
14927 +{
14928 +  if (var->kind != INTERNALVAR_MAKE_VALUE
14929 +      || var->u.make_value.functions->compile_to_ax == NULL)
14930 +    return 0;
14931 +
14932 +  var->u.make_value.functions->compile_to_ax (var, expr, value,
14933 +                                             var->u.make_value.data);
14934 +  return 1;
14935 +}
14936 +
14937  /* Look up an internal variable with name NAME.  NAME should not
14938     normally include a dollar sign.
14939  
14940 @@ -1713,7 +1776,8 @@ value_of_internalvar (struct gdbarch *gd
14941        break;
14942  
14943      case INTERNALVAR_MAKE_VALUE:
14944 -      val = (*var->u.make_value) (gdbarch, var);
14945 +      val = (*var->u.make_value.functions->make_value) (gdbarch, var,
14946 +                                                       var->u.make_value.data);
14947        break;
14948  
14949      default:
14950 @@ -1909,6 +1973,11 @@ clear_internalvar (struct internalvar *v
14951        xfree (var->u.string);
14952        break;
14953  
14954 +    case INTERNALVAR_MAKE_VALUE:
14955 +      if (var->u.make_value.functions->destroy != NULL)
14956 +       var->u.make_value.functions->destroy (var->u.make_value.data);
14957 +      break;
14958 +
14959      default:
14960        break;
14961      }
14962 @@ -1963,6 +2032,38 @@ call_internal_function (struct gdbarch *
14963    return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
14964  }
14965  
14966 +#if 0
14967 +/* Call type_mark_used for any TYPEs referenced from this GDB source file.  */
14968 +
14969 +static void
14970 +value_types_mark_used (void)
14971 +{
14972 +  struct internalvar *var;
14973 +  struct value_history_chunk *chunk;
14974 +
14975 +  for (var = internalvars; var != NULL; var = var->next)
14976 +    switch (var->kind)
14977 +      {
14978 +      case INTERNALVAR_VALUE:
14979 +       type_mark_used (value_type (var->u.value));
14980 +       break;
14981 +
14982 +      case INTERNALVAR_INTEGER:
14983 +       type_mark_used (var->u.integer.type);
14984 +       break;
14985 +      }
14986 +
14987 +  for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
14988 +    {
14989 +      int i;
14990 +
14991 +      for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
14992 +       if (chunk->values[i])
14993 +         type_mark_used (value_type (chunk->values[i]));
14994 +    }
14995 +}
14996 +#endif
14997 +
14998  /* The 'function' command.  This does nothing -- it is just a
14999     placeholder to let "help function NAME" work.  This is also used as
15000     the implementation of the sub-command that is created when
15001 @@ -2010,11 +2111,10 @@ preserve_one_value (struct value *value,
15002                     htab_t copied_types)
15003  {
15004    if (TYPE_OBJFILE (value->type) == objfile)
15005 -    value->type = copy_type_recursive (objfile, value->type, copied_types);
15006 +    value->type = copy_type_recursive (value->type, copied_types);
15007  
15008    if (TYPE_OBJFILE (value->enclosing_type) == objfile)
15009 -    value->enclosing_type = copy_type_recursive (objfile,
15010 -                                                value->enclosing_type,
15011 +    value->enclosing_type = copy_type_recursive (value->enclosing_type,
15012                                                  copied_types);
15013  }
15014  
15015 @@ -2029,7 +2129,7 @@ preserve_one_internalvar (struct interna
15016      case INTERNALVAR_INTEGER:
15017        if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile)
15018         var->u.integer.type
15019 -         = copy_type_recursive (objfile, var->u.integer.type, copied_types);
15020 +         = copy_type_recursive (var->u.integer.type, copied_types);
15021        break;
15022  
15023      case INTERNALVAR_VALUE:
15024 @@ -2080,14 +2180,22 @@ show_convenience (char *ignore, int from
15025    get_user_print_options (&opts);
15026    for (var = internalvars; var; var = var->next)
15027      {
15028 +      volatile struct gdb_exception e;
15029 +
15030        if (!varseen)
15031         {
15032           varseen = 1;
15033         }
15034        printf_filtered (("$%s = "), var->name);
15035 -      value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
15036 -                  &opts);
15037 -      printf_filtered (("\n"));
15038 +
15039 +      TRY_CATCH (e, RETURN_MASK_ERROR)
15040 +       {
15041 +         value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
15042 +                      &opts);
15043 +         printf_filtered (("\n"));
15044 +       }
15045 +      if (e.reason < 0)
15046 +       printf_filtered (_("<error: %s>\n"), e.message);
15047      }
15048    if (!varseen)
15049      printf_unfiltered (_("No debugger convenience variables now defined.\n"
15050 @@ -3047,7 +3155,24 @@ value_from_history_ref (char *h, char **
15051  struct value *
15052  coerce_ref (struct value *arg)
15053  {
15054 -  struct type *value_type_arg_tmp = check_typedef (value_type (arg));
15055 +  struct type *value_type_arg_tmp;
15056 +
15057 +  if (TYPE_DYNAMIC (value_type (arg)))
15058 +    {
15059 +      struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
15060 +      CORE_ADDR address;
15061 +
15062 +      value_type_arg_tmp = value_type (arg);
15063 +      address = value_raw_address (arg);
15064 +      value_type_arg_tmp = object_address_get_data (value_type_arg_tmp,
15065 +                                                   &address);
15066 +      if (! value_type_arg_tmp)
15067 +       error (_("Attempt to coerce non-valid value."));
15068 +      arg = value_at_lazy (value_type_arg_tmp, address);
15069 +      do_cleanups (cleanups);
15070 +    }
15071 +  else
15072 +    value_type_arg_tmp = check_typedef (value_type (arg));
15073  
15074    if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF)
15075      arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp),
15076 @@ -3145,4 +3270,10 @@ VARIABLE is already initialized."));
15077    add_prefix_cmd ("function", no_class, function_command, _("\
15078  Placeholder command for showing help on convenience functions."),
15079                   &functionlist, "function ", 0, &cmdlist);
15080 +
15081 +  make_final_cleanup (value_history_cleanup, NULL);
15082 +
15083 +#if 0
15084 +  observer_attach_mark_used (value_types_mark_used);
15085 +#endif
15086  }
15087 Index: gdb-7.2.90.20110703/gdb/value.h
15088 ===================================================================
15089 --- gdb-7.2.90.20110703.orig/gdb/value.h        2011-03-04 21:07:22.000000000 +0100
15090 +++ gdb-7.2.90.20110703/gdb/value.h     2011-07-03 10:33:11.000000000 +0200
15091 @@ -473,6 +473,10 @@ extern struct value *value_from_decfloat
15092                                           const gdb_byte *decbytes);
15093  extern struct value *value_from_history_ref (char *, char **);
15094  
15095 +extern const char *object_address_data_not_valid (struct type *type);
15096 +extern struct type *object_address_get_data (struct type *type,
15097 +                                            CORE_ADDR *address_return);
15098 +
15099  extern struct value *value_at (struct type *type, CORE_ADDR addr);
15100  extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
15101  
15102 @@ -697,10 +701,52 @@ extern struct internalvar *lookup_only_i
15103  
15104  extern struct internalvar *create_internalvar (const char *name);
15105  
15106 -typedef struct value * (*internalvar_make_value) (struct gdbarch *,
15107 -                                                 struct internalvar *);
15108 +/* An internalvar can be dynamically computed by supplying a vector of
15109 +   function pointers to perform various operations.  */
15110 +
15111 +struct internalvar_funcs
15112 +{
15113 +  /* Compute the value of the variable.  The DATA argument passed to
15114 +     the function is the same argument that was passed to
15115 +     `create_internalvar_type_lazy'.  */
15116 +
15117 +  struct value *(*make_value) (struct gdbarch *arch,
15118 +                              struct internalvar *var,
15119 +                              void *data);
15120 +
15121 +  /* Update the agent expression EXPR with bytecode to compute the
15122 +     value.  VALUE is the agent value we are updating.  The DATA
15123 +     argument passed to this function is the same argument that was
15124 +     passed to `create_internalvar_type_lazy'.  If this pointer is
15125 +     NULL, then the internalvar cannot be compiled to an agent
15126 +     expression.  */
15127 +
15128 +  void (*compile_to_ax) (struct internalvar *var,
15129 +                        struct agent_expr *expr,
15130 +                        struct axs_value *value,
15131 +                        void *data);
15132 +
15133 +  /* If non-NULL, this is called to destroy DATA.  The DATA argument
15134 +     passed to this function is the same argument that was passed to
15135 +     `create_internalvar_type_lazy'.  */
15136 +
15137 +  void (*destroy) (void *data);
15138 +};
15139 +
15140  extern struct internalvar *
15141 -  create_internalvar_type_lazy (char *name, internalvar_make_value fun);
15142 +create_internalvar_type_lazy (const char *name,
15143 +                             const struct internalvar_funcs *funcs,
15144 +                             void *data);
15145 +
15146 +/* Compile an internal variable to an agent expression.  VAR is the
15147 +   variable to compile; EXPR and VALUE are the agent expression we are
15148 +   updating.  This will return 0 if there is no known way to compile
15149 +   VAR, and 1 if VAR was successfully compiled.  It may also throw an
15150 +   exception on error.  */
15151 +
15152 +extern int compile_internalvar_to_ax (struct internalvar *var,
15153 +                                     struct agent_expr *expr,
15154 +                                     struct axs_value *value);
15155  
15156  extern struct internalvar *lookup_internalvar (const char *name);
15157  
15158 Index: gdb-7.2.90.20110703/gdb/windows-tdep.c
15159 ===================================================================
15160 --- gdb-7.2.90.20110703.orig/gdb/windows-tdep.c 2011-01-12 02:23:29.000000000 +0100
15161 +++ gdb-7.2.90.20110703/gdb/windows-tdep.c      2011-07-03 10:33:11.000000000 +0200
15162 @@ -268,7 +268,7 @@ static struct lval_funcs tlb_value_funcs
15163     if there's no object available.  */
15164  
15165  static struct value *
15166 -tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var)
15167 +tlb_make_value (struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
15168  {
15169    if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid))
15170      {
15171 @@ -425,6 +425,15 @@ init_w32_command_list (void)
15172      }
15173  }
15174  
15175 +/* Implementation of `tlb' variable.  */
15176 +
15177 +static const struct internalvar_funcs tlb_funcs =
15178 +{
15179 +  tlb_make_value,
15180 +  NULL,
15181 +  NULL
15182 +};
15183 +
15184  void
15185  _initialize_windows_tdep (void)
15186  {
15187 @@ -451,5 +460,5 @@ even if their meaning is unknown."),
15188       value with a void typed value, and when we get here, gdbarch
15189       isn't initialized yet.  At this point, we're quite sure there
15190       isn't another convenience variable of the same name.  */
15191 -  create_internalvar_type_lazy ("_tlb", tlb_make_value);
15192 +  create_internalvar_type_lazy ("_tlb", &tlb_funcs, NULL);
15193  }
15194 Index: gdb-7.2.90.20110703/gdb/xcoffread.c
15195 ===================================================================
15196 --- gdb-7.2.90.20110703.orig/gdb/xcoffread.c    2011-03-07 17:17:29.000000000 +0100
15197 +++ gdb-7.2.90.20110703/gdb/xcoffread.c 2011-07-03 10:33:11.000000000 +0200
15198 @@ -3090,6 +3090,7 @@ static const struct sym_fns xcoff_sym_fn
15199    default_symfile_segments,    /* Get segment information from a file.  */
15200    aix_process_linenos,
15201    default_symfile_relocate,    /* Relocate a debug section.  */
15202 +  NULL,                                /* sym_probe_fns */
15203    &psym_functions
15204  };
15205  
This page took 1.550343 seconds and 3 git commands to generate.