From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway32.websitewelcome.com (gateway32.websitewelcome.com [192.185.145.114]) by sourceware.org (Postfix) with ESMTPS id C1B25385F01B for ; Fri, 20 Mar 2020 15:36:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C1B25385F01B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 3313B9F86D for ; Fri, 20 Mar 2020 10:36:24 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id FJhAjUIPOEfyqFJhAjU9Rv; Fri, 20 Mar 2020 10:36:24 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dtCHvFmkYtNw38DvLf0OT2NPnBqmF9bmBmbenpuLQhg=; b=jLxwTj3L/bj561zNxYBJci86Kw g/XiCZQ7kqHU0YQ4X97r3LGpk+JRPfaUEt57s1pUblDqVgBg+WEZdOvX2DZMp78lO+AuBdYWPUZF4 83WGbkwTTAx504VS5C6mLjyM6; Received: from 97-118-117-21.hlrn.qwest.net ([97.118.117.21]:42988 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1jFJh9-000AXo-Nf; Fri, 20 Mar 2020 09:36:23 -0600 From: Tom Tromey To: Kamil Rytarowski Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Implement "info proc mappings" for NetBSD References: <20200316173424.25375-1-n54@gmx.com> X-Attribution: Tom Date: Fri, 20 Mar 2020 09:36:22 -0600 In-Reply-To: <20200316173424.25375-1-n54@gmx.com> (Kamil Rytarowski's message of "Mon, 16 Mar 2020 18:34:24 +0100") Message-ID: <875zezm421.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.117.21 X-Source-L: No X-Exim-ID: 1jFJh9-000AXo-Nf X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-117-21.hlrn.qwest.net (murgatroyd) [97.118.117.21]:42988 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_PASS, SPF_NEUTRAL, URIBL_CSS, URIBL_CSS_A 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2020 15:36:26 -0000 >>>>> "Kamil" == Kamil Rytarowski writes: Kamil> Define nbsd_nat_target::find_memory_regions and Kamil> nbsd_nat_target::info_proc. info_proc handles as of now only Kamil> the "mappings" command. Thank you for the patch. Kamil> +/* Retrieve all the memory regions in the specified process. */ Kamil> + Kamil> +static struct kinfo_vmentry * Kamil> +kinfo_get_vmmap(pid_t pid, size_t *size) Space before paren. There are multiple instances of this in the patch. Kamil> +{ Kamil> + int mib[5] = {CTL_VM, VM_PROC, VM_PROC_MAP, pid, sizeof(struct kinfo_vmentry)}; Kamil> + Kamil> + size_t length = 0; Kamil> + if (sysctl(mib, ARRAY_SIZE (mib), NULL, &length, NULL, 0)) { GNU style is to put the open brace on its own line. There are several cases of this as well. Kamil> + if (sysctl(mib, ARRAY_SIZE (mib), kiv, &length, NULL, 0)) { Kamil> + *size = 0; Kamil> + free(kiv); xfree, though these days in gdb it's better to create and return a self-managing object, like gdb::unique_xmalloc_ptr<>. Kamil> + Kamil> +int Kamil> +nbsd_nat_target::find_memory_regions (find_memory_region_ftype func, Kamil> + void *obfd) I wouldn't name that parameter "obfd" but rather "data" or "user_data" or something like that. The name "obfd" in gdb normally implies that it is a "BFD *", but this is just opaque data that's shared by the caller and the callback. Kamil> diff --git a/gdb/nbsd-tdep.c b/gdb/nbsd-tdep.c [...] Kamil> +/* Flags in the 'kve_protection' field in struct kinfo_vmentry. These Kamil> + match the KVME_PROT_* constants in . */ What if they stop matching? I wonder if this code really ought to be in the tdep file. I suppose so, if it will be used somehow when cross debugging... but will that happen? If not then maybe putting it in the -nat file is better; and then the appropriate NetBSD headers could be used. Kamil> + printf_filtered (_("Mapped address spaces:\n\n")); Kamil> + if (addr_bit == 64) Kamil> + { Kamil> + printf_filtered (" %18s %18s %10s %10s %9s %s\n", Kamil> + "Start Addr", Kamil> + " End Addr", Kamil> + " Size", " Offset", "Flags ", "File"); Kamil> + } Kamil> + else Kamil> + { Kamil> + printf_filtered ("\t%10s %10s %10s %10s %9s %s\n", Kamil> + "Start Addr", Kamil> + " End Addr", Kamil> + " Size", " Offset", "Flags ", "File"); Personally I like using ui-out tables instead of this kind of thing. Tom