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
  • 相关阅读:
    angular 中如何使用自定义组件
    angular组件数据和事件
    angular组件数据
    angular绑定数据
    angular自定义组件
    angular项目目录结构分析
    Angular 开发工具介绍
    从Microsoft.AspNet.Identity看微软推荐的一种MVC的分层架构
    EF How to use context.Set and context.Entry, which ships with EF4.1 ?
    C# 向IQueryable添加一个Include扩展方法
  • 原文地址:https://www.cnblogs.com/eiguleo/p/3879120.html
Copyright © 2011-2022 走看看