From patchwork Wed Aug 26 19:01:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 8464 Received: (qmail 53162 invoked by alias); 26 Aug 2015 19:02:22 -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 53151 invoked by uid 89); 26 Aug 2015 19:02:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 26 Aug 2015 19:02:19 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 26 Aug 2015 20:02:16 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 26 Aug 2015 20:02:14 +0100 X-MailFrom: uweigand@de.ibm.com X-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 616421B08067 for ; Wed, 26 Aug 2015 20:03:46 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t7QJ2Dhd37290176 for ; Wed, 26 Aug 2015 19:02:14 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t7QJ24fk015461 for ; Wed, 26 Aug 2015 13:02:04 -0600 Received: from oc7340732750.ibm.com (dyn-9-152-213-24.boeblingen.de.ibm.com [9.152.213.24]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t7QJ24fO015292; Wed, 26 Aug 2015 13:02:04 -0600 Received: by oc7340732750.ibm.com (Postfix, from userid 500) id EE3D939FA; Wed, 26 Aug 2015 21:01:57 +0200 (CEST) Subject: Re: Cell multi-arch broken (Re: [PATCH 2/2] GNU/Linux: Stop using libthread_db/td_ta_thr_iter) To: palves@redhat.com (Pedro Alves) Date: Wed, 26 Aug 2015 21:01:57 +0200 (CEST) From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: <55DE0417.4090309@redhat.com> from "Pedro Alves" at Aug 26, 2015 07:23:19 PM MIME-Version: 1.0 Message-Id: <20150826190157.EE3D939FA@oc7340732750.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15082619-0017-0000-0000-000005375581 Pedro Alves wrote: > On 08/26/2015 06:39 PM, Ulrich Weigand wrote: > > > In fact, it is so broken that the test suite assumes we're not even > > on a Cell/B.E. (since it can't debug the trivial test program), and > > silently skips all Cell tests, so I didn't notice in the daily build > > reports ... > > (Sounds like the testsuite could be improved to better detect this.) Yes, I think I'll at least set the test case to UNRESOLVED if something unexpected happens while attempting to detect whether we have Cell/B.E. hardware. > > The reason why we're running into the abort is that the multi-arch > > debugging logic attempts to resolve a thread-local variable from > > inside the frame unwinders (which is probably not done elsewhere). > > This uncovers a code path where the above assertion is wrong: > > Curious. Could you point me at this code path? I can't seem > to find it. I wonder whether can trigger this assertion > by stopping the inferior before thread_db is initialized (e.g., > entry point), and then trying to print a tls variable? (In order > to construct a test case). This is where it triggers for me: #0 internal_error (file=0x107e0ce0 "/home/uweigand/fsf/binutils-gdb/gdb/linux-thread-db.c", line=1663, fmt=0x107dacd8 "%s: Assertion `%s' failed.") at /home/uweigand/fsf/binutils-gdb/gdb/common/errors.c:51 #1 0x00000000100ee6e0 in find_new_threads_once (info=0x10f00de0, iteration=0, errp=0xfffffc6d380) at /home/uweigand/fsf/binutils-gdb/gdb/linux-thread-db.c:1663 #2 0x00000000100ee9ac in thread_db_find_new_threads_2 (ptid=..., until_no_new=) at /home/uweigand/fsf/binutils-gdb/gdb/linux-thread-db.c:1729 #3 0x00000000100eec10 in thread_db_get_thread_local_address (ops=0x10a59fa8, ptid=..., lm=552219129840, offset=4398046642176) at /home/uweigand/fsf/binutils-gdb/gdb/linux-thread-db.c:1856 #4 0x00000000102b0cfc in delegate_get_thread_local_address (self=, arg1=..., arg2=, arg3=) at /home/uweigand/fsf/binutils-gdb/gdb/target-delegates.c:1931 #5 0x00000000100c5540 in ppc_linux_spe_context (wordsize=0, byte_order=BFD_ENDIAN_BIG, n=0, id=0xfffffc6d660, npc=0xfffffc6d664) at /home/uweigand/fsf/binutils-gdb/gdb/ppc-linux-tdep.c:1205 #6 0x00000000100c58f4 in ppu2spu_sniffer (self=, this_frame=0x10c35fe0, this_prologue_cache=0x10c35ff8) at /home/uweigand/fsf/binutils-gdb/gdb/ppc-linux-tdep.c:1341 #7 0x00000000103a276c in frame_unwind_try_unwinder (this_frame=0x10c35fe0, this_cache=0x10c35ff8, unwinder=0x10942b70) at /home/uweigand/fsf/binutils-gdb/gdb/frame-unwind.c:105 #8 0x00000000103a28dc in frame_unwind_find_by_frame (this_frame=0x10c35fe0, this_cache=0x10c35ff8) at /home/uweigand/fsf/binutils-gdb/gdb/frame-unwind.c:160 #9 0x00000000103a0f70 in compute_frame_id (this_frame=0x10c35f10) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:454 #10 get_prev_frame_if_no_cycle (this_frame=0x10c35f10) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:1781 #11 0x00000000103a1260 in get_prev_frame_always_1 (this_frame=0x10c35f10) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:1955 #12 get_prev_frame_always (this_frame=0x10c35f10) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:1971 #13 0x00000000103a1788 in get_prev_frame (this_frame=0x10c35f10) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:2213 #14 0x00000000103a19ac in unwind_to_current_frame (ui_out=, args=) at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:1450 #15 0x000000001027707c in catch_exceptions_with_msg (func_uiout=, func=@0x10a1b980: 0x103a1990 , func_args=0x10c35f10, gdberrmsg=0x0, mask=0) at /home/uweigand/fsf/binutils-gdb/gdb/exceptions.c:187 #16 0x000000001039f2a8 in get_current_frame () at /home/uweigand/fsf/binutils-gdb/gdb/frame.c:1489 #17 0x0000000010264408 in process_event_stop_test (ecs=) at /home/uweigand/fsf/binutils-gdb/gdb/infrun.c:5877 #18 0x0000000010265fac in handle_inferior_event_1 (ecs=0xfffffc6ea08) at /home/uweigand/fsf/binutils-gdb/gdb/infrun.c:5857 #19 handle_inferior_event (ecs=0xfffffc6ea08) at /home/uweigand/fsf/binutils-gdb/gdb/infrun.c:5053 #20 0x0000000010267978 in fetch_inferior_event (client_data=) at /home/uweigand/fsf/binutils-gdb/gdb/infrun.c:3785 #21 0x00000000102864b8 in inferior_event_handler (event_type=INF_REG_EVENT, client_data=0x0) at /home/uweigand/fsf/binutils-gdb/gdb/inf-loop.c:56 #22 0x00000000100f4bb8 in handle_target_event (error=, client_data=) at /home/uweigand/fsf/binutils-gdb/gdb/linux-nat.c:4706 #23 0x0000000010284374 in handle_file_event (file_ptr=0x10ddc670, ready_mask=) at /home/uweigand/fsf/binutils-gdb/gdb/event-loop.c:708 #24 0x00000000102845dc in gdb_wait_for_event (block=) at /home/uweigand/fsf/binutils-gdb/gdb/event-loop.c:859 #25 0x00000000102849c8 in gdb_do_one_event () at /home/uweigand/fsf/binutils-gdb/gdb/event-loop.c:298 #26 0x0000000010284af4 in start_event_loop () at /home/uweigand/fsf/binutils-gdb/gdb/event-loop.c:347 #27 0x0000000010286408 in cli_command_loop (data=) at /home/uweigand/fsf/binutils-gdb/gdb/event-top.c:186 #28 0x000000001027ae28 in current_interp_command_loop () at /home/uweigand/fsf/binutils-gdb/gdb/interps.c:317 #29 0x000000001027bfc4 in captured_command_loop (data=) at /home/uweigand/fsf/binutils-gdb/gdb/main.c:318 #30 0x0000000010276e14 in catch_errors (func=@0x10a0c950: 0x1027bfa0 , func_args=0x0, errstring=0x108d1078 "", mask=0) at /home/uweigand/fsf/binutils-gdb/gdb/exceptions.c:240 #31 0x000000001027cd84 in captured_main (data=) at /home/uweigand/fsf/binutils-gdb/gdb/main.c:1157 #32 0x0000000010276e14 in catch_errors (func=@0x10a0c980: 0x1027c270 , func_args=0xfffffc6f3c0, errstring=0x108d1078 "", mask=0) at /home/uweigand/fsf/binutils-gdb/gdb/exceptions.c:240 #33 0x000000001027ba48 in gdb_main (args=) at /home/uweigand/fsf/binutils-gdb/gdb/main.c:1165 #34 0x0000000010093644 in main (argc=, argv=) at /home/uweigand/fsf/binutils-gdb/gdb/gdb.c:32 I haven't really tried to construct a test case yet ... > Try doing it like gdbserver's thread_db_get_tls_address. > > ... > lwp = get_thread_lwp (thread); > if (!lwp->thread_known) > find_one_thread (thread->entry.id); > ... > > That is, here what we're really after is the td_thrhandle_t > of the current thread, in order to be able to call > td_thr_tls_get_addr. There's no need to walk thread_db's > thread list to find that for a single thread. > > find_one_thread makes use of td_ta_map_lwp2thr for the > mapping we're after. > On the GDB side, the equivalent is linux-thread-db.c:thread_from_lwp. Ah, indeed that works for me. The attached patch also fixes the problem for me. Bye, Ulrich Index: binutils-gdb/gdb/linux-thread-db.c =================================================================== --- binutils-gdb.orig/gdb/linux-thread-db.c +++ binutils-gdb/gdb/linux-thread-db.c @@ -1851,13 +1851,16 @@ thread_db_get_thread_local_address (stru struct thread_info *thread_info; struct target_ops *beneath; - /* If we have not discovered any threads yet, check now. */ - if (!have_threads (ptid)) - thread_db_find_new_threads_1 (ptid); - /* Find the matching thread. */ thread_info = find_thread_ptid (ptid); + /* We may not have discovered the thread yet. */ + if (thread_info != NULL && thread_info->priv == NULL) + { + thread_from_lwp (ptid); + thread_info = find_thread_ptid (ptid); + } + if (thread_info != NULL && thread_info->priv != NULL) { td_err_e err;