1

I am suffering from Delphi 2009 :)

I have to find some bugs in a very old, grown software written in Delphi. When I launch the application in the Debugger, I just get an Error Msg saying: "Access violation at address xy". But I do not get any hint on the line of coide that caused the error. I really can not believe that Delphi is not able to show this information like Java for example does. I am sure I am doing something wrong here.

I have activated Debug Infos in Linker page (in Projekt options) with no success.

Please give me some hints how to setup Delphi correctly to show me the broken line. If there would be a call stacktrace as known from Java, it would be even better.

Thanks.

Christian Rockrohr
  • 1,045
  • 1
  • 14
  • 29
  • AFAIR, the Delphi debugger is powerless when it comes to access violations. You're gonna have to look into your code and see if you're trying to mess with memory that has been freed already. (If memory serves me right, that's usually the cause) – Jeff Feb 04 '13 at 19:13
  • Double check that your project is in Debug Mode (Right-click on the open project, go to options -> Compiler) and that the debugging options you want to look for are checked. – Tom A Feb 04 '13 at 19:14
  • "with debug dcu's" was set to false. does this matter? – Christian Rockrohr Feb 04 '13 at 19:22
  • Debug DCU's doesn't matter as much. Debug information provides the help you need, but if you're in debug mode already, then my first comment is useless to you right now. – Tom A Feb 04 '13 at 19:30
  • 1
    Debug dcu's option allows tracing into VCL/RTL sources. It does not affect your own code. – kludg Feb 04 '13 at 19:33
  • OK, thanks for you attention. Have a good evening – Christian Rockrohr Feb 04 '13 at 19:45
  • You should also install FastMM4, set it for full-debug, set it's `CheckHeapForCorruption` option. Maybe it manages to raise the error sooner / closer to the source of the problem. – Cosmin Prund Feb 04 '13 at 19:56
  • Is this not a duplicate of "http://stackoverflow.com/questions/8523004/how-do-i-get-a-stack-trace-from-a-handled-caught-exception-and-dump-it-to-a-trac"? The short answer is you *can* get java-style stack traces using JCL Debug. – awmross Feb 05 '13 at 01:31

1 Answers1

5

You should add exception logging to your application. For example EurekaLog or madExcept. I personally use the latter and cannot recommend it highly enough.

Once you have the exception logging tool added to your project, any unhandled exceptions will result in a comprehensive bug report including stack traces for your threads.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • OK, thanks. I will give it a try. And it is really not possible to do similar things with buildin tools? – Christian Rockrohr Feb 04 '13 at 19:16
  • 2
    Not unless you write it yourself. You can call `RtlCaptureStackBackTrace` and then relate that to code using your .map file. But that's really rather pathetic compared to the two fabulous tools I mention. My professional life involves developing a program that includes madExcept. The quality of this program is far higher due to madExcept. It has made a huge difference for us. – David Heffernan Feb 04 '13 at 19:17
  • @David, the OP says `When I launch the application in the Debugger` - that means he's running into the IDE. You can see the stack trace just fine within the IDE, that's "using built-in tools" – Cosmin Prund Feb 04 '13 at 19:43
  • @CosminPrund We all know that in the real world some bugs are harder to reproduce than others. If you have ME or EL in your app then you always get the diagnostics that you need. If you don't, and you cannot repro under the debugger, then you are stuffed. So, I wouldn't be without a tool like this. What's more, the debugger is often rubbish at giving stack traces in the face of an AV. What's more Christian points out that the debugger is providing no information. Christian is using the debugger now and it isn't giving him what he needs. – David Heffernan Feb 04 '13 at 19:45
  • 2
    @DavidHeffernan, what I'm saying, you've just told the OP that he can't get a stack-trace unless he uses 3rd party tools or writes it's own. That's just not true, you get stack traces just fine in the debugger. The OP says he's seeing the error in the debugger. – Cosmin Prund Feb 04 '13 at 19:47
  • @CosminPrund No, what I am saying is true. It's quite common for the debugger to be incapable of showing a stack trace after AV. – David Heffernan Feb 04 '13 at 19:48
  • I just installed it and it look awsome. It's allready late here, I will give an in deep try tomorrow. Thanks for your comments. – Christian Rockrohr Feb 04 '13 at 20:16
  • We use a free tool called JCLDebug. It can print stack traces to the log, including for AccessViolations. – awmross Feb 05 '13 at 01:33