Introduction to Break Points

In this chapter we will be discussing about what are breakpoints , what are the types of breakpoints, what are the benefits and limitation of each type of breakpoints.

In a simple definition we can define breakpoint is a signal which tells processor to halt execution of program  at certain moment so that we can do the debugging to find the root cause of any issue  or bug.

By using  breakpoint we can suspend execution wherever we want. After suspending of execution we can examine the state of our program and can dump value of some or all the program variables. By examine the current state at breakpoint we can see  weather our program is in expected flow or not till now.

If till now our program execution is in expected state then we can say confidently that problem is there in the program after the breakpoint and can remove current breakpoint and can add more breakpoint in after the position of our previous breakpoint.

If till now our program execution is not in expected state then we can say that some bug is there in program before breakpoint and can look the code prior to breakpoint position.

lets understand with example:

int main()

{

int a[5];

Printf(“enter  5  number “);

for(int i=0;i<5;i++)

{

scanf(“%d”,a[i]);

}

for(int i=0; i<5;i++)

{

sum=sum+a[i];

}

printf(“sum of entered number is %d \n” , sum);

}

 

above program takes 5 numbers as an input from user and print total sum of all the file numbers on screen. but Assume some how our output is not as the expected one. then we can place breakpoint in our program and check for current state of execution and then debug further.

int main()

{

int a[5];

Printf(“enter  5  number “);

for(int i=0;i<5;i++)

{

scanf(“%d”,a[i]);

}

BREAKPOINT:

for(int i=0; i<5;i++)

{

sum=sum+a[i];

}

printf(“sum of entered number is %d \n” , sum);

}

when we execute this program after placing the breakpoint then out program will execute till we get input from user and then our program execution  will suspend.

so after suspending of execution we can check that weather we got all five  number from user or not .

If yes then we are sure that problem is there after the breakpoint and if not then we are sure that problem is there before the breakpoint and can proceed further accordingly.

Benefits of Breakpoints:-

1) Breakpoints doesn’t make any changes in source code of our program so we can freely use breakpoint without worrying about effect on logic of program.

2) We can add or delete breakpoint at run time without changing source code or our program.

3)We can change the execution of our program any time.

Types of breakpoint:-

Depending upon the implementation of breakpoints , breakpoints are generally divided into two categories

1) Hardware breakpoint:-

Hardware breakpoints are breakpoints which are implemented by using some special feature of hardware or target device which we needs to debug. How actually the hardware breakpoint are implemented we will discuss in next chapter.

Advantage of hardware breakpoint:-

1)Hardware breakpoint are fast as compare to software breakpoints.

2) Hardware breakpoint can be applied to any memory weather  its RAM or ROM.

Limitation:-

1) Total number of hardware breakpoints are limited on hardware architecture.

 

 

2) Software breakpoint :-

These are the breakpoint  which are implemented in software without any dependency on hardware.  We will discuss the actual implementation of breakpoint in next chapter.

Advantages of software breakpoint:-

1) We can have unlimited number of software breakpoints.

2) we don’t need of any hardware support .

Disadvantage:-

we cannot apply software breakpoints in non volatile memory like ROM.

 

adana elektrikci

', 'auto'); ga('send', 'pageview');