In the original GKD design, it works with bochs instrumentation. Being helped (https://sourceforge.net/p/bochs/discussion/39593/thread/d960fe94/?limit=50) by the author of bochs (Mr Stanislav Shwartsman ) emulator, now we can use the prefetch instruction to specific which code-block you want to record, it becomes even more useful now.
__asm__ __volatile__("PREFETCHT0 0x12345678"); char *buffer = (char *) malloc(fileSize); fread(buffer, 1, fileSize, file); fclose(file); printf("username :"); fflush(stdout); char username[101]; __asm__ __volatile__("PREFETCHT0 0x87654321");
Every code surrounded by PREFETCHT0 and PREFETCHT1 instruction, GKD will record jumping instruction (jmp/call/iret). In my kernel, if it crash in the gets() function, i just do:
__asm__ __volatile__("PREFETCHT0 0x12345678"); gets(username); __asm__ __volatile__("PREFETCHT0 0x87654321");
Then GKD will give you this