qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Abid, Hafiz" <hafiz_abid@mentor.com>
Cc: gdb@sourceware.org, riku.voipio@iki.fi, macro@codesourcery.com,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] GDB function call failing due to memory protection of stack page in QEMU
Date: Thu, 18 Apr 2013 09:36:55 +0100	[thread overview]
Message-ID: <CAFEAcA_1_+xnCU-s4CSbMJbk-CSAy9mL2YThNo9-tXUOT_C9eg@mail.gmail.com> (raw)
In-Reply-To: <1365679257.9625.0@abidh-ubunto1104>

On 11 April 2013 12:20, Abid, Hafiz <hafiz_abid@mentor.com> wrote:
> Hi All,
> I have faced a problem using GDB with user-mode qemu. Although problem was
> observed for MIPS, I think it is a generic problem. I would appreciate an
> advice from experts on how best to deal with. Here is the problem
> description.
>
> GDB has ability to call function from the program being debugged
> (http://sourceware.org/gdb/onlinedocs/gdb/Calling.html#Calling). For MIPS
> (and on other architectures), it put a breakpoint on the stack that is used
> as return address of the function. When that breakpoint is hit, GDB knows
> that function is complete and it can return control to user. This breakpoint
> on stack causes problem for QEMU. When it runs that instruction from stack,
> it add write-protection to that page. So after the function call, GDB is not
> able to write to stack. So any future function call or other operation that
> need to write to stack will fail. I show an example session below taken
> mostly from call-sc.exp of GDB testsuite.
>
> There are 2 possible solution in my mind. One was to allow writing memory if
> this page originally had write access. This is a single line fix and a patch
> is below.

My worry here is that this will mean that writes by the
debugger won't trigger the "code area has been written, QEMU
must throw away any cached translated code for that region"
check. This is a tricky area of the code...

thanks
-- PMM

  parent reply	other threads:[~2013-04-18  8:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 11:20 [Qemu-devel] GDB function call failing due to memory protection of stack page in QEMU Abid, Hafiz
2013-04-18  8:31 ` Abid, Hafiz
2013-04-18  8:36 ` Peter Maydell [this message]
2013-04-18  9:28   ` Abid, Hafiz

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=CAFEAcA_1_+xnCU-s4CSbMJbk-CSAy9mL2YThNo9-tXUOT_C9eg@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=gdb@sourceware.org \
    --cc=hafiz_abid@mentor.com \
    --cc=macro@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /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 NNTP newsgroup(s).