I've done some research of libcudadebugger.so internals - seems that it has exactly the same patterns:
- functions table returned by GetCUDADebuggerAPI located in .data section so you can patch any callback address
- and each API function has logger
This last fact is strange - while loggers from libcuda.so were used by debugger then who consume logs from debugger itself? Check code to load those loggers:
lea rdi, aNvtxInjection6 ; "NVTX_INJECTION64_PATH"
call _getenv
mov rdi, rax ; file
test rax, rax
jz short loc_14B160
mov esi, 1 ; mode
call _dlopen
mov r13, rax
test rax, rax
jz short loc_14B190
lea rsi, aInitializeinje_1 ; "InitializeInjectionNvtx2"
mov rdi, rax ; handle
call _dlsym
test rax, rax
jz short loc_14B1A0
lea rdi, sub_14A270
call rax
lea rax, aFailedCreatede+7 ; "CreateDebuggerSession"
mov [rbp+var_18], rax
mov rax, cs:dbg_log
mov [rbp+var_20], 0
mov dword ptr [rbp+var_40], 300003h
mov dword ptr [rbp+var_20], 1
movaps [rbp+var_30], xmm0
test rax, rax
jz loc_1470AC
lea rdx, [rbp+var_40]
mov r12, rdx
mov rdi, rdx
call rax
10/02/2026 15:11:13 CreateDebuggerSession00000000 03 00 30 00-00 00 00 00|01 00 00 00-4A 84 F9 FF ..0.........J...
00000010 00 00 00 00-00 00 00 00|00 00 00 00-00 00 00 00 ................
00000020 01 00 00 00-00 00 00 00|D9 70 E3 52-55 15 00 00 .........p.RU...
Tracepoints
movzx eax, cs:word_9AA8E8
cmp ax, 1
jg short loc_147058
test ax, ax
jz loc_147080
loc_146FE4: ; CODE XREF: CreateDebuggerSession+16B↓j
cmp ax, 1
jnz short loc_147058
cmp cs:byte_9AA8EC, 31h ; '1'
jbe short loc_147058
loc_146FF3: ; CODE XREF: CreateDebuggerSession+15E↓j
cmp cs:byte_9B83CF, 0FFh
jz short loc_147058
lea rax, aCreateFailedSt ; "Create failed. status=0x%x callResult=0"...
...
call log_report
tlg {
const char *prefix;
unsigned short level; // offset 0x8
unsigned char mask1, mask2, mask3; // offset 0xa, 0xb & 0xc
};Patch for cuda-gdb
- --log=log.file for log filename
- --verbose to turn on tracepoints - note that I reused info_verbose var - it is ruled by
set verbose on/off
gdb$(EXEEXT): gdb.o $(LIBGDB_OBS) $(CDEPS) $(TDEPLIBS) $(LIBCUDACORE)
$(SILENCE) rm -f gdb$(EXEEXT)
$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_LDFLAGS) $(WIN32LDAPP) \
-o gdb$(EXEEXT) gdb.o $(LIBGDB_OBS) /home/redp/disc/src/cuda-ptx/src/denvdis/cudaso/libde_bg.a /home/redp/disc/udis86/libudis86/libudis86.a \
Комментариев нет:
Отправить комментарий