From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23124 invoked by alias); 18 May 2014 21:05:01 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 23102 invoked by uid 9674); 18 May 2014 21:05:00 -0000 Date: Sun, 18 May 2014 21:05:00 -0000 Message-ID: <20140518210500.23064.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] jankratochvil/gdbserverbuildid: Locate solib files via build-id X-Git-Refname: refs/heads/jankratochvil/gdbserverbuildid X-Git-Reftype: branch X-Git-Oldrev: d7ed10238fce3b84771db9fced8d94579e2e0184 X-Git-Newrev: ee3e8236657a8bb0c3349d61e657f118a1d6f71f X-SW-Source: 2014-q2/txt/msg00001.txt.bz2 List-Id: 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 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 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 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 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 * solib.c (solib_map_sections): Remove variable abfd. commit b1e0a6aa8ab09cea21169bfdd240aaf259e972ff Author: Jan Kratochvil 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 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 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 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 Aleksandar Ristovski * gdb.texinfo (Files): Add 'set build-id-force' and 'show build-id-force'. commit cdb5cc11a9ce7f4229f3e942fbafc19ff9ed4fb8 Author: Jan Kratochvil 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 + - - + + + 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 @@ - - + + + 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 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.