반응형

Gstreamer launcher valgrind debugging

Gstreamer Plugin을 개발하다보면 Gstreamer 내에서의 메모리 관리와 작성하고자 하는 코드의 메모리 관리가 일관되지 못해 의도치 않은 Memory leak을 유발하는 경우가 많다. 이럴 경우 어디에서 Memory의 관리를 놓쳤는지 찾아야 하는데 Gstreamer launcher로 테스트를 할 경우 valgrind를 물리는 순간 정상 동작이 안되는 경우가 많다.

Intall Debug Symbol

Gstreamer


sudo apt install gstreamer1.0-*dbg gstreamer1.0-tools

glib


sudo apt install libglib2.0-0-dbg

Symbol을 설치하기 어려울 경우 아래와 같이 실행


echo "deb [http://ddebs.ubuntu.com](http://ddebs.ubuntu.com/) $(lsb_release -cs) main restricted universe multiverse deb [http://ddebs.ubuntu.com](http://ddebs.ubuntu.com/) $(lsb_release -cs)-updates main restricted universe multiverse deb [http://ddebs.ubuntu.com](http://ddebs.ubuntu.com/) $(lsb_release -cs)-proposed main restricted universe multiverse" | \ sudo tee -a /etc/apt/sources.list.d/ddebs.list

sudo apt install ubuntu-dbgsym-keyring

sudo apt update

sudo apt install libglib2.0-bin-dbgsym libglib2.0-0-dbgsym libglib2.0-dev-bin-dbgsym

Code를 Debugging 옵션으로 빌드


# In the following line:# --prefix /usr --libdir /usr/lib/aarch64-linux-gnu#     This is required when building GStreamer plug-ins. Other applications may ignore this#     Note that aarch64-linux-gnu is for AARCH64, change accordingly# CFLAGS#     If using C# CXXFLAGS#     If using C++

./configure --prefix /usr --libdir /usr/lib/aarch64-linux-gnu CFLAGS="-g -O0" CXXFLAGS="-g -O0"
make
sudo make install

Suppressions 파일 준비

Suppression은 Valgrind에서 특정 Leak에 대해서 제외하기 위해 사용되는 파일.

gst suppressions 파일

https://gitlab.freedesktop.org/gstreamer/common/-/blob/master/gst.supp

glib suppressions 파일

https://github.com/GNOME/glib/blob/main/tools/glib.supp

Valgrind 실행


G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind \
--leak-check=full --leak-resolution=high --num-callers=20 --trace-children=yes \
--suppressions=path/to/gst.supp \
--suppressions=path/to/glib.supp \
gst-launch-1.0 videotestsrc num-buffers=10 ! fakesinkz

출처

https://developer.ridgerun.com/wiki/index.php/How_to_Analyze_GStreamer_with_Valgrind

반응형

+ Recent posts