mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: zhangqing <zhangqing@loongson.cn>
To: Youling Tang <tangyouling@loongson.cn>,
	Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>,
	loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	hejinyang@loongson.cn
Subject: Re: [PATCH 2/3] LoongArch: Add prologue unwinder support
Date: Fri, 29 Jul 2022 13:38:46 +0800	[thread overview]
Message-ID: <fd01dabd-4ba2-ff7a-0dee-c99b1478be03@loongson.cn> (raw)
In-Reply-To: <ef9a03ee-6fdf-3968-de04-057cafc7c7c7@loongson.cn>



On 2022/7/29 上午10:03, Youling Tang wrote:
> 
> 
> On 07/28/2022 10:05 PM, Qing Zhang wrote:
>> It unwind the stack frame based on prologue code analyze.
>> CONFIG_KALLSYMS is needed, at least the address and length
>> of each function.
>>
>> Three stages when we do unwind,
>>   (1)unwind_start(), the prapare of unwinding, fill unwind_state.
>>   (2)unwind_done(), judge whether the unwind process is finished or not.
>>   (3)unwind_next_frame(), unwind the next frame.
>>
>> Dividing unwinder helps to add new unwinders in the future, eg:
>> unwind_frame, unwind_orc .etc
>>
>> Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
>>
>> +
>> +    while (ip < ip_end) {
>> +        if (is_ra_save_ins(ip)) {
>> +            frame_ra = ip->reg2i12_format.immediate;
> Because the immediate member in struct reg2i12_format is defined as an
> unsigned type, the value obtained by frame_ra here can only be a
> positive number.
> 
>> +            break;
>> +        }
>> +        if (is_branch_insn(*ip))
>> +            break;
>> +        ip++;
>> +    }
>> +
>> +    if (frame_ra < 0) {
> In addition to judging whether the initial value of frame_ra is
> negative, we also want to judge whether the previously assigned
> frame_ra is negative.
> 
> Save the ra value to the stack in the prologue, offset must be a
> positive number, so we can add another judgment to is_ra_save_ins, the
> code is as follows:
> +static inline bool is_ra_save_ins(union loongarch_instruction *ip)
> +{
> +    /* st.d $ra, $sp, offset */
> +    return ip->reg2i12_format.opcode == std_op &&
> +        ip->reg2i12_format.rj == LOONGARCH_GPR_SP &&
> +        ip->reg2i12_format.rd == LOONGARCH_GPR_RA &&
> +        !(ip->reg2i12_format.immediate & (1 << 11));
> +}

Hi,
youling

you are right and I will send v2.

Thanks,
Qing


  reply	other threads:[~2022-07-29  5:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 14:05 [PATCH 1/3] LoongArch: Add guess " Qing Zhang
2022-07-28 14:05 ` [PATCH 2/3] LoongArch: Add prologue " Qing Zhang
2022-07-29  2:03   ` Youling Tang
2022-07-29  5:38     ` zhangqing [this message]
2022-07-29  2:14   ` Jinyang He
2022-07-29  5:39     ` zhangqing
2022-07-28 14:05 ` [PATCH 3/3] LoongArch: Add stacktrace support Qing Zhang
2022-07-29  2:13   ` Youling Tang
2022-07-31 12:17   ` kernel test robot
2022-08-02 19:18   ` kernel test robot
2022-08-05 20:31   ` kernel test robot
2022-08-10 13:16   ` kernel test robot
2022-07-29  2:01 ` [PATCH 1/3] LoongArch: Add guess unwinder support Youling Tang
2022-07-29  2:28   ` Jinyang He
2022-07-29  2:56     ` Youling Tang

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=fd01dabd-4ba2-ff7a-0dee-c99b1478be03@loongson.cn \
    --to=zhangqing@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=hejinyang@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kernel@xen0n.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=tangyouling@loongson.cn \
    /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

all inboxes | Powered by JetHome®