1
0
mirror of https://github.com/golang/go synced 2024-11-19 06:04:39 -07:00

[568]a: precise linenumbers for statements.

R=rsc, ken2, r, rsc1
CC=golang-dev
https://golang.org/cl/2297042
This commit is contained in:
Luuk van Dijk 2010-10-07 11:13:06 +02:00
parent cc5c2ee0ec
commit 2ad521c19a
10 changed files with 54 additions and 34 deletions

View File

@ -148,6 +148,7 @@ EXTERN int pass;
EXTERN char* pathname; EXTERN char* pathname;
EXTERN int32 pc; EXTERN int32 pc;
EXTERN int peekc; EXTERN int peekc;
EXTERN int32 stmtline;
EXTERN int sym; EXTERN int sym;
EXTERN char* symb; EXTERN char* symb;
EXTERN int thechar; EXTERN int thechar;

View File

@ -63,7 +63,11 @@
%type <gen> imm ximm name oreg ireg nireg ioreg imsr %type <gen> imm ximm name oreg ireg nireg ioreg imsr
%% %%
prog: prog:
| prog line | prog
{
stmtline = lineno;
}
line
line: line:
LLAB ':' LLAB ':'

View File

@ -658,10 +658,10 @@ jackpot:
Bputc(&obuf, a); Bputc(&obuf, a);
Bputc(&obuf, scond); Bputc(&obuf, scond);
Bputc(&obuf, reg); Bputc(&obuf, reg);
Bputc(&obuf, lineno); Bputc(&obuf, stmtline);
Bputc(&obuf, lineno>>8); Bputc(&obuf, stmtline>>8);
Bputc(&obuf, lineno>>16); Bputc(&obuf, stmtline>>16);
Bputc(&obuf, lineno>>24); Bputc(&obuf, stmtline>>24);
zaddr(g1, sf); zaddr(g1, sf);
zaddr(g2, st); zaddr(g2, st);

View File

@ -161,6 +161,7 @@ EXTERN int pass;
EXTERN char* pathname; EXTERN char* pathname;
EXTERN int32 pc; EXTERN int32 pc;
EXTERN int peekc; EXTERN int peekc;
EXTERN int32 stmtline;
EXTERN int sym; EXTERN int sym;
EXTERN char* symb; EXTERN char* symb;
EXTERN int thechar; EXTERN int thechar;

View File

@ -60,7 +60,11 @@
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 %type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%% %%
prog: prog:
| prog line | prog
{
stmtline = lineno;
}
line
line: line:
LLAB ':' LLAB ':'

View File

@ -1260,10 +1260,10 @@ jackpot:
} }
Bputc(&obuf, a); Bputc(&obuf, a);
Bputc(&obuf, a>>8); Bputc(&obuf, a>>8);
Bputc(&obuf, lineno); Bputc(&obuf, stmtline);
Bputc(&obuf, lineno>>8); Bputc(&obuf, stmtline>>8);
Bputc(&obuf, lineno>>16); Bputc(&obuf, stmtline>>16);
Bputc(&obuf, lineno>>24); Bputc(&obuf, stmtline>>24);
zaddr(&g2->from, sf); zaddr(&g2->from, sf);
zaddr(&g2->to, st); zaddr(&g2->to, st);

View File

@ -162,6 +162,7 @@ EXTERN int pass;
EXTERN char* pathname; EXTERN char* pathname;
EXTERN int32 pc; EXTERN int32 pc;
EXTERN int peekc; EXTERN int peekc;
EXTERN int32 stmtline;
EXTERN int sym; EXTERN int sym;
EXTERN char* symb; EXTERN char* symb;
EXTERN int thechar; EXTERN int thechar;

View File

@ -64,7 +64,11 @@
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 %type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8
%% %%
prog: prog:
| prog line | prog
{
stmtline = lineno;
}
line
line: line:
LLAB ':' LLAB ':'

View File

@ -925,10 +925,10 @@ jackpot:
} }
Bputc(&obuf, a); Bputc(&obuf, a);
Bputc(&obuf, a>>8); Bputc(&obuf, a>>8);
Bputc(&obuf, lineno); Bputc(&obuf, stmtline);
Bputc(&obuf, lineno>>8); Bputc(&obuf, stmtline>>8);
Bputc(&obuf, lineno>>16); Bputc(&obuf, stmtline>>16);
Bputc(&obuf, lineno>>24); Bputc(&obuf, stmtline>>24);
zaddr(&g2->from, sf); zaddr(&g2->from, sf);
zaddr(&g2->to, st); zaddr(&g2->to, st);

View File

@ -436,7 +436,7 @@ decodez(char *s)
* The line history itself * The line history itself
*/ */
static char **histfile; // [0] holds the empty string. static char **histfile; // [0] holds "<eof>", DW_LNS_set_file arguments must be > 0.
static int histfilesize; static int histfilesize;
static int histfilecap; static int histfilecap;
@ -445,7 +445,7 @@ clearhistfile(void)
{ {
int i; int i;
// [0] holds the empty string. // [0] holds "<eof>"
for (i = 1; i < histfilesize; i++) for (i = 1; i < histfilesize; i++)
free(histfile[i]); free(histfile[i]);
histfilesize = 0; histfilesize = 0;
@ -762,6 +762,11 @@ writelines(void)
diag("corrupt history or bad absolute line: %P", q); diag("corrupt history or bad absolute line: %P", q);
continue; continue;
} }
if (lh->file < 1) { // 0 is the past-EOF entry.
diag("instruction with linenumber past EOF in %s: %P", unitname, q);
continue;
}
lline = lh->line + q->line - lh->absline; lline = lh->line + q->line - lh->absline;
if (debug['v'] > 1) if (debug['v'] > 1)
print("%6llux %s[%lld] %P\n", q->pc, histfile[lh->file], lline, q); print("%6llux %s[%lld] %P\n", q->pc, histfile[lh->file], lline, q);