printk에 %로 어떤 형식을 지정할 지 헷갈릴 때가 많습니다.
이럴 때는 다음 형식을 참고하면 됩니다.
If variable is of Type, use printk format specifier:
------------------------------------------------------------
int %d or %x
unsigned int %u or %x
long %ld or %lx
unsigned long %lu or %lx
long long %lld or %llx
unsigned long long %llu or %llx
size_t %zu or %zx
ssize_t %zd or %zx
s32 %d or %x
u32 %u or %x
s64 %lld or %llx
u64 %llu or %llx
예를 들면 다음 코드와 같이,
timer->expires 멤버 변수를 (unsigned long long) 타입으로 캐스팅해서 %llu 형식으로 출력합니다.
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1008,6 +1010,21 @@ __mod_timer(struct timer_list *timer, unsigned long expires, bool pending_only)
debug_activate(timer, expires);
timer->expires = expires;
+
+ if (raspbian_debug_state == 5060) {
+ void *stack = NULL;
+ struct thread_info *current_thread;
+
+ stack = current->stack;
+ current_thread = (struct thread_info*)stack;
+
+ trace_printk("[-][%s]jiffies_64: %llu, timer->expires: %llu caller:%pS \n",
+ current->comm, jiffies_64, (unsigned long long)timer->expires, (void *)__builtin_return_address(0));
+
+ trace_printk("[-] in_softirq(): 0x%08x,preempt_count = 0x%08x \n",
+ (unsigned int)in_softirq(), (unsigned int)current_thread->preempt_count);
+ }
출처
'Core BSP 분석 > 리눅스 커널 핵심 분석' 카테고리의 다른 글
[Linux][Kernel] preempt_disable()/preempt_enable() 주의 사항 (0) | 2023.05.06 |
---|---|
[라즈베리파이] 비트 처리 __test_and_set_bit() __test_and_clear_bit() 함수 동작 원리 (0) | 2023.05.06 |
[C언어] 포인터 (p + 1) 연산 (0) | 2023.05.06 |
[Linux][GCC]## 매크로 - 심볼 생성 (0) | 2023.05.06 |
[Linux] 컴파일러(Complier) 소개 (0) | 2023.05.06 |