当前位置:   article > 正文

Linux 动态输出 dynamic_debug_linux /sys/kernel/debug/dynamic_debug/control值如何生成

linux /sys/kernel/debug/dynamic_debug/control值如何生成的
  • 怎么打开
在 def_config中添加
CONFIG_DEBUG_FS=y 
CONFIG_DYNAMIC_DEBUG=y

设置def_config 之后,3种方式可以打印动态信息.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 以sd存储卡为例
# cat /sys/kernel/debug/dynamic_debug/control  |grep  "drivers/mmc"
drivers/mmc/core/core.c:158 [mmc_core]mmc_request_done =_ "%s: req done <CMD%u>: %d: %08x %08x %08x %08x\012"
drivers/mmc/core/core.c:164 [mmc_core]mmc_request_done =_ "%s: req done (CMD%u): %d: %08x %08x %08x %08x\012"
drivers/mmc/core/core.c:169 [mmc_core]mmc_request_done =_ "%s:     %d bytes transferred: %d\012"
drivers/mmc/core/core.c:177 [mmc_core]mmc_request_done =_ "%s:     (CMD%u): %d: %08x %08x %08x %08x\012"
drivers/mmc/core/core.c:201 [mmc_core]mmc_start_request =_ "<%s: starting CMD%u arg %08x flags %08x>\012"
drivers/mmc/core/core.c:206 [mmc_core]mmc_start_request =_ "%s: starting CMD%u arg %08x flags %08x\012"
drivers/mmc/core/core.c:214 [mmc_core]mmc_start_request =_ "%s:     blksz %d blocks %d flags %08x tsac %d ms nsac %d\012"
drivers/mmc/core/core.c:220 [mmc_core]mmc_start_request =_ "%s:     CMD%u arg %08x flags %08x\012"
drivers/mmc/core/core.c:471 [mmc_core]mmc_wait_for_req_done =_ "%s: req failed (CMD%u): %d, retrying...\012"
drivers/mmc/core/core.c:655 [mmc_core]mmc_interrupt_hpi =_ "%s: HPI cannot be sent. Card state=%d\012"
drivers/mmc/core/core.c:994 [mmc_core]mmc_set_ios =_ "%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u timing %u\012"
drivers/mmc/core/core.c:1569 [mmc_core]mmc_set_signal_voltage =_ "%s: Signal voltage switch failed, power cycling card\012"
drivers/mmc/core/core.c:1628 [mmc_core]mmc_power_up =_ "Initial signal voltage of 3.3v\012"
drivers/mmc/core/core.c:1630 [mmc_core]mmc_power_up =_ "Initial signal voltage of 1.8v\012"
drivers/mmc/core/core.c:1632 [mmc_core]mmc_power_up =_ "Initial signal voltage of 1.2v\012"
drivers/mmc/core/core.c:2273 [mmc_core]mmc_calc_max_discard =_ "%s: calculated max. discard sectors %u for timeout %u ms\012"
drivers/mmc/core/core.c:2396 [mmc_core]_mmc_detect_card_removed =_ "%s: card removed too slowly\012"
drivers/mmc/core/core.c:2401 [mmc_core]_mmc_detect_card_removed =_ "%s: card remove detected\012"
drivers/mmc/core/host.c:329 [mmc_core]mmc_of_parse =_ "\042bus-width\042 property is missing, assuming 1 bit.\012"
drivers/mmc/core/sdio_io.c:68 [mmc_core]sdio_enable_func =_ "SDIO: Enabling device %s...\012"
drivers/mmc/core/sdio_io.c:93 [mmc_core]sdio_enable_func =_ "SDIO: Enabled device %s\012"
drivers/mmc/core/sdio_io.c:98 [mmc_core]sdio_enable_func =_ "SDIO: Failed to enable device %s\012"
drivers/mmc/core/sdio_io.c:118 [mmc_core]sdio_disable_func =_ "SDIO: Disabling device %s...\012"
drivers/mmc/core/sdio_io.c:130 [mmc_core]sdio_disable_func =_ "SDIO: Disabled device %s\012"
drivers/mmc/core/sdio_io.c:135 [mmc_core]sdio_disable_func =_ "SDIO: Failed to disable device %s\012"
drivers/mmc/core/sdio_irq.c:52 [mmc_core]process_sdio_pending_irqs =_ "%s: error %d reading SDIO_CCCR_INTx\012"
drivers/mmc/core/sdio_irq.c:121 [mmc_core]sdio_irq_thread =_ "%s: IRQ thread started (poll period = %lu jiffies)\012"
drivers/mmc/core/sdio_irq.c:188 [mmc_core]sdio_irq_thread =_ "%s: IRQ thread exiting with code %d\012"
drivers/mmc/core/sdio_irq.c:277 [mmc_core]sdio_claim_irq =_ "SDIO: Enabling IRQ for %s...\012"
drivers/mmc/core/sdio_irq.c:280 [mmc_core]sdio_claim_irq =_ "SDIO: IRQ for %s already in use.\012"
drivers/mmc/core/sdio_irq.c:320 [mmc_core]sdio_release_irq =_ "SDIO: Disabling IRQ for %s...\012"
drivers/mmc/core/quirks.c:94 [mmc_core]mmc_fixup_device =_ "calling %pf\012"
drivers/mmc/card/block.c:429 [mmc_block]ioctl_do_sanitize =_ "%s: %s - SANITIZE IN PROGRESS...\012"
drivers/mmc/card/block.c:440 [mmc_block]ioctl_do_sanitize =_ "%s: %s - SANITIZE COMPLETED\012"
drivers/mmc/host/mmci.c:791 [mmci]mmci_start_data =_ "blksz %04x blks %04x flags %08x\012"
drivers/mmc/host/mmci.c:883 [mmci]mmci_start_command =_ "op %02x arg %08x flags %08x\012"
drivers/mmc/host/mmci.c:938 [mmci]mmci_data_irq =_ "MCI ERROR IRQ, status 0x%08x at 0x%08x\012"
drivers/mmc/host/mmci.c:1163 [mmci]mmci_pio_irq =_ "irq1 (pio) %08x\012"
drivers/mmc/host/mmci.c:1258 [mmci]mmci_irq =_ "irq0 (data+cmd) %08x\012"
drivers/mmc/host/mmci.c:1546 [mmci]mmci_probe =_ "designer ID = 0x%02x\012"
drivers/mmc/host/mmci.c:1547 [mmci]mmci_probe =_ "revision = 0x%01x\012"
drivers/mmc/host/mmci.c:1578 [mmci]mmci_probe =_ "eventual mclk rate: %u Hz\012"
drivers/mmc/host/mmci.c:1615 [mmci]mmci_probe =_ "clocking block at %u Hz\012"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 前提
要想控制动态打印信息打印到控制台上,需要设置, 
echo 8  > /proc/sys/kernel/printk 
因为动态打印信息级别为 7 , 在小于 8(控制台打印级别) 的情况下可以打出来
  • 1
  • 2
  • 3

