This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 5/8] Move linux_find_memory_regions_full & co.


On Tue, 09 Apr 2013 17:27:42 +0200, Aleksandar Ristovski wrote:
> 
> Most notable change: read_alloc and read_stralloc are moved to new
> common-target.[ch] files.

This is not a move, it removes - and therefore regresses - this change:

commit d8c11845465f076c6ae8078d2e8fb7c1d31f1181
	Fix compatibility with Linux kernel 3.8.3.
commit 01a16f9b83c29db2c63106bbefeb505cbac17bd4
	Fix variable name shadowing.

When you git merge gdb/master you got a conflict on linux-tdep.c.  Therefore
you have to apply the non-applicable trunk change of linux-tdep.c to the new
file common/linux-maps.c instead.  You apparently had to drop the linux-tdep.c
conflict without updating common/linux-maps.c.


Regards,
Jan


This is the regression this patch introduced:

--- m	2013-04-12 21:26:21.953472657 +0200
+++ p	2013-04-14 08:00:04.284665296 +0200
@@ -56,21 +56,20 @@ typedef int linux_find_memory_region_fty
    been processed or return the value from FUNC if FUNC returns
    non-zero.  */
 
-static int
+int
 linux_find_memory_regions_full (pid_t pid, linux_find_memory_region_ftype *func,
 				void *func_data, void **memory_to_free_ptr)
 {
-  char mapsfilename[100];
+  char filename[100];
   char *data;
 
-  xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/smaps", (int) pid);
-  data = target_fileio_read_stralloc (mapsfilename);
+  xsnprintf (filename, sizeof filename, "/proc/%d/smaps", (int) pid);
+  data = linux_find_memory_read_stralloc (filename);
   if (data == NULL)
     {
       /* Older Linux kernels did not support /proc/PID/smaps.  */
-      xsnprintf (mapsfilename, sizeof mapsfilename, "/proc/%d/maps",
-		 (int) pid);
-      data = target_fileio_read_stralloc (mapsfilename);
+      xsnprintf (filename, sizeof filename, "/proc/%d/maps", (int) pid);
+      data = linux_find_memory_read_stralloc (filename);
     }
   if (data)
     {
@@ -106,30 +105,20 @@ linux_find_memory_regions_full (pid_t pi
 	       line = strtok (NULL, "\n"))
 	    {
 	      char keyword[64 + 1];
+	      unsigned long number;
 
-	      if (sscanf (line, "%64s", keyword) != 1)
+	      if (sscanf (line, "%64s%lu kB\n", keyword, &number) != 2)
 		{
-		  warning (_("Error parsing {s,}maps file '%s'"), mapsfilename);
+		  warning (_("Error parsing {s,}maps file '%s'"), filename);
 		  break;
 		}
 	      if (strcmp (keyword, "Anonymous:") == 0)
 		has_anonymous = 1;
-	      if (strcmp (keyword, "Shared_Dirty:") == 0
-		  || strcmp (keyword, "Private_Dirty:") == 0
-		  || strcmp (keyword, "Swap:") == 0
-		  || strcmp (keyword, "Anonymous:") == 0)
-		{
-		  unsigned long number;
-
-		  if (sscanf (line, "%*s%lu", &number) != 1)
-		    {
-		      warning (_("Error parsing {s,}maps file '%s' number"),
-			       mapsfilename);
-		      break;
-		    }
-		  if (number != 0)
-		    modified = 1;
-		}
+	      if (number != 0 && (strcmp (keyword, "Shared_Dirty:") == 0
+				  || strcmp (keyword, "Private_Dirty:") == 0
+				  || strcmp (keyword, "Swap:") == 0
+				  || strcmp (keyword, "Anonymous:") == 0))
+		modified = 1;
 	    }
 
 	  /* Older Linux kernels did not support the "Anonymous:" counter.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]