* [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation.
@ 2018-09-11 21:29 Sandra Loosemore
2018-09-12 17:49 ` Richard Henderson
0 siblings, 1 reply; 5+ messages in thread
From: Sandra Loosemore @ 2018-09-11 21:29 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.bennee, crwulff, marex, Sandra Loosemore
Without this patch, QEMU exits immediately when it execution stops at
a breakpoint, instead of reporting it to GDB.
Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
---
linux-user/nios2/cpu_loop.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
index dac7a06..a5ae37f 100644
--- a/linux-user/nios2/cpu_loop.c
+++ b/linux-user/nios2/cpu_loop.c
@@ -71,6 +71,9 @@ void cpu_loop(CPUNios2State *env)
gdbsig = TARGET_SIGTRAP;
break;
}
+ case EXCP_DEBUG:
+ gdbsig = TARGET_SIGTRAP;
+ break;
case 0xaa:
switch (env->regs[R_PC]) {
/*case 0x1000:*/ /* TODO:__kuser_helper_version */
--
2.8.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation.
2018-09-11 21:29 [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation Sandra Loosemore
@ 2018-09-12 17:49 ` Richard Henderson
2018-09-12 18:01 ` Sandra Loosemore
2018-09-12 18:39 ` Alex Bennée
0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2018-09-12 17:49 UTC (permalink / raw)
To: Sandra Loosemore, qemu-devel; +Cc: marex, crwulff, alex.bennee
On 09/11/2018 02:29 PM, Sandra Loosemore wrote:
> Without this patch, QEMU exits immediately when it execution stops at
> a breakpoint, instead of reporting it to GDB.
>
> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
> ---
> linux-user/nios2/cpu_loop.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
> index dac7a06..a5ae37f 100644
> --- a/linux-user/nios2/cpu_loop.c
> +++ b/linux-user/nios2/cpu_loop.c
> @@ -71,6 +71,9 @@ void cpu_loop(CPUNios2State *env)
> gdbsig = TARGET_SIGTRAP;
> break;
> }
> + case EXCP_DEBUG:
> + gdbsig = TARGET_SIGTRAP;
> + break;
This really isn't complete. You set gdbsig from odd places instead of using
queue_signal; you fail to honor the return value from gdb_handlesig.
But I suppose those should be separate patches, so
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation.
2018-09-12 17:49 ` Richard Henderson
@ 2018-09-12 18:01 ` Sandra Loosemore
2018-09-12 18:39 ` Alex Bennée
1 sibling, 0 replies; 5+ messages in thread
From: Sandra Loosemore @ 2018-09-12 18:01 UTC (permalink / raw)
To: Richard Henderson, qemu-devel; +Cc: marex, crwulff, alex.bennee
On 09/12/2018 11:49 AM, Richard Henderson wrote:
> On 09/11/2018 02:29 PM, Sandra Loosemore wrote:
>> Without this patch, QEMU exits immediately when it execution stops at
>> a breakpoint, instead of reporting it to GDB.
>>
>> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
>> ---
>> linux-user/nios2/cpu_loop.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
>> index dac7a06..a5ae37f 100644
>> --- a/linux-user/nios2/cpu_loop.c
>> +++ b/linux-user/nios2/cpu_loop.c
>> @@ -71,6 +71,9 @@ void cpu_loop(CPUNios2State *env)
>> gdbsig = TARGET_SIGTRAP;
>> break;
>> }
>> + case EXCP_DEBUG:
>> + gdbsig = TARGET_SIGTRAP;
>> + break;
>
> This really isn't complete. You set gdbsig from odd places instead of using
> queue_signal; you fail to honor the return value from gdb_handlesig.
>
> But I suppose those should be separate patches, so
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Yes, I thought this code was rather ugly. But I thought a minimal patch
to un-break GDB use would be easier to get in than any kind of rewrite,
particularly given that I'm not terribly familiar with current best
practices in the QEMU development community, etc.
-Sandra
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation.
2018-09-12 17:49 ` Richard Henderson
2018-09-12 18:01 ` Sandra Loosemore
@ 2018-09-12 18:39 ` Alex Bennée
2018-09-12 19:31 ` Sandra Loosemore
1 sibling, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2018-09-12 18:39 UTC (permalink / raw)
To: Richard Henderson; +Cc: Sandra Loosemore, qemu-devel, marex, crwulff
Richard Henderson <richard.henderson@linaro.org> writes:
> On 09/11/2018 02:29 PM, Sandra Loosemore wrote:
>> Without this patch, QEMU exits immediately when it execution stops at
>> a breakpoint, instead of reporting it to GDB.
>>
>> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
>> ---
>> linux-user/nios2/cpu_loop.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
>> index dac7a06..a5ae37f 100644
>> --- a/linux-user/nios2/cpu_loop.c
>> +++ b/linux-user/nios2/cpu_loop.c
>> @@ -71,6 +71,9 @@ void cpu_loop(CPUNios2State *env)
>> gdbsig = TARGET_SIGTRAP;
>> break;
>> }
>> + case EXCP_DEBUG:
>> + gdbsig = TARGET_SIGTRAP;
>> + break;
>
> This really isn't complete. You set gdbsig from odd places instead of using
> queue_signal; you fail to honor the return value from gdb_handlesig.
>
> But I suppose those should be separate patches, so
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
At least the cpu_loops have been separated now.. I guess the next step
is to audit each one for common features? There do seem to be some magic
numbers in the nios loop which I find concerning.
>
>
> r~
--
Alex Bennée
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation.
2018-09-12 18:39 ` Alex Bennée
@ 2018-09-12 19:31 ` Sandra Loosemore
0 siblings, 0 replies; 5+ messages in thread
From: Sandra Loosemore @ 2018-09-12 19:31 UTC (permalink / raw)
To: Alex Bennée, Richard Henderson; +Cc: qemu-devel, marex, crwulff
On 09/12/2018 12:39 PM, Alex Bennée wrote:
>
> Richard Henderson <richard.henderson@linaro.org> writes:
>
>> On 09/11/2018 02:29 PM, Sandra Loosemore wrote:
>>> Without this patch, QEMU exits immediately when it execution stops at
>>> a breakpoint, instead of reporting it to GDB.
>>>
>>> Signed-off-by: Sandra Loosemore <sandra@codesourcery.com>
>>> ---
>>> linux-user/nios2/cpu_loop.c | 3 +++
>>> 1 file changed, 3 insertions(+)
>>>
>>> diff --git a/linux-user/nios2/cpu_loop.c b/linux-user/nios2/cpu_loop.c
>>> index dac7a06..a5ae37f 100644
>>> --- a/linux-user/nios2/cpu_loop.c
>>> +++ b/linux-user/nios2/cpu_loop.c
>>> @@ -71,6 +71,9 @@ void cpu_loop(CPUNios2State *env)
>>> gdbsig = TARGET_SIGTRAP;
>>> break;
>>> }
>>> + case EXCP_DEBUG:
>>> + gdbsig = TARGET_SIGTRAP;
>>> + break;
>>
>> This really isn't complete. You set gdbsig from odd places instead of using
>> queue_signal; you fail to honor the return value from gdb_handlesig.
>>
>> But I suppose those should be separate patches, so
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> At least the cpu_loops have been separated now.. I guess the next step
> is to audit each one for common features? There do seem to be some magic
> numbers in the nios loop which I find concerning.
I'm not sure where the 0xaa value came from, but it is used to indicate
syscalls through the kuser page mapped at address 0x1000 in user space.
The addresses are a fixed ABI although not terribly well-documented
AFAICT. There's code in target/nios2 that catches attempts to execute
code on that page, and in the Linux kernel the code that goes on the
kuser page is at the end of arch/nios2/kernel/entry.S. This all could
certainly be better documented in the QEMU cpu_loop code too.
-Sandra
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-09-12 19:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-11 21:29 [Qemu-devel] [PATCH] Fix breakpoints in nios2 user-mode emulation Sandra Loosemore
2018-09-12 17:49 ` Richard Henderson
2018-09-12 18:01 ` Sandra Loosemore
2018-09-12 18:39 ` Alex Bennée
2018-09-12 19:31 ` Sandra Loosemore
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 NNTP newsgroup(s).