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. WampServer 在 httpd.conf 中配置多站点 (IP 配置法:不用每次修改 hosts 文件 + 域名配置法 )

    因为要用 ThinkPHP 的当前最新版本 3.2.2,对应要求 PHP 的版本要高于 5.3.0,所以安装了 WampServer 2.2 ( Apache 2.2.21,PHP 5.3.10,My ...

  2. Windows下编译objective-C

    Windows下编译objective-C 2011-08-31 14:32 630人阅读 评论(0) 收藏 举报 windowscocoa工具objective clibraryxcode   目录 ...

  3. TCP/IP简介

    TCP/IP协议分层 提到协议分层,我们很容易联想到ISO-OSI的七层协议经典架构,但是TCP/IP协议族的结构则稍有不同.如图所示 TCP/IP协议族按照层次由上到下,层层包装.最上面的就是应用层 ...

  4. 连接别人创建的ORACLE数据库

    以oracle10g版本为例,本机必须安装oralce10g的客户端或oralce10g的服务器 方法一(从服务器配置): 第一步:打开配置和移植工具-->Net Manager 第二步:选中服 ...

  5. 【转载】MySQL性能优化的最佳20+条经验

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数据 ...

  6. P1970 花匠

    状态定义是dp中非常重要的,可以直接影响到效率,如此题,第一种思路是: #include <bits/stdc++.h> using namespace std; const int ma ...

  7. ajxa分页+多条件查询

    操作日志数据库表: 主页面: <script src="../fzl/jquery-1.11.2.min.js"></script> <script ...

  8. Python的安装

    篇幅主要是别人的分享,我这里主要是添加注意点.我当初就是按照下面的图片开始安装python,安装的是python3.5,pyDev也是使用的博主的(还花了1资源分下载).但是运行程序时,一直显示 Er ...

  9. useful tools, excel import mysql,swagger

    http://www.th7.cn/Program/java/201602/765943.shtml------swagger http://blog.csdn.net/csfreebird/arti ...

  10. SVN hooks强制提交时填写日志

    #!/bin/bash REPOS="$1" TXN="$2" #svnlook路径 SVNLOOK=/usr/bin/svnlook #通过svnlook获取 ...