kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: William Tambe <tambewilliam@gmail.com>
To: "Valentin Vidić" <vvidic@valentin-vidic.from.hr>
Cc: kernelnewbies@kernelnewbies.org
Subject: Re: printk() format %pS wrong symbol
Date: Mon, 6 Jul 2020 18:06:42 -0400	[thread overview]
Message-ID: <CAF8i9mN1QGohck4BrRONrx=5+aNgnFR0T70ifz3nSrN5J=oBBA@mail.gmail.com> (raw)
In-Reply-To: <20200704171433.GD6573@valentin-vidic.from.hr>

On Sat, Jul 4, 2020 at 1:15 PM Valentin Vidić
<vvidic@valentin-vidic.from.hr> wrote:
>
> On Sat, Jul 04, 2020 at 12:04:59PM -0400, William Tambe wrote:
> > How or which function within that file translates an address to the string
> > symbol+offset for the format %pS ?
>
> %pS seems to end up in here:

Thanks,
the issue I am having is due to sprint_backtrace() calling
__sprint_symbol() with its argument symbol_offset == -1.
Despite the comment above its definition, it is hard to understand why
sprint_backtrace() calls __sprint_symbol() that way; in our port it
results in printing incorrect symbols.
As a workaround, we have made sprint_backtrace() to be the same as
sprint_symbol().

>
> static int __sprint_symbol(char *buffer, unsigned long address,
>                            int symbol_offset, int add_offset)
> {
>         char *modname;
>         const char *name;
>         unsigned long offset, size;
>         int len;
>
>         address += symbol_offset;
>         name = kallsyms_lookup(address, &size, &offset, &modname, buffer);
>         if (!name)
>                 return sprintf(buffer, "0x%lx", address - symbol_offset);
>
>         if (name != buffer)
>                 strcpy(buffer, name);
>         len = strlen(buffer);
>         offset -= symbol_offset;
>
>         if (add_offset)
>                 len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);
>
>         if (modname)
>                 len += sprintf(buffer + len, " [%s]", modname);
>
>         return len;
> }
>
> --
> Valentin
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2020-07-06 22:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 10:11 printk() format %pS wrong symbol William Tambe
2020-07-04 10:29 ` Valentin Vidić
2020-07-04 16:04   ` William Tambe
2020-07-04 17:14     ` Valentin Vidić
2020-07-06 22:06       ` William Tambe [this message]
2020-07-07 18:39         ` Valentin Vidić
2020-07-07 18:53           ` Valentin Vidić

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='CAF8i9mN1QGohck4BrRONrx=5+aNgnFR0T70ifz3nSrN5J=oBBA@mail.gmail.com' \
    --to=tambewilliam@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=vvidic@valentin-vidic.from.hr \
    /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).