Unit 5 SoftwareTools

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 50

Unit-5

Software Tools
Software Tools
 A programming tool or software development
tool is a program or application that software
developers use to create, debug, maintain or
otherwise support other programs and
applications.
Software Tools : Definition
 A software tool is a system program which

◦ interfaces a program with the entity generating its


input data or

◦ interfaces the result of a program with entity


consuming it.
Software Tools for Program
Development
 The fundamental steps in program
development are: -
◦ Program design, coding and documentation.
◦ Preparation of program in machine-readable form.
◦ Program linking and loading.
◦ Program testing and debugging.
◦ Performance Tuning.
◦ Reformatting the data and/or results of a program
to suit other programs.
Program Design and Coding
 Two categories of tools are used in design
and coding of program:
1. Program generators
2. Programming Environments
1. Program Generators
 Generates a program which performs a set of
functions describes in its specification.
 It generally provides graphical User Interface

and tools that allow the user to create a


program without having to write actual code.
 The user may only specify the steps or rules

required for program and need not write any


code or very little code.
2. Programming Environments
 A programming environment is a software
that provides integrated facilities for program
creation, editing, execution, testing and
debugging. It consist of following
components:-
◦ a syntax directed editor.
◦ a language processor.
◦ a debug monitor.
◦ a dialog monitor.
Syntax Directed Editor
 It incorporates a front end for the
programming language. As a user keys in
the program, the editor performs syntax
analysis and converts it into an intermediate
representation(IR).
◦ The compiler (or interpreter) and debug monitor
share the IR.
◦ The compiler is activated after editor has
converted a statement into IR.
◦ The compiler incrementally generates code for the
statements.
Syntax Directed Editor Contd..
◦ Thus, the program execution or interpretation
can be started immediately after the last
statement has been input.
◦ At any time, during execution, the programmer
can interrupt program execution and enter the
debug mode or return to the editor and then may
resume or restart its execution.
Editor
 They are the tools for program entry and
editing. The editor functions in two modes:-
 Command mode:- it accepts user commands

specifying the editing functions to be


performed.
 Data mode:- The user keys in the text to be

added to the file.


Approaches for Using Editor
 There are two approaches for using the editor
in different modes:-
 A quick exit is provided from data mode, e.g.

by pressing the escape key, such that the


editor enters the command mode.
◦ The vi editor of Unix uses this approach.
Approaches for Using Editor
 The second approach support screen mode
(also called what – you – see – is – what – you
– get).
◦ Here the editor is in data mode most of the time.
◦ The user can move the cursor on the screen and
specify command by clicking buttons or using
short-cut keys.
Types of Editors
 Line Editors
 Stream Editors
 Screen Editors
 Word Processors
 Structure Editors
Line Editor
 The scope of edit operation is limited to a
line of text.
 The advantage is their simplicity.
Stream Editor
 Views the entire text as a stream of
characters.
 They support character, line and context

oriented commands based on the current


editing context indicated by the position of
a text pointer.
 e.g. select text by positioning pointer or use

search commands.
Stream Editor
 Both line and steam editors typically
maintain multiple representation of text:
 the display form shows the text as a
sequence of lines.
 the internal form which is used to perform
the edit operation.
Screen Editors
 Use what – you – see – is – what – you – get
principle.
◦ Displays a screen full of text.
◦ The user can move cursor over the screen,
position it at the point to perform some editing.
◦ Thus the effect of operation can be seen on the
screen.
◦ Useful while formatting text.
◦ e.g. Notepad, WordPad.
Word Processor
 These are basically document editors with
additional features to produce well
formatted hard copy output.
◦ Essential features are:
 moving sections of text
 merging text
 searching and replacement of words.
 may also support spell – check and grammar
check.
 e.g. Microsoft Word
Structure Editor
 They incorporate an awareness of the
structure of a document.
 e.g. syntax directed editors used in

programming environments.
Design of Editor
 The fundamental functions in editing are:-
◦ Traveling
◦ Editing
◦ Viewing
◦ Display
Design of Editor
 Traveling: - movement of the editing
context to a new position within the text.
 Editing: -
 Viewing: - formatting the text in a manner

desired by the user.


◦ This is an abstract view, independent of the
physical characteristics of an I/O device.
Design of Editor
 Display: - The display component maps the
