Debug Info

References:

Debugger Intrinsic Functions

LLVM uses several intrinsic functions (name prefixed with “llvm.dbg”) to track source local variables through optimization and code generation.

  • void @llvm.dbg.addr(metadata, metadata, metadata). Information about a local element (e.g., variable)
    • first argument is metadata holding the address of the variable, typically a static alloca in the function entry block.
    • Second argument is a local variable containing a description of the variable.
    • Third argument is an expression DIExpression.
  • void @llvm.dbg.declare(metadata, metadata, metadata). identical to llvm.dbg.addr, except that there can only be one call to llvm.dbg.declare for a given concrete local variable.
    • The debug location is not control-dependent. That means that if a call to llvm.dbg.declare exists and has a valid location argument, that address is considered to be the true home of the variable across the entire lifetime.
  • void @llvm.dbg.value(metadata, metadata, metadata). Provides information when a user source variable is set to a new value. Describes the value of a source variable directly, not its address.
    • First argument is the new value (Wrapped as metadata).
    • Second argument is a local variable containing a description of the variable.
    • Third argument is a DIExpression.

Object lifetimes and scoping

Reference:

More

  • DIExpression
  • References: LLVM langRef – DIExpression DIExpression nodes: expressions that are inspired by the DWARF expression language. Used to describe how the referenced LLVM variable relates to the source language variable. Debug intrinsics are interpreted left-to-right: start by pushing the value/address operand of the intrinsic onto a stack, then repeatedly push and evaluate opcodes from the DIExpression until the final variable description is produced. Example opcodes: DW_OP_deref: deferences the top of the expression stack; DW_OP_plus: pops the last two entries from the expression stack, adds them together and appends the result to the expression stack.

Created Sep 14, 2020 // Last Updated Sep 16, 2020

If you could revise
the fundmental principles of
computer system design
to improve security...

... what would you change?