Skip to contentSkip to conversation

kgdb_arch_set/remove_break() ?

DISCUSSION Tom Rini 3 participants 5 messages Mar 19, 2004 – Mar 25, 2004 1 message not in the archive KGDB / KDB /debug_core

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

Hi. Right now I'm writing up a porting doc that describes the various hook functions we've got. I noticed that nothing is calling kgdb_arch_set/remove_break. Is there some arch we're expecting will need this? I'd like to just go ahead and remove them.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
#1 lore raw
Quoted 4 lines · Tom Rini

Hi. Right now I'm writing up a porting doc that describes the various hook functions we've got. I noticed that nothing is calling kgdb_arch_set/remove_break. Is there some arch we're expecting will need this? I'd like to just go ahead and remove them

I can't remember why that was done. A processor other than PPC, x86 and x86_64 needs a special implementation of set and remove breakpoint, I guess.

Anurekh, who did initial implementation of arch independent-dependent split may have some comments on this.

Signature · 3 lines
Amit Kale
EmSysSoft (http://www.emsyssoft.com)
KGDB: Linux Kernel Source Level Debugger (http://kgdb.sourceforge.net)
#2 lore raw
Quoted 11 lines · Amit S. Kale
Quoted 4 lines · Tom Rini

Hi. Right now I'm writing up a porting doc that describes the various hook functions we've got. I noticed that nothing is calling kgdb_arch_set/remove_break. Is there some arch we're expecting will need this? I'd like to just go ahead and remove them

I can't remember why that was done. A processor other than PPC, x86 and x86_64 needs a special implementation of set and remove breakpoint, I guess.

Anurekh, who did initial implementation of arch independent-dependent split may have some comments on this.

*set_break
*remove_break

These functions should only be defined for architecutes that support hardware breakpoint. Set KGDB_HW_BREAKPOINT flag.

author
#3 lore raw
Quoted 11 lines · Anurekh Saxena
Quoted 9 lines · Amit S. Kale
Quoted 4 lines · Tom Rini

Hi. Right now I'm writing up a porting doc that describes the various hook functions we've got. I noticed that nothing is calling kgdb_arch_set/remove_break. Is there some arch we're expecting will need this? I'd like to just go ahead and remove them

I can't remember why that was done. A processor other than PPC, x86 and x86_64 needs a special implementation of set and remove breakpoint, I guess.

Quoted 8 lines
Quoted 2 lines

Anurekh, who did initial implementation of arch independent-dependent split may have some comments on this.

*set_break
*remove_break

These functions should only be defined for architecutes that support hardware breakpoint. Set KGDB_HW_BREAKPOINT flag.

Amit, I think we've got a bug on i386 then. Looking at i386-lite.patch, there's:
+void kgdb_correct_hw_break(void)
+int kgdb_remove_hw_break(unsigned long addr, int type)
+int kgdb_set_hw_break(unsigned long addr, int type)
+int remove_hw_break(unsigned breakno)
+int set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned addr)

Of these, only kgdb_correct_hw_break is called in core-lite.patch, and set_hw_break/remove_hw_break (for y/Y packets) are called in i386-lite.patch.

What I think we need to do is, since y/Y packets are reserved, I'm assuming there's a special version of GDB using these for hw breakpoints, and this needs to be handled in i386-lite.patch. Since core-lite's handling of a z/Z* packet is to assume setting a breakpoint, and hw or sw is controlled by the KGDB_HW_BREAKPOINT flag, we need to make sure this (a) works and (b) is actually calling useful functions.

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/
author
#5 lore raw
In reply to a message not in the archive
Quoted 47 lines · Amit S. Kale
Quoted 34 lines · Tom Rini
Quoted 11 lines · Anurekh Saxena
Quoted 10 lines · Amit S. Kale
Quoted 4 lines · Tom Rini

Hi. Right now I'm writing up a porting doc that describes the various hook functions we've got. I noticed that nothing is calling kgdb_arch_set/remove_break. Is there some arch we're expecting will need this? I'd like to just go ahead and remove them

I can't remember why that was done. A processor other than PPC, x86 and x86_64 needs a special implementation of set and remove breakpoint, I guess.

Quoted 8 lines
Quoted 2 lines

Anurekh, who did initial implementation of arch independent-dependent split may have some comments on this.

*set_break
*remove_break

These functions should only be defined for architecutes that support hardware breakpoint. Set KGDB_HW_BREAKPOINT flag.

Amit, I think we've got a bug on i386 then. Looking at i386-lite.patch, there's:

(quoted diff) +5 -0
+void kgdb_correct_hw_break(void)
+int kgdb_remove_hw_break(unsigned long addr, int type)
+int kgdb_set_hw_break(unsigned long addr, int type)
+int remove_hw_break(unsigned breakno)
+int set_hw_break(unsigned breakno, unsigned type, unsigned len, unsigned

addr)

Of these, only kgdb_correct_hw_break is called in core-lite.patch, and set_hw_break/remove_hw_break (for y/Y packets) are called in i386-lite.patch.

Quoted 7 lines

What I think we need to do is, since y/Y packets are reserved, I'm assuming there's a special version of GDB using these for hw breakpoints, and this needs to be handled in i386-lite.patch. Since core-lite's handling of a z/Z* packet is to assume setting a breakpoint, and hw or sw is controlled by the KGDB_HW_BREAKPOINT flag, we need to make sure this (a) works and (b) is actually calling useful functions.

I had used Y,y packets since Z,z packets weren't supported. Now we support Z,z packets. It's time to move Y,y packet functionality to Z,z. That way it'll be possible to use gdb commands themselves to place hardware breakpoints.

Quoted 2 lines

Anurekh found one more problem. We don't consider hardware breakpoints when removing all breakpoints. We should fix that.

The following is an incomplete patch vs core-lite and i386-lite that _needs_ someone that understand i386 and hardware breakpoints to audit all of the code related to that in i386/kernel/kgdb.c.

We fix the remove_all_breakpoint issue by adding kgdb_remove_all_hw_break(), which must do whatever is needed to actually accomplish that (I don't see how we're even setting a hw break now, unless there's a call to correct_hw_break later which actually makes them do something). I've also gone and made the z/Z packet handling slightly different, and noted where we got the docs on how to handle the packet that way.

 arch/i386/kernel/kgdb.c |   84 +++++++++++++-----------------------------------
 include/linux/kgdb.h    |    5 +-
 kernel/kgdb.c           |   67 ++++++++++++++++++++------------------
 3 files changed, 62 insertions(+), 94 deletions(-)
include/linux/kgdb.h +3 -2
diff -u linux-2.6.4/include/linux/kgdb.h linux-2.6.4/include/linux/kgdb.h
@@ -84,8 +84,9 @@
 extern int kgdb_arch_handle_exception(int vector, int signo, int err_code,
 				      char *InBuffer, char *outBuffer,
 				      struct pt_regs *regs);
-extern int kgdb_arch_set_break(unsigned long addr, int type);
-extern int kgdb_arch_remove_break(unsigned long addr, int type);
+extern int kgdb_set_hw_break(unsigned long addr);
+extern int kgdb_remove_hw_break(unsigned long addr);
+extern void kgdb_remove_all_hw_break(void);
 extern void kgdb_correct_hw_break(void);
 extern void kgdb_shadowinfo(struct pt_regs *regs, char *buffer,
 			    unsigned threadid);
kernel/kgdb.c +35 -32

129 lines not on this page · raw message

arch/i386/kernel/kgdb.c +24 -60

125 lines not on this page · raw message

Signature · 2 lines
Tom Rini
http://gate.crashing.org/~trini/