• 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: 15 (1999)
Issue Number: 11
Column Tag: Tips & Tidbits

Tips and Tidbits

by Jeff Clites <online@mactech.com>

Poor Man's Debug Console

I've been doing some USB Device Driver development recently using Apple's USB DDK. One of the utilities supplied with this DDK is USB Prober, whose main use is to provide a console for debug messages from the USB Manager and from USB device drivers (the "USB Expert Log"). However there is nothing to prevent any piece of code, whether it be an application, device driver, or even an interrupt handler, from sending messages to USB Prober. This makes it a particularly useful debug console, particularly for code which has no user interface, such as device drivers or faceless background applications, and for code which may run at interrupt level, such as completion routines.

In order to use USB Prober for debugging, you need:

  • a Mac with USB (iMac, G3, G4, 1999 G3 PowerBook, etc.)
  • Apple’s USB DDK

In your project, you need to #include <USB.h> and link against the library USBServices.lib. To send a debug message, use the USBExpertStatus() call, e.g.

#if DEBUG
	if (err != noErr)
		USBExpertStatus(TickCount(), 
												“\pOh no ! err = “, err);
#endif

Before running your application, launch USB Prober, and open the USB Expert Log.

Paul Russell prussell@arc-software.com

Adding Descriptions to StdLog

If you are logging a series of crashes, the MacsBug 'stdlog' macro is very useful for appending a series of MacsBug commands to the file StdLog on your desktop. It includes the date and time but unfortunately doesn't allow you to enter a comment explaining the context of the crash. The following sequence of commands allows you to precede the stdlog dump with your own comments:

log "StdLog"	// opens the same file used by stdlog, creating if absent
printf "some comment in double quotes"
							// prints whatever's in quotes
log						// closes the log
stdlog				// runs the stdlog macro

If you don't have the 'printf' DCMD installed, you can use a slower method of just entering your comment in quotes on the command line:

"some comment in double quotes"
		// records comment, as seen below

The trick here is the way log recording works-anything displayed in the macsbug output window is logged. When you enter the comment in quotes, MacsBug attempts to evaluate it, resulting in an entry like:

Unrecognized symbol "some comment in double quotes"

You can of course enter as many comments as you like before closing the log - this technique is not limited to a single line.

Andy Dent dent@oofile.com.au

 
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