2009-03-02 23:14:15 +00:00
http://sourceware.org/gdb/wiki/ProjectArcher
http://sourceware.org/gdb/wiki/ArcherBranchManagement
GIT snapshot:
2010-11-17 02:58:16 +00:00
commit 9dd061f10e7d3a8a8c2d9ffa2492a08efb91f293
2009-03-02 23:14:15 +00:00
branch `archer' - the merge of branches:
2010-01-16 22:32:10 +00:00
archer-jankratochvil-vla
2010-07-21 21:30:20 +00:00
archer-jankratochvil-watchpoint3
archer-jankratochvil-ifunc
2010-11-17 02:58:16 +00:00
#archer-pmuldoon-next-over-throw2
#archer-tromey-python (not a merge)
#archer-tromey-optional-psymtab (cherry-picked from post-7.2 master)
2010-07-21 21:30:20 +00:00
#TODO:archer-tromey-threaded-dwarf
2009-03-02 23:14:15 +00:00
2009-03-02 00:11:35 +00:00
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
2010-11-17 02:58:16 +00:00
index ea71ea2..ccd7b29 100644
2009-03-02 00:11:35 +00:00
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
2010-11-17 02:58:16 +00:00
@@ -11250,6 +11250,7 @@ ada_operator_length (const struct expression *exp, int pc, int *oplenp,
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
static int
ada_operator_check (struct expression *exp, int pos,
+ int (*type_func) (struct type *type, void *data),
int (*objfile_func) (struct objfile *objfile, void *data),
void *data)
2010-01-21 16:09:11 +00:00
{
2010-11-17 02:58:16 +00:00
@@ -11264,12 +11265,15 @@ ada_operator_check (struct expression *exp, int pos,
2010-07-21 21:30:20 +00:00
break;
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
default:
- return operator_check_standard (exp, pos, objfile_func, data);
2009-08-04 05:37:29 +00:00
+ return operator_check_standard (exp, pos, type_func, objfile_func,
+ data);
2010-07-21 21:30:20 +00:00
}
/* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
- if (type && TYPE_OBJFILE (type)
2009-08-04 05:37:29 +00:00
+ if (type && type_func && (*type_func) (type, data))
+ return 1;
+ if (type && TYPE_OBJFILE (type) && objfile_func
2010-07-21 21:30:20 +00:00
&& (*objfile_func) (TYPE_OBJFILE (type), data))
return 1;
2010-01-28 22:26:15 +00:00
2009-08-18 19:37:35 +00:00
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
2010-11-17 02:58:16 +00:00
index 16e97a2..3a5d57e 100644
2009-08-18 19:37:35 +00:00
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
2010-07-21 21:30:20 +00:00
@@ -375,6 +375,20 @@ amd64_linux_dr_unset_status (unsigned long mask)
2010-01-16 22:32:10 +00:00
}
2009-08-18 19:37:35 +00:00
}
+/* See i386_dr_low_type.detach. Do not use wrappers amd64_linux_dr_set_control
+ or amd64_linux_dr_reset_addr as they would modify the register cache
+ (amd64_linux_dr). */
+
+static void
+amd64_linux_dr_detach (void)
+{
+ int regnum;
+
+ amd64_linux_dr_set (inferior_ptid, DR_CONTROL, 0);
+ amd64_linux_dr_unset_status (~0UL);
+ for (regnum = DR_FIRSTADDR; regnum <= DR_LASTADDR; regnum++)
+ amd64_linux_dr_set (inferior_ptid, regnum, 0);
+}
2010-01-16 22:32:10 +00:00
2009-08-18 19:37:35 +00:00
static void
amd64_linux_new_thread (ptid_t ptid)
2010-11-17 02:58:16 +00:00
@@ -800,6 +814,7 @@ _initialize_amd64_linux_nat (void)
2009-08-18 19:37:35 +00:00
i386_dr_low.reset_addr = amd64_linux_dr_reset_addr;
i386_dr_low.get_status = amd64_linux_dr_get_status;
2010-01-16 22:32:10 +00:00
i386_dr_low.unset_status = amd64_linux_dr_unset_status;
2009-08-18 19:37:35 +00:00
+ i386_dr_low.detach = amd64_linux_dr_detach;
i386_set_debug_register_length (8);
/* Override the GNU/Linux inferior startup hook. */
2009-03-02 23:14:15 +00:00
diff --git a/gdb/block.c b/gdb/block.c
2010-07-21 21:30:20 +00:00
index 48ac21b..ffcc97f 100644
2009-03-02 23:14:15 +00:00
--- a/gdb/block.c
+++ b/gdb/block.c
2010-07-21 21:30:20 +00:00
@@ -321,3 +321,21 @@ allocate_block (struct obstack *obstack)
2009-06-10 13:05:57 +00:00
return bl;
}
2009-08-04 05:37:29 +00:00
+
+/* Return OBJFILE in which BLOCK is located or NULL if we cannot find it for
+ whatever reason. */
+
+struct objfile *
+block_objfile (const struct block *block)
+{
+ struct symbol *func;
+
+ if (block == NULL)
+ return NULL;
+
+ func = block_linkage_function (block);
+ if (func == NULL)
+ return NULL;
+
+ return SYMBOL_SYMTAB (func)->objfile;
+}
2009-06-10 13:05:57 +00:00
diff --git a/gdb/block.h b/gdb/block.h
2010-07-21 21:30:20 +00:00
index 7eedb6c..a517e80 100644
2009-06-10 13:05:57 +00:00
--- a/gdb/block.h
+++ b/gdb/block.h
2010-07-21 21:30:20 +00:00
@@ -166,4 +166,6 @@ extern const struct block *block_global_block (const struct block *block);
2009-06-10 13:05:57 +00:00
2009-08-04 05:37:29 +00:00
extern struct block *allocate_block (struct obstack *obstack);
2009-06-10 13:05:57 +00:00
2009-08-04 05:37:29 +00:00
+extern struct objfile *block_objfile (const struct block *block);
+
#endif /* BLOCK_H */
2010-07-21 21:30:20 +00:00
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 0348bf4..f01d0ee 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -38,6 +38,7 @@
#include "block.h"
#include "inline-frame.h"
#include "psymtab.h"
+#include "elf-bfd.h"
/* Return the innermost lexical block in execution
in a specified stack frame. The frame address is assumed valid.
@@ -159,6 +160,7 @@ static CORE_ADDR cache_pc_function_low = 0;
static CORE_ADDR cache_pc_function_high = 0;
static char *cache_pc_function_name = 0;
static struct obj_section *cache_pc_function_section = NULL;
+static int cache_pc_function_is_gnu_ifunc = 0;
/* Clear cache, e.g. when symbol table is discarded. */
@@ -169,6 +171,7 @@ clear_pc_function_cache (void)
cache_pc_function_high = 0;
cache_pc_function_name = (char *) 0;
cache_pc_function_section = NULL;
+ cache_pc_function_is_gnu_ifunc = 0;
}
/* Finds the "function" (text symbol) that is smaller than PC but
@@ -184,7 +187,7 @@ clear_pc_function_cache (void)
/* Backward compatibility, no section argument. */
-int
+enum find_pc_partial_function_type
find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
CORE_ADDR *endaddr)
{
@@ -236,6 +239,7 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f));
cache_pc_function_name = SYMBOL_LINKAGE_NAME (f);
cache_pc_function_section = section;
+ cache_pc_function_is_gnu_ifunc = TYPE_GNU_IFUNC (SYMBOL_TYPE (f));
goto return_cached_value;
}
}
@@ -258,12 +262,13 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
*address = 0;
if (endaddr != NULL)
*endaddr = 0;
- return 0;
+ return FIND_PC_PARTIAL_FUNCTION_NOT_FOUND;
}
cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol);
cache_pc_function_name = SYMBOL_LINKAGE_NAME (msymbol);
cache_pc_function_section = section;
+ cache_pc_function_is_gnu_ifunc = MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc;
/* If the minimal symbol has a size, use it for the cache.
Otherwise use the lesser of the next minimal symbol in the same
@@ -323,7 +328,8 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
*endaddr = cache_pc_function_high;
}
- return 1;
+ return cache_pc_function_is_gnu_ifunc ? FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
+ : FIND_PC_PARTIAL_FUNCTION_NORMAL;
}
/* Return the innermost stack frame executing inside of BLOCK,
2009-03-02 00:11:35 +00:00
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
2010-11-17 02:58:16 +00:00
index 6b55313..b152eda 100644
2009-03-02 00:11:35 +00:00
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
2010-07-21 21:30:20 +00:00
@@ -62,6 +62,7 @@
2009-09-10 21:37:41 +00:00
#include "jit.h"
2009-09-17 12:15:42 +00:00
#include "xml-syscall.h"
2010-07-21 21:30:20 +00:00
#include "parser-defs.h"
+#include "regcache.h"
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
/* readline include files */
#include "readline/readline.h"
2010-07-21 21:30:20 +00:00
@@ -92,6 +93,9 @@ static void map_breakpoint_numbers (char *, void (*) (struct breakpoint *,
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
static void ignore_command (char *, int);
+static void update_breakpoint_locations (struct breakpoint *b,
+ struct symtabs_and_lines sals);
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
static int breakpoint_re_set_one (void *);
static void clear_command (char *, int);
2010-11-17 02:58:16 +00:00
@@ -104,6 +108,9 @@ static void break_command_1 (char *, int, int);
2010-07-21 21:30:20 +00:00
static void mention (struct breakpoint *);
+static struct bp_location *add_location_to_breakpoint (struct breakpoint *b,
+ const struct symtab_and_line *sal);
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
/* This function is used in gdbtk sources and thus can not be made static. */
struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch,
struct symtab_and_line,
2010-11-17 02:58:16 +00:00
@@ -219,6 +226,10 @@ static void disable_trace_command (char *, int);
2010-07-21 21:30:20 +00:00
static void trace_pass_command (char *, int);
+static void gnu_ifunc_resolver_stop (struct breakpoint *b);
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+static void gnu_ifunc_resolver_return_stop (struct breakpoint *b);
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
/* Assuming we're creating a static tracepoint, does S look like a
static tracepoint marker spec ("-m MARKER_ID")? */
#define is_marker_spec(s) \
2010-11-17 02:58:16 +00:00
@@ -1241,6 +1252,22 @@ watchpoint_in_thread_scope (struct breakpoint *b)
2010-07-21 21:30:20 +00:00
&& !is_executing (inferior_ptid)));
}
+static void
+watchpoint_del_at_next_stop (struct breakpoint *b)
+{
+ gdb_assert (is_watchpoint (b));
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (b->related_breakpoint != b)
+ {
+ gdb_assert (b->related_breakpoint->type == bp_watchpoint_scope);
+ gdb_assert (b->related_breakpoint->related_breakpoint == b);
+ b->related_breakpoint->disposition = disp_del_at_next_stop;
+ b->related_breakpoint->related_breakpoint = b->related_breakpoint;
+ b->related_breakpoint = b;
2009-03-02 00:11:35 +00:00
+ }
2010-07-21 21:30:20 +00:00
+ b->disposition = disp_del_at_next_stop;
2009-03-02 00:11:35 +00:00
+}
+
2010-07-21 21:30:20 +00:00
/* Assuming that B is a watchpoint:
- Reparse watchpoint expression, if REPARSE is non-zero
- Evaluate expression and store the result in B->val
2010-11-17 02:58:16 +00:00
@@ -1296,6 +1323,8 @@ update_watchpoint (struct breakpoint *b, int reparse)
2010-07-21 21:30:20 +00:00
struct frame_id saved_frame_id;
int frame_saved;
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
+ gdb_assert (is_watchpoint (b));
+
/* If this is a local watchpoint, we only want to check if the
watchpoint frame is in scope if the current thread is the thread
that was used to create the watchpoint. */
2010-11-17 02:58:16 +00:00
@@ -1500,13 +1529,7 @@ update_watchpoint (struct breakpoint *b, int reparse)
2010-07-21 21:30:20 +00:00
Watchpoint %d deleted because the program has left the block\n\
in which its expression is valid.\n"),
b->number);
- if (b->related_breakpoint)
- {
- b->related_breakpoint->disposition = disp_del_at_next_stop;
- b->related_breakpoint->related_breakpoint = NULL;
- b->related_breakpoint= NULL;
- }
- b->disposition = disp_del_at_next_stop;
+ watchpoint_del_at_next_stop (b);
}
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
/* Restore the selected frame. */
2010-11-17 02:58:16 +00:00
@@ -2354,6 +2377,8 @@ detach_breakpoints (int pid)
2010-07-21 21:30:20 +00:00
/* Detach single-step breakpoints as well. */
detach_single_step_breakpoints ();
2009-08-18 19:37:35 +00:00
+ val |= target_detach_watchpoints ();
2010-07-21 21:30:20 +00:00
+
2009-08-18 19:37:35 +00:00
do_cleanups (old_chain);
return val;
}
2010-11-17 02:58:16 +00:00
@@ -2455,9 +2480,11 @@ remove_breakpoint_1 (struct bp_location *b, insertion_state_t is)
2009-08-18 19:37:35 +00:00
return val;
b->inserted = (is == mark_inserted);
}
- else if (b->loc_type == bp_loc_hardware_watchpoint)
+ /* bp_loc_hardware_watchpoint with mark_inserted is being handled by
+ target_detach_watchpoints. */
+ else if (b->loc_type == bp_loc_hardware_watchpoint && is == mark_uninserted)
{
- b->inserted = (is == mark_inserted);
+ b->inserted = 0;
2010-07-21 21:30:20 +00:00
val = target_remove_watchpoint (b->address, b->length,
b->watchpoint_type, b->owner->cond_exp);
2009-08-18 19:37:35 +00:00
2010-11-17 02:58:16 +00:00
@@ -3342,6 +3369,8 @@ print_it_typical (bpstat bs)
2010-07-21 21:30:20 +00:00
case bp_tracepoint:
case bp_fast_tracepoint:
case bp_jit_event:
+ case bp_gnu_ifunc_resolver:
+ case bp_gnu_ifunc_resolver_return:
default:
result = PRINT_UNKNOWN;
break;
2010-11-17 02:58:16 +00:00
@@ -3562,6 +3591,8 @@ watchpoint_check (void *p)
gdb_assert (bs->breakpoint_at != NULL);
b = bs->breakpoint_at;
2010-07-21 21:30:20 +00:00
+ gdb_assert (is_watchpoint (b));
+
/* If this is a local watchpoint, we only want to check if the
watchpoint frame is in scope if the current thread is the thread
that was used to create the watchpoint. */
2010-11-17 02:58:16 +00:00
@@ -3668,13 +3699,7 @@ watchpoint_check (void *p)
2010-07-21 21:30:20 +00:00
ui_out_text (uiout, " deleted because the program has left the block in\n\
which its expression is valid.\n");
- if (b->related_breakpoint)
- {
- b->related_breakpoint->disposition = disp_del_at_next_stop;
- b->related_breakpoint->related_breakpoint = NULL;
- b->related_breakpoint = NULL;
- }
- b->disposition = disp_del_at_next_stop;
+ watchpoint_del_at_next_stop (b);
return WP_DELETED;
}
2010-11-17 02:58:16 +00:00
@@ -3743,8 +3768,12 @@ bpstat_check_location (const struct bp_location *bl,
2009-08-18 19:37:35 +00:00
/* If BS refers to a watchpoint, determine if the watched values
has actually changed, and we should stop. If not, set BS->stop
- to 0. */
-static void
+ to 0.
+ Return 0 for watchpoints which could not be the cause of this trap.
+ In such case PRINT_IT will be print_it_noop and STOP will be 0.
+ Otherwise return 1 but in such case it is not guaranteed whether this
+ breakpoint did or did not trigger this trap. */
+static int
bpstat_check_watchpoint (bpstat bs)
{
2010-07-21 21:30:20 +00:00
const struct bp_location *bl;
2010-11-17 02:58:16 +00:00
@@ -3878,9 +3907,7 @@ bpstat_check_watchpoint (bpstat bs)
2010-07-21 21:30:20 +00:00
case 0:
/* Error from catch_errors. */
printf_filtered (_("Watchpoint %d deleted.\n"), b->number);
- if (b->related_breakpoint)
- b->related_breakpoint->disposition = disp_del_at_next_stop;
- b->disposition = disp_del_at_next_stop;
+ watchpoint_del_at_next_stop (b);
/* We've already printed what needs to be printed. */
bs->print_it = print_it_done;
break;
2010-11-17 02:58:16 +00:00
@@ -3894,8 +3921,10 @@ bpstat_check_watchpoint (bpstat bs)
2009-08-18 19:37:35 +00:00
anything for this watchpoint. */
bs->print_it = print_it_noop;
bs->stop = 0;
+ return 0;
}
}
+ return 1;
}
2010-11-17 02:58:16 +00:00
@@ -4035,7 +4064,7 @@ bpstat_stop_status (struct address_space *aspace,
struct bp_location *bl;
struct bp_location *loc;
/* First item of allocated bpstat's. */
- bpstat bs_head = NULL, *bs_link = &bs_head;
+ bpstat bs_head = NULL, *bs_link = &bs_head, *bs_link_next;
/* Pointer to the last thing in the chain currently. */
bpstat bs;
int ix;
@@ -4056,6 +4085,8 @@ bpstat_stop_status (struct address_space *aspace,
2009-03-02 00:11:35 +00:00
2010-01-16 22:32:10 +00:00
for (bl = b->loc; bl != NULL; bl = bl->next)
{
+ bpstat bs_prev = bs;
+
/* For hardware watchpoints, we look only at the first location.
2010-07-21 21:30:20 +00:00
The watchpoint_check function will work on the entire expression,
not the individual locations. For read watchpoints, the
2010-11-17 02:58:16 +00:00
@@ -4084,7 +4115,7 @@ bpstat_stop_status (struct address_space *aspace,
watchpoint as triggered so that we will handle the
out-of-scope event. We'll get to the watchpoint next
iteration. */
- if (b->type == bp_watchpoint_scope)
+ if (b->type == bp_watchpoint_scope && b->related_breakpoint != b)
b->related_breakpoint->watchpoint_triggered = watch_triggered_yes;
}
}
@@ -4108,14 +4139,26 @@ bpstat_stop_status (struct address_space *aspace,
2009-09-10 21:37:41 +00:00
2010-11-17 02:58:16 +00:00
removed_any = 0;
- for (bs = bs_head; bs != NULL; bs = bs->next)
+ for (bs_link = &bs_head; *bs_link != NULL; bs_link = bs_link_next)
{
+ bs = *bs_link;
+ bs_link_next = &bs->next;
+
if (!bs->stop)
continue;
bpstat_check_watchpoint (bs);
if (!bs->stop)
- continue;
+ {
+ /* Ensure bpstat_explains_signal stays false if this BL could not be
+ the cause of this trap. */
+
+ gdb_assert (bs->print_it == print_it_noop);
+ gdb_assert (!bs->stop);
+ bs_link_next = bs_link;
+ xfree (bs);
+ continue;
+ }
b = bs->breakpoint_at;
@@ -4205,7 +4248,7 @@ handle_jit_event (void)
2010-07-21 21:30:20 +00:00
/* Decide what infrun needs to do with this bpstat. */
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
struct bpstat_what
-bpstat_what (bpstat bs)
+bpstat_what (bpstat bs_head)
{
struct bpstat_what retval;
/* We need to defer calling `solib_add', as adding new symbols
2010-11-17 02:58:16 +00:00
@@ -4213,11 +4256,12 @@ bpstat_what (bpstat bs)
2010-07-21 21:30:20 +00:00
and hence may clear unprocessed entries in the BS chain. */
int shlib_event = 0;
int jit_event = 0;
+ bpstat bs;
retval.main_action = BPSTAT_WHAT_KEEP_CHECKING;
retval.call_dummy = STOP_NONE;
- for (; bs != NULL; bs = bs->next)
+ for (bs = bs_head; bs != NULL; bs = bs->next)
2009-09-10 21:37:41 +00:00
{
2010-07-21 21:30:20 +00:00
/* Extract this BS's action. After processing each BS, we check
if its action overrides all we've seem so far. */
2010-11-17 02:58:16 +00:00
@@ -4342,6 +4386,20 @@ bpstat_what (bpstat bs)
2010-07-21 21:30:20 +00:00
out already. */
internal_error (__FILE__, __LINE__,
_("bpstat_what: tracepoint encountered"));
+ break;
+ case bp_gnu_ifunc_resolver:
+ /* Skip the current breakpoint but otherwise nothing happens. GDB is
+ inserting new bp_gnu_ifunc_resolver_return at this point but
+ bp_gnu_ifunc_resolver is being kept there as another
+ bp_gnu_ifunc_resolver_return may be inserted in the meantime. */
+ this_action = BPSTAT_WHAT_SINGLE;
+ break;
+ case bp_gnu_ifunc_resolver_return:
+ /* The whole bp_gnu_ifunc_resolver with its associated
+ bp_gnu_ifunc_resolver_return related_breakpoint's has been
+ resolved now, all these helper breakpoints are being removed and
+ new final bp_breakpoint is being put at the target location. */
+ break;
default:
internal_error (__FILE__, __LINE__,
_("bpstat_what: unhandled bptype %d"), (int) bptype);
2010-11-17 02:58:16 +00:00
@@ -4379,6 +4437,21 @@ bpstat_what (bpstat bs)
2010-07-21 21:30:20 +00:00
handle_jit_event ();
}
+ for (bs = bs_head; bs != NULL; bs = bs->next)
+ {
+ if (bs->breakpoint_at == NULL)
+ continue;
2010-11-17 02:58:16 +00:00
+ switch (bs->breakpoint_at->type)
2010-07-21 21:30:20 +00:00
+ {
+ case bp_gnu_ifunc_resolver:
2010-11-17 02:58:16 +00:00
+ gnu_ifunc_resolver_stop (bs->breakpoint_at);
2010-07-21 21:30:20 +00:00
+ break;
+ case bp_gnu_ifunc_resolver_return:
2010-11-17 02:58:16 +00:00
+ gnu_ifunc_resolver_return_stop (bs->breakpoint_at);
2010-07-21 21:30:20 +00:00
+ break;
+ }
+ }
+
return retval;
}
2010-11-17 02:58:16 +00:00
@@ -4497,6 +4570,8 @@ bptype_string (enum bptype type)
2010-01-16 22:32:10 +00:00
{bp_fast_tracepoint, "fast tracepoint"},
2010-07-21 21:30:20 +00:00
{bp_static_tracepoint, "static tracepoint"},
{bp_jit_event, "jit events"},
+ {bp_gnu_ifunc_resolver, "gnu-ifunc resolver"},
+ {bp_gnu_ifunc_resolver_return, "gnu-func resolver return"},
};
2010-11-17 02:58:16 +00:00
if (((int) type >= (sizeof (bptypes) / sizeof (bptypes[0])))
@@ -4643,6 +4718,8 @@ print_one_breakpoint_location (struct breakpoint *b,
2010-01-16 22:32:10 +00:00
case bp_fast_tracepoint:
2010-07-21 21:30:20 +00:00
case bp_static_tracepoint:
2009-09-10 21:37:41 +00:00
case bp_jit_event:
2010-07-21 21:30:20 +00:00
+ case bp_gnu_ifunc_resolver:
+ case bp_gnu_ifunc_resolver_return:
if (opts.addressprint)
{
annotate_field (4);
2010-11-17 02:58:16 +00:00
@@ -4923,7 +5000,8 @@ user_settable_breakpoint (const struct breakpoint *b)
2010-07-21 21:30:20 +00:00
|| b->type == bp_catchpoint
|| b->type == bp_hardware_breakpoint
|| is_tracepoint (b)
- || is_watchpoint (b));
+ || is_watchpoint (b)
+ || b->type == bp_gnu_ifunc_resolver);
}
/* Print information on user settable breakpoint (watchpoint, etc)
2010-11-17 02:58:16 +00:00
@@ -5389,6 +5467,8 @@ allocate_bp_location (struct breakpoint *bpt)
2009-09-10 21:37:41 +00:00
case bp_jit_event:
case bp_longjmp_master:
2010-07-21 21:30:20 +00:00
case bp_std_terminate_master:
+ case bp_gnu_ifunc_resolver:
+ case bp_gnu_ifunc_resolver_return:
2009-09-10 21:37:41 +00:00
loc->loc_type = bp_loc_software_breakpoint;
break;
case bp_hardware_breakpoint:
2010-11-17 02:58:16 +00:00
@@ -5477,6 +5557,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
2010-07-21 21:30:20 +00:00
b->ops = NULL;
b->condition_not_parsed = 0;
2010-11-17 02:58:16 +00:00
b->py_bp_object = NULL;
2010-07-21 21:30:20 +00:00
+ b->related_breakpoint = b;
/* Add this breakpoint to the end of the chain
so that a list of breakpoints will come out in order
2010-11-17 02:58:16 +00:00
@@ -5496,7 +5577,7 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
2010-07-21 21:30:20 +00:00
/* Initialize loc->function_name. */
static void
-set_breakpoint_location_function (struct bp_location *loc)
+set_breakpoint_location_function (struct bp_location *loc, int explicit_loc)
{
gdb_assert (loc->owner != NULL);
2010-11-17 02:58:16 +00:00
@@ -5504,8 +5585,29 @@ set_breakpoint_location_function (struct bp_location *loc)
2010-07-21 21:30:20 +00:00
|| loc->owner->type == bp_hardware_breakpoint
|| is_tracepoint (loc->owner))
{
- find_pc_partial_function (loc->address, &(loc->function_name),
- NULL, NULL);
+ if (find_pc_partial_function (loc->address, &(loc->function_name), NULL,
+ NULL) == FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
+ && !explicit_loc)
+ {
+ struct breakpoint *b = loc->owner;
+
+ gdb_assert (loc->pspace == current_program_space);
+ if (resolve_gnu_ifunc (loc->function_name, &loc->requested_address))
+ {
+ /* Recalculate ADDRESS based on new REQUESTED_ADDRESS. */
+ loc->address = adjust_breakpoint_address (loc->gdbarch,
+ loc->requested_address,
+ b->type);
+ }
+ else if (b->type == bp_breakpoint && b->loc == loc
+ && loc->next == NULL && b->related_breakpoint == b)
+ {
+ /* Create only the whole new breakpoint of this type but do not
+ mess more complicated breakpoints with multiple locations. */
+ b->type = bp_gnu_ifunc_resolver;
+ }
+ }
+
if (loc->function_name)
loc->function_name = xstrdup (loc->function_name);
}
2010-11-17 02:58:16 +00:00
@@ -5578,7 +5680,8 @@ set_raw_breakpoint (struct gdbarch *gdbarch,
2010-07-21 21:30:20 +00:00
b->loc->section = sal.section;
b->line_number = sal.line;
- set_breakpoint_location_function (b->loc);
+ set_breakpoint_location_function (b->loc,
+ sal.explicit_pc || sal.explicit_line);
breakpoints_changed ();
2010-11-17 02:58:16 +00:00
@@ -6652,7 +6755,7 @@ clone_momentary_breakpoint (struct breakpoint *orig)
2010-07-21 21:30:20 +00:00
copy = set_raw_breakpoint_without_location (orig->gdbarch, orig->type);
copy->loc = allocate_bp_location (copy);
- set_breakpoint_location_function (copy->loc);
+ set_breakpoint_location_function (copy->loc, 1);
copy->loc->gdbarch = orig->loc->gdbarch;
copy->loc->requested_address = orig->loc->requested_address;
2010-11-17 02:58:16 +00:00
@@ -6751,6 +6854,7 @@ mention (struct breakpoint *b)
2010-07-21 21:30:20 +00:00
do_cleanups (ui_out_chain);
break;
case bp_breakpoint:
+ case bp_gnu_ifunc_resolver:
if (ui_out_is_mi_like_p (uiout))
{
say_where = 0;
2010-11-17 02:58:16 +00:00
@@ -6761,6 +6865,8 @@ mention (struct breakpoint *b)
2010-07-21 21:30:20 +00:00
else
printf_filtered (_("Breakpoint"));
printf_filtered (_(" %d"), b->number);
+ if (b->type == bp_gnu_ifunc_resolver)
+ printf_filtered (_(" at gnu-indirect-function resolver"));
say_where = 1;
break;
case bp_hardware_breakpoint:
2010-11-17 02:58:16 +00:00
@@ -6817,6 +6923,7 @@ mention (struct breakpoint *b)
2009-09-10 21:37:41 +00:00
case bp_jit_event:
case bp_longjmp_master:
2010-07-21 21:30:20 +00:00
case bp_std_terminate_master:
+ case bp_gnu_ifunc_resolver_return:
2009-09-10 21:37:41 +00:00
break;
}
2009-03-02 00:11:35 +00:00
2010-11-17 02:58:16 +00:00
@@ -6877,7 +6984,8 @@ add_location_to_breakpoint (struct breakpoint *b,
2010-07-21 21:30:20 +00:00
gdb_assert (loc->pspace != NULL);
loc->section = sal->section;
- set_breakpoint_location_function (loc);
+ set_breakpoint_location_function (loc,
+ sal->explicit_pc || sal->explicit_line);
return loc;
}
2010-11-17 02:58:16 +00:00
@@ -9712,12 +9820,22 @@ delete_breakpoint (struct breakpoint *bpt)
2010-07-21 21:30:20 +00:00
/* At least avoid this stale reference until the reference counting of
breakpoints gets resolved. */
- if (bpt->related_breakpoint != NULL)
+ if (bpt->related_breakpoint != bpt)
{
- gdb_assert (bpt->related_breakpoint->related_breakpoint == bpt);
- bpt->related_breakpoint->disposition = disp_del_at_next_stop;
- bpt->related_breakpoint->related_breakpoint = NULL;
- bpt->related_breakpoint = NULL;
+ if (bpt->type == bp_watchpoint_scope)
+ watchpoint_del_at_next_stop (bpt->related_breakpoint);
+ else if (bpt->related_breakpoint->type == bp_watchpoint_scope)
+ watchpoint_del_at_next_stop (bpt);
+ else
+ {
+ struct breakpoint *related;
+
+ /* Unlink bpt from the bpt->related_breakpoint ring. */
+ for (related = bpt; related->related_breakpoint != bpt;
+ related = related->related_breakpoint);
+ related->related_breakpoint = bpt->related_breakpoint;
+ bpt->related_breakpoint = bpt;
+ }
}
observer_notify_breakpoint_deleted (bpt->number);
2010-11-17 02:58:16 +00:00
@@ -10049,6 +10167,9 @@ update_breakpoint_locations (struct breakpoint *b,
2010-07-21 21:30:20 +00:00
return;
b->loc = NULL;
+ xfree (b->source_file);
+ b->source_file = NULL;
+ b->line_number = 0;
for (i = 0; i < sals.nelts; ++i)
{
2010-11-17 02:58:16 +00:00
@@ -10075,11 +10196,7 @@ update_breakpoint_locations (struct breakpoint *b,
2010-07-21 21:30:20 +00:00
}
}
- if (b->source_file != NULL)
- xfree (b->source_file);
- if (sals.sals[i].symtab == NULL)
- b->source_file = NULL;
- else
+ if (sals.sals[i].symtab != NULL && b->source_file == NULL)
b->source_file = xstrdup (sals.sals[i].symtab->filename);
if (b->line_number == 0)
2010-11-17 02:58:16 +00:00
@@ -10161,6 +10278,7 @@ breakpoint_re_set_one (void *bint)
2010-07-21 21:30:20 +00:00
case bp_tracepoint:
case bp_fast_tracepoint:
case bp_static_tracepoint:
+ case bp_gnu_ifunc_resolver:
/* Do not attempt to re-set breakpoints disabled during startup. */
if (b->enable_state == bp_startup_disabled)
return 0;
2010-11-17 02:58:16 +00:00
@@ -10325,6 +10443,7 @@ breakpoint_re_set_one (void *bint)
2010-01-16 22:32:10 +00:00
case bp_longjmp:
case bp_longjmp_resume:
case bp_jit_event:
2010-07-21 21:30:20 +00:00
+ case bp_gnu_ifunc_resolver_return:
2010-01-16 22:32:10 +00:00
break;
}
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
@@ -10496,11 +10615,25 @@ map_breakpoint_numbers (char *args, void (*function) (struct breakpoint *,
2010-07-21 21:30:20 +00:00
ALL_BREAKPOINTS_SAFE (b, tmp)
if (b->number == num)
{
- struct breakpoint *related_breakpoint = b->related_breakpoint;
+ struct breakpoint *related_breakpoint;
+
match = 1;
- function (b, data);
- if (related_breakpoint)
- function (related_breakpoint, data);
+ related_breakpoint = b;
+ do
+ {
+ struct breakpoint *next_related_b;
+
+ /* FUNCTION can be also delete_breakpoint. */
+ next_related_b = related_breakpoint->related_breakpoint;
+ function (related_breakpoint, data);
2010-11-17 02:58:16 +00:00
+
+ /* For delete_breakpoint of the last entry of the ring we
+ were traversing we would never get back to B. */
+ if (next_related_b == related_breakpoint)
+ break;
2010-07-21 21:30:20 +00:00
+ related_breakpoint = next_related_b;
+ }
+ while (related_breakpoint != b);
break;
}
if (match == 0)
2010-11-17 02:58:16 +00:00
@@ -11604,6 +11737,22 @@ all_tracepoints ()
2010-01-16 22:32:10 +00:00
return tp_vec;
2009-09-10 21:37:41 +00:00
}
2010-01-16 22:32:10 +00:00
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
2009-09-10 21:37:41 +00:00
+
+static void
+breakpoint_types_mark_used (void)
+{
+ struct breakpoint *b;
+
+ ALL_BREAKPOINTS (b)
+ {
+ if (b->exp)
+ exp_types_mark_used (b->exp);
+ if (b->val)
+ type_mark_used (value_type (b->val));
+ }
+}
+
/* This help string is used for the break, hbreak, tbreak and thbreak commands.
It is defined as a macro to prevent duplication.
2010-11-17 02:58:16 +00:00
@@ -11673,6 +11822,107 @@ save_command (char *arg, int from_tty)
2010-07-21 21:30:20 +00:00
help_list (save_cmdlist, "save ", -1, gdb_stdout);
}
+static void
+gnu_ifunc_resolver_stop (struct breakpoint *b)
+{
+ struct breakpoint *b_return;
+ struct frame_info *prev_frame = get_prev_frame (get_current_frame ());
+ struct frame_id prev_frame_id = get_stack_frame_id (prev_frame);
+ CORE_ADDR prev_pc = get_frame_pc (prev_frame);
+ int thread_id = pid_to_thread_id (inferior_ptid);
+
+ gdb_assert (b->type == bp_gnu_ifunc_resolver);
+
+ for (b_return = b->related_breakpoint; b_return != b;
+ b_return = b_return->related_breakpoint)
+ {
+ gdb_assert (b_return->type == bp_gnu_ifunc_resolver_return);
+ gdb_assert (b_return->loc != NULL && b_return->loc->next == NULL);
+ gdb_assert (frame_id_p (b_return->frame_id));
+
+ if (b_return->thread == thread_id
+ && b_return->loc->requested_address == prev_pc
+ && frame_id_eq (b_return->frame_id, prev_frame_id))
+ break;
+ }
+
+ if (b_return == b)
+ {
+ struct symtab_and_line sal;
+
+ /* No need to call find_pc_line for symbols resolving as this is only
+ a helper breakpointer never shown to the user. */
+
+ init_sal (&sal);
+ sal.pspace = current_inferior ()->pspace;
+ sal.pc = prev_pc;
+ sal.section = find_pc_overlay (sal.pc);
+ sal.explicit_pc = 1;
+ b_return = set_momentary_breakpoint (get_frame_arch (prev_frame), sal,
+ prev_frame_id,
+ bp_gnu_ifunc_resolver_return);
+
+ /* Add new b_return to the ring list b->related_breakpoint. */
+ gdb_assert (b_return->related_breakpoint == b_return);
+ b_return->related_breakpoint = b->related_breakpoint;
+ b->related_breakpoint = b_return;
+ }
+}
+
+static void
+gnu_ifunc_resolver_return_stop (struct breakpoint *b)
+{
+ struct gdbarch *gdbarch = get_frame_arch (get_current_frame ());
+ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
+ struct type *value_type = TYPE_TARGET_TYPE (func_func_type);
+ struct regcache *regcache = get_thread_regcache (inferior_ptid);
+ struct value *value;
+ CORE_ADDR resolved_address, resolved_pc;
+ struct symtab_and_line sal;
+ struct symtabs_and_lines sals;
+
+ gdb_assert (b->type == bp_gnu_ifunc_resolver_return);
+
+ value = allocate_value (value_type);
+ gdbarch_return_value (gdbarch, func_func_type, value_type, regcache,
+ value_contents_raw (value), NULL);
+ resolved_address = value_as_address (value);
+ resolved_pc = gdbarch_convert_from_func_ptr_addr (gdbarch,
+ resolved_address,
+ ¤t_target);
+
+ while (b->related_breakpoint != b)
+ {
+ struct breakpoint *b_next = b->related_breakpoint;
+
+ switch (b->type)
+ {
+ case bp_gnu_ifunc_resolver:
+ break;
+ case bp_gnu_ifunc_resolver_return:
+ delete_breakpoint (b);
+ break;
+ default:
+ internal_error (__FILE__, __LINE__,
+ _("handle_inferior_event: Invalid "
+ "gnu-indirect-function breakpoint type %d"),
+ (int) b->type);
+ }
+ b = b_next;
+ }
+ gdb_assert (b->type == bp_gnu_ifunc_resolver);
+
+ gdb_assert (current_program_space == b->pspace);
+ gnu_ifunc_record_cache (gdbarch, b->addr_string, resolved_pc);
+
+ sal = find_pc_line (resolved_pc, 0);
+ sals.nelts = 1;
+ sals.sals = &sal;
+
+ b->type = bp_breakpoint;
+ update_breakpoint_locations (b, sals);
+}
+
2010-11-17 02:58:16 +00:00
struct breakpoint *
iterate_over_breakpoints (int (*callback) (struct breakpoint *, void *),
void *data)
@@ -12222,4 +12472,5 @@ inferior in all-stop mode, gdb behaves as if always-inserted mode is off."),
2009-09-10 21:37:41 +00:00
automatic_hardware_breakpoints = 1;
observer_attach_about_to_proceed (breakpoint_about_to_proceed);
+ observer_attach_mark_used (breakpoint_types_mark_used);
}
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
2010-11-17 02:58:16 +00:00
index e34c2d3..4aadd57 100644
2009-09-10 21:37:41 +00:00
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
2010-11-17 02:58:16 +00:00
@@ -138,6 +138,9 @@ enum bptype
2010-07-21 21:30:20 +00:00
/* Event for JIT compiled code generation or deletion. */
bp_jit_event,
+
+ bp_gnu_ifunc_resolver,
+ bp_gnu_ifunc_resolver_return,
};
/* States of enablement of breakpoint. */
2009-08-04 05:37:29 +00:00
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
2010-11-17 02:58:16 +00:00
index 04f8127..2e29eb2 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
2010-11-17 02:58:16 +00:00
@@ -579,7 +579,13 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
fprintf_filtered (stream, ")");
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
fprintf_filtered (stream, "[");
- if (get_array_bounds (type, &low_bound, &high_bound))
+ if (TYPE_RANGE_DATA (TYPE_INDEX_TYPE (type))->high.kind
+ != RANGE_BOUND_KIND_CONSTANT)
+ {
+ /* No _() - printed sources should not be locale dependent. */
+ fprintf_filtered (stream, "variable");
+ }
+ else if (get_array_bounds (type, &low_bound, &high_bound))
fprintf_filtered (stream, "%d", (int) (high_bound - low_bound + 1));
fprintf_filtered (stream, "]");
2010-07-22 10:49:58 +00:00
2010-07-21 21:30:20 +00:00
diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo
2010-11-17 02:58:16 +00:00
index 4a112aa..7b6bed4 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/doc/gdbint.texinfo
+++ b/gdb/doc/gdbint.texinfo
2010-11-17 02:58:16 +00:00
@@ -2104,6 +2104,18 @@ time, and so we attempt to handle symbols incrementally. For instance,
2010-07-21 21:30:20 +00:00
we create @dfn{partial symbol tables} consisting of only selected
symbols, and only expand them to full symbol tables when necessary.
+@menu
+* Symbol Reading::
+* Partial Symbol Tables::
+* Types::
+* Object File Formats::
+* Debugging File Formats::
+* Adding a New Symbol Reader to GDB::
+* Memory Management for Symbol Files::
+* Memory Management for Types::
+@end menu
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+@node Symbol Reading
@section Symbol Reading
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
@cindex symbol reading
2010-11-17 02:58:16 +00:00
@@ -2196,6 +2208,7 @@ symtab. Upon return, @code{pst->readin} should have been set to 1, and
2010-07-21 21:30:20 +00:00
zero if there were no symbols in that part of the symbol file.
@end table
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
+@node Partial Symbol Tables
@section Partial Symbol Tables
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
@value{GDBN} has three types of symbol tables:
2010-11-17 02:58:16 +00:00
@@ -2297,6 +2310,7 @@ and partial symbol tables behind a set of function pointers known as
2010-07-21 21:30:20 +00:00
the @dfn{quick symbol functions}. These are documented in
@file{symfile.h}.
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
+@node Types
@section Types
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
@unnumberedsubsec Fundamental Types (e.g., @code{FT_VOID}, @code{FT_BOOLEAN}).
2010-11-17 02:58:16 +00:00
@@ -2319,6 +2333,7 @@ types map to one @code{TYPE_CODE_*} type, and are distinguished by
2010-07-21 21:30:20 +00:00
other members of the type struct, such as whether the type is signed
or unsigned, and how many bits it uses.
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
+@anchor{Builtin Types}
@unnumberedsubsec Builtin Types (e.g., @code{builtin_type_void}, @code{builtin_type_char}).
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
These are instances of type structs that roughly correspond to
2010-11-17 02:58:16 +00:00
@@ -2333,6 +2348,7 @@ only one instance exists, while @file{c-lang.c} builds as many
2010-07-21 21:30:20 +00:00
@code{TYPE_CODE_INT} types as needed, with each one associated with
some particular objfile.
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
+@node Object File Formats
@section Object File Formats
@cindex object file formats
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
@@ -2418,6 +2434,7 @@ SOM, which is a cross-language ABI).
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
The SOM reader is in @file{somread.c}.
2010-07-11 18:06:33 +00:00
2010-07-21 21:30:20 +00:00
+@node Debugging File Formats
@section Debugging File Formats
2010-07-11 18:06:33 +00:00
2010-07-21 21:30:20 +00:00
This section describes characteristics of debugging information that
2010-11-17 02:58:16 +00:00
@@ -2489,6 +2506,7 @@ DWARF 3 is an improved version of DWARF 2.
2010-07-21 21:30:20 +00:00
@cindex SOM debugging info
Like COFF, the SOM definition includes debugging information.
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
+@node Adding a New Symbol Reader to GDB
@section Adding a New Symbol Reader to @value{GDBN}
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
@cindex adding debugging info reader
2010-11-17 02:58:16 +00:00
@@ -2511,6 +2529,7 @@ will only ever be implemented by one object file format may be called
2010-07-21 21:30:20 +00:00
directly. This interface should be described in a file
@file{bfd/lib@var{xyz}.h}, which is included by @value{GDBN}.
+@node Memory Management for Symbol Files
@section Memory Management for Symbol Files
Most memory associated with a loaded symbol file is stored on
2010-11-17 02:58:16 +00:00
@@ -2522,10 +2541,45 @@ released when the objfile is unloaded or reloaded. Therefore one
2010-07-21 21:30:20 +00:00
objfile must not reference symbol or type data from another objfile;
they could be unloaded at different times.
-User convenience variables, et cetera, have associated types. Normally
-these types live in the associated objfile. However, when the objfile
-is unloaded, those types are deep copied to global memory, so that
-the values of the user variables and history items are not lost.
+@node Memory Management for Types
+@section Memory Management for Types
+@cindex memory management for types
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
+@findex TYPE_OBJFILE
+@code{TYPE_OBJFILE} macro indicates the current memory owner of the type.
+Non-@code{NULL} value indicates it is owned by an objfile (specifically by its
+obstack) and in such case the type remains valid till the objfile is unloaded
+or reloaded. For such types with an associated objfile no reference counting
+is being made.
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
+User convenience variables, et cetera, have associated types. Normally these
+types live in the associated objfile. However, when the objfile is unloaded,
+those types are deep copied to global memory, so that the values of the user
+variables and history items are not lost. During the copy they will get their
+@code{TYPE_OBJFILE} set to @code{NULL} and become so-called @dfn{reclaimable}
+types.
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
+Types with null @code{TYPE_OBJFILE} can be either permanent types
+(@pxref{Builtin Types}) or reclaimable types which will be deallocated at the
+first idle @value{GDBN} moment if the last object referencing them is removed.
+Permanent types are allocated by the function @code{alloc_type} (and its
+derivations like @code{init_type}) specifying objfile as @code{NULL}. The
+reclaimable types are created the same way but moreover they need to have
+@code{type_init_group} called to start their tracking as being possibly
+deallocatable.
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
+@findex free_all_types
+When @value{GDBN} gets idle it always calls the @code{free_all_types} function
+which deallocates any unused types. All types currently not owned by an
+objfile must be marked as used on each @code{free_all_types} call as they would
+get deallocated as unused otherwise.
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
+@code{free_all_types} automatically checks for any cross-type references such
+as through @code{TYPE_TARGET_TYPE}, @code{TYPE_POINTER_TYPE} etc.@: and
+prevents early deallocation for any such existing references. Reclaimable
+types may reference any other reclaimable types or even permanent types. But
+permanent types must not reference reclaimable types (nor an objfile associated
+type).
2010-01-21 16:09:11 +00:00
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
@node Language Support
diff --git a/gdb/doc/observer.texi b/gdb/doc/observer.texi
index e19b8ed..343e160 100644
--- a/gdb/doc/observer.texi
+++ b/gdb/doc/observer.texi
@@ -223,6 +223,11 @@ Bytes from @var{data} to @var{data} + @var{len} have been written
to the current inferior at @var{addr}.
@end deftypefun
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
+@deftypefun void mark_used (void)
+Mark any possibly reclaimable objects as used during a mark-and-sweep garbage
+collector pass. Currently only @code{type_mark_used} marker is supported.
+@end deftypefun
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
@deftypefun void test_notification (int @var{somearg})
This observer is used for internal testing. Do not use.
See testsuite/gdb.gdb/observer.exp.
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index b9ae108..2555908 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -875,6 +875,13 @@ execute_stack_op (struct dwarf_expr_context *ctx,
ctx->dwarf_call (ctx, result);
goto no_push;
+ case DW_OP_push_object_address:
+ if (ctx->get_object_address == NULL)
+ error (_("DWARF-2 expression error: DW_OP_push_object_address must "
+ "have a value to push."));
+ result = (ctx->get_object_address) (ctx->baton);
+ break;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
default:
error (_("Unhandled dwarf expression opcode 0x%x"), op);
2010-01-21 16:09:11 +00:00
}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h
index 61b8f00..d94c03c 100644
--- a/gdb/dwarf2expr.h
+++ b/gdb/dwarf2expr.h
@@ -108,9 +108,15 @@ struct dwarf_expr_context
#if 0
/* Not yet implemented. */
+ /* Return the location expression for the dwarf expression
+ subroutine in the die at OFFSET in the current compilation unit.
+ The result must be live until the current expression evaluation
+ is complete. */
+ unsigned char *(*get_subr) (void *baton, off_t offset, size_t *length);
+#endif
+
/* Return the `object address' for DW_OP_push_object_address. */
CORE_ADDR (*get_object_address) (void *baton);
-#endif
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
/* The current depth of dwarf expression recursion, via DW_OP_call*,
DW_OP_fbreg, DW_OP_push_object_address, etc., and the maximum
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
2010-11-17 02:58:16 +00:00
index b2aecf2..afc7907 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
2010-11-17 02:58:16 +00:00
@@ -127,6 +127,9 @@ struct dwarf_expr_baton
2010-01-21 16:09:11 +00:00
{
2010-07-21 21:30:20 +00:00
struct frame_info *frame;
struct dwarf2_per_cu_data *per_cu;
+ /* From DW_TAG_variable's DW_AT_location (not DW_TAG_type's
+ DW_AT_data_location) for DW_OP_push_object_address. */
+ CORE_ADDR object_address;
};
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
/* Helper functions for dwarf2_evaluate_loc_desc. */
2010-11-17 02:58:16 +00:00
@@ -195,23 +198,33 @@ dwarf_expr_frame_base_1 (struct symbol *framefunc, CORE_ADDR pc,
2010-07-21 21:30:20 +00:00
symbaton = SYMBOL_LOCATION_BATON (framefunc);
*start = find_location_expression (symbaton, length, pc);
2010-01-21 16:09:11 +00:00
}
2010-07-21 21:30:20 +00:00
- else
+ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_locexpr_funcs)
2010-01-21 16:09:11 +00:00
{
2010-07-21 21:30:20 +00:00
struct dwarf2_locexpr_baton *symbaton;
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
symbaton = SYMBOL_LOCATION_BATON (framefunc);
- if (symbaton != NULL)
- {
- *length = symbaton->size;
- *start = symbaton->data;
- }
- else
- *start = NULL;
+ gdb_assert (symbaton != NULL);
+ *start = symbaton->data;
+ *length = symbaton->size;
2010-01-21 16:09:11 +00:00
}
2010-07-21 21:30:20 +00:00
+ else if (SYMBOL_COMPUTED_OPS (framefunc) == &dwarf2_missing_funcs)
+ {
+ struct dwarf2_locexpr_baton *symbaton;
+
+ symbaton = SYMBOL_LOCATION_BATON (framefunc);
+ gdb_assert (symbaton == NULL);
+ *start = NULL;
+ *length = 0; /* unused */
+ }
+ else
+ internal_error (__FILE__, __LINE__,
+ _("Unsupported SYMBOL_COMPUTED_OPS %p for \"%s\""),
+ SYMBOL_COMPUTED_OPS (framefunc),
+ SYMBOL_PRINT_NAME (framefunc));
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
if (*start == NULL)
error (_("Could not find the frame base for \"%s\"."),
- SYMBOL_NATURAL_NAME (framefunc));
+ SYMBOL_PRINT_NAME (framefunc));
2010-01-21 16:09:11 +00:00
}
2010-07-21 21:30:20 +00:00
/* Helper function for dwarf2_evaluate_loc_desc. Computes the CFA for
2010-11-17 02:58:16 +00:00
@@ -263,6 +276,158 @@ dwarf_expr_dwarf_call (struct dwarf_expr_context *ctx, size_t die_offset)
2010-07-21 21:30:20 +00:00
return per_cu_dwarf_call (ctx, die_offset, debaton->per_cu);
2010-07-11 18:06:33 +00:00
}
2010-07-21 21:30:20 +00:00
+static CORE_ADDR
+dwarf_expr_object_address (void *baton)
+{
+ struct dwarf_expr_baton *debaton = baton;
+
+ /* The message is suppressed in DWARF_BLOCK_EXEC. */
+ if (debaton->object_address == 0)
+ error (_("Cannot resolve DW_OP_push_object_address for a missing object"));
+
+ return debaton->object_address;
+}
+
+/* Address of the variable we are currently referring to. It is set from
+ DW_TAG_variable's DW_AT_location (not DW_TAG_type's DW_AT_data_location) for
+ DW_OP_push_object_address. */
+
+static CORE_ADDR object_address;
+
+/* Callers use object_address_set while their callers use the result set so we
+ cannot run the cleanup at the local block of our direct caller. Still we
+ should reset OBJECT_ADDRESS at least for the next GDB command. */
2010-07-11 18:06:33 +00:00
+
+static void
2010-07-21 21:30:20 +00:00
+object_address_cleanup (void *prev_save_voidp)
2010-07-11 18:06:33 +00:00
+{
2010-07-21 21:30:20 +00:00
+ CORE_ADDR *prev_save = prev_save_voidp;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ object_address = *prev_save;
+ xfree (prev_save);
+}
+
+/* Set the base address - DW_AT_location - of a variable. It is being later
+ used to derive other object addresses by DW_OP_push_object_address.
+
+ It would be useful to sanity check ADDRESS - such as for some objects with
+ unset value_raw_address - but some valid addresses may be zero (such as first
+ objects in relocatable .o files). */
+
+void
+object_address_set (CORE_ADDR address)
+{
+ CORE_ADDR *prev_save;
+
+ prev_save = xmalloc (sizeof *prev_save);
+ *prev_save = object_address;
+ make_cleanup (object_address_cleanup, prev_save);
+
+ object_address = address;
2010-07-11 18:06:33 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+/* Evaluate DWARF expression at DATA ... DATA + SIZE with its result readable
+ by dwarf_expr_fetch (RETVAL, 0). FRAME parameter can be NULL to call
+ get_selected_frame to find it. Returned dwarf_expr_context freeing is
+ pushed on the cleanup chain. */
+
+static struct dwarf_expr_context *
+dwarf_expr_prep_ctx (struct frame_info *frame, const gdb_byte *data,
+ size_t size, struct dwarf2_per_cu_data *per_cu)
2010-07-11 18:06:33 +00:00
+{
2010-07-21 21:30:20 +00:00
+ struct dwarf_expr_context *ctx;
+ struct dwarf_expr_baton baton;
+ struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
+
+ baton.frame = frame;
+ baton.per_cu = per_cu;
+ baton.object_address = object_address;
+
+ ctx = new_dwarf_expr_context ();
+ make_cleanup_free_dwarf_expr_context (ctx);
+
+ ctx->gdbarch = get_objfile_arch (objfile);
+ ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
+ ctx->offset = dwarf2_per_cu_text_offset (per_cu);
+ ctx->baton = &baton;
+ ctx->read_reg = dwarf_expr_read_reg;
+ ctx->read_mem = dwarf_expr_read_mem;
+ ctx->get_frame_base = dwarf_expr_frame_base;
+ ctx->get_frame_cfa = dwarf_expr_frame_cfa;
+ ctx->get_tls_address = dwarf_expr_tls_address;
+ ctx->dwarf_call = dwarf_expr_dwarf_call;
+ ctx->get_object_address = dwarf_expr_object_address;
+
+ dwarf_expr_eval (ctx, data, size);
+
+ /* It was used only during dwarf_expr_eval. */
+ ctx->baton = NULL;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ return ctx;
+}
+
+/* Evaluate DWARF expression at DLBATON expecting it produces exactly one
+ CORE_ADDR result on the DWARF stack stack. */
+
+CORE_ADDR
+dwarf_locexpr_baton_eval (struct dwarf2_locexpr_baton *dlbaton)
+{
+ struct dwarf_expr_context *ctx;
+ CORE_ADDR retval;
+ struct cleanup *back_to = make_cleanup (null_cleanup, 0);
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ ctx = dwarf_expr_prep_ctx (get_selected_frame (NULL), dlbaton->data,
+ dlbaton->size, dlbaton->per_cu);
+ if (ctx->num_pieces > 0)
+ error (_("DW_OP_*piece is unsupported for DW_FORM_block"));
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ retval = dwarf_expr_fetch (ctx, 0);
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (ctx->location == DWARF_VALUE_REGISTER)
2010-07-11 18:06:33 +00:00
+ {
2010-07-21 21:30:20 +00:00
+ /* Inlined dwarf_expr_read_reg as we no longer have the baton. */
+
+ int gdb_regnum = gdbarch_dwarf2_reg_to_regnum (ctx->gdbarch, retval);
+ struct type *type = builtin_type (ctx->gdbarch)->builtin_data_ptr;
+ struct frame_info *frame = get_selected_frame (NULL);
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ retval = address_from_register (type, gdb_regnum, frame);
2010-07-11 18:06:33 +00:00
+ }
+
2010-07-21 21:30:20 +00:00
+ do_cleanups (back_to);
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ return retval;
2010-07-11 18:06:33 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+/* Evaluate DWARF location list at DLLBATON expecting it produces exactly one
+ CORE_ADDR result stored to *ADDRP on the DWARF stack stack. If the result
+ could not be found return zero and keep *ADDRP unchanged. */
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+int
+dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
+ struct type *type, CORE_ADDR *addrp)
2010-07-11 18:06:33 +00:00
+{
2010-07-21 21:30:20 +00:00
+ struct frame_info *frame = get_selected_frame (NULL);
+ const gdb_byte *data;
+ size_t size;
+ struct value *val;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (!dllbaton)
+ return 0;
+
+ data = find_location_expression (dllbaton, &size,
+ get_frame_address_in_block (frame));
+ if (data == NULL)
+ return 0;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ val = dwarf2_evaluate_loc_desc (type, frame, data, size, dllbaton->per_cu);
+ if (value_optimized_out (val))
+ return 0;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
+ *addrp = value_as_address (val);
+ return 1;
2010-07-11 18:06:33 +00:00
+}
2010-07-21 21:30:20 +00:00
+
struct piece_closure
{
/* Reference count. */
2010-11-17 02:58:16 +00:00
@@ -887,10 +1052,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
2010-07-21 21:30:20 +00:00
struct dwarf2_per_cu_data *per_cu)
{
struct value *retval;
- struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
- struct cleanup *old_chain;
- struct objfile *objfile = dwarf2_per_cu_objfile (per_cu);
+ struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
2010-07-11 18:06:33 +00:00
2010-07-21 21:30:20 +00:00
if (size == 0)
{
2010-11-17 02:58:16 +00:00
@@ -900,24 +1063,8 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
2010-07-21 21:30:20 +00:00
return retval;
2010-07-11 18:06:33 +00:00
}
2010-07-21 21:30:20 +00:00
- baton.frame = frame;
- baton.per_cu = per_cu;
+ ctx = dwarf_expr_prep_ctx (frame, data, size, per_cu);
2010-07-11 18:06:33 +00:00
2010-07-21 21:30:20 +00:00
- ctx = new_dwarf_expr_context ();
- old_chain = make_cleanup_free_dwarf_expr_context (ctx);
2010-07-11 18:06:33 +00:00
-
2010-07-21 21:30:20 +00:00
- ctx->gdbarch = get_objfile_arch (objfile);
- ctx->addr_size = dwarf2_per_cu_addr_size (per_cu);
- ctx->offset = dwarf2_per_cu_text_offset (per_cu);
- ctx->baton = &baton;
- ctx->read_reg = dwarf_expr_read_reg;
- ctx->read_mem = dwarf_expr_read_mem;
- ctx->get_frame_base = dwarf_expr_frame_base;
- ctx->get_frame_cfa = dwarf_expr_frame_cfa;
- ctx->get_tls_address = dwarf_expr_tls_address;
- ctx->dwarf_call = dwarf_expr_dwarf_call;
-
- dwarf_expr_eval (ctx, data, size);
if (ctx->num_pieces > 0)
{
struct piece_closure *c;
2010-11-17 02:58:16 +00:00
@@ -951,6 +1098,11 @@ dwarf2_evaluate_loc_desc (struct type *type, struct frame_info *frame,
2010-07-21 21:30:20 +00:00
CORE_ADDR address = dwarf_expr_fetch_address (ctx, 0);
int in_stack_memory = dwarf_expr_fetch_in_stack_memory (ctx, 0);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+ /* object_address_set called here is required in ALLOCATE_VALUE's
+ CHECK_TYPEDEF for the object's possible
+ DW_OP_push_object_address. */
+ object_address_set (address);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
retval = allocate_value (type);
VALUE_LVAL (retval) = lval_memory;
set_value_lazy (retval, 1);
2010-11-17 02:58:16 +00:00
@@ -2587,11 +2739,51 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
2010-07-21 21:30:20 +00:00
dlbaton->per_cu);
}
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
-/* The set of location functions used with the DWARF-2 expression
- evaluator and location lists. */
+/* The set of location functions used with the DWARF-2 location lists. */
const struct symbol_computed_ops dwarf2_loclist_funcs = {
loclist_read_variable,
loclist_read_needs_frame,
loclist_describe_location,
loclist_tracepoint_var_ref
};
+
+static struct value *
+missing_read_variable (struct symbol *symbol, struct frame_info *frame)
+{
+ struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+
+ gdb_assert (dlbaton == NULL);
+ error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
+}
+
+static int
+missing_read_needs_frame (struct symbol *symbol)
+{
+ return 0;
+}
+
+static void
+missing_describe_location (struct symbol *symbol, CORE_ADDR addr,
+ struct ui_file *stream)
+{
+ fprintf_filtered (stream, _("a variable we are unable to resolve"));
+}
+
+static void
+missing_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
+ struct agent_expr *ax, struct axs_value *value)
+{
+ struct dwarf2_loclist_baton *dlbaton = SYMBOL_LOCATION_BATON (symbol);
+
+ gdb_assert (dlbaton == NULL);
+ error (_("Unable to resolve variable \"%s\""), SYMBOL_PRINT_NAME (symbol));
+}
+
+/* The set of location functions used with the DWARF-2 evaluator when we are
+ unable to resolve the symbols. */
+const struct symbol_computed_ops dwarf2_missing_funcs = {
+ missing_read_variable,
+ missing_read_needs_frame,
+ missing_describe_location,
+ missing_tracepoint_var_ref
+};
diff --git a/gdb/dwarf2loc.h b/gdb/dwarf2loc.h
2010-11-17 02:58:16 +00:00
index a2cfe7f..f2d07ef 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/dwarf2loc.h
+++ b/gdb/dwarf2loc.h
2010-11-17 02:58:16 +00:00
@@ -96,5 +96,14 @@ struct dwarf2_loclist_baton
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
extern const struct symbol_computed_ops dwarf2_locexpr_funcs;
extern const struct symbol_computed_ops dwarf2_loclist_funcs;
+extern const struct symbol_computed_ops dwarf2_missing_funcs;
+
+extern void object_address_set (CORE_ADDR address);
+
+extern CORE_ADDR dwarf_locexpr_baton_eval
+ (struct dwarf2_locexpr_baton *dlbaton);
+
+extern int dwarf_loclist_baton_eval (struct dwarf2_loclist_baton *dllbaton,
+ struct type *type, CORE_ADDR *addrp);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
#endif /* dwarf2loc.h */
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
2010-11-17 02:58:16 +00:00
index 404faf8..e372afb 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
2010-11-17 02:58:16 +00:00
@@ -1221,6 +1221,9 @@ static int attr_form_is_section_offset (struct attribute *);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
static int attr_form_is_constant (struct attribute *);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+static struct dwarf2_loclist_baton *dwarf2_attr_to_loclist_baton
+ (struct attribute *attr, struct dwarf2_cu *cu);
+
static void dwarf2_symbol_mark_computed (struct attribute *attr,
struct symbol *sym,
struct dwarf2_cu *cu);
2010-11-17 02:58:16 +00:00
@@ -1251,6 +1254,9 @@ static void age_cached_comp_units (void);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
static void free_one_cached_comp_unit (void *);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+static void fetch_die_type_attrs (struct die_info *die, struct type *type,
+ struct dwarf2_cu *cu);
+
static struct type *set_die_type (struct die_info *, struct type *,
struct dwarf2_cu *);
2009-08-04 05:37:29 +00:00
2010-11-17 02:58:16 +00:00
@@ -1275,6 +1281,9 @@ static struct type *get_die_type_at_offset (unsigned int,
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
static struct type *get_die_type (struct die_info *die, struct dwarf2_cu *cu);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+static struct dwarf2_locexpr_baton *dwarf2_attr_to_locexpr_baton
+ (struct attribute *attr, struct dwarf2_cu *cu);
+
2010-11-17 02:58:16 +00:00
static void dwarf2_release_queue (void *dummy);
static void queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
@@ -7112,6 +7121,29 @@ process_enumeration_scope (struct die_info *die, struct dwarf2_cu *cu)
new_symbol (die, this_type, cu);
}
+/* Create a new array dimension referencing its target type TYPE.
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ Multidimensional arrays are internally represented as a stack of
+ singledimensional arrays being referenced by their TYPE_TARGET_TYPE. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct type *
+create_single_array_dimension (struct type *type, struct type *range_type,
+ struct die_info *die, struct dwarf2_cu *cu)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ type = create_array_type (NULL, type, range_type);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* These generic type attributes need to be fetched by
+ evaluate_subexp_standard <multi_f77_subscript>'s call of
+ value_subscripted_rvalue only for the innermost array type. */
+ fetch_die_type_attrs (die, type, cu);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* These generic type attributes are checked for allocated/associated
+ validity while accessing FIELD_LOC_KIND_DWARF_BLOCK. */
+ fetch_die_type_attrs (die, range_type, cu);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return type;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Extract all information from a DW_TAG_array_type DIE and put it in
the DIE's type field. For now, this only handles one dimensional
arrays. */
@@ -7125,7 +7157,7 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *element_type, *range_type, *index_type;
struct type **range_types = NULL;
struct attribute *attr;
- int ndim = 0;
+ int ndim = 0, i;
struct cleanup *back_to;
char *name;
2009-08-04 05:37:29 +00:00
2010-11-17 02:58:16 +00:00
@@ -7178,17 +7210,11 @@ read_array_type (struct die_info *die, struct dwarf2_cu *cu)
type = element_type;
2009-08-04 05:37:29 +00:00
2010-11-17 02:58:16 +00:00
if (read_array_order (die, cu) == DW_ORD_col_major)
- {
- int i = 0;
-
- while (i < ndim)
- type = create_array_type (NULL, type, range_types[i++]);
- }
- else
- {
- while (ndim-- > 0)
- type = create_array_type (NULL, type, range_types[ndim]);
- }
+ for (i = 0; i < ndim; i++)
+ type = create_single_array_dimension (type, range_types[i], die, cu);
+ else /* (read_array_order (die, cu) == DW_ORD_row_major) */
+ for (i = ndim - 1; i >= 0; i--)
+ type = create_single_array_dimension (type, range_types[i], die, cu);
2009-03-02 00:11:35 +00:00
2010-11-17 02:58:16 +00:00
/* Understand Dwarf2 support for vector types (like they occur on
the PowerPC w/ AltiVec). Gcc just adds another attribute to the
@@ -7681,29 +7707,114 @@ read_tag_string_type (struct die_info *die, struct dwarf2_cu *cu)
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *type, *range_type, *index_type, *char_type;
struct attribute *attr;
- unsigned int length;
+ int length;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ index_type = objfile_type (objfile)->builtin_int;
+ /* RANGE_TYPE is allocated from OBJFILE, not as a permanent type. */
+ range_type = alloc_type (objfile);
+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
+ range_type = create_range_type (range_type, index_type, 0, -1);
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* C/C++ should probably have the low bound 0 but C/C++ does not use
+ DW_TAG_string_type. */
+ TYPE_LOW_BOUND (range_type) = 1;
attr = dwarf2_attr (die, DW_AT_string_length, cu);
- if (attr)
- {
- length = DW_UNSND (attr);
+ if (attr && attr_form_is_block (attr))
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* Security check for a size overflow. */
+ if (DW_BLOCK (attr)->size + 2 < DW_BLOCK (attr)->size)
+ TYPE_HIGH_BOUND (range_type) = 1;
+ /* Extend the DWARF block by a new DW_OP_deref/DW_OP_deref_size
+ instruction as DW_AT_string_length specifies the length location, not
+ its value. */
+ else
+ {
+ struct dwarf2_locexpr_baton *length_baton = NULL;
+ struct dwarf_block *blk = DW_BLOCK (attr);
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Turn any single DW_OP_reg* into DW_OP_breg*(0) but clearing
+ DW_OP_deref* in such case. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (blk->size == 1 && blk->data[0] >= DW_OP_reg0
+ && blk->data[0] <= DW_OP_reg31)
+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
+ else if (blk->size > 1 && blk->data[0] == DW_OP_regx)
+ {
+ ULONGEST ulongest;
+ const gdb_byte *end;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ end = read_uleb128 (&blk->data[1], &blk->data[blk->size],
+ &ulongest);
+ if (end == &blk->data[blk->size])
+ length_baton = dwarf2_attr_to_locexpr_baton (attr, cu);
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (length_baton == NULL)
+ {
+ struct attribute *size_attr;
+ gdb_byte *data;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ length_baton = obstack_alloc (&cu->comp_unit_obstack,
+ sizeof (*length_baton));
+ length_baton->per_cu = cu->per_cu;
+ length_baton->size = DW_BLOCK (attr)->size + 2;
+ data = obstack_alloc (&cu->comp_unit_obstack,
+ length_baton->size);
+ length_baton->data = data;
+ memcpy (data, DW_BLOCK (attr)->data, DW_BLOCK (attr)->size);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* DW_AT_BYTE_SIZE existing together with DW_AT_STRING_LENGTH
+ specifies the size of an integer to fetch. */
+ size_attr = dwarf2_attr (die, DW_AT_byte_size, cu);
+ if (size_attr)
+ {
+ data[DW_BLOCK (attr)->size] = DW_OP_deref_size;
+ data[DW_BLOCK (attr)->size + 1] = DW_UNSND (size_attr);
+ if (data[DW_BLOCK (attr)->size + 1] != DW_UNSND (size_attr))
+ complaint (&symfile_complaints,
+ _("DW_AT_string_length's DW_AT_byte_size "
+ "integer exceeds the byte size storage"));
+ }
+ else
+ {
+ data[DW_BLOCK (attr)->size] = DW_OP_deref;
+ data[DW_BLOCK (attr)->size + 1] = DW_OP_nop;
+ }
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->high.kind
+ = RANGE_BOUND_KIND_DWARF_BLOCK;
+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block = length_baton;
+ TYPE_DYNAMIC (range_type) = 1;
+ }
}
else
{
- /* check for the DW_AT_byte_size attribute */
+ if (attr && attr_form_is_constant (attr))
+ {
+ /* We currently do not support a constant address where the location
+ should be read from - attr_form_is_block is expected instead. See
+ DWARF for the DW_AT_STRING_LENGTH vs. DW_AT_BYTE_SIZE difference.
+ */
+ /* PASSTHRU */
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
attr = dwarf2_attr (die, DW_AT_byte_size, cu);
- if (attr)
- {
- length = DW_UNSND (attr);
- }
+ if (attr && attr_form_is_block (attr))
+ {
+ TYPE_RANGE_DATA (range_type)->high.kind
+ = RANGE_BOUND_KIND_DWARF_BLOCK;
+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
+ dwarf2_attr_to_locexpr_baton (attr, cu);
+ TYPE_DYNAMIC (range_type) = 1;
+ }
+ else if (attr && attr_form_is_constant (attr))
+ TYPE_HIGH_BOUND (range_type) = dwarf2_get_attr_constant_value (attr, 0);
else
- {
- length = 1;
- }
+ TYPE_HIGH_BOUND (range_type) = 1;
}
- index_type = objfile_type (objfile)->builtin_int;
- range_type = create_range_type (NULL, index_type, 1, length);
char_type = language_string_char_type (cu->language_defn, gdbarch);
type = create_string_type (NULL, char_type, range_type);
@@ -7985,8 +8096,7 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
struct type *base_type;
struct type *range_type;
struct attribute *attr;
- LONGEST low = 0;
- LONGEST high = -1;
+ LONGEST low;
char *name;
LONGEST negative_mask;
@@ -7999,48 +8109,125 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
if (range_type)
return range_type;
- if (cu->language == language_fortran)
- {
- /* FORTRAN implies a lower bound of 1, if not given. */
- low = 1;
- }
+ /* LOW_BOUND and HIGH_BOUND are set for real below. */
+ range_type = create_range_type (NULL, base_type, 0, -1);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ negative_mask =
+ (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Exclude language_ada from any TYPE_DYNAMIC constructs below. GDB Ada
+ supports implements the dynamic bounds in a non-DWARF way and the
+ existing DWARF dynamic bounds are invalid, leading to memory access
+ errors. */
- /* FIXME: For variable sized arrays either of these could be
- a variable rather than a constant value. We'll allow it,
- but we don't know how to handle it. */
attr = dwarf2_attr (die, DW_AT_lower_bound, cu);
- if (attr)
- low = dwarf2_get_attr_constant_value (attr, 0);
+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2009-09-01 13:19:03 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_block =
+ dwarf2_attr_to_locexpr_baton (attr, cu);
+ TYPE_DYNAMIC (range_type) = 1;
+ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
+ low = 0;
2009-09-01 13:19:03 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ struct die_info *target_die;
+ struct dwarf2_cu *target_cu = cu;
+ struct attribute *target_loc_attr;
2009-09-01 13:19:03 +00:00
+
2010-11-17 02:58:16 +00:00
+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
+ gdb_assert (target_cu->objfile == cu->objfile);
+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
2010-07-11 18:06:33 +00:00
+
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->low.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.loclist
+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
+ TYPE_RANGE_DATA (range_type)->low.u.dwarf_loclist.type
+ = die_type (target_die, target_cu);
+ TYPE_DYNAMIC (range_type) = 1;
+ /* For setting a default if DW_AT_UPPER_BOUND would be missing. */
+ low = 0;
2010-07-21 21:30:20 +00:00
+ }
+ else
+ {
2010-11-17 02:58:16 +00:00
+ if (attr && attr_form_is_constant (attr))
+ low = dwarf2_get_attr_constant_value (attr, 0);
+ else
+ {
+ if (cu->language == language_fortran)
+ {
+ /* FORTRAN implies a lower bound of 1, if not given. */
+ low = 1;
+ }
+ else
+ {
+ /* According to DWARF we should assume the value 0 only for
+ LANGUAGE_C and LANGUAGE_CPLUS. */
+ low = 0;
+ }
+ }
+ if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
+ low |= negative_mask;
+ TYPE_LOW_BOUND (range_type) = low;
+ if (low >= 0)
+ TYPE_UNSIGNED (range_type) = 1;
+ }
attr = dwarf2_attr (die, DW_AT_upper_bound, cu);
- if (attr)
+ if (!attr || (!attr_form_is_block (attr) && !attr_form_is_constant (attr)
+ && !is_ref_attr (attr)))
{
- if (attr->form == DW_FORM_block1 || is_ref_attr (attr))
- {
- /* GCC encodes arrays with unspecified or dynamic length
- with a DW_FORM_block1 attribute or a reference attribute.
- FIXME: GDB does not yet know how to handle dynamic
- arrays properly, treat them as arrays with unspecified
- length for now.
-
- FIXME: jimb/2003-09-22: GDB does not really know
- how to handle arrays of unspecified length
- either; we just represent them as zero-length
- arrays. Choose an appropriate upper bound given
- the lower bound we've computed above. */
- high = low - 1;
- }
- else
- high = dwarf2_get_attr_constant_value (attr, 1);
+ attr = dwarf2_attr (die, DW_AT_count, cu);
+ /* It does not hurt but it is needlessly ineffective in check_typedef. */
+ if (attr && (attr_form_is_block (attr) || attr_form_is_constant (attr)))
+ {
+ TYPE_RANGE_HIGH_BOUND_IS_COUNT (range_type) = 1;
+ TYPE_DYNAMIC (range_type) = 1;
+ }
+ /* Pass it now as the regular DW_AT_upper_bound. */
2010-07-21 21:30:20 +00:00
+ }
2010-07-11 18:06:33 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_BLOCK;
+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_block =
+ dwarf2_attr_to_locexpr_baton (attr, cu);
+ TYPE_DYNAMIC (range_type) = 1;
2010-07-21 21:30:20 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
+ {
+ struct die_info *target_die;
+ struct dwarf2_cu *target_cu = cu;
+ struct attribute *target_loc_attr;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
+ gdb_assert (target_cu->objfile == cu->objfile);
+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->high.kind = RANGE_BOUND_KIND_DWARF_LOCLIST;
+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.loclist
+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
+ TYPE_RANGE_DATA (range_type)->high.u.dwarf_loclist.type
+ = die_type (target_die, target_cu);
+ TYPE_DYNAMIC (range_type) = 1;
}
else
{
- attr = dwarf2_attr (die, DW_AT_count, cu);
- if (attr)
+ LONGEST high;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (attr && attr_form_is_constant (attr))
+ high = dwarf2_get_attr_constant_value (attr, 0);
+ else
{
- int count = dwarf2_get_attr_constant_value (attr, 1);
- high = low + count - 1;
+ /* Ada expects an empty array on no boundary attributes. */
+ if (cu->language != language_ada)
+ TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+ high = low - 1;
}
+ if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
+ high |= negative_mask;
+ TYPE_HIGH_BOUND (range_type) = high;
}
/* Dwarf-2 specifications explicitly allows to create subrange types
@@ -8082,20 +8269,41 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu)
}
}
- negative_mask =
- (LONGEST) -1 << (TYPE_LENGTH (base_type) * TARGET_CHAR_BIT - 1);
- if (!TYPE_UNSIGNED (base_type) && (low & negative_mask))
- low |= negative_mask;
- if (!TYPE_UNSIGNED (base_type) && (high & negative_mask))
- high |= negative_mask;
+ /* DW_AT_bit_stride is currently unsupported as we count in bytes. */
+ attr = dwarf2_attr (die, DW_AT_byte_stride, cu);
+ if (attr && attr_form_is_block (attr) && cu->language != language_ada)
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ TYPE_RANGE_DATA (range_type)->byte_stride.kind
+ = RANGE_BOUND_KIND_DWARF_BLOCK;
+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_block =
+ dwarf2_attr_to_locexpr_baton (attr, cu);
+ TYPE_DYNAMIC (range_type) = 1;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else if (attr && is_ref_attr (attr) && cu->language != language_ada)
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ struct die_info *target_die;
+ struct dwarf2_cu *target_cu = cu;
+ struct attribute *target_loc_attr;
- range_type = create_range_type (NULL, base_type, low, high);
+ target_die = follow_die_ref_or_sig (die, attr, &target_cu);
+ gdb_assert (target_cu->objfile == cu->objfile);
+ target_loc_attr = dwarf2_attr (target_die, DW_AT_location, target_cu);
- /* Mark arrays with dynamic length at least as an array of unspecified
- length. GDB could check the boundary but before it gets implemented at
- least allow accessing the array elements. */
- if (attr && attr->form == DW_FORM_block1)
- TYPE_HIGH_BOUND_UNDEFINED (range_type) = 1;
+ TYPE_RANGE_DATA (range_type)->byte_stride.kind
+ = RANGE_BOUND_KIND_DWARF_LOCLIST;
+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.loclist
+ = dwarf2_attr_to_loclist_baton (target_loc_attr, target_cu);
+ TYPE_RANGE_DATA (range_type)->byte_stride.u.dwarf_loclist.type
+ = die_type (target_die, target_cu);
+ TYPE_DYNAMIC (range_type) = 1;
2010-07-21 21:30:20 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else if (attr && attr_form_is_constant (attr))
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ TYPE_BYTE_STRIDE (range_type) = dwarf2_get_attr_constant_value (attr, 0);
+ if (TYPE_BYTE_STRIDE (range_type) == 0)
+ complaint (&symfile_complaints,
+ _("Found DW_AT_byte_stride with unsupported value 0"));
2010-07-21 21:30:20 +00:00
+ }
2010-11-17 02:58:16 +00:00
name = dwarf2_name (die, cu);
if (name)
@@ -10559,10 +10767,12 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
(i.e. when the value of a register or memory location is
referenced, or a thread-local block, etc.). Then again, it might
not be worthwhile. I'm assuming that it isn't unless performance
- or memory numbers show me otherwise. */
+ or memory numbers show me otherwise.
+
+ SYMBOL_CLASS may get overriden by dwarf2_symbol_mark_computed. */
- dwarf2_symbol_mark_computed (attr, sym, cu);
SYMBOL_CLASS (sym) = LOC_COMPUTED;
+ dwarf2_symbol_mark_computed (attr, sym, cu);
}
/* Given a pointer to a DWARF information entry, figure out if we need
@@ -10600,6 +10810,8 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
else
sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
OBJSTAT (objfile, n_syms++);
+ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
/* Cache this symbol's name and the name's demangled form (if any). */
SYMBOL_SET_LANGUAGE (sym, cu->language);
@@ -11367,6 +11579,9 @@ read_type_die_1 (struct die_info *die, struct dwarf2_cu *cu)
break;
}
+ if (this_type)
+ finalize_type (this_type);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
return this_type;
}
@@ -14119,67 +14334,102 @@ attr_form_is_constant (struct attribute *attr)
}
}
-static void
-dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
- struct dwarf2_cu *cu)
+/* Convert DW_BLOCK into struct dwarf2_locexpr_baton. ATTR must be a DW_BLOCK
+ attribute type. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct dwarf2_locexpr_baton *
+dwarf2_attr_to_locexpr_baton (struct attribute *attr, struct dwarf2_cu *cu)
{
- if (attr_form_is_section_offset (attr)
- /* ".debug_loc" may not exist at all, or the offset may be outside
- the section. If so, fall through to the complaint in the
- other branch. */
- && DW_UNSND (attr) < dwarf2_per_objfile->loc.size)
- {
- struct dwarf2_loclist_baton *baton;
+ struct dwarf2_locexpr_baton *baton;
- baton = obstack_alloc (&cu->objfile->objfile_obstack,
- sizeof (struct dwarf2_loclist_baton));
- baton->per_cu = cu->per_cu;
- gdb_assert (baton->per_cu);
+ gdb_assert (attr_form_is_block (attr));
- dwarf2_read_section (dwarf2_per_objfile->objfile,
- &dwarf2_per_objfile->loc);
+ baton = obstack_alloc (&cu->objfile->objfile_obstack, sizeof (*baton));
+ baton->per_cu = cu->per_cu;
+ gdb_assert (baton->per_cu);
- /* We don't know how long the location list is, but make sure we
- don't run off the edge of the section. */
- baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);
- baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr);
- baton->base_address = cu->base_address;
- if (cu->base_known == 0)
- complaint (&symfile_complaints,
- _("Location list used without specifying the CU base address."));
+ /* Note that we're just copying the block's data pointer
+ here, not the actual data. We're still pointing into the
+ info_buffer for SYM's objfile; right now we never release
+ that buffer, but when we do clean up properly this may
+ need to change. */
+ baton->size = DW_BLOCK (attr)->size;
+ baton->data = DW_BLOCK (attr)->data;
+ gdb_assert (baton->size == 0 || baton->data != NULL);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return baton;
2009-08-04 05:37:29 +00:00
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct dwarf2_loclist_baton *
+dwarf2_attr_to_loclist_baton (struct attribute *attr, struct dwarf2_cu *cu)
2009-08-04 05:37:29 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct dwarf2_loclist_baton *baton;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* DW_AT_location of the referenced DIE may be missing if the referenced
+ variable has been optimized out. */
+ if (!attr)
+ return NULL;
+ dwarf2_read_section (dwarf2_per_objfile->objfile,
+ &dwarf2_per_objfile->loc);
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!(attr_form_is_section_offset (attr)
+ /* ".debug_loc" may not exist at all, or the offset may be outside
+ the section. If so, fall through to the complaint in the
+ other branch. */
+ && DW_UNSND (attr) < dwarf2_per_objfile->loc.size))
+ return NULL;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ baton = obstack_alloc (&cu->objfile->objfile_obstack,
+ sizeof (struct dwarf2_loclist_baton));
+ baton->per_cu = cu->per_cu;
+ gdb_assert (baton->per_cu);
+
+ /* We don't know how long the location list is, but make sure we
+ don't run off the edge of the section. */
+ baton->size = dwarf2_per_objfile->loc.size - DW_UNSND (attr);
+ baton->data = dwarf2_per_objfile->loc.buffer + DW_UNSND (attr);
+ baton->base_address = cu->base_address;
+ if (cu->base_known == 0)
+ complaint (&symfile_complaints,
+ _("Location list used without specifying the CU base address."));
+
+ return baton;
2010-07-22 10:49:58 +00:00
+}
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+/* SYM may get its SYMBOL_CLASS overriden on invalid ATTR content. */
+
2010-07-22 10:49:58 +00:00
+static void
2010-11-17 02:58:16 +00:00
+dwarf2_symbol_mark_computed (struct attribute *attr, struct symbol *sym,
+ struct dwarf2_cu *cu)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct dwarf2_loclist_baton *loclist_baton;
2009-03-02 23:14:15 +00:00
+
2010-11-17 02:58:16 +00:00
+ loclist_baton = dwarf2_attr_to_loclist_baton (attr, cu);
+ if (loclist_baton)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
SYMBOL_COMPUTED_OPS (sym) = &dwarf2_loclist_funcs;
- SYMBOL_LOCATION_BATON (sym) = baton;
+ SYMBOL_LOCATION_BATON (sym) = loclist_baton;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else if (attr_form_is_block (attr))
2010-07-21 21:30:20 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
+ SYMBOL_LOCATION_BATON (sym) = dwarf2_attr_to_locexpr_baton (attr, cu);
}
else
{
- struct dwarf2_locexpr_baton *baton;
+ dwarf2_invalid_attrib_class_complaint ("location description",
+ SYMBOL_NATURAL_NAME (sym));
- baton = obstack_alloc (&cu->objfile->objfile_obstack,
- sizeof (struct dwarf2_locexpr_baton));
- baton->per_cu = cu->per_cu;
- gdb_assert (baton->per_cu);
+ /* Some methods are called w/o checking SYMBOL_COMPUTED_OPS validity. */
- if (attr_form_is_block (attr))
- {
- /* Note that we're just copying the block's data pointer
- here, not the actual data. We're still pointing into the
- info_buffer for SYM's objfile; right now we never release
- that buffer, but when we do clean up properly this may
- need to change. */
- baton->size = DW_BLOCK (attr)->size;
- baton->data = DW_BLOCK (attr)->data;
- }
- else
- {
- dwarf2_invalid_attrib_class_complaint ("location description",
- SYMBOL_NATURAL_NAME (sym));
- baton->size = 0;
- baton->data = NULL;
- }
+ SYMBOL_COMPUTED_OPS (sym) = &dwarf2_missing_funcs;
+ SYMBOL_LOCATION_BATON (sym) = NULL;
- SYMBOL_COMPUTED_OPS (sym) = &dwarf2_locexpr_funcs;
- SYMBOL_LOCATION_BATON (sym) = baton;
+ /* For functions a missing DW_AT_frame_base does not optimize out the
+ whole function definition, only its frame base resolving. */
+ if (attr->name == DW_AT_location)
+ SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
}
}
@@ -14533,6 +14783,31 @@ offset_and_type_eq (const void *item_lhs, const void *item_rhs)
return ofs_lhs->offset == ofs_rhs->offset;
}
+/* Fill in generic attributes applicable for type DIEs. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+static void
2010-11-17 02:58:16 +00:00
+fetch_die_type_attrs (struct die_info *die, struct type *type,
+ struct dwarf2_cu *cu)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct attribute *attr;
2009-08-18 18:51:17 +00:00
+
2010-11-17 02:58:16 +00:00
+ attr = dwarf2_attr (die, DW_AT_data_location, cu);
+ if (attr_form_is_block (attr))
+ TYPE_DATA_LOCATION_DWARF_BLOCK (type) = dwarf2_attr_to_locexpr_baton (attr,
+ cu);
+ gdb_assert (!TYPE_DATA_LOCATION_IS_ADDR (type));
2009-08-18 18:51:17 +00:00
+
2010-11-17 02:58:16 +00:00
+ attr = dwarf2_attr (die, DW_AT_allocated, cu);
+ if (attr_form_is_block (attr))
+ TYPE_ALLOCATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
+ gdb_assert (!TYPE_NOT_ALLOCATED (type));
2009-08-18 18:51:17 +00:00
+
2010-11-17 02:58:16 +00:00
+ attr = dwarf2_attr (die, DW_AT_associated, cu);
+ if (attr_form_is_block (attr))
+ TYPE_ASSOCIATED (type) = dwarf2_attr_to_locexpr_baton (attr, cu);
+ gdb_assert (!TYPE_NOT_ASSOCIATED (type));
2010-07-21 21:30:20 +00:00
+}
2010-07-11 18:06:33 +00:00
+
2010-11-17 02:58:16 +00:00
/* Set the type associated with DIE to TYPE. Save it in CU's hash
table if necessary. For convenience, return TYPE.
@@ -14558,6 +14833,8 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
struct objfile *objfile = cu->objfile;
htab_t *type_hash_ptr;
+ fetch_die_type_attrs (die, type, cu);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* For Ada types, make sure that the gnat-specific data is always
initialized (if not already set). There are a few types where
we should not be doing so, because the type-specific area is
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 270f93f..a589c23 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -37,6 +37,7 @@
#include "complaints.h"
#include "demangle.h"
#include "psympriv.h"
+#include "gdbtypes.h"
extern void _initialize_elfread (void);
@@ -183,7 +184,8 @@ record_minimal_symbol (const char *name, int name_len, int copy_name,
{
struct gdbarch *gdbarch = get_objfile_arch (objfile);
- if (ms_type == mst_text || ms_type == mst_file_text)
+ if (ms_type == mst_text || ms_type == mst_file_text
+ || ms_type == mst_text_gnu_ifunc)
address = gdbarch_smash_text_address (gdbarch, address);
return prim_record_minimal_symbol_full (name, name_len, copy_name, address,
@@ -391,7 +393,10 @@ elf_symtab_read (struct objfile *objfile, int type,
{
if (sym->flags & (BSF_GLOBAL | BSF_WEAK))
{
- ms_type = mst_text;
+ if (sym->flags & BSF_GNU_INDIRECT_FUNCTION)
+ ms_type = mst_text_gnu_ifunc;
+ else
+ ms_type = mst_text;
}
else if ((sym->name[0] == '.' && sym->name[1] == 'L')
|| ((sym->flags & BSF_LOCAL)
@@ -572,6 +577,250 @@ elf_symtab_read (struct objfile *objfile, int type,
}
}
+/* FIXME: Delay it through elf_sym_fns. */
2010-07-21 21:30:20 +00:00
+
+static void
2010-11-17 02:58:16 +00:00
+elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ bfd *obfd = objfile->obfd;
+ const struct elf_backend_data *bed = get_elf_backend_data (obfd);
+ asection *plt, *relplt, *got_plt;
+ unsigned u;
+ int plt_elf_idx;
+ bfd_size_type reloc_count, reloc;
+ char *string_buffer = NULL;
+ size_t string_buffer_size = 0;
+ struct cleanup *back_to;
+ struct gdbarch *gdbarch = objfile->gdbarch;
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+ size_t ptr_size = TYPE_LENGTH (ptr_type);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (objfile->separate_debug_objfile_backlink)
+ return;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ plt = bfd_get_section_by_name (obfd, ".plt");
+ if (plt == NULL)
+ return;
+ plt_elf_idx = elf_section_data (plt)->this_idx;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ got_plt = bfd_get_section_by_name (obfd, ".got.plt");
+ if (got_plt == NULL)
+ return;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* This search algorithm is from _bfd_elf_canonicalize_dynamic_reloc. */
+ for (relplt = obfd->sections; relplt != NULL; relplt = relplt->next)
+ if (elf_section_data (relplt)->this_hdr.sh_info == plt_elf_idx
+ && (elf_section_data (relplt)->this_hdr.sh_type == SHT_REL
+ || elf_section_data (relplt)->this_hdr.sh_type == SHT_RELA))
+ break;
+ if (relplt == NULL)
+ return;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (! bed->s->slurp_reloc_table (obfd, relplt, dyn_symbol_table, TRUE))
+ return;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ back_to = make_cleanup (free_current_contents, &string_buffer);
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ reloc_count = relplt->size / elf_section_data (relplt)->this_hdr.sh_entsize;
+ for (reloc = 0; reloc < reloc_count; reloc++)
2009-08-04 05:37:29 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ const char *name, *name_got_plt;
+ struct minimal_symbol *msym;
+ CORE_ADDR address;
+ const char *suffix = "@got.plt";
+ size_t suffix_len = strlen (suffix);
+ size_t name_len;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ name = bfd_asymbol_name (*relplt->relocation[reloc].sym_ptr_ptr);
+ name_len = strlen (name);
+ address = relplt->relocation[reloc].address;
2009-04-13 20:52:59 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Does the pointer reside in the .got.plt section? */
+ if (!(bfd_get_section_vma (obfd, got_plt) <= address
+ && address < bfd_get_section_vma (obfd, got_plt)
+ + bfd_get_section_size (got_plt)))
2010-07-22 10:49:58 +00:00
+ continue;
2009-04-13 20:52:59 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* We cannot check if NAME is a reference to mst_text_gnu_ifunc as in
+ OBJFILE the symbol is undefined and the objfile having NAME defined
+ may not yet have been loaded. */
+
+ if (string_buffer_size < name_len + suffix_len)
2009-08-04 05:37:29 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ string_buffer_size = 2 * (name_len + suffix_len);
+ string_buffer = xrealloc (string_buffer, string_buffer_size);
2010-07-21 21:30:20 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ memcpy (string_buffer, name, name_len);
+ memcpy (&string_buffer[name_len], suffix, suffix_len);
+
+ msym = record_minimal_symbol (string_buffer, name_len + suffix_len, 1,
+ address, mst_slot_got_plt, got_plt,
+ objfile);
+ if (msym)
+ MSYMBOL_SIZE (msym) = ptr_size;
2010-07-21 21:30:20 +00:00
+ }
2010-11-17 02:58:16 +00:00
+
+ do_cleanups (back_to);
2010-07-21 21:30:20 +00:00
+}
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Function does not check for possibly created duplicities in the cache.
+ Check it by resolve_gnu_ifunc_by_cache first. */
+
+static struct minimal_symbol *
+gnu_ifunc_record_cache_unchecked (const char *function_name,
+ CORE_ADDR function_address)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct minimal_symbol *msym, *msym_new;
+ asection *sect;
+ struct objfile *objfile;
+ char *function_name_gnu_ifunc_tgt;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = lookup_minimal_symbol_by_pc (function_address);
+ if (msym == NULL)
+ return NULL;
+ if (SYMBOL_VALUE_ADDRESS (msym) != function_address)
2010-07-21 21:30:20 +00:00
+ return NULL;
2010-11-17 02:58:16 +00:00
+ /* minimal symbols have always SYMBOL_OBJ_SECTION non-NULL. */
+ sect = SYMBOL_OBJ_SECTION (msym)->the_bfd_section;
+ objfile = SYMBOL_OBJ_SECTION (msym)->objfile;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* If .plt jumps back to .plt the symbol is still deferred for later
+ resolution and it has no use for GDB. Besides ".text" this symbol can
+ reside also in ".opd" for ppc64 function descriptor. */
+ if (strcmp (bfd_get_section_name (objfile->obfd, sect), ".plt") == 0)
2010-07-21 21:30:20 +00:00
+ return NULL;
2009-08-18 18:51:17 +00:00
+
2010-11-17 02:58:16 +00:00
+ function_name_gnu_ifunc_tgt = alloca (strlen (function_name)
+ + strlen ("@gnu-ifunc-tgt") + 1);
+ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Create new alias "@gnu-ifunc-tgt" for MSYM. */
+ msym_new = record_minimal_symbol (function_name_gnu_ifunc_tgt,
+ strlen (function_name_gnu_ifunc_tgt), 1,
+ SYMBOL_VALUE_ADDRESS (msym),
+ MSYMBOL_TYPE (msym), sect, objfile);
+ /* Should not happen. */
+ if (msym_new == NULL)
+ return 0;
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* objfile->msymbols array is already allocated on obstack and it cannot be
+ easily extended. Therefore <tab>-completion on symbol names will never
+ show the @gnu-ifunc-tgt symbol. Link it at least to the hash table so
+ that resolve_gnu_ifunc_by_cache can find it. */
+ add_minsym_to_hash_table (msym_new, objfile->msymbol_hash);
+
+ MSYMBOL_SIZE (msym_new) = MSYMBOL_SIZE (msym);
+ return msym_new;
2009-08-04 05:37:29 +00:00
+}
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Check first the cache if it - unlikely - has not been populated since
+ bp_gnu_ifunc_resolver has been created. gnu_ifunc_record_cache_unchecked
+ could create a duplicate symbol otherwise. */
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+void
+gnu_ifunc_record_cache (struct gdbarch *gdbarch, const char *function_name,
+ CORE_ADDR function_address)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct minimal_symbol *msym;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = resolve_gnu_ifunc_by_cache (function_name);
+ if (msym == NULL)
+ gnu_ifunc_record_cache_unchecked (function_name, function_address);
+ else if (SYMBOL_VALUE_ADDRESS (msym) != function_address)
2009-08-04 05:37:29 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* This case indicates buggy inferior program. GDB would need to update
+ its MSYM cache symbol for function_address. Anyway FUNCTION_NAME is
+ never normally found in the case as in such case no
+ bp_gnu_ifunc_resolver would be created in the first place. */
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ warning (_("gnu-indirect-function \"%s\" has changed its resolved "
+ "function_address from %s to %s; GDB is using the former one"),
+ function_name, paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msym)),
+ paddress (gdbarch, function_address));
+ }
+}
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct minimal_symbol *
+resolve_gnu_ifunc_by_got (const char *function_name)
+{
+ char *function_name_got_plt;
+ struct objfile *objfile;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ function_name_got_plt = alloca (strlen (function_name) + strlen ("@got.plt")
+ + 1);
+ sprintf (function_name_got_plt, "%s@got.plt", function_name);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ ALL_PSPACE_OBJFILES (current_program_space, objfile)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ bfd *obfd = objfile->obfd;
+ struct gdbarch *gdbarch = objfile->gdbarch;
+ struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+ size_t ptr_size = TYPE_LENGTH (ptr_type);
+ CORE_ADDR pointer_address, function_address;
+ asection *plt;
+ gdb_byte *buf = alloca (ptr_size);
+ struct minimal_symbol *msym;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = lookup_minimal_symbol (function_name_got_plt, NULL, objfile);
+ if (msym == NULL)
+ continue;
+ if (MSYMBOL_TYPE (msym) != mst_slot_got_plt)
2010-07-21 21:30:20 +00:00
+ continue;
2010-11-17 02:58:16 +00:00
+ pointer_address = SYMBOL_VALUE_ADDRESS (msym);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ plt = bfd_get_section_by_name (obfd, ".plt");
+ if (plt == NULL)
+ continue;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (MSYMBOL_SIZE (msym) != ptr_size)
+ continue;
+ if (target_read_memory (pointer_address, buf, ptr_size) != 0)
2010-07-21 21:30:20 +00:00
+ continue;
2010-11-17 02:58:16 +00:00
+ function_address = extract_typed_address (buf, ptr_type);
2009-04-13 20:52:59 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = gnu_ifunc_record_cache_unchecked (function_name, function_address);
+ if (msym == NULL)
+ continue;
+ return msym;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+
+ return NULL;
2009-08-04 05:37:29 +00:00
+}
2009-04-13 20:52:59 +00:00
+
2010-11-17 02:58:16 +00:00
+struct minimal_symbol *
+resolve_gnu_ifunc_by_cache (const char *function_name)
2009-08-04 05:37:29 +00:00
+{
2010-11-17 02:58:16 +00:00
+ char *function_name_gnu_ifunc_tgt;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ function_name_gnu_ifunc_tgt = alloca (strlen (function_name)
+ + strlen ("@gnu-ifunc-tgt") + 1);
+ sprintf (function_name_gnu_ifunc_tgt, "%s@gnu-ifunc-tgt", function_name);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return lookup_minimal_symbol (function_name_gnu_ifunc_tgt, NULL, NULL);
2010-07-11 18:06:33 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+int
+resolve_gnu_ifunc (const char *function_name, CORE_ADDR *function_addressp)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct minimal_symbol *msym;
2010-11-16 04:54:18 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = resolve_gnu_ifunc_by_cache (function_name);
+ if (msym != NULL)
+ {
+ *function_addressp = SYMBOL_VALUE_ADDRESS (msym);
+ return 1;
+ }
2010-01-21 16:09:11 +00:00
+
2010-11-17 02:58:16 +00:00
+ msym = resolve_gnu_ifunc_by_got (function_name);
+ if (msym != NULL)
+ {
+ *function_addressp = SYMBOL_VALUE_ADDRESS (msym);
+ return 1;
+ }
2010-01-21 16:09:11 +00:00
+
2010-11-17 02:58:16 +00:00
+ return 0;
2010-07-21 21:30:20 +00:00
+}
2010-01-21 16:09:11 +00:00
+
2010-11-17 02:58:16 +00:00
struct build_id
{
size_t size;
@@ -800,6 +1049,8 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags)
bfd_errmsg (bfd_get_error ()));
elf_symtab_read (objfile, ST_DYNAMIC, dynsymcount, dyn_symbol_table, 0);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ elf_rel_plt_read (objfile, dyn_symbol_table);
2010-07-22 10:49:58 +00:00
}
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
/* Add synthetic symbols - for instance, names for any PLT entries. */
diff --git a/gdb/eval.c b/gdb/eval.c
index 16e98ae..4fa4d5f 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -44,6 +44,7 @@
#include "objfiles.h"
#include "python/python.h"
#include "wrapper.h"
+#include "dwarf2loc.h"
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
#include "gdb_assert.h"
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
@@ -806,6 +807,7 @@ evaluate_subexp_standard (struct type *expect_type,
int save_pos1;
struct symbol *function = NULL;
char *function_name = NULL;
+ struct cleanup *old_chain;
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
pc = (*pos)++;
op = exp->elts[pc].opcode;
@@ -1822,6 +1824,8 @@ evaluate_subexp_standard (struct type *expect_type,
return value_zero (builtin_type (exp->gdbarch)->builtin_int,
not_lval);
}
+ else if (TYPE_GNU_IFUNC (ftype))
+ return allocate_value (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (ftype)));
else if (TYPE_TARGET_TYPE (ftype))
return allocate_value (TYPE_TARGET_TYPE (ftype));
else
@@ -1848,6 +1852,8 @@ evaluate_subexp_standard (struct type *expect_type,
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
/* First determine the type code we are dealing with. */
arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+ old_chain = make_cleanup (null_cleanup, 0);
+ object_address_set (value_raw_address (arg1));
type = check_typedef (value_type (arg1));
code = TYPE_CODE (type);
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
@@ -1868,6 +1874,7 @@ evaluate_subexp_standard (struct type *expect_type,
code = TYPE_CODE (type);
}
}
+ do_cleanups (old_chain);
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
switch (code)
2010-07-21 21:30:20 +00:00
{
2010-11-17 02:58:16 +00:00
@@ -2325,13 +2332,19 @@ evaluate_subexp_standard (struct type *expect_type,
{
int subscript_array[MAX_FORTRAN_DIMS];
int array_size_array[MAX_FORTRAN_DIMS];
+ int byte_stride_array[MAX_FORTRAN_DIMS];
int ndimensions = 1, i;
struct type *tmp_type;
int offset_item; /* The array offset where the item lives */
+ CORE_ADDR offset_byte; /* byte_stride based offset */
+ unsigned element_size;
2009-08-18 18:51:17 +00:00
2010-11-17 02:58:16 +00:00
if (nargs > MAX_FORTRAN_DIMS)
error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
2010-07-11 18:06:33 +00:00
2010-11-17 02:58:16 +00:00
+ old_chain = make_cleanup (null_cleanup, 0);
+ object_address_set (value_raw_address (arg1));
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
tmp_type = check_typedef (value_type (arg1));
ndimensions = calc_f77_array_dims (type);
2010-07-11 18:06:33 +00:00
2010-11-17 02:58:16 +00:00
@@ -2361,6 +2374,9 @@ evaluate_subexp_standard (struct type *expect_type,
upper = f77_get_upperbound (tmp_type);
lower = f77_get_lowerbound (tmp_type);
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
+ byte_stride_array[nargs - i - 1] =
+ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
array_size_array[nargs - i - 1] = upper - lower + 1;
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
/* Zero-normalize subscripts so that offsetting will work. */
@@ -2379,13 +2395,25 @@ evaluate_subexp_standard (struct type *expect_type,
tmp_type = check_typedef (TYPE_TARGET_TYPE (tmp_type));
}
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
+ /* Kept for the f77_get_upperbound / f77_get_lowerbound calls above. */
+ do_cleanups (old_chain);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
/* Now let us calculate the offset for this item */
- offset_item = subscript_array[ndimensions - 1];
+ offset_item = 0;
+ offset_byte = 0;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ for (i = ndimensions - 1; i >= 0; --i)
+ {
+ offset_item *= array_size_array[i];
+ if (byte_stride_array[i] == 0)
+ offset_item += subscript_array[i];
+ else
+ offset_byte += subscript_array[i] * byte_stride_array[i];
+ }
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
- for (i = ndimensions - 1; i > 0; --i)
- offset_item =
- array_size_array[i - 1] * offset_item + subscript_array[i - 1];
+ element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tmp_type));
+ offset_byte += offset_item * element_size;
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
/* Let us now play a dirty trick: we will take arg1
which is a value node pointing to the topmost level
@@ -2395,7 +2423,7 @@ evaluate_subexp_standard (struct type *expect_type,
returns the correct type value */
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
deprecated_set_value_type (arg1, tmp_type);
- return value_subscripted_rvalue (arg1, offset_item, 0);
+ return value_subscripted_rvalue (arg1, offset_byte);
}
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
case BINOP_LOGICAL_AND:
@@ -2629,14 +2657,22 @@ evaluate_subexp_standard (struct type *expect_type,
if (expect_type && TYPE_CODE (expect_type) == TYPE_CODE_PTR)
expect_type = TYPE_TARGET_TYPE (check_typedef (expect_type));
arg1 = evaluate_subexp (expect_type, exp, pos, noside);
+ old_chain = make_cleanup (null_cleanup, 0);
+ object_address_set (value_raw_address (arg1));
type = check_typedef (value_type (arg1));
if (TYPE_CODE (type) == TYPE_CODE_METHODPTR
|| TYPE_CODE (type) == TYPE_CODE_MEMBERPTR)
error (_("Attempt to dereference pointer to member without an object"));
if (noside == EVAL_SKIP)
- goto nosideret;
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ do_cleanups (old_chain);
+ goto nosideret;
+ }
if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op, noside);
+ {
+ do_cleanups (old_chain);
+ return value_x_unop (arg1, op, noside);
+ }
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
type = check_typedef (value_type (arg1));
@@ -2645,12 +2681,18 @@ evaluate_subexp_standard (struct type *expect_type,
/* In C you can dereference an array to get the 1st elt. */
|| TYPE_CODE (type) == TYPE_CODE_ARRAY
)
- return value_zero (TYPE_TARGET_TYPE (type),
- lval_memory);
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ do_cleanups (old_chain);
+ return value_zero (TYPE_TARGET_TYPE (type),
+ lval_memory);
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
else if (TYPE_CODE (type) == TYPE_CODE_INT)
- /* GDB allows dereferencing an int. */
- return value_zero (builtin_type (exp->gdbarch)->builtin_int,
- lval_memory);
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ do_cleanups (old_chain);
+ /* GDB allows dereferencing an int. */
+ return value_zero (builtin_type (exp->gdbarch)->builtin_int,
+ lval_memory);
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
else
error (_("Attempt to take contents of a non-pointer value."));
}
@@ -2660,9 +2702,14 @@ evaluate_subexp_standard (struct type *expect_type,
do. "long long" variables are rare enough that
BUILTIN_TYPE_LONGEST would seem to be a mistake. */
if (TYPE_CODE (type) == TYPE_CODE_INT)
- return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
- (CORE_ADDR) value_as_address (arg1));
- return value_ind (arg1);
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ do_cleanups (old_chain);
+ return value_at_lazy (builtin_type (exp->gdbarch)->builtin_int,
+ (CORE_ADDR) value_as_address (arg1));
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ arg1 = value_ind (arg1);
+ do_cleanups (old_chain);
+ return arg1;
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
case UNOP_ADDR:
/* C++: check for and handle pointer to members. */
@@ -3008,7 +3055,7 @@ evaluate_subexp_with_coercion (struct expression *exp,
{
enum exp_opcode op;
int pc;
- struct value *val;
+ struct value *val = NULL;
struct symbol *var;
struct type *type;
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
@@ -3019,13 +3066,18 @@ evaluate_subexp_with_coercion (struct expression *exp,
{
case OP_VAR_VALUE:
var = exp->elts[pc + 2].symbol;
+ /* address_of_variable will call object_address_set for check_typedef.
+ Call it only if required as it can error-out on VAR in register. */
+ if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
+ val = address_of_variable (var, exp->elts[pc + 1].block);
type = check_typedef (SYMBOL_TYPE (var));
if (TYPE_CODE (type) == TYPE_CODE_ARRAY
&& !TYPE_VECTOR (type)
&& CAST_IS_CONVERSION (exp->language_defn))
{
(*pos) += 4;
- val = address_of_variable (var, exp->elts[pc + 1].block);
+ if (!val)
+ val = address_of_variable (var, exp->elts[pc + 1].block);
return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
val);
}
@@ -3077,9 +3129,13 @@ evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
case OP_VAR_VALUE:
(*pos) += 4;
- type = check_typedef (SYMBOL_TYPE (exp->elts[pc + 2].symbol));
- return
- value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
+ /* We do not need to call read_var_value but the object evaluation may
+ need to have executed object_address_set which needs valid
+ SYMBOL_VALUE_ADDRESS of the symbol. Still VALUE returned by
+ read_var_value we left as lazy. */
+ type = value_type (read_var_value (exp->elts[pc + 2].symbol,
+ deprecated_safe_get_selected_frame ()));
+ return value_from_longest (size_type, (LONGEST) TYPE_LENGTH (type));
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
default:
val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_AVOID_SIDE_EFFECTS);
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index f5bb82d..29cf5ba 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -28,6 +28,10 @@ extern void f_error (char *); /* Defined in f-exp.y */
extern void f_print_type (struct type *, const char *, struct ui_file *, int,
int);
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
+extern const char *f_object_address_data_valid_print_to_stream
+ (struct type *type, struct ui_file *stream);
+extern void f_object_address_data_valid_or_error (struct type *type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
struct ui_file *, int,
const struct value *,
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index d35a255..dec81d5 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -32,7 +32,7 @@
#include "gdbcore.h"
#include "target.h"
#include "f-lang.h"
-
+#include "dwarf2loc.h"
#include "gdb_string.h"
#include <errno.h>
2010-01-21 16:09:11 +00:00
2010-11-17 02:58:16 +00:00
@@ -49,6 +49,34 @@ void f_type_print_varspec_prefix (struct type *, struct ui_file *,
void f_type_print_base (struct type *, struct ui_file *, int, int);
+const char *
+f_object_address_data_valid_print_to_stream (struct type *type,
+ struct ui_file *stream)
+{
+ const char *msg;
+
+ msg = object_address_data_not_valid (type);
+ if (msg != NULL)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* Assuming the content printed to STREAM should not be localized. */
+ fprintf_filtered (stream, "<%s>", msg);
2010-07-22 10:49:58 +00:00
+ }
+
2010-11-17 02:58:16 +00:00
+ return msg;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+void
+f_object_address_data_valid_or_error (struct type *type)
+{
+ const char *msg;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ msg = object_address_data_not_valid (type);
+ if (msg != NULL)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ error (_("Cannot access it because the %s."), _(msg));
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* LEVEL is the depth to indent lines by. */
void
@@ -58,6 +86,9 @@ f_print_type (struct type *type, const char *varstring, struct ui_file *stream,
enum type_code code;
int demangled_args;
+ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
+ return;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
f_type_print_base (type, stream, show, level);
code = TYPE_CODE (type);
if ((varstring != NULL && *varstring != '\0')
@@ -165,6 +196,9 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
QUIT;
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
+ if (TYPE_CODE (type) != TYPE_CODE_TYPEDEF)
+ CHECK_TYPEDEF (type);
+
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index e27f79e..93322a2 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -54,15 +54,17 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
/* The following macro gives us the size of the nth dimension, Where
n is 1 based. */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
-#define F77_DIM_SIZE(n) (f77_array_offset_tbl[n][1])
+#define F77_DIM_COUNT(n) (f77_array_offset_tbl[n][1])
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
-/* The following gives us the offset for row n where n is 1-based. */
+/* The following gives us the element size for row n where n is 1-based. */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
-#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
+#define F77_DIM_BYTE_STRIDE(n) (f77_array_offset_tbl[n][0])
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
int
f77_get_lowerbound (struct type *type)
{
+ f_object_address_data_valid_or_error (type);
+
if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
error (_("Lower bound may not be '*' in F77"));
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
@@ -72,14 +74,17 @@ f77_get_lowerbound (struct type *type)
int
f77_get_upperbound (struct type *type)
{
+ f_object_address_data_valid_or_error (type);
+
if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
{
- /* We have an assumed size array on our hands. Assume that
- upper_bound == lower_bound so that we show at least 1 element.
- If the user wants to see more elements, let him manually ask for 'em
- and we'll subscript the array and show him. */
+ /* We have an assumed size array on our hands. As type_length_get
+ already assumes a length zero of arrays with underfined bounds VALADDR
+ passed to the Fortran functions does not contained the real inferior
+ memory content. User should request printing of specific array
+ elements instead. */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
- return f77_get_lowerbound (type);
+ return f77_get_lowerbound (type) - 1;
2010-07-22 10:49:58 +00:00
}
2010-11-17 02:58:16 +00:00
return TYPE_ARRAY_UPPER_BOUND_VALUE (type);
@@ -134,24 +139,29 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
upper = f77_get_upperbound (tmp_type);
lower = f77_get_lowerbound (tmp_type);
- F77_DIM_SIZE (ndimen) = upper - lower + 1;
+ F77_DIM_COUNT (ndimen) = upper - lower + 1;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ F77_DIM_BYTE_STRIDE (ndimen) =
+ TYPE_ARRAY_BYTE_STRIDE_VALUE (tmp_type);
tmp_type = TYPE_TARGET_TYPE (tmp_type);
ndimen++;
}
- /* Now we multiply eltlen by all the offsets, so that later we
+ /* Now we multiply eltlen by all the BYTE_STRIDEs, so that later we
can print out array elements correctly. Up till now we
- know an offset to apply to get the item but we also
+ know an eltlen to apply to get the item but we also
have to know how much to add to get to the next item */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
ndimen--;
eltlen = TYPE_LENGTH (tmp_type);
- F77_DIM_OFFSET (ndimen) = eltlen;
+ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
+ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
while (--ndimen > 0)
{
- eltlen *= F77_DIM_SIZE (ndimen + 1);
- F77_DIM_OFFSET (ndimen) = eltlen;
+ eltlen *= F77_DIM_COUNT (ndimen + 1);
+ if (F77_DIM_BYTE_STRIDE (ndimen) == 0)
+ F77_DIM_BYTE_STRIDE (ndimen) = eltlen;
2010-07-22 10:49:58 +00:00
}
}
2010-11-17 02:58:16 +00:00
@@ -172,34 +182,34 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
if (nss != ndimensions)
{
- for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
+ for (i = 0; (i < F77_DIM_COUNT (nss) && (*elts) < options->print_max); i++)
{
fprintf_filtered (stream, "( ");
f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
- valaddr + i * F77_DIM_OFFSET (nss),
- address + i * F77_DIM_OFFSET (nss),
+ valaddr + i * F77_DIM_BYTE_STRIDE (nss),
+ address + i * F77_DIM_BYTE_STRIDE (nss),
stream, recurse, val, options, elts);
fprintf_filtered (stream, ") ");
}
- if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
+ if (*elts >= options->print_max && i < F77_DIM_COUNT (nss))
fprintf_filtered (stream, "...");
}
else
{
- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
+ for (i = 0; i < F77_DIM_COUNT (nss) && (*elts) < options->print_max;
i++, (*elts)++)
{
val_print (TYPE_TARGET_TYPE (type),
- valaddr + i * F77_DIM_OFFSET (ndimensions),
+ valaddr + i * F77_DIM_BYTE_STRIDE (ndimensions),
0,
- address + i * F77_DIM_OFFSET (ndimensions),
+ address + i * F77_DIM_BYTE_STRIDE (ndimensions),
stream, recurse, val, options, current_language);
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
- if (i != (F77_DIM_SIZE (nss) - 1))
+ if (i != (F77_DIM_COUNT (nss) - 1))
fprintf_filtered (stream, ", ");
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
if ((*elts == options->print_max - 1)
- && (i != (F77_DIM_SIZE (nss) - 1)))
+ && (i != (F77_DIM_COUNT (nss) - 1)))
fprintf_filtered (stream, "...");
}
2010-07-22 10:49:58 +00:00
}
2010-11-17 02:58:16 +00:00
@@ -256,6 +266,9 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR addr;
int index;
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
+ if (f_object_address_data_valid_print_to_stream (type, stream) != NULL)
+ return 0;
+
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
diff --git a/gdb/findvar.c b/gdb/findvar.c
index e0ca12c..de6311a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -35,6 +35,7 @@
#include "user-regs.h"
#include "block.h"
#include "objfiles.h"
+#include "dwarf2loc.h"
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
/* Basic byte-swapping routines. All 'extract' functions return a
host-format integer from a target-format integer at ADDR which is
@@ -401,27 +402,16 @@ symbol_read_needs_frame (struct symbol *sym)
/* Given a struct symbol for a variable,
and a stack frame id, read the value of the variable
and return a (pointer to a) struct value containing the value.
- If the variable cannot be found, return a zero pointer. */
+ If the variable cannot be found, return a zero pointer.
+ We have to first find the address of the variable before allocating struct
+ value to return as its size may depend on DW_OP_PUSH_OBJECT_ADDRESS possibly
+ used by its type. */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
struct value *
read_var_value (struct symbol *var, struct frame_info *frame)
2010-07-22 10:49:58 +00:00
{
2010-11-17 02:58:16 +00:00
- struct value *v;
struct type *type = SYMBOL_TYPE (var);
CORE_ADDR addr;
- int len;
-
- if (SYMBOL_CLASS (var) == LOC_COMPUTED
- || SYMBOL_CLASS (var) == LOC_REGISTER)
- /* These cases do not use V. */
- v = NULL;
- else
- {
- v = allocate_value (type);
- VALUE_LVAL (v) = lval_memory; /* The most likely possibility. */
- }
-
- len = TYPE_LENGTH (type);
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
if (symbol_read_needs_frame (var))
gdb_assert (frame);
@@ -429,33 +419,43 @@ read_var_value (struct symbol *var, struct frame_info *frame)
switch (SYMBOL_CLASS (var))
2010-07-22 10:49:58 +00:00
{
2010-11-17 02:58:16 +00:00
case LOC_CONST:
- /* Put the constant back in target format. */
- store_signed_integer (value_contents_raw (v), len,
- gdbarch_byte_order (get_type_arch (type)),
- (LONGEST) SYMBOL_VALUE (var));
- VALUE_LVAL (v) = not_lval;
- return v;
+ {
+ /* Put the constant back in target format. */
+ struct value *v = allocate_value (type);
+ VALUE_LVAL (v) = not_lval;
+ store_signed_integer (value_contents_raw (v), TYPE_LENGTH (type),
+ gdbarch_byte_order (get_type_arch (type)),
+ (LONGEST) SYMBOL_VALUE (var));
+ return v;
+ }
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
case LOC_LABEL:
- /* Put the constant back in target format. */
- if (overlay_debugging)
- {
- CORE_ADDR addr
- = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
- SYMBOL_OBJ_SECTION (var));
+ {
+ /* Put the constant back in target format. */
+ struct value *v = allocate_value (type);
+ VALUE_LVAL (v) = not_lval;
+ if (overlay_debugging)
+ {
+ CORE_ADDR addr
+ = symbol_overlayed_address (SYMBOL_VALUE_ADDRESS (var),
+ SYMBOL_OBJ_SECTION (var));
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
- store_typed_address (value_contents_raw (v), type, addr);
- }
- else
- store_typed_address (value_contents_raw (v), type,
- SYMBOL_VALUE_ADDRESS (var));
- VALUE_LVAL (v) = not_lval;
- return v;
+ store_typed_address (value_contents_raw (v), type, addr);
+ }
+ else
+ store_typed_address (value_contents_raw (v), type,
+ SYMBOL_VALUE_ADDRESS (var));
+ return v;
+ }
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
case LOC_CONST_BYTES:
- memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var), len);
- VALUE_LVAL (v) = not_lval;
- return v;
+ {
+ struct value *v = allocate_value (type);
+ VALUE_LVAL (v) = not_lval;
+ memcpy (value_contents_raw (v), SYMBOL_VALUE_BYTES (var),
+ TYPE_LENGTH (type));
+ return v;
+ }
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
case LOC_STATIC:
if (overlay_debugging)
@@ -496,12 +496,23 @@ read_var_value (struct symbol *var, struct frame_info *frame)
break;
case LOC_BLOCK:
- if (overlay_debugging)
- set_value_address (v, symbol_overlayed_address
- (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var)));
- else
- set_value_address (v, BLOCK_START (SYMBOL_BLOCK_VALUE (var)));
- return v;
+ {
+ CORE_ADDR addr;
+ struct value *v;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (overlay_debugging)
+ addr = symbol_overlayed_address
+ (BLOCK_START (SYMBOL_BLOCK_VALUE (var)), SYMBOL_OBJ_SECTION (var));
+ else
+ addr = BLOCK_START (SYMBOL_BLOCK_VALUE (var));
+ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
+ DW_OP_push_object_address. */
+ object_address_set (addr);
+ v = allocate_value (type);
+ VALUE_LVAL (v) = lval_memory;
+ set_value_address (v, addr);
+ return v;
+ }
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
case LOC_REGISTER:
case LOC_REGPARM_ADDR:
@@ -520,7 +531,6 @@ read_var_value (struct symbol *var, struct frame_info *frame)
error (_("Value of register variable not available."));
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
addr = value_as_address (regval);
- VALUE_LVAL (v) = lval_memory;
}
else
{
@@ -563,18 +573,33 @@ read_var_value (struct symbol *var, struct frame_info *frame)
break;
case LOC_OPTIMIZED_OUT:
- VALUE_LVAL (v) = not_lval;
- set_value_optimized_out (v, 1);
- return v;
+ {
+ struct value *v = allocate_value (type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ VALUE_LVAL (v) = not_lval;
+ set_value_optimized_out (v, 1);
+ return v;
+ }
default:
error (_("Cannot look up value of a botched symbol."));
break;
}
- set_value_address (v, addr);
- set_value_lazy (v, 1);
- return v;
+ {
+ struct value *v;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* ADDR is set here for ALLOCATE_VALUE's CHECK_TYPEDEF for
+ DW_OP_PUSH_OBJECT_ADDRESS. */
+ object_address_set (addr);
+ v = allocate_value (type);
+ VALUE_LVAL (v) = lval_memory;
+ set_value_address (v, addr);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ set_value_lazy (v, 1);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return v;
+ }
}
/* Install default attributes for register values. */
@@ -611,10 +636,11 @@ struct value *
value_from_register (struct type *type, int regnum, struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
- struct type *type1 = check_typedef (type);
struct value *v;
- if (gdbarch_convert_register_p (gdbarch, regnum, type1))
+ type = check_typedef (type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (gdbarch_convert_register_p (gdbarch, regnum, type))
{
/* The ISA/ABI need to something weird when obtaining the
specified value from this register. It might need to
@@ -628,7 +654,7 @@ value_from_register (struct type *type, int regnum, struct frame_info *frame)
VALUE_FRAME_ID (v) = get_frame_id (frame);
VALUE_REGNUM (v) = regnum;
gdbarch_register_to_value (gdbarch,
- frame, regnum, type1, value_contents_raw (v));
+ frame, regnum, type, value_contents_raw (v));
}
else
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d96d0f8..4bebcda 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -39,6 +39,9 @@
#include "cp-abi.h"
#include "gdb_assert.h"
#include "hashtab.h"
+#include "observer.h"
+#include "dwarf2expr.h"
+#include "dwarf2loc.h"
/* Initialize BADNESS constants. */
@@ -145,6 +148,11 @@ static void print_arg_types (struct field *, int, int);
static void dump_fn_fieldlists (struct type *, int);
static void print_cplus_stuff (struct type *, int);
+/* The hash table holding all discardable `struct type *' references. */
+static htab_t type_discardable_table;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Current type_discardable_check pass used for TYPE_DISCARDABLE_AGE. */
+static int type_discardable_age_current;
/* Allocate a new OBJFILE-associated type structure and fill it
with some defaults. Space for the type structure is allocated
@@ -175,6 +183,39 @@ alloc_type (struct objfile *objfile)
return type;
}
+/* Declare TYPE as discardable on next garbage collection by free_all_types.
+ You must call type_mark_used during each free_all_types to protect TYPE from
+ being deallocated. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+set_type_as_discardable (struct type *type)
2010-07-22 10:49:58 +00:00
+{
+ void **slot;
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (!TYPE_DISCARDABLE (type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ TYPE_DISCARDABLE (type) = 1;
+ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ slot = htab_find_slot (type_discardable_table, type, INSERT);
+ gdb_assert (!*slot);
+ *slot = type;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Allocate a new type like alloc_type but preserve for it the discardability
+ state of PARENT_TYPE. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct type *
+alloc_type_as_parent (struct type *parent_type)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct type *new_type = alloc_type_copy (parent_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_DISCARDABLE (parent_type))
+ set_type_as_discardable (new_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return new_type;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
/* Allocate a new GDBARCH-associated type structure and fill it
with some defaults. Space for the type structure is allocated
on the heap. */
@@ -300,7 +341,7 @@ make_pointer_type (struct type *type, struct type **typeptr)
2010-11-16 04:54:18 +00:00
2010-11-17 02:58:16 +00:00
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
- ntype = alloc_type_copy (type);
+ ntype = alloc_type_as_parent (type);
if (typeptr)
*typeptr = ntype;
}
@@ -377,7 +418,7 @@ make_reference_type (struct type *type, struct type **typeptr)
if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
{
- ntype = alloc_type_copy (type);
+ ntype = alloc_type_as_parent (type);
if (typeptr)
*typeptr = ntype;
}
@@ -748,6 +789,7 @@ create_range_type (struct type *result_type, struct type *index_type,
TYPE_ZALLOC (result_type, sizeof (struct range_bounds));
TYPE_LOW_BOUND (result_type) = low_bound;
TYPE_HIGH_BOUND (result_type) = high_bound;
+ TYPE_BYTE_STRIDE (result_type) = 0;
if (low_bound >= 0)
TYPE_UNSIGNED (result_type) = 1;
@@ -891,26 +933,45 @@ create_array_type (struct type *result_type,
TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
TYPE_TARGET_TYPE (result_type) = element_type;
- if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
- low_bound = high_bound = 0;
- CHECK_TYPEDEF (element_type);
- /* Be careful when setting the array length. Ada arrays can be
- empty arrays with the high_bound being smaller than the low_bound.
- In such cases, the array length should be zero. */
- if (high_bound < low_bound)
- TYPE_LENGTH (result_type) = 0;
- else
- TYPE_LENGTH (result_type) =
- TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
TYPE_NFIELDS (result_type) = 1;
TYPE_FIELDS (result_type) =
(struct field *) TYPE_ZALLOC (result_type, sizeof (struct field));
TYPE_INDEX_TYPE (result_type) = range_type;
TYPE_VPTR_FIELDNO (result_type) = -1;
- /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
+ /* DWARF blocks may depend on runtime information like
+ DW_OP_PUSH_OBJECT_ADDRESS not being available during the
+ CREATE_ARRAY_TYPE time. */
+ if (TYPE_RANGE_DATA (range_type)->low.kind != RANGE_BOUND_KIND_CONSTANT
+ || TYPE_RANGE_DATA (range_type)->high.kind != RANGE_BOUND_KIND_CONSTANT
+ || TYPE_LOW_BOUND_UNDEFINED (range_type)
+ || TYPE_HIGH_BOUND_UNDEFINED (range_type)
+ || get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ low_bound = 0;
+ high_bound = -1;
2010-07-22 10:49:58 +00:00
+ }
+
2010-11-17 02:58:16 +00:00
+ /* Be careful when setting the array length. Ada arrays can be
+ empty arrays with the high_bound being smaller than the low_bound.
+ In such cases, the array length should be zero. TYPE_TARGET_STUB needs to
+ be checked as it may have dependencies on DWARF blocks depending on
+ runtime information not available during the CREATE_ARRAY_TYPE time. */
+ if (high_bound < low_bound || TYPE_TARGET_STUB (element_type))
+ TYPE_LENGTH (result_type) = 0;
2010-07-22 10:49:58 +00:00
+ else
+ {
2010-11-17 02:58:16 +00:00
+ CHECK_TYPEDEF (element_type);
+ TYPE_LENGTH (result_type) =
+ TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
2010-07-22 10:49:58 +00:00
+ }
+
2010-11-17 02:58:16 +00:00
if (TYPE_LENGTH (result_type) == 0)
- TYPE_TARGET_STUB (result_type) = 1;
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* The real size will be computed for specific instances by
+ CHECK_TYPEDEF. */
+ TYPE_TARGET_STUB (result_type) = 1;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
return result_type;
}
@@ -1413,6 +1474,105 @@ stub_noname_complaint (void)
complaint (&symfile_complaints, _("stub type has NULL name"));
}
+/* Calculate the memory length of array TYPE.
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ TARGET_TYPE should be set to `check_typedef (TYPE_TARGET_TYPE (type))' as
+ a performance hint. Feel free to pass NULL. Set FULL_SPAN to return the
+ size incl. the possible padding of the last element - it may differ from the
+ cleared FULL_SPAN return value (the expected SIZEOF) for non-zero
+ TYPE_BYTE_STRIDE values. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static LONGEST
+type_length_get (struct type *type, struct type *target_type, int full_span)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct type *range_type;
+ LONGEST byte_stride = 0; /* `= 0' for a false GCC warning. */
+ LONGEST count, element_size, retval;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_CODE (type) != TYPE_CODE_ARRAY
+ && TYPE_CODE (type) != TYPE_CODE_STRING)
+ return TYPE_LENGTH (type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Avoid executing TYPE_HIGH_BOUND for invalid (unallocated/unassociated)
+ Fortran arrays. The allocated data will never be used so they can be
+ zero-length. */
+ if (object_address_data_not_valid (type))
+ return 0;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ range_type = TYPE_INDEX_TYPE (type);
+ if (TYPE_LOW_BOUND_UNDEFINED (range_type)
+ || TYPE_HIGH_BOUND_UNDEFINED (range_type))
+ return 0;
+ count = TYPE_HIGH_BOUND (range_type) - TYPE_LOW_BOUND (range_type) + 1;
+ /* It may happen for wrong DWARF annotations returning garbage data. */
+ if (count < 0)
+ warning (_("Range for type %s has invalid bounds %s..%s"),
+ TYPE_NAME (type), plongest (TYPE_LOW_BOUND (range_type)),
+ plongest (TYPE_HIGH_BOUND (range_type)));
+ /* The code below does not handle count == 0 right. */
+ if (count <= 0)
+ return 0;
+ if (full_span || count > 1)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* We do not use TYPE_ARRAY_BYTE_STRIDE_VALUE (type) here as we want to
+ force FULL_SPAN to 1. */
+ byte_stride = TYPE_BYTE_STRIDE (range_type);
+ if (byte_stride == 0)
+ {
+ if (target_type == NULL)
+ target_type = check_typedef (TYPE_TARGET_TYPE (type));
+ byte_stride = type_length_get (target_type, NULL, 1);
+ }
2010-07-22 10:49:58 +00:00
+ }
+
2010-11-17 02:58:16 +00:00
+ /* For now, we conservatively take the array length to be 0 if its length
+ exceeds UINT_MAX. The code below assumes that for x < 0,
+ (ULONGEST) x == -x + ULONGEST_MAX + 1, which is technically not guaranteed
+ by C, but is usually true (because it would be true if x were unsigned
+ with its high-order bit on). It uses the fact that high_bound-low_bound is
+ always representable in ULONGEST and that if high_bound-low_bound+1
+ overflows, it overflows to 0. We must change these tests if we decide to
+ increase the representation of TYPE_LENGTH from unsigned int to ULONGEST.
+ */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (full_span)
+ {
+ retval = count * byte_stride;
+ if (count == 0 || retval / count != byte_stride || retval > UINT_MAX)
+ retval = 0;
+ return retval;
+ }
+ if (target_type == NULL)
+ target_type = check_typedef (TYPE_TARGET_TYPE (type));
+ element_size = type_length_get (target_type, NULL, 1);
+ retval = (count - 1) * byte_stride + element_size;
+ if (retval < element_size
+ || (byte_stride != 0
+ && (retval - element_size) / byte_stride != count - 1)
+ || retval > UINT_MAX)
+ retval = 0;
+ return retval;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Prepare TYPE after being read in by the backend. Currently this function
+ only propagates the TYPE_DYNAMIC flag. */
+
+void
+finalize_type (struct type *type)
2010-07-22 10:49:58 +00:00
+{
+ int i;
+
2010-11-17 02:58:16 +00:00
+ for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
+ break;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* FIXME: cplus_stuff is ignored here. */
+ if (i < TYPE_NFIELDS (type)
+ || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
+ || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
+ TYPE_DYNAMIC (type) = 1;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Find the real type of TYPE. This function returns the real type,
after removing all layers of typedefs, and completing opaque or stub
types. Completion changes the TYPE argument, but stripping of
@@ -1575,52 +1735,36 @@ check_typedef (struct type *type)
}
}
- if (TYPE_TARGET_STUB (type))
+ /* copy_type_recursive automatically makes the resulting type containing only
+ constant values expected by the callers of this function. */
+ if (TYPE_DYNAMIC (type))
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ htab_t copied_types;
+ struct type *type_old = type;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ copied_types = create_copied_types_hash (NULL);
+ type = copy_type_recursive (type, copied_types);
+ htab_delete (copied_types);
2010-11-16 04:54:18 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (TYPE_DYNAMIC (type) == 0);
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_TARGET_STUB (type) || TYPE_DYNAMIC (type))
{
- struct type *range_type;
struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
+ if (TYPE_DYNAMIC (type))
+ TYPE_TARGET_TYPE (type) = target_type;
if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
{
/* Empty. */
}
else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
- && TYPE_NFIELDS (type) == 1
- && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type))
- == TYPE_CODE_RANGE))
+ || TYPE_CODE (type) == TYPE_CODE_STRING)
{
/* Now recompute the length of the array type, based on its
- number of elements and the target type's length.
- Watch out for Ada null Ada arrays where the high bound
- is smaller than the low bound. */
- const LONGEST low_bound = TYPE_LOW_BOUND (range_type);
- const LONGEST high_bound = TYPE_HIGH_BOUND (range_type);
- ULONGEST len;
-
- if (high_bound < low_bound)
- len = 0;
- else
- {
- /* For now, we conservatively take the array length to be 0
- if its length exceeds UINT_MAX. The code below assumes
- that for x < 0, (ULONGEST) x == -x + ULONGEST_MAX + 1,
- which is technically not guaranteed by C, but is usually true
- (because it would be true if x were unsigned with its
- high-order bit on). It uses the fact that
- high_bound-low_bound is always representable in
- ULONGEST and that if high_bound-low_bound+1 overflows,
- it overflows to 0. We must change these tests if we
- decide to increase the representation of TYPE_LENGTH
- from unsigned int to ULONGEST. */
- ULONGEST ulow = low_bound, uhigh = high_bound;
- ULONGEST tlen = TYPE_LENGTH (target_type);
-
- len = tlen * (uhigh - ulow + 1);
- if (tlen == 0 || (len / tlen - 1 + ulow) != uhigh
- || len > UINT_MAX)
- len = 0;
- }
- TYPE_LENGTH (type) = len;
+ number of elements and the target type's length. */
+ TYPE_LENGTH (type) = type_length_get (type, target_type, 0);
TYPE_TARGET_STUB (type) = 0;
}
else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
@@ -1628,6 +1772,7 @@ check_typedef (struct type *type)
TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
TYPE_TARGET_STUB (type) = 0;
}
+ TYPE_DYNAMIC (type) = 0;
}
2010-11-16 04:54:18 +00:00
2010-11-17 02:58:16 +00:00
type = make_qualified_type (type, instance_flags, NULL);
@@ -1902,6 +2047,8 @@ init_type (enum type_code code, int length, int flags,
TYPE_STUB_SUPPORTED (type) = 1;
if (flags & TYPE_FLAG_FIXED_INSTANCE)
TYPE_FIXED_INSTANCE (type) = 1;
+ if (flags & TYPE_FLAG_GNU_IFUNC)
+ TYPE_GNU_IFUNC (type) = 1;
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
if (name)
TYPE_NAME (type) = obsavestring (name, strlen (name),
@@ -3194,33 +3341,42 @@ type_pair_eq (const void *item_lhs, const void *item_rhs)
}
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
/* Allocate the hash table used by copy_type_recursive to walk
- types without duplicates. We use OBJFILE's obstack, because
- OBJFILE is about to be deleted. */
+ types without duplicates. */
htab_t
create_copied_types_hash (struct objfile *objfile)
2010-07-22 10:49:58 +00:00
{
2010-11-17 02:58:16 +00:00
- return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
- NULL, &objfile->objfile_obstack,
- hashtab_obstack_allocate,
- dummy_obstack_deallocate);
+ if (objfile == NULL)
+ {
+ /* NULL OBJFILE is for TYPE_DYNAMIC types already contained in
+ OBJFILE_MALLOC memory, such as those from VALUE_HISTORY_CHAIN. Table
+ element entries get allocated by xmalloc - so use xfree. */
+ return htab_create (1, type_pair_hash, type_pair_eq, xfree);
+ }
+ else
+ {
+ /* Use OBJFILE's obstack, because OBJFILE is about to be deleted. Table
+ element entries get allocated by xmalloc - so use xfree. */
+ return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
+ xfree, &objfile->objfile_obstack,
+ hashtab_obstack_allocate,
+ dummy_obstack_deallocate);
+ }
}
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
-/* Recursively copy (deep copy) TYPE, if it is associated with
- OBJFILE. Return a new type allocated using malloc, a saved type if
- we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
- not associated with OBJFILE. */
+/* A helper for copy_type_recursive. This does all the work. OBJFILE is used
+ only for an assertion checking. */
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
-struct type *
-copy_type_recursive (struct objfile *objfile,
- struct type *type,
- htab_t copied_types)
+static struct type *
+copy_type_recursive_1 (struct objfile *objfile,
+ struct type *type,
+ htab_t copied_types)
{
struct type_pair *stored, pair;
void **slot;
struct type *new_type;
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
- if (! TYPE_OBJFILE_OWNED (type))
+ if (! TYPE_OBJFILE_OWNED (type) && !TYPE_DYNAMIC (type))
return type;
/* This type shouldn't be pointing to any types in other objfiles;
@@ -3235,8 +3391,10 @@ copy_type_recursive (struct objfile *objfile,
new_type = alloc_type_arch (get_type_arch (type));
/* We must add the new type to the hash table immediately, in case
- we encounter this type again during a recursive call below. */
- stored = obstack_alloc (&objfile->objfile_obstack, sizeof (struct type_pair));
+ we encounter this type again during a recursive call below. Memory could
+ be allocated from OBJFILE in the case we will be removing OBJFILE, this
+ optimization is missed and xfree is called for it from COPIED_TYPES. */
+ stored = xmalloc (sizeof (*stored));
stored->old = type;
stored->new = new_type;
*slot = stored;
@@ -3247,6 +3405,19 @@ copy_type_recursive (struct objfile *objfile,
TYPE_OBJFILE_OWNED (new_type) = 0;
TYPE_OWNER (new_type).gdbarch = get_type_arch (type);
+ /* TYPE_MAIN_TYPE memory copy above rewrote the TYPE_DISCARDABLE flag so we
+ need to initialize it again. And even if TYPE was already discardable
+ NEW_TYPE so far is not registered in TYPE_DISCARDABLE_TABLE. */
+ TYPE_DISCARDABLE (new_type) = 0;
+ set_type_as_discardable (new_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Pre-clear the fields processed by delete_main_type. If DWARF block
+ evaluations below call error we would leave an unfreeable TYPE. */
+ TYPE_TARGET_TYPE (new_type) = NULL;
+ TYPE_VPTR_BASETYPE (new_type) = NULL;
+ TYPE_NFIELDS (new_type) = 0;
+ TYPE_FIELDS (new_type) = NULL;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
if (TYPE_NAME (type))
TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
if (TYPE_TAG_NAME (type))
@@ -3255,12 +3426,48 @@ copy_type_recursive (struct objfile *objfile,
TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
+ if (TYPE_ALLOCATED (new_type))
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ gdb_assert (!TYPE_NOT_ALLOCATED (new_type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!dwarf_locexpr_baton_eval (TYPE_ALLOCATED (new_type)))
+ TYPE_NOT_ALLOCATED (new_type) = 1;
+ TYPE_ALLOCATED (new_type) = NULL;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_ASSOCIATED (new_type))
+ {
+ gdb_assert (!TYPE_NOT_ASSOCIATED (new_type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (new_type)))
+ TYPE_NOT_ASSOCIATED (new_type) = 1;
+ TYPE_ASSOCIATED (new_type) = NULL;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!TYPE_DATA_LOCATION_IS_ADDR (new_type)
+ && TYPE_DATA_LOCATION_DWARF_BLOCK (new_type))
+ {
+ if (TYPE_NOT_ALLOCATED (new_type)
+ || TYPE_NOT_ASSOCIATED (new_type))
+ TYPE_DATA_LOCATION_DWARF_BLOCK (new_type) = NULL;
+ else
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ TYPE_DATA_LOCATION_IS_ADDR (new_type) = 1;
+ TYPE_DATA_LOCATION_ADDR (new_type) = dwarf_locexpr_baton_eval
+ (TYPE_DATA_LOCATION_DWARF_BLOCK (new_type));
2010-07-22 10:49:58 +00:00
+ }
+ }
+
2010-11-17 02:58:16 +00:00
/* Copy the fields. */
if (TYPE_NFIELDS (type))
{
int i, nfields;
+ /* TYPE_CODE_RANGE uses TYPE_RANGE_DATA of the union with TYPE_FIELDS. */
+ gdb_assert (TYPE_CODE (type) != TYPE_CODE_RANGE);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
nfields = TYPE_NFIELDS (type);
+ TYPE_NFIELDS (new_type) = nfields;
TYPE_FIELDS (new_type) = XCALLOC (nfields, struct field);
for (i = 0; i < nfields; i++)
{
@@ -3269,8 +3476,8 @@ copy_type_recursive (struct objfile *objfile,
TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
if (TYPE_FIELD_TYPE (type, i))
TYPE_FIELD_TYPE (new_type, i)
- = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
- copied_types);
+ = copy_type_recursive_1 (objfile, TYPE_FIELD_TYPE (type, i),
+ copied_types);
if (TYPE_FIELD_NAME (type, i))
TYPE_FIELD_NAME (new_type, i) =
xstrdup (TYPE_FIELD_NAME (type, i));
@@ -3297,24 +3504,166 @@ copy_type_recursive (struct objfile *objfile,
}
}
+ /* Both FIELD_LOC_KIND_DWARF_BLOCK and TYPE_RANGE_HIGH_BOUND_IS_COUNT were
+ possibly converted. */
+ TYPE_DYNAMIC (new_type) = 0;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* For range types, copy the bounds information. */
- if (TYPE_CODE (type) == TYPE_CODE_RANGE)
+ if (TYPE_CODE (new_type) == TYPE_CODE_RANGE)
{
TYPE_RANGE_DATA (new_type) = xmalloc (sizeof (struct range_bounds));
*TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ switch (TYPE_RANGE_DATA (new_type)->low.kind)
+ {
+ case RANGE_BOUND_KIND_CONSTANT:
+ break;
+ case RANGE_BOUND_KIND_DWARF_BLOCK:
+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
+ || ! has_stack_frames ())
+ {
+ /* We should set 1 for Fortran but how to find the language? */
+ TYPE_LOW_BOUND (new_type) = 0;
+ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
+ }
+ else
+ TYPE_LOW_BOUND (new_type) = dwarf_locexpr_baton_eval
+ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_block);
+ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
+ break;
+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
+ {
+ CORE_ADDR addr;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (! TYPE_NOT_ALLOCATED (new_type)
+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
+ && dwarf_loclist_baton_eval
+ (TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.loclist,
+ TYPE_RANGE_DATA (new_type)->low.u.dwarf_loclist.type, &addr))
+ TYPE_LOW_BOUND (new_type) = addr;
+ else
+ {
+ /* We should set 1 for Fortran but how to find the language? */
+ TYPE_LOW_BOUND (new_type) = 0;
+ TYPE_LOW_BOUND_UNDEFINED (new_type) = 1;
+ }
+ TYPE_RANGE_DATA (new_type)->low.kind = RANGE_BOUND_KIND_CONSTANT;
+ }
+ break;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ switch (TYPE_RANGE_DATA (new_type)->high.kind)
+ {
+ case RANGE_BOUND_KIND_CONSTANT:
+ break;
+ case RANGE_BOUND_KIND_DWARF_BLOCK:
+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
+ || ! has_stack_frames ())
+ {
+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
+ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
+ }
+ else
+ TYPE_HIGH_BOUND (new_type) = dwarf_locexpr_baton_eval
+ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_block);
+ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
+ break;
+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
+ {
+ CORE_ADDR addr;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (! TYPE_NOT_ALLOCATED (new_type)
+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ()
+ && dwarf_loclist_baton_eval
+ (TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.loclist,
+ TYPE_RANGE_DATA (new_type)->high.u.dwarf_loclist.type,
+ &addr))
+ TYPE_HIGH_BOUND (new_type) = addr;
+ else
+ {
+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type) - 1;
+ TYPE_HIGH_BOUND_UNDEFINED (new_type) = 1;
+ }
+ TYPE_RANGE_DATA (new_type)->high.kind = RANGE_BOUND_KIND_CONSTANT;
+ }
+ break;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ switch (TYPE_RANGE_DATA (new_type)->byte_stride.kind)
+ {
+ case RANGE_BOUND_KIND_CONSTANT:
+ break;
+ case RANGE_BOUND_KIND_DWARF_BLOCK:
+ /* `struct dwarf2_locexpr_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (TYPE_NOT_ALLOCATED (new_type) || TYPE_NOT_ASSOCIATED (new_type)
+ || ! has_stack_frames ())
+ TYPE_BYTE_STRIDE (new_type) = 0;
+ else
+ TYPE_BYTE_STRIDE (new_type) = dwarf_locexpr_baton_eval
+ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_block);
+ TYPE_RANGE_DATA (new_type)->byte_stride.kind
+ = RANGE_BOUND_KIND_CONSTANT;
+ break;
+ case RANGE_BOUND_KIND_DWARF_LOCLIST:
+ {
+ CORE_ADDR addr = 0;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* `struct dwarf2_loclist_baton' is too bound to its objfile so
+ it is expected to be made constant by CHECK_TYPEDEF.
+ TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are not valid for TYPE.
+ */
+ if (! TYPE_NOT_ALLOCATED (new_type)
+ && ! TYPE_NOT_ASSOCIATED (new_type) && has_stack_frames ())
+ dwarf_loclist_baton_eval
+ (TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.loclist,
+ TYPE_RANGE_DATA (new_type)->byte_stride.u.dwarf_loclist.type,
+ &addr);
+ TYPE_BYTE_STRIDE (new_type) = addr;
+ TYPE_RANGE_DATA (new_type)->byte_stride.kind
+ = RANGE_BOUND_KIND_CONSTANT;
+ }
+ break;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Convert TYPE_RANGE_HIGH_BOUND_IS_COUNT into a regular bound. */
+ if (TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type))
+ {
+ TYPE_HIGH_BOUND (new_type) = TYPE_LOW_BOUND (new_type)
+ + TYPE_HIGH_BOUND (new_type) - 1;
+ TYPE_RANGE_HIGH_BOUND_IS_COUNT (new_type) = 0;
+ }
}
/* Copy pointers to other types. */
if (TYPE_TARGET_TYPE (type))
TYPE_TARGET_TYPE (new_type) =
- copy_type_recursive (objfile,
- TYPE_TARGET_TYPE (type),
- copied_types);
+ copy_type_recursive_1 (objfile,
+ TYPE_TARGET_TYPE (type),
+ copied_types);
if (TYPE_VPTR_BASETYPE (type))
TYPE_VPTR_BASETYPE (new_type) =
- copy_type_recursive (objfile,
- TYPE_VPTR_BASETYPE (type),
- copied_types);
+ copy_type_recursive_1 (objfile,
+ TYPE_VPTR_BASETYPE (type),
+ copied_types);
/* Maybe copy the type_specific bits.
NOTE drow/2005-12-09: We do not copy the C++-specific bits like
@@ -3331,6 +3680,17 @@ copy_type_recursive (struct objfile *objfile,
return new_type;
}
+/* Recursively copy (deep copy) TYPE. Return a new type allocated using
+ malloc, a saved type if we have already visited TYPE (using COPIED_TYPES),
+ or TYPE if it is not associated with OBJFILE. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+struct type *
+copy_type_recursive (struct type *type,
+ htab_t copied_types)
+{
+ return copy_type_recursive_1 (TYPE_OBJFILE (type), type, copied_types);
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
/* Make a copy of the given TYPE, except that the pointer & reference
types are not preserved.
@@ -3353,6 +3713,199 @@ copy_type (const struct type *type)
return new_type;
}
+/* Callback type for main_type_crawl. */
+typedef int (*main_type_crawl_iter) (struct type *type, void *data);
+
+/* Iterate all main_type structures reachable through any `struct type *' from
+ TYPE. ITER will be called only for one type of each main_type, use
+ TYPE_CHAIN traversal to find all the type instances. ITER is being called
+ for each main_type found. ITER returns non-zero if main_type_crawl should
+ depth-first enter the specific type. ITER must provide some detection for
+ reentering the same main_type as this function would otherwise endlessly
+ loop. */
+
+static void
+main_type_crawl (struct type *type, main_type_crawl_iter iter, void *data)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct type *type_iter;
+ int i;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!type)
+ return;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (TYPE_OBJFILE (type) == NULL);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* `struct cplus_struct_type' handling is unsupported by this function. */
+ gdb_assert ((TYPE_CODE (type) != TYPE_CODE_STRUCT
+ && TYPE_CODE (type) != TYPE_CODE_UNION)
+ || !HAVE_CPLUS_STRUCT (type));
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!(*iter) (type, data))
+ return;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Iterate all the type instances of this main_type. */
+ type_iter = type;
+ do
+ {
+ gdb_assert (TYPE_MAIN_TYPE (type_iter) == TYPE_MAIN_TYPE (type));
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ main_type_crawl (TYPE_POINTER_TYPE (type), iter, data);
+ main_type_crawl (TYPE_REFERENCE_TYPE (type), iter, data);
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ type_iter = TYPE_CHAIN (type_iter);
+ }
+ while (type_iter != type);
+
+ for (i = 0; i < TYPE_NFIELDS (type); i++)
+ main_type_crawl (TYPE_FIELD_TYPE (type, i), iter, data);
+
+ main_type_crawl (TYPE_TARGET_TYPE (type), iter, data);
+ main_type_crawl (TYPE_VPTR_BASETYPE (type), iter, data);
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* A helper for delete_type which deletes a main_type and the things to which
+ it refers. TYPE is a type whose main_type we wish to destroy. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+delete_main_type (struct type *type)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ int i;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (TYPE_DISCARDABLE (type));
+ gdb_assert (TYPE_OBJFILE (type) == NULL);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ xfree (TYPE_NAME (type));
+ xfree (TYPE_TAG_NAME (type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ for (i = 0; i < TYPE_NFIELDS (type); ++i)
+ {
+ xfree (TYPE_FIELD_NAME (type, i));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_FIELD_LOC_KIND (type, i) == FIELD_LOC_KIND_PHYSNAME)
+ xfree (TYPE_FIELD_STATIC_PHYSNAME (type, i));
+ }
+ xfree (TYPE_FIELDS (type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (!HAVE_CPLUS_STRUCT (type));
+
+ xfree (TYPE_MAIN_TYPE (type));
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Delete all the instances on TYPE_CHAIN of TYPE, including their referenced
+ main_type. TYPE must be a reclaimable type - neither permanent nor objfile
+ associated. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+delete_type_chain (struct type *type)
+{
+ struct type *type_iter, *type_iter_to_free;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (TYPE_DISCARDABLE (type));
+ gdb_assert (TYPE_OBJFILE (type) == NULL);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ delete_main_type (type);
+
+ type_iter = type;
+ do
+ {
+ type_iter_to_free = type_iter;
+ type_iter = TYPE_CHAIN (type_iter);
+ xfree (type_iter_to_free);
+ }
+ while (type_iter != type);
+}
+
+/* Hash function for type_discardable_table. */
+
+static hashval_t
+type_discardable_hash (const void *p)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ const struct type *type = p;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return htab_hash_pointer (TYPE_MAIN_TYPE (type));
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Equality function for type_discardable_table. */
+
+static int
+type_discardable_equal (const void *a, const void *b)
+{
+ const struct type *left = a;
+ const struct type *right = b;
+
+ return TYPE_MAIN_TYPE (left) == TYPE_MAIN_TYPE (right);
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* A helper for type_mark_used. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static int
+type_mark_used_crawl (struct type *type, void *unused)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ if (!TYPE_DISCARDABLE (type))
+ return 0;
+
+ if (TYPE_DISCARDABLE_AGE (type) == type_discardable_age_current)
+ return 0;
+
+ TYPE_DISCARDABLE_AGE (type) = type_discardable_age_current;
+
+ /* Continue the traversal. */
+ return 1;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Mark TYPE and its connected types as used in this free_all_types pass. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+void
+type_mark_used (struct type *type)
+{
+ if (type == NULL)
+ return;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!TYPE_DISCARDABLE (type))
+ return;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ main_type_crawl (type, type_mark_used_crawl, NULL);
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+/* A traverse callback for type_discardable_table which removes any
+ type_discardable whose reference count is now zero (unused link). */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static int
+type_discardable_remove (void **slot, void *unused)
+{
+ struct type *type = *slot;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ gdb_assert (TYPE_DISCARDABLE (type));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_DISCARDABLE_AGE (type) != type_discardable_age_current)
+ {
+ delete_type_chain (type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ htab_clear_slot (type_discardable_table, slot);
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return 1;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Free all the reclaimable types that have been allocated and that have
+ currently zero reference counter.
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ This function is called after each command, successful or not. Use this
+ cleanup only in the GDB idle state as GDB only marks those types used by
+ globally tracked objects (with no autovariable references tracking). */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+void
+free_all_types (void)
+{
+ /* Mark a new pass. As GDB checks all the entries were visited after each
+ pass there cannot be any stale entries already containing the changed
+ value. */
+ type_discardable_age_current ^= 1;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ observer_notify_mark_used ();
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ htab_traverse (type_discardable_table, type_discardable_remove, NULL);
+}
/* Helper functions to initialize architecture-specific types. */
@@ -3701,6 +4254,8 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
= lookup_pointer_type (builtin_type->builtin_void);
builtin_type->builtin_func_ptr
= lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
+ builtin_type->builtin_func_func
+ = lookup_function_type (builtin_type->builtin_func_ptr);
/* This type represents a GDB internal function. */
builtin_type->internal_fn
@@ -3814,6 +4369,18 @@ objfile_type (struct objfile *objfile)
"<text variable, no debug info>", objfile);
TYPE_TARGET_TYPE (objfile_type->nodebug_text_symbol)
= objfile_type->builtin_int;
+ objfile_type->nodebug_text_gnu_ifunc_symbol
+ = init_type (TYPE_CODE_FUNC, 1, TYPE_FLAG_GNU_IFUNC,
+ "<text gnu-indirect-function variable, no debug info>",
+ objfile);
+ TYPE_TARGET_TYPE (objfile_type->nodebug_text_gnu_ifunc_symbol)
+ = objfile_type->nodebug_text_symbol;
+ objfile_type->nodebug_got_plt_symbol
+ = init_type (TYPE_CODE_PTR, gdbarch_addr_bit (gdbarch) / 8, 0,
+ "<text from jump slot in .got.plt, no debug info>",
+ objfile);
+ TYPE_TARGET_TYPE (objfile_type->nodebug_got_plt_symbol)
+ = objfile_type->nodebug_text_symbol;
objfile_type->nodebug_data_symbol
= init_type (TYPE_CODE_INT,
gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT, 0,
@@ -3868,6 +4435,11 @@ void
_initialize_gdbtypes (void)
{
gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+ type_discardable_table = htab_create_alloc (20, type_discardable_hash,
+ type_discardable_equal, NULL,
+ xcalloc, xfree);
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
objfile_type_data = register_objfile_data ();
add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 51eb445..627e5af 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -170,6 +170,7 @@ enum type_flag_value
TYPE_FLAG_VECTOR = (1 << 15),
TYPE_FLAG_FIXED_INSTANCE = (1 << 16),
TYPE_FLAG_STUB_SUPPORTED = (1 << 17),
+ TYPE_FLAG_GNU_IFUNC = (1 << 18),
/* Used for error-checking. */
TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED
@@ -214,6 +215,11 @@ enum type_instance_flag_value
#define TYPE_TARGET_STUB(t) (TYPE_MAIN_TYPE (t)->flag_target_stub)
+/* Type needs to be evaluated on each CHECK_TYPEDEF and its results must not be
+ sticky. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_DYNAMIC(t) (TYPE_MAIN_TYPE (t)->flag_dynamic)
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
/* Static type. If this is set, the corresponding type had
* a static modifier.
* Note: This may be unnecessary, since static data members
@@ -271,6 +277,12 @@ enum type_instance_flag_value
#define TYPE_NOTTEXT(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_NOTTEXT)
+/* Used only for TYPE_CODE_FUNC where it specifies the real function
+ address is returned by this function call. TYPE_TARGET_TYPE determines the
+ final returned function type to be presented to user. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_GNU_IFUNC(t) (TYPE_MAIN_TYPE (t)->flag_gnu_ifunc)
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
/* Type owner. If TYPE_OBJFILE_OWNED is true, the type is owned by
the objfile retrieved as TYPE_OBJFILE. Otherweise, the type is
owned by an architecture; TYPE_OBJFILE is NULL in this case. */
@@ -285,6 +297,48 @@ enum type_instance_flag_value
#define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
+/* Define this type as being reclaimable during free_all_types. Type is
+ required to be have TYPE_OBJFILE set to NULL. Setting this flag requires
+ initializing TYPE_DISCARDABLE_AGE, see alloc_type_discardable. */
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_DISCARDABLE(t) (TYPE_MAIN_TYPE (t)->flag_discardable)
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Marker this type has been visited by the type_mark_used by this
+ mark-and-sweep types garbage collecting pass. Current pass is represented
+ by TYPE_DISCARDABLE_AGE_CURRENT. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_DISCARDABLE_AGE(t) (TYPE_MAIN_TYPE (t)->flag_discardable_age)
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Is HIGH_BOUND a low-bound relative count (1) or the high bound itself (0)? */
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_RANGE_HIGH_BOUND_IS_COUNT(range_type) \
+ (TYPE_MAIN_TYPE (range_type)->flag_range_high_bound_is_count)
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Not allocated. TYPE_ALLOCATED(t) must be NULL in such case. If this flag
+ is unset and TYPE_ALLOCATED(t) is NULL then the type is allocated. If this
+ flag is unset and TYPE_ALLOCATED(t) is not NULL then its DWARF block
+ determines the actual allocation state. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_NOT_ALLOCATED(t) (TYPE_MAIN_TYPE (t)->flag_not_allocated)
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Not associated. TYPE_ASSOCIATED(t) must be NULL in such case. If this flag
+ is unset and TYPE_ASSOCIATED(t) is NULL then the type is associated. If
+ this flag is unset and TYPE_ASSOCIATED(t) is not NULL then its DWARF block
+ determines the actual association state. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_NOT_ASSOCIATED(t) (TYPE_MAIN_TYPE (t)->flag_not_associated)
+
+/* Address of the actual data as for DW_AT_data_location. Its dwarf block must
+ not be evaluated unless both TYPE_NOT_ALLOCATED and TYPE_NOT_ASSOCIATED are
+ false. If TYPE_DATA_LOCATION_IS_ADDR set then TYPE_DATA_LOCATION_ADDR value
+ is the actual data address value. If unset and
+ TYPE_DATA_LOCATION_DWARF_BLOCK is NULL then the value is the normal
+ value_raw_address. If unset and TYPE_DATA_LOCATION_DWARF_BLOCK is not NULL
+ then its DWARF block determines the actual data address. */
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+#define TYPE_DATA_LOCATION_IS_ADDR(t) \
+ (TYPE_MAIN_TYPE (t)->flag_data_location_is_addr)
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
/* Constant type. If this is set, the corresponding type has a
* const modifier.
*/
@@ -388,11 +442,19 @@ struct main_type
unsigned int flag_varargs : 1;
unsigned int flag_vector : 1;
unsigned int flag_stub_supported : 1;
+ unsigned int flag_gnu_ifunc : 1;
unsigned int flag_fixed_instance : 1;
unsigned int flag_objfile_owned : 1;
/* True if this type was declared with "class" rather than
"struct". */
unsigned int flag_declared_class : 1;
+ unsigned int flag_discardable : 1;
+ unsigned int flag_discardable_age : 1;
+ unsigned int flag_dynamic : 1;
+ unsigned int flag_range_high_bound_is_count : 1;
+ unsigned int flag_not_allocated : 1;
+ unsigned int flag_not_associated : 1;
+ unsigned int flag_data_location_is_addr : 1;
/* A discriminant telling us which field of the type_specific union
is being used for this type, if any. */
@@ -466,6 +528,20 @@ struct main_type
struct type *target_type;
+ /* For DW_AT_data_location. */
+ union
+ {
+ struct dwarf2_locexpr_baton *dwarf_block;
+ CORE_ADDR addr;
+ }
+ data_location;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* For DW_AT_allocated. */
+ struct dwarf2_locexpr_baton *allocated;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* For DW_AT_associated. */
+ struct dwarf2_locexpr_baton *associated;
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
/* For structure and union types, a description of each field.
For set and pascal array types, there is one "field",
whose type is the domain type of the set or array.
@@ -539,13 +615,34 @@ struct main_type
struct range_bounds
{
+ struct
+ {
+ union
+ {
+ LONGEST constant;
+ struct dwarf2_locexpr_baton *dwarf_block;
+ struct
+ {
+ struct dwarf2_loclist_baton *loclist;
+ struct type *type;
+ }
+ dwarf_loclist;
+ }
+ u;
+ enum range_bound_kind
+ {
+ RANGE_BOUND_KIND_CONSTANT,
+ RANGE_BOUND_KIND_DWARF_BLOCK,
+ RANGE_BOUND_KIND_DWARF_LOCLIST
+ }
+ kind;
+ }
/* Low bound of range. */
-
- LONGEST low;
-
+ low,
/* High bound of range. */
-
- LONGEST high;
+ high,
+ /* Byte stride of range. */
+ byte_stride;
/* Flags indicating whether the values of low and high are
valid. When true, the respective range value is
@@ -917,9 +1014,9 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
#define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
#define TYPE_CHAIN(thistype) (thistype)->chain
-/* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
- But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
- so you only have to call check_typedef once. Since allocate_value
+/* Note that if thistype is a TYPEDEF, ARRAY or STRING type, you have to call
+ check_typedef. But check_typedef does set the TYPE_LENGTH of the TYPEDEF
+ type, so you only have to call check_typedef once. Since allocate_value
calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */
#define TYPE_LENGTH(thistype) (thistype)->length
/* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real
@@ -927,11 +1024,16 @@ extern void allocate_gnat_aux_type (struct type *);
#define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
#define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
#define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
+#define TYPE_DATA_LOCATION_DWARF_BLOCK(thistype) TYPE_MAIN_TYPE (thistype)->data_location.dwarf_block
+#define TYPE_DATA_LOCATION_ADDR(thistype) TYPE_MAIN_TYPE (thistype)->data_location.addr
+#define TYPE_ALLOCATED(thistype) TYPE_MAIN_TYPE (thistype)->allocated
+#define TYPE_ASSOCIATED(thistype) TYPE_MAIN_TYPE (thistype)->associated
#define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
-#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
-#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
+#define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low.u.constant
+#define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high.u.constant
+#define TYPE_BYTE_STRIDE(range_type) TYPE_RANGE_DATA(range_type)->byte_stride.u.constant
#define TYPE_LOW_BOUND_UNDEFINED(range_type) \
TYPE_RANGE_DATA(range_type)->low_undefined
#define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
@@ -948,7 +1050,14 @@ extern void allocate_gnat_aux_type (struct type *);
(TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
#define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
- (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
+ TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arraytype))
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+/* TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) with a fallback to the
+ element size if no specific stride value is known. */
+#define TYPE_ARRAY_BYTE_STRIDE_VALUE(arraytype) \
+ (TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)) == 0 \
+ ? TYPE_LENGTH (TYPE_TARGET_TYPE (arraytype)) \
+ : TYPE_BYTE_STRIDE (TYPE_INDEX_TYPE (arraytype)))
/* C++ */
@@ -1176,6 +1285,10 @@ struct builtin_type
(*) () can server as a generic function pointer. */
struct type *builtin_func_ptr;
+ /* `function returning pointer to function (returning void)' type.
+ The final void return type is not significant for it. */
+ struct type *builtin_func_func;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Special-purpose types. */
@@ -1216,6 +1329,8 @@ struct objfile_type
/* Types used for symbols with no debug information. */
struct type *nodebug_text_symbol;
+ struct type *nodebug_text_gnu_ifunc_symbol;
+ struct type *nodebug_got_plt_symbol;
struct type *nodebug_data_symbol;
struct type *nodebug_unknown_symbol;
struct type *nodebug_tls_symbol;
@@ -1363,6 +1478,18 @@ extern struct type *create_array_type (struct type *, struct type *,
struct type *);
extern struct type *lookup_array_range_type (struct type *, int, int);
+extern CORE_ADDR type_range_any_field_internal (struct type *range_type,
+ int fieldno);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+extern int type_range_high_bound_internal (struct type *range_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+extern int type_range_count_bound_internal (struct type *range_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
+ struct type *element_type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+extern void finalize_type (struct type *type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
extern struct type *create_string_type (struct type *, struct type *,
struct type *);
extern struct type *lookup_string_range_type (struct type *, int, int);
@@ -1408,6 +1535,8 @@ extern int is_public_ancestor (struct type *, struct type *);
extern int is_unique_ancestor (struct type *, struct value *);
+extern void type_mark_used (struct type *type);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Overload resolution */
#define LENGTH_MATCH(bv) ((bv)->rank[0])
@@ -1478,10 +1607,11 @@ extern void maintenance_print_type (char *, int);
extern htab_t create_copied_types_hash (struct objfile *objfile);
-extern struct type *copy_type_recursive (struct objfile *objfile,
- struct type *type,
+extern struct type *copy_type_recursive (struct type *type,
htab_t copied_types);
extern struct type *copy_type (const struct type *type);
+extern void free_all_types (void);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
#endif /* GDBTYPES_H */
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 4fce1ac..144a899 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -747,6 +747,21 @@ i386_linux_dr_unset_status (unsigned long mask)
}
}
+/* See i386_dr_low_type.detach. Do not use wrappers i386_linux_dr_set_control
+ or i386_linux_dr_reset_addr as they would modify the register cache
+ (i386_linux_dr). */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+i386_linux_dr_detach (void)
+{
+ int regnum;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ i386_linux_dr_set (inferior_ptid, DR_CONTROL, 0);
+ i386_linux_dr_unset_status (~0UL);
+ for (regnum = DR_FIRSTADDR; regnum <= DR_LASTADDR; regnum++)
+ i386_linux_dr_set (inferior_ptid, regnum, 0);
+}
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
static void
i386_linux_new_thread (ptid_t ptid)
{
@@ -976,6 +991,7 @@ _initialize_i386_linux_nat (void)
i386_dr_low.reset_addr = i386_linux_dr_reset_addr;
i386_dr_low.get_status = i386_linux_dr_get_status;
i386_dr_low.unset_status = i386_linux_dr_unset_status;
+ i386_dr_low.detach = i386_linux_dr_detach;
i386_set_debug_register_length (4);
/* Override the default ptrace resume method. */
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index eaa3644..0921c7e 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -533,6 +533,17 @@ i386_remove_watchpoint (CORE_ADDR addr, int len, int type,
return retval;
}
+/* See target_detach_watchpoints. */
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+static int
+i386_detach_watchpoints (void)
+{
+ if (i386_dr_low.detach)
+ i386_dr_low.detach ();
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ return 0;
+}
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
/* Return non-zero if we can watch a memory region that starts at
address ADDR and whose length is LEN bytes. */
@@ -685,6 +696,7 @@ i386_use_watchpoints (struct target_ops *t)
t->to_stopped_data_address = i386_stopped_data_address;
t->to_insert_watchpoint = i386_insert_watchpoint;
t->to_remove_watchpoint = i386_remove_watchpoint;
+ t->to_detach_watchpoints = i386_detach_watchpoints;
t->to_insert_hw_breakpoint = i386_insert_hw_breakpoint;
t->to_remove_hw_breakpoint = i386_remove_hw_breakpoint;
}
diff --git a/gdb/i386-nat.h b/gdb/i386-nat.h
index 7317e7d..ea914a5 100644
--- a/gdb/i386-nat.h
+++ b/gdb/i386-nat.h
@@ -62,6 +62,10 @@ extern void i386_use_watchpoints (struct target_ops *);
unset_status -- unset the specified bits of the debug
status (DR6) register for all LWPs
+ detach -- clear all debug registers of only the
+ INFERIOR_PTID task without affecting any
+ register caches.
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
Additionally, the native file should set the debug_register_length
field to 4 or 8 depending on the number of bytes used for
deubg registers. */
@@ -73,6 +77,7 @@ struct i386_dr_low_type
void (*reset_addr) (int);
unsigned long (*get_status) (void);
void (*unset_status) (unsigned long);
+ void (*detach) (void);
int debug_register_length;
};
diff --git a/gdb/infcall.c b/gdb/infcall.c
index 7f60e56..b7acfc6 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -225,6 +225,56 @@ value_arg_coerce (struct gdbarch *gdbarch, struct value *arg,
return value_cast (type, arg);
}
+/* Call gnu-ifunc (STT_GNU_IFUNC - a function returning addresss of a real
+ function to call). PC is the gnu-ifunc function entry. Function returns
+ function entry of the gnu-ifunc-resolved function to call. If RETVAL_TYPEP
+ is not NULL fill in *RETVAL_TYPEP with return type of the gnu-ifunc-resolved
+ function to call. Keep *RETVAL_TYPEP intact if the return type could not be
+ found. */
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+static CORE_ADDR
+gnu_ifunc_resolve (struct gdbarch *gdbarch, CORE_ADDR pc)
+{
+ char *name_at_pc;
+ CORE_ADDR start_at_pc, address;
+ struct type *func_func_type = builtin_type (gdbarch)->builtin_func_func;
+ struct value *function, *address_val;
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (find_pc_partial_function (pc, &name_at_pc, &start_at_pc, NULL)
+ && start_at_pc == pc)
+ {
+ if (resolve_gnu_ifunc (name_at_pc, &address))
+ return address;
+ }
+ else
+ name_at_pc = NULL;
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+ function = allocate_value (func_func_type);
+ set_value_address (function, pc);
2010-07-11 18:06:33 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* gnu-ifuncs have no arguments. FUNCTION is the function entry address
+ while ADDRESS is a possible function descriptor.. */
+ address_val = call_function_by_hand (function, 0, NULL);
+ address = value_as_address (address_val);
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (name_at_pc)
+ gnu_ifunc_record_cache (gdbarch, name_at_pc, address);
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ return gdbarch_convert_from_func_ptr_addr (gdbarch, address, ¤t_target);
+}
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+static struct type *
+find_function_return_type (CORE_ADDR pc)
+{
+ struct symbol *sym = find_pc_function (pc);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (sym != NULL && BLOCK_START (SYMBOL_BLOCK_VALUE (sym)) == pc
+ && SYMBOL_TYPE (sym) != NULL)
+ return TYPE_TARGET_TYPE (SYMBOL_TYPE (sym));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return NULL;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Determine a function's address and its return type from its value.
Calls error() if the function is not valid for calling. */
2010-07-21 21:30:20 +00:00
2010-11-17 02:58:16 +00:00
@@ -233,7 +283,6 @@ find_function_addr (struct value *function, struct type **retval_type)
2010-07-21 21:30:20 +00:00
{
2010-11-17 02:58:16 +00:00
struct type *ftype = check_typedef (value_type (function));
struct gdbarch *gdbarch = get_type_arch (ftype);
- enum type_code code = TYPE_CODE (ftype);
struct type *value_type = NULL;
CORE_ADDR funaddr;
@@ -241,24 +290,34 @@ find_function_addr (struct value *function, struct type **retval_type)
part of it. */
/* Determine address to call. */
- if (code == TYPE_CODE_FUNC || code == TYPE_CODE_METHOD)
- {
- funaddr = value_address (function);
- value_type = TYPE_TARGET_TYPE (ftype);
- }
- else if (code == TYPE_CODE_PTR)
+ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
+ || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
+ funaddr = value_address (function);
+ else if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
{
funaddr = value_as_address (function);
ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
|| TYPE_CODE (ftype) == TYPE_CODE_METHOD)
+ funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
+ ¤t_target);
+ }
+ if (TYPE_CODE (ftype) == TYPE_CODE_FUNC
+ || TYPE_CODE (ftype) == TYPE_CODE_METHOD)
+ {
+ value_type = TYPE_TARGET_TYPE (ftype);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (TYPE_GNU_IFUNC (ftype))
{
- funaddr = gdbarch_convert_from_func_ptr_addr (gdbarch, funaddr,
- ¤t_target);
- value_type = TYPE_TARGET_TYPE (ftype);
+ funaddr = gnu_ifunc_resolve (gdbarch, funaddr);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ /* Skip querying the function symbol if no RETVAL_TYPE has been
+ asked for. */
+ if (retval_type)
+ value_type = find_function_return_type (funaddr);
}
}
- else if (code == TYPE_CODE_INT)
+ else if (TYPE_CODE (ftype) == TYPE_CODE_INT)
{
/* Handle the case of functions lacking debugging info.
Their values are characters since their addresses are char */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index f6b00da..56e558b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3267,6 +3267,10 @@ handle_inferior_event (struct execution_control_state *ecs)
stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
+ /* Clear WATCHPOINT_TRIGGERED values from previous stop which could
+ confuse bpstat_stop_status and bpstat_explains_signal. */
+ watchpoints_triggered (&ecs->ws);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
ecs->event_thread->stop_bpstat
= bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
stop_pc, ecs->ptid);
@@ -3354,6 +3358,10 @@ handle_inferior_event (struct execution_control_state *ecs)
stop_pc = regcache_read_pc (get_thread_regcache (ecs->ptid));
+ /* Clear WATCHPOINT_TRIGGERED values from previous stop which could
+ confuse bpstat_stop_status and bpstat_explains_signal. */
+ watchpoints_triggered (&ecs->ws);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Do whatever is necessary to the parent branch of the vfork. */
handle_vfork_child_exec_or_exit (1);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index 0e18034..96895db 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -2607,6 +2607,39 @@ linux_nat_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
return lp->stopped_data_address_p;
}
+/* In `set follow-fork-mode child' with multithreaded parent we need to detach
+ watchpoints from all the LWPs. In such case INFERIOR_PTID will be the
+ non-threaded new child while LWP_LIST will still contain all the threads of
+ the parent being detached. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static int
+linux_nat_detach_watchpoints (void)
2009-08-04 05:37:29 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct lwp_info *lp;
+ int found = 0, retval = 0;
+ ptid_t filter = pid_to_ptid (ptid_get_pid (inferior_ptid));
+ struct cleanup *old_chain = save_inferior_ptid ();
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ for (lp = lwp_list; lp; lp = lp->next)
+ if (ptid_match (lp->ptid, filter))
+ {
+ inferior_ptid = lp->ptid;
+ retval |= linux_ops->to_detach_watchpoints ();
+ found = 1;
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ do_cleanups (old_chain);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (!found)
+ {
+ gdb_assert (!is_lwp (inferior_ptid));
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ retval |= linux_ops->to_detach_watchpoints ();
+ }
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ return retval;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Commonly any breakpoint / watchpoint generate only SIGTRAP. */
static int
@@ -5660,6 +5693,8 @@ linux_nat_add_target (struct target_ops *t)
t->to_thread_address_space = linux_nat_thread_address_space;
t->to_stopped_by_watchpoint = linux_nat_stopped_by_watchpoint;
t->to_stopped_data_address = linux_nat_stopped_data_address;
+ if (linux_ops->to_detach_watchpoints)
+ t->to_detach_watchpoints = linux_nat_detach_watchpoints;
t->to_can_async_p = linux_nat_can_async_p;
t->to_is_async_p = linux_nat_is_async_p;
diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c
index c51ede9..ef8cbda 100644
--- a/gdb/linux-tdep.c
+++ b/gdb/linux-tdep.c
@@ -24,6 +24,8 @@
#include "target.h"
#include "elf/common.h"
#include "inferior.h"
+#include "value.h"
+#include "infcall.h"
static struct gdbarch_data *linux_gdbarch_data_handle;
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 310ade9..d8710a1 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -702,7 +702,6 @@ mi_cmd_var_update (char *command, char **argv, int argc)
}
else
{
- /* Get varobj handle, if a valid var obj name was specified */
struct varobj *var = varobj_get_handle (name);
varobj_update_one (var, print_values, 1 /* explicit */);
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 0a57e77..6be74df 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -337,8 +337,9 @@ lookup_minimal_symbol_text (const char *name, struct objfile *objf)
msymbol = msymbol->hash_next)
{
if (strcmp (SYMBOL_LINKAGE_NAME (msymbol), name) == 0 &&
- (MSYMBOL_TYPE (msymbol) == mst_text ||
- MSYMBOL_TYPE (msymbol) == mst_file_text))
+ (MSYMBOL_TYPE (msymbol) == mst_text
+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc
+ || MSYMBOL_TYPE (msymbol) == mst_file_text))
{
switch (MSYMBOL_TYPE (msymbol))
{
@@ -700,6 +701,16 @@ lookup_minimal_symbol_by_pc (CORE_ADDR pc)
return lookup_minimal_symbol_by_pc_section (pc, NULL);
}
+/* Return non-zero iff PC is in function implementing gnu-ifunc selection. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+int
+in_gnu_ifunc_stub (CORE_ADDR pc)
2010-07-21 21:30:20 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (pc);
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+ return msymbol && MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc;
+}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* Find the minimal symbol named NAME, and return both the minsym
struct and its objfile. This only checks the linkage name. Sets
*OBJFILE_P and returns the minimal symbol, if it is found. If it
@@ -769,6 +780,7 @@ prim_record_minimal_symbol (const char *name, CORE_ADDR address,
switch (ms_type)
{
case mst_text:
+ case mst_text_gnu_ifunc:
case mst_file_text:
case mst_solib_trampoline:
section = SECT_OFF_TEXT (objfile);
@@ -1234,7 +1246,8 @@ find_solib_trampoline_target (struct frame_info *frame, CORE_ADDR pc)
{
ALL_MSYMBOLS (objfile, msymbol)
{
- if (MSYMBOL_TYPE (msymbol) == mst_text
+ if ((MSYMBOL_TYPE (msymbol) == mst_text
+ || MSYMBOL_TYPE (msymbol) == mst_text_gnu_ifunc)
&& strcmp (SYMBOL_LINKAGE_NAME (msymbol),
SYMBOL_LINKAGE_NAME (tsymbol)) == 0)
return SYMBOL_VALUE_ADDRESS (msymbol);
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 44a2d72..e3aead4 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -38,6 +38,7 @@
#include "p-lang.h"
#include "cp-abi.h"
#include "cp-support.h"
+#include "dwarf2loc.h"
@@ -68,8 +69,27 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
struct type *char_type;
LONGEST val;
CORE_ADDR addr;
+ struct cleanup *back_to;
+ struct type *saved_type = type;
+ CORE_ADDR saved_address = address;
+
+ back_to = make_cleanup (null_cleanup, 0);
+ type = object_address_get_data (type, &address);
+ if (type == NULL)
+ {
+ fputs_filtered (object_address_data_not_valid (saved_type), stream);
+ gdb_flush (stream);
+ do_cleanups (back_to);
+ return 0;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ if (address != saved_address)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ size_t length = TYPE_LENGTH (type);
- CHECK_TYPEDEF (type);
+ valaddr = xmalloc (length);
+ make_cleanup (xfree, (gdb_byte *) valaddr);
+ read_memory (address, (gdb_byte *) valaddr, length);
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
switch (TYPE_CODE (type))
{
case TYPE_CODE_ARRAY:
@@ -125,8 +145,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
{
i = 0;
}
- val_print_array_elements (type, valaddr + embedded_offset, address, stream,
- recurse, original_value, options, i);
+ val_print_array_elements (saved_type, valaddr + embedded_offset,
+ saved_address, stream, recurse,
+ original_value, options, i);
fprintf_filtered (stream, "}");
}
break;
@@ -164,6 +185,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
/* Try to print what function it points to. */
print_address_demangle (gdbarch, addr, stream, demangle);
/* Return value is irrelevant except for string pointers. */
+ do_cleanups (back_to);
return (0);
}
@@ -254,6 +276,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
/* Return number of characters printed, including the terminating
'\0' if we reached the end. val_print_string takes care including
the terminating '\0' if necessary. */
+ do_cleanups (back_to);
return i;
break;
@@ -556,6 +579,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
error (_("Invalid pascal type code %d in symbol table."), TYPE_CODE (type));
}
gdb_flush (stream);
+ do_cleanups (back_to);
return (0);
}
diff --git a/gdb/parse.c b/gdb/parse.c
index 18038ed..1438ae0 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -487,9 +487,21 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
pc = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, ¤t_target);
if (pc != addr)
{
+ struct minimal_symbol *ifunc_msym = lookup_minimal_symbol_by_pc (pc);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
/* In this case, assume we have a code symbol instead of
a data symbol. */
- type = mst_text;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (ifunc_msym != NULL && MSYMBOL_TYPE (ifunc_msym) == mst_text_gnu_ifunc
+ && SYMBOL_VALUE_ADDRESS (ifunc_msym) == pc)
2010-07-22 10:49:58 +00:00
+ {
2010-11-17 02:58:16 +00:00
+ /* A function descriptor has been resolved but PC is still in the
+ gnu-ifunc resolver body (such as because inferior does not run to
+ be able to call it). */
+ type = mst_text_gnu_ifunc;
2010-07-22 10:49:58 +00:00
+ }
2010-11-17 02:58:16 +00:00
+ else
+ type = mst_text;
section = NULL;
addr = pc;
}
@@ -521,6 +533,11 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol);
break;
+ case mst_text_gnu_ifunc:
+ write_exp_elt_type (objfile_type (objfile)
+ ->nodebug_text_gnu_ifunc_symbol);
+ break;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
case mst_data:
case mst_file_data:
case mst_bss:
@@ -528,6 +545,10 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
write_exp_elt_type (objfile_type (objfile)->nodebug_data_symbol);
break;
+ case mst_slot_got_plt:
+ write_exp_elt_type (objfile_type (objfile)->nodebug_got_plt_symbol);
+ break;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
default:
write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol);
break;
@@ -1481,6 +1502,7 @@ parser_fprintf (FILE *x, const char *y, ...)
int
operator_check_standard (struct expression *exp, int pos,
+ int (*type_func) (struct type *type, void *data),
int (*objfile_func) (struct objfile *objfile,
void *data),
void *data)
@@ -1522,7 +1544,7 @@ operator_check_standard (struct expression *exp, int pos,
struct type *type = elts[pos + 2 + arg].type;
struct objfile *objfile = TYPE_OBJFILE (type);
- if (objfile && (*objfile_func) (objfile, data))
+ if (objfile && objfile_func && (*objfile_func) (objfile, data))
return 1;
}
}
@@ -1540,7 +1562,8 @@ operator_check_standard (struct expression *exp, int pos,
/* Check objfile where the variable itself is placed.
SYMBOL_OBJ_SECTION (symbol) may be NULL. */
- if ((*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
+ if (objfile_func
+ && (*objfile_func) (SYMBOL_SYMTAB (symbol)->objfile, data))
return 1;
/* Check objfile where is placed the code touching the variable. */
@@ -1553,24 +1576,27 @@ operator_check_standard (struct expression *exp, int pos,
/* Invoke callbacks for TYPE and OBJFILE if they were set as non-NULL. */
- if (type && TYPE_OBJFILE (type)
+ if (type && type_func && (*type_func) (type, data))
+ return 1;
+ if (type && TYPE_OBJFILE (type) && objfile_func
&& (*objfile_func) (TYPE_OBJFILE (type), data))
return 1;
- if (objfile && (*objfile_func) (objfile, data))
+ if (objfile && objfile_func && (*objfile_func) (objfile, data))
return 1;
return 0;
}
-/* Call OBJFILE_FUNC for any TYPE and OBJFILE found being referenced by EXP.
- The functions are never called with NULL OBJFILE. Functions get passed an
- arbitrary caller supplied DATA pointer. If any of the functions returns
- non-zero value then (any other) non-zero value is immediately returned to
- the caller. Otherwise zero is returned after iterating through whole EXP.
- */
+/* Call TYPE_FUNC and OBJFILE_FUNC for any TYPE and OBJFILE found being
+ referenced by EXP. The functions are never called with NULL TYPE or NULL
+ OBJFILE. Functions get passed an arbitrary caller supplied DATA pointer.
+ If any of the functions returns non-zero value then (any other) non-zero
+ value is immediately returned to the caller. Otherwise zero is returned
+ after iterating through whole EXP. */
static int
exp_iterate (struct expression *exp,
+ int (*type_func) (struct type *type, void *data),
int (*objfile_func) (struct objfile *objfile, void *data),
void *data)
{
@@ -1585,7 +1611,9 @@ exp_iterate (struct expression *exp,
pos = endpos - oplen;
if (exp->language_defn->la_exp_desc->operator_check (exp, pos,
- objfile_func, data))
+ type_func,
+ objfile_func,
+ data))
return 1;
endpos = pos;
@@ -1616,7 +1644,26 @@ exp_uses_objfile (struct expression *exp, struct objfile *objfile)
{
gdb_assert (objfile->separate_debug_objfile_backlink == NULL);
- return exp_iterate (exp, exp_uses_objfile_iter, objfile);
+ return exp_iterate (exp, NULL, exp_uses_objfile_iter, objfile);
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Helper for exp_types_mark_used. */
+
+static int
+exp_types_mark_used_iter (struct type *type, void *unused)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ type_mark_used (type);
+
+ /* Continue the traversal. */
+ return 0;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+/* Call type_mark_used for any type contained in EXP. */
+
+void
+exp_types_mark_used (struct expression *exp)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ exp_iterate (exp, exp_types_mark_used_iter, NULL, NULL);
}
void
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 1625575..d072f86 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -194,6 +194,8 @@ extern void operator_length_standard (const struct expression *, int, int *,
int *);
extern int operator_check_standard (struct expression *exp, int pos,
+ int (*type_func) (struct type *type,
+ void *data),
int (*objfile_func)
(struct objfile *objfile, void *data),
void *data);
@@ -291,6 +293,7 @@ struct exp_descriptor
value should be immediately returned to the caller. Otherwise zero
should be returned. */
int (*operator_check) (struct expression *exp, int pos,
+ int (*type_func) (struct type *type, void *data),
int (*objfile_func) (struct objfile *objfile,
void *data),
void *data);
@@ -329,4 +332,8 @@ extern void parser_fprintf (FILE *, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
+extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+extern void exp_types_mark_used (struct expression *exp);
+
#endif /* PARSER_DEFS_H */
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 18ddee7..652b02a 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2010,6 +2010,24 @@ ppc_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw,
return ret;
}
+/* See target_detach_watchpoints. Do not use wrapper
+ ppc_linux_remove_watchpoint as it would modify the register cache
+ (saved_dabr_value). */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static int
+ppc_linux_detach_watchpoints (void)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ pid_t tid;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid);
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (ptrace (PTRACE_SET_DEBUGREG, tid, NULL, NULL) < 0)
+ return -1;
+ return 0;
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
static void
ppc_linux_new_thread (ptid_t ptid)
{
@@ -2349,6 +2367,7 @@ _initialize_ppc_linux_nat (void)
t->to_region_ok_for_hw_watchpoint = ppc_linux_region_ok_for_hw_watchpoint;
t->to_insert_watchpoint = ppc_linux_insert_watchpoint;
t->to_remove_watchpoint = ppc_linux_remove_watchpoint;
+ t->to_detach_watchpoints = ppc_linux_detach_watchpoints;
t->to_stopped_by_watchpoint = ppc_linux_stopped_by_watchpoint;
t->to_stopped_data_address = ppc_linux_stopped_data_address;
t->to_watchpoint_addr_within_range = ppc_linux_watchpoint_addr_within_range;
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 5586767..144e851 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -971,6 +971,11 @@ print_command_1 (char *exp, int inspect, int voidprint)
else
val = access_value_history (0);
+ /* Do not try to OBJECT_ADDRESS_SET here anything. We are interested in the
+ source variable base addresses as found by READ_VAR_VALUE. The value here
+ can be already a calculated expression address inappropriate for
+ DW_OP_push_object_address. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
if (voidprint || (val && value_type (val) &&
TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
{
@@ -1471,6 +1476,22 @@ x_command (char *exp, int from_tty)
set_internalvar (lookup_internalvar ("__"), last_examine_value);
}
}
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+print_types_mark_used (void)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ struct display *d;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ if (last_examine_value)
+ type_mark_used (value_type (last_examine_value));
+
+ for (d = display_chain; d; d = d->next)
+ if (d->exp)
+ exp_types_mark_used (d->exp);
2010-07-22 10:49:58 +00:00
+}
2010-11-17 02:58:16 +00:00
+
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
/* Add an expression to the auto-display chain.
@@ -2869,4 +2890,6 @@ Show printing of source filename and line number with <symbol>."), NULL,
add_com ("eval", no_class, eval_command, _("\
Convert \"printf format string\", arg1, arg2, arg3, ..., argn to\n\
a command line, and call it."));
+
+ observer_attach_mark_used (print_types_mark_used);
}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
2010-11-17 02:58:16 +00:00
index 8232436..e9fc8aa 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
2010-11-17 02:58:16 +00:00
@@ -29,6 +29,8 @@
2010-07-21 21:30:20 +00:00
#include "language.h"
2010-11-17 02:58:16 +00:00
#include "vec.h"
#include "bcache.h"
2010-07-21 21:30:20 +00:00
+#include "observer.h"
+#include "gdb_assert.h"
typedef struct pyty_type_object
{
2010-11-17 02:58:16 +00:00
@@ -37,11 +39,17 @@ typedef struct pyty_type_object
2010-07-21 21:30:20 +00:00
/* If a Type object is associated with an objfile, it is kept on a
doubly-linked list, rooted in the objfile. This lets us copy the
- underlying struct type when the objfile is deleted. */
+ underlying struct type when the objfile is deleted.
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ With NULL objfile Type still can be doubly-linked in the list
+ PYTY_OBJECTS_DISCARDABLE. */
struct pyty_type_object *prev;
struct pyty_type_object *next;
} type_object;
+/* First element of a doubly-linked list of TYPE_DISCARDABLE Types. */
+static type_object *pyty_objects_discardable;
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
static PyTypeObject type_object_type;
/* A Field object. */
2010-11-17 02:58:16 +00:00
@@ -919,8 +927,59 @@ typy_richcompare (PyObject *self, PyObject *other, int op)
2010-07-21 21:30:20 +00:00
+/* Key associated with each objfile pointing to the first element of
+ a doubly-linked list of Types associated with this objfile. */
static const struct objfile_data *typy_objfile_data_key;
+/* Link TYPE_OBJ to its appropriate list. Either to its objfile associated one
+ or at least to the global list for TYPE_DISCARDABLE Types. Permanent types
+ do not get linked anywhere. */
2009-08-04 05:37:29 +00:00
+static void
2010-07-21 21:30:20 +00:00
+typy_link (type_object *type_obj)
2009-08-04 05:37:29 +00:00
+{
2010-07-21 21:30:20 +00:00
+ type_obj->prev = NULL;
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (type_obj->type && TYPE_OBJFILE (type_obj->type))
+ {
+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ type_obj->next = objfile_data (objfile, typy_objfile_data_key);
+ if (type_obj->next)
+ type_obj->next->prev = type_obj;
+ set_objfile_data (objfile, typy_objfile_data_key, type_obj);
+ }
+ else if (type_obj->type && TYPE_DISCARDABLE (type_obj->type))
2009-08-04 05:37:29 +00:00
+ {
2010-07-21 21:30:20 +00:00
+ type_obj->next = pyty_objects_discardable;
+ if (type_obj->next)
+ type_obj->next->prev = type_obj;
+ pyty_objects_discardable = type_obj;
2009-08-04 05:37:29 +00:00
+ }
2010-07-21 21:30:20 +00:00
+ else
+ type_obj->next = NULL;
2009-08-04 05:37:29 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+/* Unlink TYPE_OBJ from its current list. Permanent types are not linked
+ anywhere and this function has no effect on them. */
+static void
+typy_unlink (type_object *type_obj)
2009-08-04 05:37:29 +00:00
+{
2010-07-21 21:30:20 +00:00
+ if (type_obj->prev)
+ type_obj->prev->next = type_obj->next;
+ else if (type_obj->type && TYPE_OBJFILE (type_obj->type))
+ {
+ /* Must reset head of list. */
+ struct objfile *objfile = TYPE_OBJFILE (type_obj->type);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ set_objfile_data (objfile, typy_objfile_data_key, type_obj->next);
+ }
+ else if (pyty_objects_discardable == type_obj)
+ pyty_objects_discardable = type_obj->next;
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (type_obj->next)
+ type_obj->next->prev = type_obj->prev;
+}
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
static void
save_objfile_types (struct objfile *objfile, void *datum)
{
2010-11-17 02:58:16 +00:00
@@ -938,12 +997,13 @@ save_objfile_types (struct objfile *objfile, void *datum)
2010-07-21 21:30:20 +00:00
{
type_object *next = obj->next;
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
- htab_empty (copied_types);
+ gdb_assert (TYPE_OBJFILE (obj->type) == objfile);
+ typy_unlink (obj);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
- obj->type = copy_type_recursive (objfile, obj->type, copied_types);
+ obj->type = copy_type_recursive (obj->type, copied_types);
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
- obj->next = NULL;
- obj->prev = NULL;
+ gdb_assert (TYPE_OBJFILE (obj->type) == NULL);
+ typy_link (obj);
obj = next;
}
2010-11-17 02:58:16 +00:00
@@ -954,42 +1014,25 @@ save_objfile_types (struct objfile *objfile, void *datum)
2010-07-21 21:30:20 +00:00
}
static void
-set_type (type_object *obj, struct type *type)
+typy_dealloc (PyObject *obj)
2009-08-04 05:37:29 +00:00
{
2010-07-21 21:30:20 +00:00
- obj->type = type;
- obj->prev = NULL;
- if (type && TYPE_OBJFILE (type))
- {
- struct objfile *objfile = TYPE_OBJFILE (type);
+ type_object *type_obj = (type_object *) obj;
- obj->next = objfile_data (objfile, typy_objfile_data_key);
- if (obj->next)
- obj->next->prev = obj;
- set_objfile_data (objfile, typy_objfile_data_key, obj);
- }
- else
- obj->next = NULL;
+ typy_unlink (type_obj);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ type_obj->ob_type->tp_free (obj);
}
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
static void
-typy_dealloc (PyObject *obj)
+typy_types_mark_used (void)
{
- type_object *type = (type_object *) obj;
-
- if (type->prev)
- type->prev->next = type->next;
- else if (type->type && TYPE_OBJFILE (type->type))
- {
- /* Must reset head of list. */
- struct objfile *objfile = TYPE_OBJFILE (type->type);
-
- if (objfile)
- set_objfile_data (objfile, typy_objfile_data_key, type->next);
- }
- if (type->next)
- type->next->prev = type->prev;
+ type_object *type_obj;
2009-08-18 18:51:17 +00:00
2010-07-21 21:30:20 +00:00
- type->ob_type->tp_free (type);
+ for (type_obj = pyty_objects_discardable;
+ type_obj != NULL;
+ type_obj = type_obj->next)
+ type_mark_used (type_obj->type);
}
2009-08-18 18:51:17 +00:00
2010-07-21 21:30:20 +00:00
/* Create a new Type referring to TYPE. */
2010-11-17 02:58:16 +00:00
@@ -1000,7 +1043,10 @@ type_to_type_object (struct type *type)
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
type_obj = PyObject_New (type_object, &type_object_type);
if (type_obj)
- set_type (type_obj, type);
+ {
+ type_obj->type = type;
+ typy_link (type_obj);
+ }
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
return (PyObject *) type_obj;
}
2010-11-17 02:58:16 +00:00
@@ -1074,6 +1120,8 @@ gdbpy_initialize_types (void)
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
Py_INCREF (&field_object_type);
PyModule_AddObject (gdb_module, "Field", (PyObject *) &field_object_type);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ observer_attach_mark_used (typy_types_mark_used);
}
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
2010-11-17 02:58:16 +00:00
index 4445655..8b06fd8 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
2010-11-17 02:58:16 +00:00
@@ -28,6 +28,7 @@
#include "infcall.h"
#include "expression.h"
#include "cp-abi.h"
2010-07-21 21:30:20 +00:00
+#include "observer.h"
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
#ifdef HAVE_PYTHON
2010-02-03 06:05:13 +00:00
2010-11-17 02:58:16 +00:00
@@ -1220,6 +1221,17 @@ gdbpy_is_value_object (PyObject *obj)
return PyObject_TypeCheck (obj, &value_object_type);
}
2010-07-22 10:49:58 +00:00
2010-11-17 02:58:16 +00:00
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+static void
+python_types_mark_used (void)
2010-07-22 10:49:58 +00:00
+{
2010-11-17 02:58:16 +00:00
+ value_object *iter;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ for (iter = values_in_python; iter; iter = iter->next)
+ type_mark_used (value_type (iter->value));
2010-07-22 10:49:58 +00:00
+}
+
2010-11-17 02:58:16 +00:00
void
gdbpy_initialize_values (void)
{
@@ -1230,6 +1242,8 @@ gdbpy_initialize_values (void)
PyModule_AddObject (gdb_module, "Value", (PyObject *) &value_object_type);
values_in_python = NULL;
2010-07-22 10:49:58 +00:00
+
2010-11-17 02:58:16 +00:00
+ observer_attach_mark_used (python_types_mark_used);
}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
2010-11-17 02:58:16 +00:00
index db21360..1897d10 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
2010-11-17 02:58:16 +00:00
@@ -1276,7 +1276,8 @@ svr4_in_dynsym_resolve_code (CORE_ADDR pc)
2010-07-21 21:30:20 +00:00
&& pc < info->interp_text_sect_high)
|| (pc >= info->interp_plt_sect_low
&& pc < info->interp_plt_sect_high)
- || in_plt_section (pc, NULL));
+ || in_plt_section (pc, NULL)
+ || in_gnu_ifunc_stub (pc));
}
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
/* Given an executable's ABFD and target, compute the entry-point
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
2010-11-17 02:58:16 +00:00
index ef63216..1cc9082 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
2010-11-17 02:58:16 +00:00
@@ -264,6 +264,9 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
2010-07-21 21:30:20 +00:00
case mst_text:
ms_type = 'T';
break;
+ case mst_text_gnu_ifunc:
+ ms_type = 'i';
+ break;
case mst_solib_trampoline:
ms_type = 'S';
break;
diff --git a/gdb/symtab.c b/gdb/symtab.c
2010-11-17 02:58:16 +00:00
index a6023b9..9d577b0 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
2010-11-17 02:58:16 +00:00
@@ -2988,7 +2988,7 @@ search_symbols (char *regexp, domain_enum kind, int nfiles, char *files[],
static const enum minimal_symbol_type types3[]
2010-07-21 21:30:20 +00:00
= {mst_file_data, mst_solib_trampoline, mst_abs, mst_unknown};
2010-11-17 02:58:16 +00:00
static const enum minimal_symbol_type types4[]
2010-07-21 21:30:20 +00:00
- = {mst_file_bss, mst_text, mst_abs, mst_unknown};
+ = {mst_file_bss, mst_text_gnu_ifunc, mst_abs, mst_unknown};
enum minimal_symbol_type ourtype;
enum minimal_symbol_type ourtype2;
enum minimal_symbol_type ourtype3;
diff --git a/gdb/symtab.h b/gdb/symtab.h
2010-11-17 02:58:16 +00:00
index a4032f8..944dd33 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
2010-11-17 02:58:16 +00:00
@@ -290,6 +290,9 @@ enum minimal_symbol_type
2010-07-21 21:30:20 +00:00
{
mst_unknown = 0, /* Unknown type, the default */
mst_text, /* Generally executable instructions */
+ mst_text_gnu_ifunc, /* Executable code returning address
+ of executable code */
+ mst_slot_got_plt,
mst_data, /* Generally initialized data */
mst_bss, /* Generally uninitialized data */
mst_abs, /* Generally absolute (nonrelocatable) */
2010-11-17 02:58:16 +00:00
@@ -955,11 +958,25 @@ extern struct symbol *find_pc_sect_function (CORE_ADDR, struct obj_section *);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
/* lookup function from address, return name, start addr and end addr */
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
-extern int find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *,
- CORE_ADDR *);
+extern enum find_pc_partial_function_type
+ {
+ FIND_PC_PARTIAL_FUNCTION_NOT_FOUND = 0,
+ FIND_PC_PARTIAL_FUNCTION_NORMAL,
+ FIND_PC_PARTIAL_FUNCTION_GNU_IFUNC
+ } find_pc_partial_function (CORE_ADDR, char **, CORE_ADDR *, CORE_ADDR *);
extern void clear_pc_function_cache (void);
+extern int resolve_gnu_ifunc (const char *function_name,
+ CORE_ADDR *function_addressp);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+extern struct minimal_symbol *resolve_gnu_ifunc_by_cache
+ (const char *function_name);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+extern void gnu_ifunc_record_cache (struct gdbarch *gdbarch,
+ const char *function_name,
+ CORE_ADDR function_address);
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
/* lookup partial symbol table by address and section */
2010-01-21 16:09:11 +00:00
2010-07-21 21:30:20 +00:00
extern struct symtab *find_pc_sect_symtab_via_partial (CORE_ADDR,
2010-11-17 02:58:16 +00:00
@@ -1034,6 +1051,8 @@ extern struct minimal_symbol *lookup_minimal_symbol_by_pc_name
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
extern struct minimal_symbol *lookup_minimal_symbol_by_pc (CORE_ADDR);
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+extern int in_gnu_ifunc_stub (CORE_ADDR pc);
2010-01-16 22:32:10 +00:00
+
2010-07-21 21:30:20 +00:00
extern struct minimal_symbol *
lookup_minimal_symbol_and_objfile (const char *,
struct objfile **);
diff --git a/gdb/target.c b/gdb/target.c
2010-11-17 02:58:16 +00:00
index 5984125..06589d4 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -123,6 +123,8 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
struct expression *);
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
+static int debug_to_detach_watchpoints (void);
2010-01-28 22:26:15 +00:00
+
2010-07-21 21:30:20 +00:00
static int debug_to_stopped_by_watchpoint (void);
2010-01-28 22:26:15 +00:00
2010-07-21 21:30:20 +00:00
static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
@@ -606,6 +608,7 @@ update_current_target (void)
INHERIT (to_remove_hw_breakpoint, t);
INHERIT (to_insert_watchpoint, t);
INHERIT (to_remove_watchpoint, t);
+ INHERIT (to_detach_watchpoints, t);
INHERIT (to_stopped_data_address, t);
INHERIT (to_have_steppable_watchpoint, t);
INHERIT (to_have_continuable_watchpoint, t);
@@ -739,6 +742,9 @@ update_current_target (void)
de_fault (to_remove_watchpoint,
(int (*) (CORE_ADDR, int, int, struct expression *))
return_minus_one);
+ de_fault (to_detach_watchpoints,
+ (int (*) (void))
+ return_zero);
de_fault (to_stopped_by_watchpoint,
(int (*) (void))
return_zero);
2010-11-17 02:58:16 +00:00
@@ -3570,6 +3576,19 @@ debug_to_remove_watchpoint (CORE_ADDR addr, int len, int type,
2010-07-21 21:30:20 +00:00
return retval;
}
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
+static int
+debug_to_detach_watchpoints (void)
+{
+ int retval;
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ retval = debug_target.to_detach_watchpoints ();
2009-08-04 05:37:29 +00:00
+
2010-07-21 21:30:20 +00:00
+ fprintf_unfiltered (gdb_stdlog,
+ "target_detach_watchpoints () = %ld\n",
+ (unsigned long) retval);
+ return retval;
+}
2009-08-18 19:37:35 +00:00
+
static void
2010-07-21 21:30:20 +00:00
debug_to_terminal_init (void)
2009-09-10 21:37:41 +00:00
{
2010-11-17 02:58:16 +00:00
@@ -3817,6 +3836,7 @@ setup_target_debug (void)
2010-07-21 21:30:20 +00:00
current_target.to_remove_hw_breakpoint = debug_to_remove_hw_breakpoint;
current_target.to_insert_watchpoint = debug_to_insert_watchpoint;
current_target.to_remove_watchpoint = debug_to_remove_watchpoint;
+ current_target.to_detach_watchpoints = debug_to_detach_watchpoints;
current_target.to_stopped_by_watchpoint = debug_to_stopped_by_watchpoint;
current_target.to_stopped_data_address = debug_to_stopped_data_address;
current_target.to_watchpoint_addr_within_range = debug_to_watchpoint_addr_within_range;
diff --git a/gdb/target.h b/gdb/target.h
2010-11-17 02:58:16 +00:00
index 7290d90..c026d76 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/target.h
+++ b/gdb/target.h
2010-11-17 02:58:16 +00:00
@@ -445,6 +445,7 @@ struct target_ops
2010-07-21 21:30:20 +00:00
provided with the corresponding target_* macros. */
int (*to_remove_watchpoint) (CORE_ADDR, int, int, struct expression *);
int (*to_insert_watchpoint) (CORE_ADDR, int, int, struct expression *);
+ int (*to_detach_watchpoints) (void);
2009-09-10 21:37:41 +00:00
2010-07-21 21:30:20 +00:00
int (*to_stopped_by_watchpoint) (void);
int to_have_steppable_watchpoint;
2010-11-17 02:58:16 +00:00
@@ -1324,6 +1325,15 @@ extern char *normal_pid_to_str (ptid_t ptid);
2010-07-21 21:30:20 +00:00
#define target_remove_watchpoint(addr, len, type, cond) \
(*current_target.to_remove_watchpoint) (addr, len, type, cond)
2009-09-10 21:37:41 +00:00
2010-07-21 21:30:20 +00:00
+/* Clear all debug registers without affecting any register caches. Function
+ acts on INFERIOR_PTID which should be the forked-off process, either the
+ non-threaded child one or the threaded parent one, depending on `set
+ follow-fork-mode'. Both watchpoints and hardware breakpoints get removed.
+ Return 0 on success, -1 on failure. */
2009-09-10 21:37:41 +00:00
+
2010-07-21 21:30:20 +00:00
+#define target_detach_watchpoints() \
+ (*current_target.to_detach_watchpoints) ()
2009-09-10 21:37:41 +00:00
+
2010-07-21 21:30:20 +00:00
#define target_insert_hw_breakpoint(gdbarch, bp_tgt) \
(*current_target.to_insert_hw_breakpoint) (gdbarch, bp_tgt)
2009-09-10 21:37:41 +00:00
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..83faaf6
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
@@ -0,0 +1,457 @@
+ .file "x86_64-vla-pointer.c"
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .text
+.Ltext0:
+.globl foo
+ .type foo, @function
+foo:
+.LFB2:
+ .file 1 "x86_64-vla-pointer.c"
+ .loc 1 22 0
+ pushq %rbp
+.LCFI0:
+ movq %rsp, %rbp
+.LCFI1:
+ subq $64, %rsp
+.LCFI2:
+ movl %edi, -36(%rbp)
+ .loc 1 22 0
+ movq %rsp, %rax
+ movq %rax, -48(%rbp)
+ .loc 1 23 0
+ movl -36(%rbp), %edx
+ movslq %edx,%rax
+ subq $1, %rax
+ movq %rax, -24(%rbp)
+ .loc 1 24 0
+ movslq %edx,%rax
+ addq $15, %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ subq %rax, %rsp
+ movq %rsp, -56(%rbp)
+ movq -56(%rbp), %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ movq %rax, -56(%rbp)
+ movq -56(%rbp), %rax
+ movq %rax, -16(%rbp)
+ .loc 1 27 0
+ movl $0, -4(%rbp)
+ jmp .L2
+.L3:
+ .loc 1 28 0
+ movl -4(%rbp), %esi
+ movl -4(%rbp), %eax
+ movl %eax, %ecx
+ movq -16(%rbp), %rdx
+ movslq %esi,%rax
+ movb %cl, (%rdx,%rax)
+ .loc 1 27 0
+ addl $1, -4(%rbp)
+.L2:
+ movl -4(%rbp), %eax
+ cmpl -36(%rbp), %eax
+ jl .L3
+ .loc 1 30 0
+ .globl break_here
+break_here:
+ movq -16(%rbp), %rax
+ movb $0, (%rax)
+ movq -48(%rbp), %rsp
+ .loc 1 31 0
+ leave
+ ret
+.LFE2:
+ .size foo, .-foo
+ .section .debug_frame,"",@progbits
+.Lframe0:
+ .long .LECIE0-.LSCIE0
+.LSCIE0:
+ .long 0xffffffff
+ .byte 0x1
+ .string ""
+ .uleb128 0x1
+ .sleb128 -8
+ .byte 0x10
+ .byte 0xc
+ .uleb128 0x7
+ .uleb128 0x8
+ .byte 0x90
+ .uleb128 0x1
+ .align 8
+.LECIE0:
+.LSFDE0:
+ .long .LEFDE0-.LASFDE0
+.LASFDE0:
+ .long .Lframe0
+ .quad .LFB2
+ .quad .LFE2-.LFB2
+ .byte 0x4
+ .long .LCFI0-.LFB2
+ .byte 0xe
+ .uleb128 0x10
+ .byte 0x86
+ .uleb128 0x2
+ .byte 0x4
+ .long .LCFI1-.LCFI0
+ .byte 0xd
+ .uleb128 0x6
+ .align 8
+.LEFDE0:
+ .section .eh_frame,"a",@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1
+.LSCIE1:
+ .long 0x0
+ .byte 0x1
+ .string "zR"
+ .uleb128 0x1
+ .sleb128 -8
+ .byte 0x10
+ .uleb128 0x1
+ .byte 0x3
+ .byte 0xc
+ .uleb128 0x7
+ .uleb128 0x8
+ .byte 0x90
+ .uleb128 0x1
+ .align 8
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1
+.LASFDE1:
+ .long .LASFDE1-.Lframe1
+ .long .LFB2
+ .long .LFE2-.LFB2
+ .uleb128 0x0
+ .byte 0x4
+ .long .LCFI0-.LFB2
+ .byte 0xe
+ .uleb128 0x10
+ .byte 0x86
+ .uleb128 0x2
+ .byte 0x4
+ .long .LCFI1-.LCFI0
+ .byte 0xd
+ .uleb128 0x6
+ .align 8
+.LEFDE1:
+ .text
+.Letext0:
+ .section .debug_loc,"",@progbits
+.Ldebug_loc0:
+.LLST0:
+ .quad .LFB2-.Ltext0
+ .quad .LCFI0-.Ltext0
+ .value 0x2
+ .byte 0x77
+ .sleb128 8
+ .quad .LCFI0-.Ltext0
+ .quad .LCFI1-.Ltext0
+ .value 0x2
+ .byte 0x77
+ .sleb128 16
+ .quad .LCFI1-.Ltext0
+ .quad .LFE2-.Ltext0
+ .value 0x2
+ .byte 0x76
+ .sleb128 16
+ .quad 0x0
+ .quad 0x0
+ .section .debug_info
+.Ldebug_relative:
+ .long .Ldebug_end - .Ldebug_start
+.Ldebug_start:
+ .value 0x2
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .LASF2
+ .byte 0x1
+ .long .LASF3
+ .long .LASF4
+ .quad .Ltext0
+ .quad .Letext0
+ .long .Ldebug_line0
+ .uleb128 0x2
+ .byte 0x1
+ .string "foo"
+ .byte 0x1
+ .byte 0x16
+ .byte 0x1
+ .quad .LFB2
+ .quad .LFE2
+ .long .LLST0
+ .long .Ltype_int - .Ldebug_relative
+ .uleb128 0x3
+ .long .LASF5
+ .byte 0x1
+ .byte 0x15
+ .long .Ltype_int - .Ldebug_relative
+ .byte 0x2
+ .byte 0x91
+ .sleb128 -52
+.Ltag_pointer:
+ .uleb128 0x4
+ .byte 0x8 /* DW_AT_byte_size */
+ .long .Ltag_array_type - .debug_info /* DW_AT_type */
+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
+ .long .LASF0
+ .byte 0x1
+ .byte 0x18
+#if 1
+ .long .Ltag_pointer - .debug_info
+#else
+ /* Debugging only: Skip the typedef indirection. */
+ .long .Ltag_array_type - .debug_info
+#endif
+ /* DW_AT_location: DW_FORM_block1: start */
+ .byte 0x3
+ .byte 0x91
+ .sleb128 -32
+#if 0
+ .byte 0x6 /* DW_OP_deref */
+#else
+ .byte 0x96 /* DW_OP_nop */
+#endif
+ /* DW_AT_location: DW_FORM_block1: end */
+ .uleb128 0x6
+ .string "i"
+ .byte 0x1
+ .byte 0x19
+ .long .Ltype_int - .Ldebug_relative
+ .byte 0x2
+ .byte 0x91
+ .sleb128 -20
+ .byte 0x0
+.Ltype_int:
+ .uleb128 0x7
+ .byte 0x4
+ .byte 0x5
+ .string "int"
+.Ltag_array_type:
+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
+ .long .Ltype_char - .Ldebug_relative
+ .long .Ltype_ulong - .Ldebug_relative /* DW_AT_sibling: DW_FORM_ref4 */
+1: /* DW_AT_data_location: DW_FORM_block1: start */
+ .byte 2f - 3f /* length */
+3:
+ .byte 0x97 /* DW_OP_push_object_address */
+#if 1
+ .byte 0x6 /* DW_OP_deref */
+#else
+ .byte 0x96 /* DW_OP_nop */
+#endif
+2: /* DW_AT_data_location: DW_FORM_block1: end */
+ .uleb128 0x9
+ .long .Ltype_char - .Ldebug_relative /* DW_AT_type: DW_FORM_ref4 */
+ .byte 0x3
+ .byte 0x91
+ .sleb128 -40
+ .byte 0x6
+ .byte 0x0
+.Ltype_ulong:
+ .uleb128 0xa
+ .byte 0x8
+ .byte 0x7
+.Ltype_char:
+ .uleb128 0xb
+ .byte 0x1
+ .byte 0x6
+ .long .LASF1
+ .byte 0x0
+.Ldebug_end:
+ .section .debug_abbrev
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x1b
+ .uleb128 0xe
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x10
+ .uleb128 0x6
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0xc
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0xc
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x6
+ .uleb128 0x1
+ .uleb128 0x13
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x5
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x4 /* .Ltag_pointer abbrev */
+ .uleb128 0x0f /* DW_TAG_pointer_type */
+ .byte 0x0
+ .uleb128 0x0b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x5
+ .uleb128 0x34
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x6
+ .uleb128 0x34
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x7
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
+ .uleb128 0x1
+ .byte 0x1
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x1 /* DW_AT_sibling */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x50 /* DW_AT_data_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x9
+ .uleb128 0x21
+ .byte 0x0
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x2f
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0xa
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .byte 0x0
+ .byte 0x0
+ .byte 0x0
+ .section .debug_pubnames,"",@progbits
+ .long 0x16
+ .value 0x2
+ .long .Ldebug_info0
+ .long 0xa8
+ .long 0x2d
+ .string "foo"
+ .long 0x0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0x0
+ .value 0x0
+ .value 0x0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0x0
+ .quad 0x0
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "array"
+.LASF5:
+ .string "size"
+.LASF3:
+ .string "x86_64-vla-pointer.c"
+.LASF6:
+ .string "array_t"
+.LASF1:
+ .string "char"
+.LASF4:
+ .string "gdb.arch"
+.LASF2:
+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..fe2c8f7
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2009 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+#if 0
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+void
+foo (int size)
2010-01-21 16:09:11 +00:00
+{
2010-07-21 21:30:20 +00:00
+ typedef char array_t[size];
+ array_t array;
+ int i;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ for (i = 0; i < size; i++)
+ array[i] = i;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ array[0] = 0; /* break-here */
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+#else
+
2010-01-21 16:09:11 +00:00
+int
2010-07-21 21:30:20 +00:00
+main (void)
2010-01-21 16:09:11 +00:00
+{
2010-07-21 21:30:20 +00:00
+ foo (26);
+ foo (78);
+ return 0;
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
+
+#endif
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..d243cf1
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
@@ -0,0 +1,66 @@
+# Copyright 2009 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
2010-07-21 21:30:20 +00:00
+if ![istarget "x86_64-*-*"] then {
+ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
+ return
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+set testfile x86_64-vla-pointer
+set srcasmfile ${testfile}-foo.S
+set srcfile ${testfile}.c
2010-01-21 16:09:11 +00:00
+set binfile ${objdir}/${subdir}/${testfile}
2010-07-21 21:30:20 +00:00
+set binobjfile ${objdir}/${subdir}/${testfile}-foo.o
+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
2010-01-21 16:09:11 +00:00
+ untested "Couldn't compile test program"
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
2010-07-21 21:30:20 +00:00
+if ![runto_main] {
+ untested x86_64-vla-pointer
+ return -1
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+gdb_breakpoint "break_here"
+
+gdb_continue_to_breakpoint "break_here"
+
+gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "first: whatis array"
+gdb_test "ptype array" "type = char \\(\\*\\)\\\[26\\\]" "first: ptype array"
+
+gdb_test "whatis *array" "type = char \\\[26\\\]" "first: whatis *array"
+gdb_test "ptype *array" "type = char \\\[26\\\]" "first: ptype *array"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "p (*array)\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
+gdb_test "p (*array)\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
+gdb_test "p (*array)\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
+gdb_test "p (*array)\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_continue_to_breakpoint "break_here"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "whatis array" "type = char \\(\\*\\)\\\[variable\\\]" "second: whatis array"
+gdb_test "ptype array" "type = char \\(\\*\\)\\\[78\\\]" "second: ptype array"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "whatis *array" "type = char \\\[78\\\]" "second: whatis *array"
+gdb_test "ptype *array" "type = char \\\[78\\\]" "second: ptype *array"
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
new file mode 100644
index 0000000..66f7a39
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
@@ -0,0 +1,455 @@
+ .file "x86_64-vla-typedef.c"
+ .section .debug_abbrev,"",@progbits
+.Ldebug_abbrev0:
+ .section .debug_info,"",@progbits
+.Ldebug_info0:
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .text
+.Ltext0:
+.globl foo
+ .type foo, @function
+foo:
+.LFB2:
+ .file 1 "x86_64-vla-typedef.c"
+ .loc 1 22 0
+ pushq %rbp
+.LCFI0:
+ movq %rsp, %rbp
+.LCFI1:
+ subq $64, %rsp
+.LCFI2:
+ movl %edi, -36(%rbp)
+ .loc 1 22 0
+ movq %rsp, %rax
+ movq %rax, -48(%rbp)
+ .loc 1 23 0
+ movl -36(%rbp), %edx
+ movslq %edx,%rax
+ subq $1, %rax
+ movq %rax, -24(%rbp)
+ .loc 1 24 0
+ movslq %edx,%rax
+ addq $15, %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ subq %rax, %rsp
+ movq %rsp, -56(%rbp)
+ movq -56(%rbp), %rax
+ addq $15, %rax
+ shrq $4, %rax
+ salq $4, %rax
+ movq %rax, -56(%rbp)
+ movq -56(%rbp), %rax
+ movq %rax, -16(%rbp)
+ .loc 1 27 0
+ movl $0, -4(%rbp)
+ jmp .L2
+.L3:
+ .loc 1 28 0
+ movl -4(%rbp), %esi
+ movl -4(%rbp), %eax
+ movl %eax, %ecx
+ movq -16(%rbp), %rdx
+ movslq %esi,%rax
+ movb %cl, (%rdx,%rax)
+ .loc 1 27 0
+ addl $1, -4(%rbp)
+.L2:
+ movl -4(%rbp), %eax
+ cmpl -36(%rbp), %eax
+ jl .L3
+ .loc 1 30 0
+ .globl break_here
+break_here:
+ movq -16(%rbp), %rax
+ movb $0, (%rax)
+ movq -48(%rbp), %rsp
+ .loc 1 31 0
+ leave
+ ret
+.LFE2:
+ .size foo, .-foo
+ .section .debug_frame,"",@progbits
+.Lframe0:
+ .long .LECIE0-.LSCIE0
+.LSCIE0:
+ .long 0xffffffff
+ .byte 0x1
+ .string ""
+ .uleb128 0x1
+ .sleb128 -8
+ .byte 0x10
+ .byte 0xc
+ .uleb128 0x7
+ .uleb128 0x8
+ .byte 0x90
+ .uleb128 0x1
+ .align 8
+.LECIE0:
+.LSFDE0:
+ .long .LEFDE0-.LASFDE0
+.LASFDE0:
+ .long .Lframe0
+ .quad .LFB2
+ .quad .LFE2-.LFB2
+ .byte 0x4
+ .long .LCFI0-.LFB2
+ .byte 0xe
+ .uleb128 0x10
+ .byte 0x86
+ .uleb128 0x2
+ .byte 0x4
+ .long .LCFI1-.LCFI0
+ .byte 0xd
+ .uleb128 0x6
+ .align 8
+.LEFDE0:
+ .section .eh_frame,"a",@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1
+.LSCIE1:
+ .long 0x0
+ .byte 0x1
+ .string "zR"
+ .uleb128 0x1
+ .sleb128 -8
+ .byte 0x10
+ .uleb128 0x1
+ .byte 0x3
+ .byte 0xc
+ .uleb128 0x7
+ .uleb128 0x8
+ .byte 0x90
+ .uleb128 0x1
+ .align 8
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1
+.LASFDE1:
+ .long .LASFDE1-.Lframe1
+ .long .LFB2
+ .long .LFE2-.LFB2
+ .uleb128 0x0
+ .byte 0x4
+ .long .LCFI0-.LFB2
+ .byte 0xe
+ .uleb128 0x10
+ .byte 0x86
+ .uleb128 0x2
+ .byte 0x4
+ .long .LCFI1-.LCFI0
+ .byte 0xd
+ .uleb128 0x6
+ .align 8
+.LEFDE1:
+ .text
+.Letext0:
+ .section .debug_loc,"",@progbits
+.Ldebug_loc0:
+.LLST0:
+ .quad .LFB2-.Ltext0
+ .quad .LCFI0-.Ltext0
+ .value 0x2
+ .byte 0x77
+ .sleb128 8
+ .quad .LCFI0-.Ltext0
+ .quad .LCFI1-.Ltext0
+ .value 0x2
+ .byte 0x77
+ .sleb128 16
+ .quad .LCFI1-.Ltext0
+ .quad .LFE2-.Ltext0
+ .value 0x2
+ .byte 0x76
+ .sleb128 16
+ .quad 0x0
+ .quad 0x0
+ .section .debug_info
+ .long .Ldebug_end - .Ldebug_start
+.Ldebug_start:
+ .value 0x2
+ .long .Ldebug_abbrev0
+ .byte 0x8
+ .uleb128 0x1
+ .long .LASF2
+ .byte 0x1
+ .long .LASF3
+ .long .LASF4
+ .quad .Ltext0
+ .quad .Letext0
+ .long .Ldebug_line0
+ .uleb128 0x2
+ .byte 0x1
+ .string "foo"
+ .byte 0x1
+ .byte 0x16
+ .byte 0x1
+ .quad .LFB2
+ .quad .LFE2
+ .long .LLST0
+ .long 0x83
+ .uleb128 0x3
+ .long .LASF5
+ .byte 0x1
+ .byte 0x15
+ .long 0x83
+ .byte 0x2
+ .byte 0x91
+ .sleb128 -52
+.Ltag_typedef:
+ .uleb128 0x4
+ .long .LASF6
+ .byte 0x1
+ .byte 0x17
+ .long .Ltag_array_type - .debug_info
+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
+ .long .LASF0
+ .byte 0x1
+ .byte 0x18
+#if 1
+ .long .Ltag_typedef - .debug_info
+#else
+ /* Debugging only: Skip the typedef indirection. */
+ .long .Ltag_array_type - .debug_info
+#endif
+ /* DW_AT_location: DW_FORM_block1: start */
+ .byte 0x3
+ .byte 0x91
+ .sleb128 -32
+#if 0
+ .byte 0x6 /* DW_OP_deref */
+#else
+ .byte 0x96 /* DW_OP_nop */
+#endif
+ /* DW_AT_location: DW_FORM_block1: end */
+ .uleb128 0x6
+ .string "i"
+ .byte 0x1
+ .byte 0x19
+ .long 0x83
+ .byte 0x2
+ .byte 0x91
+ .sleb128 -20
+ .byte 0x0
+ .uleb128 0x7
+ .byte 0x4
+ .byte 0x5
+ .string "int"
+.Ltag_array_type:
+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
+1: /* DW_AT_data_location: DW_FORM_block1: start */
+ .byte 2f - 3f /* length */
+3:
+ .byte 0x97 /* DW_OP_push_object_address */
+ .byte 0x6 /* DW_OP_deref */
+2: /* DW_AT_data_location: DW_FORM_block1: end */
+ .uleb128 0x9
+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
+ .byte 0x3
+ .byte 0x91
+ .sleb128 -40
+ .byte 0x6
+ .byte 0x0
+ .uleb128 0xa
+ .byte 0x8
+ .byte 0x7
+ .uleb128 0xb
+ .byte 0x1
+ .byte 0x6
+ .long .LASF1
+ .byte 0x0
+.Ldebug_end:
+ .section .debug_abbrev
+ .uleb128 0x1
+ .uleb128 0x11
+ .byte 0x1
+ .uleb128 0x25
+ .uleb128 0xe
+ .uleb128 0x13
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x1b
+ .uleb128 0xe
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x10
+ .uleb128 0x6
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x2
+ .uleb128 0x2e
+ .byte 0x1
+ .uleb128 0x3f
+ .uleb128 0xc
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x27
+ .uleb128 0xc
+ .uleb128 0x11
+ .uleb128 0x1
+ .uleb128 0x12
+ .uleb128 0x1
+ .uleb128 0x40
+ .uleb128 0x6
+ .uleb128 0x1
+ .uleb128 0x13
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x5
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x4
+ .uleb128 0x16
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x5
+ .uleb128 0x34
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0xe
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x6
+ .uleb128 0x34
+ .byte 0x0
+ .uleb128 0x3
+ .uleb128 0x8
+ .uleb128 0x3a
+ .uleb128 0xb
+ .uleb128 0x3b
+ .uleb128 0xb
+ .uleb128 0x49
+ .uleb128 0x13
+ .uleb128 0x2
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x7
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0x8
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
+ .uleb128 0x1
+ .byte 0x1
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x1 /* DW_AT_sibling */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x50 /* DW_AT_data_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0x9
+ .uleb128 0x21
+ .byte 0x0
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x2f
+ .uleb128 0xa
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0xa
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .byte 0x0
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0x24
+ .byte 0x0
+ .uleb128 0xb
+ .uleb128 0xb
+ .uleb128 0x3e
+ .uleb128 0xb
+ .uleb128 0x3
+ .uleb128 0xe
+ .byte 0x0
+ .byte 0x0
+ .byte 0x0
+ .section .debug_pubnames,"",@progbits
+ .long 0x16
+ .value 0x2
+ .long .Ldebug_info0
+ .long 0xa8
+ .long 0x2d
+ .string "foo"
+ .long 0x0
+ .section .debug_aranges,"",@progbits
+ .long 0x2c
+ .value 0x2
+ .long .Ldebug_info0
+ .byte 0x8
+ .byte 0x0
+ .value 0x0
+ .value 0x0
+ .quad .Ltext0
+ .quad .Letext0-.Ltext0
+ .quad 0x0
+ .quad 0x0
+ .section .debug_str,"MS",@progbits,1
+.LASF0:
+ .string "array"
+.LASF5:
+ .string "size"
+.LASF3:
+ .string "x86_64-vla-typedef.c"
+.LASF6:
+ .string "array_t"
+.LASF1:
+ .string "char"
+.LASF4:
+ .string "gdb.arch"
+.LASF2:
+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..b809c4e
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
@@ -0,0 +1,43 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2008 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+#if 0
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+void
+foo (int size)
+{
+ typedef char array_t[size];
+ array_t array;
+ int i;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ for (i = 0; i < size; i++)
+ array[i] = i;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ array[0] = 0; /* break-here */
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+#else
2010-01-21 16:09:11 +00:00
+
+int
2010-07-21 21:30:20 +00:00
+main (void)
2010-01-21 16:09:11 +00:00
+{
2010-07-21 21:30:20 +00:00
+ foo (26);
+ foo (78);
+ return 0;
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
+
+#endif
diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..b05411e
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
@@ -0,0 +1,64 @@
+# Copyright 2009 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
2010-07-21 21:30:20 +00:00
+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+if ![istarget "x86_64-*-*"] then {
+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
+ return
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set testfile x86_64-vla-typedef
+set srcasmfile ${testfile}-foo.S
+set srcfile ${testfile}.c
2010-01-21 16:09:11 +00:00
+set binfile ${objdir}/${subdir}/${testfile}
2010-07-21 21:30:20 +00:00
+set binobjfile ${objdir}/${subdir}/${testfile}-foo.o
+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
2010-01-21 16:09:11 +00:00
+ untested "Couldn't compile test program"
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
2010-07-21 21:30:20 +00:00
+if ![runto_main] {
+ untested x86_64-vla-typedef
+ return -1
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+gdb_breakpoint "break_here"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_continue_to_breakpoint "break_here"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "whatis array" "type = array_t" "first: whatis array"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_continue_to_breakpoint "break_here"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "whatis array" "type = array_t" "second: whatis array"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
index ecc3289..f79ad40 100644
--- a/gdb/testsuite/gdb.base/arrayidx.c
+++ b/gdb/testsuite/gdb.base/arrayidx.c
@@ -17,6 +17,13 @@
int array[] = {1, 2, 3, 4};
+#ifdef __GNUC__
+struct
+ {
+ int a[0];
+ } unbound;
+#endif
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
int
main (void)
{
diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
index 3a33618..f2e11dd 100644
--- a/gdb/testsuite/gdb.base/arrayidx.exp
+++ b/gdb/testsuite/gdb.base/arrayidx.exp
@@ -57,4 +57,12 @@ gdb_test "print array" \
"\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
"Print array with array-indexes on"
-
+set test "p unbound.a == &unbound.a\[0\]"
+gdb_test_multiple $test $test {
+ -re " = 1\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
+ unsupported "$test (no GCC)"
+ }
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc-lib.c b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..680530a
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.base/gnu-ifunc-lib.c
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2009, 2010 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+extern volatile int gnu_ifunc_initialized;
+extern int init_stub (int arg);
+extern int final (int arg);
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+typedef int (*final_t) (int arg);
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+asm (".type gnu_ifunc, @gnu_indirect_function");
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+final_t
+gnu_ifunc (void)
+{
+ if (! gnu_ifunc_initialized)
+ return init_stub;
+ else
+ return final;
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.c b/gdb/testsuite/gdb.base/gnu-ifunc.c
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..106271f
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.c
@@ -0,0 +1,61 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2009, 2010 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+#include <assert.h>
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+int
+init_stub (int arg)
+{
+ return 0;
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+int
+final (int arg)
+{
+ return arg + 1;
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+/* Make differentiation of how the gnu_ifunc call resolves before and after
+ calling gnu_ifunc_pre. This ensures the resolved function address is not
+ being cached anywhere for the debugging purposes. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+volatile int gnu_ifunc_initialized;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+static void
+gnu_ifunc_pre (void)
+{
+ assert (!gnu_ifunc_initialized);
+
+ gnu_ifunc_initialized = 1;
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+extern int gnu_ifunc (int arg);
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+int
+main (void)
+{
+ int i;
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ gnu_ifunc_pre ();
+
+ i = gnu_ifunc (1); /* break-at-call */
+ assert (i == 2);
+
+ gnu_ifunc (2); /* break-at-nextcall */
+
+ return 0; /* break-at-exit */
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.base/gnu-ifunc.exp b/gdb/testsuite/gdb.base/gnu-ifunc.exp
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..8ecf558
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.base/gnu-ifunc.exp
@@ -0,0 +1,110 @@
+# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
2010-07-21 21:30:20 +00:00
+if {[skip_shlib_tests]} {
+ return 0
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+set testfile "gnu-ifunc"
+set srcfile ${testfile}.c
2010-01-21 16:09:11 +00:00
+set binfile ${objdir}/${subdir}/${testfile}
2010-07-21 21:30:20 +00:00
+
+set libfile "${testfile}-lib"
+set libsrc ${libfile}.c
+set lib_so ${objdir}/${subdir}/${libfile}.so
+
+# We need DWARF for the "final" function as we "step" into the function and GDB
+# would step-over the "final" function if there would be no line number debug
+# information (DWARF) available.
+#
+# We must not have DWARF for the "gnu_ifunc" function as DWARF has no way to
+# express the gnu-ifunc type and it would be considered as a regular function
+# due to DWARF by GDB. In ELF gnu-ifunc is expressed by the STT_GNU_IFUNC type.
+#
+# Both functions need to be in the same shared library file but
+# gdb_compile_shlib has no way to specify source-specific compilation options.
+#
+# Therefore $libfile contains only the gnu-ifunc function with no DWARF
+# referencing all the other parts from the main executable with DWARF.
+
+set lib_opts {}
+set exec_opts [list debug shlib=$lib_so]
+
+if [get_compiler_info ${binfile}] {
2010-01-21 16:09:11 +00:00
+ return -1
+}
+
2010-07-21 21:30:20 +00:00
+if { [gdb_compile_shlib ${srcdir}/${subdir}/$libsrc $lib_so $lib_opts] != ""
+ || [gdb_compile ${srcdir}/${subdir}/$srcfile $binfile executable $exec_opts] != ""} {
+ untested "Could not compile either $libsrc or $srcfile."
+ return -1
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+# Start with a fresh gdb.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+clean_restart $testfile
+gdb_load_shlibs ${lib_so}
2010-01-21 16:09:11 +00:00
+
+if ![runto_main] then {
2010-07-21 21:30:20 +00:00
+ fail "Can't run to main"
+ return 1;
2010-01-21 16:09:11 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+# The "if" condition is artifical to test regression of a former patch.
+gdb_breakpoint "[gdb_get_line_number "break-at-nextcall"] if i && gnu_ifunc (i) != 42"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_breakpoint [gdb_get_line_number "break-at-call"]
+gdb_continue_to_breakpoint "break-at-call" ".*break-at-call.*"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Test GDB will automatically indirect the call.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "p gnu_ifunc (3)" " = 4"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Test GDB will skip the gnu_ifunc resolver on first call.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "step" "\r\nfinal .*"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Test GDB will not break before the final chosen implementation.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Also test a former patch regression:
+# Continuing.
+# Error in testing breakpoint condition:
+# Attempt to take address of value not located in memory.
+#
+# Breakpoint 2, main () at ./gdb.base/gnu-ifunc.c:33
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "continue" "Continuing.\r\n\r\nBreakpoint .* (at|in) .*break-at-nextcall.*" \
+ "continue to break-at-nextcall"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_breakpoint "gnu_ifunc"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_continue_to_breakpoint "nextcall gnu_ifunc"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "frame" "#0 +(0x\[0-9a-f\]+ in +)?final \\(.*" "nextcall gnu_ifunc skipped"
2010-01-21 16:09:11 +00:00
+
+
2010-07-21 21:30:20 +00:00
+# Check any commands not doing an inferior call still compute with address of
+# the gnu-ifunc resolver.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "p gnu_ifunc" " = {<text gnu-indirect-function variable, no debug info>} 0x\[0-9a-f\]+ <gnu_ifunc>" "p gnu_ifunc executing"
+gdb_test "info sym gnu_ifunc" "gnu_ifunc in section .*" "info sym gnu_ifunc executing"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set test "info addr gnu_ifunc"
+gdb_test_multiple $test $test {
+ -re "Symbol \"gnu_ifunc\" is at (0x\[0-9a-f\]+) in .*$gdb_prompt $" {
+ pass $test
+ }
+}
+gdb_test "info sym $expect_out(1,string)" "gnu_ifunc in section .*" "info sym <gnu_ifunc-address>"
diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
new file mode 100644
index 0000000..eeb7b85
--- /dev/null
+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
@@ -0,0 +1,20 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2009 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+struct {
+ int field;
+} staticstruct = { 1 };
diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
new file mode 100644
index 0000000..6d82e73
--- /dev/null
+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
@@ -0,0 +1,26 @@
+# Copyright 2009 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set test internal-var-field-address
+set binfile ${test}.x
+if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "${objdir}/${subdir}/${binfile}" object {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+clean_restart $binfile
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test {set $varstruct = staticstruct}
+gdb_test {p $varstruct.field} " = 1"
diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
new file mode 100644
index 0000000..c5d5ee0
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-overflow.c
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2008 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+#include <stdlib.h>
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+int
+main (int argc, char **argv)
+{
+ int array[argc];
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ array[0] = array[0];
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ abort ();
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
new file mode 100644
index 0000000..24a608f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-overflow.exp
@@ -0,0 +1,109 @@
+# Copyright 2008 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# We could crash in:
+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
+# ...
+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
+# ...
+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set testfile vla-overflow
+set shfile ${objdir}/${subdir}/${testfile}-gdb.sh
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
+ return -1
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set f [open "|getconf PAGESIZE" "r"]
+gets $f pagesize
+close $f
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+if { [runto_main] < 0 } {
+ untested vla-overflow
+ return -1
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Get the GDB memory size when we stay at main.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+proc memory_v_pages_get {} {
+ global pid_of_gdb pagesize
+ set fd [open "/proc/$pid_of_gdb/statm"]
+ gets $fd line
+ close $fd
+ # number of pages of virtual memory
+ scan $line "%d" drs
+ return $drs
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set pages_found [memory_v_pages_get]
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
+set mb_reserve 40
+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
+set kb_found [expr $pages_found * $pagesize / 1024]
+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Create the ulimit wrapper.
+set f [open $shfile "w"]
+puts $f "#! /bin/sh"
+puts $f "ulimit -v $kb_permit"
+puts $f "exec $GDB \"\$@\""
+close $f
+remote_exec host "chmod +x $shfile"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_exit
+set GDBold $GDB
+set GDB "$shfile"
+gdb_start
+set GDB $GDBold
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+set pid_of_gdb [exp_pid -i [board_info host fileid]]
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# Check the size again after the second run.
+# We must not stop in main as it would cache `array' and never crash later.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_run_cmd
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+# `abort' can get expressed as `*__GI_abort'.
+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
new file mode 100644
index 0000000..e1f3ed1
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla.c
@@ -0,0 +1,55 @@
+/* This testcase is part of GDB, the GNU debugger.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ Copyright 2008 Free Software Foundation, Inc.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+#include <string.h>
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+void
+marker (void)
2010-01-21 16:09:11 +00:00
+{
2010-07-21 21:30:20 +00:00
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+void
+bar (char *a, char *b, char *c, int size)
+{
+ memset (a, '1', size);
+ memset (b, '2', size);
+ memset (c, '3', 48);
+}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+void
+foo (int size)
2010-01-21 16:09:11 +00:00
+{
2010-07-21 21:30:20 +00:00
+ char temp1[size];
+ char temp3[48];
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ temp1[size - 1] = '\0';
+ {
+ char temp2[size];
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ bar (temp1, temp2, temp3, size);
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+ marker (); /* break-here */
+ }
+}
2010-01-21 16:09:11 +00:00
+
+int
2010-07-21 21:30:20 +00:00
+main (void)
+{
+ foo (26);
+ foo (78);
+ return 0;
2010-01-21 16:09:11 +00:00
+}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
2010-01-21 16:09:11 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..5da7378
2010-01-21 16:09:11 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.base/vla.exp
@@ -0,0 +1,62 @@
2010-01-21 16:09:11 +00:00
+# Copyright 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
2010-11-17 02:58:16 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-01-21 16:09:11 +00:00
+
2010-11-17 02:58:16 +00:00
+set testfile vla
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "Couldn't compile test program"
2010-07-21 21:30:20 +00:00
+ return -1
2010-01-21 16:09:11 +00:00
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
2010-11-17 02:58:16 +00:00
+if ![runto_main] {
+ untested vla
2010-07-21 21:30:20 +00:00
+ return -1
2010-01-28 22:26:15 +00:00
+}
+
2010-11-17 02:58:16 +00:00
+gdb_breakpoint [gdb_get_line_number "break-here"]
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_continue_to_breakpoint "break-here"
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "first: whatis temp1"
+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "first: whatis temp2"
+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
+gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
+gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_continue_to_breakpoint "break-here"
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "whatis temp1" "type = char \\\[variable\\\]" "second: whatis temp1"
+gdb_test "whatis temp2" "type = char \\\[variable\\\]" "second: whatis temp2"
+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
+gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
+gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.c b/gdb/testsuite/gdb.base/watchpoint-delete.c
new file mode 100644
index 0000000..031ef92
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-delete.c
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+ Copyright 2010 Free Software Foundation, Inc.
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+void
+func (void)
+{
+ volatile int x = 0;
2010-01-16 22:32:10 +00:00
+
2010-11-17 02:58:16 +00:00
+ x++; /* break-here */
+ x++;
+}
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+int
+main (void)
+{
+ func ();
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/watchpoint-delete.exp b/gdb/testsuite/gdb.base/watchpoint-delete.exp
new file mode 100644
index 0000000..45bc650
--- /dev/null
+++ b/gdb/testsuite/gdb.base/watchpoint-delete.exp
@@ -0,0 +1,38 @@
+# Copyright 2010 Free Software Foundation, Inc.
2009-08-04 05:37:29 +00:00
+
2010-11-17 02:58:16 +00:00
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2009-03-07 00:32:30 +00:00
+
2010-11-17 02:58:16 +00:00
+set testfile "watchpoint-delete"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
+ untested ${testfile}.exp
+ return -1
+}
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+# It is more compatible this way.
+gdb_test_no_output "set can-use-hw-watchpoints 0"
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+if ![runto_main] {
+ return -1
+}
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+# Ensure there is a parent frame to create related bp_watchpoint_scope.
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here" ".* break-here .*"
2010-07-21 21:30:20 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test "watch x" {Watchpoint [0-9]+: x}
2009-03-02 00:11:35 +00:00
+
2010-11-17 02:58:16 +00:00
+gdb_test_no_output {delete $bpnum}
2010-07-11 18:06:33 +00:00
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..7fb00ea
2010-07-11 18:06:33 +00:00
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
2010-07-21 21:30:20 +00:00
@@ -0,0 +1,212 @@
2010-07-11 18:06:33 +00:00
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2010 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Debug information */
+
+/* We will `break *main' at the very first instruction. */
+#define main_length 1
+
+ .section .data
+vardata:
+ /* See DW_OP_lit3 + 1 (0-based). */
+ .string "seennotseen"
+
+ .section .debug_info
+.Lcu1_begin:
+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
+.Lcu1_start:
+ .2byte 2 /* DWARF version number */
+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
+ .byte 4 /* Pointer Size (in bytes) */
+
+ /* CU die */
+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
+ .4byte .Lproducer /* DW_AT_producer */
+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */
+ .byte 4 /* DW_AT_language (C++) - */
+ .4byte main /* DW_AT_low_pc */
+ .byte main_length /* DW_AT_high_pc */
+
+.Larray_type:
+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
+
+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
+ .byte 0 /* DW_AT_lower_bound */
+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
+ .byte 0 /* End of children of die */
+
2010-07-21 21:30:20 +00:00
+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
+.Larrayb_type:
+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
+
+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
+ .byte 0 /* DW_AT_lower_bound */
+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
+ .byte 0 /* End of children of die */
+
2010-07-11 18:06:33 +00:00
+.Luint_type:
+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
+ .4byte .Luint_str /* DW_AT_name */
+ .byte 4 /* DW_AT_byte_size */
+ .byte 7 /* DW_AT_encoding */
+
+.Lchar_type:
+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
+ .4byte .Lchar_str /* DW_AT_name */
+ .byte 1 /* DW_AT_byte_size */
+ .byte 6 /* DW_AT_encoding */
+
+.Llen_var:
+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
+ .byte 1 /* DW_AT_artificial */
+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
+
2010-07-21 21:30:20 +00:00
+ /* optimized-out variable for b_string. */
+.Llenb_var:
+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
+ .byte 1 /* DW_AT_artificial */
+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
+
2010-07-11 18:06:33 +00:00
+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
+ .string "a_string" /* DW_AT_name */
2010-07-21 21:30:20 +00:00
+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
+ .byte 2f - 1f /* DW_AT_location */
+1: .byte 3 /* DW_OP_addr */
+ .4byte vardata /* <addr> */
+2:
+
+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
+ .string "b_string" /* DW_AT_name */
+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
2010-07-11 18:06:33 +00:00
+ .byte 2f - 1f /* DW_AT_location */
+1: .byte 3 /* DW_OP_addr */
+ .4byte vardata /* <addr> */
+2:
+
+ .byte 0 /* End of children of CU */
+.Lcu1_end:
+
+ .section .debug_loc
+.Lloclist:
+.Llen_loclist:
+ .4byte 0 # Location list begin address
+ .4byte main_length # Location list end address
+ .value 2f-1f # Location expression size
+1: .byte 0x33 # DW_OP_lit3
+ .byte 0x9f # DW_OP_stack_value
+2:
+ .quad 0x0 # Location list terminator begin (*.LLST2)
+ .quad 0x0 # Location list terminator end (*.LLST2)
+
+ .section .debug_abbrev
+.Ldebug_abbrev0:
+ .uleb128 1 /* Abbrev code */
+ .uleb128 0x11 /* DW_TAG_compile_unit */
+ .byte 0x1 /* has_children */
+ .uleb128 0x25 /* DW_AT_producer */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x13 /* DW_AT_language */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x11 /* DW_AT_low_pc */
+ .uleb128 0x1 /* DW_FORM_addr */
+ .uleb128 0x12 /* DW_AT_high_pc */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 2 /* Abbrev code */
+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
+ .byte 0x1 /* DW_children_yes */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 3 /* Abbrev code */
+ .uleb128 0x21 /* DW_TAG_subrange_type */
+ .byte 0x0 /* no children */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x22 /* DW_AT_lower_bound */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x2f /* DW_AT_upper_bound */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 4 /* Abbrev code */
+ .uleb128 0x24 /* DW_TAG_base_type */
+ .byte 0x0 /* no_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0xb /* DW_AT_byte_size */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3e /* DW_AT_encoding */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 5 /* Abbrev code */
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0 /* no_children */
+ .uleb128 0x34 /* DW_AT_artificial */
+ .uleb128 0x0c /* DW_FORM_flag */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x02 /* DW_AT_location */
+ .uleb128 0x06 /* DW_FORM_data4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
+ .uleb128 6 /* Abbrev code */
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0 /* no_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x2 /* DW_AT_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
2010-07-21 21:30:20 +00:00
+ .uleb128 7 /* Abbrev code */
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0 /* no_children */
+ .uleb128 0x34 /* DW_AT_artificial */
+ .uleb128 0x0c /* DW_FORM_flag */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
+
2010-07-11 18:06:33 +00:00
+ .byte 0x0 /* Terminator */
+
+/* String table */
+ .section .debug_str
+.Lproducer:
+ .string "GNU C 3.3.3"
+.Lchar_str:
+ .string "char"
+.Luint_str:
+ .string "unsigned int"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..5dbed3f
2010-07-11 18:06:33 +00:00
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
2010-07-21 21:30:20 +00:00
@@ -0,0 +1,51 @@
2010-07-11 18:06:33 +00:00
+# Copyright 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test printing variable with dynamic bounds which reference a different
+# (artificial in the GCC case) variable containing loclist as its location.
+# This testcase uses value (not address) of the referenced variable:
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+ && ![istarget *-*-gnu*]
+ && ![istarget *-*-elf*]
+ && ![istarget *-*-openbsd*]
+ && ![istarget arm-*-eabi*]
+ && ![istarget powerpc-*-eabi*]} {
+ return 0
+}
+
+set testfile dw2-bound-loclist
+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
+ return -1
+}
+
+# Verify it behaves at least as an unbound array without inferior.
+
+gdb_test "p a_string" { = 0x[0-9a-f]+ "seennotseen"}
+gdb_test "ptype a_string" {type = char \[\]}
+
+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
+if ![runto "*main"] {
+ return -1
+}
+
+gdb_test "p a_string" { = "seen"}
+gdb_test "ptype a_string" {type = char \[4\]}
2010-01-21 16:09:11 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
+gdb_test "ptype b_string" {type = char \[\]}
2010-01-16 22:32:10 +00:00
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
2009-08-04 05:37:29 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..1f02d90
2009-08-04 05:37:29 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2004 Free Software Foundation, Inc.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
2009-03-02 00:11:35 +00:00
+
+
2010-01-16 22:32:10 +00:00
+/* The function `func1' traced into must have debug info on offset > 0;
+ (DW_UNSND (attr)). This is the reason of `func0' existence. */
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+void
+func0(int a, int b)
+{
+}
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+/* `func1' being traced into must have some arguments to dump. */
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+void
+func1(int a, int b)
+{
+ func0 (a,b);
2009-03-02 00:11:35 +00:00
+}
+
+int
2010-01-16 22:32:10 +00:00
+main(void)
2009-03-02 00:11:35 +00:00
+{
2010-01-16 22:32:10 +00:00
+ func1 (1, 2);
+ return 0;
2009-03-02 00:11:35 +00:00
+}
2010-01-16 22:32:10 +00:00
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
2009-03-02 00:11:35 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..1c6e84a
2009-03-02 00:11:35 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
@@ -0,0 +1,79 @@
+# Copyright 2006 Free Software Foundation, Inc.
2009-03-02 00:11:35 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+# the Free Software Foundation; either version 2 of the License, or
2009-03-02 00:11:35 +00:00
+# (at your option) any later version.
2010-01-16 22:32:10 +00:00
+#
2009-03-02 00:11:35 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+#
2009-03-02 00:11:35 +00:00
+# You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# Minimal DWARF-2 unit test
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# This test can only be run on targets which support DWARF-2.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+ && ![istarget *-*-gnu*]
+ && ![istarget *-*-elf*]
+ && ![istarget *-*-openbsd*]
+ && ![istarget arm-*-eabi*]
+ && ![istarget powerpc-*-eabi*]} {
+ return 0
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+set testfile "dw2-stripped"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}.x
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+remote_exec build "rm -f ${binfile}"
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# get the value of gcc_compiled
+if [get_compiler_info ${binfile}] {
+ return -1
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+# This test can only be run on gcc as we use additional_flags=FIXME
+if {$gcc_compiled == 0} {
+ return 0
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
+ return -1
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+remote_exec build "objcopy -R .debug_loc ${binfile}"
+set strip_output [remote_exec build "objdump -h ${binfile}"]
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+set test "stripping test file preservation"
+if [ regexp ".debug_info " $strip_output] {
+ pass "$test (.debug_info preserved)"
+} else {
+ fail "$test (.debug_info got also stripped)"
2009-08-18 18:51:17 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+set test "stripping test file functionality"
+if [ regexp ".debug_loc " $strip_output] {
+ fail "$test (.debug_loc still present)"
+} else {
+ pass "$test (.debug_loc stripped)"
2009-09-10 21:37:41 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+# For C programs, "start" should stop in main().
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_test "start" \
+ ".*main \\(\\) at .*" \
+ "start"
+gdb_test "step" \
+ "func.* \\(.*\\) at .*" \
+ "step"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
2009-08-10 13:22:51 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..5fcdd84
2009-08-10 13:22:51 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
@@ -0,0 +1,83 @@
+/* This testcase is part of GDB, the GNU debugger.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2009 Free Software Foundation, Inc.
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+/* Debug information */
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ .section .debug_info
+.Lcu1_begin:
+ /* CU header */
+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
+.Lcu1_start:
+ .2byte 2 /* DWARF Version */
+ .4byte .Labbrev1_begin /* Offset into abbrev section */
+ .byte 4 /* Pointer size */
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* CU die */
+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
+ .byte 1 /* DW_AT_language (C) */
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+.Ltype_uchar:
+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */
+ .ascii "some_struct\0" /* DW_AT_name */
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+ .uleb128 3 /* Abbrev: DW_TAG_member */
+ .ascii "field\0" /* DW_AT_name */
+ .byte 0 /* DW_AT_data_member_location */
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+ .byte 0 /* End of children of some_struct */
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+ .byte 0 /* End of children of CU */
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+.Lcu1_end:
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+/* Abbrev table */
+ .section .debug_abbrev
+.Labbrev1_begin:
+ .uleb128 1 /* Abbrev code */
+ .uleb128 0x11 /* DW_TAG_compile_unit */
+ .byte 1 /* has_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x25 /* DW_AT_producer */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x13 /* DW_AT_language */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
2009-08-18 18:51:17 +00:00
+
2010-01-16 22:32:10 +00:00
+ .uleb128 2 /* Abbrev code */
+ .uleb128 0x13 /* DW_TAG_structure_type */
+ .byte 1 /* has_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+ .uleb128 3 /* Abbrev code */
+ .uleb128 0x0d /* DW_TAG_member */
+ .byte 0 /* has_children */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x38 /* DW_AT_data_member_location */
+ .uleb128 0x0b /* DW_FORM_data1 */
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+ .byte 0x0 /* Terminator */
+ .byte 0x0 /* Terminator */
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
2010-01-12 22:15:57 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..c41151c
2010-01-12 22:15:57 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
@@ -0,0 +1,37 @@
+# Copyright 2009 Free Software Foundation, Inc.
2010-01-12 22:15:57 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
2010-01-16 22:32:10 +00:00
+# This test can only be run on targets which support DWARF-2 and use gas.
+# For now pick a sampling of likely targets.
+if {![istarget *-*-linux*]
+ && ![istarget *-*-gnu*]
+ && ![istarget *-*-elf*]
+ && ![istarget *-*-openbsd*]
+ && ![istarget arm-*-eabi*]
+ && ![istarget powerpc-*-eabi*]} {
+ return 0
2010-01-12 22:15:57 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+set testfile "dw2-struct-member-data-location"
+set srcfile ${testfile}.S
+set binfile ${testfile}.x
2010-01-12 22:15:57 +00:00
+
2010-01-16 22:32:10 +00:00
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objdir}/${subdir}/${binfile}" object {nodebug}] != "" } {
2010-01-12 22:15:57 +00:00
+ return -1
+}
+
2010-01-16 22:32:10 +00:00
+clean_restart $binfile
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
2009-09-03 19:45:38 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..cd3486b
2009-09-03 19:45:38 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
@@ -0,0 +1,42 @@
+# Copyright 2009 Free Software Foundation, Inc.
2009-09-03 19:45:38 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+# the Free Software Foundation; either version 2 of the License, or
2009-09-03 19:45:38 +00:00
+# (at your option) any later version.
2010-01-16 22:32:10 +00:00
+#
2009-09-03 19:45:38 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+#
2009-09-03 19:45:38 +00:00
+# You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file is part of the gdb testsuite. Array element stride must not be
+# specified in the number of elements but in a number of bytes instead.
+# Original problem:
+# (gdb) p c40pt(1)
+# $1 = '0-hello', ' ' <repeats 33 times>
+# (gdb) p c40pt(2)
+# warning: Fortran array stride not divisible by the element size
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+set testfile dwarf-stride
+set srcfile ${testfile}.f90
+
+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f77}] } {
2009-09-03 19:45:38 +00:00
+ return -1
+}
+
2010-01-16 22:32:10 +00:00
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
2009-09-03 19:45:38 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
+gdb_test "p c40pt(1)" " = '0-hello.*"
+gdb_test "p c40pt(2)" " = '1-hello.*"
diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
new file mode 100644
index 0000000..e492b3a
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
@@ -0,0 +1,40 @@
+! Copyright 2009 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program; if not, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! File written by Alan Matsuoka.
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+program repro
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+ type small_stride
+ character*40 long_string
+ integer small_pad
+ end type small_stride
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+ type(small_stride), dimension (20), target :: unpleasant
+ character*40, pointer, dimension(:):: c40pt
2009-09-03 19:45:38 +00:00
+
2010-01-16 22:32:10 +00:00
+ integer i
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ do i = 0,19
+ unpleasant(i+1)%small_pad = i+1
+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
+ end do
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ c40pt => unpleasant%long_string
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+ print *, c40pt ! break-here
2009-08-10 13:22:51 +00:00
+
2010-01-16 22:32:10 +00:00
+end program repro
diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
2009-03-02 00:11:35 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..0ccebe0
2009-03-02 00:11:35 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
@@ -0,0 +1,145 @@
+# Copyright 2007 Free Software Foundation, Inc.
2009-03-02 00:11:35 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+# the Free Software Foundation; either version 2 of the License, or
2009-03-02 00:11:35 +00:00
+# (at your option) any later version.
2010-01-16 22:32:10 +00:00
+#
2009-03-02 00:11:35 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2009-09-10 21:37:41 +00:00
+# GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+#
2009-09-10 21:37:41 +00:00
+# You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-11 18:07:06 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file is part of the gdb testsuite. It contains tests for dynamically
+# allocated Fortran arrays.
+# It depends on the GCC dynamic Fortran arrays DWARF support:
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
2009-08-11 18:07:06 +00:00
+
2010-01-16 22:32:10 +00:00
+set testfile "dynamic"
+set srcfile ${testfile}.f90
2009-09-10 21:37:41 +00:00
+set binfile ${objdir}/${subdir}/${testfile}
2009-08-11 18:07:06 +00:00
+
2010-01-16 22:32:10 +00:00
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
+ untested "Couldn't compile ${srcfile}"
+ return -1
2009-09-10 21:37:41 +00:00
+}
+
2009-08-11 18:07:06 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
2010-01-16 22:32:10 +00:00
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
2009-09-10 21:37:41 +00:00
+ continue
2009-08-11 18:07:06 +00:00
+}
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varx-init"]
+gdb_continue_to_breakpoint "varx-init"
+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx unallocated"
+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx unallocated"
+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"
+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"
+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"
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varx-allocated"]
+gdb_continue_to_breakpoint "varx-allocated"
+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx allocated"
+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varx-filled"]
+gdb_continue_to_breakpoint "varx-filled"
+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
+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"
+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"
2009-09-10 21:37:41 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varv-associated"]
+gdb_continue_to_breakpoint "varv-associated"
+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)" "ptype varx with varv associated"
+# Intel Fortran Compiler 10.1.008 uses the pointer type.
+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varv-filled"]
+gdb_continue_to_breakpoint "varv-filled"
+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
+gdb_continue_to_breakpoint "varv-deassociated"
+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
+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"
+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"
+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
+gdb_test "p varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
+gdb_test "ptype varv(1,5,17)" "(Cannot access it|Unable to access the object) because the (object|array) is not associated\\."
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
+gdb_continue_to_breakpoint "varx-deallocated"
+gdb_test "p varx" "\\$\[0-9\]* = <(object|the array) is not allocated>" "p varx deallocated"
+gdb_test "ptype varx" "type = <(object|the array) is not allocated>" "ptype varx deallocated"
+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
+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"
+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"
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "vary-passed"]
+gdb_continue_to_breakpoint "vary-passed"
+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "vary-filled"]
+gdb_continue_to_breakpoint "vary-filled"
+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
+gdb_continue_to_breakpoint "varw-almostfilled"
+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
+# "up" works with GCC but other Fortran compilers may copy the values into the
+# outer function only on the exit of the inner function.
+# We need both variants as depending on the arch we optionally may still be
+# executing the caller line or not after `finish'.
+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
+gdb_continue_to_breakpoint "varz-almostfilled"
+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
+gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
+# maps to foo::vary(1,1)
+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
+# maps to foo::vary(2,2)
+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
+# maps to foo::vary(1,3)
+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
2009-08-04 05:37:29 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..0f43564
2009-08-04 05:37:29 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
@@ -0,0 +1,98 @@
+! Copyright 2007 Free Software Foundation, Inc.
2009-08-04 05:37:29 +00:00
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2010-01-16 22:32:10 +00:00
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program; if not, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+subroutine baz
+ real, target, allocatable :: varx (:, :, :)
+ real, pointer :: varv (:, :, :)
+ real, target :: varu (1, 2, 3)
+ logical :: l
+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init
+ l = allocated (varx)
+ varx(:, :, :) = 6 ! varx-allocated
+ varx(1, 5, 17) = 7
+ varx(2, 6, 18) = 8
+ varx(6, 15, 28) = 9
+ varv => varx ! varx-filled
+ l = associated (varv)
+ varv(3, 7, 19) = 10 ! varv-associated
+ varv => null () ! varv-filled
+ l = associated (varv)
+ deallocate (varx) ! varv-deassociated
+ l = allocated (varx)
+ varu(:, :, :) = 10 ! varx-deallocated
+ allocate (varv (1:6, 5:15, 17:28))
+ l = associated (varv)
+ varv(:, :, :) = 6
+ varv(1, 5, 17) = 7
+ varv(2, 6, 18) = 8
+ varv(6, 15, 28) = 9
+ deallocate (varv)
+ l = associated (varv)
+ varv => varu
+ varv(1, 1, 1) = 6
+ varv(1, 2, 3) = 7
+ l = associated (varv)
+end subroutine baz
+subroutine foo (vary, varw)
+ real :: vary (:, :)
+ real :: varw (:, :, :)
+ vary(:, :) = 4 ! vary-passed
+ vary(1, 1) = 8
+ vary(2, 2) = 9
+ vary(1, 3) = 10
+ varw(:, :, :) = 5 ! vary-filled
+ varw(1, 1, 1) = 6
+ varw(2, 2, 2) = 7 ! varw-almostfilled
+end subroutine foo
+subroutine bar (varz, vart)
+ real :: varz (*)
+ real :: vart (2:11, 7:*)
+ varz(1:3) = 4
+ varz(2) = 5 ! varz-almostfilled
+ vart(2,7) = vart(2,7)
+end subroutine bar
+program test
+ interface
+ subroutine foo (vary, varw)
+ real :: vary (:, :)
+ real :: varw (:, :, :)
+ end subroutine
+ end interface
+ interface
+ subroutine bar (varz, vart)
+ real :: varz (*)
+ real :: vart (2:11, 7:*)
+ end subroutine
+ end interface
+ real :: x (10, 10), y (5), z(8, 8, 8)
+ x(:,:) = 1
+ y(:) = 2
+ z(:,:,:) = 3
+ call baz
+ call foo (x, z(2:6, 4:7, 6:8))
+ call bar (y, x)
+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
+ if (x (1, 3) .ne. 10) call abort
+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
+ call foo (transpose (x), z)
+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
+ if (x (3, 1) .ne. 10) call abort
+end
diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
2009-08-04 05:37:29 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..b1120c3
2009-08-04 05:37:29 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.fortran/string.exp
@@ -0,0 +1,59 @@
+# Copyright 2008 Free Software Foundation, Inc.
2009-08-04 05:37:29 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+# the Free Software Foundation; either version 2 of the License, or
2009-08-04 05:37:29 +00:00
+# (at your option) any later version.
2010-01-16 22:32:10 +00:00
+#
2009-08-04 05:37:29 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+#
2009-08-04 05:37:29 +00:00
+# You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file is part of the gdb testsuite. It contains tests for Fortran
+# strings with dynamic length.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+set testfile "string"
+set srcfile ${testfile}.f90
2009-08-04 05:37:29 +00:00
+set binfile ${objdir}/${subdir}/${testfile}
+
2010-01-16 22:32:10 +00:00
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
2009-08-04 05:37:29 +00:00
+ untested "Couldn't compile ${srcfile}"
+ return -1
+}
+
2010-01-16 22:32:10 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
2009-08-04 05:37:29 +00:00
+gdb_load ${binfile}
+
2010-01-16 22:32:10 +00:00
+if ![runto MAIN__] then {
+ perror "couldn't run to breakpoint MAIN__"
+ continue
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "var-init"]
+gdb_continue_to_breakpoint "var-init"
+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
+gdb_test "p c" "\\$\[0-9\]* = 'c'"
+gdb_test "p d" "\\$\[0-9\]* = 'd '"
+gdb_test "p e" "\\$\[0-9\]* = 'g '"
+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 '\\) \\)"
+gdb_test "p *e" "Attempt to take contents of a non-pointer value."
+gdb_test "p *f" "Attempt to take contents of a non-pointer value."
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_breakpoint [gdb_get_line_number "var-finish"]
+gdb_continue_to_breakpoint "var-finish"
+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
+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"
diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
new file mode 100644
index 0000000..226dc5d
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/string.f90
@@ -0,0 +1,37 @@
+! Copyright 2008 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program; if not, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+subroutine foo (e, f)
+ character (len=1) :: c
+ character (len=8) :: d
+ character (len=*) :: e
+ character (len=*) :: f (1:7, 8:10)
+ c = 'c'
+ d = 'd'
+ e = 'e' ! var-init
+ f = 'f'
+ f(1,9) = 'f2'
+ c = 'c' ! var-finish
+end subroutine foo
+ character (len=4) :: g, h (1:7, 8:10)
+ g = 'g'
+ h = 'h'
+ call foo (g, h)
+end
diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
new file mode 100644
index 0000000..729f457
--- /dev/null
+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
@@ -0,0 +1,22 @@
+/* This file is part of GDB, the GNU debugger.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2009 Free Software Foundation, Inc.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+int
+func (int *arr)
+{
+ return arr[0];
+}
diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
new file mode 100644
index 0000000..3090e7e
--- /dev/null
+++ b/gdb/testsuite/gdb.opt/array-from-register.c
@@ -0,0 +1,28 @@
+/* This file is part of GDB, the GNU debugger.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2009 Free Software Foundation, Inc.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+extern int func (int *arr);
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+int
+main (void)
+{
+ int arr[] = { 42 };
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ func (arr);
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ return 0;
2009-08-04 05:37:29 +00:00
+}
2010-01-16 22:32:10 +00:00
diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
2009-08-04 05:37:29 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..f2de718
2009-08-04 05:37:29 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
@@ -0,0 +1,33 @@
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# This file is part of the gdb testsuite.
2009-03-02 00:11:35 +00:00
+
2010-01-16 22:32:10 +00:00
+if { [prepare_for_testing array-from-register.exp "array-from-register" \
+ {array-from-register.c array-from-register-func.c} \
+ {debug optimize=-O2}] } {
+ return -1
2009-03-02 00:11:35 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+if ![runto func] then {
+ return -1
2009-03-02 00:11:35 +00:00
+}
2010-01-16 22:32:10 +00:00
+
+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
+
+# Seen regression:
+# Address requested for identifier "arr" which is in register $rdi
+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
2009-08-04 05:37:29 +00:00
new file mode 100644
2010-11-17 02:58:16 +00:00
index 0000000..c108ea5
2009-08-04 05:37:29 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
2010-11-17 02:58:16 +00:00
@@ -0,0 +1,39 @@
2010-01-16 22:32:10 +00:00
+# Copyright 2009 Free Software Foundation, Inc.
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+# the Free Software Foundation; either version 2 of the License, or
2009-08-04 05:37:29 +00:00
+# (at your option) any later version.
2010-01-16 22:32:10 +00:00
+#
2009-08-04 05:37:29 +00:00
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
2010-01-16 22:32:10 +00:00
+#
2009-08-04 05:37:29 +00:00
+# You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+# Test GDB can cope with Fortran strings having their length present in a CPU
+# register. With -O0 the string length is passed on the stack. To make this
+# test meaningful the follow assertion should pass. It is not being checked
+# here as the "_s" symbol is compiler dependent:
+# (gdb) info address _s
+# Symbol "_s" is a variable in register XX.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+set test fortran-string
+set srcfile ${test}.f90
+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f77 additional_flags=-O2}] } {
2009-08-04 05:37:29 +00:00
+ return -1
+}
+
2010-11-17 02:58:16 +00:00
+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
2010-01-16 22:32:10 +00:00
+ perror "couldn't run to breakpoint MAIN__"
+ continue
2009-08-04 05:37:29 +00:00
+}
+
2010-01-16 22:32:10 +00:00
+gdb_test "frame" ".*s='foo'.*"
+gdb_test "ptype s" "type = character\\*3"
+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
new file mode 100644
index 0000000..e48d520
--- /dev/null
+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
@@ -0,0 +1,28 @@
+! Copyright 2009 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 2 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program; if not, write to the Free Software
+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+!
+! Ihis file is the Fortran source file for dynamic.exp.
+! Original file written by Jakub Jelinek <jakub@redhat.com>.
+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ subroutine f(s)
+ character*(*) s
+ s = s
+ end
2009-08-04 05:37:29 +00:00
+
2010-01-16 22:32:10 +00:00
+ program main
+ call f ('foo')
+ end
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
2010-01-16 22:32:10 +00:00
new file mode 100644
2010-07-21 21:30:20 +00:00
index 0000000..ccc6e1e
2010-01-16 22:32:10 +00:00
--- /dev/null
2010-07-21 21:30:20 +00:00
+++ b/gdb/testsuite/gdb.pascal/arrays.exp
@@ -0,0 +1,104 @@
+# Copyright 2008, 2009 Free Software Foundation, Inc.
+#
2010-01-16 22:32:10 +00:00
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+if $tracelevel then {
+ strace $tracelevel
+}
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+load_lib "pascal.exp"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+set testfile "arrays"
+set srcfile ${testfile}.pas
+set binfile ${objdir}/${subdir}/${testfile}$EXEEXT
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+# These tests only work with fpc, using the -gw3 compile-option
+pascal_init
+if { $pascal_compiler_is_fpc != 1 } {
2010-01-16 22:32:10 +00:00
+ return -1
+}
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+# Detect if the fpc version is below 2.3.0
+set fpc_generates_dwarf_for_dynamic_arrays 1
+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
+ set fpc_generates_dwarf_for_dynamic_arrays 0
2009-08-18 19:37:35 +00:00
+}
+
+
2010-07-21 21:30:20 +00:00
+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
+ return -1
2010-01-16 22:32:10 +00:00
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
2010-07-21 21:30:20 +00:00
+gdb_load ${binfile}
+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
2009-08-18 19:37:35 +00:00
+
+
2010-07-21 21:30:20 +00:00
+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
+ pass "setting breakpoint 1"
+}
+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
+ pass "setting breakpoint 2"
+}
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+# Verify that "start" lands inside the right procedure.
+if { [gdb_start_cmd] < 0 } {
+ untested start
2010-01-16 22:32:10 +00:00
+ return -1
+}
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "" ".* at .*${srcfile}.*" "start"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
+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"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
+}
+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
+}
+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
+}
+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
+}
+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
2010-01-16 22:32:10 +00:00
+}
2010-07-21 21:30:20 +00:00
+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
+ setup_xfail "*-*-*"
2010-01-16 22:32:10 +00:00
+}
2010-07-21 21:30:20 +00:00
+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
new file mode 100644
index 0000000..295602d
--- /dev/null
+++ b/gdb/testsuite/gdb.pascal/arrays.pas
@@ -0,0 +1,82 @@
+{
+ Copyright 2008, 2009 Free Software Foundation, Inc.
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
2009-08-18 19:37:35 +00:00
+}
+
2010-07-21 21:30:20 +00:00
+program arrays;
+
+{$mode objfpc}{$h+}
+
+uses sysutils;
+
+type TStatArrInt= array[0..11] of integer;
+ TDynArrInt= array of integer;
+ TStatArrStr= array[0..12] of string;
+ TDynArrStr= array of string;
+ TDynArrChar = array of char;
+ TStatArrChar = array [0..11] of char;
+
+ TStat2dArrInt = array[0..11,0..4] of integer;
2009-08-18 19:37:35 +00:00
+
2010-07-21 21:30:20 +00:00
+var StatArrInt: TStatArrInt;
+ StatArrInt_: Array[0..11] of integer;
+ DynArrInt: TDynArrInt;
+ DynArrInt_: Array of integer;
+ StatArrStr: TStatArrStr;
+ DynArrStr: TDynArrStr;
+ StatArrChar: TStatArrChar;
+ DynArrChar: TDynArrChar;
+
+ Stat2dArrInt: TStat2dArrInt;
+
+ s: string;
+
+ i,j : integer;
+
+begin
+ for i := 0 to 11 do
+ begin
+ StatArrInt[i]:= i+50;
+ StatArrInt_[i]:= i+50;
+ StatArrChar[i]:= chr(ord('a')+i);
+ for j := 0 to 4 do
+ Stat2dArrInt[i,j]:=i+j;
+ end;
+ writeln(StatArrInt_[0]);
+ writeln(StatArrInt[0]); { set breakpoint 1 here }
+ writeln(StatArrChar[0]);
+ writeln(Stat2dArrInt[0,0]);
+
+ setlength(DynArrInt,13);
+ setlength(DynArrInt_,13);
+ setlength(DynArrStr,13);
+ setlength(DynArrChar,13);
+ for i := 0 to 12 do
+ begin
+ DynArrInt[i]:= i+50;
+ DynArrInt_[i]:= i+50;
+ DynArrChar[i]:= chr(ord('a')+i);
+ StatArrStr[i]:='str'+inttostr(i);
+ DynArrStr[i]:='dstr'+inttostr(i);
+ end;
+ writeln(DynArrInt_[1]);
+ writeln(DynArrInt[1]);
+ writeln(DynArrStr[1]);
+ writeln(StatArrStr[1]);
+ writeln(DynArrChar[1]);
+
+ s := 'test'#0'string';
+ writeln(s); { set breakpoint 2 here }
+end.
2010-01-16 22:32:10 +00:00
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c
2009-08-18 19:37:35 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..4dc308b
2009-08-18 19:37:35 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-forkoff.c
@@ -0,0 +1,175 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2008, 2009 Free Software Foundation, Inc.
+
+ This file is part of GDB.
2009-08-18 19:37:35 +00:00
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
2010-01-16 22:32:10 +00:00
+ the Free Software Foundation; either version 2 of the License, or
2009-08-18 19:37:35 +00:00
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
2010-01-16 22:32:10 +00:00
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
2009-08-18 19:37:35 +00:00
+
+#include <string.h>
2010-01-16 22:32:10 +00:00
+#include <errno.h>
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void
+delay (void)
+{
+ int i = usleep (1000000 / 100);
+ assert (i == 0 || errno == EINTR);
+}
+
+#if defined FOLLOW_PARENT
+
+static void
+forkoff (int nr)
+{
+ pid_t child, pid_got;
+ int exit_code = 42 + nr;
+ int status, i;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ child = fork ();
+ switch (child)
+ {
+ case -1:
+ assert (0);
+ case 0:
+ printf ("child%d: %d\n", nr, (int) getpid ());
+ /* Delay to get both the "child%d" and "parent%d" message printed without
+ a race breaking expect by its endless wait on `$gdb_prompt$':
+ Breakpoint 3, breakpoint () at ../../../gdb/testsuite/gdb.threads/watchpoint-fork.c:33
+ 33 }
+ (gdb) parent2: 14223 */
+ i = sleep (1);
+ assert (i == 0);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* We must not get caught here (against a forgotten breakpoint). */
+ var++;
+ breakpoint ();
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ _exit (exit_code);
+ default:
+ printf ("parent%d: %d\n", nr, (int) child);
+ /* Delay to get both the "child%d" and "parent%d" message printed, see
+ above. */
+ i = sleep (1);
+ assert (i == 0);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ pid_got = wait (&status);
+ assert (pid_got == child);
+ assert (WIFEXITED (status));
+ assert (WEXITSTATUS (status) == exit_code);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* We must get caught here (against a false watchpoint removal). */
+ breakpoint ();
+ }
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#elif defined FOLLOW_CHILD
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static volatile int usr1_got;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void
+handler_usr1 (int signo)
+{
+ usr1_got++;
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void
+forkoff (int nr)
2009-08-18 19:37:35 +00:00
+{
2010-01-16 22:32:10 +00:00
+ pid_t child;
+ int i, loop;
+ struct sigaction act, oldact;
+#ifdef THREAD
+ void *thread_result;
+#endif
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ memset (&act, 0, sizeof act);
+ act.sa_flags = SA_RESTART;
+ act.sa_handler = handler_usr1;
+ sigemptyset (&act.sa_mask);
+ i = sigaction (SIGUSR1, &act, &oldact);
2009-08-18 19:37:35 +00:00
+ assert (i == 0);
+
2010-01-16 22:32:10 +00:00
+ child = fork ();
+ switch (child)
2009-08-18 19:37:35 +00:00
+ {
2010-01-16 22:32:10 +00:00
+ case -1:
+ assert (0);
+ default:
+ printf ("parent%d: %d\n", nr, (int) child);
+
+ /* Sleep for a while to possibly get incorrectly ATTACH_THREADed by GDB
+ tracing the child fork with no longer valid thread/lwp entries of the
+ parent. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ i = sleep (2);
2009-08-18 19:37:35 +00:00
+ assert (i == 0);
+
2010-01-16 22:32:10 +00:00
+ /* We must not get caught here (against a forgotten breakpoint). */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ var++;
+ breakpoint ();
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#ifdef THREAD
+ /* And neither got caught our thread. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ step = 99;
+ i = pthread_join (thread, &thread_result);
+ assert (i == 0);
+ assert (thread_result == (void *) 99UL);
+#endif
+
+ /* Be sure our child knows we did not get caught above. */
+
+ i = kill (child, SIGUSR1);
+ assert (i == 0);
+
+ /* Sleep for a while to check GDB's `info threads' no longer tracks us in
+ the child fork. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ i = sleep (2);
+ assert (i == 0);
+
+ _exit (0);
+ case 0:
+ printf ("child%d: %d\n", nr, (int) getpid ());
+
+ /* Let the parent signal us about its success. Be careful of races. */
+
+ for (loop = 0; loop < 1000; loop++)
+ {
+ /* Parent either died (and USR1_GOT is zero) or it succeeded. */
+ if (kill (getppid (), 0) != 0)
+ break;
+ /* Parent succeeded? */
+ if (usr1_got)
+ break;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ delay ();
+ }
+ assert (usr1_got);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* We must get caught here (against a false watchpoint removal). */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ breakpoint ();
+ }
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ i = sigaction (SIGUSR1, &oldact, NULL);
2009-08-18 19:37:35 +00:00
+ assert (i == 0);
2010-01-16 22:32:10 +00:00
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#else
+# error "!FOLLOW_PARENT && !FOLLOW_CHILD"
+#endif
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
new file mode 100644
index 0000000..edacfc0
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork-mt.c
@@ -0,0 +1,157 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2008, 2009 Free Software Foundation, Inc.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This file is part of GDB.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#include <assert.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <pthread.h>
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#include <asm/unistd.h>
+#include <unistd.h>
+#define gettid() syscall (__NR_gettid)
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+/* Non-atomic `var++' should not hurt as we synchronize the threads by the STEP
+ variable. Hit-comments need to be duplicite there to catch both at-stops
+ and behind-stops, depending on the target. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static volatile int var;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void
+dummy (void)
2009-08-18 19:37:35 +00:00
+{
+}
+
+static void
2010-01-16 22:32:10 +00:00
+breakpoint (void)
2009-08-18 19:37:35 +00:00
+{
2010-01-16 22:32:10 +00:00
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+/* Include here the functions:
+ static void forkoff (int nr);
+ static void delay (void); */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static pthread_t thread;
+static volatile int step;
+#define THREAD
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#include "watchpoint-fork-forkoff.c"
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void *
+start (void *arg)
+{
+ if (step >= 3)
+ goto step_3;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ while (step != 1)
+ delay ();
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ var++; /* validity-thread-B */
+ dummy (); /* validity-thread-B */
+ step = 2;
+ while (step != 3)
+ {
+ if (step == 99)
+ goto step_99;
+ delay ();
+ }
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+step_3:
+ if (step >= 5)
+ goto step_5;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ var++; /* after-fork1-B */
+ dummy (); /* after-fork1-B */
+ step = 4;
+ while (step != 5)
2009-08-18 19:37:35 +00:00
+ {
2010-01-16 22:32:10 +00:00
+ if (step == 99)
+ goto step_99;
+ delay ();
+ }
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+step_5:
+ var++; /* after-fork2-B */
+ dummy (); /* after-fork2-B */
+ return (void *) 5UL;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+step_99:
+ /* We must not get caught here (against a forgotten breakpoint). */
+ var++;
+ breakpoint ();
+ return (void *) 99UL;
2009-08-18 19:37:35 +00:00
+}
+
+int
2010-01-16 22:32:10 +00:00
+main (void)
2009-08-18 19:37:35 +00:00
+{
+ int i;
2010-01-16 22:32:10 +00:00
+ void *thread_result;
2009-08-18 19:37:35 +00:00
+
+ setbuf (stdout, NULL);
2010-01-16 22:32:10 +00:00
+ printf ("main: %d\n", (int) gettid ());
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* General watchpoints validity. */
+ var++; /* validity-first */
+ dummy (); /* validity-first */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ i = pthread_create (&thread, NULL, start, NULL);
2009-08-18 19:37:35 +00:00
+ assert (i == 0);
+
2010-01-16 22:32:10 +00:00
+ var++; /* validity-thread-A */
+ dummy (); /* validity-thread-A */
+ step = 1;
+ while (step != 2)
+ delay ();
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* Hardware watchpoints got disarmed here. */
+ forkoff (1);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ var++; /* after-fork1-A */
+ dummy (); /* after-fork1-A */
+ step = 3;
+#ifdef FOLLOW_CHILD
+ /* Spawn new thread as it was deleted in the child of FORK. */
+ i = pthread_create (&thread, NULL, start, NULL);
2009-08-18 19:37:35 +00:00
+ assert (i == 0);
2010-01-16 22:32:10 +00:00
+#endif
+ while (step != 4)
+ delay ();
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* A sanity check for double hardware watchpoints removal. */
+ forkoff (2);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ var++; /* after-fork2-A */
+ dummy (); /* after-fork2-A */
+ step = 5;
+#ifdef FOLLOW_CHILD
+ /* Spawn new thread as it was deleted in the child of FORK. */
+ i = pthread_create (&thread, NULL, start, NULL);
+ assert (i == 0);
+#endif
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ i = pthread_join (thread, &thread_result);
+ assert (i == 0);
+ assert (thread_result == (void *) 5UL);
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.c b/gdb/testsuite/gdb.threads/watchpoint-fork.c
new file mode 100644
index 0000000..5f62e7f
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.c
@@ -0,0 +1,57 @@
+/* Test case for forgotten hw-watchpoints after fork()-off of a process.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ Copyright 2008, 2009 Free Software Foundation, Inc.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This file is part of GDB.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#include <assert.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <stdlib.h>
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static volatile int var;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+static void
+breakpoint (void)
+{
+}
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+/* Include here the function:
+ static void forkoff (int nr); */
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+#include "watchpoint-fork-forkoff.c"
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+int
+main (void)
+{
+ setbuf (stdout, NULL);
+ printf ("main: %d\n", (int) getpid ());
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ /* General watchpoints validity. */
+ var++;
+ /* Hardware watchpoints got disarmed here. */
+ forkoff (1);
+ /* This watchpoint got lost before. */
+ var++;
+ /* A sanity check for double hardware watchpoints removal. */
+ forkoff (2);
+ var++;
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ return 0;
2009-08-18 19:37:35 +00:00
+}
2010-01-16 22:32:10 +00:00
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
2009-08-18 19:37:35 +00:00
new file mode 100644
2010-01-16 22:32:10 +00:00
index 0000000..1dc93ab
2009-08-18 19:37:35 +00:00
--- /dev/null
2010-01-16 22:32:10 +00:00
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
@@ -0,0 +1,130 @@
+# Copyright 2008, 2009 Free Software Foundation, Inc.
2009-08-18 19:37:35 +00:00
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
2010-01-16 22:32:10 +00:00
+# Test case for forgotten hw-watchpoints after fork()-off of a process.
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+proc test {type symbol} {
+ global objdir subdir srcdir
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ set test watchpoint-fork
2009-08-18 19:37:35 +00:00
+
+ global pf_prefix
+ set prefix_test $pf_prefix
2010-01-16 22:32:10 +00:00
+ lappend pf_prefix "$type:"
+ set prefix_mt $pf_prefix
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ # no threads
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ set pf_prefix $prefix_mt
+ lappend pf_prefix "singlethreaded:"
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ set executable ${test}-${type}
+ if { [gdb_compile ${srcdir}/${subdir}/${test}.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
+ untested ${test}.exp
+ return -1
2009-08-18 19:37:35 +00:00
+ }
2010-01-16 22:32:10 +00:00
+ clean_restart $executable
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ gdb_test "show detach-on-fork" "Whether gdb will detach the child of a fork is on."
+ gdb_test "set follow-fork-mode $type"
+ gdb_test "show follow-fork-mode" "Debugger response to a program call of fork or vfork is \"$type\"."
+ # Testcase uses it for the `follow-fork-mode child' type.
+ gdb_test "handle SIGUSR1 nostop noprint pass"
+
+ if { ![runto_main] } then {
+ gdb_suppress_tests
+ return
2009-08-18 19:37:35 +00:00
+ }
+
2010-01-16 22:32:10 +00:00
+ # Install the watchpoint only after getting into MAIN - workaround some PPC
+ # problem.
+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint"
+
+ # It is never hit but it should not be left over in the fork()ed-off child.
+ gdb_breakpoint "breakpoint"
2009-08-18 19:37:35 +00:00
+
+ gdb_test "continue" \
2010-01-16 22:32:10 +00:00
+ "atchpoint 2: var.*Old value = 0.*New value = 1.*forkoff *\\(1\\).*" "watchpoints work"
+ gdb_test "continue" \
+ "reakpoint 3, breakpoint.*" "breakpoint after the first fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 1.*New value = 2.*forkoff *\\(2\\).*" "watchpoint after the first fork"
+ gdb_test "continue" \
+ "reakpoint 3, breakpoint.*" "breakpoint after the second fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 2.*New value = 3.*return *0;" "watchpoint after the second fork"
+ gdb_test "continue" "Continuing..*Program exited normally." "finish"
+
+
+ # threads
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ set pf_prefix $prefix_mt
+ lappend pf_prefix "multithreaded:"
+
+ set executable ${test}-mt-${type}
+ if { [gdb_compile_pthreads ${srcdir}/${subdir}/${test}-mt.c ${objdir}/${subdir}/${executable} executable [list debug additional_flags=-D$symbol]] != "" } {
+ untested ${test}.exp
+ return -1
+ }
+ clean_restart $executable
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ gdb_test "set follow-fork-mode $type"
+ # Testcase uses it for the `follow-fork-mode child' type.
+ gdb_test "handle SIGUSR1 nostop noprint pass"
2009-08-18 19:37:35 +00:00
+
2010-01-16 22:32:10 +00:00
+ if { ![runto_main] } then {
+ gdb_suppress_tests
+ return
2009-08-18 19:37:35 +00:00
+ }
+
2010-01-16 22:32:10 +00:00
+ # Install the watchpoint only after getting into MAIN - workaround some PPC
+ # problem.
+ gdb_test "watch var" "atchpoint 2: var" "Set the watchpoint"
+
+ # It is never hit but it should not be left over in the fork()ed-off child.
+ gdb_breakpoint "breakpoint"
+
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 0.*New value = 1.*validity-first.*" "singlethread watchpoints work"
2009-08-18 19:37:35 +00:00
+ gdb_test "continue" \
2010-01-16 22:32:10 +00:00
+ "atchpoint 2: var.*Old value = 1.*New value = 2.*validity-thread-A.*" "multithreaded watchpoints work at A"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 2.*New value = 3.*validity-thread-B.*" "multithreaded watchpoints work at B"
+ gdb_test "continue" \
+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the first fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 3.*New value = 4.*after-fork1-A.*" "watchpoint A after the first fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 4.*New value = 5.*after-fork1-B.*" "watchpoint B after the first fork"
+ gdb_test "continue" \
+ "reakpoint 3, breakpoint.*" "breakpoint (A) after the second fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 5.*New value = 6.*after-fork2-A.*" "watchpoint A after the second fork"
+ gdb_test "continue" \
+ "atchpoint 2: var.*Old value = 6.*New value = 7.*after-fork2-B.*" "watchpoint B after the second fork"
+ gdb_test "continue" "Continuing..*Program exited normally." "finish"
2009-08-18 19:37:35 +00:00
+
2010-01-12 22:15:57 +00:00
+
2010-01-16 22:32:10 +00:00
+ # cleanup
2009-08-18 19:37:35 +00:00
+
+ set pf_prefix $prefix_test
+}
2010-01-16 22:32:10 +00:00
+
+test parent FOLLOW_PARENT
+
+# Only GNU/Linux is known to support `set follow-fork-mode child'.
+if {[istarget "*-*-linux*"]} {
+ test child FOLLOW_CHILD
+}
2010-07-21 21:30:20 +00:00
diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
2010-11-17 02:58:16 +00:00
index af0b00d..e1a8dc4 100644
2010-07-21 21:30:20 +00:00
--- a/gdb/testsuite/lib/pascal.exp
+++ b/gdb/testsuite/lib/pascal.exp
@@ -37,6 +37,9 @@ proc pascal_init {} {
global pascal_compiler_is_fpc
global gpc_compiler
global fpc_compiler
+ global fpcversion_major
+ global fpcversion_minor
+ global fpcversion_release
global env
if { $pascal_init_done == 1 } {
@@ -64,6 +67,20 @@ proc pascal_init {} {
set pascal_compiler_is_fpc 1
verbose -log "Free Pascal compiler found"
2010-01-21 16:09:11 +00:00
}
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ # Detect the fpc-version
+ if { $pascal_compiler_is_fpc == 1 } {
+ set fpcversion_major 1
+ set fpcversion_minor 0
+ set fpcversion_release 0
+ set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
+ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
2009-08-04 05:37:29 +00:00
+ }
2010-07-21 21:30:20 +00:00
+ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
2009-08-04 05:37:29 +00:00
+ }
2010-07-21 21:30:20 +00:00
}
set pascal_init_done 1
}
2009-08-04 05:37:29 +00:00
diff --git a/gdb/top.c b/gdb/top.c
2010-11-17 02:58:16 +00:00
index 6680c38..38d1cc2 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/top.c
+++ b/gdb/top.c
2010-11-17 02:58:16 +00:00
@@ -338,6 +338,7 @@ void
2009-09-10 21:37:41 +00:00
prepare_execute_command (void)
{
2009-08-04 05:37:29 +00:00
free_all_values ();
+ free_all_types ();
2009-03-02 00:11:35 +00:00
2009-09-10 21:37:41 +00:00
/* With multiple threads running while the one we're examining is stopped,
the dcache can get stale without us being able to detect it.
2009-08-04 05:37:29 +00:00
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
2010-01-16 22:32:10 +00:00
index ce9f551..5f9d739 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
2010-01-16 22:32:10 +00:00
@@ -36,6 +36,7 @@
2009-08-04 05:37:29 +00:00
#include "gdb_string.h"
#include "exceptions.h"
#include "valprint.h"
+#include "dwarf2loc.h"
#include <errno.h>
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
extern void _initialize_typeprint (void);
2010-01-16 22:32:10 +00:00
@@ -77,6 +78,9 @@ void
2009-08-04 05:37:29 +00:00
type_print (struct type *type, char *varstring, struct ui_file *stream,
int show)
{
+ if (show >= 0)
+ type = check_typedef (type);
+
LA_PRINT_TYPE (type, varstring, stream, show, 0);
}
2009-03-02 00:11:35 +00:00
2010-01-16 22:32:10 +00:00
@@ -115,7 +119,8 @@ whatis_exp (char *exp, int show)
2009-08-04 05:37:29 +00:00
{
struct expression *expr;
struct value *val;
- struct cleanup *old_chain = NULL;
+ /* Required at least for the object_address_set call. */
+ struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
struct type *real_type = NULL;
struct type *type;
int full = 0;
2010-01-16 22:32:10 +00:00
@@ -126,12 +131,13 @@ whatis_exp (char *exp, int show)
2009-08-04 05:37:29 +00:00
if (exp)
{
expr = parse_expression (exp);
- old_chain = make_cleanup (free_current_contents, &expr);
+ make_cleanup (free_current_contents, &expr);
val = evaluate_type (expr);
}
else
val = access_value_history (0);
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
+ object_address_set (value_raw_address (val));
type = value_type (val);
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
get_user_print_options (&opts);
2010-01-16 22:32:10 +00:00
@@ -168,8 +174,7 @@ whatis_exp (char *exp, int show)
2009-08-04 05:37:29 +00:00
type_print (type, "", gdb_stdout, show);
printf_filtered ("\n");
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
- if (exp)
- do_cleanups (old_chain);
+ do_cleanups (old_chain);
}
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
static void
diff --git a/gdb/valarith.c b/gdb/valarith.c
2010-11-17 02:58:16 +00:00
index 7c553d1..80be82f 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
2010-07-11 18:06:33 +00:00
@@ -161,12 +161,26 @@ value_subscript (struct value *array, LONGEST index)
2009-03-02 00:11:35 +00:00
2010-07-21 21:30:20 +00:00
get_discrete_bounds (range_type, &lowerbound, &upperbound);
2009-08-04 05:37:29 +00:00
if (VALUE_LVAL (array) != lval_memory)
- return value_subscripted_rvalue (array, index, lowerbound);
+ {
+ if (index >= lowerbound && index <= upperbound)
+ {
+ CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
+ CORE_ADDR offset = (index - lowerbound) * element_size;
+
+ return value_subscripted_rvalue (array, offset);
+ }
+ error (_("array or string index out of range"));
+ }
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
if (c_style == 0)
{
if (index >= lowerbound && index <= upperbound)
- return value_subscripted_rvalue (array, index, lowerbound);
+ {
+ CORE_ADDR element_size = TYPE_LENGTH (TYPE_TARGET_TYPE (tarray));
+ CORE_ADDR offset = (index - lowerbound) * element_size;
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ return value_subscripted_rvalue (array, offset);
+ }
/* Emit warning unless we have an array of unknown size.
An array of unknown size has lowerbound 0 and upperbound -1. */
if (upperbound > -1)
2010-07-21 21:30:20 +00:00
@@ -185,34 +199,37 @@ value_subscript (struct value *array, LONGEST index)
2009-08-04 05:37:29 +00:00
error (_("not an array or string"));
}
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
-/* Return the value of EXPR[IDX], expr an aggregate rvalue
- (eg, a vector register). This routine used to promote floats
- to doubles, but no longer does. */
+/* Return the value of *((void *) ARRAY + ELEMENT), ARRAY an aggregate rvalue
+ (eg, a vector register). This routine used to promote floats to doubles,
+ but no longer does. OFFSET is zero-based with 0 for the lowermost existing
+ element, it must be expressed in bytes (therefore multiplied by
+ check_typedef (TYPE_TARGET_TYPE (array_type)). */
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
struct value *
-value_subscripted_rvalue (struct value *array, LONGEST index, int lowerbound)
+value_subscripted_rvalue (struct value *array, CORE_ADDR offset)
{
struct type *array_type = check_typedef (value_type (array));
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
- unsigned int elt_size = TYPE_LENGTH (elt_type);
- unsigned int elt_offs = elt_size * longest_to_int (index - lowerbound);
struct value *v;
2010-07-21 21:30:20 +00:00
- if (index < lowerbound || (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
- && elt_offs >= TYPE_LENGTH (array_type)))
2009-08-04 05:37:29 +00:00
- error (_("no such vector element"));
+ /* Do not check TYPE_LENGTH (array_type) as we may have been given the
+ innermost dimension of a multi-dimensional Fortran array where its length
+ is shorter than the possibly accessed element offset. */
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
v = allocate_value (elt_type);
if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
set_value_lazy (v, 1);
else
- memcpy (value_contents_writeable (v),
- value_contents (array) + elt_offs, elt_size);
2009-03-02 00:11:35 +00:00
+ {
2009-08-04 05:37:29 +00:00
+ unsigned int elt_size = TYPE_LENGTH (elt_type);
+ memcpy (value_contents_writeable (v),
+ value_contents (array) + offset, elt_size);
2009-03-02 00:11:35 +00:00
+ }
2009-08-04 05:37:29 +00:00
set_value_component_location (v, array);
VALUE_REGNUM (v) = VALUE_REGNUM (array);
VALUE_FRAME_ID (v) = VALUE_FRAME_ID (array);
- set_value_offset (v, value_offset (array) + elt_offs);
+ set_value_offset (v, value_offset (array) + offset);
return v;
2009-03-02 00:11:35 +00:00
}
2010-07-21 21:30:20 +00:00
@@ -292,6 +309,10 @@ int
binop_user_defined_p (enum exp_opcode op,
struct value *arg1, struct value *arg2)
{
+ /* FIXME: We should support user defined ops for dynamic types. */
+ if (TYPE_DYNAMIC (value_type (arg1)) || TYPE_DYNAMIC (value_type (arg2)))
+ return 0;
2010-07-11 18:06:33 +00:00
+
2010-07-21 21:30:20 +00:00
return binop_types_user_defined_p (op, value_type (arg1), value_type (arg2));
}
2010-07-11 18:06:33 +00:00
2009-08-04 05:37:29 +00:00
diff --git a/gdb/valops.c b/gdb/valops.c
2010-11-17 02:58:16 +00:00
index 932e311..5ce565f 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -38,6 +38,7 @@
#include "cp-support.h"
#include "dfp.h"
#include "user-regs.h"
+#include "dwarf2loc.h"
#include <errno.h>
#include "gdb_string.h"
2010-11-17 02:58:16 +00:00
@@ -897,6 +898,65 @@ value_one (struct type *type, enum lval_type lv)
2009-08-04 05:37:29 +00:00
return val;
2009-03-02 00:11:35 +00:00
}
2009-08-04 05:37:29 +00:00
+/* object_address_set must be already called before this function. */
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+const char *
+object_address_data_not_valid (struct type *type)
2009-03-02 00:11:35 +00:00
+{
2009-08-04 05:37:29 +00:00
+ /* Attributes are present only at the target type of a typedef. Make the
+ call conditional as it would otherwise loop through type_length_get. */
+ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
+ CHECK_TYPEDEF (type);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ /* DW_AT_associated has a preference over DW_AT_allocated. */
+ if (TYPE_NOT_ASSOCIATED (type)
+ || (TYPE_ASSOCIATED (type) != NULL
+ && 0 == dwarf_locexpr_baton_eval (TYPE_ASSOCIATED (type))))
+ return N_("object is not associated");
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ if (TYPE_NOT_ALLOCATED (type)
+ || (TYPE_ALLOCATED (type) != NULL
+ && 0 == dwarf_locexpr_baton_eval (TYPE_ALLOCATED (type))))
+ return N_("object is not allocated");
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ return NULL;
+}
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+/* Return non-NULL check_typedef result on TYPE if the variable is valid. If
+ it is valid the function may store the data address (DW_AT_DATA_LOCATION) of
+ TYPE at *ADDRESS_RETURN. You must set *ADDRESS_RETURN from
+ value_raw_address (VAL) before calling this function. If no
+ DW_AT_DATA_LOCATION is present for TYPE the address at *ADDRESS_RETURN is
+ left unchanged. ADDRESS_RETURN must not be NULL, use
2009-08-04 05:37:29 +00:00
+ object_address_data_not_valid () for just the data validity check. */
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+struct type *
2009-08-04 05:37:29 +00:00
+object_address_get_data (struct type *type, CORE_ADDR *address_return)
+{
+ gdb_assert (address_return != NULL);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ object_address_set (*address_return);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ /* TYPE_DATA_LOCATION_DWARF_BLOCK / TYPE_DATA_LOCATION_ADDR are present only
+ at the target type of a typedef. */
+ CHECK_TYPEDEF (type);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ if (object_address_data_not_valid (type) != NULL)
2009-03-02 00:11:35 +00:00
+ {
2009-08-04 05:37:29 +00:00
+ /* Do not try to evaluate DW_AT_data_location as it may even crash
+ (it would just return the value zero in the gfortran case). */
2010-07-21 21:30:20 +00:00
+ return NULL;
2009-03-02 00:11:35 +00:00
+ }
+
2009-08-04 05:37:29 +00:00
+ if (TYPE_DATA_LOCATION_IS_ADDR (type))
+ *address_return = TYPE_DATA_LOCATION_ADDR (type);
+ else if (TYPE_DATA_LOCATION_DWARF_BLOCK (type) != NULL)
+ *address_return
+ = dwarf_locexpr_baton_eval (TYPE_DATA_LOCATION_DWARF_BLOCK (type));
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ return type;
2009-03-02 00:11:35 +00:00
+}
+
2009-09-10 21:37:41 +00:00
/* Helper function for value_at, value_at_lazy, and value_at_lazy_stack. */
2009-03-02 00:11:35 +00:00
2009-09-10 21:37:41 +00:00
static struct value *
2010-11-17 02:58:16 +00:00
@@ -995,15 +1055,21 @@ value_fetch_lazy (struct value *val)
2009-03-02 00:11:35 +00:00
}
2009-08-04 05:37:29 +00:00
else if (VALUE_LVAL (val) == lval_memory)
{
- CORE_ADDR addr = value_address (val);
- int length = TYPE_LENGTH (check_typedef (value_enclosing_type (val)));
+ CORE_ADDR addr = value_raw_address (val);
2009-09-10 21:37:41 +00:00
- if (length)
2009-08-04 05:37:29 +00:00
+ if (object_address_get_data (value_type (val), &addr))
2009-09-10 21:37:41 +00:00
{
- if (value_stack (val))
- read_stack (addr, value_contents_all_raw (val), length);
- else
- read_memory (addr, value_contents_all_raw (val), length);
2009-08-04 05:37:29 +00:00
+ struct type *type = value_enclosing_type (val);
+ int length = TYPE_LENGTH (check_typedef (type));
2009-09-10 21:37:41 +00:00
+
2009-08-04 05:37:29 +00:00
+ if (length)
+ {
+ addr += value_offset (val);
2009-09-10 21:37:41 +00:00
+ if (value_stack (val))
+ read_stack (addr, value_contents_all_raw (val), length);
+ else
+ read_memory (addr, value_contents_all_raw (val), length);
2009-08-04 05:37:29 +00:00
+ }
2009-09-10 21:37:41 +00:00
}
2009-08-04 05:37:29 +00:00
}
else if (VALUE_LVAL (val) == lval_register)
2010-11-17 02:58:16 +00:00
@@ -1407,7 +1473,18 @@ address_of_variable (struct symbol *var, struct block *b)
2009-08-04 05:37:29 +00:00
if ((VALUE_LVAL (val) == lval_memory && value_lazy (val))
|| TYPE_CODE (type) == TYPE_CODE_FUNC)
{
- CORE_ADDR addr = value_address (val);
+ CORE_ADDR addr;
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ if (VALUE_LVAL (val) == lval_memory)
+ {
+ addr = value_raw_address (val);
+ if (!object_address_get_data (type, &addr))
+ error (_("Can't take address of memory lvalue \"%s\"."),
+ SYMBOL_PRINT_NAME (var));
+ set_value_address (val, addr);
+ }
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ addr = value_address (val);
2010-07-21 21:30:20 +00:00
2009-08-04 05:37:29 +00:00
return value_from_pointer (lookup_pointer_type (type), addr);
2009-03-02 00:11:35 +00:00
}
2010-11-17 02:58:16 +00:00
@@ -1515,6 +1592,7 @@ struct value *
2009-08-04 05:37:29 +00:00
value_coerce_array (struct value *arg1)
{
struct type *type = check_typedef (value_type (arg1));
+ CORE_ADDR address;
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
/* If the user tries to do something requiring a pointer with an
array that has not yet been pushed to the target, then this would
2010-11-17 02:58:16 +00:00
@@ -1524,8 +1602,12 @@ value_coerce_array (struct value *arg1)
2009-08-04 05:37:29 +00:00
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
+ address = value_raw_address (arg1);
+ if (!object_address_get_data (type, &address))
+ error (_("Attempt to take address of non-valid value."));
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
return value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
- value_address (arg1));
+ address + value_offset (arg1));
}
/* Given a value which is a function, return a value which is a pointer
diff --git a/gdb/valprint.c b/gdb/valprint.c
2010-11-17 02:58:16 +00:00
index ddb16e4..c4c2969 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
2010-07-21 21:30:20 +00:00
@@ -36,6 +36,7 @@
#include "dfp.h"
#include "python/python.h"
#include "ada-lang.h"
+#include "dwarf2loc.h"
#include <errno.h>
@@ -237,7 +238,6 @@ scalar_type_p (struct type *type)
2009-09-01 13:19:03 +00:00
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
case TYPE_CODE_SET:
- case TYPE_CODE_STRING:
case TYPE_CODE_BITSTRING:
return 0;
default:
2010-11-17 02:58:16 +00:00
@@ -1104,6 +1104,7 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
2010-07-21 21:30:20 +00:00
{
unsigned int things_printed = 0;
unsigned len;
+ struct type *saved_type = type;
struct type *elttype, *index_type;
unsigned eltlen;
/* Position of the array element we are examining to see
2010-11-17 02:58:16 +00:00
@@ -1112,9 +1113,33 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
2010-07-21 21:30:20 +00:00
/* Number of repetitions we have detected so far. */
unsigned int reps;
2010-11-17 02:58:16 +00:00
LONGEST low_bound, high_bound;
2010-07-21 21:30:20 +00:00
+ struct cleanup *back_to;
+ CORE_ADDR saved_address = address;
+
+ back_to = make_cleanup (null_cleanup, 0);
+ type = object_address_get_data (type, &address);
+ if (!type)
+ {
+ fputs_filtered (object_address_data_not_valid (type), stream);
+ do_cleanups (back_to);
+ return;
+ }
+ if (address != saved_address)
+ {
+ size_t length = TYPE_LENGTH (type);
- elttype = TYPE_TARGET_TYPE (type);
- eltlen = TYPE_LENGTH (check_typedef (elttype));
+ valaddr = xmalloc (length);
+ make_cleanup (xfree, (gdb_byte *) valaddr);
+ read_memory (address, (gdb_byte *) valaddr, length);
+ }
+
+ /* Skip typedefs but do not resolve TYPE_DYNAMIC. */
+ elttype = saved_type;
+ while (TYPE_CODE (elttype) == TYPE_CODE_TYPEDEF)
+ elttype = TYPE_TARGET_TYPE (elttype);
+ elttype = TYPE_TARGET_TYPE (elttype);
+
+ eltlen = TYPE_ARRAY_BYTE_STRIDE_VALUE (type);
index_type = TYPE_INDEX_TYPE (type);
2009-08-04 05:37:29 +00:00
2010-11-17 02:58:16 +00:00
if (get_array_bounds (type, &low_bound, &high_bound))
@@ -1189,6 +1214,8 @@ val_print_array_elements (struct type *type, const gdb_byte *valaddr,
2010-07-21 21:30:20 +00:00
{
fprintf_filtered (stream, "...");
}
+
+ do_cleanups (back_to);
}
/* Read LEN bytes of target memory at address MEMADDR, placing the
2009-08-04 05:37:29 +00:00
diff --git a/gdb/value.c b/gdb/value.c
2010-11-17 02:58:16 +00:00
index 85cb62a..013a9fc 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/value.c
+++ b/gdb/value.c
2010-07-21 21:30:20 +00:00
@@ -39,6 +39,7 @@
2009-08-04 05:37:29 +00:00
#include "objfiles.h"
#include "valprint.h"
#include "cli/cli-decode.h"
+#include "observer.h"
#include "python/python.h"
2010-11-17 02:58:16 +00:00
@@ -850,12 +851,15 @@ void
2010-07-21 21:30:20 +00:00
set_value_component_location (struct value *component,
const struct value *whole)
2009-03-02 00:11:35 +00:00
{
2009-08-04 05:37:29 +00:00
+ CORE_ADDR addr;
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
if (whole->lval == lval_internalvar)
2009-08-04 05:37:29 +00:00
VALUE_LVAL (component) = lval_internalvar_component;
else
2010-07-21 21:30:20 +00:00
VALUE_LVAL (component) = whole->lval;
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
component->location = whole->location;
+
2010-07-21 21:30:20 +00:00
if (whole->lval == lval_computed)
2009-08-04 05:37:29 +00:00
{
struct lval_funcs *funcs = whole->location.computed.funcs;
2010-11-17 02:58:16 +00:00
@@ -863,6 +867,12 @@ set_value_component_location (struct value *component,
2009-08-04 05:37:29 +00:00
if (funcs->copy_closure)
component->location.computed.closure = funcs->copy_closure (whole);
2009-03-02 00:11:35 +00:00
}
+
2009-08-04 05:37:29 +00:00
+ addr = value_raw_address (component);
+ object_address_get_data (value_type (whole), &addr);
2010-01-12 22:15:57 +00:00
+ if (component->lval != lval_internalvar
+ && component->lval != lval_internalvar_component)
+ set_value_address (component, addr);
2009-03-07 00:32:30 +00:00
}
2009-08-04 05:37:29 +00:00
2010-11-17 02:58:16 +00:00
@@ -995,6 +1005,29 @@ show_values (char *num_exp, int from_tty)
2009-08-04 05:37:29 +00:00
num_exp[1] = '\0';
}
}
+
+/* Sanity check for memory leaks and proper types reference counting. */
+
2009-03-07 00:32:30 +00:00
+static void
2009-08-04 05:37:29 +00:00
+value_history_cleanup (void *unused)
2009-03-07 00:32:30 +00:00
+{
2009-08-04 05:37:29 +00:00
+ while (value_history_chain)
+ {
+ struct value_history_chunk *chunk = value_history_chain;
+ int i;
2009-03-07 00:32:30 +00:00
+
2009-08-04 05:37:29 +00:00
+ for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
+ value_free (chunk->values[i]);
2009-03-07 00:32:30 +00:00
+
2009-08-04 05:37:29 +00:00
+ value_history_chain = chunk->next;
+ xfree (chunk);
+ }
+ value_history_count = 0;
+
+ /* Free the unreferenced types above. */
+ free_all_values ();
+ free_all_types ();
+}
/* Internal variables. These are variables within the debugger
that hold values assigned by debugger commands.
2010-11-17 02:58:16 +00:00
@@ -1473,6 +1506,40 @@ call_internal_function (struct gdbarch *gdbarch,
2009-08-04 05:37:29 +00:00
return (*ifn->handler) (gdbarch, language, ifn->cookie, argc, argv);
2009-03-02 00:11:35 +00:00
}
2009-08-04 05:37:29 +00:00
+/* Call type_mark_used for any TYPEs referenced from this GDB source file. */
+
+static void
+value_types_mark_used (void)
+{
+ struct internalvar *var;
+ struct value_history_chunk *chunk;
+
+ for (var = internalvars; var != NULL; var = var->next)
+ switch (var->kind)
2009-03-02 00:11:35 +00:00
+ {
2009-08-04 05:37:29 +00:00
+ case INTERNALVAR_VALUE:
+ type_mark_used (value_type (var->u.value));
+ break;
2009-03-02 00:11:35 +00:00
+
2009-08-19 16:19:15 +00:00
+ case INTERNALVAR_INTEGER:
+ type_mark_used (var->u.integer.type);
2009-08-04 05:37:29 +00:00
+ break;
2009-03-02 00:11:35 +00:00
+
2009-08-19 16:19:15 +00:00
+ case INTERNALVAR_POINTER:
+ type_mark_used (var->u.pointer.type);
+ break;
2009-03-02 00:11:35 +00:00
+ }
+
2009-08-04 05:37:29 +00:00
+ for (chunk = value_history_chain; chunk != NULL; chunk = chunk->next)
2009-03-02 00:11:35 +00:00
+ {
2009-08-04 05:37:29 +00:00
+ int i;
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ for (i = 0; i < ARRAY_SIZE (chunk->values); i++)
+ if (chunk->values[i])
+ type_mark_used (value_type (chunk->values[i]));
2009-03-02 00:11:35 +00:00
+ }
2009-08-04 05:37:29 +00:00
+}
+
/* The 'function' command. This does nothing -- it is just a
placeholder to let "help function NAME" work. This is also used as
the implementation of the sub-command that is created when
2010-11-17 02:58:16 +00:00
@@ -1520,11 +1587,10 @@ preserve_one_value (struct value *value, struct objfile *objfile,
2009-08-04 05:37:29 +00:00
htab_t copied_types)
{
if (TYPE_OBJFILE (value->type) == objfile)
- value->type = copy_type_recursive (objfile, value->type, copied_types);
2009-08-10 13:22:51 +00:00
+ value->type = copy_type_recursive (value->type, copied_types);
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
if (TYPE_OBJFILE (value->enclosing_type) == objfile)
- value->enclosing_type = copy_type_recursive (objfile,
- value->enclosing_type,
2009-08-10 13:22:51 +00:00
+ value->enclosing_type = copy_type_recursive (value->enclosing_type,
copied_types);
2009-08-04 05:37:29 +00:00
}
2009-03-02 00:11:35 +00:00
2010-11-17 02:58:16 +00:00
@@ -1539,13 +1605,13 @@ preserve_one_internalvar (struct internalvar *var, struct objfile *objfile,
2009-08-19 16:19:15 +00:00
case INTERNALVAR_INTEGER:
if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type) == objfile)
var->u.integer.type
- = copy_type_recursive (objfile, var->u.integer.type, copied_types);
+ = copy_type_recursive (var->u.integer.type, copied_types);
break;
case INTERNALVAR_POINTER:
if (TYPE_OBJFILE (var->u.pointer.type) == objfile)
var->u.pointer.type
- = copy_type_recursive (objfile, var->u.pointer.type, copied_types);
+ = copy_type_recursive (var->u.pointer.type, copied_types);
2009-08-04 05:37:29 +00:00
break;
2009-03-02 00:11:35 +00:00
2009-08-04 05:37:29 +00:00
case INTERNALVAR_VALUE:
2010-11-17 02:58:16 +00:00
@@ -2399,7 +2465,24 @@ value_from_decfloat (struct type *type, const gdb_byte *dec)
2010-07-21 21:30:20 +00:00
struct value *
coerce_ref (struct value *arg)
{
- struct type *value_type_arg_tmp = check_typedef (value_type (arg));
+ struct type *value_type_arg_tmp;
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ if (TYPE_DYNAMIC (value_type (arg)))
2009-08-04 05:37:29 +00:00
+ {
2010-07-21 21:30:20 +00:00
+ struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
+ CORE_ADDR address;
2009-03-02 00:11:35 +00:00
+
2010-07-21 21:30:20 +00:00
+ value_type_arg_tmp = value_type (arg);
+ address = value_raw_address (arg);
+ value_type_arg_tmp = object_address_get_data (value_type_arg_tmp,
+ &address);
+ if (! value_type_arg_tmp)
+ error (_("Attempt to coerce non-valid value."));
+ arg = value_at_lazy (value_type_arg_tmp, address);
+ do_cleanups (cleanups);
2009-03-02 00:11:35 +00:00
+ }
2010-07-21 21:30:20 +00:00
+ else
+ value_type_arg_tmp = check_typedef (value_type (arg));
2009-08-04 05:37:29 +00:00
2010-07-21 21:30:20 +00:00
if (TYPE_CODE (value_type_arg_tmp) == TYPE_CODE_REF)
arg = value_at_lazy (TYPE_TARGET_TYPE (value_type_arg_tmp),
2010-11-17 02:58:16 +00:00
@@ -2497,4 +2580,8 @@ VARIABLE is already initialized."));
2009-08-04 05:37:29 +00:00
add_prefix_cmd ("function", no_class, function_command, _("\
Placeholder command for showing help on convenience functions."),
&functionlist, "function ", 0, &cmdlist);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ make_final_cleanup (value_history_cleanup, NULL);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
+ observer_attach_mark_used (value_types_mark_used);
}
diff --git a/gdb/value.h b/gdb/value.h
2010-11-17 02:58:16 +00:00
index ef2cb4f..ac99a4b 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/value.h
+++ b/gdb/value.h
2010-11-17 02:58:16 +00:00
@@ -373,6 +373,10 @@ extern struct value *value_from_double (struct type *type, DOUBLEST num);
2009-08-04 05:37:29 +00:00
extern struct value *value_from_decfloat (struct type *type,
const gdb_byte *decbytes);
+extern const char *object_address_data_not_valid (struct type *type);
2010-07-21 21:30:20 +00:00
+extern struct type *object_address_get_data (struct type *type,
+ CORE_ADDR *address_return);
2009-03-02 00:11:35 +00:00
+
2009-08-04 05:37:29 +00:00
extern struct value *value_at (struct type *type, CORE_ADDR addr);
extern struct value *value_at_lazy (struct type *type, CORE_ADDR addr);
2010-11-17 02:58:16 +00:00
@@ -733,7 +737,7 @@ extern struct value *value_allocate_space_in_inferior (int);
2009-08-04 05:37:29 +00:00
extern struct value *value_of_local (const char *name, int complain);
extern struct value *value_subscripted_rvalue (struct value *array,
- LONGEST index, int lowerbound);
+ CORE_ADDR offset);
/* User function handler. */
diff --git a/gdb/varobj.c b/gdb/varobj.c
2010-11-17 02:58:16 +00:00
index 25518d4..cb5d8a2 100644
2009-08-04 05:37:29 +00:00
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
2009-09-17 12:15:42 +00:00
@@ -26,6 +26,8 @@
2009-08-10 13:22:51 +00:00
#include "gdbcmd.h"
#include "block.h"
#include "valprint.h"
+#include "objfiles.h"
+#include "parser-defs.h"
2009-08-04 05:37:29 +00:00
#include "gdb_assert.h"
#include "gdb_string.h"