Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

(11) Development Tools

We have variety of Development tools


FOSS development tools Compiler
Developers make a new Debugger
tool for themselves Analyzer, profiler
Plenty of tools for Source code
distributed development management
Based on FOSS Maintaining
development via the
compatibility
Internet
Localization
GUI-based tools are
increasing, in addition to Documentation
conventional CUI-based IDE based on GUI
tools Bug tracking tools

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 292
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Compiler
Process of building software
Compile
Source code -> object code
Link
Set of object code -> executable code
File describing the process of building software
Makefile

gcc, make, ld
De fact standard tools for FOSS development

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 293
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
GCC
gcc (the GNU Compiler Collection)
Development started in 1984 by Richard Stallman

Originally stood for GNU C Compiler


Now stands for GNU Compiler Collection
Includes compilers and libraries for C, C++, Objective-
C, Fortran, Java and Ada
C++ compiler g++
Fortran compiler g77
Java compiler gcj

Features
Widely used for commercial and non-commercial
operating systems
Can also be used as cross-compiler

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 294
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Make
To help manage build PACKAGE = hogehoge
SRCS = $(PACKAGE).c
process OBJS = $(SRCS:.c=.o)

FILES = README Makefile $(HEADS) $(SRCS)


VER = `date +%Y%m%d`

Marking of dependency CC = gcc


CFLAGS = -g -O2 -Wall $(DEBUG)
and processing method CPPFLAGS = -I.

Rules (compile, link, .SUFFIXES:


.SUFFIXES: .o .c .cc .f .p
installation, etc.) are all: $(PACKAGE)
described in makefile $(PACKAGE): $(OBJS)
$(LD) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
Autotools convenient for
$(OBJS): $(HEADS) Makefile
automatic generation of
rules .c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
.cc.o:
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
Build optimization .f.o:
$(FC) $(FFLAGS) -c $< -o $@
.p.o:
Looks up time of last $(PC) $(PFLAGS) $(CPPFLAGS) -c $< -o $@

update and only clean:


$(RM) $(PACKAGE) $(OBJS)
executes minimum build $(RM) core gmon.out *~ #*#

needed Makefile example


An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 295
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
The GNU Linker Ld
Invoked at end of build process
Link multiple object files and library or archive files
Relocate data
Tie up symbol references # ld -o a.out /usr/lib/crt1.o \
/usr/lib/crti.o hello.o -lc

Static linking
Combines all object files and libraries from build into one
program
Runs as standalone file but produces large file size

Dynamic linking
Only designates name of libraries
Dynamically links to libraries during execution
Small file size

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 296
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debugging Tools
Debugging
Process of fixing bugs in coding
Basically check for:
Are values for variables as expected?
Is conditional branch correct?
Possible to insert code to output values at various
points, but labor-intensive
Use of debugging tools

Debugging tools
Debuggers, profilers, tracers, etc.

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 297
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debuggers
GDB (The GNU Project
Debugger)
CUI debugger
Features: Set
breakpoints, step-by-
step execution, etc.

DDD (GNU Data


Display Debugger)
GUI front-end for GDB
and other CUI
debuggers

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 298
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debugging Case Study (Part 1)

gscanbus
Tool for acquiring and
displaying data from
connected IEEE 1394
device

