@@ -213,8 +213,10 @@ sub edbgEmitHeader( byval filename as zstring ptr )
213213
214214 ctx.typecnt = 1
215215 ctx.label = NULL
216- ctx.incfile = NULL
217- ctx.filename = *filename
216+ ctx.incfile = NULL
217+
218+ '' ctx.filename is never used
219+ ctx.filename = *filename
218220
219221 '' emit source file name
220222 lname = *symbUniqueLabel( )
@@ -240,7 +242,6 @@ sub edbgEmitHeader( byval filename as zstring ptr )
240242
241243 emitWriteStr( "" )
242244
243- hEmitSTABS( STAB_TYPE_BINCL, filename, 0 , 0 )
244245end sub
245246
246247'':::::
@@ -1017,41 +1018,32 @@ end sub
10171018
10181019sub edbgInclude( byval incfile as zstring ptr )
10191020 dim as string lname
1020-
1021- '' incfile is the new include file for which we should open a block.
1022- '' incfile can be NULL to indicate that no next include file is coming,
1023- '' in which case we just want to return to the toplevel .bas file name,
1024- '' if we previously opened an include file block.
1025-
1026- '' Already in the correct block?
1027- '' (same include file, or NULL for toplevel)
1028- if ( incfile = ctx.incfile ) then
1029- exit sub
1030- end if
1031-
1032- '' Currently in an include file block?
1033- if ( ctx.incfile ) then
1034- '' Close it
1035- hEmitSTABS( STAB_TYPE_EINCL, "" , 0 , 0 )
1036-
1037- '' "Return" to the main filename, if no new include file block
1038- '' will be opened
1039- if ( incfile = NULL ) then
1040- emitSECTION( IR_SECTION_CODE, 0 )
1041- lname = *symbUniqueLabel( )
1042- hEmitSTABS( STAB_TYPE_SOL, ctx.filename, 0 , 0 , lname )
1043- hLABEL( lname )
1044- end if
1045- end if
1046-
1047- ctx.incfile = incfile
1048-
1049- '' Open new include file block if needed
1050- if ( incfile ) then
1051- hEmitSTABS( STAB_TYPE_BINCL, incfile, 0 , 0 )
1052- emitSECTION( IR_SECTION_CODE, 0 )
1053- lname = *symbUniqueLabel( )
1054- hEmitSTABS( STAB_TYPE_SOL, incfile, 0 , 0 , lname )
1055- hLABEL( lname )
1056- end if
1021+
1022+ '' NOTE: originally, fbc used STAB_TYPE_BINCL and STAB_TYPE_EINCL
1023+ '' to mark the beginning and end of an include file. The purpose
1024+ '' for these markers is so the linker (LD) can remove duplicate
1025+ '' debug type information from the final EXE. However, because
1026+ '' fbc only emits types actually used, the end result is that
1027+ '' type information from a header (.BI) is often different from
1028+ '' one object module to another is generally not used in the
1029+ '' way that BINCL/EINCL/EXCL was intented.
1030+
1031+ '' incfile is the new include file or main file name
1032+
1033+ '' coming from _close incfile is null so no real need to change
1034+ If ( incfile = NULL ) Then
1035+ Exit Sub
1036+ EndIf
1037+
1038+ '' Already handling the correct name
1039+ if ( incfile = ctx.incfile ) Then
1040+ exit sub
1041+ end If
1042+
1043+ emitSECTION( IR_SECTION_CODE, 0 )
1044+ lname = *symbUniqueLabel( )
1045+ hEmitSTABS( STAB_TYPE_SOL, incfile, 0 , 0 , lname )
1046+ hLABEL( lname )
1047+
1048+ ctx.incfile = incfile
10571049end sub
0 commit comments