home *** CD-ROM | disk | FTP | other *** search
- Copyright (C) 1992 MetaWare Incorporated; All Rights Reserved.
-
- High C/C++ Version 3.0
- Globally Optimizing Compiler
- for Extended DOS 80386/486 and Windows 3.0
- July 1992
-
- +---------------------------------+
- | Developing an ADS Application |
- +---------------------------------+
-
-
- Table of Contents
- -----------------
- 1. ADS Development
- 1.1. Removing the Old Initializer
- 1.2. Building Sample ADS Programs with MAKESAMP.BAT
- 1.3. Debugging Your ADS Application with ADSDB.BAT and MDB
-
- 2. ADI Development
-
- 3. For FUTURE AutoCAD Releases with MWADS.LIB
-
- 4. Technical Details for Debugging ADS Applications
- 4.1 Need for Breakpoint Protocol
- 4.2 Effect of INT 3
- 4.3 Determining the ADS Code Selector
- 4.4 Getting to ADS with AutoCAD Release 11
- 4.5 Getting to ADS with AutoCAD Release 12
- 4.6 MDB Commands Generated by ADSDB
- 4.7 Loading Multiple Applications
- 4.8 Use Current Versions of ADSDB.BAT and COUNTAPP.COM
- 4.9 Multiple ADS Applications that Interact
-
-
- 1. ADS Development
- ------------------
- The new driver command-line switches for using the ADS.LIB library are:
-
- -Hloclib - This option causes the compiler to use the High C Version 1.x
- calling convention and alignment. It uses 1.x-compatible
- headers from HIGHC\V1X\INC and libraries from HIGHC\V1X\SMALL.
- It also uses HIGHC\V1X\SMALL\LSDTUB.LIB, which takes care of
- how the long doubles are treated (a long double is 12 bytes in
- High C Version 3.x compilers and 10 bytes in High C Version 1.x
- compilers).
-
- -Hads - Automatically links with the Autodesk-modified initializer
- HIGHC\V1X\SMALL\INITADS.OBJ and HIGHC\V1X\SMALL\DOSADS.OBJ.
-
- To help you develop ADS applications two batch files, MAKESAMP.BAT and
- ADSDB.BAT, are included in the HIGHC\BIN directory. Before you try to use
- these batch files you must remove the old initializer and modify the scripts,
- as described in the following sections.
-
-
- 1.1. Removing the Old Initializer
- ----------------------------------
- FIXADS removes the old initializer from the ADS.LIB library.
- Follow these steps:
-
- (1) Save ADS.LIB somewhere for safety. ADS.LIB is in your ACAD\ADS directory.
-
- (2) Copy FIXADS.BAT to your ACAD\ADS directory.
-
- (3) Go to the ACAD\ADS directory and type:
-
- FIXADS
-
-
- 1.2. Building Sample ADS Programs with MAKESAMP.BAT.
- -----------------------------------------------------
- MAKESAMP.BAT builds all the sample programs in the ACAD\ADS directory.
- Follow these steps:
-
- (1) Copy MAKESAMP.BAT from the BIN subdirectory to your working directory.
-
- (2) Edit MAKESAMP.BAT to provide the correct settings for your AutoCAD release
- and for optional debugging.
-
- (3) To compile all the examples type:
-
- MAKESAMP
-
- To compile a specific example type:
-
- MAKESAMP <filename>
-
-
- 1.3. Debugging your ADS application with ADSDB.BAT.
- ----------------------------------------------------
- Use batch file ADSDB.BAT to debug your ADS application. You must:
-
- * edit ADSDB.BAT to provide the correct setting for your AutoCAD release
-
- * compile your application for debugging.
-
- Follow these steps:
-
- (1) Modify MAKESAMP.BAT to select the command line for debugging. Uncoment
- the following line in MAKESAMP.BAT:
-
- If you are compiling C programs
- -------------------------------
- :: hc386 -g %ADS_COMP% -f287 %1.c -Hkeep -Hpro=sample.pro
-
- If you are compiling C++ programs
- ---------------------------------
- :: hc386 -g %ADS_COMP% -f287 %1.cpp -Hkeep -Hpro=sample.pro
-
- (2) Run MAKESAMP.BAT to compile your program for debugging:
-
- MAKESAMP yourapp
-
- (3) Copy ADSDB.BAT to the directory that contains the application you are
- debugging.
-
- (4) Edit ADSDB.BAT to provide the correct values for ADS_VERSION and ACADPATH
- variables.
-
- (5) Assuming that AutoCAD is installed in C:ACAD, set the following DOS
- environment variables, depending on which AutoCAD release you are using:
-
- AutoCAD Release 11
- ------------------
- SET ACAD=C:\ACAD;C:\ACAD\SAMPLE;C:\ACAD\ADS
- SET ACADCFG=C:\ACAD
-
- AutoCAD Release 12
- ------------------
- SET ACAD=C:\ACAD\SUPPORT;C:\ACAD\FONTS;C:\ACAD\ADS;
- SET ACADCFG=C:\ACAD
- SET ACADDRV=C:\ACAD\DRV
-
- (6) Debug the application:
-
- ADSDB yourapp
-
-
- 2. ADI Development
- -------------------
- The new driver command-line switches for using the P386LIB.LIB and
- P386ELIB.LIB libraries are:
-
- -Hloclib - This option causes the compiler to use the High C Version 1.x
- calling convention and alignment. It uses 1.x-compatible
- headers from HIGHC\V1X\INC and libraries from HIGHC\V1X\SMALL.
- It also uses HIGHC\V1X\SMALL\LSDTUB.LIB, which takes care of
- how long doubles are treated (a long double is 12 bytes in
- High C Version 3.x compilers and 10 bytes in High C Version 1.x
- compilers).
-
- -Hadi - Automatically links with the Autodesk-modified initializer
- HIGHC\V1X\SMALL\INITADI.OBJ and HIGHC\V1X\SNALL\DOSADI.OBJ.
-
- Batch file MAKESAMP.BAT is included in the HIGHC\BIN directory to help you
- develop ADI applications.
-
- You must run FIXADI.BAT, included in the HIGHC\V1X directory, to remove the
- old initializer from the P386LIB and P386ELIB libraries before you run
- MAKESAMP.BAT. You also have to modify the ADS_COMP variable in the
- MAKESAMP.BAT file to properly pass P386LIB.LIB and P386ELIB.LIB libraries.
-
- Assuming the libraries P386LIB and P386ELIB are in your AutoCAD's ADS
- subdirectory, set ADS_COMP as follows:
-
- set ADS_COMP=-Hadi -Hloclib -L%ADSPATH%\ads -lP386ELIB -lP386LIB
-
-
-
-
- 3. For FUTURE AutoCAD Releases with MWADS.LIB
- ---------------------------------------------
- If you have a version of AutoCAD R12 that includes MWADS.LIB you can develop
- ADS applications in both C and C++.
-
- To use MWADS.LIB you must modify the MAKESAMP.BAT file to select the proper
- ADS_COMP variable; see MAKESAMP.BAT for details. The ADS_COMP variable looks
- like this:
-
- set ADS_COMP=-Hads -L%ADSPATH%\ads -lmwads
-
-
- 4. Technical Details for Debugging ADS Applications
- -----------------------------------------------------
- MetaWare's debugger, MDB, is a full-featured general-purpose debugger you can
- use for all your High C/C++ programs. Although not tailored specifically to
- AutoCAD ADS applications, once the AutoCAD environment has been set up for
- MDB, you can proceed with debugging as usual. MDB has no intrinsic knowledge
- about specific applications such as ADS. To MDB, AutoCAD is an application,
- and an ADS application is another application that is loaded from within
- AutoCAD.
-
-
- 4.1 Need for Breakpoint Protocol
- --------------------------------
- The ADS application's environment (which is AutoCAD) must set up a protocol
- for establishing breakpoints in the ADS application. Because an ADS
- application is loaded from within AutoCAD, to get access to the ADS code MDB
- must first load AutoCAD. Getting from there into the ADS application code is
- difficult without the help of the ADS's application environment (AutoCAD).
-
-
- 4.2 Effect of INT 3
- -------------------
- AutoCAD inserts an INT 3 debug-break machine instruction in its XLOAD command.
- Under normal operating conditions this has no effect on AutoCAD behavior,
- because INT 3 simply responds with a return. However, inside the debugger
- environment, MDB traps this instruction, and thus gains control of the CPU.
- So an ADS application can be debugged by first loading and running AutoCAD
- within MDB. As soon as you type XLOAD to load the ADS application into
- AutoCAD, MDB receives an INT 3 trap and control is passed back to MDB.
-
-
- 4.3 Determining the ADS Code Selector
- -------------------------------------
- An ADS application resides in a different code and data segment from AutoCAD.
- Immediately after INT 3, control is still in the AutoCAD code and data
- segment. To set a breakpoint in the ADS application, you must know the ADS
- application code segment (sometimes called "code selector") assigned by
- AutoCAD.
-
- AutoCAD Release 11 (and prior) displays the code and data selector to be
- assigned to the ADS application immediately after the XLOAD command is issued.
- Getting the code-selector value from the screen is inconvenient from the
- application developer's point of view, and this value may no longer be
- available beginning with AutoCAD Release 12. So, we need another way to get
- to the code selector value.
-
-
- 4.4 Getting to ADS with AutoCAD Release 11
- ------------------------------------------
- In AutoCAD Release 11, transfer is passed to the ADS application's initializer
- after AutoCAD executes two or three instructions past INT 3. You can set a
- breakpoint in your ADS application simply by executing MDB's STEP IN command
- three or four times after INT 3, and execution will be at the ADS application
- code and data segment.
-
- At this point you can type GO MAIN to get directly to the ADS application main
- (this is equivalent to setting a breakpoint at main and typing GO). Remember:
- the purpose of setting this breakpoint is to skip AutoCAD code that is not
- part of the ADS application, and get to the ADS application's main. From
- there you can set further breakpoints or single steps through the code as
- desired, just like debugging any program. (Simply typing GO without setting
- further breakpoints would defeat the whole purpose of setting the first
- breakpoint, because AutoCAD would regain control of the CPU and there is no
- way to get back to MDB's interactive mode.)
-
- For AutoCAD Release 11, MDB's commands to set a breakpoint at main are:
-
- eip++ // to skip over INT 3.
- step in // to skip over one instruction.
- step in // to skip over another instruction.
- step in // to skip over yet another instruction (hopefully, now
- // we have switched to the ADS code segment.
- go main // go to the ADS main.
-
- If you use the latest version of the ADSDB.BAT script, these MDB commands are
- automatically entered for you via MDB's journal file.
-
-
- 4.5 Getting to ADS with AutoCAD Release 12
- ------------------------------------------
- In AutoCAD release 12, about 100 AutoLISP instructions are executed after the
- INT 3, before you get into the ADS initializer (that is, the point where
- AutoCAD switches code and data segment to the ADS application initializer).
- The code sequence between INT 3 and transfer to an ADS application consists of
- several instructions follow by a call to someplace, then several more
- instructions followed by a far call to the ADS application (beware that MDB
- mistakenly displays it as near call).
-
- The sequence of MDB commands to set a breakpoint at ADS's main is:
-
- eip++ // to skip over INT 3.
- go till call // to skip over to first call.
- go till call // to skip over to second call.
- step in // to step to the call.
- step in // to step into the initializer.
- go main // go to the ADS main.
-
- Pre-release versions of AutoCAD Release 12 may have a different instruction
- sequence before the transfer of control to the ADS application. If you are
- using a pre-release version, you must modify the ADSDB.BAT script (see file
- ADSDB.BAT for guidelines).
-
-
- 4.6 MDB Commands Generated by ADSDB
- -----------------------------------
- If you look at the MDB journal file (yourapp.jou) generated by the ADSDB.BAT
- script, for AutoCAD Release 11 the following MDB commands are issued:
-
- main off
- flip on
- load yourapp nocode
- go
-
- "main off" prevents MDB from skipping main.
-
- "flip on" causes MDB to flip and refresh the graphics screen every time an
- instruction is executed. This is necessary for debugging graphics applications.
-
- "load yourapp nocode" loads your application symbols information, but without
- the code (your application must be loaded from AutoCAD via the XLOAD command).
-
- "go" loads and runs AutoCAD. When AutoCAD is loaded and running, you can
- issue the XLOAD command to load your ADS application at any time. Control is
- passed to MDB via the INT 3 instruction trap after XLOAD. At this point, the
- remaining journal file's commands are executed, and execution is transferred
- automatically into the application's main, where normal debugging can take
- place.
-
-
- 4.7 Loading Multiple Applications
- ---------------------------------
- AutoCAD Release 12 can load multiple applications. Look in the AutoCAD
- directory for a file called ACAD.ADS that contains a list of the applications
- to be loaded after AutoCAD is loaded. Because AutoCAD uses XLOAD to load
- these applications, the debugger receives an INT 3 for each application
- loaded. To skip over breaks for applications you are not trying to debug, you
- must issue the following MDB commands:
-
- eip++ // Skip over INT 3.
- go // Continue from here.
-
- INT 3 can be skipped only with MDB's eip++ command. The COUNTAPP.COM program
- in your distribution generates as many "eip++" "go" sequences as there are
- applications listed in the ACAD.ADS file. Make sure you have version 1.02 or
- later of COUNTAPP.COM; earlier versions treated every blank line in ACAD.ADS
- as an ADS application name. To see what version of COUNTAPP.COM you have,
- invoke COUNTAPP.COM; it should display the version number. For example:
-
- C:> countapp
- Program: countapp (Ver 1.02) Copyright (C) MetaWare Incorporated 1991-1992
- Utility : Counts the number of ADS applications in acad.ads, and generates
- MDB commands for ADSDB.BAT script.
- Usage: your_application acad_version
-
- 4.8 Use Current Versions of ADSDB.BAT and COUNTAPP.COM
- ------------------------------------------------------
- With the versions of ADSDB.BAT and COUNTAPP.COM you receive with this
- document, you no longer have to look at AutoCAD's screen for the ADS
- application code selector to set a breakpoint to main. Control is
- automatically directed to your application's main when you invoke ADSDB.
-
- WARNING: Due to possible differences in AutoCAD releases, the automatic
- scheme to get to the application main with ADSDB.BAT script may be
- off by a few commands. If you understand the details described
- above, modifying the ADSDB.BAT to suite your environment may not
- be as difficult or complicated as it seems.
-
- 4.9 Multiple ADS Applications that Interact
- --------------------------------------------
- The information described in this document may be essential in debugging
- multiple ADS applications interacting with each other. Currently, there is no
- easy way to debug multiple ADS applications simultaneously. You cannot use
- ADSDB.BAT; instead you must follow the steps described in this document to set
- a breakpoint at each application, and load each application with no code at
- the appropriate point. Applications developed this way require more effort to
- debug.