Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Trace 程式碼之皮
Search
Wen_Liao
November 24, 2014
Technology
0
900
Trace 程式碼之皮
Wen_Liao
November 24, 2014
Tweet
Share
More Decks by Wen_Liao
See All by Wen_Liao
COSCUP-2020-Linux 軟體組裝工和他的工具們
wen_liao
2
1.5k
開放街圖 自助旅行的好幫手
wen_liao
0
1.3k
GNU AS簡介
wen_liao
0
1.2k
UPnP 1.0 簡介
wen_liao
0
1.1k
自由軟體和 Richard Stallman
wen_liao
0
2.3k
Hello world在那邊?背景說明 0
wen_liao
0
750
A successful Git branching model 導讀
wen_liao
0
670
GNU ld的linker script簡介
wen_liao
0
1.3k
淺談Debian套件打包
wen_liao
0
600
Other Decks in Technology
See All in Technology
2025-07-31: GitHub Copilot Agent mode at Vibe Coding Cafe (15min)
chomado
2
390
MCP認可の現在地と自律型エージェント対応に向けた課題 / MCP Authorization Today and Challenges to Support Autonomous Agents
yokawasa
5
2.1k
AWS DDoS攻撃防御の最前線
ryutakondo
1
140
SRE新規立ち上げ! Hubbleインフラのこれまでと展望
katsuya0515
0
180
開発 × 生成AI × コミュニケーション:GENDAの開発現場で感じたコミュニケーションの変化 / GENDA Tech Talk #1
genda
0
110
GMOペパボのデータ基盤とデータ活用の現在地 / Current State of GMO Pepabo's Data Infrastructure and Data Utilization
zaimy
3
210
AIのグローバルトレンド 2025 / ai global trend 2025
kyonmm
PRO
1
130
「Roblox」の開発環境とその効率化 ~DAU9700万人超の巨大プラットフォームの開発 事始め~
keitatanji
0
120
九州の人に知ってもらいたいGISスポット / gis spot in kyushu 2025
sakaik
0
110
Rubyの国のPerlMonger
anatofuz
3
730
Google Cloud で学ぶデータエンジニアリング入門 2025年版 #GoogleCloudNext / 20250805
kazaneya
PRO
19
4.3k
Amazon S3 Vectorsは大規模ベクトル検索を低コスト化するサーバーレスなベクトルデータベースだ #jawsugsaga / S3 Vectors As A Serverless Vector Database
quiver
1
140
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
430
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.3k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.4k
A Modern Web Designer's Workflow
chriscoyier
695
190k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.6k
The Cult of Friendly URLs
andyhume
79
6.5k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Transcript
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/