dmd
dmd copied to clipboard
Make -betterC not disable EH, let -nothrow handle that
See #16174 for context
-nothrow was added recently, wich is what the user should use to disable EH, otherwise APIs like backtrace can't be used to generate stack traces, wich is useful for debugging
I added a change log entry, but my english might be poor, so please don't hesitate to rephrase it
Thanks for your pull request and interest in making D better, @ryuukk! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:
- My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
- My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
- I have provided a detailed rationale explaining my changes
- New or modified functions have Ddoc comments (with
Params:andReturns:)
Please see CONTRIBUTING.md for more information.
If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.
Bugzilla references
Your PR doesn't reference any Bugzilla issue.
If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
Testing this PR locally
If you don't have a local development environment setup, you can use Digger to test this PR:
dub run digger -- build "master + dmd#16177"
Can someone review this please?
To help understand what this PR does:
For cases where one uses -betterC or uses a custom runtime, it makes it possible to still use debugging APIs like backtrace
Example code:
extern(C) void main()
{
rt_register_crash_handler();
crash_me();
}
void crash_me()
{
int* a;
*a = 42;
}
(full code + rt_register_crash_handler impl: https://gist.github.com/ryuukk/)e2d5260b4c4acec1b972ad9ce9228753)
The code should crash and print:
-------------------------------------------------------------------+
Received signal 'SIGSEGV' (11)
-------------------------------------------------------------------+
executable: /tmp/dmd_runXn753y
backtrace: 7
??:? _start+0x25
??:? __libc_start_main+0x8a
??:? +0x25cd0
/run/media/ryuukk/E0C0C01FC0BFFA3C/dev/kdom/./_.d:4 main+0xe
/run/media/ryuukk/E0C0C01FC0BFFA3C/dev/kdom/./_.d:11 void _.crash_me()+0xe
But if i compile with -betterC or with a custom runtime, i get:
-------------------------------------------------------------------+
Received signal 'SIGSEGV' (11)
-------------------------------------------------------------------+
executable: /tmp/dmd_run1UPD7W
backtrace: 1
Not helpful at all..
This PR solves that
ping @WalterBright