home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 1.ddi / DOC / README.ADS next >
Encoding:
Text File  |  1992-07-10  |  15.0 KB  |  360 lines

  1.        Copyright (C) 1992 MetaWare Incorporated; All Rights Reserved.
  2.  
  3.                           High C/C++ Version 3.0
  4.                        Globally Optimizing Compiler
  5.                 for Extended DOS 80386/486 and Windows 3.0
  6.                                 July 1992
  7.  
  8.                     +---------------------------------+
  9.                     |  Developing an ADS Application  |
  10.                     +---------------------------------+
  11.  
  12.  
  13. Table of Contents
  14. -----------------
  15. 1.  ADS Development
  16. 1.1.  Removing the Old Initializer
  17. 1.2.  Building Sample ADS Programs with MAKESAMP.BAT
  18. 1.3.  Debugging Your ADS Application with ADSDB.BAT and MDB
  19.  
  20. 2.  ADI Development
  21.  
  22. 3.  For FUTURE AutoCAD Releases with MWADS.LIB
  23.  
  24. 4.  Technical Details for Debugging ADS Applications
  25. 4.1   Need for Breakpoint Protocol
  26. 4.2   Effect of INT 3
  27. 4.3   Determining the ADS Code Selector
  28. 4.4   Getting to ADS with AutoCAD Release 11
  29. 4.5   Getting to ADS with AutoCAD Release 12
  30. 4.6   MDB Commands Generated by ADSDB
  31. 4.7   Loading Multiple Applications
  32. 4.8   Use Current Versions of ADSDB.BAT and COUNTAPP.COM
  33. 4.9   Multiple ADS Applications that Interact
  34.  
  35.  
  36. 1. ADS Development
  37. ------------------
  38. The new driver command-line switches for using the ADS.LIB library are:
  39.  
  40.   -Hloclib  -  This option causes the compiler to use the High C Version 1.x
  41.                calling convention and alignment.  It uses 1.x-compatible
  42.                headers from HIGHC\V1X\INC and libraries from HIGHC\V1X\SMALL.
  43.                It also uses HIGHC\V1X\SMALL\LSDTUB.LIB, which takes care of
  44.                how the long doubles are treated (a long double is 12 bytes in
  45.                High C Version 3.x compilers and 10 bytes in High C Version 1.x
  46.                compilers).
  47.  
  48.   -Hads     -  Automatically links with the Autodesk-modified initializer
  49.                HIGHC\V1X\SMALL\INITADS.OBJ and HIGHC\V1X\SMALL\DOSADS.OBJ.
  50.  
  51. To help you develop ADS applications two batch files, MAKESAMP.BAT and
  52. ADSDB.BAT, are included in the HIGHC\BIN directory.  Before you try to use
  53. these batch files you must remove the old initializer and modify the scripts,
  54. as described in the following sections.
  55.  
  56.  
  57. 1.1.  Removing the Old Initializer
  58. ----------------------------------
  59. FIXADS removes the old initializer from the ADS.LIB library.
  60. Follow these steps:
  61.  
  62. (1) Save ADS.LIB somewhere for safety.  ADS.LIB is in your ACAD\ADS directory.
  63.  
  64. (2) Copy FIXADS.BAT to your ACAD\ADS directory.
  65.  
  66. (3) Go to the ACAD\ADS directory and type:
  67.  
  68.        FIXADS
  69.  
  70.  
  71. 1.2.  Building Sample ADS Programs with MAKESAMP.BAT.
  72. -----------------------------------------------------
  73. MAKESAMP.BAT builds all the sample programs in the ACAD\ADS directory.
  74. Follow these steps:
  75.  
  76. (1) Copy MAKESAMP.BAT from the BIN subdirectory to your working directory.
  77.  
  78. (2) Edit MAKESAMP.BAT to provide the correct settings for your AutoCAD release
  79.     and for optional debugging.
  80.  
  81. (3) To compile all the examples type:
  82.  
  83.        MAKESAMP
  84.  
  85.     To compile a specific example type:
  86.  
  87.        MAKESAMP <filename>
  88.  
  89.  
  90. 1.3.  Debugging your ADS application with ADSDB.BAT.
  91. ----------------------------------------------------
  92. Use batch file ADSDB.BAT to debug your ADS application.  You must:
  93.  
  94. * edit ADSDB.BAT to provide the correct setting for your AutoCAD release
  95.  
  96. * compile your application for debugging.
  97.  
  98. Follow these steps:
  99.  
  100. (1) Modify MAKESAMP.BAT to select the command line for debugging.  Uncoment
  101.     the following line in MAKESAMP.BAT:
  102.  
  103.     If you are compiling C programs
  104.     -------------------------------
  105.     :: hc386 -g %ADS_COMP% -f287 %1.c -Hkeep -Hpro=sample.pro
  106.  
  107.     If you are compiling C++ programs
  108.     ---------------------------------
  109.     :: hc386 -g %ADS_COMP% -f287 %1.cpp -Hkeep -Hpro=sample.pro
  110.  
  111. (2) Run MAKESAMP.BAT to compile your program for debugging:
  112.  
  113.         MAKESAMP yourapp
  114.  
  115. (3) Copy ADSDB.BAT to the directory that contains the application you are
  116.     debugging.
  117.  
  118. (4) Edit ADSDB.BAT to provide the correct values for ADS_VERSION and ACADPATH
  119.     variables.
  120.  
  121. (5) Assuming that AutoCAD is installed in C:ACAD, set the following DOS
  122.     environment variables, depending on which AutoCAD release you are using:
  123.  
  124.     AutoCAD Release 11
  125.     ------------------
  126.     SET ACAD=C:\ACAD;C:\ACAD\SAMPLE;C:\ACAD\ADS
  127.     SET ACADCFG=C:\ACAD
  128.  
  129.     AutoCAD Release 12
  130.     ------------------
  131.     SET ACAD=C:\ACAD\SUPPORT;C:\ACAD\FONTS;C:\ACAD\ADS;
  132.     SET ACADCFG=C:\ACAD
  133.     SET ACADDRV=C:\ACAD\DRV
  134.  
  135. (6) Debug the application:
  136.  
  137.        ADSDB yourapp
  138.  
  139.  
  140. 2. ADI Development
  141. -------------------
  142. The new driver command-line switches for using the P386LIB.LIB and
  143. P386ELIB.LIB libraries are:
  144.  
  145.   -Hloclib  -  This option causes the compiler to use the High C Version 1.x
  146.                calling convention and alignment.  It uses 1.x-compatible
  147.                headers from HIGHC\V1X\INC and libraries from HIGHC\V1X\SMALL.
  148.                It also uses HIGHC\V1X\SMALL\LSDTUB.LIB, which takes care of
  149.                how long doubles are treated (a long double is 12 bytes in
  150.                High C Version 3.x compilers and 10 bytes in High C Version 1.x
  151.                compilers).
  152.  
  153.   -Hadi     -  Automatically links with the Autodesk-modified initializer
  154.                HIGHC\V1X\SMALL\INITADI.OBJ and HIGHC\V1X\SNALL\DOSADI.OBJ.
  155.  
  156. Batch file MAKESAMP.BAT is included in the HIGHC\BIN directory to help you
  157. develop ADI applications.
  158.  
  159. You must run FIXADI.BAT, included in the HIGHC\V1X directory, to remove the
  160. old initializer from the P386LIB and P386ELIB libraries before you run
  161. MAKESAMP.BAT.  You also have to modify the ADS_COMP variable in the
  162. MAKESAMP.BAT file to properly pass P386LIB.LIB and P386ELIB.LIB libraries.
  163.  
  164. Assuming the libraries P386LIB and P386ELIB are in your AutoCAD's ADS
  165. subdirectory, set ADS_COMP as follows:
  166.  
  167.     set ADS_COMP=-Hadi -Hloclib -L%ADSPATH%\ads -lP386ELIB -lP386LIB
  168.  
  169.  
  170.  
  171.  
  172. 3. For FUTURE AutoCAD Releases with MWADS.LIB
  173. ---------------------------------------------
  174. If you have a version of AutoCAD R12 that includes MWADS.LIB you can develop
  175. ADS applications in both C and C++.
  176.  
  177. To use MWADS.LIB you must modify the MAKESAMP.BAT file to select the proper
  178. ADS_COMP variable; see MAKESAMP.BAT for details.  The ADS_COMP variable looks
  179. like this:
  180.  
  181.     set ADS_COMP=-Hads -L%ADSPATH%\ads -lmwads
  182.  
  183.  
  184. 4.  Technical Details for Debugging ADS Applications
  185. -----------------------------------------------------
  186. MetaWare's debugger, MDB, is a full-featured general-purpose debugger you can
  187. use for all your High C/C++ programs.  Although not tailored specifically to
  188. AutoCAD ADS applications, once the AutoCAD environment has been set up for
  189. MDB, you can proceed with debugging as usual.  MDB has no intrinsic knowledge
  190. about specific applications such as ADS.  To MDB, AutoCAD is an application,
  191. and an ADS application is another application that is loaded from within
  192. AutoCAD.
  193.  
  194.  
  195. 4.1 Need for Breakpoint Protocol
  196. --------------------------------
  197. The ADS application's environment (which is AutoCAD) must set up a protocol
  198. for establishing breakpoints in the ADS application.  Because an ADS
  199. application is loaded from within AutoCAD, to get access to the ADS code MDB
  200. must first load AutoCAD.  Getting from there into the ADS application code is
  201. difficult without the help of the ADS's application environment (AutoCAD).
  202.  
  203.  
  204. 4.2 Effect of INT 3
  205. -------------------
  206. AutoCAD inserts an INT 3 debug-break machine instruction in its XLOAD command.
  207. Under normal operating conditions this has no effect on AutoCAD behavior,
  208. because INT 3 simply responds with a return.  However, inside the debugger
  209. environment, MDB traps this instruction, and thus gains control of the CPU.
  210. So an ADS application can be debugged by first loading and running AutoCAD
  211. within MDB.  As soon as you type XLOAD to load the ADS application into
  212. AutoCAD, MDB receives an INT 3 trap and control is passed back to MDB.
  213.  
  214.  
  215. 4.3 Determining the ADS Code Selector
  216. -------------------------------------
  217. An ADS application resides in a different code and data segment from AutoCAD.
  218. Immediately after INT 3, control is still in the AutoCAD code and data
  219. segment.  To set a breakpoint in the ADS application, you must know the ADS
  220. application code segment (sometimes called "code selector") assigned by
  221. AutoCAD.
  222.  
  223. AutoCAD Release 11 (and prior) displays the code and data selector to be
  224. assigned to the ADS application immediately after the XLOAD command is issued.
  225. Getting the code-selector value from the screen is inconvenient from the
  226. application developer's point of view, and this value may no longer be
  227. available beginning with AutoCAD Release 12.  So, we need another way to get
  228. to the code selector value.
  229.  
  230.  
  231. 4.4 Getting to ADS with AutoCAD Release 11
  232. ------------------------------------------
  233. In AutoCAD Release 11, transfer is passed to the ADS application's initializer
  234. after AutoCAD executes two or three instructions past INT 3.  You can set a
  235. breakpoint in your ADS application simply by executing MDB's STEP IN command
  236. three or four times after INT 3, and execution will be at the ADS application
  237. code and data segment.
  238.  
  239. At this point you can type GO MAIN to get directly to the ADS application main
  240. (this is equivalent to setting a breakpoint at main and typing GO).  Remember:
  241. the purpose of setting this breakpoint is to skip AutoCAD code that is not
  242. part of the ADS application, and get to the ADS application's main.  From
  243. there you can set further breakpoints or single steps through the code as
  244. desired, just like debugging any program.  (Simply typing GO without setting
  245. further breakpoints would defeat the whole purpose of setting the first
  246. breakpoint, because AutoCAD would regain control of the CPU and there is no
  247. way to get back to MDB's interactive mode.)
  248.  
  249. For AutoCAD Release 11, MDB's commands to set a breakpoint at main are:
  250.  
  251.    eip++         // to skip over INT 3.
  252.    step in       // to skip over one instruction.
  253.    step in       // to skip over another instruction.
  254.    step in       // to skip over yet another instruction (hopefully, now
  255.                  //  we have switched to the ADS code segment.
  256.    go main       // go to the ADS main.
  257.  
  258. If you use the latest version of the ADSDB.BAT script, these MDB commands are
  259. automatically entered for you via MDB's journal file.
  260.  
  261.  
  262. 4.5 Getting to ADS with AutoCAD Release 12
  263. ------------------------------------------
  264. In AutoCAD release 12, about 100 AutoLISP instructions are executed after the
  265. INT 3, before you get into the ADS initializer (that is, the point where
  266. AutoCAD switches code and data segment to the ADS application initializer).
  267. The code sequence between INT 3 and transfer to an ADS application consists of
  268. several instructions follow by a call to someplace, then several more
  269. instructions followed by a far call to the ADS application (beware that MDB
  270. mistakenly displays it as near call).
  271.  
  272. The sequence of MDB commands to set a breakpoint at ADS's main is:
  273.  
  274.    eip++         // to skip over INT 3.
  275.    go till call  // to skip over to first call.
  276.    go till call  // to skip over to second call.
  277.    step in       // to step to the call.
  278.    step in       // to step into the initializer.
  279.    go main       // go to the ADS main.
  280.  
  281. Pre-release versions of AutoCAD Release 12 may have a different instruction
  282. sequence before the transfer of control to the ADS application.  If you are
  283. using a pre-release version, you must modify the ADSDB.BAT script (see file
  284. ADSDB.BAT for guidelines).
  285.  
  286.  
  287. 4.6 MDB Commands Generated by ADSDB
  288. -----------------------------------
  289. If you look at the MDB journal file (yourapp.jou) generated by the ADSDB.BAT
  290. script, for AutoCAD Release 11 the following MDB commands are issued:
  291.  
  292.    main off
  293.    flip on
  294.    load yourapp nocode
  295.    go
  296.  
  297. "main off" prevents MDB from skipping main.
  298.  
  299. "flip on" causes MDB to flip and refresh the graphics screen every time an
  300. instruction is executed.  This is necessary for debugging graphics applications.
  301.  
  302. "load yourapp nocode" loads your application symbols information, but without
  303. the code (your application must be loaded from AutoCAD via the XLOAD command).
  304.  
  305. "go" loads and runs AutoCAD.  When AutoCAD is loaded and running, you can
  306. issue the XLOAD command to load your ADS application at any time.  Control is
  307. passed to MDB via the INT 3 instruction trap after XLOAD.  At this point, the
  308. remaining journal file's commands are executed, and execution is transferred
  309. automatically into the application's main, where normal debugging can take
  310. place.
  311.  
  312.  
  313. 4.7 Loading Multiple Applications
  314. ---------------------------------
  315. AutoCAD Release 12 can load multiple applications.  Look in the AutoCAD
  316. directory for a file called ACAD.ADS that contains a list of the applications
  317. to be loaded after AutoCAD is loaded.  Because AutoCAD uses XLOAD to load
  318. these applications, the debugger receives an INT 3 for each application
  319. loaded.  To skip over breaks for applications you are not trying to debug, you
  320. must issue the following MDB commands:
  321.  
  322.    eip++         // Skip over INT 3.
  323.    go            // Continue from here.
  324.  
  325. INT 3 can be skipped only with MDB's eip++ command.  The COUNTAPP.COM program
  326. in your distribution generates as many "eip++" "go" sequences as there are
  327. applications listed in the ACAD.ADS file.  Make sure you have version 1.02 or
  328. later of COUNTAPP.COM; earlier versions treated every blank line in ACAD.ADS
  329. as an ADS application name.  To see what version of COUNTAPP.COM you have,
  330. invoke COUNTAPP.COM; it should display the version number.  For example:
  331.  
  332.     C:> countapp
  333.     Program: countapp (Ver 1.02) Copyright (C) MetaWare Incorporated 1991-1992
  334.     Utility : Counts the number of ADS applications in acad.ads, and generates
  335.               MDB commands for ADSDB.BAT script.
  336.     Usage: your_application acad_version
  337.  
  338. 4.8 Use Current Versions of ADSDB.BAT and COUNTAPP.COM
  339. ------------------------------------------------------
  340. With the versions of ADSDB.BAT and COUNTAPP.COM you receive with this
  341. document, you no longer have to look at AutoCAD's screen for the ADS
  342. application code selector to set a breakpoint to main.  Control is
  343. automatically directed to your application's main when you invoke ADSDB.
  344.  
  345. WARNING:  Due to possible differences in AutoCAD releases, the automatic
  346.           scheme to get to the application main with ADSDB.BAT script may be
  347.           off by a few commands.  If you understand the details described
  348.           above, modifying the ADSDB.BAT to suite your environment may not
  349.           be as difficult or complicated as it seems.
  350.  
  351. 4.9 Multiple ADS Applications that Interact
  352. --------------------------------------------
  353. The information described in this document may be essential in debugging
  354. multiple ADS applications interacting with each other.  Currently, there is no
  355. easy way to debug multiple ADS applications simultaneously.  You cannot use
  356. ADSDB.BAT; instead you must follow the steps described in this document to set
  357. a breakpoint at each application, and load each application with no code at
  358. the appropriate point.  Applications developed this way require more effort to
  359. debug.
  360.