Embedded technology study notes (4)

Debugger: gdb
1. gdb is part of the GNU project. Kernel debugging uses KGDB
2. Program errors are divided into two categories: (1) compile-time errors, which are actually syntax errors, and (2) runtime errors, which are actually memory errors or logic errors.
3. The gdb function: (1) Run the program (2) Set a breakpoint (3) Check the value of the variable
4. How to use gdb: gcc -g hello.c -o hello Then use gdb hello to use gdb
5, gdb specific commands Brief introduction to
gdb --tui: enter gdb graphical interface
layout asm: display assembly window
layout src: display source code window
layout split: display source code and assembly window

run: start running
finish: end run
continue: end the current breakpoint, continue to run until the next breakpoint

break plus line number: set breakpoint at line number
break plus function name: set breakpoint at function name
break plus line number plus if condition: set breakpoint at condition
info break: list all breakpoint information
delete plus break Point number: delete the breakpoint
enable plus the breakpoint number: make the breakpoint effective
disable plus the breakpoint number: make the breakpoint invalid

Single-step execution (after setting a breakpoint)
step can enter the sub-function
next can not enter the sub-function,
but both can step through the program

Project manager: make
1. Project manager: Compile a software code structure composed of many files. These files may be of different types, stored in different directories, and use different resource files. If there are multiple .c files, it will be very troublesome to compile them, and using make can automatically compile these .c files.
Automatic compilation: (1) Automatically compile based on the content of the makefile (2) Determine whether the file needs to be compiled based on the timestamp of the file.
makefile is a script file, which is
the syntax of the makefile used for batch processing : target, dependency, command structure is as follows:
target and then enter :, after the colon is dependent, press the tab and then enter the command to
execute the command, rely on this file, and finally Generate this goal.
Makefile execution sequence: from top to bottom, when your target dependent file has another target, it will first jump to the target to execute related commands
make + target name: start from the target and execute from top to bottom.
Makefile pseudo target: only execute the command, do not generate the corresponding file use. PHONY: add the file name to generate the pseudo target

Functional directory management software code:
makefile:
Makefile control, enter each functional directory and execute make, and link all .o files to generate executable files
. Makefile, compile the source files under the functional directory to generate the target file.o
scripts directory header File Makefile, define variables for use by other makefiles
Read the order of makefiles: (1) Makefile in scripts directory header (2) Makefile in master control (3) Makefile in function directory

Published 14 original articles · Like1 · Visits 477

Guess you like

Origin blog.csdn.net/a1152946932/article/details/104920439