Archive for the ‘Sticker’ Category

Feeling too lazy!

December 27th, 2005

Sticker needs a bit of design change & i’m feeling too lazy to do that!




Get up makuchaku!

Posted in Sticker | Comments (0)

Child notifies parent before terminating…

December 26th, 2005

Finally managed to get hold of SIGCHLD signal when the child terminates.
The code can be found here.

Posted in Sticker | Comments (1)

Non-blocking wait…

December 24th, 2005

The parent wants to wait() for child’s exit, but not blockingly… how to do this?

One of the solution, i found was to trap SIGCHILD. This signal is sent to the parent on child’s termination. The parent can then loop on a bolean variable to check for child’s existance, while doing other work… something i needed exactly for sticker!

Lets see, will it work as i wanted or not… :-)

Posted in Sticker, Technology | Comments (1)

PTRACE_SINGLESTEP

December 22nd, 2005

ptrace() needs to be reminded again & again that in what mode is it operating. So if you have to single-step through all the instructions in a program, you need to constantly call (or set) ptrace request to PTRACE_SINGLESTEP

For example, this code will just single-step through first 10 instructions.

while(1)
{
 wait(&status);
 if(WIFEXITED(status))
 {
  printf("Breaking\n");
  break;
 }

 ptrace(PTRACE_GETREGS, child, NULL, &regs);
 ins = ptrace(PTRACE_PEEKTEXT, child, regs.eip, NULL);
 printf("(i = %d) EIP : 0x%X (%X)\n", i, regs.eip, ins);
 i++;

 if(i < 10 )
 ptrace(PTRACE_SINGLESTEP, child, NULL, NULL);
}

Posted in Sticker | Comments (0)

Disassembling Hello World…

December 22nd, 2005

(gdb) disassemble main
Dump of assembler code for function main:
0×08048368 : push %ebp
0×08048369 : mov %esp,%ebp
0×0804836b : sub $0×8,%esp
0×0804836e : and $0xfffffff0,%esp
0×08048371 : mov $0×0,%eax
0×08048376 : add $0xf,%eax
0×08048379 : add $0xf,%eax
0×0804837c : shr $0×4,%eax
0×0804837f : shl $0×4,%eax
0×08048382 : sub %eax,%esp
0×08048384 : sub $0xc,%esp
0×08048387 : push $0×804847c
0×0804838c : call 0×80482b0 <_init+56>
0×08048391 : add $0×10,%esp
0×08048394 : mov $0×0,%eax
0×08048399 : leave
0×0804839a : ret
End of assembler dump.

(gdb) x/51xb 0×08048368
0×8048368

: 0×55 0×89 0xe5 0×83 0xec 0×08 0×83 0xe4
0×8048370 : 0xf0 0xb8 0×00 0×00 0×00 0×00 0×83 0xc0
0×8048378 : 0×0f 0×83 0xc0 0×0f 0xc1 0xe8 0×04 0xc1
0×8048380 : 0xe0 0×04 0×29 0xc4 0×83 0xec 0×0c 0×68
0×8048388 : 0×7c 0×84 0×04 0×08 0xe8 0×1f 0xff 0xff
0×8048390 : 0xff 0×83 0xc4 0×10 0xb8 0×00 0×00 0×00
0×8048398 : 0×00 0xc9 0xc3

Posted in Sticker | Comments (0)