;****************************************************************************
;** save_current_registers.cmm
;** This script is designed to save current a set of registers.
;**
;**
;**
;** when who what, where, why
;** -------------- ------------ ------------------------------------------------------
;** 04/21/2018 austindh.kim@gmail.com First version
;****************************************************************************
ENTRY &ramdump_dir &output_file
;specify the output directory of dump file
&dump_debug_file="&ramdump_dir"+"/&output_file.cmm"
;=====specify the output directory of dump file, end =====
open #1 &dump_debug_file /create
&ARCH_MODE=0x0
&ARM_32_BIT_MODE=0x32
&ARM_64_BIT_MODE=0x64
&r0=0x0
&r1=0x0
&r2=0x0
&r3=0x0
&r4=0x0
&r5=0x0
&r6=0x0
&r7=0x0
&r8=0x0
&r9=0x0
&r10=0x0
&r11=0x0
&r12=0x0
&r13=0x0
&r14=0x0
&r15=0x0
&r16=0x0
&r17=0x0
&r18=0x0
&r19=0x0
&r20=0x0
&r21=0x0
&r22=0x0
&r23=0x0
&r24=0x0
&r25=0x0
&r26=0x0
&r27=0x0
&r28=0x0
&r29=0x0
&r30=0x0
&pc=0x0
&sp=0x0
gosub configureARMArchBitMode
; configure a set of registers
if (&ARCH_MODE==&ARM_32_BIT_MODE)
(
gosub ConfigureRegister32Bit
)
if (&ARCH_MODE==&ARM_64_BIT_MODE)
(
gosub ConfigureRegister64Bit
)
close #1
enddo
; *************************************************************************
; configureARMArchBitMode
;
; This function determines ARM architecture mode(ARM32/ARM64)
; *************************************************************************
configureARMArchBitMode:
LOCAL &next_addr &prev_addr &TEMP_ADDRESS &address_unit
// temp address for testing
&TEMP_ADDRESS=V.VALUE(&init_task)
&next_addr=V.ADDRESS( ( (struct list_head*)&TEMP_ADDRESS)->next )
&prev_addr=V.ADDRESS( ( (struct list_head*)&TEMP_ADDRESS)->prev )
&address_unit=&prev_addr-&next_addr
if &address_unit==0x4
(
&ARCH_MODE=&ARM_32_BIT_MODE
)
else if &address_unit==0x8
(
&ARCH_MODE=&ARM_64_BIT_MODE
)
else
(
print "invalid fault"
)
RETURN
// end of configureARMArchBitMode
; *************************************************************************
; ConfigureRegister32Bit
;
; Read current Register and save it.
;
; *************************************************************************
ConfigureRegister32Bit:
LOCAL &temp
&r0=r(r0)
&r1=r(r1)
&r2=r(r2)
&r3=r(r3)
&r4=r(r4)
&r5=r(r5)
&r6=r(r6)
&r7=r(r7)
&r8=r(r8)
&r9=r(r9)
&r10=r(r10)
&r11=r(r11)
&r12=r(r12)
&r14=r(r14)
&sp=r(r13)
&pc=r(pc)
write #1 "r.s r0 0x" &r0
write #1 "r.s r1 0x" &r1
write #1 "r.s r2 0x" &r2
write #1 "r.s r3 0x" &r3
write #1 "r.s r4 0x" &r4
write #1 "r.s r5 0x" &r5
write #1 "r.s r6 0x" &r6
write #1 "r.s r7 0x" &r7
write #1 "r.s r8 0x" &r8
write #1 "r.s r9 0x" &r9
write #1 "r.s r10 0x" &r10
write #1 "r.s r11 0x" &r11
write #1 "r.s r12 0x" &r12
write #1 "r.s r13 0x" &sp
write #1 "r.s r14 0x" &r14
write #1 "r.s pc 0x" &pc
// gosub ConfigureRegister32Bit
RETURN
; *************************************************************************
; ConfigureRegister32Bit
;
; Read current Register and save it.
;
; *************************************************************************
ConfigureRegister64Bit:
LOCAL &temp
&r0=r(x0)
&r1=r(x1)
&r2=r(x2)
&r3=r(x3)
&r4=r(x4)
&r5=r(x5)
&r6=r(x6)
&r7=r(x7)
&r8=r(x8)
&r9=r(x9)
&r10=r(x10)
&r11=r(x11)
&r12=r(x12)
&r13=r(x13)
&r14=r(x14)
&r15=r(x15)
&r16=r(x16)
&r17=r(x17)
&r18=r(x18)
&r19=r(x19)
&r20=r(x20)
&r21=r(x21)
&r22=r(x22)
&r23=r(x23)
&r24=r(x24)
&r25=r(x25)
&r26=r(x26)
&r27=r(x27)
&r28=r(x28)
&r29=r(x29)
&r30=r(x30)
&sp=r(sp)
&pc=r(pc)
write #1 "r.s x0 0x" &r0
write #1 "r.s x1 0x" &r1
write #1 "r.s x2 0x" &r2
write #1 "r.s x3 0x" &r3
write #1 "r.s x4 0x" &r4
write #1 "r.s x5 0x" &r5
write #1 "r.s x6 0x" &r6
write #1 "r.s x7 0x" &r7
write #1 "r.s x8 0x" &r8
write #1 "r.s x9 0x" &r9
write #1 "r.s x10 0x" &r10
write #1 "r.s x11 0x" &r11
write #1 "r.s x12 0x" &r12
write #1 "r.s x13 0x" &r13
write #1 "r.s x14 0x" &r14
write #1 "r.s x15 0x" &r15
write #1 "r.s x16 0x" &r16
write #1 "r.s x17 0x" &r17
write #1 "r.s x18 0x" &r18
write #1 "r.s x19 0x" &r19
write #1 "r.s x20 0x" &r20
write #1 "r.s x21 0x" &r21
write #1 "r.s x22 0x" &r22
write #1 "r.s x23 0x" &r23
write #1 "r.s x24 0x" &r24
write #1 "r.s x25 0x" &r25
write #1 "r.s x26 0x" &r26
write #1 "r.s x27 0x" &r27
write #1 "r.s x28 0x" &r28
write #1 "r.s x29 0x" &r29
write #1 "r.s x30 0x" &r30
write #1 "r.s pc 0x" &pc
write #1 "r.s sp 0x" &sp
// gosub ConfigureRegister64Bit
RETURN
'유용한 디버깅 팁 > TRACE32' 카테고리의 다른 글
[Linux][Kernel][Debug] T32 - container_of 매크로 (0) | 2023.05.05 |
---|---|
[crash-utility] crash-utilty 실행 시 디버깅 옵션(-d 6) (0) | 2023.04.01 |
[Linux][Kernel][Debug] T32 - container_of 매크로 (0) | 2023.04.01 |
[TRACE32] 폰트(FONT) 사이트 변경 (0) | 2023.03.31 |
유용한 TRACE32(T32) 명령어 (0) | 2023.03.28 |