public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Shahab Vahedi <shahab.vahedi@gmail.com>
To: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>,
	Simon Marchi <simark@simark.ca>,
	Luis Machado <luis.machado@linaro.org>,
	Shahab Vahedi <shahab@synopsys.com>
Subject: Re: Why enforcing sw_breakpoint_from_kind() implementation in GDBserver targets
Date: Wed, 17 Jun 2020 23:31:06 +0200	[thread overview]
Message-ID: <20200617213106.GA1634@gmail.com> (raw)
In-Reply-To: <SN6PR11MB28938F79B770283CF67A3AE3C49D0@SN6PR11MB2893.namprd11.prod.outlook.com>

Hi Baris,

Sorry for my late reply and thank you again for your thorough response.

On Tue, Jun 16, 2020 at 01:15:29PM +0000, Aktemur, Tankut Baris wrote:
> 1. In GDB 9 (i.e. before C++'ification of gdbserver's target definition),
> the base linux target implemented the "sw_breakpoint_from_kind" target op
> to directly delegate to "sw_breakpoint_from_kind" of the linux low target.
> It asserted that the low target's "sw_breakpoint_from_kind" function pointer
> is non-null.

And this is how the ARC port at the time looked like:
gdb/gdbserver/linux-arc-low.c [1]:
...
struct linux_target_ops the_low_target =
{
  arc_arch_setup,
  arc_regs_info,
  arc_cannot_fetch_register,
  arc_cannot_store_register,
  NULL,                      /* fetch_register  */
  linux_get_pc_32bit,
  linux_set_pc_32bit,
  NULL,                      /* breakpoint_kind_from_pc  */
  NULL,                      /* sw_breakpoint_from_kind  */
  NULL,                      /* get_next_pcs  */
  0,                         /* decr_pc_after_break  */
  arc_breakpoint_at,
};
...
This did not hit the assert in base linux implementation, since
"linux_sw_breakpoint_from_kind" was never executed. It's because
the GDB client was writing the breakpoint opcodes to the address
through gdbserver while bypassing sw_breakpoint_from_kind().

> As far as I understand, there is a certain control flow and a combination
> of (un)supported features in the ARC port with which the "sw_breakpoint_from_kind"
> target op is not invoked.  I'm not sure what this flow or feature combination is.

I guess what I explained above should be the case. I do not know
the exact control flow that led/leads to this though.
> Just out of curiosity, is there a specific reason why you want to avoid implementing
> the "sw_breakpoint_from_kind" target op?

No, there is no reason that I might be against it. I brought this whole thing
up because I noticed ARC did not have sw_breakpoint_from_kind implemented and
it was working fine. Even after I implemented the pure virtual method [2], it
does not get executed (I put an assert in a temporary implementation as an
experiment). So it seemed like an unnecessary constraint for compilation.
If we want to deprecate how ARC inserts breakpoints (GDB client writing
the opcode through GDBserver) then that is fine [3]. If not, then implementing
sw_breakpoint_from_kind() shouldn't be mandatory. 

I just wanted to make sure that this message is conveyed. That's all :)

For the record, I plan to change ARC's behavior to really use
sw_breakpoint_from_kind(), but that is not the purpose of this email.


Shahab

[1]
https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/blob/arc-2019.09-gdb/gdb/gdbserver/linux-arc-low.c#L300

[2]
https://github.com/foss-for-synopsys-dwc-arc-processors/binutils-gdb/blob/arc-2020.09/gdbserver/linux-arc-low.cc#L350

[3]
Please keep in mind that if deprecation is wanted, yet still nothing is
stopping ARC (and the likes) from bypassing sw_breakpoint_from_kind().

  reply	other threads:[~2020-06-17 21:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10 17:47 Shahab Vahedi
2020-06-11  3:05 ` Simon Marchi
2020-06-11  9:40   ` Shahab Vahedi
2020-06-11 10:35     ` Luis Machado
2020-06-11 11:00       ` Shahab Vahedi
2020-06-11 11:44         ` Shahab Vahedi
2020-06-12 11:04           ` Aktemur, Tankut Baris
2020-06-15 10:39             ` Shahab Vahedi
2020-06-16 13:15               ` Aktemur, Tankut Baris
2020-06-17 21:31                 ` Shahab Vahedi [this message]
2020-06-17 22:20                   ` Luis Machado
2020-06-11 14:51         ` Simon Marchi
2020-06-15  8:54           ` Metzger, Markus T
2020-06-17  0:40             ` Maciej W. Rozycki
2020-06-18  8:11               ` Metzger, Markus T
2020-06-18  9:13                 ` Maciej W. Rozycki
2020-06-18 10:29                   ` Metzger, Markus T
2020-06-18 11:03                     ` Maciej W. Rozycki
2020-06-18 11:11                       ` Metzger, Markus T
2020-06-11 21:21 ` Martin Simmons

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=20200617213106.GA1634@gmail.com \
    --to=shahab.vahedi@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=luis.machado@linaro.org \
    --cc=shahab@synopsys.com \
    --cc=simark@simark.ca \
    --cc=tankut.baris.aktemur@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).