SlideShare a Scribd company logo
How to debug mrubyHow to debug mruby
RubyConf.tw 2014RubyConf.tw 2014
Team YamanekkoTeam Yamanekko
Yurie Yamane / Masayoshi TakahashiYurie Yamane / Masayoshi Takahashi
自我介紹
Who are we?
Who are we
●
やまね ゆりえ (Yurie Yamane)
●
高橋征義 (Masayoshi Takahashi)
●
ちー (Chie)
Team Yamanekko
Who are we
http://mrb.h2so5.net/
電子書出版社
http://tatsu-zine.com/
Tatsu-zine Publishing Inc.
How to debug mruby (rubyconftw2014)
How to debug mruby (rubyconftw2014)
http://ruby-no-kai.org/
http://rubykaigi.org/2014
http://rubykaigi.org/2015
CFP will be opened soon
公開徵求講者
our talks
到現在的經歷
Our talks
RubyConf.tw 2012
Our talks
OSDC.tw 2013
RubyConf 2013
https://www.flickr.com/photos/igaiga/10836637785/
Demo
演示
STM32F4的演示
Push Button
Push Button
Power ON
blinking
mode
tilt sensor
mode
Our problem
我們的問題
mruby core
*.rb (stdlib)
*.rb (your code)
C/C++
libmruby.a
Bytecode
(C String)
mrbgems
Bytecode
(C String)
mruby core
*.rb (stdlib)
*.rb (your code)
C/C++
mrbgems
Ruby
C
mrb_led_toggle
debugging in C → Eclipse+CDT
debugging in Ruby → ???
add breakpoint in C
●
aaa
●
Bbb
●
mrbc
breakpoint
mrbgems
C part in
Application
add breakpoint in Ruby
●
aaa
●
Bbb
●
mrbc
breakpoint
Today's Topic
今天的主題
Debug
除錯
https://www.flickr.com/photos/monkeymashbutton/7618269720/https://www.flickr.com/photos/monkeymashbutton/7618269720/
CRuby的除錯
Debugging in CRuby
Debugging in CRuby
●
p || printf
●
irb
●
ruby-debug || bybug
Debugging in CRuby
●
p || printf
●
irb
●
ruby-debug || bybug
mruby/src/vm.c
STDIO is an option in mruby
Debugging in CRuby
●
p || printf
●
irb
●
ruby-debug || bybug
How to debug mruby (rubyconftw2014)
How to debug mruby (rubyconftw2014)
Debugging in CRuby
●
p || printf
●
irb
●
ruby-debug || bybug
Debugging in CRuby
●
p || printf
●
irb
●
ruby-debug || bybug
mruby has no debugger (yet)
–
田中先生 will develop mruby debugger (in
this year?)
Issues in mruby
●
embedding into C/C++ apps
–
mruby's code is just a part of application
–
We need to debug C/C++ code AND ruby code
●
ruby-debug is only Ruby-level debugger
–
GDB && ruby-debug ??
What we want to do
●
adding breakpoint in Ruby AND C
●
step over/into/return in Ruby AND C
●
show stacktrace in Ruby AND C
●
show variable in Ruby AND C
–
it's different from ruby-debug
We can do them in C level
https://www.sourceware.org/gdb/
our solution
●
“hybrid debugger”
–
C-level debugger + Ruby-level extension
–
Ruby debugger on GDB
How to debug mrubyHow to debug mruby
RubyConf.tw 2014RubyConf.tw 2014
Team YamanekkoTeam Yamanekko
Yurie Yamane / Masayoshi TakahashiYurie Yamane / Masayoshi Takahashi
make a debugger tomake a debugger to
Our debugger status
●
just started (not finished yet Orz)
●
We talk how it works, showing
simple demo with gdb and Eclipse
plugin
m
http://ruby-hacking-guide.github.io/
mrbc and mrubyVM
*.rb *.mrb mrubyVMmrbc
Compile
Ruby Bytecode
Execute
mrbc and mrubyVM
*.rb *.mrb mrubyVMmrbc
Compile
Ruby Bytecode
Execute
mruby VM don't see
original code in Ruby
bytecode structure
●
We made mruby bytecode parser
–
mrb_parser (v0.0.1)
–
http://rubygems.org/gems/mrb_parser
–
https://github.com/yamanekko/mrb_parser
How to debug mruby (rubyconftw2014)
bytecode structure
RITE Section (Header)
IREP Section
END Section
IREP
Record
*.mrb
http://commons.wikimedia.org/wiki/File:Dialog-warning-orange.svg
without -g option,
mrbc doesn't generate
mappings between line
numbers of ruby souce code
and bytecodes.
mrbc and mrubyVM
*.rb *.mrb
Compile
Ruby
Bytecode with
debug section
Execute
mrbc -g
mrbc mrubyVM
bytecode structure
RITE Section(Header)
IREP Section
END Section
IREP Record
DEBUG Section
DEBUG Info
*.mrb
corresponding
How to debug mruby (rubyconftw2014)
bytecode structure
RITE Section
IREP Section
END Section
IREP Record
DEBUG Section
DEBUG Info
*.mrb
corresponding
How to debug mruby (rubyconftw2014)
How to debug mruby (rubyconftw2014)
i=1+2
p i
http://commons.wikimedia.org/wiki/File:Dialog-warning-orange.svg
number of byte code
≠
line number of Ruby code
not 1 to 1 mapping
mruby VM
mruby VM
●
src/vm.c
●
mrb_context_run()
●
≒ case statements within loops
mrb_context_run()
How to debug mruby (rubyconftw2014)
How to debug mruby (rubyconftw2014)
How to debug mruby (rubyconftw2014)
http://commons.wikimedia.org/wiki/File:Dialog-warning-orange.svg
You should define
ENABLE_DEBUG
in mrbconf.h
ENABLE_DEBUG in mrbconf.h
mrb_state has code_fetch_hook
setting code_fetch_hook function
How to debug mruby (rubyconftw2014)
GDB demo
Eclipse
Eclipse + CDT
●
CDT = C/C++ Development Tooling
–
support various toolchains
–
standard make build
–
source navigation
–
various source knowledge tools
Eclipse + CDT meets mruby
Eclipse Platform
DSF-GDB
target application
(+mruby)
GDB/MI
DSF
CDT
mrubydebugger
Demo
演示
Conclusion
結語
Conclusion
●
programming in mruby is fun
●
debugging in mruby is hard
●
making debugger is harder than
that
●
Cool tool helps you and makes less
hard
TODO
●
step into/step over
●
show backtrace
●
show variables
Kernel#local_variables
How to debug mruby (rubyconftw2014)
TODO
●
extending *.mrb
●
adding LVAR section???
Thanks!
Happy mruby Hacking!
special thanks to:

