Debugging technology-orisun-blog
35 degrees in China
Data mining, NLP, search engine
Debugging technology
GDB
(GDB) r 65536 Hello running with Parameters
You can use PS | grep ××× or pstree to view the process ID.
Attach <pid> mountedProgramDebugging the running program
Detach <pid> unmount
Watch <expression> once the expression value changes, stop the program immediately.
View during GDB debuggingSource code
List
List <line-number>
List <function>
For single-step debugging, you can use N (EXT) and S (TEP). Step is used to enter the function and next is not used.
Set the breakpoint B sum in the specified function
Set ARGs "ZCY" -- Specify runtime Parameters
Show ARGs -- view the set runtime Parameters
Shell Command -- run shell commands directly during debugging
Break row number or function name if condition expression -- Set breakpoint
Tbreak row number or function name if condition expression -- sets a temporary breakpoint and is automatically deleted upon arrival
Delete breakpoint number -- delete a specified breakpoint. Its breakpoint number is the first column in "info B. If the default breakpoint number is used, all breakpoints are deleted.
Disable breakpoint number -- stop a specified breakpoint and use "info B" to view the breakpoint. Similar to delete, a breakpoint number is saved to stop all breakpoints.
Enable breakpoint number -- specifies the breakpoint to be activated, that is, the breakpoint to be disabled by disable is activated.
Condition breakpoint number if <condition expression> -- modify the condition of the corresponding breakpoint
C -- continue to execute the function until the function ends or a new breakpoint occurs.
Ignore breakpoint number <num> during program execution, the corresponding breakpoint num is ignored.
Wahtis P viewing variable types
Backtrace (or BT) to view stack information
When a function is called, the address, parameters, and local variables of the function are pushed into the stack.
Each function corresponds to a frame. When a function is called, the frame has many layers.
Frame 0
Up move frame up
Move down Frame
Info register view register information
Multi-process debugging
(GDB) Continue debugging the parent process after follow-fork-mode parent fork. The child process is not affected.
(GDB) subprocesses are debugged after follow-fork-mode child fork. Parent and Child processes are not affected.
(GDB) set detach-on-fork on disconnect and debug the process specified by follow-fork-Mode
(GDB) set detach-on-fork off GDB will continue to control sub-processes and parent processes. The process specified by follow-fork-mode will be debugged, And the other process will be in the suspend state.
Multi-thread debugging
Info threads displays the summary of all threads
Thread <threadno> sets the process whose process number is threadno to the current process
Break <linenumber> thread <threadno> specifies the line number and process number when a breakpoint is set.
Remote debugging
Gdbserver + GDB runs on the host, and gdbserver runs on the target environment
Download and decompress the gdb package
CD gdb-6.6
./Configure -- target = arm-Linux
Make
Sudo make install
This is to compile the gdb program for the host.
Cd gdb/gdbserver/
./Configure -- target = arm-Linux -- Host = arm-Linux
Make cc =/opt/embedsky/4.3.3/bin/ARM-Linux-gcc
Sudo make install
Download the generated gdbserver TO THE DEVELOPMENT BOARD
Use the arm-Linux-gcc-ggdb programming program test. C on the PC to download test to the Development Board, and keep test on the PC.
GDB and gdbserver can communicate with each other through TCP (in the format of Host: port), UDP (in the format of UDP: Host: port), or serial port.
Take TCP as an example:
On the Development Board, # gdbserver 192.168.0.100: 5678./overflow 192.168.0.100 is the Host IP address.
On the host, $ arm-Linux-GDB./Overflow
(GDB) target remote 192.168.0.102: 5678 192.168.0.102 is the IP address of the Development Board.
For more information, see http://blog.csdn.net/shawnrong/archive/2007/08/16/1745998.aspx
And http://blog.ednchina.com/baifanshuishou/1968826/message.aspx
Graphical debugging
Use DDD (data display debugger)
Author: orisun (35 degrees in China) http://www.cnblogs.com/zhangchaoyang