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

  • 相关阅读:
    ajax提交json数据到后端C#解析
    icheck判断是否选中
    sql多列值一行显示
    IDEA 2018 搭建 Spring MVC helloworld
    C# 注册DLL至GAC 并在添加引用中使用该DLL
    Java获取执行进程的dump文件及获取Java stack
    intellij idea搭建SpringBoot
    通过链接跳转登录到另外一个系统
    访问Hsql .data数据库文件
    基于weui的城市选择器(city-picker)
  • 原文地址:https://www.cnblogs.com/cutepig/p/2173208.html
Copyright © 2011-2022 走看看