1 http://sourceware.org/gdb/wiki/ProjectArcher
2 http://sourceware.org/gdb/wiki/ArcherBranchManagement
5 commit 42fbc89fd3a797da9880ecbc467c32f282acf31f
7 branch `archer' - the merge of branches:
8 archer-jankratochvil-vla
9 archer-jankratochvil-watchpoint3
11 archer-sergiodj-stap-fedora15jk
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
22 +/* The following struct stores information about every SystemTap section
23 + found in the object file. */
26 + struct sdt_note *next;
31 /* Some private data is stashed away for future use using the tdata pointer
32 in the bfd structure. */
34 @@ -1633,6 +1642,11 @@ struct elf_obj_tdata
35 bfd_size_type build_id_size;
38 + /* Linked-list containing information about every Systemtap section
39 + found in the object file. Each section corresponds to one entry
41 + struct sdt_note *sdt_note_head;
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
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
54 +#define SDT_NOTE_TYPE 3
57 +elfobj_grok_stapsdt_note_1 (bfd *abfd, Elf_Internal_Note *note)
59 + struct sdt_note *cur =
60 + (struct sdt_note *) bfd_alloc (abfd, sizeof (struct sdt_note)
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);
67 + elf_tdata (abfd)->sdt_note_head = cur;
73 +elfobj_grok_stapsdt_note (bfd *abfd, Elf_Internal_Note *note)
78 + return elfobj_grok_stapsdt_note_1 (abfd, note);
86 elfcore_netbsd_get_lwpid (Elf_Internal_Note *note, int *lwpidp)
88 @@ -9189,6 +9220,12 @@ elf_parse_notes (bfd *abfd, char *buf, s
89 if (! elfobj_grok_gnu_note (abfd, &in))
92 + else if (in.namesz == sizeof "stapsdt"
93 + && strcmp (in.namedata, "stapsdt") == 0)
95 + if (! elfobj_grok_stapsdt_note (abfd, &in))
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
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 \
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 \
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
123 # Header files that already have srcdir in them, or which are in objdir.
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 \
130 + jit.o progspace.o stap-probe.o
134 @@ -1320,6 +1320,12 @@ stamp-h: $(srcdir)/config.in config.stat
136 $(SHELL) config.status
138 +.gdbinit: $(srcdir)/gdbinit.in config.status
139 + CONFIG_FILES=".gdbinit:gdbinit.in" \
142 + $(SHELL) config.status
144 config.status: $(srcdir)/configure configure.tgt configure.host
145 $(SHELL) config.status --recheck
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
152 Initial support for the OpenCL C language (http://www.khronos.org/opencl)
153 has been integrated into GDB.
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.
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
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),
174 @@ -11435,12 +11436,15 @@ ada_operator_check (struct expression *e
178 - return operator_check_standard (exp, pos, objfile_func, data);
179 + return operator_check_standard (exp, pos, type_func, objfile_func,
183 /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
185 - if (type && TYPE_OBJFILE (type)
186 + if (type && type_func && (*type_func) (type, data))
188 + if (type && TYPE_OBJFILE (type) && objfile_func
189 && (*objfile_func) (TYPE_OBJFILE (type), data))
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
198 /* Support for debug registers. */
200 -static unsigned long amd64_linux_dr[DR_CONTROL + 1];
203 -amd64_linux_dr_get (ptid_t ptid, int regnum)
204 +amd64_linux_dr_get (int tid, int regnum)
209 - tid = TIDGET (ptid);
211 - tid = PIDGET (ptid);
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. */
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)
225 - tid = TIDGET (ptid);
227 - tid = PIDGET (ptid);
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"));
236 -/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */
237 +/* Helper for amd64_linux_dr_set_control. */
240 +amd64_linux_dr_set_control_callback (int tid, void *control_voidp)
242 + unsigned long control = *(unsigned long *) control_voidp;
244 + amd64_linux_dr_set (tid, DR_CONTROL, control);
247 +static void amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr);
249 +/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */
252 amd64_linux_dr_set_control (unsigned long control)
254 - struct lwp_info *lp;
256 + int inferior_pid = ptid_get_pid (inferior_ptid);
257 + struct inferior *inf = current_inferior ();
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)
264 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
267 + /* There were two changes in Linux kernel 2.6.33 by the commit:
268 + 72f674d203cd230426437cdcf7dd6f681dad8b0d
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.
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.
280 + The second issue is hopefully going to be fixed in Linux kernel:
281 + https://bugzilla.redhat.com/show_bug.cgi?id=660204 */
283 + if (!dr_mirror->addr_preset)
285 + dr_mirror->addr_preset = 1;
287 + for (i = 0; i < DR_LASTADDR - DR_FIRSTADDR; i++)
288 + amd64_linux_dr_set_addr (i, dr_mirror->addr[i]);
292 + linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_control_callback,
296 +/* Helper for amd64_linux_dr_set_addr. */
298 +struct amd64_linux_dr_set_addr_data
305 +amd64_linux_dr_set_addr_callback (int tid, void *datap_voidp)
307 + const struct amd64_linux_dr_set_addr_data *datap = datap_voidp;
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);
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.
320 amd64_linux_dr_set_addr (int regnum, CORE_ADDR addr)
322 - struct lwp_info *lp;
324 + struct amd64_linux_dr_set_addr_data data;
326 gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
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;
333 + linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_set_addr_callback, &data);
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.
341 amd64_linux_dr_reset_addr (int regnum)
342 @@ -354,37 +402,54 @@ amd64_linux_dr_reset_addr (int regnum)
344 amd64_linux_dr_get_status (void)
346 - return amd64_linux_dr_get (inferior_ptid, DR_STATUS);
349 + tid = TIDGET (inferior_ptid);
351 + tid = PIDGET (inferior_ptid);
353 + return amd64_linux_dr_get (tid, DR_STATUS);
356 -/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */
357 +/* Helper for amd64_linux_dr_unset_status. */
360 -amd64_linux_dr_unset_status (unsigned long mask)
361 +amd64_linux_dr_unset_status_callback (int tid, void *mask_voidp)
363 - struct lwp_info *lp;
366 - ALL_LWPS (lp, ptid)
368 - unsigned long value;
369 + unsigned long mask = *(unsigned long *) mask_voidp;
370 + unsigned long value;
372 - value = amd64_linux_dr_get (ptid, DR_STATUS);
374 - amd64_linux_dr_set (ptid, DR_STATUS, value);
376 + value = amd64_linux_dr_get (tid, DR_STATUS);
378 + amd64_linux_dr_set (tid, DR_STATUS, value);
381 +/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */
384 +amd64_linux_dr_unset_status (unsigned long mask)
386 + linux_nat_iterate_watchpoint_lwps (amd64_linux_dr_unset_status_callback,
391 amd64_linux_new_thread (ptid_t ptid)
394 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
397 + /* Verify DR_MIRROR is valid. */
398 + gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
400 + tid = TIDGET (ptid);
402 + tid = PIDGET (ptid);
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]);
409 - amd64_linux_dr_set (ptid, DR_CONTROL, amd64_linux_dr[DR_CONTROL]);
410 + amd64_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
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
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;
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;
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);
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)
446 +/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for
447 + whatever reason. */
450 +block_objfile (const struct block *block)
452 + struct symbol *func;
457 + func = block_linkage_function (block);
461 + return SYMBOL_SYMTAB (func)->objfile;
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_
469 extern struct block *allocate_block (struct obstack *obstack);
471 +extern struct objfile *block_objfile (const struct block *block);
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
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"
486 /* readline include files */
487 @@ -107,6 +109,9 @@ static void break_command_1 (char *, int
489 static void mention (struct breakpoint *);
491 +static struct bp_location *add_location_to_breakpoint (struct breakpoint *b,
492 + const struct symtab_and_line *sal);
494 /* This function is used in gdbtk sources and thus can not be made
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))
501 + if (b->pspace != current_program_space)
504 if (b->disposition == disp_del_at_next_stop)
507 @@ -1520,6 +1528,40 @@ should_be_inserted (struct bp_location *
511 +/* See the comment in breakpoint.h. */
514 +modify_semaphore (struct bp_location *loc, int set)
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;
526 + /* Swallow errors. */
527 + if (target_read_memory (address, bytes, TYPE_LENGTH (type)) != 0)
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
539 + store_unsigned_integer (bytes, TYPE_LENGTH (type),
540 + gdbarch_byte_order (arch), value);
542 + target_write_memory (address, bytes, TYPE_LENGTH (type));
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 *
550 val = target_insert_breakpoint (bl->gdbarch,
553 + modify_semaphore (bl, 1);
557 @@ -1870,6 +1914,7 @@ insert_breakpoint_locations (void)
559 int disabled_breaks = 0;
560 int hw_breakpoint_error = 0;
561 + struct program_space *saved_current_program_space = current_program_space;
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.
572 + Also inserting breakpoints into inappropriate inferior must be
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))
580 val = insert_bp_location (bl, tmp_error_stream, &disabled_breaks,
581 @@ -1923,13 +1972,19 @@ insert_breakpoint_locations (void)
583 if (bpt->disposition == disp_del_at_next_stop)
587 for (loc = bpt->loc; loc; loc = loc->next)
588 - if (!loc->inserted && should_be_inserted (loc))
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)))
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];
611 + /* SystemTap probe point for longjmp (if any). */
612 + const struct stap_probe *longjmp_probe;
614 /* Minimal symbol for "std::terminate()" (if any). */
615 struct minimal_symbol *terminate_msym;
617 /* Minimal symbol for "_Unwind_DebugHook" (if any). */
618 struct minimal_symbol *exception_msym;
620 + /* SystemTap probe point for unwinding (if any). */
621 + const struct stap_probe *exception_probe;
624 static const struct objfile_data *breakpoint_objfile_key;
626 +/* SystemTap probe not found sentinel. */
627 +static const struct stap_probe probe_not_found;
629 /* Minimal symbol not found sentinel. */
630 static struct minimal_symbol msym_not_found;
632 @@ -2227,6 +2291,29 @@ create_longjmp_master_breakpoint (void)
634 bp_objfile_data = get_breakpoint_objfile_data (objfile);
636 + if (bp_objfile_data->longjmp_probe != &probe_not_found)
638 + if (bp_objfile_data->longjmp_probe == NULL)
639 + bp_objfile_data->longjmp_probe
640 + = find_probe_in_objfile (objfile, "libc", "longjmp");
642 + if (bp_objfile_data->longjmp_probe)
644 + struct breakpoint *b;
645 + struct gdbarch *gdbarch = get_objfile_arch (objfile);
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;
656 + bp_objfile_data->longjmp_probe = &probe_not_found;
659 for (i = 0; i < NUM_LONGJMP_NAMES; i++)
661 struct breakpoint *b;
662 @@ -2335,6 +2422,31 @@ create_exception_master_breakpoint (void
664 bp_objfile_data = get_breakpoint_objfile_data (objfile);
666 + /* We prefer the SystemTap probe point if it exists. */
667 + if (bp_objfile_data->exception_probe != &probe_not_found)
669 + if (bp_objfile_data->exception_probe == NULL)
670 + bp_objfile_data->exception_probe
671 + = find_probe_in_objfile (objfile, "libgcc", "unwind");
673 + if (bp_objfile_data->exception_probe)
675 + struct breakpoint *b;
676 + struct gdbarch *gdbarch = get_objfile_arch (objfile);
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;
686 + bp_objfile_data->exception_probe = &probe_not_found;
689 + /* Otherwise, try the hook function. */
691 if (msym_not_found_p (bp_objfile_data->exception_msym))
694 @@ -2553,6 +2665,8 @@ remove_breakpoint_1 (struct bp_location
695 val = target_remove_hw_breakpoint (bl->gdbarch, &bl->target_info);
697 val = target_remove_breakpoint (bl->gdbarch, &bl->target_info);
699 + modify_semaphore (bl, 0);
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;
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;
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;
727 @@ -7628,6 +7745,16 @@ create_breakpoints_sal (struct gdbarch *
731 + if (canonical->pre_expanded)
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);
741 for (i = 0; i < sals.nelts; ++i)
743 struct symtabs_and_lines expanded =
744 @@ -8148,7 +8275,7 @@ create_breakpoint (struct gdbarch *gdbar
748 - if (sals.nelts > 1)
749 + if (sals.nelts > 1 && !canonical.pre_expanded)
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);
757 + b->pspace = current_program_space;
758 b->disposition = disp_donttouch;
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;
765 + if (old_loc->pspace != current_program_space)
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. */
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,
781 struct symtabs_and_lines sals = {0};
782 struct gdb_exception e;
783 + int my_pre_expanded = 0;
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);
791 - sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, NULL);
793 + struct linespec_result canonical;
795 + init_linespec_result (&canonical);
796 + sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0,
799 + /* We don't need the contents. */
800 + if (canonical.canonical)
804 + for (i = 0; i < sals.nelts; ++i)
805 + xfree (canonical.canonical[i]);
806 + xfree (canonical.canonical);
809 + my_pre_expanded = canonical.pre_expanded;
811 + *pre_expanded = my_pre_expanded;
816 @@ -11003,7 +11156,7 @@ addr_string_to_sals (struct breakpoint *
818 if (e.reason == 0 || e.error != NOT_FOUND_ERROR)
820 - gdb_assert (sals.nelts == 1);
821 + gdb_assert (my_pre_expanded || sals.nelts == 1);
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;
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);
836 - sals = addr_string_to_sals (b, b->addr_string, &found);
837 + sals = addr_string_to_sals (b, b->addr_string, &found, &pre_expanded);
840 make_cleanup (xfree, sals.sals);
841 - expanded = expand_line_sal_maybe (sals.sals[0]);
845 + expanded = expand_line_sal_maybe (sals.sals[0]);
848 if (b->addr_string_range_end)
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,
855 make_cleanup (xfree, sals_end.sals);
856 @@ -12496,6 +12654,24 @@ all_tracepoints (void)
861 +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
864 +breakpoint_types_mark_used (void)
866 + struct breakpoint *b;
868 + ALL_BREAKPOINTS (b)
871 + exp_types_mark_used (b->exp);
873 + type_mark_used (value_type (b->val));
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;
884 observer_attach_about_to_proceed (breakpoint_about_to_proceed);
886 + observer_attach_mark_used (breakpoint_types_mark_used);
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;
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;
904 /* Details of the placed breakpoint, when inserted. */
905 @@ -1237,4 +1242,11 @@ extern struct breakpoint *iterate_over_b
907 extern int user_breakpoint_p (struct breakpoint *);
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. */
914 +extern void modify_semaphore (struct bp_location *location, int set);
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, ")");
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)
931 + /* No _() - printed sources should not be locale dependent. */
932 + fprintf_filtered (stream, "variable");
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, "]");
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 *
948 +/* See documentation in cli-utils.h. */
951 +extract_arg (char **arg)
953 + char *result, *copy;
958 + /* Find the start of the argument. */
959 + *arg = skip_spaces (*arg);
964 + /* Find the end of the argument. */
965 + *arg = skip_to_space (*arg + 1);
967 + if (result == *arg)
970 + copy = xmalloc (*arg - result + 1);
971 + memcpy (copy, result, *arg - result);
972 + copy[*arg - result] = '\0';
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);
983 extern char *remove_trailing_whitespace (const char *start, char *s);
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. */
989 +extern char *extract_arg (char **arg);
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
998 default_symfile_relocate, /* sym_relocate: Relocate a debug
1000 + NULL, /* sym_probe_fns */
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 = \
1010 PYTHON_INSTALL_DIR = $(DESTDIR)$(GDB_DATADIR)/$(PYTHON_DIR)
1012 + gdb/FrameIterator.py \
1013 + gdb/FrameWrapper.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 \
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
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.
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. */
1050 default_symfile_relocate, /* Relocate a debug section. */
1051 + NULL, /* sym_probe_fns */
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);
1063 +extern struct cleanup *make_cleanup_restore_selected_frame (void);
1065 extern char *gdb_realpath (const char *);
1066 extern char *xfullpath (const char *);
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.
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.
1086 @c resolve the situation of these eventually
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...''
1097 @@ -4499,6 +4510,50 @@ and remove the breakpoint definitions yo
1098 that can no longer be recreated.
1101 +@node Static Probe Points
1102 +@subsection Static Probe Points
1104 +@cindex SystemTap static probe point
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}).
1111 +You can examine the available @code{SystemTap} static probes using
1112 +@code{info probes}:
1115 +@kindex info probes
1116 +@item info probes [@var{provider} [@var{name} [@var{objfile}]]]
1117 +List the available @code{SystemTap} static probes.
1119 +If given, @var{provider} is a regular expression used to select which
1120 +providers to list. If omitted, all providers are listed.
1122 +If given, @var{name} is a regular expression used to select which
1123 +probes to list. If omitted, all probes are listed.
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.
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.
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
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.
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.
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.
1164 +@xref{Static Probe Points}, for more information on finding and using
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.
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.
1183 +@itemx $_probe_arg0@dots{}$_probe_arg9
1184 +Arguments to a SystemTap static probe. @xref{Static Probe Points}.
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.
1191 Collect all local variables.
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}
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}
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:
1209 (@value{GDBP}) python
1211 -End with a line saying just "end".
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
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.
1229 It is also possible to execute a Python script from the @value{GDBN}
1230 @@ -20755,6 +20853,14 @@ and thus is always available.
1232 @cindex programming in python
1234 +You can get quick online help for @value{GDBN}'s Python API by issuing
1235 +the command @w{@kbd{python help (gdb)}}.
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)}}.
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.
1255 +* Partial Symbol Tables::
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::
1264 +@node Symbol Reading
1265 @section Symbol Reading
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.
1272 +@node Partial Symbol Tables
1273 @section Partial Symbol Tables
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
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.
1288 +@anchor{Builtin Types}
1289 @unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}).
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.
1296 +@node Object File Formats
1297 @section Object File Formats
1298 @cindex object file formats
1300 @@ -2418,6 +2434,7 @@ SOM, which is a cross-language ABI).
1302 The SOM reader is in @file{somread.c}.
1304 +@node Debugging File Formats
1305 @section Debugging File Formats
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.
1312 +@node Adding a New Symbol Reader to GDB
1313 @section Adding a New Symbol Reader to @value{GDBN}
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}.
1320 +@node Memory Management for Symbol Files
1321 @section Memory Management for Symbol Files
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.
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
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
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}
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
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.
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
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}.
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.
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;
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);
1406 error (_("Unhandled dwarf expression opcode 0x%x"), op);
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
1414 /* Not yet implemented. */
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
1420 + unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length);
1423 /* Return the `object address' for DW_OP_push_object_address. */
1424 CORE_ADDR (*get_object_address) (void *baton);
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
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;
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);
1448 + else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs)
1450 struct dwarf2_locexpr_baton *symbaton;
1452 symbaton = SYMBOL_LOCATION_BATON (framefunc);
1453 - if (symbaton != NULL)
1455 - *length = symbaton->size;
1456 - *start = symbaton->data;
1460 + gdb_assert (symbaton != NULL);
1461 + *start = symbaton->data;
1462 + *length = symbaton->size;
1464 + else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_missing_funcs)
1466 + struct dwarf2_locexpr_baton *symbaton;
1468 + symbaton = SYMBOL_LOCATION_BATON (framefunc);
1469 + gdb_assert (symbaton == NULL);
1471 + *length = 0; /* unused */
1474 + internal_error (__FILE__, __LINE__,
1475 + _("Unsupported SYMBOL_COMPUTED_OPS %p for \"%s\""),
1476 + SYMBOL_COMPUTED_OPS (framefunc),
1477 + SYMBOL_PRINT_NAME (framefunc));
1480 error (_("Could not find the frame base for \"%s\"."),
1481 - SYMBOL_NATURAL_NAME (framefunc));
1482 + SYMBOL_PRINT_NAME (framefunc));
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);
1491 +dwarf_expr_object_address (void *baton)
1493 + struct dwarf_expr_baton *debaton = baton;
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"));
1499 + return debaton->object_address;
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. */
1506 +static CORE_ADDR object_address;
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. */
1513 +object_address_cleanup (void *prev_save_voidp)
1515 + CORE_ADDR *prev_save = prev_save_voidp;
1517 + object_address = *prev_save;
1518 + xfree (prev_save);
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.
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). */
1529 +object_address_set (CORE_ADDR address)
1531 + CORE_ADDR *prev_save;
1533 + prev_save = xmalloc (sizeof *prev_save);
1534 + *prev_save = object_address;
1535 + make_cleanup (object_address_cleanup, prev_save);
1537 + object_address = address;
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. */
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)
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;
1554 + baton.frame = frame;
1555 + baton.per_cu = per_cu;
1556 + baton.object_address = object_address;
1558 + ctx = new_dwarf_expr_context ();
1559 + make_cleanup_free_dwarf_expr_context (ctx);
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;
1574 + TRY_CATCH (ex, RETURN_MASK_ERROR)
1576 + dwarf_expr_eval (ctx, data, size);
1578 + if (ex.reason < 0)
1580 + if (ex.error == NOT_AVAILABLE_ERROR)
1583 + throw_exception (ex);
1586 + /* It was used only during dwarf_expr_eval. */
1587 + ctx->baton = NULL;
1592 +/* Evaluate DWARF expression at DLBATON expecting it produces exactly one
1593 + CORE_ADDR result on the DWARF stack stack. */
1596 +dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton)
1598 + struct dwarf_expr_context *ctx;
1600 + struct cleanup *back_to = make_cleanup (null_cleanup, 0);
1602 + ctx = dwarf_expr_prep_ctx (get_selected_frame (NULL), dlbaton->data,
1603 + dlbaton->size, dlbaton->per_cu);
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"));
1609 + retval = dwarf_expr_fetch (ctx, 0);
1611 + if (ctx->location == DWARF_VALUE_REGISTER)
1613 + /* Inlined dwarf_expr_read_reg as we no longer have the baton. */
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);
1619 + retval = address_from_register (type, gdb_regnum, frame);
1622 + do_cleanups (back_to);
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. */
1632 +dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
1633 + struct type *type, CORE_ADDR *addrp)
1635 + struct frame_info *frame = get_selected_frame (NULL);
1636 + const gdb_byte *data;
1638 + struct value *val;
1643 + data = dwarf2_find_location_expression (dllbaton, &size,
1644 + get_frame_address_in_block (frame));
1648 + val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu);
1649 + if (value_optimized_out (val))
1652 + *addrp = value_as_address (val);
1656 struct piece_closure
1658 /* Reference count. */
1659 @@ -1072,11 +1251,8 @@ dwarf2_evaluate_loc_desc_full (struct ty
1660 LONGEST byte_offset)
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;
1669 if (byte_offset < 0)
1670 invalid_synthetic_pointer ();
1671 @@ -1089,38 +1265,14 @@ dwarf2_evaluate_loc_desc_full (struct ty
1675 - baton.frame = frame;
1676 - baton.per_cu = per_cu;
1678 - ctx = new_dwarf_expr_context ();
1679 - old_chain = make_cleanup_free_dwarf_expr_context (ctx);
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);
1694 - TRY_CATCH (ex, RETURN_MASK_ERROR)
1696 - dwarf_expr_eval (ctx, data, size);
1698 - if (ex.reason < 0)
1699 + ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
1702 - if (ex.error == NOT_AVAILABLE_ERROR)
1704 - retval = allocate_value (type);
1705 - mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
1709 - throw_exception (ex);
1710 + retval = allocate_value (type);
1711 + mark_value_bytes_unavailable (retval, 0, TYPE_LENGTH (type));
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);
1720 + /* Frame may be needed for check_typedef of TYPE_DYNAMIC. */
1721 + make_cleanup_restore_selected_frame ();
1722 + select_frame (frame);
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);
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
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
1746 +static struct value *
1747 +missing_read_variable (struct symbol *symbol, struct frame_info *frame)
1749 + struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1751 + gdb_assert (dlbaton == NULL);
1752 + error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
1756 +missing_read_needs_frame (struct symbol *symbol)
1762 +missing_describe_location (struct symbol *symbol, CORE_ADDR addr,
1763 + struct ui_file *stream)
1765 + fprintf_filtered (stream, _("a variable we are unable to resolve"));
1769 +missing_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
1770 + struct agent_expr *ax, struct axs_value *value)
1772 + struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
1774 + gdb_assert (dlbaton == NULL);
1775 + error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
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
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
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;
1796 +extern void object_address_set (CORE_ADDR address);
1798 +extern CORE_ADDR dwarf_locexpr_baton_eval
1799 + (struct dwarf2_locexpr_baton *dlbaton);
1801 +extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
1802 + struct type *type, CORE_ADDR *addrp);
1804 /* Compile a DWARF location expression to an agent expression.
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);
1814 +static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton
1815 + (struct attribute *attr, struct dwarf2_cu *cu);
1817 static void dwarf2_symbol_mark_computed (struct attribute *attr,
1819 struct dwarf2_cu *cu);
1820 @@ -1256,6 +1259,9 @@ static void age_cached_comp_units (void)
1822 static void free_one_cached_comp_unit (void *);
1824 +static void fetch_die_type_attrs (struct die_info *die, struct type *type,
1825 + struct dwarf2_cu *cu);
1827 static struct type *set_die_type (struct die_info *, struct type *,
1828 struct dwarf2_cu *);
1830 @@ -1280,6 +1286,9 @@ static struct type *get_die_type_at_offs
1832 static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
1834 +static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
1835 + (struct attribute *attr, struct dwarf2_cu *cu);
1837 static void dwarf2_release_queue (void *dummy);
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);
1844 +/* Create a new array dimension referencing its target type TYPE.
1846 + Multidimensional arrays are internally represented as a stack of
1847 + singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */
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)
1853 + type = create_array_type (NULL, type, range_type);
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);
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);
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
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;
1876 struct cleanup *back_to;
1879 @@ -7608,17 +7640,19 @@ read_array_type (struct die_info *die, s
1880 type = element_type;
1882 if (read_array_order (die, cu) == DW_ORD_col_major)
1887 - type = create_array_type (NULL, type, range_types[i++]);
1891 - while (ndim-- > 0)
1892 - type = create_array_type (NULL, type, range_types[ndim]);
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);
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));
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;
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);
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;
1927 attr = dwarf2_attr (die, DW_AT_string_length, cu);
1929 + if (attr && attr_form_is_block (attr))
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
1940 + struct dwarf2_locexpr_baton *length_baton = NULL;
1941 + struct dwarf_block *blk = DW_BLOCK (attr);
1943 + /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing
1944 + DW_OP_deref* in such case. */
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)
1951 + ULONGEST ulongest;
1952 + const gdb_byte *end;
1954 + end = read_uleb128 (&blk->data[1], &blk->data[blk->size],
1956 + if (end == &blk->data[blk->size])
1957 + length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
1960 + if (length_baton == NULL)
1962 + struct attribute *size_attr;
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);
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);
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"));
1988 + data[DW_BLOCK (attr)->size] = DW_OP_deref;
1989 + data[DW_BLOCK (attr)->size + 1] = DW_OP_nop;
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;
2001 - /* Check for the DW_AT_byte_size attribute. */
2002 + if (attr && attr_form_is_constant (attr))
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.
2011 attr = dwarf2_attr (die, DW_AT_byte_size, cu);
2014 - length = DW_UNSND (attr);
2016 + if (attr && attr_form_is_block (attr))
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;
2024 + else if (attr && attr_form_is_constant (attr))
2025 + TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0);
2030 + TYPE_HIGH_BOUND (range_type) = 1;
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);
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;
2043 - LONGEST high = -1;
2046 LONGEST negative_mask;
2048 @@ -8423,53 +8541,126 @@ read_subrange_type (struct die_info *die
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;
2058 + (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
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
2065 + attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
2066 + if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2068 - /* FORTRAN implies a lower bound of 1, if not given. */
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. */
2077 + else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2079 + struct die_info *target_die;
2080 + struct dwarf2_cu *target_cu = cu;
2081 + struct attribute *target_loc_attr;
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);
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);
2093 - attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
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. */
2106 - if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
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
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. */
2121 + if (attr && attr_form_is_constant (attr))
2122 + low = dwarf2_get_attr_constant_value (attr, 0);
2124 - high = dwarf2_get_attr_constant_value (attr, 1);
2126 + if (cu->language == language_fortran)
2128 + /* FORTRAN implies a lower bound of 1, if not given. */
2133 + /* According to DWARF we should assume the value 0 only for
2134 + LANGUAGE_C and LANGUAGE_CPLUS. */
2138 + if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
2139 + low |= negative_mask;
2140 + TYPE_LOW_BOUND (range_type) = low;
2142 + TYPE_UNSIGNED (range_type) = 1;
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)))
2150 attr = dwarf2_attr (die, DW_AT_count, cu);
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)))
2158 + TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
2159 + TYPE_DYNAMIC (range_type) = 1;
2161 + /* Pass it now as the regular DW_AT_upper_bound. */
2164 + if (attr && attr_form_is_block (attr) && cu->language != language_ada)
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;
2171 + else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2173 + struct die_info *target_die;
2174 + struct dwarf2_cu *target_cu = cu;
2175 + struct attribute *target_loc_attr;
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);
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;
2192 + if (attr && attr_form_is_constant (attr))
2193 + high = dwarf2_get_attr_constant_value (attr, 0);
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;
2202 + if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
2203 + high |= negative_mask;
2204 + TYPE_HIGH_BOUND (range_type) = high;
2207 /* Dwarf-2 specifications explicitly allows to create subrange types
2208 @@ -8510,24 +8701,41 @@ read_subrange_type (struct die_info *die
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;
2219 - range_type = create_range_type (NULL, base_type, low, high);
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;
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)
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;
2240 + else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2242 + struct die_info *target_die;
2243 + struct dwarf2_cu *target_cu = cu;
2244 + struct attribute *target_loc_attr;
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);
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;
2258 + else if (attr && attr_form_is_constant (attr))
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"));
2266 name = dwarf2_name (die, cu);
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.
2275 + SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */
2277 - dwarf2_symbol_mark_computed (attr, sym, cu);
2278 SYMBOL_CLASS (sym) = LOC_COMPUTED;
2279 + dwarf2_symbol_mark_computed (attr, sym, cu);
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
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;
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
2297 + finalize_type (this_type);
2302 @@ -14742,61 +14957,99 @@ fill_in_loclist_baton (struct dwarf2_cu
2303 baton->base_address = cu->base_address;
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. */
2312 +static struct dwarf2_locexpr_baton *
2313 +dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
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
2319 - && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
2320 - &dwarf2_per_objfile->loc))
2322 - struct dwarf2_loclist_baton *baton;
2323 + struct dwarf2_locexpr_baton *baton;
2325 - baton = obstack_alloc (&cu->objfile->objfile_obstack,
2326 - sizeof (struct dwarf2_loclist_baton));
2327 + gdb_assert (attr_form_is_block (attr));
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);
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);
2350 +static struct dwarf2_loclist_baton *
2351 +dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu)
2353 + struct dwarf2_loclist_baton *baton;
2355 + /* DW_AT_location of the referenced DIE may be missing if the referenced
2356 + variable has been optimized out. */
2360 + dwarf2_read_section (dwarf2_per_objfile->objfile,
2361 + &dwarf2_per_objfile->loc);
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
2367 + && DW_UNSND (attr) < dwarf2_section_size (dwarf2_per_objfile->objfile,
2368 + &dwarf2_per_objfile->loc)))
2371 + baton = obstack_alloc (&cu->objfile->objfile_obstack,
2372 + sizeof (struct dwarf2_loclist_baton));
2374 + fill_in_loclist_baton (cu, baton, attr);
2376 + if (cu->base_known == 0)
2377 + complaint (&symfile_complaints,
2378 + _("Location list used without "
2379 + "specifying the CU base address."));
2384 +/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */
2387 +dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
2388 + struct dwarf2_cu *cu)
2390 + struct dwarf2_loclist_baton *loclist_baton;
2392 + loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu);
2393 + if (loclist_baton)
2395 SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
2396 - SYMBOL_LOCATION_BATON (sym) = baton;
2397 + SYMBOL_LOCATION_BATON (sym) = loclist_baton;
2399 + else if (attr_form_is_block (attr))
2401 + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
2402 + SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
2406 - struct dwarf2_locexpr_baton *baton;
2407 + dwarf2_invalid_attrib_class_complaint ("location description",
2408 + SYMBOL_NATURAL_NAME (sym));
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. */
2416 - if (attr_form_is_block (attr))
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;
2428 - dwarf2_invalid_attrib_class_complaint ("location description",
2429 - SYMBOL_NATURAL_NAME (sym));
2431 - baton->data = NULL;
2433 + SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
2434 + SYMBOL_LOCATION_BATON (sym) = NULL;
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;
2445 @@ -15145,6 +15398,25 @@ offset_and_type_eq (const void *item_lhs
2446 return ofs_lhs->offset == ofs_rhs->offset;
2449 +/* Fill in generic attributes applicable for type DIEs. */
2452 +fetch_die_type_attrs (struct die_info *die, struct type *type,
2453 + struct dwarf2_cu *cu)
2455 + struct attribute *attr;
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));
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));
2468 /* Set the type associated with DIE to TYPE. Save it in CU's hash
2469 table if necessary. For convenience, return TYPE.
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;
2475 + fetch_die_type_attrs (die, type, cu);
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
2485 #include "infcall.h"
2486 #include "gdbthread.h"
2487 #include "regcache.h"
2488 +#include "stap-probe.h"
2489 +#include "arch-utils.h"
2491 +#include "infcall.h"
2492 +#include "gdbthread.h"
2493 +#include "regcache.h"
2495 extern void _initialize_elfread (void);
2497 @@ -61,6 +67,21 @@ struct elfinfo
2498 asection *mdebugsect; /* Section pointer for .mdebug section */
2501 +/* Per-objfile data for SystemTap probe info. */
2503 +static const struct objfile_data *stap_probe_key = NULL;
2505 +/* Per-objfile data about SystemTap probes. */
2507 +struct stap_probe_per_objfile
2509 + /* The number of probes in this objfile. */
2510 + int stap_num_probes;
2512 + /* The probes themselves. */
2513 + struct stap_probe *probes;
2516 static void free_elfinfo (void *);
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);
2524 +/* Helper function that parses the information contained in a
2525 + SystemTap's probe. Basically, the information consists in:
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;
2533 + - Probe's argument format. */
2536 +handle_probe (struct objfile *objfile, struct sdt_note *el,
2537 + struct stap_probe *ret, CORE_ADDR base)
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;
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. */
2552 + complaint (&symfile_complaints, _("corrupt probe when reading `%s'"),
2557 + /* Retrieving the probe's address. */
2558 + ret->address = extract_typed_address ((const gdb_byte *) &el->data[0],
2560 + /* Link-time sh_addr of `.stapsdt.base' section. */
2561 + base_ref = extract_typed_address ((const gdb_byte *) &el->data[size],
2563 + /* Semaphore address. */
2564 + ret->sem_addr = extract_typed_address ((const gdb_byte *) &el->data[2 * size],
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);
2575 + /* Arguments. We can only extract the argument format if there is a valid
2576 + name for this probe. */
2579 + ret->args = memchr (ret->name, '\0',
2580 + (unsigned long *) el->data
2581 + + el->size - (unsigned long *) ret->name);
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'"),
2594 +/* The name of the SystemTap section where we will find information about
2597 +#define STAP_BASE_SECTION_NAME ".stapsdt.base"
2599 +/* Helper function which tries to find the base address of the SystemTap
2600 + base section named STAP_BASE_SECTION_NAME. */
2603 +get_base_address_1 (bfd *abfd, asection *sect, void *obj)
2605 + bfd_vma *base = (bfd_vma *) obj;
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;
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. */
2618 +get_base_address (bfd *obfd)
2620 + bfd_vma base = (bfd_vma) -1;
2622 + bfd_map_over_sections (obfd, get_base_address_1, (void *) &base);
2627 +/* Implementation of `sym_get_probes', as documented in symfile.h. */
2629 +static const struct stap_probe *
2630 +elf_get_probes (struct objfile *objfile, int *num_probes)
2632 + struct stap_probe *ret = NULL;
2633 + struct stap_probe_per_objfile *probes_per_objfile;
2635 + /* Initially, no probes. */
2638 + /* Have we parsed this objfile's probes already? */
2639 + probes_per_objfile
2640 + = (struct stap_probe_per_objfile *) objfile_data (objfile,
2643 + if (!probes_per_objfile)
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
2650 + bfd *obfd = objfile->obfd;
2651 + bfd_vma base = get_base_address (obfd);
2652 + struct sdt_note *iter;
2656 + if (! elf_tdata (obfd)->sdt_note_head)
2657 + /* There isn't any probe here. */
2660 + /* Allocating space for probe info. */
2661 + for (iter = elf_tdata (obfd)->sdt_note_head;
2663 + iter = iter->next, ++n);
2665 + ret = xcalloc (n, sizeof (struct stap_probe));
2667 + /* Parsing each probe's information. */
2668 + for (iter = elf_tdata (obfd)->sdt_note_head, i = 0;
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);
2675 + /* Creating a cache for these probes in the objfile's registry. */
2676 + probes_per_objfile = xmalloc (sizeof (struct stap_probe_per_objfile));
2678 + probes_per_objfile->stap_num_probes = n;
2679 + probes_per_objfile->probes = ret;
2681 + set_objfile_data (objfile, stap_probe_key, probes_per_objfile);
2684 + ret = probes_per_objfile->probes;
2686 + *num_probes = probes_per_objfile->stap_num_probes;
2691 +/* Implementation of `sym_get_probe_argument_count', as documented in
2695 +elf_get_probe_argument_count (struct objfile *objfile,
2696 + const struct stap_probe *probe)
2698 + const char *pargs = probe->args;
2700 + if (!pargs || !*pargs || *pargs == ':')
2701 + /* No arguments. */
2704 + return stap_get_probe_argument_count (probe);
2707 +/* Implementation of `sym_evaluate_probe_argument', as documented in
2710 +static struct value *
2711 +elf_evaluate_probe_argument (struct objfile *objfile,
2712 + const struct stap_probe *probe,
2713 + struct frame_info *frame,
2716 + return stap_evaluate_probe_argument (objfile, probe, frame, n);
2719 +/* Implementation of `sym_compile_to_ax', as documented in symfile.h. */
2722 +elf_compile_to_ax (struct objfile *objfile,
2723 + const struct stap_probe *probe,
2724 + struct agent_expr *expr,
2725 + struct axs_value *value,
2728 + stap_compile_to_ax (objfile, probe, expr, value, n);
2731 +/* Implementation of `sym_relocate_probe', as documented in symfile.h. */
2734 +elf_symfile_relocate_probe (struct objfile *objfile,
2735 + struct section_offsets *new_offsets,
2736 + struct section_offsets *delta)
2739 + struct stap_probe_per_objfile *p
2740 + = (struct stap_probe_per_objfile *) objfile_data (objfile,
2744 + /* No probe to relocate. */
2747 + for (i = 0; i < p->stap_num_probes; i++)
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));
2755 +/* Helper function used to free the space allocated for storing SystemTap
2756 + probe information. */
2759 +stap_probe_key_free (struct objfile *objfile, void *d)
2762 + struct stap_probe_per_objfile *data = (struct stap_probe_per_objfile *) d;
2764 + for (i = 0; i < data->stap_num_probes; i++)
2765 + stap_free_parsed_args (data->probes[i].parsed_args);
2766 + xfree (data->probes);
2772 +/* Implementation `sym_probe_fns', as documented in symfile.h. */
2774 +static const struct sym_probe_fns elf_probe_fns =
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 */
2783 /* Register that we are able to handle ELF object file formats. */
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. */
2789 default_symfile_relocate, /* Relocate a debug section. */
2790 + &elf_probe_fns, /* sym_probe_fns */
2794 @@ -1586,6 +1867,7 @@ static const struct sym_fns elf_sym_fns_
2795 elf_symfile_segments, /* Get segment information from a file. */
2797 default_symfile_relocate, /* Relocate a debug section. */
2798 + &elf_probe_fns, /* sym_probe_fns */
2802 @@ -1603,6 +1885,7 @@ static const struct sym_fns elf_sym_fns_
2803 elf_symfile_segments, /* Get segment information from a file. */
2805 default_symfile_relocate, /* Relocate a debug section. */
2806 + &elf_probe_fns, /* sym_probe_fns */
2807 &dwarf2_gdb_index_functions
2810 @@ -1619,6 +1902,8 @@ static const struct gnu_ifunc_fns elf_gn
2812 _initialize_elfread (void)
2815 + = register_objfile_data_with_cleanup (NULL, stap_probe_key_free);
2816 add_symtab_fns (&elf_sym_fns);
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
2824 #include "objfiles.h"
2825 #include "python/python.h"
2826 #include "wrapper.h"
2827 +#include "dwarf2loc.h"
2829 #include "gdb_assert.h"
2831 @@ -489,27 +490,217 @@ init_array_element (struct value *array,
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)
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);
2846 + /* Type to use for the newly allocated value ARRAY. */
2847 + struct type *new_array_type;
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;
2854 + /* Pointer in the last holder to the type of current dimension. */
2855 + struct type **typep = &new_array_type;
2857 + struct subscript_index
2859 + enum { SUBSCRIPT_RANGE, SUBSCRIPT_NUMBER } kind;
2862 + struct subscript_range
2864 + enum f90_range_type f90_range_type;
2865 + LONGEST low_bound, high_bound;
2872 + struct type **type_array;
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;
2879 + old_chain = make_cleanup (null_cleanup, 0);
2880 + object_address_set (value_raw_address (array));
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);
2891 + copied_types = create_copied_types_hash (NULL);
2892 + type = copy_type_recursive (type, copied_types);
2893 + htab_delete (copied_types);
2895 + if (nargs != calc_f77_array_dims (type))
2896 + error (_("Wrong number of subscripts"));
2898 + if (TYPE_DATA_LOCATION_IS_ADDR (type))
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;
2906 - low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
2908 + gdb_assert (TYPE_DATA_LOCATION_DWARF_BLOCK (type) == NULL);
2909 + value_byte_address = value_address (array);
2912 + new_array_type = type;
2914 + subscript_array = alloca (sizeof (*subscript_array) * nargs);
2916 + gdb_assert (nargs > 0);
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. */
2921 + /* Take array indices left to right. */
2922 + for (i = 0; i < nargs; i++)
2924 + struct subscript_index *index = &subscript_array[i];
2926 + if (exp->elts[*pos].opcode == OP_F90_RANGE)
2928 + int pc = (*pos) + 1;
2929 + struct subscript_range *range;
2931 + index->kind = SUBSCRIPT_RANGE;
2932 + range = &index->range;
2935 + range->f90_range_type = longest_to_int (exp->elts[pc].longconst);
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,
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,
2949 + struct value *val;
2951 + index->kind = SUBSCRIPT_NUMBER;
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);
2961 + /* Internal type of array is arranged right to left. */
2962 + for (i = nargs - 1; i >= 0; i--)
2964 + struct subscript_index *index = &subscript_array[i];
2965 + struct type *range_type = TYPE_INDEX_TYPE (type);
2967 + switch (index->kind)
2969 + case SUBSCRIPT_RANGE:
2971 + struct subscript_range *range = &index->range;
2972 + CORE_ADDR byte_offset;
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);
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);
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"));
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;
2995 + typep = &TYPE_TARGET_TYPE (type);
2996 + value_byte_offset += byte_offset;
2997 + type = TYPE_TARGET_TYPE (type);
3001 + case SUBSCRIPT_NUMBER:
3003 + CORE_ADDR byte_offset;
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"));
3010 + byte_offset = ((index->number - TYPE_LOW_BOUND (range_type))
3011 + * TYPE_ARRAY_BYTE_STRIDE_VALUE (type));
3013 + type = TYPE_TARGET_TYPE (type);
3015 + value_byte_offset += byte_offset;
3021 + type_last_target = type;
3022 + type_array = alloca (sizeof (*type_array) * nargs);
3024 + for (type = new_array_type; type != type_last_target;
3025 + type = TYPE_TARGET_TYPE (type))
3026 + type_array[i++] = type;
3029 + struct type *type = type_array[--i];
3031 + /* Force TYPE_LENGTH (type) recalculation. */
3032 + TYPE_TARGET_STUB (type) = 1;
3033 + check_typedef (type);
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;
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);
3048 - return value_slice (array, low_bound, high_bound - low_bound + 1);
3049 + if (!value_lazy (saved_array))
3051 + allocate_value_contents (array);
3052 + set_value_lazy (array, 0);
3054 + memcpy (value_contents_writeable (array),
3055 + value_contents (saved_array) + value_byte_offset,
3056 + TYPE_LENGTH (new_array_type));
3059 + do_cleanups (old_chain);
3064 @@ -790,6 +981,7 @@ evaluate_subexp_standard (struct type *e
3066 struct symbol *function = NULL;
3067 char *function_name = NULL;
3068 + struct cleanup *old_chain;
3071 op = exp->elts[pc].opcode;
3072 @@ -1862,6 +2054,8 @@ evaluate_subexp_standard (struct type *e
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);
3081 @@ -1882,23 +2076,13 @@ evaluate_subexp_standard (struct type *e
3082 code = TYPE_CODE (type);
3085 + do_cleanups (old_chain);
3089 case TYPE_CODE_ARRAY:
3090 - if (exp->elts[*pos].opcode == OP_F90_RANGE)
3091 - return value_f90_subarray (arg1, exp, pos, noside);
3093 - goto multi_f77_subscript;
3095 case TYPE_CODE_STRING:
3096 - if (exp->elts[*pos].opcode == OP_F90_RANGE)
3097 - return value_f90_subarray (arg1, exp, pos, noside);
3100 - arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
3101 - return value_subscript (arg1, value_as_long (arg2));
3103 + return value_f90_subarray (arg1, exp, pos, nargs, noside);
3106 case TYPE_CODE_FUNC:
3107 @@ -2337,49 +2521,6 @@ evaluate_subexp_standard (struct type *e
3111 - multi_f77_subscript:
3113 - LONGEST subscript_array[MAX_FORTRAN_DIMS];
3114 - int ndimensions = 1, i;
3115 - struct value *array = arg1;
3117 - if (nargs > MAX_FORTRAN_DIMS)
3118 - error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
3120 - ndimensions = calc_f77_array_dims (type);
3122 - if (nargs != ndimensions)
3123 - error (_("Wrong number of subscripts"));
3125 - gdb_assert (nargs > 0);
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. */
3130 - /* Take array indices left to right. */
3131 - for (i = 0; i < nargs; i++)
3133 - /* Evaluate each subscript; it must be a legal integer in F77. */
3134 - arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
3136 - /* Fill in the subscript array. */
3138 - subscript_array[i] = value_as_long (arg2);
3141 - /* Internal type of array is arranged right to left. */
3142 - for (i = nargs; i > 0; i--)
3144 - struct type *array_type = check_typedef (value_type (array));
3145 - LONGEST index = subscript_array[i - 1];
3147 - lower = f77_get_lowerbound (array_type);
3148 - array = value_subscripted_rvalue (array, index, lower);
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)
3171 + do_cleanups (old_chain);
3174 if (unop_user_defined_p (op, arg1))
3175 - return value_x_unop (arg1, op, noside);
3177 + do_cleanups (old_chain);
3178 + return value_x_unop (arg1, op, noside);
3180 else if (noside == EVAL_AVOID_SIDE_EFFECTS)
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
3187 - return value_zero (TYPE_TARGET_TYPE (type),
3190 + do_cleanups (old_chain);
3191 + return value_zero (TYPE_TARGET_TYPE (type),
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,
3199 + do_cleanups (old_chain);
3200 + /* GDB allows dereferencing an int. */
3201 + return value_zero (builtin_type (exp->gdbarch)->builtin_int,
3205 error (_("Attempt to take contents of a non-pointer value."));
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);
3215 + do_cleanups (old_chain);
3216 + return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
3217 + (CORE_ADDR) value_as_address (arg1));
3219 + arg1 = value_ind (arg1);
3220 + do_cleanups (old_chain);
3224 /* C++: check for and handle pointer to members. */
3225 @@ -2991,7 +3151,7 @@ evaluate_subexp_with_coercion (struct ex
3229 - struct value *val;
3230 + struct value *val = NULL;
3234 @@ -3002,13 +3162,18 @@ evaluate_subexp_with_coercion (struct ex
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))
3248 - val = address_of_variable (var, exp->elts[pc + 1].block);
3250 + val = address_of_variable (var, exp->elts[pc + 1].block);
3251 return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
3254 @@ -3060,9 +3225,13 @@ evaluate_subexp_for_sizeof (struct expre
3258 - type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
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));
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
3273 calc_f77_array_dims (struct type *array_type)
3276 - struct type *tmp_type;
3277 + switch (TYPE_CODE (array_type))
3279 + case TYPE_CODE_STRING:
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:
3288 - tmp_type = array_type;
3289 + while ((array_type = TYPE_TARGET_TYPE (array_type)))
3291 + if (TYPE_CODE (array_type) == TYPE_CODE_ARRAY)
3297 - while ((tmp_type = TYPE_TARGET_TYPE (tmp_type)))
3299 - if (TYPE_CODE (tmp_type) == TYPE_CODE_ARRAY)
3302 + error (_("Can't get dimensions for a non-array/non-string type"));
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; }
3315 -arglist : arglist ',' exp %prec ABOVE_COMMA
3316 +arglist : arglist ',' exp %prec ABOVE_COMMA
3317 + { arglist_len++; }
3318 + | arglist ',' subrange %prec ABOVE_COMMA
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,
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);
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
3342 #include "gdbcore.h"
3346 +#include "dwarf2loc.h"
3347 #include "gdb_string.h"
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);
3355 +f_object_address_data_valid_print_to_stream (struct type *type,
3356 + struct ui_file *stream)
3360 + msg = object_address_data_not_valid (type);
3363 + /* Assuming the content printed to STREAM should not be localized. */
3364 + fprintf_filtered (stream, "<%s>", msg);
3371 +f_object_address_data_valid_or_error (struct type *type)
3375 + msg = object_address_data_not_valid (type);
3378 + error (_("Cannot access it because the %s."), _(msg));
3382 /* LEVEL is the depth to indent lines by. */
3385 @@ -58,6 +86,9 @@ f_print_type (struct type *type, const c
3386 enum type_code code;
3389 + if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
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
3399 + if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
3400 + CHECK_TYPEDEF (type);
3402 switch (TYPE_CODE (type))
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
3413 -#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
3414 +#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
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. */
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])
3423 f77_get_lowerbound (struct type *type)
3425 + f_object_address_data_valid_or_error (type);
3427 if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
3428 error (_("Lower bound may not be '*' in F77"));
3430 @@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type)
3432 f77_get_upperbound (struct type *type)
3434 + f_object_address_data_valid_or_error (type);
3436 if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
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. */
3448 - return f77_get_lowerbound (type);
3449 + return f77_get_lowerbound (type) - 1;
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);
3457 - F77_DIM_SIZE (ndimen) = upper - lower + 1;
3458 + F77_DIM_COUNT (ndimen) = upper - lower + 1;
3460 + F77_DIM_BYTE_STRIDE (ndimen) =
3461 + TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
3463 tmp_type = TYPE_TARGET_TYPE (tmp_type);
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. */
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)
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;
3489 @@ -174,37 +184,35 @@ f77_print_array_1 (int nss, int ndimensi
3491 if (nss != ndimensions)
3494 - (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max);
3496 + for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++)
3498 fprintf_filtered (stream, "( ");
3499 f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
3501 - embedded_offset + i * F77_DIM_OFFSET (nss),
3502 + embedded_offset + i * F77_DIM_BYTE_STRIDE (nss),
3504 stream, recurse, val, options, elts);
3505 fprintf_filtered (stream, ") ");
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, "...");
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;
3517 val_print (TYPE_TARGET_TYPE (type),
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);
3524 - if (i != (F77_DIM_SIZE (nss) - 1))
3525 + if (i != (F77_DIM_COUNT (nss) - 1))
3526 fprintf_filtered (stream, ", ");
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, "...");
3534 @@ -260,6 +268,9 @@ f_val_print (struct type *type, const gd
3538 + if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
3541 CHECK_TYPEDEF (type);
3542 switch (TYPE_CODE (type))
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
3549 #include "user-regs.h"
3551 #include "objfiles.h"
3552 +#include "dwarf2loc.h"
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 *
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. */
3569 read_var_value (struct symbol *var, struct frame_info *frame)
3570 @@ -417,16 +421,6 @@ read_var_value (struct symbol *var, stru
3572 struct type *type = SYMBOL_TYPE (var);
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);
3583 - len = TYPE_LENGTH (type);
3585 if (symbol_read_needs_frame (var))
3587 @@ -436,7 +430,7 @@ read_var_value (struct symbol *var, stru
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
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;
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
3614 addr += SYMBOL_VALUE (var);
3615 - v = allocate_value_lazy (type);
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);
3628 addr = get_frame_locals_address (frame);
3629 addr += SYMBOL_VALUE (var);
3630 - v = allocate_value_lazy (type);
3634 @@ -508,7 +499,6 @@ read_var_value (struct symbol *var, stru
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."));
3645 addr = value_as_address (regval);
3646 - v = allocate_value_lazy (type);
3650 @@ -572,7 +561,6 @@ read_var_value (struct symbol *var, stru
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);
3658 @@ -587,6 +575,10 @@ read_var_value (struct symbol *var, stru
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);
3669 @@ -626,11 +618,12 @@ struct value *
3670 value_from_register (struct type *type, int regnum, struct frame_info *frame)
3672 struct gdbarch *gdbarch = get_frame_arch (frame);
3673 - struct type *type1 = check_typedef (type);
3675 int optim, unavail, ok;
3677 - if (gdbarch_convert_register_p (gdbarch, regnum, type1))
3678 + type = check_typedef (type);
3680 + if (gdbarch_convert_register_p (gdbarch, regnum, type))
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,
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
3698 echo Setting up the environment for debugging gdb.\n
3700 +# Set up the Python library and "require" command.
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)
3708 +source @srcdir@/python/lib/gdb/__init__.py
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
3719 #include "gdb_assert.h"
3720 #include "hashtab.h"
3721 +#include "observer.h"
3722 +#include "dwarf2expr.h"
3723 +#include "dwarf2loc.h"
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,
3735 +/* The hash table holding all discardable `struct type *' references. */
3736 +static htab_t type_discardable_table;
3738 +/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */
3739 +static int type_discardable_age_current;
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)
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. */
3754 +set_type_as_discardable (struct type *type)
3758 + gdb_assert (!TYPE_DISCARDABLE (type));
3760 + TYPE_DISCARDABLE (type) = 1;
3761 + TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
3763 + slot = htab_find_slot (type_discardable_table, type, INSERT);
3764 + gdb_assert (!*slot);
3769 +/* Allocate a new type like alloc_type but preserve for it the discardability
3770 + state of PARENT_TYPE. */
3772 +static struct type *
3773 +alloc_type_as_parent (struct type *parent_type)
3775 + struct type *new_type = alloc_type_copy (parent_type);
3778 + if (TYPE_DISCARDABLE (parent_type))
3779 + set_type_as_discardable (new_type);
3785 /* Allocate a new GDBARCH-associated type structure and fill it
3786 with some defaults. Space for the type structure is allocated
3788 @@ -300,7 +349,7 @@ make_pointer_type (struct type *type, st
3790 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
3792 - ntype = alloc_type_copy (type);
3793 + ntype = alloc_type_as_parent (type);
3797 @@ -377,7 +426,7 @@ make_reference_type (struct type *type,
3799 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
3801 - ntype = alloc_type_copy (type);
3802 + ntype = alloc_type_as_parent (type);
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;
3813 TYPE_UNSIGNED (result_type) = 1;
3814 @@ -891,26 +941,31 @@ create_array_type (struct type *result_t
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;
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;
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;
3845 + CHECK_TYPEDEF (element_type);
3846 + TYPE_LENGTH (result_type) = type_length_get (result_type, element_type,
3849 if (TYPE_LENGTH (result_type) == 0)
3850 - TYPE_TARGET_STUB (result_type) = 1;
3852 + /* The real size will be computed for specific instances by
3854 + TYPE_TARGET_STUB (result_type) = 1;
3859 @@ -1413,6 +1468,105 @@ stub_noname_complaint (void)
3860 complaint (&symfile_complaints, _("stub type has NULL name"));
3863 +/* Calculate the memory length of array TYPE.
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. */
3872 +type_length_get (struct type *type, struct type *target_type, int full_span)
3874 + struct type *range_type;
3875 + LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */
3876 + LONGEST count, element_size, retval;
3878 + if (TYPE_CODE (type) != TYPE_CODE_ARRAY
3879 + && TYPE_CODE (type) != TYPE_CODE_STRING)
3880 + return TYPE_LENGTH (type);
3882 + /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
3883 + Fortran arrays. The allocated data will never be used so they can be
3885 + if (object_address_data_not_valid (type))
3888 + range_type = TYPE_INDEX_TYPE (type);
3889 + if (TYPE_LOW_BOUND_UNDEFINED (range_type)
3890 + || TYPE_HIGH_BOUND_UNDEFINED (range_type))
3892 + count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
3893 + /* It may happen for wrong DWARF annotations returning garbage data. */
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. */
3901 + if (full_span || count > 1)
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)
3908 + if (target_type == NULL)
3909 + target_type = check_typedef (TYPE_TARGET_TYPE (type));
3910 + byte_stride = type_length_get (target_type, NULL, 1);
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.
3926 + retval = count * byte_stride;
3927 + if (count == 0 || retval / count != byte_stride || retval > UINT_MAX)
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)
3943 +/* Prepare TYPE after being read in by the backend. Currently this function
3944 + only propagates the TYPE_DYNAMIC flag. */
3947 +finalize_type (struct type *type)
3951 + for (i = 0; i < TYPE_NFIELDS (type); ++i)
3952 + if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
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;
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)
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))
3974 + htab_t copied_types;
3976 + copied_types = create_copied_types_hash (NULL);
3977 + type = copy_type_recursive (type, copied_types);
3978 + htab_delete (copied_types);
3980 + gdb_assert (TYPE_DYNAMIC (type) == 0);
3981 + /* Force TYPE_LENGTH (type) recalculation. */
3982 + TYPE_DYNAMIC (type) = 1;
3985 + if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))
3987 - struct type *range_type;
3988 struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
3990 + if (TYPE_DYNAMIC (type))
3991 + TYPE_TARGET_TYPE (type) = target_type;
3992 if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
3994 /* Nothing we can do. */
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)
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);
4010 - if (high_bound < low_bound)
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);
4028 - len = tlen * (uhigh - ulow + 1);
4029 - if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh
4030 - || len > UINT_MAX)
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;
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;
4043 + TYPE_DYNAMIC (type) = 0;
4046 type = make_qualified_type (type, instance_flags, NULL);
4047 @@ -3266,33 +3406,42 @@ type_pair_eq (const void *item_lhs, cons
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. */
4056 create_copied_types_hash (struct objfile *objfile)
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)
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);
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);
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. */
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)
4096 struct type_pair *stored, pair;
4098 struct type *new_type;
4100 - if (! TYPE_OBJFILE_OWNED (type))
4101 + if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type))
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));
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. */
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));
4117 stored->new = new_type;
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);
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);
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;
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);
4145 + if (TYPE_ALLOCATED (new_type))
4147 + gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
4149 + if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
4150 + TYPE_NOT_ALLOCATED (new_type) = 1;
4151 + TYPE_ALLOCATED (new_type) = NULL;
4154 + if (TYPE_ASSOCIATED (new_type))
4156 + gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
4158 + if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
4159 + TYPE_NOT_ASSOCIATED (new_type) = 1;
4160 + TYPE_ASSOCIATED (new_type) = NULL;
4163 + if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
4164 + && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
4166 + if (TYPE_NOT_ALLOCATED (new_type)
4167 + || TYPE_NOT_ASSOCIATED (new_type))
4168 + TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
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));
4177 /* Copy the fields. */
4178 if (TYPE_NFIELDS (type))
4182 + /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */
4183 + gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE);
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++)
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),
4196 + = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
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
4205 + /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
4206 + possibly converted. */
4207 + TYPE_DYNAMIC (new_type) = 0;
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)
4213 TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
4214 *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
4216 + switch (TYPE_RANGE_DATA (new_type)->low.kind)
4218 + case RANGE_BOUND_KIND_CONSTANT:
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.
4225 + if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4226 + || ! has_stack_frames ())
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;
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;
4239 + TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
4241 + case RANGE_BOUND_KIND_DWARF_LOCLIST:
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.
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))
4255 + TYPE_LOW_BOUND (new_type) = addr;
4256 + if (TYPE_LOW_BOUND (new_type) >= 0)
4257 + TYPE_UNSIGNED (new_type) = 1;
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;
4265 + TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
4270 + switch (TYPE_RANGE_DATA (new_type)->high.kind)
4272 + case RANGE_BOUND_KIND_CONSTANT:
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.
4279 + if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4280 + || ! has_stack_frames ())
4282 + TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
4283 + TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
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;
4290 + case RANGE_BOUND_KIND_DWARF_LOCLIST:
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.
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,
4304 + TYPE_HIGH_BOUND (new_type) = addr;
4307 + TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
4308 + TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
4310 + TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
4315 + switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind)
4317 + case RANGE_BOUND_KIND_CONSTANT:
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.
4324 + if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
4325 + || ! has_stack_frames ())
4326 + TYPE_BYTE_STRIDE (new_type) = 0;
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;
4333 + case RANGE_BOUND_KIND_DWARF_LOCLIST:
4335 + CORE_ADDR addr = 0;
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.
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,
4347 + TYPE_BYTE_STRIDE (new_type) = addr;
4348 + TYPE_RANGE_DATA (new_type)->byte_stride.kind
4349 + = RANGE_BOUND_KIND_CONSTANT;
4354 + /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */
4355 + if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type))
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;
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),
4369 + copy_type_recursive_1 (objfile,
4370 + TYPE_TARGET_TYPE (type),
4372 if (TYPE_VPTR_BASETYPE (type))
4373 TYPE_VPTR_BASETYPE (new_type) =
4374 - copy_type_recursive (objfile,
4375 - TYPE_VPTR_BASETYPE (type),
4377 + copy_type_recursive_1 (objfile,
4378 + TYPE_VPTR_BASETYPE (type),
4381 + if (TYPE_CODE (new_type) == TYPE_CODE_ARRAY)
4383 + struct type *new_index_type = TYPE_INDEX_TYPE (new_type);
4385 + if (TYPE_BYTE_STRIDE (new_index_type) == 0)
4386 + TYPE_BYTE_STRIDE (new_index_type)
4387 + = TYPE_LENGTH (TYPE_TARGET_TYPE (new_type));
4390 /* Maybe copy the type_specific bits.
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
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. */
4402 +copy_type_recursive (struct type *type,
4403 + htab_t copied_types)
4405 + return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types);
4408 /* Make a copy of the given TYPE, except that the pointer & reference
4409 types are not preserved.
4411 @@ -3426,6 +3798,201 @@ copy_type (const struct type *type)
4416 +/* Callback type for main_type_crawl. */
4417 +typedef int (*main_type_crawl_iter) (struct type *type, void *data);
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
4428 +main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data)
4430 + struct type *type_iter;
4436 + gdb_assert (TYPE_OBJFILE (type) == NULL);
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));
4443 + if (!(*iter) (type, data))
4446 + /* Iterate all the type instances of this main_type. */
4450 + gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type));
4452 + main_type_crawl (TYPE_POINTER_TYPE (type), iter, data);
4453 + main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data);
4455 + type_iter = TYPE_CHAIN (type_iter);
4457 + while (type_iter != type);
4459 + for (i = 0; i < TYPE_NFIELDS (type); i++)
4460 + main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data);
4462 + main_type_crawl (TYPE_TARGET_TYPE (type), iter, data);
4463 + main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data);
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. */
4470 +delete_main_type (struct type *type)
4474 + gdb_assert (TYPE_DISCARDABLE (type));
4475 + gdb_assert (TYPE_OBJFILE (type) == NULL);
4477 + xfree (TYPE_NAME (type));
4478 + xfree (TYPE_TAG_NAME (type));
4480 + for (i = 0; i < TYPE_NFIELDS (type); ++i)
4482 + xfree (TYPE_FIELD_NAME (type, i));
4484 + if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
4485 + xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
4487 + xfree (TYPE_FIELDS (type));
4489 + gdb_assert (!HAVE_CPLUS_STRUCT (type));
4491 + xfree (TYPE_MAIN_TYPE (type));
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
4499 +delete_type_chain (struct type *type)
4501 + struct type *type_iter, *type_iter_to_free;
4503 + gdb_assert (TYPE_DISCARDABLE (type));
4504 + gdb_assert (TYPE_OBJFILE (type) == NULL);
4506 + delete_main_type (type);
4511 + type_iter_to_free = type_iter;
4512 + type_iter = TYPE_CHAIN (type_iter);
4513 + xfree (type_iter_to_free);
4515 + while (type_iter != type);
4518 +/* Hash function for type_discardable_table. */
4521 +type_discardable_hash (const void *p)
4523 + const struct type *type = p;
4525 + return htab_hash_pointer (TYPE_MAIN_TYPE (type));
4528 +/* Equality function for type_discardable_table. */
4531 +type_discardable_equal (const void *a, const void *b)
4533 + const struct type *left = a;
4534 + const struct type *right = b;
4536 + return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right);
4539 +/* A helper for type_mark_used. */
4542 +type_mark_used_crawl (struct type *type, void *unused)
4544 + if (!TYPE_DISCARDABLE (type))
4547 + if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current)
4550 + TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
4552 + /* Continue the traversal. */
4556 +/* Mark TYPE and its connected types as used in this free_all_types pass. */
4559 +type_mark_used (struct type *type)
4564 + if (!TYPE_DISCARDABLE (type))
4567 + main_type_crawl (type, type_mark_used_crawl, NULL);
4570 +/* A traverse callback for type_discardable_table which removes any
4571 + type_discardable whose reference count is now zero (unused link). */
4574 +type_discardable_remove (void **slot, void *unused)
4576 + struct type *type = *slot;
4578 + gdb_assert (TYPE_DISCARDABLE (type));
4580 + if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current)
4582 + delete_type_chain (type);
4584 + htab_clear_slot (type_discardable_table, slot);
4590 +/* Free all the reclaimable types that have been allocated and that have
4591 + currently zero reference counter.
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). */
4598 +free_all_types (void)
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
4603 + type_discardable_age_current ^= 1;
4605 + observer_notify_mark_used ();
4607 + htab_traverse (type_discardable_table, type_discardable_remove, NULL);
4611 /* Helper functions to initialize architecture-specific types. */
4613 @@ -3955,6 +4522,13 @@ void
4614 _initialize_gdbtypes (void)
4616 gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
4619 + type_discardable_table = htab_create_alloc (20, type_discardable_hash,
4620 + type_discardable_equal, NULL,
4624 objfile_type_data = register_objfile_data ();
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
4633 #define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
4635 +/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
4638 +#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic)
4640 /* Static type. If this is set, the corresponding type had
4642 Note: This may be unnecessary, since static data members
4643 @@ -292,6 +297,50 @@ enum type_instance_flag_value
4645 #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
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. */
4652 +#define TYPE_DISCARDABLE(t) (TYPE_MAIN_TYPE (t)->flag_discardable)
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. */
4658 +#define TYPE_DISCARDABLE_AGE(t) (TYPE_MAIN_TYPE (t)->flag_discardable_age)
4661 +/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */
4663 +#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
4664 + (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
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. */
4671 +#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated)
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. */
4678 +#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
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. */
4688 +#define TYPE_DATA_LOCATION_IS_ADDR(t) \
4689 + (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
4691 /* Constant type. If this is set, the corresponding type has a
4694 @@ -400,6 +449,15 @@ struct main_type
4695 /* True if this type was declared with "class" rather than
4697 unsigned int flag_declared_class : 1;
4699 + unsigned int flag_discardable : 1;
4700 + unsigned int flag_discardable_age : 1;
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;
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
4712 struct type *target_type;
4714 + /* For DW_AT_data_location. */
4717 + struct dwarf2_locexpr_baton *dwarf_block;
4722 + /* For DW_AT_allocated. */
4723 + struct dwarf2_locexpr_baton *allocated;
4725 + /* For DW_AT_associated. */
4726 + struct dwarf2_locexpr_baton *associated;
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
4740 + struct dwarf2_locexpr_baton *dwarf_block;
4743 + struct dwarf2_loclist_baton *loclist;
4744 + struct type *type;
4749 + enum range_bound_kind
4751 + RANGE_BOUND_KIND_CONSTANT,
4752 + RANGE_BOUND_KIND_DWARF_BLOCK,
4753 + RANGE_BOUND_KIND_DWARF_LOCLIST
4757 /* Low bound of range. */
4762 /* High bound of range. */
4766 + /* Byte stride of range. */
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
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))))
4806 #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
4807 - (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
4808 + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
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)))
4819 @@ -1379,6 +1484,18 @@ extern struct type *create_array_type (s
4821 extern struct type *lookup_array_range_type (struct type *, int, int);
4823 +extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
4826 +extern int type_range_high_bound_internal (struct type *range_type);
4828 +extern int type_range_count_bound_internal (struct type *range_type);
4830 +extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
4831 + struct type *element_type);
4833 +extern void finalize_type (struct type *type);
4835 extern struct type *create_string_type (struct type *, 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
4840 extern int is_unique_ancestor (struct type *, struct value *);
4843 +extern void type_mark_used (struct type *type);
4846 /* Overload resolution */
4848 #define LENGTH_MATCH(bv) ((bv)->rank[0])
4849 @@ -1496,10 +1617,13 @@ extern void maintenance_print_type (char
4851 extern htab_t create_copied_types_hash (struct objfile *objfile);
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);
4858 extern struct type *copy_type (const struct type *type);
4861 +extern void free_all_types (void);
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
4873 -/* Support for debug registers. */
4875 -static unsigned long i386_linux_dr[DR_CONTROL + 1];
4877 /* Get debug register REGNUM value from only the one LWP of PTID. */
4879 static unsigned long
4880 -i386_linux_dr_get (ptid_t ptid, int regnum)
4881 +i386_linux_dr_get (int tid, int regnum)
4884 unsigned long value;
4886 - tid = TIDGET (ptid);
4888 - tid = PIDGET (ptid);
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. */
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)
4902 - tid = TIDGET (ptid);
4904 - tid = PIDGET (ptid);
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"));
4913 -/* Set DR_CONTROL to ADDR in all LWPs of LWP_LIST. */
4914 +/* Helper for i386_linux_dr_set_control. */
4917 +i386_linux_dr_set_control_callback (int tid, void *control_voidp)
4919 + unsigned long control = *(unsigned long *) control_voidp;
4921 + i386_linux_dr_set (tid, DR_CONTROL, control);
4924 +static void i386_linux_dr_set_addr (int regnum, CORE_ADDR addr);
4926 +/* Set DR_CONTROL to ADDR in all LWPs of CURRENT_INFERIOR. */
4929 i386_linux_dr_set_control (unsigned long control)
4931 - struct lwp_info *lp;
4933 + int inferior_pid = ptid_get_pid (inferior_ptid);
4934 + struct inferior *inf = current_inferior ();
4936 + /* The amd64 counterpart and description is amd64_linux_dr_set_control. */
4937 + if (inf->pid != inferior_pid)
4939 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
4942 + if (!dr_mirror->addr_preset)
4944 + dr_mirror->addr_preset = 1;
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]);
4954 + linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_control_callback,
4958 -/* Set address REGNUM (zero based) to ADDR in all LWPs of LWP_LIST. */
4959 +/* Helper for i386_linux_dr_set_addr. */
4961 +struct i386_linux_dr_set_addr_data
4968 +i386_linux_dr_set_addr_callback (int tid, void *datap_voidp)
4970 + const struct i386_linux_dr_set_addr_data *datap = datap_voidp;
4972 + i386_linux_dr_set (tid, DR_FIRSTADDR + datap->regnum, datap->addr);
4975 +/* Set address REGNUM (zero based) to ADDR in all LWPs of CURRENT_INFERIOR.
4979 i386_linux_dr_set_addr (int regnum, CORE_ADDR addr)
4981 - struct lwp_info *lp;
4983 + struct i386_linux_dr_set_addr_data data;
4985 gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
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;
4992 + linux_nat_iterate_watchpoint_lwps (i386_linux_dr_set_addr_callback, &data);
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.
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)
5005 - return i386_linux_dr_get (inferior_ptid, DR_STATUS);
5008 + tid = TIDGET (inferior_ptid);
5010 + tid = PIDGET (inferior_ptid);
5012 + return i386_linux_dr_get (tid, DR_STATUS);
5015 -/* Unset MASK bits in DR_STATUS in all LWPs of LWP_LIST. */
5016 +/* Helper for i386_linux_dr_unset_status. */
5019 -i386_linux_dr_unset_status (unsigned long mask)
5020 +i386_linux_dr_unset_status_callback (int tid, void *mask_voidp)
5022 - struct lwp_info *lp;
5025 - ALL_LWPS (lp, ptid)
5027 - unsigned long value;
5028 + unsigned long mask = *(unsigned long *) mask_voidp;
5029 + unsigned long value;
5031 - value = i386_linux_dr_get (ptid, DR_STATUS);
5033 - i386_linux_dr_set (ptid, DR_STATUS, value);
5035 + value = i386_linux_dr_get (tid, DR_STATUS);
5037 + i386_linux_dr_set (tid, DR_STATUS, value);
5040 +/* Unset MASK bits in DR_STATUS in all LWPs of CURRENT_INFERIOR. */
5043 +i386_linux_dr_unset_status (unsigned long mask)
5045 + linux_nat_iterate_watchpoint_lwps (i386_linux_dr_unset_status_callback,
5050 i386_linux_new_thread (ptid_t ptid)
5053 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5056 + /* Verify DR_MIRROR is valid. */
5057 + gdb_assert (PIDGET (ptid) == PIDGET (inferior_ptid));
5059 + tid = TIDGET (ptid);
5061 + tid = PIDGET (ptid);
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]);
5068 - i386_linux_dr_set (ptid, DR_CONTROL, i386_linux_dr[DR_CONTROL]);
5069 + i386_linux_dr_set (tid, DR_CONTROL, dr_mirror->control);
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
5080 #include "gdb_assert.h"
5081 +#include "inferior.h"
5083 /* Support for hardware watchpoints and breakpoints using the i386
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)
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). */
5093 @@ -111,49 +111,60 @@ struct i386_dr_low_type i386_dr_low;
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)
5101 +i386_dr_vacant (struct i386_dr_mirror *dr_mirror, int i)
5103 + return (dr_mirror->control & (3 << (DR_ENABLE_SIZE * i))) == 0;
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)))
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)))
5114 +i386_dr_local_enable (struct i386_dr_mirror *dr_mirror, int i)
5116 + dr_mirror->control |= 1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * i);
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)))
5124 +i386_dr_disable (struct i386_dr_mirror *dr_mirror, int i)
5126 + dr_mirror->control &= ~(3 << (DR_ENABLE_SIZE * i));
5129 /* Set in DR7 the RW and LEN fields for the I'th debug register. */
5130 -#define I386_DR_SET_RW_LEN(i,rwlen) \
5132 - dr_control_mirror &= ~(0x0f << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
5133 - dr_control_mirror |= ((rwlen) << (DR_CONTROL_SHIFT+DR_CONTROL_SIZE*(i))); \
5137 +i386_dr_set_rw_len (struct i386_dr_mirror *dr_mirror, int i, unsigned rwlen)
5139 + dr_mirror->control &= ~(0x0f << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i));
5140 + dr_mirror->control |= rwlen << (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i);
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)
5147 +static inline unsigned
5148 +i386_dr_get_rw_len (struct i386_dr_mirror *dr_mirror, int i)
5150 + return ((dr_mirror->control >> (DR_CONTROL_SHIFT + DR_CONTROL_SIZE * i))
5154 /* Mask that this I'th watchpoint has triggered. */
5155 #define I386_DR_WATCH_MASK(i) (1 << (i))
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))
5160 +i386_dr_watch_hit (struct i386_dr_mirror *dr_mirror, int i)
5162 + return (dr_mirror->status & I386_DR_WATCH_MASK (i)) != 0;
5165 /* A macro to loop over all debug registers. */
5166 #define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++)
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;
5173 -/* Reference counts for each debug register. */
5174 -static int dr_ref_count[DR_NADDR];
5176 /* Whether or not to print the mirrored debug registers. */
5177 static int maint_show_dr;
5179 @@ -195,21 +206,80 @@ static int i386_handle_nonaligned_watchp
5181 /* Implementation. */
5183 +/* Per-inferior data key. */
5184 +static const struct inferior_data *i386_inferior_data;
5186 +struct i386_inferior_data
5188 + /* Copy of i386 hardware debug registers for performance reasons. */
5189 + struct i386_dr_mirror dr_mirror;
5193 +i386_inferior_data_cleanup (struct inferior *inf, void *arg)
5195 + struct i386_inferior_data *inf_data = arg;
5200 +static struct i386_inferior_data *
5201 +i386_inferior_data_get (void)
5203 + struct inferior *inf = current_inferior ();
5204 + struct i386_inferior_data *inf_data;
5206 + inf_data = inferior_data (inf, i386_inferior_data);
5207 + if (inf_data == NULL)
5209 + inf_data = xzalloc (sizeof (*inf_data));
5210 + set_inferior_data (current_inferior (), i386_inferior_data, inf_data);
5213 + if (inf->pid != ptid_get_pid (inferior_ptid))
5215 + static struct i386_inferior_data detached_inf_data_local;
5216 + static int detached_inf_pid = -1;
5218 + if (detached_inf_pid != ptid_get_pid (inferior_ptid))
5220 + detached_inf_pid = ptid_get_pid (inferior_ptid);
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;
5228 + return &detached_inf_data_local;
5234 /* Clear the reference counts and forget everything we knew about the
5237 +struct i386_dr_mirror *
5238 +i386_dr_mirror_get (void)
5240 + return &i386_inferior_data_get ()->dr_mirror;
5244 i386_cleanup_dregs (void)
5246 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5249 ALL_DEBUG_REGISTERS(i)
5252 - dr_ref_count[i] = 0;
5253 + dr_mirror->addr[i] = 0;
5254 + dr_mirror->ref_count[i] = 0;
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;
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)
5268 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5269 int addr_size = gdbarch_addr_bit (target_gdbarch) / 8;
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)
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]);
5292 @@ -313,6 +387,7 @@ Invalid hardware breakpoint length %d in
5294 i386_insert_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
5296 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
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)
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)
5310 - dr_ref_count[i]++;
5311 + dr_mirror->ref_count[i]++;
5315 @@ -335,7 +409,7 @@ i386_insert_aligned_watchpoint (CORE_ADD
5316 /* Next, look for a vacant debug register. */
5317 ALL_DEBUG_REGISTERS(i)
5319 - if (I386_DR_VACANT (i))
5320 + if (i386_dr_vacant (dr_mirror, i))
5324 @@ -346,9 +420,9 @@ i386_insert_aligned_watchpoint (CORE_ADD
5325 /* Now set up the register I to watch our region. */
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
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;
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);
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
5357 i386_remove_aligned_watchpoint (CORE_ADDR addr, unsigned len_rw_bits)
5359 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5362 ALL_DEBUG_REGISTERS(i)
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)
5370 - if (--dr_ref_count[i] == 0) /* no longer in use? */
5371 + if (--dr_mirror->ref_count[i] == 0) /* no longer in use? */
5373 /* Reset our mirror. */
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);
5384 @@ -556,26 +630,27 @@ i386_region_ok_for_watchpoint (CORE_ADDR
5386 i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
5388 + struct i386_dr_mirror *dr_mirror = i386_dr_mirror_get ();
5393 - dr_status_mirror = i386_dr_low.get_status ();
5394 + dr_mirror->status = i386_dr_low.get_status ();
5396 ALL_DEBUG_REGISTERS(i)
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
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))
5412 - addr = dr_mirror[i];
5413 + addr = dr_mirror->addr[i];
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;
5422 + if (i386_inferior_data == NULL)
5423 + i386_inferior_data
5424 + = register_inferior_data_with_cleanup (i386_inferior_data_cleanup);
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
5434 extern struct i386_dr_low_type i386_dr_low;
5436 +/* The number of debug address registers. */
5439 +/* Copy of hardware debug registers for performance reasons. */
5441 +struct i386_dr_mirror
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];
5447 + /* All the ADDR hardware registers have been written at least once. */
5448 + unsigned addr_preset : 1;
5450 + /* Reference counts for each debug register. */
5451 + int ref_count[DR_NADDR];
5453 + unsigned long status, control;
5456 +extern struct i386_dr_mirror *i386_dr_mirror_get (void);
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
5466 #include "inline-frame.h"
5468 #include "tracepoint.h"
5469 +#include "stap-probe.h"
5470 +#include "objfiles.h"
5472 /* Prototypes for local functions */
5474 @@ -2247,7 +2249,7 @@ static void insert_step_resume_breakpoin
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 *);
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:
5485 if (what.is_longjmp)
5487 - if (!gdbarch_get_longjmp_target_p (gdbarch)
5488 - || !gdbarch_get_longjmp_target (gdbarch,
5489 - frame, &jmp_buf_pc))
5490 + struct value *arg_value;
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);
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))
5503 fprintf_unfiltered (gdb_stdlog,
5504 @@ -4189,12 +4199,7 @@ process_event_stop_test:
5505 insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
5509 - struct symbol *func = get_frame_function (frame);
5512 - check_exception_resume (ecs, frame, func);
5514 + check_exception_resume (ecs, frame);
5518 @@ -5268,15 +5273,65 @@ insert_exception_resume_breakpoint (stru
5522 +/* A helper for check_exception_resume that sets an
5523 + exception-breakpoint based on a SystemTap probe. */
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)
5531 + struct value *arg_value;
5532 + CORE_ADDR handler;
5533 + struct breakpoint *bp;
5535 + arg_value = stap_safe_evaluate_at_pc (frame, 1);
5539 + handler = value_as_address (arg_value);
5542 + fprintf_unfiltered (gdb_stdlog,
5543 + "infrun: exception resume at %s\n",
5544 + paddress (get_objfile_arch (objfile),
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;
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. */
5558 check_exception_resume (struct execution_control_state *ecs,
5559 - struct frame_info *frame, struct symbol *func)
5560 + struct frame_info *frame)
5562 struct gdb_exception e;
5563 + struct objfile *objfile;
5564 + const struct stap_probe *probe;
5565 + struct symbol *func;
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);
5574 + insert_exception_resume_from_probe (ecs->event_thread, probe,
5579 + func = get_frame_function (frame);
5583 TRY_CATCH (e, RETURN_MASK_ERROR)
5585 @@ -6258,7 +6313,8 @@ static struct lval_funcs siginfo_value_f
5586 if there's no object available. */
5588 static struct value *
5589 -siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var)
5590 +siginfo_make_value (struct gdbarch *gdbarch, struct internalvar *var,
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);
5599 +/* Implementation of `siginfo' variable. */
5601 +static const struct internalvar_funcs siginfo_funcs =
5603 + siginfo_make_value,
5609 _initialize_infrun (void)
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);
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
5625 #include "arch-utils.h"
5627 #include "cli/cli-utils.h"
5628 +#include "stap-probe.h"
5630 /* We share this one with symtab.c, but it is not exported widely. */
5632 @@ -786,6 +787,7 @@ keep_name_info (char *p, int on_boundary
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
5638 This may all be followed by an "if EXPR", which we ignore.
5640 @@ -854,6 +856,9 @@ decode_line_1 (char **argptr, int funfir
5641 if (**argptr == '*')
5642 return decode_indirect (argptr);
5644 + if (strncmp (*argptr, "probe:", 6) == 0)
5645 + return parse_stap_probe (argptr, canonical);
5647 is_quoted = (strchr (get_gdb_completer_quote_characters (),
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;
5658 + /* If non-zero, the linespec result should be considered to be a
5659 + "pre-expanded" multi-location linespec. */
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,
5673 +/* Helper for linux_nat_iterate_watchpoint_lwps. */
5675 +struct iterate_watchpoint_lwps_data
5677 + linux_nat_iterate_watchpoint_lwps_ftype callback;
5678 + void *callback_data;
5682 +iterate_watchpoint_lwps_callback (struct lwp_info *lp, void *datap_voidp)
5684 + struct iterate_watchpoint_lwps_data *datap = datap_voidp;
5687 + tid = TIDGET (lp->ptid);
5689 + tid = PIDGET (lp->ptid);
5691 + datap->callback (tid, datap->callback_data);
5693 + /* Continue the traversal. */
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.
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). */
5704 +linux_nat_iterate_watchpoint_lwps
5705 + (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data)
5707 + struct iterate_watchpoint_lwps_data data;
5708 + int inferior_pid = ptid_get_pid (inferior_ptid);
5709 + struct inferior *inf = current_inferior ();
5711 + data.callback = callback;
5712 + data.callback_data = callback_data;
5714 + if (inf->pid == inferior_pid)
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. */
5720 + iterate_over_lwps (pid_to_ptid (inferior_pid),
5721 + iterate_watchpoint_lwps_callback, &data);
5725 + /* Detaching a new child PID temporarily present in INFERIOR_PID. */
5727 + callback (inferior_pid, callback_data);
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
5742 +typedef void (*linux_nat_iterate_watchpoint_lwps_ftype) (int tid, void *data);
5744 +extern void linux_nat_iterate_watchpoint_lwps
5745 + (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data);
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. */
5757 macho_symfile_relocate, /* Relocate a debug section. */
5758 + NULL, /* sym_get_probes */
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
5768 #include "interps.h"
5770 +#include "python/python.h"
5772 #include "cli/cli-cmds.h"
5773 #include "python/python.h"
5774 @@ -260,6 +261,8 @@ captured_main (void *data)
5776 char *ttyarg = NULL;
5778 + int python_script = 0;
5780 /* These are static so that we can take their address in an
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},
5788 + {"python", no_argument, 0, 'P'},
5789 + {"P", no_argument, 0, 'P'},
5791 {0, no_argument, 0, 0}
5795 + while (!python_script)
5799 @@ -472,6 +479,9 @@ captured_main (void *data)
5801 /* Long option that just sets a flag. */
5804 + python_script = 1;
5809 @@ -667,7 +677,31 @@ captured_main (void *data)
5811 /* Now that gdb_init has created the initial inferior, we're in
5812 position to set args for that inferior. */
5814 + if (python_script)
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)
5821 + fprintf_unfiltered (gdb_stderr,
5822 + _("%s: Python script file name required\n"),
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. */
5832 + /* FIXME: should read .gdbinit if, and only if, a prompt is
5833 + requested by the script. Though... maybe this is not
5835 + /* FIXME: likewise, reading in history. */
5836 + inhibit_gdbinit = 1;
5838 + else if (set_args)
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)
5844 /* Read in the old history after all the command files have been
5847 + if (!python_script)
5852 @@ -927,13 +962,25 @@ captured_main (void *data)
5853 /* Show time and/or space usage. */
5854 do_cleanups (pre_stat_chain);
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. */
5862 + if (python_script)
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]);
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. */
5879 + catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL);
5882 /* No exit -- exit is through quit_command. */
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);
5891 + fputs_unfiltered (_("\
5892 + gdb [options] [--python|-P] script-file [script-arguments ...]\n"), stream);
5894 + fputs_unfiltered (_("\n\
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);
5905 + fputs_unfiltered (_("\
5906 + --python, -P Following argument is Python script file; remaining\n\
5907 + arguments are passed to script.\n"), stream);
5909 + fputs_unfiltered (_("\
5910 --quiet Do not print version number on startup.\n\
5911 --readnow Fully read symbol files on first access.\n\
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 *
5921 - /* Get varobj handle, if a valid var obj name was specified */
5922 struct varobj *var = varobj_get_handle (name);
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. */
5932 default_symfile_relocate, /* Relocate a debug section. */
5933 + NULL, /* sym_probe_fns */
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));
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);
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
5959 #include "cp-support.h"
5960 #include "exceptions.h"
5961 +#include "dwarf2loc.h"
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;
5969 + struct cleanup *back_to;
5970 + struct type *saved_type = type;
5971 + CORE_ADDR saved_address = address;
5973 + back_to = make_cleanup (null_cleanup, 0);
5974 + address += embedded_offset;
5975 + type = object_address_get_data (type, &address);
5978 + fputs_filtered (object_address_data_not_valid (saved_type), stream);
5979 + gdb_flush (stream);
5980 + do_cleanups (back_to);
5983 + if (address != saved_address + embedded_offset)
5985 + size_t length = TYPE_LENGTH (type);
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;
5994 + address -= embedded_offset;
5995 switch (TYPE_CODE (type))
5997 case TYPE_CODE_ARRAY:
5998 @@ -120,8 +144,8 @@ pascal_val_print (struct type *type, con
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, "}");
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);
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);
6025 @@ -567,6 +593,7 @@ pascal_val_print (struct type *type, con
6029 + do_cleanups (back_to);
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,
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,
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);
6049 - if (objfile && (*objfile_func) (objfile, data))
6050 + if (objfile && objfile_func && (*objfile_func) (objfile, data))
6054 @@ -1561,7 +1562,8 @@ operator_check_standard (struct expressi
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))
6060 + && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
6063 /* Check objfile where is placed the code touching the variable. */
6064 @@ -1574,24 +1576,27 @@ operator_check_standard (struct expressi
6066 /* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
6068 - if (type && TYPE_OBJFILE (type)
6069 + if (type && type_func && (*type_func) (type, data))
6071 + if (type && TYPE_OBJFILE (type) && objfile_func
6072 && (*objfile_func) (TYPE_OBJFILE (type), data))
6074 - if (objfile && (*objfile_func) (objfile, data))
6075 + if (objfile && objfile_func && (*objfile_func) (objfile, data))
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.
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. */
6095 exp_iterate (struct expression *exp,
6096 + int (*type_func) (struct type *type, void *data),
6097 int (*objfile_func) (struct objfile *objfile, void *data),
6100 @@ -1606,7 +1611,9 @@ exp_iterate (struct expression *exp,
6102 pos = endpos - oplen;
6103 if (exp->language_defn->la_exp_desc->operator_check (exp, pos,
6104 - objfile_func, data))
6111 @@ -1637,8 +1644,29 @@ exp_uses_objfile (struct expression *exp
6113 gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
6115 - return exp_iterate (exp, exp_uses_objfile_iter, objfile);
6116 + return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile);
6119 +/* Helper for exp_types_mark_used. */
6123 +exp_types_mark_used_iter (struct type *type, void *unused)
6125 + type_mark_used (type);
6127 + /* Continue the traversal. */
6131 +/* Call type_mark_used for any type contained in EXP. */
6134 +exp_types_mark_used (struct expression *exp)
6136 + exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL);
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
6149 extern int operator_check_standard (struct expression *exp, int pos,
6150 + int (*type_func) (struct type *type,
6153 (struct objfile *objfile, 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,
6163 @@ -329,4 +332,10 @@ extern void parser_fprintf (FILE *, cons
6165 extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
6167 +extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
6170 +extern void exp_types_mark_used (struct expression *exp);
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;
6183 +booke_insert_point_callback (int tid, void *pp_voidp)
6185 + struct ppc_hw_breakpoint *pp = pp_voidp;
6187 + booke_insert_point (pp, tid);
6190 /* Return the number of registers needed for a ranged breakpoint. */
6193 @@ -1654,8 +1662,6 @@ static int
6194 ppc_linux_insert_hw_breakpoint (struct gdbarch *gdbarch,
6195 struct bp_target_info *bp_tgt)
6198 - struct lwp_info *lp;
6199 struct ppc_hw_breakpoint p;
6201 if (!have_ptrace_booke_interface ())
6202 @@ -1681,18 +1687,23 @@ ppc_linux_insert_hw_breakpoint (struct g
6206 - ALL_LWPS (lp, ptid)
6207 - booke_insert_point (&p, TIDGET (ptid));
6208 + linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
6214 +booke_remove_point_callback (int tid, void *pp_voidp)
6216 + struct ppc_hw_breakpoint *pp = pp_voidp;
6218 + booke_remove_point (pp, tid);
6222 ppc_linux_remove_hw_breakpoint (struct gdbarch *gdbarch,
6223 struct bp_target_info *bp_tgt)
6226 - struct lwp_info *lp;
6227 struct ppc_hw_breakpoint p;
6229 if (!have_ptrace_booke_interface ())
6230 @@ -1718,8 +1729,7 @@ ppc_linux_remove_hw_breakpoint (struct g
6234 - ALL_LWPS (lp, ptid)
6235 - booke_remove_point (&p, TIDGET (ptid));
6236 + linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
6240 @@ -1946,6 +1956,15 @@ ppc_linux_can_accel_watchpoint_condition
6241 && check_condition (addr, cond, &data_value, &len));
6245 +set_saved_dabr_value_callback (int tid, void *retp_voidp)
6247 + int *retp = retp_voidp;
6249 + if (ptrace (PTRACE_SET_DEBUGREG, tid, 0, saved_dabr_value) < 0)
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)
6260 - struct lwp_info *lp;
6264 if (have_ptrace_booke_interface ())
6265 @@ -2010,8 +2027,7 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
6267 create_watchpoint_request (&p, addr, len, rw, cond, 1);
6269 - ALL_LWPS (lp, ptid)
6270 - booke_insert_point (&p, TIDGET (ptid));
6271 + linux_nat_iterate_watchpoint_lwps (booke_insert_point_callback, &p);
6275 @@ -2054,12 +2070,8 @@ ppc_linux_insert_watchpoint (CORE_ADDR a
6277 saved_dabr_value = dabr_value;
6279 - ALL_LWPS (lp, ptid)
6280 - if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
6281 - saved_dabr_value) < 0)
6285 + linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &ret);
6289 @@ -2069,8 +2081,6 @@ static int
6290 ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
6291 struct expression *cond)
6293 - struct lwp_info *lp;
6297 if (have_ptrace_booke_interface ())
6298 @@ -2079,20 +2089,16 @@ ppc_linux_remove_watchpoint (CORE_ADDR a
6300 create_watchpoint_request (&p, addr, len, rw, cond, 0);
6302 - ALL_LWPS (lp, ptid)
6303 - booke_remove_point (&p, TIDGET (ptid));
6304 + linux_nat_iterate_watchpoint_lwps (booke_remove_point_callback, &p);
6310 saved_dabr_value = 0;
6311 - ALL_LWPS (lp, ptid)
6312 - if (ptrace (PTRACE_SET_DEBUGREG, TIDGET (ptid), 0,
6313 - saved_dabr_value) < 0)
6317 + linux_nat_iterate_watchpoint_lwps (set_saved_dabr_value_callback, &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,
6327 val = access_value_history (0);
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. */
6334 if (voidprint || (val && value_type (val) &&
6335 TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
6337 @@ -1476,6 +1481,24 @@ x_command (char *exp, int from_tty)
6338 set_internalvar (lookup_internalvar ("__"), last_examine_value);
6343 +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
6346 +print_types_mark_used (void)
6348 + struct display *d;
6350 + if (last_examine_value)
6351 + type_mark_used (value_type (last_examine_value));
6353 + for (d = display_chain; d; d = d->next)
6355 + exp_types_mark_used (d->exp);
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."));
6368 + observer_attach_mark_used (print_types_mark_used);
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
6376 +# Iterator over frames.
6378 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
6393 +class FrameIterator:
6394 + """An iterator that iterates over frames."""
6396 + def __init__ (self, frame):
6397 + "Initialize a FrameIterator. FRAME is the starting frame."
6398 + self.frame = frame
6400 + def __iter__ (self):
6404 + result = self.frame
6405 + if result is None:
6406 + raise StopIteration
6407 + self.frame = result.older ()
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
6414 +# Wrapper API for frames.
6416 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
6433 +# FIXME: arguably all this should be on Frame somehow.
6434 +class FrameWrapper:
6435 + def __init__ (self, frame):
6436 + self.frame = frame;
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:
6444 + stream.write (sym.print_name + "=")
6446 + val = self.read_var (sym)
6449 + # FIXME: would be nice to have a more precise exception here.
6450 + except RuntimeError, text:
6453 + stream.write ("???")
6455 + stream.write (str (val))
6457 + def print_frame_locals (self, stream, func):
6462 + block = func.value
6465 + if sym.is_argument:
6468 + self.write_symbol (stream, sym, block)
6469 + stream.write ('\n')
6471 + def print_frame_args (self, stream, func):
6476 + block = func.value
6479 + if not sym.is_argument:
6483 + stream.write (", ")
6485 + self.write_symbol (stream, sym, block)
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")
6496 + sal = self.find_sal ()
6498 + name = self.name ()
6501 + if pc != sal.pc or not sal.symtab:
6502 + stream.write (" 0x%08x in" % pc)
6503 + stream.write (" " + name + " (")
6505 + func = self.function ()
6506 + self.print_frame_args (stream, func)
6508 + stream.write (")")
6510 + if sal.symtab and sal.symtab.filename:
6511 + stream.write (" at " + sal.symtab.filename)
6512 + stream.write (":" + str (sal.line))
6514 + if not self.name () or (not sal.symtab or not sal.symtab.filename):
6515 + lib = gdb.solib_address (pc)
6517 + stream.write (" from " + lib)
6519 + stream.write ("\n")
6522 + self.print_frame_locals (stream, func)
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
6531 +# Filtering backtrace.
6533 +# Copyright (C) 2008, 2011 Free Software Foundation, Inc.
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.
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.
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/>.
6551 +# Our only exports.
6552 +__all__ = ['push_frame_filter', 'create_frame_filter']
6554 +frame_filter = None
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
6565 + frame_filter = lambda iterator, filter = frame_filter: constructor (filter (iterator))
6567 +def create_frame_filter (iter):
6568 + global frame_filter
6569 + if frame_filter is None:
6571 + return frame_filter (iter)
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
6580 +# Copyright (C) 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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)
6606 + def invoke(self, arg, from_tty):
6607 + gdb.execute (self.real + ' ' + arg, from_tty)
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."""
6616 + def __init__ (self):
6617 + # Completion is not quite right here.
6618 + super (AliasCommand, self).__init__ ("alias", gdb.COMMAND_NONE,
6619 + gdb.COMPLETE_COMMAND)
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()
6627 + start = args.index ('=')
6629 + except ValueError:
6632 + target = " ".join(args[end:])
6633 + AliasImplementation (" ".join (args[0:start]), target,
6634 + "This command is an alias for '%s'." % target)
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
6642 +# New backtrace command.
6644 +# Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
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.
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.
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/>.
6660 +import gdb.backtrace
6662 +from gdb.FrameIterator import FrameIterator
6663 +from gdb.FrameWrapper import FrameWrapper
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."""
6671 + set_doc = "Enable or disable reverse backtraces."
6672 + show_doc = "Show whether backtraces will be printed in reverse order."
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
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.
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()
6693 + def reverse_iter (self, iter):
6696 + result.append (item)
6700 + def final_n (self, iter, x):
6703 + result.append (item)
6706 + def invoke (self, arg, from_tty):
6712 + for word in arg.split (" "):
6715 + elif word == 'raw':
6717 + elif word == 'full':
6720 + count = int (word)
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))
6728 + iter = gdb.backtrace.create_frame_filter (iter)
6730 + # Now wrap in an iterator that numbers the frames.
6731 + iter = itertools.izip (itertools.count (0), iter)
6733 + # Reverse if the user wanted that.
6734 + if self.reverse.value:
6735 + iter = self.reverse_iter (iter)
6737 + # Extract sub-range user wants.
6739 + iter = self.final_n (iter, count)
6741 + iter = itertools.islice (iter, 0, count)
6744 + sys.stdout.write ("#%-2d" % pair[0])
6745 + pair[1].describe (sys.stdout, full)
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
6753 +# Ignore errors in user commands.
6755 +# Copyright (C) 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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."""
6777 + def __init__ (self):
6778 + super (IgnoreErrorsCommand, self).__init__ ("ignore-errors",
6779 + gdb.COMMAND_OBSCURE,
6781 + gdb.COMPLETE_COMMAND)
6783 + def invoke (self, arg, from_tty):
6785 + gdb.execute (arg, from_tty)
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
6795 +# pahole command for gdb
6797 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
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."""
6819 + def __init__ (self):
6820 + super (Pahole, self).__init__ ("pahole", gdb.COMMAND_NONE,
6821 + gdb.COMPLETE_SYMBOL)
6823 + def pahole (self, type, level, name):
6829 + print '%sstruct %s {' % (' ' * (2 * level), tag)
6831 + for field in type.fields ():
6832 + # Skip static fields.
6833 + if not hasattr (field, ('bitpos')):
6836 + ftype = field.type.strip_typedefs()
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
6845 + # TARGET_CHAR_BIT here...
6846 + fieldsize = 8 * ftype.sizeof
6849 + print ' /* %3d %3d */' % (int (bitpos / 8), int (fieldsize / 8)),
6850 + bitpos = bitpos + fieldsize
6852 + if ftype.code == gdb.TYPE_CODE_STRUCT:
6853 + self.pahole (ftype, level + 1, field.name)
6855 + print ' ' * (2 + 2 * level),
6856 + print '%s %s' % (str (ftype), field.name)
6858 + print ' ' * (14 + 2 * level),
6859 + print '} %s' % name
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
6867 + self.pahole (type, 0, '')
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
6875 +# Demand-loading commands.
6877 +# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
6895 +class RequireCommand (gdb.Command):
6896 + """Prefix command for requiring features."""
6898 + def __init__ (self):
6899 + super (RequireCommand, self).__init__ ("require",
6900 + gdb.COMMAND_SUPPORT,
6901 + gdb.COMPLETE_NONE,
6904 +class RequireSubcommand (gdb.Command):
6905 + """Demand-load a command by name."""
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)
6913 + def invoke (self, arg, from_tty):
6914 + for cmd in arg.split():
6915 + exec ('import gdb.' + self.name + '.' + cmd, globals ())
6917 + def complete (self, text, word):
6918 + dir = gdb.pythondir + '/gdb/' + self.name
6920 + for file in os.listdir(dir):
6921 + if not file.startswith (word) or not file.endswith ('.py'):
6923 + feature = file[0:-3]
6924 + if feature == 'require' or feature == '__init__':
6926 + result.append (feature)
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
6939 +# Copyright (C) 2009 Free Software Foundation, Inc.
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.
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.
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/>.
6956 +from gdb.FrameIterator import FrameIterator
6957 +from gdb.FrameWrapper import FrameWrapper
6959 +class UptoPrefix (gdb.Command):
6960 + def __init__ (self):
6961 + super (UptoPrefix, self).__init__ ("upto", gdb.COMMAND_STACK,
6964 +class UptoImplementation (gdb.Command):
6965 + def __init__ (self, subcommand):
6966 + super (UptoImplementation, self).__init__ ("upto " + subcommand,
6967 + gdb.COMMAND_STACK)
6969 + def search (self):
6970 + saved = gdb.selected_frame ()
6971 + iter = FrameIterator (saved)
6974 + for frame in iter:
6977 + if self.filter (frame):
6978 + wrapper = FrameWrapper (frame)
6979 + wrapper.describe (sys.stdout, False)
6986 + raise RuntimeError, 'Could not find a matching frame'
6988 + def invoke (self, arg, from_tty):
6989 + self.rx = re.compile (arg)
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
6998 + def __init__ (self):
6999 + super (UptoSymbolCommand, self).__init__ ("symbol")
7001 + def filter (self, frame):
7002 + name = frame.name ()
7003 + if name is not None:
7004 + if self.rx.search (name) is not None:
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."""
7014 + def __init__ (self):
7015 + super (UptoSourceCommand, self).__init__ ("source")
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:
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."""
7030 + def __init__ (self):
7031 + super (UptoObjectCommand, self).__init__ ("object")
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:
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."""
7046 + def __init__ (self):
7047 + super (UptoWhereCommand, self).__init__ ("where")
7049 + def filter (self, frame):
7051 + if gdb.parse_and_eval (self.expression):
7057 + def invoke (self, arg, from_tty):
7058 + self.expression = arg
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
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
7077 +# Caller-is functions.
7079 +# Copyright (C) 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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."""
7105 + def __init__ (self):
7106 + super (CallerIs, self).__init__ ("caller_is")
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 ()
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."""
7123 + def __init__ (self):
7124 + super (CallerMatches, self).__init__ ("caller_matches")
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
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
7140 +# In-scope function.
7142 +# Copyright (C) 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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."""
7163 + def __init__ (self):
7164 + super (InScope, self).__init__ ("in_scope")
7166 + def invoke (self, *vars):
7167 + if len (vars) == 0:
7168 + raise TypeError, "in_scope takes at least one argument"
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))
7174 + block = gdb.selected_frame ().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)
7182 + block = block.superblock
7184 + return wanted == found
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
7192 #include "language.h"
7195 +#include "observer.h"
7196 +#include "gdb_assert.h"
7198 typedef struct pyty_type_object
7200 @@ -37,11 +39,19 @@ typedef struct pyty_type_object
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.
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;
7214 +/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */
7215 +static type_object *pyty_objects_discardable;
7218 static PyTypeObject type_object_type;
7220 /* A Field object. */
7221 @@ -919,8 +929,63 @@ typy_richcompare (PyObject *self, PyObje
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;
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. */
7233 +typy_link (type_object *type_obj)
7235 + type_obj->prev = NULL;
7237 + if (type_obj->type && TYPE_OBJFILE (type_obj->type))
7239 + struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
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);
7247 + else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type))
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;
7256 + type_obj->next = NULL;
7259 +/* Unlink TYPE_OBJ from its current list. Permanent types are not linked
7260 + anywhere and this function has no effect on them. */
7262 +typy_unlink (type_object *type_obj)
7264 + if (type_obj->prev)
7265 + type_obj->prev->next = type_obj->next;
7266 + else if (type_obj->type && TYPE_OBJFILE (type_obj->type))
7268 + /* Must reset head of list. */
7269 + struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
7271 + set_objfile_data (objfile, typy_objfile_data_key, type_obj->next);
7274 + else if (pyty_objects_discardable == type_obj)
7275 + pyty_objects_discardable = type_obj->next;
7278 + if (type_obj->next)
7279 + type_obj->next->prev = type_obj->prev;
7283 save_objfile_types (struct objfile *objfile, void *datum)
7285 @@ -938,12 +1003,13 @@ save_objfile_types (struct objfile *objf
7287 type_object *next = obj->next;
7289 - htab_empty (copied_types);
7290 + gdb_assert (TYPE_OBJFILE (obj->type) == objfile);
7291 + typy_unlink (obj);
7293 - obj->type = copy_type_recursive (objfile, obj->type, copied_types);
7294 + obj->type = copy_type_recursive (obj->type, copied_types);
7298 + gdb_assert (TYPE_OBJFILE (obj->type) == NULL);
7303 @@ -954,43 +1020,28 @@ save_objfile_types (struct objfile *objf
7307 -set_type (type_object *obj, struct type *type)
7308 +typy_dealloc (PyObject *obj)
7312 - if (type && TYPE_OBJFILE (type))
7314 - struct objfile *objfile = TYPE_OBJFILE (type);
7316 - obj->next = objfile_data (objfile, typy_objfile_data_key);
7318 - obj->next->prev = obj;
7319 - set_objfile_data (objfile, typy_objfile_data_key, obj);
7323 + type_object *type_obj = (type_object *) obj;
7325 + typy_unlink (type_obj);
7327 + type_obj->ob_type->tp_free (obj);
7331 +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
7333 -typy_dealloc (PyObject *obj)
7334 +typy_types_mark_used (void)
7336 - type_object *type = (type_object *) obj;
7339 - type->prev->next = type->next;
7340 - else if (type->type && TYPE_OBJFILE (type->type))
7342 - /* Must reset head of list. */
7343 - struct objfile *objfile = TYPE_OBJFILE (type->type);
7346 - set_objfile_data (objfile, typy_objfile_data_key, type->next);
7349 - type->next->prev = type->prev;
7350 + type_object *type_obj;
7352 - type->ob_type->tp_free (type);
7353 + for (type_obj = pyty_objects_discardable;
7355 + type_obj = type_obj->next)
7356 + type_mark_used (type_obj->type);
7360 /* Create a new Type referring to TYPE. */
7362 @@ -1000,7 +1051,10 @@ type_to_type_object (struct type *type)
7364 type_obj = PyObject_New (type_object, &type_object_type);
7366 - set_type (type_obj, type);
7368 + type_obj->type = type;
7369 + typy_link (type_obj);
7372 return (PyObject *) type_obj;
7374 @@ -1074,6 +1128,10 @@ gdbpy_initialize_types (void)
7376 Py_INCREF (&field_object_type);
7377 PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
7380 + observer_attach_mark_used (typy_types_mark_used);
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
7390 #include "infcall.h"
7391 #include "expression.h"
7393 +#include "observer.h"
7397 @@ -1210,6 +1211,19 @@ gdbpy_is_value_object (PyObject *obj)
7398 return PyObject_TypeCheck (obj, &value_object_type);
7402 +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
7405 +python_types_mark_used (void)
7407 + value_object *iter;
7409 + for (iter = values_in_python; iter; iter = iter->next)
7410 + type_mark_used (value_type (iter->value));
7415 gdbpy_initialize_values (void)
7417 @@ -1220,6 +1234,10 @@ gdbpy_initialize_values (void)
7418 PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
7420 values_in_python = NULL;
7423 + observer_attach_mark_used (python_types_mark_used);
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"
7435 #include "version.h"
7436 +#include "inferior.h"
7437 +#include "gdbthread.h"
7439 #include "gdbthread.h"
7440 +#include "event-top.h"
7442 static PyMethodDef GdbMethods[];
7444 @@ -769,6 +772,53 @@ gdbpy_print_stack (void)
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;
7451 +/* True if we are currently in a call to 'gdb.cli', false otherwise. */
7454 +/* Enter the command loop. */
7457 +gdbpy_cli (PyObject *unused1, PyObject *unused2)
7459 + if (! running_python_script || in_cli)
7460 + return PyErr_Format (PyExc_RuntimeError, "cannot invoke CLI recursively");
7463 + cli_command_loop ();
7469 +/* Set up the Python argument vector and evaluate a script. This is
7470 + used to implement 'gdb -P'. */
7473 +run_python_script (int argc, char **argv)
7477 + /* We never free this, since we plan to exit at the end. */
7478 + ensure_python_env (get_current_arch (), current_language);
7480 + running_python_script = 1;
7481 + PySys_SetArgv (argc - 1, argv + 1);
7482 + input = fopen (argv[0], "r");
7485 + fprintf (stderr, "could not open %s: %s\n", argv[0], strerror (errno));
7488 + PyRun_SimpleFile (input, argv[0]);
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" },
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
7513 void source_python_script (FILE *stream, const char *file);
7515 +void run_python_script (int argc, char **argv);
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. */
7527 default_symfile_relocate, /* Relocate a debug section. */
7528 + NULL, /* sym_get_probes */
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
7538 const struct language_defn *language;
7539 struct value_print_options opts;
7540 + struct cleanup *old_chain;
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);
7547 opts.summary = summary;
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);
7555 ui_out_field_stream (uiout, "value", stb);
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
7563 +/* SystemTap probe support for GDB.
7565 + Copyright (C) 2011 Free Software Foundation, Inc.
7567 + This file is part of GDB.
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.
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.
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/>. */
7583 +#include "stap-probe.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"
7592 +#include "exceptions.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"
7602 +/* This define is used to inform whether we are compiling an agent
7603 + expression or not. */
7605 +#define STAP_COMPILING_AGENT_EXPR_P(eval_info) \
7606 + (eval_info->aexpr != NULL)
7608 +/* The various possibilities of bitness defined for a probe's argument.
7610 + The relationship is:
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@'. */
7618 +enum stap_arg_bitness
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,
7627 +/* The following structure represents a single argument for the probe. */
7629 +struct stap_probe_arg
7631 + /* The bitness of this argument. */
7632 + enum stap_arg_bitness bitness;
7634 + /* The string representing this argument. */
7638 +/* The maximum number of arguments that a probe can have,
7639 + as defined in <sys/sdt.h>. */
7641 +#define STAP_MAX_ARGS 10
7643 +/* Structure that holds information about all arguments of a probe. */
7645 +struct stap_args_info
7647 + /* The number of valid parsed arguments. */
7650 + /* The probe to which these arguments belong. */
7651 + struct stap_probe *probe;
7653 + /* Information about each argument. */
7654 + struct stap_probe_arg *arg;
7657 +/* Structure that contains all the necessary information to evaluate
7660 +struct stap_evaluation_info
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;
7668 + /* Modifiable version of the above pointer. */
7671 + /* The pointer to the current gdbarch. */
7672 + struct gdbarch *gdbarch;
7674 + /* The pointer to the current frame, used when accessing registers'
7676 + struct frame_info *frame;
7678 + /* The bitness specified for this argument. */
7679 + enum stap_arg_bitness bitness;
7681 + /* If the above flag is true (one), this field will contain the
7682 + pointer to the agent expression. */
7683 + struct agent_expr *aexpr;
7685 + /* The value we are modifying (for agent expression). */
7686 + struct axs_value *avalue;
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. */
7693 +static struct stap_args_info dummy_stap_args_info =
7694 + { 0, NULL, NULL };
7696 +static struct value *stap_evaluate_probe_argument_2
7697 + (struct stap_evaluation_info *eval_info,
7698 + struct value *lhs, int prec);
7700 +static struct value *stap_evaluate_conditionally
7701 + (struct stap_evaluation_info *eval_info);
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
7709 +stap_skip_whitespace_cond (char **s, int inside_paren)
7712 + *s = skip_spaces (*s);
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. */
7720 +stap_parse_arg (const char **p)
7722 + char *cur = (char *) *p;
7724 + int paren_open = 0;
7731 + /* If we're here, then we have already parsed everything
7732 + from this argument. */
7741 + stap_skip_whitespace_cond (&cur, paren_open);
7751 + cur = skip_spaces (cur);
7754 + case '+': case '-':
7755 + case '*': case '/':
7756 + case '>': case '<': case '|': case '&':
7757 + case '^': case '!':
7765 + if (c != '<' && c != '>')
7779 + if (c != '=' && c != '<' && c != '>' && c != '!')
7802 + /* Infix operators take two arguments, one on either
7803 + side. Skipping the whitespaces that may happen on the
7805 + stap_skip_whitespace_cond (&cur, paren_open);
7812 + stap_skip_whitespace_cond (&cur, paren_open);
7813 + if (*cur >= 'a' && *cur <= 'z')
7815 + /* We're dealing with a register name. */
7816 + while (isalnum (*cur))
7819 + stap_skip_whitespace_cond (&cur, paren_open);
7821 + /* Some registers (e.g. floating-point register stack
7822 + registers on Intel i386) have the following syntax:
7824 + `%st(0)', `%st(1)', and so on.
7826 + So it's ok to expect parenthesis here. */
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. */
7836 + stap_skip_whitespace_cond (&cur, paren_open);
7838 + /* We only expect one number. */
7841 + stap_skip_whitespace_cond (&cur, paren_open);
7849 + /* This is an integer constant. */
7851 + stap_skip_whitespace_cond (&cur, paren_open);
7853 + while (isdigit (*cur))
7856 + stap_skip_whitespace_cond (&cur, paren_open);
7860 + case '0': case '1': case '2': case '3': case '4':
7861 + case '5': case '6': case '7': case '8': case '9':
7866 + while (isdigit (*cur))
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);
7875 + case '+': case '-':
7876 + /* We may find the `@' sign, and it means that the
7877 + argument has finished, so we shouldn't advance the
7879 + if (cur[1] && (cur[1] == '4' || cur[1] == '8')
7880 + && cur[2] && cur[2] == '@')
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. */
7894 + /* We may also have sentences in the form:
7910 +/* Helper function which is responsible for freeing the space allocated to
7911 + hold information about a probe's arguments. */
7914 +stap_free_args_info (void *args_info_ptr)
7916 + struct stap_args_info *a = (struct stap_args_info *) args_info_ptr;
7919 + for (i = 0; i < a->n_args; i++)
7921 + xfree (a->arg[i].arg_str);
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.
7932 + Consider the following argument string:
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. */
7941 +stap_parse_probe_arguments (struct stap_probe *probe)
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. */
7959 + /* For now, we assume everything is not going to work. */
7960 + probe->parsed_args = &dummy_stap_args_info;
7962 + if (!cur || !*cur || *cur == ':')
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));
7969 + /* Ok, let's start. */
7970 + current_state = NEW_ARG;
7974 + switch (current_state)
7979 + if (current_arg >= STAP_MAX_ARGS)
7981 + complaint (&symfile_complaints,
7982 + _("probe `%s' has more arguments than the maximum "
7983 + "allowed"), probe->name);
7984 + do_cleanups (back_to);
7988 + current_state = BITNESS;
7993 + enum stap_arg_bitness b;
7994 + int got_minus = 0;
7996 + /* We expect to find something like:
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
8003 + if ((*cur == '-' && cur[1] && cur[2] != '@')
8006 + current_state = PARSE_ARG;
8007 + args_info->arg[current_arg].bitness
8008 + = STAP_ARG_BITNESS_UNDEFINED;
8014 + /* Discard the `-'. */
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;
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);
8036 + args_info->arg[current_arg].bitness = b;
8037 + /* Discard the number and the `@' sign. */
8040 + current_state = PARSE_ARG;
8046 + const char *start = cur;
8048 + if (!stap_parse_arg (&cur))
8050 + /* We have tried to parse this argument, but it's
8051 + malformed. This is an error. */
8052 + do_cleanups (back_to);
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;
8065 + if (!*cur && current_state != NEW_ARG)
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'"),
8073 + do_cleanups (back_to);
8078 + args_info->n_args = current_arg + 1;
8079 + args_info->arg = xrealloc (args_info->arg,
8081 + * sizeof (struct stap_probe_arg));
8082 + args_info->probe = probe;
8084 + probe->parsed_args = args_info;
8086 + discard_cleanups (back_to);
8089 +/* See definition in stap-probe.h. */
8092 +stap_get_probe_argument_count (const struct stap_probe *probe)
8094 + if (!probe->parsed_args)
8095 + stap_parse_probe_arguments ((struct stap_probe *) probe);
8097 + return probe->parsed_args->n_args;
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. */
8105 +stap_get_operator_prec (enum exp_opcode op)
8109 + case BINOP_LOGICAL_OR:
8112 + case BINOP_LOGICAL_AND:
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:
8121 + case BINOP_BITWISE_IOR: case BINOP_BITWISE_AND:
8122 + case BINOP_BITWISE_XOR: case UNOP_LOGICAL_NOT:
8125 + case BINOP_MUL: case BINOP_DIV: case BINOP_REM:
8126 + case BINOP_LSH: case BINOP_RSH:
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. */
8139 +stap_get_opcode (char **s, enum exp_opcode *op)
8158 + if (isalpha (**s))
8160 + /* Dealing with a register name. */
8176 + else if (**s == '=')
8181 + else if (**s == '>')
8184 + *op = BINOP_NOTEQUAL;
8195 + else if (**s == '=')
8203 + *op = BINOP_BITWISE_IOR;
8207 + *op = BINOP_LOGICAL_OR;
8212 + *op = BINOP_BITWISE_AND;
8216 + *op = BINOP_LOGICAL_AND;
8221 + *op = BINOP_BITWISE_XOR;
8225 + *op = UNOP_LOGICAL_NOT;
8242 + *op = BINOP_EQUAL;
8246 + /* We didn't find any operator. */
8254 +/* Given the operator OPCODE, this function generates agent bytecode
8258 +stap_opcode_to_ax (struct stap_evaluation_info *eval_info,
8259 + enum exp_opcode opcode)
8261 + struct agent_expr *expr = eval_info->aexpr;
8266 + ax_simple (expr, aop_mul);
8270 + ax_simple (expr, aop_div_signed);
8274 + ax_simple (expr, aop_rem_unsigned);
8278 + ax_simple (expr, aop_less_signed);
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);
8289 + /* A > B is B < A */
8290 + ax_simple (expr, aop_swap);
8291 + ax_simple (expr, aop_less_signed);
8295 + /* A >= B is !(A < B) */
8296 + ax_simple (expr, aop_less_signed);
8297 + ax_simple (expr, aop_log_not);
8300 + case BINOP_NOTEQUAL:
8301 + ax_simple (expr, aop_equal);
8302 + ax_simple (expr, aop_log_not);
8306 + ax_simple (expr, aop_lsh);
8310 + ax_simple (expr, aop_rsh_unsigned);
8313 + case BINOP_BITWISE_IOR:
8314 + ax_simple (expr, aop_bit_or);
8317 + case BINOP_LOGICAL_OR:
8318 + error (_("Operator logical-or (`||') not supported yet."));
8321 + case BINOP_BITWISE_AND:
8322 + ax_simple (expr, aop_bit_and);
8325 + case BINOP_LOGICAL_AND:
8326 + error (_("Operator logical-and (`&&') not supported yet."));
8329 + case BINOP_BITWISE_XOR:
8330 + ax_simple (expr, aop_bit_xor);
8333 + case UNOP_LOGICAL_NOT:
8334 + ax_simple (expr, aop_log_not);
8338 + ax_simple (expr, aop_add);
8342 + ax_simple (expr, aop_sub);
8346 + ax_simple (expr, aop_equal);
8350 + error (_("Invalid operator."));
8354 +/* Returns 1 if *S is an operator, zero otherwise. */
8357 +stap_is_operator (char *s)
8366 + if (*s == '%' && isalpha (s[1]))
8367 + /* Register name. */
8370 + return (op == '+' || op == '-' || op == '*' || op == '/'
8371 + || op == '>' || op == '<' || op == '!' || op == '^'
8372 + || op == '|' || op == '&' || op == '%' || op == '=');
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. */
8381 +static struct value *
8382 +stap_fetch_reg_value (struct stap_evaluation_info *eval_info,
8383 + struct value *displacement)
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;
8391 + int len, regnum, indirect_p = 0;
8392 + struct value *ret = NULL;
8394 + /* The function which called us did not check if the expression
8395 + buffer was empty. */
8396 + gdb_assert (s && *s);
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);
8405 + /* Valid register name on x86 platforms are:
8407 + [paren]%{a-z0-9}[paren]
8409 + Let's check for that here. */
8413 + if (!*s || *s != '%'
8414 + || (*s == '%' && !isalpha (s[1])))
8415 + error (_("Invalid register name on expression `%s'."),
8416 + eval_info->saved_expr);
8418 + /* The presence of parenthesis means that we want to indirect
8422 + else if (*s == '%')
8425 + if (!*s || !isalpha (*s))
8426 + error (_("Invalid register name on expression `%s'."),
8427 + eval_info->saved_expr);
8430 + error (_("Invalid register name on expression `%s'."),
8431 + eval_info->saved_expr);
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);
8438 + /* Ok, let's calculate the size of the register name. */
8440 + while (isalnum (*s))
8445 + if (indirect_p && *s == ')')
8448 + regname = alloca (len + 1);
8449 + strncpy (regname, start, len);
8450 + regname[len] = '\0';
8452 + /* Translating the register name into the corresponding number. */
8453 + regnum = user_reg_map_name_to_regnum (gdbarch, regname, len);
8456 + error (_("Invalid register name `%s' on expression `%s'."),
8457 + regname, eval_info->saved_expr);
8459 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8460 + ax_reg (eval_info->aexpr, regnum);
8462 + ret = value_of_register (regnum, frame);
8466 + struct type *t = NULL;
8467 + enum agent_op aop = aop_ref32;
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. */
8477 + case STAP_ARG_BITNESS_UNDEFINED:
8478 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8480 + if (gdbarch_addr_bit (gdbarch) == 32)
8487 + if (gdbarch_addr_bit (gdbarch) == 32)
8488 + t = lookup_pointer_type
8489 + (builtin_type (gdbarch)->builtin_uint32);
8491 + t = lookup_pointer_type
8492 + (builtin_type (gdbarch)->builtin_uint64);
8496 + case STAP_ARG_BITNESS_32BIT_SIGNED:
8497 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8500 + t = lookup_pointer_type
8501 + (builtin_type (gdbarch)->builtin_int32);
8504 + case STAP_ARG_BITNESS_32BIT_UNSIGNED:
8505 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8508 + t = lookup_pointer_type
8509 + (builtin_type (gdbarch)->builtin_uint32);
8512 + case STAP_ARG_BITNESS_64BIT_SIGNED:
8513 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8516 + t = lookup_pointer_type
8517 + (builtin_type (gdbarch)->builtin_int64);
8520 + case STAP_ARG_BITNESS_64BIT_UNSIGNED:
8521 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8524 + t = lookup_pointer_type
8525 + (builtin_type (gdbarch)->builtin_uint64);
8529 + internal_error (__FILE__, __LINE__,
8530 + _("Undefined bitness for probe."));
8536 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8538 + ax_const_l (eval_info->aexpr, value_as_long (displacement));
8539 + ax_simple (eval_info->aexpr, aop_add);
8542 + ret = value_ptradd (ret, value_as_long (displacement));
8545 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8549 + gdb_assert (aop == aop_ref32 || aop == aop_ref64);
8550 + ax_trace_quick (eval_info->aexpr, aop == aop_ref32 ? 4 : 8);
8552 + ax_simple (eval_info->aexpr, aop);
8556 + ret = value_cast (t, ret);
8557 + ret = value_ind (ret);
8561 + /* Updating the expression buffer pointer, because we have made
8562 + some modifications to it before. */
8563 + eval_info->exp_buf = s;
8568 +/* This function tries to evaluate a single operand of the expression.
8570 + Single operands can be:
8572 + - unary operators `-' and `~';
8573 + - integer constants (beginning with `$');
8574 + - register access, with/out displacement and indirection. */
8576 +static struct value *
8577 +stap_evaluate_single_operand (struct stap_evaluation_info *eval_info)
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;
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);
8591 + switch (*eval_info->exp_buf)
8593 + case '-': case '~':
8595 + char c = *eval_info->exp_buf;
8597 + /* This is an unary operator (either `-' or `~').
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 `~').
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 `(%'.
8609 + If it is followed by a `$', then it is an integer constant, and
8610 + we should apply the correct operation to it. */
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] != '%')
8618 + struct value *tmp_res;
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);
8629 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
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);
8637 + res = value_neg (tmp_res);
8641 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8642 + ax_simple (eval_info->aexpr, aop_bit_not);
8644 + res = value_complement (tmp_res);
8647 + else if (isdigit (*eval_info->exp_buf))
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
8656 + error (_("Invalid operator `%c' for register displacement "
8657 + "on expression `%s'."), c, eval_info->saved_expr);
8659 + number = strtol (eval_info->exp_buf,
8660 + &eval_info->exp_buf, 0) * -1;
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);
8670 + = value_from_longest (builtin_type (gdbarch)->builtin_int,
8673 + res = stap_fetch_reg_value (eval_info, res);
8675 + else if (*eval_info->exp_buf == '$')
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);
8686 + if (!STAP_COMPILING_AGENT_EXPR_P (eval_info))
8688 + = value_from_longest (builtin_type (gdbarch)->builtin_int,
8691 + ax_const_l (eval_info->aexpr, number);
8693 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8697 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8698 + ax_simple (eval_info->aexpr, aop_log_not);
8700 + res = value_neg (res);
8704 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8705 + ax_simple (eval_info->aexpr, aop_bit_not);
8707 + res = value_complement (res);
8711 + error (_("Invalid operand to unary operator `%c' on "
8712 + "expression `%s'."), c, eval_info->saved_expr);
8716 + case '0': case '1': case '2': case '3': case '4':
8717 + case '5': case '6': case '7': case '8': case '9':
8719 + int number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
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);
8729 + res = value_from_longest (builtin_type (gdbarch)->builtin_int,
8732 + res = stap_fetch_reg_value (eval_info, res);
8740 + /* This is an integer constant. We just have to read the number
8742 + ++eval_info->exp_buf;
8743 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8745 + number = strtol (eval_info->exp_buf, &eval_info->exp_buf, 0);
8747 + if (STAP_COMPILING_AGENT_EXPR_P (eval_info))
8748 + ax_const_l (eval_info->aexpr, number);
8750 + res = value_from_longest (builtin_type (gdbarch)->builtin_int,
8753 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8757 + case '(': case '%':
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);
8767 + error (_("Operator `%c' not recognized on expression `%s'."),
8768 + *eval_info->exp_buf, eval_info->saved_expr);
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:
8778 + - Unary operators;
8779 + - Integer constants;
8780 + - Register displacement, indirection, and direct access;
8781 + - Parenthesized operand. */
8783 +static struct value *
8784 +stap_evaluate_conditionally (struct stap_evaluation_info *eval_info)
8786 + char *s = eval_info->exp_buf;
8787 + struct value *ret = NULL;
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 == '(')
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);
8804 + ret = stap_evaluate_probe_argument_2 (eval_info,
8805 + /*lhs=*/NULL, /*prec=*/0);
8807 + if (*eval_info->exp_buf != ')')
8808 + error (_("Missign close-paren on expression `%s'."),
8809 + eval_info->saved_expr);
8811 + ++eval_info->exp_buf;
8812 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8815 + error (_("Cannot evaluate expression `%s'."),
8816 + eval_info->saved_expr);
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. */
8825 +static struct value *
8826 +stap_evaluate_probe_argument_2 (struct stap_evaluation_info *eval_info,
8827 + struct value *lhs, int prec)
8829 + struct value *rhs = NULL;
8830 + int compiling_p = STAP_COMPILING_AGENT_EXPR_P (eval_info);
8832 + /* This is an operator-precedence parser and evaluator.
8834 + We work with left- and right-sides of expressions, and
8835 + evaluate them depending on the precedence of the operators
8838 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
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);
8847 + /* Start to evaluate the right-side, and to "join" left and right sides
8848 + depending on the operation specified.
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 != ')')
8857 + char *tmp_exp_buf;
8858 + enum exp_opcode opcode;
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);
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);
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
8880 + eval_info->exp_buf = tmp_exp_buf;
8881 + eval_info->exp_buf = skip_spaces (eval_info->exp_buf);
8883 + /* Evaluate the right-side of the expression. */
8884 + rhs = stap_evaluate_conditionally (eval_info);
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))
8891 + enum exp_opcode lookahead_opcode;
8892 + int lookahead_prec;
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);
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. */
8905 + rhs = stap_evaluate_probe_argument_2 (eval_info,
8906 + rhs, lookahead_prec);
8909 + /* Now, "join" both left and right sides into one left-side, using
8910 + the specified operator. */
8912 + stap_opcode_to_ax (eval_info, opcode);
8914 + lhs = value_binop (lhs, rhs, opcode);
8920 +/* This function fills the necessary arguments for the evaluation function
8923 +static struct value *
8924 +stap_evaluate_probe_argument_1 (struct objfile *objfile,
8925 + const struct stap_probe *probe,
8926 + struct frame_info *frame,
8929 + struct stap_evaluation_info eval_info;
8930 + char *s = (char *) probe->parsed_args->arg[n].arg_str;
8931 + struct value *res, *vs[4];
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;
8943 + res = stap_evaluate_probe_argument_2 (&eval_info,
8944 + /*lhs=*/NULL, /*prec=*/0);
8947 + error (_("Could not evaluate expression `%s'."),
8948 + eval_info.saved_expr);
8953 +/* See definition in stap-probe.h. */
8956 +stap_evaluate_probe_argument (struct objfile *objfile,
8957 + const struct stap_probe *probe,
8958 + struct frame_info *frame,
8961 + if (!probe->parsed_args)
8962 + stap_parse_probe_arguments ((struct stap_probe *) probe);
8964 + if (!probe->parsed_args->arg
8965 + || n >= probe->parsed_args->n_args)
8968 + return stap_evaluate_probe_argument_1 (objfile, probe, frame, n);
8971 +/* Helper function which compiles the probe's argument N into an
8972 + agent expression, suitable for using with tracepoints. */
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,
8981 + struct stap_evaluation_info eval_info;
8982 + struct gdbarch *gdbarch = expr->gdbarch;
8983 + char *s = (char *) probe->parsed_args->arg[n].arg_str;
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;
8995 + /* We can always use this kind. */
8996 + value->kind = axs_rvalue;
8998 + /* Figuring out the correct type for this axs_value. */
8999 + switch (eval_info.bitness)
9001 + case STAP_ARG_BITNESS_UNDEFINED:
9002 + if (gdbarch_addr_bit (gdbarch) == 32)
9003 + value->type = builtin_type (gdbarch)->builtin_uint32;
9005 + value->type = builtin_type (gdbarch)->builtin_uint64;
9008 + case STAP_ARG_BITNESS_32BIT_SIGNED:
9009 + value->type = builtin_type (gdbarch)->builtin_int32;
9012 + case STAP_ARG_BITNESS_32BIT_UNSIGNED:
9013 + value->type = builtin_type (gdbarch)->builtin_uint32;
9016 + case STAP_ARG_BITNESS_64BIT_SIGNED:
9017 + value->type = builtin_type (gdbarch)->builtin_int64;
9020 + case STAP_ARG_BITNESS_64BIT_UNSIGNED:
9021 + value->type = builtin_type (gdbarch)->builtin_uint64;
9025 + internal_error (__FILE__, __LINE__,
9026 + _("Undefined bitness for probe."));
9030 + stap_evaluate_probe_argument_2 (&eval_info,
9031 + /*lhs=*/NULL, /*prec=*/0);
9034 +/* See definition in stap-probe.h. */
9037 +stap_compile_to_ax (struct objfile *objfile,
9038 + const struct stap_probe *probe,
9039 + struct agent_expr *expr,
9040 + struct axs_value *value,
9043 + if (!probe->parsed_args)
9044 + stap_parse_probe_arguments ((struct stap_probe *) probe);
9046 + if (!probe->parsed_args->arg
9047 + || n >= probe->parsed_args->n_args)
9050 + stap_compile_to_ax_1 (objfile, probe, expr, value, n);
9054 +stap_safe_evaluate_at_pc (struct frame_info *frame, int n)
9056 + const struct stap_probe *probe;
9057 + struct objfile *objfile;
9060 + probe = find_probe_by_pc (get_frame_pc (frame), &objfile);
9063 + gdb_assert (objfile->sf && objfile->sf->sym_probe_fns);
9066 + = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9068 + if (n >= n_probes)
9071 + return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
9077 +/* This function frees the space allocated to hold information about
9078 + the probe's parsed arguments. */
9081 +stap_free_parsed_args (struct stap_args_info *parsed_args)
9086 + || parsed_args == &dummy_stap_args_info
9087 + || parsed_args->n_args == 0)
9090 + for (i = 0; i < parsed_args->n_args; i++)
9091 + xfree (parsed_args->arg);
9093 + xfree (parsed_args);
9096 +/* A utility structure. A VEC of these is built when handling "info
9099 +struct stap_probe_and_objfile
9102 + const struct stap_probe *probe;
9103 + /* The probe's objfile. */
9104 + struct objfile *objfile;
9107 +typedef struct stap_probe_and_objfile stap_entry;
9108 +DEF_VEC_O (stap_entry);
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. */
9115 +compile_rx_or_error (regex_t *pattern, const char *rx, const char *message)
9122 + code = regcomp (pattern, rx, REG_NOSUB);
9124 + make_regfree_cleanup (pattern);
9127 + char *err = get_regcomp_error (code, pattern);
9129 + make_cleanup (xfree, err);
9130 + error (_("%s: %s"), message, err);
9134 +/* Make a vector of probes matching OBJNAME, PROVIDER, and PROBE.
9135 + Each argument is a regexp, or NULL, which matches anything. */
9137 +static VEC (stap_entry) *
9138 +collect_probes (char *objname, char *provider, char *probe)
9140 + struct objfile *objfile;
9141 + VEC (stap_entry) *result = NULL;
9142 + struct cleanup *cleanup;
9143 + regex_t obj_pat, prov_pat, probe_pat;
9145 + cleanup = make_cleanup (VEC_cleanup (stap_entry), &result);
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"));
9151 + ALL_OBJFILES (objfile)
9153 + const struct stap_probe *probes;
9154 + int i, num_probes;
9156 + if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9161 + if (regexec (&obj_pat, objfile->name, 0, NULL, 0) != 0)
9165 + probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9166 + for (i = 0; i < num_probes; ++i)
9172 + if (regexec (&prov_pat, probes[i].provider, 0, NULL, 0) != 0)
9178 + if (regexec (&probe_pat, probes[i].name, 0, NULL, 0) != 0)
9182 + entry.probe = &probes[i];
9183 + entry.objfile = objfile;
9184 + VEC_safe_push (stap_entry, result, &entry);
9188 + discard_cleanups (cleanup);
9192 +/* A qsort comparison function for stap_entry objects. */
9195 +compare_entries (const void *a, const void *b)
9197 + const stap_entry *ea = a;
9198 + const stap_entry *eb = b;
9201 + v = strcmp (ea->probe->provider, eb->probe->provider);
9205 + v = strcmp (ea->probe->name, eb->probe->name);
9209 + if (ea->probe->address < eb->probe->address)
9211 + if (ea->probe->address > eb->probe->address)
9214 + return strcmp (ea->objfile->name, eb->objfile->name);
9217 +/* Implementation of the "info probes" command. */
9220 +info_probes_command (char *arg, int from_tty)
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;
9228 + provider = extract_arg (&arg);
9231 + make_cleanup (xfree, provider);
9233 + probe = extract_arg (&arg);
9236 + make_cleanup (xfree, probe);
9238 + objname = extract_arg (&arg);
9240 + make_cleanup (xfree, objname);
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");
9250 + if (! VEC_empty (stap_entry, items))
9251 + qsort (VEC_address (stap_entry, items),
9252 + VEC_length (stap_entry, items),
9253 + sizeof (stap_entry),
9256 + addr_width = 4 + (gdbarch_ptr_bit (get_current_arch ()) / 4);
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",
9263 + ui_out_table_header (uiout, 30, ui_left, "object", _("Object"));
9264 + ui_out_table_body (uiout);
9266 + for (i = 0; VEC_iterate (stap_entry, items, i, entry); ++i)
9268 + struct cleanup *inner;
9270 + inner = make_cleanup_ui_out_tuple_begin_end (uiout, "probe");
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");
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");
9284 + do_cleanups (inner);
9287 + any_found = ! VEC_empty (stap_entry, items);
9288 + do_cleanups (cleanup);
9291 + ui_out_message (uiout, 0, _("No probes matched.\n"));
9296 +/* See definition in stap-probe.h. */
9298 +const struct stap_probe *
9299 +find_probe_in_objfile (struct objfile *objfile,
9300 + const char *provider,
9303 + const struct stap_probe *probes;
9304 + int i, num_probes;
9306 + if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9309 + probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9310 + for (i = 0; i < num_probes; ++i)
9312 + if (strcmp (probes[i].provider, provider) != 0)
9315 + if (strcmp (probes[i].name, name) != 0)
9318 + return &probes[i];
9324 +/* See definition in stap-probe.h. */
9326 +struct symtabs_and_lines
9327 +parse_stap_probe (char **argptr, struct linespec_result *canonical)
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;
9336 + result.sals = NULL;
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);
9345 + /* Extract each word from the argument, separated by ":"s. */
9346 + p = strchr (arg, ':');
9349 + /* This is `probe:name'. */
9354 + char *hold = p + 1;
9357 + p = strchr (hold, ':');
9360 + /* This is `probe:provider:name'. */
9366 + /* This is `probe:objfile:provider:name'. */
9368 + objfile_name = arg;
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"));
9382 + canonical->canonical = NULL;
9384 + ALL_OBJFILES (objfile)
9386 + const struct stap_probe *probes;
9387 + int i, num_probes;
9389 + if (! objfile->sf || ! objfile->sf->sym_probe_fns)
9393 + && FILENAME_CMP (objfile->name, objfile_name) != 0
9394 + && FILENAME_CMP (lbasename (objfile->name), objfile_name) != 0)
9397 + probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile, &num_probes);
9398 + for (i = 0; i < num_probes; ++i)
9400 + struct symtab_and_line *sal;
9402 + if (provider && strcmp (probes[i].provider, provider) != 0)
9405 + if (strcmp (probes[i].name, name) != 0)
9409 + result.sals = xrealloc (result.sals,
9410 + result.nelts * sizeof (struct symtab_and_line));
9411 + sal = &result.sals[result.nelts - 1];
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;
9423 + canonical->canonical = xrealloc (canonical->canonical,
9424 + result.nelts * sizeof (char **));
9425 + canonical->canonical[result.nelts - 1] = xstrdup (full_arg);
9430 + if (result.nelts == 0)
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>"),
9441 + canonical->special_display = 1;
9442 + canonical->pre_expanded = 1;
9445 + do_cleanups (cleanup);
9452 +/* See definition in stap-probe.h. */
9454 +const struct stap_probe *
9455 +find_probe_by_pc (CORE_ADDR pc, struct objfile **objfile_out)
9457 + struct objfile *objfile;
9459 + ALL_OBJFILES (objfile)
9461 + const struct stap_probe *probes;
9462 + int i, num_probes;
9465 + if (! objfile->sf || ! objfile->sf->sym_probe_fns)
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)
9472 + if (probes[i].address == pc)
9474 + *objfile_out = objfile;
9475 + return &probes[i];
9483 +/* This is called to compute the value of one of the $_probe_arg*
9484 + convenience variables. */
9486 +static struct value *
9487 +compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
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;
9497 + /* SEL==10 means "_probe_argc". */
9498 + gdb_assert (sel >= 0 && sel <= STAP_MAX_ARGS);
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));
9505 + = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9508 + return value_from_longest (builtin_type (arch)->builtin_int, n_probes);
9510 + if (sel >= n_probes)
9511 + error (_("Invalid probe argument %d -- probe has %d arguments available"),
9514 + return objfile->sf->sym_probe_fns->sym_evaluate_probe_argument (objfile,
9519 +/* This is called to compile one of the $_probe_arg* convenience
9520 + variables into an agent expression. */
9523 +compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
9524 + struct axs_value *value, void *data)
9526 + CORE_ADDR pc = expr->scope;
9527 + int sel = (int) (uintptr_t) data;
9528 + struct objfile *objfile;
9529 + const struct stap_probe *pc_probe;
9532 + /* SEL==10 means "_probe_argc". */
9533 + gdb_assert (sel >= 0 && sel <= 10);
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));
9540 + = objfile->sf->sym_probe_fns->sym_get_probe_argument_count (objfile,
9544 + value->kind = axs_rvalue;
9545 + value->type = builtin_type (expr->gdbarch)->builtin_int;
9546 + ax_const_l (expr, n_probes);
9550 + gdb_assert (sel >= 0);
9551 + if (sel >= n_probes)
9552 + error (_("Invalid probe argument %d -- probe has %d arguments available"),
9555 + objfile->sf->sym_probe_fns->sym_compile_to_ax (objfile, pc_probe,
9556 + expr, value, sel);
9561 +/* Implementation of `$_probe_arg*' set of variables. */
9563 +static const struct internalvar_funcs probe_funcs =
9565 + compute_probe_arg,
9566 + compile_probe_arg,
9571 +_initialize_stap_probe (void)
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."));
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);
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
9609 +/* SystemTap probe support for GDB.
9611 + Copyright (C) 2011 Free Software Foundation, Inc.
9613 + This file is part of GDB.
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.
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.
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/>. */
9628 +#if !defined (STAP_PROBE_H)
9629 +#define STAP_PROBE_H 1
9631 +struct stap_args_info;
9633 +struct linespec_result;
9635 +/* Main structure which holds information about a SystemTap probe. */
9639 + /* The provider of this probe. */
9640 + const char *provider;
9642 + /* The name of the probe. */
9645 + /* The address where the probe is inserted. */
9646 + CORE_ADDR address;
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;
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. */
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;
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
9667 +extern struct symtabs_and_lines parse_stap_probe (char **argptr,
9668 + struct linespec_result *canon);
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. */
9673 +extern const struct stap_probe *find_probe_in_objfile (struct objfile *objfile,
9674 + const char *provider,
9675 + const char *name);
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. */
9681 +extern const struct stap_probe *find_probe_by_pc (CORE_ADDR pc,
9682 + struct objfile **objfile_out);
9684 +/* Given PROBE, returns the number of arguments present in that probe's
9685 + argument string. */
9687 +extern int stap_get_probe_argument_count (const struct stap_probe *probe);
9689 +/* Given PARSED_ARGS, frees the space allocated to hold information about
9690 + the probe's parsed arguments. */
9692 +extern void stap_free_parsed_args (struct stap_args_info *parsed_args);
9694 +/* Evaluates the probe's argument N, returning a value corresponding
9697 +extern struct value *stap_evaluate_probe_argument (struct objfile *objfile,
9698 + const struct stap_probe *probe,
9699 + struct frame_info *frame,
9702 +/* Compile the probe's argument N to agent expression. */
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,
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. */
9714 +extern struct value *stap_safe_evaluate_at_pc (struct frame_info *frame,
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;
9732 /* Comparison function for symbol look ups. */
9734 @@ -290,6 +295,52 @@ struct quick_symbol_functions
9738 +/* Structure of functions used for SystemTap probe support. If one of
9739 + these functions is provided, all must be. */
9741 +struct sym_probe_fns
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 *,
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);
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
9762 + struct value *(*sym_evaluate_probe_argument) (struct objfile *objfile,
9763 + const struct stap_probe *probe,
9764 + struct frame_info *frame,
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,
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);
9784 /* Structure to keep track of symbol reading functions for various
9785 object file types. */
9787 @@ -360,6 +411,10 @@ struct sym_fns
9789 bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf);
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;
9795 /* The "quick" (aka partial) symbol functions for this symbol
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)
9804 sal->explicit_pc = 0;
9805 sal->explicit_line = 0;
9806 + sal->semaphore = 0;
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
9819 + /* If non-zero, the semaphore location associated with a SystemTap
9821 + CORE_ADDR semaphore;
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
9830 + .file "x86_64-vla-pointer.c"
9831 + .section .debug_abbrev,"",@progbits
9833 + .section .debug_info,"",@progbits
9835 + .section .debug_line,"",@progbits
9840 + .type foo, @function
9843 + .file 1 "x86_64-vla-pointer.c"
9851 + movl %edi, -36(%rbp)
9854 + movq %rax, -48(%rbp)
9856 + movl -36(%rbp), %edx
9859 + movq %rax, -24(%rbp)
9867 + movq %rsp, -56(%rbp)
9868 + movq -56(%rbp), %rax
9872 + movq %rax, -56(%rbp)
9873 + movq -56(%rbp), %rax
9874 + movq %rax, -16(%rbp)
9880 + movl -4(%rbp), %esi
9881 + movl -4(%rbp), %eax
9883 + movq -16(%rbp), %rdx
9885 + movb %cl, (%rdx,%rax)
9889 + movl -4(%rbp), %eax
9890 + cmpl -36(%rbp), %eax
9895 + movq -16(%rbp), %rax
9897 + movq -48(%rbp), %rsp
9903 + .section .debug_frame,"",@progbits
9905 + .long .LECIE0-.LSCIE0
9921 + .long .LEFDE0-.LASFDE0
9927 + .long .LCFI0-.LFB2
9933 + .long .LCFI1-.LCFI0
9938 + .section .eh_frame,"a",@progbits
9940 + .long .LECIE1-.LSCIE1
9958 + .long .LEFDE1-.LASFDE1
9960 + .long .LASFDE1-.Lframe1
9965 + .long .LCFI0-.LFB2
9971 + .long .LCFI1-.LCFI0
9978 + .section .debug_loc,"",@progbits
9981 + .quad .LFB2-.Ltext0
9982 + .quad .LCFI0-.Ltext0
9986 + .quad .LCFI0-.Ltext0
9987 + .quad .LCFI1-.Ltext0
9991 + .quad .LCFI1-.Ltext0
9992 + .quad .LFE2-.Ltext0
9998 + .section .debug_info
10000 + .long .Ldebug_end - .Ldebug_start
10003 + .long .Ldebug_abbrev0
10012 + .long .Ldebug_line0
10022 + .long .Ltype_int - .Ldebug_relative
10027 + .long .Ltype_int - .Ldebug_relative
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) */
10040 + .long .Ltag_pointer - .debug_info
10042 + /* Debugging only: Skip the typedef indirection. */
10043 + .long .Ltag_array_type - .debug_info
10045 + /* DW_AT_location: DW_FORM_block1: start */
10050 + .byte 0x6 /* DW_OP_deref */
10052 + .byte 0x96 /* DW_OP_nop */
10054 + /* DW_AT_location: DW_FORM_block1: end */
10059 + .long .Ltype_int - .Ldebug_relative
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 */
10076 + .byte 0x97 /* DW_OP_push_object_address */
10078 + .byte 0x6 /* DW_OP_deref */
10080 + .byte 0x96 /* DW_OP_nop */
10082 +2: /* DW_AT_data_location: DW_FORM_block1: end */
10084 + .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */
10101 + .section .debug_abbrev
10159 + .uleb128 0x4 /* .Ltag_pointer abbrev */
10160 + .uleb128 0x0f /* DW_TAG_pointer_type */
10209 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
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 */
10223 + .uleb128 0x49 /* DW_AT_type */
10224 + .uleb128 0x13 /* DW_FORM_ref4 */
10250 + .section .debug_pubnames,"",@progbits
10253 + .long .Ldebug_info0
10258 + .section .debug_aranges,"",@progbits
10261 + .long .Ldebug_info0
10267 + .quad .Letext0-.Ltext0
10270 + .section .debug_str,"MS",@progbits,1
10276 + .string "x86_64-vla-pointer.c"
10278 + .string "array_t"
10282 + .string "gdb.arch"
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
10292 +/* This testcase is part of GDB, the GNU debugger.
10294 + Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
10314 + typedef char array_t[size];
10318 + for (i = 0; i < size; i++)
10321 + array[0] = 0; /* break-here */
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
10340 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>.
10355 +if ![istarget "x86_64-*-*"] then {
10356 + verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
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"
10369 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
10370 + untested "Couldn't compile test program"
10376 +gdb_reinitialize_dir $srcdir/$subdir
10377 +gdb_load ${binfile}
10379 +if ![runto_main] {
10380 + untested x86_64-vla-pointer
10384 +gdb_breakpoint "break_here"
10386 +gdb_continue_to_breakpoint "break_here"
10388 +gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array"
10389 +gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array"
10391 +gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array"
10392 +gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array"
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'"
10399 +gdb_continue_to_breakpoint "break_here"
10401 +gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array"
10402 +gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array"
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
10411 + .file "x86_64-vla-typedef.c"
10412 + .section .debug_abbrev,"",@progbits
10414 + .section .debug_info,"",@progbits
10416 + .section .debug_line,"",@progbits
10421 + .type foo, @function
10424 + .file 1 "x86_64-vla-typedef.c"
10432 + movl %edi, -36(%rbp)
10435 + movq %rax, -48(%rbp)
10437 + movl -36(%rbp), %edx
10440 + movq %rax, -24(%rbp)
10448 + movq %rsp, -56(%rbp)
10449 + movq -56(%rbp), %rax
10453 + movq %rax, -56(%rbp)
10454 + movq -56(%rbp), %rax
10455 + movq %rax, -16(%rbp)
10457 + movl $0, -4(%rbp)
10461 + movl -4(%rbp), %esi
10462 + movl -4(%rbp), %eax
10464 + movq -16(%rbp), %rdx
10466 + movb %cl, (%rdx,%rax)
10468 + addl $1, -4(%rbp)
10470 + movl -4(%rbp), %eax
10471 + cmpl -36(%rbp), %eax
10474 + .globl break_here
10476 + movq -16(%rbp), %rax
10478 + movq -48(%rbp), %rsp
10484 + .section .debug_frame,"",@progbits
10486 + .long .LECIE0-.LSCIE0
10502 + .long .LEFDE0-.LASFDE0
10506 + .quad .LFE2-.LFB2
10508 + .long .LCFI0-.LFB2
10514 + .long .LCFI1-.LCFI0
10519 + .section .eh_frame,"a",@progbits
10521 + .long .LECIE1-.LSCIE1
10539 + .long .LEFDE1-.LASFDE1
10541 + .long .LASFDE1-.Lframe1
10543 + .long .LFE2-.LFB2
10546 + .long .LCFI0-.LFB2
10552 + .long .LCFI1-.LCFI0
10559 + .section .debug_loc,"",@progbits
10562 + .quad .LFB2-.Ltext0
10563 + .quad .LCFI0-.Ltext0
10567 + .quad .LCFI0-.Ltext0
10568 + .quad .LCFI1-.Ltext0
10572 + .quad .LCFI1-.Ltext0
10573 + .quad .LFE2-.Ltext0
10579 + .section .debug_info
10580 + .long .Ldebug_end - .Ldebug_start
10583 + .long .Ldebug_abbrev0
10592 + .long .Ldebug_line0
10616 + .long .Ltag_array_type - .debug_info
10617 + .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
10622 + .long .Ltag_typedef - .debug_info
10624 + /* Debugging only: Skip the typedef indirection. */
10625 + .long .Ltag_array_type - .debug_info
10627 + /* DW_AT_location: DW_FORM_block1: start */
10632 + .byte 0x6 /* DW_OP_deref */
10634 + .byte 0x96 /* DW_OP_nop */
10636 + /* DW_AT_location: DW_FORM_block1: end */
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 */
10657 + .byte 0x97 /* DW_OP_push_object_address */
10658 + .byte 0x6 /* DW_OP_deref */
10659 +2: /* DW_AT_data_location: DW_FORM_block1: end */
10661 + .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
10676 + .section .debug_abbrev
10788 + .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
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 */
10802 + .uleb128 0x49 /* DW_AT_type */
10803 + .uleb128 0x13 /* DW_FORM_ref4 */
10829 + .section .debug_pubnames,"",@progbits
10832 + .long .Ldebug_info0
10837 + .section .debug_aranges,"",@progbits
10840 + .long .Ldebug_info0
10846 + .quad .Letext0-.Ltext0
10849 + .section .debug_str,"MS",@progbits,1
10855 + .string "x86_64-vla-typedef.c"
10857 + .string "array_t"
10861 + .string "gdb.arch"
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
10871 +/* This testcase is part of GDB, the GNU debugger.
10873 + Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>. */
10893 + typedef char array_t[size];
10897 + for (i = 0; i < size; i++)
10900 + array[0] = 0; /* break-here */
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
10919 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>.
10934 +# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
10936 +if ![istarget "x86_64-*-*"] then {
10937 + verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
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"
10950 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
10951 + untested "Couldn't compile test program"
10957 +gdb_reinitialize_dir $srcdir/$subdir
10958 +gdb_load ${binfile}
10960 +if ![runto_main] {
10961 + untested x86_64-vla-typedef
10965 +gdb_breakpoint "break_here"
10967 +gdb_continue_to_breakpoint "break_here"
10969 +gdb_test "whatis array" "type = array_t" "first: whatis array"
10971 +gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
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'"
10978 +gdb_continue_to_breakpoint "break_here"
10980 +gdb_test "whatis array" "type = array_t" "second: whatis array"
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
10989 int array[] = {1, 2, 3, 4};
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"
11010 +set test "p unbound.a == &unbound.a\[0\]"
11011 +gdb_test_multiple $test $test {
11012 + -re " = 1\r\n$gdb_prompt $" {
11015 + -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
11016 + unsupported "$test (no GCC)"
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" "
11025 {$_siginfo = void} \
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>} \
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
11046 +/* This testcase is part of GDB, the GNU debugger.
11048 + Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
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
11071 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>.
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"
11093 +clean_restart $binfile
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
11102 +/* This testcase is part of GDB, the GNU debugger.
11104 + Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>. */
11121 +#define _SDT_HAS_SEMAPHORES
11122 +__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
11123 +#define TEST teste_user_semaphore
11125 +__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
11126 +#define TEST2 teste_two_semaphore
11135 +#include <sys/sdt.h>
11137 +/* We only support SystemTap and only the v3 form. */
11138 +#if _SDT_NOTE_TYPE != 3
11139 +#error "not using SystemTap v3 probes"
11146 + STAP_PROBE (teste, two);
11153 + STAP_PROBE (teste, two);
11160 + STAP_PROBE1(teste, user, x);
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
11176 +# Copyright (C) 2011 Free Software Foundation, Inc.
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.
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.
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/>.
11191 +set testfile stap-probe
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
11199 + if {$arg != ""} {
11200 + set arg "additional_flags=$arg"
11201 + set addendum ", with semaphore"
11203 + set addendum ", no semaphore"
11206 + if {[prepare_for_testing ${testfile}.exp ${testfile} ${testfile}.c \
11207 + [concat $arg debug]]} {
11211 + if ![runto_main] {
11215 + gdb_test "print \$_probe_argc" "No SystemTap probe at PC $hex" \
11216 + "check argument not at probe point$addendum"
11218 + gdb_test "info probes" \
11219 + "teste *user *$hex .*" \
11220 + "info probes$addendum"
11222 + if {[runto "probe:teste:user"]} {
11223 + pass "run to probe:teste:user$addendum"
11225 + fail "run to probe:teste:user$addendum"
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"
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"
11243 +if {[stap_test] == -1} {
11244 + untested stap-probe.exp
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
11253 +/* This testcase is part of GDB, the GNU debugger.
11255 + Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>. */
11270 +#include <stdlib.h>
11273 +main (int argc, char **argv)
11277 + array[0] = array[0];
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
11288 +# Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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
11313 +# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
11315 +# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
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"
11326 +set f [open "|getconf PAGESIZE" "r"]
11332 +gdb_reinitialize_dir $srcdir/$subdir
11333 +gdb_load ${binfile}
11335 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
11337 +if { [runto_main] < 0 } {
11338 + untested vla-overflow
11342 +# Get the GDB memory size when we stay at main.
11344 +proc memory_v_pages_get {} {
11345 + global pid_of_gdb pagesize
11346 + set fd [open "/proc/$pid_of_gdb/statm"]
11349 + # number of pages of virtual memory
11350 + scan $line "%d" drs
11354 +set pages_found [memory_v_pages_get]
11356 +# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
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"
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 \"\$@\""
11369 +remote_exec host "chmod +x $shfile"
11377 +gdb_reinitialize_dir $srcdir/$subdir
11378 +gdb_load ${binfile}
11380 +set pid_of_gdb [exp_pid -i [board_info host fileid]]
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.
11387 +verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
11389 +gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
11391 +verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
11393 +# `abort' can get expressed as `*__GI_abort'.
11394 +gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
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
11402 +/* This testcase is part of GDB, the GNU debugger.
11404 + Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>. */
11419 +#include <string.h>
11427 +bar (char *a, char *b, char *c, int size)
11429 + memset (a, '1', size);
11430 + memset (b, '2', size);
11431 + memset (c, '3', 48);
11437 + char temp1[size];
11440 + temp1[size - 1] = '\0';
11442 + char temp2[size];
11444 + bar (temp1, temp2, temp3, size);
11446 + marker (); /* break-here */
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
11462 +# Copyright 2008 Free Software Foundation, Inc.
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.
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.
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/>.
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"
11487 +gdb_reinitialize_dir $srcdir/$subdir
11488 +gdb_load ${binfile}
11490 +if ![runto_main] {
11495 +gdb_breakpoint [gdb_get_line_number "break-here"]
11497 +gdb_continue_to_breakpoint "break-here"
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"
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"
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"
11511 +gdb_continue_to_breakpoint "break-here"
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"
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"
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
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"
11537 + -re "\r\n$gdb_prompt $" {
11543 unsupported "nextoverthrow.exp could not find _Unwind_DebugHook"
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
11551 +/* This testcase is part of GDB, the GNU debugger.
11553 + Copyright 2010 Free Software Foundation, Inc.
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.
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.
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/>. */
11568 +/* Debug information */
11570 +/* We will `break *main' at the very first instruction. */
11571 +#define main_length 1
11575 + /* See DW_OP_lit3 + 1 (0-based). */
11576 + .string "seennotseen"
11578 + .section .debug_info
11580 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
11582 + .2byte 2 /* DWARF version number */
11583 + .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
11584 + .byte 4 /* Pointer Size (in bytes) */
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 */
11595 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
11596 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
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 */
11604 + /* DW_AT_upper_bound is referencing an optimized-out variable. */
11606 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
11607 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
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 */
11615 + /* DW_AT_upper_bound is referencing register. */
11617 + .uleb128 2 /* Abbrev: DW_TAG_array_type */
11618 + .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
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 */
11626 + .byte 0 /* End of children of die */
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 */
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 */
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 */
11646 + /* optimized-out variable for b_string. */
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 */
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> */
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> */
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> */
11678 + .byte 0 /* End of children of CU */
11681 + .section .debug_loc
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
11690 + .quad 0x0 # Location list terminator begin (*.LLST2)
11691 + .quad 0x0 # Location list terminator end (*.LLST2)
11693 + .section .debug_abbrev
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 */
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 */
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 */
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 */
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 */
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 */
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 */
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 */
11787 + .byte 0x0 /* Terminator */
11789 +/* String table */
11790 + .section .debug_str
11792 + .string "GNU C 3.3.3"
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
11802 +# Copyright 2010 Free Software Foundation, Inc.
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.
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.
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/>.
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
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*]} {
11833 +set testfile dw2-bound-loclist
11834 +if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
11838 +# Verify it behaves at least as an unbound array without inferior.
11840 +gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"}
11841 +gdb_test "ptype a_string" {type = char \[\]}
11843 +# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
11844 +if ![runto "*main"] {
11848 +gdb_test "p a_string" { = "seen"}
11849 +gdb_test "ptype a_string" {type = char \[4\]}
11851 +gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
11852 +gdb_test "ptype b_string" {type = char \[\]}
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
11861 +/* This testcase is part of GDB, the GNU debugger.
11863 + Copyright 2004 Free Software Foundation, Inc.
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.
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.
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,
11881 +/* The function `func1' traced into must have debug info on offset > 0;
11882 + (DW_UNSND (attr)). This is the reason of `func0' existence. */
11885 +func0(int a, int b)
11889 +/* `func1' being traced into must have some arguments to dump. */
11892 +func1(int a, int b)
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
11908 +# Copyright 2006 Free Software Foundation, Inc.
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.
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.
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.
11924 +# Minimal DWARF-2 unit test
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*]} {
11937 +set testfile "dw2-stripped"
11938 +set srcfile ${testfile}.c
11939 +set binfile ${objdir}/${subdir}/${testfile}.x
11941 +remote_exec build "rm -f ${binfile}"
11943 +# get the value of gcc_compiled
11944 +if [get_compiler_info ${binfile}] {
11948 +# This test can only be run on gcc as we use additional_flags=FIXME
11949 +if {$gcc_compiled == 0} {
11953 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
11957 +remote_exec build "objcopy -R .debug_loc ${binfile}"
11958 +set strip_output [remote_exec build "objdump -h ${binfile}"]
11960 +set test "stripping test file preservation"
11961 +if [ regexp ".debug_info " $strip_output] {
11962 + pass "$test (.debug_info preserved)"
11964 + fail "$test (.debug_info got also stripped)"
11967 +set test "stripping test file functionality"
11968 +if [ regexp ".debug_loc " $strip_output] {
11969 + fail "$test (.debug_loc still present)"
11971 + pass "$test (.debug_loc stripped)"
11976 +gdb_reinitialize_dir $srcdir/$subdir
11977 +gdb_load ${binfile}
11979 +# For C programs, "start" should stop in main().
11981 +gdb_test "start" \
11982 + ".*main \\(\\) at .*" \
11985 + "func.* \\(.*\\) at .*" \
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
11992 +/* This testcase is part of GDB, the GNU debugger.
11994 + Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
12009 +/* Debug information */
12011 + .section .debug_info
12014 + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
12016 + .2byte 2 /* DWARF Version */
12017 + .4byte .Labbrev1_begin /* Offset into abbrev section */
12018 + .byte 4 /* Pointer size */
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) */
12027 + .uleb128 2 /* Abbrev: DW_TAG_structure_type */
12028 + .ascii "some_struct\0" /* DW_AT_name */
12030 + .uleb128 3 /* Abbrev: DW_TAG_member */
12031 + .ascii "field\0" /* DW_AT_name */
12032 + .byte 0 /* DW_AT_data_member_location */
12034 + .byte 0 /* End of children of some_struct */
12036 + .byte 0 /* End of children of CU */
12040 +/* Abbrev table */
12041 + .section .debug_abbrev
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 */
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 */
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 */
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
12080 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>.
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*]} {
12106 +set testfile "dw2-struct-member-data-location"
12107 +set srcfile ${testfile}.S
12108 +set binfile ${testfile}.x
12110 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } {
12114 +clean_restart $binfile
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
12122 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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.
12138 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
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
12148 +set testfile dwarf-stride
12149 +set srcfile ${testfile}.f90
12151 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
12155 +if ![runto MAIN__] then {
12156 + perror "couldn't run to breakpoint MAIN__"
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
12169 +! Copyright 2009 Free Software Foundation, Inc.
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.
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.
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.
12185 +! File written by Alan Matsuoka.
12189 + type small_stride
12190 + character*40 long_string
12191 + integer small_pad
12192 + end type small_stride
12194 + type(small_stride), dimension (20), target :: unpleasant
12195 + character*40, pointer, dimension(:):: c40pt
12200 + unpleasant(i+1)%small_pad = i+1
12201 + unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
12204 + c40pt => unpleasant%long_string
12206 + print *, c40pt ! break-here
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
12214 +! Copyright 2010 Free Software Foundation, Inc.
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.
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.
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.
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>.
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
12243 +# Copyright 2010 Free Software Foundation, Inc.
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.
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.
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.
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}
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}"
12272 +clean_restart ${executable}
12274 +if ![runto bar_] then {
12275 + perror "couldn't run to bar_"
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
12285 +! Copyright 2010 Free Software Foundation, Inc.
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.
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.
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.
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>.
12305 +subroutine foo (string)
12310 + character string*(*)
12311 + call bar ! stop-here
12312 +end subroutine foo
12315 + subroutine foo (string)
12316 + character string*(*)
12319 + call foo ('hello')
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
12326 +# Copyright 2007 Free Software Foundation, Inc.
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.
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.
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.
12342 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
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
12349 +set testfile "dynamic"
12350 +set srcfile ${testfile}.f90
12351 +set binfile ${objdir}/${subdir}/${testfile}
12353 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
12354 + untested "Couldn't compile ${srcfile}"
12360 +gdb_reinitialize_dir $srcdir/$subdir
12361 +gdb_load ${binfile}
12363 +if ![runto MAIN__] then {
12364 + perror "couldn't run to breakpoint MAIN__"
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"
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"
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"
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"
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"
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\\."
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"
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, .\]*\\)"
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, .\]*\\)"
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"
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
12476 +! Copyright 2007 Free Software Foundation, Inc.
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.
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.
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.
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>.
12497 + real, target, allocatable :: varx (:, :, :)
12498 + real, pointer :: varv (:, :, :)
12499 + real, target :: varu (1, 2, 3)
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)
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
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)
12541 + real :: vart (2:11, 7:*)
12543 + varz(2) = 5 ! varz-almostfilled
12544 + vart(2,7) = vart(2,7)
12545 +end subroutine bar
12548 + subroutine foo (vary, varw)
12549 + real :: vary (:, :)
12550 + real :: varw (:, :, :)
12554 + subroutine bar (varz, vart)
12556 + real :: vart (2:11, 7:*)
12559 + real :: x (10, 10), y (5), z(8, 8, 8)
12564 + call foo (x, z(2:6, 4:7, 6:8))
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
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
12579 +# Copyright 2008 Free Software Foundation, Inc.
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.
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.
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.
12595 +# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
12597 +# This file is part of the gdb testsuite. It contains tests for Fortran
12598 +# strings with dynamic length.
12600 +set testfile "string"
12601 +set srcfile ${testfile}.f90
12602 +set binfile ${objdir}/${subdir}/${testfile}
12604 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
12605 + untested "Couldn't compile ${srcfile}"
12611 +gdb_reinitialize_dir $srcdir/$subdir
12612 +gdb_load ${binfile}
12614 +if ![runto MAIN__] then {
12615 + perror "couldn't run to breakpoint MAIN__"
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."
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
12643 +! Copyright 2008 Free Software Foundation, Inc.
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.
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.
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.
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>.
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)
12670 + e = 'e' ! var-init
12673 + c = 'c' ! var-finish
12674 +end subroutine foo
12675 + character (len=4) :: g, h (1:7, 8:10)
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
12685 +# Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>.
12700 +if { [skip_fortran_tests] } { return -1 }
12702 +set testfile "subrange"
12703 +set srcfile ${testfile}.f90
12704 +if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
12708 +if ![runto MAIN__] {
12709 + perror "Couldn't run to MAIN__"
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\\))"
12718 +gdb_breakpoint [gdb_get_line_number "break-static"]
12719 +gdb_continue_to_breakpoint "break-static" ".*break-static.*"
12721 +foreach var {a alloc ptr} {
12723 + set old_prefix $pf_prefix
12724 + lappend pf_prefix "$var:"
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"
12738 + set pf_prefix $old_prefix
12741 +gdb_test_no_output {set $a=a}
12742 +delete_breakpoints
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
12750 +! Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>.
12766 + integer, target :: a (4, 3)
12767 + integer, allocatable :: alloc (:, :)
12768 + integer, pointer :: ptr (:, :)
12771 + a (i, j) = j * 10 + i
12773 + allocate (alloc (4, 3))
12776 + write (*,*) a ! break-static
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"
12786 + -re ".*python_script = 0.*$gdb_prompt $" {
12787 + set description "step over python_script initialization"
12788 + set command "step"
12790 -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" {
12791 set description "next over make_command_stats_cleanup and everything it calls"
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
12798 +/* Copyright 2011 Free Software Foundation, Inc.
12800 + This file is part of GDB.
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.
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.
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/>. */
12816 +main (int argc, char **argv)
12820 + vla[0] = 0; /* break-here */
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
12829 +# Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>.
12844 +load_lib mi-support.exp
12845 +set MIFLAGS "-i=mi2"
12848 +if [mi_gdb_start] {
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} {
12859 +mi_delete_breakpoints
12860 +mi_gdb_reinitialize_dir $srcdir/$subdir
12861 +mi_gdb_load ${binfile}
12863 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
12865 + "maintenance set internal-error quit yes"
12867 +mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
12869 + "maintenance set internal-error corefile yes"
12871 +set line [gdb_get_line_number "break-here"]
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"
12878 +if { [mi_run_cmd] < 0 } {
12881 +mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
12883 +mi_create_varobj "vla" "vla" "create local variable vla"
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
12891 +/* This testcase is part of GDB, the GNU debugger.
12893 + Copyright 2010 Free Software Foundation, Inc.
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.
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.
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/>. */
12908 +#include <pthread.h>
12909 +#include <assert.h>
12911 +static volatile int a, b, c;
12914 +marker_exit1 (void)
12919 +/* Workaround PR breakpoints/12272 by two different breakpoint locations. */
12921 +marker_exit2 (void)
12938 + pthread_t thread;
12941 + i = pthread_create (&thread, NULL, start, NULL);
12943 + i = pthread_join (thread, NULL);
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
12955 +# Copyright 2010 Free Software Foundation, Inc.
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.
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.
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/>.
12970 +if { [is_remote target] || ![isnative] } then {
12974 +set testfile "watchpoint-multi"
12976 +set executable ${testfile}
12977 +set srcfile ${testfile}.c
12978 +set binfile ${objdir}/${subdir}/${executable}
12980 +if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
12981 + untested ${testfile}.exp
12985 +clean_restart $executable
12987 +if ![runto_main] {
12990 +# Never keep/use any non-hw breakpoints to workaround a multi-inferior bug.
12991 +delete_breakpoints
12993 +gdb_test "add-inferior" "Added inferior 2"
12994 +gdb_test "inferior 2" "witching to inferior 2 .*"
12997 +if ![runto_main] {
13000 +delete_breakpoints
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"
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"
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 $" {
13022 + -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
13024 + untested ${testfile}.exp
13029 +gdb_test "inferior 1" "witching to inferior 1 .*"
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 .*}
13034 +gdb_test "inferior 2" "witching to inferior 2 .*"
13036 +# FAIL would be a hit on watchpoint for `b' - that one is for the other
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"
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 *-*-*
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 *-*-*
13052 +gdb_test "inferior 1" "witching to inferior 1 .*"
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"
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 *-*-*
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 *-*-*
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
13073 +/* This file is part of GDB, the GNU debugger.
13075 + Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
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
13100 +/* This file is part of GDB, the GNU debugger.
13102 + Copyright 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
13117 +extern int func (int *arr);
13122 + int arr[] = { 42 };
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
13133 +# Copyright 2009 Free Software Foundation, Inc.
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.
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.
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.
13149 +# This file is part of the gdb testsuite.
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}] } {
13157 +if ![runto func] then {
13161 +gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
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
13171 +# Copyright 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
13186 +if $tracelevel then {
13187 + strace $tracelevel
13190 +load_lib "pascal.exp"
13192 +set testfile "arrays"
13193 +set srcfile ${testfile}.pas
13194 +set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
13196 +# These tests only work with fpc, using the -gw3 compile-option
13198 +if { $pascal_compiler_is_fpc != 1 } {
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
13209 +if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
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"]
13221 +if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
13222 + pass "setting breakpoint 1"
13224 +if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
13225 + pass "setting breakpoint 2"
13228 +# Verify that "start" lands inside the right procedure.
13229 +if { [gdb_start_cmd] < 0 } {
13234 +gdb_test "" ".* at .*${srcfile}.*" "start"
13236 +gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
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"
13241 +gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
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"
13246 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13247 + setup_xfail "*-*-*"
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 "*-*-*"
13253 +gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
13255 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13256 + setup_xfail "*-*-*"
13258 +gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
13260 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13261 + setup_xfail "*-*-*"
13263 +gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
13265 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13266 + setup_xfail "*-*-*"
13268 +gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
13270 +if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
13271 + setup_xfail "*-*-*"
13273 +gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
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
13281 + Copyright 2008, 2009 Free Software Foundation, Inc.
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.
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.
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/>.
13299 +{$mode objfpc}{$h+}
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;
13310 + TStat2dArrInt = array[0..11,0..4] of integer;
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;
13321 + Stat2dArrInt: TStat2dArrInt;
13328 + for i := 0 to 11 do
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;
13336 + writeln(StatArrInt_[0]);
13337 + writeln(StatArrInt[0]); { set breakpoint 1 here }
13338 + writeln(StatArrChar[0]);
13339 + writeln(Stat2dArrInt[0,0]);
13341 + setlength(DynArrInt,13);
13342 + setlength(DynArrInt_,13);
13343 + setlength(DynArrStr,13);
13344 + setlength(DynArrChar,13);
13345 + for i := 0 to 12 do
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);
13353 + writeln(DynArrInt_[1]);
13354 + writeln(DynArrInt[1]);
13355 + writeln(DynArrStr[1]);
13356 + writeln(StatArrStr[1]);
13357 + writeln(DynArrChar[1]);
13359 + s := 'test'#0'string';
13360 + writeln(s); { set breakpoint 2 here }
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
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"
13378 gdb_test "python print 'result =', gdb.selected_frame () == f1" " = True" "test gdb.selected_frame"
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"
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"
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
13404 test_value_after_death
13405 +test_cast_regression
13407 # The following test recompiles the binary to test either C or C++
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
13414 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13416 + Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13418 + This file is part of GDB.
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.
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.
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. */
13435 +#include <string.h>
13436 +#include <errno.h>
13437 +#include <unistd.h>
13438 +#include <assert.h>
13439 +#include <signal.h>
13440 +#include <stdio.h>
13442 +#include "watchpoint-fork.h"
13444 +static volatile int usr1_got;
13447 +handler_usr1 (int signo)
13455 + pid_t child, save_parent = getpid ();
13457 + struct sigaction act, oldact;
13459 + void *thread_result;
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);
13475 + printf ("parent%d: %d\n", nr, (int) child);
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
13484 + /* We must not get caught here (against a forgotten breakpoint). */
13490 + /* And neither got caught our thread. */
13493 + i = pthread_join (thread, &thread_result);
13495 + assert (thread_result == (void *) 99UL);
13498 + /* Be sure our child knows we did not get caught above. */
13500 + i = kill (child, SIGUSR1);
13503 + /* Sleep for a while to check GDB's `info threads' no longer tracks us in
13504 + the child fork. */
13511 + printf ("child%d: %d\n", nr, (int) getpid ());
13513 + /* Let the parent signal us about its success. Be careful of races. */
13517 + /* Parent either died (and USR1_GOT is zero) or it succeeded. */
13518 + if (getppid () != save_parent)
13520 + if (kill (getppid (), 0) != 0)
13522 + /* Parent succeeded? */
13527 + i = pthread_yield ();
13531 + assert (usr1_got);
13533 + /* We must get caught here (against a false watchpoint removal). */
13538 + i = sigaction (SIGUSR1, &oldact, NULL);
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
13546 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13548 + Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13550 + This file is part of GDB.
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.
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.
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. */
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>
13574 +#include <asm/unistd.h>
13575 +#include <unistd.h>
13576 +#define gettid() syscall (__NR_gettid)
13578 +#include "watchpoint-fork.h"
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. */
13602 +volatile int step;
13612 + while (step != 1)
13614 + i = pthread_yield ();
13618 + var++; /* validity-thread-B */
13619 + empty (); /* validity-thread-B */
13621 + while (step != 3)
13626 + i = pthread_yield ();
13634 + var++; /* after-fork1-B */
13635 + empty (); /* after-fork1-B */
13637 + while (step != 5)
13642 + i = pthread_yield ();
13647 + var++; /* after-fork2-B */
13648 + empty (); /* after-fork2-B */
13649 + return (void *) 5UL;
13652 + /* We must not get caught here (against a forgotten breakpoint). */
13655 + return (void *) 99UL;
13662 + void *thread_result;
13664 + setbuf (stdout, NULL);
13665 + printf ("main: %d\n", (int) gettid ());
13667 + /* General hardware breakpoints and watchpoints validity. */
13669 + var++; /* validity-first */
13670 + empty (); /* validity-first */
13672 + i = pthread_create (&thread, NULL, start, NULL);
13675 + var++; /* validity-thread-A */
13676 + empty (); /* validity-thread-A */
13678 + while (step != 2)
13680 + i = pthread_yield ();
13684 + /* Hardware watchpoints got disarmed here. */
13687 + var++; /* after-fork1-A */
13688 + empty (); /* after-fork1-A */
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);
13695 + while (step != 4)
13697 + i = pthread_yield ();
13701 + /* A sanity check for double hardware watchpoints removal. */
13704 + var++; /* after-fork2-A */
13705 + empty (); /* after-fork2-A */
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);
13713 + i = pthread_join (thread, &thread_result);
13715 + assert (thread_result == (void *) 5UL);
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
13725 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13727 + Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13729 + This file is part of GDB.
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.
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.
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. */
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>
13754 +#include "watchpoint-fork.h"
13759 + pid_t child, pid_got;
13760 + int exit_code = 42 + nr;
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
13774 + (gdb) parent2: 14223 */
13778 + /* We must not get caught here (against a forgotten breakpoint). */
13782 + _exit (exit_code);
13784 + printf ("parent%d: %d\n", nr, (int) child);
13785 + /* Delay to get both the "child%d" and "parent%d" message printed, see
13790 + pid_got = wait (&status);
13791 + assert (pid_got == child);
13792 + assert (WIFEXITED (status));
13793 + assert (WEXITSTATUS (status) == exit_code);
13795 + /* We must get caught here (against a false watchpoint removal). */
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
13804 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
13806 + Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
13808 + This file is part of GDB.
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.
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.
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. */
13825 +#include <assert.h>
13826 +#include <unistd.h>
13827 +#include <sys/wait.h>
13828 +#include <stdio.h>
13829 +#include <stdlib.h>
13831 +#include "watchpoint-fork.h"
13848 + setbuf (stdout, NULL);
13849 + printf ("main: %d\n", (int) getpid ());
13851 + /* General hardware breakpoints and watchpoints validity. */
13854 + /* Hardware watchpoints got disarmed here. */
13856 + /* This watchpoint got lost before. */
13858 + /* A sanity check for double hardware watchpoints removal. */
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
13870 +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
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.
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.
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/>.
13885 +# Test case for forgotten hw-watchpoints after fork()-off of a process.
13887 +proc test {type symbol} {
13888 + global objdir subdir srcdir gdb_prompt
13890 + set testfile watchpoint-fork
13893 + set prefix_test $pf_prefix
13894 + lappend pf_prefix "$type:"
13895 + set prefix_mt $pf_prefix
13897 + set srcfile_type ${srcdir}/${subdir}/${testfile}-${type}.c
13902 + set pf_prefix $prefix_mt
13903 + lappend pf_prefix "singlethreaded:"
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
13911 + clean_restart $executable
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.*"
13919 + if ![runto_main] {
13923 + gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
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 $" {
13932 + -re "(No hardware breakpoint support in the target\\.|Hardware breakpoints used exceeds limit\\.)\r\n$gdb_prompt $" {
13934 + set hbreak "break"
13935 + gdb_test "break marker"
13939 + gdb_breakpoint "mark_exit"
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"
13958 + set pf_prefix $prefix_mt
13959 + lappend pf_prefix "multithreaded:"
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
13967 + clean_restart $executable
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.*"
13973 + if ![runto_main] {
13977 + gdb_test "watch var" "atchpoint \[0-9\]+: var" "Set the watchpoint"
13979 + # It should not be left over in the fork()ed-off child.
13980 + gdb_test "$hbreak marker" {reakpoint [0-9]+.*}
13982 + gdb_breakpoint "mark_exit"
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"
14008 + set pf_prefix $prefix_test
14011 +test parent FOLLOW_PARENT
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
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
14024 +/* Test case for forgotten hw-watchpoints after fork()-off of a process.
14026 + Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
14028 + This file is part of GDB.
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.
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.
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. */
14046 +#include <pthread.h>
14048 +extern volatile int step;
14049 +extern pthread_t thread;
14050 +#endif /* THREAD */
14052 +extern volatile int var;
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
14061 +/* This testcase is part of GDB, the GNU debugger.
14063 + Copyright 2011 Free Software Foundation, Inc.
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.
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.
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/>. */
14080 +#define _SDT_HAS_SEMAPHORES
14081 +__extension__ unsigned short teste_user_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
14082 +#define TEST teste_user_semaphore
14084 +__extension__ unsigned short teste_two_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes")));
14085 +#define TEST2 teste_two_semaphore
14092 +#endif /* USE_PROBES */
14094 +#include <sys/sdt.h>
14096 +/* We only support SystemTap and only the v3 form. */
14097 +#if _SDT_NOTE_TYPE != 3
14098 +#error "not using SystemTap v3 probes"
14105 + STAP_PROBE1 (teste, two, x);
14112 + STAP_PROBE1(teste, user, x);
14128 + nothing (); /* end-here */
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
14138 +# Free Software Foundation, Inc.
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.
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.
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/>.
14153 +load_lib "trace-support.exp"
14155 +if $tracelevel then {
14156 + strace $tracelevel
14159 +set testfile "stap-trace"
14160 +set srcfile ${testfile}.c
14161 +set executable $testfile
14162 +set binfile $objdir/$subdir/$executable
14164 +set ws "\[\r\n\t \]+"
14165 +set cr "\[\r\n\]+"
14167 +# Only x86 and x86_64 targets are supported for now.
14169 +if { ![istarget "x86_64-*"] && ![istarget "i?86-*"] } {
14173 +proc compile_stap_bin {{ arg "" }} {
14179 + if { $arg != "" } {
14180 + set arg "additional_flags=$arg"
14183 + if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
14184 + executable [concat $arg debug nowarnings]] != "" } {
14185 + untested "Could not compile ${srcfile}"
14190 +proc prepare_for_trace_test {} {
14191 + global executable
14193 + clean_restart $executable
14195 + if { ![runto_main] } {
14196 + perror "Could not run to `main'."
14200 + gdb_breakpoint [gdb_get_line_number "end-here"]
14203 +proc run_trace_experiment { test_probe msg } {
14204 + global gdb_prompt
14206 + set test "collect $msg: start trace experiment"
14207 + gdb_test_multiple "tstart" "$test" {
14208 + -re "^tstart\r\n$gdb_prompt $" {
14213 + gdb_test "continue" \
14214 + "Continuing.*Breakpoint \[0-9\]+.*" \
14215 + "collect $msg: run trace experiment"
14216 + gdb_test "tstop" \
14218 + "collect $msg: stop trace experiment"
14219 + gdb_test "tfind start" \
14221 + "collect $msg: tfind test frame"
14224 +proc gdb_collect_probe_arg { msg probe val_arg0 } {
14225 + global gdb_prompt
14228 + prepare_for_trace_test
14230 + gdb_test "trace $probe" \
14231 + "Tracepoint \[0-9\]+ at .*" \
14232 + "collect $msg: set tracepoint"
14233 + gdb_trace_setactions "collect $msg: define actions" \
14235 + "collect \$_probe_arg0" "^$"
14237 + # Begin the test.
14238 + run_trace_experiment $msg $probe
14240 + gdb_test "print \$_probe_arg0" \
14241 + "\\$\[0-9\]+ = $val_arg0$cr" \
14242 + "collect $msg: collected probe arg0"
14245 +compile_stap_bin ""
14247 +clean_restart $executable
14248 +if { ![runto_main] } {
14249 + perror "Could not run to `main'."
14253 +if { ![gdb_target_supports_trace] } {
14254 + # Test cannot run on this target.
14258 +gdb_collect_probe_arg "probe args without semaphore" "probe:user" "23"
14261 +compile_stap_bin "-DUSE_PROBES"
14262 +gdb_collect_probe_arg "probe args with semaphore" "probe:two" "46"
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 {} {
14274 + -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
14276 + verbose "\t\tUnloading symbols for program being debugged"
14279 -re "Discard symbol table from .*y or n.*$" {
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
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"
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
14312 + verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
14315 set pascal_init_done 1
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. */
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,
14329 struct thread_info *tp = find_thread_ptid (inferior_ptid);
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;
14335 +/* Implementation of `thread' variable. */
14337 +static struct internalvar_funcs thread_funcs =
14339 + thread_id_make_value,
14345 _initialize_thread (void)
14347 @@ -1494,5 +1504,5 @@ Show printing of thread events (such as
14348 show_print_thread_events,
14349 &setprintlist, &showprintlist);
14351 - create_internalvar_type_lazy ("_thread", thread_id_make_value);
14352 + create_internalvar_type_lazy ("_thread", &thread_funcs, NULL);
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)
14361 free_all_values ();
14363 + free_all_types ();
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)
14374 for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
14376 + struct bp_location *loc;
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;
14386 + for (loc = t->loc; loc; loc = loc->next)
14387 + modify_semaphore (loc, 1);
14389 VEC_free (breakpoint_p, tp_vec);
14391 @@ -1672,7 +1677,28 @@ trace_stop_command (char *args, int from
14393 stop_tracing (void)
14395 + VEC(breakpoint_p) *tp_vec = NULL;
14397 + struct breakpoint *t;
14399 target_trace_stop ();
14401 + tp_vec = all_tracepoints ();
14402 + for (ix = 0; VEC_iterate (breakpoint_p, tp_vec, ix, t); ix++)
14404 + struct bp_location *loc;
14406 + if ((t->type == bp_fast_tracepoint
14407 + ? !may_insert_fast_tracepoints
14408 + : !may_insert_tracepoints))
14411 + for (loc = t->loc; loc; loc = loc->next)
14412 + modify_semaphore (loc, 0);
14415 + VEC_free (breakpoint_p, tp_vec);
14417 /* Should change in response to reply? */
14418 current_trace_status ()->running = 0;
14420 @@ -4515,7 +4541,8 @@ info_static_tracepoint_markers_command (
14423 static struct value *
14424 -sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var)
14425 +sdata_make_value (struct gdbarch *gdbarch, struct internalvar *var,
14430 @@ -4694,6 +4721,15 @@ traceframe_available_memory (VEC(mem_ran
14434 +/* Implementation of `sdata' variable. */
14436 +static const struct internalvar_funcs sdata_funcs =
14438 + sdata_make_value,
14443 /* module initialization */
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);
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
14460 #include "gdb_string.h"
14461 #include "exceptions.h"
14462 #include "valprint.h"
14463 +#include "dwarf2loc.h"
14466 extern void _initialize_typeprint (void);
14467 @@ -77,6 +78,9 @@ void
14468 type_print (struct type *type, char *varstring, struct ui_file *stream,
14472 + type = check_typedef (type);
14474 LA_PRINT_TYPE (type, varstring, stream, show, 0);
14477 @@ -115,7 +119,8 @@ whatis_exp (char *exp, int show)
14479 struct expression *expr;
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;
14487 @@ -126,12 +131,13 @@ whatis_exp (char *exp, int show)
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);
14496 val = access_value_history (0);
14498 + object_address_set (value_raw_address (val));
14499 type = value_type (val);
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");
14507 - do_cleanups (old_chain);
14508 + do_cleanups (old_chain);
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_
14520 +/* Helper for make_cleanup_restore_page_info. */
14523 +do_restore_selected_frame_cleanup (void *arg)
14525 + struct frame_id *frame_idp = arg;
14527 + select_frame (frame_find_by_id (*frame_idp));
14529 + xfree (frame_idp);
14532 +/* Provide cleanup for restoring currently selected frame. Use frame_id for
14533 + the case the current frame becomes stale in the meantime. */
14536 +make_cleanup_restore_selected_frame (void)
14538 + struct frame_id *frame_idp;
14540 + /* get_selected_frame->get_current_frame would error otherwise. */
14541 + if (!has_stack_frames ())
14542 + return make_cleanup (null_cleanup, NULL);
14544 + frame_idp = xmalloc (sizeof (*frame_idp));
14545 + *frame_idp = get_frame_id (get_selected_frame (NULL));
14547 + return make_cleanup (do_restore_selected_frame_cleanup, frame_idp);
14550 /* Set the screen size based on LINES_PER_PAGE and CHARS_PER_LINE. */
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);
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)
14573 + /* FIXME: We should support user defined ops for dynamic types. */
14574 + if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2)))
14577 return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2));
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
14585 #include "objfiles.h"
14586 #include "symtab.h"
14587 #include "exceptions.h"
14588 +#include "dwarf2loc.h"
14590 extern int overload_debug;
14591 /* Local functions. */
14592 @@ -915,6 +916,65 @@ value_one (struct type *type, enum lval_
14596 +/* object_address_set must be already called before this function. */
14599 +object_address_data_not_valid (struct type *type)
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);
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");
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");
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. */
14629 +object_address_get_data (struct type *type, CORE_ADDR *address_return)
14631 + gdb_assert (address_return != NULL);
14633 + object_address_set (*address_return);
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);
14639 + if (object_address_data_not_valid (type) != NULL)
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). */
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)
14650 + = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type));
14655 /* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */
14657 static struct value *
14658 @@ -1011,12 +1071,20 @@ value_fetch_lazy (struct value *val)
14660 else if (VALUE_LVAL (val) == lval_memory)
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);
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))
14671 + struct type *type = value_enclosing_type (val);
14672 + int length = TYPE_LENGTH (check_typedef (type));
14676 + addr += value_offset (val);
14677 + read_value_memory (val, 0, value_stack (val),
14678 + addr, value_contents_all_raw (val), length);
14682 else if (VALUE_LVAL (val) == lval_register)
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)
14688 - CORE_ADDR addr = value_address (val);
14691 + if (VALUE_LVAL (val) == lval_memory)
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);
14700 + addr = value_address (val);
14702 return value_from_pointer (lookup_pointer_type (type), addr);
14704 @@ -1635,6 +1714,7 @@ struct value *
14705 value_coerce_array (struct value *arg1)
14707 struct type *type = check_typedef (value_type (arg1));
14708 + CORE_ADDR address;
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."));
14716 + address = value_raw_address (arg1);
14717 + if (!object_address_get_data (type, &address))
14718 + error (_("Attempt to take address of non-valid value."));
14720 return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
14721 - value_address (arg1));
14722 + address + value_offset (arg1));
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),
14729 lowbound + length - 1);
14730 + TYPE_BYTE_STRIDE (slice_range_type) = TYPE_BYTE_STRIDE (range_type);
14732 if (TYPE_CODE (array_type) == TYPE_CODE_BITSTRING)
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
14741 #include "python/python.h"
14742 #include "ada-lang.h"
14743 +#include "dwarf2loc.h"
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:
14755 @@ -1193,6 +1193,7 @@ val_print_array_elements (struct type *t
14757 unsigned int things_printed = 0;
14759 + struct type *saved_type = type;
14760 struct type *elttype, *index_type;
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. */
14766 LONGEST low_bound, high_bound;
14767 + struct cleanup *back_to;
14768 + CORE_ADDR saved_address = address;
14770 + back_to = make_cleanup (null_cleanup, 0);
14771 + type = object_address_get_data (type, &address);
14774 + fputs_filtered (object_address_data_not_valid (type), stream);
14775 + do_cleanups (back_to);
14778 + if (address != saved_address)
14780 + size_t length = TYPE_LENGTH (type);
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);
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);
14795 + eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type);
14796 index_type = TYPE_INDEX_TYPE (type);
14798 if (get_array_bounds (type, &low_bound, &high_bound))
14799 @@ -1290,6 +1315,8 @@ val_print_array_elements (struct type *t
14801 fprintf_filtered (stream, "...");
14804 + do_cleanups (back_to);
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
14813 #include "python/python.h"
14815 #include "tracepoint.h"
14816 +#include "observer.h"
14818 /* Prototypes for exported functions. */
14820 @@ -1339,12 +1340,15 @@ void
14821 set_value_component_location (struct value *component,
14822 const struct value *whole)
14826 if (whole->lval == lval_internalvar)
14827 VALUE_LVAL (component) = lval_internalvar_component;
14829 VALUE_LVAL (component) = whole->lval;
14831 component->location = whole->location;
14833 if (whole->lval == lval_computed)
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);
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);
14849 @@ -1485,6 +1495,31 @@ show_values (char *num_exp, int from_tty
14854 +/* Sanity check for memory leaks and proper types reference counting. */
14857 +value_history_cleanup (void *unused)
14859 + while (value_history_chain)
14861 + struct value_history_chunk *chunk = value_history_chain;
14864 + for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
14865 + value_free (chunk->values[i]);
14867 + value_history_chain = chunk->next;
14870 + value_history_count = 0;
14872 + /* Free the unreferenced types above. */
14873 + free_all_values ();
14875 + free_all_types ();
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;
14884 /* The call-back routine used with INTERNALVAR_MAKE_VALUE. */
14885 - internalvar_make_value make_value;
14888 + /* The functions to call. */
14889 + const struct internalvar_funcs *functions;
14891 + /* The function's user-data. */
14895 /* The internal function used with INTERNALVAR_FUNCTION. */
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
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. */
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,
14912 struct internalvar *var = create_internalvar (name);
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;
14921 +/* See documentation in value.h. */
14924 +compile_internalvar_to_ax (struct internalvar *var,
14925 + struct agent_expr *expr,
14926 + struct axs_value *value)
14928 + if (var->kind != INTERNALVAR_MAKE_VALUE
14929 + || var->u.make_value.functions->compile_to_ax == NULL)
14932 + var->u.make_value.functions->compile_to_ax (var, expr, value,
14933 + var->u.make_value.data);
14937 /* Look up an internal variable with name NAME. NAME should not
14938 normally include a dollar sign.
14940 @@ -1713,7 +1776,8 @@ value_of_internalvar (struct gdbarch *gd
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);
14950 @@ -1909,6 +1973,11 @@ clear_internalvar (struct internalvar *v
14951 xfree (var->u.string);
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);
14962 @@ -1963,6 +2032,38 @@ call_internal_function (struct gdbarch *
14963 return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
14967 +/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
14970 +value_types_mark_used (void)
14972 + struct internalvar *var;
14973 + struct value_history_chunk *chunk;
14975 + for (var = internalvars; var != NULL; var = var->next)
14976 + switch (var->kind)
14978 + case INTERNALVAR_VALUE:
14979 + type_mark_used (value_type (var->u.value));
14982 + case INTERNALVAR_INTEGER:
14983 + type_mark_used (var->u.integer.type);
14987 + for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
14991 + for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
14992 + if (chunk->values[i])
14993 + type_mark_used (value_type (chunk->values[i]));
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)
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);
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,
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);
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)
15028 + volatile struct gdb_exception e;
15034 printf_filtered (("$%s = "), var->name);
15035 - value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
15037 - printf_filtered (("\n"));
15039 + TRY_CATCH (e, RETURN_MASK_ERROR)
15041 + value_print (value_of_internalvar (gdbarch, var), gdb_stdout,
15043 + printf_filtered (("\n"));
15045 + if (e.reason < 0)
15046 + printf_filtered (_("<error: %s>\n"), e.message);
15049 printf_unfiltered (_("No debugger convenience variables now defined.\n"
15050 @@ -3047,7 +3155,24 @@ value_from_history_ref (char *h, char **
15052 coerce_ref (struct value *arg)
15054 - struct type *value_type_arg_tmp = check_typedef (value_type (arg));
15055 + struct type *value_type_arg_tmp;
15057 + if (TYPE_DYNAMIC (value_type (arg)))
15059 + struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
15060 + CORE_ADDR address;
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,
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);
15072 + value_type_arg_tmp = check_typedef (value_type (arg));
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);
15081 + make_final_cleanup (value_history_cleanup, NULL);
15084 + observer_attach_mark_used (value_types_mark_used);
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 **);
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);
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);
15102 @@ -697,10 +701,52 @@ extern struct internalvar *lookup_only_i
15104 extern struct internalvar *create_internalvar (const char *name);
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. */
15111 +struct internalvar_funcs
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'. */
15117 + struct value *(*make_value) (struct gdbarch *arch,
15118 + struct internalvar *var,
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
15128 + void (*compile_to_ax) (struct internalvar *var,
15129 + struct agent_expr *expr,
15130 + struct axs_value *value,
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'. */
15137 + void (*destroy) (void *data);
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,
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. */
15152 +extern int compile_internalvar_to_ax (struct internalvar *var,
15153 + struct agent_expr *expr,
15154 + struct axs_value *value);
15156 extern struct internalvar *lookup_internalvar (const char *name);
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. */
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)
15169 if (target_has_stack && !ptid_equal (inferior_ptid, null_ptid))
15171 @@ -425,6 +425,15 @@ init_w32_command_list (void)
15175 +/* Implementation of `tlb' variable. */
15177 +static const struct internalvar_funcs tlb_funcs =
15185 _initialize_windows_tdep (void)
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);
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 */