this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CoreServices: Add some Debugging APIs (#739)

+97 -5
+27
src/frameworks/CoreServices/include/CoreServices/Debugging.h
··· 1 + #ifndef _CS_DEBUGGING_H 2 + #define _CS_DEBUGGING_H 3 + #include <CoreServices/MacTypes.h> 4 + 5 + #ifdef __cplusplus 6 + extern "C" { 7 + #endif 8 + 9 + extern void DebugAssert(OSType componentSignature, UInt32 options, const char *assertionString, 10 + const char *exceptionLabelString, const char *errorString, const char *fileName, 11 + long lineNumber, void *value); 12 + 13 + typedef void(*DebugAssertOutputHandlerUPP)(OSType componentSignature, UInt32 options, const char *assertionString, 14 + const char *exceptionLabelString, const char *errorString, const char *fileName, 15 + long lineNumber, ConstStr255Param outputMsg); 16 + 17 + extern void InstallDebugAssertOutputHandler(DebugAssertOutputHandlerUPP handler); 18 + 19 + extern UInt32 TaskLevel(void); 20 + 21 + extern void DebugStr(ConstStr255Param msg); 22 + 23 + #ifdef __cplusplus 24 + } 25 + #endif 26 + 27 + #endif
+1
src/frameworks/CoreServices/src/CarbonCore/CMakeLists.txt
··· 25 25 ResourcesImpl.cpp 26 26 MacErrors.cpp 27 27 UserBreak.cpp 28 + Debugging.cpp 28 29 ) 29 30 30 31 set(DYLIB_COMPAT_VERSION "1.0.0")
+63
src/frameworks/CoreServices/src/CarbonCore/Debugging.cpp
··· 1 + /* 2 + This file is part of Darling. 3 + 4 + Copyright (C) 2020 Lubos Dolezel 5 + 6 + Darling is free software: you can redistribute it and/or modify 7 + it under the terms of the GNU General Public License as published by 8 + the Free Software Foundation, either version 3 of the License, or 9 + (at your option) any later version. 10 + 11 + Darling is distributed in the hope that it will be useful, 12 + but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + GNU General Public License for more details. 15 + 16 + You should have received a copy of the GNU General Public License 17 + along with Darling. If not, see <http://www.gnu.org/licenses/>. 18 + */ 19 + #include <CoreServices/Debugging.h> 20 + #include <iostream> 21 + #include <sstream> 22 + #include <algorithm> 23 + #include "UserBreak.h" 24 + 25 + static void defaultHandler(OSType componentSignature, UInt32 options, const char *assertionString, 26 + const char *exceptionLabelString, const char *errorString, const char *fileName, 27 + long lineNumber, ConstStr255Param outputMsg) 28 + { 29 + DebugStr(outputMsg); 30 + } 31 + 32 + static DebugAssertOutputHandlerUPP debugAssertHandler = defaultHandler; 33 + 34 + void DebugAssert(OSType componentSignature, UInt32 options, const char *assertionString, 35 + const char *exceptionLabelString, const char *errorString, const char *fileName, 36 + long lineNumber, void *value) 37 + { 38 + Str255 out; 39 + 40 + std::stringstream ss; 41 + ss << "DebugAssert: " << assertionString << " " << exceptionLabelString 42 + << " " << errorString << " [" << fileName << ":" << lineNumber << "]\n"; 43 + 44 + std::string str = ss.str(); 45 + out[0] = std::min<uint8_t>(str.length(), 255); 46 + memcpy(&out[1], str.c_str(), out[0]); 47 + 48 + debugAssertHandler(componentSignature, options, assertionString, exceptionLabelString, errorString, fileName, lineNumber, out); 49 + } 50 + 51 + void InstallDebugAssertOutputHandler(DebugAssertOutputHandlerUPP handler) 52 + { 53 + if (handler == nullptr) 54 + debugAssertHandler = defaultHandler; 55 + else 56 + debugAssertHandler = handler; 57 + } 58 + 59 + UInt32 TaskLevel(void) 60 + { 61 + return 0; 62 + } 63 +
+6 -5
src/frameworks/CoreServices/src/CarbonCore/Processes.cpp
··· 29 29 #include <CoreFoundation/CFBundle.h> 30 30 #include <stdio.h> 31 31 #include <ctype.h> 32 + #include <iostream> 33 + #include "UserBreak.h" 32 34 33 35 #define STUB() // TODO 34 36 #ifndef PATH_MAX ··· 241 243 return noErr; 242 244 } 243 245 244 - void DebugStr(ConstStr255Param a) 246 + void DebugStr(ConstStr255Param msg) 245 247 { 246 - printf("%s\n", a); 248 + std::cerr.write((const char*) &msg[1], msg[0]); 249 + std::cerr << std::endl; 250 + doUserBreak(); 247 251 } 248 - 249 - 250 -