The CaseVision/WorkShop tools from SGI offer a wealth of power to the
ARX developer. The tips presented here are aimed toward the use of the
CV tools although they should apply to the standard command-line 'dbx'
debugger as well.
First, to debug ARX applications, a few concepts need to be understood.
foo.arx
) is implemented as
an IRIX dynamic shared object (DSO). As such, it lacks a main()
function and can't be run (or debugged) by itself. This means you need
to debug AutoCAD itself:
acrxEntryPoint()
function.
acrxEntryPoint()
in this
application, then load your own application, the debugger will
automatically set a breakpoint at its acrxEntryPoint()
function
as well.
cvd > stop in acrxEntryPoin
t
acrxEntryPoint()
. Usually a second call will happen
before your application can process commands. You can now set
breakpoints in your code simply by clicking the mouse to the left of
the line of code you wish to break at.
If your ARX application causes a run-time error inside AutoCAD, you'll probably get an error dialog with a message like: "AutoCAD can't continue...". Then AutoCAD will exit and you may see one of the following kinds of messages in your shell window:
Since AutoCAD has internal signal handlers, you'll most likely never
see a 'core'
dump from AutoCAD. Rather, you'll need to run
AutoCAD in the debugger, then let the debugger trap the signal and tell
you where in your application the error occurred.
The WorkShop package includes a memory allocation library that offers run-time debugging information. Normally, you would link the debug library into your application, but since ARX applications are themselves linked into AutoCAD at run-time, this technique is not applicable. Rather it is necessary to instruct the run-time linker (rld) to load the malloc_cv library first when starting AutoCAD. In this manner the debug functions are used.
The debug library can be used as-is, running AutoCAD in a stand-alone
mode. Debug messages will be written to stderr
and you can
control the various memory allocation tracing features via enviroment
variables. Alternately, you can run AutoCAD inside the debugger (cvd) and gain
additional information. Most notably, if you set a breakpoint at the cvmalloc_error
function (cvd> stop in cvmalloc_error
) you can see the
call stack at the point the error was detected.
Here's a handy shell script to use for debugging memory allocation errors in AutoCAD.
chmod +x cvmalloc_acad
)
Last updated: 02.NOV.1998