www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Access Violation line number

reply =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
Hi.

How can I obtain the line number where an Access Violation occured?

Up until now I've scattered lots of writefs to see when they would stop 
printing but it's a lot of guessing work. Can't the access violation 
message print at least the function/method that is in execution atm?

Thanks.
Aug 18 2005
next sibling parent reply Sean Kelly <sean f4.ca> writes:
In article <de2828$2qi3$1 digitaldaemon.com>,
=?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= says...
Hi.

How can I obtain the line number where an Access Violation occured?
You can't :p Access violations are triggered by the hardware and handled by hook functions in Phobos. Your best bet would be to alter that code to signal the debugger. Sean
Aug 18 2005
parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Sean Kelly" <sean f4.ca> wrote in message 
news:de29h0$2saa$1 digitaldaemon.com...
 In article <de2828$2qi3$1 digitaldaemon.com>,
 =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= says...
Hi.

How can I obtain the line number where an Access Violation occured?
You can't :p Access violations are triggered by the hardware and handled by hook functions in Phobos. Your best bet would be to alter that code to signal the debugger. Sean
You know what would be awesome? If D did null object checking like it does array bounds checking. Array bounds checking works like: assert(someIndex>=0 && someIndex<a.length); x=a[someIndex]; Kind of an implicit assert. The same could be done for member access, such as assert(obj !is null); obj.doSomething(); This would help find probably 90% of the access violations that you get in D.
Aug 18 2005
next sibling parent reply AJG <AJG_member pathlink.com> writes:
You know what would be awesome?  If D did null object checking like it does 
array bounds checking.  Array bounds checking works like:
assert(someIndex>=0 && someIndex<a.length); x=a[someIndex];
Kind of an implicit assert.The same could be done for member access, such as
assert(obj !is null); obj.doSomething();
YES. Please. Thank you, --AJG.
Aug 18 2005
parent "ElfQT" <dethjunk yahoo.com> writes:
A bitt off, but speaking of Assert, a text message would be also highly 
appreciated.
I guess that was asked before. 
Aug 18 2005
prev sibling next sibling parent Chuck Esterbrook <Chuck.Esterbrook gmail.antispam.com> writes:
On Thu, 18 Aug 2005 14:48:26 -0400, "Jarrett Billingsley"
<kb3ctd2 yahoo.com> wrote:

"Sean Kelly" <sean f4.ca> wrote in message 
news:de29h0$2saa$1 digitaldaemon.com...
 In article <de2828$2qi3$1 digitaldaemon.com>,
 =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= says...
Hi.

How can I obtain the line number where an Access Violation occured?
You can't :p Access violations are triggered by the hardware and handled by hook functions in Phobos. Your best bet would be to alter that code to signal the debugger. Sean
You know what would be awesome? If D did null object checking like it does array bounds checking. Array bounds checking works like: assert(someIndex>=0 && someIndex<a.length); x=a[someIndex]; Kind of an implicit assert. The same could be done for member access, such as assert(obj !is null); obj.doSomething(); This would help find probably 90% of the access violations that you get in D.
I just wanted to cast my vote for this idea. This would be a great productivity boost. This is also the type of thing we could work in ourselves if we had a D-to-D front end (see my tiny thread in this news group, "D-to-D [was: ..."). -Chuck
Aug 20 2005
prev sibling parent =?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= writes:
This would work exactly as I want. An AssertError before the access 
violation.

Jarrett Billingsley wrote:
 "Sean Kelly" <sean f4.ca> wrote in message 
 news:de29h0$2saa$1 digitaldaemon.com...
 
In article <de2828$2qi3$1 digitaldaemon.com>,
=?ISO-8859-1?Q?Julio_C=E9sar_Carrascal_Urquijo?= says...

Hi.

How can I obtain the line number where an Access Violation occured?
You can't :p Access violations are triggered by the hardware and handled by hook functions in Phobos. Your best bet would be to alter that code to signal the debugger. Sean
You know what would be awesome? If D did null object checking like it does array bounds checking. Array bounds checking works like: assert(someIndex>=0 && someIndex<a.length); x=a[someIndex]; Kind of an implicit assert. The same could be done for member access, such as assert(obj !is null); obj.doSomething(); This would help find probably 90% of the access violations that you get in D.
Aug 20 2005
prev sibling parent "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Julio César Carrascal Urquijo" <adnoctum phreaker.net> wrote in message 
news:de2828$2qi3$1 digitaldaemon.com...
 Hi.

 How can I obtain the line number where an Access Violation occured?

 Up until now I've scattered lots of writefs to see when they would stop 
 printing but it's a lot of guessing work. Can't the access violation 
 message print at least the function/method that is in execution atm?

 Thanks.
Run the program in WinDbg (or gdb on Linux). It will stop at the violation and you can get the stack and open the source and view the problem statement. Compile with -g.
Aug 20 2005