From e880de741678a4c5b174a4c002e19c38b5f7769f Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 28 Feb 2010 23:29:40 +0100 Subject: controled config bug fix liberty controled by autoconf now --- ChangeLog | 4 ++++ configure.ac | 11 +++++++++++ src/Makefile | 6 ++++-- src/audit-init.c | 18 +++++++++++++++--- src/autoconf.h.in | 3 +++ src/autoconf.make.in | 2 ++ src/config.c | 6 ++++++ src/output.c | 4 ++++ 8 files changed, 49 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0662f76..3d1b688 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-02-28 Jiri Olsa + * controled config bug fix + * liberty controled by autoconf now + 2010-02-13 Jiri Olsa * controled config feature * disable auditing feature diff --git a/configure.ac b/configure.ac index 96e9ee3..33588df 100644 --- a/configure.ac +++ b/configure.ac @@ -83,6 +83,17 @@ elif test "$unamem" = "i686"; then AC_DEFINE(LT_ARCH_X86, 1, [The x86 arch.]) fi +CONFIG_LIBERTY=[] +AC_SEARCH_LIBS(cplus_demangle,iberty, + [iberty_found=yes], + [iberty_found=no],[]) +if test "$iberty_found" = "yes"; then + AC_DEFINE(LT_LIBERTY, 1, "Liberty found.") + CONFIG_LIBERTY=[-liberty] +fi + +AC_SUBST(CONFIG_LIBERTY) + AC_CONFIG_HEADER([src/autoconf.h]) AC_CONFIG_FILES([src/autoconf.make]) AC_CONFIG_FILES([doc/asciidoc.conf]) diff --git a/src/Makefile b/src/Makefile index bc625bf..54c7ec7 100644 --- a/src/Makefile +++ b/src/Makefile @@ -20,7 +20,8 @@ # libltaudit.so AUDIT_BIN=libltaudit.so.$(LT_VER) AUDIT_LDFLAGS="-Wl,-init=audit_init" "-Wl,-soname,$(AUDIT_BIN)" -fPIC -shared -AUDIT_LIBS=-liberty +AUDIT_LIBS=$(CONFIG_LIBERTY) + AUDIT_OBJS=\ src/audit.o \ src/audit-init.o \ @@ -44,7 +45,8 @@ install:: # latrace binary LATRACE_BIN=latrace LATRACE_CTL=latrace-ctl -LATRACE_LIB=-liberty +LATRACE_LIB= $(CONFIG_LIBERTY) + LATRACE_OBJS=\ src/latrace.o \ src/ctl.o \ diff --git a/src/audit-init.c b/src/audit-init.c index b5ad366..a3c0cf7 100644 --- a/src/audit-init.c +++ b/src/audit-init.c @@ -33,11 +33,17 @@ struct lt_config_audit cfg; -static int init_ctl_config(int fd) +static int init_ctl_config(char *file) { void *sh; int len; int page = sysconf(_SC_PAGE_SIZE); + int fd; + + if (-1 == (fd = open(file, O_RDWR))) { + perror("open failed"); + return -1; + } /* align the shared config length */ len = sizeof(struct lt_config_shared); @@ -69,7 +75,7 @@ static int read_config(char *dir) cfg.dir = dir; sprintf(file, "%s/config", dir); - if (-1 == (fd = open(file, O_RDWR))) { + if (-1 == (fd = open(file, O_RDONLY))) { perror("open failed"); return -1; } @@ -96,7 +102,13 @@ static int read_config(char *dir) cfg.sh = cfg.sh_storage.sh = &cfg.sh_storage; - if (lt_sh(&cfg, ctl_config) && init_ctl_config(fd)) + /* + * If we are not controled, we can close the file, + * since we read everything we needed. + */ + close(fd); + + if (lt_sh(&cfg, ctl_config) && init_ctl_config(file)) printf("ctl config failed, carring on with standard\n"); return 0; diff --git a/src/autoconf.h.in b/src/autoconf.h.in index efcc490..bf6ed9d 100644 --- a/src/autoconf.h.in +++ b/src/autoconf.h.in @@ -33,4 +33,7 @@ /* x86_64 define. */ #undef LT_ARCH_X86_64 +/* liberty */ +#undef LT_LIBERTY + #endif diff --git a/src/autoconf.make.in b/src/autoconf.make.in index c162165..eec759e 100644 --- a/src/autoconf.make.in +++ b/src/autoconf.make.in @@ -39,4 +39,6 @@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ CONFIG_SYSDEP_DIR = @CONFIG_SYSDEP_DIR@ +CONFIG_LIBERTY = @CONFIG_LIBERTY@ + LT_VER = @LT_VER@ diff --git a/src/config.c b/src/config.c index 7cb4672..a52a489 100644 --- a/src/config.c +++ b/src/config.c @@ -221,6 +221,12 @@ int lt_config(struct lt_config_app *cfg, int argc, char **argv) break; case 'd': + #ifndef LT_LIBERTY + printf("demangle support not compiled in," \ + " liberty not found\n"); + break; + #endif + lt_sh(cfg, demangle) = 1; break; diff --git a/src/output.c b/src/output.c index cadf3c6..5a569ae 100644 --- a/src/output.c +++ b/src/output.c @@ -56,6 +56,7 @@ do { \ /* libiberty external */ extern char* cplus_demangle(const char *mangled, int options); +#ifdef LT_LIBERTY #define DEMANGLE(sym, d) \ do { \ char *dem; \ @@ -65,6 +66,9 @@ do { \ d = 1; \ } \ } while(0) +#else +#define DEMANGLE(sym, d) +#endif int lt_out_entry(struct lt_config_shared *cfg, struct timeval *tv, -- cgit