abstract view into the physical
characteristics of an I/O device.
◦ This determines where a particular view may
appear on the user’s screen.
◦ The separation of viewing and display functions
give rise to possibilities like multiple windows on
the same screen, concurrent edit operations
using the same display terminal etc.
Working of Editor
 For a given position of the text, the editing
and viewing filters operate on the internal
form of text to prepare the forms suitable for
editing and viewing.
 These forms are put in the editing and

viewing buffer respectively.


 The viewing and display manager makes

provision for appropriate display of this text.


Working of Editor
 When the position of cursor changes, the
filter operates on a new position of the text
to update the contents of the buffer.
 As editing is performed, the editing filter

reflects the changes into the internal form


and updates the contents of the viewing
buffer.
 The undo function is implemented by storing

a stack of previous views or by devising an


inverse for edit operation.
Software Testing and Debugging
 Software Testing: - Software Testing can be
stated as the process of validating and
verifying that a software program/
application/product:
◦ meets the business and technical requirements that
guided its design and development;
◦ works as expected; and
◦ can be implemented with the same characteristics.
Software Debugging
 It is a process of finding and reducing the
number of bugs, or defects, in a computer
program
 Important steps in testing and debugging are:
◦ Selection of test data for the program
◦ Analysis of test results to detect errors (if any).
◦ Debugging: localization and removal of errors.
Software Tools for Testing &
Debugging
 Test Data Generators: - help the user in
selecting test data for the program
 Automated Test Drivers: - help in regression

testing.
 Debug Monitor: - help in obtaining

information for localization of errors.


 Source Code Control System: -help to keep

track of modifications in the source code.


Regression Testing
 A type of software testing that seeks to
uncover software errors by partially retesting
a modified program.
 The intent of regression testing is to assure

that a bug fix has been successfully corrected


based on the error that was found, while
providing a general assurance that no other
errors were introduced in the process of
fixing the original problem.
Debug Monitors
 Debug monitors provide the following
facilities for dynamic debugging:-
◦ Setting breakpoints in the program.
◦ Initiating a debug conversation when control
eaches a breakpoint.
◦ Displaying values of variables.
◦ Assigning new values to variables.
◦ Testing under defined assertions and predicates
involving program variables.
Debug Monitors
 To enable the use of debug monitor, the user
must compile the program under the debug
option.
 The compiler inserts the following instruction

before each statement:-


 no-op <statement number>
◦ where statement number is a constant indicating
the serial number of statement in program.
Debug Monitors
 When a user gives a command to set a
breakpoint (say) at statement 100, the debug
monitor introduces an instruction
<SI-instrn> <Code>
in place of no-op 100.
 <SI-instrn> produces a interrupt with the

interrupt code <Code> and a debug


conversation is opened.
Debug Monitors
 The steps involved in dynamic debugging of a
program are: -
1. Compile the program under debug option.
2. Two files are produced- compiled code file
and debug information file.
3. Activate the debug monitor indicating the
name of the program to be debugged.
Debug Monitors
4. Specify debug requirements-
◦ a list of breakpoints and actions to be performed at breakpoints.
◦ The debug monitor instruments the program and builds a debug
table containing the pair ( statement number, debug action ).
5. The instrumented program gets control and executes up
to a breakpoint.
◦ A software interrupt is generated at <SI-instrn>.
◦ Control is given to debug monitor, which performs debug action
using debug table.
◦ User may now issue debug command or modify breakpoints and
actions.
◦ Control returns back to instrumented program.
6. Repeat steps 4 and 5 until the end of the debug session.
Testing Assertions
 A debug assertion is a relation between the
values of program variables.
 An assertion can be associated with a

program statement.
 Program execution continues if the assertion

is fulfilled, else a debug conversation is


opened.
 Use of debug assertions eliminates the need

to produce voluminous information for


debugging purposes.
Performance Tuning
 Program efficiency depends on two factors-
◦ the efficiency of the algorithm and
◦ the efficiency of its coding.
 An optimizing compiler can improve
efficiency of code but it cannot improve the
efficiency of the algorithm.
 Only a program designer can improve its

efficiency by rewriting the algorithm.


Performance Tuning
 A performance-tuning tool helps in
