[AVR32] Enable debugging only when needed

Keep track of processes being debugged (including the kernel itself)
and turn the OCD system on and off as appropriate. Since enabling
debugging turns off some optimizations in the CPU core, this fixes the
issue that enabling KProbes support or simply running a program under
gdbserver will reduce system performance significantly until the next
reboot.

The CPU performance will still be reduced for all processes while a
process is being debugged, but this is a lot better than reducing the
performance forever.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
This commit is contained in:
Haavard Skinnemoen
2007-11-27 13:50:45 +01:00
parent 6ea6dd93c9
commit 13b54a5052
8 changed files with 186 additions and 13 deletions

View File

@ -103,7 +103,7 @@ EXPORT_SYMBOL(kernel_thread);
*/
void exit_thread(void)
{
/* nothing to do */
ocd_disable(current);
}
void flush_thread(void)
@ -345,6 +345,9 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
p->thread.cpu_context.ksp = (unsigned long)childregs;
p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG))
ocd_enable(p);
return 0;
}