How to do -g but without assertions?

For other topics related to the FreeBASIC project or its community.
speedfixer
Posts: 393
Joined: Nov 28, 2012 1:27
Location: California

Re: How to do -g but without assertions?

Postby speedfixer » May 12, 2019 1:57

@coderJeff:
maybe a verbose version of version? like '-version -v'?


To me: confusing. In many languages, there are synonyms and variations of an option, like -verbose, -v, --verbose, etc. Which is which?
'Stacking' on a simple option doesn't make sense. Somewhere, someone does -v ... or ... a -v -v to get a lot more. Simple, intuitive, but not elegant.

We DO have nice, simple -e, -ex, -exx. Once you see them - easy to remember.

How about something like:

-version = FBC version, standard version dump, as now
-v = verbose build info, as now
-vb = verbose build information, version with switches, options and limits shown
-vc = version and all compile options/switches for this compiler run -- in a handy group to add to source to keep things straight.

On the other hand, it looks like there would be little to add to the current -v and -version to display the new possible options.
Maybe just mod -version and -v only?
Simplest choice.


I do agree with the sentiment of splitting out bounds checking, etc. as suggested by TeeEmCee. Not sure how much work that would be, though.

david
coderJeff
Site Admin
Posts: 3160
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: How to do -g but without assertions?

Postby coderJeff » Jun 23, 2019 19:37

speedfixer wrote:On the other hand, it looks like there would be little to add to the current -v and -version to display the new possible options.
Maybe just mod -version and -v only?
Simplest choice.


I think so too. '-v' option has always meant 'be verbose', so I think it's fair to use it for more detailed information.

In pull request New command line options for control over debug code generation #154 I have implemented skeleton code to allow:
'-help -v' for verbose help
'-version -v' for verbose version information

If you don't mind listing out some specifics for '-version -v' verbose version information I will do my best to add. Thanks.
coderJeff
Site Admin
Posts: 3160
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: How to do -g but without assertions?

Postby coderJeff » Jun 23, 2019 19:49

I modified my original plan and have created pull request New command line options for control over debug code generation #154 for:

'-earray' enable array bounds error checking
'-eassert' enable asserts error checking
'-edebug' enable __FB_DEBUG__
'-edebuginfo' enable adding debug info
'-enullptr' enable null pointer error checking
'-elocation' enable reporting of error location

Does not break existing meaning of '-e', '-ex', '-exx', or '-g'
'-g' enables debug info (implies '-edebuginfo'), __FB_DEBUG__ (implies '-edebug'), and asserts (implies '-eassert')
'-exx' enables extra error checking (implies '-e -ex -earray, -elocation, -enullptr)

Internally, '__FB_DEBUG__' is tied to the '-edebug' option (previously was tied to assertions)

__FB_ERR__ sum of the following values (bits)
1 = '-e' specified
2 = '-ex' specified
4 = '-exx' specified
8 = '-earray`' or '-exx' specified
16 = '-enullptr' or '-exx' specified
32 = '-eassert' or '-g' specified
64 = '-edebuginfo' or '-g' specified
128 = '-edebug' or '-g' specified
256 = '-elocation' or '-exx' specified

I've only given the options some simple testing. If some users are willing to test, I'd feel more confident about merging in to master, with the expectation that problems could be solved before next release with user feedback.
coderJeff
Site Admin
Posts: 3160
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: How to do -g but without assertions?

Postby coderJeff » Jun 23, 2019 20:08

TeeEmCee wrote:Also, it would be nice if you could get bounds/nullptr/rtlib checking but without the overhead of 4 calls to fb_ErrorSetModName/fb_ErrorSetFuncName in every single function? Those calls are a huge overhead in small inlined functions, which might otherwise compile to just a few instructions. The line number and filename are already passed to fb_ErrorThrowAt anyway. Could add a variant which passes the function name too (and maybe omits the res_label & resnext_label args, to reduce bloat a little?).
Of course fb_ErrorSetMod/FuncName are also used to report the position if a fatal signal occurs, but I'm OK with that. Also, even in that case you can get the function name in other ways, eg with glibc using backtrace/backtrace_symbols (which uses exported function names (ld --export-dynamic), not debug info.)


I haven't quite explored all the interactions of these new options yet. However, with the new options, I think can get part of what you are asking for. For example, compiling with '-enullptr' only will error on null pointer checks, but not call the procs to set module/procedure name.

To reduce bloat, i.e. optimize the error handling, I need to think about it more.

As mentioned in an earlier post, if you think you can help test, I could merge in the changes for the pull request, knowing that I will get some user feedback to fix the defects. Thanks.
coderJeff
Site Admin
Posts: 3160
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: How to do -g but without assertions?

Postby coderJeff » Jun 23, 2019 20:17

dkl wrote:I think I have a simple solution: Let's think of __FB_DEBUG__ as refering to "adding debug code to the program" (which could be assertions, or any other code added for debugging purposes). Then -g can stay as-is (enabling __FB_DEBUG__, assertions, and -debuginfo).

It probably doesn't make sense for __FB_DEBUG__ to be related to "adding debug info", because it's a source code configuration option but one can't control debug info this way (except perhaps with inline asm). And should we ever need something like that, then we could still add an __FB_DEBUGINFO__.

In the pull request, I think I've come close to this, though I've separated the options even more:

'-edebuginfo' new option is pretty much same as '-debuginfo' you propose, though I didn't add __FB_DEBUGINFO__, and instead put it in with __FB_ERR__ bits.

So to answer the original question of the thread:
'-g', same as before, debug info, __FB_DEBUG__, and assertions

Otherwise, can make any combination of:
'-eassert', enable assertions
'-edebug', enable __FB_DEBUG__ sections of code
'-edebuginfo' add debug info
TeeEmCee
Posts: 268
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: How to do -g but without assertions?

Postby TeeEmCee » Jun 24, 2019 1:51

Oh, awesome! Thank you for this, it's more than I could have hoped for. I will test it, since I happen to be adding better error reporting to my engine anyway (such as printing a backtrace on a crash), but will probably take me a couple days to get back to you. Lately I've been wishing I could turn on just array bounds checking in release builds, so this is perfectly timed!

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest