Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: Pedro Alves <palves@redhat.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH 00/18] Remote all-stop on top of non-stop
Date: Mon, 19 Oct 2015 11:48:00 -0000	[thread overview]
Message-ID: <86h9ln2i6x.fsf@gmail.com> (raw)
In-Reply-To: <86lhb23gm4.fsf@gmail.com> (Yao Qi's message of "Fri, 16 Oct 2015	17:47:31 +0100")

Yao Qi <qiyaoltc@gmail.com> writes:

> There is one fail on multi-arch aarch64-linux in
> gdb.base/range-stepping.exp,
>
>   FAIL: gdb.base/range-stepping.exp: multi insns: next: vCont;s=1 vCont;r=1
>
> in the testing GDB and GDBserver is configured for aarch64-linux, but
> the program is compiled for arm-linux.  I checked gdb.log that there is
> vCont;r but no vCont;s.  I suspect that GDB does software single
> step, but arm-linux-tdep.c:arm_linux_software_single_step has already disable
> software single step if GDBserver can do single step (AArch64 GDBserver
> can do hardware single step).

Hi Pedro,
This fail above isn't caused by your patch series, but this series
exposes something we need to think about here.

In the test, after command "n" is issued, the test expects to see
vCont;s and vCont;r, because GDB first steps over the breakpoint and
then do range-stepping across the line of code.  Here is an assumption
that the remote target can do range stepping must support single step
(either by hardware or by software done by remote target itself), and
that is why I check the number vCont;r and vCont;s in the tests.  This
assumption is true for x86-linux and aarch64-linux.

However, it isn't the case when aarch64-linux GDBservers debugs
arm-linux program.  Aarch64-linux GDBserver claims supporting
range-stepping by defining aarch64_supports_range_stepping in
linux-aarch64-low.c, gdb.base/range-stepping.exp is tested.
(Note that this test is skipped on pure arm-linux testing, because
arm-linux GDBserver doesn't support range-stepping).  GDB will still
emit vCont;r to do range stepping, that is fine.

Before range-stepping, GDB needs to step over the breakpoint by in-line
stepping, GDB uses the right gdbarch (for arm-linux) to do that, so the
right decision on hardware single step vs software single step can be
made according to target_can_do_single_step ...

static int
arm_linux_software_single_step (struct frame_info *frame)
{
  struct gdbarch *gdbarch = get_frame_arch (frame);
  struct address_space *aspace = get_frame_address_space (frame);
  CORE_ADDR next_pc;

  if (arm_deal_with_atomic_sequence (frame))
    return 1;

  /* If the target does have hardware single step, GDB doesn't have
     to bother software single step.  */
  if (target_can_do_single_step () == 1)
    return 0;

in the multi-arch case, GDB stills emit vCont;s because it knows the
remote target can do single step.  That is why these tests pass before.

With your patch applied, GDB prefers to step over the breakpoint by
out-of-line stepping, and nowadays gdbarch (for arm-linux) decides to
resume the instructions in scratchpad rather than single step them,

in infrun.c:resume:

	  /* Update pc to reflect the new address from which we will
	     execute instructions due to displaced stepping.  */
	  pc = regcache_read_pc (get_thread_regcache (inferior_ptid));

	  displaced = get_displaced_stepping_state (ptid_get_pid (inferior_ptid));
	  step = gdbarch_displaced_step_hw_singlestep (gdbarch,
						       displaced->step_closure);

(gdbarch_displaced_step_hw_singlestep returns zero on arm-linux), so GDB
emits vCont;c rather than vCont;s.  There are some ways fixing this
problem,

 1. stop checking vCont;s packet anymore in range-stepping tests.
 2. let gdbarch_displaced_step_hw_singlestep returns true for arm-linux
 in the multi-arch case like this,

int
arm_displaced_step_hw_singlestep (struct gdbarch *gdbarch,
				  struct displaced_step_closure *closure)
{
  if (target_can_do_single_step () == 1)
    return 1;

  return 0;
}
then further, we need to either,

  2.1 teach GDB core to support single stepping multiple instructions in
  scratch pad.  Nowadays, GDB only expects one stop event when executing
  instructions in the scratchpad.  ARM is the only target that GDB
  copies more than one instructions to the scratchpad, and resume
  program there instead of single step.  Other targets, like x86,
  aarch64, GDB only copies *one* instruction to the scratchpad and
  single step.
  2.2 rewrite arm displaced stepping code to be aware that the target
  may be able to do single step, so that each time GDB has only to copy
  one instruction to the scratchpad, do single step and fix up if necessary.

Fix #1 looks reasonable and ideal to me, and the easiest one.  Fix #2.1
and #2.2 will need much work, at least #2.2, and I don't know how useful
#2.1 is.

-- 
Yao (齐尧)


  reply	other threads:[~2015-10-19 11:48 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14 15:28 Pedro Alves
2015-10-14 15:28 ` [PATCH 01/18] Fix mi-nonstop.exp with extended-remote Pedro Alves
2015-10-14 15:28 ` [PATCH 18/18] remote: enable "maint set target-non-stop" by default Pedro Alves
2015-10-14 15:28 ` [PATCH 15/18] gdbserver:prepare_access_memory: pick another thread Pedro Alves
2015-10-14 15:28 ` [PATCH 02/18] Remote all-stop-on-top-of-non-stop Pedro Alves
2015-10-24 22:39   ` Yao Qi
2015-11-23 15:40     ` Pedro Alves
2015-11-23 18:39       ` Pedro Alves
2015-11-26 15:53         ` Yao Qi
2015-10-14 15:28 ` [PATCH 03/18] attach + target always in non-stop mode: stop all threads Pedro Alves
2015-10-26 13:22   ` Yao Qi
2015-11-23 18:15     ` Pedro Alves
2015-11-23 18:42       ` Pedro Alves
2015-11-26 16:12       ` Yao Qi
2015-11-26 16:23         ` Pedro Alves
2015-11-27  9:33           ` Yao Qi
2015-10-14 15:28 ` [PATCH 13/18] infrun: Fix TARGET_WAITKIND_NO_RESUMED handling in non-stop mode Pedro Alves
2015-10-14 15:33 ` [PATCH 05/18] remote: stop reason and watchpoint data address per thread Pedro Alves
2015-10-14 15:33 ` [PATCH 10/18] Remote thread create/exit events Pedro Alves
2015-10-14 16:35   ` Eli Zaretskii
2015-10-26 16:50   ` Yao Qi
2015-11-23 15:41     ` Pedro Alves
2015-12-01 15:12   ` Ulrich Weigand
2015-12-01 16:06     ` Pedro Alves
2015-12-01 17:10       ` Ulrich Weigand
2015-10-14 15:36 ` [PATCH 04/18] gdbserver crash running gdb.threads/non-ldr-exc-1.exp Pedro Alves
2015-10-26 13:54   ` Yao Qi
2015-11-24 16:34     ` Pedro Alves
2015-11-26 16:23       ` Yao Qi
2015-11-30 14:53         ` Pedro Alves
2015-10-14 15:36 ` [PATCH 06/18] New vCtrlC packet, non-stop mode equivalent of \003 Pedro Alves
2015-10-26 14:11   ` Yao Qi
2015-11-30 18:25     ` Pedro Alves
2015-10-14 15:36 ` [PATCH 17/18] gdbserver: don't exit until GDB disconnects Pedro Alves
2015-10-14 15:36 ` [PATCH 11/18] gdbserver: fix killed-outside.exp Pedro Alves
2015-10-27 12:02   ` Yao Qi
2015-11-25 15:06     ` Pedro Alves
2015-11-26 16:51       ` Yao Qi
2015-11-26 17:56         ` Pedro Alves
2015-10-14 15:36 ` [PATCH 12/18] testsuite: Range stepping and non-stop mode Pedro Alves
2015-10-14 15:36 ` [PATCH 14/18] Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Pedro Alves
2015-10-14 16:36   ` Eli Zaretskii
2015-10-19 16:21   ` Yao Qi
2015-10-19 16:48     ` Pedro Alves
2015-10-14 15:37 ` [PATCH 09/18] Make dprintf-non-stop.exp cope with remote testing Pedro Alves
2015-10-14 15:37 ` [PATCH 07/18] gdbserver crash if gdb attaches too fast Pedro Alves
2015-10-14 15:37 ` [PATCH 16/18] gdbserver/linux: Always wake up event loop after resume Pedro Alves
2015-10-26 17:28   ` Yao Qi
2015-11-25 15:31     ` Pedro Alves
2015-10-14 15:38 ` [PATCH 08/18] gdbserver resume_stop handling bug Pedro Alves
2015-10-14 16:37   ` Eli Zaretskii
2015-11-25 15:12     ` Pedro Alves
2015-11-25 17:53       ` Eli Zaretskii
2015-10-15 10:46 ` [PATCH 00/18] Remote all-stop on top of non-stop Pedro Alves
2015-10-16 16:47 ` Yao Qi
2015-10-19 11:48   ` Yao Qi [this message]
2015-10-19 15:28     ` Pedro Alves
2015-10-19 15:47       ` Yao Qi
2015-10-27 13:11 ` Yao Qi
2015-11-30 19:59   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86h9ln2i6x.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox