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: Tests for validate symbol file using build-id
Date: Mon, 03 Aug 2015 20:36:00 -0000	[thread overview]
Message-ID: <20150803203654.47582.qmail@sourceware.org> (raw)

The branch, jankratochvil/gdbserverbuildid has been updated
  discards  d3b64846f32fe967eda4a42993509fa043bf6fab (commit)
  discards  127a7c8c5f95c94627a7020ea70baaf34e8af4c4 (commit)
  discards  9a330d05001869fafbeb1977ba01002760f06223 (commit)
  discards  2ac4a4a2b1c67501c243500f89f39b993afc9d57 (commit)
  discards  c957e11eefea3a3b0df0725d0bcc7f71284cbfdd (commit)
  discards  7fc9a74927d454a5390f1d5d2a1cb3c4610d2bd6 (commit)
  discards  1819c3617e892c280ef275ddc227cde019215137 (commit)
  discards  363c073195eb984c1a87337c2b766264c9b492c0 (commit)
  discards  41d3fed626c53a4c1941bb7e5cab4f31d1867d86 (commit)
  discards  9d78733d3e5cb8a75da2fde76c4b5b016adaa73e (commit)
  discards  daf575991634bf88c15a21b206af0025eb7945b3 (commit)
  discards  ff999b8d72b8b986c21a85f3853a933d61377d62 (commit)
  discards  4c5ec92510d46549c0ab8b7bef138e49916a9c7e (commit)
  discards  be47105b3a08816825e3af06e364976a50b0addc (commit)
  discards  3f48d4a72c91deb16d7845e05c1c6de0017363a1 (commit)
  discards  ee108b9e22005af135a0e3abdd987a6e8d11ae60 (commit)
  discards  e5ac2b27b2656e633f03e03471215134039eab26 (commit)
  discards  357927ebc9c67445f26db3e8f9c4f9619da9758c (commit)
  discards  5fb62cb37b182a1724c142fb5074c610438f3d21 (commit)
  discards  fc362f9aceda33a7fda5587a894afb845d9ab969 (commit)
  discards  cc7e9e180d16e577c75fac12e8dd7397fe0305b8 (commit)
  discards  77349f9a27c0b1ad34a16b8245dd8f89663a6b99 (commit)
  discards  d0ec4ffa44abbfb3ae91d073d9e173d08add716a (commit)
  discards  53ecd8abae0b52b4972c15d71174e0ba0f141976 (commit)
  discards  90f484011751e127565e5600bfde5308773edb93 (commit)
  discards  0ad719190dd1375219d3bcdc3718daf109dff476 (commit)
       via  18b55a2660c4c4bc90b617db0336a1172d6ad506 (commit)
       via  f14f9cc588192ab6db2276f533133a13a8a97cfa (commit)
       via  92266c35bc7ccf402827fd15dcf01d4475522b8d (commit)
       via  24ef919babbb591d0a1aceeb3afd9fce7f573147 (commit)
       via  e5293e8b402363b88775a010c20d8818f44637f7 (commit)
       via  53ff2abcee6f83ab6d6896b7e4335b95f4477299 (commit)
       via  9c874130415a43f3b06df0473e6d716e3f6844cf (commit)
      from  d3b64846f32fe967eda4a42993509fa043bf6fab (commit)

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

- Log -----------------------------------------------------------------
commit 18b55a2660c4c4bc90b617db0336a1172d6ad506
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sun Jul 12 20:59:03 2015 +0200

    Tests for validate symbol file using build-id
    
    New testcase.
    
    gdb/testsuite/ChangeLog
    2015-07-15  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 f14f9cc588192ab6db2276f533133a13a8a97cfa
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Jul 15 17:37:28 2015 +0200

    Validate symbol file using build-id
    
    Consumer part of the "build-id" attribute.
    
    gdb/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Validate symbol file using build-id.
    	* NEWS (Changes since GDB 7.10): Add 'set validate-build-id'
    	and 'show validate-build-id'.  Add build-id attribute.
    	* solib-darwin.c (_initialize_darwin_solib): Assign validate value.
    	* solib-dsbt.c (_initialize_dsbt_solib): Ditto.
    	* solib-frv.c (_initialize_frv_solib): Ditto.
    	* solib-spu.c (set_spu_solib_ops): Ditto.
    	* solib-svr4.c: Include rsp-low.h.
    	(NOTE_GNU_BUILD_ID_NAME): New define.
    	(svr4_validate): New function.
    	(svr4_copy_library_list): Duplicate field 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 (validate_build_id, show_validate_build_id): New.
    	(solib_map_sections): Use ops->validate.
    	(clear_so): Free build_id.
    	(default_solib_validate): New function.
    	(_initialize_solib): Add "validate-build-id".
    	* 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'.
    
    gdb/doc/ChangeLog
    2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* gdb.texinfo (Files): Add 'set validate-build-id'
    	and 'show validate-build-id'.

commit 92266c35bc7ccf402827fd15dcf01d4475522b8d
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Jul 15 17:37:28 2015 +0200

    gdbserver build-id attribute generator
    
    Producer part of the new "build-id" XML attribute.
    
    gdb/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	gdbserver build-id attribute generator.
    	* features/library-list-svr4.dtd (library-list-svr4): New
    	'build-id' attribute.
    
    gdb/doc/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.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/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.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.

commit 24ef919babbb591d0a1aceeb3afd9fce7f573147
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Jul 15 17:37:27 2015 +0200

    Move linux_find_memory_regions_full & co.
    
    This should be just a move with no changes.
    
    gdb/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Move linux_find_memory_regions_full & co.
    	* linux-tdep.c (linux-maps.h): Include.
    	(gdb_regex.h): Remove the include.
    	(enum filterflags, struct smaps_vmflags, read_mapping, decode_vmflags)
    	(mapping_is_anonymous_p, dump_mapping_p): Moved to common/linux-maps.c.
    	(linux_find_memory_region_ftype): Moved typedef to common/linux-maps.h.
    	(linux_find_memory_regions_full): Moved definition to
    	common/linux-maps.c.
    	* common/linux-maps.c: Include ctype.h, target/target-utils.h,
    	gdb_regex.h and target/target.h.
    	(struct smaps_vmflags, read_mapping, decode_vmflags)
    	(mapping_is_anonymous_p, dump_mapping_p): Move from linux-tdep.c.
    	(linux_find_memory_regions_full): Move from linux-tdep.c.
    	* common/linux-maps.h (read_mapping): New declaration.
    	(linux_find_memory_region_ftype, enum filterflags): Moved from
    	linux-tdep.c.
    	(linux_find_memory_regions_full): New declaration.
    	* target.c (target/target-utils.h): Include.
    	(read_alloc_pread_ftype): Moved typedef to target/target-utils.h.
    	(read_alloc, read_stralloc_func_ftype, read_stralloc): Moved
    	definitions to target/target-utils.c.
    	* target.h (target_fileio_read_stralloc): Move it to target/target.h.
    	* target/target-utils.c (read_alloc, read_stralloc): Move definitions
    	from target.c.
    	* target/target-utils.h (read_alloc_pread_ftype): New typedef.
    	(read_alloc): New declaration.
    	(read_stralloc_func_ftype): New typedef.
    	(read_stralloc): New declaration.
    	* target/target.h (target_fileio_read_stralloc): Move it from target.h.
    
    gdb/gdbserver/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* target.c: Include target/target-utils.h and fcntl.h.
    	(target_fileio_read_stralloc_1_pread, target_fileio_read_stralloc_1)
    	(target_fileio_read_stralloc): New functions.

commit e5293e8b402363b88775a010c20d8818f44637f7
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Jul 15 17:37:27 2015 +0200

    Prepare linux_find_memory_regions_full & co. for move
    
    Prepare code for move into gdb/common/.
    
    gdb/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Prepare linux_find_memory_regions_full & co. for move.
    	* linux-tdep.c (linux_find_memory_region_ftype): Comment.
    	(linux_find_memory_regions_full): Change signature and prepare
    	for moving to linux-maps.
    	(linux_find_memory_regions_data): Rename field 'obfd' to 'data'.
    	(linux_find_memory_regions_thunk): New.
    	(linux_find_memory_regions_thunk): Use 'data' field instead of 'obfd'.
    	(linux_find_memory_regions_gdb): New.
    	(linux_find_memory_regions): Rename argument 'obfd' to 'func_data'.
    	(linux_make_mappings_corefile_notes): Use
    	linux_find_memory_regions_gdb.
    	* target.c (read_alloc_pread_ftype): New typedef.
    	(target_fileio_read_alloc_1_pread): New function.
    	(read_alloc): Refactor from target_fileio_read_alloc_1.
    	(read_stralloc_func_ftype): New typedef.
    	(target_fileio_read_alloc_1): New implementation. Use read_alloc.
    	(read_stralloc): Refactored from target_fileio_read_stralloc.
    	(target_fileio_read_stralloc): New implementation, use read_stralloc.

commit 53ff2abcee6f83ab6d6896b7e4335b95f4477299
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Wed Jul 15 17:37:27 2015 +0200

    Move gdb_regex* to common/
    
    Later patches need regex support also in gdbserver.
    
    gdb/ChangeLog
    2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* Makefile.in (HFILES_NO_SRCDIR): Change gdb_regex.h to
    	common/gdb_regex.h.
    	(COMMON_OBS): Add gdb_regex.o.
    	(gdb_regex.o): New.
    	* common/common.m4 (GDB_AC_COMMON): Add gdb_use_included_regex,
    	--without-included-regex and USE_INCLUDED_REGEX.
    	* common/gdb_regex.c: New file from utils.c functions.
    	* common/gdb_regex.h: Move it here from gdb_regex.h, update include
    	file wrapping define name.
    	* configure: Rebuilt.
    	* configure.ac (gdb_use_included_regex, --without-included-regex)
    	(USE_INCLUDED_REGEX): Move them to common/common.m4.
    	* gdb_regex.h: Move it to common/gdb_regex.h.
    	* utils.c: Remove include gdb_regex.h.
    	(do_regfree_cleanup, make_regfree_cleanup, get_regcomp_error)
    	(compile_rx_or_error): Move them to common/gdb_regex.c.
    
    gdb/gdbserver/ChangeLog
    2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* Makefile.in (OBS): Add gdb_regex.o.
    	(gdb_regex.o): New.
    	* config.in: Rebuilt.
    	* configure: Rebuilt.

commit 9c874130415a43f3b06df0473e6d716e3f6844cf
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Mon Aug 3 22:34:34 2015 +0200

    Create empty common/linux-maps.[ch] and common/target-utils.[ch]
    
    Prepare new files for later move.
    
    gdb/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Create empty common/linux-maps.[ch] and common/target-utils.[ch].
    	* Makefile.in (ALL_TARGET_OBS): Add linux-maps.o.
    	(HFILES_NO_SRCDIR); Add common/linux-maps.h,
    	common/target-utils.h.
    	(COMMON_OBS): Add target-utils.o.
    	(linux-maps.o, target-utils.o): New.
    	* target/target-utils.c: New file.
    	* target/target-utils.h: New file.
    	* common/linux-maps.c: New file.
    	* common/linux-maps.h: New file.
    	* configure.tgt (aarch64*-*-linux*, alpha*-*-linux*)
    	(am33_2.0*-*-linux*, arm*-*-linux*, bfin-*-*linux*, cris*, frv-*-*)
    	(hppa*-*-linux*, i[34567]86-*-linux*, ia64-*-linux*, m32r*-*-linux*)
    	(m68*-*-linux*, microblaze*-linux-*, microblaze*-*-linux*)
    	(mips*-*-linux*, nios2*-*-linux*, powerpc*-*-linux*, s390*-*-linux*)
    	(sh*-*-linux*, sparc-*-linux*, sparc64-*-linux*, tic6x-*-*linux)
    	(tilegx-*-linux*, x86_64-*-linux*, xtensa*-*-linux*): Add linux-maps.o
    	to gdb_target_obs.
    
    gdb/gdbserver/ChangeLog
    2015-07-15  Aleksandar Ristovski  <aristovski@qnx.com
    	    Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	Create empty common/linux-maps.[ch] and common/target-utils.[ch].
    	* Makefile.in (OBS): Add target-utils.o.
    	(linux-maps.o, target-utils.o): New.
    	* configure.srv (srv_linux_obj): Add linux-maps.o.

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

Summary of changes:
 gdb/Makefile.in                           |    6 +-
 gdb/build-id.c                            |  137 +++--------
 gdb/build-id.h                            |    3 -
 gdb/cli/cli-cmds.c                        |    7 +-
 gdb/common/filestuff.c                    |    2 -
 gdb/{nat => common}/linux-maps.c          |    0
 gdb/{nat => common}/linux-maps.h          |    6 +-
 gdb/defs.h                                |   15 +-
 gdb/doc/ChangeLog                         |    6 +
 gdb/doc/gdb.texinfo                       |   20 +-
 gdb/dwarf2read.c                          |    6 +-
 gdb/exec.c                                |   80 ++++++-
 gdb/features/library-list-svr4.dtd        |    5 +-
 gdb/gdb_bfd.c                             |   18 +-
 gdb/gdb_bfd.h                             |    2 -
 gdb/gdbserver/Makefile.in                 |    2 +-
 gdb/gdbserver/linux-low.c                 |   19 +--
 gdb/linux-tdep.c                          |    2 +-
 gdb/nto-tdep.c                            |   30 ++-
 gdb/nto-tdep.h                            |    2 +-
 gdb/solib-aix.c                           |    6 +-
 gdb/solib-darwin.c                        |    5 +-
 gdb/solib-dsbt.c                          |    3 +-
 gdb/solib-frv.c                           |    3 +-
 gdb/solib-spu.c                           |    5 +-
 gdb/solib-svr4.c                          |  156 ++++++++-----
 gdb/solib-target.c                        |    2 +
 gdb/solib.c                               |  338 ++++++++++++----------------
 gdb/solib.h                               |    4 +
 gdb/solist.h                              |   22 ++-
 gdb/source.c                              |  355 ++++-------------------------
 gdb/source.h                              |   24 --
 gdb/symfile.c                             |   31 ++-
 gdb/testsuite/gdb.base/solib-mismatch.exp |   46 +----
 gdb/utils.c                               |    9 -
 gdb/utils.h                               |    2 -
 36 files changed, 506 insertions(+), 873 deletions(-)
 rename gdb/{nat => common}/linux-maps.c (100%)
 rename gdb/{nat => common}/linux-maps.h (96%)

First 500 lines of diff:
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 66d5117..2d86684 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -904,7 +904,7 @@ LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c
 # right, it is probably easiest just to list .h files here directly.
 
 HFILES_NO_SRCDIR = \
-common/gdb_signals.h nat/gdb_thread_db.h common/gdb_vecs.h nat/linux-maps.h \
+common/gdb_signals.h nat/gdb_thread_db.h common/gdb_vecs.h common/linux-maps.h \
 common/x86-xstate.h nat/linux-ptrace.h nat/mips-linux-watch.h \
 proc-utils.h aarch64-tdep.h arm-tdep.h ax-gdb.h ppcfbsd-tdep.h \
 ppcnbsd-tdep.h cli-out.h gdb_expat.h breakpoint.h infcall.h obsd-tdep.h \
@@ -2221,8 +2221,8 @@ common-agent.o: $(srcdir)/common/agent.c
 	$(COMPILE) $(srcdir)/common/agent.c
 	$(POSTCOMPILE)
 
-linux-maps.o: ${srcdir}/nat/linux-maps.c
-	$(COMPILE) $(srcdir)/nat/linux-maps.c
+linux-maps.o: ${srcdir}/common/linux-maps.c
+	$(COMPILE) $(srcdir)/common/linux-maps.c
 	$(POSTCOMPILE)
 
 vec.o: ${srcdir}/common/vec.c
diff --git a/gdb/build-id.c b/gdb/build-id.c
index 037d710..c89cd55 100644
--- a/gdb/build-id.c
+++ b/gdb/build-id.c
@@ -26,23 +26,6 @@
 #include "objfiles.h"
 #include "filenames.h"
 #include "gdbcore.h"
