Mukesh Chauhan

Just another WordPress.com weblog

Show callstack from the C program

Dear all,

I am currently working to show call stack of the current thread from the code itself. For this purpose, I am analyzing StackWalk64 and CaptureStackBackTrace windows API. I will update the post once I get through it.

Though, external utilities can also be used. user dump of the process can be taken to see the call stack. Solaris (and linux) has pstack command which is very excellent utility.

Please leave a comment if you have more information regarding this.

July 27, 2011 Posted by | Programming | Leave a comment

Casting malloc

Originally, the C language did not enjoy the void pointer. In those dark ages the char pointer was used as a generic pointer, so the definition of malloc looked something like this:

char *malloc(size)
int size;

Of course, this tended to cause problems when trying to assign a char pointer to, say, a double pointer. Because of this a cast was required:
Continue reading

May 30, 2010 Posted by | Programming | Leave a comment