[ANNOUNCE] KDB hardware breakpoint support integrated in 2.6.26-{common,ia64,x86}-2
Jay Lan <[email protected]> Fri, 18 Jul 2008 12:54:51 -0700
| Newsgroups | gmane.linux.kernel.debugging |
|---|---|
| Message-ID | <[email protected]> |
Hi, I have integrated hardware breakpoint (bph/bpha) support on IA64 from Greg Banks <[email protected]> and support on x86 arch from Konstantin Baydarov <[email protected]> in the kdb-v4.4-2.6.26-{common,ia64,x86)-2 patches. This will break compilation of other platforms. Basically, two things you need to change: 1) write a pair of wrapper, kdba_alloc_hwbp & kdba_free_hwbp, in your arch/*/kdb/kdba_bp.c to call kdba_allocbp and kdba_freebp. 2) change all references to bp->bp_hard bp->bp_hard[0] if you keep one kdbhard_bp_t pointer in the kdb_bp_t struct (as in the IA64 case), or change to bp->bp_hard[<cpu>] if you keep kdbhard_bp_t pointer per cpu in the kdb_bp_t struct (as in the case of x86.) The above steps would only get your arch-dependent code compiled again. You still need to provide your own implementation to support hardware breakpoints. Send me email <[email protected]> if you need help. I will attach Greg's and Konstantin's original description below. Note that i had to twist their codes a bit, especially the common code, to get a version that works on ia64, x86_64 and i386. Another note. You should use bph/bpha to set breakpoints on data addresses and use bp to set breakpoints on instruction. At least the bph/bpha on ia64 does not support instruction mode. Avi Nehori reported that the case below did not work. It may still true. I did nothing in this regard. when you set an hardware break point to address XXXXX int *ptr = XXXXX -4; *(ptr + 4) =9; didnt work. Regards, - jay [Description from Greg Banks] The patch implements only the bare minimum to solve my particular problem. Things it does *NOT* do include: * Implement "inst" type breakpoints (using the IBR registers instead of the DBR registers). This would be fairly easy but utterly redundant given that existing software breakpoints (which writes a break.m instruction into RAM) work fine. * Implement "io" type breakpoints. I have no idea how. * Fix KDB to allow a read+write breakpoint, i.e. a breakpoint which traps when the cpu either reads or writes. You get to choose read breakpoints, or write breakpoints, but not both, and you can't put two breakpoints on the same address either. * Fix KDB to allow watching areas of memory other than 1, 2 or 4 bytes in size. The natural size on ia64 would be 8 bytes, and the format of the DBR registers allows much larger areas (powers of 2 up to 2^56). * Fix KDB to align the breakpoint address to the watched size (the hardware does this internally, so KDB should report what the hw is actually going to do). IA64 hardware debug registers generate faults, not traps. IOW, on return from the debugger, the cpu executes exactly the same instruction again. This patch gets around that this way: - Force the user to use the "ss" command to single-step the instruction manually; this was how I got through my debugging sessions. Caveats: Any process using ptrace() or perfmon() to access DBRs from userspace will be surprised to see psr.db propagate across fork. However, as the wider problem of making those processes and KDB co-exist while using the same small set of DBRs remains unaddressed, I wasn't too worried. [Description from Konstantin Baydarov]: This patch adds support for global hardware breakpoints to KDB on x86 targets. Hardware breakpoints are installed by setting per CPU db registers. So to make a hardware breakpoint global it should be installed in db registers on every CPU in system. So global hw bp can't be handle by kdb_bp_install_global and kdb_bp_remove_global because these functions are called only on "monarch" CPU, kdb_bp_install_local and kdb_bp_remove_local should be used instead because these are called for all CPUs. Main changes: - kdb_hardbreaks[KDB_MAXHARDBPT] - The processor architecture hardware breakpoint registers descriptors is defined for every CPU: static kdbhard_bp_t kdb_hardbreaks[NR_CPUS][KDB_MAXHARDBPT]; - "kdb_bp_t" (main breakpint structure) contains hardware breakpoint registers for every CPU: kdbhard_bp_t* bp_hard[NR_CPUS]; - global hardware breakpoint installation and removal is handled by kdb_bp_install_local and kdb_bp_remove_local which are executed on every CPU - kdba_allocbp and kdba_freebp are static, now kdba_alloc_hwbp and kdba_free_hwbp are used for allocating/freeing hardware breakpoint registers. If the hardware breakpoint is global then kdba_alloc_hwbp tries to allocate hardware breakpoint registers on every CPU. If there is no free hardware breakpoint on a CPU the allocation fails. - bph_installed was added to the hardware breakpoint descriptor to track per CPU hardware breakpoint installation. --------------------------- Use http://oss.sgi.com/ecartis to modify your settings or to unsubscribe.