实验室环境gdb调试

  • 打印单个线程的调用栈
    gdb attach tid handle SIGUSR2 nostop noprint set height 0 bt detach quit

  • 对程序中对任意点加打印
    gdb attch pid handle SIGUSR2 nostop noprint set height 0 break filename:linenum commands 1 print varname continue end continue detach quit
    如1:
    gdb attch 21890 handle SIGUSR2 nostop noprint set height 0 break isup.c : 4002 if pos == 2572 commands 1 print pos continue end continue detach quit
    如2:
    gdb attch 18849 handle SIGUSR2 nostop noprint set height 0 break diameter.c:557 commands 1 print g_pstDiamTdrCb[ulTdrCbIdx].stDiamInfo.stDiamTDR.ulHopId call sanex_printf( "diameter.c", 557, "DiamDmtMsgProc", 4, 467, "Receive request message, the HopID is %x.", g_pstDiamTdrCb[ulTdrCbIdx].stDiamInfo.stDiamTDR.ulHopId) continue end break diameter.c:447 commands 2 print g_pstDiamTdrCb[ulTdrCbIdx].stDiamInfo.stDiamTDR.ulHopId call sanex_printf( "diameter.c", 557, "DiamDmtMsgProc", 4, 467, "Time out, the HopID is %x.", g_pstDiamTdrCb[ulTdrCbIdx].stDiamInfo.stDiamTDR.ulHopId) continue end continue detach quit

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 概述 GDB是一个由GNU开源组织发布的、UNIX/Linux操作系统下的、基于命令行的、功能强大的程序调试工具。...
    咕咕鷄阅读 20,980评论 0 8
  • 最近迷上了看《余罪》,不过都是自从看完了电视剧才看的小说,虽然现在还没有看完,大概才看了16%,小说挺长的,不过感...
    LOYD阅读 216评论 0 0
  • 我近来一直在内思“做真实自我”这件事,至近两三日渐有所得,当然我所行思的内容未必是正确或具备普世意义的,ta们不过...
    山贼爷阅读 359评论 1 0
  • 昨天刚吵了嘴。嫌他不懂得取悦人。一个不懂得取悦的人那他对这个人是多不用心啊?嫌他情商低。低到负。 就是很生气啊。活...
    啊哈王大可儿阅读 212评论 2 1