본문 바로가기

[Debugging] Tips

[TRACE32] struct devce 정보 덤프: dpm_device_list_dump.cmm

아래 cmm 을 실행하면 디바이스에 존재하는 struct device 인스턴스 정보를 모두 볼 수 있습니다.
 
;****************************************************************************
;**         dpm_device_list_dump.cmm
;**
;**         This cmm file is designed to dump all  dpm_list.
;**
;**
;****************************************************************************
;**
;**                        EDIT HISTORY FOR MODULE
;**
;**
;** when        who      what, where, why
;** --------    ---      ------------------------------------------------------
;** 01/30/2021   austindh.kim@gmail.com CREATE
 
Area.Create IO 80. 100.
Area.Select IO
Area IO
 
;=====specify the output directory of dump file, start =====
DIALOG.DIR D:\kernel_panic\*
ENTRY &ramdump_dir
 
&dump_debug_file="&ramdump_dir"+"/dpm_device_debug.c"
 
printer.FILE &dump_debug_file
printer.OPEN &dump_debug_file
 
&CURRENT_DPM_LIST=0x0
&FIRST_DPM_LIST=0x0
 
//offset of struct device.power.entry
&OFFSET_DEVICE_POWER_ENTRY=0x0
 
&CURRENT_DEVICE_ADDRESS=0x0
 
&LOOP_CONDITION=0x0
 
// default symbols, start
y.create.var __guillerMo_char_start 0xc000d000 char [300]
y.create.done
 
y.create.var __guillerMo_char_end 0xc000e000 char [300]
y.create.done
 
y.create.var __guillerMo_char_dpm_noirq 0xc000f000 char [300]
y.create.done
 
 
v __guillerMo_char_start="============= START ==========="
v __guillerMo_char_end="============== END ============"
v __guillerMo_char_dpm_noirq="@@@@@@@@DPM_NOIRQ_LIST@@@@@@@@@@@"
// default symbols, end
 
y.create.var __guillerMo_dpm_list 0 struct list_head
y.create.done
 
y.create.var __guillerMo_device 0 struct device
y.create.done
 
symbol.modify.address __guillerMo_dpm_list VAR.VALUE(&dpm_list)
 
gosub getDeviceOffsetAddress
 
&FIRST_DPM_LIST=VAR.VALUE(&dpm_list)
&CURRENT_DPM_LIST=&FIRST_DPM_LIST
 
while &LOOP_CONDITION!=0x7
(
&CURRENT_DEVICE_ADDRESS=&CURRENT_DPM_LIST-&OFFSET_DEVICE_POWER_ENTRY
symbol.modify.address __guillerMo_device &CURRENT_DEVICE_ADDRESS
 
// start logging display struct device*
wp.v.v %string.on __guillerMo_char_start
 
wp.v.v %string.on __guillerMo_device.kobj.name
wp.v.v %all %L __guillerMo_device
 
wp.v.v %string.on __guillerMo_char_end
// end logging display struct device*
&CURRENT_DPM_LIST=V.VALUE( ((struct list_head *)&CURRENT_DPM_LIST)->next )
 
if &CURRENT_DPM_LIST==&FIRST_DPM_LIST
(
&LOOP_CONDITION=0x7
)
)
 
// start logging dpm_noirq_list for struct device*
wp.v.v %string.on __guillerMo_char_dpm_noirq
 
&FIRST_DPM_LIST=VAR.VALUE(&dpm_noirq_list)
&CURRENT_DPM_LIST=&FIRST_DPM_LIST
 
&LOOP_CONDITION=0x0
 
while &LOOP_CONDITION!=0x7
(
&CURRENT_DEVICE_ADDRESS=&CURRENT_DPM_LIST-&OFFSET_DEVICE_POWER_ENTRY
symbol.modify.address __guillerMo_device &CURRENT_DEVICE_ADDRESS
 
// start logging display struct device*
wp.v.v %string.on __guillerMo_char_start
 
wp.v.v %string.on __guillerMo_device.kobj.name
wp.v.v %all %L __guillerMo_device
 
wp.v.v %string.on __guillerMo_char_end
// end logging display struct device*
&CURRENT_DPM_LIST=V.VALUE( ((struct list_head *)&CURRENT_DPM_LIST)->next )
 
if &CURRENT_DPM_LIST==&FIRST_DPM_LIST
(
&LOOP_CONDITION=0x7
)
)
 
 
printer.close
 
y.create.RESET
enddo
 
; *************************************************************************
; getDeviceOffsetAddress
;
; This function determines offset of struct device.power.entry
; *************************************************************************
getDeviceOffsetAddress:
  LOCAL &local_power_entry  &local_power_offset
  
  &local_power_entry=0x0
  &local_power_offset=0x0
  
  symbol.modify.address __guillerMo_device VAR.VALUE(&dpm_list)
  
  &local_power_entry=V.ADDRESS(__guillerMo_device.power.entry)
  &local_power_offset=&local_power_entry-V.ADDRESS(__guillerMo_device)
  
  &OFFSET_DEVICE_POWER_ENTRY=&local_power_offset
  
RETURN
// end of getDeviceOffsetAddress