Skip to content

Commit 01b6109

Browse files
SARG-FBjayrm
authored andcommitted
Fix for debugging lines in include files but not in procedures
1 parent c0fdfeb commit 01b6109

File tree

13 files changed

+77
-45
lines changed

13 files changed

+77
-45
lines changed

src/compiler/ast-node-misc.bas

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ end function
152152
function astNewDBG _
153153
( _
154154
byval op as integer, _
155-
byval ex as integer _
155+
byval ex As Integer, _
156+
byval filename As ZString Ptr _
156157
) as ASTNODE ptr
157158

158159
dim as ASTNODE ptr n = any
@@ -165,13 +166,14 @@ function astNewDBG _
165166

166167
n->dbg.op = op
167168
n->dbg.ex = ex
169+
n->dbg.filename = filename
168170

169171
function = n
170172
end function
171173

172174
function astLoadDBG( byval n as ASTNODE ptr ) as IRVREG ptr
173175
if( ast.doemit ) then
174-
irEmitDBG( n->dbg.op, astGetProc( )->sym, n->dbg.ex )
176+
irEmitDBG( n->dbg.op, astGetProc( )->sym, n->dbg.ex, n->dbg.filename )
175177
end if
176178

177179
function = NULL

src/compiler/ast.bi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ type AST_NODE_JMPTB
172172
end type
173173

174174
type AST_NODE_DBG
175-
ex as integer
176-
op as integer
175+
ex as integer
176+
filename as ZString Ptr
177+
op as integer
177178
end type
178179

179180
type AST_NODE_MEM
@@ -793,8 +794,9 @@ declare function astNewASM( byval asmtokhead as ASTASMTOK ptr ) as ASTNODE ptr
793794

794795
declare function astNewDBG _
795796
( _
796-
byval op as integer, _
797-
byval ex as integer = 0 _
797+
byval op As integer, _
798+
byval ex as integer = 0, _
799+
byval filename As ZString Ptr = 0 _
798800
) as ASTNODE ptr
799801

800802
declare function astNewMEM _

src/compiler/edbg_stab.bas

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,13 @@ sub edbgLineBegin _
266266
( _
267267
byval proc as FBSYMBOL ptr, _
268268
byval lnum as integer, _
269-
byval pos_ as integer _
269+
byval pos_ as Integer, _
270+
ByVal filename As ZString Ptr _
270271
)
271272

272273
if( env.clopt.debuginfo = FALSE ) then
273274
exit sub
274-
end if
275+
end If
275276

276277
if( ctx.lnum > 0 ) then
277278
ctx.pos = pos_ - ctx.pos
@@ -281,6 +282,8 @@ sub edbgLineBegin _
281282
end if
282283
end if
283284

285+
edbgInclude(filename)
286+
284287
ctx.pos = pos_
285288
ctx.lnum = lnum
286289
if( ctx.isnewline ) then
@@ -530,7 +533,7 @@ sub edbgEmitProcHeader _
530533

531534
''
532535
ctx.isnewline = TRUE
533-
ctx.lnum = 0
536+
ctx.lnum = 0
534537
ctx.pos = 0
535538
ctx.label = NULL
536539

@@ -645,7 +648,7 @@ sub edbgEmitProcFooter _
645648

646649
''
647650
ctx.isnewline = TRUE
648-
ctx.lnum = 0
651+
ctx.lnum = 0
649652
ctx.pos = 0
650653
ctx.label = NULL
651654

src/compiler/emit.bas

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ sub emitFlush( )
204204
case EMIT_NODECLASS_DBG
205205
cast( EMIT_DBGCB, emit.opFnTb[n->dbg.op] )( n->dbg.sym, _
206206
n->dbg.lnum, _
207-
n->dbg.pos )
207+
n->dbg.pos, _
208+
n->dbg.filename )
208209

209210
end select
210211

@@ -456,7 +457,8 @@ private function hNewDBG _
456457
byval op as integer, _
457458
byval sym as FBSYMBOL ptr, _
458459
byval lnum as integer = 0, _
459-
byval pos_ as integer = 0 _
460+
byval pos_ as integer = 0, _
461+
ByVal filename As ZString Ptr =0 _
460462
) as EMIT_NODE ptr static
461463

462464
dim as EMIT_NODE ptr n
@@ -466,6 +468,7 @@ private function hNewDBG _
466468
n->dbg.op = op
467469
n->dbg.sym = sym
468470
n->dbg.lnum = lnum
471+
n->dbg.filename = filename
469472
n->dbg.pos = pos_
470473

471474
function = n
@@ -1632,10 +1635,11 @@ end function
16321635
function emitDBGLineBegin _
16331636
( _
16341637
byval proc as FBSYMBOL ptr, _
1635-
byval lnum as integer _
1638+
byval lnum as Integer, _
1639+
ByVal filename As ZString Ptr _
16361640
) as EMIT_NODE ptr
16371641

