extend to user types of parameter and initialize them. introduce

'typename' to parameter_info, it's C/C++ name of parameter type. rewrite
parameter printing using new capabilities.
This commit is contained in:
2020-04-16 18:56:40 +04:00
parent f9f26f5f7d
commit c7e9925efe
3 changed files with 126 additions and 55 deletions
+35 -10
View File
@@ -11,24 +11,49 @@
#include <stdint.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
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
int line; ///< line of definition of the function. -1 if library failed to get file line
unw_word_t pc; ///< address between LowPC & HighPC (plus base address offset). actually, address of currently executed command in function
} pst_function_info;
/// @brief bitmask of parameter options
typedef enum {
PARAM_RETURN = 1, ///< parameter is return value of a function
PARAM_VARIABLE = 2, ///< parameter is variable inside of a function
PARAM_HAS_VALUE = 4 ///< parameter has a valid value (if not set, then value is undefined)
// scope & access
PARAM_CONST = 0x00000001, ///< constant access
PARAM_GLOBAL = 0x00000002, ///< global scope
PARAM_STATIC = 0x00000004, ///< parameter defined as static
PARAM_RETURN = 0x00000008, ///< parameter is return value of a function
PARAM_VARIABLE = 0x00000010, ///< parameter is variable inside of a function
// validity
PARAM_HAS_VALUE = 0x00000020, ///< parameter has a valid value (if not set, then value is undefined)
PARAM_INVALID = 0x00000040, ///< library failed to dereference pointer
// base types
PARAM_TYPE_POINTER = 0x00000080, ///< pointer
PARAM_TYPE_INT = 0x00000100, ///< integer. to determine size of value, use 'size' field of parameter
PARAM_TYPE_UINT = 0x00000200, ///< unsigned integer. to determine size of value, use 'size' field of parameter
PARAM_TYPE_FLOAT = 0x00000400, ///< float
PARAM_TYPE_BOOL = 0x00000800, ///< boolean
PARAM_TYPE_VOID = 0x00001000, ///< void
PARAM_TYPE_CHAR = 0x00002000, ///< character
PARAM_TYPE_UCHAR = 0x00004000, ///< unsigned character
PARAM_TYPE_REF = 0x00008000, ///< reference
// complex types
PARAM_TYPE_ARRAY = 0x00010000, ///< array
PARAM_TYPE_STRUCT = 0x00020000, ///< structure
PARAM_TYPE_UNION = 0x00040000, ///< union
PARAM_TYPE_ENUM = 0x00080000, ///< enumeration
PARAM_TYPE_CLASS = 0x00100000, ///< class
PARAM_TYPE_TYPEDEF = 0x00200000, ///< type definition
} pst_param_flags;
typedef struct pst_parameter_info {
typedef struct {
char* name; ///< parameter's name
char* type_name; ///< name of parameter's type in case of 'PARAM_TYPE_TYPEDEF'
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
unw_word_t size; ///< size of parameter in bits
unw_word_t value; ///< value of parameter. use 'size' to determine number of actual bits of 'value'
pst_param_flags flags; ///< flags of various parameter's options
} pst_parameter_info;