public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: jkratoch@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  jankratochvil/gdbserverbuildid: Locate solib files via build-id
Date: Sun, 18 May 2014 21:05:00 -0000	[thread overview]
Message-ID: <20140518210500.23064.qmail@sourceware.org> (raw)

The branch, jankratochvil/gdbserverbuildid has been updated
  discards  d7ed10238fce3b84771db9fced8d94579e2e0184 (commit)
  discards  7942c500647ab683d19fbbe47c39c6cbe113faa1 (commit)
  discards  a46739aaffc3020ce5bc690b96a4e6777dd99213 (commit)
  discards  e9e5076df987055e70a5806927bd4fb9f3ee91e8 (commit)
  discards  5521f4d26ee994ba331e405de5bf9d82db8b2ae4 (commit)
  discards  fe7e8e94ff9705e27edd57bcfb9419123f874e9f (commit)
       via  ee3e8236657a8bb0c3349d61e657f118a1d6f71f (commit)
       via  001358687d7ea7ffff886e0ead16b19bf24a29c3 (commit)
       via  b1e0a6aa8ab09cea21169bfdd240aaf259e972ff (commit)
       via  187dd34cffd96aa535b8a60aeceddb0d85d1c5f1 (commit)
       via  fe7cec8ec87e8939ba34d44a3f897f5fca2a4135 (commit)
       via  cdb5cc11a9ce7f4229f3e942fbafc19ff9ed4fb8 (commit)
      from  d7ed10238fce3b84771db9fced8d94579e2e0184 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit ee3e8236657a8bb0c3349d61e657f118a1d6f71f
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:06 2014 +0200

    Locate solib files via build-id
    
    Hi,
    
    this is a new functionality that the file itself (*) it found via build-id, if
    the regular name-located file does not match inferior build-id or if the
    named-located file even does not exist.
    
    I am not completely sure with the SO->SO_NAME initialization.  It cannot be
    a regression but not sure how it should behave for the build-id-located files.
    Currently the original target filename is kept but the comment there says is
    may confuse MI frontends.  OTOH putting there the build-id located file will
    show its build-id name in SO_NAME which is also wrong.
    
    (*) /usr/lib/libxxx.so, not /usr/lib/debug/usr/lib/libxxx.so.debug.
        Although GDB uses only symbols from that file so in fact the *.debug file
        would be sufficient.  But for example .symtab is sometimes only in the .so
        file and not the .so.debug file so GDB looks up .so as the associated
        .so.debug file gets loaded automatically on top of .so anyway.
    
    
    Thanks,
    Jan
    
    
    gdb/
    2014-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Locate solib files via build-id.
    	* build-id.c (build_id_to_debug_bfd): Rename to ...
    	(build_id_to_bfd): ... here.  Add parameter suffix.
    	(build_id_to_debug_bfd): New wrapper of build_id_to_bfd.
    	(build_id_so_validate): Remove const from the parameter,
    	return void.  Handle also NULL SO->ABFD.  Call also build_id_to_bfd.
    	* build-id.h (build_id_so_validate): Update declaration.
    	* solib.c (solib_map_sections): Call VALIDATE even for NULL SO->ABFD.
    	No longer free SO->ABFD on failed VALIDATE.
    	(default_solib_validate): Update its const and return value.
    	* solib.h (default_solib_validate): Update declaration.
    	* solist.h (struct target_so_ops): Update definition of field validate.
    
    gdb/testsuite/
    2014-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Locate solib files via build-id.
    	* gdb.base/solib-mismatch.exp (nocrlf, expected_header): Make
    	solib_matching_test variables global.
    	(solib_locate_test): New proc.
    	(locate non-matching shared library)
    	(locate non-existing shared library): New tests.

commit 001358687d7ea7ffff886e0ead16b19bf24a29c3
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:05 2014 +0200

    Code cleanup: solib_map_sections abfd var
    
    Hi,
    
    just remove a local variable holding so->abfd copy as so->abfd may change in
    the next patch.
    
    
    Jan
    
    
    gdb/
    2014-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* solib.c (solib_map_sections): Remove variable abfd.

