CptS 360 (System Programming) Unit 3: Development Tools Bob Lewis - - PowerPoint PPT Presentation

cpts 360 system programming unit 3 development tools
SMART_READER_LITE
LIVE PREVIEW

CptS 360 (System Programming) Unit 3: Development Tools Bob Lewis - - PowerPoint PPT Presentation

Unit 3: Development Tools CptS 360 (System Programming) Unit 3: Development Tools Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2020 Bob Lewis WSU CptS 360 (Spring, 2020) Unit 3: Development Tools


slide-1
SLIDE 1

Unit 3: Development Tools

CptS 360 (System Programming) Unit 3: Development Tools

Bob Lewis

School of Engineering and Applied Sciences Washington State University

Spring, 2020

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-2
SLIDE 2

Unit 3: Development Tools

Motivation

◮ Using UNIX-style development tools lets you port your code

to more platforms.

◮ Most of these tools are console based: GUIs aren’t very useful

when editing over ssh(1) (say).

◮ It is not couth to write system programs with an IDE.

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-3
SLIDE 3

Unit 3: Development Tools

Reference

◮ Stevens & Rago, Ch. 3

aside: You can find find all code from the book in /cslab/lib/courses/cpts360/stevens_rago_apue

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-4
SLIDE 4

Unit 3: Development Tools

Getting Help

Several approached to getting help:

◮ man pages ◮ info(1) ◮ grep(1) ◮ /usr/share/doc ◮ /usr/include ◮ google.com (of course)

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-5
SLIDE 5

Unit 3: Development Tools

man(1) pages

Traditional UNIX manual page sections are: section contains 1 commands 2 system calls (most POSIX API pages) 3 general-purpose libraries (e.g. math, stdio, dbm) 4 devices 5 file formats 6 games 7 conventions and miscellany 8 system administration To get help on these classifications, use “$ man n intro”.

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-6
SLIDE 6

Unit 3: Development Tools

man Command Invocations

◮ $ man n entry

gets information on entry , optionally restricting the search to section n

◮ $ whatis entry

gets a one-line description of entry

◮ $ apropos keyword (or $ man -k keyword )

gets one-line description of one or more pages whose description includes keyword

◮ man:entry or man:entry (section )

in browser (Firefox, at least)

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-7
SLIDE 7

Unit 3: Development Tools

info

◮ emacs-like hypertext help browser. ◮ part of GNU ◮ Run “$ info” by itself to start at the top level with a list of

(all) commands.

◮ Run “$ info command ” for information on command . ◮ especially useful for compilers and make

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-8
SLIDE 8

Unit 3: Development Tools

Installing Documentation

On Linux systems, if you want documentation on foo, look for the package foo-doc.

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-9
SLIDE 9

Unit 3: Development Tools

grep

I’m not kidding, grep(1) is a very useful tool, if you know what to grep for... Use $ grep pat /usr/include/*.h $ grep pat /usr/include/*/*.h to find a #define or function prototype. Use $ zgrep -l pat /usr/share/man/mann /*.gz to find some remembered phrase or keyword in a man page you may have seen before. Other help source: /usr/share/doc/*

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-10
SLIDE 10

Unit 3: Development Tools

make(1)

◮ We’ll touch on the basics. ◮ Good for more than just compiling. ◮ It helps to draw a dependency diagram.

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-11
SLIDE 11

Unit 3: Development Tools

Makefile Syntax

◮ Comments

◮ Begin with “#” to end-of-line.

◮ Targets

◮ May be real files or nonexistent goals (e.g. clean).

◮ Rules

◮ Need to use Tab. ◮ Each line is distinct shell command, unless you use “;\”.

◮ Suffix rules:

◮ may be built-in or user-defined Bob Lewis WSU CptS 360 (Spring, 2020)

slide-12
SLIDE 12

Unit 3: Development Tools

make Macros

◮ syntax:

name =value

◮ environment variables imported by default ◮ various macro tricks:

◮ old-style substitution:

OBJS=$(SRCS:.c=.o)

◮ nested macros:

CFLAGS=$(CFLAGS_$(ARCH))

◮ remember: D-R-Y

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-13
SLIDE 13

Unit 3: Development Tools

Commonly-used Macros

Most systems have these automatically defined: CC the C compiler CFLAGS C compiler options CPP the C++ compiler CPPFLAGS C++ compiler options LD the loader (usually = $(CC)) LDFLAGS loader options MAKE make itself, with arguments These can be overridden on the command line.

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-14
SLIDE 14

Unit 3: Development Tools

make Command Line Options

  • k

keep going as long as possible

  • n

echo the required operations

  • f filename

use an alternate to makefile or Makefile.

  • j [# of jobs]

(try this on a multiprocessor system!)

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-15
SLIDE 15

Unit 3: Development Tools

Commonly-Used Targets

◮ default (first target) ◮ install ◮ clean ◮ immaculate

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-16
SLIDE 16

Unit 3: Development Tools

makedepend(1)

◮ analyzes source files to create dependencies of its own. ◮ handles nested includes ◮ appends dependencies to the makefile (e.g. Makefile) ◮ “transitive closure on #include”

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-17
SLIDE 17

Unit 3: Development Tools

tar(1)

◮ syntax

$ tar [options ] file ...

◮ where options are

◮ -c

create new archive (a.k.a. “tarball”)

◮ -v

be verbose

◮ -f filename

use filename for new or old tarball name

◮ -x

extract output

◮ -z

compress/uncompress tarball with gzip(1)/gunzip(1)

◮ -t

list the contents of a tarball

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-18
SLIDE 18

Unit 3: Development Tools

Older Revisioning Systems

◮ SCCS (Source Code Control System) (obs.) ◮ CVS (Concurrent Version System)

◮ for multiple developers ◮ was superseded by...

◮ RCS (Revision Control System)

◮ now mostly superseded by... Bob Lewis WSU CptS 360 (Spring, 2020)

slide-19
SLIDE 19

Unit 3: Development Tools

Contemporary Revisioning Systems

◮ SVN (Subversion)

◮ manages whole directory trees of files ◮ uses database for central repository ◮ allows easy renaming of files and directories

◮ Git

◮ devised by Linus Torvalds for the Linux kernel (he formerly

used BitKeeper)

◮ project ↔ repository ◮ repositories often hosted on GitHub

(https://www.github.com)

◮ each user gets their own copy of the whole repository ◮ see https://xkcd.com/1296 and https://xkcd.com/1597

◮ Mercurial

◮ don’t know much about this one

(see man pages)

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-20
SLIDE 20

Unit 3: Development Tools

And Then There’s...

◮ The C Preprocessor:

#if 1 // experimental code #else // code that you’re replacing, but want to keep around #endif

◮ The new Script (q.v.)

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-21
SLIDE 21

Unit 3: Development Tools

Document Processing

System programmers produce documentation. Popular choices:

◮ nroff(1), groff(1), and

troff(1)

◮ easy to figure out ◮ outdated for regular

documents, but...

◮ still used for man pages

◮ Microsoft Word

◮ if you absolutely must

◮ OpenOffice

◮ WYSIWYG, mostly ◮ OpenDoc format

(.od[bgmpst]) easy to analyze (zipped XML archive) and generate

◮ LaTeX

◮ a pain to learn, but... ◮ worth the effort, esp. for

professional publications

◮ best book (IMHO):

Kopka & Daley’s Guide to LaTeX

◮ ReST (ReStructured Text)

◮ intuitive ◮ uses readable ASCII files ◮ generates HTML, LaTeX,

XML, slides from the same input

◮ can insert LaTeX if

needed

Bob Lewis WSU CptS 360 (Spring, 2020)

slide-22
SLIDE 22

Unit 3: Development Tools

Text Editors

System programmers should know at least one of these UNIX editors:

◮ emacs(1)

◮ “East Coast” (MIT) origin ◮ also a development environment ◮ programmable in Lisp ◮ windowed or console

(“emacs -nw”) mode

◮ vim(1)

◮ “West Coast” (UCB) origin (as

vi)

◮ most widely-used by system

programmers

◮ programmable in Python ◮ console mode only

Or maybe

◮ jed(1) or jove(1)

◮ low-overhead

versions of emacs(1)

◮ console mode only

◮ gedit(1)

◮ Linux (Gnome)

  • nly

◮ GUI mode only Bob Lewis WSU CptS 360 (Spring, 2020)

slide-23
SLIDE 23

Unit 3: Development Tools

IDEs: Integrated Development Environments

If you really need one:

◮ Eclipse

◮ runs just about

everywhere

◮ Visual Studio

◮ runs just about

everywhere

◮ kdevelop(1)

◮ Linux (KDE) only

◮ kate(1)

◮ Linux only

◮ XCode

◮ MacOS only

◮ Qt Creator

◮ C++ only ◮ runs just about

everywhere

◮ uses Qt4 GUI framework

(with Qt Designer)

◮ Code::Blocks

◮ runs just about

everywhere

◮ uses wxWidgets GUI

framework

Most of these support multiple languages/file formats. Any others you’d like to plug?

Bob Lewis WSU CptS 360 (Spring, 2020)