如何使用vscode在macOS平台调试ffmpeg
使用vscode调试ffmpeg
准备知识:Debug C++ in Visual Studio Code
ffmpeg 源码 https://github.com/FFmpeg/FFmpeg.git
ffmpeg 配置, 使其支持调试
关于-g3
相关知识gcc-g-vs-g3-gdb-flag-what-is-the-difference
1 |
|
以_g
结尾的就是可以调试的程序ffmpeg_g, ffplay_g, ffprobe_g
vscode配置
如下命令:
1 |
|
launch.json 对应的配置
1 |
|
打上断点,点击运行,就可以愉快的调试了
附上链接:lldb 使用教程 Tutorial
调试ffmpeg/doc/example
1 |
|
在ffmpeg/doc/example目录下, 以_g
结尾的就是可以调试的
配置launch.json
开始调试吧
修改代码重新编译
例如你在调试的时候,修改了ffmpeg的源码,想调试一下更改后的代码,需要重新编译生成。
1 |
|
你想自动化这个过程,在调试之前自动编译,如何实现呢?
配置 prelaunchTask
在tasks.json中添加一个task
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "make -j 16; make examples",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"cwd": "${workspaceFolder}"
}
}
]
}在launch.json中配置prelaunchTask
然后修改代码,点击调试, vscode 自动执行make,编译修改后的文件,重新生成可执行程序。然后就可以愉快地修改代码,调试,修改也会即时生效。
备注:m1 芯片的mac 如果遇到调试问题
解决办法:
使用 CodeLLDB debugger
插件,而不是vc code 原生的调试插件
I would suggest you to use CodeLLDB debugger (vadimcn.vscode-lldb). It’s an extension in VSCode and works exactly like the native debugger in VSCode. For its setup, you just need to change the configuration of your launch.json file with the one provided by the extension. And that should do the trick.
Now if you would try to debug then, VSCode will make use of that extension and should be able to debug your programs as it was to be done by the native debugger.
I am personally using it on my M1 chip MacBook Air, and it works perfectly fine. According to me, It’s much easier to implement than other workarounds present at the moment.