@@ -46,15 +46,24 @@ typedef struct typeart_struct_layout_t { // NOLINT
4646 const size_t * count ;
4747} typeart_struct_layout ;
4848
49+ typedef struct typeart_base_type_info_t {
50+ const void * address ;
51+ int type_id ;
52+ size_t count ;
53+ } typeart_base_type_info ;
54+
55+ typedef struct typeart_type_info_t {
56+ const void * address ;
57+ int type_id ;
58+ size_t count ;
59+ typeart_base_type_info base_type_info ; // API dependent
60+ } typeart_type_info ;
61+
4962/**
5063 * Determines the type and array element count at the given address.
5164 * For nested types with classes/structs, the containing type is resolved recursively, until an exact with the address
5265 * is found.
53- * See typeart_get_type_length and typeart_get_type_id for resolving only one such parameter
54- *
55- * Note that this function will always return the outermost type lining up with the address.
56- * Given a pointer to the start of a struct, the returned type will therefore be that of the struct, not of the first
57- * member.
66+ * base_type_info is the outermost type and array element count at the given address.
5867 *
5968 * Code example:
6069 * {
@@ -68,20 +77,15 @@ typedef struct typeart_struct_layout_t { // NOLINT
6877 * }
6978 *
7079 * \param[in] addr The address.
71- * \param[out] type_id Type ID
72- * \param[out] count Allocation size
80+ * \param[out] base_type allocation info at the address addr. The address equals [in] param addr.
7381 *
7482 * \return A status code:
7583 * - TYPEART_OK: The query was successful and the contents of type and count are valid.
7684 * - TYPEART_UNKNOWN_ADDRESS: The given address is either not allocated, or was not correctly recorded by the runtime.
7785 * - TYPEART_BAD_ALIGNMENT: The given address does not line up with the start of the atomic type at that location.
7886 * - TYPEART_INVALID_ID: Encountered unregistered ID during lookup.
7987 */
80- typeart_status typeart_get_type (const void * addr , int * type_id , size_t * count );
81-
82- typeart_status typeart_get_type_length (const void * addr , size_t * count );
83-
84- typeart_status typeart_get_type_id (const void * addr , int * type_id );
88+ typeart_status typeart_get_type (const void * addr , typeart_type_info * type_info );
8589
8690/**
8791 * Determines the outermost type and array element count at the given address.
@@ -117,17 +121,18 @@ typeart_status typeart_get_type_id(const void* addr, int* type_id);
117121 * to &data[0])
118122 * }
119123 *
120- * \param[in] addr The address.
121- * \param[out] type_id Type ID of the containing type
122- * \param[out] count Number of elements in the containing buffer, not counting elements before the given address.
123- * \param[out] base_address Address of the containing buffer.
124+ * \param[in] type The result of a `typeart_get_type` call on some address.
125+ * \param[out] containing_type Type information of the containing type.
124126 * \param[out] byte_offset The byte offset within that buffer element.
125127 *
126128 * \return A status code.
127129 * - TYPEART_OK: The query was successful.
128130 * - TYPEART_UNKNOWN_ADDRESS: The given address is either not allocated, or was not correctly recorded by the runtime.
129131 */
130- typeart_status typeart_get_containing_type (const void * addr , int * type_id , size_t * count , const void * * base_address ,
132+ // typeart_status typeart_get_containing_type(const void* addr, int* type_id, size_t* count, const void** base_address,
133+ // size_t* byte_offset);
134+
135+ typeart_status typeart_get_containing_type (typeart_type_info type_info , typeart_base_type_info * containing_type ,
131136 size_t * byte_offset );
132137
133138/**
@@ -156,24 +161,20 @@ typeart_status typeart_get_containing_type(const void* addr, int* type_id, size_
156161 * -> subtype_count: 1 (length of member float[2] at offset 20)
157162 * }
158163 *
164+ * \param[in] container_layout typeart_struct_layout corresponding to the containing type
159165 * \param[in] baseAddr Pointer to the start of the containing type.
160166 * \param[in] offset Byte offset within the containing type.
161- * \param[in] container_layout typeart_struct_layout corresponding to the containing type
162- * \param[out] subtype_id The type ID corresponding to the subtype.
163- * \param[out] subtype_base_addr Pointer to the start of the subtype.
167+ * \param[out] subtype_info The type container to the subtype.
164168 * \param[out] subtype_byte_offset Byte offset within the subtype.
165- * \param[out] subtype_count Number of elements in subarray.
166169 *
167170 * \return One of the following status codes:
168171 * - TYPEART_OK: Success.
169172 * - TYPEART_BAD_ALIGNMENT: Address corresponds to location inside an atomic type or padding.
170173 * - TYPEART_BAD_OFFSET: The provided offset is invalid.
171174 * - TYPEART_ERROR: The typeart_struct_layout is invalid.
172175 */
173- typeart_status typeart_get_subtype (const void * base_addr , size_t offset , const typeart_struct_layout * container_layout ,
174- int * subtype_id , const void * * subtype_base_addr , size_t * subtype_byte_offset ,
175- size_t * subtype_count );
176-
176+ typeart_status typeart_get_subtype (const typeart_struct_layout * container_layout , const void * base_addr , size_t offset ,
177+ typeart_base_type_info * subtype_info , size_t * subtype_byte_offset );
177178/**
178179 * Returns the stored debug address generated by __builtin_return_address(0).
179180 *
@@ -204,22 +205,6 @@ typeart_status typeart_get_return_address(const void* addr, const void** return_
204205 */
205206typeart_status typeart_get_source_location (const void * addr , char * * file , char * * function , char * * line );
206207
207- /**
208- * Given an address, this function provides information about the corresponding struct type.
209- * This is more expensive than the below version, since the pointer addr must be resolved.
210- *
211- * \param[in] addr The pointer address
212- * \param[out] struct_layout Data layout of the struct.
213- *
214- * \return One of the following status codes:
215- * - TYPEART_OK: Success.
216- * - TYPEART_WRONG_KIND: ID does not correspond to a struct type.
217- * - TYPEART_UNKNOWN_ADDRESS: The given address is either not allocated, or was not correctly recorded by the runtime.
218- * - TYPEART_BAD_ALIGNMENT: The given address does not line up with the start of the atomic type at that location.
219- * - TYPEART_INVALID_ID: Encountered unregistered ID during lookup.
220- */
221- typeart_status typeart_resolve_type_addr (const void * addr , typeart_struct_layout * struct_layout );
222-
223208/**
224209 * Given a type ID, this function provides information about the corresponding struct type.
225210 *
0 commit comments