Month: August 2015

Amazing recording feature by specific which code-block you want to record

In the original GKD design, it works with bochs instrumentation. Being helped ( 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);
printf("username :");
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");
__asm__ __volatile__("PREFETCHT0 0x87654321");

Then GKD will give you this


read count : 177

handling exception 7

the easiest way to handle exception 7 is to execute clts then iret. My kernel was crashed because it generated a exception 0x7.

read count : 82

hard to theme netbeans perfectly

It is hard to theme netbeans using traditional swing look & feel. The reason is netbean’s tab container is not traditional swing JTabbedPane. See the post

Netbeans use a AbstractViewTabDisplayerUI to support only few “default look & feel”, such as Metal, Nimbus, Aqua. see below:


The problem is : This default look & feel tab container styles are preset to netbeans source code. So we *DONT* have a way to override it. And each of them just draw things by its own ways (see below), even you look & feel is based on one of them, you CANT override its style.

    private void paintBottomBorder(Graphics g, JComponent c) {
        Color color = isActive() ? getActBgColor() : getInactBgColor();
        Rectangle bounds = c.getBounds();
        g.fillRect(1, bounds.height - 3, bounds.width - 1, 2);
        g.drawLine(1, bounds.height - 1, bounds.width - 1, bounds.height - 1);


When i apply peter-swing to netbeans, take a look below, the tab container is ugly (LHS). In right hand side, the tab should look like that.

netbeans tab is ugly

read count : 189

grub is slow on bochs

if grub is running slowly on bochs, try to add “–no-rs-codes” to your grub-bios-setup command. It will be 0.5 sec versus 5 seconds different.

read count : 110

gcc can’t handle too much #if macro

gcc can’t handle too much macro (#if, #define), the output dwarf will have wrong line number. So when you disassemble the assembly with c/c++ source, everything are wrong, including wrong line number, wrong assembly code to c source code, duplicated c/c++ line.

wrong dwarf produced by gcc
wrong dwarf produced by gcc


The decoded lines are out of order
The decoded lines are out of order

In GKD, i add an on/off button to filter out those out of order source, i can’t prove it must be correct but it makes the assembly code more reasonable.

filter out of order c source
filter out of order c source

read count : 750