I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

Similar documents
I117 II I117 PROGRAMMING PRACTICE II 2 SOFTWARE DEVELOPMENT ENV. 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara yasu

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

I117 II I117 PROGRAMMING PRACTICE II DEBUG Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

I117 II I117 PROGRAMMING PRACTICE II HASH Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental data structures /06/14(Tue) / Memory Management

I117 II I117 PROGRAMMING PRACTICE II SCRIPT LANGUAGE 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara

r07.dvi

ohp07.dvi

2 2 3 dbxtool dbx (GUI) dbxtool dbx C++ Oracle Solaris Studio 12.2 examples/debugger/debug_tutorial 1. cp -r /opt/solstudio12.2/examples/de

Introduction Purpose The course describes library configuration and usage in the High Performance Embedded Workshop (HEW), which speeds development of

untitled

debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology

Introduction Purpose This training module provides an overview of debugging features in H8S Simulator. Objectives Understand how to use the Simulator.

2) TA Hercules CAA 5 [6], [7] CAA BOSS [8] 2. C II C. ( 1 ) C. ( 2 ). ( 3 ) 100. ( 4 ) () HTML NFS Hercules ( )

,,,,., C Java,,.,,.,., ,,.,, i

Introduction Purpose This training course describes the configuration and session features of the High-performance Embedded Workshop (HEW), a key tool

25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble

r08.dvi

IPSJ SIG Technical Report Vol.2014-EIP-63 No /2/21 1,a) Wi-Fi Probe Request MAC MAC Probe Request MAC A dynamic ads control based on tra

ohp08.dvi

joho09.ppt

RR-US470 (RQCA1588).indd

ohp03.dvi

Agenda Intro & history LLVM overview Demo Pros & Cons LLVM Intermediate Language LLVM tools

Microsoft Word - Win-Outlook.docx


elemmay09.pub

I I / 68

2

2

double float

橡Pro PDF

fx-9860G Manager PLUS_J


r03.dvi

LC304_manual.ai


国際恋愛で避けるべき7つの失敗と解決策

4.1 % 7.5 %

. IDE JIVE[1][] Eclipse Java ( 1) Java Platform Debugger Architecture [5] 3. Eclipse GUI JIVE 3.1 Eclipse ( ) 1 JIVE Java [3] IDE c 016 Information Pr

日本語教育紀要 7/pdf用 表紙

2

2 3

main

C言語によるアルゴリズムとデータ構造



1st-session key

I 2 tutimura/ I 2 p.1/??





きずなプロジェクト-表紙.indd

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

*Ł\”ƒ‚ä(DCH800)

28 Docker Design and Implementation of Program Evaluation System Using Docker Virtualized Environment

20 Method for Recognizing Expression Considering Fuzzy Based on Optical Flow

\615L\625\761\621\745\615\750\617\743\623\6075\614\616\615\606.PS

<95DB8C9288E397C389C88A E696E6462>

soturon.dvi

25 D Effects of viewpoints of head mounted wearable 3D display on human task performance

2 3

