zoukankan      html  css  js  c++  java
  • gdb exe control

    Finish And Until
        'finish' lets the current function execute until it finishes.
        'until <source line> makes gdb continue program execution until the given line is reached.
        Note: 'until' can only be executed if the program already

    return
        Sometimes we want a function to terminate prematurely during a debugging session.
        For example:
                A function computes a variable's value wrongly.
                We found this, but still want to debug the rest of the program.
                we can force the function to return immediately with the correct value:
        return 59

    Conditional Break-Points

        Let us suppose we have a long loop, and we want to start debugging only at the 503rd iteration.
        We do this using conditional break-points:

        Breakpoint 1, func_long_calc (i=5000) at c1.c:5
        5        int j = 5;
        (gdb) list 8,10
        8        for (plastic = 0; plastic < i; ++plastic) {
        9            j += plastic;
        10        }
        (gdb) break 9 if plastic == 503
        Breakpoint 4 at 0x804835a: file c1.c, line 9.
        (gdb) cont
        Continuing.

        Breakpoint 4, func_long_calc (i=5000) at c1.c:9
        9            j += plastic;
        (gdb) print plastic
        $1 = 503

    Other Break-Point Commands

      表达式匹配断点
        'rbreak <regular expression>' sets break-points for all functions whose name matches the regular expression.
        'disable <number>' disables (but does not delete) the given break-point.
        'enable <number>' re-enables the given (previously disabled) break-point.

      临时断点
        'tbreak' sets a temporary break-point - once it is hit, it is deleted.

    监测点
    Watch-Points
        定义
        A watch-point makes the program stop when an expression is true, regardless of the function in which it happens.
            例1
        A basic example: 'watch a == 1' makes the program stop when variable 'a' has the value... '1'.
            例2
        Checking when my memory gets over-written with a zero byte:
        watch *(char*)0x65476 == 0
        查看
        Watch-points and other break-points are all seen using 'info break' or 'info watch'.
            删除
        use 'delete <watch-point number>' to delete a watch-point, just like with a break-point.

    Hardware Vs. Software Watch-Points
        By default, gdb attempts to use hardware-assisted break-points.
        These get processed using the hardware, and have a lesser impact on program speed...
        ...relative to software watch-points.
        There are a few other caveats to watch-points regarding multi-threaded programs - we'll see them later.

    I Want To Do This - Again!
        You can ask gdb to save a "checkpoint": (恢复点)
        checkpoint

    reference: http://www.haifux.org/lectures/210/index.html

    more time!



        After stepping forward and finding you've gone further then you wanted, switch back to the checkpoint:
        restart <checkpoint id>    (返回恢复点)

        To see the list of active check-points:
        info checkpoints (查看恢复点)

        What a checkpoint does: forks off a copy of the program, so gdb will be able to switch back to it later on.
        To delete checkpoints:
        delete checkpoint <checkpoint id> (删除恢复点)

  • 相关阅读:
    ASP.NET MVC案例——————拦截器
    Windows Azure Virtual Network (10) 使用Azure Access Control List(ACL)设置客户端访问权限
    Windows Azure Storage (20) 使用Azure File实现共享文件夹
    Windows Azure HandBook (5) Azure混合云解决方案
    Windows Azure Service Bus (6) 中继(Relay On) 使用VS2013开发Service Bus Relay On
    Azure PowerShell (9) 使用PowerShell导出订阅下所有的Azure VM的Public IP和Private IP
    Windows Azure Service Bus (5) 主题(Topic) 使用VS2013开发Service Bus Topic
    Azure China (9) 在Azure China配置CDN服务
    Windows Azure Storage (19) 再谈Azure Block Blob和Page Blob
    Windows Azure HandBook (4) 分析Windows Azure如何处理Session
  • 原文地址:https://www.cnblogs.com/kwingmei/p/3224530.html
Copyright © 2011-2022 走看看