Old Chapter 10: Programming Tools A Developer’s Candy Store.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

Utilizing the GDB debugger to analyze programs Background and application.
SYSTEM PROGRAMMING & SYSTEM ADMINISTRATION
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
1 © John Urrutia. All rights reserved. Programming.
Makefiles Software Tools. Slide 2 make Overview The make utility helps… n Keep track of which modules of a program have been updated n To ensure that.
Understanding Makefiles COMP 2400, Fall 2008 Prof. Chris GauthierDickey.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Unix Continuum of Tools Do something once: use the command line Do something many times: –Use an alias –Use a shell script Do something that is complex.
Guide To UNIX Using Linux Third Edition
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Week 4 - Friday.  What did we talk about last time?  Some extra systems programming stuff  Scope.
F13 Forensic tool analysis Dr. John P. Abraham Professor UTPA.
Debugging, Build and Version Control Rudra Dutta CSC Spring 2007, Section 001.
Programming Tools gcc make utility Open Source code Static and Shared Libraries gdb Memory debugging tools.
리눅스 : Lecture 5 UNIX 유틸리티 : text editor, compilation (make), …
August 7, 2003Serguei A. Mokhov, 1 gcc Tutorial COMP 444/5201 Revision 1.1 Date: January 25, 2004.
Compiling & Debugging Quick tutorial. What is gcc? Gcc is the GNU Project C compiler A command-line program Gcc takes C source files as input Outputs.
Developing C/C++ applications with the Eclipse CDT David Gallardo.
Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice:
Adv. UNIX: large/131 Advanced UNIX v Objectives of these slides: –learn how to write/manage large programs consisting of multiple files, which.
Programming With C.
Scons Writing Solid Code Overview What is scons? scons Basics Other cools scons stuff Resources.
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Chapter 0 Overview. Why you are here? Where will you go? What is this course for?
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Debugging and Profiling With some help from Software Carpentry resources.
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Chapter 1 Introduction. Chapter 1 -- Introduction2  Def: Compiler --  a program that translates a program written in a language like Pascal, C, PL/I,
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
Build Tools 1. Building a program for a large project is usually managed by a build tool that controls the various steps involved. These steps may include:
How to configure, build and install Trilinos November 2, :30-9:30 a.m. Jim Willenbring.
Week 4 - Friday.  What did we talk about last time?  Some extra systems programming stuff  Scope.
Advanced UNIX progamming Fall 2002 Instructor: Ashok Srinivasan Lecture 2 Class web site:
GNU Make Computer Organization II 1 © McQuain What is make ? make is a system utility for managing the build process (compilation/linking/etc).
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Lecture 6 UNIX Development Tools. Software Development Tools.
Multiple file project management & Makefile
Evolution and History of Programming Languages
UMBC CMSC 104 – Section 01, Fall 2016
Compilation and Debugging
Compilation and Debugging
Chapter 2: System Structures
Computer System and Programming
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Editor, Compiler, Linker, Debugger, Makefiles
Introduction to C Topics Compilation Using the gcc Compiler
Makefile Tutorial CIS5027 Prof: Dr. Shu-Ching Chen
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Hector Cen Fall 2017
Chapter 11 Introduction to Programming in C
Makefiles and the make utility
Chapter 11 Introduction to Programming in C
Getting Started: Developing Code with Cloud9
CMPSC 60: Week 4 Discussion
Appendix F C Programming Environment on UNIX Systems
Chapter 1 Introduction.
Makefiles and the make utility
Debugging.
Makefiles, GDB, Valgrind
ICS103 Programming in C 1: Overview of Computers And Programming
SPL – PS1 Introduction to C++.
What is make? make is a system utility for managing the build process (compilation/linking/etc). There are various versions of make; these notes discuss.
Presentation transcript:

Old Chapter 10: Programming Tools A Developer’s Candy Store

In this chapter … Overview Shared Libraries make System calls CVS

UNIX/Linux and Programming Since the OS and most of the tools are written in C, continued development necessitated a thorough set of C development tools Over time, many other languages found their way to UNIX/Linux, making it an excellent development platform Machine Independent + Portable + Standards Based = Great for Development

C Programming Most prevalent C compiler available is the GNU C Compiler, gcc gcc has progressed to support many other languages including C++, java, cobol, fortran Has many options and complex syntax, but most simply it compiles and links

C Programming This is not a programming course, so we’re not interested in how to program We’ll focus on the utilities and the process of building apps We’ll focus on C, but these processes extend to most other compiled languages Scripting languages are different – interpreted (ex. perl, python, shell scripts)

Compiling and Linking Preprocessor Compiler Assembler Linker

Preprocessor Directives in C/C++ files #include include_file –Inserts code files from other locations –Can be files you’ve written, or standard library files Ex: –#include “myHeader.h” –#include

Compiler Changes high level language code into assembly code Here code is optimized by the compiler (there are varying levels of optimization) The better the compiler, the neater and more efficient this code is

Assembler Assembly code is then turned into machine- readable object code Each code file compiled and assembled creates a file with a.o extension These are binary files – not readable by human eye

Linker The last step is to combine all the object code into one executable Combines with system libraries with common function calls – system specific Executables are in Executable and Linking Format (ELF) – standardized

Shared Libraries Most systems contain a collection of standard shared libraries Contain standard defined functions, written for the specific OS and machine architecture Most often found in /lib, /usr/lib If you’ve got a 64-bit system – also have /lib64 and /usr/lib64 Also /usr/X11R6/lib for X Windows apps

Shared Libraries, con’t Two types of shared libraries Dynamic – not linked when compiled, called upon execution Static – linked when compiled, any changes to library forces recompilation of program To see what libraries a program uses, use ldd

make When you change a source file that is referenced by other files, you have to recompile your program If your program has a great deal of source files, it can be hard to remember what is dependent on what Enter make

make con’t make will only recompile files that it needs to Checks modification dates to see if any dependent files need to be recompiled Uses a file called a Makefile to keep track of the dependencies Saves time and is convenient

Makefile Format: target: prerequisite-list construction-commands First line lists files that are needed to create target – if one changes, we need to recompile Second line MUST start with a tab, contains the command to compile/link/etc

Makefile example form: size.o length.o gcc –o form size.o length.o size.o: size.c form.h gcc –c size.c length.o: length.c form.h gcc –c length.c form.h: num.h table.h cat num.h table.h > form.h clean: rm *.o *core*

make con’t When you run make without arguments, it will attempt to build the first target in the file So the end result (complete program) should be the first line You can force make to build any target by issuing it as an argument –Ex: make clean

Advanced Makefiles More complex Makefiles contain macros, which are like variables Referenced via $(macro) CC – compiler CFLAGS – C compiler flags CPPFLAGS – C++ compiler flags COMPILE.c – translates to: $(CC) –c $(CFLAGS) $(CPPFLAGS)

Advanced Makefiles con’t LDFLAGS – linker flags LINK.c – translates to: $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) FILES – list of source files HEADERS – list of header files OBJECTS – list of object files

Debugging First level of debugging is simply putting breaks and print statements in your code Can be time consuming To help prevent problems tell compiler to show warnings about common mistakes gcc –Wall will show all warnings

Debugging con’t Bigger problems require the use of a symbolic debugger Allows execution to be monitored and controlled Allows setting of break points and display of variable contents Lets you trace through memory dumps to see where run time errors occur

gdb GNU gdb symbolic debugger Compile programs with –g to allow debugging This adds debugging information to program, a list of symbols that relate to variables and functions Also allows you to associate system calls in executable to lines in source file

gdb con’t gdb is very robust and complex, lots of commands and options Other graphic front ends are available, but at the command line your best bet is probably going to be gdb

System Calls Kernel is responsible for process control, filesystem management, and operation of peripheral devices We have access to these kernel abilities via system calls The system works directly on our behalf Depending on the operation you may need elevated privileges

Important system calls fork() – create new process exec() – runs program in memory getpid() – get a process ID kill() – terminates a process open() – open a file read() – read an open file write() – write to an open file

CVS: Source Code Management When multiple people are working on a project, source code management becomes an issue Need something to keep track of revisions, and make sure users don’t step on one another Enter CVS – Concurrent Versions System –Developed from Revision Control System (RCS)

CVS Allows users to check out source code, modify it, the check it back in and integrate their changes When you check out files, a copy is made for you to edit Originals are kept in data store You then can commit your changes to the store

CVS con’t Syntax: cvs [cvs-options] command [options] Commands include: –checkout – get copy of source –commit – submit changes –update – check for changes made by others –add – add new file to project –delete – remove file from project

CVS con’t A thorough treatment of CVS is beyond the scope of this class Unless you are a programmer, you probably won’t come into contact with CVS If you are, you will learn to appreciate it when you work on group projects Other CVS alternatives: Subversion, BitKeeper, Git