Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>, gdb-patches@sourceware.org
Cc: Jerome Guitton <guitton@adacore.com>
Subject: Re: [RFA] arm-pikeos: software single step
Date: Tue, 11 Sep 2018 09:08:00 -0000	[thread overview]
Message-ID: <808bd91f-3ad3-9a42-bc04-ac42835fceb9@redhat.com> (raw)
In-Reply-To: <1536592407-13448-1-git-send-email-brobecker@adacore.com>

On 09/10/2018 04:13 PM, Joel Brobecker wrote:
> From: Jerome Guitton <guitton@adacore.com>
> 
> Hello,
> 
> On ARM, PikeOS does not support hardware single step, causing various
> semi-random errors when trying to next/step over some user code. So
> this patch changes this target to use software-single-step instead.
> 
> The challenge is that, up to now, the PikeOS target was in all respects
> identical to a baremetal target as far as GDB was concerned, meaning
> we were using the baremetal osabi for this target too. This is no longer
> possible, and we need to introduce a new OSABI variant. Unfortunately,
> there isn't anything in the object file that would allow us to
> differentiate between the two platforms. So we have to rely on a
> heuristic instead, where we look for some known symbols that are
> required in a PikeOS application (these symbols are expected to be
> defined by the default linker script, and correspond to routines used
> to allocate the application stack).

It's unfortunate to have to introduce an OSABI for something that is a
property of the target that doesn't effect anything when e.g., you're
not connected yet.

It seems to me we can take a better approach here, that eliminates
this particular problem not just for PikeOS, but for all other cases
of random RTOS's.

That is, you should be able to make your stub tell GDB that it
can or can't hardware single step, and then GDB adjusts itself.

We already have all the info we need, we're just not using it.

See target_can_do_single_step and the remote.c implementation:

 int
 remote_target::can_do_single_step ()
 {
   /* We can only tell whether target supports single step or not by
      supported s and S vCont actions if the stub supports vContSupported
      feature.  If the stub doesn't support vContSupported feature,
      we have conservatively to think target doesn't supports single
      step.  */
   if (packet_support (PACKET_vContSupported) == PACKET_ENABLE)


From the manual:

 @item vContSupported
 This feature indicates whether @value{GDBN} wants to know the
 supported actions in the reply to @samp{vCont?} packet.
 @end table

 @item vCont?
 @cindex @samp{vCont?} packet
 Request a list of actions supported by the @samp{vCont} packet.

So, if you make your stub indicate support for the "vContSupported"
feature, and make sure the the reply to "vCont?" does not include
the s/S features, then GDB knows the target does not support
hardware single step.

The only think missing then I think is moving the only call to
target_can_do_single_step out of the arm-linux-tdep.c file:

 static std::vector<CORE_ADDR>
 arm_linux_software_single_step (struct regcache *regcache)
 {
   struct gdbarch *gdbarch = regcache->arch ();
   struct arm_get_next_pcs next_pcs_ctx;
 
   /* 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 {};

into somewhere more generic, around infrun.c:maybe_software_singlestep.

Can you try that?

Thanks,
Pedro Alves

> 
> gdb/ChangeLog (Jerome Guitton  <guitton@adacore.com>):
> 
>         * arm-pikeos-tdep.c: New file.
>         * configure.tgt: Add arm-pikeos-tdep.o to the case of ARM
>         embedded system.
>         * defs.h (enum gdb_osabi): Add GDB_OSABI_PIKEOS.
>         * osabi.c (gdb_osabi_names): Add name for GDB_OSABI_PIKEOS.
> 
> Tested on arm-pikeos and arm-elf using AdaCore's testsuite.
> We also evaluated it on armhf-linux as a cross platform.
> 
> OK to apply?
> 
> Thanks!
> 


  parent reply	other threads:[~2018-09-11  9:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-10 15:13 Joel Brobecker
2018-09-10 17:28 ` Tom Tromey
2018-09-10 17:43   ` Joel Brobecker
2018-09-10 18:39     ` [RFA v2] " y
2018-09-10 20:01       ` Simon Marchi
2018-09-10 20:53         ` Tom Tromey
2018-09-11  8:56         ` Joel Brobecker
2018-09-11  9:58           ` Simon Marchi
2018-09-11 13:51             ` Joel Brobecker
2018-09-11 15:41           ` Tom Tromey
2018-09-11 21:17             ` Joel Brobecker
2018-09-14  0:47               ` Joel Brobecker
2018-09-14 10:57                 ` Simon Marchi
2018-11-01 21:44                 ` Joel Brobecker
2018-09-11  9:08 ` Pedro Alves [this message]
2018-09-11 11:04   ` [RFA] " Joel Brobecker
2018-09-11 11:27     ` Pedro Alves
2018-09-11 20:57       ` Joel Brobecker
2018-09-12 13:22         ` Pedro Alves
2018-09-14  0:38           ` Joel Brobecker

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=808bd91f-3ad3-9a42-bc04-ac42835fceb9@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=guitton@adacore.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