Fix bug in `expr_clone`
[platform/upstream/ltrace.git] / library.c
index 0c6b483..2339153 100644 (file)
--- a/library.c
+++ b/library.c
@@ -1,6 +1,6 @@
 /*
  * This file is part of ltrace.
- * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2011,2012,2013,2014 Petr Machata, Red Hat Inc.
  * Copyright (C) 2001,2009 Juan Cespedes
  * Copyright (C) 2006 Ian Wienand
  *
@@ -20,6 +20,8 @@
  * 02110-1301 USA
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
@@ -297,6 +299,7 @@ private_library_init(struct library *lib, enum library_type type)
 
        lib->symbols = NULL;
        library_exported_names_init(&lib->exported_names);
+       lib->should_activate_latent = false;
        lib->type = type;
 
 #if defined(HAVE_LIBDW)
@@ -340,7 +343,7 @@ static int clone_vect(struct vect **to, const struct vect **from, void *data)
                           dtor_string,
                           NULL);
 }
-static void dtor_vect(const struct vect **tgt, void *data)
+static void dtor_vect(struct vect **tgt, void *data)
 {
        VECT_DESTROY(*tgt, const char*, dtor_string, NULL);
        free(*tgt);
@@ -385,7 +388,7 @@ library_exported_names_clone(struct library_exported_names *retp,
 }
 
 int library_exported_names_push(struct library_exported_names *names,
-                               uint64_t addr, const char *name,
+                               uint64_t addr, char *name,
                                int own_name )
 {
        // first, take ownership of the name, if it's not yet ours
@@ -428,7 +431,7 @@ int library_exported_names_push(struct library_exported_names *names,
        else
                aliases = *paliases;
 
-       const char *namedup = strdup(name);
+       char *namedup = strdup(name);
        if (namedup == NULL)
                return -1;
 
@@ -463,7 +466,7 @@ library_exported_names_each_alias_cb(const char **name, void *data)
 }
 
 const char** library_exported_names_each_alias(
-       const struct library_exported_names *names,
+       struct library_exported_names *names,
        const char *aliasname,
        const char **name_start_after,
        enum callback_status (*cb)(const char *,
@@ -490,8 +493,8 @@ const char** library_exported_names_each_alias(
                         library_exported_names_each_alias_cb, &context);
 }
 
-int library_exported_names_contains(const struct library_exported_names* names,
-                                   const charqueryname)
+int library_exported_names_contains(struct library_exported_names *names,
+                                   const char *queryname)
 {
        uint64_t *addr = DICT_FIND_REF(&names->names,
                                       &queryname, uint64_t);
@@ -522,6 +525,7 @@ library_clone(struct library *retp, struct library *lib)
        library_set_pathname(retp, pathname, lib->own_pathname);
 
        retp->key = lib->key;
+       retp->should_activate_latent = lib->should_activate_latent;
 
        /* Clone symbols.  */
        {
@@ -558,6 +562,12 @@ library_clone(struct library *retp, struct library *lib)
                goto fail;
        }
 
+#if defined(HAVE_LIBDW)
+       /* Wipe DWFL_MODULE, leave it to proc_add_library to
+        * initialize.  */
+       lib->dwfl_module = NULL;
+#endif
+
        return 0;
 }