shell之调试&分析
2016-03-15 21:41
453 查看
gdb调试
语句 | 含义 |
---|---|
gcc -g | 编译源码确保含有-g的参数 |
gdb ./app | 启动gdb并开始调试程序app |
(gdb)set args x1 y1 | 设置app运行的参数(./app x1 y1) |
(gdb) r | 开始运行程序(run的简写) |
(gdb) l | 列举调试的源码(list的简写) |
(gdb) b 16 | 在代码16行设置断点 |
(gdb)b main.cpp:12 | 在main.cpp文件的12行设置断点 |
(gdb)b onRecv | 在onRecv函数设置断点 |
(gdb)info break | 查看所有的断点 |
(gdb)info break 3 | 查看第3个断点 |
(gdb)n | 单行执行,有函数不会进入函数(next简写) |
(gdb)s | 单步执行,有函数会跳入函数(step简写) |
(gdb)finish | 退出函数 |
(gdb)c | 继续运行(continue简写) |
(gdb)q | 退出调试(quit简写) |
(gdb)p a | int a = add(1,2); |
tcpdump
tcpdump -n -i eth0 host 192.168.31.147 and 114.114.114.114截取本机192.168.31.147和主机114.114.114.114之间的通信数据
tcpdump -n -i eth0 dst 192.168.31.147
tcpdump -n -i eth0 dst 192.168.31.147 or 192.168.31.157
截取所有进入本机的数据(或多个IP)
tcpdump -n -i eth0 dst 192.168.31.147 or 192.168.31.157 and tcp
抓取进入本机的所有tcp数据包
tcpdump -n -i eth0 src 192.168.31.147 or 192.168.31.157
tcpdump -n -i eth0 src 192.168.31.147 and port ! 22 and tcp
抓取从本机发出的数据包(and or进行条件筛选端口)
tcpdump host 192.168.1.142
截获主机所有的收发的数据
strace
strace –o log.txt app执行app程序,并将其涉及的所有系统调用输出到log.txt中
strace –o log.txt –p pid
查看指定进程号的程序对应的系统调用的过程
valgrind
安装valgrindYum install valgrind
生成内存泄露信息
valgrind –tool=memcheck –leak-check=yes –log-file=mem.txt ./app
definitely lost
肯定泄露部分
possibly lost
可能泄露部分
indirectly lost
间接泄露
相关文章推荐
- Linux学习6之shell筛选当前目录下文件并逐个对其进行操作
- Linux学习5之shell显示当前目录下所有的文件和文件夹
- Xmanager Enterprise 4连接不上xshell
- About Zsh & Go2Shell & iTerm2
- shell实现trim函数-去除字符串两侧的空格(包括tab,space键)
- shell之gcc用法汇总
- shell之dhcp的配置介绍
- Bash,Vim,gdb&git常用命令
- shell入门指南
- shell之dns配置
- shell之dns_zone的配置含义
- shell定时备份
- shell之Crontab介绍
- 能用Shell就别编程-海量文本型数据的处理
- Linux Shell编程基础
- Hbase快速开始——shell操作
- 静默调用ShellContextMenu 实现QQ文件共享
- shell 获取时间
- 用shell编程实现打印九九乘法表
- linux shell 系列 sed 命令基本用法实例-①set命令选项的应用案例