linux-mips
[Top] [All Lists]

Re: [PATCH] Remove mfinfo[64] used by get_wchan()

To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: Re: [PATCH] Remove mfinfo[64] used by get_wchan()
From: Franck Bui-Huu <vagabon.xyz@gmail.com>
Date: Fri, 18 Aug 2006 10:50:01 +0200
Cc: vagabon.xyz@gmail.com, ralf@linux-mips.org, linux-mips@linux-mips.org
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:reply-to:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:from; b=dfwD6PwbAU8VUXs+6NA4I8niwFl5TAmYmyaL3Bwfinif21CuM0I8MBQ34Nmi2b1/iljBObnuStbq3m2Xi6iZjXXMOKCF9smJ2mPaIfegh1t+1fEbgSu15gka5ovooCqdOS90zU1pNuQD0PbIqjLhArmzG4ZkS30JvrrZwj7FNMI=
In-reply-to: <20060818.171558.89065994.nemoto@toshiba-tops.co.jp>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <44E475C8.5000105@innova-card.com> <20060818.115213.108739385.nemoto@toshiba-tops.co.jp> <44E57161.5060104@innova-card.com> <20060818.171558.89065994.nemoto@toshiba-tops.co.jp>
Reply-to: Franck <vagabon.xyz@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
Atsushi Nemoto wrote:
> On Fri, 18 Aug 2006 09:50:57 +0200, Franck Bui-Huu <vagabon.xyz@gmail.com> 
> wrote:
>>>> +  unsigned long size = 0;
>>> You must pass some non-zero size even if CONFIG_KALLSYMS was not set.
>>> Otherwise schedule_mfi will not be initialized as expected.  Actually,
>>> this is not a problem of this patch, but we missed this point on
>>> previous cleanups for the get_frame_info()...
>> or maybe we can just fix get_frame_info() and make it more robust ?
> 
> Maybe.  But info->func_size == 0 is valid input when it was called via
> show_backtrace.  If an exception occured on a first instruction of a
> function, get_frame_info() should return 1.  So it would be easy to
> give some appropriate (128?) size here.
> 

Does something like this seem correct ? If an exception occured on a first
instruction of a function, show_backtrace() will call get_frame_info()
with info->func_size != 0 but very small. In this case it returns 1.

If the caller of get_frame_info() set info->func_size = 0, then it doesn't
know the size of the function, and we assume it to 128 instructions.

                Franck

-- >8 --


diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 951bf9c..5b18806 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -311,12 +311,19 @@ static inline int is_sp_move_ins(union m
 static int get_frame_info(struct mips_frame_info *info)
 {
        union mips_instruction *ip = info->func;
-       int i, max_insns =
-               min(128UL, info->func_size / sizeof(union mips_instruction));
+       unsigned max_insns = info->func_size / sizeof(union mips_instruction);
+       unsigned i;
 
        info->pc_offset = -1;
        info->frame_size = 0;
 
+       if (!ip)
+               goto err;
+       
+       if (max_insns == 0)
+               max_insns = 128U;
+       max_insns = min(128U, max_insns);
+
        for (i = 0; i < max_insns; i++, ip++) {
 
                if (is_jal_jalr_jr_ins(ip))
@@ -337,6 +344,7 @@ static int get_frame_info(struct mips_fr
        if (info->pc_offset < 0) /* leaf */
                return 1;
        /* prologue seems boggus... */
+err:
        return -1;
 }

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