[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] common/symbols: Drop '+0/<len>' when printing function pointer symbols.



Introduce print_function() with the same semantics as print_symbol().  The
underlying __print_symbol() now takes an extra boolean indicating whether we
are expecting to print a function pointer.   In the case that we are expecting
a function pointer, and the offset is 0, drop the offset and length.

The requirement for offset being 0 is for the (hopefully never, but we really
want to know if it does happen) case where a Xen function pointer is not
actually pointing at the start of a function.

The relevent print_symbol() functions are updated to print_function()

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/irq.c        |    2 +-
 xen/arch/x86/time.c       |    4 ++--
 xen/common/symbols.c      |    7 +++++--
 xen/common/timer.c        |    2 +-
 xen/include/xen/symbols.h |   16 +++++++++++++---
 5 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index c61cc46..c349dd2 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2280,7 +2280,7 @@ static void dump_irqs(unsigned char key)
             printk("\n");
         }
         else if ( desc->action )
-            print_symbol("%s\n", (unsigned long)desc->action->handler);
+            print_function("%s()\n", (unsigned long)desc->action->handler);
         else
             printk("mapped, unbound\n");
 
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index c1bbd50..d857650 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1475,8 +1475,8 @@ static int 
_disable_pit_irq(void(*hpet_broadcast_setup)(void))
         {
             if ( xen_cpuidle > 0 )
             {
-                print_symbol("%s() failed, turning to PIT broadcast\n",
-                             (unsigned long)hpet_broadcast_setup);
+                print_function("%s() failed, turning to PIT broadcast\n",
+                               (unsigned long)hpet_broadcast_setup);
                 return -1;
             }
             ret = 0;
diff --git a/xen/common/symbols.c b/xen/common/symbols.c
index 83b2b58..9dcaaba 100644
--- a/xen/common/symbols.c
+++ b/xen/common/symbols.c
@@ -150,7 +150,7 @@ const char *symbols_lookup(unsigned long addr,
 }
 
 /* Replace "%s" in format with address, or returns -errno. */
-void __print_symbol(const char *fmt, unsigned long address)
+void __print_symbol(const char *fmt, unsigned long address, bool_t fnptr)
 {
     const char *name;
     unsigned long offset, size, flags;
@@ -168,7 +168,10 @@ void __print_symbol(const char *fmt, unsigned long address)
     if (!name)
         snprintf(buffer, BUFFER_SIZE, "???");
     else
-        snprintf(buffer, BUFFER_SIZE, "%s+%#lx/%#lx", name, offset, size);
+        if ( fnptr && offset == 0 )
+            snprintf(buffer, BUFFER_SIZE, "%s", name);
+        else
+            snprintf(buffer, BUFFER_SIZE, "%s+%#lx/%#lx", name, offset, size);
 
     printk(fmt, buffer);
 
diff --git a/xen/common/timer.c b/xen/common/timer.c
index 9ed74e9..2008aa3 100644
--- a/xen/common/timer.c
+++ b/xen/common/timer.c
@@ -513,7 +513,7 @@ static void dump_timer(struct timer *t, s_time_t now)
 {
     printk("  ex=%8"PRId64"us timer=%p cb=%p(%p)",
            (t->expires - now) / 1000, t, t->function, t->data);
-    print_symbol(" %s\n", (unsigned long)t->function);
+    print_function(" %s()\n", (unsigned long)t->function);
 }
 
 static void dump_timerq(unsigned char key)
diff --git a/xen/include/xen/symbols.h b/xen/include/xen/symbols.h
index 37cf6bf..866231e 100644
--- a/xen/include/xen/symbols.h
+++ b/xen/include/xen/symbols.h
@@ -11,8 +11,12 @@ const char *symbols_lookup(unsigned long addr,
                            unsigned long *offset,
                            char *namebuf);
 
-/* Replace "%s" in format with address, if found */
-void __print_symbol(const char *fmt, unsigned long address);
+/*
+ * Replace "%s" in format with address, if found.  'fnptr' indicates a
+ * function pointer address is expected, in which case the '+0/<length>' is
+ * dropped for clarity.
+ */
+void __print_symbol(const char *fmt, unsigned long address, bool_t fnptr);
 
 /* This macro allows us to keep printk typechecking */
 static void __check_printsym_format(const char *fmt, ...)
@@ -31,7 +35,13 @@ static void __check_printsym_format(const char *fmt, ...)
 #define print_symbol(fmt, addr)                        \
 do {                                           \
        __check_printsym_format(fmt, "");       \
-       __print_symbol(fmt, addr);              \
+       __print_symbol(fmt, addr, 0);           \
+} while(0)
+
+#define print_function(fmt, addr)              \
+do {                                           \
+       __check_printsym_format(fmt, "");       \
+       __print_symbol(fmt, addr, 1);           \
 } while(0)
 
 #endif /*_XEN_SYMBOLS_H*/
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.