From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Keir Fraser <keir@xen.org>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH] common/symbols: Drop '+0/<len>' when printing function pointer symbols.
Date: Fri, 4 Oct 2013 11:02:33 +0100 [thread overview]
Message-ID: <1380880953-20453-1-git-send-email-andrew.cooper3@citrix.com> (raw)
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@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <jbeulich@suse.com>
---
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
next reply other threads:[~2013-10-04 10:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-04 10:02 Andrew Cooper [this message]
2013-10-04 10:12 ` [PATCH] common/symbols: Drop '+0/<len>' when printing function pointer symbols Ian Campbell
2013-10-04 10:15 ` Jan Beulich
2013-10-04 10:18 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1380880953-20453-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=keir@xen.org \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).