diff --git a/src/compiler/ast-node-misc.bas b/src/compiler/ast-node-misc.bas index 1c60c1e00f..8b932285b2 100644 --- a/src/compiler/ast-node-misc.bas +++ b/src/compiler/ast-node-misc.bas @@ -152,8 +152,8 @@ end function function astNewDBG _ ( _ byval op as integer, _ - byval ex as integer, _ - byval filename As ZString Ptr _ + byval ex as integer, _ + byval filename As ZString Ptr _ ) as ASTNODE ptr dim as ASTNODE ptr n = any @@ -166,14 +166,14 @@ function astNewDBG _ n->dbg.op = op n->dbg.ex = ex - n->dbg.filename = filename + n->dbg.filename = filename function = n end function function astLoadDBG( byval n as ASTNODE ptr ) as IRVREG ptr if( ast.doemit ) then - irEmitDBG( n->dbg.op, astGetProc( )->sym, n->dbg.ex, n->dbg.filename ) + irEmitDBG( n->dbg.op, astGetProc( )->sym, n->dbg.ex, n->dbg.filename ) end if function = NULL diff --git a/src/compiler/ast.bi b/src/compiler/ast.bi index cdab53e454..3651d19c85 100644 --- a/src/compiler/ast.bi +++ b/src/compiler/ast.bi @@ -172,9 +172,9 @@ type AST_NODE_JMPTB end type type AST_NODE_DBG - ex as integer - filename as zstring ptr - op as integer + ex as integer + filename as zstring ptr + op as integer end type type AST_NODE_MEM @@ -794,9 +794,9 @@ declare function astNewASM( byval asmtokhead as ASTASMTOK ptr ) as ASTNODE ptr declare function astNewDBG _ ( _ - byval op as integer, _ - byval ex as integer = 0, _ - byval filename as zstring ptr = 0 _ + byval op as integer, _ + byval ex as integer = 0, _ + byval filename as zstring ptr = 0 _ ) as ASTNODE ptr declare function astNewMEM _ diff --git a/src/compiler/edbg_stab.bas b/src/compiler/edbg_stab.bas index 4b0328a95c..1fc2413d2d 100644 --- a/src/compiler/edbg_stab.bas +++ b/src/compiler/edbg_stab.bas @@ -213,10 +213,10 @@ sub edbgEmitHeader( byval filename as zstring ptr ) ctx.typecnt = 1 ctx.label = NULL - ctx.incfile = NULL - - '' ctx.filename is never used - ctx.filename = *filename + ctx.incfile = NULL + + '' ctx.filename is never used + ctx.filename = *filename '' emit source file name lname = *symbUniqueLabel( ) @@ -267,13 +267,13 @@ sub edbgLineBegin _ ( _ byval proc as FBSYMBOL ptr, _ byval lnum as integer, _ - byval pos_ as integer, _ - ByVal filename As zstring ptr _ + byval pos_ as integer, _ + ByVal filename As zstring ptr _ ) if( env.clopt.debuginfo = FALSE ) then exit sub - end if + end if if( ctx.lnum > 0 ) then ctx.pos = pos_ - ctx.pos @@ -283,8 +283,8 @@ sub edbgLineBegin _ end if end if - edbgInclude( filename ) - + edbgInclude( filename ) + ctx.pos = pos_ ctx.lnum = lnum if( ctx.isnewline ) then @@ -534,7 +534,7 @@ sub edbgEmitProcHeader _ '' ctx.isnewline = TRUE - ctx.lnum = 0 + ctx.lnum = 0 ctx.pos = 0 ctx.label = NULL @@ -649,7 +649,7 @@ sub edbgEmitProcFooter _ '' ctx.isnewline = TRUE - ctx.lnum = 0 + ctx.lnum = 0 ctx.pos = 0 ctx.label = NULL @@ -1018,32 +1018,32 @@ end sub sub edbgInclude( byval incfile as zstring ptr ) dim as string lname - - '' NOTE: originally, fbc used STAB_TYPE_BINCL and STAB_TYPE_EINCL - '' to mark the beginning and end of an include file. The purpose - '' for these markers is so the linker (LD) can remove duplicate - '' debug type information from the final EXE. However, because - '' fbc only emits types actually used, the end result is that - '' type information from a header (.BI) is often different from - '' one object module to another is generally not used in the - '' way that BINCL/EINCL/EXCL was intented. - - '' incfile is the new include file or main file name - - '' coming from _close incfile is null so no real need to change - If( incfile = NULL )Then - Exit Sub - EndIf - - '' Already handling the correct name - if( incfile = ctx.incfile ) Then - exit sub - end If - - emitSECTION( IR_SECTION_CODE, 0 ) - lname = *symbUniqueLabel( ) - hEmitSTABS( STAB_TYPE_SOL, incfile, 0, 0, lname ) - hLABEL( lname ) - - ctx.incfile = incfile + + '' NOTE: originally, fbc used STAB_TYPE_BINCL and STAB_TYPE_EINCL + '' to mark the beginning and end of an include file. The purpose + '' for these markers is so the linker (LD) can remove duplicate + '' debug type information from the final EXE. However, because + '' fbc only emits types actually used, the end result is that + '' type information from a header (.BI) is often different from + '' one object module to another is generally not used in the + '' way that BINCL/EINCL/EXCL was intented. + + '' incfile is the new include file or main file name + + '' coming from _close incfile is null so no real need to change + If( incfile = NULL )Then + Exit Sub + EndIf + + '' Already handling the correct name + if( incfile = ctx.incfile ) Then + exit sub + end If + + emitSECTION( IR_SECTION_CODE, 0 ) + lname = *symbUniqueLabel( ) + hEmitSTABS( STAB_TYPE_SOL, incfile, 0, 0, lname ) + hLABEL( lname ) + + ctx.incfile = incfile end sub diff --git a/src/compiler/emit.bas b/src/compiler/emit.bas index bcc188fb96..69c91b45dd 100644 --- a/src/compiler/emit.bas +++ b/src/compiler/emit.bas @@ -204,8 +204,8 @@ sub emitFlush( ) case EMIT_NODECLASS_DBG cast( EMIT_DBGCB, emit.opFnTb[n->dbg.op] )( n->dbg.sym, _ n->dbg.lnum, _ - n->dbg.pos, _ - n->dbg.filename ) + n->dbg.pos, _ + n->dbg.filename ) end select @@ -457,8 +457,8 @@ private function hNewDBG _ byval op as integer, _ byval sym as FBSYMBOL ptr, _ byval lnum as integer = 0, _ - byval pos_ as integer = 0, _ - byval filename As zstring ptr = 0 _ + byval pos_ as integer = 0, _ + byval filename As zstring ptr = 0 _ ) as EMIT_NODE ptr static dim as EMIT_NODE ptr n @@ -468,7 +468,7 @@ private function hNewDBG _ n->dbg.op = op n->dbg.sym = sym n->dbg.lnum = lnum - n->dbg.filename = filename + n->dbg.filename = filename n->dbg.pos = pos_ function = n @@ -1635,11 +1635,11 @@ end function function emitDBGLineBegin _ ( _ byval proc as FBSYMBOL ptr, _ - byval lnum as integer, _ - byval filename As zstring ptr _ + byval lnum as integer, _ + byval filename As zstring ptr _ ) as EMIT_NODE ptr - function = hNewDBG( EMIT_OP_LINEINI, proc, lnum, emit.pos, filename ) + function = hNewDBG( EMIT_OP_LINEINI, proc, lnum, emit.pos, filename ) end function diff --git a/src/compiler/emit.bi b/src/compiler/emit.bi index 88de7eb217..0d1c958eba 100644 --- a/src/compiler/emit.bi +++ b/src/compiler/emit.bi @@ -199,7 +199,7 @@ type EMIT_DBGNODE op as integer sym as FBSYMBOL ptr lnum as integer - filename as zstring ptr + filename as zstring ptr pos as integer end type @@ -262,8 +262,8 @@ type EMIT_MEMCB as sub( byval dvreg as IRVREG ptr, _ type EMIT_DBGCB as sub( byval sym as FBSYMBOL ptr, _ byval lnum as integer, _ - byval pos as Integer, _ - ByVal filename As ZString Ptr =0 ) + byval pos as Integer, _ + ByVal filename As ZString Ptr =0 ) '' if changed, update the _vtbl symbols at emit_*.bas::*_ctor type EMIT_VTBL @@ -792,8 +792,8 @@ declare function emitSTKCLEAR _ declare function emitDBGLineBegin _ ( _ byval proc as FBSYMBOL ptr, _ - byval ex as Integer, _ - ByVal filename As ZString Ptr _ + byval ex as Integer, _ + ByVal filename As ZString Ptr _ ) as EMIT_NODE ptr declare function emitDBGLineEnd _ diff --git a/src/compiler/emit_x86.bas b/src/compiler/emit_x86.bas index 327111e27d..9ed09e6f17 100644 --- a/src/compiler/emit_x86.bas +++ b/src/compiler/emit_x86.bas @@ -6049,11 +6049,11 @@ private sub _emitLINEINI _ ( _ byval proc as FBSYMBOL ptr, _ byval lnum as integer, _ - byval pos_ as integer, _ - byval filename As zstring ptr _ + byval pos_ as integer, _ + byval filename As zstring ptr _ ) - edbgLineBegin( proc, lnum, pos_, filename ) + edbgLineBegin( proc, lnum, pos_, filename ) end sub diff --git a/src/compiler/emitdbg.bi b/src/compiler/emitdbg.bi index e75d68e72a..fb0bf962d5 100644 --- a/src/compiler/emitdbg.bi +++ b/src/compiler/emitdbg.bi @@ -9,8 +9,8 @@ declare sub edbgLineBegin _ ( _ byval proc as FBSYMBOL ptr, _ byval lnum as integer, _ - byval pos as integer, _ - byval filename as zstring ptr _ + byval pos as integer, _ + byval filename as zstring ptr _ ) declare sub edbgLineEnd _ diff --git a/src/compiler/ir-llvm.bas b/src/compiler/ir-llvm.bas index 2aae038a75..cd305ea677 100644 --- a/src/compiler/ir-llvm.bas +++ b/src/compiler/ir-llvm.bas @@ -185,8 +185,8 @@ declare sub _emitDBG _ ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval lnum as integer, _ - ByVal filename As zstring ptr = 0 _ + byval lnum as integer, _ + ByVal filename As zstring ptr = 0 _ ) declare function hVregToStr( byval vreg as IRVREG ptr ) as string declare sub hEmitConvert( byval v1 as IRVREG ptr, byval v2 as IRVREG ptr ) @@ -2081,18 +2081,18 @@ private sub _emitDBG _ ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval lnum as integer, _ - ByVal filename As zstring ptr _ + byval lnum as integer, _ + ByVal filename As zstring ptr _ ) - if( op = AST_OP_DBG_LINEINI ) Then - if( filename <> NULL ) then - hWriteLine( "#line " & lnum & " """ & hReplace( filename, "\", $"\\" ) & """" ) - else - hWriteLine( "#line " & lnum & " """ & hReplace( env.inf.name, "\", $"\\" ) & """" ) - end if - ctx.linenum = lnum - end If + if( op = AST_OP_DBG_LINEINI ) Then + if( filename <> NULL ) then + hWriteLine( "#line " & lnum & " """ & hReplace( filename, "\", $"\\" ) & """" ) + else + hWriteLine( "#line " & lnum & " """ & hReplace( env.inf.name, "\", $"\\" ) & """" ) + end if + ctx.linenum = lnum + end If end sub diff --git a/src/compiler/ir-tac.bas b/src/compiler/ir-tac.bas index b8d396e100..effc7dab06 100644 --- a/src/compiler/ir-tac.bas +++ b/src/compiler/ir-tac.bas @@ -106,8 +106,8 @@ declare sub hFlushDBG _ ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval ex as integer, _ - ByVal filename As zstring ptr _ + byval ex as integer, _ + ByVal filename As zstring ptr _ ) declare sub hFlushLIT( byval op as integer, byval text as zstring ptr ) @@ -295,8 +295,8 @@ private sub _emit _ byval v2 as IRVREG ptr, _ byval vr as IRVREG ptr, _ byval ex1 as FBSYMBOL ptr = NULL, _ - byval ex2 as integer = 0, _ - byval ex3 as zstring ptr = 0 _ + byval ex2 as integer = 0, _ + byval ex3 as zstring ptr = 0 _ ) static dim as IRTAC ptr t @@ -319,8 +319,8 @@ private sub _emit _ t->ex1 = ex1 t->ex2 = ex2 - t->ex3 = ex3 - + t->ex3 = ex3 + ctx.taccnt += 1 end sub @@ -682,11 +682,11 @@ private sub _emitDBG _ ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval ex as integer, _ - byval filename as zstring ptr _ + byval ex as integer, _ + byval filename as zstring ptr _ ) - _emit( op, NULL, NULL, NULL, proc, ex, filename ) + _emit( op, NULL, NULL, NULL, proc, ex, filename ) end sub @@ -1365,7 +1365,7 @@ private sub _flush static hFlushMEM( op, v1, v2, t->ex2, t->ex1 ) case AST_NODECLASS_DBG - hFlushDBG( op, t->ex1, t->ex2, t->ex3 ) + hFlushDBG( op, t->ex1, t->ex2, t->ex3 ) case AST_NODECLASS_LIT hFlushLIT( op, cast( any ptr, t->ex1 ) ) @@ -2401,13 +2401,13 @@ private sub hFlushDBG _ ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval ex as integer, _ - ByVal filename As zstring ptr _ + byval ex as integer, _ + ByVal filename As zstring ptr _ ) select case as const op case AST_OP_DBG_LINEINI - emitDBGLineBegin( proc, ex, filename ) + emitDBGLineBegin( proc, ex, filename ) case AST_OP_DBG_LINEEND emitDBGLineEnd( proc, ex ) diff --git a/src/compiler/ir.bi b/src/compiler/ir.bi index 8fe76d19cb..0807507d73 100644 --- a/src/compiler/ir.bi +++ b/src/compiler/ir.bi @@ -67,7 +67,7 @@ type IRTAC ex1 as FBSYMBOL ptr '' extra field, used by call/jmp ex2 as integer '' / - ex3 as zstring ptr '' filename, used by DBG + ex3 as zstring ptr '' filename, used by DBG end type type IRVREG @@ -320,8 +320,8 @@ type IR_VTBL ( _ byval op as integer, _ byval proc as FBSYMBOL ptr, _ - byval ex as integer, _ - byval filename As zstring ptr = 0 _ + byval ex as integer, _ + byval filename As zstring ptr = 0 _ ) emitVarIniBegin as sub( byval sym as FBSYMBOL ptr ) @@ -600,7 +600,7 @@ declare function vregDump( byval v as IRVREG ptr ) as string #define irEmitSCOPEEND(s) ir.vtbl.emitScopeEnd( s ) -#define irEmitDBG(op, proc, ex, filename) ir.vtbl.emitDBG( op, proc, ex, filename ) +#define irEmitDBG(op, proc, ex, filename) ir.vtbl.emitDBG( op, proc, ex, filename ) #define irEmitDECL( sym ) ir.vtbl.emitDECL( sym ) diff --git a/src/compiler/parser-inlineasm.bas b/src/compiler/parser-inlineasm.bas index c52ef575a6..ceaa1843b1 100644 --- a/src/compiler/parser-inlineasm.bas +++ b/src/compiler/parser-inlineasm.bas @@ -319,7 +319,7 @@ function cAsmBlock as integer '' (AsmCode Comment? NewLine)+ do if( issingleline = FALSE ) then - astAdd( astNewDBG( AST_OP_DBG_LINEINI, lexLineNum( ), env.inf.incfile )) + astAdd( astNewDBG( AST_OP_DBG_LINEINI, lexLineNum( ), env.inf.incfile )) end if cAsmCode( ) diff --git a/src/compiler/parser-toplevel.bas b/src/compiler/parser-toplevel.bas index 5fe5c1e45c..860dc443cc 100644 --- a/src/compiler/parser-toplevel.bas +++ b/src/compiler/parser-toplevel.bas @@ -110,7 +110,7 @@ sub cProgram() '' For each line... do '' line begin - astAdd( astNewDBG( AST_OP_DBG_LINEINI, lexLineNum( ), env.inf.incfile ) ) + astAdd( astNewDBG( AST_OP_DBG_LINEINI, lexLineNum( ), env.inf.incfile ) ) '' Label? cLabel( )