MCPcopy Create free account
hub / github.com/crownengine/crown / debugPrintfData

Function debugPrintfData

3rdparty/bx/src/debug.cpp:189–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187#define DBG_ADDRESS "%" PRIxPTR
188
189 void debugPrintfData(const void* _data, uint32_t _size, const char* _format, ...)
190 {
191#define HEX_DUMP_WIDTH 16
192#define HEX_DUMP_SPACE_WIDTH 48
193#define HEX_DUMP_FORMAT "%-" BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
194
195 va_list argList;
196 va_start(argList, _format);
197 debugPrintfVargs(_format, argList);
198 va_end(argList);
199
200 debugPrintf("\ndata: " DBG_ADDRESS ", size: %d\n", _data, _size);
201
202 if (NULL != _data)
203 {
204 const uint8_t* data = (const uint8_t*)_data;
205 char hex[HEX_DUMP_WIDTH*3+1];
206 char ascii[HEX_DUMP_WIDTH+1];
207 uint32_t hexPos = 0;
208 uint32_t asciiPos = 0;
209 for (uint32_t ii = 0; ii < _size; ++ii)
210 {
211 snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]);
212 hexPos += 3;
213
214 ascii[asciiPos] = isPrint(data[asciiPos]) ? data[asciiPos] : '.';
215 asciiPos++;
216
217 if (HEX_DUMP_WIDTH == asciiPos)
218 {
219 ascii[asciiPos] = '\0';
220 debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
221 data += asciiPos;
222 hexPos = 0;
223 asciiPos = 0;
224 }
225 }
226
227 if (0 != asciiPos)
228 {
229 ascii[asciiPos] = '\0';
230 debugPrintf("\t" DBG_ADDRESS "\t" HEX_DUMP_FORMAT "\t%s\n", data, hex, ascii);
231 }
232 }
233
234#undef HEX_DUMP_WIDTH
235#undef HEX_DUMP_SPACE_WIDTH
236#undef HEX_DUMP_FORMAT
237 }
238
239 class DebugWriter : public WriterI
240 {

Callers

nothing calls this directly

Calls 4

debugPrintfVargsFunction · 0.85
debugPrintfFunction · 0.85
isPrintFunction · 0.85
snprintfFunction · 0.70

Tested by

no test coverage detected