如何让VSCode的python调试器在调试时跳过某些模块 [英] How to make VSCode's python debugger skip stepping into some modules when debugging
问题描述
在 vscode 的 python (ms-python) 扩展中,有没有办法让调试器 (debugpy) 不进入特定模块中定义的函数.我找到了 justMyCode 但它只会跳过进入外部模块(如 stdlib 的成员),而有时我需要跳过我自己的模块.
In vscode's python (ms-python) extension, is there a way to make the debugger (debugpy) not to step-into functions defined in specific modules. I have found justMyCode but it will skip entering into external modules only (like members of stdlib) while I need to skip my own modules sometimes.
我看到一些其他语言的调试适配器实现了 skipFiles 属性.python有没有类似的东西?
I saw some debug adaptors for some other languages implement skipFiles property. Is there anything similar for python?
推荐答案
通过调试代码我发现这个未记录的功能就像一个魅力:在 launch.json 的调试配置中添加<代码>规则":[{模块":*xxx*",包含":假}].确保 xxx 是完整的模块名称,如 a.b.module
Going thru debugpy code I found this undocumented feature which works like a charm: in launch.json's debug configuration add
"rules" : [{"module":"*xxx*", "include":false}]
. Make sure the xxx is the full module name like a.b.module
There are more working options. They can be seen here
警告.这个功能没有记录(至少我没有在任何地方找到它)所以谨慎使用,因为它可能有一天会消失.另一方面,此功能作为代码统一测试的一部分进行了适当的测试(如您从链接中看到的)
A word of warning. This feature is undocumented (at least I did not find it anywhere) so use with caution as it might disappear one day. At the other hand, this feature is properly tested as part of the code uni-testing (as you can see from the link)
这篇关于如何让VSCode的python调试器在调试时跳过某些模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!