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

XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?Yurii Bilyk
 
0wn-premises: Bypassing Microsoft Defender for Identity
0wn-premises: Bypassing Microsoft Defender for Identity0wn-premises: Bypassing Microsoft Defender for Identity
0wn-premises: Bypassing Microsoft Defender for IdentityNikhil Mittal
 
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS FilterX-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS FilterMasato Kinugawa
 
PythonによるWebスクレイピング入門
PythonによるWebスクレイピング入門PythonによるWebスクレイピング入門
PythonによるWebスクレイピング入門Hironori Sekine
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Mario Heiderich
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundDirkjanMollema
 
모의해킹 전문가 되기
모의해킹 전문가 되기모의해킹 전문가 되기
모의해킹 전문가 되기Jeremy Bae
 
Sızma Testlerinde Fiziksel Güvenlik Riskleri
Sızma Testlerinde Fiziksel Güvenlik RiskleriSızma Testlerinde Fiziksel Güvenlik Riskleri
Sızma Testlerinde Fiziksel Güvenlik RiskleriBGA Cyber Security
 
HotPics 2021
HotPics 2021HotPics 2021
HotPics 2021neexemil
 
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilitiesVorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilitiesDefconRussia
 
How to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI AttacksHow to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI AttacksImperva
 
Cross Site Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesMarco Morana
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesOWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesFrans Rosén
 
入門ClojureScript
入門ClojureScript入門ClojureScript
入門ClojureScriptsohta
 
A8 cross site request forgery (csrf) it 6873 presentation
A8 cross site request forgery (csrf)   it 6873 presentationA8 cross site request forgery (csrf)   it 6873 presentation
A8 cross site request forgery (csrf) it 6873 presentationAlbena Asenova-Belal
 

What's hot (20)

XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?XSS - Do you know EVERYTHING?
XSS - Do you know EVERYTHING?
 
0wn-premises: Bypassing Microsoft Defender for Identity
0wn-premises: Bypassing Microsoft Defender for Identity0wn-premises: Bypassing Microsoft Defender for Identity
0wn-premises: Bypassing Microsoft Defender for Identity
 
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS FilterX-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
X-XSS-Nightmare: 1; mode=attack XSS Attacks Exploiting XSS Filter
 
PythonによるWebスクレイピング入門
PythonによるWebスクレイピング入門PythonによるWebスクレイピング入門
PythonによるWebスクレイピング入門
 
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
Copy & Pest - A case-study on the clipboard, blind trust and invisible cross-...
 
Celery
CeleryCelery
Celery
 
aclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHoundaclpwn - Active Directory ACL exploitation with BloodHound
aclpwn - Active Directory ACL exploitation with BloodHound
 
모의해킹 전문가 되기
모의해킹 전문가 되기모의해킹 전문가 되기
모의해킹 전문가 되기
 
Sızma Testlerinde Fiziksel Güvenlik Riskleri
Sızma Testlerinde Fiziksel Güvenlik RiskleriSızma Testlerinde Fiziksel Güvenlik Riskleri
Sızma Testlerinde Fiziksel Güvenlik Riskleri
 
HotPics 2021
HotPics 2021HotPics 2021
HotPics 2021
 
A Threat Hunter Himself
A Threat Hunter HimselfA Threat Hunter Himself
A Threat Hunter Himself
 
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilitiesVorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
 
HTML 語法教學
HTML 語法教學HTML 語法教學
HTML 語法教學
 
How to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI AttacksHow to Prevent RFI and LFI Attacks
How to Prevent RFI and LFI Attacks
 
Cross Site Request Forgery Vulnerabilities
Cross Site Request Forgery VulnerabilitiesCross Site Request Forgery Vulnerabilities
Cross Site Request Forgery Vulnerabilities
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web TechnologiesOWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
OWASP AppSecEU 2018 – Attacking "Modern" Web Technologies
 
入門ClojureScript
入門ClojureScript入門ClojureScript
入門ClojureScript
 
A8 cross site request forgery (csrf) it 6873 presentation
A8 cross site request forgery (csrf)   it 6873 presentationA8 cross site request forgery (csrf)   it 6873 presentation
A8 cross site request forgery (csrf) it 6873 presentation
 
Web Uygulama Pentest Eğitimi
Web Uygulama Pentest EğitimiWeb Uygulama Pentest Eğitimi
Web Uygulama Pentest Eğitimi
 

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 程式碼之皮