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. ThinkPHP 学习笔记 ( 五 ) 数据验证

    根据官网的教程 ( http://www.thinkphp.cn/info/171.html ),数据验证的使用静态定义方式 ( 以 regex 为例 ) 无法验证数据: 而采用动态验证则正常: 控制 ...

  2. md5只是用来签名,签名的作用是保证数据完整不会被破坏而已。签名和加密是两回事

    md5只是用来签名,签名的作用是保证数据完整不会被破坏而已,多一个sign标签,sign的值就是md5生成的字符串.签名和加密是两回事

  3. svn local obstruction, incoming add upon merge

    http://little418.com/2009/05/svn-local-obstruction-incoming-add-upon-merge.html If you've found this ...

  4. word 使用宏批量设置表格

    Sub ChangeTable() Application.Browser.Target = wdBrowseTable To ActiveDocument.Tables.Count ActiveDo ...

  5. heapsort

    Introduction to Algorithms Third Edition The (binary) heap data structure is an array object that we ...

  6. 关于Hive的调优(本身,sql,mapreduce)

    1.关于hive的优化 ->大表拆分小表 ->过滤字段 ->按字段分类存放 ->外部表与分区表 ->外部表:删除时只删除元数据信息,不删除数据文件 多人使用多个外部表操作 ...

  7. ThreadLocal知识总结

    以前学习<Thinking in Java>时,了解过ThreadLocal,但没做笔记.现在又忘记了.嗯,要勤动笔.API中ThreadLocal的方法: public T get() ...

  8. 自己写的一个DirectUI库,基础控件基本都已实现

    http://download.csdn.net/detail/pcradio/9254881 http://blog.csdn.net/pcradio

  9. Wordpress更换编辑器

    这里我更换为KindEditor 1.下载插件 https://wordpress.org/plugins/kindeditor-for-wordpress/ 2.启动插件 3.在 设置 – Kind ...

  10. LightOj1285 - Drawing Simple Polygon(连接多边形各点)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1285 题意:给你一些点,然后把它们用一条线把它们连起来,构成一个多边形,不能有相交,必 ...