Changeset 104966 in vbox
- Timestamp:
- Jun 19, 2024 3:40:02 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
include/iprt/tracelog-decoder-plugin.h (modified) (3 diffs)
-
src/VBox/Devices/Trace/VBoxTraceLogDecoders.cpp (modified) (46 diffs)
-
src/VBox/Runtime/tools/RTTraceLogTool.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/tracelog-decoder-plugin.h
r104921 r104966 60 60 61 61 62 /** The integer value should be dumped as a hex number instead. */ 63 #define RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX RT_BIT_32(0) 64 /** The hexdump should be dumped as an inline string (Rhxs). */ 65 #define RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX_DUMP_STR RT_BIT_32(1) 66 67 68 /** 69 * An enum entry for the struct builder. 70 */ 71 typedef struct RTTRACELOGDECODERSTRUCTBLDENUM 72 { 73 /** The raw enum value. */ 74 uint64_t u64EnumVal; 75 /** String version of the enum value. */ 76 const char *pszString; 77 /** Some opaque user data not used by RTTRACELOGDECODERHLP::pfnStructBldAddEnum. */ 78 uintptr_t uPtrUser; 79 } RTTRACELOGDECODERSTRUCTBLDENUM; 80 /** Pointer to a struct build enum entry. */ 81 typedef RTTRACELOGDECODERSTRUCTBLDENUM *PRTTRACELOGDECODERSTRUCTBLDENUM; 82 /** Pointer to a const struct build enum entry. */ 83 typedef const RTTRACELOGDECODERSTRUCTBLDENUM *PCRTTRACELOGDECODERSTRUCTBLDENUM; 84 85 86 /** Initializes a enum entry, extended version. */ 87 #define RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT_EX(a_enmVal, a_uPtrUser) \ 88 { a_enmVal, #a_enmVal, a_uPtrUser } 89 /** Initializes a enum entry, extended version. */ 90 #define RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(a_enmVal) \ 91 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT_EX(a_enmVal, 0) 92 93 62 94 /** 63 95 * Helper functions for decoders. … … 92 124 93 125 126 /** @name Decoder state related callbacks. 127 * @{ */ 128 94 129 /** 95 130 * Creates a new decoder state and associates it with the given helper structure. … … 125 160 DECLCALLBACKMEMBER(void*, pfnDecoderStateGet, (PRTTRACELOGDECODERHLP pHlp)); 126 161 162 /** @} */ 163 164 /** @name Structure builder callbacks. 165 * @{ */ 166 167 /** 168 * Begins a new (sub-)structure with the given name. 169 * 170 * @returns IPRT status code. 171 * @param pHlp Pointer to the callback structure. 172 * @param pszName Name of the structure. 173 */ 174 DECLCALLBACKMEMBER(int, pfnStructBldBegin, (PRTTRACELOGDECODERHLP pHlp, const char *pszName)); 175 176 177 /** 178 * Ends the current (sub-)structure and returns to the parent. 179 * 180 * @returns IPRT status code. 181 * @param pHlp Pointer to the callback structure. 182 */ 183 DECLCALLBACKMEMBER(int, pfnStructBldEnd, (PRTTRACELOGDECODERHLP pHlp)); 184 185 186 /** 187 * Adds a boolean member to the current (sub-)structure with the given name and value. 188 * 189 * @returns IPRT status code. 190 * @param pHlp Pointer to the callback structure. 191 * @param pszName Name of the member. 192 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 193 * @param f The boolean value to record. 194 */ 195 DECLCALLBACKMEMBER(int, pfnStructBldAddBool, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, bool f)); 196 197 198 /** 199 * Adds an unsigned byte (uint8_t) member to the current (sub-)structure with the given name and value. 200 * 201 * @returns IPRT status code. 202 * @param pHlp Pointer to the callback structure. 203 * @param pszName Name of the member. 204 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 205 * @param u8 The value to record. 206 */ 207 DECLCALLBACKMEMBER(int, pfnStructBldAddU8, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint8_t u8)); 208 209 210 /** 211 * Adds an unsigned 16-bit (uint16_t) member to the current (sub-)structure with the given name and value. 212 * 213 * @returns IPRT status code. 214 * @param pHlp Pointer to the callback structure. 215 * @param pszName Name of the member. 216 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 217 * @param u16 The value to record. 218 */ 219 DECLCALLBACKMEMBER(int, pfnStructBldAddU16, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint16_t u16)); 220 221 222 /** 223 * Adds an unsigned 32-bit (uint32_t) member to the current (sub-)structure with the given name and value. 224 * 225 * @returns IPRT status code. 226 * @param pHlp Pointer to the callback structure. 227 * @param pszName Name of the member. 228 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 229 * @param u32 The value to record. 230 */ 231 DECLCALLBACKMEMBER(int, pfnStructBldAddU32, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint32_t u32)); 232 233 234 /** 235 * Adds an unsigned 64-bit (uint64_t) member to the current (sub-)structure with the given name and value. 236 * 237 * @returns IPRT status code. 238 * @param pHlp Pointer to the callback structure. 239 * @param pszName Name of the member. 240 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 241 * @param u64 The value to record. 242 */ 243 DECLCALLBACKMEMBER(int, pfnStructBldAddU64, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint64_t u64)); 244 245 246 /** 247 * Adds a signed byte (int8_t) member to the current (sub-)structure with the given name and value. 248 * 249 * @returns IPRT status code. 250 * @param pHlp Pointer to the callback structure. 251 * @param pszName Name of the member. 252 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 253 * @param i8 The value to record. 254 */ 255 DECLCALLBACKMEMBER(int, pfnStructBldAddS8, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int8_t i8)); 256 257 258 /** 259 * Adds a signed 16-bit (int16_t) member to the current (sub-)structure with the given name and value. 260 * 261 * @returns IPRT status code. 262 * @param pHlp Pointer to the callback structure. 263 * @param pszName Name of the member. 264 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 265 * @param i16 The value to record. 266 */ 267 DECLCALLBACKMEMBER(int, pfnStructBldAddS16, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int16_t i16)); 268 269 270 /** 271 * Adds a signed 32-bit (int32_t) member to the current (sub-)structure with the given name and value. 272 * 273 * @returns IPRT status code. 274 * @param pHlp Pointer to the callback structure. 275 * @param pszName Name of the member. 276 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 277 * @param i32 The value to record. 278 */ 279 DECLCALLBACKMEMBER(int, pfnStructBldAddS32, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int32_t i32)); 280 281 282 /** 283 * Adds a signed 64-bit (int64_t) member to the current (sub-)structure with the given name and value. 284 * 285 * @returns IPRT status code. 286 * @param pHlp Pointer to the callback structure. 287 * @param pszName Name of the member. 288 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 289 * @param i32 The value to record. 290 */ 291 DECLCALLBACKMEMBER(int, pfnStructBldAddS64, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int64_t i64)); 292 293 294 /** 295 * Adds a string member to the current (sub-)structure with the given name and string. 296 * 297 * @returns IPRT status code. 298 * @param pHlp Pointer to the callback structure. 299 * @param pszName Name of the member. 300 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 301 * @param pszStr The string to add. 302 */ 303 DECLCALLBACKMEMBER(int, pfnStructBldAddStr, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, const char *pszStr)); 304 305 306 /** 307 * Adds a data buffer member to the current (sub-)structure with the given name and content. 308 * 309 * @returns IPRT status code. 310 * @param pHlp Pointer to the callback structure. 311 * @param pszName Name of the member. 312 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 313 * @param pb The buffer to add. 314 * @param cb Size of the buffer in bytes. 315 */ 316 DECLCALLBACKMEMBER(int, pfnStructBldAddBuf, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, const uint8_t *pb, size_t cb)); 317 318 319 /** 320 * Adds a enum member to the current (sub-)structure with the given name and value. 321 * 322 * @returns IPRT status code. 323 * @param pHlp Pointer to the callback structure. 324 * @param pszName Name of the member. 325 * @param fFlags Combination of RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_XXX. 326 * @param cBits Size of the enum data type in bits. 327 * @param paEnums Pointer to an erray of enum entries mapping a value to the description. 328 */ 329 DECLCALLBACKMEMBER(int, pfnStructBldAddEnum, (PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint8_t cBits, 330 PCRTTRACELOGDECODERSTRUCTBLDENUM paEnums, uint64_t u64Val)); 331 332 /** 333 * Begins a new array member in the current (sub-)structure with the given name. 334 * 335 * @returns IPRT status code. 336 * @param pHlp Pointer to the callback structure. 337 * @param pszName Name of the array member. 338 */ 339 DECLCALLBACKMEMBER(int, pfnStructBldArrayBegin, (PRTTRACELOGDECODERHLP pHlp, const char *pszName)); 340 341 342 /** 343 * Ends the current array member in the current (sub-)structure. 344 * 345 * @returns IPRT status code. 346 * @param pHlp Pointer to the callback structure. 347 */ 348 DECLCALLBACKMEMBER(int, pfnStructBldArrayEnd, (PRTTRACELOGDECODERHLP pHlp)); 349 350 /** @} */ 127 351 128 352 /** End marker (DBGCCMDHLP_MAGIC). */ -
trunk/src/VBox/Devices/Trace/VBoxTraceLogDecoders.cpp
r104961 r104966 123 123 * Algorithm ID to string mapping array. 124 124 */ 125 static const TPMALGID2STRg_aAlgId2Str[] =125 static const RTTRACELOGDECODERSTRUCTBLDENUM g_aAlgId2Str[] = 126 126 { 127 127 #define TPM_ALGID_2_STR(a_AlgId) { a_AlgId, #a_AlgId, 0 } … … 187 187 TPM_ALGID_2_STR(TPM2_ALG_KMACXOF256), 188 188 TPM_ALGID_2_STR(TPM2_ALG_KMAC128), 189 TPM_ALGID_2_STR(TPM2_ALG_KMAC256) 189 TPM_ALGID_2_STR(TPM2_ALG_KMAC256), 190 { 0, NULL, 0 } 190 191 #undef TPM_ALGID_2_STR 191 192 }; … … 320 321 { 321 322 for (uint32_t i = 0; i < RT_ELEMENTS(g_aAlgId2Str); i++) 322 if (g_aAlgId2Str[i].u 16AlgId== u16AlgId)323 return g_aAlgId2Str[i].psz AlgId;323 if (g_aAlgId2Str[i].u64EnumVal == u16AlgId) 324 return g_aAlgId2Str[i].pszString; 324 325 325 326 return "<UNKNOWN>"; … … 330 331 { 331 332 for (uint32_t i = 0; i < RT_ELEMENTS(g_aAlgId2Str); i++) 332 if (g_aAlgId2Str[i].u 16AlgId== u16AlgId)333 return g_aAlgId2Str[i]. cbDigest;333 if (g_aAlgId2Str[i].u64EnumVal == u16AlgId) 334 return g_aAlgId2Str[i].uPtrUser; 334 335 335 336 return 0; … … 343 344 if (pCtx->fError) return 344 345 346 #define TPM_DECODE_BOOL(a_Var, a_Name) \ 347 uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \ 348 if (pCtx->fError) break; \ 349 pHlp->pfnStructBldAddBool(pHlp, #a_Name, 0 /*fFlags*/, RT_BOOL(a_Var)) 350 345 351 #define TPM_DECODE_U8(a_Var, a_Name) \ 346 352 uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \ 347 if (pCtx->fError) break 353 if (pCtx->fError) break; \ 354 pHlp->pfnStructBldAddU8(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 348 355 349 356 #define TPM_DECODE_U16(a_Var, a_Name) \ 350 357 uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \ 351 if (pCtx->fError) break 358 if (pCtx->fError) break; \ 359 pHlp->pfnStructBldAddU16(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 352 360 353 361 #define TPM_DECODE_U32(a_Var, a_Name) \ 354 362 uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \ 355 if (pCtx->fError) break 363 if (pCtx->fError) break; \ 364 pHlp->pfnStructBldAddU32(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 356 365 357 366 #define TPM_DECODE_U64(a_Var, a_Name) \ 358 367 uint64_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(pCtx, pHlp, #a_Name); \ 359 if (pCtx->fError) break 368 if (pCtx->fError) break; \ 369 pHlp->pfnStructBldAddU64(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 360 370 361 371 #define TPM_DECODE_I32(a_Var, a_Name) \ 362 372 int32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(pCtx, pHlp, #a_Name); \ 373 if (pCtx->fError) break; \ 374 pHlp->pfnStructBldAddS32(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 375 376 #define TPM_DECODE_U8_HEX(a_Var, a_Name) \ 377 uint8_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU8(pCtx, pHlp, #a_Name); \ 378 if (pCtx->fError) break; \ 379 pHlp->pfnStructBldAddU8(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var) 380 381 #define TPM_DECODE_U16_HEX(a_Var, a_Name) \ 382 uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \ 383 if (pCtx->fError) break; \ 384 pHlp->pfnStructBldAddU16(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var) 385 386 #define TPM_DECODE_U32_HEX(a_Var, a_Name) \ 387 uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \ 388 if (pCtx->fError) break; \ 389 pHlp->pfnStructBldAddU32(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var) 390 391 #define TPM_DECODE_U32_HEX_STR(a_Var, a_pszName) \ 392 uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, a_pszName); \ 393 if (pCtx->fError) break; \ 394 pHlp->pfnStructBldAddU32(pHlp, a_pszName, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var) 395 396 #define TPM_DECODE_U64_HEX(a_Var, a_Name) \ 397 uint64_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU64(pCtx, pHlp, #a_Name); \ 398 if (pCtx->fError) break; \ 399 pHlp->pfnStructBldAddU64(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, a_Var) 400 401 #define TPM_DECODE_I32_HEX(a_Var, a_Name) \ 402 int32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetI32(pCtx, pHlp, #a_Name); \ 403 if (pCtx->fError) break; \ 404 pHlp->pfnStructBldAddS32(pHlp, #a_Name, 0 /*fFlags*/, a_Var) 405 406 #define TPM_DECODE_BUF_EX(a_Var, a_Name, a_cb) \ 407 const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \ 363 408 if (pCtx->fError) break 364 409 365 410 #define TPM_DECODE_BUF(a_Var, a_Name, a_cb) \ 366 411 const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \ 367 if (pCtx->fError) break 412 if (pCtx->fError) break; \ 413 if (a_Var) \ 414 pHlp->pfnStructBldAddBuf(pHlp, #a_Name, 0 /*fFlags*/, a_Var, a_cb); 415 416 #define TPM_DECODE_BUF_HEX_STRING(a_Var, a_Name, a_cb) \ 417 const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, #a_Name, a_cb); \ 418 if (pCtx->fError) break; \ 419 if (a_Var) \ 420 pHlp->pfnStructBldAddBuf(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX_DUMP_STR, a_Var, a_cb); 421 422 #define TPM_DECODE_U16_ENUM(a_Var, a_Name, a_aEnums) \ 423 uint16_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU16(pCtx, pHlp, #a_Name); \ 424 if (pCtx->fError) break; \ 425 pHlp->pfnStructBldAddEnum(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, 16, a_aEnums, a_Var) 426 427 #define TPM_DECODE_U32_ENUM(a_Var, a_Name, a_aEnums) \ 428 uint32_t a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetU32(pCtx, pHlp, #a_Name); \ 429 if (pCtx->fError) break; \ 430 pHlp->pfnStructBldAddEnum(pHlp, #a_Name, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, 32, a_aEnums, a_Var) 368 431 369 432 #define TPM_DECODE_BUF_STR(a_Var, a_pszName, a_cb) \ 370 433 const uint8_t *a_Var = vboxTraceLogDecodeEvtTpmDecodeCtxGetBuf(pCtx, pHlp, a_pszName, a_cb); \ 371 if (pCtx->fError) break 434 if (pCtx->fError) break; \ 435 if (a_Var) \ 436 pHlp->pfnStructBldAddBuf(pHlp, a_pszName, RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX_DUMP_STR, a_Var, a_cb); 372 437 373 438 #define TPM_DECODE_END_IF_ERROR() \ … … 377 442 { 378 443 TPM_DECODE_INIT(); 379 TPM_DECODE_U16(u16AlgId, u16AlgId); 380 TPM_DECODE_U8(cbPcrSelection, u8SizeOfSelect); 381 TPM_DECODE_BUF(pb, PCRs, cbPcrSelection); 382 383 pHlp->pfnPrintf(pHlp, " u16AlgId: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16AlgId)); 384 pHlp->pfnPrintf(pHlp, " u8SizeOfSlect: %u\n", cbPcrSelection); 385 pHlp->pfnPrintf(pHlp, " PCRs: "); 444 TPM_DECODE_U16_ENUM(u16AlgId, u16AlgId, g_aAlgId2Str ); 445 TPM_DECODE_U8( cbPcrSelection, u8SizeOfSelect ); 446 TPM_DECODE_BUF_EX( pb, PCRs, cbPcrSelection); 447 448 pHlp->pfnStructBldArrayBegin(pHlp, "PCRs"); 386 449 387 450 for (uint8_t idxPcr = 0; idxPcr < cbPcrSelection * 8; idxPcr++) 388 451 if (RT_BOOL(*(pb + (idxPcr / 8)) & RT_BIT(idxPcr % 8))) 389 pHlp->pfnPrintf(pHlp, "%u ", idxPcr); 390 391 pHlp->pfnPrintf(pHlp, "\n"); 452 pHlp->pfnStructBldAddU8(pHlp, NULL, 0 /*fFlags*/, idxPcr); 453 454 pHlp->pfnStructBldArrayEnd(pHlp); 455 392 456 TPM_DECODE_END(); 393 457 } … … 398 462 TPM_DECODE_INIT(); 399 463 TPM_DECODE_U32(u32Count, u32Count); 400 pHlp->pfnPrintf(pHlp, " u32Count: %u\n", u32Count); 464 465 pHlp->pfnStructBldBegin(pHlp, "aPcrSelection"); 401 466 402 467 /* Walk the list of PCR selection entries. */ … … 406 471 TPM_DECODE_END_IF_ERROR(); 407 472 } 473 474 pHlp->pfnStructBldEnd(pHlp); 475 408 476 TPM_DECODE_END(); 409 477 } … … 414 482 TPM_DECODE_INIT(); 415 483 TPM_DECODE_U32(u32DigestCount, u32DigestCount); 416 pHlp->pfnPrintf(pHlp, " u32DigestCount: %u\n", u32DigestCount); 484 485 pHlp->pfnStructBldBegin(pHlp, "aDigests"); 486 417 487 for (uint32_t i = 0; i < u32DigestCount; i++) 418 488 { 419 489 TPM_DECODE_U16(u16DigestSize, u16DigestSize); 420 TPM_DECODE_BUF(pbDigest, abDigest, u16DigestSize); 421 pHlp->pfnPrintf(pHlp, " u16DigestSize: %u\n", u16DigestSize); 422 pHlp->pfnPrintf(pHlp, " abDigest: %.*Rhxs\n", u16DigestSize, pbDigest); 490 TPM_DECODE_BUF_HEX_STRING(pbDigest, abDigest, u16DigestSize); 423 491 } 492 493 pHlp->pfnStructBldEnd(pHlp); 494 424 495 TPM_DECODE_END(); 425 496 } … … 430 501 TPM_DECODE_INIT(); 431 502 TPM_DECODE_U32(u32DigestCount, u32DigestCount); 432 pHlp->pfnPrintf(pHlp, " u32DigestCount: %u\n", u32DigestCount); 503 504 pHlp->pfnStructBldBegin(pHlp, "aDigests"); 505 433 506 for (uint32_t i = 0; i < u32DigestCount; i++) 434 507 { 435 TPM_DECODE_U16 (u16HashAlg, u16HashAlg);508 TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str); 436 509 437 510 size_t cbDigest = vboxTraceLogDecodeEvtTpmAlgId2DigestSize(u16HashAlg); 438 TPM_DECODE_BUF(pb, abDigest, cbDigest); 439 440 pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg)); 441 pHlp->pfnPrintf(pHlp, " abDigest: %.*Rhxs\n", cbDigest, pb); 511 TPM_DECODE_BUF_HEX_STRING(pb, abDigest, cbDigest); 442 512 } 513 514 pHlp->pfnStructBldEnd(pHlp); 515 443 516 TPM_DECODE_END(); 444 517 } … … 447 520 static void vboxTraceLogDecodeEvtTpmAuthSessionReq(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx) 448 521 { 449 TPM_DECODE_INIT(); 450 TPM_DECODE_U32(u32Size, u32Size); 451 TPM_DECODE_U32(u32SessionHandle, u32SessionHandle); 452 TPM_DECODE_U16(u16NonceSize, u16NonceSize); 453 TPM_DECODE_BUF(pbNonce, abNonce, u16NonceSize); 454 TPM_DECODE_U8( u8Attr, u8Attr); 455 TPM_DECODE_U16(u16HmacSize, u16HmacSize); 456 TPM_DECODE_BUF(pbHmac, abHmac, u16HmacSize); 457 458 pHlp->pfnPrintf(pHlp, " u32AuthSize: %u\n", u32Size); 459 pHlp->pfnPrintf(pHlp, " u32SessionHandle: %#x\n", u32SessionHandle); 460 pHlp->pfnPrintf(pHlp, " u16NonceSize: %u\n", u16NonceSize); 461 if (u16NonceSize) 462 pHlp->pfnPrintf(pHlp, " abNonce: %.*Rhxs\n", u16NonceSize, pbNonce); 463 pHlp->pfnPrintf(pHlp, " u8Attr: %u\n", u8Attr); 464 pHlp->pfnPrintf(pHlp, " u16HmacSize: %u\n", u16HmacSize); 465 if (u16HmacSize) 466 pHlp->pfnPrintf(pHlp, " abHmac: %.*Rhxs\n", u16HmacSize, pbHmac); 467 TPM_DECODE_END(); 522 pHlp->pfnStructBldBegin(pHlp, "AuthArea"); 523 TPM_DECODE_INIT(); 524 TPM_DECODE_U32( u32Size, u32Size); 525 TPM_DECODE_U32_HEX(u32SessionHandle, u32SessionHandle); 526 TPM_DECODE_U16( u16NonceSize, u16NonceSize); 527 TPM_DECODE_BUF( pbNonce, abNonce, u16NonceSize); 528 TPM_DECODE_U8( u8Attr, u8Attr); 529 TPM_DECODE_U16( u16HmacSize, u16HmacSize); 530 TPM_DECODE_BUF( pbHmac, abHmac, u16HmacSize); 531 TPM_DECODE_END(); 532 pHlp->pfnStructBldEnd(pHlp); 468 533 } 469 534 … … 471 536 static void vboxTraceLogDecodeEvtTpmAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx) 472 537 { 538 pHlp->pfnStructBldBegin(pHlp, "AuthArea"); 473 539 TPM_DECODE_INIT(); 474 540 TPM_DECODE_U16(u16NonceSize, u16NonceSize); … … 477 543 TPM_DECODE_U16(u16AckSize, u16AckSize); 478 544 TPM_DECODE_BUF(pbAck, abAck, u16AckSize); 479 480 pHlp->pfnPrintf(pHlp, " u16NonceSize: %u\n", u16NonceSize); 481 if (u16NonceSize) 482 pHlp->pfnPrintf(pHlp, " abNonce: %.*Rhxs\n", u16NonceSize, pbNonce); 483 pHlp->pfnPrintf(pHlp, " u8Attr: %u\n", u8Attr); 484 pHlp->pfnPrintf(pHlp, " u16AckSize: %u\n", u16AckSize); 485 if (u16AckSize) 486 pHlp->pfnPrintf(pHlp, " abAck: %.*Rhxs\n", u16AckSize, pbAck); 487 TPM_DECODE_END(); 545 TPM_DECODE_END(); 546 pHlp->pfnStructBldEnd(pHlp); 488 547 } 489 548 … … 491 550 static void vboxTraceLogDecodeSizedBufU16(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName) 492 551 { 493 TPM_DECODE_INIT();494 pHlp->pfnPrintf(pHlp, " %s:\n", pszName);552 pHlp->pfnStructBldBegin(pHlp, pszName); 553 TPM_DECODE_INIT(); 495 554 TPM_DECODE_U16(u16Size, u16Size); 496 pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);497 555 if (u16Size) 498 556 { 499 557 TPM_DECODE_BUF_STR(pb, pszName, u16Size); 500 pHlp->pfnPrintf(pHlp, " %s:\n"501 "%.*Rhxd\n", pszName, u16Size, pb);502 558 } 503 559 TPM_DECODE_END(); 560 pHlp->pfnStructBldEnd(pHlp); 504 561 } 505 562 … … 507 564 static void vboxTraceLogDecodeSymEncDef(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName) 508 565 { 509 RT_NOREF(pszName); 510 511 TPM_DECODE_INIT(); 512 pHlp->pfnPrintf(pHlp, " %s:\n", pszName); 513 TPM_DECODE_U16(u16HashAlg, u16HashAlg); 514 pHlp->pfnPrintf(pHlp, " u16Alg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg)); 566 pHlp->pfnStructBldBegin(pHlp, pszName); 567 TPM_DECODE_INIT(); 568 TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str); 515 569 if (u16HashAlg != TPM2_ALG_NULL) 516 570 { 517 571 TPM_DECODE_U16(u16KeyBits, u16KeyBits); 518 pHlp->pfnPrintf(pHlp, " u16KeyBits: %u\n", u16KeyBits); 519 TPM_DECODE_U16(u16SymMode, u16SymMode); 520 pHlp->pfnPrintf(pHlp, " u16SymMode: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SymMode)); 572 TPM_DECODE_U16_ENUM(u16SymMode, u16SymMode, g_aAlgId2Str); 521 573 /* Symmetric details are not required as of now. */ 522 574 } 523 575 TPM_DECODE_END(); 576 pHlp->pfnStructBldEnd(pHlp); 524 577 } 525 578 … … 527 580 static void vboxTraceLogDecodeNvPublic(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName) 528 581 { 529 TPM_DECODE_INIT();530 pHlp->pfnPrintf(pHlp, " %s:\n", pszName);582 pHlp->pfnStructBldBegin(pHlp, pszName); 583 TPM_DECODE_INIT(); 531 584 TPM_DECODE_U16(u16Size, u16Size); 532 pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);533 585 if (u16Size) 534 586 { 535 TPM_DECODE_U32 (hNvIndex,hNvIndex);587 TPM_DECODE_U32_HEX(hNvIndex, hNvIndex); 536 588 TPM_DECODE_U16(u16HashAlgName, u16HashAlgName); 537 589 TPM_DECODE_U32(u32Attr, fAttr); 538 539 pHlp->pfnPrintf(pHlp, " hNvIndex: %#x\n", hNvIndex);540 pHlp->pfnPrintf(pHlp, " u16HashAlgName: %u\n", u16HashAlgName);541 pHlp->pfnPrintf(pHlp, " u32Attr: %#x\n", u32Attr);542 543 590 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy"); 544 591 TPM_DECODE_U16(u16DataSize, u16DataSize); 545 pHlp->pfnPrintf(pHlp, " u16DataSize: %u\n", u16DataSize);546 592 } 547 593 TPM_DECODE_END(); 594 pHlp->pfnStructBldEnd(pHlp); 548 595 } 549 596 … … 551 598 static void vboxTraceLogDecodeTicket(PRTTRACELOGDECODERHLP pHlp, PTPMDECODECTX pCtx, const char *pszName) 552 599 { 553 TPM_DECODE_INIT(); 554 pHlp->pfnPrintf(pHlp, " %s:\n", pszName); 555 556 TPM_DECODE_U16(u16Tag, u16Tag); 557 TPM_DECODE_U32(hHierarchy, hHierarchy); 558 pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag); 559 pHlp->pfnPrintf(pHlp, " hHierarchy: %#x\n", hHierarchy); 600 pHlp->pfnStructBldBegin(pHlp, pszName); 601 TPM_DECODE_INIT(); 602 TPM_DECODE_U16_HEX(u16Tag, u16Tag); 603 TPM_DECODE_U32_HEX(hHierarchy, hHierarchy); 560 604 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Digest"); 561 605 TPM_DECODE_END(); 562 } 606 pHlp->pfnStructBldEnd(pHlp); 607 } 608 609 610 static RTTRACELOGDECODERSTRUCTBLDENUM g_aStartupShutdownParam[] = 611 { 612 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_SU_CLEAR), 613 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_SU_STATE) 614 }; 563 615 564 616 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartupShutdownReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx) … … 567 619 568 620 TPM_DECODE_INIT(); 569 TPM_DECODE_U16(u16TpmSu, u16State); 570 571 if (u16TpmSu == TPM2_SU_CLEAR) 572 pHlp->pfnPrintf(pHlp, " TPM2_SU_CLEAR\n"); 573 else if (u16TpmSu == TPM2_SU_STATE) 574 pHlp->pfnPrintf(pHlp, " TPM2_SU_STATE\n"); 575 else 576 pHlp->pfnPrintf(pHlp, " Unknown: %#x\n", u16TpmSu); 577 TPM_DECODE_END(); 578 } 579 580 581 static struct 582 { 583 const char *pszCap; 584 const uint32_t *paProperties; 585 } s_aTpm2Caps[] = 586 { 587 { RT_STR(TPM2_CAP_ALGS), NULL }, 588 { RT_STR(TPM2_CAP_HANDLES), NULL }, 589 { RT_STR(TPM2_CAP_COMMANDS), NULL }, 590 { RT_STR(TPM2_CAP_PP_COMMANDS), NULL }, 591 { RT_STR(TPM2_CAP_AUDIT_COMMANDS), NULL }, 592 { RT_STR(TPM2_CAP_PCRS), NULL }, 593 { RT_STR(TPM2_CAP_TPM_PROPERTIES), NULL }, 594 { RT_STR(TPM2_CAP_PCR_PROPERTIES), NULL }, 595 { RT_STR(TPM2_CAP_ECC_CURVES), NULL }, 596 { RT_STR(TPM2_CAP_AUTH_POLICIES), NULL }, 597 { RT_STR(TPM2_CAP_ACT), NULL }, 621 TPM_DECODE_U16_ENUM(u16TpmSu, u16State, g_aStartupShutdownParam); 622 TPM_DECODE_END(); 623 } 624 625 626 static RTTRACELOGDECODERSTRUCTBLDENUM g_aTpm2Caps[] = 627 { 628 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ALGS), 629 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_HANDLES), 630 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_COMMANDS), 631 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PP_COMMANDS), 632 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_AUDIT_COMMANDS), 633 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PCRS), 634 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_TPM_PROPERTIES), 635 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_PCR_PROPERTIES), 636 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ECC_CURVES), 637 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_AUTH_POLICIES), 638 RT_TRACELOG_DECODER_STRUCT_BLD_ENUM_INIT(TPM2_CAP_ACT) 598 639 }; 599 640 … … 601 642 { 602 643 TPM_DECODE_INIT(); 603 TPM_DECODE_U32 (u32Cap, u32Cap);604 TPM_DECODE_U32 (u32Property, u32Property);605 TPM_DECODE_U32( u32Count, u32Count);644 TPM_DECODE_U32_ENUM(u32Cap, u32Cap, g_aTpm2Caps); 645 TPM_DECODE_U32_HEX( u32Property, u32Property ); 646 TPM_DECODE_U32( u32Count, u32Count ); 606 647 607 648 pThis->u.GetCapability.u32Cap = u32Cap; 608 649 pThis->u.GetCapability.u32Property = u32Property; 609 650 pThis->u.GetCapability.u32Count = u32Count; 610 611 if (u32Cap < RT_ELEMENTS(s_aTpm2Caps))612 pHlp->pfnPrintf(pHlp, " u32Cap: %s\n"613 " u32Property: %#x\n"614 " u32Count: %#x\n",615 s_aTpm2Caps[u32Cap].pszCap, u32Property, u32Count);616 else617 pHlp->pfnPrintf(pHlp, " u32Cap: %#x (UNKNOWN)\n"618 " u32Property: %#x\n"619 " u32Count: %#x\n",620 u32Cap, u32Property, u32Count);621 651 TPM_DECODE_END(); 622 652 } … … 628 658 629 659 TPM_DECODE_INIT(); 630 TPM_DECODE_U8( fMoreData, fMoreData); 631 TPM_DECODE_U32(u32Cap, u32Cap); 632 633 pHlp->pfnPrintf(pHlp, " fMoreData: %RTbool\n", fMoreData); 634 if (u32Cap < RT_ELEMENTS(s_aTpm2Caps)) 660 TPM_DECODE_BOOL( fMoreData, fMoreData); 661 TPM_DECODE_U32_ENUM(u32Cap, u32Cap, g_aTpm2Caps); 662 663 switch (u32Cap) 635 664 { 636 pHlp->pfnPrintf(pHlp, " u32Cap: %s\n", s_aTpm2Caps[u32Cap]); 637 switch (u32Cap) 665 case TPM2_CAP_PCRS: 638 666 { 639 case TPM2_CAP_PCRS: 640 { 641 vboxTraceLogDecodePcrSelectionList(pHlp, pCtx); 642 break; 643 } 644 default: 645 break; 667 vboxTraceLogDecodePcrSelectionList(pHlp, pCtx); 668 break; 646 669 } 670 default: 671 break; 647 672 } 648 else649 pHlp->pfnPrintf(pHlp, " u32Cap: %#x (UNKNOWN)\n", u32Cap);650 673 TPM_DECODE_END(); 651 674 } … … 679 702 TPM_DECODE_U16(u16RandomBytes, u16RandomBytes); 680 703 pThis->u.GetRandom.cbRnd = u16RandomBytes; 681 pHlp->pfnPrintf(pHlp, " u16RandomBytes: %u\n", pThis->u.GetRandom.cbRnd);682 704 TPM_DECODE_END(); 683 705 } … … 696 718 697 719 TPM_DECODE_BUF(pb, RndBuf, cbBuf); 698 pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbBuf, pb);699 720 TPM_DECODE_END(); 700 721 } … … 717 738 TPM_DECODE_INIT(); 718 739 TPM_DECODE_U32(u32PcrUpdateCounter, u32PcrUpdateCounter); 719 pHlp->pfnPrintf(pHlp, " u32PcrUpdateCounter: %u\n", u32PcrUpdateCounter);720 721 740 vboxTraceLogDecodePcrSelectionList(pHlp, pCtx); 722 741 TPM_DECODE_END_IF_ERROR(); … … 749 768 TPM_DECODE_INIT(); 750 769 TPM_DECODE_U64(u64Time, u64Time); 751 pHlp->pfnPrintf(pHlp, " u64Time: %RX64\n", u64Time);752 770 753 771 /* Decode TPMS_CLOCK_INFO. */ 754 TPM_DECODE_U64(u64Clock, u64Clock); 755 TPM_DECODE_U32(u32ResetCount, u32ResetCount); 756 TPM_DECODE_U32(u32RestartCount, u32RestartCount); 757 TPM_DECODE_U8( fSafe, fSafe); 758 pHlp->pfnPrintf(pHlp, " u64Clock: %RX64\n", u64Clock); 759 pHlp->pfnPrintf(pHlp, " u32ResetCount: %u\n", u32ResetCount); 760 pHlp->pfnPrintf(pHlp, " u32RestartCount: %u\n", u32RestartCount); 761 pHlp->pfnPrintf(pHlp, " fSafe: %RTbool\n", fSafe); 762 772 TPM_DECODE_U64( u64Clock, u64Clock); 773 TPM_DECODE_U32( u32ResetCount, u32ResetCount); 774 TPM_DECODE_U32( u32RestartCount, u32RestartCount); 775 TPM_DECODE_BOOL(fSafe, fSafe); 763 776 TPM_DECODE_END(); 764 777 } … … 800 813 TPM_DECODE_END_IF_ERROR(); 801 814 802 TPM_DECODE_U8(u8SessionType, u8SessionType); 803 pHlp->pfnPrintf(pHlp, " u8SessionType: %#x\n", u8SessionType); 815 TPM_DECODE_U8_HEX(u8SessionType, u8SessionType); 804 816 805 817 vboxTraceLogDecodeSymEncDef(pHlp, pCtx, "Symmetric"); 818 TPM_DECODE_END_IF_ERROR(); 819 820 TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str); 821 TPM_DECODE_END(); 822 } 823 824 825 static const char *g_apszHandlesStartAuthSessionResp[] = 826 { 827 "hSession", 828 NULL 829 }; 830 831 832 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx) 833 { 834 RT_NOREF(pThis); 835 836 TPM_DECODE_INIT(); 837 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm"); 838 TPM_DECODE_END(); 839 } 840 841 842 static const char *g_apszHandlesHierarchyChangeAuthReq[] = 843 { 844 "hAuth", 845 NULL 846 }; 847 848 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx) 849 { 850 RT_NOREF(pThis); 851 852 TPM_DECODE_INIT(); 853 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NewAuth"); 854 TPM_DECODE_END(); 855 } 856 857 858 static const char *g_apszHandlesNvDefineSpaceReq[] = 859 { 860 "hAuth", 861 NULL 862 }; 863 864 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx) 865 { 866 RT_NOREF(pThis); 867 868 TPM_DECODE_INIT(); 869 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Auth"); 870 TPM_DECODE_END_IF_ERROR(); 871 872 vboxTraceLogDecodeNvPublic(pHlp, pCtx, "PublicInfo"); 873 TPM_DECODE_END(); 874 } 875 876 877 static const char *g_apszHandlesSetPrimaryPolicyReq[] = 878 { 879 "hAuth", 880 NULL 881 }; 882 883 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx) 884 { 885 RT_NOREF(pThis); 886 887 TPM_DECODE_INIT(); 888 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy"); 806 889 TPM_DECODE_END_IF_ERROR(); 807 890 … … 812 895 813 896 814 static const char *g_apszHandlesStartAuthSessionResp[] =815 {816 "hSession",817 NULL818 };819 820 821 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeStartAuthSessionResp(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)822 {823 RT_NOREF(pThis);824 825 TPM_DECODE_INIT();826 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NonceTpm");827 TPM_DECODE_END();828 }829 830 831 static const char *g_apszHandlesHierarchyChangeAuthReq[] =832 {833 "hAuth",834 NULL835 };836 837 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeHierarchyChangeAuthReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)838 {839 RT_NOREF(pThis);840 841 TPM_DECODE_INIT();842 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "NewAuth");843 TPM_DECODE_END();844 }845 846 847 static const char *g_apszHandlesNvDefineSpaceReq[] =848 {849 "hAuth",850 NULL851 };852 853 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeNvDefineSpaceReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)854 {855 RT_NOREF(pThis);856 857 TPM_DECODE_INIT();858 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "Auth");859 TPM_DECODE_END_IF_ERROR();860 861 vboxTraceLogDecodeNvPublic(pHlp, pCtx, "PublicInfo");862 TPM_DECODE_END();863 }864 865 866 static const char *g_apszHandlesSetPrimaryPolicyReq[] =867 {868 "hAuth",869 NULL870 };871 872 static DECLCALLBACK(void) vboxTraceLogDecodeEvtTpmDecodeSetPrimaryPolicyReq(PRTTRACELOGDECODERHLP pHlp, PTPMSTATE pThis, PTPMDECODECTX pCtx)873 {874 RT_NOREF(pThis);875 876 TPM_DECODE_INIT();877 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "AuthPolicy");878 TPM_DECODE_END_IF_ERROR();879 880 TPM_DECODE_U16(u16HashAlg, u16HashAlg);881 pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg));882 TPM_DECODE_END();883 }884 885 886 897 static const char *g_apszHandlesCreatePrimaryReq[] = 887 898 { … … 961 972 962 973 TPM_DECODE_INIT(); 963 TPM_DECODE_U64(u64BitsOr, u64BitsOr); 964 pHlp->pfnPrintf(pHlp, " u64BitsOr: %#RX64\n", u64BitsOr); 974 TPM_DECODE_U64_HEX(u64BitsOr, u64BitsOr); 965 975 TPM_DECODE_END(); 966 976 } … … 983 993 984 994 TPM_DECODE_U16(u16Offset, u16Offset); 985 pHlp->pfnPrintf(pHlp, " u16Offset: %u\n", u16Offset);986 995 TPM_DECODE_END(); 987 996 } … … 1002 1011 TPM_DECODE_U32(u32NewRecoveryTime, u32NewRecoveryTime); 1003 1012 TPM_DECODE_U32(u32LockoutRecovery, u32LockoutRecovery); 1004 1005 pHlp->pfnPrintf(pHlp, " u32NewMaxTries: %u\n", u32NewMaxTries);1006 pHlp->pfnPrintf(pHlp, " u32NewRecoveryTime: %u\n", u32NewRecoveryTime);1007 pHlp->pfnPrintf(pHlp, " u32LockoutRecovery: %u\n", u32LockoutRecovery);1008 1013 TPM_DECODE_END(); 1009 1014 } … … 1027 1032 TPM_DECODE_END_IF_ERROR(); 1028 1033 1029 TPM_DECODE_U16(u16SigningScheme, u16SigningScheme); 1030 pHlp->pfnPrintf(pHlp, " u16SigningScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigningScheme)); 1031 1034 TPM_DECODE_U16_ENUM(u16SigningScheme, u16SigningScheme, g_aAlgId2Str); 1032 1035 vboxTraceLogDecodeTicket(pHlp, pCtx, "CreationTicket"); 1033 1036 TPM_DECODE_END(); … … 1043 1046 1044 1047 /* Decode TPMT_SIGNATURE */ 1045 TPM_DECODE_U16(u16SigningAlg, u16SigningAlg); 1046 pHlp->pfnPrintf(pHlp, " u16SigningAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigningAlg)); 1047 TPM_DECODE_U16(u16HashAlg, u16HashAlg); 1048 pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg)); 1049 1048 TPM_DECODE_U16_ENUM(u16SigningAlg, u16SigningAlg, g_aAlgId2Str); 1049 TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str); 1050 1050 TPM_DECODE_END(); 1051 1051 } … … 1065 1065 TPM_DECODE_INIT(); 1066 1066 TPM_DECODE_U16(u16Size, u16Size); 1067 pHlp->pfnPrintf(pHlp, " u16Size: %u\n", u16Size);1068 1067 TPM_DECODE_U16(u16Offset, u16Offset); 1069 pHlp->pfnPrintf(pHlp, " u16Offset: %u\n", u16Offset);1070 1068 TPM_DECODE_END(); 1071 1069 } … … 1102 1100 1103 1101 TPM_DECODE_I32(i32Expiration, i32Expiration); 1104 pHlp->pfnPrintf(pHlp, " i32Expiration: %u\n", i32Expiration);1105 1102 TPM_DECODE_END(); 1106 1103 } … … 1175 1172 TPM_DECODE_INIT(); 1176 1173 TPM_DECODE_U16(u16CurveId, u16CurveId); 1177 pHlp->pfnPrintf(pHlp, " u16CurveId: %#x\n", u16CurveId);1178 1174 TPM_DECODE_END(); 1179 1175 } … … 1185 1181 1186 1182 TPM_DECODE_INIT(); 1187 TPM_DECODE_U16(u16CurveId, u16CurveId); 1188 TPM_DECODE_U16(u16KeySize, u16KeySize); 1189 TPM_DECODE_U16(u16KdfScheme, u16KdfScheme); 1190 TPM_DECODE_U16(u16KdfSchemeHash, u16KdfSchemeHash); 1191 TPM_DECODE_U16(u16EccScheme, u16EccScheme); 1192 1193 pHlp->pfnPrintf(pHlp, " u16CurveId: %#x\n", u16CurveId); 1194 pHlp->pfnPrintf(pHlp, " u16KeySize: %u\n", u16KeySize); 1195 pHlp->pfnPrintf(pHlp, " u16KdfScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16KdfScheme)); 1196 pHlp->pfnPrintf(pHlp, " u16KdfSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16KdfSchemeHash)); 1197 pHlp->pfnPrintf(pHlp, " u16EccScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16EccScheme)); 1183 TPM_DECODE_U16_HEX( u16CurveId, u16CurveId); 1184 TPM_DECODE_U16( u16KeySize, u16KeySize); 1185 TPM_DECODE_U16_ENUM(u16KdfScheme, u16KdfScheme, g_aAlgId2Str); 1186 TPM_DECODE_U16_ENUM(u16KdfSchemeHash, u16KdfSchemeHash, g_aAlgId2Str); 1187 TPM_DECODE_U16_ENUM(u16EccScheme, u16EccScheme, g_aAlgId2Str); 1198 1188 if (u16EccScheme != TPM2_ALG_NULL) 1199 1189 { 1200 TPM_DECODE_U16(u16EccSchemeHash, u16EccSchemeHash); 1201 pHlp->pfnPrintf(pHlp, " u16EccSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16EccSchemeHash)); 1190 TPM_DECODE_U16_ENUM(u16EccSchemeHash, u16EccSchemeHash, g_aAlgId2Str); 1202 1191 } 1203 1192 vboxTraceLogDecodeSizedBufU16(pHlp, pCtx, "p"); … … 1234 1223 TPM_DECODE_END_IF_ERROR(); 1235 1224 1236 TPM_DECODE_U16(u16SigScheme, u16SigScheme); 1237 pHlp->pfnPrintf(pHlp, " u16SigScheme: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigScheme)); 1225 TPM_DECODE_U16_ENUM(u16SigScheme, u16SigScheme, g_aAlgId2Str); 1238 1226 if (u16SigScheme != TPM2_ALG_NULL) 1239 1227 { 1240 TPM_DECODE_U16(u16SigSchemeHash, u16SigSchemeHash); 1241 pHlp->pfnPrintf(pHlp, " u16SigSchemeHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigSchemeHash)); 1228 TPM_DECODE_U16_ENUM(u16SigSchemeHash, u16SigSchemeHash, g_aAlgId2Str); 1242 1229 } 1243 1230 … … 1255 1242 TPM_DECODE_END_IF_ERROR(); 1256 1243 1257 TPM_DECODE_U16(u16SigAlg, u16SigAlg); 1258 pHlp->pfnPrintf(pHlp, " u16SigAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigAlg)); 1244 TPM_DECODE_U16_ENUM(u16SigAlg, u16SigAlg, g_aAlgId2Str); 1259 1245 if (u16SigAlg != TPM2_ALG_NULL) 1260 1246 { 1261 TPM_DECODE_U16(u16SigAlgHash, u16SigAlgHash); 1262 pHlp->pfnPrintf(pHlp, " u16SigAlgHash: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16SigAlgHash)); 1247 TPM_DECODE_U16_ENUM(u16SigAlgHash, u16SigAlgHash, g_aAlgId2Str); 1263 1248 } 1264 1249 TPM_DECODE_END(); … … 1281 1266 TPM_DECODE_END_IF_ERROR(); 1282 1267 1283 TPM_DECODE_U16(u16HashAlg, u16HashAlg); 1284 pHlp->pfnPrintf(pHlp, " u16HashAlg: %s\n", vboxTraceLogDecodeEvtTpmAlgId2Str(u16HashAlg)); 1268 TPM_DECODE_U16_ENUM(u16HashAlg, u16HashAlg, g_aAlgId2Str); 1285 1269 TPM_DECODE_END(); 1286 1270 } … … 1508 1492 if (s_aTpmCmdCodes[i].u32CmdCode == u32CmdCode) 1509 1493 { 1510 pHlp->pfnPrintf(pHlp, " %s (%u bytes):\n", s_aTpmCmdCodes[i].pszCmdCode, cbReqPayload); 1511 pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag); 1512 1494 pHlp->pfnStructBldBegin(pHlp, "Command"); 1495 pHlp->pfnStructBldAddStr(pHlp, "CmdCode", 0 /*fFlags*/, s_aTpmCmdCodes[i].pszCmdCode); 1496 pHlp->pfnStructBldAddU32(pHlp, "PayloadSize", 0 /*fFlags*/, cbReqPayload); 1497 pHlp->pfnStructBldAddU16(pHlp, "u16Tag", RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, u16Tag); 1513 1498 1514 1499 TPMDECODECTX Ctx; … … 1519 1504 if (s_aTpmCmdCodes[i].papszHandlesReq) 1520 1505 { 1521 pHlp->pfn Printf(pHlp, " Handles:\n");1506 pHlp->pfnStructBldBegin(pHlp, "Handles"); 1522 1507 1523 1508 const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesReq; 1524 1509 while (*papszHnd) 1525 1510 { 1526 TPM_DECODE_U32(u32Hnd, u32Hnd); 1527 pHlp->pfnPrintf(pHlp, " %s: %#x\n", *papszHnd, u32Hnd); 1511 TPM_DECODE_U32_HEX_STR(u32Hnd, *papszHnd); 1528 1512 papszHnd++; 1529 1513 } 1514 1515 pHlp->pfnStructBldEnd(pHlp); 1530 1516 } 1531 1517 1532 1518 /* Decode authorization area if available. */ 1533 1519 if (u16Tag == TPM2_ST_SESSIONS) 1534 {1535 pHlp->pfnPrintf(pHlp, " Authorization Area:\n");1536 1520 vboxTraceLogDecodeEvtTpmAuthSessionReq(pHlp, pCtx); 1537 }1538 1521 1539 1522 /* Decode parameters. */ 1540 1523 if (s_aTpmCmdCodes[i].pfnDecodeReq) 1541 1524 { 1542 pHlp->pfn Printf(pHlp, " Parameters:\n");1525 pHlp->pfnStructBldBegin(pHlp, "Parameters"); 1543 1526 s_aTpmCmdCodes[i].pfnDecodeReq(pHlp, pTpmState, &Ctx); 1527 pHlp->pfnStructBldEnd(pHlp); 1544 1528 } 1545 1529 … … 1547 1531 pHlp->pfnPrintf(pHlp, " Leftover undecoded data:\n" 1548 1532 "%.*Rhxd\n", pCtx->cbLeft, pCtx->pbBuf); 1533 1534 pHlp->pfnStructBldEnd(pHlp); 1549 1535 return; 1550 1536 } … … 1571 1557 uint16_t u16Tag = RT_BE2H_U16(pHdr->u16Tag); 1572 1558 1573 pHlp->pfnPrintf(pHlp, " Status code: %#x (%u bytes)\n", u32ErrCode, cbRespPayload); 1574 pHlp->pfnPrintf(pHlp, " u16Tag: %#x\n", u16Tag); 1559 pHlp->pfnStructBldBegin(pHlp, "Response"); 1560 1561 pHlp->pfnStructBldAddU16(pHlp, "u16Tag", RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX, u16Tag); 1562 pHlp->pfnStructBldAddU32(pHlp, "u32ErrCode", 0 /*fFlags*/, u32ErrCode); 1563 pHlp->pfnStructBldAddU32(pHlp, "cbResponse", 0 /*fFlags*/, cbRespPayload); 1564 1575 1565 PTPMSTATE pTpmState = (PTPMSTATE)pHlp->pfnDecoderStateGet(pHlp); 1576 1566 … … 1590 1580 if (s_aTpmCmdCodes[i].papszHandlesResp) 1591 1581 { 1592 pHlp->pfn Printf(pHlp, " Handles:\n");1582 pHlp->pfnStructBldBegin(pHlp, "Handles"); 1593 1583 1594 1584 const char **papszHnd = s_aTpmCmdCodes[i].papszHandlesResp; 1595 1585 while (*papszHnd) 1596 1586 { 1597 TPM_DECODE_U32(u32Hnd, u32Hnd); 1598 pHlp->pfnPrintf(pHlp, " %s: %#x\n", *papszHnd, u32Hnd); 1587 TPM_DECODE_U32_HEX_STR(u32Hnd, *papszHnd); 1599 1588 papszHnd++; 1600 1589 } 1590 1591 pHlp->pfnStructBldEnd(pHlp); 1601 1592 } 1602 1593 … … 1605 1596 TPM_DECODE_INIT(); 1606 1597 TPM_DECODE_U32(u32ParamSz, u32ParamSize); 1607 pHlp->pfnPrintf(pHlp, " u32ParamSize: %#x\n", u32ParamSz);1608 1598 TPM_DECODE_END(); 1609 1599 } … … 1611 1601 /* Decode parameters. */ 1612 1602 if (s_aTpmCmdCodes[i].pfnDecodeResp) 1603 { 1604 pHlp->pfnStructBldBegin(pHlp, "Parameters"); 1613 1605 s_aTpmCmdCodes[i].pfnDecodeResp(pHlp, pTpmState, pCtx); 1606 pHlp->pfnStructBldEnd(pHlp); 1607 } 1614 1608 1615 1609 /* Decode authorization area if available. */ 1616 1610 if (u16Tag == TPM2_ST_SESSIONS) 1617 {1618 pHlp->pfnPrintf(pHlp, " Authorization Area:\n");1619 1611 vboxTraceLogDecodeEvtTpmAuthSessionResp(pHlp, pCtx); 1620 }1621 1612 1622 1613 if (pCtx->cbLeft) 1623 pHlp->pfnPrintf(pHlp, " Leftover undecoded data:\n" 1624 "%.*Rhxd\n", pCtx->cbLeft, pCtx->pbBuf); 1625 1614 pHlp->pfnStructBldAddBuf(pHlp, "Leftover undecoded data", 0 /*fFlags*/, pCtx->pbBuf, pCtx->cbLeft); 1615 pHlp->pfnStructBldEnd(pHlp); 1626 1616 return; 1627 1617 } … … 1630 1620 1631 1621 if (cbRespPayload) 1632 pHlp->pfnPrintf(pHlp, "%.*Rhxd\n", cbRespPayload, pHdr + 1); 1622 pHlp->pfnStructBldAddBuf(pHlp, "Data", 0 /*fFlags*/, (const uint8_t *)(pHdr + 1), cbRespPayload); 1623 1624 pHlp->pfnStructBldEnd(pHlp); 1633 1625 } 1634 1626 else -
trunk/src/VBox/Runtime/tools/RTTraceLogTool.cpp
r104923 r104966 65 65 /** The free callback of any attached decoder state. */ 66 66 PFNTRACELOGDECODERSTATEFREE pfnDecoderStateFree; 67 /** Current struct nesting level. */ 68 uint32_t cStructNesting; 69 /** Current array level nesting. */ 70 uint32_t cArrayNesting; 67 71 } RTTRACELOGDECODER; 68 72 typedef RTTRACELOGDECODER *PRTTRACELOGDECODER; … … 277 281 278 282 283 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldBegin(PRTTRACELOGDECODERHLP pHlp, const char *pszName) 284 { 285 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 286 287 RTPrintf("%*s%s:\n", pDecoder->cStructNesting * 4, "", pszName); 288 pDecoder->cStructNesting++; 289 return VINF_SUCCESS; 290 } 291 292 293 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldEnd(PRTTRACELOGDECODERHLP pHlp) 294 { 295 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 296 297 pDecoder->cStructNesting--; 298 return VINF_SUCCESS; 299 } 300 301 302 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddBool(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, bool f) 303 { 304 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 305 306 RT_NOREF(fFlags); 307 RTPrintf("%*s%-16s %32RTbool\n", pDecoder->cStructNesting * 4, "", pszName, f); 308 return VINF_SUCCESS; 309 } 310 311 312 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddU8(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint8_t u8) 313 { 314 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 315 316 if (pszName) 317 { 318 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 319 RTPrintf("%*s%-16s %#32RX8\n", pDecoder->cStructNesting * 4, "", pszName, u8); 320 else 321 RTPrintf("%*s%-16s %32RU8\n", pDecoder->cStructNesting * 4, "", pszName, u8); 322 } 323 else 324 { 325 Assert(pDecoder->cArrayNesting > 0); 326 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 327 RTPrintf(" %#02RX8", u8); 328 else 329 RTPrintf(" %02RU8", u8); 330 } 331 return VINF_SUCCESS; 332 } 333 334 335 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddU16(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint16_t u16) 336 { 337 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 338 339 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 340 RTPrintf("%*s%-16s %#32RX16\n", pDecoder->cStructNesting * 4, "", pszName, u16); 341 else 342 RTPrintf("%*s%-16s %32RU16\n", pDecoder->cStructNesting * 4, "", pszName, u16); 343 return VINF_SUCCESS; 344 } 345 346 347 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddU32(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint32_t u32) 348 { 349 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 350 351 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 352 RTPrintf("%*s%-16s %#32RX32\n", pDecoder->cStructNesting * 4, "", pszName, u32); 353 else 354 RTPrintf("%*s%-16s %32RU32\n", pDecoder->cStructNesting * 4, "", pszName, u32); 355 return VINF_SUCCESS; 356 } 357 358 359 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddU64(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint64_t u64) 360 { 361 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 362 363 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 364 RTPrintf("%*s%-16s %#32RX64\n", pDecoder->cStructNesting * 4, "", pszName, u64); 365 else 366 RTPrintf("%*s%-16s %32RU64\n", pDecoder->cStructNesting * 4, "", pszName, u64); 367 return VINF_SUCCESS; 368 } 369 370 371 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddS8(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int8_t i8) 372 { 373 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 374 375 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 376 RTPrintf("%*s%-16s %#32RX8\n", pDecoder->cStructNesting * 4, "", pszName, i8); 377 else 378 RTPrintf("%*s%-16s %32RI8\n", pDecoder->cStructNesting * 4, "", pszName, i8); 379 return VINF_SUCCESS; 380 } 381 382 383 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddS16(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int16_t i16) 384 { 385 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 386 387 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 388 RTPrintf("%*s%-16s %#32RX16\n", pDecoder->cStructNesting * 4, "", pszName, i16); 389 else 390 RTPrintf("%*s%-16s %32RI16\n", pDecoder->cStructNesting * 4, "", pszName, i16); 391 return VINF_SUCCESS; 392 } 393 394 395 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddS32(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int32_t i32) 396 { 397 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 398 399 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 400 RTPrintf("%*s%-16s %#RX32\n", pDecoder->cStructNesting * 4, "", pszName, i32); 401 else 402 RTPrintf("%*s%-16s %RI32\n", pDecoder->cStructNesting * 4, "", pszName, i32); 403 return VINF_SUCCESS; 404 } 405 406 407 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddS64(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, int64_t i64) 408 { 409 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 410 411 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 412 RTPrintf("%*s%-16s %#RX64\n", pDecoder->cStructNesting * 4, "", pszName, i64); 413 else 414 RTPrintf("%*s%-16s %RI64\n", pDecoder->cStructNesting * 4, "", pszName, i64); 415 return VINF_SUCCESS; 416 } 417 418 419 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddStr(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, const char *pszStr) 420 { 421 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 422 423 RT_NOREF(fFlags); 424 RTPrintf("%*s%-16s %32s\n", pDecoder->cStructNesting * 4, "", pszName, pszStr); 425 return VINF_SUCCESS; 426 } 427 428 429 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddBuf(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, const uint8_t *pb, size_t cb) 430 { 431 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 432 433 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX_DUMP_STR) 434 RTPrintf("%*s%-16s %.*Rhxs\n", pDecoder->cStructNesting * 4, "", pszName, cb, pb); 435 else 436 RTPrintf("%*s%-16s\n" 437 "%.*Rhxd\n", pDecoder->cStructNesting * 4, "", pszName, cb, pb); 438 return VINF_SUCCESS; 439 } 440 441 442 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldAddEnum(PRTTRACELOGDECODERHLP pHlp, const char *pszName, uint32_t fFlags, uint8_t cBits, 443 PCRTTRACELOGDECODERSTRUCTBLDENUM paEnums, uint64_t u64Val) 444 { 445 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 446 447 const char *pszEnum = "<UNKNOWN>"; 448 while (paEnums->pszString) 449 { 450 if (paEnums->u64EnumVal == u64Val) 451 { 452 pszEnum = paEnums->pszString; 453 break; 454 } 455 paEnums++; 456 } 457 458 RT_NOREF(cBits); 459 if (fFlags & RTTRACELOG_DECODER_HLP_STRUCT_BLD_F_HEX) 460 RTPrintf("%*s%-16s 0x%0*RX64 (%s)\n", pDecoder->cStructNesting * 4, "", pszName, cBits / 4, u64Val, pszEnum); 461 else 462 RTPrintf("%*s%-16s %RU64 (%s)\n", pDecoder->cStructNesting * 4, "", pszName, u64Val, pszEnum); 463 return VINF_SUCCESS; 464 } 465 466 467 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldArrayBegin(PRTTRACELOGDECODERHLP pHlp, const char *pszName) 468 { 469 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 470 471 RTPrintf("%*s%-16s [", pDecoder->cStructNesting * 4, "", pszName); 472 Assert(!pDecoder->cArrayNesting); 473 pDecoder->cArrayNesting++; 474 return VINF_SUCCESS; 475 } 476 477 478 static DECLCALLBACK(int) rtTraceLogToolDecoderHlpStructBldArrayEnd(PRTTRACELOGDECODERHLP pHlp) 479 { 480 PRTTRACELOGDECODER pDecoder = RT_FROM_MEMBER(pHlp, RTTRACELOGDECODER, Hlp); 481 RTPrintf(" ]\n"); 482 Assert(pDecoder->cArrayNesting > 0); 483 pDecoder->cArrayNesting--; 484 return VINF_SUCCESS; 485 } 486 487 279 488 static DECLCALLBACK(int) rtTraceLogToolRegisterDecoders(void *pvUser, PCRTTRACELOGDECODERREG paDecoders, uint32_t cDecoders) 280 489 { … … 299 508 pDecoder->pvDecoderState = NULL; 300 509 pDecoder->pfnDecoderStateFree = NULL; 510 pDecoder->cStructNesting = 0; 511 pDecoder->cArrayNesting = 0; 301 512 pDecoder->Hlp.pfnPrintf = rtTraceLogToolDecoderHlpPrintf; 302 513 pDecoder->Hlp.pfnErrorMsg = rtTraceLogToolDecoderHlpErrorMsg; … … 304 515 pDecoder->Hlp.pfnDecoderStateDestroy = rtTraceLogToolDecoderHlpStateDestroy; 305 516 pDecoder->Hlp.pfnDecoderStateGet = rtTraceLogToolDecoderHlpStateGet; 517 pDecoder->Hlp.pfnStructBldBegin = rtTraceLogToolDecoderHlpStructBldBegin; 518 pDecoder->Hlp.pfnStructBldEnd = rtTraceLogToolDecoderHlpStructBldEnd; 519 pDecoder->Hlp.pfnStructBldAddBool = rtTraceLogToolDecoderHlpStructBldAddBool; 520 pDecoder->Hlp.pfnStructBldAddU8 = rtTraceLogToolDecoderHlpStructBldAddU8; 521 pDecoder->Hlp.pfnStructBldAddU16 = rtTraceLogToolDecoderHlpStructBldAddU16; 522 pDecoder->Hlp.pfnStructBldAddU32 = rtTraceLogToolDecoderHlpStructBldAddU32; 523 pDecoder->Hlp.pfnStructBldAddU64 = rtTraceLogToolDecoderHlpStructBldAddU64; 524 pDecoder->Hlp.pfnStructBldAddS8 = rtTraceLogToolDecoderHlpStructBldAddS8; 525 pDecoder->Hlp.pfnStructBldAddS16 = rtTraceLogToolDecoderHlpStructBldAddS16; 526 pDecoder->Hlp.pfnStructBldAddS32 = rtTraceLogToolDecoderHlpStructBldAddS32; 527 pDecoder->Hlp.pfnStructBldAddS64 = rtTraceLogToolDecoderHlpStructBldAddS64; 528 pDecoder->Hlp.pfnStructBldAddStr = rtTraceLogToolDecoderHlpStructBldAddStr; 529 pDecoder->Hlp.pfnStructBldAddBuf = rtTraceLogToolDecoderHlpStructBldAddBuf; 530 pDecoder->Hlp.pfnStructBldAddEnum = rtTraceLogToolDecoderHlpStructBldAddEnum; 531 pDecoder->Hlp.pfnStructBldArrayBegin = rtTraceLogToolDecoderHlpStructBldArrayBegin; 532 pDecoder->Hlp.pfnStructBldArrayEnd = rtTraceLogToolDecoderHlpStructBldArrayEnd; 306 533 } 307 534 … … 470 697 || cVals != pEvtDesc->cEvtItems) 471 698 { 699 pDecoder->cStructNesting = 0; 700 pDecoder->cArrayNesting = 0; 472 701 rc = pDecoder->pReg->pfnDecode(&pDecoder->Hlp, pDecodeEvt->idDecodeEvt, hTraceLogEvt, 473 702 pEvtDesc, &aVals[0], cVals);
Note:
See TracChangeset
for help on using the changeset viewer.

