[kgtp] r1581 committed - Update doc

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Thu, 30 May 2013 06:03:24 +0000

Revision: 1581
Author:   teawater
Date:     Wed May 29 23:03:13 2013
Log:      Update doc

http://code.google.com/p/kgtp/source/detail?r=1581

Modified:
 /wiki/HOWTO.wiki
 /wiki/HOWTOCN.wiki

=======================================
--- /wiki/HOWTO.wiki    Tue May 28 22:29:44 2013
+++ /wiki/HOWTO.wiki    Wed May 29 23:03:13 2013
@@ -1,8 +1,8 @@
 #labels Phase-QA,Phase-Deploy
-Update in 2013-05-29
+Update in 2013-05-30
 <wiki:toc max_depth="4" />
 = What is KGTP =
-*KGTP* is a *flexible* , *lightweight* and *realtime* Linux *debugger* and *tracer*.<br> +*KGTP* is a *flexible* , *lightweight* and *realtime* Linux (include Android) *debugger* and *tracer*.<br> To use it, you *don't* need patch or rebuild the Linux kernel. Just build KGTP module and insmod it is OK.<br>
 <br>
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.<br>
@@ -48,6 +48,20 @@
        [*] Debug Filesystem
        [*] Compile the kernel with debug info
 }}}
+Please rebuild your Linux kernel if you change any options of the config.
+
+=== Android ===
+The default Linux kernel config of Android should not support KGTP. To use KGTP, Linux kernel of Android need open following options:
+{{{
+[*] Enable loadable module support  --->
+General setup  --->
+       [*] Prompt for development and/or incomplete code/drivers
+       [*] Kprobes
+Kernel hacking  --->
+       [*] Debug Filesystem
+       [*] Compile the kernel with debug info
+}}}
+Please rebuild your Linux kernel if you change any options of the Linux kernel config.

 === If your system use the Linux kernel from distribution ===
 You need install some Linux kernel package.
@@ -168,24 +182,6 @@
 }}}
This linux_banner is the kernel info that Linux kernel that KGTP is tracing. If it is same with the prev kernel info, the Linux kernel debug image is right.

