Skip to content

Commit dde5e66

Browse files
authored
Merge pull request #154 from jayrm/debug-options
Command line options for control over debug code generation: '-v' be verbose command line option affects '-help' output '-earray' command line option to enable array bounds checking '-enullptr' command line option to enable null pointer checking '-eassert' command line option to enable assert() and assertwarn() checking '-edebug' command line option to enable __FB_DEBUG__ '-edebuginfo' command line option to enable debug symbols '-elocation' command line option to enable reporting error location
2 parents a3a0229 + 4b3cf09 commit dde5e66

File tree

13 files changed

+199
-51
lines changed

13 files changed

+199
-51
lines changed

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Version 1.07.0
22

33
[changed]
44
- SADD/STRPTR(wstring) returns WSTRING PTR
5+
- '-v' be verbose command line option affects '-help' output
56

67
[added]
78
- CVA_LIST type, CVA_START(), CVA_COPY() CVA_END(), CVA_ARG() macros will map to gcc's __builtin_va_list and __builtin_va_* macros in gcc backend
@@ -24,6 +25,12 @@ Version 1.07.0
2425
- SWAP statement will accept UDT as Z|WSTRING
2526
- IIF function will accept UDT as Z|WSTRING
2627
- PRINT/LPRINT/WRITE will accept UDT as Z|WSTRING
28+
- '-earray' command line option to enable array bounds checking
29+
- '-enullptr' command line option to enable null pointer checking
30+
- '-eassert' command line option to enable assert() and assertwarn() checking
31+
- '-edebug' command line option to enable __FB_DEBUG__
32+
- '-edebuginfo' command line option to enable debug symbols
33+
- '-elocation' command line option to enable reporting error location
2734

2835
[fixed]
2936
- sf.net #881: C backend: support for varadic function parameters in gcc using __builtin_va_list type and related macros

