1 / 19

Chapter 13 Programming Tools

Chapter 13 Programming Tools. Contents. C compiler Debugging tool lint, dbx System call Make utility Source code management SCCS. C 프로그램의 컴파일(1). $ cc tabs.c -c : object file 생성 - o : output file 생성 - g : debugging 정보 첨가 $ cc calc.c -lm ; math library

thelma
Télécharger la présentation

Chapter 13 Programming Tools

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 13Programming Tools

  2. Contents • C compiler • Debugging tool • lint, dbx • System call • Make utility • Source code management • SCCS

  3. C 프로그램의 컴파일(1) $ cc tabs.c -c : object file 생성 -o : output file 생성 -g : debugging 정보 첨가 $ cc calc.c -lm ; math library $ cc -O ledger.c acctspay.c acctsrec.c ; optimizer $ a.out < mymemo ; call a.out $ mv a.out tabs ; save a.out file

  4. C 프로그램의 컴파일(2) • 실행 파일의 지정 $ cc -o accounting ledger.c acctspay.c acctsrec.c $ accounting • 목적 파일의 생성 $ cc -c ledger.c acctspay.c acctsrec.c $ ls acctspay.c acctsrec.c ledger.c acctspay.o acctsrec.o ledger.o

  5. C 프로그램 디버깅 도구(1) • lint • 프로그램 에러 및 문제점의 발견. 예를 들어 • 변수의 값이 지정되기 전에 사용된 경우. • 정의는 되었으나 사용되지 않은 인자. • 리턴되지 않은 리턴값을 사용하는 function의 발견. • Symbolic Debuggers • 종류: adb, sdb, dbx, gdb • 프로그램 수행을 감시 및 제어하는 기능 포함. • 프로그램 수행 단계를 추적하며 변수의 값을 조사. • 에러 발생시의 프로그램 상태 분석 (core파일 이용). • 디버거를 사용하기 위해 컴파일시 -g 옵션을 사용. % cc -g tabs.c -o tabs

  6. C 프로그램 디버깅 도구(2) • dbx 명령어 • list 현재 위치에서 처음 10줄을 보여 줌. • where 수행중인 function의 이름과 주소를 제시. • whatis 특정 변수에 대한 선언문 제시. • whereis 변수의 위치 제시. • stop 수행중인 프로세스를 중단. • run 현재 프로그램의 실행. • next, step 다음 명령어 수행 • print 변수의 값을 검사. • cont 계속 수행하도록 지시. • quit 디버거 세션의 종결. • help 도움말. 명령어의 요약.

  7. System Calls(1) • 유닉스 커널의 기본적 기능 • 프로세스의 제어 • 파일시스템 관리 • 주변장치의 구동. • 시스템 호출 (system calls)은 라이브러리 루틴의 호출과는 달리 사용자 프로그램에서 "직접" 운영체제의 커널로 하여금 어떤 작업을 수행하도록 지시. 보통 한 개의 라이브러리 루틴의 수행을 위해 여러 개의 시스템 호출을 필요로 함.

  8. System Calls(2) • 프로세스 제어를 위한 시스템 호출 • wait(), exit(), nice(), kill() • 파일 시스템의 접근을 위한 시스템 호출 • stat(), access(), creat(), open(), read(), write(), close(), unlink(), chmod(), chown() • 주변장치의 접근을 위한 시스템 호출 • 보통의 파일을 접근하기 위한 방법과 같은 방법을 사용 하여, /dev 디렉토리에 있는 파일에 읽고 쓰는 명령을 수행함으로써 가능.

  9. Make 유틸리티(1) • 한 개의 프로그램이 여러 개의 원시 파일과 헤더 파일을 가진 경우, 하나의 파일을 변경하면 이에 종속된 관계에 있는 다른 모든 파일들이 다시 컴파일되어야 한다. make 유틸리티는 재컴파일하는 과정을 자동화. • makefile의 양식 target: prerequisite-list # target/dependency line <TAB> construction-commands # command line

  10. Make 유틸리티(2) • touch • 특정 파일의 변경 시간을 변화시킨다. 모든 파일이 up to date 일 때, 특정 파일을 touch 후 make를 실행하면, 이에 종속된 파일들이 모두 다시 컴파일됨. • Macros • makefile안에서 매크로를 생성하고 사용할 수 있다. • Built-in Macro • CC : c compiler를 지정하는 macro • $@ : 현재 target의 이름 • $* : 현재 target에서 확장자를 제외한 이름

  11. Makefile의 예 form: size.o length.o cc -o form size.o length.o size.o size.c form.h cc -c size.c length.o: length.c form.h cc -c length.c form.h: num.h table.h cat num.h table.h > form.h num.h tab.h form.h size.c length.c size.o length.o form

  12. Macro 사용 예 CFLAGS = -O FILES = in.c out.c ratio.c process.c tally.c OBJECTS = in.o out.o ratio.o process.o tally.o HEADERS = names.h copanies.h conventions.h report: $(OBJECTS) cc -o report $(OBJECTS) ratio.o: $(HEADERS) process.o: $(HEADERS) tally.o: $(HEADERS) print: pr $(FILES) $(HEADERS) | lp

  13. Source Code Management • 대규모의 소프트웨어를 여러 사람이 장기간에 걸쳐 개발할 때에, source code와 document의 버전 관리를 위한 시스템 • source file의 개발과정을 추적하고, 하나의 파일이 동시에 여러 사람에 의해서 변경되는 것을 방지 • Source Code Control System (SCCS) • Revision Control System (RCS)

  14. SCCS(1) • delta : a set of changes to a source code • version number • release.level.branch.sequence-number • initially 1.1 2.1.1.1 branch 1.1 1.2 1.3 2.1 2.2

  15. SCCS(2) • Putting files under SCCS control • Making an SCCS directory $ mkdir SCCS • Creating an SCCS file $ sccs create filename • filename is moved to ,filename • a history file s.filename is created in SCCS

  16. SCCS(3) • Checking out files • for reading $ sccs get filename // 특정 파일 $ sccs get SCCS // SCCS의 모든 파일 • 파일이 현재 디렉토리로 복사됨 • for editing $ sccs get -e filename $ sccs get -e SCCS • early version $ sccs get -r version-number • cancelling an editing session $ sccs unedit filename

  17. SCCS(4) • Checking in files $ sccs delta filename • check-in 한 사용자인지를 확인 • comment 요구 • 변경된 내용을 저장 • 현재 디렉토리의 복사본 삭제 • sccs get -e filename으로 현재 edit 중인 파일은 sccs delta filename으로 파일을 저장하기 전에는 edit할 수 없음

  18. SCCS(5) • Getting information about files • Whick files are being edited? $ sccs info $ sccs info -u username • What is the lastest versions of the each file? $ sccs what filenames • What is the history of this fils? $ sccs prt filename

  19. SCCS(6) • Creating new releases $ sccs get -e -r2 tmp.c 1.3 new delta 2.1 7 lines • Creating new branch $ sccs get -e -r1.3 filename 1.3 new delta 1.3.1.1 7lines

More Related