commit b1e0a6aa8ab09cea21169bfdd240aaf259e972ff
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:05 2014 +0200

    Tests for validate symbol file using build-id
    
    
    Hi,
    
    new testcase.
    
    
    Jan
    
    
    gdb/testsuite/
    2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
    
    	Tests for validate symbol file using build-id.
    	* gdb.base/solib-mismatch-lib.c: New file.
    	* gdb.base/solib-mismatch-libmod.c: New file.
    	* gdb.base/solib-mismatch.c: New file.
    	* gdb.base/solib-mismatch.exp: New file.

commit 187dd34cffd96aa535b8a60aeceddb0d85d1c5f1
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:05 2014 +0200

    Validate symbol file using build-id
    
    
    Hi,
    
    consumer part of the "build-id" attribute.
    
    
    Jan
    
    
    gdb/
    2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Validate symbol file using build-id.
    	* NEWS (Changes since GDB 7.7): Add build-id attribute.
    	* build-id.c: Include solist.h.
    	(build_id_so_validate): New.
    	* build-id.h (build_id_so_validate): New declaration.
    	* solib-darwin.c (_initialize_darwin_solib): Assign validate value.
    	* solib-dsbt.c (_initialize_dsbt_solib): Ditto.
    	* solib-frv.c (_initialize_frv_solib): Ditto.
    	* solib-ia64-hpux.c (ia64_hpux_target_so_ops): Ditto.
    	* solib-irix.c (_initialize_irix_solib): Ditto.
    	* solib-osf.c (_initialize_osf_solib): Ditto.
    	* solib-pa64.c (_initialize_pa64_solib): Ditto.
    	* solib-som.c (_initialize_som_solib): Ditto.
    	* solib-spu.c (set_spu_solib_ops): Ditto.
    	* solib-svr4.c: Include build-id.h and rsp-low.h.
    	(svr4_copy_library_list): Deeply copy also BUILD_ID.
    	(library_list_start_library): Parse 'build-id' attribute.
    	(svr4_library_attributes): Add 'build-id' attribute.
    	(_initialize_svr4_solib): Assign validate value.
    	* solib-target.c (solib.h): Include.
    	(_initialize_solib_target): Assign validate value.
    	* solib.c (solib_map_sections): Use ops->validate.
    	(free_so): Free build_id.
    	(default_solib_validate): New function.
    	* solib.h (default_solib_validate): New declaration.
    	* solist.h (struct so_list): New fields 'build_idsz' and 'build_id'.
    	(target_so_ops): New field 'validate'.

commit fe7cec8ec87e8939ba34d44a3f897f5fca2a4135
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:05 2014 +0200

    New set build-id-force
    
    Hi,
    
    as the build-id verification is now integrated with existing build-id.[ch]
    I find logical to generalize former 'set solib-build-id-force'
    to 'set build-id-force' applicable even to existing .debug-vs-primary and
    common .dwz file verifications.
    
    I am not completely sure it is right to make a common setting for both
    inferior-vs-local-file build-id verification and local-file-vs-local-file
    verification.  But I guess using this setting should be very very rare so that
    should not matter.
    
    
    Jan
    
    
    gdb/
    2014-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    	    Aleksandar Ristovski  <aristovski@qnx.com
    
    	* NEWS (Changes since GDB 7.7): Add 'set build-id-force'
    	and 'show build-id-force'.
    	* build-id.c: Include rsp-low.h and gdbcmd.h.
    	(build_id_force, show_build_id_force): New.
    	(build_id_verify): Use BUILD_ID_FORCE.
    	(_initialize_build_id): New.
    
    gdb/doc/
    2014-03-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* gdb.texinfo (Files): Add 'set build-id-force'
    	and 'show build-id-force'.

