VirtualBox

source: vbox/trunk/src/VBox/Runtime/r0drv/os2/assert-r0drv-os2.cpp@ 75129

Last change on this file since 75129 was 75129, checked in by vboxsync, 6 years ago

IPRT: Make Watcom C an alterntive for compiling the OS/2 kernel code (GA mainly), governed by VBOX_USE_WATCOM_FOR_OS2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.9 KB
Line 
1/* $Id: assert-r0drv-os2.cpp 75129 2018-10-28 17:00:27Z vboxsync $ */
2/** @file
3 * IPRT - Assertion Workers, Ring-0 Drivers, OS/2.
4 */
5
6/*
7 * Copyright (c) 2007 knut st. osmundsen <[email protected]>
8 *
9 * Permission is hereby granted, free of charge, to any person
10 * obtaining a copy of this software and associated documentation
11 * files (the "Software"), to deal in the Software without
12 * restriction, including without limitation the rights to use,
13 * copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following
16 * conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31
32/*********************************************************************************************************************************
33* Header Files *
34*********************************************************************************************************************************/
35#include <iprt/assert.h>
36#include <iprt/log.h>
37#include <iprt/string.h>
38#include <iprt/stdarg.h>
39
40#include <VBox/log.h>
41
42#include "internal/assert.h"
43
44
45/*********************************************************************************************************************************
46* Global Variables *
47*********************************************************************************************************************************/
48RT_C_DECLS_BEGIN /* for watcom */
49/** The last assert message. (in DATA16) */
50extern char g_szRTAssertMsg[2048];
51/** The length of the last assert message. (in DATA16) */
52extern size_t g_cchRTAssertMsg;
53RT_C_DECLS_END
54
55
56/*********************************************************************************************************************************
57* Internal Functions *
58*********************************************************************************************************************************/
59static DECLCALLBACK(size_t) rtR0Os2AssertOutputCB(void *pvArg, const char *pachChars, size_t cbChars);
60
61
62DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
63{
64#if defined(DEBUG_bird)
65 RTLogComPrintf("\n!!Assertion Failed!!\n"
66 "Expression: %s\n"
67 "Location : %s(%d) %s\n",
68 pszExpr, pszFile, uLine, pszFunction);
69#endif
70
71 g_cchRTAssertMsg = RTStrPrintf(g_szRTAssertMsg, sizeof(g_szRTAssertMsg),
72 "\r\n!!Assertion Failed!!\r\n"
73 "Expression: %s\r\n"
74 "Location : %s(%d) %s\r\n",
75 pszExpr, pszFile, uLine, pszFunction);
76}
77
78
79DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va)
80{
81#if defined(DEBUG_bird)
82 va_list vaCopy;
83 va_copy(vaCopy, va);
84 RTLogComPrintfV(pszFormat, vaCopy);
85 va_end(vaCopy);
86#endif
87
88 size_t cch = g_cchRTAssertMsg;
89 char *pch = &g_szRTAssertMsg[cch];
90 cch += RTStrFormatV(rtR0Os2AssertOutputCB, &pch, NULL, NULL, pszFormat, va);
91 g_cchRTAssertMsg = cch;
92
93 NOREF(fInitial);
94}
95
96
97/**
98 * Output callback.
99 *
100 * @returns number of bytes written.
101 * @param pvArg Pointer to a char pointer with the current output position.
102 * @param pachChars Pointer to an array of utf-8 characters.
103 * @param cbChars Number of bytes in the character array pointed to by pachChars.
104 */
105static DECLCALLBACK(size_t) rtR0Os2AssertOutputCB(void *pvArg, const char *pachChars, size_t cbChars)
106{
107 char **ppch = (char **)pvArg;
108 char *pch = *ppch;
109
110 while (cbChars-- > 0)
111 {
112 const char ch = *pachChars++;
113 if (ch == '\r')
114 continue;
115 if (ch == '\n')
116 {
117 if (pch + 1 >= &g_szRTAssertMsg[sizeof(g_szRTAssertMsg)])
118 break;
119 *pch++ = '\r';
120 }
121 if (pch + 1 >= &g_szRTAssertMsg[sizeof(g_szRTAssertMsg)])
122 break;
123 *pch++ = ch;
124 }
125 *pch = '\0';
126
127 size_t cbWritten = pch - *ppch;
128 *ppch = pch;
129 return cbWritten;
130}
131
132
133/* RTR0AssertPanicSystem is implemented in RTR0AssertPanicSystem-r0drv-os2.asm */
134
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette