[ltrace-commits] 01/06: added debugging functions to dump the protolib, symbols

Petr Machata pmachata-guest at moszumanska.debian.org
Tue Sep 2 13:26:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

pmachata-guest pushed a commit to branch pmachata/dima-rebase
in repository ltrace.

commit 1a0806372c8f493de733c9158b68c4a2a0d307a6
Author: Dima Kogan <dima at secretsauce.net>
Date:   Sat May 3 23:02:36 2014 -0700

    added debugging functions to dump the protolib, symbols
---
 library.c   | 28 ++++++++++++++++++++++++++++
 library.h   |  5 +++++
 prototype.c | 13 +++++++++++++
 prototype.h |  3 +++
 4 files changed, 49 insertions(+)

diff --git a/library.c b/library.c
index 2339153..f19b00d 100644
--- a/library.c
+++ b/library.c
@@ -671,3 +671,31 @@ library_with_key_cb(struct process *proc, struct library *lib, void *keyp)
 {
 	return lib->key == *(arch_addr_t *)keyp ? CBS_STOP : CBS_CONT;
 }
+
+static enum callback_status
+library_dump_aliases_cb(const char **name, void *data)
+{
+	(void)data;
+	fprintf(stderr, "%s ", *name);
+	return CBS_CONT;
+}
+
+static enum callback_status
+library_dump_cb(uint64_t *addr, struct vect **aliases, void *data)
+{
+	(void)data;
+	VECT_EACH_CST(*aliases, const char*, NULL,
+		      library_dump_aliases_cb, NULL);
+	fprintf(stderr, "\n");
+	return CBS_CONT;
+}
+
+void
+library_dump_symbols(const struct library *lib)
+{
+	fprintf(stderr, "symbol dump start for soname '%s' ===\n", lib->soname);
+
+	DICT_EACH(&lib->exported_names.addrs, uint64_t, struct vect*, NULL,
+		  library_dump_cb, NULL);
+	fprintf(stderr, "symbol dump end =========\n");
+}
diff --git a/library.h b/library.h
index 03d6dc1..27abbb8 100644
--- a/library.h
+++ b/library.h
@@ -291,4 +291,9 @@ const char** library_exported_names_each_alias(
 int library_exported_names_contains(struct library_exported_names *names,
 				    const char *queryname);
 
+/* Debugging function to dump all known library symbols (and their aliases) to
+ * stderr */
+void library_dump_symbols(const struct library *lib);
+
+
 #endif /* LIBRARY_H */
diff --git a/prototype.c b/prototype.c
index fa52ff3..65cfef3 100644
--- a/prototype.c
+++ b/prototype.c
@@ -195,6 +195,19 @@ is_or_imports(struct protolib **plibp, void *data)
 		return CBS_CONT;
 }
 
+static
+enum callback_status dump_prototypes_cb(void *key, void *value, void *data)
+{
+	fprintf(stderr, "    Have prototype '%s'\n", *(char**)key);
+	return CBS_CONT;
+}
+void protolib_dump_prototypes(const struct protolib *plib)
+{
+	fprintf(stderr, "protolib dump start =========\n");
+	dict_each(&plib->prototypes, NULL, dump_prototypes_cb, NULL);
+	fprintf(stderr, "protolib dump end =========\n");
+}
+
 int
 protolib_add_import(struct protolib *plib, struct protolib *import)
 {
diff --git a/prototype.h b/prototype.h
index cbb6ed2..815146b 100644
--- a/prototype.h
+++ b/prototype.h
@@ -230,6 +230,9 @@ int protolib_cache_protolib(struct protolib_cache *cache,
 			    const char *filename, int own_filename,
 			    struct protolib *plib);
 
+/* Debugging function to dump all known prototypes to stderr */
+void protolib_dump_prototypes(const struct protolib *plib);
+
 /* Single global prototype cache.
  *
  * XXX Eventually each ABI should have its own cache.  The idea is

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/ltrace.git



More information about the ltrace-commits mailing list