commit cdb5cc11a9ce7f4229f3e942fbafc19ff9ed4fb8
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sat May 17 07:19:04 2014 +0200

    gdbserver build-id attribute generator
    
    
    Hi,
    
    producer part of the new "build-id" XML attribute.
    
    
    Jan
    
    
    gdb/
    2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
    
    	gdbserver build-id attribute generator.
    	* features/library-list-svr4.dtd (library-list-svr4): New
    	'build-id' attribute.
    
    gdb/doc/
    2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
    
    	gdbserver build-id attribute generator.
    	* gdb.texinfo (Library List Format for SVR4 Targets): Add
    	'build-id' in description, example, new attribute in dtd.
    
    gdb/gdbserver/
    2014-02-26  Aleksandar Ristovski  <aristovski@qnx.com
    
    	gdbserver build-id attribute generator.
    	* linux-low.c (linux-maps.h, search.h, rsp-low.h): Include.
    	(ElfXX_Ehdr, ElfXX_Phdr, ElfXX_Nhdr): New.
    	(ELFXX_FLD, ELFXX_SIZEOF, ELFXX_ROUNDUP, BUILD_ID_INVALID): New.
    	(find_phdr): New.
    	(get_dynamic): Use find_pdhr to traverse program headers.
    	(struct mapping_entry, mapping_entry_s, free_mapping_entry_vec)
    	(compare_mapping_entry_range, struct find_memory_region_callback_data)
    	(read_build_id, find_memory_region_callback, lrfind_mapping_entry)
    	(get_hex_build_id): New.
    	(linux_qxfer_libraries_svr4): Add optional build-id attribute
    	to reply XML document.

-----------------------------------------------------------------------

Summary of changes:
 gdb/doc/gdb.texinfo                |   14 +++++---
 gdb/features/library-list-svr4.dtd |    5 ++-
 gdb/gdbserver/linux-low.c          |   17 ++++++++++
 gdb/solib-svr4.c                   |   63 +++++++++++++++++++++++++-----------
 4 files changed, 73 insertions(+), 26 deletions(-)

First 500 lines of diff:
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 98bbf77..bbf91c3 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -38295,8 +38295,10 @@ address the file was prelinked to during the library load.
 @end itemize
 
 Additionally the single @code{main-lm} attribute specifies address of
-@code{struct link_map} used for the main executable.  This parameter is used
-for TLS access and its presence is optional.
+@code{struct link_map} used for the main executable.  This parameter is
+used for TLS access and its presence is optional.  Similarly the single
+@code{main-build-id} optional attribute specifies hex encoded
+@code{NT_GNU_BUILD_ID} note for the main executable.
 
 @value{GDBN} must be linked with the Expat library to support XML
 SVR4 library lists.  @xref{Expat}.
@@ -38305,7 +38307,8 @@ A simple memory map, with two loaded libraries (which do not use prelink),
 looks like this:
 
 @smallexample
-<library-list-svr4 version="1.0" main-lm="0xe4f8f8">
+<library-list-svr4 version="1.0" main-lm="0xe4f8f8"
+    main-build-id="b96b2f6fbfb7d144b676cb66f56b6100">
   <library name="/lib/ld-linux.so.2" lm="0xe4f51c" l_addr="0xe2d000"
            l_ld="0xe4eefc"/>
   <library name="/lib/libc.so.6" lm="0xe4fbe8" l_addr="0x154000"
@@ -38318,8 +38321,9 @@ The format of an SVR4 library list is described by this DTD:
 @smallexample
 <!-- library-list-svr4: Root element with versioning -->
 <!ELEMENT library-list-svr4  (library)*>
-<!ATTLIST library-list-svr4  version  CDATA   #FIXED  "1.0">
-<!ATTLIST library-list-svr4  main-lm  CDATA   #IMPLIED>
+<!ATTLIST library-list-svr4  version       CDATA   #FIXED  "1.0">
+<!ATTLIST library-list-svr4  main-lm       CDATA   #IMPLIED>
+<!ATTLIST library-list-svr4  main-build-id CDATA   #IMPLIED>
 <!ELEMENT library            EMPTY>
 <!ATTLIST library            name     CDATA   #REQUIRED>
 <!ATTLIST library            lm       CDATA   #REQUIRED>
