From 0b31a4bcec2efec9bc8ca40deb61123c52690a2e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 3 Jun 2016 14:11:08 -0600 Subject: 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 * 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) : Update comment. : 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. : 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 PR python/20190: * gdb.threads/tls.exp (check_thread_local): Add python symbol test. --- gdb/testsuite/gdb.threads/tls.exp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'gdb/testsuite/gdb.threads') diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp index 29384e5..5c07844 100644 --- a/gdb/testsuite/gdb.threads/tls.exp +++ b/gdb/testsuite/gdb.threads/tls.exp @@ -14,6 +14,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . */ +load_lib gdb-python.exp + standard_testfile tls.c tls2.c if [istarget "*-*-linux"] then { @@ -70,6 +72,17 @@ proc check_thread_local {number} { "= $expected_value" \ "${number} thread local storage" + if {![skip_python_tests]} { + gdb_test_no_output \ + "python sym = gdb.lookup_symbol('a_thread_local')\[0\]" \ + "${number} look up a_thread_local symbol" + # We intentionally do not pass a frame to "value" here. If a + # TLS variable requires a frame, this will fail. However, if + # it does not require a frame, then it will succeed. + gdb_test "python print(sym.value())" "$expected_value" \ + "${number} get symbol value without frame" + } + gdb_test "p K::another_thread_local" \ "= $me_variable" \ "${number} another thread local storage" @@ -139,6 +152,10 @@ proc check_thread_stack {number spin_threads spin_threads_level} { } clean_restart ${binfile} + +gdb_test "print a_thread_local" \ + "Cannot read .a_thread_local. without registers" + if ![runto_main] then { fail "Can't run to main" return 0 -- cgit v1.1