exprt next_function, next_parameter function_info, parameter_info to
external interface of the library
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* libpst-types.h
|
||||
*
|
||||
* Created on: Apr 5, 2020
|
||||
* Author: nnosov
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_LIBPST_TYPES_H_
|
||||
#define INCLUDE_LIBPST_TYPES_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libunwind.h>
|
||||
|
||||
typedef struct pst_function_info {
|
||||
char* name; ///< demangled name of the function
|
||||
char* file; ///< file name where the function is defined
|
||||
int line; ///< line of definition of the function
|
||||
unw_word_t pc; ///< address between LowPC & HighPC (plus base address offset). actually, address of currently executed command in function
|
||||
} pst_function_info;
|
||||
|
||||
typedef struct pst_parameter_info {
|
||||
char* name; ///< parameter's name
|
||||
uint32_t line; ///< line of parameter definition
|
||||
unw_word_t size; ///< size of parameter in bytes
|
||||
unw_word_t value; ///< value of parameter. currently only base types supported. use 'size' to determine number of actual bytes of value
|
||||
bool is_return; ///< whether this parameter is return value of the function
|
||||
bool is_variable; ///< whether this parameter is function variable or argument of function
|
||||
bool has_value; ///< whether we got value of parameter or not
|
||||
} pst_parameter_info;
|
||||
|
||||
#endif /* INCLUDE_LIBPST_TYPES_H_ */
|
||||
+35
-8
@@ -15,7 +15,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libpst-types.h"
|
||||
|
||||
typedef struct pst_handler pst_handler;
|
||||
typedef struct pst_function pst_function;
|
||||
typedef struct pst_parameter pst_parameter;
|
||||
|
||||
/**
|
||||
* @brief allocate libpst handler and initialize the library
|
||||
@@ -35,26 +39,49 @@ void pst_lib_fini(pst_handler* handler);
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup unwind_simple
|
||||
* @brief Unwinds current stack trace using base information about program (i.e. function address, function name and line)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup unwind_simple
|
||||
* @brief Save stack trace information to provided buffer in RAM
|
||||
* @param handler The handler obtained by pst_lib_init()
|
||||
* @return 1 on success, 0 on failure
|
||||
*/
|
||||
int pst_unwind_simple(pst_handler* handler);
|
||||
|
||||
/**
|
||||
* @ingroup unwind_simple
|
||||
* @brief Print unwound stack trace to internal buffer
|
||||
* @param handler The handler obtained by pst_lib_init()
|
||||
* @return pointer on zero terminated C string, NULL on failure
|
||||
* @return pointer to zero terminated C string, NULL on failure
|
||||
*/
|
||||
const char* pst_print_simple(pst_handler* handler);
|
||||
|
||||
/**
|
||||
* @brief Get next function handle in stack trace
|
||||
* @param handler The handler obtained by pst_lib_init()
|
||||
* @param current pointer to current function. NULL to get first
|
||||
* @return pointer to next function's handle, NULL in case of end of list
|
||||
*/
|
||||
const pst_function* pst_get_next_function(pst_handler* handler, pst_function* current);
|
||||
|
||||
/**
|
||||
* @brief Get function's information (name, address, line)
|
||||
* @param function Function's handle obtained by pst_get_next_function()
|
||||
* @return pointer to function's info
|
||||
*/
|
||||
const pst_function_info* pst_get_function_info(pst_function* function);
|
||||
|
||||
/**
|
||||
* @brief Get next parameter's handle in function
|
||||
* @param function Function's handler obtained by pst_get_next_function()
|
||||
* @param current pointer to current parameter. NULL to get first
|
||||
* @return pointer to next parameter's handle, NULL in case of end of list
|
||||
*/
|
||||
const pst_parameter* pst_get_next_parameter(pst_function* function, pst_parameter* current);
|
||||
|
||||
/**
|
||||
* @brief Get parameter's information (name, type, line etc)
|
||||
* @param parameter Parameter's handle obtained by pst_get_next_parameter()
|
||||
* @return pointer to parameter's info
|
||||
*/
|
||||
const pst_parameter_info* pst_get_parameter_info(pst_parameter* parameter);
|
||||
|
||||
//
|
||||
// Advanced unwind routines.
|
||||
// Additionally to pst_unwind_simple(...) provides types of parameters and variables in functions and their values if possible
|
||||
|
||||
Reference in New Issue
Block a user