Docsity

Progamming - Advanced Unix Programming - Lecture Slides, Slides of Computer Programming

Partial preview of the text

Download Progamming - Advanced Unix Programming - Lecture Slides and more Slides Computer Programming in PDF only on Docsity!

Advanced UNIX progamming

Week 1 Topics

  • Course outline and policies
  • UNIX programming environment
    • Editors
    • C compilers and debuggers
    • Makefiles
  • Review some features of C
    • Header files
    • Command line arguments
    • Utilities
  • Review some UNIX system calls
    • system, etc

UNIX programming environment

• Editors

• C compilers

• Debugger

• Makefiles

  • make

Editors

  • vi, pico, emacs , etc
  • What is good about emacs?
    • emacs is more than just an editor
    • You can compile and edit within emacs
    • If you know lisp , you can expand its functionality
    • Some useful commands to get started:
      • C-h t get tutorial
      • C-g cancel command
      • C-x C-c quit emacs
      • C-h help

Debugger

  • ddd, xxgdb, gdb
  • The code must be compiled with –g option.
  • The power of a debugger:
    • Finding the line that causes coredump.
    • See example:
      • Break point, show value, change value, step, next, continue, print
    • Very efficient in debugging sequential code
    • Not very effective in debugging concurrent code (multiple threads, multiple processes)
  • Good software development practice: You must have seen each line of your code execute in the debugger, at least once

Make

  • make [-f makefile][option] target
    • A tool to update files derived from other files
    • The default files for make are ./makefile, ./Makefile, ./s.makefile
    • Use the –f option to specify some other file
      • make –f makefile
    • The makefile has three components
      • Macros: define constants
      • Target rules: Specify how targets are made
      • Inference rules: Specify how targets can be made, implicitly. make will first check if a target rule applies, before using inference rules.