调试和分析
**********

这些库可以帮助你进行 Python 开发：调试器使你能够逐步执行代码，分析堆栈
帧并设置中断点等等，性能分析器可以运行代码并为你提供执行时间的详细数据
，使你能够找出你的程序中的瓶颈。 审计事件提供运行时行为的可见性，如果
没有此工具则需要进行侵入式调试或修补。

* 审计事件表

* "bdb" --- 调试器框架

  * "BdbQuit"

  * "Breakpoint"

    * "deleteMe()"

    * "enable()"

    * "disable()"

    * "bpformat()"

    * "bpprint()"

    * "file"

    * "line"

    * "temporary"

    * "cond"

    * "funcname"

    * "enabled"

    * "bpbynumber"

    * "bplist"

    * "ignore"

    * "hits"

  * "Bdb"

    * "canonic()"

    * "reset()"

    * "trace_dispatch()"

    * "dispatch_line()"

    * "dispatch_call()"

    * "dispatch_return()"

    * "dispatch_exception()"

    * "is_skipped_line()"

    * "stop_here()"

    * "break_here()"

    * "break_anywhere()"

    * "user_call()"

    * "user_line()"

    * "user_return()"

    * "user_exception()"

    * "do_clear()"

    * "set_step()"

    * "set_next()"

    * "set_return()"

    * "set_until()"

    * "set_trace()"

    * "set_continue()"

    * "set_quit()"

    * "set_break()"

    * "clear_break()"

    * "clear_bpbynumber()"

    * "clear_all_file_breaks()"

    * "clear_all_breaks()"

    * "get_bpbynumber()"

    * "get_break()"

    * "get_breaks()"

    * "get_file_breaks()"

    * "get_all_breaks()"

    * "get_stack()"

    * "format_stack_entry()"

    * "run()"

    * "runeval()"

    * "runctx()"

    * "runcall()"

  * "checkfuncname()"

  * "effective()"

  * "set_trace()"

* "faulthandler" --- 转储 Python 回溯信息

  * 转储跟踪信息

    * "dump_traceback()"

  * 故障处理程序的状态

    * "enable()"

    * "disable()"

    * "is_enabled()"

  * 一定时间后转储跟踪数据。

    * "dump_traceback_later()"

    * "cancel_dump_traceback_later()"

  * 转储用户信号的跟踪信息。

    * "register()"

    * "unregister()"

  * 文件描述符相关话题

  * 示例

* "pdb" --- Python 的调试器

  * "run()"

  * "runeval()"

  * "runcall()"

  * "set_trace()"

  * "post_mortem()"

  * "pm()"

  * "Pdb"

    * "run()"

    * "runeval()"

    * "runcall()"

    * "set_trace()"

  * 调试器命令

* Python 性能分析器

  * 性能分析器简介

  * 实时用户手册

  * "profile" 和 "cProfile" 模块参考

    * "run()"

    * "runctx()"

    * "Profile"

      * "enable()"

      * "disable()"

      * "create_stats()"

      * "print_stats()"

      * "dump_stats()"

      * "run()"

      * "runctx()"

      * "runcall()"

  * "Stats" 类

    * "Stats"

      * "strip_dirs()"

      * "add()"

      * "dump_stats()"

      * "sort_stats()"

      * "reverse_order()"

      * "print_stats()"

      * "print_callers()"

      * "print_callees()"

      * "get_stats_profile()"

  * 什么是确定性性能分析？

  * 局限性

  * 准确估量

  * 使用自定义计时器

* "timeit" --- 测量小代码片段的执行时间

  * 基本示例

  * Python 接口

    * "timeit()"

    * "repeat()"

    * "default_timer()"

    * "Timer"

      * "timeit()"

      * "autorange()"

      * "repeat()"

      * "print_exc()"

  * 命令行接口

  * 例子

* "trace" --- 跟踪或记录 Python 语句的执行

  * 命令行用法

    * 主要的可选参数

    * 修饰器

    * 过滤器

  * 编程接口

    * "Trace"

      * "run()"

      * "runctx()"

      * "runfunc()"

      * "results()"

    * "CoverageResults"

      * "update()"

      * "write_results()"

* "tracemalloc" --- 跟踪内存分配

  * 例子

    * 显示前10项

    * 计算差异

    * 获取一个内存块的溯源

    * 美化的 top

      * 记录所有被追踪内存块的当前和峰值大小

  * API

    * 函数

      * "clear_traces()"

      * "get_object_traceback()"

      * "get_traceback_limit()"

      * "get_traced_memory()"

      * "reset_peak()"

      * "get_tracemalloc_memory()"

      * "is_tracing()"

      * "start()"

      * "stop()"

      * "take_snapshot()"

    * 域过滤器

      * "DomainFilter"

        * "inclusive"

        * "domain"

    * 过滤器

      * "Filter"

        * "domain"

        * "inclusive"

        * "lineno"

        * "filename_pattern"

        * "all_frames"

    * 帧

      * "Frame"

        * "filename"

        * "lineno"

    * 快照

      * "Snapshot"

        * "compare_to()"

        * "dump()"

        * "filter_traces()"

        * "load()"

        * "statistics()"

        * "traceback_limit"

        * "traces"

    * 统计

      * "Statistic"

        * "count"

        * "size"

        * "traceback"

    * StatisticDiff

      * "StatisticDiff"

        * "count"

        * "count_diff"

        * "size"

        * "size_diff"

        * "traceback"

    * 跟踪

      * "Trace"

        * "domain"

        * "size"

        * "traceback"

    * 回溯

      * "Traceback"

        * "total_nframe"

        * "format()"
