CarbonAPI DebugStr() deprecation

Howdy all,

I'm in the process of eliminating some compiler warnings in a legacy project, and have come across a compiler warning for the usage of extern void DebugStr(ConstStr255Param debuggerMsg), defined in MacTypes.h as part of CarbonCore-769-1.

I've looked through Apple's documentation for Cocoa and the MacOSX13.1 SDK but haven't found any leads on what I could/should replace it with.

Can anyone point me in the right direction? Thanks!!

Answered by DTS Engineer in 764989022

DebugStr has two functions:

  • It traps into the debugger.

  • It logs the supplied message.

On macOS the second part is actually done fprintf. These days it’s better to use the system log. See Your Friend the System Log.

In terms of trapping into the debugging, the best way to do that depends on the language you’re using. The fact that you’re talking about DebugStr suggests you’re using a C-based language, in which case my preferred option is __builtin_trap.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

You can write to the console log using NSLog or os_log. What programming language are you using?

DebugStr has two functions:

  • It traps into the debugger.

  • It logs the supplied message.

On macOS the second part is actually done fprintf. These days it’s better to use the system log. See Your Friend the System Log.

In terms of trapping into the debugging, the best way to do that depends on the language you’re using. The fact that you’re talking about DebugStr suggests you’re using a C-based language, in which case my preferred option is __builtin_trap.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Thanks for the response! I messed around a bit with DebugStr, and it doesn't appear to affect execution at a glance, whereas __builtin_trap and __builtin_debugtrap cause the program to exit and pause respectively. Does DebugStr pause and resume immediately, and if so, how does it resume execution?

Historically Debugstr would trap into MacsBug with the supplied message. If you don’t want it to trap, simply omit the __builtin_trap. Alternatively, you can conditionalise that trap based on the presence of the debugger, using the technique from QA1361 Detecting the Debugger.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

CarbonAPI DebugStr() deprecation
 
 
Q