-=== Handle the issue that cannot find any file in "/sys/" or "/sys/kernel/debug/" === -Because KGTP interface is "/sys/kernel/debug/gtp", it will cannot be used if cannot find any file in "/sys/" or "/sys/kernel/debug/".<br><br>
-
-If you got this issue, please make sure "Debug Filesystem" is opened in your kernel config first. [If_your_system_use_the_Linux_kernel_that_is_built_by_yourself]<br><br>
-
-If it is opened, please use following command mount sysfs.
-{{{
-sudo mount -t sysfs none /sys/
-}}}
-Then you can find files in "/sys/".
-<br><br>
-
-please use following command mount debugfs.
-{{{
-mount -t debugfs none /sys/kernel/debug/
-}}}
-Then you can find files in "/sys/kernel/debug/".
-
=== Handle the issue that Linux kernel debug image's address info is not same with Linux kernel when it running === In X86_32, you will found that the Linux kernel debug image's address info is not same with Linux kernel when it running through the ways in [HOWTO#Make_sure_current_Linux_kernel_debug_image_is_right]. And you determine the Linux kernel debug image is right.<br>
 This issue is because:
@@ -311,7 +307,10 @@
If you have issue about GDB please get help according to [HOWTO#Report_issues_about_KGTP].

 = Howto use =
-== Exec it ==
+
+== Execution ==
+=== Normal Linux ===
+==== Insmod the KGTP module ===
 If you have installed KGTP in your system, you can:
 {{{
 sudo modprobe gtp
@@ -321,9 +320,23 @@
 cd kgtp/
 sudo insmod gtp.ko
 }}}
-== Make GDB connect to gtp ==
+==== Handle the issue that cannot find "/sys/kernel/debug/gtp"  ====
+If you got this issue, please make sure "Debug Filesystem" is opened in your kernel config first. [If_your_system_use_the_Linux_kernel_that_is_built_by_yourself]<br>
+
+If it is opened, please use following command mount sysfs.
+{{{
+sudo mount -t sysfs none /sys/
+}}}
+Maybe you will got some error for examle "sysfs is already mounted on /sys". Please ignore it.
+<br>
+please use following command mount debugfs.
+{{{
+mount -t debugfs none /sys/kernel/debug/
+}}}
+Then you can find "/sys/kernel/debug/gtp".
+==== Make GDB connect to gtp ====
Please *note* that let GDB open a right vmlinux file is very important. Please goto [#Make_sure_current_Linux_kernel_debug_image_is_right] get how to do it.
-=== GDB on the current machine ===
+===== GDB on the current machine =====
 {{{
 sudo gdb ./vmlinux
 (gdb) target remote /sys/kernel/debug/gtp
@@ -331,28 +344,65 @@
 0x0000000000000000 in ?? ()
 }}}
After that, you can begin to use GDB command trace and debug the Linux Kernel.
-=== If GDB on remote machine ===
+===== GDB on remote machine =====
+Use nc map the KGTP interface to port 1024.
 {{{
-#Open the KGTP interface in current machine.
 sudo su
 nc -l 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp
-(nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp for old version netcat.)
-#Let gdb connect to the port 1234
-gdb ./vmlinux
+#(nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp for old version netcat.)
+}}}
+After that, nc will hang there to wait connection.<br>
+Let gdb connect to the port 1234.
+{{{
+gdb-release ./vmlinux
 (gdb) target remote xxx.xxx.xxx.xxx:1234
 }}}
+After that, you can begin to use GDB command trace and debug the Linux Kernel.
+=== Android ===
+==== Insmod the KGTP module ===
+*First*, make sure ADB has connected with Android.<br>
+*Second*, copy KGTP module to Android.
+{{{
+sudo adb push gtp.ko /
+}}}
+Directory "/" may be read-only. You can choice other directory or use command "sudo adb shell mount -o rw,remount /" remount the directory to can write.<br>
+*Third*, insmod the module.
+{{{
+adb shell insmod /gtp.ko
+}}}
+==== Handle the issue that cannot find "/sys/kernel/debug/gtp"  ====
+If you got this issue, please make sure "Debug Filesystem" is opened in your kernel config first. [If_your_system_use_the_Linux_kernel_that_is_built_by_yourself]<br>
+
+If it is opened, please use following command mount sysfs.
+{{{
+sudo adb shell mount -t sysfs none /sys/
+}}}
+Maybe you will got some error for examle "Device or resource busy". Please ignore it.
+<br>
+please use following command mount debugfs.
+{{{
+sudo adb shell mount -t debugfs none /sys/kernel/debug/
+}}}
+Then you can find "/sys/kernel/debug/gtp".
+===== GDB connect to the KGTP =====
+Use nc map the KGTP interface to port 1024.
+{{{
+adb forward tcp:1234 tcp:1234
+adb shell "nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp"
+#(adb shell "nc -l 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp" for new version netcat.)
+}}}
+After that, nc will hang there to wait connection.<br>
+Let gdb connect to the port 1234.
+{{{
+gdb-release ./vmlinux
+(gdb) target remote :1234
+}}}
After that, you can begin to use GDB command trace and debug the Linux Kernel.
+
 == Add module symbols to GDB ==
Sometimes you need to add a Linux kernel module's symbols to GDB to debug it.<br> Add symbols with hand is not very easy, so KGTP package include an GDB python script "getmod.py" and a program "getmod" can help you.

-=== How to use getmod.py ===
-Connect to KGTP before use the getmod.py.
-{{{
-(gdb) source ~/kgtp/getmod.py
-}}}
-Then this script will auto load the Linux kernel module's symbols to GDB.
-
 === How to use getmod ===
"getmod" is written by C so you can use it anywhere even if in an embedded environment.<br>
 For example:
@@ -379,7 +429,12 @@
#/lib/modules/2.6.39-rc5+/kernel is replaced to sudo ./getmod -r /home/teawater/kernel/b26
 sudo ./getmod -r /home/teawater/kernel/b26 >~/tmp/mi
 }}}
-
+=== How to use getmod.py ===
+Connect to KGTP before use the getmod.py.
+{{{
+(gdb) source ~/kgtp/getmod.py
+}}}
+Then this script will auto load the Linux kernel module's symbols to GDB.
 == Direct access the current value in normal mode ==
After GDB connect to KGTP, if it doesn't select any a entry of trace frame bufffer with GDB command "tfind", GDB in the *normal mode*. Then you can direct access the current value of memory (Linux kernel or the user space program) and the trace state variables without stop anything.<br> If you have selected a trace frame entry, use GDB command "tfind -1" to return to normal mode. Please goto [#Use_tfind_select_the_entry_inside_the_trace_frame_info] get more info about GDB command "tfind".
=======================================
--- /wiki/HOWTOCN.wiki  Tue May 28 22:30:59 2013
+++ /wiki/HOWTOCN.wiki  Wed May 29 23:03:13 2013
@@ -1,8 +1,8 @@
 #labels Phase-QA,Phase-Deploy
