Slide 1

Slide 1 text

Introduction of new features for VS Code debugging Naoto ONO

Slide 2

Slide 2 text

Naoto ONO • Developer Productivity Group at CyberAgent, Inc • ruby/debug (debug.gem), ruby/vscode-rdbg contributor • Chrome Integration • E2E Test Frameworks • GitHub: @ono-max

Slide 3

Slide 3 text

Question: have you ever read code with a debugger?

Slide 4

Slide 4 text

Code reading with a debugger is great!

Slide 5

Slide 5 text

Code reading with a debugger is great! However, ...

Slide 6

Slide 6 text

Reading complex code is still hard, isn’t it?

Slide 7

Slide 7 text

Demo: Read complex code with debug.gem.

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Read code inside of Active Record object

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Dif fi culty of Reading complex code • We sometimes forget which method was called when we stopped before 😭 • We sometimes forget to take note of the return value of the methods 😖

Slide 12

Slide 12 text

What should we do? 


Slide 13

Slide 13 text

What should we do? => Let’s trace the program with Trace Inspector!!

Slide 14

Slide 14 text

Agenda • Main topic: Trace Inspector • Subtopic: VS Code Debug Visualizer

Slide 15

Slide 15 text

Trace Inspector

Slide 16

Slide 16 text

Demo: Trace the program with Trace Inspector

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Trace “bar” method

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

(Repeat) Dif fi culties in reading complex codes. • We sometimes forget which method was called when we stopped before 😭 • We sometimes forget to take note of the return value of the methods 😖
 
 


Slide 21

Slide 21 text

(Repeat) Dif fi culties in reading complex code. • We sometimes forget which method was called when we stopped before 😭 • We sometimes forget to take note of the return value of the methods 😖
 
 
 => We can solve the above problems in Trace Inspector!!

Slide 22

Slide 22 text

Trace Inspector • We can check which method was called anytime 😁 • We can copy parameters and return value by clicking the target log 😃 • All organized tracing logs help you to understand the procedure 🤗

Slide 23

Slide 23 text

Summary of Demo • How to start Trace Inspector
 1. Click “Enable Trace”
 2. Execute the program • If you click a log, the target fi le is opened, and the line is highlighted. • Parameters and return values are displayed in the editor.

Slide 24

Slide 24 text

We want to record local variables and backtraces, don’t we?

Slide 25

Slide 25 text

Record And Replay • We can record local variables and backtraces by enabling “Record And Replay” mode. • “Record And Replay” mode is disabled in the default since it’s slow.

Slide 26

Slide 26 text

Demo: Trace local variables and backtraces with Trace Inspector

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

Trace “bar” method

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Summary of Demo • How to record local variables and backtraces
 1. Click “•••” (more icon), then put a checkmark of “Record And Replay (Slow)”
 2. Click “Enable Trace”
 3. Execute the program •

Slide 31

Slide 31 text

Options for tracing Location Method name & Params Return Value Backtrace Local variables Trace Line (Default) ✅ N/A N/A Trace Call/Return 
 (Default) ✅ ✅ ✅ Record And Replay ✅ ✅ ✅ ✅ ✅

Slide 32

Slide 32 text

Performance Comparison for each option Execution Time (sec) Without tracing (Normal mode) 0.007 Trace Line 0.063 Trace Call/Return 0.437 Record And Replay 10.640 x 9.0 x 62.4 x 1520.0 ruby 3.2.1 (2023-02-08 revision 31819e82c8) [arm64-darwin21] MacBook Pro (16-inch, 2021) Chip: Apple M1 Max Memory 32 GB

Slide 33

Slide 33 text

Comparison with existing tracing tools Overview Frontend Trace Inspector A tool that improves the UI of rdbg (CLI) VS Code rdbg (CLI) A tool that traces debugging programs Terminal ruby/tracer A tool that traces executing programs Terminal

Slide 34

Slide 34 text

Comparison with existing tracing tools Overview Frontend Trace Inspector A tool that improves the UI of rdbg (CLI) VS Code rdbg (CLI) A tool that traces debugging programs Terminal ruby/tracer A tool that traces executing programs Terminal Trace Inspector can provide rich user experiences by making use of VS Code!!

Slide 35

Slide 35 text

The way of displaying trace logs rdbg(CLI) Trace Inspector

Slide 36

Slide 36 text

