在 VSCode 中,断点存储在哪里?
当我重新启动 VSCode 时,这些断点仍然存在,所以 VSCode 应该有一个地方来存储它们。但它既不存储在工作区中,也不存储在 .vscode
中。 .
我需要知道它们存储在哪里,以便我可以方便有效地备份/恢复/添加/修改/删除多个断点。
最佳答案
断点存储在哪里?
在 Windows 上,断点存储在:
%APPDATA%/Code/User/workspaceStorage/(long_hash)/state.vscdb
在 Linux 上,它们位于(根据 Matt 的评论):$HOME/.config/Code/User/workspaceStorage/(long_hash)/state.vscdb
定位(long_hash)
,我加了一个断点,找了个最近修改过的文件。如果您有 Cygwin bash,这样的命令可以在添加或删除断点后立即生效: $ cd $APPDATA/Code
$ find . -mmin -1
state.vscdb
文件是 SQLite数据库。我可以使用 strings
从中提取一些数据(另一个 Cygwin 命令): $ strings state.vscdb | grep 'debug.breakpoint'
debug.breakpoint
debug.breakpoint
debug.breakpoint[{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":12},{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":13}]g
debug.breakpoint[{"enabled":true,"uri":{"$mid":1,"fsPath":"d:\\wrk\\learn\\vscode\\cpphello\\helloworld.cpp","_sep":1,"external":"file:///d%3A/wrk/learn/vscode/cpphello/helloworld.cpp","path":"/D:/wrk/learn/vscode/cpphello/helloworld.cpp","scheme":"file"},"lineNumber":12}]
以上是在 helloworld.cpp
处的单个断点第 12 行。访问这个文件是个好主意吗?
可能不是!
如果您的目标是通过修改此文件自己查询或操作断点,我会警告说这可能会损坏 VSCode 的内部存储(即使使用适当的 SQLite 客户端)。
我建议改为使用 VSCode 扩展 API
debug.breakpoints
和 debug.addBreakpoints
从 VSCode 中查询和修改它们。
关于visual-studio-code - 断点存储在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57767800/