debug工具_linux PCI debug工具

Martoni/pcie_debug​github.com
97471244e45ddad788b2988b06939e90.png

ubuntu 上的编译错误及解决方法

l~/repo/tool/pcie_debug$ make

gcc -Wall -lreadline -lcurses pci_debug.c -o pci_debug

pci_debug.c:32:10: fatal error: readline/readline.h: 没有那个文件或目录

#include <readline/readline.h>

^~~~~~~~~~~~~~~~~~~~~

compilation terminated.

<内置>: recipe for target 'pci_debug' failed

make: *** [pci_debug] Error 1

原因是缺少依赖库:sudo apt-get install libreadline-dev

~/repo/tool/pcie_debug$ make

gcc -Wall -lreadline -lcurses pci_debug.c -o pci_debug

/usr/bin/ld: 找不到 -lcurses

collect2: error: ld returned 1 exit status

<内置>: recipe for target 'pci_debug' failed

make: *** [pci_debug] Error 1

sudo apt-get install libncurses5-dev

gcc -Wall -lreadline -lcurses pci_debug.c -o pci_debug

/tmp/ccwU9wyj.o:在函数‘parse_command’中:

pci_debug.c:(.text+0x65b):对‘readline’未定义的引用

pci_debug.c:(.text+0x6af):对‘add_history’未定义的引用

collect2: error: ld returned 1 exit status

<内置>: recipe for target 'pci_debug' failed

make: *** [pci_debug] Error 1

gcc pci_debug.c -o pci_debug -lreadline -lcurses

./pci_debug

Usage: pci_debug -s <device>

-h Help (this message)

-s <device> Slot/device (as per lspci)

-b <BAR> Base address region (BAR) to access, eg. 0 for BAR0

可以看出pci_debug工具是导出BAR空间的寄存器

sudo ./pci_debug -s 00:14.0 -b 0

PCI debug

---------

- accessing BAR0

- region size is 65536-bytes

- offset into region is 0-bytes

? Help

d[width] addr len Display memory starting from addr

[width]

8 - 8-bit access

16 - 16-bit access

32 - 32-bit access (default)

c[width] addr val Change memory at addr to val

e Print the endian access mode

e[mode] Change the endian access mode

[mode]

b - big-endian (default)

l - little-endian

f[width] addr val len inc Fill memory

addr - start address

val - start value

len - length (in bytes)

inc - increment (defaults to 1)

q Quit

Notes:

1. addr, len, and val are interpreted as hex values

addresses are always byte based

PCI> d 0x0 20

00000000: 01000080 12000840 14200054 0200000A

00000010: 200077C1 00003000 00002000 00000000

PCI> d 0x0 0x20

00000000: 01000080 12000840 14200054 0200000A

00000010: 200077C1 00003000 00002000 00000000

PCI> d 0x0 0x30

00000000: 01000080 12000840 14200054 0200000A

00000010: 200077C1 00003000 00002000 00000000

00000020: 00000000 00000000 00000000 00000000

PCI>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值