I'm trying to generate HDF5 bindings from a Matlab Simulink/RTW C API.
Their API has several datastructures with the names, addresses, and types
of variables in memory.
Since their API exposes absolute addresses in memory, I thought I might
tell HDF5 about "the object starting at address 0". The essence of my
hid_t memtype=H5Tcreate(H5T_COMPOUND, SIZE_MAX);
H5Tinsert(memtype, name, (size_t)(address), htype);
H5Dwrite(dataset, memtype, memspace, filespace, H5P_DEFAULT, 0);
This fails with a runtime error.
HDF5-DIAG: Error detected in HDF5 (1.8.6) thread 0:
#000: H5Dio.c line 255 in H5Dwrite(): no output buffer
major: Invalid arguments to routine
minor: Bad value
Inspecting the code shows somebody put a check for my 0 to protect a file
transport I don't use... So try a different small number. New code.
hid_t memtype=H5Tcreate(H5T_COMPOUND, SIZE_MAX-4);
H5Tinsert(memtype, name, (size_t)(((char *)address)-4), htype);
H5Dwrite(dataset, memtype, memspace, filespace, H5P_DEFAULT, 4);
This segfaults deep in a memcpy in H5D_gather_mem. Yeah, can't memcpy the
whole memory space...
Any suggestions on how to describe a dataset when you only know absolute
addresses that may cover a wide chunk of memory? Do I really have to do
my own copies to a smaller data structure?