The way of displaying trace logs rdbg(CLI) Trace Inspector You can see only what you want to see by clicking! A trace log

Slide 37

Slide 37 text

The way of displaying trace logs rdbg(CLI) Trace Inspector You can see only what you want to see by clicking!

Slide 38

Slide 38 text

Trace logs can be viewed on the editor The line is highlighted!

Slide 39

Slide 39 text

Trace logs can be viewed on the editor Parameters are displayed on the editor!

Slide 40

Slide 40 text

The history to develop Trace Inspector Start developing the tracing tool that improves the UI of rdbg (CLI). History Inspector is introduced in RubyKaigi 2022. Trace Inspector which improves History Inspector, is introduced now!

Slide 41

Slide 41 text

How does Trace Inspector work?

Slide 42

Slide 42 text

How does Trace Inspector work? VS Code debug.gem VS Code extension

Slide 43

Slide 43 text

How does Trace Inspector work? VS Code debug.gem VS Code extension

Slide 44

Slide 44 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem JSON

Slide 45

Slide 45 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem

Slide 46

Slide 46 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem

Slide 47

Slide 47 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem Click “Enable Trace”

Slide 48

Slide 48 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem Click “Enable Trace” Enable Trace

Slide 49

Slide 49 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem Click “Enable Trace” Enable Trace Success

Slide 50

Slide 50 text

Debug Adapter Protocol (DAP) VS Code extension debug.gem Change “Enable Trace” to “Disable Trace” Enable Trace Success

Slide 51

Slide 51 text

Conclusion of Trace Inspector • Trace Inspector is available in debug.gem version 1.8. • Trace Inspector helps you to read complex code.

Slide 52

Slide 52 text

VS Code Debug Visualizer

Slide 53

Slide 53 text

Demo: Visualize objects in VS Code Debug Visualizer

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

Visualize variable “foo"

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

VS Code Debug Visualizer • A VS Code extension that visualizes objects while debugging. • This extension is created by Henning Dieterichs (@hediet).

Slide 58

Slide 58 text

Supported Languages (Excerpt) • JavaScript • Python • Go • C++ • Java •

Slide 59

Slide 59 text

• JavaScript • Python • Go • C++ • Java • Ruby <- New!! Supported Languages (Excerpt)

Slide 60

Slide 60 text

How Ruby objects are visualized?

Slide 61

Slide 61 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem debugvisualizer.gem

Slide 62

Slide 62 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem debugvisualizer.gem What I developed this time!

Slide 63

Slide 63 text

How Ruby object are visualized? VS Code Debug Visualizer

Slide 64

Slide 64 text

How Ruby object are visualized? VS Code Debug Visualizer Enter “foo”

Slide 65

Slide 65 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem Evaluate “foo” Enter “foo”

Slide 66

Slide 66 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem Evaluate “foo” debugvisualizer.gem Result

Slide 67

Slide 67 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem debugvisualizer.gem Result VS Code Debug Visualizer Protocol Evaluate “foo”

Slide 68

Slide 68 text

How Ruby object are visualized? VS Code Debug Visualizer debug.gem debugvisualizer.gem Result Evaluate “foo” VS Code Debug Visualizer Protocol

Slide 69

Slide 69 text

Inside story of using VS Code Debug Visualizer • Although we planned to create the front end by ourselves at fi rst, we had the following problems: • Maintenance cost • Risk of using third-party libraries • We decided to use VS Code Debug Visualizer to solve the above issues.

Slide 70

Slide 70 text

Conclusion

Slide 71

Slide 71 text

New features for VS Code debugging • Trace Inspector • Please update your version of debug.gem to the latest version! • VS Code Debug Visualizer

Slide 72

Slide 72 text

Helpful references to review my talk • Trace Inspector • https://github.com/ruby/debug/pull/959 • VS Code Debug Visualizer • https://github.com/hediet/vscode-debug-visualizer • https://github.com/ono-max/debugvisualizer • (Japanese) https://zenn.dev/ono_max/articles/cb5cf14caef2d8

Slide 73

Slide 73 text

Acknowledgement • Koichi Sasada san (@ko1) • He helped me to design Trace Inspector. • If it had not been for his help, I wouldn’t have been here! • Thank you for giving me much feedback about Trace Inspector! • Yusuke Endoh san (@mame) • Mari Imaizumi san (@ima1zumi) • Yuki Torii san (@yotii23)

Slide 74

Slide 74 text

Thank you for your time!