I'm trying to implement a custom exception system in BetterC. Does anyone know how I'd go about getting a stack trace so that I can print it to stdout? :)
I was thinking of utilising UDAs & __LINE__
but it turns out that UDAs don't let you inject code, which is a shame!
Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 04, 2022 BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
September 04, 2022 Re: BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to IchorDev | On Sunday, 4 September 2022 at 17:43:01 UTC, IchorDev wrote: >I'm trying to implement a custom exception system in BetterC. Does anyone know how I'd go about getting a stack trace so that I can print it to stdout? :) You can use https://www.nongnu.org/libunwind/ It's a C library, but it should work for D too. |
September 05, 2022 Re: BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Sunday, 4 September 2022 at 18:49:37 UTC, Paul Backus wrote: >You can use https://www.nongnu.org/libunwind/ It's a C library, but it should work for D too. Ah, I'm actually trying to create my own implementation of this, so the goal would be to not rely on a dependency. I'm sure there must be something hidden in |
September 05, 2022 Re: BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to IchorDev | On Monday, 5 September 2022 at 10:47:38 UTC, IchorDev wrote: >Ah, I'm actually trying to create my own implementation of this, so the goal would be to not rely on a dependency. I'm sure there must be something hidden in I think this is what you are looking for: https://github.com/dlang/dmd/blob/master/druntime/src/rt/deh.d |
September 05, 2022 Re: BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Monday, 5 September 2022 at 12:07:35 UTC, Paul Backus wrote: >On Monday, 5 September 2022 at 10:47:38 UTC, IchorDev wrote: >Ah, I'm actually trying to create my own implementation of this, so the goal would be to not rely on a dependency. I'm sure there must be something hidden in I think this is what you are looking for: https://github.com/dlang/dmd/blob/master/druntime/src/rt/deh.d Digging in a little deeper, it looks like the druntime implementation ultimately depends on the C++ exception handling ABI, via its platform-independent library interface. Bindings are defined in There is also what looks like a from-scratch implementation of table-based exception handling in |
September 06, 2022 Re: BetterC stack traces? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Monday, 5 September 2022 at 12:35:10 UTC, Paul Backus wrote: >Digging in a little deeper, it looks like the druntime implementation ultimately depends on the C++ exception handling ABI, via its platform-independent library interface. Bindings are defined in It even uses libunwind, it seems! https://github.com/dlang/dmd/blob/master/druntime/src/core/internal/backtrace/handler.d |