Professional Documents
Culture Documents
Development Tools: We Have Variety of FOSS Development Tools Development Tools
Development Tools: We Have Variety of FOSS Development Tools Development 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
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)
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.
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.
Tracers
Tools to trace function calls and system calls
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
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
patch return 0;
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
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
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
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
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.