原文:https://blog.csdn.net/u014633966/article/details/37921313
gcc: -c : just compile don't link -o: -o2: gcc -g -o2 hello.c -o hello -l -L -Wall : display the warnin while compiling 静态编译 gcc -static -o gcc -shared -o hishared main.c -L. -lmyhi test!!!!!!! hi.c hi.h
gcc -c hi.c 生成hi.o
history 100: see the 100 histroy commands recently gdb 查看coredump
file kill list next step run quit watch break make
1.编译的时候 gcc -g test.c -o test 2.编译完后启动gdb gdb test 3.list 显示程序 4.打断点:
1)在某个函数入口打断点: b main 2)在某一行打断点: b 25 3)在某个文件的某一行 b test.c:25 4)加条件下断点 如果i=25时在20行断点 b 20 if i=25 5.查看所有断点 info break 6.删除断点: delete 1 删除断点编号 7. 查看变量的值 print i 8.退出gdb quit
ls -lrt
show listsize set listsize
i b; d n disable n : enable n continue
pwd cd : change dir gdb中使用shell: shell (退出: exit)
gdb 执行文件 coredump 可以看到第三方程序code,保密?权限
调试正在运行的程序: gdb PID 28281 break *address clear : 清除所有停止点 break if condition break if i=50 edit *a@4 取4个数
dissemble
l 1,20
disassemle main 查看变量,数组,输出格式 p/x p/o 改变变量值: print x=4
info register
jump
g++ -o hellocpp hello.cpp : 注意要用gdb调试的话,需要 -g
g++ -g -o hellocpp hello.cpp