SlideShare a Scribd company logo
1 of 25
Download to read offline
Trace 程式碼之皮 
Wen Liao
Disclaimer 
投影片資料為作者整理資料及個人意見,沒有經 
過嚴謹確認,請讀者自行斟酌
目標 
分享在Linux 下使用編輯器 trace 程式碼的技巧
測試環境: OS
測試環境: 編輯器
動機 
● 菜鳥的痛苦,看不懂別人的程式碼。 
● 花時間時間在找尋 
○ 這變數誰在用的? 
○ 呼叫的這個函數到在那邊實作? 
○ 這個函數是誰在呼叫的? 
○ 我找到的變數到底是在哪個函數內? 
○ ...
編輯器也是有效率高低的 
● 找出現在游標的變數會被誰呼叫? 
○ 菜鳥式:以gedit為例 
■ 游標移動到Search,按一下滑鼠左鍵 
■ 選Find,從鍵盤輸入要找的變數名稱 
■ 游標移動到搜尋按鈕,看要往上找還是往下找 
○ 非菜鳥式:以gedit為例 
■ 複製變數,按ctrl + f,貼上 
■ ctrl + g往下找, shift + crtl + g往上找 
○ vim:單鍵搞定 
■ * 自動幫你往下找,不用複製貼上變數名稱 
■ # 自動幫你往上找,不用複製貼上變數名稱
我就喜歡用gedit慢慢 
找,咬我啊
等你遇到一個檔案上萬行, 
單一函數幾百行的時候就知 
道厲害!
為什麼要用編輯器的進階功能? 
● 搜尋和定位是一種干擾 
○ 你必須停下目前的思緒,找出下一筆資料才能夠繼續 
思考。 
● 這些功能能夠讓搜尋和定位這兩件事時間最 
小化,切換程式思維的時間就會更少。
說明 
● 本投影片只是vgod的文章:給程式設計師的 
Vim入門圖解說明的註腳
範例程式,九九乘法表
快速找下一個相同字串 
①游標在這邊,按* 
_ 
_ ②游標移動了
快速找上一個相同字串 
②游標移動了 
①游標在這邊,按# 
_ 
_
馬上知道自己在哪個函數中 
①游標在這邊,按[[ 
②游標移動了 
_
直接跳到下一個函數 
①游標在這邊,按]] 
②游標移動了 
_
跳到目前block開頭 
②游標移動了 
_ 
①游標在這邊,按[{
跳到目前block結尾 
①游標在這邊,按]} 
②游標移動了 
_
成對跳躍 (1) 
按%切換 
_ _
成對跳躍 (2) 
按%切換 
_ 
_
成對跳躍%還可以用在 
● [ ] 
● #ifdef …. #endif
切回上次游標位置 
①游標在這邊,按[[ 
②游標移動了 
_ 
③按``切回上次游標位置
結論 
● 善用編輯器功能,可以減少trace code的時 
間。 
● 上面的使用方式當專案程式碼大到某個程度 
效益就不大了。 
● 這些工具只是減少trace code的搜尋定位時 
間,理解程式碼拼湊並理解完全和工具無關。 
而這些才是真正trace code的肉、骨、髓。
延伸作業 
● 安裝ctags和cscope,嘗試操作。 
● 學習grep和簡單的POSIX regular expression
參考資料 
● 給程式設計師的Vim入門圖解說明 - vgod 
○ http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/

More Related Content

What's hot

Waits in Selenium | Selenium Wait Commands | Edureka
Waits in Selenium | Selenium Wait Commands | EdurekaWaits in Selenium | Selenium Wait Commands | Edureka
Waits in Selenium | Selenium Wait Commands | EdurekaEdureka!
 
End to end test automation with cypress
End to end test automation with cypressEnd to end test automation with cypress
End to end test automation with cypressPankajSingh184960
 
Test Case Design
Test Case DesignTest Case Design
Test Case Designacatalin
 
Test automation project estimation calculator
Test automation project estimation calculatorTest automation project estimation calculator
Test automation project estimation calculatorssuser2e8d4b
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assuranceRajeev Sharan
 
Special value testing
Special value testingSpecial value testing
Special value testingBapi Das
 
Key Test Design Techniques
Key Test Design TechniquesKey Test Design Techniques
Key Test Design TechniquesTechWell
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Deepak Singhvi
 
тестирование по стратегии черного ящика
тестирование по стратегии черного ящикатестирование по стратегии черного ящика
тестирование по стратегии черного ящикаvyacheslavmaslov
 
원티드 발표자료 나수현 2018
원티드 발표자료 나수현 2018원티드 발표자료 나수현 2018
원티드 발표자료 나수현 2018Soohyun Na
 
Subjective evaluation answer ppt
Subjective evaluation answer pptSubjective evaluation answer ppt
Subjective evaluation answer pptMrunal Pagnis
 
Policy Gradient Theorem
Policy Gradient TheoremPolicy Gradient Theorem
Policy Gradient TheoremAshwin Rao
 
Software testing and quality assurance
Software testing and quality assuranceSoftware testing and quality assurance
Software testing and quality assuranceTOPS Technologies
 
로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법Jeongsang Baek
 
Overpsss API / Overpass-Turbo
Overpsss API / Overpass-TurboOverpsss API / Overpass-Turbo
Overpsss API / Overpass-TurboYu-Chin Tsai
 

What's hot (20)

Waits in Selenium | Selenium Wait Commands | Edureka
Waits in Selenium | Selenium Wait Commands | EdurekaWaits in Selenium | Selenium Wait Commands | Edureka
Waits in Selenium | Selenium Wait Commands | Edureka
 
End to end test automation with cypress
End to end test automation with cypressEnd to end test automation with cypress
End to end test automation with cypress
 
Test Case Design
Test Case DesignTest Case Design
Test Case Design
 
Test automation project estimation calculator
Test automation project estimation calculatorTest automation project estimation calculator
Test automation project estimation calculator
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assurance
 
Special value testing
Special value testingSpecial value testing
Special value testing
 
QA Process Overview
QA Process OverviewQA Process Overview
QA Process Overview
 
Key Test Design Techniques
Key Test Design TechniquesKey Test Design Techniques
Key Test Design Techniques
 
ISTQB foundation level - day 2
ISTQB foundation level - day 2ISTQB foundation level - day 2
ISTQB foundation level - day 2
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
 
Test case writing
Test case writingTest case writing
Test case writing
 
тестирование по стратегии черного ящика
тестирование по стратегии черного ящикатестирование по стратегии черного ящика
тестирование по стратегии черного ящика
 
Testing Metrics
Testing MetricsTesting Metrics
Testing Metrics
 
원티드 발표자료 나수현 2018
원티드 발표자료 나수현 2018원티드 발표자료 나수현 2018
원티드 발표자료 나수현 2018
 
Subjective evaluation answer ppt
Subjective evaluation answer pptSubjective evaluation answer ppt
Subjective evaluation answer ppt
 
The Docker Ecosystem
The Docker EcosystemThe Docker Ecosystem
The Docker Ecosystem
 
Policy Gradient Theorem
Policy Gradient TheoremPolicy Gradient Theorem
Policy Gradient Theorem
 
Software testing and quality assurance
Software testing and quality assuranceSoftware testing and quality assurance
Software testing and quality assurance
 
로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법로그 기깔나게 잘 디자인하는 법
로그 기깔나게 잘 디자인하는 법
 
Overpsss API / Overpass-Turbo
Overpsss API / Overpass-TurboOverpsss API / Overpass-Turbo
Overpsss API / Overpass-Turbo
 

Viewers also liked

GNU ld的linker script簡介
GNU ld的linker script簡介GNU ld的linker script簡介
GNU ld的linker script簡介Wen Liao
 
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code Meetup
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code MeetupDebug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code Meetup
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code MeetupJian-Hong Pan
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tipsViller Hsiao
 
開放街圖 自助旅行的好幫手
開放街圖   自助旅行的好幫手開放街圖   自助旅行的好幫手
開放街圖 自助旅行的好幫手Wen Liao
 
GNU AS簡介
GNU AS簡介GNU AS簡介
GNU AS簡介Wen Liao
 
UPnP 1.0 簡介
UPnP 1.0 簡介UPnP 1.0 簡介
UPnP 1.0 簡介Wen Liao
 
trace code tool 以及人月神話
trace code tool 以及人月神話trace code tool 以及人月神話
trace code tool 以及人月神話Yi-Hsiang Huang
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryWen Liao
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)William Lee
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataAlket Cecaj
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcationNir Cohen
 
Hello world在那邊?背景說明
Hello world在那邊?背景說明Hello world在那邊?背景說明
Hello world在那邊?背景說明Wen Liao
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationWilliam Lee
 
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...資彥 解
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web PageWilliam Lee
 
從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理Wen Liao
 

Viewers also liked (20)

GNU ld的linker script簡介
GNU ld的linker script簡介GNU ld的linker script簡介
GNU ld的linker script簡介
 
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code Meetup
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code MeetupDebug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code Meetup
Debug C/C++ Programs More Comfortably @ 2014.12.14 Trace Code Meetup
 
Trace kernel code tips
Trace kernel code tipsTrace kernel code tips
Trace kernel code tips
 
開放街圖 自助旅行的好幫手
開放街圖   自助旅行的好幫手開放街圖   自助旅行的好幫手
開放街圖 自助旅行的好幫手
 
GNU AS簡介
GNU AS簡介GNU AS簡介
GNU AS簡介
 
from Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Worksfrom Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Works
 
UPnP 1.0 簡介
UPnP 1.0 簡介UPnP 1.0 簡介
UPnP 1.0 簡介
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
trace code tool 以及人月神話
trace code tool 以及人月神話trace code tool 以及人月神話
trace code tool 以及人月神話
 
Annotation processing
Annotation processingAnnotation processing
Annotation processing
 
What Can Compilers Do for Us?
What Can Compilers Do for Us?What Can Compilers Do for Us?
What Can Compilers Do for Us?
 
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard LibraryA Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
A Brief Introduction to Regular Expression with Python 2.7.3 Standard Library
 
Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)Cygwin Install How-To (Chinese)
Cygwin Install How-To (Chinese)
 
