Re: Print only part of a stack trace

2020-07-01 Thread Dennis via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 19:33:08 UTC, JN wrote: Bit off-topic, but if you can use them, debug contexts offer much better OpenGL error-checking experience. https://www.khronos.org/opengl/wiki/Debug_Output . Instead of checking glGetError() after each call, you can setup a C callback that

Re: Print only part of a stack trace

2020-07-01 Thread JN via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 18:30:15 UTC, Dennis wrote: I have a function that checks a global error constant of a C library (OpenGL) like this: ``` void assertNoOpenGLErrors() { if (glGetError() != GL_NO_ERROR) { assert(0); // stack trace points to here instead of caller } }

Re: Print only part of a stack trace

2020-07-01 Thread Dennis via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 18:54:55 UTC, Dennis wrote: It sort of works, but it seems it does not start at the right stack frame, the top item is this: ??:? void rt.dmain2._d_run_main2(char[][], ulong, extern (C) int function(char[][])*).runAll().__lambda1() [0x55c19a09c1fa] So dmd skips

Re: Print only part of a stack trace

2020-07-01 Thread Dennis via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 18:44:10 UTC, Stanislav Blinov wrote: void assertNoOpenGLErrors(string file = __FILE__, int line = __LINE__, string func = __PRETTY_FUNCTION__) { if (glGetError() != GL_NO_ERROR) { print(file, ":", line, ":", func, ": blah"); exit(); } } :)

Re: Print only part of a stack trace

2020-07-01 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 17:44:45 UTC, Dennis wrote: On assertion failure, the default error handler prints a stack trace that looks like this My cgi.d does something just like that. It just does `exception.toString()` then `splitLines` on that string. Element

Re: Print only part of a stack trace

2020-07-01 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 18:30:15 UTC, Dennis wrote: I have a function that checks a global error constant of a C library (OpenGL) like this: ``` void assertNoOpenGLErrors() { if (glGetError() != GL_NO_ERROR) { assert(0); // stack trace points to here instead of caller }

Re: Print only part of a stack trace

2020-07-01 Thread Dennis via Digitalmars-d-learn
On Wednesday, 1 July 2020 at 18:05:09 UTC, Jacob Carlborg wrote: [1] https://dlang.org/phobos/core_runtime.html#.Runtime.traceHandler Thanks, but I don't want to re-implement the default trace handler, I want to use it on a specific location and capture its output. I'll be more specific in

Re: Print only part of a stack trace

2020-07-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-01 19:44, Dennis wrote: On assertion failure, the default error handler prints a stack trace that looks like this [library functions] [application functions] [druntime start-up functions] I'm only interested in application functions, the rest is noise. I could easily filter