dmesg 程序崩溃调试
[root@localhost log]# cat -n /root/xx.c
#include <stdio.h>
void func(char *p)
{
*p = 'p';
}
int main(int argc, char *argv[])
{
char *p=NULL;
func(p);
return ;
}
[root@localhost log]# /root/xx
[root@localhost log]# dmesg xx[8226]: segfault at 0 ip 0000000000400454 sp 00007fffcb8b6360 error 6 in xx[400000+1000]
[root@localhost log]# objdump -d /root/xx /root/xx: file format elf64-x86- Disassembly of section .init: <_init>:
: ec sub $0x8,%rsp
40033c: e8 5b callq 40039c <call_gmon_start>
: e8 da callq <frame_dummy>
: e8 d5 callq <__do_global_ctors_aux>
40034b: c4 add $0x8,%rsp
40034f: c3 retq
Disassembly of section .plt: <__libc_start_main@plt-0x10>:
: ff d2 pushq (%rip) # <_GLOBAL_OFFSET_TABLE_+0x8>
: ff d4 jmpq *(%rip) # <_GLOBAL_OFFSET_TABLE_+0x10>
40035c: 0f 1f nopl 0x0(%rax) <__libc_start_main@plt>:
: ff d2 jmpq *(%rip) # <_GLOBAL_OFFSET_TABLE_+0x18>
: pushq $0x0
40036b: e9 e0 ff ff ff jmpq <_init+0x18>
Disassembly of section .text: <_start>:
: ed xor %ebp,%ebp
: d1 mov %rdx,%r9
: 5e pop %rsi
: e2 mov %rsp,%rdx
: e4 f0 and $0xfffffffffffffff0,%rsp
40037d: push %rax
40037e: push %rsp
40037f: c7 c0 mov $0x400480,%r8
: c7 c1 mov $0x400490,%rcx
40038d: c7 c7 mov $0x400459,%rdi
: e8 c7 ff ff ff callq <__libc_start_main@plt>
: f4 hlt0039a: nop0039b: nop 000000000040039c <call_gmon_start>:
40039c: ec sub $0x8,%rsp
4003a0: 8b mov (%rip),%rax # <_DYNAMIC+0x190>
4003a7: c0 test %rax,%rax
4003aa: je 4003ae <call_gmon_start+0x12>
4003ac: ff d0 callq *%rax
4003ae: c4 add $0x8,%rsp
4003b2: c3 retq
4003b3: nop003b4: nop003b5: nop003b6: nop003b7: nop003b8: nop003b9: nop003ba: nop003bb: nop003bc: nop003bd: nop003be: nop003bf: nop 00000000004003c0 <__do_global_dtors_aux>:
4003c0: push %rbp
4003c1: e5 mov %rsp,%rbp
4003c4: push %rbx
4003c5: ec sub $0x8,%rsp
4003c9: 3d cmpb $0x0,(%rip) # <completed.>
4003d0: jne <__do_global_dtors_aux+0x56>
4003d2: b8 mov $0x600678,%eax
4003d7: 2d sub $0x600670,%rax
4003dd: c1 f8 sar $0x3,%rax
4003e1: 8d ff lea 0xffffffffffffffff(%rax),%rbx
4003e5: 8b 5c mov (%rip),%rax # <dtor_idx.>
4003ec: c3 cmp %rax,%rbx
4003ef: 1e jbe 40040f <__do_global_dtors_aux+0x4f>
4003f1: c0 add $0x1,%rax
4003f5: 4c mov %rax,(%rip) # <dtor_idx.>
4003fc: ff c5 callq *0x600670(,%rax,)
: 8b 3e mov (%rip),%rax # <dtor_idx.>
40040a: c3 cmp %rax,%rbx
40040d: e2 ja 4003f1 <__do_global_dtors_aux+0x31>
40040f: c6 3a movb $0x1,(%rip) # <completed.>
: c4 add $0x8,%rsp
40041a: 5b pop %rbx
40041b: c9 leaveq
40041c: c3 retq
40041d: 0f 1f nopl (%rax) <frame_dummy>:
: push %rbp
: 3d cmpq $0x0,(%rip) # <__JCR_END__>
:
: e5 mov %rsp,%rbp
40042c: je <frame_dummy+0x24>
40042e: b8 mov $0x0,%eax
: c0 test %rax,%rax
: 0c je <frame_dummy+0x24>
: bf mov $0x600680,%edi
40043d: c3 mov %rax,%r11
: c9 leaveq
: ff e3 jmpq *%r11
: c9 leaveq
: c3 retq
: nop
: nop <func>:
: push %rbp
: e5 mov %rsp,%rbp
40044c: 7d f8 mov %rdi,0xfffffffffffffff8(%rbp)
: 8b f8 mov 0xfffffffffffffff8(%rbp),%rax
: c6 movb $0x70,(%rax)
: c9 leaveq
: c3 retq <main>:
: push %rbp
40045a: e5 mov %rsp,%rbp
40045d: ec sub $0x20,%rsp
: 7d ec mov %edi,0xffffffffffffffec(%rbp)
: e0 mov %rsi,0xffffffffffffffe0(%rbp)
: c7 f8 movq $0x0,0xfffffffffffffff8(%rbp)
40046f:
: 8b 7d f8 mov 0xfffffffffffffff8(%rbp),%rdi
: e8 cf ff ff ff callq <func>
: b8 mov $0x0,%eax
40047e: c9 leaveq
40047f: c3 retq <__libc_csu_fini>:
: f3 c3 repz retq
: 0f 1f nopl 0x0(%rax)
: 0f 1f nopl 0x0(%rax) <__libc_csu_init>:
: 4c e0 mov %r12,0xffffffffffffffe0(%rsp)
: 4c 6c e8 mov %r13,0xffffffffffffffe8(%rsp)
40049a: 4c 8d bb lea (%rip),%r12 # 60065c <__fini_array_end>
4004a1: 4c f0 mov %r14,0xfffffffffffffff0(%rsp)
4004a6: 4c 7c f8 mov %r15,0xfffffffffffffff8(%rsp)
4004ab: f6 mov %rsi,%r14
4004ae: 5c d0 mov %rbx,0xffffffffffffffd0(%rsp)
4004b3: 6c d8 mov %rbp,0xffffffffffffffd8(%rsp)
4004b8: ec sub $0x38,%rsp
4004bc: ff mov %edi,%r15d
4004bf: d5 mov %rdx,%r13
4004c2: e8 fe ff ff callq <_init>
4004c7: 8d 8e lea (%rip),%rax # 60065c <__fini_array_end>
4004ce: c4 sub %rax,%r12
4004d1: c1 fc sar $0x3,%r12
4004d5: 4d e4 test %r12,%r12
4004d8: 1e je 4004f8 <__libc_csu_init+0x68>
4004da: ed xor %ebp,%ebp
4004dc: c3 mov %rax,%rbx
4004df: nop004e0: c5 add $0x1,%rbp
4004e4: 4c ea mov %r13,%rdx
4004e7: 4c f6 mov %r14,%rsi
4004ea: ff mov %r15d,%edi
4004ed: ff callq *(%rbx)
4004ef: c3 add $0x8,%rbx
4004f3: ec cmp %rbp,%r12
4004f6: e8 jne 4004e0 <__libc_csu_init+0x50>
4004f8: 8b 5c mov 0x8(%rsp),%rbx
4004fd: 8b 6c mov 0x10(%rsp),%rbp
: 4c 8b mov 0x18(%rsp),%r12
: 4c 8b 6c mov 0x20(%rsp),%r13
40050c: 4c 8b mov 0x28(%rsp),%r14
: 4c 8b 7c mov 0x30(%rsp),%r15
: c4 add $0x38,%rsp
40051a: c3 retq
40051b: nop0051c: nop0051d: nop0051e: nop0051f: nop <__do_global_ctors_aux>:
: push %rbp
: e5 mov %rsp,%rbp
: push %rbx
: bb mov $0x600660,%ebx
40052a: ec sub $0x8,%rsp
40052e: 8b 2b mov (%rip),%rax # <__CTOR_LIST__>
: f8 ff cmp $0xffffffffffffffff,%rax
: je 40054f <__do_global_ctors_aux+0x2f>
40053b: 0f 1f nopl 0x0(%rax,%rax,)
: eb sub $0x8,%rbx
: ff d0 callq *%rax
: 8b mov (%rbx),%rax
: f8 ff cmp $0xffffffffffffffff,%rax
40054d: f1 jne <__do_global_ctors_aux+0x20>
40054f: c4 add $0x8,%rsp
: 5b pop %rbx
: c9 leaveq
: c3 retq
: nop
: nop
Disassembly of section .fini: <_fini>:
: ec sub $0x8,%rsp
40055c: e8 5f fe ff ff callq 4003c0 <__do_global_dtors_aux>
: c4 add $0x8,%rsp
: c3 retq [root@localhost log]# objdump -d /root/xx |grep -C5
<func>:
: push %rbp
: e5 mov %rsp,%rbp
40044c: 7d f8 mov %rdi,0xfffffffffffffff8(%rbp)
: 8b f8 mov 0xfffffffffffffff8(%rbp),%rax
400454: c6 movb $0x70,(%rax)
: c9 leaveq
: c3 retq <main>:
: push %rbp
Usage: addr2line [option(s)] [addr(s)]
Convert addresses into line number/file name pairs.
If no addresses are specified on the command line, they will be read from stdin
The options are:
@<file> Read options from <file>
-b --target=<bfdname> Set the binary file format
-e --exe=<executable> Set the input file name (default is a.out)
-i --inlines Unwind inlined functions
-j --section=<name> Read section-relative offsets instead of addresses
-s --basenames Strip directory names
-f --functions Show function names
-C --demangle[=style] Demangle function names
-h --help Display this information
-v --version Display the program's version [root@localhost log]# addr2line -e /root/xx 0x400454
/root/xx.c:7
gdb调试: [root@localhost ~]# gdb ./xx
GNU gdb (GDB) .
Copyright (C) Free Software Foundation, Inc.
License GPLv3+: GNU GPL version or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./xx...done. (gdb) disas 0x400454
Dump of assembler code for function func:
0x0000000000400448 <+>: push %rbp
0x0000000000400449 <+>: mov %rsp,%rbp
0x000000000040044c <+>: mov %rdi,-0x8(%rbp)
0x0000000000400450 <+>: mov -0x8(%rbp),%rax
0x0000000000400454 <+>: movb $0x70,(%rax)
0x0000000000400457 <+>: leaveq
0x0000000000400458 <+>: retq
End of assembler dump.
(gdb) list func
#include <stdio.h>
void func(char *p)
{
*p = 'p';
}
int main(int argc, char *argv[])
dmesg 程序崩溃调试的更多相关文章
- dmesg 程序崩溃调试2
dmesg命令基于缓冲区打印信息dmesg -c可以清除该内存信息清除后demsg 命令不显示任何信息,但可以到/var/log/dmesg查看信息 dmesg |tail 20dmesg |head ...
- [ios-必看] IOS调试技巧:当程序崩溃的时候怎么办 iphone IOS
from:http://article.ityran.com/archives/1143 有这样一种情形:当我们正在快乐的致力于我们的app时,并且什么看都是无比顺利,但是突然,坑爹啊,它崩溃了.(悲 ...
- Ubuntu16.04下写的Qt程序,调试时没问题,运行时偶现崩溃 (需要在运行时生成core dump文件,QMAKE_CC += -g)
记录一下 Ubuntu16.04下写的Qt程序,调试时没问题,运行时偶现崩溃 需要在运行时生成core dump文件 首先在pro结尾里加入 QMAKE_CC += -g QMAKE_CXX += - ...
- Windows 程序 dump 崩溃调试
Windows 程序捕获崩溃异常 生成dump 概述 事情的起因是,有个同事开发的程序,交付的版本程序,会偶尔随机崩溃了. 悲催的是没有输出log,也没有输出dump文件. 我建议他给程序代码加个异常 ...
- IOS调试技巧:当程序崩溃的时候怎么办 xcode调试
转自:http://www.ityran.com/archives/1143 ------------------------------------------------ 欢迎回到当程序崩溃的时候 ...
- Linux高级调试与优化——信号量机制与应用程序崩溃
背景介绍 Linux分为内核态和用户态,用户态通过系统调用(syscall)进入内核态执行. 用户空间的glibc库将Linux内核系统调用封装成GNU C Library库文件(兼容ANSI &am ...
- 你的java/c/c++程序崩溃了?揭秘段错误(Segmentation fault)(3)
前言 接上两篇: 你的C/C++程序为什么无法运行?揭秘Segmentation fault (1) 你的C/C++程序为什么无法运行?揭秘Segmentation fault (2) 写到这里,越跟 ...
- iOS崩溃调试的使用和技巧总结
在iOS开发调试过程中以及上线之后,程序经常会出现崩溃的问题.简单的崩溃还好说,复杂的崩溃就需要我们通过解析Crash文件来分析了,解析Crash文件在iOS开发中是比较常见的. 现在网上有很多关于解 ...
- MATLAB调用C程序、调试和LDPC译码
MATLAB是一个很好用的工具.利用MATLAB脚本进行科学计算也特别方便快捷.但是代码存在较多循环时,MATLAB运行速度极慢.如果不想放弃MATLAB中大量方便使用的库,又希望代码能迅速快捷的运行 ...
随机推荐
- jquery parent()和parents()区别
parent(exp) 取得一个包含着所有匹配元素的唯一父元素的元素集合. 你可以使用可选的表达式来筛选. 查找段落的父元素中每个类名为selected的父元素. HTML 代码: <div&g ...
- GC回收建议
1.最基本的建议就是尽早释放无用对象的引用.大多数程序员在使用临时变量的时候,都是让引用变量在退出活动域(scope)后,自动设置为 null.我们在使用这种方式时候,必须特别注意一些复杂的对象图,例 ...
- HTML本地测试成功后上传博客注意事项
需要注意不要跟博客已经存在的样式(CSS)或功能(JavaScript)起冲突 功能名一定不要一样 样式名尽量不一样 如果样式名一样,存在属性名的对应属性值尽量跟博客内相同
- Aspcms所有标签调用
错误号3002: 出现此问题一般是有些频道模板不全,或者缺少一部分模板导致,或者没有单独设置html文件夹,并将所有html页面放进去 基本语法 {aspcms:sitepath} 网站终极目录(可放 ...
- WordPress Checkout插件跨站脚本漏洞和任意文件上传漏洞
漏洞名称: WordPress Checkout插件跨站脚本漏洞和任意文件上传漏洞 CNNVD编号: CNNVD-201311-015 发布时间: 2013-11-04 更新时间: 2013-11-0 ...
- 【随笔】这段时间没有写博客是因为一边看Qt5的帮助文档一边写小程序
长话短说,因为和做程序员的以前的同学联系了一下,知道自己有很多不足,加之接到一个培训机构的人打来的电话稍微打击了一下,虽然那个人满嘴跑火车想装做和我很谈得来,但是我依然看到了自己没有写过任何命令行以外 ...
- 设置将 Microsoft Azure 的网络基础结构以支持设置为灾难恢复站点
Prateek Sharma 云 + Enterprise 高级项目经理 Azure SiteRecovery (ASR)可以将Microsoft Azure用作您的虚拟机的灾难恢复站点. 当管理 ...
- apache虚拟主机的设置
方法一: 首先打开apache中conf下的http.conf文件打开虚拟主机的注释:如下去掉第二行前面的#即可 # Virtual hosts# Include conf/extra/httpd-v ...
- 【转】Xcode常用快捷键与技巧分享
原文网址:http://www.jianshu.com/p/039954b0cbe0 工欲善其事必先利其器. 虽然Xcode编写objective-c or swift很完美, 但了解其工具的常用快捷 ...
- linux文件属性详解
Linux 文件或目录的属性主要包括:文件或目录的节点.种类.权限模式.链接数量.所归属的用户和用户组.最近访问或修改的时间等内容.具体情况如下: 命令: ls -lih 输出: [root@loca ...