diff options
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/mtrace.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/malloc/mtrace.c b/malloc/mtrace.c index 86f89540d4..02da0ae764 100644 --- a/malloc/mtrace.c +++ b/malloc/mtrace.c @@ -97,11 +97,22 @@ tr_where (caller) Dl_info info; if (_dl_addr (caller, &info)) { - fprintf (mallstream, "@ %s%s%s%s%s[%p]", + char *buf = (char *) ""; + if (info.dli_sname && info.dli_sname[0]) + { + size_t len = strlen (info.dli_sname) + 22; + buf = alloca (len); + if (caller >= (const __ptr_t) info.dli_saddr) + snprintf (buf, len, "(%s+0x%x)", info.dli_sname, + caller - (const __ptr_t) info.dli_saddr); + else + snprintf (buf, len, "(%s-0x%x)", info.dli_sname, + (const __ptr_t) info.dli_saddr - caller); + } + + fprintf (mallstream, "@ %s%s%s[%p] ", info.dli_fname ?: "", info.dli_fname ? ":" : "", - info.dli_sname ? "(" : "", - info.dli_sname ?: "", info.dli_sname ? ") " : " ", - caller); + buf, caller); } else #endif |