• MacTech Network:
  • Tech Support
  • |
  • MacForge.net
  • |
  • Apple News
  • |
  • Register Domains
  • |
  • SSL Certificates
  • |
  • iPod Deals
  • |
  • Mac Deals
  • |
  • Mac Book Shelf

MAC TECH

  • Home
  • Magazine
    • About MacTech in Print
    • Issue Table of Contents
    • Subscribe
    • Risk Free Sample
    • Back Issues
    • MacTech DVD
  • Archives
    • MacTech Print Archives
    • MacMod
    • MacTutor
    • FrameWorks
    • develop
  • Forums
  • News
    • MacTech News
    • MacTech Blog
    • MacTech Reviews and KoolTools
    • Whitepapers, Screencasts, Videos and Books
    • News Scanner
    • Rumors Scanner
    • Documentation Scanner
    • Submit News or PR
    • MacTech News List
  • Store
  • Apple Expo
    • by Category
    • by Company
    • by Product
  • Job Board
  • Editorial
    • Submit News or PR
    • Writer's Kit
    • Editorial Staff
    • Editorial Calendar
  • Advertising
    • Benefits of MacTech
    • Mechanicals and Submission
    • Dates and Deadlines
    • Submit Apple Expo Entry
  • User
    • Register for Ongoing Raffles
    • Register new user
    • Edit User Settings
    • Logout
  • Contact
    • Customer Service
    • Webmaster Feedback
    • Submit News or PR
    • Suggest an article
  • Connect Tools
    • MacTech Live Podcast
    • RSS Feeds
    • Twitter

ADVERTISEMENT
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

 
MacTech Only Search:
Community Search:

 
 
 

 
 
 
 
 
  • SPREAD THE WORD:
  • Slashdot
  • Digg
  • Del.icio.us
  • Reddit
  • Newsvine
  • Generate a short URL for this page:



MacTech Magazine. www.mactech.com
Toll Free 877-MACTECH, Outside US/Canada: 805-494-9797
MacTech is a registered trademark of Xplain Corporation. Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, Apple Expo, MacTech Central, MacTech Domains, MacNews, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corporation. Sprocket is a registered trademark of eSprocket Corporation. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.
All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.
 
Nov. 20: Take Control of Syncing Data in Sow Leopard' released
Nov. 19: Cocktail 4.5 (Leopard Edition) released
Nov. 19: macProVideo offers new Cubase tutorials
Nov. 18: S Stardom anounces Safe Capsule, a companion piece for Apple's
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live
Nov. 17: Ableton releases Max for Live