Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Ben Cheng <bccheng@google.com>
Cc: gdb-patches@sourceware.org
Subject: [patchv2] Ignore the first entry returned by svr4_current_sos_via_xfer_libraries for dynamically linked programs
Date: Wed, 05 Jun 2013 11:38:00 -0000	[thread overview]
Message-ID: <20130605113800.GA10973@host2.jankratochvil.net> (raw)
In-Reply-To: <CAPk6zkBgXrkXWddho=WLXW1qVOMSdQE55pYVS7CbowCJbLQt+w@mail.gmail.com>

On Tue, 04 Jun 2013 23:21:36 +0200, Ben Cheng wrote:
> If you don't mind I'll let you take care of it. :)

I will check it in in some time.


Regards,
Jan


gdb/gdbserver/
2013-06-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

	Fix compatibility with Android Bionic.
	* linux-low.c (linux_qxfer_libraries_svr4): Ignore first entry even if
	it is not empty.

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 03ac469..0f3e0f0 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -5829,45 +5829,54 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
 	  break;
 	}
 
-      /* Not checking for error because reading may stop before
-	 we've got PATH_MAX worth of characters.  */
-      libname[0] = '\0';
-      linux_read_memory (l_name, libname, sizeof (libname) - 1);
-      libname[sizeof (libname) - 1] = '\0';
-      if (libname[0] != '\0')
+      /* Ignore the first entry even if it has valid name as the first entry
+	 corresponds to the main executable.  The first entry should not be
+	 skipped if the dynamic loader was loaded late by a static executable
+	 (see solib-svr4.c parameter ignore_first).  But in such case the main
+	 executable does not have PT_DYNAMIC present and this function already
+	 exited above due to failed get_r_debug.  */
+      if (lm_prev == 0)
 	{
-	  /* 6x the size for xml_escape_text below.  */
-	  size_t len = 6 * strlen ((char *) libname);
-	  char *name;
-
-	  if (!header_done)
+	  sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr);
+	  p = p + strlen (p);
+	}
+      else
+	{
+	  /* Not checking for error because reading may stop before
+	     we've got PATH_MAX worth of characters.  */
+	  libname[0] = '\0';
+	  linux_read_memory (l_name, libname, sizeof (libname) - 1);
+	  libname[sizeof (libname) - 1] = '\0';
+	  if (libname[0] != '\0')
 	    {
-	      /* Terminate `<library-list-svr4'.  */
-	      *p++ = '>';
-	      header_done = 1;
-	    }
+	      /* 6x the size for xml_escape_text below.  */
+	      size_t len = 6 * strlen ((char *) libname);
+	      char *name;
 
-	  while (allocated < p - document + len + 200)
-	    {
-	      /* Expand to guarantee sufficient storage.  */
-	      uintptr_t document_len = p - document;
+	      if (!header_done)
+		{
+		  /* Terminate `<library-list-svr4'.  */
+		  *p++ = '>';
+		  header_done = 1;
+		}
 
-	      document = xrealloc (document, 2 * allocated);
-	      allocated *= 2;
-	      p = document + document_len;
-	    }
+	      while (allocated < p - document + len + 200)
+		{
+		  /* Expand to guarantee sufficient storage.  */
+		  uintptr_t document_len = p - document;
 
-	  name = xml_escape_text ((char *) libname);
-	  p += sprintf (p, "<library name=\"%s\" lm=\"0x%lx\" "
-			"l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
-			name, (unsigned long) lm_addr,
-			(unsigned long) l_addr, (unsigned long) l_ld);
-	  free (name);
-	}
-      else if (lm_prev == 0)
-	{
-	  sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr);
-	  p = p + strlen (p);
+		  document = xrealloc (document, 2 * allocated);
+		  allocated *= 2;
+		  p = document + document_len;
+		}
+
+	      name = xml_escape_text ((char *) libname);
+	      p += sprintf (p, "<library name=\"%s\" lm=\"0x%lx\" "
+			    "l_addr=\"0x%lx\" l_ld=\"0x%lx\"/>",
+			    name, (unsigned long) lm_addr,
+			    (unsigned long) l_addr, (unsigned long) l_ld);
+	      free (name);
+	    }
 	}
 
       lm_prev = lm_addr;


  reply	other threads:[~2013-06-05 11:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 18:31 [PATCH] " Ben Cheng
2013-05-29 10:17 ` Gary Benson
2013-06-04  8:58 ` Jan Kratochvil
2013-06-04 17:19   ` Ben Cheng
2013-06-04 18:07 ` Jan Kratochvil
2013-06-04 18:18   ` Ben Cheng
2013-06-04 20:23     ` Jan Kratochvil
2013-06-04 20:36       ` Ben Cheng
2013-06-04 20:45         ` Ben Cheng
2013-06-04 20:57           ` Jan Kratochvil
2013-06-04 21:21             ` Ben Cheng
2013-06-05 11:38               ` Jan Kratochvil [this message]
     [not found]                 ` <51AF4C5B.5080104@redhat.com>
2013-06-09 18:08                   ` [commit] [patchv2] " Jan Kratochvil
2013-06-11  6:32                     ` Ben Cheng

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=20130605113800.GA10973@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=bccheng@google.com \
    --cc=gdb-patches@sourceware.org \
    /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