From: Sandra Loosemore <sandra@codesourcery.com>
To: Yao Qi <yao@codesourcery.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [patch, nios2] clean up prologue/epilogue detection code
Date: Mon, 24 Nov 2014 23:52:00 -0000 [thread overview]
Message-ID: <5473C4BA.2050903@codesourcery.com> (raw)
In-Reply-To: <87bnoeif74.fsf@codesourcery.com>
On 11/10/2014 08:33 PM, Yao Qi wrote:
> These fixes should be in separate patches. I'd like to see this patch
> is split to a series which includes the following patches,
>
> 1. add new helpers and rewrite existing functions with these new
> helpers,
> 2. permit more than one stack adjustment instruction to appear in
> epilogue
> 3. detect some additional prologue instruction patterns,
Hmmm, OK (although this required rewriting code for part 1 that is
promptly going to get thrown away again with parts 2 and 3).
> There should be an empty line between the end of comment and the function.
Fixed throughout the patch.
>> +
>> +/* Match and disassemble an ADD-type instruction, with 3 register operands.
>> + Returns true on success, and fills in the operand pointers. */
>> +static int
>> +nios2_match_add (uint32_t insn,
>> + const struct nios2_opcode *op,
>> + unsigned long mach,
>> + int *ra, int *rb, int *rc)
>
> Is there any reason you put these parameters in different lines? We can
> place them on the same line like:
>
> static int
> nios2_match_add (uint32_t insn, const struct nios2_opcode *op,
> unsigned long mach, int *ra, int *rb, int *rc)
>
> then the function can be shorter.
Fixed here and elsewhere.
> An empty line is needed between declaration and statement.
Fixed.
>> + /* We found a whole lot of stack adjustments. Be safe, tell GDB that
>> + the epilogue stack unwind is in progress even if we didn't see a
>> + return yet. */
>> + if (ninsns == max_insns)
>> + return 1;
>
> I am confused by the comments and code. Infer from your code above that
> GCC emits arbitrary number of sp-adjusting continuous instructions in
> epilogue, is that true?
No, GCC doesn't emit an arbitrary number of SP-adjusting instructions,
but what should GDB do if it gets some code that looks like that? I've
rewritten the comment to make it more clear that this is a "shouldn't
happen" situation.
> Looks the epilogue detection isn't precise nor accurate. Supposing we
> have an epilogue like this below,
>
> 1. ADDI sp, sp, n
> 2. RET
>
> if pc points at insn #1, nios2_in_epilogue_p returns true, which isn't
> precise, because the stack frame isn't destroyed at the moment pc points
> at insn #1. gdbarch in_function_epilogue_p's name is misleading, and
> better to be renamed to stack_frame_destroyed_p (it's on my todo list).
>
> if pc points at insn #2, nios2_in_epilogue_p returns false, which isn't
> accurate.
I think that you have gotten confused by the pc and insn variables being
updated out of sync in the scanning loop. I have rewritten the loop
code and the comments to make it more obvious that scanning for stack
adjustments starts at the instruction before current_pc. It doesn't
matter if there have been additional stack adjustments in the sequence
of instructions before that -- we only need to see one to know that the
stack teardown is already in progress at current_pc.
> Why do we change from byte_order_for_code to byte_order?
Leftover bits from some other changes that aren't ready to commit yet.
I've put it back the way it was.
New patch set coming up shortly.
-Sandra
next prev parent reply other threads:[~2014-11-24 23:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-08 23:01 Sandra Loosemore
2014-11-11 3:33 ` Yao Qi
2014-11-24 23:52 ` Sandra Loosemore [this message]
2014-11-25 0:03 ` [1/3 patch, nios2] clean up prologue/epilogue detection code, v2 Sandra Loosemore
2014-11-25 2:50 ` Yao Qi
2014-11-25 0:03 ` [3/3 " Sandra Loosemore
2014-11-25 3:00 ` Yao Qi
2014-11-25 0:03 ` [2/3 " Sandra Loosemore
2014-11-25 3:29 ` Yao Qi
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=5473C4BA.2050903@codesourcery.com \
--to=sandra@codesourcery.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.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