@@ -358,7 +358,7 @@ enum class payload_flag_t {
358
358
//
359
359
using trace_point_t = uint16_t ;
360
360
using event_type_t = uint16_t ;
361
- using string_id_t = int32_t ;
361
+ using string_id_t = uint32_t ;
362
362
using object_id_t = int32_t ;
363
363
364
364
using safe_flag_t = std::atomic<bool >;
@@ -455,60 +455,105 @@ struct payload_t {
455
455
456
456
payload_t () = default ;
457
457
458
- // If the address of the kernel/function name is provided, we mark it as
459
- // valid since we can potentially reconstruct the name and the source file
460
- // information during post-processing step of symbol resolution; this
461
- // indicates a partial but valid payload.
458
+ // /
459
+ // / @brief Constructs a payload_t with only a code pointer.
460
+ // /
461
+ // / @details
462
+ // / Initializes the payload with the provided code pointer address. All other
463
+ // / fields (name, source file, line number, column number) are set to invalid
464
+ // / or null values. If a valid code pointer is provided, the corresponding
465
+ // / flag is set to indicate its availability.
466
+ // /
467
+ // / If the address of the kernel/function name is provided, we mark it as
468
+ // / valid since we can potentially reconstruct the name and the source file
469
+ // / information during post-processing step of symbol resolution; this
470
+ // / indicates a partial but valid payload.
471
+ // /
472
+ // / @param codeptr Pointer to the code location associated with this payload.
473
+ // /
462
474
payload_t (const void *codeptr) {
463
- code_ptr_va = codeptr;
464
- name = nullptr ; // /< Invalid name string pointer
465
- source_file = nullptr ; // /< Invalid source file string pointer
466
- line_no = invalid_id<>; // /< Invalid line number
467
- column_no = invalid_id<>; // /< Invalid column number
475
+ code_ptr_va = codeptr; // /< Override the default initialization
476
+ // If the incoming code ptr is null, we ensure that the flags are set
477
+ // correctly
468
478
if (codeptr) {
469
479
flags = (uint64_t )payload_flag_t ::CodePointerAvailable;
470
480
}
471
481
}
472
482
473
- // If neither an address or the fully identifyable source file name and
474
- // location are not available, we take in the name of the
475
- // function/task/user-defined name as input and create a hash from it. We
476
- // mark it as valid since we can display the name in a timeline view, but
477
- // the payload is considered to be a partial but valid payload.
483
+ // /
484
+ // / @brief Constructs a payload_t with only a function or kernel name.
485
+ // /
486
+ // / @details
487
+ // / Initializes the payload with the provided function or kernel name.
488
+ // / If neither an address or the fully identifyable source file name and
489
+ // / location are not available, we take in the name of the
490
+ // / function/task/user-defined name as input and create a hash from it. We
491
+ // / mark it as valid since we can display the name in a timeline view, but
492
+ // / the payload is considered to be a partial but valid payload.
493
+ // /
494
+ // / @param func_name Name of the function, kernel, or user-defined entity.
495
+ // /
478
496
payload_t (const char *func_name) {
479
- code_ptr_va = nullptr ;
480
- name = func_name; // /< Invalid name string pointer
481
- source_file = nullptr ; // /< Invalid source file string pointer
497
+ name = func_name; // /< Override the default initialization
498
+ // If the incoming name is null, we ensure that the flags are set correctly
482
499
if (func_name) {
483
500
flags = (uint64_t )(payload_flag_t ::NameAvailable);
484
501
}
485
502
}
486
503
504
+ // /
505
+ // / @brief Constructs a payload_t with a function or kernel name and code
506
+ // / pointer.
507
+ // /
508
+ // / @details
509
+ // / Initializes the payload with the provided function or kernel name and code
510
+ // / pointer. The source file is set to null. Flags are set to indicate which
511
+ // / fields are available. The payload is considered partial, but valid.
512
+ // /
513
+ // / @param func_name Name of the function, kernel, or user-defined entity.
514
+ // / @param codeptr Pointer to the code location associated with this payload.
515
+ // /
487
516
payload_t (const char *func_name, const void *codeptr) {
488
- code_ptr_va = codeptr;
489
- name = func_name; // /< Invalid name string pointer
490
- source_file = nullptr ; // /< Invalid source file string pointer
517
+ code_ptr_va = codeptr; // /< Override the default initialization
518
+ name = func_name; // /< Override the default initialization
519
+ // If the incoming name is null, we ensure that the flags are set correctly
491
520
if (func_name) {
492
521
flags = (uint64_t )(payload_flag_t ::NameAvailable);
493
522
}
523
+ // If the incoming code ptr is null, we ensure that the flags are set
524
+ // correctly
494
525
if (codeptr) {
495
526
flags |= (uint64_t )payload_flag_t ::CodePointerAvailable;
496
527
}
497
528
}
498
529
499
- // When the end user opts out of preserving the code location information and
500
- // the KernelInfo is not available from the given entry point, we will rely
501
- // on dynamic backtrace as a possibility. In this case, we send in the
502
- // caller/callee information as a string in the form "caller->callee" that
503
- // will be used to generate the unique ID.
530
+ // /
531
+ // / @brief Constructs a payload_t with a name, stack trace, and code pointer.
532
+ // /
533
+ // / @details
534
+ // / Used when code location information is not preserved and dynamic backtrace
535
+ // / is used. Initializes the payload with the provided kernel name,
536
+ // / caller-callee stack trace, and code pointer. Sets flags to indicate which
537
+ // / fields are available.
538
+ // /
539
+ // / When the end user opts out of preserving the code location information and
540
+ // / the KernelInfo is not available from the given entry point, we will rely
541
+ // / on dynamic backtrace as a possibility. In this case, we send in the
542
+ // / caller/callee information as a string in the form "caller->callee" that
543
+ // / will be used to generate the unique ID.
544
+ // /
545
+ // / @param kname Name of the kernel or function.
546
+ // / @param caller_callee String representing the caller->callee relationship.
547
+ // / @param codeptr Pointer to the code location associated with this payload.
548
+ // /
504
549
payload_t (const char *kname, const char *caller_callee, const void *codeptr) {
505
550
if (codeptr) {
506
- code_ptr_va = codeptr;
551
+ code_ptr_va = codeptr; // /< Override the default initialization
507
552
flags |= (uint64_t )payload_flag_t ::CodePointerAvailable;
508
553
}
509
- // / Capture the rest of the parameters
554
+ // If the incoming name is null, we ensure that the flags are set correctly
510
555
if (kname) {
511
- name = kname;
556
+ name = kname; // /< Override the default initialization
512
557
flags |= (uint64_t )payload_flag_t ::NameAvailable;
513
558
}
514
559
if (caller_callee) {
@@ -517,34 +562,69 @@ struct payload_t {
517
562
}
518
563
}
519
564
520
- // We need the payload to contain at the very least, the code pointer
521
- // information of the kernel or function. In the full payload case, we will
522
- // also have the function name and source file name along with the line and
523
- // column number of the trace point that forms the payload.
565
+ // /
566
+ // / @brief Constructs a fully populated payload_t.
567
+ // /
568
+ // / @details
569
+ // / Initializes the payload with the provided kernel name, source file, line
570
+ // / number, column number, and optionally a code pointer. Sets flags to
571
+ // / indicate which fields are available. This would constitute a fully
572
+ // / populated payload.
573
+ // /
574
+ // / @param kname Name of the kernel or function.
575
+ // / @param sf Source file name.
576
+ // / @param line Line number in the source file.
577
+ // / @param col Column number in the source file.
578
+ // / @param codeptr (Optional) Pointer to the code location associated with
579
+ // / this payload.
580
+ // /
524
581
payload_t (const char *kname, const char *sf, int line, int col,
525
582
const void *codeptr = nullptr ) {
526
- code_ptr_va = codeptr;
527
- // / Capture the rest of the parameters
528
- name = kname;
529
- source_file = sf;
530
- line_no = static_cast <uint32_t >(line);
531
- column_no = static_cast <uint32_t >(col);
583
+ code_ptr_va = codeptr; // /< Override the default initialization
584
+ name = kname; // /< Override the default initialization
585
+ source_file = sf; // /< Override the default initialization
586
+ line_no =
587
+ static_cast <uint32_t >(line); // /< Override the default initialization
588
+ column_no =
589
+ static_cast <uint32_t >(col); // /< Override the default initialization
590
+ // If the incoming name is null, we ensure that the flags are set correctly
532
591
if (kname && kname[0 ] != ' \0 ' ) {
533
592
flags = (uint64_t )payload_flag_t ::NameAvailable;
534
593
}
594
+ // If the incoming source file name is null, we ensure that the flags are
595
+ // set correctly
535
596
if (sf && sf[0 ] != ' \0 ' ) {
536
597
flags |= (uint64_t )payload_flag_t ::SourceFileAvailable |
537
598
(uint64_t )payload_flag_t ::LineInfoAvailable |
538
599
(uint64_t )payload_flag_t ::ColumnInfoAvailable;
539
600
}
601
+ // If the incoming code ptr is null, we ensure that the flags are set
602
+ // correctly
540
603
if (codeptr) {
541
604
flags |= (uint64_t )payload_flag_t ::CodePointerAvailable;
542
605
}
543
606
}
544
607
545
- int32_t name_sid () const { return (int32_t )(uid.p2 & 0x00000000ffffffff ); }
546
- int32_t stacktrace_sid () const { return (int32_t )(uid.p2 >> 32 ); }
547
- int32_t source_file_sid () const { return (int32_t )(uid.p1 >> 32 ); }
608
+ // / @brief Retrieves the string ID (SID) for the name.
609
+ // / @details Extracts the lower 32 bits of the uid.p2 member, which represents
610
+ // / the xpti::string_id_t in legacy implementations or XPTI_USE_STRICT_HASH
611
+ // / mode and contains the FNV1a hash value associated with the name.
612
+ // / @return The 32-bit name string ID.
613
+ uint32_t name_sid () const { return (uint32_t )(uid.p2 & 0x00000000ffffffff ); }
614
+
615
+ // / @brief Retrieves the string ID (SID) for the stack trace.
616
+ // / @details Extracts the upper 32 bits of the uid.p2 member, which represents
617
+ // / the xpti::string_id_t in legacy implementations or XPTI_USE_STRICT_HASH
618
+ // / mode and contains the FNV1a hash value associated with the stack trace.
619
+ // / @return The 32-bit stack trace string ID.
620
+ uint32_t stacktrace_sid () const { return (uint32_t )(uid.p2 >> 32 ); }
621
+
622
+ // / @brief Retrieves the string ID (SID) for the source file.
623
+ // / @details Extracts the upper 32 bits of the uid.p1 member, which represents
624
+ // / the xpti::string_id_t in legacy implementations or XPTI_USE_STRICT_HASH
625
+ // / mode and contains the FNV1a hash value associated with the source file.
626
+ // / @return The 32-bit source file string ID.
627
+ uint32_t source_file_sid () const { return (uint32_t )(uid.p1 >> 32 ); }
548
628
};
549
629
550
630
// / A data structure that holds information about an API function call and its
0 commit comments