From 3c7105eb970c58ec5589e795fd97aa426a54cd43 Mon Sep 17 00:00:00 2001 From: Nikolai Nosov Date: Wed, 5 Feb 2020 09:41:22 +0400 Subject: [PATCH] code hierarchy refactoring --- Makefile | 25 +++++++-------- framework/.gitignore | 2 -- framework/dwarf_handler.h => include/libpst.h | 19 ++++------- {framework => src}/Makefile | 6 ++-- {framework => src/arch}/registers.cpp | 1 - {framework => src/arch}/registers.h | 0 {framework => src}/common.cpp | 15 ++------- {framework => src}/common.h | 1 - {framework => src}/context.cpp | 3 +- {framework => src}/context.h | 4 +-- {framework => src/dwarf}/dwarf_call_site.cpp | 12 +++---- {framework => src/dwarf}/dwarf_call_site.h | 12 +++---- {framework => src/dwarf}/dwarf_expression.cpp | 5 +-- {framework => src/dwarf}/dwarf_expression.h | 10 +++--- {framework => src/dwarf}/dwarf_function.cpp | 7 ++-- {framework => src/dwarf}/dwarf_function.h | 14 ++++---- {framework => src/dwarf}/dwarf_handler.cpp | 13 +++++--- src/dwarf/dwarf_handler.h | 32 +++++++++++++++++++ {framework => src/dwarf}/dwarf_operations.cpp | 3 +- {framework => src/dwarf}/dwarf_operations.h | 4 +-- {framework => src/dwarf}/dwarf_parameter.cpp | 5 +-- {framework => src/dwarf}/dwarf_parameter.h | 10 +++--- {framework => src/dwarf}/dwarf_stack.cpp | 11 +++---- {framework => src/dwarf}/dwarf_stack.h | 10 +++--- {framework => src/dwarf}/dwarf_utils.cpp | 11 +++++++ {framework => src/dwarf}/dwarf_utils.h | 11 ++++--- {framework => src/utils}/allocator.cpp | 3 +- {framework => src/utils}/allocator.h | 0 {framework => src/utils}/hash_multimap.cpp | 3 +- {framework => src/utils}/hash_multimap.h | 2 +- {framework => src/utils}/list_head.h | 0 {framework/logger => src/utils}/log.cpp | 2 +- {framework/logger => src/utils}/log.h | 0 main.cpp => tests/main.cpp | 2 +- simple.cpp => tests/simple.cpp | 0 35 files changed, 145 insertions(+), 113 deletions(-) delete mode 100644 framework/.gitignore rename framework/dwarf_handler.h => include/libpst.h (72%) rename {framework => src}/Makefile (88%) rename {framework => src/arch}/registers.cpp (99%) rename {framework => src/arch}/registers.h (100%) rename {framework => src}/common.cpp (88%) rename {framework => src}/common.h (91%) rename {framework => src}/context.cpp (99%) rename {framework => src}/context.h (97%) rename {framework => src/dwarf}/dwarf_call_site.cpp (98%) rename {framework => src/dwarf}/dwarf_call_site.h (94%) rename {framework => src/dwarf}/dwarf_expression.cpp (97%) rename {framework => src/dwarf}/dwarf_expression.h (87%) rename {framework => src/dwarf}/dwarf_function.cpp (99%) rename {framework => src/dwarf}/dwarf_function.h (88%) rename {framework => src/dwarf}/dwarf_handler.cpp (97%) create mode 100644 src/dwarf/dwarf_handler.h rename {framework => src/dwarf}/dwarf_operations.cpp (99%) rename {framework => src/dwarf}/dwarf_operations.h (88%) rename {framework => src/dwarf}/dwarf_parameter.cpp (99%) rename {framework => src/dwarf}/dwarf_parameter.h (91%) rename {framework => src/dwarf}/dwarf_stack.cpp (98%) rename {framework => src/dwarf}/dwarf_stack.h (95%) rename {framework => src/dwarf}/dwarf_utils.cpp (88%) rename {framework => src/dwarf}/dwarf_utils.h (76%) rename {framework => src/utils}/allocator.cpp (97%) rename {framework => src/utils}/allocator.h (100%) rename {framework => src/utils}/hash_multimap.cpp (99%) rename {framework => src/utils}/hash_multimap.h (95%) rename {framework => src/utils}/list_head.h (100%) rename {framework/logger => src/utils}/log.cpp (99%) rename {framework/logger => src/utils}/log.h (100%) rename main.cpp => tests/main.cpp (99%) rename simple.cpp => tests/simple.cpp (100%) diff --git a/Makefile b/Makefile index fd2f4d9..dc19492 100644 --- a/Makefile +++ b/Makefile @@ -43,19 +43,16 @@ BIN = $(RESULT_DIR)/trace # ) #source file search path. add here new directories which contains files specified for $(SRC) -VPATH = ./ +VPATH = ./tests SRC = $(shell find . -name '*.cpp') #OBJ = $(patsubst %.cpp,%.o,$(addprefix $(BUILD_DIR)/,$(notdir $(SRC)))) OBJ = $(BUILD_DIR)/main.o -LIBS = -L./ -lpthread -luuid -ldl -ldw -lunwind -lunwind-x86_64 -lstdc++ -ATR_LIBS = ./build/libframework.a +LIBS = -L./ -lpthread -ldl -ldw -lunwind -lunwind-x86_64 -lstdc++ +PST_LIBS = ./build/libpst.a -INCS = -I./ \ --I/usr/include/postgresql -I /usr/include/libxml2 -I./thirdparty -I/opt/swifttest/include -I/usr/include/GraphicsMagick \ --I./framework -I./framework/swi -I./framework/utils -I./framework/rmq -I./framework/logger -I$(BUILD_DIR) -#FLAGS = -Wall -gdwarf-4 -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=c++11 +INCS = -I./include -I./src FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS @@ -63,12 +60,12 @@ FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_M all: $(BIN) -$(ATR_LIBS): - @make -C ./framework +$(PST_LIBS): + @make -C ./src clean: ${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h - @make clean -C ./framework + @make clean -C ./src @if [ -z "$$(ls -A $(BUILD_DIR) 2>&1)" ]; then ${RM} -r $(BUILD_DIR); fi @if [ -z "$$(ls -A $(RESULT_DIR) 2>&1)" ]; then ${RM} -r $(RESULT_DIR); fi @@ -80,11 +77,11 @@ $(RESULT_DIR)/prepare.res: @if [ ! -e $(RESULT_DIR) ]; then mkdir -vp $(RESULT_DIR); fi @touch $@ -$(BIN): $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(OBJ) $(ATR_LIBS) - gcc -ggdb -O3 -o $(BUILD_DIR)/simple simple.cpp - @make -C ./framework +$(BIN): $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(OBJ) $(PST_LIBS) + gcc -ggdb -O3 -o $(BUILD_DIR)/simple ./tests/simple.cpp + @make -C ./src @printf "Create %-60s" $@ - @OUT=$$($(CXX) $(COLOR) -o $@ $(OBJ) $(ATR_LIBS) $(LIBS) 2>&1); \ + @OUT=$$($(CXX) $(COLOR) -o $@ $(OBJ) $(PST_LIBS) $(LIBS) 2>&1); \ if [ $$? -ne "0" ]; \ then echo -e "${RED}[FAILED]${NC}"; echo -e "$$OUT"; \ else \ diff --git a/framework/.gitignore b/framework/.gitignore deleted file mode 100644 index f959c24..0000000 --- a/framework/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build/ -/libframework.a diff --git a/framework/dwarf_handler.h b/include/libpst.h similarity index 72% rename from framework/dwarf_handler.h rename to include/libpst.h index 06638e6..84bceb6 100644 --- a/framework/dwarf_handler.h +++ b/include/libpst.h @@ -5,31 +5,26 @@ * Author: nnosov */ -#ifndef SC_SYSUTILS_H_ -#define SC_SYSUTILS_H_ +#ifndef PST_HANDLER_H_ +#define PST_HANDLER_H_ //system +#include +/* #include #include #include #include #include #include -#include #include #include #include #include +*/ -#include "allocator.h" -#include "common.h" +#include "utils/list_head.h" #include "context.h" -#include "allocator.h" -#include "list_head.h" -#include "dwarf_expression.h" -#include "dwarf_parameter.h" -#include "dwarf_utils.h" -#include "dwarf_function.h" typedef struct pst_handler { pst_context ctx; // context of unwinding @@ -42,4 +37,4 @@ bool pst_handler_handle_dwarf(pst_handler* h); void pst_handler_print_dwarf(pst_handler* h); bool pst_handler_unwind(pst_handler* h); -#endif /* SC_SYSUTILS_H_ */ +#endif /* PST_HANDLER_H_ */ diff --git a/framework/Makefile b/src/Makefile similarity index 88% rename from framework/Makefile rename to src/Makefile index bfeb573..75b046a 100644 --- a/framework/Makefile +++ b/src/Makefile @@ -23,7 +23,7 @@ AR = ar rvs BUILD_DIR = ./build RESULT_DIR = ../build -LIB_STATIC = $(RESULT_DIR)/libframework.a +LIB_STATIC = $(RESULT_DIR)/libpst.a #Software LABEL, BUILD number, and DATE of build $(shell mkdir -p ${BUILD_DIR}) @@ -31,12 +31,12 @@ SOFT_BUILD = $(shell STR=`cat $(BUILD_DIR)/version.h 2> /dev/null | grep 'SOFT_B DATE_BUILD = $(shell date +"%D %T") #source and header files search path. add here new directories which contains files specified for $(SRC) -VPATH = . logger storage http/client http/server utils swi rmq interfaces swi/protocols +VPATH = . dwarf arch utils SRC = $(wildcard $(addsuffix /*.cpp,${VPATH})) OBJ = $(patsubst %.cpp,%.o,$(addprefix $(BUILD_DIR)/,$(notdir $(SRC)))) -INCS = -I"../thirdparty" -I"./" -I"./utils" -I"./rmq" -I"/usr/include/json-c" -I"/usr/include/postgresql" -I /usr/include/libxml2 -I"/opt/swifttest/include" -I"../thirdparty/libswiftclient/src/lib" +INCS = -I"./dwarf" -I"./" -I"./utils" -I"./arch" FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DSOFT_BUILD=$(SOFT_BUILD) -DUSER_BUILD=$(USER) -DDATE_BUILD="$(DATE_BUILD)" .PHONY: all clean diff --git a/framework/registers.cpp b/src/arch/registers.cpp similarity index 99% rename from framework/registers.cpp rename to src/arch/registers.cpp index 31dfe4f..a7650fd 100644 --- a/framework/registers.cpp +++ b/src/arch/registers.cpp @@ -10,7 +10,6 @@ #include "common.h" #include "registers.h" -#include "dwarf_operations.h" dwarf_reg_map reg_map[] = { // GP Registers diff --git a/framework/registers.h b/src/arch/registers.h similarity index 100% rename from framework/registers.h rename to src/arch/registers.h diff --git a/framework/common.cpp b/src/common.cpp similarity index 88% rename from framework/common.cpp rename to src/common.cpp index 4a9970a..f3c46a9 100644 --- a/framework/common.cpp +++ b/src/common.cpp @@ -14,20 +14,11 @@ #include #include -#include "logger/log.h" #include "common.h" -#include "dwarf_operations.h" -#include "registers.h" - -bool is_location_form(int form) -{ - if (form == DW_FORM_block1 || form == DW_FORM_block2 || form == DW_FORM_block4 || form == DW_FORM_block || - form == DW_FORM_data4 || form == DW_FORM_data8 || form == DW_FORM_sec_offset) { - return true; - } - return false; -} +#include "dwarf/dwarf_operations.h" +#include "utils/log.h" +#include "arch/registers.h" int32_t decode_sleb128(uint8_t *sleb128) { diff --git a/framework/common.h b/src/common.h similarity index 91% rename from framework/common.h rename to src/common.h index 97073b3..48abdbd 100644 --- a/framework/common.h +++ b/src/common.h @@ -13,6 +13,5 @@ int32_t decode_sleb128(uint8_t *sleb128); uint32_t decode_uleb128(uint8_t *uleb128); -bool is_location_form(int form); #endif // __PST_COMMON_H__ diff --git a/framework/context.cpp b/src/context.cpp similarity index 99% rename from framework/context.cpp rename to src/context.cpp index 4b76d1f..e54d2f7 100644 --- a/framework/context.cpp +++ b/src/context.cpp @@ -9,8 +9,9 @@ #include #include "context.h" + +#include "../src/dwarf/dwarf_operations.h" #include "registers.h" -#include "dwarf_operations.h" extern dwarf_reg_map reg_map[]; diff --git a/framework/context.h b/src/context.h similarity index 97% rename from framework/context.h rename to src/context.h index c564b34..68bc0a3 100644 --- a/framework/context.h +++ b/src/context.h @@ -14,8 +14,8 @@ #include #include -#include "logger/log.h" -#include "allocator.h" +#include "../src/utils/allocator.h" +#include "../src/utils/log.h" extern pst_log logger; // logger for whole PST library extern pst_allocator allocator; // custom allocator for PST library diff --git a/framework/dwarf_call_site.cpp b/src/dwarf/dwarf_call_site.cpp similarity index 98% rename from framework/dwarf_call_site.cpp rename to src/dwarf/dwarf_call_site.cpp index caa0836..08e5909 100644 --- a/framework/dwarf_call_site.cpp +++ b/src/dwarf/dwarf_call_site.cpp @@ -5,14 +5,15 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_call_site.h" + #include #include -#include "dwarf_call_site.h" -#include "dwarf_utils.h" -#include "hash_multimap.h" -#include "dwarf_utils.h" -#include "dwarf_function.h" +#include "../src/dwarf/dwarf_function.h" +#include "../src/dwarf/dwarf_utils.h" +#include "../src/dwarf/dwarf_utils.h" +#include "../utils/hash_multimap.h" // ----------------------------------------------------------------------------------- // pst_call_site_param @@ -104,7 +105,6 @@ bool call_site_handle_dwarf(pst_call_site* site, Dwarf_Die* child) // expression represent where callee parameter will be stored pst_call_site_param* param = add_param(site); if(dwarf_hasattr(child, DW_AT_location)) { - // handle location expression here // determine location of parameter in stack/heap or CPU registers attr = dwarf_attr(child, DW_AT_location, &attr_mem); if(!handle_location(site->ctx, attr, ¶m->location, pc, NULL)) { diff --git a/framework/dwarf_call_site.h b/src/dwarf/dwarf_call_site.h similarity index 94% rename from framework/dwarf_call_site.h rename to src/dwarf/dwarf_call_site.h index cc8079e..f908256 100644 --- a/framework/dwarf_call_site.h +++ b/src/dwarf/dwarf_call_site.h @@ -5,16 +5,16 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_CALL_SITE_H_ -#define FRAMEWORK_DWARF_CALL_SITE_H_ +#ifndef SRC_DWARF_DWARF_CALL_SITE_H_ +#define SRC_DWARF_DWARF_CALL_SITE_H_ #include #include -#include "list_head.h" +#include "../src/dwarf/dwarf_expression.h" +#include "../utils/hash_multimap.h" +#include "../utils/list_head.h" #include "context.h" -#include "dwarf_expression.h" -#include "hash_multimap.h" typedef struct pst_callee_info { Dwarf_Addr target; @@ -87,4 +87,4 @@ void pst_call_site_storage_del(pst_call_site_storage* storage, pst_call_site* st void pst_call_site_storage_del(pst_call_site_storage* storage, pst_call_site* st); -#endif /* FRAMEWORK_DWARF_CALL_SITE_H_ */ +#endif /* SRC_DWARF_DWARF_CALL_SITE_H_ */ diff --git a/framework/dwarf_expression.cpp b/src/dwarf/dwarf_expression.cpp similarity index 97% rename from framework/dwarf_expression.cpp rename to src/dwarf/dwarf_expression.cpp index 85f531b..d58e200 100644 --- a/framework/dwarf_expression.cpp +++ b/src/dwarf/dwarf_expression.cpp @@ -5,11 +5,12 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_expression.h" + #include -#include "dwarf_expression.h" +#include "../utils/allocator.h" #include "common.h" -#include "allocator.h" #include "context.h" // diff --git a/framework/dwarf_expression.h b/src/dwarf/dwarf_expression.h similarity index 87% rename from framework/dwarf_expression.h rename to src/dwarf/dwarf_expression.h index 3ec85a1..69fc600 100644 --- a/framework/dwarf_expression.h +++ b/src/dwarf/dwarf_expression.h @@ -5,14 +5,14 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_EXPRESSION_H_ -#define FRAMEWORK_DWARF_EXPRESSION_H_ +#ifndef SRC_DWARF_DWARF_EXPRESSION_H_ +#define SRC_DWARF_DWARF_EXPRESSION_H_ #include #include -#include "list_head.h" -#include "allocator.h" +#include "../utils/allocator.h" +#include "../utils/list_head.h" // DWARF operation (represents our own DW_OP_XXX) typedef struct { @@ -46,4 +46,4 @@ bool pst_dwarf_expr_equal(pst_dwarf_expr* lhs, pst_dwarf_expr* rhs); bool pst_dwarf_expr_print_op(pst_dwarf_expr* expr, const char* fmt, ...); void pst_dwarf_expr_set_value(pst_dwarf_expr* expr, uint64_t v); -#endif /* FRAMEWORK_DWARF_EXPRESSION_H_ */ +#endif /* SRC_DWARF_DWARF_EXPRESSION_H_ */ diff --git a/framework/dwarf_function.cpp b/src/dwarf/dwarf_function.cpp similarity index 99% rename from framework/dwarf_function.cpp rename to src/dwarf/dwarf_function.cpp index ed1a7e1..ba93c77 100644 --- a/framework/dwarf_function.cpp +++ b/src/dwarf/dwarf_function.cpp @@ -5,13 +5,14 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_function.h" + #include #include #include -#include "dwarf_function.h" -#include "dwarf_utils.h" -#include "dwarf_stack.h" +#include "../src/dwarf/dwarf_stack.h" +#include "../src/dwarf/dwarf_utils.h" // ----------------------------------------------------------------------------------- // pst_function diff --git a/framework/dwarf_function.h b/src/dwarf/dwarf_function.h similarity index 88% rename from framework/dwarf_function.h rename to src/dwarf/dwarf_function.h index 390e3a4..3337a26 100644 --- a/framework/dwarf_function.h +++ b/src/dwarf/dwarf_function.h @@ -5,14 +5,14 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_FUNCTION_H_ -#define FRAMEWORK_DWARF_FUNCTION_H_ +#ifndef SRC_DWARF_DWARF_FUNCTION_H_ +#define SRC_DWARF_DWARF_FUNCTION_H_ +#include "../src/dwarf/dwarf_call_site.h" +#include "../src/dwarf/dwarf_expression.h" +#include "../src/dwarf/dwarf_parameter.h" +#include "../utils/list_head.h" #include "context.h" -#include "dwarf_expression.h" -#include "list_head.h" -#include "dwarf_call_site.h" -#include "dwarf_parameter.h" // ----------------------------------------------------------------------------------- // pst_function @@ -46,4 +46,4 @@ bool pst_function_unwind(pst_function* fn, Dwarf_Addr addr); bool pst_function_handle_dwarf(pst_function * fn, Dwarf_Die* d); bool pst_function_print_dwarf(pst_function* fn); -#endif /* FRAMEWORK_DWARF_FUNCTION_H_ */ +#endif /* SRC_DWARF_DWARF_FUNCTION_H_ */ diff --git a/framework/dwarf_handler.cpp b/src/dwarf/dwarf_handler.cpp similarity index 97% rename from framework/dwarf_handler.cpp rename to src/dwarf/dwarf_handler.cpp index ef44149..39ff89a 100644 --- a/framework/dwarf_handler.cpp +++ b/src/dwarf/dwarf_handler.cpp @@ -10,14 +10,15 @@ #include #include +#include #include #include #include -#include #include +#include #include "dwarf_handler.h" -#include "logger/log.h" + #define USE_LIBUNWIND @@ -26,9 +27,11 @@ #endif #include "common.h" -#include "dwarf_operations.h" -#include "allocator.h" -#include "dwarf_stack.h" +#include "utils/log.h" +#include "utils/allocator.h" +#include "dwarf/dwarf_operations.h" +#include "dwarf/dwarf_stack.h" +#include "dwarf/dwarf_function.h" // dwfl_addrsegment() possibly can be used to check address validity // dwarf_getattrs() allows to enumerate all DIE attributes diff --git a/src/dwarf/dwarf_handler.h b/src/dwarf/dwarf_handler.h new file mode 100644 index 0000000..d68b3a5 --- /dev/null +++ b/src/dwarf/dwarf_handler.h @@ -0,0 +1,32 @@ +/* + * sysutils.h + * + * Created on: Dec 28, 2019 + * Author: nnosov + */ + +#ifndef PST_HANDLER_H_ +#define PST_HANDLER_H_ + +//system +#include + +#include "utils/list_head.h" +#include "common.h" +#include "context.h" + +typedef struct pst_context pst_context; + +typedef struct pst_handler { + pst_context ctx; // context of unwinding + list_head functions; // list of functions in stack frame +} pst_handler; + +void pst_handler_init(pst_handler* h, ucontext_t* hctx); +void pst_handler_fini(pst_handler* h); + +bool pst_handler_handle_dwarf(pst_handler* h); +void pst_handler_print_dwarf(pst_handler* h); +bool pst_handler_unwind(pst_handler* h); + +#endif /* PST_HANDLER_H_ */ diff --git a/framework/dwarf_operations.cpp b/src/dwarf/dwarf_operations.cpp similarity index 99% rename from framework/dwarf_operations.cpp rename to src/dwarf/dwarf_operations.cpp index 9b8200f..7167cb3 100644 --- a/framework/dwarf_operations.cpp +++ b/src/dwarf/dwarf_operations.cpp @@ -5,10 +5,11 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_operations.h" + #include #include -#include "dwarf_operations.h" #include "common.h" #include "registers.h" diff --git a/framework/dwarf_operations.h b/src/dwarf/dwarf_operations.h similarity index 88% rename from framework/dwarf_operations.h rename to src/dwarf/dwarf_operations.h index 233ee9f..3967437 100644 --- a/framework/dwarf_operations.h +++ b/src/dwarf/dwarf_operations.h @@ -2,12 +2,12 @@ #include +#include "../src/dwarf/dwarf_stack.h" +#include "../utils/list_head.h" #include "common.h" -#include "list_head.h" #include "context.h" #include "dwarf_handler.h" -#include "dwarf_stack.h" typedef struct __dwarf_op_map dwarf_op_map; diff --git a/framework/dwarf_parameter.cpp b/src/dwarf/dwarf_parameter.cpp similarity index 99% rename from framework/dwarf_parameter.cpp rename to src/dwarf/dwarf_parameter.cpp index 83f95f9..caaf49b 100644 --- a/framework/dwarf_parameter.cpp +++ b/src/dwarf/dwarf_parameter.cpp @@ -5,11 +5,12 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_parameter.h" + #include #include -#include "dwarf_parameter.h" -#include "dwarf_utils.h" +#include "../src/dwarf/dwarf_utils.h" #include "context.h" // diff --git a/framework/dwarf_parameter.h b/src/dwarf/dwarf_parameter.h similarity index 91% rename from framework/dwarf_parameter.h rename to src/dwarf/dwarf_parameter.h index 31abf0f..9b70afa 100644 --- a/framework/dwarf_parameter.h +++ b/src/dwarf/dwarf_parameter.h @@ -5,15 +5,15 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_PARAMETER_H_ -#define FRAMEWORK_DWARF_PARAMETER_H_ +#ifndef SRC_DWARF_DWARF_PARAMETER_H_ +#define SRC_DWARF_DWARF_PARAMETER_H_ #include #include -#include "list_head.h" +#include "../src/dwarf/dwarf_expression.h" +#include "../utils/list_head.h" #include "context.h" -#include "dwarf_expression.h" typedef struct __pst_type { list_node node; // uplink @@ -56,4 +56,4 @@ bool pst_parameter_print_dwarf(pst_parameter* param); bool pst_parameter_handle_type(pst_parameter* param, Dwarf_Attribute* base); pst_type* pst_parameter_add_type(pst_parameter* param, const char* name, int type); -#endif /* FRAMEWORK_DWARF_PARAMETER_H_ */ +#endif /* SRC_DWARF_DWARF_PARAMETER_H_ */ diff --git a/framework/dwarf_stack.cpp b/src/dwarf/dwarf_stack.cpp similarity index 98% rename from framework/dwarf_stack.cpp rename to src/dwarf/dwarf_stack.cpp index 51df01a..bd83c7e 100644 --- a/framework/dwarf_stack.cpp +++ b/src/dwarf/dwarf_stack.cpp @@ -5,17 +5,16 @@ * Author: nnosov */ +#include "../src/dwarf/dwarf_stack.h" + #include #include #include -#include "allocator.h" -#include "list_head.h" - -#include "dwarf_stack.h" - +#include "../src/dwarf/dwarf_operations.h" +#include "../utils/allocator.h" +#include "../utils/list_head.h" #include "dwarf_handler.h" -#include "dwarf_operations.h" // ----------------------------------------------------------------------------------- // DWARF Stack value diff --git a/framework/dwarf_stack.h b/src/dwarf/dwarf_stack.h similarity index 95% rename from framework/dwarf_stack.h rename to src/dwarf/dwarf_stack.h index 8ad6d97..d523cd3 100644 --- a/framework/dwarf_stack.h +++ b/src/dwarf/dwarf_stack.h @@ -5,15 +5,15 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_STACK_H_ -#define FRAMEWORK_DWARF_STACK_H_ +#ifndef SRC_DWARF_DWARF_STACK_H_ +#define SRC_DWARF_DWARF_STACK_H_ #include #include "common.h" -#include "allocator.h" #include "context.h" -#include "dwarf_handler.h" +#include "utils/allocator.h" +#include "dwarf/dwarf_function.h" // ----------------------------------------------------------------------------------- // DWARF Stack value @@ -94,4 +94,4 @@ pst_dwarf_value* pst_dwarf_stack_pop(pst_dwarf_stack* st); void pst_dwarf_stack_push_value(pst_dwarf_stack* st, pst_dwarf_value* value); void pst_dwarf_stack_push(pst_dwarf_stack* st, void* v, uint32_t s, int t); -#endif /* FRAMEWORK_DWARF_STACK_H_ */ +#endif /* SRC_DWARF_DWARF_STACK_H_ */ diff --git a/framework/dwarf_utils.cpp b/src/dwarf/dwarf_utils.cpp similarity index 88% rename from framework/dwarf_utils.cpp rename to src/dwarf/dwarf_utils.cpp index fed3937..11663bc 100644 --- a/framework/dwarf_utils.cpp +++ b/src/dwarf/dwarf_utils.cpp @@ -9,6 +9,17 @@ #include "dwarf_utils.h" #include "dwarf_stack.h" +#include "dwarf_function.h" + + +bool is_location_form(int form) +{ + if (form == DW_FORM_block1 || form == DW_FORM_block2 || form == DW_FORM_block4 || form == DW_FORM_block || + form == DW_FORM_data4 || form == DW_FORM_data8 || form == DW_FORM_sec_offset) { + return true; + } + return false; +} int regname_callback (void *arg, int regno, const char *setname, const char *prefix, const char *regname, int bits, int type) { diff --git a/framework/dwarf_utils.h b/src/dwarf/dwarf_utils.h similarity index 76% rename from framework/dwarf_utils.h rename to src/dwarf/dwarf_utils.h index fde682a..511c8c1 100644 --- a/framework/dwarf_utils.h +++ b/src/dwarf/dwarf_utils.h @@ -5,14 +5,14 @@ * Author: nnosov */ -#ifndef FRAMEWORK_DWARF_UTILS_H_ -#define FRAMEWORK_DWARF_UTILS_H_ +#ifndef SRC_DWARF_DWARF_UTILS_H_ +#define SRC_DWARF_DWARF_UTILS_H_ #include -#include "dwarf_expression.h" #include "context.h" -#include "dwarf_handler.h" +#include "dwarf_expression.h" +#include "dwarf_function.h" typedef struct __reginfo { __reginfo() { @@ -25,5 +25,6 @@ typedef struct __reginfo { int regname_callback (void *arg, int regno, const char *setname, const char *prefix, const char *regname, int bits, int type); bool handle_location(pst_context* ctx, Dwarf_Attribute* attr, pst_dwarf_expr* loc, Dwarf_Addr pc, pst_function* fun); +bool is_location_form(int form); -#endif /* FRAMEWORK_DWARF_UTILS_H_ */ +#endif /* SRC_DWARF_DWARF_UTILS_H_ */ diff --git a/framework/allocator.cpp b/src/utils/allocator.cpp similarity index 97% rename from framework/allocator.cpp rename to src/utils/allocator.cpp index f7b6c9f..df855cb 100644 --- a/framework/allocator.cpp +++ b/src/utils/allocator.cpp @@ -5,12 +5,13 @@ * Author: nnosov */ +#include "../src/utils/allocator.h" + #include #include #include #include "common.h" -#include "allocator.h" void heap_free(pst_allocator* alloc, void* buff) { diff --git a/framework/allocator.h b/src/utils/allocator.h similarity index 100% rename from framework/allocator.h rename to src/utils/allocator.h diff --git a/framework/hash_multimap.cpp b/src/utils/hash_multimap.cpp similarity index 99% rename from framework/hash_multimap.cpp rename to src/utils/hash_multimap.cpp index 0a3cf64..a3931d2 100644 --- a/framework/hash_multimap.cpp +++ b/src/utils/hash_multimap.cpp @@ -11,10 +11,11 @@ * http://nsoft.volgocity.ru/cdl or * http://cdl.sourceforge.net * ===========================================================================*/ +#include "../src/utils/hash_multimap.h" + #include #include #include -#include "hash_multimap.h" /* Default hash function @param key hash key diff --git a/framework/hash_multimap.h b/src/utils/hash_multimap.h similarity index 95% rename from framework/hash_multimap.h rename to src/utils/hash_multimap.h index acaec75..43259a6 100644 --- a/framework/hash_multimap.h +++ b/src/utils/hash_multimap.h @@ -1,7 +1,7 @@ #ifndef HASH_MULTIMAP_H #define HASH_MULTIMAP_H -#include "list_head.h" +#include "../src/utils/list_head.h" #define HASH_MIN_SHIFT (8) #define HASH_MAX_SHIFT (15) diff --git a/framework/list_head.h b/src/utils/list_head.h similarity index 100% rename from framework/list_head.h rename to src/utils/list_head.h diff --git a/framework/logger/log.cpp b/src/utils/log.cpp similarity index 99% rename from framework/logger/log.cpp rename to src/utils/log.cpp index b8676bc..8a44483 100644 --- a/framework/logger/log.cpp +++ b/src/utils/log.cpp @@ -1,4 +1,4 @@ -#include "log.h" +#include "../../src/utils/log.h" #include #include diff --git a/framework/logger/log.h b/src/utils/log.h similarity index 100% rename from framework/logger/log.h rename to src/utils/log.h diff --git a/main.cpp b/tests/main.cpp similarity index 99% rename from main.cpp rename to tests/main.cpp index a7b8a10..fcb2cb4 100644 --- a/main.cpp +++ b/tests/main.cpp @@ -2,8 +2,8 @@ #include #include +#include "dwarf/dwarf_handler.h" #include "context.h" -#include "dwarf_handler.h" typedef enum { DEF_1 = 1, diff --git a/simple.cpp b/tests/simple.cpp similarity index 100% rename from simple.cpp rename to tests/simple.cpp