From: Nick Alcock <nix@esperi.org.uk>
To: Kris Van Hees <kris.van.hees@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH 09/20] libdtrace: streamline kernel symbol parsing and module lookup
Date: Fri, 06 Nov 2026 12:56:47 +0000 [thread overview]
Message-ID: <87eccyt8xc.fsf@esperi.org.uk> (raw)
In-Reply-To: <bf45a777b3fc14c2223d21c81a84fd13@oracle.com>
On 30 Oct 2026, Kris Van Hees told this:
Is it really worth replacing sscanf(), which though it's a bit clunky is
at least used by other people, with even more hand-rolled parsing code?
The hex parser isn't too bad, but this:
> +static int
> +dt_modsym_parse(const char *line, int kind, dt_kallsym_t *sym)
> +{
> + const char *end;
> + uint64_t value;
> + size_t len;
> +
> + if (dt_modsym_hex(&line, &value) != 0)
> + return -1;
> + sym->addr = value;
> + sym->size = 1;
> + if (kind == DT_MODSYM_KALLMODSYMS) {
> + if (dt_modsym_hex(&line, &value) != 0 || value > SIZE_MAX)
> + return -1;
> + sym->size = value;
> + }
> + while (isspace((unsigned char)*line))
> + line++;
> + if (*line == '\0')
> + return -1;
> + sym->type = *line++;
> + if (!isspace((unsigned char)*line))
> + return -1;
> + while (isspace((unsigned char)*line))
> + line++;
> + len = strcspn(line, " \t\r\n");
> + if (len == 0 || len >= sizeof(sym->name))
> + return -1;
> + memcpy(sym->name, line, len);
> + sym->name[len] = '\0';
> + line += len;
> + while (isspace((unsigned char)*line))
> + line++;
> + if (*line == '\0') {
> + strcpy(sym->mod, "vmlinux");
> + return 0;
> + }
> + if (*line++ != '[' || (end = strchr(line, ']')) == NULL)
> + return -1;
> + len = end - line;
> + if (len == 0 || len >= sizeof(sym->mod))
> + return -1;
> + memcpy(sym->mod, line, len);
> + sym->mod[len] = '\0';
> + return 1; /* Explicit module name(s). */
> +}
... strikes me as exactly the sort of thing you should never ever do as
root.
Is sscanf() really noticable in profiles? (I guess it might be: we are
calling it hundreds of thousands of times, after all...)
--
NULL && (void)
next prev parent reply other threads:[~2026-11-06 12:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 19:36 [PATCH 09/20] libdtrace: streamline kernel symbol parsing and module lookup Kris Van Hees
2026-11-06 12:56 ` Nick Alcock [this message]
2026-11-07 15:53 ` Kris Van Hees
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=87eccyt8xc.fsf@esperi.org.uk \
--to=nix@esperi.org.uk \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=kris.van.hees@oracle.com \
/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