Linux x86-64 函数调用栈实例分析

前言 动手实践并写文章花5倍的时间一次性把事情做到90分,好过读别人文章只能做到60分,后面还需要花时间继续深入学习(做事情一定要做到有效的阈值)。本文目的希望通过分析一个简单的函数调用加深对x86-64寄存器及栈帧的结构的认识,以便在定位问题需要的时候能够熟练运用。 ...

March 9, 2016

代码是核心,但不仅仅是代码

其实以前也有类似的想法,但是决定写这篇文章是由下面一件事情引起的。 引子 同事自已造轮子要实现一个rtmp协议,在调试过程由于有一个问题有没有解决,影响团队的联调,对于他造主动造轮子,我是不支持的。重复实现一个完整的rtmp协议,会走很多坑的,需要花费较多的时间,而开源的librtmp已经实现完整的rtmp协议功能,我决定将librtmp协议移植到现在系统。 ...

March 5, 2016

docker image命令实践

搭建了docker环境,就来体验一下Docker,常用docker image命令如下: 1. 搜索docker image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 root@localhost ~]# docker search ubuntu NAME DESCRIPTION STARS OFFICIAL AUTOMATED ubuntu Ubuntu is a Debian-based Linux operating s... 2954 [OK] ubuntu-upstart Upstart is an event-based replacement for ... 58 [OK] dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC on po... 32 [OK] torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 25 [OK] ubuntu-debootstrap debootstrap --variant=minbase --components... 22 [OK] tleyden5iwx/ubuntu-cuda Ubuntu 14.04 with CUDA drivers pre-installed 18 [OK] rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 16 [OK] consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC sessi... 8 [OK] ioft/armhf-ubuntu [ABR] Ubuntu Docker images for the ARMv7(a... 7 [OK] n3ziniuka5/ubuntu-oracle-jdk Ubuntu with Oracle JDK. Check tags for ver... 7 [OK] nuagebec/ubuntu Simple always updated Ubuntu docker images... 4 [OK] nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli installed 3 [OK] nimmis/ubuntu This is a docker images different LTS vers... 3 [OK] maxexcloo/ubuntu Docker base image built on Ubuntu with Sup... 2 [OK] sylvainlasnier/ubuntu Ubuntu 15.10 root docker images with commo... 1 [OK] isuper/base-ubuntu This is just a small and clean base Ubuntu... 1 [OK] densuke/ubuntu-jp-remix Ubuntu Linuxの日本語remix風味です 1 [OK] seetheprogress/ubuntu Ubuntu image provided by seetheprogress us... 1 [OK] nickistre/ubuntu-lamp LAMP server on Ubuntu 1 [OK] teamrock/ubuntu TeamRock's Ubuntu image configured with AW... 0 [OK] konstruktoid/ubuntu Ubuntu base image 0 [OK] birkof/ubuntu Ubuntu 14.04 LTS (Trusty Tahr) 0 [OK] zoni/ubuntu 0 [OK] esycat/ubuntu Ubuntu LTS 0 [OK] rallias/ubuntu Ubuntu with the needful 0 2. 下载image 1 docker pull 3. 查看image 1 2 3 4 5 [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest d55e68e6cc9c 4 weeks ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB training/sinatra latest f0f4ab557f95 19 months ago 447 MB 4. 删除image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [root@localhost ~]# docker rm training/sinatra Error response from daemon: no such id: training/sinatra Error: failed to remove containers: [training/sinatra] [root@localhost ~]# docker rm f0f4ab557f95 Error response from daemon: no such id: f0f4ab557f95 Error: failed to remove containers: [f0f4ab557f95] [root@localhost ~]# docker rmi f0f4ab557f95 Untagged: training/sinatra:latest Deleted: f0f4ab557f954f3e04177663a3af90e88641bcdcce1f02ac900dbd9768ef4945 Deleted: 79e6bf39f99322cc062a79bec4a09de0dd19cb7f5f735b4b6b7832c04b13bb45 Deleted: ce80548340bb03726d391bb8fa4d134f8418c2fff90be9a7323560debdea9bd2 Deleted: e809f156dc985e07105fdc86ec05eb03eb7aac8636dc210e8595d31b55787f4a Deleted: bfab314f3b766eddf9778f8dce089f44e84ea028f4a44ce68740dce81a844ec8 Deleted: be88c4c27e80023b6aea82f0f2e15fb21c6f4193fe814e5b58010d356dd7846b Deleted: 3e76c0a80540a0d36493ae7110796fc92f559a191454e3ac19c1d4c650bdd9e0 Deleted: 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158 You have new mail in /var/spool/mail/root [root@localhost ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu latest af88597ec24b 6 days ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB 5. 运行image 1 [root@localhost ~]# docker run -i -t apache2 6. kill运行的docker image 1 2 3 4 5 6 7 8 9 10 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 68333b272b52 ubuntu "/bin/bash" 18 minutes ago Up 18 minutes clever_babbage 0ca2aff5b94b ubuntu "bash" 48 minutes ago Up 48 minutes focused_hypatia You have new mail in /var/spool/mail/root [root@localhost ~]# docker kill 68333b272b52 68333b272b52 [root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0ca2aff5b94b ubuntu "bash" 54 minutes ago Up 54 minutes focused_hypatia 7. 制作image 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [root@localhost tmp]# more Dockerfile FROM apache2 RUN apt-get install -y wget [root@localhost tmp]# docker build -t wget . Sending build context to Docker daemon 2.609 MB Sending build context to Docker daemon Step 0 : FROM apache2 ---> f5cf247f22af Step 1 : RUN apt-get install -y wget ---> Running in ab3cd326c53c [root@localhost tmp]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE wget latest be8bf51f39d5 29 seconds ago 229.1 MB apache2 latest f5cf247f22af 5 hours ago 223.8 MB ubuntu latest af88597ec24b 6 days ago 187.9 MB ubuntu 14.04 d55e68e6cc9c 4 weeks ago 187.9 MB 8. docker volume clean 1 docker system prune --all --volumes --force

