Jan 29, 2016
GCC & Shell Script
GCC & Shell ScriptKAIST 11SPARCS 11Rodumani ( )GCC,GDB & Shell Script. [email protected]. 6. 27.1ContentsGCC & GDBGCC (GNU C Compiler)GDB (GNU Project Debugger)Shell & Shell ScriptShell?Shell Script
GCC,GDB & Shell Script. [email protected]. 6. 27.2GCCKAIST 11SPARCS 11Rodumani ( )GCC,GDB & Shell Script. [email protected]. 6. 27.3GCC & GDBGCCGNU Compiler Collection !C,C++,Objective-C, Java, etc C + GCC C++ + STL C++ Class Lib. GNU Project C & C++ CompilerGDBGNU Project Debugger GCC GCC,GDB & Shell Script. [email protected]. 6. 27.4GCC ! !Helloworld.c
$ gcc o Helloworld Helloworld.c
GCC,GDB & Shell Script. [email protected]. 6. 27.5GCC !$gcc o Helloworld Hellworld.c
$ls
$./Helloworld //
!
GCC,GDB & Shell Script. [email protected]. 6. 27.6GCC $ gcc [SourceFile1] [SourceFile2] a.out .$ gcc o [Export FileName] [SrFile1] [SrFile2] .. ! ( SourceFile .)$ gcc c [SourceFile] [SourceFile] (~.o) . $ gcc o [Export FileName] [Object File] .
GCC,GDB & Shell Script. [email protected]. 6. 27.7GCC $ gcc v o Helloworld Helloworld.c
.GCC,GDB & Shell Script. [email protected]. 6. 27.8GCC $ gcc --save-temps o Helloworld Helloworld.c (.i) (.s) !
..? ..? !GCC,GDB & Shell Script. [email protected]. 6. 27.9GCC
GCC,GDB & Shell Script. [email protected]. 6. 27.10Link , .
GCC,GDB & Shell Script. [email protected]. 6. 27.111. Object File .Relocatable object file.( Obj-File) , - .Executable object file.( Obj-File) , .Shared object file.( Obj-File) , - - .
GCC,GDB & Shell Script. [email protected]. 6. 27.122. Library .(Wikipedia) (letyoursoulbefree) . . . .( !) DLL , SO . /lib/ .printf(), scanf() GCC,GDB & Shell Script. [email protected]. 6. 27.13GCC
GCC,GDB & Shell Script. [email protected]. 6. 27.14gcc & ldld : . gcc . gcc ld ! gcc ld .GCC,GDB & Shell Script. [email protected]. 6. 27.15 Helloworld.c ! ! rodumani.c noname.c boolgom ,$ gcc o boolgom rodumani.c noname.c !
GCC,GDB & Shell Script. [email protected]. 6. 27.16 $ gcc o boolgom rodumani.c noname.c . $gcc c rodumani.c$gcc c noname.c$gcc -o boolgom rodumani.o noname.o ObjectFile !gcc !GCC,GDB & Shell Script. [email protected]. 6. 27.17?gcc o boolgom rodumani.c noname.c rodumani.c noname.c . . make Makefile .
GCC,GDB & Shell Script. [email protected]. 6. 27.18Makemake : . (MakeFile) . Timestamp .
GCC,GDB & Shell Script. [email protected]. 6. 27.19MakeFile ExampleCalculator :cal_main : main calculator.c : add,minus,multiple,divide calculator.h : add,minus,multiple,divide GCC,GDB & Shell Script. [email protected]. 6. 27.20MakeFile ExampleCalculator.h
GCC,GDB & Shell Script. [email protected]. 6. 27.21MakeFile Examplecalculator.c
GCC,GDB & Shell Script. [email protected]. 6. 27.22MakeFile Examplecal_main.c
GCC,GDB & Shell Script. [email protected]. 6. 27.23MakeFile Example$ gcc o calculator cal_main.c calculator.c
GCC,GDB & Shell Script. [email protected]. 6. 27.24MakeFile Example makefile Makefile .
GCC,GDB & Shell Script. [email protected]. 6. 27.25MakeFile Example$make calculator
make ?GCC,GDB & Shell Script. [email protected]. 6. 27.26MakeFile Example !cal_main.c
GCC,GDB & Shell Script. [email protected]. 6. 27.27MakeFile Example !$ make calculator
cal_main.c calculator .
GCC,GDB & Shell Script. [email protected]. 6. 27.28Makefile TAB . SPACE !# .
http://www.gnu.org/software/make/manual/make.html ,
GCC,GDB & Shell Script. [email protected]. 6. 27.29gcc -O .-O1 O3 . .GCC,GDB & Shell Script. [email protected]. 6. 27.30 -g . gdb . ! . g .-O() . g O .GCC,GDB & Shell Script. [email protected]. 6. 27.31 .$ gcc c objectfile ,$ ar r libstuff.a source1.o source2.o libstuff.a archive . $ ranlib libstuff.a !$ar rs libstuff.a source1.0 source2.o ranlib .GCC,GDB & Shell Script. [email protected]. 6. 27.32 .[libstuff].h extern [] . Ex) libstuff.h extern float suare(float);extern int factorial(int, int); ..
GCC,GDB & Shell Script. [email protected]. 6. 27.33 libstuff.h libstuff.a .. *.h *.a user include,lib .
$ gcc I../include L../lib o output a.c b.c lstuff-lstuff Linker ../lib libstuff.a . ex ) lmath libmath.a .
GCC,GDB & Shell Script. [email protected]. 6. 27.34GDBKAIST 11SPARCS 11Rodumani ( )GCC,GDB & Shell Script. [email protected]. 6. 27.35GDB -$ gdb [Filename] help : run : (, breakpoint .)quit : list : . (, . g .)
GCC,GDB & Shell Script. [email protected]. 6. 27.36GDB -breakpoint Break ( b)
$ run
GCC,GDB & Shell Script. [email protected]. 6. 27.37GDB -next & step .next . step .line 10 BreakPoint next, step ?
GCC,GDB & Shell Script. [email protected]. 6. 27.3838step
4 add main 13 .GCC,GDB & Shell Script. [email protected]. 6. 27.39next 13 .
GCC,GDB & Shell Script. [email protected]. 6. 27.40next & step next , step .GCC,GDB & Shell Script. [email protected]. 6. 27.41GDB -print .
GCC,GDB & Shell Script. [email protected]. 6. 27.42GDB ptype : , .
GCC,GDB & Shell Script. [email protected]. 6. 27.43GDB -info : info program : info locals : .(wing ide : stack data )
GCC,GDB & Shell Script. [email protected]. 6. 27.44GDB Core File : .$ gdb [filename] core core .Backtrace : call stack . frame n : call stack n stackframe .up : stackframe down : stackframe
GCC,GDB & Shell Script. [email protected]. 6. 27.45GDB - Process GDB attach .$gdb [name] (gdb) attach [pid]
detach attach .GCC,GDB & Shell Script. [email protected]. 6. 27.46Shell & Shell ScriptKAIST 11SPARCS 11Rodumani ( )GCC,GDB & Shell Script. [email protected]. 6. 27.47Shell Kernel bash, csh, ksh, sh, tchs,zsh.. .bash .
GCC,GDB & Shell Script. [email protected]. 6. 27.4848Shell !$ echo $SHELL ?$ chsh
.(+ . )
GCC,GDB & Shell Script. [email protected]. 6. 27.49Shell Ctrl+C : interrupt key ( )Ctrl+z : suspend key( )fg : foreground Ctrl+H : Backspace Ctrl+U: GCC,GDB & Shell Script. [email protected]. 6. 27.50 UNIX stdout ()stdin stderr () . > Redirect . GCC,GDB & Shell Script. [email protected]. 6. 27.51$ ls ../zzongaly > ~/zzongalyFiles
GCC,GDB & Shell Script. [email protected]. 6. 27.52 ?>>
GCC,GDB & Shell Script. [email protected]. 6. 27.53 > ? stdout . ?>& stdout,stderr . ?2> stderr . 1> stdout .
GCC,GDB & Shell Script. [email protected]. 6. 27.54 < : stdin File Redirection . . GCC,GDB & Shell Script. [email protected]. 6. 27.55 | (pipe)|(pipe) f1 | f2 f1 stdout f2 stdin . .(f1|f2|f3|..)nugu | grep
GCC,GDB & Shell Script. [email protected]. 6. 27.56Shell ScriptKAIST 11SPARCS 11Rodumani ( )GCC,GDB & Shell Script. [email protected]. 6. 27.57 ?UNIX . ex) ls /bin ! .$ echo $PATH
export PATH=$PATH:~/bin ~/bin
GCC,GDB & Shell Script. [email protected]. 6. 27.58 (bash Shell )$ echo [str]: Str . $ grep [str] [file] : file str .$ file [filename] : filename filetype .$ read var : var .$ tee [filename] : file $ basename [file] : $ dirname file : $ pwd : $ sed : http://blog.naver.com/juner84?Redirect=Log&logNo=100129369041GCC,GDB & Shell Script. [email protected]. 6. 27.59Hello World!$vi hello #! /bin/shecho hello world!
# .
GCC,GDB & Shell Script. [email protected]. 6. 27.60Hello World!!!linux . $ chmod +x hello // $ ./hello
GCC,GDB & Shell Script. [email protected]. 6. 27.61Shell Script -eq : -ne : -ge : -gt : -le : -lt : [ 124 le 125 ] ?
GCC,GDB & Shell Script. [email protected]. 6. 27.62Shell Script ! y=0let y=y+1 y=0y=$(($y+1))
GCC,GDB & Shell Script. [email protected]. 6. 27.63Shell Script name=RodumaniFullName=Rodumani, Jeong= .
GCC,GDB & Shell Script. [email protected]. 6. 27.64Shell Script num=2echo this is the $numnd var echo this is the ${num}nd var
GCC,GDB & Shell Script. [email protected]. 6. 27.65Shell Scriptread []
GCC,GDB & Shell Script. [email protected]. 6. 27.66Shell Scriptselect :
GCC,GDB & Shell Script. [email protected]. 6. 27.67Shell Scriptif list1; then commands //list1 elif list2; then commands //list2 elsecommands fi //if
list 0 .0 .(return 0)
GCC,GDB & Shell Script. [email protected]. 6. 27.68Shell Script[ -f "file" ] : file .[ -x "/bin/ls" ] : /bin/ls .[ -n "$var" ] : $var .[ "$a" = "$b" ] : $a $b !
GCC,GDB & Shell Script. [email protected]. 6. 27.69Shell Scriptex ) test
# ! Shell .
GCC,GDB & Shell Script. [email protected]. 6. 27.70Shell Script
&& : || :
GCC,GDB & Shell Script. [email protected]. 6. 27.71Shell Script case
case : esac $1 : . > /dev/null . .$? : .
GCC,GDB & Shell Script. [email protected]. 6. 27.72Shell Script While
if
while [list]do(expressions)done
GCC,GDB & Shell Script. [email protected]. 6. 27.73Shell Script ! for !
python for .for i in * : . $i .GCC,GDB & Shell Script. [email protected]. 6. 27.74Shell Script ! for !
python for .for i in * : . $i .
GCC,GDB & Shell Script. [email protected]. 6. 27.75Shell Script !funcname(){(expressions)}
funcname .
GCC,GDB & Shell Script. [email protected]. 6. 27.76Shell Script !-move
GCC,GDB & Shell Script. [email protected]. 6. 27.77Shell Scriptdeclare a arr !arr[1]=2 {} .echo ${arr[0]} GCC,GDB & Shell Script. [email protected]. 6. 27.78! n .
11. 6. 27.GCC,GDB & Shell Script. [email protected]
Referenceshttp://www.lws.pe.kr/11 - UNIX Shellhttp://blog.naver.com/juner84?Redirect=Log&logNo=100129369041 -sed http://tldp.org/LDP/abs/html/ -bash ShellScripthttp://wiki.kldp.org/HOWTO/html/Adv-Bash-Scr-HOWTO/ - GCC,GDB & Shell Script. [email protected]. 6. 27.80!GCC,GDB & Shell Script. [email protected]. 6. 27.81