untitled

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) A: Shiritori if python3 a, b, c = input().split() if a[len(a)-1] == b[0] and b[len(

I117 プログラミング演習II

2


19_22_26R9000操作編ブック.indb

161 J 1 J 1997 FC 1998 J J J J J2 J1 J2 J1 J2 J1 J J1 J1 J J 2011 FIFA 2012 J 40 56

untitled

Microsoft Word - j201drills27.doc

2


2

listings-ext

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology


<96BC8FCC96A290DD92E82D37>

NINJAL Research Papers No.8

memo ii

A5 PDF.pwd

kubostat2015e p.2 how to specify Poisson regression model, a GLM GLM how to specify model, a GLM GLM logistic probability distribution Poisson distrib

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

¥×¥í¥°¥é¥ß¥ó¥°±é½¬I Exercise on Programming I [1zh] ` `%%%`#`&12_`__~~~ alse

Z7000操作編_本文.indb

36

untitled

untitled

1 Code Generation Part I Chapter 8 (1 st ed. Ch.9) COP5621 Compiler Construction Copyright Robert van Engelen, Florida State University,

Study on Application of the cos a Method to Neutron Stress Measurement Toshihiko SASAKI*3 and Yukio HIROSE Department of Materials Science and Enginee


( ) [1] [4] ( ) 2. [5] [6] Piano Tutor[7] [1], [2], [8], [9] Radiobaton[10] Two Finger Piano[11] Coloring-in Piano[12] ism[13] MIDI MIDI 1 Fig. 1 Syst

Page 1 of 6 B (The World of Mathematics) November 20, 2006 Final Exam 2006 Division: ID#: Name: 1. p, q, r (Let p, q, r are propositions. ) (10pts) (a

Quickstart Guide 3rd Edition

206“ƒŁ\”ƒ-fl_“H„¤‰ZŁñ

cpp1.dvi

32C2100操作編ブック.indb

syspro-0405.ppt

Transcription:

I117 II I117 PROGRAMMING PRACTICE II SOFTWARE DEVELOPMENT ENV. 1 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara yasu@jaist.ac.jp

/ SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming 2. 2011/06/09(Thu) / Fundamental data structures 3. 2011/06/14(Tue) / Memory Management 1 4. 2011/06/16(Thu) / Memory Management 2 5. 2011/06/21(Tue) / Debugging 6. 2011/06/23(Thu) / Software Development Env. 1 7. 2011/06/28(Tue) / Software Development Env. 2 8. 2011/06/30(Thu) / Data Structure : Tree 9. 2011/07/05(Tue) / Data Structure: Hash 10. 2011/07/07(Thu) / Understanding Programs 1 11. 2011/07/12(Tue) / Understanding Programs 2 12. 2011/07/14(Thu) / Script Language 1 13. 2011/07/19(Tue) / Script Language 2 14. 2011/07/21(Thu) / Other Languages 15. 2011/07/26(Tue) / Examination

/ FINAL REPORT free topic : decide topic by 7/5(Tue) report us of the topic by e-mail: i117report@jaist.ac.jp / Sound file converter / web crawler (CalDAV) calendar program new shell, editor, window manager rsync encrypt/decrypt, rsync markov-chain program choose good theme TAask TA and me The final report must have deep consideration

/ TODAY'S INDEX / dubugging / debugging method printf / printf debug / debugger / memory checker

/ DEBUGGING METHOD

PRINTF / PRINTF DEBUG / print inside states of the program to debug Cprintf / use printf printf / called "printf debug" even in languages other than C / pros / simple / can be used when debugger cannot be used / cons printf / printf function can affect results printf / situation such as it works with printf and doesn't without printf / happens in multithread programs and device drivers printf / you have to (be able to) compile the program / compilation takes time

/ A PROGRAM WITH BUG / the function has some bugs int fibonacci(int n) { int num1 = 0; int num2 = 1; int tmp; int i; for (i = 0; i < n; i++) { tmp = num2; num1 = num2; num2 += tmp; } The definition of fibonacci numbers: F 0 = 0, F 1 = 1 F n+2 = F n + F n+1 } return num1;

PRINTS EACH STEPS printf / an example with printf int fibonacci(int n) { int num1 = 0; int num2 = 1; int tmp; int i; for (i = 0; i < n; i++) { tmp = num2; printf( tmp = %d\n, tmp); num1 = num2; printf( num1 = %d\n, num1); } printf( num2 = %d + %d\n, num2, tmp); num2 += tmp; printf( num2 = %d\n\n, num2); } return num1;

PRINTF / OUTPUTS fibonacci(1): results of fibonacci (1) tmp = 1 /* F0 = 0 (incorrect) */ num1 = 1 /* F1 = 1 (correct) */ num2 = 1 + 1 /* F2 = F0 + F1 = 0 + 1 (incorrect)*/ num2 = 2 /* F2 = 1 (incorrect) */ 2 / two parts seem incorrect for (i = 0; i < n; i++) { tmp = num1; /* tmp = num2; / bug fixed */ num1 = num2; num2 += tmp; }

/ USE OF PREPROCESSOR printf / cumbersome to remove printfs / must remove all... / sometimes necessary to revive the printf DEBUGprintf / use of DEBUG macro int fibonacci(int n) { int num1 = 0, num2 = 1, tmp, i; for (i = 0; i < n; i++) { #ifdef DEBUG printf( num1 = %d, num2 = %d\n, num1, num2); #endif tmp = num2, num1 = num2, num2 += tmp; } return num1; }

DEBUG / WITH "DEBUG" #define DEBUG /define in program #define DEBUG int fibonacci(int n) {... } -DDEBUG / define in compilation $ ls fib.c $ cc DDEBUG fib.c / see the difference $ cc DDEBUG E fib.c $ cc E fib.c

/ USE OF MACRO, PREPROCESSOR DEBUGprintf / define a macro that runs printf only when "DEBUG" is defined. #ifdef DEBUG #define D(X) printf X #else #define D(X) #endif / usage D(( num1 = %d\n, num1)); /* (())*/

/ WHEN LOTS OF LOGS ARE PRINTED... tee / output both to the display and to a file $./a.out tee output.txt / only to a file $./a.out > output.txt

/ DEBUGGER

DBX / DEBUG USING DBX dbx / what is dbx Unix / source level debugger Sun / attached in Sun compiler C, C++, Java, Fortran 77, Fortran 99 / what can be done / step runs for each line / trace of function call / set a break point / display and set a variable / display a register / display contents of memory etc...

DBX -g / with g option, debugging info is attached in the executable file $ cc g sample.c / run the debugger with the executable $ dbx./a.out a.out ld.so.1 libc.so.1 / display help (dbx) help... (dbx) help stop... # # stop

/ EXAMPLE fib.c and fibmain.c fib.c 1 int fibonacci(int n) 2 { 3 int num1 = 0, num2 = 1; 4 int tmp, i; 5 6 for (i = 0; i < n; i++) 7 { 8 tmp = num1; 9 num1 = num2; 10 num2 += tmp; 11 } 12 13 return num1; 14 } fibmain.c 1 #include <stdio.h> 2 3 extern int fibonacci(int n); 4 5 void main(void) 6 { 7 int f10 = fibonacci(10); 8 printf( F(10) = %d\n, 9 f10); 10 }

NUM1, NUM2 / DISPLAY VARIABLE dbx / compile, start dbx $ cc g -c fib.c $ cc g fib.o fibmain.c $ dbx a.out fib.c9 set a break point (dbx) stop at fib.c:9 (2) stop at fib.c :9 / run the program on the debugger (dbx) run... stopped in fibonacci : 9 fib.c 9 num1 = num2; num1, num2 / print variables (dbx) print num1, num2 num1 = 0 num2 = 1

/ STEP RUNS AND ASSIGNMENT 1 execute for a single line (dbx) next stoopped in fibonacci : 6 fib.c 6 for (i = 0; i < n; i++) (dbx) print num1, num2 num1 = 1 num2 = 1 1next step / what's the difference in "next" and "step"? num1 0 / assign a value (dbx) assign num1 = 0 (dbx) print num1 num1 = 0

/ PRINT CALL STACK AND CHANGE FRAME / display call stack and print a register called "program counter" (dbx) where =>[1] fibonacci(n = 10), 6 fib.c [2] main(), 7 fibmain.c (dbx) print fx $pc $pc = 0x10c84 main / go back to main() (dbx) frame 2 :main 7 int f10 = fibonacci(10) (dbx) where [1] fibonacci(n = 10), 6 fib.c =>[2] main(), 7 fibmain.c (dbx) print fx $pc $pc = 0x10cd8

STACK / HOW STACK WORKS PUSH POP SPARC : SP x86 : SP(16bit)/ESP(32bit)/RSP(64bit) SPARC: FP x86 : BP(16bit)/EBP(32bit)/RBP(64bit) high-address

/ CONTINUE AND DELETE BREAKPOINTS / continue the run (dbx) cont stoopped in fibonacci : 9 fib.c 9 num1 = num2; / delete the break points and continue (dbx) delete all (dbx) cont F(10) = 55 1

DBX / EXITING DBX / exit (dbx) exit

/ PRACTICE

DBX / LET'S USE DBX dbx / let's use dbx / debbuger / memory checker