when we write a program, cpu and memory usages are very important to indicate the stability of the program. Once the cpu usage reached 90%, there are some bugs in your program, and you must find the problem. Here is a simply guide to debug with cpu 100%. For example:

void *first_routine (void * args)
{
while()
{
int a = ;
usleep();
} return NULL;
} int main()
{
pthread_t thread_first, thread_second;
pthread_create(&thread_first, NULL, &first_routine, NULL); while()
{
sleep();
}
return ;
}

then complile it : gcc debug.c -o debug -lpthread , and run it .

iii) use top tool find the bug thread,  top -p $pid -H

iv) use pstack : pstack $tid(bug thread), to look the stack of the bug thread. but pstack can't see the paraments. if you still can't determine the bug line, user gcore to get the program core.  (gcore $pid)

v)  gdb -c  $core.file  ./exe , and the use  command  bt(back trace), then use the paraments to determine the bug code.

最新文章

  1. 学习笔记--C#深复制和浅复制
  2. 通过端口 8080 连接到主机 localhost 的 TCP/IP 连接失败
  3. linux系统中批量查找文件与文件内容的方法
  4. 1、Hadoop的伪分布式部署
  5. JDK、Jmeter、Android环境变量配置
  6. 夺命雷公狗-----React---3--标签的规则
  7. Python 时间和日期模块的常用例子
  8. 关于新的man版本出现“无法解析 /usr/share/man/zh_CN/man1/ls.1.gz: 没有那个文件或目录“
  9. DAC,MAC和SELinux,SEAndroid
  10. 3.0:pandas【基础操作】
  11. JDBC连接数据以及操作数据
  12. angularjs directive (自定义标签解析)
  13. Anagram
  14. Java I/O流详解与应用
  15. 访问System x3650 IMM2的几种方式
  16. WSGI协议主要包括server和application两部分:
  17. git 工作区管理
  18. shell_base
  19. 清北合肥day1
  20. 【R作图】lattice包,画多个分布柱形图,hist图纵轴转换为百分比

热门文章

  1. oracle数据迁移
  2. 一款基于jQuery的支持鼠标拖拽滑动焦点图
  3. Golang学习 - bufio 包
  4. uboot 网络不通问题解决一例1
  5. 单表多次join的sql
  6. iOS 10 的一些资料整理
  7. 基本java类-In.java
  8. Python-Networkx
  9. Storm累计求和进群运行代码
  10. CentOS安装VMware Tools