// SPDX-License-Identifier: MPL-2.0 #ifndef SH_LIB_PEZ_DEBUG_H #define SH_LIB_PEZ_DEBUG_H #include "std/type.h" #include "std/status.h" #define SH_PEZ_DEBUG_ALLOC_HEADER 0 #define SH_PEZ_DEBUG_FREE_HEADER 1 #define SH_PEZ_DEBUG_SIZE_LIST_HEADER 2 #define SH_PEZ_DEBUG_BOUNDARY_RADIX_HEADER 3 #define SH_PEZ_DEBUG_BITMAP_REGIONS_HEADER 4 #define SH_PEZ_DEBUG_SIZE_LIST_BLOCK_HEADER 5 // Struct for Pez alloc #pragma pack(1) typedef struct { sh_uint32 size_asked; sh_uint32 found_region_start_index; sh_uint32 found_region_size; sh_bool is_exact_fit; sh_uint32 remaining_size; sh_uint32 new_start; sh_uint32 reg_idx; } sh_pez_debug_ALLOC; #pragma pack() // Struct for Pez free #pragma pack(1) typedef struct { sh_uint32 region_start_freeed; sh_uint32 size_freeed; sh_uint32 left_region_idx; sh_uint32 right_region_idx; sh_uint32 left_region_size; sh_uint32 right_region_size; sh_uint32 left_region_start; sh_uint32 right_region_start; sh_uint32 final_inserted_region_idx; sh_uint32 final_inserted_region_start; sh_uint32 final_inserted_region_size; sh_bool was_right_region_object_freeed; sh_bool was_new_region_object_allocated; sh_uint32 new_reg_obj_start; sh_uint32 new_reg_obj_size; } sh_pez_debug_FREE; #pragma pack() // Struct for Pez regions from size list #pragma pack(1) typedef struct { sh_uint32 start; sh_uint32 size; sh_uint32 idx; sh_uint32 next_idx; } sh_pez_debug_REGION_SIZE_LIST; #pragma pack() // Struct for Pez size list #pragma pack(1) typedef struct { sh_uint32 size; sh_uint32 count; sh_pez_debug_REGION_SIZE_LIST regions[512]; } sh_pez_debug_SIZE_LIST; #pragma pack() // Struct for Pez region from boundary #pragma pack(1) typedef struct { sh_uint32 pos_start; sh_uint32 idx_start; sh_uint32 prev_start; sh_uint32 pos_end; sh_uint32 idx_end; sh_uint32 prev_end; } sh_pez_debug_REGION_BOUNDARY; #pragma pack() // Struct for Pez boundary radix #pragma pack(1) typedef struct { sh_uint32 count; sh_pez_debug_REGION_BOUNDARY regions[512]; } sh_pez_debug_BOUNDARY_RADIX; #pragma pack() // Struct for Pez regions from bitmap #pragma pack(1) typedef struct { sh_uint32 start; sh_uint32 size; } sh_pez_debug_REGION_BITMAP; #pragma pack() // Struct for Pez bitmap #pragma pack(1) typedef struct { sh_uint32 count; sh_pez_debug_REGION_BITMAP regions[512]; } sh_pez_debug_BITMAP; #pragma pack() #endif // Send an alloc payload SH_STATUS sh_pez_debug_send_alloc(sh_pez_debug_ALLOC *alloc); // Send a free payload SH_STATUS sh_pez_debug_send_free(sh_pez_debug_FREE *free); // Send a size list payload. Sending size list radix header must be done prior to any size list being send. It consist of SH_PEZ_DEBUG_SIZE_LIST_BLOCK_HEADER and the count of sizes list SH_STATUS sh_pez_debug_send_size_list(sh_pez_debug_SIZE_LIST *size_list); // Send a boundary radix payload SH_STATUS sh_pez_debug_send_boundary_radix(sh_pez_debug_BOUNDARY_RADIX *boundary_radix); // Send a bitmap payload SH_STATUS sh_pez_debug_send_bitmap(sh_pez_debug_BITMAP *bitmap);