Skip to contentSkip to conversation

powerpc: Replace hardcoded offset by BREAK_INSTR_SIZE

PATCH In review Michal Simek 3 participants 3 messages Jul 28, 2010 – Jul 30, 2010 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Replace hardcoded offset by BREAK_INSTR_SIZE

kgdb_handle_breakpoint checks the first arch_kgdb_breakpoint which is not known by gdb that's why is necessary jump over it. The jump lenght is equal to BREAK_INSTR_SIZE that's why is cleaner to use defined macro instead of hardcoded non-described offset.

CC Jason Wessel <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/kernel/kgdb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/kgdb.c +1 -1
index 82a7b22..7f61a3a 100644
@@ -129,7 +129,7 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
 		return 0;
 
 	if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
-		regs->nip += 4;
+		regs->nip += BREAK_INSTR_SIZE;
 
 	return 1;
 }
Signature · 1 line
1.5.5.6
#1 lore raw
Quoted 7 lines · Michal Simek

kgdb_handle_breakpoint checks the first arch_kgdb_breakpoint which is not known by gdb that's why is necessary jump over it. The jump lenght is equal to BREAK_INSTR_SIZE that's why is cleaner to use defined macro instead of hardcoded non-described offset.

Seems fine to me. I'll add this to the kgdb merge queue for 2.6.36.

Jason.

Quoted 22 lines
CC Jason Wessel <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/kernel/kgdb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/kgdb.c +1 -1
index 82a7b22..7f61a3a 100644
@@ -129,7 +129,7 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
 		return 0;
 
 	if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
-		regs->nip += 4;
+		regs->nip += BREAK_INSTR_SIZE;
 
 	return 1;
 }
#2 lore raw
In reply to Michal Simek
Quoted 19 lines · Michal Simek

kgdb_handle_breakpoint checks the first arch_kgdb_breakpoint which is not known by gdb that's why is necessary jump over it. The jump lenght is equal to BREAK_INSTR_SIZE that's why is cleaner to use defined macro instead of hardcoded non-described offset.

CC Jason Wessel <[email protected]>
CC Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/kernel/kgdb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/kgdb.c +0 -0
index 82a7b22..7f61a3a 100644

arch/powerpc/kernel/kgdb.c static int kgdb_handle_breakpoint(struct pt_regs *regs) · line 132

Quoted 5 lines
arch/powerpc/kernel/kgdb.c +1 -1
@@ -129,7 +129,7 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
 		return 0;
 
 	if (*(u32 *) (regs->nip) == *(u32 *) (&arch_kgdb_ops.gdb_bpt_instr))
-		regs->nip += 4;
+		regs->nip += BREAK_INSTR_SIZE;

Except to powerpc fokls, who intuitively know what nip + 4 means, but will have to lookup what BREAK_INSTR_SIZE is to be sure. But I'm being nit-picky :)

cheers