More Related Content

PDF
Writing mruby Debugger
PDF
2008-12-21 Rubinius
PDF
Why don't you Groovy?
PPTX
RJB - another choice for Ruby and Java interoperability
PDF
Ruby on rails探索
PPS
Groovy & Grails
PDF
How to control physical devices with mruby
PDF
The Architecture of PicCollage Server
Writing mruby Debugger
2008-12-21 Rubinius
Why don't you Groovy?
RJB - another choice for Ruby and Java interoperability
Ruby on rails探索
Groovy & Grails
How to control physical devices with mruby
The Architecture of PicCollage Server

What's hot (20)

PDF
APIs Rest com NodeJS
PDF
freeCodeCamp Tokyo meetup 19
PDF
MacRuby For Ruby Developers
PDF
TDD with Spock @xpdays_ua
PDF
Swoole Meetup AFUP¨Montpellier 27/01/2021
PDF
JRuby Basics
PDF
JRuby - The Perfect Alternative
PDF
MacRuby
PDF
Introduzione a macruby
PDF
Intro to Crystal Programming Language
PPTX
React web development
PDF
Dev + DevOps для PHP розробника
PDF
Frameworks
PDF
Як РНР розробник пише код на Kotlin
PDF
Development: What they don't teach you in college
PDF
Groovy as a Dynamic Language
PDF
Daniel Steigerwald - Este.js - konec velkého Schizma
PDF
Typescript - MentorMate Academy
ODP
Extjs Howto
PDF
ruby-cocoa
APIs Rest com NodeJS
freeCodeCamp Tokyo meetup 19
MacRuby For Ruby Developers
TDD with Spock @xpdays_ua
Swoole Meetup AFUP¨Montpellier 27/01/2021
JRuby Basics
JRuby - The Perfect Alternative
MacRuby
Introduzione a macruby
Intro to Crystal Programming Language
React web development
Dev + DevOps для PHP розробника
Frameworks
Як РНР розробник пише код на Kotlin
Development: What they don't teach you in college
Groovy as a Dynamic Language
Daniel Steigerwald - Este.js - konec velkého Schizma
Typescript - MentorMate Academy
Extjs Howto
ruby-cocoa
Ad

