Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Add debug info for labels to Odin

Open tf2spi opened this issue 1 year ago • 1 comments

This is a PR that adds debug info for labels in the Odin compiler, so now labels attached to statements in general like if, block, for, etc., have debug info.

package labels
import "core:fmt"
main :: proc() {
        myloop: for i in 0..<5 {
                fmt.println("We have debug labels now!")
        }

        myswitch: switch true {
                case:
                        fmt.println("Debug labels on switches but not in cases")
        }
        myif: if true {
                fmt.println("Debug labels on if statements")
        }
        // etc...
}

This is useful because debuggers can discern the location of code given a function and label and do actions to it like putting breakpoints on it. It's less finnicky than line breakpoints when it comes to source code changes.

# This works on gdb and puts a breakpoint on the 'myif' label in the code above
b labels.main:myif

tf2spi avatar Oct 17 '24 01:10 tf2spi