From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 926EA3857812 for ; Tue, 2 Mar 2021 06:00:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 926EA3857812 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-zLWI3PlOPue3MqrdFvs6VA-1; Tue, 02 Mar 2021 01:00:19 -0500 X-MC-Unique: zLWI3PlOPue3MqrdFvs6VA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 078F510066F3; Tue, 2 Mar 2021 06:00:18 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-112-51.ams2.redhat.com [10.36.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22B4B10013C1; Tue, 2 Mar 2021 06:00:16 +0000 (UTC) From: Florian Weimer To: "H.J. Lu via Libc-alpha" Subject: Re: [PATCH 1/2] ld.so: Implement the --list-diagnostics option References: <875z2hshtn.fsf@oldenburg.str.redhat.com> Date: Tue, 02 Mar 2021 07:00:19 +0100 In-Reply-To: (H. J. Lu via Libc-alpha's message of "Mon, 1 Mar 2021 15:13:19 -0800") Message-ID: <871rcy3xjg.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2021 06:00:23 -0000 * 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