Rename liblttng-ust-libc to liblttng-ust-libc-wrapper
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 8 Feb 2012 22:44:19 +0000 (17:44 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 8 Feb 2012 22:44:19 +0000 (17:44 -0500)
What a beautiful piece of code we can find in python:

/usr/lib/python2.6/ctypes/util.py:

    def _findLib_gcc(name):
        expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)

Basically, this match any library having "libc.so" in its name. It
should be reported to python developers as a bug, but let's not be the
first to trigger the issue in the wild.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 files changed:
Makefile.am
README
configure.ac
liblttng-ust-libc-wrapper/Makefile.am [new file with mode: 0644]
liblttng-ust-libc-wrapper/README [new file with mode: 0644]
liblttng-ust-libc-wrapper/lttng-ust-malloc.c [new file with mode: 0644]
liblttng-ust-libc-wrapper/run [new file with mode: 0755]
liblttng-ust-libc-wrapper/ust_libc.h [new file with mode: 0644]
liblttng-ust-libc/Makefile.am [deleted file]
liblttng-ust-libc/README [deleted file]
liblttng-ust-libc/lttng-ust-malloc.c [deleted file]
liblttng-ust-libc/run [deleted file]
liblttng-ust-libc/ust_libc.h [deleted file]

index 98a38810caecd5db109b15f6702209f2674b0e03..8aff58db6c371c5c6a6ac45f1f0c2968f3d09d66 100644 (file)
@@ -4,7 +4,7 @@ SUBDIRS = . include snprintf libringbuffer liblttng-ust-comm \
                liblttng-ust \
                liblttng-ust-ctl \
                liblttng-ust-fork \
-               liblttng-ust-libc \
+               liblttng-ust-libc-wrapper \
                tests
 
 if BUILD_JNI_INTERFACE
diff --git a/README b/README
index 45521d00c6fe5c8b615aadec45021b33d6a5f83e..e2b52aa026f74a3ff598c774bc034baefe01c5aa 100644 (file)
--- a/README
+++ b/README
@@ -144,7 +144,7 @@ PACKAGE CONTENTS:
   - tests
     Various test programs
 
-  - liblttng-ust-libc
+  - liblttng-ust-libc-wrapper
     An example library that can be LD_PRELOAD'ed to instrument some
     calls to libc (currently malloc() and free()) in any program without
     need to recompile it.
