From: Antoine Tremblay <antoine.tremblay@ericsson.com>
To: Antoine Tremblay <antoine.tremblay@ericsson.com>
Cc: Yao Qi <qiyaoltc@gmail.com>, <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32.
Date: Thu, 01 Dec 2016 15:55:00 -0000 [thread overview]
Message-ID: <wwokwpfjwsop.fsf@ericsson.com> (raw)
In-Reply-To: <wwoky3zzwtwx.fsf@ericsson.com>
Antoine Tremblay writes:
> Yao Qi writes:
>
>> On Mon, Nov 28, 2016 at 07:27:56AM -0500, Antoine Tremblay wrote:
>>> Before this patch, some functions would read the inferior memory with
>>> (*the_target)->read_memory, which returns the raw memory, rather than the
>>> shadowed memory.
>>>
>>> This is wrong since these functions do not expect to read a breakpoint
>>> instruction and can lead to invalid behavior.
>>>
>>> Use of raw memory in get_next_pcs_read_memory_unsigned_integer for example
>>> could lead to get_next_pc returning an invalid pc.
>>
>> Can you elaborate under what circumstance breakpoints are still in memory
>> when these functions are called? Can we have a test case?
>>
>
> Here is an example:
>
> In non-stop mode multiple threads are stepping, like in the
> non-stop-fair-events.exp test.
>
> GDB:
> thread 1
> step&
>
> GDBServer:
> thread 1 is at instruction A
> installs single step breakpoint on instruction B
>
> GDB:
> thread 2
> step&
>
> GDBServer:
>
> thread 2 is at instruction B
>
> GDBServer needs to install a single step breakpoint at the next
> instruction from B.
>
> To do so get_next_pc is called, but since the single step
> breakpoint for thread 1 at instruction B is there. get_next_pc
> reads the current instruction as a breakpoint instruction and fails.
>
> Note that I used a user driven example here to make it more clear but
> this is also true while range-stepping in a loop for example:
>
> - thread 1 hits its single-step breakpoint deletes it
> - it's not out of a range-step so
> - tries to install a single-step breakpoint at the next
> instruction
> - but thread 2 has a breakpoint at thread 1's current
> instruction and get_next_pc fails.
>
> This is already tested by non-stop-fair-events.exp, the test will fail
> without this patch.
>
> Note that this test is testing both range-stepping and the user
> stepping.
>
Sorry I got confused with the code patched with the latest 2 patches I
sent refactoring the single stepping code.
Considering the current code this is handled by the step-over process,
and should not be an issue as it will always step-over before installing
any single-step breakpoints.
And step-over removes all breakpoints when stepping over thus
get_next_pc is ok.
This becomes an issue like I said before with
https://sourceware.org/ml/gdb-patches/2016-11/msg00939.html
Since with this it's possible to install single-step breakpoints without
a step-over check.
We could consider this patch a preparation for
https://sourceware.org/ml/gdb-patches/2016-11/msg00939.html
or just a good pratice to use target_read_memory.
Thanks,
Antoine
next prev parent reply other threads:[~2016-12-01 15:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 12:28 Antoine Tremblay
2016-11-28 12:28 ` [PATCH 3/3] Fix inferior memory reading in GDBServer for sparc Antoine Tremblay
2016-12-09 12:51 ` Antoine Tremblay
2016-11-28 12:28 ` [PATCH 2/3] Fix inferior memory reading in GDBServer for ppc Antoine Tremblay
2016-11-30 20:46 ` [PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32 Luis Machado
2016-12-01 14:44 ` Yao Qi
2016-12-01 15:28 ` Antoine Tremblay
2016-12-01 15:55 ` Antoine Tremblay [this message]
2016-12-01 16:18 ` Antoine Tremblay
2016-12-01 18:10 ` Antoine Tremblay
2016-12-09 12:06 ` Yao Qi
2016-12-09 12:22 ` [PATCH v2] " Antoine Tremblay
2016-12-09 12:23 ` [PATCH 1/3] " Yao Qi
2016-12-09 12:46 ` [PATCH v3] " Antoine Tremblay
2017-01-09 11:55 ` Antoine Tremblay
2017-01-09 17:31 ` Yao Qi
2017-01-09 17:41 ` Antoine Tremblay
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=wwokwpfjwsop.fsf@ericsson.com \
--to=antoine.tremblay@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.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