Revision: 1582 Author: teawater Date: Thu May 30 01:05:36 2013 Log: Update doc http://code.google.com/p/kgtp/source/detail?r=1582 Modified: /wiki/HOWTO.wiki ======================================= --- /wiki/HOWTO.wiki Wed May 29 23:03:13 2013 +++ /wiki/HOWTO.wiki Thu May 30 01:05:36 2013 @@ -306,11 +306,9 @@So if your GDB is older than 7.6 please go to [https://code.google.com/p/gdbt/] to get howto install GDB for KGTP. It supplies sources of UBUBTU, CentOS, Fedora, Mandriva, RHEL, SLE, openSUSE. Also have static binary for others.<br> If you have issue about GDB please get help according to [HOWTO#Report_issues_about_KGTP].
-= Howto use = - -== Execution == -=== Normal Linux === -==== Insmod the KGTP module === += Use GDB connect to KGTP = +== Normal Linux == +=== Insmod the KGTP module === If you have installed KGTP in your system, you can: {{{ sudo modprobe gtp @@ -320,7 +318,7 @@ cd kgtp/ sudo insmod gtp.ko }}} -==== Handle the issue that cannot find "/sys/kernel/debug/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. @@ -334,9 +332,9 @@ mount -t debugfs none /sys/kernel/debug/ }}} Then you can find "/sys/kernel/debug/gtp". -==== Make GDB connect to 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 @@ -344,7 +342,7 @@ 0x0000000000000000 in ?? () }}}After that, you can begin to use GDB command trace and debug the Linux Kernel.
-===== GDB on remote machine ===== +==== GDB on remote machine ==== Use nc map the KGTP interface to port 1024. {{{ sudo su @@ -358,8 +356,8 @@ (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 === +== Android == +=== Insmod the KGTP module === *First*, make sure ADB has connected with Android.<br> *Second*, copy KGTP module to Android. {{{ @@ -370,7 +368,7 @@ {{{ adb shell insmod /gtp.ko }}} -==== Handle the issue that cannot find "/sys/kernel/debug/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. @@ -384,7 +382,7 @@ sudo adb shell mount -t debugfs none /sys/kernel/debug/ }}} Then you can find "/sys/kernel/debug/gtp". -===== GDB connect to the KGTP ===== +=== GDB connect to the KGTP === Use nc map the KGTP interface to port 1024. {{{ adb forward tcp:1234 tcp:1234 @@ -399,11 +397,11 @@ }}}After that, you can begin to use GDB command trace and debug the Linux Kernel.
-== Add module symbols to GDB == += 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 === +== How to use getmod =="getmod" is written by C so you can use it anywhere even if in an embedded environment.<br>
For example: {{{ @@ -429,12 +427,14 @@#/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 === +== 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. + += Howto use GDB control KGTP trace Linux kernel = == 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".