aboutsummaryrefslogtreecommitdiff
path: root/gdb/findvar.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-06-03 14:11:08 -0600
committerTom Tromey <tom@tromey.com>2016-07-26 13:43:27 -0600
commit0b31a4bcec2efec9bc8ca40deb61123c52690a2e (patch)
tree174c97fc33b15c671836a0d5f8744b8981dbb7bf /gdb/findvar.c
parent8484fb75874eb9ef35710ac6579433f062ddba18 (diff)
downloadgdb-0b31a4bcec2efec9bc8ca40deb61123c52690a2e.zip
gdb-0b31a4bcec2efec9bc8ca40deb61123c52690a2e.tar.gz
gdb-0b31a4bcec2efec9bc8ca40deb61123c52690a2e.tar.bz2
PR python/20190 - compute TLS symbol without a frame
PR python/20190 arose from an exception I noticed when trying to use the Python unwinder for Spider Monkey in Firefox. The problem is that the unwinder wants to examine the value of a thread-local variable. However, sympy_value rejects this because symbol_read_needs_frame returns true for a TLS variable. This problem arose once before, though in a different context: https://sourceware.org/bugzilla/show_bug.cgi?id=11803 At the time Pedro and Daniel pointed out a simpler way to fix that bug (see links in 20190 if you are interested); but for this new bug I couldn't think of a similar fix and ended up implementing Daniel's other suggestion: https://sourceware.org/ml/gdb-patches/2010-07/msg00393.html That is, this patch makes it possible to detect whether a symbol needs a specific frame, or whether it just needs the inferior to have registers. Built and regtested on x86-64 Fedora 24. 2016-07-26 Tom Tromey <tom@tromey.com> * symtab.c (register_symbol_computed_impl): Update. PR python/20190: * value.h (symbol_read_needs): Declare. (symbol_read_needs_frame): Add comment. * symtab.h (struct symbol_computed_ops) <read_variable>: Update comment. <get_symbol_read_needs>: Rename. Change return type. * findvar.c (symbol_read_needs): New function. (symbol_read_needs_frame): Rewrite. (default_read_var_value): Use symbol_read_needs. * dwarf2loc.c (struct symbol_needs_baton): Rename. <needs>: Renamed from needs_frame. Changed type. (needs_frame_read_addr_from_reg, symbol_needs_get_reg_value) (symbol_needs_read_mem, symbol_needs_frame_base) (symbol_needs_frame_cfa, symbol_needs_tls_address) (symbol_needs_dwarf_call): Rename. (needs_dwarf_reg_entry_value): Update. (symbol_needs_ctx_funcs, dwarf2_loc_desc_get_symbol_read_needs): Rename and update. (locexpr_get_symbol_read_needs, loclist_symbol_needs): Likewise. (dwarf2_locexpr_funcs, dwarf2_loclist_funcs): Update. * defs.h (enum symbol_needs_kind): New. 2016-07-26 Tom Tromey <tom@tromey.com> PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test.
Diffstat (limited to 'gdb/findvar.c')
-rw-r--r--gdb/findvar.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/gdb/findvar.c b/gdb/findvar.c
index c64ec06..6e28a29 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -337,14 +337,13 @@ address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
-/* Will calling read_var_value or locate_var_value on SYM end
- up caring what frame it is being evaluated relative to? SYM must
- be non-NULL. */
-int
-symbol_read_needs_frame (struct symbol *sym)
+/* See value.h. */
+
+enum symbol_needs_kind
+symbol_read_needs (struct symbol *sym)
{
if (SYMBOL_COMPUTED_OPS (sym) != NULL)
- return SYMBOL_COMPUTED_OPS (sym)->read_needs_frame (sym);
+ return SYMBOL_COMPUTED_OPS (sym)->get_symbol_read_needs (sym);
switch (SYMBOL_CLASS (sym))
{
@@ -358,7 +357,7 @@ symbol_read_needs_frame (struct symbol *sym)
case LOC_REF_ARG:
case LOC_REGPARM_ADDR:
case LOC_LOCAL:
- return 1;
+ return SYMBOL_NEEDS_FRAME;
case LOC_UNDEF:
case LOC_CONST:
@@ -374,9 +373,17 @@ symbol_read_needs_frame (struct symbol *sym)
case LOC_CONST_BYTES:
case LOC_UNRESOLVED:
case LOC_OPTIMIZED_OUT:
- return 0;
+ return SYMBOL_NEEDS_NONE;
}
- return 1;
+ return SYMBOL_NEEDS_FRAME;
+}
+
+/* See value.h. */
+
+int
+symbol_read_needs_frame (struct symbol *sym)
+{
+ return symbol_read_needs (sym) == SYMBOL_NEEDS_FRAME;
}
/* Private data to be used with minsym_lookup_iterator_cb. */
@@ -575,6 +582,7 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
struct value *v;
struct type *type = SYMBOL_TYPE (var);
CORE_ADDR addr;
+ enum symbol_needs_kind sym_need;
/* Call check_typedef on our type to make sure that, if TYPE is
a TYPE_CODE_TYPEDEF, its length is set to the length of the target type
@@ -583,8 +591,11 @@ default_read_var_value (struct symbol *var, const struct block *var_block,
set the returned value type description correctly. */
check_typedef (type);
- if (symbol_read_needs_frame (var))
+ sym_need = symbol_read_needs (var);
+ if (sym_need == SYMBOL_NEEDS_FRAME)
gdb_assert (frame != NULL);
+ else if (sym_need == SYMBOL_NEEDS_REGISTERS && !target_has_registers)
+ error (_("Cannot read `%s' without registers"), SYMBOL_PRINT_NAME (var));
if (frame != NULL)
frame = get_hosting_frame (var, var_block, frame);