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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 31 Jul 2006 17:51:22 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> 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@xxxxxxxxxxxxx>

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 &&


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux