digitalmars.D.learn - Getting line number where error occured?
- Hoenir (3/3) Jan 14 2009 Might be a dumb question, but is it possible in any way to get the line
- Sergey Gromov (6/9) Jan 14 2009 assert gives a line number. There's also a keyword, __LINE__, which is
- Bill Baxter (8/17) Jan 14 2009 Nothing built-in for this,
- Kagamin (2/9) Jan 15 2009 Weren't stack traces added to druntime some time ago?
- Sergey Gromov (7/18) Jan 15 2009 You're correct, I missed that. Exception is derived from Throwable in
- Bill Baxter (5/23) Jan 15 2009 And also, D1 will not be moved to the new common druntime, so if
- Jarrett Billingsley (10/16) Jan 15 2009 By default there is no mechanism to fill in this info, so it's null.
- Hoenir (2/5) Jan 15 2009 only with Tango? I've also seen some Phobos hacks on their site.
- Jarrett Billingsley (4/10) Jan 16 2009 The Phobos backtrace hack on team0xf's site is for D1. Since D2 now
Might be a dumb question, but is it possible in any way to get the line number where an error occured? Don't think so, but maybe I'm missing something.
Jan 14 2009
Thu, 15 Jan 2009 02:47:07 +0100, Hoenir wrote:Might be a dumb question, but is it possible in any way to get the line number where an error occured? Don't think so, but maybe I'm missing something.assert gives a line number. There's also a keyword, __LINE__, which is an expression evaluating to the current line number, like in writefln(__LINE__); If you mean an exception stack trace then no, there's no such thing, though it's a very popular feature request.
Jan 14 2009
On Thu, Jan 15, 2009 at 12:02 PM, Sergey Gromov <snake.scaly gmail.com> wrote:Thu, 15 Jan 2009 02:47:07 +0100, Hoenir wrote:Nothing built-in for this, but there are the backtrace hacks: http://team0xf.com/index.php?n=Site.Download Never tried those myself though. I use a debugger when I need a stack trace. http://ddbg.mainia.de/releases.html (Windows - on Linux I think you can use GDB). --bbMight be a dumb question, but is it possible in any way to get the line number where an error occured? Don't think so, but maybe I'm missing something.assert gives a line number. There's also a keyword, __LINE__, which is an expression evaluating to the current line number, like in writefln(__LINE__); If you mean an exception stack trace then no, there's no such thing, though it's a very popular feature request.
Jan 14 2009
Bill Baxter Wrote:Nothing built-in for this, but there are the backtrace hacks: http://team0xf.com/index.php?n=Site.Download Never tried those myself though. I use a debugger when I need a stack trace. http://ddbg.mainia.de/releases.html (Windows - on Linux I think you can use GDB).Weren't stack traces added to druntime some time ago?
Jan 15 2009
Thu, 15 Jan 2009 13:08:35 -0500, Kagamin wrote:Bill Baxter Wrote:You're correct, I missed that. Exception is derived from Throwable in druntime, and Throwable has a field 'info' of type TraceInfo with opApply in its interface. But it doesn't work, at least with DMD 2.023 on Windows. Attempts to access this field cause object.Error: Access Violation. I didn't try to investigate further though.Nothing built-in for this, but there are the backtrace hacks: http://team0xf.com/index.php?n=Site.Download Never tried those myself though. I use a debugger when I need a stack trace. http://ddbg.mainia.de/releases.html (Windows - on Linux I think you can use GDB).Weren't stack traces added to druntime some time ago?
Jan 15 2009
On Fri, Jan 16, 2009 at 10:50 AM, Sergey Gromov <snake.scaly gmail.com> wrote:Thu, 15 Jan 2009 13:08:35 -0500, Kagamin wrote:And also, D1 will not be moved to the new common druntime, so if you're using D1 then backtrace hacks or a debugger are still your only options I think. --bbBill Baxter Wrote:You're correct, I missed that. Exception is derived from Throwable in druntime, and Throwable has a field 'info' of type TraceInfo with opApply in its interface. But it doesn't work, at least with DMD 2.023 on Windows. Attempts to access this field cause object.Error: Access Violation. I didn't try to investigate further though.Nothing built-in for this, but there are the backtrace hacks: http://team0xf.com/index.php?n=Site.Download Never tried those myself though. I use a debugger when I need a stack trace. http://ddbg.mainia.de/releases.html (Windows - on Linux I think you can use GDB).Weren't stack traces added to druntime some time ago?
Jan 15 2009
On Thu, Jan 15, 2009 at 8:50 PM, Sergey Gromov <snake.scaly gmail.com> wrote:You're correct, I missed that. Exception is derived from Throwable in druntime, and Throwable has a field 'info' of type TraceInfo with opApply in its interface. But it doesn't work, at least with DMD 2.023 on Windows. Attempts to access this field cause object.Error: Access Violation. I didn't try to investigate further though.By default there is no mechanism to fill in this info, so it's null. The "proper" usage would be something like: if(ex.info) writefln("Traceback: %s", ex.info); But again, there is no mechanism to fill this in, only the hooks to make it possible to do so. Team0xf has made a few traceback modules which work only with Tango on Windows to fill in this info, but there's no reason it couldn't be done on other platforms or with Phobos.
Jan 15 2009
Jarrett Billingsley schrieb:Team0xf has made a few traceback modules which work only with Tango on Windows to fill in this info, but there's no reason it couldn't be done on other platforms or with Phobos.only with Tango? I've also seen some Phobos hacks on their site.
Jan 15 2009
On Fri, Jan 16, 2009 at 2:40 AM, Hoenir <mrmocool gmx.de> wrote:Jarrett Billingsley schrieb:The Phobos backtrace hack on team0xf's site is for D1. Since D2 now uses druntime, they wouldn't work, but an approach similar/identical to the Tango backtracers would.Team0xf has made a few traceback modules which work only with Tango on Windows to fill in this info, but there's no reason it couldn't be done on other platforms or with Phobos.only with Tango? I've also seen some Phobos hacks on their site.
Jan 16 2009