Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging an AutoCAD module

I am working on a project which is a dll module for AutoCAD, which adds some new functionality (like menus, objects, etc.) to the environment. Naturally, there are some bugs in the menus, objects of the module.

The problem is as follows, when I see some bug in a dialog, menu item, edit field, or during some operation how do I find the corresponding place in the source code that is responsible for it? What tools should I use besides the ordinary debugging?

I use C++ in VS2010. The source code has about 500 000 lines, so it takes some time to get acquainted with it.

like image 252
grzkv Avatar asked Aug 16 '26 00:08

grzkv


2 Answers

Here is the method I use for C#/.NET. I can't guarantee it will also work for C++ dlls but it's worth a try.

First, in the Visual Studio config file for your solution, add the following lines to the Debug|Any CPU configuration:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <!-- there should be other options already in here! -->
  <StartAction>Program</StartAction>
  <StartProgram>c:\program files\autocad2008\acad.exe</StartProgram>
</PropertyGroup>

I use AutoCAD 2008 - substitute the path to your executable. In Visual Studio you should be able to set this from the configuration screen but in the Express editions you need to make this change manually in notepad or a similar editor.

Next, make sure that any AutoCAD provided dll that you reference in your project has the Copy Local attribute set to False.

Set any breakpoints you want in your code.

Now when you 'run' the dll it should start AutoCAD.

Load your dll in AutoCAD using netload (Make sure you select a debug version - release versions won't work!)

The module should run to your first breakpoint.

like image 193
JayP Avatar answered Aug 18 '26 14:08

JayP


Autocad doesn't provide debug info for it's binaries (pdb files).

If the crash is in your module, it should be fairly easy to debug, just make sure you have the corresponding pdb's and dll's. By dll's I'm also talking about arx and dbx files.

If the crash is in an AutoCAD module... well, from experience, I'm 99.9% sure that the source is your code, and not AutoCAD's.

like image 24
Luchian Grigore Avatar answered Aug 18 '26 15:08

Luchian Grigore



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!