From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/2] ld.so: Implement the --list-diagnostics option
Date: Tue, 02 Mar 2021 07:00:19 +0100 [thread overview]
Message-ID: <871rcy3xjg.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAMe9rOrc7Mg4pKnrgQiwrxce+oEKm9S9cXFyipucvRqg-JNK8g@mail.gmail.com> (H. J. Lu via Libc-alpha's message of "Mon, 1 Mar 2021 15:13:19 -0800")
* H. J. Lu via Libc-alpha:
>> +void
>> +_dl_diagnostics_print_labeled_value (const char *label, uint64_t value)
>> +{
>> + if (sizeof (value) == sizeof (unsigned long int))
>> + /* _dl_printf can print 64-bit values directly. */
>> + _dl_printf ("%s=0x%lx\n", label, (unsigned long int) value);
>> + else
>> + {
>> + uint32_t high = value >> 32;
>> + uint32_t low = value;
>> + if (high == 0)
>> + _dl_printf ("%s=0x%x\n", label, low);
>> + else
>> + _dl_printf ("%s=0x%x%08x\n", label, high, low);
>> + }
>> +}
>
> You want to print out everything in strings and values.
If I don't know that the value is a valid pointer, I can't print it as a
string.
>> + static const char unfiltered[] =
>> + "DATEMSK\0"
>> + "GCONV_PATH\0"
>> + "GETCONF_DIR\0"
>> + "GETCONF_DIR\0"
>> + "GLIBC_TUNABLES\0"
>> + "GMON_OUTPUT_PREFIX\0"
>> + "HESIOD_CONFIG\0"
>> + "HES_DOMAIN\0"
>> + "HOSTALIASES\0"
>> + "I18NPATH\0"
>> + "IFS\0"
>> + "LANG\0"
>> + "LOCALDOMAIN\0"
>> + "LOCPATH\0"
>> + "MSGVERB\0"
>> + "NIS_DEFAULTS\0"
>> + "NIS_GROUP\0"
>> + "NIS_PATH\0"
>> + "NLSPATH\0"
>> + "PATH\0"
>> + "POSIXLY_CORRECT\0"
>> + "RESOLV_HOST_CONF\0"
>> + "RES_OPTIONS\0"
>> + "SEV_LEVEL\0"
>> + "TMPDIR\0"
>> + "TZ\0"
>> + "TZDIR\0"
>
> Any particular reason to have double '\0' at the end of string?
> Will a single '\0' work?
It's necessary to recognize the end of the list.
>> +/* On Hurd, uname is not available on ld.so. This corresponds to a
>> + missing domainname member. */
>> +#define PRINT_UNAME (_UTSNAME_DOMAIN_LENGTH > 0)
>> +
>> +#if PRINT_UNAME
>> +/* Print one uname entry. */
>> +static void
>> +print_utsname_entry (const char *field, const char *value)
>> +{
>> + _dl_printf ("uname.");
>> + _dl_diagnostics_print_labeled_string (field, value);
>> +}
>> +
>> +/* Print information from uname, including the kernel version. */
>> +static void
>> +print_uname (void)
>> +{
>> + struct utsname uts;
>> + if (__uname (&uts) == 0)
>> + {
>> + print_utsname_entry ("sysname", uts.sysname);
>> + print_utsname_entry ("nodename", uts.nodename);
>> + print_utsname_entry ("release", uts.release);
>> + print_utsname_entry ("version", uts.version);
>> + print_utsname_entry ("machine", uts.machine);
>> + print_utsname_entry ("domainname", uts.domainname);
>> + }
>> +}
>> +#endif
>
> Put it under sysdeps/generic?
Okay, will do that.
Thanks,
Florian
prev parent reply other threads:[~2021-03-02 6:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-24 13:42 Florian Weimer
2021-02-24 13:43 ` [PATCH 2/2] x86: Add CPU-specific diagnostics to ld.so --list-diagnostics Florian Weimer
2021-03-01 23:20 ` H.J. Lu
2021-03-02 6:32 ` Florian Weimer
2021-03-01 9:12 ` [PATCH 1/2] ld.so: Implement the --list-diagnostics option Florian Weimer
2021-03-01 23:13 ` H.J. Lu
2021-03-02 6:00 ` Florian Weimer [this message]
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=871rcy3xjg.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).