GDB Debugging Tools/Makfile Project management

Source: Internet
Author: User
Tags mul

GDB Debugging Tools

Gcc-g Main.c-o Main

Common commands

Command Shorthand function

Help h List command classes by module

Help class to find a specific type of command

List L View Code, can follow line number and function name

Quit Q Exit GDB

Run R running the program at full speed

Start stepping, running the program, stopping on the first line to execute the statement

Next n Step over process

Step s executes in a statement, encounters a function, and executes within a function

BackTrace b Viewing the call stack frames and hierarchy relationships of functions

Info I View values of local variables inside a function

Frame f Toggle function for stack frames

Finish ends the current function, returning the function call point

Set sets the value of a variable

Run arvg[1] argv[2] command-line pass parameters when debugging

Print p printing variables and addresses

Break B Sets a breakpoint that can be based on the line number and function name

Delete d Remove Breakpoint D breakpoints NUM

Display Settings observation variable

Undisplay Canceling observation variables

Continue continues to run the remaining code at full speed

Enable breakpoints enabling breakpoints

Disable breakpoints Disabling breakpoints

X View memory X/20XW display 20 units, 16 binary, 4 bytes per unit

Watch is set to the observation point when the variable is sent to modify, print display

I watch display observation points

Core file ulimit-c 1024 open core file, debug GDB a.out Core

Set Var sets the value of variables in debugging such as N=10 set Var n=100

GDB Debug Mode

GDB Debug Mode

Run running at full speed

Start single-Step commissioning

Set Follow-fork-mode child/parent #Makefile项目管理 trace child process and parent process

Makfile Project Management

Project Code Compilation Management

Save time compiling projects

Write a lifetime benefit at a time

Operation sample file: Add.c sub.c mul.c dive.c main.c

Basic principles

Three elements

Goal

Conditions

Command

Makefile Working principle

Analyze the relationship between each goal and dependency

Execute commands from bottom up based on dependency relationship

According to the modified time than the target new, determine the update

If the target does not depend on any conditions, execute the corresponding command in order to update

Clean

Purpose: Clears the intermediate. o File and final destination file of the compiled production

Make clean if there is a clean file with the same name in the current directory, the clean corresponding command is not executed

Pseudo-target declaration:. Phony:clean

Special symbols in the clean command

    • "-" This command has an error and make will continue to execute subsequent commands. such as: "-rm main.o"
    • "@" does not display the command itself, only displays the results. such as: "@echo" clean-Done ""

Other

-make default executes the first occurrence of the target, you can specify the target to be executed by make DST

-distclean Target

-install Target

-make-c the specified directory into the specified directory, call inside the makefile

Simple to use Makefile

[Email protected]:~/linuxc/calc$ cat Makefile

#目标: Dependent (conditional)

# command

#阶段一

#app: add.c sub.c dive.c mul.c main.c

# gcc add.c sub.c dive.c mul.c main.c-o app

#

#阶段二

#app: add.o sub.o dive.o MUL.O MAIN.O

# gcc ADD.O sub.o dive.o mul.o main.o-o app

#add. o:add.c

# gcc-c ADD.C

#sub. O:SUB.C

# gcc-c SUB.C

#dive. o:dive.c

# gcc-c DIVE.C

#mul. o:mul.c

# gcc-c MUL.C

#main. o:main.c

# gcc-c MAIN.C

#阶段三

# [Email protected] represents the target, $^ indicates that all dependent,$< represent the first of the dependencies

#obj =add.o sub.o MUL.O dive.o MAIN.O

#src = $ (wildcard *.c)

#obj = $ (patsubst%.c,%.o,$ (SRC))

#target = App

#$ (target): $ (obj)

# gcc $^-o [email protected]

#%.o:%.c

# gcc-c $<-o [email protected]

#阶段四

cppflags=-iinclude

cflags=-g-wall

ldflags=

cc=gcc

#CC =ARM-LINUX-GCC

src = $ (wildcard *.c)

obj = $ (patsubst%.c,%.o,$ (SRC))

target = App

$ (target): $ (obj)

$ (CC) $^ $ (ldflags)-o [email protected]

%.o:%.c

$ (CC)-C $< $ (CFLAGS) $ (cppflags)-o [email protected]

. Phony:clean

#彻底清除生生过程文件

Clean

-rm-f *.O

-rm-f app

#彻底清除生生过程文件和生成配置文件

Distclean:

Rm/usr/bin/app

Install

CP App/usr/bin

Test

@echo $ (SRC)

@echo $ (obj)

GDB Debugging Tools/Makfile Project management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.