From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115190 invoked by alias); 26 Oct 2015 10:55:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 115178 invoked by uid 89); 26 Oct 2015 10:55:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f49.google.com Received: from mail-pa0-f49.google.com (HELO mail-pa0-f49.google.com) (209.85.220.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 26 Oct 2015 10:55:43 +0000 Received: by pacfa8 with SMTP id fa8so6481072pac.0 for ; Mon, 26 Oct 2015 03:55:41 -0700 (PDT) X-Received: by 10.66.233.104 with SMTP id tv8mr21125071pac.56.1445856941814; Mon, 26 Oct 2015 03:55:41 -0700 (PDT) Received: from E107787-LIN (gcc2-power8.osuosl.org. [140.211.9.43]) by smtp.gmail.com with ESMTPSA id fx3sm21355689pbb.60.2015.10.26.03.55.38 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 26 Oct 2015 03:55:41 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 04/18] gdbserver crash running gdb.threads/non-ldr-exc-1.exp References: <1444836486-25679-1-git-send-email-palves@redhat.com> <1444836486-25679-5-git-send-email-palves@redhat.com> Date: Mon, 26 Oct 2015 13:54:00 -0000 In-Reply-To: <1444836486-25679-5-git-send-email-palves@redhat.com> (Pedro Alves's message of "Wed, 14 Oct 2015 16:27:52 +0100") Message-ID: <86mvv52920.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-10/txt/msg00554.txt.bz2 Pedro Alves writes: > diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c > index e25b7c7..ec52f84 100644 > --- a/gdb/gdbserver/server.c > +++ b/gdb/gdbserver/server.c > @@ -1971,6 +1971,27 @@ handle_query (char *own_buf, int packet_len, int *= new_packet_len_p) >=20=20 > if (strcmp ("qSymbol::", own_buf) =3D=3D 0) > { > + struct thread_info *save_thread =3D current_thread; > + > + /* For qSymbol, GDB only changes the current thread if the > + previous current thread was of a different process. So if > + the previous thread is gone, we need to pick another one of > + the same process. This can happen e.g., if we followed an > + exec in a non-leader thread. */ > + if (current_thread =3D=3D NULL) > + { > + current_thread =3D find_any_thread_of_pid (ptid_get_pid (general_thre= ad)); > + Nit, this line is too long. Patch looks good to me, otherwise. I do something similar in AArch64 GDBserver backend to fix the crash. Could you include this patch in your series if it is OK to you? My patch depends on your patch 04/18. Note that I didn't add "set_general_process" as you suggested, because I am not 100% sure the rules of switching current_thread. --=20 Yao (=E9=BD=90=E5=B0=A7) =46rom 58ad7851575c5b9c1a2343e6de3dfb4b7b51a6c6 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Fri, 23 Oct 2015 14:00:50 +0100 Subject: [PATCH] [aarch64] gdbserver crash running gdb.threads/no-unwaited-for-left.exp This fixes an aarch64 GDBserver crash when running gdb.threads/no-unwaited-for-left.exp. The problem is that current_thread is NULL when GDBserver checks whether is 64-bit or not. The fix is straightforward, if current_thread is NULL, find other thread in the same process. If none is found, assume the thread is 64-bit. gdb/gdbserver: 2015-10-26 Yao Qi * linux-aarch64-low.c (is_64bit_tdesc): If current_thread is NULL, select another thread of the same process, otherwise, select current_thread. diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch6= 4-low.c index cb49a04..54d8891 100644 --- a/gdb/gdbserver/linux-aarch64-low.c +++ b/gdb/gdbserver/linux-aarch64-low.c @@ -81,7 +81,24 @@ struct arch_process_info static int is_64bit_tdesc (void) { - struct regcache *regcache =3D get_thread_regcache (current_thread, 0); + struct thread_info *thread; + struct regcache *regcache; + + /* If the current thread is gone, pick another one of the same + process. */ + if (current_thread =3D=3D NULL) + thread =3D find_any_thread_of_pid (ptid_get_pid (general_thread)); + else + thread =3D current_thread; + + if (thread =3D=3D NULL) + { + /* If we didn't find a thread, assume the inferior will be an + aarch64 process. */ + return 1; + } + + regcache =3D get_thread_regcache (thread, 0); =20 return register_size (regcache->tdesc, 0) =3D=3D 8; }