zoukankan      html  css  js  c++  java
  • Simple GDB case

    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 ";
    10        char b=foo(arr);
    (gdb) 
    11        printf("%c ",b);
    12        printf("%s ",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 ";
       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 " //find the "abc "
    (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
  • 相关阅读:
    大数据之路week07--day05 (一个基于Hadoop的数据仓库建模工具之一 HIve)
    大数据之路week07--day04 (Linux 中查看文件内容的关键字处)
    大数据之路week07--day04 (YARN,Hadoop的优化,combline,join思想,)
    hdu 1575 Tr A(矩阵快速幂,简单)
    hdu 1757 A Simple Math Problem (矩阵快速幂,简单)
    zoj 2974 Just Pour the Water (矩阵快速幂,简单)
    LightOj 1065
    LightOj 1096
    poj 1006 生理周期(中国剩余定理)
    POJ 2251 Dungeon Master(广搜,三维,简单)
  • 原文地址:https://www.cnblogs.com/eiguleo/p/3879120.html
Copyright © 2011-2022 走看看