Python扩展GDB自动continue致断点仅触发一次的问题求助
GDB Python脚本自动continue后断点不再触发的问题
我用Python扩展GDB功能时遇到一个异常情况:当断点被频繁触发时,GDB仅在第一次触发时暂停并执行脚本逻辑,后续断点触发时完全不暂停,脚本也不再响应。但如果不在脚本里用gdb.execute('continue', to_string=True)自动恢复执行,而是手动在GDB命令行输入continue,每次断点触发都会正常暂停,脚本也能正常运行。
我的Python脚本代码
def CmdCaptureBreaks(event): print("capture a event") if not isinstance(event, gdb.BreakpointEvent): return cur = event.breakpoints[0].location if cur is None: cur = event.breakpoints[0].expr o = gdb.execute('bt', to_string=True) print(o) BreakDispatch(cur) #time.sleep(3) gdb.execute('continue', to_string=True) gdb.events.stop.connect(CmdCaptureBreaks)
自动执行continue时的GDB运行日志
(gdb) b rte_flow_query Breakpoint 1 at 0x56190d3ee190 (gdb) c Continuing. [Switching to Thread 0x7fd59effd400 (LWP 30636)] Thread 17 "revalidator12" hit Breakpoint 1, 0x000056190d3ee190 in rte_flow_query () ##### first hit capture a event #0 0x000056190d3ee190 in rte_flow_query () #1 0x000056190d5ea00a in netdev_dpdk_rte_flow_query_count () #2 0x000056190d5ea56a in netdev_offload_dpdk_flow_get () #3 0x000056190d4b0e03 in dpif_netdev_get_flow_offload_status () #4 0x000056190d4b0f44 in get_dpif_flow_status () #5 0x000056190d4b1048 in dp_netdev_flow_to_dpif_flow () #6 0x000056190d4b2dd0 in dpif_netdev_flow_dump_next () #7 0x000056190d4c8301 in dpif_flow_dump_next () #8 0x000056190d46fcac in revalidate.isra () #9 0x000056190d471d30 in udpif_revalidator () #10 0x000056190d566fa0 in ovsthread_wrapper () #11 0x00007fd5d0dd9609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #12 0x00007fd5d0acb293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 17 "revalidator12" hit Breakpoint 1, 0x000056190d3ee190 in rte_flow_query () #####no stop Thread 17 "revalidator12" hit Breakpoint 1, 0x000056190d3ee190 in rte_flow_query () #####no stop Thread 17 "revalidator12" hit Breakpoint 1, 0x000056190d3ee190 in rte_flow_query () #####no stop Thread 17 "revalidator12" hit Breakpoint 1, 0x000056190d3ee190 in rte_flow_query () #####no stop Aborted (core dumped) When execute control+c may cause crash.
手动执行continue时的GDB运行日志
(gdb) b rte_flow_query Breakpoint 1 at 0x5617df277190 (gdb) c Continuing. [Switching to Thread 0x7f1627fff400 (LWP 53739)] Thread 17 "revalidator12" hit Breakpoint 1, 0x00005617df277190 in rte_flow_query () capture a event #0 0x00005617df277190 in rte_flow_query () #1 0x00005617df47300a in netdev_dpdk_rte_flow_query_count () #2 0x00005617df47356a in netdev_offload_dpdk_flow_get () #3 0x00005617df339e03 in dpif_netdev_get_flow_offload_status () #4 0x00005617df339f44 in get_dpif_flow_status () #5 0x00005617df33a048 in dp_netdev_flow_to_dpif_flow () #6 0x00005617df33bdd0 in dpif_netdev_flow_dump_next () #7 0x00005617df351301 in dpif_flow_dump_next () #8 0x00005617df2f8cac in revalidate.isra () #9 0x00005617df2fad30 in udpif_revalidator () #10 0x00005617df3effa0 in ovsthread_wrapper () #11 0x00007f1669996609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #12 0x00007f1669688293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 (gdb) continue ####### manually execute Thread 17 "revalidator12" hit Breakpoint 1, 0x00005617df277190 in rte_flow_query () capture a event #0 0x00005617df277190 in rte_flow_query () #1 0x00005617df47300a in netdev_dpdk_rte_flow_query_count () #2 0x00005617df47356a in netdev_offload_dpdk_flow_get () #3 0x00005617df339e03 in dpif_netdev_get_flow_offload_status () #4 0x00005617df339f44 in get_dpif_flow_status () #5 0x00005617df346770 in dpif_netdev_operate () #6 0x00005617df352e80 in dpif_operate () #7 0x00005617df2f46a1 in push_dp_ops () #8 0x00005617df2f967d in revalidate.isra () #9 0x00005617df2fad30 in udpif_revalidator () #10 0x00005617df3effa0 in ovsthread_wrapper () #11 0x00007f1669996609 in start_thread (arg=<optimized out>) at pthread_create.c:477 #12 0x00007f1669688293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
环境信息
- GDB版本:GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
恳请各位提供解决建议,提前感谢!
内容的提问来源于stack exchange,提问作者xiaoxi0329
相关产品推荐
相关产品推荐

