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

The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »

Price Scanner via MacPrices.net

Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.