January 28, 2016

升级Linux内核,搭建docker环境

docker可以说是去年最热的技术,也是业界大谈特谈的技术,到了今年有很多公司已经将docker应用于自己的生产环境。Docker已经从一个工具转化成平台,小生态圈。作为一名程序员应该与时俱进,学习新技术,不断地提高自己。 ...

December 13, 2015

gdb自定义断点操作

gdb是c/c++上调试利器,有很多技巧能让调试程序与解决问题更加方便与高效,下面关于command 命令的使用一个实例,具体如下: 1. 设置断点 1 2 3 (gdb) b GenVedioSeekPoint Breakpoint 1 at 0x402e58: file GenIndex.cpp, line 140. (gdb) 2. 利用commad自定义断点操作 1 2 3 4 5 6 7 (gdb) command 1 Type commands for breakpoint(s) 1, one per line. End with a line saying just "end". >p *pstPktHead >continue >end (gdb) 3. 设置gdb log信息输出到指定文件 1 2 3 4 5 (gdb) set logging file genindex.txt (gdb) set logging on Copying output to genindex.txt. (gdb) set pagination off (gdb) 4. 开始或继续执行程序 1 (gdb) run 有输出信息如下: ...

August 28, 2015

nginx实践-添加自定义模块hello

nginx是一个值得学习与研究的开源代码,写这篇文章主要目的是让自己能够能够从最简单的任务开始,通过写作促进自己一步一步地深入学习与分析nginx。本文是这个系列的第一篇,主要是记录自己实现一个自定义的模块hello的过程。 ...

August 8, 2015

Linux netstat 应用示例

关于netstat netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Memberships) 等等。 常用参数 -a (all)显示所有选项,默认不显示LISTEN相关 ...

July 28, 2015

读书笔记:《从0到1---开启商业与未来的秘密》

启发思考 在什么重要问题上你与其他有不同的看法? 除了书中讲到参考模式:太多数人相信X,但是事实却是X的对立面;世界是多样的,我们应当追求正确的差异化 企业失败的共同的原因 企业失败的原因却是相同:它们都无法逃脱竞争 ...

July 3, 2015

实现无符号整型数的分解

题目 将一个无符号数N拆分为不多于M个数,使拆分的数之和等于N,条件: N >= M; N与M都是无符号整型数 求:一共有多少中拆分方法? 分析 参考代码 代码 代码实现计算拆分方法及打印拆分组合信息 ...

June 14, 2015

ping不通常见原因总结

ping不通从ping的流程分为两大类: 请求报文没有到达对端 应答报文未收到 请求报文没有到达对端的可能原因: 发送端发送流程出错 源端,转发设备没有目的地址的路由 ttl 小于转发跳数 分片丢包 MTU限制 转发丢包 报文错误 防火墙规则不允许该类型报文通过 中间进行nat转换等处理出错 目的地址不存在 接收端收包流程出错 应答报文未收到的可能原因: ...

May 27, 2015