diff --git a/gdb/features/library-list-svr4.dtd b/gdb/features/library-list-svr4.dtd
index ff79990..6ab7b4b 100644
--- a/gdb/features/library-list-svr4.dtd
+++ b/gdb/features/library-list-svr4.dtd
@@ -6,8 +6,9 @@
 
 <!-- library-list-svr4: Root element with versioning -->
 <!ELEMENT library-list-svr4  (library)*>
-<!ATTLIST library-list-svr4  version  CDATA   #FIXED  "1.0">
-<!ATTLIST library-list-svr4  main-lm  CDATA   #IMPLIED>
+<!ATTLIST library-list-svr4  version       CDATA   #FIXED  "1.0">
+<!ATTLIST library-list-svr4  main-lm       CDATA   #IMPLIED>
+<!ATTLIST library-list-svr4  main-build-id CDATA   #IMPLIED>
 
 <!ELEMENT library            EMPTY>
 <!ATTLIST library            name     CDATA   #REQUIRED>
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 55485e0..8071dab 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -6148,8 +6148,25 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
 	 exited above due to failed get_r_debug.  */
       if (lm_prev == 0)
 	{
+	  const char *hex_enc_build_id = get_hex_build_id (l_addr, l_ld, &data);
+
 	  sprintf (p, " main-lm=\"0x%lx\"", (unsigned long) lm_addr);
 	  p = p + strlen (p);
+
+	  if (hex_enc_build_id != NULL)
+	    {
+	      while (allocated
+		     < p - document + 200 + strlen (hex_enc_build_id))
+		{
+		  /* Expand to guarantee sufficient storage.  */
+		  uintptr_t document_len = p - document;
+
+		  document = xrealloc (document, 2 * allocated);
+		  allocated *= 2;
+		  p = document + document_len;
+		}
+	      p += sprintf (p, " main-build-id=\"%s\"", hex_enc_build_id);
+	    }
 	}
       else
 	{
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 7323970..d305fc7 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -361,6 +361,8 @@ struct svr4_info
 
   /* Load map address for the main executable.  */
   CORE_ADDR main_lm_addr;
+  size_t main_build_idsz;
+  gdb_byte *main_build_id;
 
   CORE_ADDR interp_text_sect_low;
   CORE_ADDR interp_text_sect_high;
@@ -1046,6 +1048,9 @@ struct svr4_library_list
   /* Inferior address of struct link_map used for the main executable.  It is
      NULL if not known.  */
   CORE_ADDR main_lm;
+
+  size_t main_build_idsz;
+  gdb_byte *main_build_id;
 };
 
 /* Implementation for target_so_ops.free_so.  */
@@ -1119,6 +1124,27 @@ svr4_copy_library_list (struct so_list *src)
 
 #include "xml-support.h"
 
+static void
+hex2bin_allocate (const char *hex, gdb_byte **binp, size_t *binszp)
+{
+  size_t hex_len, binsz;
+
+  if (hex == NULL)
+    return;
+  hex_len = strlen (hex);
+  if (hex_len == 0 || (hex_len & 1U) != 0)
+    return;
+  binsz = hex_len / 2;
+  *binp = xmalloc (binsz);
+  *binszp = hex2bin (hex, *binp, binsz);
+  if (*binszp != binsz)
+    {
+      xfree (*binp);
+      *binp = NULL;
+      *binszp = 0;
+    }
+}
+
 /* Handle the start of a <library> element.  Note: new elements are added
    at the tail of the list, keeping the list in order.  */
 