Viewers also liked (6)

PDF
Wakayama.rbボードの使い方
PDF
Stm32f4硬體週邊介紹
PDF
STM32F4 for 智慧型電動輪椅系統Part1
PPTX
Apache Storm and twitter Streaming API integration
PPTX
présentation STM32
PPT
Wakayama.rbボードの使い方
Stm32f4硬體週邊介紹
STM32F4 for 智慧型電動輪椅系統Part1
Apache Storm and twitter Streaming API integration
présentation STM32
Ad

Similar to How to debug mruby (rubyconftw2014) (20)

PDF
Developing cross platform desktop application with Ruby
PDF
使用Eclipse快樂的mruby開發
PDF
Montreal.rb ruby debugging basics - march 20th 2012
PDF
Getting started with Ruby on Rails
PPTX
Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...
PDF
Startup and Rapid web development
PDF
Middleware as Code with mruby
PDF
RubyならMacでしょう
PDF
Ruby confhighlights
PDF
20140626 red dotrubyconf2014
PDF
Hangout Utche #6. "Rambovidnaya problema"
PDF
Introduction of Cybersecurity with OSS at Code Europe 2024
PDF
Lightweight APIs in mRuby (Михаил Бортник)
PPTX
IronRuby - A brave new world for .Net (NDC2010)
PDF
Merb presentation at ORUG
PDF
RailsConf 2022 - Upgrading Rails: The Dual Boot Way
PDF
ZJIT: Building a Next Generation Ruby JIT
PDF
The story of language development
PDF
How to turn your developers in less than 6 months in perfect software craftsmen
PDF
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Developing cross platform desktop application with Ruby
使用Eclipse快樂的mruby開發
Montreal.rb ruby debugging basics - march 20th 2012
Getting started with Ruby on Rails
Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...
Startup and Rapid web development
Middleware as Code with mruby
RubyならMacでしょう
Ruby confhighlights
20140626 red dotrubyconf2014
Hangout Utche #6. "Rambovidnaya problema"
Introduction of Cybersecurity with OSS at Code Europe 2024
Lightweight APIs in mRuby (Михаил Бортник)
IronRuby - A brave new world for .Net (NDC2010)
Merb presentation at ORUG
RailsConf 2022 - Upgrading Rails: The Dual Boot Way
ZJIT: Building a Next Generation Ruby JIT
The story of language development
How to turn your developers in less than 6 months in perfect software craftsmen
Highly Surmountable Challenges in Ruby+OMR JIT Compilation

More from yamanekko (10)

PDF
Model2code mruby 2018
PDF
Ev3rt and mruby-ev3rt 2018ver
PDF
mruby can be more lightweight
PDF
Rubykaigi2016 High Tech Seat in mruby
PDF
Domo Arigato, Mr(uby) Roboto
PDF
RubyKaigi2015 making robots-with-mruby
PDF
mrubyでETロボコンに出よう
PDF
ルネサスナイト
PDF
Tokyurubykaigi05
PDF
RubyConfの話の続きのおはなし
Model2code mruby 2018
Ev3rt and mruby-ev3rt 2018ver
mruby can be more lightweight
Rubykaigi2016 High Tech Seat in mruby
Domo Arigato, Mr(uby) Roboto
RubyKaigi2015 making robots-with-mruby
mrubyでETロボコンに出よう
ルネサスナイト
Tokyurubykaigi05
RubyConfの話の続きのおはなし

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Cloud computing and distributed systems.
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Chapter 3 Spatial Domain Image Processing.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Machine learning based COVID-19 study performance prediction
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Cloud computing and distributed systems.
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Weekly Chronicles - August'25 Week I

How to debug mruby (rubyconftw2014)