GDB is a debugging tool under UNIX and Unix-like. The people who develop under Linux will not be unfamiliar, also have the corresponding debug version under the Arm-linux. Here are some of the things that are used in work to debug multithreading with GDB under Arm-linux.
First, download Debugging tools
The ARM-NONE-LINUX-GNUEABI-GCC compiler was used in the project to provide a download site ARM-NONE-LINUX-GNUEABI-GCC.
You can see the version information and the success of the ARM-ARAGO-LINUX-GNUEABI-GDB-V after you perform the transfer.
[email protected]:~/workdir/$ Arm-arago-linux-gnueabi-gdb-vgnu gdb (gdb) 7.2 Copyright (C) 2010 free software Foundation, inc.license gplv3+: GNU GPL version 3 or later //GNU.ORG/LICENSES/GPL.HTML> Span class= "hljs-built_in" >free software:you is free to change and Redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show Warranty" for details. This GDB is configured as "--host=i686-linux--target=arm-arago-linux-gnueabi" . For bugs reporting instructions, please see://www.gnu.org/software/gdb/bugs/> .
Second, the establishment of commissioning environment
1. Input in the following machine:gdbserver 10.11.13.19:215 Test.app
# gdbserver 10.11.13.19:215 test.app 817215
Where 10.11.13.19 is the IP address of the host, 215 is the port number of the connection, and Test.app is the application to debug. After success, the lower machine will listen to Port 215.
2, in the host input:arm-arago-linux-gnueabi-gdb Test.app
[Email protected]:~/workdir/$arm-arago-linux-gnueabi-gdb test.appgnu gdb (GDB)7.2Copyright (C) .Free software Foundation, inc.license gplv3+: GNU GPL version3or later //gnu.org/licenses/gpl.html>This is FreeSoftware:you is FreeTo change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type"Show copying"and"Show warranty" forDetails. This GDB is configured as"--host=i686-linux--target=arm-arago-linux-gnueabi". For bugs reporting instructions, please see://www.gnu.org/software/gdb/bugs/>, .....Reading symbols From/home/xxx/workdir/test.app...done. (GDB)
3, the next machine and the host to establish a connection, after (GDB) input: target remote 10.11.13.215:215
10.11.13.215:215using10.11.13.215:215Reading symbols from /lib/ld-linux.so.3for /lib/ld-linux.so.30x400b3790 in ?? () from /lib/ld-linux.so.3
10.11.13.215 is the IP address of the lower machine, 215 is the port number. After the success of the next opportunity to promise a Remote debugging from the host 10.11.13.19 information.
Third, the commissioning process
All of the above steps can be successfully executed after the corresponding debugging commands to debug the program, the following are some common debugging commands.
1, break point
Can be used: B < function name >
10x488281402.
or use b file name: line number.
(gdb) b cfg_bswv_valid_check.cpp :30120x565a4301.
In addition, disable n can make n breakpoints invalid, such as disable 2 to make breakpoint 2 invalid, valid for enable 2, remove breakpoints with disable 2, clear breakpoints with clear
2, let the program execution typing C can be
(gdb)c
3, check the information during debugging can use the Info keyword.
For example, view breakpoint information can be used with I (info B):
(gdb) i bNum Type Disp Enb Address What1 breakpoint keep y 0x00048828 in cfg_bswv_main_t::set_pulse_duty(cfg_data_t) at cfg_bswv_main.cpp:1402 1 time2 breakpoint keep y 0x000565a4 in cfg_bswv_valid_check_t::check_pulse_duty(fp64&, fp64, fp64, fp64, cfg_bswv_wave_t&) at cfg_bswv_valid_check.cpp:301
Info can also view a lot of information, such as viewing thread information: Info threads, you can enter info to find yourself, again not listed.
4, the next step with N, stepping (can enter the function inside) with S.
5. View the value of the variable with P
(gdb) p data$120, unit = CFG_IU}
6. View current stack information with BT
(GDB) bt#0 cfg_bswv_main_t::set_pulse_duty (THIS=0X7BED50, data= ...) at cfg_bswv_main.cpp:1405#1 0X000487BC in Cfg_bswv_main_t::set_pulse_width_duty_mode (THIS=0X7BED50, Pulse_mode=cfg_pulse_duty_mode) At Cfg_bswv_main.cpp:1369#2 0x0007356c in bswv_pulse_duty_width_mode_msg_t::d eal_set_message (this=0x7c1144, msg_data= ...)At Cfg_bswv_msg.cpp:1480#3 0x000217b4 in cfg_msg_t::d eal_message (this=0x7c1144, in_buffer=0x426da570) at cfg_lib_msg.cpp:49#4 0x0015a168 in deal_message_t::d eal (this=0x7c1144, message_buffer=0x426da570) at message.cpp:567#5 0x00159d44 in message_receive_t::d eal_message (this=0x426da568) at message.cpp:399#6 0x00159820 in Message_receive_t::wait_message (this=0x426da568, msgflg=4096, msg_id=0) at message.cpp:290#7 0x0003c94c in Cfg_main (arg=0x0) at cfg_main.cpp:80#8 0x0003c820 in Cfg_if_config_thread (arg=0x0) at cfg_if_main.cpp:40#9 0x400ddcf8 in?? () from/home/ding/ti-sdk-am335x/filesystem/lib/libpthread.so.0#10 0x400ddcf8 in?? () from/home/ding/ti-sdk-am335x/filesystem/lib/libpthread.so.0BackTrace stopped:previous frame identical to ThisFRAME (corruptStack?)
You can see the program's call stack on the current thread. Further implementation; thread apply all BT can view the stack condition for all threads. From here we can also find that each thread has its own call stack.
7. Kill terminates debugging.
8. Break Filename:line number multiple files set breakpoints
9, p/x hexadecimal display variable value
(gdb) p/x frq.data$40x3e8
10, finish continue to do know the current function end
11. Jump jumps to the development line
12. Tbreak Set temporary breakpoint (set breakpoint to execute only once)
13. P A=5 assigns a value to a variable
14. Show Scheduler-locking
for"off".
Off when the thread can be scheduled, on when only the current.
15. Set Scheduler-locking Off|on|step
Debug Unlock | lock | Step into the current thread, and other threads stop.
16. Thread num View threads information for the specified thread number
2 2815)]#0 cfg_bswv_main_t::set_pulse_duty (this=0x7bed50, data=...) at cfg_bswv_main.cpp:14071407 get_prd(prd);
17. X/4096xh Memory Printing
18, B 477 if point_count=1000 conditional breakpoint
19, until run to the specified line
20. Thread Apply ID1 ID2 command
22, p d d p Span style= "Display:inline-block; width:0px; Height:2.279em; " > Add + Size
Dump binary memory./file 1 2
In addition, there are many debugging commands, not listed here. Can be found in the relevant documentation. But the above are basically enough ~
Iv. Summary
In a word, in the process of use can feel GDB debugging function is still very powerful, when the program has a bug, first look at the code there is no error, in the appropriate place to add printing information is an effective way, but when these are not solved, do not try to use GDB. Debug commands can also be written in the script to execute, the command to execute the script is: source.
Multi-threaded debugging under Arm-linux