zoukankan      html  css  js  c++  java
  • [Debug_Windows]Windbg 环境搭建

     [应用场景]:Win 系统crash,BSOD 或者需要分析程序异常的时候,Windows 需要kernel debug 查看root cause.

    1. 名词

      • 目标机(target):被调试机器
      • 主机(host):运行调试工具(windbg)的机器

    2. Requirements:

    • A USB 3.0 debug cable.This is an A-A crossover cable that has only the USB 3.0 lines and no Vbus. 特殊定制的USB 3.0 AM-AM线缆,淘宝可以买到,链接: https://shop129099241.taobao.com

    • Disable Secure Boot on the target PC in BIOS

    • 操作系统
      Windows 8 或 Windows Server 2012以上版本(主机,目标机)

    3.1 设置目标机

    1> 在目标机上运行UsbView
    2> 找出所有的xHCI Controller
    3> 查找xHCI Controller下的Port,找到支持调试的端口

    [Port10] 
    Is Port User Connectable:         yes
    Is Port Debug Capable:            yes
    Companion Port Number:            1
    Companion Hub Symbolic Link Name: ...
    Protocols Supported:
     USB 1.1:                         no
     USB 2.0:                         no
     USB 3.0:                         yes
    ConnectionStatus:      NoDeviceConnected

    需满足

    UserConnectable == yes And DebugCapable == yes

    4> [可跳过] 记录下此节点对应的xHCI Controller的BDF值(十进制)

    Bus.Device.Function (in decimal): 0.20.0

    5> 找出电脑上对应这个xHCI Controller的插口。用一个usb 3.0的u盘去试你电脑上的usb口,如果在usbview里显示插到了支持调试的口上,就可以了。
    6> 管理员权限打开cmd,运行

    • bcdedit /debug on
    • bcdedit /dbgsettings usb targetname:TargetNameTargetName可任意指定,长度必须小于24个字符,只能包含-, _, 0-9, a-z, A-Z

    7> [可跳过] 如果你的电脑上不止一个usb controller,额外输入

    bcdedit /set "{dbgsettings}" busparams b.d.f

    b.d.f为第4步中获得的数字,同样为十进制
    在我们的例子里,

    bcdedit /set "{dbgsettings}" busparams 0.20.0

    8> 核对设置,可跳过

    • bcdedit /dbgsettings
    • bcdedit /enum

    9> 重启

    3. 2设置主机

    1> 使用usb调试线连接目标机和主机的usb 3.0接口。
    2> 检查主机系统是32位还是64位的,运行相应位宽的windbg。如果您是第一次设置,务必使用管理员权限。
    3> 打开File菜单,选择Kernel Debug. 打开USB标签,输入你上面设置的TargetName,点击OK.
    4> 如果是第一次,会自动安装驱动
    5> 在主机的设备管理器里,会看到:

     

    4.查看是否成功方法:

    4.1  在目标计算机上,打开命令提示符窗口,以管理员身份,并输入以下命令:

    • bcdedit /debug on #打开
    • bcdedit /debug off
    • bcdedit /dbgsettings 查看状态

    4.2Host 主机(远程)能看到debug 信息,则表明OK

    5. 故障排除

    1> 尝试主机和目标机上不同的usb3.0 口
    2> 关闭主机xHCI Controller的省电模式
    2.1> 打开设备管理器,按connection排序。找到xHCI Controller,右键,属性。电源管理标签,Allow the computer to turn off this device to save power的勾去掉。
    2.2> 再找到xHCI Controller下面Root Hub的节点。右键,属性。电源管理标签,Allow the computer to turn off this device to save power的勾去掉(同上)。
    3> 检查是否以管理员权限运行 windbg,32/64位是否选对。

    6.WinDbg 常用命令手册

    https://www.cnblogs.com/gaochundong/p/windbg_cheat_sheet.html

    参考:

    https://docs.microsoft.com/zh-cn/windows-hardware/drivers/debugger/setting-up-a-usb-3-0-debug-cable-connection

    https://zhuanlan.zhihu.com/p/35414973

  • 相关阅读:
    点击刷新验证码
    自定义shiro实现权限验证方法isAccessAllowed
    trackerClient.getConnection()为null
    spring boot集成FastDFS
    云服务器80端口无法访问
    linux搭建FastDFS文件服务器
    maven仓库有jar包还是报错怎么办?
    input表单强制大小写
    springboot集成freemarker静态资源无法访问
    idea 错误: 找不到或无法加载主类
  • 原文地址:https://www.cnblogs.com/ASAP/p/12017461.html
Copyright © 2011-2022 走看看