[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 程序崩溃调试的更多相关文章

  1. dmesg 程序崩溃调试2

    dmesg命令基于缓冲区打印信息dmesg -c可以清除该内存信息清除后demsg 命令不显示任何信息,但可以到/var/log/dmesg查看信息 dmesg |tail 20dmesg |head ...

  2. [ios-必看] IOS调试技巧:当程序崩溃的时候怎么办 iphone IOS

    from:http://article.ityran.com/archives/1143 有这样一种情形:当我们正在快乐的致力于我们的app时,并且什么看都是无比顺利,但是突然,坑爹啊,它崩溃了.(悲 ...

  3. Ubuntu16.04下写的Qt程序,调试时没问题,运行时偶现崩溃 (需要在运行时生成core dump文件,QMAKE_CC += -g)

    记录一下 Ubuntu16.04下写的Qt程序,调试时没问题,运行时偶现崩溃 需要在运行时生成core dump文件 首先在pro结尾里加入 QMAKE_CC += -g QMAKE_CXX += - ...

  4. Windows 程序 dump 崩溃调试

    Windows 程序捕获崩溃异常 生成dump 概述 事情的起因是,有个同事开发的程序,交付的版本程序,会偶尔随机崩溃了. 悲催的是没有输出log,也没有输出dump文件. 我建议他给程序代码加个异常 ...

  5. IOS调试技巧:当程序崩溃的时候怎么办 xcode调试

    转自:http://www.ityran.com/archives/1143 ------------------------------------------------ 欢迎回到当程序崩溃的时候 ...

  6. Linux高级调试与优化——信号量机制与应用程序崩溃

    背景介绍 Linux分为内核态和用户态,用户态通过系统调用(syscall)进入内核态执行. 用户空间的glibc库将Linux内核系统调用封装成GNU C Library库文件(兼容ANSI &am ...

  7. 你的java/c/c++程序崩溃了?揭秘段错误(Segmentation fault)(3)

    前言 接上两篇: 你的C/C++程序为什么无法运行?揭秘Segmentation fault (1) 你的C/C++程序为什么无法运行?揭秘Segmentation fault (2) 写到这里,越跟 ...

  8. iOS崩溃调试的使用和技巧总结

    在iOS开发调试过程中以及上线之后,程序经常会出现崩溃的问题.简单的崩溃还好说,复杂的崩溃就需要我们通过解析Crash文件来分析了,解析Crash文件在iOS开发中是比较常见的. 现在网上有很多关于解 ...

  9. MATLAB调用C程序、调试和LDPC译码

    MATLAB是一个很好用的工具.利用MATLAB脚本进行科学计算也特别方便快捷.但是代码存在较多循环时,MATLAB运行速度极慢.如果不想放弃MATLAB中大量方便使用的库,又希望代码能迅速快捷的运行 ...

随机推荐

  1. Universal Asynchronous Receiver/Transmitter

    USART簡介與特性 NRZ標準資料格式(Mark/Space) 半雙工/全雙工 Synchronous 同步傳輸 CLOCK SKEW Asynchronous 非同步傳輸 半/全雙工.同步/非同步 ...

  2. C语言动态内存管理

    1-概述 动态存储管理的基本问题是:系统如何按请求分配内存,如何回收内存再利用.提出请求的用户可能是系统的一个作业,也可能是程序中的一个变量. 空闲块 未曾分配的地址连续的内存区称为“空闲块”. 占用 ...

  3. 【HDOJ】4516 威威猫系列故事——因式分解

    可解的算法太多了,采用的算法是试x的值.注意题目的输入x^3-2x^2不会写成x^3+-2x^2.一直RE在这儿. /* 4516 */ #include <iostream> #incl ...

  4. C#的同步和异步调用方法

    同步和异步大家都明白什么意思,在这里不多介绍了. namespace ConsoleTest { class Program { static void Main(string[] args) { C ...

  5. An error occurred while filtering resources

    一个比较恶心的问题.在使用过程中项目中有个错误 ,找不到原因.. An error occurred while filtering resources     Maven -> Update ...

  6. Xcode7创建纯代码空白工程

    0: Create a new project  with  'single view controller' A: Xcode Settings 1: migrate launch image B: ...

  7. 【转】简单几步让App Store软件下载快如迅雷 -- 不错!!!

    原文网址:http://pad.zol.com.cn/237/2376160_all.html 下载速度慢的原因     1)国内用户从苹果软件商店下载软件速度很慢这是大家都知道的事实,究其原因就是苹 ...

  8. C#调用C++函数入口点的问题 z

    C++使用 void extern __declspec(dllexport) 函数名()定义的输出函数, 在C#中调用时, 如前文所述, 使用 [DllImport("D:\VS2005P ...

  9. Using the Task Parallel Library (TPL) for Events

    Using the Task Parallel Library (TPL) for Events The parallel tasks library was introduced with the ...

  10. HDU-1896 Stones

    http://acm.hdu.edu.cn/showproblem.php?pid=1896 题意:一个人从0开始走起,遇到偶数个石头就踢.要是同一位置有多个石头,则先扔最重的石头(也就是扔的最近的那 ...