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
  • 相关阅读:
    Android 添加cookie
    解决安卓TextView异常换行,参差不齐等问题
    Java遍历List的时候删除item
    android setCompoundDrawables 不显示问题
    Git 操作的一些场景
    C# 函数参数中的this
    Git 常用命令
    C# 判断程序是否执行 进行启动或前台显示
    在窗体中嵌入 应用程序
    byte[] 转 2进制字符串
  • 原文地址:https://www.cnblogs.com/eiguleo/p/3879120.html
Copyright © 2011-2022 走看看