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

  • 相关阅读:
    P3241 [HNOI2015]开店 动态点分治
    P4199 万径人踪灭 FFT + manacher
    P4173 残缺的字符串
    P3338 [ZJOI2014]力
    CF1005F Berland and the Shortest Paths
    CF567E President and Roads
    P2446 [SDOI2010]大陆争霸
    CF1082G Petya and Graph
    CF1082E Increasing Frequency
    直接查数据导出xls
  • 原文地址:https://www.cnblogs.com/cutepig/p/2173208.html
Copyright © 2011-2022 走看看