TweetFollow Us on Twitter

Nov 94 Tips
Volume Number:10
Issue Number:11
Column Tag:Tips &Tidbits

Tips &Tidbits

By Scott T Boyd, Editor

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Send us your tips! We’ll send you money, and developers all over the world will marvel at your insight, your wisdom, or the simple fact that you’ve got enough extra time to write and send a little bit of e-mail to make their lives a little bit better.

We pay $25 for every tip we use, and $50 for Tip of the Month. You can take your award in orders or subscriptions if you prefer. Make sure code compiles, and send tips by e-mail; editorial@xplain.com is a great address. See page two for our other addresses.

Tip Of The Month

Trapping Non-Trap Vector Calls

The Debugger has certain limitations in its ability to trace A-Line traps and such. As an example, suppose we’re interested in breaking on calls to CacheFlush. It’s a trap vector which is usually referenced by a JSR ([xx]) instead of the usual A-Line Trap vector. Because it doesn’t go through the normal A-line dispatcher, we can’t break on references to it with the Trap Intercept mechanism.

Here’s some example code that creates a dummy procedure in an application, and an initialization proc that patches the low-memory trap vector so that it points to the dummy procedure. I modify the dummy procedure to make it a JMP to the original value of the low memory vector [Remember, this is for debugging, not for shipping code. Shipping code should generally not modify code it’s about to execute - Ed stb]. Finally, the doPatch proc undoes the patch and restores the system to its previous state.

To use this, set a breakpoint at my_doPatch_Proc. When you drop into your debugger, look at the stack to see who’s calling. After some looking, you can automate the process by observing where the interesting return addresses are on the stack with an action clause (such as the one shown here) that would list them in the -Notes- window:

?ra := (ra7)^; { return addr is contents of A7 }

{ In the next line we check PC for an address in the Quadra 900 ROM }

if ?pc = 40887824 then ?ra := (ra7+#46+#28)^-2; { # = decimal } writeln(?ra:ProcPtr); { display the address as a proc name + offset }

resume;


/* 1 */
procedure my_doPatch_Proc; { make it at least 6 bytes long } 
begin 
end;

procedure doPatch(doit:Boolean); 
CONST jCacheFlush = $6f4; 
type  jmpL = record opc:integer; addr:Longint; end; 
VAR 
 q:^jmpL; 
 p:^Longint; 
begin
    p := pointer(jCacheFlush);{$06F4 is the low-mem global jCacheFlush}
    q := @my_doPatch_Proc;
    if doit then begin
 with q^ do begin 
 opc := $4EF9; {JMP.L} 
 addr := p^;  
 end;
   p^ := Ord(q);
 end
   else begin
        p^ := q^.addr;  { undo patch }
   end; 
end;

- Steve Jasik, Menlo Park, CA

Even Better Data Gathering

The September issue’s tip-of-the-month recommended a way to log standard information during crashes using the EveryTime MacsBug macro. This technique is particularly useful for beta sites to report bugs, but there’s an even easier way. Many versions of MacsBug already have a built-in macro called StdLog that does almost the same thing. Beta-sites can just use stdlog to supply you with information and it doesn’t require them to muck with their “Debugger Prefs” file.

- Harold Ekstrom, Walnut Creek, CA

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Combo Quest (Games)
Combo Quest 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: Combo Quest is an epic, time tap role-playing adventure. In this unique masterpiece, you are a knight on a heroic quest to retrieve... | Read more »
Hero Emblems (Games)
Hero Emblems 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: ** 25% OFF for a limited time to celebrate the release ** ** Note for iPhone 6 user: If it doesn't run fullscreen on your device... | Read more »
Puzzle Blitz (Games)
Puzzle Blitz 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Puzzle Blitz is a frantic puzzle solving race against the clock! Solve as many puzzles as you can, before time runs out! You have... | Read more »
Sky Patrol (Games)
Sky Patrol 1.0.1 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.1 (iTunes) Description: 'Strategic Twist On The Classic Shooter Genre' - Indie Game Mag... | Read more »
The Princess Bride - The Official Game...
The Princess Bride - The Official Game 1.1 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1 (iTunes) Description: An epic game based on the beloved classic movie? Inconceivable! Play the world of The Princess Bride... | Read more »
Frozen Synapse (Games)
Frozen Synapse 1.0 Device: iOS iPhone Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: Frozen Synapse is a multi-award-winning tactical game. (Full cross-play with desktop and tablet versions) 9/10 Edge 9/10 Eurogamer... | Read more »
Space Marshals (Games)
Space Marshals 1.0.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.1 (iTunes) Description: ### IMPORTANT ### Please note that iPhone 4 is not supported. Space Marshals is a Sci-fi Wild West adventure taking place... | Read more »
Battle Slimes (Games)
Battle Slimes 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: BATTLE SLIMES is a fun local multiplayer game. Control speedy & bouncy slime blobs as you compete with friends and family.... | Read more »
Spectrum - 3D Avenue (Games)
Spectrum - 3D Avenue 1.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0 (iTunes) Description: "Spectrum is a pretty cool take on twitchy/reaction-based gameplay with enough complexity and style to stand out from the... | Read more »
Drop Wizard (Games)
Drop Wizard 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: Bring back the joy of arcade games! Drop Wizard is an action arcade game where you play as Teo, a wizard on a quest to save his... | Read more »

Price Scanner via MacPrices.net

Apple’s M4 Mac minis on sale for record-low p...
B&H Photo has M4 and M4 Pro Mac minis in stock and on sale right now for up to $150 off Apple’s MSRP, each including free 1-2 day shipping to most US addresses. Prices start at only $469: – M4... Read more
Deal Alert! Mac Studio with M4 Max CPU on sal...
B&H Photo has the standard-configuration Mac Studio model with Apple’s M4 Max CPU in stock today and on sale for $300 off MSRP, now $1699 (10-Core CPU and 32GB RAM/512GB SSD). B&H also... Read more

Jobs Board

All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.