Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Trace 程式碼之皮
Search
Wen_Liao
November 24, 2014
Technology
990
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Trace 程式碼之皮
Wen_Liao
November 24, 2014
Transcript
25 slides
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 Decks by Wen_Liao
See All by Wen_Liao
COSCUP-2020-Linux 軟體組裝工和他的工具們
wen_liao
2
1.5k
開放街圖 自助旅行的好幫手
wen_liao
0
1.4k
GNU AS簡介
wen_liao
0
1.3k
UPnP 1.0 簡介
wen_liao
0
1.2k
自由軟體和 Richard Stallman
wen_liao
0
2.4k
Hello world在那邊?背景說明 0
wen_liao
0
850
A successful Git branching model 導讀
wen_liao
0
780
GNU ld的linker script簡介
wen_liao
0
1.5k
淺談Debian套件打包
wen_liao
0
750
Other Decks in Technology
See All in Technology
エンタープライズIAMについて - ID・権限をどう統制するか
oidfj
1
350
現場に渡し、構造で守る AI エージェントを活用したセルフサーブのデータ基盤の運用
legalontechnologies
PRO
0
140
From vibe coding to reliable (agentic) development
jcabot
0
290
AWS DevOps Agentの構造から読み解く運用 AI エージェントの設計原則/aws-devops-agent-design-principles
tomoki10
0
300
FPGAでアクティブセンシングがやりたくてカメラモジュールを自作した話
ryuz88
0
130
メルカリの小規模チーム「Pod」で、 エンジニアがデータアナリストなしで、 AIを使ってデータ分析の自走を目指す取り組み
jackojacko_
1
370
AIフレンドリーなGenerative UIをJSXで
uhyo
2
730
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
5
18k
「それ、AIでよくない?」- AI時代の技術発信はオワコンなのか?
estie
1
110
Fukurou Labo_Engineer_Deck
fukuroulabo
0
110
全てを疑え!非自明な挙動と異常系から考える堅牢なカスタムコントローラ開発入門(CNDW2026)
lycorptech_jp
PRO
0
120
AWS re:Invent 2026 FSI Pre-Event Networking Night
junjikoide
0
310
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
830
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
2
2.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
HDC tutorial
michielstock
2
1k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
4 Signs Your Business is Dying
shpigford
187
23k
The Curse of the Amulet
leimatthew05
4
17k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k