Unstuck

769 views
721 views

Published on

Design And Implementation of a Backward-In-Time Debugger

Traditional debugging and stepping execution trace are well-accepted techniques to understand deep internals about a program. However in many cases navigating the stack trace is not enough to find bugs, since the cause of a bug is often not in the stack trace anymore and old state is lost, so out of reach from the debugger. In this paper, we present the design and implementation of a backward-in-time debugger for a dynamic language, i.e, a debugger that allows one to navigate back the history of the application. We present the design and implementation of a backward-in-time debugger called Unstuck and show our solution to key implementation challenges.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
769
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Unstuck

  1. 1. Design and Implementation of a Backward-In-Time Debugger Christoph Hofer Marcus Denker Stephane Ducasse © Marcus Denker
  2. 2. Roadmap > Problem > Unstuck: A new Debugger for Squeak > Implementation > Lessons Learned > Future work © Marcus Denker
  3. 3. Problem > Debugger: Snapshot of state at time of error > Cause for errors is in the past — Who assigned *that* value? > very incomplete history available — guess were to set breakpoint, rerun © Marcus Denker
  4. 4. Example Foo>>initialize Foo>>bar var1 := 0. ...... var2 := ''. Foo>>moreBar Foo>>start var2 size > 0 ifTrue:[ self beforeBar. ^var2 at: 1]. self bar. ^'' self moreBar. Foo>>beforeBar var1 = 0 ifTrue: [ var2 := nil.] © Marcus Denker
  5. 5. Stack Trace > Squeak Debugger > Shows stack trace — methods not returned — old state lost © Marcus Denker
  6. 6. Stack Trace > Squeak Debugger > Shows stack trace — methods not returned — old state lost © Marcus Denker
  7. 7. Solution > We want: — Record the history of the program — View the state at any point in the past > Unstuck — A new Debugger for Squeak — Provides full trace information © Marcus Denker
  8. 8. Unstuck UI 1. Trace 2. Object 3. Code 4. History 5. Query © Marcus Denker
  9. 9. Searching Variable Search Domain event All events send all message sends return all method returns varAccess all variable accesses instVarAccess instance variable access tempVarAccess temporary variables © Marcus Denker
  10. 10. Searching: Example Query Result send selector = #foo All the executed methods named ”foo” return returnValue > 4 All returns with a return value greater than 4 events isSend & Message sends with exactly (even arguments size = 1) one argument © Marcus Denker
  11. 11. Coloring > We can assign a color to any object > Easy tracking of objects > Color is shown in all views of the UI © Marcus Denker
  12. 12. Implementation Debugger uses Trace Library uses ByteSurgeon © Marcus Denker
  13. 13. ByteSurgeon > Framework for editing bytecode for Squeak — Like Javasist in Java, but: > Uses structural reflection to transform at runtime — Simple model: Inline code before / after a bytecode — Inlined code is normal smalltalk code — Not much knowledge about bytecode needed © Marcus Denker
  14. 14. Trace Library > Called from annotated code > Builds up the trace > Provides — Trace model — Event pre-processing (ordering) — State reconstruction © Marcus Denker
  15. 15. State reconstruction > State not recorded for completely annotated classes — past state can be reconstructed from trace > System never completely annotated — Tracer saves state of non-annotated objects © Marcus Denker
  16. 16. Debugging system classes > Annotate classes used by Bytesurgeon or Tracer — System classes (e.g. Collection or String) — Compiler (e.g. AST) > Problems: — Classes used for annotation --> crash — Tracer records events generated by the tracer © Marcus Denker
  17. 17. Solution > Retain both methods (original + annotated) > Generate preamble — test for global — call original methods when inactive > Common problem when using reflection! — General solution? — Future work! © Marcus Denker
  18. 18. Benchmarks Events Slowdown Memory (Kb) Example 74 6 16 AST Bug 2725 3.8 800 Pier Trace 389689 248 88800 © Marcus Denker
  19. 19. Future Work > further analyze + improve — Memory Consumption (GC effects) — Performance > Use behavioral reflection — fine grained selection — Scoping — Annotation of system classes © Marcus Denker
  20. 20. Conclusion > Problem of current debugging tools > Overview of Unstuck — UI — Implementation > Having the history available helps — Possible for small programs — Work needed for bigger systems + continuous use © Marcus Denker
  21. 21. Conclusion > Problem of current debugging tools > Overview of Unstuck — UI — Implementation Questions? > Having the history available helps — Possible for small programs — Work needed for bigger systems + continuous use © Marcus Denker

×