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. pycharm 皮肤主题及个性化设置

    1.设置IDE皮肤主题 File -> Settings -> IDE Settings -> Appearance -> Theme -> 选择“Alloy.IDEA ...

  2. Linux Nginx 安装配置

    安装前准备工作 GCC编译器-程序代码编译工具! 首先检验你的服务器环境是否安装gcc,方法如下: #gcc 如果出现:gcc: no input files 证明已经安装过gcc编译工具! 如果出现 ...

  3. Windows 下使用 GNUstep 编译并运行 Objective-C 程序

    今晚上开始看<Objective-C 程序设计(第4版)>这本书(OSChina 正在做此书的书评活动,详情请看这里),到现在为止看到第 7 章,于是想动手试试写两简单的程序编译跑跑看. ...

  4. Apache Kafka源码分析 - autoLeaderRebalanceEnable

    在broker的配置中,auto.leader.rebalance.enable (false) 那么这个leader是如何进行rebalance的? 首先在controller启动的时候会打开一个s ...

  5. Delphi出现“borland license information was found,but it is not valid for delphi”的错误,无法运行的解决方法

    1) 删除文件: C:\documents and settings\<username>\.borland\registry.slm,如果在win8或在win7下,即C:\Users\H ...

  6. 【php学习】图片操作

    前两天要对一张图片进行处理,其实很简单,就是在图片上加上字符串,一个图片而已,但是自己如同得了短暂性失忆似的,图片操作的函数一个都想不起来.所以就抽空整理了一下图片操作函数. 图片处理三步走: 创建画 ...

  7. ubuntu12.04 安装 php5.4/php5.5

    1:修改源(我使用163的源)直接修改/etc/apt/sources.list deb http://mirrors.163.com/ubuntu/ precise main universe re ...

  8. NHibernate学习笔记

    原文详见http://www.cnblogs.com/GoodHelper/archive/2011/02/16/nhibernate_03.html   NHibernate_Demo程序框架: D ...

  9. Delphi 缩放图像代码 - 支持PNG透明通道

    要求Delphi2007或者更高版本, 系统要求至少XP-SP2以上 实际上是利用了Windows的windowscodecs.dll这个文件的功能 在VCL里已经封装为TWICImage类 proc ...

  10. eclipse Maven -->web project

    http://blog.chinaunix.net/uid-26959955-id-3248053.html http://blog.csdn.net/wilsonke/article/details ...