linux-mips
[Top] [All Lists]

Re: [PATCH] dump_stack() based on prologue code analysis

To: vagabon.xyz@gmail.com
Subject: Re: [PATCH] dump_stack() based on prologue code analysis
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Date: Tue, 01 Aug 2006 00:59:33 +0900 (JST)
Cc: linux-mips@linux-mips.org, ralf@linux-mips.org
In-reply-to: <44CE26FA.8070909@innova-card.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <44CE1494.4080801@innova-card.com> <20060801.003311.75758612.anemo@mba.ocn.ne.jp> <44CE26FA.8070909@innova-card.com>
Sender: linux-mips-bounce@linux-mips.org
On Mon, 31 Jul 2006 17:51:22 +0200, Franck Bui-Huu <vagabon.xyz@gmail.com> 
wrote:
> while you're at it, (union mips_instruction *) cast is useless and "func"
> local too. Just write 
> 
>       union mips_instruction *ip = info->func;
> 
> is more readable, IMHO.

Indeed.  Revised.


Subject: [PATCH] make get_frame_info() more readable.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 8709a46..cd99bc8 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -284,20 +284,18 @@ static int mfinfo_num;
 static int get_frame_info(struct mips_frame_info *info)
 {
        int i;
-       void *func = info->func;
-       union mips_instruction *ip = (union mips_instruction *)func;
+       union mips_instruction *ip = info->func;
+       int max_insns =
+               min(128UL, info->func_size / sizeof(union mips_instruction));
        info->pc_offset = -1;
        info->frame_size = 0;
-       for (i = 0; i < 128; i++, ip++) {
+       for (i = 0; i < max_insns; i++, ip++) {
                /* if jal, jalr, jr, stop. */
                if (ip->j_format.opcode == jal_op ||
                    (ip->r_format.opcode == spec_op &&
                     (ip->r_format.func == jalr_op ||
                      ip->r_format.func == jr_op)))
                        break;
-
-               if (info->func_size && i >= info->func_size / 4)
-                       break;
                if (
 #ifdef CONFIG_32BIT
                    ip->i_format.opcode == addiu_op &&

<Prev in Thread] Current Thread [Next in Thread>