KGTP (dynamic tracer for Linux kernel and applications) 20131218 release (support Uprobes to trace user applications)
Subsystems (6)
KGTP (http://kgtp.googlecode.com/) is a comprehensive dynamic tracer for analysing Linux kernel and application (including Android) problems on production systems in real time.
To use it, you don't need patch or rebuild the Linux kernel. Just build KGTP module and insmod it is OK.
http://www.youtube.com/watch?v=7nfGAbNsEZY
or http://www.tudou.com/programs/view/fPu_koiKo38/ is the video that introduced KGTP in English.
http://www.infoq.com/cn/presentations/gdb-sharp-knife-kgtp-linux-kernel
is the video that introduced KGTP in Chinese.
Please goto https://code.google.com/p/kgtp/wiki/HOWTO (English)
or https://code.google.com/p/kgtp/wiki/HOWTOCN (Chinese) to get howto use KGTP. Or download the pdf version in https://raw.github.com/teawater/kgtp/master/kgtp.pdf (English) or https://raw.github.com/teawater/kgtp/master/kgtpcn.pdf(Chinese).
Now, KGTP 20131218 release.
To get it in github:
Get through https:
https://github.com/teawater/kgtp/archive/20131218.tar.gz
Get through git:
git clone https://github.com/teawater/kgtp.git
git checkout 20131218 -b 20131218
To get it in CSDN:
Get through https:
https://code.csdn.net/teawater/kgtp/repository/archive?ref=20131218
Get through git:
git clone git://code.csdn.net/teawater/kgtp.git
git checkout 20131218 -b 20131218
The main change of this release is:
Support Uprobes to trace user applications. So now, you can use GDB trace or access the memory of user applications through KGTP without stop them like what KGTP can do with Linux kernel. Please goto
https://code.google.com/p/kgtp/wiki/HOWTO#Use_KGTP_with_user_applications
get more info about howto use it.
Please goto https://github.com/teawater/kgtp/blob/20131218/UPDATE
get more info about this release.
The howto of KGTP doesn't introcue trace more than one user applications or Linux kernel in same time. This is because multiprocess support of GDB tracepoint is not complete. Without this support, KGTP need add a special line in actions to support multiprocess tracepoint. So I make some patches for GDB to make it works:
https://sourceware.org/ml/gdb-patches/2013-12/msg00730.html
https://sourceware.org/ml/gdb-patches/2013-12/msg00731.html
https://sourceware.org/ml/gdb-patches/2013-12/msg00732.html
https://sourceware.org/ml/gdb-patches/2013-12/msg00733.html
Hope they can get review before GDB 7.7 release. Maybe I need add them to https://code.google.com/p/gdbt/ first.
So in the next release of KGTP, GDB can very easy to trace user applications and Linux kernel through KGTP in same time.
According to the comments of Christoph, Geoff and Andi. I make KGTP function lite patch for Linux kernel upstream. Please goto
http://lkml.org/lkml/2013/11/21/7 to got it.
And I also post it with this mail.
---
arch/arc/kernel/kgdb.c +1 -0
@@ -61,6 +61,7 @@ void pt_regs_to_gdb_regs(unsigned long *to_gdb_regs (gdb_regs, kernel_regs, (struct callee_regs *) current->thread.callee_reg); } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);void gdb_regs_to_pt_regs (unsigned long *gdb_regs,struct pt_regs *kernel_regs) {
arch/blackfin/kernel/kgdb.c +1 -0
@@ -73,6 +73,7 @@ void pt_regs_to_gdb_regs(unsigned long * gdb_regs[BFIN_EXTRA3 ] =0 ; gdb_regs[BFIN_IPEND ] = regs->ipend; } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);/* * Extracts ebp, esp and eip values understandable by gdb from the values
arch/microblaze/kernel/kgdb.c +1 -0
@@ -64,6 +64,7 @@ void pt_regs_to_gdb_regs(unsigned long * __asm__ __volatile__ ("mfs %0, rtlbhi;" :"=r" (temp) : ); gdb_regs[GDB_RTLBHI ] = temp; } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);void gdb_regs_to_pt_regs (unsigned long *gdb_regs,struct pt_regs *regs) {
arch/mn10300/kernel/kgdb.c +1 -0
@@ -66,6 +66,7 @@ void pt_regs_to_gdb_regs(unsigned long * gdb_regs[GDB_FR_DUMMY1 ] =0 ; gdb_regs[GDB_FR_FS0 ] =0 ; } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);/* * Extracts kernel SP/PC values understandable by gdb from the values
arch/sparc/kernel/kgdb_32.c +1 -0
@@ -41,6 +41,7 @@ void pt_regs_to_gdb_regs(unsigned long * gdb_regs[GDB_FSR ] =0 ; gdb_regs[GDB_CSR ] =0 ; } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);void sleeping_thread_to_gdb_regs (unsigned long *gdb_regs,struct task_struct *p) {
arch/sparc/kernel/kgdb_64.c +1 -0
@@ -37,6 +37,7 @@ void pt_regs_to_gdb_regs(unsigned long * gdb_regs[GDB_FPRS ] =0 ; gdb_regs[GDB_Y ] = regs->y; } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);void sleeping_thread_to_gdb_regs (unsigned long *gdb_regs,struct task_struct *p) {
arch/x86/include/asm/gtp.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ASM_X86_GTP_H_ +#define _ASM_X86_GTP_H_ + +static inline void gtp_copy_and_adjuest_regs (struct pt_regs *dest, +struct pt_regs *src) +{ +memcpy (dest, src,sizeof (struct pt_regs )); + +#ifdef CONFIG_X86_32 + dest->sp = (unsigned long )&src->sp; +#endif /* CONFIG_X86_32 */ + + dest->ip -=1 ; +} + +#endif
kernel/Makefile +2 -0
@@ -94,6 +94,8 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_JUMP_LABEL) += jump_label.o obj-$(CONFIG_CONTEXT_TRACKING) += context_tracking.o +obj-$(CONFIG_GTP) += gtp.o + $(obj)/configs.o: $(obj)/config_data.h # config_data.h contains the same information as ikconfig.h but gzipped.
kernel/debug/gdbstub.c +2 -0
@@ -258,6 +258,7 @@ char *kgdb_mem2hex(char *mem, char *buf,return buf; } +EXPORT_SYMBOL_GPL (kgdb_mem2hex);/* * Convert the hex array pointed to by buf into binary to be placed in
@@ -349,6 +350,7 @@ void pt_regs_to_gdb_regs(unsigned long * idx += dbg_reg_def[i].size; } } +EXPORT_SYMBOL_GPL (pt_regs_to_gdb_regs);void gdb_regs_to_pt_regs (unsigned long *gdb_regs,struct pt_regs *regs) {
kernel/gtp.c new file +876 -0
876 lines not on this page · raw message
lib/Kconfig.debug +15 -0
@@ -1578,6 +1578,21 @@ config DMA_API_DEBUG This option causes a performance degredation. Use only if you want to debug device drivers. If unsure, say N. +config GTP + tristate "KGTP" + depends on X86 + select KPROBES + select DEBUG_FS + select KGDB + ---help--- + KGTP is a flexible, lightweight and realtime Linux (include + Android) debugger and tracer. + It makes Linux Kernel supply a GDB remote debug interface. + Then GDB in current machine or remote machine can debug and + trace Linux kernel and user space program through GDB tracepoint + and some other functions without stopping the Linux Kernel. + http://kgtp.googlecode.com/ + source "samples/Kconfig" source "lib/Kconfig.kgdb"