Re-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk DataRe-identification of Anomized CDR datasets using Social networlk Data
Re-identification of Anomized CDR datasets using Social networlk Data
 
Timing over packet demarcation
Timing over packet demarcationTiming over packet demarcation
Timing over packet demarcation
 
Hello world在那邊?背景說明
Hello world在那邊?背景說明Hello world在那邊?背景說明
Hello world在那邊?背景說明
 
Asterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log RotationAsterisk (IP-PBX) CDR Log Rotation
Asterisk (IP-PBX) CDR Log Rotation
 
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
AI Chatbot Service Framework based on Backpropagation Network for Predicting ...
 
Internationalization(i18n) of Web Page
Internationalization(i18n) of Web PageInternationalization(i18n) of Web Page
Internationalization(i18n) of Web Page
 
從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理從組裝軟體中談談軟體發展管理
從組裝軟體中談談軟體發展管理
 

More from Wen Liao

Hello world 的一生
Hello world 的一生Hello world 的一生
Hello world 的一生Wen Liao
 
Notes on oracle solaris 11.3 linkers and libraries guide chapter one
Notes on oracle solaris 11.3 linkers  and libraries guide  chapter oneNotes on oracle solaris 11.3 linkers  and libraries guide  chapter one
Notes on oracle solaris 11.3 linkers and libraries guide chapter oneWen Liao
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard StallmanWen Liao
 
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀Wen Liao
 
