TweetFollow Us on Twitter

The Debugger
Volume Number:6
Issue Number:3
Column Tag:Developer's Workshop

The Debugger, MacApp,
and Incremental Linking

By Ronald G. Parsons, Donoho Design Group, Inc., Austin, TX

[Ron Parsons is a theoretical physicist turned Macintosh developer now living in Austin, Texas where he preaches “the way” is “OOP and MacApp.” His experience with MacApp emphasizes scientific visualization and parallel processing. He can be reached at AppleLink D1977.]

In the Beginning

Steve Jasik has recently released a new version of The Debugger, Jasik Design’s answer to those who want even the kitchen sink in a source level debugger. The debugging and disassembling aspects of this program have been discussed before here (MacTutor, April 1987, p. 13) and elsewhere (MacWEEK, September 15, 1987, p. 22). In this article, I will concentrate on two new aspects of The Debugger, an incremental build system which greatly reduces the time required for the compile-link-test cycle, and some features added to facilitate debugging in an object-oriented environment - specifically MacApp®. These new features include:

• The ability to “step into” MacApp methods at the source level.

• The addition of an “Object Inspector.”

• The capability to do WriteLn’s to the -Notes- window of The Debugger.

• A procedure entry/exit trace window.

The Debugger provides at least partial solutions to two problems every MacApp developer faces. A MacApp program must be linked with most of the MacApp libraries each time a change is made to the source code and the application rebuilt. Since these libraries are large, even a small MacApp program may require a minute or two on a Mac II for the linker to do its thing. A new feature, the Incremental Build System (IBS), has been added by Jasik to reduce to nearly zero the time required to link after an incremental change.

The Incremental Build System requires a Mac with at least 4 Mb of RAM. It is available only with the Universal Version (which is required for the Mac II and SE/30). A Quick Reference card is now provided for The Debugger. This is a very handy document (four pages of small type) and is concise synopsis of its features.

The Thrill of Debugging

Incremental linking using IBS really shines where a small set of routines need a number of tweaks with debugger sessions in between. Because the MPW editor is not language sensitive, the programmer must tell IBS manually what modules (procedures or functions) have been changed since the last master build using the MPW tool make. Telling IBS that a module needs incremental building is as simple as selecting the name of the changed or new module and selecting a menu item in the MPW shell. Once you’ve told IBS that a module is changed, it remembers until the next full make.

To perform an incremental link, you interrupt your running program by pressing Option-and re-enter the MPW shell. After you make the changes to the source, and tell IBS of the changed module(s), choose the PatchBuild menu item in the IBS menu and the source file is re-compiled, and (nearly) instantly re-linked. If the PatchBuild was successful, your program is restarted where it was interrupted.

Stepping into and thru MacApp methods is as straightforward as in a non-object oriented environment. I have had problems with SADE’s stepIntoMethod proc. It would step into a MacApp method but its brakes would fail and would skid along inside the method, finally stopping after perhaps falling into yet another called method. No such failures were observed with The Debugger’s stepping.

“Getting Acquainted” with Pascal MacApp

Jasik’s IBS notes do not have an example of using MacApp with IBS, so this void is filled below. We’ll use a copy of the MacApp Nothing example program from MacApp 2.0b9. I will assume that the source file is in a folder with path

First the correct MABuild parameters must be used. We need .map and .sym files and we’ll be using The Debugger rather than the MacApp debugger so the MABuild command is:

#1

MABuild Nothing 
 -NoDebug 
 -NoAutobuild 
 -LinkMap 
 -Sym 

Now perform the following steps:

• Build the Nothing application using the MABuild command above.

• Choose Create Project from the IBS menu. You will be asked the find the Nothing application. It will be in the .SADE Non-Debug Files folder within the folder

• The next dialog will ask which type of application you are debugging. Of course, we’ll choose “1) is MacApp based.”

• IBS will create the Debugger Startup Info (.dsi) file. A series of GetFile dialogs will be presented. Select a file in each folder that contains your source or MacApp’s source. Your source will be in and MacApp’s will be in Click cancel when finished.

• Next modify the .dsi file by adding the text from the TList_REDEF file in the SIJ_MacApp_Libs folder of The Debugger before the =END statement of the .dsi file. Now The Debugger will be able to find the appropriate source files and be able to display TList objects better. Save and close the .dsi file.

• Now execute Nothing under the MPW Shell.

• Transfer from Nothing to The Debugger by pressing Option- The source of TApplication. GetEvent will be displayed with the call to WaitNextEvent hilighted.

• Use the Side Door to MPW menu command to transfer to MPW. About the only method overridden in Nothing is TDefaultView.Draw so let’s modify that procedure. Change the PenSize command to draw a thicker border, e.g. PenSize(30, 30);. Hilight the procedure name TDefaultView.Draw and choose Add Hint from the IBS menu. This will tell the IBS that you are modifying this procedure so it will link in the new code. Choose PatchBuild from the IBS menu. The link will be almost instantaneous. If there are no errors, the application Nothing will be resumed at the WaitNextEvent trap. Press Cmd-E to resume Nothing. The gray border will now be thicker. Exit back to The Debugger by again pressing Option-

• Use the Side Door to MPW menu command to transfer to MPW. Now insert a Debugger trap as the first instruction in the TDefaultView.Draw procedure, e.g., DebugStr(‘Stopped in TDefaultView.Draw’);It is not necessary to again choose Add Hint as IBS will remember the changed procedures until the next full build. Choose PatchBuild from the IBS menu. Now when Draw is executed, the debugger trap will be caught by The Debugger and the added source line displayed. The application may be resumed by pressing Cmd-E (Exit to Program).

“Getting Acquainted” with C++ MacApp

Using The Debugger with the new C++ headers for MacApp is not much different from the familiar Pascal MacApp. The correct MABuild parameters are slightly different for C++. We will use the translation of the Pascal Nothing example into C++. Rename the source file CPlusNothing.cp so there will be no conflict with the Nothing project in the IBS menu. If there are string constants in your code that will be debugged, the -b parameter must be passed to CPlus and PatchBuild. The MABuild command is:

#2

MABuild CPlusNothing 
 -NoDebug 
 -NoAutobuild 
 -LinkMap 
 -CPlus -b 
 -Sym 

Now perform the same steps as in the Pascal MacApp case with the following changed steps:

• In addition the other .dsi file changes, add the following lines to the .dsi file before the =End line:

=Flags

CPlus = 1;

• Hilight the procedure name TDefaultView::Draw and choose Add Hint from the IBS menu.

HyperText and The Debugger

One of the great features of The Debugger is its use of the HyperText paradigm. Many commands in The Debugger take whatever is selected in its front window as an argument to a command.

For example, assume we are using the Pascal Nothing application and are stopped in the The Debugger after pressing Option-The Object Inspector Menu (this appears in the right of the menu bar as n - <task name>) contains several items useful with MacApp. Select the first item - Object Classes. In the middle of the list will be the lines

TDEFAULTVIEW TVIEW

Select TDEFAULTVIEW. See Figure 1.

Fig. 1. Classes Window

Press Cmd-space. A definition of the fields in TDefaultView will be displayed in a window along with the field data types. See Figure 2.

Fig. 2. Field Definitions

Select Objects by Class from the Object Inspector Menu. On the list you will see TDEFAULTVIEW_@xxxxxx where xxxxxx is the hex address of the pointer to the object. Select TDEFAULTVIEW_@xxxxxx. See Figure 3

Fig. 3. Objects by Class

Press Cmd-space. A formatted display of the fields in TDefaultView will be displayed in a window along with the field data values. See Figure 4.

Fig. 4. Field Values

Its too bad that this window is not read/write so we could make changes to the field values in this formatted view. Changing memory requires calculating the memory address and entering a hex value in another window. Select just the address @xxxxxx. Press Cmd-space and a hex dump of memory at that address will be displayed. See Figure 5.

Fig. 5. Memory Dump of Object Pointer

Since @xxxxxx is a pointer to the object, select the first 4 bytes of the dump, e.g., YYYY ZZZZ, and press Cmd-space. A hex dump of the object will be displayed. See Figure 6.

