AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
154 stars 25 forks source link

add assume.c/.h, convert assert-like error checks into assume statements #216

Open tehKaiN opened 7 months ago

tehKaiN commented 7 months ago

Description

Adds assertion-like mechanism, which falls back to GCC13's assume attribute. Closes #204. On Bartman suite, this results with a breakpoint on where the failed error check took place.

Motivation and Context

Getting used to errors or not finding them among logs is quite common. Proposed feature makes them more apparent and also unifies the behavior on failed, often critical, error checks.

It also takes the burden off of failing gracefully of some parts, especially those, which shouldn't ever fail if user code is well formed.

Also generalizes checkNull() approach introduced by @approxit in state manager, adding it to remaining part of codebase.

How Has This Been Tested?

Built Aminer with it, ran the game for a while, so apparently there are no regressions. Did some dummy checks to see if breakpoints on failed assumptions trigger properly.

Types of changes

Checklist

tehKaiN commented 7 months ago

Currently, there's a problem with Bartman suite, which doesn't allow inspecting variables in the middle of the call stack. The dirty solution is ensuring that assertions always trigger one level deep and convert the _assume() function into macro.

The better solution would be fixing the debugger support as explained in https://github.com/BartmanAbyss/vscode-amiga-debug/issues/244 . We'll have to see how this pans out.