Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Crossing Abstraction Barriers When Debugging In Dynamic Languages

187 views

Published on

Programmers use abstractions to reduce implementation effort and focus on domain-specifics. The resulting application often runs in a convenient guest runtime that is provided by an increasingly complex ecosystem of libraries, VMs, JIT-compilers, operating systems, and native machine architectures.

While abstractions are designed to hide complexity, experience tells us that “All non-trivial abstractions, to some degree, are leaky.”1. Leaky abstractions are problematic, for example, when the use of under-documented or unspecified behavior of a library or virtual machine causes a failure in domain-specific code. Users may need to understand whether the virtual machine is just under-documented but working as intended or faulty. At that point, the artificially created barrier that protects language users from domain-independent complexity becomes an obstacle. We call this crossing the abstraction barrier.

Prior research has investigated how symbolic debuggers can work across language barriers. However, this resulted in dedicated workflows and UIs that differ substantially from traditional symbolic debugging. Users need to remember these rather elaborate workflows, and the learning effort is often larger than the perceived benefit of answering the given debugging questions. As a result, the value of these tools may not be immediately recognized and developers will only consider learning them after having spent much time with conventional debugging methods.

We propose an interaction model that generalizes the conventional symbolic debugger so that the known workflow can be kept and users can opt-in to cross-abstraction debugging when necessary. By replacing the traditional list view on the active call chain with a tree model and adding perspective selection, we obtain an unobtrusive, minimal user interface that still offers powerful cross-language debugging features.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Crossing Abstraction Barriers When Debugging In Dynamic Languages

  1. 1. Crossing Abstraction Barriers When Debugging in Dynamic Languages Bastian Kruck, Tobias Pape, Tim Felgentreff, Robert Hirschfeld Software-Architecture Group at HPI Potsdam 5.4.2017
  2. 2. Bug or Feature? Bastian Kruck SAC 2017 Crossing Abstraction Barriers Chart 2
  3. 3. ■ Squeak Debugger ■ VMMaker Simulator ■ Slang Code Generator ■ Bytecode Printer ■ gdb One Debugger For Each Use Case Chart 3 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  4. 4. Cog Primitive Smalltalk Bytecode Smalltalk AST Smalltalk QoppaS Qoppa Scheme begin QoppaInterpreter>>operate:o QoppaOperative>>in:operate [] in QoppaInterpreter>>vau:w eval: (if (null? xs) (quote nil) ( list if Proceed Restart Into Over Q#xs a Cons((if (<= n 1) (begin (halt) acc) (fact-r (- n 1) ( (define list (vau xs env (if (null? xs) ’() (cons (eval env (car xs)) (eval env (cons list (cdr xs))))))) One Debugger For Each Use Case Chart 4 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  5. 5. ■ minInt31 // -1 returns minInt31 ■ Negative divided by negative returns negative ■ Occurs only in JIT-Compiler Scenario Chart 5 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  6. 6. Video Demo: Debugging minInt31 // -1 ■ Motivation ■ Fast-Forward Demo ■ Features: ■ Select A Perspective ■ Primitive Evaluation ■ Transformation Debugging
  7. 7. Connecting multiple high-level debuggers ■ Motivation ■ Fast-Forward Demo ■ Features: ■ Select A Perspective ■ Primitive Evaluation ■ Transformation Debugging
  8. 8. Connecting multiple high-level debuggers: Smalltalk Perspective Chart 9 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  9. 9. Connecting multiple high-level debuggers: Smalltalk AST Perspective Chart 10 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  10. 10. Connecting multiple high-level debuggers: Smalltalk Bytecode Perspective Chart 11 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  11. 11. Background: Hierarchical Call Stacks Chart 12 ■ Conventionally, we see the inspected call stack only ■ Higher-level stacks are groups of inspected stack frame ■ These are formed with interpreters, and embedded languages like libraries, DSLs, frameworks ■ Abstraction author implements grouping perspective Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  12. 12. Abstract ■ Stack-based: Virtual activations group actual activations ■ Loop-based: Actual activations belong to topmost Virtual activation Background: Abstract Virtual Activations Chart 13 Concrete ■ Static Details ■ Low-level blocks □ Closures □ Jumps ■ No live-pc or stepping Actual [1] Bastian Kruck, Stefan Lehmann, Christoph Keßler, Jakob Reschke, Tim Felgentreff, Jens Lincke, Robert Hirschfeld Multi-Level Debugging For Interpreter Developers Cog Primitive Smalltalk Bytecode Smalltalk AST Smalltalk QoppaS Qoppa Scheme begin QoppaInterpreter>>operate:o QoppaOperative>>in:operate [] in QoppaInterpreter>>vau:w eval: (if (null? xs) (quote nil) ( list if Proceed Restart Into Over Q#xs a Cons((if (<= n 1) (begin (halt) acc) (fact-r (- n 1) ( (define list (vau xs env (if (null? xs) ’() (cons (eval env (car xs)) (eval env (cons list (cdr xs))))))) Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  13. 13. Abstract ■ Stack-based: Virtual activations group actual activations ■ Loop-based: Actual activations belong to topmost Virtual activation Background: Abstract Virtual Activations (contd.) Chart 14 Concrete ■ Static Details ■ Low-level blocks □ Closures □ Jumps ■ No live-pc or stepping Actual [1] Bastian Kruck, Stefan Lehmann, Christoph Keßler, Jakob Reschke, Tim Felgentreff, Jens Lincke, Robert Hirschfeld Multi-Level Debugging For Interpreter Developers Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  14. 14. Abstract ■ Stack-based: Virtual activations group actual activations ■ Loop-based: Actual activations belong to topmost Virtual activation Concrete Virtual Activations Chart 15 Concrete ■ Static Details ■ Low-level blocks □ Closures □ Jumps ■ No live-pc or stepping Actual Live Static Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  15. 15. Primitive Evaluation And Stepping ■ Motivation ■ Fast-Forward Demo ■ Features: ■ Select A Perspective ■ Primitive Evaluation ■ Transformation Debugging
  16. 16. ■ Simulate the Integer Division primitive with arguments minInt31 and -1 Primitive Evaluation And Stepping 1 2 3 Evaluation Results Debug on Click
  17. 17. Live VM Debugging Chart 18 ■ Multi-Level Debugging means shifting between primitives and calls ■ Application debugger provides entry point for VM debugger Bastian Kruck SAC 2017
  18. 18. Debugging The Transformator ■ Motivation ■ Fast-Forward Demo ■ Features: ■ Select A Perspective ■ Primitive Evaluation ■ Transformation Debugging ✅ embedded languages ✅ interpreted languages  compiled languages
  19. 19. ■ Click “Debug assembly of this bytecode” ■ Debugger opens halted on the compiler while creating that bytecode ■ We can change and Save the compiler ■ Live VM Debugging ■ Limitation: Running VM can not be swapped on the fly. ■ Assumption: JIT-Compiler is stable Debugging The Transformator Chart 20 1 2 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  20. 20. ■ Step through transformation and observe the created data structure ■ When the bytecode of interest is written, raise an exception ■ Open a debugger on the signaling context Implementation: Seeking A Transformation Chart 21 Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  21. 21. Implementation: Debugged Transformations Chart 22 Level Translator Implementation Lines of Translator- specific Code AST Assembly Stubbed Stream 14 LOC ST Bytecode Assembly Stubbed Stream 22 LOC Printing WaitAndRaiseStream 20 LOC Cogit HIL Assembly Add HIL-PC (Reuse Phase 3 Tracer) & Patched Phase 2 2 + 40 LOC Cogit Machinecode Assembly Patched Phase 3 3 + 27 LOC Printing WaitAndRaiseStream 27 LOC Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  22. 22. Language Levels We Saw Today Chart 23 Smalltalk Program ParseNode AST Smalltalk Bytecode Program Machine Code Program Cogit JIT-C HIL Program Machine Code Program interpreted compiled Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  23. 23. Language Levels We Saw Today Chart 24 Smalltalk Program ParseNode AST Smalltalk Bytecode Program Machine Code Program Cogit JIT-C HIL Program Machine Code Program interpreted compiled ST80 Parser ST80 Compiler CogVM Interpreter CogVM HIL JIT-C CogVM LIL JIT-C evaluated by Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  24. 24. CogVM Language Levels We Saw Today Chart 25 Smalltalk Program ParseNode AST Smalltalk Bytecode Program Machine Code Program ST80 Parser ST80 Compiler CogVM Interpreter CogVM HIL JIT-C Cogit JIT-C HIL Program CogVM LIL JIT-C Machine Code Program CCodeGenerator C Program C Compiler interpreted compiled Slang evaluated by Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  25. 25. CogVM Language Levels in our system Speaker, Job Description, Date if needed Presentation Title Chart 26 Scheme Program Qoppa Program Smalltalk Program ParseNode AST Smalltalk Bytecode Program Machine Code Program Qoppa Prelude QoppaS ST80 Parser ST80 Compiler CogVM Interpreter CogVM HIL JIT-C Cogit JIT-C HIL Program CogVM LIL JIT-C Machine Code Program CCodeGenerator C Program C Compiler embedded interpreted compiled Slang evaluated by Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  26. 26. Crossing Abstraction Barriers When Debugging in Dynamic Languages Chart 27 Embedded, Interpreted, Compiled Live Debugging Of Transformators Virtual Activations & Perspectives Join point for Tools Primitive Simulate Bastian Kruck SAC 2017 Crossing Abstraction Barriers
  27. 27. Thank you for your attention! Bastian Kruck Master Student at Hasso Plattner Institute Potsdam
  28. 28. ■ The perspective implementation for this JIT-Compiler is stable □ i.e. “Translator(program) = assembly” is a pure function ■ Perspectives may implement arbitrarily how to □ retrieve the evaluation result of a primitive and □ how to step through it Stability Speaker, Job Description, Date if needed Presentation Title Chart 29
  29. 29. ■ Consisting of: □ Primitive Operations □ Procedures □ Call Operation ■ e.g. Stack Machines ■ Various Perspectives: □ … □ Smalltalk □ Smalltalk AST □ Smalltalk Bytecode □ … Background: Layered Abstractions Bastian Kruck 1.3.2017 Live Programming For VMs Chart 30 Figure source: Daniel D Gajski, Samar Abdi, Andreas Gerstlauer, and Gunar Schirner. Embedded System Design: Modeling, Synthesis and Verification, p. 3
  30. 30. ■ WaitAndRaiseFoundIt ■ COP use case: one layer per phase allows us avoid hacking with machineCodeSize or initializing Cogit Translator Tracing Implementation
  31. 31. ■ An MLDVerifier strategy can □ compute a primitive value based on primitiveIndex, receiver and arguments □ construct an execution context that a debugger can use. ■ Example: MLDVerifierForVm □ compile method with primIndex □ run it Implementation: Primitive Verification Speaker, Job Description, Date if needed Presentation Title Chart 32
  32. 32. MLDVerifierForVm>>resultGeneratingBlockFor: result ■ creates context that evaluates the primitive ■ automatically steps into method of interest Implementation: Primitive Verification Speaker, Job Description, Date if needed Presentation Title Chart 33
  33. 33. ■ Initialize array with empty instructions (the high-level intermediate language, HIL) ■ Cycle over it 1. initializeCodeZoneFrom:upTo: (e.g. generateOpenPICPrototype) 2. generate native operations (compileEntireMethod) 3. build machine code for each (generateInstructionsAt:) 4. copy each to object space (outputInstructionsAt:) ■ To map from instruction pointer to HIL instruction, we □ determine HIL pc (Raise when writing to IP address in Phase 3.) □ halt when mapping ST80-bytecode to native instructions (Raise when writing given HIL-PC in Phase 2.) Cogit Translation Tracing Speaker, Job Description, Date if needed Presentation Title Chart 34
  34. 34. ■ Compiler(translator source) = translator assembly ■ Translator(program) = assembly ■ For interpreters, the assembly is an object structure Background: 4 Language Levels A Translation Debugger Acts Upon

×