gcc,gdb 个人笔记

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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值