@@ -219,13 +219,70 @@ int mambo_register_function_cb(mambo_context *ctx, char *fn_name,
219
219
mambo_callback cb_pre , mambo_callback cb_post , int max_args );
220
220
221
221
/* Memory management */
222
+ /**
223
+ * @brief A wrapper of mmap to allocate memory space optimised to support the
224
+ * DBM use case.
225
+ *
226
+ * An mmap wrapper that allocates private to MAMBO memory space with read/write
227
+ * permissions.
228
+ *
229
+ * @param ctx The context that holds the plugin state. Currently unused.
230
+ * @param size The allocation size requested. Will round up to a multiple of
231
+ * page size due to calling mmap.
232
+ * @return Pointer to the mapped area or @c (void*)-1 on error.
233
+ */
222
234
void * mambo_alloc (mambo_context * ctx , size_t size );
235
+
236
+ /**
237
+ * @brief Frees memory space pointed by @c ptr which must have been returned by a
238
+ * previous call to mambo_alloc.
239
+ *
240
+ * Currently this function is just and empty wrapper.
241
+ *
242
+ * @param ctx The context that holds the plugin state. Currently unused.
243
+ * @param ptr Pointer to memory space requested for freeing. Currently unused.
244
+ */
223
245
void mambo_free (mambo_context * ctx , void * ptr );
224
246
225
247
/* Access plugin data */
248
+ /**
249
+ * @brief Stores an address holding data to a global structure, making data
250
+ * accessible between callbacks of all threads running in MAMBO.
251
+ *
252
+ * @param ctx The context that holds the plugin state.
253
+ * @param data Pointer to the address where data will be stored.
254
+ * @return MAMBO_SUCCESS on success or MAMBO_INVALID_PLUGIN_ID on error.
255
+ */
226
256
int mambo_set_plugin_data (mambo_context * ctx , void * data );
257
+
258
+ /**
259
+ * @brief Retrieves an address holding data from a global structure accessible
260
+ * between callbacks of all threads running in MAMBO.
261
+ *
262
+ * @param ctx The context that holds the plugin state.
263
+ * @return Pointer to the address holding the data.
264
+ */
227
265
void * mambo_get_plugin_data (mambo_context * ctx );
266
+
267
+ /**
268
+ * @brief Stores an address holding data to a structure allocated in the calling
269
+ * thread, making data accessible between callbacks of that thread running in
270
+ * MAMBO.
271
+ *
272
+ * @param ctx The context that holds the plugin state.
273
+ * @param data Pointer to the address where data will be stored.
274
+ * @return MAMBO_SUCCESS on success, or MAMBO_INVALID_PLUGIN_ID or
275
+ * MAMBO_INVALID_THREAD on error.
276
+ */
228
277
int mambo_set_thread_plugin_data (mambo_context * ctx , void * data );
278
+
279
+ /**
280
+ * @brief Retrieves an address holding data to a structure allocated in the
281
+ * calling thread, accessible between its callbacks running in MAMBO.
282
+ *
283
+ * @param ctx The context that holds the plugin state.
284
+ * @return Pointer to the address holding the data.
285
+ */
229
286
void * mambo_get_thread_plugin_data (mambo_context * ctx );
230
287
231
288
/* Scratch register management */
@@ -298,6 +355,21 @@ int mambo_reserve_cc_space(mambo_context *ctx, size_t size);
298
355
mambo_branch_type mambo_get_branch_type (mambo_context * ctx );
299
356
300
357
/* Symbol-related functions */
358
+
359
+ /**
360
+ * @brief Uses the untranslated address of the application's instruction to
361
+ * return the symbol name, the starting address of the symbol name and the
362
+ * filename that this instruction belongs to.
363
+ *
364
+ * @param addr The untranslated address of the application's instruction.
365
+ * @param sym_name Pointer to the pointer to the address where the symbol name
366
+ * will be stored.
367
+ * @param start_addr Pointer to the pointer to the address where the starting
368
+ * address of the symbol name will be stored.
369
+ * @param filename Pointer to the pointer to the address where the filename will
370
+ * be stored.
371
+ * @return 0 on success or -1 on error.
372
+ */
301
373
int get_symbol_info_by_addr (uintptr_t addr , char * * sym_name , void * * start_addr , char * * filename );
302
374
typedef int (* stack_frame_handler )(void * data , void * addr , char * sym_name , void * symbol_start_addr , char * filename );
303
375
int get_backtrace (stack_frame_t * fp , stack_frame_handler handler , void * ptr );
0 commit comments