debug info tutorial
play

Debug Info Tutorial Eric Christopher (echristo@gmail.com), David - PowerPoint PPT Presentation

Debug Info Tutorial Eric Christopher (echristo@gmail.com), David Blaikie (dblaikie@gmail.com) What is debug info? Mapping of source to binary Program structure, lines, columns, variables Debuggers, Profiling, Editors Kaleidoscope Background


  1. Debug Info Tutorial Eric Christopher (echristo@gmail.com), David Blaikie (dblaikie@gmail.com)

  2. What is debug info? Mapping of source to binary Program structure, lines, columns, variables Debuggers, Profiling, Editors

  3. Kaleidoscope Background What is it? http://llvm.org/docs/tutorial/ How does it work? Jitting and top level statements

  4. Kaleidoscope Background Example program:

  5. Kaleidoscope Background - Changes JIT disabled Optimization passes disabled Remove helpful prompts and status

  6. What is DWARF then? Standard for how to encode program structure, lines, columns, variables Permissive standard with vendor extensions Probably a bit too permissive

  7. DWARF Vaguaries DWARF consumers not generalized because they’ve only seen output from one tool (GDB works great with GCC’s DWARF output) is_stmt - a line table feature “indicating that the current instruction is a recommended breakpoint location” - omitting this caused GDB to do… strange things.

  8. DWARF Structure debug_info: source construct description (functions, types, namespaces, etc) debug_line: instruction -> source line mapping Use and similar tools to examine this data in object and executable files. Bunch of other implementation details probably not worth discussing on a first pass: debug_loc, debug_ranges, debug_string, debug_abbrev, etc.

  9. DWARF Structure - Info Hierarchical tag+attribute format, imagine something like a binary XML.

  10. DWARF Structure - Line Table State machine & all that, but if you’re just reading it it’s fairly simple

  11. DIBuilder Background The debug info equivalent of IRBuilder - a helper API for building LLVM IR metadata for debug info … … …

  12. Module level setup Add a module flag with the debug info version! Not all targets support all dwarf!

  13. Kaleidoscope Dwarf Additions Language Name - DW_LANG_KS Couple of simple places to put it in LLVM. No vendor range for this so use with caution.

  14. Creating the Compile Unit - Code

  15. Creating the Compile Unit - Metadata

  16. Creating the Compile Unit - DWARF

  17. Types - Code

  18. Types - Metadata … [ ] [ ] [line 0, size 64, align 64, offset 0, enc DW_ATE_float]

  19. Types - DWARF

  20. Functions - Code

  21. Functions - Code

  22. Functions - Metadata … … … … … … …

  23. Functions - DWARF

  24. Line Information - A Digression Build source location information into your front end! Build AST and Lexer dumping mechanisms!

  25. Line Information - Code

  26. Line Information - Metadata … Optimizations know how to propagate this information when transforming instructions.

  27. Line Information - DWARF

  28. Line Information - DWARF

  29. Variables - Code

  30. Variables - A Bit More Code

  31. Variables - Metadata Only works well with allocas, some limited support when in reg. … … … … …

  32. Variables - DWARF

  33. Inlining you are investigating issues in inlining debug info quality you want to simulate inlining in your front end’s codegen you’re implementing a custom inlining pass in LLVM … … … …

  34. Inlining DWARF Allows debuggers to simulate distinct function calls, even after they’ve been inlined. … …

  35. Debugger Support DW_LANG_KS isn’t supported by any debugger… … but DW_LANG_C is!

  36. Questions?

Recommend


More recommend