Skip to content

Commit

Permalink
revamp code, the way to the first stable release 0.2
Browse files Browse the repository at this point in the history
reference counting for breakpoints and tasks
fix non interactive mode
eliminate dead code
new option --nocpp, useful when tracing c++ programs linked against
libstdc++
fix verbose mode
fix about exit and exit
  • Loading branch information
sstefani committed May 5, 2015
1 parent 7acdb6f commit bd06113
Show file tree
Hide file tree
Showing 25 changed files with 743 additions and 518 deletions.
3 changes: 3 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ noinst_HEADERS = \
thread.h \
trace.h

dist_man1_MANS = mtrace.1
dist_man5_MANS = mtrace.conf.5

dist_doc_DATA = COPYING CREDITS INSTALL README TODO

EXTRA_DIST =
Expand Down
122 changes: 108 additions & 14 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)"
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
"$(DESTDIR)$(man5dir)" "$(DESTDIR)$(docdir)"
PROGRAMS = $(bin_PROGRAMS)
am_mtrace_OBJECTS = breakpoint.$(OBJEXT) common.$(OBJEXT) \
debug.$(OBJEXT) dict.$(OBJEXT) dwarf.$(OBJEXT) event.$(OBJEXT) \
Expand Down Expand Up @@ -217,6 +218,10 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
man1dir = $(mandir)/man1
man5dir = $(mandir)/man5
NROFF = nroff
MANS = $(dist_man1_MANS) $(dist_man5_MANS)
DATA = $(dist_doc_DATA)
HEADERS = $(noinst_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
Expand Down Expand Up @@ -249,7 +254,8 @@ ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
am__DIST_COMMON = $(dist_man1_MANS) $(dist_man5_MANS) \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/config/autoconf/compile \
$(top_srcdir)/config/autoconf/config.guess \
$(top_srcdir)/config/autoconf/config.sub \
Expand Down Expand Up @@ -476,6 +482,8 @@ noinst_HEADERS = \
thread.h \
trace.h

dist_man1_MANS = mtrace.1
dist_man5_MANS = mtrace.conf.5
dist_doc_DATA = COPYING CREDITS INSTALL README TODO
EXTRA_DIST =
MAINTAINERCLEANFILES = \
Expand Down Expand Up @@ -658,6 +666,88 @@ clean-libtool:

distclean-libtool:
-rm -f libtool config.lt
install-man1: $(dist_man1_MANS)
@$(NORMAL_INSTALL)
@list1='$(dist_man1_MANS)'; \
list2=''; \
test -n "$(man1dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.1[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
done; }

uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(dist_man1_MANS)'; test -n "$(man1dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
install-man5: $(dist_man5_MANS)
@$(NORMAL_INSTALL)
@list1='$(dist_man5_MANS)'; \
list2=''; \
test -n "$(man5dir)" \
&& test -n "`echo $$list1$$list2`" \
|| exit 0; \
echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \
$(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \
{ for i in $$list1; do echo "$$i"; done; \
if test -n "$$list2"; then \
for i in $$list2; do echo "$$i"; done \
| sed -n '/\.5[a-z]*$$/p'; \
fi; \
} | while read p; do \
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; echo "$$p"; \
done | \
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
sed 'N;N;s,\n, ,g' | { \
list=; while read file base inst; do \
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \
fi; \
done; \
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
while read files; do \
test -z "$$files" || { \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \
done; }

uninstall-man5:
@$(NORMAL_UNINSTALL)
@list='$(dist_man5_MANS)'; test -n "$(man5dir)" || exit 0; \
files=`{ for i in $$list; do echo "$$i"; done; \
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir)
install-dist_docDATA: $(dist_doc_DATA)
@$(NORMAL_INSTALL)
@list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
Expand Down Expand Up @@ -975,10 +1065,10 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(PROGRAMS) $(DATA) $(HEADERS) config.h
all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) $(HEADERS) config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)"; do \
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(docdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
Expand Down Expand Up @@ -1035,7 +1125,7 @@ info: info-recursive

info-am:

install-data-am: install-dist_docDATA
install-data-am: install-dist_docDATA install-man

install-dvi: install-dvi-recursive

Expand All @@ -1051,7 +1141,7 @@ install-info: install-info-recursive

install-info-am:

install-man:
install-man: install-man1 install-man5

install-pdf: install-pdf-recursive

Expand Down Expand Up @@ -1084,7 +1174,10 @@ ps: ps-recursive

ps-am:

uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA
uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA \
uninstall-man

uninstall-man: uninstall-man1 uninstall-man5

.MAKE: $(am__recursive_targets) all install-am install-strip

Expand All @@ -1100,13 +1193,14 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA
install-data-am install-dist_docDATA install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-local mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-dist_docDATA
install-man1 install-man5 install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-local mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-binPROGRAMS uninstall-dist_docDATA uninstall-man \
uninstall-man1 uninstall-man5

.PRECIOUS: Makefile

Expand Down
Empty file removed README
Empty file.
1 change: 1 addition & 0 deletions README
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@ The mtrace utility was designed to run in a very constrained environment, like s

The mtrace utility intercepts the following GLIBC calls:

malloc()
memalign()
realloc()
free()
posix_memalign()
aligned_alloc()
valloc()
pvalloc()
mmap()
munmap()
clone()
system()
execve()
exit()

The operator new() method is using malloc(), so memory allocations of a C++ application can also be traced.

There is currently support for X86 (32 udn 64 Bit), PowerPC (32 Bit) and ARM (32 Bit). Only Linux is now supported, but there are plans to support different operating systems and CPU's.
void *malloc(size_t size);
void free(void *ptr);
void *calloc(size_t nmemb, size_t size);
void *realloc(void *ptr, size_t size);
int posix_memalign(void **memptr, size_t alignment, size_t size);
void *aligned_alloc(size_t alignment, size_t size);
void *valloc(size_t size);
void *memalign(size_t alignment, size_t size);
void *pvalloc(size_t size);
void cfree(void *ptr);
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
void *mmap64(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t length);
void *mremap(void *old_address, size_t old_size, size_t new_size, int flags, ... /* void *new_address */);

void *operator new(size_t size) throw (std::bad_alloc)
void *operator new(size_t size, const std::nothrow_t& nt) __THROW
void *operator new[](size_t size) throw (std::bad_alloc)
void *operator new[](size_t size, const std::nothrow_t& nt) __THROW
void operator delete(void* p) __THROW
void operator delete(void* p, const std::nothrow_t& nt) __THROW
void operator delete[](void* p) __THROW
void operator delete[](void* p, const std::nothrow_t& nt) __THROW

There is currently support for X86 (32 and 64 Bit), PowerPC (32 Bit) and ARM (32 Bit). Only Linux is now supported, but there are plans to support different operating systems and CPU's.

Stay tuned...

6 changes: 3 additions & 3 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ppc single step
ppc single step enhancement
arm thumb support
dwarf debug support
arm & ppc hw bp support
dwarf caching
invalid stack trace cache for unmapped libraries
restore REALLOC_TRY when realloc fails
manual page
documentation
mremap revamp
write documentation
Loading

0 comments on commit bd06113

Please sign in to comment.