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

coreadm – core file administration

Coreadm utility is used to set various options for generating core on Solaris system.

Sometimes, core file is not generated for a process which has setid bit enabled. Use following command to enable the core generation for such processes –

coreadm -e proc-setid

Please see here for more options to use with coreadm.

July 22, 2011 Posted by | Uncategorized | Leave a comment

Difference between paged pool and nonpaged pool memory

Windows divides the kernel mode address space into paged and nonpaged memory pools. The paged memory can be swapped out and nonpaged memory is never swapped out.

Device drivers are usually not paged. For example, interrupt routine must be in nonpaged memory because interrupt can occur anytime. Paged pool can be allocated and accessed at IRQL < DISPATCH_LEVEL.

For more information, please visit this blog.

July 14, 2011 Posted by | Uncategorized | , | Leave a comment

FSUTIL – Create a file of specified size

Windows utility “fsutil” can be used to create a file of certain size.

Fsutil file createnew

For example:

fsutil file createnew C:\file_100MB.dat 104857600
will create a 100MB file (104,857,600B = 100MB) named “file_100MB.dat” in C drive.

July 1, 2011 Posted by | Uncategorized | Leave a comment

Disable structure padding in C

Following is the way to disable structure padding using pragma in C.

#pragma pack(push, 1)
//Define your structure here
#pragma pack(pop)
//Structure padding is re enabled.

More information can be found at MSDN. GCC follows the same specifications.

July 1, 2011 Posted by | Uncategorized | Leave a comment

Watch out

Ever been in the situation where you want to run the command continuously without writing a shell script for it.

Watch is used to run a command to run at regular intervals. The basic syntax of the command is
Continue reading

July 1, 2011 Posted by | Uncategorized | 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

Bang bang!!!

One reason people hate using command line is if something goes wrong or has to rerun the command, they have to type it all over again. Some use up arrow instead of retyping. But here is bang command typed as (!) exclamation, for your rescue.
Continue reading

April 16, 2010 Posted by | Uncategorized | Leave a comment

Fedora 12 installation hangs on Dell laptop

I was trying to install Fedora 12 on my system. I have Dell Vostro 1015 with 2 GB RAM. The installation hangs after running for some time. It does not hang at one particular place. I tried 3 or 4 times and every time it hanged at different places.

After going through their bug list, I found a bug about my problem. To see the bug information, go to bug.

They have given a work around which did not work for me but it did work for some people.

Update (01-Jul-2011):
This seems to be a known bug. Even, I have faced the same issue with FC14 also. Now, I am using Kubuntu and installed FC14 on Virtual Box in windows. So far so good for me. I wish they could resolve this issue.

Please see below link for the details on the bug here.

February 13, 2010 Posted by | Uncategorized | 2 Comments

Gustavo Duarte’s Linux Internals Series

I have been reading Gustavo Duarte’s blog for last few days. The blog contains very good and neatly written contents on Linux internals. He has explained the things in the simplest manner using code and, especial mention to, excellent diagrams.

I would definitely recommend you to read the blog series, if you are interested in Linux internals.

August 25, 2009 Posted by | Linux | 5 Comments