KGTP (dynamic tracer for Linux kernel and applications) 20131218 release (support Uprobes to trace user applications)

2013-12-18 Thread Hui Zhu

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.

Signed-off-by: Hui Zhu 
---
--- a/arch/arc/kernel/kgdb.c
+++ b/arch/arc/kernel/kgdb.c
@@ -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)

 {
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -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
--- a/arch/microblaze/kernel/kgdb.c
+++ b/arch/microblaze/kernel/kgdb.c
@@ -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)

 {
--- a/arch/mn10300/kernel/kgdb.c
+++ b/arch/mn10300/kernel/kgdb.c
@@ -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
--- a/arch/sparc/kernel/kgdb_32.c
+++ b/arch/sparc/kernel/kgdb_32.c
@@ -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)

 {
--- a/arch/sparc/kernel/kgdb_64.c
+++ b/arch/sparc/kernel/kgdb_64.c
@@ -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)

 {
--- /dev/null
+++ b/arch/x86/include/asm/gtp.h
@@ -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,
+  

KGTP (dynamic tracer for Linux kernel and applications) 20131218 release (support Uprobes to trace user applications)

2013-12-18 Thread Hui Zhu

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.

Signed-off-by: Hui Zhu teawa...@gmail.com
---
--- a/arch/arc/kernel/kgdb.c
+++ b/arch/arc/kernel/kgdb.c
@@ -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)

 {
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -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
--- a/arch/microblaze/kernel/kgdb.c
+++ b/arch/microblaze/kernel/kgdb.c
@@ -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)

 {
--- a/arch/mn10300/kernel/kgdb.c
+++ b/arch/mn10300/kernel/kgdb.c
@@ -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
--- a/arch/sparc/kernel/kgdb_32.c
+++ b/arch/sparc/kernel/kgdb_32.c
@@ -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)

 {
--- a/arch/sparc/kernel/kgdb_64.c
+++ b/arch/sparc/kernel/kgdb_64.c
@@ -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)

 {
--- /dev/null
+++ b/arch/x86/include/asm/gtp.h
@@ -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,
+