From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 123600 invoked by alias); 13 Mar 2015 19:37:36 -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 123588 invoked by uid 89); 13 Mar 2015 19:37:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 13 Mar 2015 19:37:34 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2DJbXqm008200 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 13 Mar 2015 15:37:33 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2DJbVCn023318; Fri, 13 Mar 2015 15:37:32 -0400 Message-ID: <55033C7B.6040601@redhat.com> Date: Fri, 13 Mar 2015 19:37:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Sergio Durigan Junior , GDB Patches CC: Jan Kratochvil , Oleg Nesterov Subject: Re: [PATCH] Improve corefile generation by using /proc/PID/coredump_filter (PR corefile/16902) References: <878ufc9kau.fsf@redhat.com> In-Reply-To: <878ufc9kau.fsf@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-03/txt/msg00403.txt.bz2 On 03/05/2015 03:48 AM, Sergio Durigan Junior wrote: > In a nutshell, what the new code is doing is: > > - If the mapping is associated to a file whose name ends with " > (deleted)", or if the file is "/dev/zero", or if it is "/SYSV%08x" > (shared memory), or if there is no file associated with it, or if the > AnonHugePages: or the Anonymous: fields in the /proc/PID/smaps have > contents, then GDB considers this mapping to be anonymous. Otherwise, > GDB considers this mapping to be a file-backed mapping (because there > will be a file associated with it). > > It is worth mentioning that, from all those checks described above, > the most fragile is the one to see if the file name ends with " > (deleted)". This does not necessarily mean that the mapping is > anonymous, because the deleted file associated with the mapping may > have been a hard link to another file, for example. The Linux kernel > checks to see if "i_nlink == 0", but GDB cannot easily do this check. > Therefore, we made a compromise here, and we assume that if the file > name ends with " (deleted)", then the mapping is indeed anonymous. > FWIW, this is something the Linux kernel could do better: expose this > information in a more direct way. > > - If we see the flag "sh" in the VmFlags: field (in /proc/PID/smaps), > then certainly the memory mapping is shared (VM_SHARED). If we have > access to the VmFlags, and we don't see the "sh" there, then certainly > the mapping is private. However, older Linus kernels do not have the > VmFlags field; in that case, we use another heuristic: if we see 'p' > in the permission flags, then we assume that the mapping is private, > even though the presence of the 's' flag there would mean VM_MAYSHARE, > which means the mapping could still be private. This should work OK > enough, however. I missed seeing a git commit log in v2, but looking here, I think it'd be good to move paragraphs to the code instead, to a general overview section, even. Thanks, Pedro Alves