-Update in 2013-05-29
+Update in 2013-05-30
 <wiki:toc max_depth="4" />
 = 什么是KGTP =
-*KGTP* 是一个 *灵活* *轻量级* *实时* Linux *调试器* 和 *跟踪器* 。<br>
+*KGTP* 是一个 *灵活* *轻量级* *实时* Linux (包括 Android) *调试器* 和 *跟踪 器* 。<br> 使用KGTP *不需要* 在Linux内核上打PATCH或者重新编译,只要编译KGTP模块并 insmod就可以。<br>
 <br>
其让Linux内核提供一个远程GDB调试接口,于是在本地或者远程的主机上的GDB可以在 不需要停止内核的情况下用GDB tracepoint和其他一些功能 *调试* 和 *跟踪* Linux内核和应用程序。<br>
@@ -47,6 +47,20 @@
        [*] Debug Filesystem
        [*] Compile the kernel with debug info
 }}}
+如果你改了Linux内核config的任何项目,请重新编译你的内核。
+
+=== Android ===
+默认的Android Linux内核config应该不支持KGTP。要使用KGTP,你需要打开下面这些 内核选项:
+{{{
+[*] Enable loadable module support  --->
+General setup  --->
+       [*] Prompt for development and/or incomplete code/drivers
+       [*] Kprobes
+Kernel hacking  --->
+       [*] Debug Filesystem
+       [*] Compile the kernel with debug info
+}}}
+如果你改了Linux内核config的任何项目,请重新编译你的内核。

 === 如果你的系统内核是发行版自带的 ===
 你需要安装一些Linux内核软件包。
@@ -167,25 +181,6 @@
 }}}
这个linux_banner是KGTP正在trace的内核的内核信息,如果相同,则Linux内核调试 镜像是正确的。

-=== 处理不能在"/sys/"或者"/sys/kernel/debug/"找到任何文件的问题 ===
-因为KGTP的接口是"/sys/kernel/debug/gtp",所以如果"/sys/"或 者"/sys/kernel/debug/"中找不到任何文件则KGTP将不能使用。<br><br>
-
-如果你有这个问题,请先确定你的内核config打开了"Debug Filesystem"。 [http://code.google.com/p/kgtp/wiki/HOWTOCN#如果你的系统内核是自己编译的 ]<br><br>
-
-如果它以及被打开了,请用下面命令mount sysfs。
-{{{
-sudo mount -t sysfs none /sys/
-}}}
-然后你就能在"/sys/"找到文件。
-<br><br>
-
-请用下面命令mount debugfs。
-{{{
-mount -t debugfs none /sys/kernel/debug/
-}}}
-然后你就能在"/sys/kernel/debug/"找到文件。
-<br><br>
-
 === 处理Linux内核调试镜像地址信息和Linux内核执行时不同的问题 ===
在X86_32上,用 [http://code.google.com/p/kgtp/wiki/HOWTOCN#确定Linux内核调 试镜像是正确的] 介绍的方法发现Linux内核调试镜像地址信息和Linux内核执行时不 同,而且确定使用的Linux内核调试镜像是正确的。<br>
 这个问题是因为:
@@ -311,6 +306,8 @@

 = 如何使用 =
 == 执行 ==
+=== 普通Linux ===
+==== 安装KGTP模块 ====
 如果你已经安装了KGTP在你的系统中,你可以:
 {{{
 sudo modprobe gtp
@@ -320,9 +317,24 @@
 cd kgtp/
 sudo insmod gtp.ko
 }}}
-== 让GDB连接到KGTP ==
+==== 处理找不到"/sys/kernel/debug/gtp"的问题 ====
+如果你有这个问题,请先确定你的内核config打开了"Debug Filesystem"。 [http://code.google.com/p/kgtp/wiki/HOWTOCN#如果你的系统内核是自己编译的 ]<br>
+
+如果它以及被打开了,请用下面命令mount sysfs。
+{{{
+sudo mount -t sysfs none /sys/
+}}}
+也许你可能会得到一些错误例如"sysfs is already mounted on /sys",请忽略他 们。
+<br>
+
+请用下面命令mount debugfs。
+{{{
+mount -t debugfs none /sys/kernel/debug/
+}}}
+然后你就找到"/sys/kernel/debug/gtp"。
+==== 让GDB连接到KGTP ====
请 *注意* 让GDB打开正确的vmlinux文件非常重要。请到 [http://code.google.com/p/kgtp/wiki/HOWTOCN#确定Linux内核调试镜像是正确的] 去看下如何做。
-=== GDB在本地主机上 ===
+===== GDB在本地主机上 =====
 {{{
 sudo gdb ./vmlinux
 (gdb) target remote /sys/kernel/debug/gtp
@@ -330,28 +342,67 @@
 0x0000000000000000 in ?? ()
 }}}
 然后你就可以用GDB命令调试和跟踪Linux内核了。
-=== 如果GDB在远程主机上 ===
+===== 如果GDB在远程主机上 =====
+用nc把KGTP接口映射到端口1024上。
 {{{
-#在当前主机打开KGTP
 sudo su
 nc -l 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp
-(nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp for old version netcat.)
-#让GDB连接1234端口
-gdb ./vmlinux
+#(nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp 给老版本的nc)
+}}}
+之后,nc会在那里等待连接。<br>
+让GDB连接1234端口。
+{{{
+gdb-release ./vmlinux
 (gdb) target remote xxx.xxx.xxx.xxx:1234
 }}}
 然后你就可以用GDB命令调试和跟踪Linux内核了。
+
+=== Android ===
+==== 安装KGTP模块 ===
+*第一步* 确定ADB已经连接到Android上。<br>
+*第二步* 拷贝KGTP模块到Android上。
+{{{
+sudo adb push gtp.ko /
+}}}
+目录 "/" 可能是只读的。你可以选择其他目录或者用命令"sudo adb shell mount -o rw,remount /"把这个目录remount为可写。<br>
+*第三步* 安装KGTP模块。
+{{{
+adb shell insmod /gtp.ko
+}}}
+==== 处理找不到"/sys/kernel/debug/gtp"的问题 ====
+如果你有这个问题,请先确定你的内核config打开了"Debug Filesystem"。 [http://code.google.com/p/kgtp/wiki/HOWTOCN#如果你的系统内核是自己编译的 ]<br>
+
+如果它以及被打开了,请用下面命令mount sysfs。
+{{{
+sudo adb shell mount -t debugfs none /sys/kernel/debug/
+}}}
+也许你可能会得到一些错误例如"Device or resource busy",请忽略他们。
+<br>
+
+请用下面命令mount debugfs。
+{{{
+mount -t debugfs none /sys/kernel/debug/
+}}}
+然后你就找到"/sys/kernel/debug/gtp"。
+===== GDB连接KGTP =====
+用nc将KGTP接口映射到1024端口上。
+{{{
+adb forward tcp:1234 tcp:1234
+adb shell "nc -l -p 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp"
+#(adb shell "nc -l 1234 </sys/kernel/debug/gtp >/sys/kernel/debug/gtp" 给新 版本的nc)
+}}}
+之后,nc会在那里等待连接。<br>
+让GDB连接1234端口。
+{{{
+gdb-release ./vmlinux
+(gdb) target remote :1234
+}}}
+然后你就可以用GDB命令调试和跟踪Linux内核了。
+
 == 增加模块的符号信息到GDB ==
 有时你需要添加一个Linux内核模块的符号信息到GDB好调试其。<br>
手动增加符号信息不太容易,所以KGTP包里包含了GDB Python脚本"getmod.py"和程 序"getmod"可以帮到你。

-=== 如何使用getmod.py ===
-在使用getmod.py前连接到KGTP。
-{{{
-(gdb) source ~/kgtp/getmod.py
-}}}
-于是这个脚本将自动装载Linux内核模块到GDB中。
-
 === 如何使用getmod ===
 "getmod" 是用C写的所以你可以把它用在任何地方即使是一个嵌入式环境。<br>
 例如:
@@ -378,6 +429,13 @@
 #/home/teawater/kernel/b26是GDB所在主机上内核模块所在的路径
 sudo ./getmod -r /home/teawater/kernel/b26 >~/tmp/mi
 }}}
+
+=== 如何使用getmod.py ===
+在使用getmod.py前连接到KGTP。
+{{{
+(gdb) source ~/kgtp/getmod.py
+}}}
+于是这个脚本将自动装载Linux内核模块到GDB中。

 == 在普通模式直接访问当前值 ==
在GDB连到KGTP上以后,如果没有用GDB命令"tfind"选择一条trace帧缓存里面的条 目,GDB就处于 *普通模式*。于是你可以直接访问内存(Linux内核或者用户程序)的值 和trace状态变量的值。<br>

Other related posts:

  • » [kgtp] r1581 committed - Update doc - kgtp