index 67756c4f1e2f0d4527786c4622aef67e872a1585..10b669142d2e2750c2621db5a1dc2e0c92861e98 100644 (file)
@@ -234,7 +234,7 @@ AC_CONFIG_FILES([
        liblttng-ust-ctl/Makefile
        liblttng-ust-fork/Makefile
        liblttng-ust-java/Makefile
-       liblttng-ust-libc/Makefile
+       liblttng-ust-libc-wrapper/Makefile
        tests/Makefile
        tests/hello/Makefile
        tests/hello-static-lib/Makefile
diff --git a/liblttng-ust-libc-wrapper/Makefile.am b/liblttng-ust-libc-wrapper/Makefile.am
new file mode 100644 (file)
index 0000000..6220f76
--- /dev/null
@@ -0,0 +1,13 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CFLAGS = -fno-strict-aliasing
+
+lib_LTLIBRARIES = liblttng-ust-libc-wrapper.la
+liblttng_ust_libc_wrapper_la_SOURCES = \
+       lttng-ust-malloc.c \
+       ust_libc.h
+liblttng_ust_libc_wrapper_la_LIBADD = -ldl \
+       -L$(top_builddir)/liblttng-ust/.libs \
+       -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/liblttng-ust-libc-wrapper/README b/liblttng-ust-libc-wrapper/README
new file mode 100644 (file)
index 0000000..09e17cb
--- /dev/null
@@ -0,0 +1,9 @@
+liblttng-ust-libc is used for instrumenting some calls to libc in a
+program, without need for recompiling it.
+
+This library defines a malloc() function that is instrumented with a
+tracepoint. It also calls the libc malloc afterwards. When loaded with
+LD_PRELOAD, it replaces the libc malloc() function, in effect
+instrumenting all calls to malloc(). The same is performed for free().
+
+See the "run" script for a usage example.
diff --git a/liblttng-ust-libc-wrapper/lttng-ust-malloc.c b/liblttng-ust-libc-wrapper/lttng-ust-malloc.c
new file mode 100644 (file)
index 0000000..3212ff0
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+#define _GNU_SOURCE
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <stdio.h>
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_libc.h"
+
+void *malloc(size_t size)
+{
+       static void *(*plibc_malloc)(size_t size) = NULL;
+       void *retval;
+
+       if (plibc_malloc == NULL) {
+               plibc_malloc = dlsym(RTLD_NEXT, "malloc");
+               if (plibc_malloc == NULL) {
+                       fprintf(stderr, "mallocwrap: unable to find malloc\n");
+                       return NULL;
+               }
+       }
+       retval = plibc_malloc(size);
+       tracepoint(ust_libc, malloc, size, retval);
+       return retval;
+}
+
+void free(void *ptr)
+{
+       static void *(*plibc_free)(void *ptr) = NULL;
+
+       if (plibc_free == NULL) {
+               plibc_free = dlsym(RTLD_NEXT, "free");
+               if (plibc_free == NULL) {
+                       fprintf(stderr, "mallocwrap: unable to find free\n");
+                       return;
+               }
+       }
+       tracepoint(ust_libc, free, ptr);
+       plibc_free(ptr);
+}
diff --git a/liblttng-ust-libc-wrapper/run b/liblttng-ust-libc-wrapper/run
new file mode 100755 (executable)
index 0000000..e902cd8
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-libc.so $1
diff --git a/liblttng-ust-libc-wrapper/ust_libc.h b/liblttng-ust-libc-wrapper/ust_libc.h
new file mode 100644 (file)
index 0000000..b40548f
--- /dev/null
@@ -0,0 +1,51 @@
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_libc
+
+#if !defined(_TRACEPOINT_UST_LIBC_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_LIBC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose,  provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_libc, malloc,
+       TP_ARGS(size_t, size, void *, ptr),
+       TP_FIELDS(
+               ctf_integer(size_t, size, size)
+               ctf_integer_hex(unsigned long, ptr, (unsigned long) ptr)
+       )
+)
+
+TRACEPOINT_EVENT(ust_libc, free,
+       TP_ARGS(void *, ptr),
+       TP_FIELDS(
+               ctf_integer_hex(unsigned long, ptr, (unsigned long) ptr)
+       )
+)
+
+#endif /* _TRACEPOINT_UST_LIBC_H */
+
+#undef TRACEPOINT_INCLUDE_FILE
+#define TRACEPOINT_INCLUDE_FILE ./ust_libc.h
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus 
+}
+#endif
diff --git a/liblttng-ust-libc/Makefile.am b/liblttng-ust-libc/Makefile.am
deleted file mode 100644 (file)
index 99d8ed9..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include
-AM_CFLAGS = -fno-strict-aliasing
-
-lib_LTLIBRARIES = liblttng-ust-libc.la
-liblttng_ust_libc_la_SOURCES = \
-       lttng-ust-malloc.c \
-       ust_libc.h
-liblttng_ust_libc_la_LIBADD = -ldl \
-       -L$(top_builddir)/liblttng-ust/.libs \
-       -llttng-ust
-
-noinst_SCRIPTS = run
-EXTRA_DIST = run
diff --git a/liblttng-ust-libc/README b/liblttng-ust-libc/README
deleted file mode 100644 (file)
index 09e17cb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-liblttng-ust-libc is used for instrumenting some calls to libc in a
-program, without need for recompiling it.
-
-This library defines a malloc() function that is instrumented with a
-tracepoint. It also calls the libc malloc afterwards. When loaded with
-LD_PRELOAD, it replaces the libc malloc() function, in effect
-instrumenting all calls to malloc(). The same is performed for free().
-
-See the "run" script for a usage example.
diff --git a/liblttng-ust-libc/lttng-ust-malloc.c b/liblttng-ust-libc/lttng-ust-malloc.c
deleted file mode 100644 (file)
index 3212ff0..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2009  Pierre-Marc Fournier
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
- */
-
-#define _GNU_SOURCE
-#include <dlfcn.h>
-#include <sys/types.h>
-#include <stdio.h>
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_libc.h"
-
-void *malloc(size_t size)
-{
-       static void *(*plibc_malloc)(size_t size) = NULL;
-       void *retval;
-
-       if (plibc_malloc == NULL) {
-               plibc_malloc = dlsym(RTLD_NEXT, "malloc");
-               if (plibc_malloc == NULL) {
-                       fprintf(stderr, "mallocwrap: unable to find malloc\n");
-                       return NULL;
-               }
-       }
-       retval = plibc_malloc(size);
-       tracepoint(ust_libc, malloc, size, retval);
-       return retval;
-}
-
-void free(void *ptr)
-{
-       static void *(*plibc_free)(void *ptr) = NULL;
-
-       if (plibc_free == NULL) {
-               plibc_free = dlsym(RTLD_NEXT, "free");
-               if (plibc_free == NULL) {
-                       fprintf(stderr, "mallocwrap: unable to find free\n");
-                       return;
-               }
-       }
-       tracepoint(ust_libc, free, ptr);
-       plibc_free(ptr);
-}
diff --git a/liblttng-ust-libc/run b/liblttng-ust-libc/run
deleted file mode 100755 (executable)
index e902cd8..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-LD_VERBOSE=1 LD_PRELOAD=.libs/liblttng-ust-libc.so $1
diff --git a/liblttng-ust-libc/ust_libc.h b/liblttng-ust-libc/ust_libc.h
deleted file mode 100644 (file)
index b40548f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#undef TRACEPOINT_PROVIDER
-#define TRACEPOINT_PROVIDER ust_libc
-
-#if !defined(_TRACEPOINT_UST_LIBC_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
-#define _TRACEPOINT_UST_LIBC_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose,  provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#include <lttng/tracepoint.h>
-
-TRACEPOINT_EVENT(ust_libc, malloc,
-       TP_ARGS(size_t, size, void *, ptr),
-       TP_FIELDS(
-               ctf_integer(size_t, size, size)
-               ctf_integer_hex(unsigned long, ptr, (unsigned long) ptr)
-       )
-)
-
-TRACEPOINT_EVENT(ust_libc, free,
-       TP_ARGS(void *, ptr),
-       TP_FIELDS(
-               ctf_integer_hex(unsigned long, ptr, (unsigned long) ptr)
-       )
-)
-
-#endif /* _TRACEPOINT_UST_LIBC_H */
-
-#undef TRACEPOINT_INCLUDE_FILE
-#define TRACEPOINT_INCLUDE_FILE ./ust_libc.h
-
-/* This part must be outside ifdef protection */
-#include <lttng/tracepoint-event.h>
-
-#ifdef __cplusplus 
-}
-#endif
This page took 0.030954 seconds and 4 git commands to generate.