[ltrace-commits] 05/06: Fixed bug where an aliased symbol was breaking DWARF filtering

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 3eaba10c5fdc01f0de09d28b18a27e6d160470d7
Author: Dima Kogan <dima at secretsauce.net>
Date:   Sat Jul 26 01:50:48 2014 -0700

    Fixed bug where an aliased symbol was breaking DWARF filtering
    
    On my machine (Debian amd64) I was seeing
    
     dima at shorty:$ ltrace -L -x '*ftell at libc.so*' ./dwarf
     ftell at libc.so.6(0x7f71126bc4e0)     = -1
    
    which is corect; ftell() DWARF information was correctly interpreted, and we
    know that ftell() takes one argument. However filtering more specifically, the
    DWARF parsing appears to fail:
    
     dima at shorty:$ ltrace -L -x 'ftell at libc.so*' ./dwarf
     ftell at libc.so.6(0x7fb58872f4e0, 0x7fffb846b0c0, 7, 0x7fffb846b080)     = -1
    
    Here we use the default (and wrong) prototype for ftell(). The issue is that
    ftell() is an aliased symbol, and the DWARF parser only adds symbols that pass
    the filter. This patch looks to see if the alias names pass the filter too, and
    if they do, the DWARF prototypes are accepted. This makes the above work.
---
 dwarf_prototypes.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/dwarf_prototypes.c b/dwarf_prototypes.c
index a39219e..85b0278 100644
--- a/dwarf_prototypes.c
+++ b/dwarf_prototypes.c
@@ -905,13 +905,42 @@ static bool get_prototype(struct prototype *result,
 #undef CLEANUP_AND_RETURN_ERROR
 }
 
+
+static enum callback_status
+any_filter_matches_function_cb(const char *name, void *data)
+{
+	struct library *lib = (struct library*)data;
+
+	return CBS_STOP_IF(
+		filter_matches_symbol(options.plt_filter,    name, lib) ||
+		filter_matches_symbol(options.static_filter, name, lib) ||
+		filter_matches_symbol(options.export_filter, name, lib));
+}
+static bool any_filter_matches_function(const char *function_name,
+					struct library *lib,
+					Dwarf_Die *die)
+{
+	// I give up if this function is not wanted AND if none of its aliased
+	// names are wanted
+	if (any_filter_matches_function_cb(function_name, lib) == CBS_STOP)
+		return true;
+
+	// prototype not found. Is it aliased?
+	if (library_exported_names_each_alias(&lib->exported_names,
+					      function_name, NULL,
+					      any_filter_matches_function_cb,
+					      lib) != NULL)
+		return true;
+
+	complain(die, "Prototype not requested by any filter");
+	return false;
+
+}
 static bool import_subprogram_name(struct protolib *plib, struct library *lib,
 				   struct dict *type_dieoffset_hash,
-				   Dwarf_Die *die, const char* function_name)
+				   Dwarf_Die *die, const char *function_name)
 {
-	if (!filter_matches_symbol(options.plt_filter,    function_name, lib) &&
-	    !filter_matches_symbol(options.static_filter, function_name, lib) &&
-	    !filter_matches_symbol(options.export_filter, function_name, lib)) {
+	if (!any_filter_matches_function( function_name, lib, die)) {
 		complain(die, "Prototype not requested by any filter");
 		return true;
 	}

-- 
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