vscode調(diào)試gstreamer源碼的詳細(xì)流程
1. 安裝vscode插件
- C/C++
- C/C++ Extension
2. 配置文件修改
vscode中每個項(xiàng)目都有一套配置文件集合,位于.vscode目錄下,其中有:
- tasks.json:編譯的相關(guān)配置
- launch.json:debug的相關(guān)配置
- c_cpp_properties.json:c/c++程序相關(guān)配置
2.1 自定義c_cpp_properties.json
{ "configurations": [ { "name": "Linux", # 配置標(biāo)識符 linux, mac, win32 "includePath": [ "${workspaceFolder}/**" #頭文件搜索路徑 # **:表示遞歸搜索 ], "defines": [], "compilerPath": "/usr/bin/gcc", # 編譯器路徑 "cStandard": "gnu11", # c語言的標(biāo)準(zhǔn)版本 "cppStandard": "gnu++14", # c++語言的標(biāo)準(zhǔn)版本 "intelliSenseMode": "linux-gcc-x64" } ], "version": 4 }
2.2 自定義tasks.json文件
{ "tasks": [ { "type": "shell", "label": "test", "command": "make", // "args": [ // "-fdiagnostics-color=always", // "-g", // "${file}", // "-o", // "${fileDirname}/${fileBasenameNoExtension}" // ], // "options": { // "cwd": "${fileDirname}" // }, // "problemMatcher": [ // "$gcc" // ], "group": { "kind": "build", "isDefault": true }, "detail": "調(diào)試器生成的任務(wù)。" } ], "version": "2.0.0" }
其他參數(shù)含義:
- workspaceFolder:打開的vscode目錄
- workspaceFolderBasename:workspaceFolder的根目錄
- fileDirname: 當(dāng)前VsCode打開文件的目錄
- fileBasenameNoExtension:file里每個文件不帶后綴
2.3 Debug
{ // 使用 IntelliSense 了解相關(guān)屬性。 // 懸停以查看現(xiàn)有屬性的描述。 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "test", "type": "cppdbg", // debug的模式,分為launch和attach兩種 "request": "launch", // 程序可執(zhí)行文件的完整路徑 "program": "${workspaceFolder}/deepstream-test-rt-src-add-del", // 傳遞給程序的命令行參數(shù) "args": ["file:///opt/nvidia/deepstream/deepstream-6.0/samples/streams/sample_720p.h264"], // 可選參數(shù)。如果為 true,則調(diào)試程序應(yīng)在目標(biāo)的入口點(diǎn)處停止 "stopAtEntry": false, // 目標(biāo)的工作目錄 "cwd": "${workspaceFolder}", // 要添加到程序環(huán)境的環(huán)境變量 "environment": [], "externalConsole": false, // 指示 MIDebugEngine 要連接到的控制臺調(diào)試程序。允許的值為 "gdb"、"lldb"。 "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], // 調(diào)試會話開始前要運(yùn)行的任務(wù) "preLaunchTask": "test", // MI 調(diào)試程序(如 gdb)的路徑。如果未指定,將首先在路徑中搜索調(diào)試程序 "miDebuggerPath": "/usr/bin/gdb" } ] }
3. Makefile環(huán)境下
使用 -g 來啟動調(diào)試環(huán)境
4. Python調(diào)試
{ // 使用 IntelliSense 了解相關(guān)屬性。 // 懸停以查看現(xiàn)有屬性的描述。 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "test", "type": "python", "request": "launch", "program": "${workspaceRoot}/tools/inference.py", "args": ["--config", "anomalib/models/padim/config.yaml", "--weight_path", "results/padim/mvtec/test7/weights/model.ckpt", "--image_path", "datasets/MVTec/test7/train/good/", "--save_path", "results/padim/mvtec/test7/train_data"], "console": "integratedTerminal", "cwd":"${workspaceRoot}", "justMyCode": true } ] }
5. 調(diào)試gstreamer源碼
GStreamer
是用來構(gòu)建流媒體應(yīng)用的開源多媒體框架(framework),其目標(biāo)是要簡化音/視頻應(yīng)用程序的開發(fā).
下載gstreamer源碼
使用gst-inspect1.0
工具可以獲取gstreamer
中element
的信息,以multifilesrc element
為例,輸入如下命令:
gst-inspect-1.0 multifilesrc
即可輸出下圖的信息,找到源碼下載地址。
選擇如下版本
下載源碼,解壓
編譯源碼
編譯源碼可以參考如下文章【編譯gstreamer插件-multifilesrc】
修改Makefile
搜索-g
選項(xiàng)信息
將-O2
選項(xiàng)修改未-O0
重新編譯得到動態(tài)庫
root@2a2466b40131:~/homework/gst_plugin_good/gst/multifile# make CC test_splitmux_part_reader-test-splitmuxpartreader.o CC test_splitmux_part_reader-gstsplitmuxpartreader.o CC test_splitmux_part_reader-gstsplitmuxsrc.o CC test_splitmux_part_reader-gstsplitutils.o CC test_splitmux_part_reader-patternspec.o CCLD test-splitmux-part-reader CC libgstmultifile_la-gstmultifilesink.lo CC libgstmultifile_la-gstmultifilesrc.lo CC libgstmultifile_la-gstmultifile.lo CC libgstmultifile_la-gstsplitfilesrc.lo CC libgstmultifile_la-gstsplitmuxsink.lo CC libgstmultifile_la-gstsplitmuxpartreader.lo CC libgstmultifile_la-gstsplitmuxsrc.lo CC libgstmultifile_la-gstsplitutils.lo CC libgstmultifile_la-patternspec.lo CCLD libgstmultifile.la
4.將動態(tài)庫拷貝到系統(tǒng)路徑下
make install cp /root/homework/gst_plugin_good/bin/lib/gstreamer-1.0/libgstmultifile.so /usr/lib/x86_64-linux-gnu/gstreamer-1.0/
修改launch.json
文件內(nèi)容
launch.json
文件內(nèi)容重點(diǎn)需要修改如下三個參數(shù):
整個launch.json
文件內(nèi)容如下,具體測試的pipeline
如下:
gst-launch-1.0 multifilesrc location=test%d.jpg ! jpegparse ! jpegdec ! videoconvert ! jpegenc ! multifilesink location=output%d.jpg
{ // 使用 IntelliSense 了解相關(guān)屬性。 // 懸停以查看現(xiàn)有屬性的描述。 // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "test", "type": "cppdbg", // debug的模式,分為launch和attach兩種 "request": "launch", // 程序可執(zhí)行文件的完整路徑 "program": "/usr/bin/gst-launch-1.0", // 傳遞給程序的命令行參數(shù) "args":["multifilesrc", "location=test%d.jpg", "!", "jpegparse", "!", "jpegdec", "!", "videoconvert", "!", "jpegenc", "!", "multifilesink", "location=output%d.jpg"], // 可選參數(shù)。如果為 true,則調(diào)試程序應(yīng)在目標(biāo)的入口點(diǎn)處停止 "stopAtEntry": false, // 目標(biāo)的工作目錄 "cwd": "${workspaceFolder}/data", // 要添加到程序環(huán)境的環(huán)境變量 "environment": [], "externalConsole": false, // 指示 MIDebugEngine 要連接到的控制臺調(diào)試程序。允許的值為 "gdb"、"lldb"。 "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], // 調(diào)試會話開始前要運(yùn)行的任務(wù) // "preLaunchTask": "test", // MI 調(diào)試程序(如 gdb)的路徑。如果未指定,將首先在路徑中搜索調(diào)試程序 "miDebuggerPath": "/usr/bin/gdb" } ] }
輸入斷點(diǎn)
在如下gst_multi_file_src_set_location
函數(shù)中打上斷點(diǎn),按F5啟動調(diào)試,即可進(jìn)行調(diào)試
總結(jié)
在本文中,主要介紹了如何使用vscode調(diào)試C++和python程序,并進(jìn)一步分析了如何調(diào)試gstreamer源碼,講述了如何調(diào)試gstreamer源碼的具體流程。
到此這篇關(guān)于vscode調(diào)試gstreamer源碼的文章就介紹到這了,更多相關(guān)vscode調(diào)試gstreamer內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C語言 詳細(xì)解析時間復(fù)雜度與空間復(fù)雜度
算法復(fù)雜度分為時間復(fù)雜度和空間復(fù)雜度。其作用: 時間復(fù)雜度是度量算法執(zhí)行的時間長短;而空間復(fù)雜度是度量算法所需存儲空間的大小2022-04-04C++詳細(xì)講解內(nèi)存管理工具primitives
文章向大家介紹C++內(nèi)存管理primitives,主要包括primitives使用實(shí)例、應(yīng)用技巧、基本知識點(diǎn)總結(jié)和需要注意事項(xiàng),具有一定的參考價值,需要的朋友可以參考一下2022-06-06C++實(shí)現(xiàn)LeetCode(93.復(fù)原IP地址)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(93.復(fù)原IP地址),本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07用C++實(shí)現(xiàn),將一句話里的單詞進(jìn)行倒置的方法詳解
本篇文章是對用C++實(shí)現(xiàn),將一句話里的單詞進(jìn)行倒置的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05C++ 中使用lambda代替 unique_ptr 的Deleter的方法
這篇文章主要介紹了C++ 中使用lambda代替 unique_ptr 的Deleter的方法,需要的朋友可以參考下2017-04-04