From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19688 invoked by alias); 24 Jul 2015 11:12:10 -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 19670 invoked by uid 89); 24 Jul 2015 11:12:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 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-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 24 Jul 2015 11:12:08 +0000 Received: by pabkd10 with SMTP id kd10so13026923pab.2 for ; Fri, 24 Jul 2015 04:12:07 -0700 (PDT) X-Received: by 10.66.242.1 with SMTP id wm1mr26687850pac.79.1437736326922; Fri, 24 Jul 2015 04:12:06 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id fl3sm14003165pdb.30.2015.07.24.04.12.00 (version=TLS1_2 cipher=AES128-SHA256 bits=128/128); Fri, 24 Jul 2015 04:12:04 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 7/8] Initialise target descrption after skipping extra traps for --wrapper References: <1437392126-29503-1-git-send-email-yao.qi@linaro.org> <1437392126-29503-8-git-send-email-yao.qi@linaro.org> <55B17806.2060000@redhat.com> Date: Fri, 24 Jul 2015 11:12:00 -0000 In-Reply-To: <55B17806.2060000@redhat.com> (Pedro Alves's message of "Fri, 24 Jul 2015 00:25:58 +0100") Message-ID: <86bnf1hksj.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-07/txt/msg00688.txt.bz2 Pedro Alves writes: > Instead of this whole code block, I think we should be able to skip > the bits in the function that require accessing registers. E.g., > this: > > /* Cancel actions that rely on GDB not changing the PC (e.g., the > user used the "jump" command, or "set $pc =3D foo"). */ > if (lwp->stop_pc !=3D get_pc (lwp)) > { > /* Collecting 'while-stepping' actions doesn't make sense > anymore. */ > release_while_stepping_state_list (thread); > } > > Could be guarded by: > > if (thread->while_stepping !=3D NULL) > > And this: > > if (the_low_target.get_pc !=3D NULL) > { > struct regcache *regcache =3D get_thread_regcache (current_thread, = 1); > > lwp->stop_pc =3D (*the_low_target.get_pc) (regcache); > > if (debug_threads) > { > debug_printf (" %s from pc 0x%lx\n", step ? "step" : "continue", > (long) lwp->stop_pc); > } > } > > could be guarded by: > > if (proc->tdesc =3D=3D NULL) > > Did you try that? To make sure I understand you correctly, is the change below what you sugge= sted? If yes, I thought about this approach before, but I didn't try that because I was worried that we should check every piece of code in linux_resume_one_lwp_throw and its callees that don't access registers when target description isn't initialised yet. Especially for the_low_target.prepare_to_resume, the implementation of this hook should be aware of that target description may not be available. Nowadays, prepare_to_resume is only used to update HW debug registers, and should be OK because GDBserver shouldn't update HW debug registers before the inferior stops at the first instruction of the program. However, in nat/x86-linux.c:lwp_debug_registers_changed, I saw such comments struct arch_lwp_info *info =3D lwp_arch_private_info (lwp); /* NULL means either that this is the main thread still going through the shell, or that no watchpoint has been set yet. The debug registers are unchanged in either case. */ I was wondering all the implementations of prepare_to_resume of different targets should be aware that "thread still going through the shell"? I'll test this patch on targets other than x86 (such as arm and aarch64) and see if it causes fails. --=20 Yao (=E9=BD=90=E5=B0=A7) @@ -3651,6 +3671,14 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, struct thread_info *thread =3D get_lwp_thread (lwp); struct thread_info *saved_thread; int fast_tp_collecting; + struct process_info *proc =3D get_thread_process (thread); + + /* Note that target description may not be initialised + (proc->tdesc =3D=3D NULL) at this point because the program hasn't + stopped at the first instruction yet. It means GDBserver skips + the extra traps from the wrapper program (see option --wrapper). + Code in this function that requires register access should be + guarded by proc->tdesc =3D=3D NULL or something else. */ =20 if (lwp->stopped =3D=3D 0) return; @@ -3661,7 +3689,7 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, =20 /* Cancel actions that rely on GDB not changing the PC (e.g., the user used the "jump" command, or "set $pc =3D foo"). */ - if (lwp->stop_pc !=3D get_pc (lwp)) + if (thread->while_stepping !=3D NULL && lwp->stop_pc !=3D get_pc (lwp)) { /* Collecting 'while-stepping' actions doesn't make sense anymore. */ @@ -3787,7 +3815,7 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, step =3D 1; } =20 - if (the_low_target.get_pc !=3D NULL) + if (proc->tdesc !=3D NULL && the_low_target.get_pc !=3D NULL) { struct regcache *regcache =3D get_thread_regcache (current_thread, 1= ); =20