-#include "gdbcmd.h"
-#include "source.h"
-#include "rsp-low.h"
-
-/* Boolean for command 'set validate-build-id'.  */
-int validate_build_id = 1;
-
-/* Implement 'show validate-build-id'.  */
-
-static void
-show_validate_build_id (struct ui_file *file, int from_tty,
-			struct cmd_list_element *c, const char *value)
-{
-  fprintf_filtered (file, _("Validation a build-id matches to load a shared "
-			    "library is %s.\n"),
-		    value);
-}
 
 /* See build-id.h.  */
 
@@ -64,62 +47,38 @@ build_id_bfd_get (bfd *abfd)
 int
 build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check)
 {
-  const struct bfd_build_id *found = build_id_bfd_get (abfd);
-  char *message, *check_hex = alloca (check_len * 2 + 1);
-  struct cleanup *back_to;
+  const struct bfd_build_id *found;
+  int retval = 0;
 
-  bin2hex (check, check_hex, check_len);
+  found = build_id_bfd_get (abfd);
 
   if (found == NULL)
-    message = xstrprintf (_("inferior build ID is %s but symbol file \"%s\" "
-			    "does not have build ID"),
-			  check_hex, bfd_get_filename (abfd));
+    warning (_("File \"%s\" has no build-id, file skipped"),
+	     bfd_get_filename (abfd));
   else if (found->size != check_len
            || memcmp (found->data, check, found->size) != 0)
-    {
-      char *abfd_hex = alloca (found->size * 2 + 1);
-
-      bin2hex (found->data, abfd_hex, found->size);
-      message = xstrprintf (_("inferior build ID %s is not identical to "
-			      "symbol file \"%s\" build ID %s"),
-			    check_hex, bfd_get_filename (abfd), abfd_hex);
-    }
+    warning (_("File \"%s\" has a different build-id, file skipped"),
+	     bfd_get_filename (abfd));
   else
-    return 1;
-  back_to = make_cleanup (xfree, message);
+    retval = 1;
 
-  if (validate_build_id)
-    {
-      warning (_("Symbol file \"%s\" could not be validated (%s) and "
-		 "will be ignored; or use 'set validate-build-id off'."),
-	       bfd_get_filename (abfd), message);
-      do_cleanups (back_to);
-      return 0;
-    }
-  warning (_("Symbol file \"%s\" could not be validated (%s) "
-	     "but it is being loaded due to 'set validate-build-id off'."),
-	   bfd_get_filename (abfd), message);
-  do_cleanups (back_to);
-  return 1;
+  return retval;
 }
 
-/* Find and open a BFD given a build-id.  If no BFD can be found,
-   return NULL.  Use "" or ".debug" for SUFFIX.  The returned reference to the
-   BFD must be released by the caller.  */
+/* See build-id.h.  */
 
-struct file_location
-build_id_to_file (size_t build_id_len, const bfd_byte *build_id,
-		  const char *suffix, int is_bfd)
+bfd *
+build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
 {
   char *link, *debugdir;
   VEC (char_ptr) *debugdir_vec;
   struct cleanup *back_to;
   int ix;
-  struct file_location result;
+  bfd *abfd = NULL;
 
   /* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
   link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
-		 + 2 * build_id_len + strlen (suffix) + 1);
+		 + 2 * build_id_len + (sizeof ".debug" - 1) + 1);
 
   /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
      cause "/.build-id/..." lookups.  */
@@ -133,6 +92,8 @@ build_id_to_file (size_t build_id_len, const bfd_byte *build_id,
       const gdb_byte *data = build_id;
       size_t size = build_id_len;
       char *s;
+      char *filename = NULL;
+      struct cleanup *inner;
 
       memcpy (link, debugdir, debugdir_len);
       s = &link[debugdir_len];
@@ -146,39 +107,32 @@ build_id_to_file (size_t build_id_len, const bfd_byte *build_id,
 	*s++ = '/';
       while (size-- > 0)
 	s += sprintf (s, "%02x", (unsigned) *data++);
-      strcpy (s, suffix);
+      strcpy (s, ".debug");
 
-      result = file_location_from_filename (link, is_bfd, build_id_len, build_id);
-      if (file_location_is_valid (&result))
-	{
-	  do_cleanups (back_to);
-	  return result;
-	}
-      file_location_free (&result);
-    }
+      /* lrealpath() is expensive even for the usually non-existent files.  */
+      if (access (link, F_OK) == 0)
+	filename = lrealpath (link);
 
-  file_location_enoent (&result);
-  return result;
-}
+      if (filename == NULL)
+	continue;
 
-/* See build-id.h.  */
+      /* We expect to be silent on the non-existing files.  */
+      inner = make_cleanup (xfree, filename);
+      abfd = gdb_bfd_open (filename, gnutarget, -1);
+      do_cleanups (inner);
 
-bfd *
-build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id)
-{
-  struct file_location result;
-  bfd *retval;
+      if (abfd == NULL)
+	continue;
 
-  result = build_id_to_file (build_id_len, build_id, ".debug", 1 /* is_bfd */);
-  if (result.abfd == NULL)
-    {
-      file_location_free (&result);
-      return NULL;
+      if (build_id_verify (abfd, build_id_len, build_id))
+	break;
+
+      gdb_bfd_unref (abfd);
+      abfd = NULL;
     }
-  gdb_bfd_ref (result.abfd);
-  retval = result.abfd;
-  file_location_free (&result);
-  return retval;
+
+  do_cleanups (back_to);
+  return abfd;
 }
 
 /* See build-id.h.  */
@@ -213,22 +167,3 @@ find_separate_debug_file_by_buildid (struct objfile *objfile)
     }
   return NULL;
 }
-
-extern initialize_file_ftype _initialize_build_id; /* -Wmissing-prototypes */
-
-void
-_initialize_build_id (void)
-{
-  add_setshow_boolean_cmd ("validate-build-id", class_support,
-			   &validate_build_id, _("\
-Set validation a build-id matches to load a shared library."), _("\
-SHow validation a build-id matches to load a shared library."), _("\
-Inferior shared library and symbol file may contain unique build-id.\n\
-If both build-ids are present but they do not match then this setting\n\
-enables (off) or disables (on) loading of such symbol file.\n\
-Loading non-matching symbol file may confuse debugging including breakage\n\
-of backtrace output."),
-			   NULL,
-			   show_validate_build_id,
-			   &setlist, &showlist);
-}
diff --git a/gdb/build-id.h b/gdb/build-id.h
index 5fd7043..bea761b 100644
--- a/gdb/build-id.h
+++ b/gdb/build-id.h
@@ -30,7 +30,6 @@ extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd);
 extern int build_id_verify (bfd *abfd,
 			    size_t check_len, const bfd_byte *check);
 
