Spread and use Firefox
Advertise on this blog!
-->

Subscribe to my posts via Email


Delivered by FeedBurner

I'm an Indian
Darn proud of being an Indian!

Links...

Categories

Archives

Friends



Subscribe





External Links



You might want to check out...

Online Casinos - A guide to the best online casinos, gambling sites and casino bonuses

December 27, 2005

Feeling too lazy!

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




Get up makuchaku!

December 26, 2005

Child notifies parent before terminating…

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

December 24, 2005

Non-blocking wait…

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… :-)

December 22, 2005

PTRACE_SINGLESTEP

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);
}

Disassembling Hello World…

(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

Generating class diagrams using Umbrello

From past 4-5 days, I was hopping mad to generate Sticker’s class diagrams using autoDia, which was giving strange errors! Never in these 5 days I thought of using Umbrello directly for this…. & today morning, all I had to do was to ask Umbrello to “Import C++ classes”. It even generated the connecting arrows (implementations) itself… neat eah?

:)

Sticker - Class Diagram

December 16, 2005

& its working like a charm…

“”" After 2 days of hair pulling, 1 day of slogging, finally… its working… as expected, without any major setbacks to the design :-) “”"

[root@hddlntd6010590 sticker]# make clean; make
/bin/rm -f main.o sticker.o stickerDebug.o stickerRegisters.o stickerException.o stickerBase.o sticker *~
g++ -c -g main.cpp -o main.o
g++ -c -g sticker.cpp -o sticker.o
g++ -c -g stickerDebug.cpp -o stickerDebug.o
g++ -c -g stickerRegisters.cpp -o stickerRegisters.o
g++ -c -g stickerException.cpp -o stickerException.o
g++ -c -g stickerBase.cpp -o stickerBase.o
g++ main.o sticker.o stickerDebug.o stickerRegisters.o stickerException.o stickerBase.o -o sticker
[root@hddlntd6010590 sticker]# ./sticker
Enter PID : 1
Sticker[debug] : Initializing Sticker
Sticker[debug] : Sticker initialized
Sticker[debug] : Entering doPtrace
Sticker[debug] : Attaching to victim
Sticker[debug] : Entering ptrace stub
Sticker[debug] : Insufficient privileges to trace the process
Exception (main) : Insufficient privileges to trace the process
[root@hddlntd6010590 sticker]# ./sticker
Enter PID : 100
Sticker[debug] : Initializing Sticker
Sticker[debug] : Sticker initialized
Sticker[debug] : Entering doPtrace
Sticker[debug] : Attaching to victim
Sticker[debug] : Entering ptrace stub
Sticker[debug] : Specified process does not exists
Exception (main) : Specified process does not exists
[root@hddlntd6010590 sticker]

December 15, 2005

Coding standards for Sticker

Come coding standards i wish to follow for
@ Sticker-Dev mailing list

A seemingly awesome doc referred by Tarun Sir (My Proj Manager @ HCLT)
Privoxy coding standards

December 13, 2005

Sticker SRS

Sticker SRS is now available at Docs@Sticker

Now the Sticker team has a direction :-P

December 12, 2005

Welcome heart_reaver (Arjun) to the Sticker team

Today, heart_reaver (Arjun) has officially joined Sticker.

He’ll be developing the test modules for Sticker (unit tests). I wish him good luck :-P

Why i made an offer to Arjun to join the project? His dedication & spirit to learn. Not everyone is a C expert, but those who have the courage & will power to learn are few… & i value that.

heart_reaver (Arjun), welcome to the Sticker team :-)

How to commit code to my Sticker’s repository

// This is just for my reference :-)

0) Check out the latest code from CVS to PC in pc:///root/sticker/
1) scp it to lappy:///root/Projects/sticker/src/
2) Edit code on lappy using Anjuta
3) scp the code from lappy:///root/Projects/sticker/src/ to pc:///sticker/sticker/
4) run a CVS update from PC:///root/sticker/
5) run a CVS commit from PC:///root/sticker/

December 11, 2005

Getting dirty with CVS ;-)

Some routine commands for everyone’s reference…

1) Checking out a module

cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project co module

2) Commiting a change

cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project commit

3) Adding a file to the project

cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project add filename.cpp

4) Deleting (some/all)files from the module

// checkout the module
cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project co module
// cd module; rm -fv *; cd ..
// tell cvs to remove the module
cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project remove module
// commit
cvs -z3 -d:ext:username@forgecvs1.novell.com:/cvsroot/project commit

I still dont understand the following…
1) How to remove the empty directories from the project… the ones which have attic created inside them…
2) How to control the version numbers. Instead of default 1.1, 1.2, 1.3, cant i have 0.1, 0.2, etc…?

A really nice & short CVS tutorial can be found at Sticker’s Novell Forge page :-P

BTW, jut to chip in, colored diff’s are just awesome…!!! Have a look at it
beautyofdiff

Browse Sticker’s CVS…

December 10, 2005

Some code… finally!

// Test Sticker stub :-P
// Shucks! Indentation is lost…!!!

#include “sticker.h”

int
main()
{

unsigned long pid;

printf(“Enter PID : “);
scanf(“%lu”, &pid);

try
{

Sticker *sticker = new Sticker(pid);

sticker->attachSticker();
StickerRegisters *regs = sticker->getRegisters();

sticker->detachSticker();

if(regs)
printf(“main : regs is at 0x%X\tEIP = 0x%X\n”, regs, regs->getEIP());

else
printf(“NULL :-P\n”);
}

catch
(StickerException e)
{

printf(e.getReason());
}

return 0;
}

At the end of 5 hours - A cute Segfault!

root@Warrior:~/Projects/Sticker/src# ./sticker
Enter PID : 549
Sticker[debug] : Initializing Sticker
Sticker[debug] : Sticker initialized
Sticker[debug] : Entering doPtrace
Sticker[debug] : Attaching to victim
Sticker[debug] : Entering ptrace stub
Sticker[debug] : Exiting ptrace stub
Sticker[debug] : Exiting doPtrace
Sticker[debug] : Entering doPtrace
Sticker[debug] : Fetching registers from victim
Sticker[debug] : Entering ptrace stub
Sticker[debug] : Exiting ptrace stub
Sticker[debug] : Exiting doPtrace
Sticker[debug] : Entering doPtrace
Sticker[debug] : Detaching from victim
Sticker[debug] : Entering ptrace stub
Sticker[debug] : Exiting ptrace stub
Sticker[debug] : Exiting doPtrace
Segmentation fault
root@Warrior:~/Projects/Sticker/src#


getting back to debug this :-P