Fig. 6. Memory Dump of Object

To see the source for a method, select the name of a class from one of the object menus - say Object Classes. Choose Methods of menu from the Object Inspector Menu. Select one of the methods and press Cmd-D. The source listing of that method will be displayed.

To set a breakpoint, select the symbol in front of the source line. Press Cmd-B and the symbol will change to •. A breakpoint will now be set at that point. Breakpoints can be unset by the same process. See Figure 7. To change from a source level display to an assembly listing, Cmd-click on the window.

Fig. 7. Source Listing Showing Breakpoint

After a bit of use, this HyperText paradigm becomes very natural and familiar.

The “Object Inspector”

The Object Inspector consists of several menu items under the Task Name menu.

• Object Classes - shows a list of the object classes (with their superclass) sorted by the name of the class. We used this menu item above (Figure 1).

• Objects by Time - shows a list of known objects sorted by the time of their creation.

• Objects by Name - shows a list of objects and their addresses sorted by the name of the object.

• Objects of - shows a list of objects. The name of the class should be hilighted prior to choosing this menu item or you will be asked to type the name of the desired class.

• Methods of - shows a list of methods. The name of the class should be hilighted prior to choosing this menu item or you will be asked to type the name of the desired class.

For example if TSSCROLLBAR is hilighted in the Object Classes window and Objects of is chosen from the Object Inspector menu, the list in Figure 8 is shown.

Fig. 8. Objects of display

If the first line of that window is selected and Cmd-space is pressed, the fields of this instance of TSSCROLLBAR is shown. See Figure 9 (entire record is not shown).

Fig. 9. Fields of TSSCROLLBAR

If TSSCROLLBAR is hilighted in the front window and Methods of is chosen from the Object Inspector menu, the list in Figure 10 is shown.

Fig. 10. Methods of display

This new set of Object Inspector functions greatly enhance the ability of The Debugger to work with MacApp and Object Pascal programs.

That .dsi File

Associated with each program (or other task) that The Debugger works on is a file named <appName>.dsi. This Debugger Startup Info (hence .dsi) file contains commands relevant to that program. One of the commands, =Source, gives the pathname to the source. The manual states that the single line following the command contains the pathname to the folder containing the source files. Thankfully (although I wasted nearly a day on this) the documentation is incorrect and the =Source command may be followed by multiple lines containing pathnames to the various folders containing the source to your program, including your libraries and MacApp’s libraries.

A prototype .dsi file will be built for you the first time you create an IBS project (no relation to MPW Projector projects) for the program you will be using with IBS. However if you throw away the file (for example, by throwing away the folder where MacApp stores your objects and The Debugger stores its project files), you are not asked again to locate your source files but The Debugger will keep telling you that it cannot locate the source whenever you re-enter The Debugger.

If you do throw away the .dsi file and the other auxiliary files, you should edit the file IBS_ProjInfo kept in the System Folder. It contains a list of the IBS_project files. Delete the line containing the reference to your program. Then IBS will again ask you to locate all the folders containing source and re-create the .dsi file for you.

[Steve has fixed this problem in later versions of IBS so that the deleter project script references the IBS_ProjInfo file.-ed]

Installation

Installing The Debugger can be a little confusing for the first time user. Installation is covered in at least four places in the documentation - a little differently in each. My version came on one diskette in Auto UnStuffit format. That made it very easy to get the files on the hard disk but confusing when the documentation refers to that “Blue disk” or “White disk” I didn’t have. The IBS_Install script instructions are to “Read it and execute it.” That script contains comments directing me to do additional things besides what the script does. The program’s documentation should include a simple step-by-step set of installation instructions to get the new user over the hump of installation and on to useful work.

The Debugger was installed as an INIT because it must load before MultiFinder. That led to playing the INIT order game. After searching for all the places in the documentation giving hints for this game, I found that I must rename Suitcase II to zSuitcase II and uninstall the TOPS INIT. The latter was a real bummer as TOPS is central to my installation. Fortunately, the next release of TOPS (Version 3.0) eliminates the conflict with The Debugger.