-extern struct file_location build_id_to_file (size_t build_id_len, const bfd_byte *build_id, const char *suffix, int is_bfd);
 
 /* Find and open a BFD given a build-id.  If no BFD can be found,
    return NULL.  The returned reference to the BFD must be released by
@@ -46,6 +45,4 @@ extern bfd *build_id_to_debug_bfd (size_t build_id_len,
 
 extern char *find_separate_debug_file_by_buildid (struct objfile *objfile);
 
-extern int validate_build_id;
-
 #endif /* BUILD_ID_H */
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 4723f1f..2ec2dd3 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -499,7 +499,7 @@ find_and_open_script (const char *script_file, int search_path,
   char *file;
   int fd;
   struct cleanup *old_cleanups;
-  int search_flags = OPF_TRY_CWD_FIRST;
+  int search_flags = OPF_TRY_CWD_FIRST | OPF_RETURN_REALPATH;
 
   file = tilde_expand (script_file);
   old_cleanups = make_cleanup (xfree, file);
@@ -509,7 +509,8 @@ find_and_open_script (const char *script_file, int search_path,
 
   /* Search for and open 'file' on the search path used for source
      files.  Put the full location in *FULL_PATHP.  */
-  fd = openp (source_path, search_flags, file, full_pathp);
+  fd = openp (source_path, search_flags,
+	      file, O_RDONLY, full_pathp);
 
   if (fd == -1)
     {
@@ -521,8 +522,6 @@ find_and_open_script (const char *script_file, int search_path,
 
   do_cleanups (old_cleanups);
 
-  *full_pathp = gdb_realpath_and_xfree (*full_pathp);
-
   *streamp = fdopen (fd, FOPEN_RT);
   if (*streamp == NULL)
     {
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index 9124e8b..25ea8fa 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -244,7 +244,6 @@ static void
 mark_cloexec (int fd)
 {
 #ifdef HAVE_F_GETFD
-  int save_errno = errno;
   int old = fcntl (fd, F_GETFD, 0);
 
   if (old != -1)
@@ -259,7 +258,6 @@ mark_cloexec (int fd)
 	    trust_o_cloexec = -1;
 	}
     }
-  errno = save_errno;
 #endif /* HAVE_F_GETFD */
 }
 
diff --git a/gdb/nat/linux-maps.c b/gdb/common/linux-maps.c
similarity index 100%
rename from gdb/nat/linux-maps.c
rename to gdb/common/linux-maps.c
diff --git a/gdb/nat/linux-maps.h b/gdb/common/linux-maps.h
similarity index 96%
rename from gdb/nat/linux-maps.h
rename to gdb/common/linux-maps.h
index 7e10d65..0bec9db 100644
--- a/gdb/nat/linux-maps.h
+++ b/gdb/common/linux-maps.h
@@ -16,8 +16,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef NAT_LINUX_MAPS_H
-#define NAT_LINUX_MAPS_H
+#ifndef COMMON_LINUX_MAPS_H
+#define COMMON_LINUX_MAPS_H
 
 extern void
   read_mapping (const char *line,
@@ -61,4 +61,4 @@ extern int
 				  linux_find_memory_region_ftype *func,
 				  void *func_data);
 
-#endif /* NAT_LINUX_MAPS_H */
+#endif /* COMMON_LINUX_MAPS_H */
diff --git a/gdb/defs.h b/gdb/defs.h
index 2e91d83..a555da1 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -316,18 +316,11 @@ extern const char *pc_prefix (CORE_ADDR);
 /* From source.c */
 
 /* See openp function definition for their description.  */
-enum openp_flags
-{
-  OPF_TRY_CWD_FIRST   = (1 << 0),
-  OPF_SEARCH_IN_PATH  = (1 << 1),
-  OPF_IS_BFD          = (1 << 2),
-};
-
-extern int openp (const char *, enum openp_flags, const char *, char **);
-
-extern bfd *openp_bfd (const char *path, enum openp_flags opts, const char *string);
+#define OPF_TRY_CWD_FIRST     0x01
+#define OPF_SEARCH_IN_PATH    0x02
+#define OPF_RETURN_REALPATH   0x04
 
-extern struct file_location openp_file (const char *path, enum openp_flags opts, const char *string, size_t build_idsz, const gdb_byte *build_id);
+extern int openp (const char *, int, const char *, int, char **);
 
 extern int source_full_path_of (const char *, char **);
 
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index c305b16..eec2dc6 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -8,6 +8,12 @@
 
 2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
+	Revert the previous 2 commits:
+	gdbserver build-id attribute generator
+	Validate symbol file using build-id
+
+2015-07-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
 	* gdb.texinfo (Files): Add 'set validate-build-id'
 	and 'show validate-build-id'.
 
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 752b9d4..513c08e 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -17957,10 +17957,8 @@ discarded.
 Setting to override @value{GDBN} build-id check.
 
 Inferior shared libraries and symbol files may contain unique build-id.
-@value{GDBN} expects the build-ids of each shared library and its corresponding
-symbol file to be identical.  If they are not identical, then by default
-@value{GDBN} will @value{GDBN} will ignore symbol files with non-matching
-build-id while printing:
+By default @value{GDBN} will ignore symbol files with non-matching build-id
+while printing:
 
 @smallexample
   warning: Shared object "libfoo.so.1" could not be validated (remote
@@ -39558,10 +39556,8 @@ 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.  Similarly the single
-@code{main-build-id} optional attribute specifies hex encoded
-@code{NT_GNU_BUILD_ID} note for the main executable.
+@code{struct link_map} used for the main executable.  This parameter is used
+for TLS access and its presence is optional.
 
 @value{GDBN} must be linked with the Expat library to support XML
 SVR4 library lists.  @xref{Expat}.
@@ -39570,8 +39566,7 @@ 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"
-    main-build-id="b96b2f6fbfb7d144b676cb66f56b6100">
+<library-list-svr4 version="1.0" main-lm="0xe4f8f8">
   <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"
@@ -39584,9 +39579,8 @@ 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  main-build-id CDATA   #IMPLIED>
+<!ATTLIST library-list-svr4  version  CDATA   #FIXED  "1.0">
+<!ATTLIST library-list-svr4  main-lm  CDATA   #IMPLIED>
 <!ELEMENT library            EMPTY>
 <!ATTLIST library            name     CDATA   #REQUIRED>
 <!ATTLIST library            lm       CDATA   #REQUIRED>
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 75b46a5..24a4022 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10475,14 +10475,14 @@ try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
   else
     search_path = xstrdup (debug_file_directory);
 
-  flags = 0;
+  flags = OPF_RETURN_REALPATH;
   if (is_dwp)
     flags |= OPF_SEARCH_IN_PATH;
-  desc = openp (search_path, flags, file_name, &absolute_name);
+  desc = openp (search_path, flags, file_name,
+		O_RDONLY | O_BINARY, &absolute_name);
   xfree (search_path);
   if (desc < 0)
     return NULL;
-  absolute_name = gdb_realpath_and_xfree (absolute_name);
 
   sym_bfd = gdb_bfd_open (absolute_name, gnutarget, desc);
   xfree (absolute_name);
diff --git a/gdb/exec.c b/gdb/exec.c
index 631861b..f1b1049 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -216,30 +216,84 @@ exec_file_attach (const char *filename, int from_tty)
     }
   else
     {
+      int load_via_target = 0;
+      char *scratch_pathname, *canonical_pathname;
+      int scratch_chan;
       struct target_section *sections = NULL, *sections_end = NULL;
       char **matching;
 
-      exec_bfd = openp_bfd (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename);
-#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
-      if (exec_bfd == NULL)
+      if (is_target_filename (filename))
+	{
+	  if (target_filesystem_is_local ())
+	    filename += strlen (TARGET_SYSROOT_PREFIX);
+	  else
+	    load_via_target = 1;
+	}
+
+      if (load_via_target)
 	{
-	  char *exename = alloca (strlen (filename) + 5);
+	  /* gdb_bfd_fopen does not support "target:" filenames.  */
+	  if (write_files)
+	    warning (_("writing into executable files is "
+		       "not supported for %s sysroots"),
+		     TARGET_SYSROOT_PREFIX);
 
-	  strcat (strcpy (exename, filename), ".exe");
-	  exec_bfd = openp_bfd (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename);
+	  scratch_pathname = xstrdup (filename);
+	  make_cleanup (xfree, scratch_pathname);
+
+	  scratch_chan = -1;
+
+	  canonical_pathname = scratch_pathname;
 	}
+      else
+	{
+	  scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
+				filename, write_files ?
+				O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
+				&scratch_pathname);
+#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
+	  if (scratch_chan < 0)
+	    {
+	      char *exename = alloca (strlen (filename) + 5);
+
+	      strcat (strcpy (exename, filename), ".exe");
+	      scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
+				    exename, write_files ?
+				    O_RDWR | O_BINARY
+				    : O_RDONLY | O_BINARY,
+				    &scratch_pathname);
+	    }
 #endif


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


             reply	other threads:[~2015-08-03 20:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 20:36 jkratoch [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-07-23 17:19 jkratoch
2015-06-21 10:15 jkratoch
2015-06-14 19:25 jkratoch
2015-06-07 20:03 jkratoch
2015-06-07 20:02 jkratoch
2014-03-19 22:17 jkratoch
2014-03-19 21:22 jkratoch
2014-03-08 19:58 jkratoch
2014-03-03 20:58 jkratoch
2014-03-02 19:50 jkratoch
2014-03-02 18:52 jkratoch
2014-03-02  9:51 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=20150803203654.47582.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).