@@ -1837,3 +1837,52 @@ int _odp_ishm_status(const char *title)
odp_spinlock_unlock(&ishm_tbl->lock);
return nb_blocks;
}
+
+void _odp_ishm_print(int block_index)
+{
+ ishm_block_t *block;
+ const char *str;
+
+ odp_spinlock_lock(&ishm_tbl->lock);
+
+ if ((block_index < 0) ||
+ (block_index >= ISHM_MAX_NB_BLOCKS) ||
+ (ishm_tbl->block[block_index].len == 0)) {
+ odp_spinlock_unlock(&ishm_tbl->lock);
+ ODP_ERR("Request for info on an invalid block\n");
+ return;
+ }
+
+ block = &ishm_tbl->block[block_index];
+
+ ODP_PRINT("\nSHM block info\n--------------\n");
+ ODP_PRINT(" name: %s\n", block->name);
+ ODP_PRINT(" file: %s\n", block->filename);
+ ODP_PRINT(" expt: %s\n", block->exptname);
+ ODP_PRINT(" user_flags: 0x%x\n", block->user_flags);
+ ODP_PRINT(" flags: 0x%x\n", block->flags);
+ ODP_PRINT(" user_len: %lu\n", block->user_len);
+ ODP_PRINT(" start: %p\n", block->start);
+ ODP_PRINT(" len: %lu\n", block->len);
+
+ switch (block->huge) {
+ case HUGE:
+ str = "huge";
+ break;
+ case NORMAL:
+ str = "normal";
+ break;
+ case EXTERNAL:
+ str = "external";
+ break;
+ default:
+ str = "??";
+ }
+
+ ODP_PRINT(" page type: %s\n", str);
+ ODP_PRINT(" seq: %lu\n", block->seq);
+ ODP_PRINT(" refcnt: %lu\n", block->refcnt);
+ ODP_PRINT("\n");
+
+ odp_spinlock_unlock(&ishm_tbl->lock);
+}
@@ -45,6 +45,7 @@ void *_odp_ishm_address(int block_index);
int _odp_ishm_info(int block_index, _odp_ishm_info_t *info);
int _odp_ishm_status(const char *title);
int _odp_ishm_cleanup_files(const char *dirpath);
+void _odp_ishm_print(int block_index);
#ifdef __cplusplus
}
@@ -116,6 +116,11 @@ void odp_shm_print_all(void)
_odp_ishm_status("Memory allocation status:");
}
+void odp_shm_print(odp_shm_t shm)
+{
+ _odp_ishm_print(from_handle(shm));
+}
+
uint64_t odp_shm_to_u64(odp_shm_t hdl)
{
return _odp_pri(hdl);
@@ -152,6 +152,8 @@ void shmem_test_basic(void)
odp_cunit_thread_create(run_test_basic_thread, &thrdarg);
CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0);
+ odp_shm_print(shm);
+
CU_ASSERT(0 == odp_shm_free(shm));
}