mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: plumb prologueEnd into DWARF
This marks the first instruction after the prologue for consumption by debuggers, specifically Delve, who asked for it. gdb appears to ignore it, lldb appears to use it. The bits for end-of-prologue and beginning-of-epilogue are added to Pos (reducing maximum line number by 4x, to 1048575). They're added in cmd/internal/obj/<ARCH>.go (currently x86 only), so the compiler-proper need not deal with them. The linker currently does nothing with beginning-of-epilogue, but the plumbing exists to make it easier in the future. This also upgrades the line number table to DWARF version 3. This CL includes a regression in the coverage for testdata/i22558.gdb-dbg.nexts, this appears to be a gdb artifact but the fix would be in the preceding CL in the stack. Change-Id: I3bda5f46a0ed232d137ad48f65a14835c742c506 Reviewed-on: https://go-review.googlesource.com/110416 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
c2c1822b12
commit
7bac2a95f6
6 changed files with 127 additions and 16 deletions
|
|
@ -15,6 +15,7 @@ package ld
|
|||
|
||||
import (
|
||||
"cmd/internal/dwarf"
|
||||
"cmd/internal/obj"
|
||||
"cmd/internal/objabi"
|
||||
"cmd/internal/sys"
|
||||
"cmd/link/internal/sym"
|
||||
|
|
@ -953,7 +954,7 @@ const (
|
|||
LINE_BASE = -4
|
||||
LINE_RANGE = 10
|
||||
PC_RANGE = (255 - OPCODE_BASE) / LINE_RANGE
|
||||
OPCODE_BASE = 10
|
||||
OPCODE_BASE = 11
|
||||
)
|
||||
|
||||
func putpclcdelta(linkctxt *Link, ctxt dwarf.Context, s *sym.Symbol, deltaPC uint64, deltaLC int64) {
|
||||
|
|
@ -1157,7 +1158,7 @@ func writelines(ctxt *Link, lib *sym.Library, textp []*sym.Symbol, ls *sym.Symbo
|
|||
unitLengthOffset := ls.Size
|
||||
ls.AddUint32(ctxt.Arch, 0) // unit_length (*), filled in at end.
|
||||
unitstart = ls.Size
|
||||
ls.AddUint16(ctxt.Arch, 2) // dwarf version (appendix F)
|
||||
ls.AddUint16(ctxt.Arch, 3) // dwarf version (appendix F)
|
||||
headerLengthOffset := ls.Size
|
||||
ls.AddUint32(ctxt.Arch, 0) // header_length (*), filled in at end.
|
||||
headerstart = ls.Size
|
||||
|
|
@ -1177,6 +1178,7 @@ func writelines(ctxt *Link, lib *sym.Library, textp []*sym.Symbol, ls *sym.Symbo
|
|||
ls.AddUint8(0) // standard_opcode_lengths[7]
|
||||
ls.AddUint8(0) // standard_opcode_lengths[8]
|
||||
ls.AddUint8(1) // standard_opcode_lengths[9]
|
||||
ls.AddUint8(0) // standard_opcode_lengths[10]
|
||||
ls.AddUint8(0) // include_directories (empty)
|
||||
|
||||
// Create the file table. fileNums maps from global file
|
||||
|
|
@ -1271,8 +1273,19 @@ func writelines(ctxt *Link, lib *sym.Library, textp []*sym.Symbol, ls *sym.Symbo
|
|||
|
||||
// Only changed if it advanced
|
||||
if is_stmt != uint8(pcstmt.value) {
|
||||
is_stmt = uint8(pcstmt.value)
|
||||
ls.AddUint8(uint8(dwarf.DW_LNS_negate_stmt))
|
||||
new_stmt := uint8(pcstmt.value)
|
||||
switch new_stmt &^ 1 {
|
||||
case obj.PrologueEnd:
|
||||
ls.AddUint8(uint8(dwarf.DW_LNS_set_prologue_end))
|
||||
case obj.EpilogueBegin:
|
||||
// TODO if there is a use for this, add it.
|
||||
// Don't forget to increase OPCODE_BASE by 1 and add entry for standard_opcode_lengths[11]
|
||||
}
|
||||
new_stmt &= 1
|
||||
if is_stmt != new_stmt {
|
||||
is_stmt = new_stmt
|
||||
ls.AddUint8(uint8(dwarf.DW_LNS_negate_stmt))
|
||||
}
|
||||
}
|
||||
|
||||
// putpcldelta makes a row in the DWARF matrix, always, even if line is unchanged.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue