to be added...
 
gdb a.out
 
[Inferior 1 (process 9718) exited with code 05]
(gdb) list
Line number 15 out of range; t.c has 14 lines.
(gdb) list 1
1       #include
2       char foo(char *s)
3       {
4         char *c=s;
5         return *(c+2);
6       }
7       int main()
8       {
9         char arr[5]="abc\n";
10        char b=foo(arr);
(gdb) 
11        printf("%c\n",b);
12        printf("%s\n",arr);
13
14      }
(gdb) disass /m
Dump of assembler code for function main:
8       {
   0x08048449 <+0>:     push   �p
   0x0804844a <+1>:     mov    %esp,�p
   0x0804844c <+3>:     and    $0xfffffff0,%esp
   0x0804844f <+6>:     sub    $0x20,%esp
 
9         char arr[5]="abc\n";
   0x08048452 <+9>:     movl   $0xa636261,0x1a(%esp)
   0x0804845a <+17>:    movb   $0x0,0x1e(%esp)
 
10        char b=foo(arr);
=> 0x0804845f <+22>:    lea    0x1a(%esp),�x //eip 
   0x08048463 <+26>:    mov    �x,(%esp)
   0x08048466 <+29>:    call   0x8048434
   0x0804846b <+34>:    mov    %al,0x1f(%esp)
(gdb) info registers esp
esp            0xbfffefb0       0xbfffefb0
#another shell
johv@linux-8f1f:~> echo $((0xbfffefb0+0x1a))
3221221322
 
johv@linux-8f1f:~> echo 'obase=16;base=10;3221221322' | bc
BFFFEFCA
(gdb) x /s 0xbfffefca
0xbfffefca:      "abc\n" //find the "abc\n"
(gdb) 
 
gdb) help catch
Set catchpoints to catch events.
 
List of catch subcommands:
 
catch assert -- Catch failed Ada assertions
catch catch -- Catch an exception
catch exception -- Catch Ada exceptions
catch exec -- Catch calls to exec
catch fork -- Catch calls to fork
catch syscall -- Catch system calls by their names and/or numbers
catch throw -- Catch an exception
catch vfork -- Catch calls to vfork
 
Type "help catch" followed by catch subcommand name for 
full documentation.
Type "apropos word" to search for commands related to "word".
Command name abbreviations are allowed if unambiguous.
(gdb) 
(gdb) info breakpoints 
Num     Type           Disp Enb Address    What
7       breakpoint     keep y   0x08048440 in foo 
                                           at t.c:5
        breakpoint already hit 1 time
8       catchpoint     keep y              syscall "" 
9       breakpoint     keep y    exception catch
10      catchpoint     keep y              fork
(gdb) disable breakpoints 7
(gdb) 
condition

Simple GDB case的更多相关文章

  1. A simple json-rpc case for bitcoin blockchains

    #!/usr/bin/env python import json import jsonrpc import requests #url = "http://user:password@i ...

  2. 锁大全与 GDB调试

    1.innodb_lock_monitor:打开锁信息的方式 mysql> create table innodb_lock_monitor(id int) engine=InnoDB; Que ...

  3. 使用linux的GDB打印STL(vector,map,set..................)

    在linux用gdb或者cgdb计较不爽的地方是无法打印STL的东西,所有啊去网上找了找解决方案https://www.douban.com/note/182826844/?qq-pf-to=pcqq ...

  4. Linux开发工具之gdb(上)

    三.gdb调试(上) 01.gdb:gdb是GNU debugger的缩写,是编程调试工作. 功能:   启动程序,可以按照用户自定义的要求随心所欲的运行程序:   可让被调试的程序在用户所指定的调试 ...

  5. 让gdb能打印C++中的容器类型

    由于原生的gdb对vector,map等容器的支持不太好,所以找到了一个工具,将这个工具集成到gdb中,就可以实现map,vector等容器的内容的打印操作. 1.用vim将下方的代码拷贝到一个新的文 ...

  6. 使用GDB调试STL容器

    GDB中print方法并不能直接打印STL容器中保存的变量,想知道STL容器保存的变量,使用如下办法: 1. 创建文件~/.gdbinit: # # STL GDB evaluators/views/ ...

  7. gdb打印C++容器

    将以下内容保存成 .gdbinit 文件放到你的根目录,或者在gdb中source这个文件可以加载. 直接print容器即可. # # STL GDB evaluators/views/utiliti ...

  8. SQL使用CASE 语句

    CASE 语句可以在SELECT 子句和ORDER BY 子句中使用 CASE语句分为两种Case Simple Expression and Case Search Expression Case ...

  9. GDB —— 优化STL容器变量的显示

    步骤 wget http://www.yolinux.com/TUTORIALS/src/dbinit_stl_views-1.03.txt cp dbinit_stl_views-1.03.txt ...

随机推荐

  1. directX学习系列8 颜色融合(转)

    1, Multipass(多通道)    将一个任务划分成几个阶段,由多个pass处理不同阶段,后续pass总是处理前一个pass的结果.例如复杂的光照方程可以分成几个pass来计算.    用不同的 ...

  2. 20145235 《Java程序设计》第8周学习总结

    教材学习内容总结 15.1.1日志API简介 使用日志的起点是logger类,logger实例的创建有许多要处理的要素,必须使用logger的静态方法getLogger(). 通常在哪个类上取得的lo ...

  3. Arrays类的十大用法

    还有很多地方需要细细斟酌 0. 声明数组 String[] aArray = new String[5]; String[] bArray = {"a","b" ...

  4. ubuntu下各个软件完全卸载

    1.卸载mysql sudo rm /var/lib/mysql/ -R删除mysql的数据文件2sudo rm /etc/mysql/ -R删除mqsql的配置文件3sudo apt-get aut ...

  5. 在Vista或更高版本Windows系统中, 获取超大图标的办法

    这几天写个小东西, 需要获取系统正在运行的程序图标, 一般来说32*32就足够了, 不过既然Win7能够支持超大图标(256*256), 咱们也需要与时俱进, 说不定什么时候遇到个变态客户就有这要求了 ...

  6. C# DateTime类型和时间戳 互相转换

    /// <summary> /// 时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></para ...

  7. jquerymobile动态添加元素之后不能正确渲染解决方法

    jquerymobile动态添加元素之后有些不能被正确渲染的解决方法: listview:               添加 jq(".detail").listview(&quo ...

  8. 答CsdnBlogger问-关于定时和后台服务问题

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 前段时间写了不少博客,在问答页面也陆续回答几十个问题,之后Csdn乙同学找到我,说要推荐我参加问答类 ...

  9. httpclient提交json参数

    private void httpReqUrl(List<HongGuTan> list, String url) throws ClientProtocolException, IOEx ...

  10. 如何使用批处理解决批量telnet命令的输入

    用telnet命令做不了自动,因为如果成功telnet了,telnet就控制输入了.其实,不用那么麻烦,您下载一个微软官方的扫描器叫portqry,用一句for读取您文件里的ip和port,执行就行了 ...