Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Pedro Alves <palves@redhat.com>,
	       Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH] Improve corefile generation by using /proc/PID/coredump_filter (PR corefile/16902)
Date: Thu, 05 Mar 2015 15:48:00 -0000	[thread overview]
Message-ID: <20150305154827.GA9441@host1.jankratochvil.net> (raw)
In-Reply-To: <878ufc9kau.fsf@redhat.com>

On Thu, 05 Mar 2015 04:48:09 +0100, Sergio Durigan Junior wrote:
>   bit 0  Dump anonymous private mappings.
>   bit 1  Dump anonymous shared mappings.
>   bit 2  Dump file-backed private mappings.
>   bit 3  Dump file-backed shared mappings.
>   bit 4 (since Linux 2.6.24)
>          Dump ELF headers.
>   bit 5 (since Linux 2.6.28)
>          Dump private huge pages.
>   bit 6 (since Linux 2.6.28)
>          Dump shared huge pages.
[...]
> The default value for this file, used by the Linux kernel, is 0x33,
> which means that bits 0, 1 and 4 are enabled.  This is also the default

and 5

> for GDB implemented in this patch, FWIW.
[...]
> With Oleg's help, we could improve the current algorithm for determining
> whether a memory mapping is anonymous/file-backed, private/shared.  GDB
> now also respects the MADV_DONTDUMP flag and does not dump the memory

s/does not dump/does dump/

> mapping marked as so, and won't try to dump "[vsyscall]" or "[vdso]"
> mappings as before (just like the Linux kernel).

Currently it also tries to dump [vvar] (by default rules) but that is
unreadable for some reason, causing:
warning: Memory read failed for corefile section, 8192 bytes at 0x7ffff6ceb000.
                                                                ^^^^^^^^^^^^^^
Saved corefile /tmp/1j
(gdb) _
# grep 7ffff6ceb000 /proc/$p/maps
7ffff6ceb000-7ffff6ced000 r--p 00000000 00:00 0                          [vvar]
^^^^^^^^^^^^                                                              ^^^^

I do not know what [vvar] is good for and why it cannot be read.


>   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.

# stat /proc/21604/map_files/400000-4ec000 
  File: ‘/proc/21604/map_files/400000-4ec000’ -> ‘/tmp/bash-deleted’
  Size: 64        	Blocks: 0          IO Block: 1024   symbolic link
Device: 3h/3d	Inode: 1554082     Links: 1
# stat -L /proc/21604/map_files/400000-4ec000 
  File: ‘/proc/21604/map_files/400000-4ec000’
  Size: 1051464   	Blocks: 2056       IO Block: 4096   regular file
Device: fd01h/64769d	Inode: 5509691     Links: 1
# rm /tmp/bash-deleted
# stat -L /proc/21604/map_files/400000-4ec000 
  File: ‘/proc/21604/map_files/400000-4ec000’
  Size: 1051464   	Blocks: 2056       IO Block: 4096   regular file
Device: fd01h/64769d	Inode: 5509691     Links: 0
                                                  ^

One could find if i_nlink == 0 if it would be enough.  But it would work only
if GDB runs as root so it is probably not worth coding it:

$ ls -ld /proc/3803/map_files
dr-x------ 2 lace lace 0 Mar  5 16:44 /proc/3803/map_files/
$ stat /proc/3803/map_files/400000-4ec000
stat: cannot stat ‘/proc/3803/map_files/400000-4ec000’: Operation not permitted


Jan


  reply	other threads:[~2015-03-05 15:48 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-05  3:48 Sergio Durigan Junior
2015-03-05 15:48 ` Jan Kratochvil [this message]
2015-03-05 20:53   ` Sergio Durigan Junior
2015-03-05 20:57     ` Jan Kratochvil
2015-03-11 20:02       ` Oleg Nesterov
2015-03-12 11:31         ` Sergio Durigan Junior
2015-03-12 14:36         ` vvar, gup && coredump Oleg Nesterov
2015-03-12 16:29           ` Andy Lutomirski
2015-03-12 16:56             ` Oleg Nesterov
2015-03-12 17:18               ` Andy Lutomirski
2015-03-12 17:40                 ` Oleg Nesterov
2015-03-12 17:45                   ` Sergio Durigan Junior
2015-03-12 18:04                     ` Oleg Nesterov
2015-03-13  4:50                       ` Sergio Durigan Junior
2015-03-13 15:06                         ` Oleg Nesterov
2015-03-12 17:56                   ` Andy Lutomirski
2015-03-12 18:28                     ` Oleg Nesterov
2015-03-12 17:48               ` Oleg Nesterov
2015-03-12 17:55                 ` Andy Lutomirski
2015-03-12 18:16                   ` Oleg Nesterov
2015-03-12 18:23                     ` Sergio Durigan Junior
2015-03-12 18:20                 ` Pedro Alves
2015-03-12 18:26                   ` Andy Lutomirski
2015-03-16 19:03                 ` install_special_mapping && vm_pgoff (Was: vvar, gup && coredump) Oleg Nesterov
2015-03-16 19:20                   ` Andy Lutomirski
2015-03-16 19:46                     ` Oleg Nesterov
2015-03-17 13:45                       ` Oleg Nesterov
2015-03-18  1:45                         ` Andy Lutomirski
2015-03-18 18:08                           ` Oleg Nesterov
2015-03-16 19:40                   ` Pedro Alves
2015-03-12 15:02         ` [PATCH] Improve corefile generation by using /proc/PID/coredump_filter (PR corefile/16902) Oleg Nesterov
2015-03-12 15:46           ` Pedro Alves
2015-03-12 15:57             ` Jan Kratochvil
2015-03-12 16:19               ` Pedro Alves
2015-03-12 16:07             ` Oleg Nesterov
2015-03-12 16:28               ` Pedro Alves
2015-03-12 17:37           ` Sergio Durigan Junior
2015-03-12 21:39 ` [PATCH v2] " Sergio Durigan Junior
2015-03-13 19:34   ` Pedro Alves
2015-03-16 23:53     ` Sergio Durigan Junior
2015-03-18 19:10       ` Pedro Alves
2015-03-18 19:39         ` Sergio Durigan Junior
2015-03-14  9:40   ` Eli Zaretskii
2015-03-16  2:42     ` Sergio Durigan Junior
2015-03-13 19:37 ` [PATCH] " Pedro Alves
2015-03-13 19:48   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150305154827.GA9441@host1.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=oleg@redhat.com \
    --cc=palves@redhat.com \
    --cc=sergiodj@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox