GCC

GCC

# CbC on GCC 銇仱銇勩仸

# 銈ゃ兂銈广儓銉笺儷鏂规硶

  • 銇俱仛銇疢ercurial銉儩銈搞儓銉亱銈 GCC 銈掑彇寰
1
% hg clone ssh://one@www.cr.ie.u-ryukyu.ac.jp/hg/CbC/CbC_devel (淇濆瓨鍏堛傛寚瀹氥仐銇亜鍫村悎./CbC_devel銇仾銈)
  • 娆°伀銈ゃ兂銈广儓銉笺儷鍏堛伄銉囥偅銉偗銉堛儶銈掍綔銈嬨傘仱銇勩仹銇仢銇撱伀绉诲嫊銆 (!! 蹇呫仛CbC_devel銇銇綔銇c仸銇紒 !!)
1
2
% mkdir (銇勩倱銇欍仺銉笺倠銇欍倠銇ㄣ亾)
% cd (鈫戙仹銇ゃ亸銇c仧銇ㄣ亾)
  • OSX Maverics浠ラ檷銇牬鍚堛伅 GMP, MPFR, MPC銇屽繀瑕併俢onfigure瀹熻鍓嶃伀銈ゃ兂銈广儓銉笺儷銇欍倠蹇呰銇屻亗銈嬨

    • gcc4.9.0銇с伅GMP 4.2浠ヤ笂, MPFR 2.4.0浠ヤ笂 MPC 0.8.0浠ヤ笂銇岃姹傘仌銈屻倠銆
    • homebrew銇с偆銉炽偣銉堛兗銉仚銈嬪牬鍚堛併仢銈屻仦銈屻伄formula鍚嶃伅gmp,mpfr,libmpc銇с仚銆
  • configure銈掑疅琛屻仚銈嬨傘亾銇檪銆併偆銉炽偣銉堛兗銉厛銇儑銈c儸銈儓銉伀绉诲嫊娓堛伩銇с亗銈嬨亾銇ㄣ倰纰鸿獚銇欍倠銇撱仺銆

1
2
3
% (GCC銇ㄣ仯銇︺亶銇熷牬鎵)/configure CFLAGS="-g3 -O0" --prefix=$PWD \
    --disable-nls --disable-bootstrap --enable-languages=c \
    --enable-checking=tree,rtl,assert,types
* 鍚勩偑銉椼偡銉с兂銇仱銇勩仸
    * -g3~

gdb銇с伄macro銇睍闁嬨倰鍙兘銇仚銈嬨 * -O0~ 鏈閬╁寲銇偒銉冦儓銆 * –prefix=dir~ 銈ゃ兂銈广儓銉笺儷鍏堛伄銉囥偅銉偗銉堛儶鎸囧畾銆 * –disable-nls~ gettext銇甽10n銈抩ff銇 * –disable-bootstrap~ 閫氬父GCC銇3鍥炪儞銉儔銇曘倢銈嬨亴銇撱倢銈1鍥炪仩銇戙伀闄愬畾銆 * –enable-languages 浣跨敤銇欍倠瑷瑾炪伄鎸囧畾銆 * –enable-checking~ 銉囥儛銉冦偘鐢ㄣ伄鎸囧畾銆俠rowse_tree,debug_rtx,assert銇宱n銇仾銈嬨

  • make銇欍倠
1
% make && make install
  • 銈ゃ兂銈广儓銉笺儷銇曘倢銇熴亱銉併偋銉冦偗銇欍倠銆
1
% (銈ゃ兂銈广儓銉笺儷銇椼仧鍫存墍)/bin/gcc --version

姝c仐銇忋偆銉炽偣銉堛兗銉仌銈屻仸銇勩倢銇般儛銉笺偢銉с兂銇岃銈屻倠銇仛銆傝銈屻仧銈夐仼褰撱仾銈炽兗銉夈仹姝c仐銇忓嫊銇忋亱纰鸿獚銇欍倠銇撱仺銆

# gdb銇у嫊銇嬨仚鍫村悎銇墜闋

  • 銇俱仛鍕曘亱銇欍仺銇嶃伄寮曟暟銈掑緱銈
1
% (CbC_GCC) (source file) -v |& grep cc1

銇撱倢銇у疅闅涖伀瀹熻銇曘倢銈嬨偝銉炪兂銉夈仺寮曟暟銇屽彇銈屻倠銇仹寮曟暟銇犮亼銈炽償銉笺仚銈嬨

  • gdb銈掑嫊銇嬨仚
1
% gdb --args (銇曘仯銇嶃偝銉斻兗銇椼仧銈傘伄銈掕布銈)

銇撱倢銇с亞銇斻亸銇仛銆傛銇椼亸鍕曘亱銇亜鍫村悎銇痬ake銇屻仭銈冦倱銇ㄣ仹銇嶃仸銇勩倠銇嬨乧onfigure銇偑銉椼偡銉с兂銈掗枔閬曘亪銇︺亜銇亜銇嬨仾銇┿倰纰鸿獚銇欍倠銆

# lldb銇у嫊銇嬨仚鍫村悎銇墜闋

瀹熻鏅傘伄寮曟暟銇竴绶掋仾銇仹gdb銇у嫊銇嬨仚鍫村悎銇仺銇撹銇︺

  • lldb銈掑嫊銇嬨仚
1
% lldb (gcc銇儜銈)
  • 瀹熻
1
(lldb) r (銈炽償銉笺仐銇熴倓銇)

# gdb銇仭銈囥仯銇ㄣ仐銇熴儐銈儖銉冦偗

# 浣曞害銈傚紩銇c亱銇嬨倠銈裤偆銉椼伄銉栥儸銉笺偗銉濄偆銉炽儓銇渶寰屻伄涓鍥炪亴瑕嬨仧銇勩仺銇

  • 銇俱仛銈炽兂銉嗐儖銉ャ兗銇嬨亼銇俱亸銈
1
(gdb) c 9999
  • 銇娿仢銈夈亸銇9999鍥炪倐銈炽兂銉嗐儖銉ャ兗銇涖仛銇疅琛屻亴绲備簡銇欍倠銆傘亾銇撱仹break point銇儏鍫便倰瑕嬨倠
1
(gdb) info b

瑕嬨仧銇勩仺銇撱亴浣曞洖姝€伨銇c仧銇亱銈掔⒑瑾嶃仚銈嬨俛lready hit 銆 銇ㄣ亱銇嬨亱銈屻仸銇勩倠銇仛銆

  • 鏈寰屻伄涓鍥炪仹姝€伨銈嬨倛銇嗐伀浠曞悜銇戙倠 閫氬父瀹熻銇椼仧銈夈仌銇c亶瑕嬨仧鏁板瓧鍒哹reak point銈掗氶亷銇欍倠銇ㄣ亜銇嗐亾銇ㄣ仾銇仹銆併仢銇洖鏁-1鍥炲垎鐒¤銇欍倠銈堛亞銇仚銈嬨
1
(gdb) ignore (break point銇暘鍙) (銇曘仯銇嶃伄鏁板瓧-1)

銇撱倢銇ф銇俱倠銇仛銆

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy