From: Yao Qi <yao@codesourcery.com>
To: Jon Burgess <jburgess777@gmail.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [RFC][PATCH] arm-tdep.c (arm_m_exception_cache): Handle stack switching to PSP during exception unwind.
Date: Tue, 23 Sep 2014 05:30:00 -0000 [thread overview]
Message-ID: <8761geykjg.fsf@codesourcery.com> (raw)
In-Reply-To: <1411253227.22117.27.camel@shark.nightingale.homedns.org> (Jon Burgess's message of "Sat, 20 Sep 2014 23:47:07 +0100")
Jon Burgess <jburgess777@gmail.com> writes:
> + /* The EXC_RETURN address indicates what type of transition
Nitpick: I'd like to say "EXC_RETURN (exception return address)" rather
than "EXC_RETURN address", because its value is the magic address.
> + the CPU makes when returning from the exception. A value
> + of 0xfffffffd causes the stack pointer to switch from
> + MSP to PSP. */
I'd like to replace MSP and PSP with SP_main and SP_process, which are
used in the ARMv7-M ARM.
These details in your comments are described in ARMv7-M ARM. IWBN to
add something like:
See details in "B1.5.8 Exception return behavior" in "ARMv7-M
Architecture Reference Manual".
> + if (this_pc == 0xfffffffd) {
> + int pspreg;
> + struct regcache *regcache;
> + struct value *pspval;
> +
> + pspreg = user_reg_map_name_to_regnum (gdbarch, "psp", 3);
The main sp and process sp aren't in the gdb's target description.
Different gdb stubs (jtag probes) may name them differently. OpenOCD
names it as "psp", but our codesourcery sprite names it as "sp_main".
We may need an array for the names of process sp, and iterate the array
to find the number by different name variants.
> + gdb_assert (pspreg != -1);
This is too strong to me. If the process sp isn't found, it means GDB
stub doesn't provide process sp in the target description or the name of
process sp isn't recognized by GDB. It is not GDB's fault. We can emit
an error here, IMO.
> +
> + regcache = get_current_regcache ();
> + pspval = regcache_cooked_read_value (regcache, pspreg);
In general, getting the register value in unwinding from current
regcache is wrong, because register value should be got from the
previous frame. However, in the case that getting process sp in
exception on cortex-m, it is correct. At this point, the program is
still in exception, and main sp is used (process sp isn't used nor changed).
When GDB is unwinding frames from the exception to the application, the
process sp register is still valid.
--
Yao (齐尧)
next prev parent reply other threads:[~2014-09-23 5:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-20 22:47 Jon Burgess
2014-09-22 18:16 ` Sergio Durigan Junior
2014-09-23 5:30 ` Yao Qi [this message]
2014-09-23 8:38 ` Pedro Alves
2014-09-23 12:27 ` Yao Qi
2014-09-23 12:45 ` Pedro Alves
2015-05-07 18:00 ` Simon Schubert
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=8761geykjg.fsf@codesourcery.com \
--to=yao@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=jburgess777@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