1638-
function = hNewDBG( EMIT_OP_LINEINI, proc, lnum, emit.pos )
1642+
function = hNewDBG( EMIT_OP_LINEINI, proc, lnum, emit.pos, filename )
16391643

16401644
end function
16411645

src/compiler/emit.bi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ type EMIT_DBGNODE
199199
op as integer
200200
sym as FBSYMBOL ptr
201201
lnum as integer
202+
filename As ZString Ptr
202203
pos as integer
203204
end type
204205

@@ -261,7 +262,8 @@ type EMIT_MEMCB as sub( byval dvreg as IRVREG ptr, _
261262

262263
type EMIT_DBGCB as sub( byval sym as FBSYMBOL ptr, _
263264
byval lnum as integer, _
264-
byval pos as integer )
265+
byval pos as Integer, _
266+
ByVal filename As ZString Ptr =0 )
265267

266268
'' if changed, update the _vtbl symbols at emit_*.bas::*_ctor
267269
type EMIT_VTBL
@@ -790,7 +792,8 @@ declare function emitSTKCLEAR _
790792
declare function emitDBGLineBegin _
791793
( _
792794
byval proc as FBSYMBOL ptr, _
793-
byval ex as integer _
795+
byval ex as Integer, _
796+
ByVal filename As ZString Ptr _
794797
) as EMIT_NODE ptr
795798

796799
declare function emitDBGLineEnd _

src/compiler/emit_x86.bas

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6049,10 +6049,11 @@ private sub _emitLINEINI _
60496049
( _
60506050
byval proc as FBSYMBOL ptr, _
60516051
byval lnum as integer, _
6052-
byval pos_ as integer _
6052+
byval pos_ as Integer, _
6053+
ByVal filename As ZString Ptr _
60536054
)
60546055

6055-
edbgLineBegin( proc, lnum, pos_ )
6056+
edbgLineBegin( proc, lnum, pos_, filename )
60566057

60576058
end sub
60586059

src/compiler/emitdbg.bi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ declare sub edbgLineBegin _
99
( _
1010
byval proc as FBSYMBOL ptr, _
1111
byval lnum as integer, _
12-
byval pos as integer _
12+
byval pos as Integer, _
13+
ByVal filename as ZString Ptr _
1314
)
1415

1516
declare sub edbgLineEnd _

src/compiler/ir-hlc.bas

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ type IRHLCCTX
192192
section as integer '' Current section to write to
193193
sectiongosublevel as integer
194194

195-
linenum as integer
195+
lnum as integer
196196
escapedinputfilename as string
197197
usedbuiltins as uinteger '' BUILTIN_*
198198

@@ -223,7 +223,8 @@ declare sub _emitDBG _
223223
( _
224224
byval op as integer, _
225225
byval proc as FBSYMBOL ptr, _
226-
byval ex as integer _
226+
byval lnum as Integer, _
227+
ByVal filename As ZString Ptr = 0 _
227228
)
228229

229230
declare sub exprFreeNode( byval n as EXPRNODE ptr )
@@ -385,7 +386,7 @@ private sub hWriteLine( byref s as string, byval noline as integer = FALSE )
385386
static as string ln
386387

