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
LLDBを活用したデザインチェック
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Suita Fujino
June 23, 2021
Programming
2.5k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
LLDBを活用したデザインチェック
potatotips #74 (2021/6/23)
GitHub:
https://github.com/Scior/LLDBVisualDebug
Suita Fujino
June 23, 2021
Other Decks in Programming
See All in Programming
自動化したのに回らないテスト運用の壁ーAI時代の品質責任と生産性
mfunaki
1
130
生成AI導入の「期待外れ」を乗り越える ー 開発フロー改革が目指す、真の組織変革
starfish719
0
4.5k
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
700
PHP Application における Kubernetes 内 gRPC 通信
ganchiku
0
590
FDEが実現するAI駆動経営の現在地
gonta
2
280
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
670
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
5
1.9k
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
440
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
500
仕様駆動開発の消費期限
watany
20
8.4k
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
290
プロポーザルを書いてもらう
pvcresin
0
540
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
How to build a perfect <img>
jonoalderson
1
5.9k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
210
Designing for humans not robots
tammielis
254
26k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
200
Chasing Engaging Ingredients in Design
codingconduct
0
270
Leo the Paperboy
mayatellez
8
2.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
Transcript
(@Scior) LLDB Swift Python 1
AppBrew LIPS iOS PjM ( Keynote) ࣗݾհ🦙 ෩ܠ͖֯ͷਓू·Εʙ📷
None
(lldb) e view.isHidden = false
Google UI
Python
None
( )
UIView Save
UIView UIView Data UIGraphicsImageRenderer SBProcess.ReadMemory Lib/io LLDB
(lldb) saveimage imageView /tmp/alpaca.png
Swift ( ) loadext DebugExtensions.swift evaluate DebugExtensions.swift
Swift (loadext) @lldb.command("loadext") def load(debugger, command, result, dict): path =
os.path.join(os.path.dirname(__file__), 'swift/DebugExtensions.swift') with open(path, 'r') as f: common.evaluate(f.read()) * common.evaluate
DebugExtensions.swift extension UIView { func takeSnapshot() -> UIImage? { let
renderer = UIGraphicsImageRenderer(bounds: bounds) return renderer.image { context in layer.render(in: context.cgContext) } } func convertToPNGData() -> Data { return takeSnapshot()!.pngData()! } } ͪΖΜ#if DEBUG ~ #endifͰғͬͯίϯύΠϧͯ͠ྑ͍
saveimage ( ) saveimage convertToPNGData() evaluate convertToPNGData() DebugExtensions.swift
saveimage ( ) saveimage address size convertToPNGData() evaluate convertToPNGData() Data
SBValue DebugExtensions.swift
saveimage ( ) @lldb.command("saveimage") def save_image(debugger, arguments, result, dict): view,
path = arguments.split() var_name = str(uuid.uuid4()).replace('-', '') common.evaluate('let $%s = %s.convertToPNGData()' % (var_name, view)) address_str = common.evaluate('($%s as NSData).bytes' % var_name).GetObjectDescription().split()[1] address = int(address_str, 16) size = int(common.evaluate('$%s.count' % var_name).GetValue()) process = lldb.debugger.GetSelectedTarget().GetProcess() error = lldb.SBError() data = process.ReadMemory(address, size, error) with open(path, "wb") as f: f.write(data)
@lldb.command("saveimage") def save_image(debugger, arguments, result, dict): @lldb.command command script add
-f LLDB
convertToPNGData() common.evaluate('let $%s = %s.convertToPNGData()' % (var_name, view)) let $hoge
= imageView.convertToPNGData()
Data address_str = common.evaluate('($%s as NSData).bytes' % var_name).GetObjectDescription().split()[1] address =
int(address_str, 16) size = int(common.evaluate('$%s.count' % var_name).GetValue()) ($hoge as NSData).bytes $hoge.count (Obj-C++ )
process = lldb.debugger.GetSelectedTarget().GetProcess() error = lldb.SBError() data = process.ReadMemory(address, size,
error) with open(path, "wb") as f: f.write(data) SBProcess.ReadMemory Python
* GitHub
( )
UIView Overlay
UIView Data UIImage UnsafeMutablePointer UIImage.init(data:) Lib/io SBProcess.WriteMemory LLDB
(lldb) overlayimage imageView /tmp/alpaca.png
ImageBuffer final class ImageBuffer { typealias Pointer = UnsafeMutablePointer<UInt8> private
let size: Int let pointer: Pointer init(size: Int) { self.size = size pointer = Pointer.allocate(capacity: size) } deinit { pointer.deallocate() } func getData() -> Data { let bufferPointer = UnsafeMutableBufferPointer(start: pointer, count: size) return .init(buffer: bufferPointer) } }
overlayimage @lldb.command("overlayimage") def overlay_image(debugger, arguments, result, dict): view, path =
arguments.split() with open(path, 'rb') as f: data = f.read() buf_name = common.generateVarName() common.evaluate('let $%s = ImageBuffer(size: %s)' % (buf_name, len(data))) address_str = common.evaluate('$%s.pointer' % buf_name).GetObjectDescription().split()[1] address = int(address_str, 16) process = lldb.debugger.GetSelectedTarget().GetProcess() error = lldb.SBError() size = process.WriteMemory(address, data, error) view_name = common.generateVarName() common.evaluate('let $%s = DebugOverlayView(frame: %s.frame)' % (view_name, view)) common.evaluate('$%s.set(data: $%s.getData())' % (view_name, buf_name)) common.evaluate(‘%s.superview?.addSubview($%s)' % (view, view_name))
with open(path, 'rb') as f: data = f.read() common.evaluate('let $%s
= ImageBuffer(size: %s)' % (buf_name, len(data))) address_str = common.evaluate('$%s.pointer' % buf_name).GetObjectDescription().split()[1] address = int(address_str, 16) ImageBuffer
process = lldb.debugger.GetSelectedTarget().GetProcess() error = lldb.SBError() size = process.WriteMemory(address, data,
error) SBProcess.WriteMemory
View common.evaluate('let $%s = DebugOverlayView(frame: %s.frame)' % (view_name, view)) common.evaluate('$%s.set(data:
$%s.getData())' % (view_name, buf_name)) common.evaluate(‘%s.superview?.addSubview($%s)' % (view, view_name)) let $view = DebugOverlayView(frame: view.frame) $view.set(data: $buf.getData()) view.superview?.addSubview($view)
☺ * GitHub
With OpenCV and scikit-image (in progress) View cv skimage (UILabel
)
https://github.com/Scior/LLDBVisualDebug
Appendix
common.evaluate def evaluate(exp): options = lldb.SBExpressionOptions() options.SetLanguage(lldb.eLanguageTypeSwift) frame = (
lldb.debugger.GetSelectedTarget() .GetProcess() .GetSelectedThread() .GetSelectedFrame() ) return frame.EvaluateExpression(exp, options)
LLDB Python API: https://lldb.llvm.org/python_api.html facebook/chisel: https://github.com/facebook/chisel
🦙