identifying those parts of a program, which
consume a considerable amount of execution
time.
 It is empirically observed that less than three

percent of program code generally accounts


for more than 50 percent of program
execution time.
Example
Name of Module Number of % of execution
Statements time
A 150 4.00
B 80 6.00
C 35 90.00

It is seen that module C, which is around 13


percent of the total program size, consumes
90% of the program execution time.
Profile Monitor
 A profile monitor is a software tool that
collects information regarding the execution
behavior of a program and presents it in a
form execution profile.
 e.g. execution time consumed by its

modules.
 Using this information, the programmer can

focus attention on the program sections


consuming a significant amount of execution
time.
Coroutines
 The word “coroutine” is composed of two
words: “co” (cooperative) and “routines” (funct
ions).
 Coroutines are functions that are cooperative.
How are functions non-cooperative?
 Usually, when a function calls a second
function, the first cannot continue until the
second function finishes and returns to where
it was called.

A(){
--- B(){
--- ---
B() ---
--- ---
--- }
}
Coroutines
 Coroutines are functions where the control is
transferred from one function to the other
function in a way that the exit point from
the first function and the entry point to
the second function are remembered –
without changing the context.
 Thus, each function remembers where it left

the execution and where it should resume


from.
Coroutines
 When A() calls B(), control is transferred to B()
until it gives the control back to A() using
resume A() statement.
 This way both functions can co-ordinate with

one another.

A(){
B(){
---
---
---
____
B()
Resume A()
---
---
Resume B()
Resume A()
---
--
Resume B()
}
}
Coroutine
int function(void) {
int i;
for (i = 0; i < 10; i++)
return i;
/* won't work, but wouldn't it be nice */
}
 We want have ten successive calls to the function

return the numbers 0 through 9.


 How can we implement this?
 Well, we can transfer control to an arbitrary point

in the function using a goto statement.


Coroutine: Example
int function(void) {
static int i, state = 0;
switch (state) {
case 0: goto LABEL0;
case 1: goto LABEL1;
}
LABEL0: /* start of function */
for (i = 0; i < 10; i++) {
state = 1; /* so we will come back to LABEL1 */
return i;
LABEL1:; /* resume control straight after the return */
}
}
#include<stdio.h>
#include<conio.h>
int fun() OUTPUT:
{ 0
static int i; 0
for(i=0;i<10;i++) 0
{ 0
return i; 0
} 0
} 0
void main() 0
{ 0
clrscr(); 0
int k;
for(int j=0;j<10;j++)
{
k=fun();
printf("%d\n", k);
}
getch();
}
#include<stdio.h>
#include<conio.h>
int fun()
OUTPUT:
{
static int i, state=0; 0
switch(state){ 1
case 0: goto LABEL0; 2
case 1: goto LABEL1; 3
} 4
LABEL0: 5
for(i=0;i<10;i++){ 6
state=1;
7
return i;
LABEL1:; 8
} 9
}
void main()
{
int k;
for(int j=0;j<10;j++)
{ For j =1
k=fun(); to 9
printf("%d\n", k);
}
getch();
}
Reentrant Programs
 A computer program or routine is described
as reentrant if the routine can be re-entered
while it is already running (i.e it can be safely
executed concurrently).
Conditions for Reentrant Program
 Must hold no static (or global) non-constant data.
 Must not return the address to static (or global)
non-constant data.
 Must work only on the data provided to it by the
caller.
 Must not rely on locks to singleton resources.
 Must not modify its own code (unless executing in
its own unique thread storage)
 Must not call non-reentrant computer programs
or routines.
Non-Reentrant Version of Program
// [The function depends on global variable i]
// Both fun1() and fun2() are not reentrant
// fun1() is NOT reentrant because it uses global variable i
// fun2() is NOT reentrant because it calls a non-reentrant function
  
int i;
  
int fun1()
{
    return i * 5;
}
  
int fun2()
{
   return fun1() * 5
}
Reentrant Version of Program
 In the below code, fun1 and fun2 both are reentrant functions.
 If an interrupt pauses execution of fun2 and shifts the control to

fun1.
 After fun1 completes, the control is again transferred to fun2 and

it reenters the execution phase.

int fun1(int i)
{
    return i * 5;
}
  
int fun2(int i)
{
   return fun1(i) * 5;
}

You might also like