From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Jean-Marc Saffroy <saffroy@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] refreshed patch for PR 11804 and PR 9904
Date: Sat, 28 Jul 2012 07:05:00 -0000 [thread overview]
Message-ID: <20120728070451.GA2167@host2.jankratochvil.net> (raw)
In-Reply-To: <alpine.DEB.2.00.1207180238040.5348@erda.mds>
Hello,
> which I've refreshed for gdb 7.4.1. So here it is,
this is unfortunately not sufficient, 7.4.1 is too old. The patch is not
applicable to FSF GDB HEAD - to be accepted. See how to download HEAD:
http://sources.redhat.com/gdb/current/
Primarily linux_nat_find_memory_regions is now reworked and renamed as
linux_find_memory_regions as GDB can now gcore also from remotely run process
via gdbserver. The testcase should be verified it also works with gdbserver
afterwards, see gdb/testsuite/boards/native-gdbserver.exp.
Also there should be descriptive comments before each modified function.
I can write those otherwise.
On Wed, 18 Jul 2012 02:50:08 +0200, Jean-Marc Saffroy wrote:
static int
objfile_find_memory_regions (find_memory_region_ftype func, void *obfd)
/* Call callback function for each objfile section. */
ALL_OBJSECTIONS (objfile, objsec)
Here is missing a check:
if (separate_debug_objfile_backlink != NULL)
continue;
as separate debug info files (in /usr/lib/debug, sometimes with .debug
extension) are irrelevant for gcore.
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
[...]
> @@ -4370,6 +4370,40 @@ read_mapping (FILE *mapfile,
[...]
> + if (fscanf (mapfile, "%64s%lu kB\n", keyword, &number) != 2)
> + {
> + warning (_("Error parsing /proc/PID/{s,}maps file"));
> + do
> + ch = fgetc (mapfile);
> + while (ch != EOF && ch != '\n');
> + break;
> + }
> + if (number != 0 && (strcmp (keyword, "Shared_Dirty:") == 0
> + || strcmp (keyword, "Private_Dirty:") == 0
> + || strcmp (keyword, "Swap:") == 0))
The patch is primarily missing the check for "Anonymous:" entry in recent
Linux kernels, described by Ulrich Weigand in:
http://sourceware.org/ml/gdb-patches/2010-09/msg00398.html
Therefore if "Anonymous:" entry is not present at all (=not supported by Linux
kernel on that host) we must write out very every area as we have no way to
verify for swap-cached pages (having Anonymous > 0).
Sure if "Anonymous:" is present and it is > 0 it also must be written out.
You can reproduce the "Anonymous:" problem with
http://people.redhat.com/jkratoch/relroswap.c
although it is not suitable for GDB testsuite as it needs to do huge memory
allocations to swap out (+swap in) the testcase pages.
(If you have a better idea how to make "Anonymous:" entry non-zero it is sure
welcome. I have tried madvise (MADV_DONTNEED) but it does not work.)
> + *modified = 1;
> + else if (*modified == -1)
> + {
> + /* Valid line proves an smaps file is being read in. */
> + *modified = 0;
> + }
> + }
> + }
> +
> return (ret != 0 && ret != EOF);
> }
>
[...]
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/gcore-relro.exp
> @@ -0,0 +1,80 @@
> +# Copyright 2010 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +if {[skip_shlib_tests]} {
> + return 0
> +}
> +
> +set testfile "gcore-relro"
Is hould use 'standard_testfile' like other testcases recently modified by Tom
Tromey.
> +set srcmainfile ${testfile}-main.c
> +set srclibfile ${testfile}-lib.c
> +set libfile ${objdir}/${subdir}/${testfile}-lib.so
> +set objfile ${objdir}/${subdir}/${testfile}-main.o
> +set executable ${testfile}-main
> +set binfile ${objdir}/${subdir}/${executable}
> +set gcorefile ${objdir}/${subdir}/${executable}.gcore
> +
> +if { [gdb_compile_shlib ${srcdir}/${subdir}/${srclibfile} ${libfile} {debug}] != ""
> + || [gdb_compile ${srcdir}/${subdir}/${srcmainfile} ${objfile} object {debug}] != "" } {
> + untested ${testfile}.exp
> + return -1
> +}
> +set opts [list debug shlib=${libfile} additional_flags=-Wl,-z,relro]
> +if { [gdb_compile ${objfile} ${binfile} executable $opts] != "" } {
> + unsupported "-Wl,-z,relro compilation failed"
> + return -1
> +}
> +
> +clean_restart $executable
> +gdb_load_shlibs $libfile
[...]
Thanks,
Jan
next prev parent reply other threads:[~2012-07-28 7:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-18 0:50 Jean-Marc Saffroy
2012-07-28 7:05 ` Jan Kratochvil [this message]
2012-07-29 17:11 ` Jean-Marc Saffroy
2012-07-29 17:35 ` Jean-Marc Saffroy
2012-07-31 13:21 ` Jan Kratochvil
2012-08-07 13:27 ` [commit] " Jan Kratochvil
2012-07-28 7:10 ` Jan Kratochvil
2012-07-31 13:23 ` Jan Kratochvil
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=20120728070451.GA2167@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=saffroy@gmail.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