zoukankan      html  css  js  c++  java
  • [转]使用gdb调试异常

    有时程序中有未捕获的异常会导致程序异常的行为甚至导致程序的直接退出。 这对服务器程序来说是不可接受的。

    可以使用gdb的catch命令来帮助我们调试异常。

    使用gdb捕获异常的扔出点(相当于在扔出异常的地方添加断点):

    catch throw
    使用gdb捕获线程退出(相当于在线程退出的时候添加断点):

    catch pthread_exit
    这样,如果相应的事件发生,gdb就会中断程序的执行, 就可以使用gdb的bt命令来检查出现错误的调用栈了。

    更多信息:

    (gdb) help catch
    Set catchpoints to catch events.
    Raised signals may be caught:
      catch signal              - all signals
      catch signal <signame>    - a particular signal
    Raised exceptions may be caught:
      catch throw               - all exceptions, when thrown
      catch throw <exceptname>  - a particular exception, when thrown
      catch catch               - all exceptions, when caught
      catch catch <exceptname>  - a particular exception, when caught
    Thread or process events may be caught:
      catch thread_start        - any threads, just after creation
      catch thread_exit         - any threads, just before expiration
      catch thread_join         - any threads, just after joins
    Process events may be caught:
      catch start               - any processes, just after creation
      catch exit                - any processes, just before expiration
      catch fork                - calls to fork()
      catch vfork               - calls to vfork()
      catch exec                - calls to exec()
    Dynamically-linked library events may be caught:
      catch load                - loads of any library
      catch load <libname>      - loads of a particular library
      catch unload              - unloads of any library
      catch unload <libname>    - unloads of a particular library
    The act of your program's execution stopping may also be caught:
      catch stop
    
    C++ exceptions may be caught:
      catch throw               - all exceptions, when thrown
      catch catch               - all exceptions, when caught
    
    Do "help set follow-fork-mode" for info on debugging your program
    after a fork or vfork is caught.
    
    Do "help breakpoints" for info on other commands dealing with breakpoints.
    

    转自http://blog.chenming.info/blog/2008/04/16/handle-exception-in-gdb/

  • 相关阅读:
    实验一 总结
    C#中将JObject类型数据转换成这样的货币数字-带千分符-四舍五入2位小数
    Git常用命令+报错solution
    Python Requests学习笔记
    Python requests 环境搭建
    关于Page Object个人结合测试框架的一些理解
    REST理解 + API测试学习笔记
    记录组内做API测试的流程
    理解c#的Get Set访问器及测试脚本中的应用
    tp3
  • 原文地址:https://www.cnblogs.com/catmelo/p/7207062.html
Copyright © 2011-2022 走看看