x/debug: implement server.handleBreakpointAtLine.  Add a function to x/debug/dwarf for converting source lines to addresses.

Make line numbers uint64s everywhere instead of ints.

PCToLine: the previous logic considered that we had found the PC if the
line machine reaches an equal-or-larger address, but the line machine
can consist of multiple sequences which aren't guaranteed to be in order
of address.  It now checks that within one sequence we output the PC, or
pass from a PC below it to a PC above it.

LineToPCs: the caller may provide us a partial path name, so we use a
heuristic to choose which file in the executable is the best match.  We
choose the file where the largest number of trailing path components
match.  We break ties by choosing the file with the shortest name.

evalCompilationUnit: call a function at each output from the line
machine, so we can use this function for both PCToLine and LineToPCs.

Rename "prologue" to "header" to avoid confusion with function

Separate header parsing out of evalCompilationUnit so that LineToPCs has
access to file names before it starts processing line machine

Some minor fixes to evalCompilationUnit:  Make the line machine output
at special opcodes and at the ends of sequences.  Continue processing
until we reach the end of the line machine, not until when we reach the
end of a sequence.  For the copy opcode, do the output before updating
registers.  For DW_LNS_const_add_pc, only perform the step of special
opcode 255 that updates the address and op_index registers, and remove
the associated TODO.  If we reach the end of the line machine without
seeing the end of the current sequence, return an error, don't panic.

Change-Id: I140ca299313ad1d54971557a05dc46d7c6c349a4
Reviewed-on: https://go-review.googlesource.com/11350
Reviewed-by: Rob Pike <r@golang.org>
4 files changed