Debugging

1. Here is a simple piece of code:

#include <stdio.h>
//int a;
//int b = 10;
//int c = 0;
//static int d = 10;
//static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        276          4       1333        535    a.out

2. Lets uncomment first line …

#include <stdio.h>
int a;
//int b = 10;
//int c = 0;
//static int d = 10;
//static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        276          8       1337        539    a.out

3. Lets uncomment the next line:

#include <stdio.h>
int a;
int b = 10;
//int c = 0;
//static int d = 10;
//static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        280          8       1341        53d    a.out

4. Lets uncomment next line:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
//static int d = 10;
//static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        280         12       1345        541    a.out

5. Lets uncomment the next line:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
//static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        284         12       1349        545    a.out

6. Lets uncomment next:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
static int e = 0;

void main ()
{

//int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        284         16       1353        549    a.out

7. Lets uncomment next:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
static int e = 0;

void main ()
{

int f = 0;
//int g;
//static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        284         16       1353        549    a.out

8. Let’s Uncomment Next line:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
static int e = 0;

void main ()
{

int f = 0;
int g;
//static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        284         16       1353        549    a.out

Lets Uncomment next:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
static int e = 0;

void main ()
{

int f = 0;
int g;
static int i = 0;
//static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        284         20       1357        54d    a.out

Let’s Uncomment Next:

#include <stdio.h>
int a;
int b = 10;
int c = 0;
static int d = 10;
static int e = 0;

void main ()
{

int f = 0;
int g;
static int i = 0;
static int j = 10;

return ;
}

Now:

rahul@rahul:~/Work/Learning$ size -d a.out
text       data        bss        dec        hex    filename
1053        288         20       1361        551    a.out

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s