From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11475 invoked by alias); 18 Dec 2011 12:38:10 -0000 Received: (qmail 11456 invoked by uid 22791); 18 Dec 2011 12:38:09 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-vw0-f41.google.com (HELO mail-vw0-f41.google.com) (209.85.212.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 18 Dec 2011 12:37:56 +0000 Received: by vbbfn1 with SMTP id fn1so4074431vbb.0 for ; Sun, 18 Dec 2011 04:37:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.188.193 with SMTP id gc1mr9601179vdc.19.1324211875625; Sun, 18 Dec 2011 04:37:55 -0800 (PST) Received: by 10.52.34.35 with HTTP; Sun, 18 Dec 2011 04:37:55 -0800 (PST) In-Reply-To: <20111214211652.GO2203@ZenIV.linux.org.uk> References: <20111214211652.GO2203@ZenIV.linux.org.uk> Date: Sun, 18 Dec 2011 13:53:00 -0000 Message-ID: Subject: Re: [PATCH 1/1] x86: Add process memory layout to coredump file From: t cheney To: Al Viro Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, gdb-patches@sourceware.org, binutils@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 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 X-SW-Source: 2011-12/txt/msg00600.txt.bz2 On 12/15/11, Al Viro wrote: > On Sat, Dec 10, 2011 at 10:37:02PM +0800, t cheney wrote: >> This patch just add memory layout(same as /proc/pid/maps) to >> coredump file. The layout is appended to corenote segment with >> flag NT_MAPS=7. > >> + len = sprintf(buf, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu", >> + start, >> + end, >> + flags & VM_READ ? 'r' : '-', >> + flags & VM_WRITE ? 'w' : '-', >> + flags & VM_EXEC ? 'x' : '-', >> + flags & VM_MAYSHARE ? 's' : 'p', >> + pgoff, >> + MAJOR(dev), MINOR(dev), ino); > > Device numbers may be wider than 16 bits. Yes, it should be: len = sprintf(buf, "%08lx-%08lx %c%c%c%c %08llx %03x:%05x %lu", and corresponding change from 25 to 29 in function pad_spaces: static int pad_spaces(char *p, int len) { len = 29 + sizeof(void *) * 6 - len; > >> + p = d_path(&vma->vm_file->f_path, s, maps_size-1); > > What if somebody renames the file (or, better yet, its parent directory) > between two calls of that thing? > Yes, function core_handle_maps is called twice, first one just calculate size, second one write maps into coredump file. If the pathname is changed, the size may changed too. If the new size is less than or same as origin, all maps string is written to file. If the new size is more than origin, just part is written to file, the rest is ignored.