HEADER_INSTALLDIR = /usr/local/include/
TIZEN_TARGET = da_probe_tizen.so
+PROBE_EVENT_TARGET = swap_probe_event.so
DUMMY_TARGET = libdaprobe.so
PARSE_ELF_LIB_TARGET = libparserelf.so
PARSE_ELF_BIN_TARGET = parse_elf
-lrt \
-ldl \
-lwayland-client \
- -lsensor \
-Wl,-z,noexecstack
ASMFLAG = -O0 -g -Werror
CFLAGS = $(WARN_CFLAGS) -fPIC
CXXFLAGS = $(WARN_CFLAGS) -fPIC
-CPPFLAGS = $(INCLUDE_CPPFLAGS) -D_GNU_SOURCE -DSELF_LIB_NAME="\"/$(INSTALLDIR)/$(TIZEN_TARGET)\""
+CPPFLAGS = $(INCLUDE_CPPFLAGS) -D_GNU_SOURCE
-TIZEN_CPPFLAGS = -DTIZENAPP $(SWAP_PROBE_DEFS)
+TIZEN_CPPFLAGS = -DSELF_LIB_NAME="\"/$(INSTALLDIR)/$(TIZEN_TARGET)\"" -DTIZENAPP $(SWAP_PROBE_DEFS)
TIZEN_LDFLAGS = -lstdc++
./probe_memory/probe_memory.c \
./probe_socket/libdasocket.c \
./probe_socket/probe_socket.c \
- ./probe_event/gesture.c \
- ./probe_event/da_event.c \
- ./probe_event/keytouch.c \
- ./probe_event/probe_event.c \
./probe_third/libdaemon.c \
./probe_thread/libdathread.c \
./probe_thread/libdasync.c \
./probe_file/da_io_stdc.c \
./probe_file/probe_file.c \
+PROBE_EVENT_SRCS = \
+ ./probe_event/gesture.c \
+ ./probe_event/da_event.c \
+ ./probe_event/keytouch.c \
+ ./probe_event/probe_event.c
+
ifeq ($(TIZEN_FEATURE_WAYLAND),y)
UTILITY_SRCS += ./helper/dacapture.c
-PROBE_SRCS += ./probe_event/orientation.c
+PROBE_EVENT_SRCS += ./probe_event/orientation.c
CFLAGS += -DTIZEN_FEATURE_WAYLAND
CFLAGS += -I/usr/include/wayland-extension/
LDFLAGS+=-lecore \
ASM_OBJ = $(patsubst %.S,%.o, $(ASM_SRC))
CAPI_OBJS = $(patsubst %.c,%.o, $(CAPI_SRCS)) $(ASM_OBJ)
TIZEN_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(TIZEN_SRCS))) $(ASM_OBJ)
+PROBE_EVENT_OBJS = $(patsubst %.cpp,%.o, $(patsubst %.c,%.o, $(PROBE_EVENT_SRCS)))
DUMMY_OBJS = $(patsubst %.c,%.o, $(DUMMY_SRCS))
PARSE_ELF_LIB_OBJ = $(patsubst %.c,%.o, $(PARSE_ELF_LIB_SRC))
PARSE_ELF_BIN_OBJ = $(patsubst %.c,%.o, $(PARSE_ELF_BIN_SRC))
-all: elflib capi tizen dummy elfparser
+all: elflib capi tizen dummy event elfparser
tizen: headers $(TIZEN_TARGET)
dummy: headers $(DUMMY_TARGET)
elflib: $(PARSE_ELF_LIB_OBJ) $(PARSE_ELF_LIB_TARGET)
lsan:
$(MAKE) -C lsan
+event: tizen $(PROBE_EVENT_TARGET)
+
$(ASM_OBJ): $(ASM_SRC)
$(CC) $(ASMFLAG) -c $^ -o $@
$(TIZEN_TARGET): $(TIZEN_OBJS)
$(CC) $(LDFLAGS) $^ -o $@
+PROBE_EVENT_LDFLAGS = \
+ -L. \
+ -lstdc++ \
+ -lsensor \
+ -l:da_probe_tizen.so
+
+$(PROBE_EVENT_TARGET): LDFLAGS+=$(PROBE_EVENT_LDFLAGS)
+$(PROBE_EVENT_TARGET): CPPFLAGS+=-DSELF_LIB_NAME="\"/$(INSTALLDIR)/$(PROBE_EVENT_TARGET)\"" -DTIZENAPP $(SWAP_PROBE_DEFS)
+$(PROBE_EVENT_TARGET): CPPFLAGS+=$(DEBUG_FLAGS)
+$(PROBE_EVENT_TARGET): $(TIZEN_TARGET) $(PROBE_EVENT_OBJS)
+ $(CC) $(LDFLAGS) $^ -o $@
+
$(DUMMY_TARGET): $(DUMMY_OBJS)
$(CC) $(LDFLAGS) $^ -o $@
ldheader: $(SOURCE_HEADERS) $(LINKER_HEADER)
-install: install_da install_ld install_elf install_lsan
+install: install_da install_event install_ld install_elf install_lsan
install_da: all
[ -d "$(DESTDIR)/$(INSTALLDIR)" ] || mkdir -p $(DESTDIR)/$(INSTALLDIR)
[ -d "$(DESTDIR)/$(INSTALLDIR)" ] || mkdir -p $(DESTDIR)/$(INSTALLDIR)
install $(LSAN_DIR)/$(LSAN_TARGET) $(DESTDIR)/$(INSTALLDIR)/
+install_event: event
+ [ -d "$(DESTDIR)/$(INSTALLDIR)" ] || mkdir -p $(DESTDIR)/$(INSTALLDIR)
+ install $(PROBE_EVENT_TARGET) $(DESTDIR)/$(INSTALLDIR)/
+
+
clean:
- rm -f *.so $(TIZEN_OBJS) $(PARSE_ELF_LIB_OBJ) $(PARSE_ELF_BIN_OBJ) $(GENERATED_HEADERS) $(API_NAME_LIST) $(SOURCE_HEADERS)
+ rm -f *.so $(TIZEN_OBJS) $(PROBE_EVENT_OBJS) $(PARSE_ELF_LIB_OBJ) $(PARSE_ELF_BIN_OBJ) $(GENERATED_HEADERS) $(API_NAME_LIST) $(SOURCE_HEADERS)
-.PHONY: all capi tizen dummy clean install_ld install_da install_elf install headers lsan
+.PHONY: all capi tizen dummy event clean install_ld install_da install_event install_elf install headers lsan
struct wl_list link;
};
+static int __current_angle = 0;
+
static void
display_handle_geometry(void __attribute__((unused)) *data,
struct wl_output *wl_output,
{
SCREENSHOT_DONE();
}
+
+int current_angle_get()
+{
+ return __current_angle;
+}
+void current_angle_set(int angle)
+{
+ __current_angle = angle;
+}
/* Features list, defined in probe_* headers */
#define FEATURES_LIST \
- X(memory_feature) \
- X(memory_feature_always) \
- X(helper_feature) \
- X(capi_feature) \
- X(event_feature) \
- X(file_feature) \
- X(file_feature_always) \
- X(graphics_feature) \
- X(graphics_feature_always) \
- X(network_feature) \
- X(network_feature_always) \
- X(thread_feature) \
- X(thread_feature_always) \
- X(ui_feature)
+ X(OPT_ALLOC, memory_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_ALLOC_ALWAYS, memory_feature_always, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_ALWAYSON, helper_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_ALWAYSON, capi_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_EVENT, event_feature, "/usr/lib/swap_probe_event.so") \
+ X(OPT_FILE, file_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_FILE_ALWAYS, file_feature_always, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_GLES, graphics_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_GLES_ALWAYS, graphics_feature_always, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_NETWORK, network_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_NETWORK_ALWAYS, network_feature_always, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_THREAD, thread_feature, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_THREAD_ALWAYS, thread_feature_always, "/usr/lib/da_probe_tizen.so") \
+ X(OPT_UI, ui_feature, "/usr/lib/da_probe_tizen.so")
/* Declare array of features length */
-#define X(feature) +1
+#define X(flag, feat, file) +1
static unsigned int features_cnt = (FEATURES_LIST);
+static void * feature_handles[(FEATURES_LIST)] = { NULL };
static struct feature_desc_t *features[(FEATURES_LIST)] = { NULL };
#undef X
/* Declare array's indexes */
-#define X(feature) feature##_ind,
+#define X(flag, feat, file) feat##_ind,
enum {
FEATURES_LIST
/* Declare array of features */
-#define X(feature) features[feature##_ind] = &feature;
+#define X(flag, feat, file) \
+ if (features[feat##_ind] == NULL || \
+ feature_handles[feat##_ind] != NULL) \
+ features[feat##_ind] = dlsym(feature_handles[feat##_ind], #feat);
/* Can be initialized only dynamically, because struct addresses are resolved
* only at a runtime */
-static void _init_features_ptrs(void)
+static void _init_feature_ptrs(void)
+{
+ FEATURES_LIST
+}
+
+#undef X
+
+/* Declare array of feature's library handles */
+#define X(flag, feat, file) \
+ if (feature_handles[feat##_ind] == NULL && isOptionEnabled(flag)) \
+ feature_handles[feat##_ind] = dlopen(file, RTLD_NOW);
+
+/* Init features that are in already loaded binaries. */
+/* TODO make dlclose() on stop */
+static void _init_feature_handles(void)
{
FEATURES_LIST
}
static inline bool _is_ignored(const char *path)
{
const char probe_lib[] = "/usr/lib/da_probe_tizen.so";
+ const char event_lib[] = "/usr/lib/swap_probe_event.so";
const char uihv_lib[] = "/usr/lib/da_ui_viewer.so";
const char linux_gate[] = "linux-gate.so.1";
const char linker_2[] = "/lib/ld-linux.so.2";
if (path[0] == '\0' ||
!strcmp(probe_lib, path) ||
+ !strcmp(event_lib, path) ||
!strcmp(uihv_lib, path) ||
!strcmp(linux_gate, path) ||
!strcmp(linker_2, path) ||
unsigned int i;
for (i = 0; i < features_cnt; i++) {
- if (!isOptionEnabled(features[i]->feature))
+ if (features[i] == NULL ||
+ !isOptionEnabled(features[i]->feature))
continue;
_patch_target_bins(features[i]);
}
/* Iterate features to find target probe */
for (i = 0; i < features_cnt; i++) {
- if (!isOptionEnabled(features[i]->feature))
+ if (features[i] == NULL ||
+ !isOptionEnabled(features[i]->feature))
continue;
if ((!check_binary(l->l_name) &&
* another calls relocated function before we patch its address */
for (i = 0; i < features_cnt; i++) {
- if (!isOptionEnabled(features[i]->feature))
+ if (features[i] == NULL ||
+ !isOptionEnabled(features[i]->feature))
continue;
is_for_all = _is_for_all_feature(features[i]);
return ret;
}
+void init_features(void)
+{
+ _init_feature_handles();
+ _init_feature_ptrs();
+}
+
void process_got_patching(char *data)
{
if (!inited) {
_init_linker_addr();
- _init_features_ptrs();
inited = true;
}
_process_target_bins(data);
void process_got_patching(char *data);
void restore_got_patching(void);
+void init_features(void);
#endif /* __GOT_PATCHING_H__ */
SCREENSHOT_SET();
else
SCREENSHOT_UNSET();
+
+ init_features();
+
PRINTMSG("configure in probe : %s, %llx\n", configstr, gTraceInfo.optionflag);
}
gTraceInfo.socket.daemonSock = -1;
}
- finalize_event();
-
finalize_hash_table();
for(i = 0; i < NUM_ORIGINAL_LIBRARY; i++)
#if 0 /* TODO Support old preload */
#define PREPARE_LOCAL_BUF() \
- char *LOCAL_BUF = (char *)(*real_malloc)(MAX_LOCAL_BUF_SIZE); \
+ char *LOCAL_BUF = (char *)malloc(MAX_LOCAL_BUF_SIZE); \
char *BUF_PTR = LOCAL_BUF; \
char *RET_PTR = NULL; \
char *CALL_TYPE_PTR = NULL; \
#else
#define PREPARE_LOCAL_BUF() \
- char *LOCAL_BUF = (char *)(*real_malloc)(MAX_LOCAL_BUF_SIZE); \
+ char *LOCAL_BUF = (char *)malloc(MAX_LOCAL_BUF_SIZE); \
char *BUF_PTR = LOCAL_BUF; \
char *RET_PTR = NULL;
char *real_abs_path(int fd, char *buffer, size_t bufsiz);
// event related functions
-int initialize_event();
-int finalize_event();
int current_angle_get();
void current_angle_set(int angle);
void on_orientation_changed(int angle, bool capi);
%manifest swap-probe.manifest
%defattr(-,root,root,-)
%{_prefix}/lib/da_probe_tizen.so
+%{_prefix}/lib/swap_probe_event.so
%{_prefix}/lib/libdaprobe.so
%files -n swap-probe-devel
#include "binproto.h"
#include "real_functions.h"
-static int __current_angle = 0;
-
-// ====================================================================
-// initialize and finalize event
-// ====================================================================
-
-int initialize_event()
-{
- return 0;
-}
-
-int finalize_event()
-{
- return 0;
-}
// ===================================================================
// orientation related functions
void on_orientation_changed(int angle, bool capi)
{
- __current_angle = angle;
-
if (isOptionEnabled(OPT_EVENT)) {
inc_current_event_index();
/* Always feature */
PACK_COMMON_END('v', 0, 0, 0, (uint64_t)0xffffffff);
PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "",
- convert_angle(__current_angle));
+ convert_angle(angle));
FLUSH_LOCAL_BUF();
}
SCREENSHOT_SET();
}
-
-int current_angle_get()
-{
- return __current_angle;
-}
-void current_angle_set(int angle)
-{
- __current_angle = angle;
-}