mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-28 16:01:18 +01:00
native profiling support
only works with Linux for now
This commit is contained in:
parent
a134bb4238
commit
8ef02d3b9d
@ -26,9 +26,9 @@ export ASFLAGS =
|
||||
export DEBUGGER_FLAGS = $(ELF)
|
||||
export VALGRIND_FLAGS ?= --track-origins=yes
|
||||
all-valgrind: export CFLAGS += -DHAVE_VALGRIND_H -g
|
||||
all-valgrind: export NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
|
||||
|
||||
export INCLUDES += $(NATIVEINCLUDES)
|
||||
all-valgrind: export INCLUDES += $(shell pkg-config valgrind --cflags)
|
||||
all-profile: export CFLAGS += -pg
|
||||
all-profile: export LINKFLAGS += -pg
|
||||
|
||||
# backward compatability with glibc <= 2.17 for native
|
||||
ifeq ($(CPU),native)
|
||||
@ -56,6 +56,8 @@ endif
|
||||
|
||||
all: # do not override first target
|
||||
|
||||
all-profile: all
|
||||
|
||||
all-valgrind: all
|
||||
|
||||
valgrind:
|
||||
@ -63,3 +65,6 @@ valgrind:
|
||||
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
||||
# VALGRIND_FLAGS += --db-attach=yes
|
||||
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
||||
|
||||
profile:
|
||||
gprof $(ELF)
|
||||
|
||||
@ -186,7 +186,6 @@ __attribute__((constructor)) static void startup(int argc, char **argv)
|
||||
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
|
||||
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
|
||||
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
|
||||
*(void **)(&real_calloc) = dlsym(RTLD_NEXT, "calloc");
|
||||
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
|
||||
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
|
||||
|
||||
|
||||
@ -107,12 +107,22 @@ void free(void *ptr)
|
||||
_native_syscall_leave();
|
||||
}
|
||||
|
||||
int _native_in_calloc;
|
||||
void *calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
/* XXX: This is a dirty hack to enable old dlsym versions to run.
|
||||
* Throw it out when Ubuntu 12.04 support runs out (in 2017-04)! */
|
||||
/* dynamically load calloc when it's needed - this is necessary to
|
||||
* support profiling as it uses calloc before startup runs */
|
||||
if (!real_calloc) {
|
||||
return NULL;
|
||||
if (_native_in_calloc) {
|
||||
/* XXX: This is a dirty hack to enable old dlsym versions to run.
|
||||
* Throw it out when Ubuntu 12.04 support runs out (in 2017-04)! */
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
_native_in_calloc = 1;
|
||||
*(void **)(&real_calloc) = dlsym(RTLD_NEXT, "calloc");
|
||||
_native_in_calloc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void *r;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user