1 启动后动态打印设置

  • 测试1
echo 'module mmci +p' > /sys/kernel/debug/dynamic_debug/control
就会循环打印出
mmci-pl18x 10005000.mmci: op 0d arg 45670000 flags 00000195
mmci-pl18x 10005000.mmci: irq0 (data+cmd) 00000040
mmci-pl18x 10005000.mmci: irq0 (data+cmd) 00000000
然后 关闭打印
echo 'module mmci -p' > /sys/kernel/debug/dynamic_debug/control
就会停止打印
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 测试2
echo 'module mmc_core +p' > /sys/kernel/debug/dynamic_debug/control

mmc0: req done (CMD13): 0: 00000900 00000000 00000000 00000000
mmc0: starting CMD13 arg 45670000 flags 00000195

echo 'module mmc_core -p' > /sys/kernel/debug/dynamic_debug/control
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2 启动前动态打印设置

qemu-system-arm 参数-append 中 添加 loglevel=8 mmc_core.dyndbg=+plft
-append "init=/linuxrc console=ttyAMA0 loglevel=8 root=/dev/mmcblk0 mmc_core.dyndbg=+plft"

就会打印 mmc_core模块 的 动态打印信息

  • 1
  • 2
  • 3
  • 4
  • 5

3 编译时动态打印设置

在你关系的模块的目录下的Makefile下添加如下代码,例如 mmc_core ,对应 drivers/mmc/core/Makefile 
ccflags-y := -DDEBUG
ccflags-y += -DVERBOSE_DEBUG
  • 1
  • 2
  • 3

其他启动后动态打印设置

echo 'file xxx.c +p'
'module xxx +p'
'func xxx +p'
echo -n '*usb* +p' 	// 打开文件路径中包含usb的文件里面所有的动态输出语句
echo -n '+p'		// 打开系统所有文件里面所有的动态输出语句
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/334897
推荐阅读
相关标签
  

闽ICP备14008679号