淺談Debian套件打包
淺談Debian套件打包淺談Debian套件打包
淺談Debian套件打包Wen Liao
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介Wen Liao
 
GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例Wen Liao
 
Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Wen Liao
 
Testing in python 2.7.3
Testing in python 2.7.3Testing in python 2.7.3
Testing in python 2.7.3Wen Liao
 
軟體組裝心得分享
軟體組裝心得分享軟體組裝心得分享
軟體組裝心得分享Wen Liao
 
Introduce to Linux command line
Introduce to Linux command lineIntroduce to Linux command line
Introduce to Linux command lineWen Liao
 

More from Wen Liao (11)

Hello world 的一生
Hello world 的一生Hello world 的一生
Hello world 的一生
 
Notes on oracle solaris 11.3 linkers and libraries guide chapter one
Notes on oracle solaris 11.3 linkers  and libraries guide  chapter oneNotes on oracle solaris 11.3 linkers  and libraries guide  chapter one
Notes on oracle solaris 11.3 linkers and libraries guide chapter one
 
故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman故事:自由軟體和 Richard Stallman
故事:自由軟體和 Richard Stallman
 
A successful git branching model 導讀
A successful git branching model 導讀A successful git branching model 導讀
A successful git branching model 導讀
 
淺談Debian套件打包
淺談Debian套件打包淺談Debian套件打包
淺談Debian套件打包
 
GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介GNU Make, Autotools, CMake 簡介
GNU Make, Autotools, CMake 簡介
 
GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例GNU gettext簡介 - 以C語言為範例
GNU gettext簡介 - 以C語言為範例
 
Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10
 
Testing in python 2.7.3
Testing in python 2.7.3Testing in python 2.7.3
Testing in python 2.7.3
 
軟體組裝心得分享
軟體組裝心得分享軟體組裝心得分享
軟體組裝心得分享
 
Introduce to Linux command line
Introduce to Linux command lineIntroduce to Linux command line
Introduce to Linux command line
 

Trace 程式碼之皮