Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: Andrew Cagney <cagney@gnu.org>
Cc: Elena Zannoni <ezannoni@redhat.com>, gdb-patches@sources.redhat.com
Subject: Re: [RFA] gcore: ignore no protection segments
Date: Wed, 14 Jan 2004 18:39:00 -0000	[thread overview]
Message-ID: <16389.35948.575905.347881@localhost.redhat.com> (raw)
In-Reply-To: <40043CEB.1020108@gnu.org>

Andrew Cagney writes:
 > +
 > +  if (read == 0 && write == 0 && exec == 0)
 > +    {
 > +      if (info_verbose)
 > +        {
 > +          fprintf_filtered (gdb_stdout, "Ignore segment, %lld bytes at 
 > 0x%s\n",+                           (long long) size, paddr_nz (vaddr));
 > +        }
 > +
 > +      return 0;
 > +    }
 > 
 > Makes sense.  Suggest adding a few details in a comment, and 
 > paddr_d(size) for the length.
 > 
 > Andrew
 > 

OK, I fixed the rest of the file as well.

committed.

2004-01-14  Elena Zannoni  <ezannoni@redhat.com>

	* gcore.c (gcore_copy_callback): Use paddr_d to print size
	variable.
	(gcore_create_callback): Ditto.  Skip any memory segment that has
	no permissions set.


Index: gcore.c
===================================================================
RCS file: /cvs/src/src/gdb/gcore.c,v
retrieving revision 1.13
diff -u -p -r1.13 gcore.c
--- gcore.c	11 Oct 2003 01:56:53 -0000	1.13
+++ gcore.c	14 Jan 2004 18:37:17 -0000
@@ -1,6 +1,6 @@
 /* Generate a core file for the inferior process.
 
-   Copyright 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -314,6 +314,20 @@ gcore_create_callback (CORE_ADDR vaddr, 
   asection *osec;
   flagword flags = SEC_ALLOC | SEC_HAS_CONTENTS | SEC_LOAD;
 
+  /* If the memory segment has no permissions set, ignore it, otherwise
+     when we later try to access it for read/write, we'll get an error
+     or jam the kernel.  */
+  if (read == 0 && write == 0 && exec == 0)
+    {
+      if (info_verbose)
+        {
+          fprintf_filtered (gdb_stdout, "Ignore segment, %s bytes at 0x%s\n",
+                           paddr_d (size), paddr_nz (vaddr));
+        }
+
+      return 0;
+    }
+
   if (write == 0)
     {
       /* See if this region of memory lies inside a known file on disk.
@@ -364,8 +378,8 @@ gcore_create_callback (CORE_ADDR vaddr, 
 
   if (info_verbose)
     {
-      fprintf_filtered (gdb_stdout, "Save segment, %lld bytes at 0x%s\n",
-			(long long) size, paddr_nz (vaddr));
+      fprintf_filtered (gdb_stdout, "Save segment, %s bytes at 0x%s\n",
+			paddr_d (size), paddr_nz (vaddr));
     }
 
   bfd_set_section_size (obfd, osec, size);
@@ -450,8 +464,8 @@ gcore_copy_callback (bfd *obfd, asection
 
   if (target_read_memory (bfd_section_vma (obfd, osec),
 			  memhunk, size) != 0)
-    warning ("Memory read failed for corefile section, %ld bytes at 0x%s\n",
-	     (long) size, paddr (bfd_section_vma (obfd, osec)));
+    warning ("Memory read failed for corefile section, %s bytes at 0x%s\n",
+	     paddr_d (size), paddr (bfd_section_vma (obfd, osec)));
   if (!bfd_set_section_contents (obfd, osec, memhunk, 0, size))
     warning ("Failed to write corefile contents (%s).",
 	     bfd_errmsg (bfd_get_error ()));


      reply	other threads:[~2004-01-14 18:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-13 17:01 Elena Zannoni
2004-01-13 18:46 ` Andrew Cagney
2004-01-14 18:39   ` Elena Zannoni [this message]

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=16389.35948.575905.347881@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.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