mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #789 from LudwigOrtmann/native_gprof
native profiling tools support
This commit is contained in:
commit
2749531324
@ -20,15 +20,23 @@ export DEBUGGER = gdb
|
|||||||
export TERMPROG = $(ELF)
|
export TERMPROG = $(ELF)
|
||||||
export FLASHER = true
|
export FLASHER = true
|
||||||
export VALGRIND ?= valgrind
|
export VALGRIND ?= valgrind
|
||||||
|
export CGANNOTATE ?= cg_annotate
|
||||||
|
export GPROF ?= gprof
|
||||||
|
|
||||||
# flags:
|
# flags:
|
||||||
export CFLAGS += -Wall -Wextra -pedantic -m32
|
export CFLAGS += -Wall -Wextra -pedantic -m32
|
||||||
export LINKFLAGS += -m32 -gc -ldl
|
export LINKFLAGS += -m32 -gc -ldl
|
||||||
export ASFLAGS =
|
export ASFLAGS =
|
||||||
export DEBUGGER_FLAGS = $(ELF)
|
export DEBUGGER_FLAGS = $(ELF)
|
||||||
export VALGRIND_FLAGS ?= --track-origins=yes
|
term-memcheck: export VALGRIND_FLAGS ?= --track-origins=yes
|
||||||
|
term-cachegrind: export CACHEGRIND_FLAGS += --tool=cachegrind
|
||||||
|
term-gprof: export TERMPROG = GMON_OUT_PREFIX=gmon.out $(ELF)
|
||||||
all-valgrind: export CFLAGS += -DHAVE_VALGRIND_H -g
|
all-valgrind: export CFLAGS += -DHAVE_VALGRIND_H -g
|
||||||
all-valgrind: export NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
|
all-valgrind: export NATIVEINCLUDES += $(shell pkg-config valgrind --cflags)
|
||||||
|
all-debug: export CFLAGS += -g
|
||||||
|
all-cachegrind: export CFLAGS += -g
|
||||||
|
all-gprof: export CFLAGS += -pg
|
||||||
|
all-gprof: export LINKFLAGS += -pg
|
||||||
|
|
||||||
export INCLUDES += $(NATIVEINCLUDES)
|
export INCLUDES += $(NATIVEINCLUDES)
|
||||||
|
|
||||||
@ -58,10 +66,25 @@ endif
|
|||||||
|
|
||||||
all: # do not override first target
|
all: # do not override first target
|
||||||
|
|
||||||
|
all-gprof: all
|
||||||
|
|
||||||
all-valgrind: all
|
all-valgrind: all
|
||||||
|
|
||||||
valgrind:
|
all-cachegrind: all
|
||||||
|
|
||||||
|
term-valgrind:
|
||||||
# use this if you want to attach gdb from valgrind:
|
# use this if you want to attach gdb from valgrind:
|
||||||
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
# echo 0 > /proc/sys/kernel/yama/ptrace_scope
|
||||||
# VALGRIND_FLAGS += --db-attach=yes
|
# VALGRIND_FLAGS += --db-attach=yes
|
||||||
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
$(VALGRIND) $(VALGRIND_FLAGS) $(ELF) $(PORT)
|
||||||
|
|
||||||
|
term-cachegrind:
|
||||||
|
$(VALGRIND) $(CACHEGRIND_FLAGS) $(ELF) $(PORT)
|
||||||
|
|
||||||
|
term-gprof: term
|
||||||
|
|
||||||
|
eval-gprof:
|
||||||
|
$(GPROF) $(ELF) $(shell ls -rt gmon.out* | tail -1)
|
||||||
|
|
||||||
|
eval-cachegrind:
|
||||||
|
$(CGANNOTATE) $(shell ls -rt cachegrind.out* | tail -1)
|
||||||
|
@ -186,7 +186,6 @@ __attribute__((constructor)) static void startup(int argc, char **argv)
|
|||||||
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
|
*(void **)(&real_read) = dlsym(RTLD_NEXT, "read");
|
||||||
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
|
*(void **)(&real_write) = dlsym(RTLD_NEXT, "write");
|
||||||
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
|
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
|
||||||
*(void **)(&real_calloc) = dlsym(RTLD_NEXT, "calloc");
|
|
||||||
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
|
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
|
||||||
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
|
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
|
||||||
|
|
||||||
|
@ -107,12 +107,22 @@ void free(void *ptr)
|
|||||||
_native_syscall_leave();
|
_native_syscall_leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _native_in_calloc;
|
||||||
void *calloc(size_t nmemb, size_t size)
|
void *calloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
/* XXX: This is a dirty hack to enable old dlsym versions to run.
|
/* dynamically load calloc when it's needed - this is necessary to
|
||||||
* Throw it out when Ubuntu 12.04 support runs out (in 2017-04)! */
|
* support profiling as it uses calloc before startup runs */
|
||||||
if (!real_calloc) {
|
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;
|
void *r;
|
||||||
|
Loading…
Reference in New Issue
Block a user