David Binderman pointed out that we were doing a full memset()
of the gdb register buffer and then doing a memcpy() to it that
was almost as big. This commit optimizes that by only doing a
memset() of the registers that are intended to be zero.
While making this change I noticed that we were not copying the
link register (LR, number 55) due to a fencepost error in commit
f419e6f63c ("arch: tile: kernel: kgdb.c: Use memcpy() instead of
pointer copy one by one"), and I've corrected that as well.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
It is used by kgdb, ftrace, kprobe and jump label, so we factor
this out into a helper routine.
Reviewed-by: Chris Metcalf <cmetcalf@ezchip.com>
Signed-off-by: Zhigang Lu <zlu@ezchip.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Not only memcpy() is faster than pointer copy, but also let code more
clearer and simple, which can avoid compiling warning (the original
implementation copy registers by exceeding member array border).
The related warning (with allmodconfig under tile):
CC arch/tile/kernel/kgdb.o
arch/tile/kernel/kgdb.c: In function 'sleeping_thread_to_gdb_regs':
arch/tile/kernel/kgdb.c:140:31: warning: iteration 53u invokes undefined behavior [-Waggressive-loop-optimizations]
*(ptr++) = thread_regs->regs[reg];
^
arch/tile/kernel/kgdb.c:139:2: note: containing loop
for (reg = 0; reg <= TREG_LAST_GPR; reg++)
^
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
Enter kernel debugger at boot with:
--hvd UART_1=1 --hvx kgdbwait --hvx kgdboc=ttyS1,115200
or at runtime with:
echo ttyS1,115200 > /sys/module/kgdboc/parameters/kgdboc
echo g > /proc/sysrq-trigger
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>