• qtcreator调试webkit


    qtreator是在ubuntu上支持gdb比较好的IDE,可以方便的单步调试,快速熟悉代码。

    ubuntu上通过qtcreator调试wpewebkit,因为是通过cog启动,wpewebkit进程和cog不是同一个进程,需要通过attach的方式才能断点到Mediaplayer的代码。


    配置qtcreator


    先从命令行启动cog


    cog --platform=x11 https://www.w3.org/2010/05/video/mediaevents.html
    
    • 1

    找到webkit进程


    $ ps -ax | grep webkit
    15983 pts/18   SLl+   0:00 /home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPENetworkProcess 3 10
    15994 pts/18   tLl+   2:37 /home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPEWebProcess 8 19
    
    • 1
    • 2
    • 3

    增加qtcreator环境变量


    LD_LIBRARY_PATH
    
    $LD_LIBRARY_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib:/home/hui/disk4t/codes/wpe/source/inst/lib/x86_64-linux-gnu
    
    
    • 1
    • 2
    • 3
    • 4

    ubuntu上通过qtcreator调试webkit,因为是通过cog启动,wpewebkit进程和cog不是同一个进程,需要通过attach的方式才能断点到Mediaplayer的代码。


    attach到WPEWebProcess进程


    attach从qtcreator菜单进入:

    Select Debug > Start Debugging > Attach to Running Application
    
    • 1

    选择15994进程,如果出现ptrace的error,需要做如下配置:

    ptrace: Operation not permitted.
    
    Could not attach to the process. Make sure no other debugger traces this process.
    If your uid matches the uid
    of the target process, check the settings of
    /proc/sys/kernel/yama/ptrace_scope
    For more details, see /etc/sysctl.d/10-ptrace.conf
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    将/proc/sys/kernel/yama/ptrace_scope虚拟文件的内容设为0:

    echo 0 > /proc/sys/kernel/yama/ptrace_scope
    
    • 1

    这个是临时方法,重启之后失效。


    设置好断点后,运行效果如下:

    在这里插入图片描述

    通过cog启动,然后attach到WPEWebProcess后,发现https://www.w3.org/2010/05/video/mediaevents.html这个测试页面在cog启动后,video标签已经完全加载,没法断点到player创建的地方。

    所以又找了一个测试页面https://easyhtml5video.com/help/html-5-video-test-7.html,通过log发现,这个页面启动cog后video标签没有加载,满足条件,设置断点后成功中断。


    cog启动:


    cog --platform=x11 https://easyhtml5video.com/help/html-5-video-test-7.html
    
    • 1

    attach进程后的中断:


    在这里插入图片描述

    MediaPlayerPrivateGStreamer::load的调用栈:

    在这里插入图片描述


    输出log


    journalctl

    # 这样过滤的log不全:
    
    journalctl -f WEBKIT_SUBSYSTEM=WPEWebKit WEBKIT_CHANNEL=Media
    
    -- Logs begin at Mon 2021-12-27 19:51:37 CST. --
    211 09:54:05 hui WPEWebProcess[32009]: HTMLMediaElement::mediaPlayerPlaybackStateChanged(FE25312987F69B65) false
    211 09:54:05 hui WPEWebProcess[32009]: HTMLMediaElement::playInternal(FE25312987F69B65)
    211 09:54:05 hui WPEWebProcess[32009]: MediaElementSession::clientWillBeginPlayback(FE25312987F69B65) state = Playing
    211 09:54:05 hui WPEWebProcess[32009]: PlatformMediaSessionManager::setCurrentSession(0) (FE25312987F69B65)
    211 09:54:05 hui WPEWebProcess[32009]: PlatformMediaSessionManager::sessionWillBeginPlayback(0) (FE25312987F69B65) returning true
    211 09:54:05 hui WPEWebProcess[32009]: HTMLMediaElement::setAutoplayEventPlaybackState(FE25312987F69B65) StartedWithoutUserGesture
    211 09:54:05 hui WPEWebProcess[32009]: HTMLMediaElement::updatePlayState(FE25312987F69B65) shouldBePlaying = true, playerPaused = false
    211 09:54:05 hui WPEWebProcess[32009]: HTMLMediaElement::mediaPlayerVolumeChanged(FE25312987F69B65)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
     # webkit
     export WEBKIT_DEBUG="Network=debug,Media=debug"
     export WEBKIT_DEBUG="all"
     
     # gstreamer
     export GST_DEBUG="3,webkit*:6"
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    查看journalctl日志


    journalctl -ef | grep -E "WPEWebProcess|WPENetworkProcess"
    
    • 1

    MediaSource的log输出:

    WPEWebProcess[2883]: MediaSource::detachFromElement(0)
    WPEWebProcess[2883]: MediaSource::onReadyStateChange(0) old state = open, new state = closed
    WPEWebProcess[2883]: MediaSourcePrivateGStreamer::~MediaSourcePrivateGStreamer(20E2EA6F)
    WPEWebProcess[2883]: MediaSource::onReadyStateChange(0) old state = closed, new state = open
    WPEWebProcess[2883]: MediaSource::setDuration(0) 8656.959
    WPEWebProcess[2883]: MediaSource::setDurationInternal(0) {"value":8656.959}
    WPEWebProcess[2883]: MediaSource::seekToTime(0) {"value":130}
    WPEWebProcess[2883]: MediaSource::completeSeek(0) {"value":130}
    WPEWebProcess[2883]: MediaSource::seekToTime(0) {"value":130}
    WPEWebProcess[2883]: MediaSource::completeSeek(0) {"value":130}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    SourceBuffer的log输出:

    WPEWebProcess[2883]: SourceBuffer::SourceBuffer(62DF0001)
    WPEWebProcess[2883]: SourceBuffer::SourceBuffer(62DF0002)
    WPEWebProcess[2883]: SourceBuffer::~SourceBuffer(20E20002)
    WPEWebProcess[2883]: SourceBuffer::~SourceBuffer(20E20001)
    WPEWebProcess[2883]: SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(62DF0001)
    WPEWebProcess[2883]: SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(62DF0002)
    WPEWebProcess[2883]: SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment(62DF0002)
    WPEWebProcess[2883]: SourceBuffer::seekToTime(62DF0001) {"value":130}
    WPEWebProcess[2883]: SourceBuffer::seekToTime(62DF0002) {"value":130}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9


    参考

    Launching the Debugger

  • 相关阅读:
    如何用优盘加密自己的电脑:人离后自动锁定
    [附源码]Python计算机毕业设计Django的云网盘设计
    VMware _ Ubuntu _ root 密码是什么,怎么进入 root 账户
    new Vue的时候到底做了什么
    无限边界:现代整合安全如何保护云
    [JS真好玩] 掘金创作者必备: 监控每天是谁取关了你?
    Rancher 2.x集群销毁及卸载清理
    Python 实现自动化测试 dubbo 协议接口
    ElasticSearch之健康状态
    Android进阶之路 - 存、取、读 本地 Json 文件
  • 原文地址:https://blog.csdn.net/hongszh/article/details/126252417