@@ -1146,25 +1172,7 @@ library_list_start_library (struct gdb_xml_parser *parser,
   strncpy (new_elem->so_name, name, sizeof (new_elem->so_name) - 1);
   new_elem->so_name[sizeof (new_elem->so_name) - 1] = 0;
   strcpy (new_elem->so_original_name, new_elem->so_name);
-  if (hex_build_id != NULL)
-    {
-      const size_t hex_build_id_len = strlen (hex_build_id);
-
-      if (hex_build_id_len > 0 && (hex_build_id_len & 1U) == 0)
-	{
-	  const size_t build_idsz = hex_build_id_len / 2;
-
-	  new_elem->build_id = xmalloc (build_idsz);
-	  new_elem->build_idsz = hex2bin (hex_build_id, new_elem->build_id,
-					  build_idsz);
-	  if (new_elem->build_idsz != build_idsz)
-	    {
-	      xfree (new_elem->build_id);
-	      new_elem->build_id = NULL;
-	      new_elem->build_idsz = 0;
-	    }
-	}
-    }
+  hex2bin_allocate (hex_build_id, &new_elem->build_id, &new_elem->build_idsz);
 
   *list->tailp = new_elem;
   list->tailp = &new_elem->next;
@@ -1180,6 +1188,9 @@ svr4_library_list_start_list (struct gdb_xml_parser *parser,
   struct svr4_library_list *list = user_data;
   const char *version = xml_find_attribute (attributes, "version")->value;
   struct gdb_xml_value *main_lm = xml_find_attribute (attributes, "main-lm");
+  const struct gdb_xml_value *const att_build_id
+    = xml_find_attribute (attributes, "build-id");
+  const char *const hex_build_id = att_build_id ? att_build_id->value : NULL;
 
   if (strcmp (version, "1.0") != 0)
     gdb_xml_error (parser,
@@ -1188,6 +1199,7 @@ svr4_library_list_start_list (struct gdb_xml_parser *parser,
 
   if (main_lm)
     list->main_lm = *(ULONGEST *) main_lm->value;
+  hex2bin_allocate (hex_build_id, &list->main_build_id, &list->main_build_idsz);
 }
 
 /* The allowed elements and attributes for an XML library list.
@@ -1217,6 +1229,7 @@ static const struct gdb_xml_attribute svr4_library_list_attributes[] =
 {
   { "version", GDB_XML_AF_NONE, NULL, NULL },
   { "main-lm", GDB_XML_AF_OPTIONAL, gdb_xml_parse_attr_ulongest, NULL },
+  { "main-build-id", GDB_XML_AF_OPTIONAL, NULL, NULL },
   { NULL, GDB_XML_AF_NONE, NULL, NULL }
 };
 
@@ -1444,15 +1457,24 @@ svr4_current_sos_direct (struct svr4_info *info)
      Unfortunately statically linked inferiors will also fall back through this
      suboptimal code path.  */
 
+  library_list.main_build_id = NULL;
+  library_list.main_build_idsz = 0;
   info->using_xfer = svr4_current_sos_via_xfer_libraries (&library_list,
 							  NULL);
   if (info->using_xfer)
     {
       if (library_list.main_lm)
 	info->main_lm_addr = library_list.main_lm;
+      if (library_list.main_build_id != NULL)
+	{
+	  xfree (info->main_build_id);
+	  info->main_build_id = library_list.main_build_id;
+	  info->main_build_idsz = library_list.main_build_idsz;
+	}
 
       return library_list.head ? library_list.head : svr4_default_sos ();
     }
+  xfree (library_list.main_build_id);
 
   /* Always locate the debug struct, in case it has moved.  */
   info->debug_base = 0;
@@ -2979,6 +3001,9 @@ svr4_clear_solib (void)
   info->debug_loader_offset = 0;
   xfree (info->debug_loader_name);
   info->debug_loader_name = NULL;
+  xfree (info->main_build_id);
+  info->main_build_id = NULL;
+  info->main_build_idsz = 0;
 }
 
 /* Clear any bits of ADDR that wouldn't fit in a target-format


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2014-05-18 21:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-18 21:05 jkratoch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-05-17  6:02 jkratoch
2014-03-24 19:18 jkratoch
2014-03-24  4:57 jkratoch

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=20140518210500.23064.qmail@sourceware.org \
    --to=jkratoch@sourceware.org \
    --cc=archer-commits@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).