gdb调试RTSPClient,分析流程之一
2015-04-29 15:29
316 查看
注意如果想让某程序可以被gdb调试,编译的时候就必须加上 gcc 或者g++ -g 命令
live555有专门配置为gdb的配置文件!只需配置即可
gdb binFile 调试某个可执行文件
liqinghan@ubuntu:~/work/live/testProgs$ gdb ./testRTSPClient
run/r argv参数 运行程序
(gdb) run rtsp://192.168.1.2:8554/11.mkv
break/b class::func(type,type,..) 设置某个类的函数断点
(gdb) break DummySink::afterGettingFrame(void*,unsigned , unsigned,struct timeval,unsigned)
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y <PENDING> DummySink::afterGettingFrame(void*,unsigned , unsigned,struct timeval,unsigned)
break func 设置函数断点
info break查看断点
watch expr当expr变化时,停止运行。
continue/c 继续执行
p 查看变量值
s 单步调试(进入函数)
n 单步调试(不进函数)
d 删除指定编号的某个断点(使用info列出的断点)
如下:
(gdb) info break
Num Type Disp Enb Address What
2 hw watchpoint keep y DummySink::afterGettingFrame(void*,unsigned,unsigned,struct timeval,unsigned)
3 breakpoint keep y <PENDING> DummySink::afterGettingFrame(void*,unsigned,unsigned,struct timeval,unsigned)
4 breakpoint keep y 0x0804954e in DummySink::continuePlaying()
at testRTSPClient.cpp:523
那么Num就是编号
break lineNum也可以,执行到当前文件的行号
break 491
9 breakpoint keep y 0x08049ff4 in DummySink::afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int) at testRTSPClient.cpp:491
break 500
10 breakpoint keep y 0x08049e3a in DummySink::afterGettingFrame(unsigned int, unsigned int, timeval, unsigned int) at testRTSPClient.cpp:500
bt 查看函数堆栈
finish 退出函数
typedef void (afterGettingFunc)(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
经过调试可以知道RTSPClinet的执行顺序:
1、DummySink::afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int)
2、DummySink::afterGettingFrame(unsigned int, unsigned int, timeval, unsigned int)
//已经得到下一帧数据,用户自己要做的事情,比如调用函数输出视频帧,以及帧信息。用户可以在启动RTSP Client的时候注册一个函数,然后在这个里面调用这个函数,输出这视频帧,即可!
3、DummySink::continuePlaying()
continuPlaying注册afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int)函数,
fSource->getNextFrame(fReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE,
afterGettingFrame, this,
onSourceClosure, this); //获取下一帧数据
void FramedSource::getNextFrame(unsigned char* to, unsigned maxSize,
afterGettingFunc* afterGettingFunc,
void* afterGettingClientData,
onCloseFunc* onCloseFunc,
void* onCloseClientData) {
doGetNextFrame();//MultiFramedRTPSource::doGetNextFrame
}
void MultiFramedRTPSource::doGetNextFrame() {
if (!fAreDoingNetworkReads) {
// Turn on background read handling of incoming packets:
fAreDoingNetworkReads = True;
TaskScheduler::BackgroundHandlerProc* handler
= (TaskScheduler::BackgroundHandlerProc*)&networkReadHandler;
fRTPInterface.startNetworkReading(handler);
}
fSavedTo = fTo;
fSavedMaxSize = fMaxSize;
fFrameSize = 0; // for now
fNeedDelivery = True;
doGetNextFrame1();
}
void MultiFramedRTPSource::doGetNextFrame1() {
...
nextPacket->use(fTo, fMaxSize, frameSize, fNumTruncatedBytes,
fCurPacketRTPSeqNum, fCurPacketRTPTimestamp,
fPresentationTime, fCurPacketHasBeenSynchronizedUsingRTCP,
fCurPacketMarkerBit);
...
}
类继承关系如下图所示
live555有专门配置为gdb的配置文件!只需配置即可
gdb binFile 调试某个可执行文件
liqinghan@ubuntu:~/work/live/testProgs$ gdb ./testRTSPClient
run/r argv参数 运行程序
(gdb) run rtsp://192.168.1.2:8554/11.mkv
break/b class::func(type,type,..) 设置某个类的函数断点
(gdb) break DummySink::afterGettingFrame(void*,unsigned , unsigned,struct timeval,unsigned)
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y <PENDING> DummySink::afterGettingFrame(void*,unsigned , unsigned,struct timeval,unsigned)
break func 设置函数断点
info break查看断点
watch expr当expr变化时,停止运行。
continue/c 继续执行
p 查看变量值
s 单步调试(进入函数)
n 单步调试(不进函数)
d 删除指定编号的某个断点(使用info列出的断点)
如下:
(gdb) info break
Num Type Disp Enb Address What
2 hw watchpoint keep y DummySink::afterGettingFrame(void*,unsigned,unsigned,struct timeval,unsigned)
3 breakpoint keep y <PENDING> DummySink::afterGettingFrame(void*,unsigned,unsigned,struct timeval,unsigned)
4 breakpoint keep y 0x0804954e in DummySink::continuePlaying()
at testRTSPClient.cpp:523
那么Num就是编号
break lineNum也可以,执行到当前文件的行号
break 491
9 breakpoint keep y 0x08049ff4 in DummySink::afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int) at testRTSPClient.cpp:491
break 500
10 breakpoint keep y 0x08049e3a in DummySink::afterGettingFrame(unsigned int, unsigned int, timeval, unsigned int) at testRTSPClient.cpp:500
bt 查看函数堆栈
finish 退出函数
typedef void (afterGettingFunc)(void* clientData, unsigned frameSize,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds);
经过调试可以知道RTSPClinet的执行顺序:
1、DummySink::afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int)
2、DummySink::afterGettingFrame(unsigned int, unsigned int, timeval, unsigned int)
//已经得到下一帧数据,用户自己要做的事情,比如调用函数输出视频帧,以及帧信息。用户可以在启动RTSP Client的时候注册一个函数,然后在这个里面调用这个函数,输出这视频帧,即可!
3、DummySink::continuePlaying()
continuPlaying注册afterGettingFrame(void*, unsigned int, unsigned int, timeval, unsigned int)函数,
fSource->getNextFrame(fReceiveBuffer, DUMMY_SINK_RECEIVE_BUFFER_SIZE,
afterGettingFrame, this,
onSourceClosure, this); //获取下一帧数据
void FramedSource::getNextFrame(unsigned char* to, unsigned maxSize,
afterGettingFunc* afterGettingFunc,
void* afterGettingClientData,
onCloseFunc* onCloseFunc,
void* onCloseClientData) {
doGetNextFrame();//MultiFramedRTPSource::doGetNextFrame
}
void MultiFramedRTPSource::doGetNextFrame() {
if (!fAreDoingNetworkReads) {
// Turn on background read handling of incoming packets:
fAreDoingNetworkReads = True;
TaskScheduler::BackgroundHandlerProc* handler
= (TaskScheduler::BackgroundHandlerProc*)&networkReadHandler;
fRTPInterface.startNetworkReading(handler);
}
fSavedTo = fTo;
fSavedMaxSize = fMaxSize;
fFrameSize = 0; // for now
fNeedDelivery = True;
doGetNextFrame1();
}
void MultiFramedRTPSource::doGetNextFrame1() {
...
nextPacket->use(fTo, fMaxSize, frameSize, fNumTruncatedBytes,
fCurPacketRTPSeqNum, fCurPacketRTPTimestamp,
fPresentationTime, fCurPacketHasBeenSynchronizedUsingRTCP,
fCurPacketMarkerBit);
...
}
类继承关系如下图所示
相关文章推荐
- GDB调试基本流程
- linux调试工具gdb的演示分析
- gdb调试分析多线程死锁
- memcached 1.4.21 源代码分析 (1)memcached 安装 、使用及gdb 调试
- [原理分析]Linux下的栈溢出案例分析-GDB调试操练[3]
- Linux内核分析,gdb调试linux内核--第三周
- 20145239 GDB调试汇编堆栈过程分析
- 20145212——GDB调试汇编堆栈过程分析
- 20145234黄斐《信息安全系统设计基础》GDB调试汇编堆栈过程分析
- Client提交作业与作业在JT中的初始化流程分析
- gdb调试core分析jvm(JNI)奔溃原因
- 网络摄像机IPCamera RTSP直播播放网络/权限/音视频数据/花屏问题检测与分析助手EasyRTSPClient
- MTK平台camera AF马达驱动调试流程分析
- 开源代码分析技巧之二——gdb单步调试
- 开源代码分析技巧之——gdb单步调试
- testProgs中的OpenRTSP是典型的RTSPClient示例分析
- GDB调试汇编堆栈过程分析
- live555库的rtsp服务器源码分析总结,流程详解RTSPServer
- Hadoop RPC通信Client客户端的流程分析
- Darwin RTSP点播流程代码分析2