Next I tried the “Getting Acquainted” section of the IBS Release Notes using the MPW Pascal example program TESample. All went exactly as described. Unfortunately I decided to revert back to the original source files by throwing away the folder containing the object, application and other files. Upon recompiling and running under The Debugger, I started getting requests to locate the source files. Of course, the problem was that I had thrown away the .dsi file.

[Steve has recently added a set of Debugger Tech Notes to the documentation. Tech Note #0 contains a revised installation procedure, and the intro letter contains a road map to the documentation. -ed]

More Goodies

The Debugger is not just a debugger - it can be a way of life. Included with The Debugger are a set of MPW scripts and tools of general usefulness to the MPW programmer. These tools make using the Mark facility of the MPW Shell much easier. One of the tools will read a selected set of object (.o) files and build a script to create markers to your procedures and functions. Another tool implements a GOTO Def of menu item. Just select the name of a function or procedure and press Cmd-J. The source is opened at the definition of the function or procedure. If you don’t have Debugger Tech Note #4, get it!

Some Remaining Problems

Because of the newness of IBS and object-oriented additions to The Debugger, there are still some rough edges in these areas. Because the MPW Shell editor is not language sensitive, the programmer is required to manually inform IBS which modules are being changed (and this must be done before saving the source file). Steve Jasik is reportedly trying to obtain a language sensitive editor to alleviate this problem.

When debugging a MacApp program, the Stack window will display the methods in the call chain but often the Until Caller menu item in the Go menu complains that it can’t find the calling routine on the stack. This makes exiting a subroutine a little tedious.

There are some problems with C++ that cause The Debugger some problems. The current version of C++ (3.1b1) has some problems which causes single-stepping at the source level to be double-stepping (two instructions at a time). Also the display of the fields of an object is incorrect - the display is based at the pointer to the object rather that the object itself. These C++ problems should be ironed out by Apple and Jasik in the near future.

Conclusion

Getting through the first day with The Debugger was a trying experience. But as I became more familiar with the program, its charms, hidden as they sometimes are, began to grow on me. The Incremental Build System (IBS) does indeed save a considerable amount of time in repetitive compile-link-test cycles. If you keep your source files short, the compile times are not long and the link time insignificant.

The ability to have my source files in front of me while debugging is great. SADE provides this as well, but SADE seems ponderous compared to The Debugger.

The Object Inspector Menu provides a convenient way of inspecting MacApp objects and their fields. If only the object/field display windows were read/write.

I have only begun to discuss the features of this program. Rather than trying to be all inclusive, I have concentrated on two aspects - Incremental Linking and debugging with MacApp. The Debugger has such a vast set of capabilities that it may not be the debugger for everyone or for every situation. But there are times when only Jasik’s The Debugger will suffice. For those cases, let’s hear it for The Head Nose.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Tokkun Studio unveils alpha trailer for...
We are back on the MMORPG news train, and this time it comes from the sort of international developers Tokkun Studio. They are based in France and Japan, so it counts. Anyway, semantics aside, they have released an alpha trailer for the upcoming... | Read more »
Win a host of exclusive in-game Honor of...
To celebrate its latest Jujutsu Kaisen crossover event, Honor of Kings is offering a bounty of login and achievement rewards kicking off the holiday season early. [Read more] | Read more »
Miraibo GO comes out swinging hard as it...
Having just launched what feels like yesterday, Dreamcube Studio is wasting no time adding events to their open-world survival Miraibo GO. Abyssal Souls arrives relatively in time for the spooky season and brings with it horrifying new partners to... | Read more »
Ditch the heavy binders and high price t...
As fun as the real-world equivalent and the very old Game Boy version are, the Pokemon Trading Card games have historically been received poorly on mobile. It is a very strange and confusing trend, but one that The Pokemon Company is determined to... | Read more »
Peace amongst mobile gamers is now shatt...
Some of the crazy folk tales from gaming have undoubtedly come from the EVE universe. Stories of spying, betrayal, and epic battles have entered history, and now the franchise expands as CCP Games launches EVE Galaxy Conquest, a free-to-play 4x... | Read more »
Lord of Nazarick, the turn-based RPG bas...
Crunchyroll and A PLUS JAPAN have just confirmed that Lord of Nazarick, their turn-based RPG based on the popular OVERLORD anime, is now available for iOS and Android. Starting today at 2PM CET, fans can download the game from Google Play and the... | Read more »
Digital Extremes' recent Devstream...
If you are anything like me you are impatiently waiting for Warframe: 1999 whilst simultaneously cursing the fact Excalibur Prime is permanently Vault locked. To keep us fed during our wait, Digital Extremes hosted a Double Devstream to dish out a... | Read more »
The Frozen Canvas adds a splash of colou...
It is time to grab your gloves and layer up, as Torchlight: Infinite is diving into the frozen tundra in its sixth season. The Frozen Canvas is a colourful new update that brings a stylish flair to the Netherrealm and puts creativity in the... | Read more »
Back When AOL WAS the Internet – The Tou...
In Episode 606 of The TouchArcade Show we kick things off talking about my plans for this weekend, which has resulted in this week’s show being a bit shorter than normal. We also go over some more updates on our Patreon situation, which has been... | Read more »
Creative Assembly's latest mobile p...
The Total War series has been slowly trickling onto mobile, which is a fantastic thing because most, if not all, of them are incredibly great fun. Creative Assembly's latest to get the Feral Interactive treatment into portable form is Total War:... | Read more »

Price Scanner via MacPrices.net

Early Black Friday Deal: Apple’s newly upgrad...
Amazon has Apple 13″ MacBook Airs with M2 CPUs and 16GB of RAM on early Black Friday sale for $200 off MSRP, only $799. Their prices are the lowest currently available for these newly upgraded 13″ M2... Read more
13-inch 8GB M2 MacBook Airs for $749, $250 of...
Best Buy has Apple 13″ MacBook Airs with M2 CPUs and 8GB of RAM in stock and on sale on their online store for $250 off MSRP. Prices start at $749. Their prices are the lowest currently available for... Read more
Amazon is offering an early Black Friday $100...
Amazon is offering early Black Friday discounts on Apple’s new 2024 WiFi iPad minis ranging up to $100 off MSRP, each with free shipping. These are the lowest prices available for new minis anywhere... Read more
Price Drop! Clearance 14-inch M3 MacBook Pros...
Best Buy is offering a $500 discount on clearance 14″ M3 MacBook Pros on their online store this week with prices available starting at only $1099. Prices valid for online orders only, in-store... Read more
Apple AirPods Pro with USB-C on early Black F...
A couple of Apple retailers are offering $70 (28%) discounts on Apple’s AirPods Pro with USB-C (and hearing aid capabilities) this weekend. These are early AirPods Black Friday discounts if you’re... Read more
Price drop! 13-inch M3 MacBook Airs now avail...
With yesterday’s across-the-board MacBook Air upgrade to 16GB of RAM standard, Apple has dropped prices on clearance 13″ 8GB M3 MacBook Airs, Certified Refurbished, to a new low starting at only $829... Read more
Price drop! Apple 15-inch M3 MacBook Airs now...
With yesterday’s release of 15-inch M3 MacBook Airs with 16GB of RAM standard, Apple has dropped prices on clearance Certified Refurbished 15″ 8GB M3 MacBook Airs to a new low starting at only $999.... Read more
Apple has clearance 15-inch M2 MacBook Airs a...
Apple has clearance, Certified Refurbished, 15″ M2 MacBook Airs now available starting at $929 and ranging up to $410 off original MSRP. These are the cheapest 15″ MacBook Airs for sale today at... Read more
Apple drops prices on 13-inch M2 MacBook Airs...
Apple has dropped prices on 13″ M2 MacBook Airs to a new low of only $749 in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, now available for $679 for 8-Core CPU/7-Core GPU/256GB models. Apple’s one-year warranty is included, shipping is free, and each... Read more

Jobs Board

Seasonal Cashier - *Apple* Blossom Mall - J...
Seasonal Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Seasonal Fine Jewelry Commission Associate -...
…Fine Jewelry Commission Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) Read more
Seasonal Operations Associate - *Apple* Blo...
Seasonal Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.