Changeset 5685 in vbox for trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
- Timestamp:
- Nov 11, 2007 11:11:40 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Debugger/testcase/tstDBGCParser.cpp
r5681 r5685 29 29 30 30 /******************************************************************************* 31 * Internal Functions * 32 *******************************************************************************/ 33 static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies); 34 static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead); 35 static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten); 36 37 38 /******************************************************************************* 31 39 * Global Variables * 32 40 *******************************************************************************/ 33 41 /** Global error counter. */ 34 42 static unsigned g_cErrors = 0; 43 /** The DBGC backend structure for use in this testcase. */ 44 static DBGCBACK g_tstBack = 45 { 46 tstDBGCBackInput, 47 tstDBGCBackRead, 48 tstDBGCBackWrite 49 }; 50 /** For keeping track of output prefixing. */ 51 static bool g_fPendingPrefix = true; 52 53 54 /** 55 * Checks if there is input. 56 * 57 * @returns true if there is input ready. 58 * @returns false if there not input ready. 59 * @param pBack Pointer to the backend structure supplied by 60 * the backend. The backend can use this to find 61 * it's instance data. 62 * @param cMillies Number of milliseconds to wait on input data. 63 */ 64 static DECLCALLBACK(bool) tstDBGCBackInput(PDBGCBACK pBack, uint32_t cMillies) 65 { 66 RTPrintf("tstDBGCParser: tstDBGCBackInput was called!\n"); 67 g_cErrors++; 68 return false; 69 } 70 71 72 /** 73 * Read input. 74 * 75 * @returns VBox status code. 76 * @param pBack Pointer to the backend structure supplied by 77 * the backend. The backend can use this to find 78 * it's instance data. 79 * @param pvBuf Where to put the bytes we read. 80 * @param cbBuf Maximum nymber of bytes to read. 81 * @param pcbRead Where to store the number of bytes actually read. 82 * If NULL the entire buffer must be filled for a 83 * successful return. 84 */ 85 static DECLCALLBACK(int) tstDBGCBackRead(PDBGCBACK pBack, void *pvBuf, size_t cbBuf, size_t *pcbRead) 86 { 87 RTPrintf("tstDBGCParser: tstDBGCBackRead was called!\n"); 88 g_cErrors++; 89 return VERR_INTERNAL_ERROR; 90 } 91 92 93 /** 94 * Write (output). 95 * 96 * @returns VBox status code. 97 * @param pBack Pointer to the backend structure supplied by 98 * the backend. The backend can use this to find 99 * it's instance data. 100 * @param pvBuf What to write. 101 * @param cbBuf Number of bytes to write. 102 * @param pcbWritten Where to store the number of bytes actually written. 103 * If NULL the entire buffer must be successfully written. 104 */ 105 static DECLCALLBACK(int) tstDBGCBackWrite(PDBGCBACK pBack, const void *pvBuf, size_t cbBuf, size_t *pcbWritten) 106 { 107 const char *pch = (const char *)pvBuf; 108 *pcbWritten = cbBuf; 109 while (cbBuf-- > 0) 110 { 111 if (g_fPendingPrefix) 112 { 113 RTPrintf("tstDBGCParser: OUTPUT: "); 114 g_fPendingPrefix = false; 115 } 116 if (*pch == '\n') 117 g_fPendingPrefix = true; 118 RTPrintf("%c", *pch); 119 pch++; 120 } 121 return VINF_SUCCESS; 122 } 123 124 125 /** 126 * Completes the output, making sure that we're in 127 * the 1 position of a new line. 128 */ 129 static void tstCompleteOutput(void) 130 { 131 if (!g_fPendingPrefix) 132 RTPrintf("\n"); 133 g_fPendingPrefix = true; 134 } 135 35 136 36 137 … … 45 146 46 147 /* 47 * 148 * Create a DBGC instance. 48 149 */ 150 PDBGC pDbgc; 151 int rc = dbgcCreate(&pDbgc, &g_tstBack, 0); 152 if (RT_SUCCESS(rc)) 153 { 154 155 dbgcDestroy(pDbgc); 156 } 49 157 50 158
Note:
See TracChangeset
for help on using the changeset viewer.