387388
if( env.clopt.debuginfo and (noline = FALSE) ) then
388-
ln = "#line " + str( ctx.linenum )
389+
ln = "#line " + str( ctx.lnum )
389390
ln += " """ + ctx.escapedinputfilename + """"
390391
sectionWriteLine( ln )
391392
end if
@@ -1249,7 +1250,7 @@ private function _emitBegin( ) as integer
12491250

12501251
ctx.section = -1
12511252
ctx.sectiongosublevel = 0
1252-
ctx.linenum = 0
1253+
ctx.lnum = 0
12531254
ctx.usedbuiltins = 0
12541255
ctx.globalvarpass = 0
12551256
hUpdateCurrentFileName( env.inf.name )
@@ -3158,11 +3159,13 @@ private sub _emitDBG _
31583159
( _
31593160
byval op as integer, _
31603161
byval proc as FBSYMBOL ptr, _
3161-
byval ex as integer _
3162+
byval lnum as Integer, _
3163+
ByVal filename As ZString Ptr _
31623164
)
31633165

31643166
if( op = AST_OP_DBG_LINEINI ) then
3165-
ctx.linenum = ex
3167+
ctx.lnum = lnum
3168+
If filename<>0 Then hUpdateCurrentFileName(filename)
31663169
end if
31673170

31683171
end sub

src/compiler/ir-llvm.bas

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const MAXVARINISCOPES = 128
155155

156156
type IRLLVMCONTEXT
157157
indent as integer '' current indentation used by hWriteLine()
158-
linenum as integer
158+
lnum as integer
159159

160160
varini as string
161161
variniscopelevel as integer
@@ -185,7 +185,8 @@ declare sub _emitDBG _
185185
( _
186186
byval op as integer, _
187187
byval proc as FBSYMBOL ptr, _
188-
byval ex as integer _
188+
byval lnum as Integer, _
189+
ByVal filename As ZString Ptr = 0 _
189190
)
190191
declare function hVregToStr( byval vreg as IRVREG ptr ) as string
191192
declare sub hEmitConvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr )
@@ -885,7 +886,7 @@ private function _emitBegin( ) as integer
885886
ctx.head_txt = ""
886887
ctx.body_txt = ""
887888
ctx.foot_txt = ""
888-
ctx.linenum = 0
889+
ctx.lnum = 0
889890
ctx.section = SECTION_HEAD
890891

891892
for i as integer = 0 to BUILTIN__COUNT-1
@@ -2080,13 +2081,18 @@ private sub _emitDBG _
20802081
( _
20812082
byval op as integer, _
20822083
byval proc as FBSYMBOL ptr, _
2083-
byval ex as integer _
2084+
byval lnum as Integer, _
2085+
ByVal filename As ZString Ptr _
20842086
)
20852087

2086-
if( op = AST_OP_DBG_LINEINI ) then
2087-
hWriteLine( "#line " & ex & " """ & hReplace( env.inf.name, "\", $"\\" ) & """" )
2088-
ctx.linenum = ex
2089-
end if
2088+
if( op = AST_OP_DBG_LINEINI ) Then
2089+
If filename<>0 Then
2090+
hWriteLine( "#line " & lnum & " """ & hReplace( filename, "\", $"\\" ) & """" )
2091+
Else
2092+
hWriteLine( "#line " & lnum & " """ & hReplace( env.inf.name, "\", $"\\" ) & """" )
2093+
End If
2094+
ctx.lnum = lnum
2095+
end If
20902096

20912097
end sub
20922098

src/compiler/ir-tac.bas

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ declare sub hFlushDBG _
106106
( _
107107
byval op as integer, _
108108
byval proc as FBSYMBOL ptr, _
109-
byval ex as integer _
109+
byval ex as Integer, _
110+
ByVal filename As ZString Ptr _
110111
)
111112

112113
declare sub hFlushLIT( byval op as integer, byval text as zstring ptr )
@@ -294,7 +295,8 @@ private sub _emit _
294295
byval v2 as IRVREG ptr, _
295296
byval vr as IRVREG ptr, _
296297
byval ex1 as FBSYMBOL ptr = NULL, _
297-
byval ex2 as integer = 0 _
298+
byval ex2 as integer = 0, _
299+
byval ex3 as ZString Ptr = 0 _
298300
) static
299301

300302
dim as IRTAC ptr t
@@ -317,7 +319,8 @@ private sub _emit _
317319

318320
t->ex1 = ex1
319321
t->ex2 = ex2
320-
322+
t->ex3 = ex3
323+
321324
ctx.taccnt += 1
322325

323326
end sub
@@ -679,10 +682,11 @@ private sub _emitDBG _
679682
( _
680683
byval op as integer, _
681684
byval proc as FBSYMBOL ptr, _
682-
byval ex as integer _
685+
byval ex As Integer, _
686+
ByVal filename As ZString Ptr _
683687
)
684688

685-
_emit( op, NULL, NULL, NULL, proc, ex )
689+
_emit( op, NULL, NULL, NULL, proc, ex, filename )
686690

687691
end sub
688692

@@ -1361,7 +1365,7 @@ private sub _flush static
13611365
hFlushMEM( op, v1, v2, t->ex2, t->ex1 )
13621366

13631367
case AST_NODECLASS_DBG
1364-
hFlushDBG( op, t->ex1, t->ex2 )
1368+
hFlushDBG( op, t->ex1, t->ex2, t->ex3 )
13651369

13661370
case AST_NODECLASS_LIT
13671371
hFlushLIT( op, cast( any ptr, t->ex1 ) )
@@ -2397,12 +2401,13 @@ private sub hFlushDBG _
23972401
( _
23982402
byval op as integer, _
23992403
byval proc as FBSYMBOL ptr, _
2400-
byval ex as integer _
2404+
byval ex as Integer, _
2405+
ByVal filename As ZString Ptr _
24012406
)
24022407

24032408
select case as const op
24042409
case AST_OP_DBG_LINEINI
2405-
emitDBGLineBegin( proc, ex )
2410+
emitDBGLineBegin( proc, ex, filename )
24062411

24072412
case AST_OP_DBG_LINEEND
24082413
emitDBGLineEnd( proc, ex )

0 commit comments

Comments
 (0)