mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] stacktrace: print real address of trace entries
@ 2020-09-04 10:00 Haesung Kim
  2020-09-04 16:07 ` Mark Rutland
  0 siblings, 1 reply; 2+ messages in thread
From: Haesung Kim @ 2020-09-04 10:00 UTC (permalink / raw)
  To: jirislaby, mark.rutland, akpm, mingo, geert; +Cc: linux-kernel, Haesung Kim

If function is marked as static and compiler decies to lnline function
with or without inline keyword, the function has no symbol.
We just know symbol located near the address of the inline function
by %pS type that shows symbol and offset. But we don't know function
name.
The real address let us extract the function name and location of
source code by debugging tools such as addr2line. This is helpful to
debug.

Signed-off-by: Haesung Kim <matia.kim@lge.com>
---
 kernel/stacktrace.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
index 946f44a..b7168c5 100644
--- a/kernel/stacktrace.c
+++ b/kernel/stacktrace.c
@@ -24,12 +24,15 @@ void stack_trace_print(const unsigned long *entries, unsigned int nr_entries,
 		       int spaces)
 {
 	unsigned int i;
+	unsigned long ip;
 
 	if (WARN_ON(!entries))
 		return;
 
 	for (i = 0; i < nr_entries; i++)
-		printk("%*c%pS\n", 1 + spaces, ' ', (void *)entries[i]);
+		ip = entries[i];
+		printk("%*c[<%px>] %pS\n",
+			1 + spaces, ' ', (void *) ip, (void *) ip);
 }
 EXPORT_SYMBOL_GPL(stack_trace_print);
 
@@ -47,13 +50,15 @@ int stack_trace_snprint(char *buf, size_t size, const unsigned long *entries,
 			unsigned int nr_entries, int spaces)
 {
 	unsigned int generated, i, total = 0;
+	unsigned long ip;
 
 	if (WARN_ON(!entries))
 		return 0;
 
 	for (i = 0; i < nr_entries && size; i++) {
-		generated = snprintf(buf, size, "%*c%pS\n", 1 + spaces, ' ',
-				     (void *)entries[i]);
+		ip = entries[i];
+		generated = snprintf(buf, size, "%*c[<%px>] %pS\n",
+				     1 + spaces, ' ', (void *) ip, (void *) ip);
 
 		total += generated;
 		if (generated >= size) {
-- 
2.7.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-04 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-04 10:00 [PATCH] stacktrace: print real address of trace entries Haesung Kim
2020-09-04 16:07 ` Mark Rutland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®