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 16:32:52 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote:
> Well could we use "sizeof(union mips_instruction)" so nobody won't
> make the same mistake ?
> 
>  		if (i >= info->func_size / sizeof(union mips_instruction))
>  			break;

Indeed.

> BTW I omit the first condition "info->func_size != 0" because
> normally a func has a no null size. If it has we should stop
> right now.
 
Yes.  I can not remember why "info->func_size != 0" is there...

> We should also test this condition _before_ testing that "*ip" is
> a jal instruction, shouldn't we ?

Yes, and we can hold the condition indo the "for" statement.


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..949efaf 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -286,18 +286,17 @@ static int get_frame_info(struct mips_fr
 	int i;
 	void *func = info->func;
 	union mips_instruction *ip = (union mips_instruction *)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