haide frame storage from user and introduce separate method

pst_get_register() to obtain register value within function's stack
frame
This commit is contained in:
2020-05-02 13:51:31 +04:00
parent 1825515ca0
commit d1441b3b6f
6 changed files with 33 additions and 9 deletions
+13 -1
View File
@@ -11,6 +11,18 @@
#include <stdint.h>
#include <libunwind.h>
/// @brief bitmask of function's options
typedef enum {
FUNC_GLOBAL = 0x00000001, ///< function has global visibility
FUNC_LOCAL = 0x00000002, ///< function has local visibility
IS_MEMBER_OF = 0x00000004, ///< function is member of class
IS_INLINED = 0x00000008, ///< function was inlined
IS_PRIVATE = 0x00000010, ///< private member of class
IS_PROTECTED = 0x00000020, ///< protected member of class
IS_PUBLIC = 0x00000040, ///< public member of class
} pst_fun_flags;
typedef struct {
char* name; ///< demangled name of the function. NULL if function name resolution failed
char* file; ///< file name where the function is defined. NULL if library failed to get file name
@@ -20,7 +32,7 @@ typedef struct {
unw_word_t highpc; ///< offset to the next address after the end of the function against base address
unw_word_t sp; ///< SP register in function's frame
unw_word_t cfa; ///< CFA (Canonical Frame Address) of the function. !!! Don't use CFA provided by libunwind, it's not valid !!!
unw_cursor_t context;///< Function's frame including register's values
pst_fun_flags flags; ///< flags of various function options
} pst_function_info;
/// @brief bitmask of parameter's options
+9
View File
@@ -74,6 +74,15 @@ const pst_function* pst_function_next(pst_handler* handler, pst_function* curren
*/
const pst_function_info* pst_get_function_info(pst_function* function);
/**
* @brief Get value of CPU register in function's frame
* @param function function's handler obtained by pst_get_next_function()
* @param regno index of register
* @param val pointer to store register's value
* @return zero on success, UNW_EUNSPEC in case of unspecified error, UNW_EBADREG - register that is either invalid or not accessible in the current frame
*/
int pst_get_register(pst_function* function, int regno, unw_word_t* val);
/**
* @brief Get next parameter's handle in function
* @param function Function's handler obtained by pst_get_next_function()