Skip to content

Commit 376fc48

Browse files
committed
cmd/compile: add new symbol for debug line numbers
This is broken out from: CL 187117 This new symbol will be populated by the compiler and contain debug line information that's currently generated in the linker. One might say it's sad to create a new symbol, but this symbol will replace the isStmt symbols. Testing: Ran go build -toolexec 'toolstash -cmp' Change-Id: If8f7ae4b43b7247076605b6429b7d03a1fd239c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/188238 Reviewed-by: Austin Clements <[email protected]>
1 parent f4ca3c1 commit 376fc48

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

src/cmd/internal/dwarf/dwarf.go

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const RangePrefix = "go.range."
3030
// IsStmtPrefix is the prefix for all the symbols containing DWARF is_stmt info for the line number table.
3131
const IsStmtPrefix = "go.isstmt."
3232

33+
// DebugLinesPrefix is the prefix for all the symbols containing DWARF debug_line information from the compiler.
34+
const DebugLinesPrefix = "go.debuglines."
35+
3336
// ConstInfoPrefix is the prefix for all symbols containing DWARF info
3437
// entries that contain constants.
3538
const ConstInfoPrefix = "go.constinfo."

src/cmd/internal/obj/link.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,12 @@ type FuncInfo struct {
402402
Pcln Pcln
403403
InlMarks []InlMark
404404

405-
dwarfInfoSym *LSym
406-
dwarfLocSym *LSym
407-
dwarfRangesSym *LSym
408-
dwarfAbsFnSym *LSym
409-
dwarfIsStmtSym *LSym
405+
dwarfInfoSym *LSym
406+
dwarfLocSym *LSym
407+
dwarfRangesSym *LSym
408+
dwarfAbsFnSym *LSym
409+
dwarfIsStmtSym *LSym
410+
dwarfDebugLinesSym *LSym
410411

411412
GCArgs *LSym
412413
GCLocals *LSym

src/cmd/internal/obj/objfile.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func isDwarf64(ctxt *Link) bool {
537537
return ctxt.Headtype == objabi.Haix
538538
}
539539

540-
func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym, dwarfAbsFnSym, dwarfIsStmtSym *LSym) {
540+
func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym, dwarfAbsFnSym, dwarfIsStmtSym, dwarfDebugLines *LSym) {
541541
if s.Type != objabi.STEXT {
542542
ctxt.Diag("dwarfSym of non-TEXT %v", s)
543543
}
@@ -551,9 +551,9 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym,
551551
s.Func.dwarfAbsFnSym = ctxt.DwFixups.AbsFuncDwarfSym(s)
552552
}
553553
s.Func.dwarfIsStmtSym = ctxt.LookupDerived(s, dwarf.IsStmtPrefix+s.Name)
554-
554+
s.Func.dwarfDebugLinesSym = ctxt.LookupDerived(s, dwarf.DebugLinesPrefix+s.Name)
555555
}
556-
return s.Func.dwarfInfoSym, s.Func.dwarfLocSym, s.Func.dwarfRangesSym, s.Func.dwarfAbsFnSym, s.Func.dwarfIsStmtSym
556+
return s.Func.dwarfInfoSym, s.Func.dwarfLocSym, s.Func.dwarfRangesSym, s.Func.dwarfAbsFnSym, s.Func.dwarfIsStmtSym, s.Func.dwarfDebugLinesSym
557557
}
558558

559559
func (s *LSym) Len() int64 {
@@ -577,7 +577,7 @@ func (ctxt *Link) fileSymbol(fn *LSym) *LSym {
577577
// TEXT symbol 's'. The various DWARF symbols must already have been
578578
// initialized in InitTextSym.
579579
func (ctxt *Link) populateDWARF(curfn interface{}, s *LSym, myimportpath string) {
580-
info, loc, ranges, absfunc, _ := ctxt.dwarfSym(s)
580+
info, loc, ranges, absfunc, _, _ := ctxt.dwarfSym(s)
581581
if info.Size != 0 {
582582
ctxt.Diag("makeFuncDebugEntry double process %v", s)
583583
}

src/cmd/internal/obj/plist.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int) {
137137
ctxt.Text = append(ctxt.Text, s)
138138

139139
// Set up DWARF entries for s.
140-
info, loc, ranges, _, isstmt := ctxt.dwarfSym(s)
140+
info, loc, ranges, _, isstmt, _ := ctxt.dwarfSym(s)
141141
info.Type = objabi.SDWARFINFO
142142
info.Set(AttrDuplicateOK, s.DuplicateOK())
143143
if loc != nil {

src/cmd/internal/objabi/symkind.go

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060
SDWARFRANGE
6161
SDWARFLOC
6262
SDWARFMISC
63+
SDWARFLINES
6364
// ABI alias. An ABI alias symbol is an empty symbol with a
6465
// single relocation with 0 size that references the native
6566
// function implementation symbol.

src/cmd/link/internal/sym/symkind.go

+2
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const (
110110
SDWARFINFO
111111
SDWARFRANGE
112112
SDWARFLOC
113+
SDWARFLINES
113114
SDWARFMISC // Not really a section; informs/affects other DWARF section generation
114115

115116
// ABI aliases (these never appear in the output)
@@ -130,6 +131,7 @@ var AbiSymKindToSymKind = [...]SymKind{
130131
SDWARFINFO,
131132
SDWARFRANGE,
132133
SDWARFLOC,
134+
SDWARFLINES,
133135
SDWARFMISC,
134136
SABIALIAS,
135137
}

src/cmd/link/internal/sym/symkind_string.go

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)