From patchwork Mon Aug 22 23:04:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 14862 Received: (qmail 33060 invoked by alias); 22 Aug 2016 23:04:52 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 33031 invoked by uid 89); 22 Aug 2016 23:04:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=*expr, prerequisite X-HELO: gproxy7-pub.mail.unifiedlayer.com Received: from gproxy7-pub.mail.unifiedlayer.com (HELO gproxy7-pub.mail.unifiedlayer.com) (70.40.196.235) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 22 Aug 2016 23:04:41 +0000 Received: (qmail 6095 invoked by uid 0); 22 Aug 2016 23:04:37 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy7.mail.unifiedlayer.com with SMTP; 22 Aug 2016 23:04:37 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id aP4X1t00e2f2jeq01P4aYG; Mon, 22 Aug 2016 17:04:37 -0600 X-Authority-Analysis: v=2.1 cv=Q9FBveGa c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=znx7bYsp1uEA:10 a=7z1cN_iqozsA:10 a=zstS-IiYAAAA:8 a=KKAkSRfTAAAA:8 a=Tc74FtP70L-Gy-J_6GIA:9 a=i-HLp-OcL_bQu5c2:21 a=gW7pfPHXLV8tEZQz:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=cvBusfyB2V15izCimMoJ:22 Received: from 75-171-190-201.hlrn.qwest.net ([75.171.190.201]:34874 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bbyGe-000888-1y; Mon, 22 Aug 2016 17:04:32 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Handle DW_OP_form_tls_address Date: Mon, 22 Aug 2016 17:04:27 -0600 Message-Id: <1471907067-23458-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 75.171.190.201 authed with tom+tromey.com} X-Exim-ID: 1bbyGe-000888-1y X-Source-Sender: 75-171-190-201.hlrn.qwest.net (bapiya.Home) [75.171.190.201]:34874 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== Currently gdb supports DW_OP_GNU_push_tls_address, but not DW_OP_form_tls_address. I think it would be better if the toolchain as a whole moved to using the standard opcode, and the prerequisite to this is getting gdb to recognize it. GCC can sometimes emit DW_OP_form_tls_address for emultls targets. As far as I know, nobody has ever tried this with gdb (since it wouldn't work at all). I don't think there's a major drawback to using a single opcode for all targets, because computing the location of a thread-local is already target specific. This is PR gdb/11616. I don't know how to write a test case for this; though it's worth noting that there aren't explicit tests for DW_OP_GNU_push_tls_address either -- and if I change GCC, these paths will be tested to the same extent they are now. 2016-08-22 Tom Tromey PR gdb/11616: * dwarf2read.c (decode_locdesc): Handle DW_OP_form_tls_address. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Handle DW_OP_form_tls_address. (locexpr_describe_location_piece): Likewise. * dwarf2expr.h (struct dwarf_expr_context_funcs): Update comment. * dwarf2expr.c (execute_stack_op): Handle DW_OP_form_tls_address. (ctx_no_get_tls_address): Mention DW_OP_form_tls_address. * compile/compile-loc2c.c (struct insn_info): Update comment. (compute_stack_depth_worker): Handle DW_OP_form_tls_address. --- gdb/ChangeLog | 13 +++++++++++++ gdb/compile/compile-loc2c.c | 7 ++++--- gdb/dwarf2expr.c | 3 ++- gdb/dwarf2expr.h | 2 +- gdb/dwarf2loc.c | 7 +++++-- gdb/dwarf2read.c | 1 + 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index db3527b..972a533 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +2016-08-22 Tom Tromey + + PR gdb/11616: + * dwarf2read.c (decode_locdesc): Handle DW_OP_form_tls_address. + * dwarf2loc.c (dwarf2_compile_expr_to_ax): Handle + DW_OP_form_tls_address. + (locexpr_describe_location_piece): Likewise. + * dwarf2expr.h (struct dwarf_expr_context_funcs): Update comment. + * dwarf2expr.c (execute_stack_op): Handle DW_OP_form_tls_address. + (ctx_no_get_tls_address): Mention DW_OP_form_tls_address. + * compile/compile-loc2c.c (struct insn_info): Update comment. + (compute_stack_depth_worker): Handle DW_OP_form_tls_address. + 2016-08-19 Yao Qi * aarch64-tdep.c (aarch64_analyze_prologue): Handle register diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 1a267b8..e8bef55 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -48,9 +48,9 @@ struct insn_info unsigned int label : 1; - /* Whether this instruction is DW_OP_GNU_push_tls_address. This is - a hack until we can add a feature to glibc to let us properly - generate code for TLS. */ + /* Whether this instruction is DW_OP_GNU_push_tls_address or + DW_OP_form_tls_address. This is a hack until we can add a + feature to glibc to let us properly generate code for TLS. */ unsigned int is_tls : 1; }; @@ -323,6 +323,7 @@ compute_stack_depth_worker (int start, int *need_tempvar, break; case DW_OP_GNU_push_tls_address: + case DW_OP_form_tls_address: info[ndx].is_tls = 1; break; diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c index 7bf3c78..7eb1982 100644 --- a/gdb/dwarf2expr.c +++ b/gdb/dwarf2expr.c @@ -1257,6 +1257,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, break; case DW_OP_GNU_push_tls_address: + case DW_OP_form_tls_address: /* Variable is at a constant offset in the thread-local storage block into the objfile for the current thread and the dynamic linker module containing this expression. Here @@ -1533,7 +1534,7 @@ ctx_no_get_frame_pc (void *baton) CORE_ADDR ctx_no_get_tls_address (void *baton, CORE_ADDR offset) { - error (_("%s is invalid in this context"), "DW_OP_GNU_push_tls_address"); + error (_("%s is invalid in this context"), "DW_OP_form_tls_address"); } /* Stub dwarf_expr_context_funcs.dwarf_call implementation. */ diff --git a/gdb/dwarf2expr.h b/gdb/dwarf2expr.h index 3d7ca00..cbab45b 100644 --- a/gdb/dwarf2expr.h +++ b/gdb/dwarf2expr.h @@ -56,7 +56,7 @@ struct dwarf_expr_context_funcs CORE_ADDR (*get_frame_pc) (void *baton); /* Return the thread-local storage address for - DW_OP_GNU_push_tls_address. */ + DW_OP_GNU_push_tls_address or DW_OP_form_tls_address. */ CORE_ADDR (*get_tls_address) (void *baton, CORE_ADDR offset); /* Execute DW_AT_location expression for the DWARF expression subroutine in diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index e60475f..946ddf8 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -3571,6 +3571,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc, break; case DW_OP_GNU_push_tls_address: + case DW_OP_form_tls_address: unimplemented (op); break; @@ -3907,7 +3908,8 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, && (data[0] == DW_OP_addr || (addr_size == 4 && data[0] == DW_OP_const4u) || (addr_size == 8 && data[0] == DW_OP_const8u)) - && data[1 + addr_size] == DW_OP_GNU_push_tls_address + && (data[1 + addr_size] == DW_OP_GNU_push_tls_address + || data[1 + addr_size] == DW_OP_form_tls_address) && piece_end_p (data + 2 + addr_size, end)) { ULONGEST offset; @@ -3930,7 +3932,8 @@ locexpr_describe_location_piece (struct symbol *symbol, struct ui_file *stream, && data + 1 + (leb128_size = skip_leb128 (data + 1, end)) < end && data[0] == DW_OP_GNU_const_index && leb128_size > 0 - && data[1 + leb128_size] == DW_OP_GNU_push_tls_address + && (data[1 + leb128_size] == DW_OP_GNU_push_tls_address + || data[1 + leb128_size] == DW_OP_form_tls_address) && piece_end_p (data + 2 + leb128_size, end)) { uint64_t offset; diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 924b417..9ad2caa 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -20817,6 +20817,7 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu) break; case DW_OP_GNU_push_tls_address: + case DW_OP_form_tls_address: /* The top of the stack has the offset from the beginning of the thread control block at which the variable is located. */ /* Nothing should follow this operator, so the top of stack would