zoukankan      html  css  js  c++  java
  • gdb试用(1)

    gdb试用(1)
    cutepig@ubuntu:/mnt/hgfs/share/testValgrind$ gdb ./test
    GNU gdb (GDB) 7.0-ubuntu
    Copyright (C) 2009 Free Software Foundation, Inc.
    License GPLv3+: GNU GPL version 3 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 "i486-linux-gnu".
    For bug reporting instructions, please see:
    <http://www.gnu.org/software/gdb/bugs/>...
    Reading symbols from /mnt/hgfs/share/testValgrind/test...done.

    (gdb) list
    1    #include <string.h>
    2    #include <stdlib.h>
    3   
    4   
    5    int main(int argc, char *argv[])
    6    {
    7        char *ptr;
    8   
    9        ptr = (char*) malloc(10);
    10        strcpy(ptr, "01234567890");

    (gdb) b 9
    Breakpoint 1 at 0x804850d: file test.cpp, line 9.
    (gdb) r
    Starting program: /mnt/hgfs/share/testValgrind/test

    Breakpoint 1, main (argc=1, argv=0xbffff524) at test.cpp:9
    9        ptr = (char*) malloc(10);

    (gdb) info break
    Num     Type           Disp Enb Address    What
    1       breakpoint     keep y   0x0804850d in main at test.cpp:9
        breakpoint already hit 1 time
    当前帧能看到的变量   
    (gdb) info frame
    Stack level 0, frame at 0xbffff480:
     eip = 0x804850d in main (test.cpp:9); saved eip 0x3bdb56
     source language c++.
     Arglist at 0xbffff478, args: argc=1, argv=0xbffff524
     Locals at 0xbffff478, Previous frame's sp is 0xbffff480
     Saved registers:
      ebp at 0xbffff478, eip at 0xbffff47c
    查看某个变量
    (gdb) print argv
    $1 = (char **) 0xbffff524
    (gdb) whatis argv
    type = char **
    (gdb)

    参考
    http://www.study-area.org/cyril/opentools/opentools/x1253.html

  • 相关阅读:
    visio 2019 激活方法
    sftp 多用户安装与配置
    CentOS configuration uses the SFTP server
    esxi命令行强行关闭虚拟机
    esxi 版本升级命令
    存储分析 开源重复数据删除技术崭露头角
    最简单-转换MBR为GPT
    CentOS 7 搭建本地YUM仓库,并定期同步阿里云源
    uml建模工具介绍
    C/C++中extern关键字详解
  • 原文地址:https://www.cnblogs.com/cutepig/p/2173208.html
Copyright © 2011-2022 走看看