doc/fbc.1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH FBC 1 "2019-05-20" "FreeBASIC Compiler 1.07.0" "FreeBASIC Compiler"
1+
.TH FBC 1 "2019-07-23" "FreeBASIC Compiler 1.07.0" "FreeBASIC Compiler"
22
.SH NAME
33
fbc \- The FreeBASIC compiler
44
.SH DESCRIPTION
@@ -45,6 +45,24 @@ Create a Win32 DLL or Linux/*BSD shared library
4545
\fB\-e\fR
4646
Enable runtime error checking
4747
.TP
48+
\fB\-earray\fR
49+
Enable array bounds checking
50+
.TP
51+
\fB\-eassert\fR
52+
Enable assert() and assertwarn() checking
53+
.TP
54+
\fB\-edebug\fR
55+
Enable __FB_DEBUG__
56+
.TP
57+
\fB\-edebuginfo\fR
58+
Add debug information
59+
.TP
60+
\fB\-elocation\fR
61+
Enable full error location reporting
62+
.TP
63+
\fB\-enullptr\fR
64+
Enable null-pointer checking
65+
.TP
4866
\fB\-ex\fR
4967
\fB-e\fR plus RESUME support
5068
.TP
@@ -64,7 +82,7 @@ Select floating-point math accuracy/speed
6482
Set target FPU
6583
.TP
6684
\fB\-g\fR
67-
Add debug info
85+
Add debug info, enable __FB_DEBUG__, and enable asserts
6886
.TP
6987
\fB\-gen\fR \fBgas\fR|\fBgcc\fR|\fBllvm\fR
7088
Select code generation backend

src/compiler/ast-helper.bas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function astBuildVtableLookup _
440440

441441
'' null pointer checking for ABSTRACTs
442442
'' (in case it wasn't overridden)
443-
if( env.clopt.extraerrchk ) then
443+
if( env.clopt.nullptrchk ) then
444444
if( symbIsAbstract( proc ) ) then
445445
p = astBuildPTRCHK( p )
446446
end if
@@ -793,7 +793,7 @@ function astBuildMultiDeref _
793793
end select
794794

795795
'' null pointer checking
796-
if( env.clopt.extraerrchk ) then
796+
if( env.clopt.nullptrchk ) then
797797
expr = astBuildPTRCHK( expr )
798798
end if
799799

src/compiler/ast-node-addr.bas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function astNewADDROF( byval l as ASTNODE ptr ) as ASTNODE ptr
131131

132132
select case( t->class )
133133
case AST_NODECLASS_DEREF
134-
if( env.clopt.extraerrchk ) then
134+
if( env.clopt.nullptrchk ) then
135135
hRemoveNullPtrCheck( t )
136136
end if
137137

@@ -152,7 +152,7 @@ function astNewADDROF( byval l as ASTNODE ptr ) as ASTNODE ptr
152152
case AST_NODECLASS_FIELD
153153
'' @0->field to const
154154
if( t->l->class = AST_NODECLASS_DEREF ) then
155-
if( env.clopt.extraerrchk ) then
155+
if( env.clopt.nullptrchk ) then
156156
hRemoveNullPtrCheck( t->l )
157157
end if
158158

src/compiler/ast-node-proc.bas

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,20 +535,18 @@ private function hCheckErrHnd _
535535

536536
'' error check? add to head (must be done only when closing the proc body
537537
'' or constructor's field would be initialized and break ctor chaining)
538-
if( env.clopt.extraerrchk ) then
538+
if( env.clopt.errlocation ) then
539539
head_node = astAddAfter( rtlErrorSetModName( sym, _
540-
astNewCONSTstr( @env.inf.name ) ), _
541-
head_node )
540+
astNewCONSTstr( @env.inf.name ) ), head_node )
542541

543542
head_node = astAddAfter( rtlErrorSetFuncName( sym, _
544-
astNewCONSTstr( symbGetName( sym ) ) ), _
545-
head_node )
543+
astNewCONSTstr( symbGetName( sym ) ) ), head_node )
546544
end if
547545

548546
with sym->proc.ext->err
549547
if( .lastfun <> NULL ) then
550548
astAdd( rtlErrorSetFuncName( NULL, astNewVAR( .lastfun ) ) )
551-
.lastfun = NULL
549+
.lastfun = NULL
552550
end if
553551

554552
if( .lastmod <> NULL ) then

src/compiler/fb.bas

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,14 @@ sub fbGlobalInit()
459459
env.clopt.lang = FB_DEFAULT_LANG
460460
env.clopt.forcelang = FALSE
461461

462+
env.clopt.debug = FALSE
462463
env.clopt.debuginfo = FALSE
463464
env.clopt.assertions = FALSE
464465
env.clopt.errorcheck = FALSE
465466
env.clopt.extraerrchk = FALSE
467+
env.clopt.errlocation = FALSE
468+
env.clopt.arrayboundchk = FALSE
469+
env.clopt.nullptrchk = FALSE
466470
env.clopt.resumeerr = FALSE
467471
env.clopt.profile = FALSE
468472

@@ -529,6 +533,8 @@ sub fbSetOption( byval opt as integer, byval value as integer )
529533
case FB_COMPOPT_FORCELANG
530534
env.clopt.forcelang = value
531535

536+
case FB_COMPOPT_DEBUG
537+
env.clopt.debug = value
532538
case FB_COMPOPT_DEBUGINFO
533539
env.clopt.debuginfo = value
534540
case FB_COMPOPT_ASSERTIONS
@@ -539,6 +545,12 @@ sub fbSetOption( byval opt as integer, byval value as integer )
539545
env.clopt.resumeerr = value
540546
case FB_COMPOPT_EXTRAERRCHECK
541547
env.clopt.extraerrchk = value
548+
case FB_COMPOPT_ERRLOCATION
549+
env.clopt.errlocation = value
550+
case FB_COMPOPT_ARRAYBOUNDCHECK
551+
env.clopt.arrayboundchk = value
552+
case FB_COMPOPT_NULLPTRCHECK
553+
env.clopt.nullptrchk = value
542554
case FB_COMPOPT_PROFILE
543555
env.clopt.profile = value
544556

@@ -608,6 +620,8 @@ function fbGetOption( byval opt as integer ) as integer
608620
case FB_COMPOPT_FORCELANG
609621
function = env.clopt.forcelang
610622

623+
case FB_COMPOPT_DEBUG
624+
function = env.clopt.debug
611625
case FB_COMPOPT_DEBUGINFO
612626
function = env.clopt.debuginfo
613627
case FB_COMPOPT_ASSERTIONS
@@ -618,6 +632,12 @@ function fbGetOption( byval opt as integer ) as integer
618632
function = env.clopt.resumeerr
619633
case FB_COMPOPT_EXTRAERRCHECK
620634
function = env.clopt.extraerrchk
635+
case FB_COMPOPT_ERRLOCATION
636+
function = env.clopt.errlocation
637+
case FB_COMPOPT_ARRAYBOUNDCHECK
638+
function = env.clopt.arrayboundchk
639+
case FB_COMPOPT_NULLPTRCHECK
640+
function = env.clopt.nullptrchk
621641
case FB_COMPOPT_PROFILE
622642
function = env.clopt.profile
623643

src/compiler/fb.bi

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ enum FB_COMPOPT
6969
FB_COMPOPT_FORCELANG '' boolean: TRUE if -forcelang was specified
7070

7171
'' debugging/error checking
72-
FB_COMPOPT_DEBUGINFO '' boolean: debugging info (affects code generation)
73-
FB_COMPOPT_ASSERTIONS '' boolean: enable assert() and __FB_DEBUG__
72+
FB_COMPOPT_DEBUG '' boolean: enable __FB_DEBUG__ (affects code generation)
73+
FB_COMPOPT_DEBUGINFO '' boolean: enable debugging info (affects code generation)
74+
FB_COMPOPT_ASSERTIONS '' boolean: enable assert()
7475
FB_COMPOPT_ERRORCHECK '' boolean: runtime error checks
7576
FB_COMPOPT_RESUMEERROR '' boolean: RESUME support
7677
FB_COMPOPT_EXTRAERRCHECK '' boolean: NULL pointer/array bounds checks
78+
FB_COMPOPT_ERRLOCATION '' boolean: enable reporting of error location
79+
FB_COMPOPT_NULLPTRCHECK '' boolean: NULL pointer
80+
FB_COMPOPT_ARRAYBOUNDCHECK '' boolean: array bounds checks
7781
FB_COMPOPT_PROFILE '' boolean: -profile
7882

7983
'' error/warning reporting behaviour
@@ -251,11 +255,15 @@ type FBCMMLINEOPT
251255
forcelang as integer '' TRUE if -forcelang was specified
252256

253257
'' debugging/error checking
258+
debug as integer '' true = enable __FB_DEBUG__ (default = false)
254259
debuginfo as integer '' true = add debug info (default = false)
255-
assertions as integer '' true = enable assert() and __FB_DEBUG__ (default = false)
260+
assertions as integer '' true = enable assert() (default = false)
256261
errorcheck as integer '' enable runtime error checks?
257262
resumeerr as integer '' enable RESUME support?
258263
extraerrchk as integer '' enable NULL pointer/array bounds checks?
264+
errlocation as integer '' enable reporting of error location (default = false)
265+
arrayboundchk as integer '' enable array bounds checks?
266+
nullptrchk as integer '' enable NULL pointer checks?
259267
profile as integer '' build profiling code (default = false)
260268

261269
'' error/warning reporting behaviour

0 commit comments

Comments
 (0)