trash
漆雕宏浚
2023-12-01
int func_cnt;
void func_enter(void)
{
u32 reg_pc;
func_cnt = 0;
__asm__ (
"mov %0, lr\n"
:"=r"(reg_pc)
);
printf("\n---------- [ ENTER ] ----------> |PC = 0x%08X|\n", reg_pc);
return;
}
void func_exec(void)
{
u32 reg_pc;
func_cnt++;
__asm__ (
"mov %0, lr\n"
:"=r"(reg_pc)
);
printf("---------- [ %d ] ----------> |PC = 0x%08X|\n",func_cnt, reg_pc);
return;
}
void func_exit(void)
{
u32 reg_pc;
func_cnt = 0;
__asm__ (
"mov %0, lr\n"
:"=r"(reg_pc)
);
printf("---------- [ EXIT ] ----------> |PC = 0x%08X|\n\n", reg_pc);
return;
}
void current_regs(void)
{
__asm__ __volatile__(
"sub sp, sp, #72\n"
"stmia sp, {r0 - r12}\n"
"add r7, sp, #60\n"
"stmdb r7, {sp, lr}\n"
"str lr, [r7, #0]\n"
"mrs r6, spsr\n"
"str r6, [r7, #4]\n"
"str r0, [r7, #8]\n"
"mov r0, sp\n"
"bl show_regs\n"
"add r7, sp, #60\n"
"ldr lr, [r7, #0]\n"
"add sp, sp, #72\n"
::: "memory");
return;
}