Problem (bug?)
Camera icon displayed
as question mark
Camera works
properly
Device type not
recognized

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 299
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debugging Example (Part 2)
Dig through the source code
File names
Icon.h and icon.c files are suspect
icon.h
InitIcons() and chooseIcon() functions called from
outside
ChooseIcon() is suspect; chooseIcon() function is for
initialization
ChooseIcon() in icon.c file
Icon appears to be switched by rom_info>node_type
void chooseIcon(Rom_info *rom_info, GdkBitmap **xpm_node,
GdkBitmap **xpm_node_mask, char **label) {

switch(rom_info->node_type) {
case NODE_TYPE_CONF_CAM:
case NODE_TYPE_AVC:
*xpm_node = xpm_dvcr;
*xpm_node_mask = xpm_dvcr_mask;
*label = "AV/C Device";
break;
case NODE_TYPE_SBP2:

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 300
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debugging Example (Part 3)
Debugging process
Rom_info.h and rom_info.c files exist
Use grep to search location where value of node_type is set
Get_node_type is suspect
Probable solution: Change code to return
NODE_TYPE_CONF_CAM when camera you are using
(unit_sw_version=0x101) is connected
int get_node_type(Rom_info *rom_info) {
char cpu;
if (rom_info->unit_spec_id == 0xA02D) {
if (rom_info->unit_sw_version == 0x100) {
return NODE_TYPE_CONF_CAM;
} else if (rom_info->unit_sw_version == 0x10000 ||
rom_info->unit_sw_version == 0x10001) {
return NODE_TYPE_AVC;
}
} else if (rom_info->unit_spec_id == 0x609E &&
rom_info->unit_sw_version == 0x10483) {
return NODE_TYPE_SBP2;
} else {
resolv_guid(rom_info->guid_hi, rom_info->guid_lo, &cpu);
if (cpu) return NODE_TYPE_CPU;
}
return NODE_TYPE_UNKNOWN;
}

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 301
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Debugging Example (Part 4)
Result
Icon is correctly displayed
Unknown if patch is correct method to fix problem
Fix was possible because of viewable source code
Patch may be incorporated into next version by
feeding back to community

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 302
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Analysis Tools
Analyze how program runs dynamically and/or check
source code statically
To help bugfix, quality improvement and speed up, etc.

Profilers / memory testing tools


Tools to get statistical information on CPU and memory

Tracers
Tools to trace function calls and system calls

Source code analyzing tools


ctags, etags, etc.
Create tag information by reviewing source code
To jump directly to the definition of classes and functions
cflow
To show the invocation tree between functions and functions
An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 303
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Profilers
Profiling
Acquire status of program execution at fixed intervals
Show process and thread status
Also acquire hardware information such as cache hit
ratio

CPU profilers
Measure CPU utilization rates

Memory profilers
Measure memory usage, detect memory leaks

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 304
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
GNU Gprof
Utility for measuring and displaying operating
status of program
Number of calls for each function, processing time, etc.
Shows bottlenecks to consider for acceleration
Using gprof
Specify -pg option when compiling
Execute program normally
# gprof executable-file gmon.out
Sample output
func1 takes up zero time
func2 has room for acceleration
% cumulative self self total
time seconds seconds calls ms/call ms/call name
100.00 0.40 0.40 80 5.00 5.00 func2
0.00 0.40 0.00 3 0.00 133.33 func1

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 305
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Memory Testing
MemProf
Profiler for memory
usage
Test for memory leaks

MEMWATCH
CUI memory testing
tool for C
Detection of memory
leaks, data corruption,
etc.

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 306
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Tracers
Traces function calls and system calls
CTrace
Traces function calls

Ltrace
Traces function calls for shared libraries

Strace for GNU/Linux and ktrace for *BSD


Traces system calls

__libc_start_main(0x080664e0, 1, 0xbffff654, 0x08106ab0, 0x08106af8 <unfinished ...>


setlocale(6, "") = "ja_JP.eucJP"
bindtextdomain("sylpheed", "/usr/local/share/locale") = "/usr/local/share/locale"
bind_textdomain_codeset(0x08106c02, 0x08106ba0, 0xbffff608, 0x08106aca, 0x40608968) = 0x08142870
textdomain("sylpheed") = "sylpheed"
g_get_current_dir(0x08106c02, 0x08142870, 0xbffff608, 0x08106aca, 0x40608968 <unfinished ...>
malloc(4097) = 0x08142890
¿Àø

Sample output from ltrace


An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 307
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Source Code Management
Manages source code itself, the changing history
and so on
Essential tool for team development
To make sure when, who, where and how modified?
Reverting back to older revision and/or making branch
versions are possible

Inevitability of source code management tool


RCS, CVS, subversions and other similar tools were
developed in association with changes of development
styles from independent development to team and
distributed development

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 308
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Diff, Patch
Patchfile (shown at right)
Shows differences between files

Diff and patch *** hello.c


--- nice.c
***************
2005-06-17 17:46:46.000000000 +0900
2005-06-17 17:47:04.000000000 +0900

*** 3,5 ****


diff !
int main(void){
printf("Hello World!\n");
return 0;
Tool to generate differences --- 3,5 ----
int main(void){
! printf("Nice to meet you!\n");

patch return 0;

Tool for applying differences to create revised file

Basic features of RCS, CVS and Subversion


Used by someone other than source code administrator
to create bug fixes or add features
Redundant to send entire modified file
Send only differences to administrator
Practice dates back to when transmission speeds were
slow, making it necessary to reduce data volume
An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 309
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Version Control (SCCS, RCS, CVS,
Subversion)
SCCS and RCS Commands in CVS and
Version control for single Subversion
files checkout
CVS Creates working copies from
Creates working copies repository
on client based on commit
contents of server Saves to repository
(repository) update
Enables concurrent Updates working copies
editing of same file by add/delete
multiple persons
Adds and deletes files
Subversion diff
Addresses downsides of Shows differences between files
CVS (inability to move or status
delete directories, etc.)
Shows status of files
An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 310
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Maintaining Compatibility
Differences in platforms
Differences in operating systems
GNU/Linux, *BSD, Unix, Windows, etc.
Differences in libraries
OpenGL/Mesa, Xaw, Motif/lesstif, etc.
Differences in versions
Specifications can change due to version upgrades
Differences in paths

Need arrangement for absorbing these


differences
Labor-intensive to implement manually
Difficult to support platforms not possessed by
developers

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 311
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
GNU Autotools
Need more than just source code
Need tools to compile and execute same program on
different platforms (OS or environment)
Improve portability and maintainability

Tools such as autoconf, automake, etc.


Autoconf: Used to generate configure scripts
Automake: Used to generate makefiles

Minor format differences depending on version


of Autotools used
Contradicts the very purpose of Autotools?

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 312
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Localization
English is the universal language of FOSS
development
Many developers and users lack English skills
Desire for different language versions so that many
others can use software
Localization
Enables display of character strings such as menus
and dialogs in different languages
Developers do not need to be versed in each language
Translators do not need to understand source code
Localization tools do not support
internationalization
Multilingual handling, line breaks, etc.
See I18n, M17n and L10n
An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 313
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
GNU gettext
Implements localization without major changes to
existing source code
Prepare a message catalog
Surround the internationalized character string with N_()
Ex. Change char *str = "Hi"; to char *str = N_("Hi");
Surround variables that call on the string with _()
Ex. Change printf("%s\n", str); to printf("% s\n", _(str));
Example of message catalog
Replaces “Hi” (msgid) with “Guten Tag” (msgstr)

msgid "Hi"
msgstr "Guten Tag"

msgid "Add"
msgstr "H inzufuegen"

msgid "Edit"
msgstr "Editieren"

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 314
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Documentation
Importance of documentation
Expand user base
User manual
Expand developer base
Helpful for hacking
Above all, documentation helps the original developer
Tendency to forget the purpose of old code

Writing documents perceived as bothersome


Documentation tools
Automatically generate documents from source code
Can also graph class relationships, etc.
Not designed to identify purpose of program

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 315
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Doxygen, Javadoc, Doc++
Doxygen/Doc++
Supports Java, C, C++,
PHP, etc.
Output in HTML or LaTeX
formats

JavaDoc
Comes standard with JDK

Sample output from Doxygen

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 316
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Integrated Development
Environments
Unix and GNU programming centers on
command line tools
Convenience of many tools, but tools are difficult to
master
Difficult to program outside of IDE framework
Demand for GUI-based IDEs as developer base grows
Simplifies migration from Windows development
environments

Leading IDEs
Eclipse with multi-language support
Anjuta for GNOME applications
KDevelop for KDE applications

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 317
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Eclipse
IDE written in Java
Runs on variety of operating systems

High extensibility
Billed as “universal tool platform”
Plug-in architecture to strengthen various features
Plug-ins for Java, C, C++, PHP, Ruby and COBOL

History of Eclipse
IBM Visual Age released as FOSS
IBM sells Eclipse-based IBM Rational Software
Development Platform

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 318
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Bug Reporting Tools
Also called bug tracking systems
Dedicated database for bug tracking
Well-known tools: Bugzilla, Debian bug tracking system (BTS),
GNU GNATS

Centralized management of bugs


As software grows in scale, management tools such as e-mail
and spreadsheets become inadequate for grasping overall
picture
Stores information such as bug reporter, reproduction method,
bug correction assignee, correction history, correction method,
degree of importance, test status, etc.

Bug life cycle


(1) bug report, (2) assignment of person to correct bug, (3)
correction of bug, (4) testing and (5) close of bug report
Bugs can sometimes recur after bug correction or during testing
An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 319
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.
Bugzilla
Developed by
Mozilla.org to track
bugs for Mozilla
browser
Powerful bug tracking
and search features
Used for projects such
as XFree86, Apache,
Samba, GNOME, etc.

An Introduction to Free/Open-Source Software Copyright © 2005,2006, Center of the International Cooperation for Computerization (CICC) All Rights Reserved.
Copyright © 2005,2006, Mitsubishi Research Institute, Inc. All Rights Reserved. 320
Copyright © 2008, University of Puerto Rico at Mayaguez. All Rights Reserved.

You might also like