SlideShare une entreprise Scribd logo
1  sur  83
Télécharger pour lire hors ligne
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.
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
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
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
bytecode structure
RITE Section
IREP Section
END Section
IREP Record
DEBUG Section
DEBUG Info
*.mrb
corresponding
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()
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
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
TODO
●
extending *.mrb
●
adding LVAR section???
Thanks!
Happy mruby Hacking!
special thanks to:

Contenu connexe

Tendances

Tendances (20)

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

En vedette

Stm32f4硬體週邊介紹
Stm32f4硬體週邊介紹Stm32f4硬體週邊介紹
Stm32f4硬體週邊介紹
Jack Wang
 
STM32F4 for 智慧型電動輪椅系統Part1
STM32F4 for 智慧型電動輪椅系統Part1STM32F4 for 智慧型電動輪椅系統Part1
STM32F4 for 智慧型電動輪椅系統Part1
Jack Wang
 
Apache Storm and twitter Streaming API integration
Apache Storm and twitter Streaming API integrationApache Storm and twitter Streaming API integration
Apache Storm and twitter Streaming API integration
Uday Vakalapudi
 

En vedette (6)

Wakayama.rbボードの使い方
Wakayama.rbボードの使い方Wakayama.rbボードの使い方
Wakayama.rbボードの使い方
 
Stm32f4硬體週邊介紹
Stm32f4硬體週邊介紹Stm32f4硬體週邊介紹
Stm32f4硬體週邊介紹
 
STM32F4 for 智慧型電動輪椅系統Part1
STM32F4 for 智慧型電動輪椅系統Part1STM32F4 for 智慧型電動輪椅系統Part1
STM32F4 for 智慧型電動輪椅系統Part1
 
Apache Storm and twitter Streaming API integration
Apache Storm and twitter Streaming API integrationApache Storm and twitter Streaming API integration
Apache Storm and twitter Streaming API integration
 
présentation STM32
présentation STM32présentation STM32
présentation STM32
 
Introduction to stm32-part1
Introduction to stm32-part1Introduction to stm32-part1
Introduction to stm32-part1
 

Similaire à How to debug mruby (rubyconftw2014)

使用Eclipse快樂的mruby開發
使用Eclipse快樂的mruby開發使用Eclipse快樂的mruby開發
使用Eclipse快樂的mruby開發
yamanekko
 
Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...
Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...
Kids, Ruby, Run! - Introduction of the Smalruby and the Ruby Programming Shou...
宏治 高尾
 
20140626 red dotrubyconf2014
20140626 red dotrubyconf201420140626 red dotrubyconf2014
20140626 red dotrubyconf2014
Hiroshi SHIBATA
 

Similaire à How to debug mruby (rubyconftw2014) (20)

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

Plus de yamanekko (10)

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

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

How to debug mruby (rubyconftw2014)