From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 53836 invoked by alias); 16 Sep 2018 02:27:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 53800 invoked by uid 89); 16 Sep 2018 02:27:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=wash, kinfo_file X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 16 Sep 2018 02:27:03 +0000 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id C1CF71E16B; Sat, 15 Sep 2018 22:27:00 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=simark.ca; s=mail; t=1537064821; bh=QRpo+wZIDjJzK0nCv/IZbpKnrnEhFPC8fEaW4BM94X0=; h=Subject:To:References:From:Date:In-Reply-To:From; b=Fne/DDZ0ljoUIQjs8eVUV5yB9IaUPOqsEeTjV69Lm3gMGE1v4cwDHlW6j1jE0BJzT EXw5bKbOEdme/v5WfL+ObcFcLMWlPpg0fGjHbVQJ1NbHv1xp6Go/njCleb31SD5YFR R2YoyGduilibM6TdZ0NBquEnVY+BDvNIgiOb0njY= Subject: Re: [PATCH v2 3/6] Add support for 'info proc files' on FreeBSD core dumps. To: John Baldwin , gdb-patches@sourceware.org References: <20180912233707.43492-1-jhb@FreeBSD.org> <20180912233707.43492-4-jhb@FreeBSD.org> From: Simon Marchi Message-ID: Date: Sun, 16 Sep 2018 02:27:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180912233707.43492-4-jhb@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-09/txt/msg00517.txt.bz2 Some nits about the comments, otherwise LGTM (I didn't check the bits-reading code in detail, I assumed it wash largely unchanged). On 2018-09-12 7:37 p.m., John Baldwin wrote: > +static void > +fbsd_print_sockaddr_in6 (const void *sockaddr) > +{ > + const struct fbsd_sockaddr_in6 *sin6 = > + reinterpret_cast(sockaddr); > + uint16_t words[ARRAY_SIZE(sin6->sin6_addr) / 2]; > + > + /* Populate the array of 16-bit words from network-order bytes. */ > + for (int i = 0; i < ARRAY_SIZE(words); i++) > + words[i] = (sin6->sin6_addr[i * 2] << 8) | sin6->sin6_addr[i * 2 + 1]; > + > + /* Find the longest run of zero words. */ > + int best, bestlen, current, len; > + > + best = -1; > + bestlen = 0; > + current = -1; > + len = 0; > + for (int i = 0; i < ARRAY_SIZE(words); i++) > + { > + if (words[i] == 0) > + { > + if (current >= 0) > + len++; > + else > + { > + current = i; > + len = 1; > + } > + } > + else > + { > + if (current >= 0 && len > bestlen) > + { > + best = current; > + bestlen = len; > + } > + current = -1; > + len = 0; > + } > + } > + if (current >= 0 && len > bestlen) > + { > + best = current; > + bestlen = len; > + } > + if (bestlen < 2) > + best = -1; > + > + for (int i = 0; i < ARRAY_SIZE(words); i++) > + { > + if (best >= 0 && i >= best && i < best + bestlen) > + { > + if (i == best || i == ARRAY_SIZE(words) - 1) > + printf_filtered (":"); > + } > + else > + { > + if (i != 0) > + printf_filtered (":"); > + printf_filtered ("%x", words[i]); > + } > + } > + printf_filtered (".%u", (sin6->sin6_port[0] << 8) | sin6->sin6_port[1]); > +} > + > +/* Output the header for "info proc files". */ This should be /* See fbsd-tdep.h. */, same for fbsd_info_proc_files_entry. > +void > +fbsd_info_proc_files_header () > +{ > + printf_filtered (_("Open files:\n\n")); > + printf_filtered (" %6s %6s %10s %9s %s\n", > + "FD", "Type", "Offset", "Flags ", "Name"); > +} ... > +/* Output description of a single file descriptor for "info proc > + files". The KF_TYPE, KF_FD, KF_FLAGS, KF_OFFSET, KF_VNODE_TYPE, > + KF_SOCK_DOMAIN, KF_SOCK_TYPE, and KF_SOCK_PROTOCOL parameters > + should contain the value of the corresponding fields in a 'struct > + kinfo_file'. The KF_SA_LOCAL, KF_SA_PEER, and KF_PATH parameters > + should contain pointers to the corresponding fields in a 'struct > + kinfo_file'. */ Some parameters name in the doc here don't match the actual names below. > +extern void fbsd_info_proc_files_entry (int kf_type, int kf_fd, int kf_flags, > + LONGEST kf_offset, int kf_vnode_type, > + int kf_sock_domain, int kf_sock_type, > + int kf_sock_protocol, > + const void *kf_sa_local, > + const void *fa_sa_peer, > + const void *path); > + Simon