Technology Sharing

[Linux] Using gdb to debug FFmpeg source code on Windows platform

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

FFmpeg is a cross-platform multimedia library. Sometimes it needs to be developed and debugged on other platforms. This article records the basic method of using gdb to debug FFmpeg source code in Linux environment.

1. Executable file

To debug FFmpeg source code in Linux environment on Windows platform, you need to compile and generate an exe file with suffix _g.ffmpeg compilationIf you want to use vs debugging on Windows, you need to add –toolchain=msvc when compiling FFmepg to generate a pdb file.
insert image description here

2. gdb debugging

Use msys2, a virtual Linux environment, for gdb debugging. The command line is

gdb ffmpeg_g.exe  // 开始启用gdb
set args -i output.h264 test.yuv // 设置参数,输入为output.h264,输出为test.yuv
start // 开始调试
  • 1
  • 2
  • 3

insert image description here
Common commands:

n // next, 逐过程
s // step, 逐语句
list // 显示代码
b n // 设置第n行一个断点
jump n // 跳转到第n行
  • 1
  • 2
  • 3
  • 4
  • 5

Using the list command
insert image description here
Here, the entry point of the function is located in the main function of fftoolffmpeg.c. After adding a breakpoint, you can debug it.