From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 91002 invoked by alias); 19 Aug 2015 16:20:03 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 90983 invoked by uid 9674); 19 Aug 2015 16:20:02 -0000 Date: Wed, 19 Aug 2015 16:20:00 -0000 Message-ID: <20150819162002.90895.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] jankratochvil/gdbserverbuildid: mainbuildid X-Git-Refname: refs/heads/jankratochvil/gdbserverbuildid X-Git-Reftype: branch X-Git-Oldrev: 295a8e9aac03bc1d9e4171d390547dfe36f091b1 X-Git-Newrev: e5507f8594737d27a2f2fe16f2221e4ca649146d X-SW-Source: 2015-q3/txt/msg00036.txt.bz2 List-Id: The branch, jankratochvil/gdbserverbuildid has been updated discards 295a8e9aac03bc1d9e4171d390547dfe36f091b1 (commit) discards 62ef4dab59b9919fa01adc1f47b31a87b24d9679 (commit) discards 0135e550ce15ed1b3796c16b1a77b09410395681 (commit) discards fef4666f6b3f3ffbd9c2e85f2990514772a84895 (commit) discards 985601646481aefd6304f398be8b03545c877559 (commit) discards 1eb21b54e9572702cb377dd2c401242d03c541f3 (commit) discards 749f69903be8e96e0d0362408eb9f5dbb4c681fb (commit) discards 170204351e1aff6160e08ca6e3d420cd901ef9c3 (commit) discards b74795165b852e4427d14968b77a668262b2b61b (commit) discards 3865249c28d15498ad90589719c5ce0e0582de25 (commit) discards 40d06717b5315f7770f4e3dd763cf55897578ecf (commit) discards ea0ea3b46c08a5922a8cfdbf784d3669a42ad4c9 (commit) discards 902f3ad6b7b42c21d891a220be74c783366907de (commit) discards c976bc3030cad2ff2b9135c3e63982a9446c04a3 (commit) discards de12313d1abfe8467a42df3ea4cea698f2c566b8 (commit) discards a4e19f0c9c7087922910fb56d8a709a4a99bc86b (commit) discards 4b60037e3600142aa6e3d0dbceccc6432b51694b (commit) discards 015dc972aa3cd7c7d71bcb368bf8af110e0efe7b (commit) discards 6c4892292153b82202d598a5c75f4d7f333737ac (commit) discards 69d58245ab0758763c4c14da6fb09d4ea93754e3 (commit) discards 0cb6c2225a22f28f09c821934dc32911ce868034 (commit) discards d9cbc96668c5af6ba19f937e80635e7d80d2dccc (commit) discards 548608ab3b42c9376055224ccd5ecd6fc7bdc52c (commit) discards 7cd5067be92346752ad6dde93a938d596582484a (commit) discards fee553fc5696a90209ffc0f1b2a4e3fe0cf7b162 (commit) discards 758d882951dd2084b80a7ab0ab249eebd447c87c (commit) discards 675af07c3197652f1d6cfe1ae16c299f8e12c44a (commit) discards 28bea9dcc9f5d5c3aae0a83a11a7f75d7abc31b3 (commit) discards 0b1ba7f7810a813a5ecd883b4d31c87a09a7ecdd (commit) discards fdbe940d41ab5212b13c0e2c9de2210290bd0f39 (commit) discards 07980d2eb445547f2c40bddbba0593c631f4b4cc (commit) via e5507f8594737d27a2f2fe16f2221e4ca649146d (commit) via 5ff4e589f6fe2bc2a8650f787f9a19b1c5ab2dd2 (commit) via 3751bb587bb5e1646a1fcba1ebffa27f6106dccd (commit) via 5f63a388e55f85724b5d43612cfd50fe61c1d129 (commit) via 5947a0c9cceb88d4a9ce62c67f3f61e363de7ddc (commit) via 4e1494a43a52b384d696e02f2906d80e306a95f6 (commit) via fbf2026ee8b96565184917aaa92bba3c9e1f14d5 (commit) via 11dadb4d264555fd91ab0ae46a136dc61af990f5 (commit) via a5f5b8ea74ee76db95178b3d2ce7623ba614007a (commit) via 41492ad8abdaf4cc33c9f70550f45251a080eb23 (commit) via 06333a2a928fc3336ab1bdcc881d6d7437d14086 (commit) via f3deab52baf3eb5e375a7f336c9de79a9eb90a85 (commit) via fc02788f47d59ce13086aa0877d62ee422d56c10 (commit) via 28f27b3907e177dd11ee4c9bcc0c802a40ffb44d (commit) via b13b54a2c120999e08bfca8e4d8ab2148a7745fe (commit) via 3cb111fb4dedceda32b0daaf5c05d9b68751a048 (commit) via 8b26582be65a0db52f849eebfdf60c7678e69779 (commit) via 1042077e6bef94e03fe6371aa5ff02b6c7ecaa0a (commit) via 26b420e6255539de37024a6af1927b886b1b510a (commit) via 2179cd5a95f40a8bcafa2bfc55504c68631254d2 (commit) via 21b5225718b928c4f47bfeb660f3d1af6dd281ed (commit) via 1837127dfa8a55db25a410a5f6b705fc7c66499f (commit) via 530b609f9e975ec38b2e234dfdbd6260f76ecaf6 (commit) via fa098ccdf9a6eb22c98ec202d4b6ff605c0f785d (commit) via 6e49cd7f3be2d9090b1afbea9ed8475d27a2afba (commit) via 4df97c6d0d18295c788d8bf3f1dd62ccfdaa4810 (commit) via 5f17ab81872a7e316cb83dcb814bd2444783978e (commit) via e0b27412689ea95cc05d207f6091c70972077fc5 (commit) via f6cd4980f1bb94b524dca174dcdd381ad2be32da (commit) via ace8843332eb835e1010275d6ba2d4f2cddbdb5d (commit) via ec0053bd4301d249eef54d95908e5849ab100724 (commit) from 295a8e9aac03bc1d9e4171d390547dfe36f091b1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit e5507f8594737d27a2f2fe16f2221e4ca649146d Author: Jan Kratochvil Date: Thu Aug 13 16:17:19 2015 +0200 mainbuildid commit 5ff4e589f6fe2bc2a8650f787f9a19b1c5ab2dd2 Author: Jan Kratochvil Date: Sun Aug 16 22:11:19 2015 +0200 sticky Message-ID: <559A7C37.6020501@redhat.com> On 07/03/2015 04:44 PM, Pedro Alves wrote: > (I still suspect that if we reverse the sense of the flag, then > its management ends up being more centralized, as then the > place that sets it is also the place that needs to check it, > instead of doing that in multiple places. But, see below.) It didn't seem fair to impose a subjective preference, so I tried this in order to understand it myself, and I now agree that is really doesn't make much difference, as then we'd have to mark auto-discovered in a few more places that I wasn't originally seeing. There's at least the execd handling in infrun.c, and also spu_symbol_file_add_from_memory. As I was playing with this already, I poked at the other review points I made, and came up with the variant of the patch below. > This function is called while the passed in PID is not the > current inferior. E.g., the remote_add_inferior path. > > Therefore seems to me that these symbol_file_add_main / exec_file_attach > calls can change the symbols of the wrong inferior. ... > I also notice that reread_symbols has an exec_file_attach > call which seems to me results in losing the is_user_supplied > flag if the executable's timestamp changed, at least here: > >> + /* Attempt to open the file that was executed to create this >> + inferior. If the user has explicitly specified executable >> + and/or symbol files then warn the user if their choices do >> + not match. Otherwise, set exec_file and symfile_objfile to >> + the new file. */ >> + exec_file_locate_attach (ptid_get_pid (inferior_ptid), from_tty); >> + >> + if (exec_file_is_user_supplied) >> { >> reopen_exec_file (); >> reread_symbols (); > > > I also notice that the clone-inferior command ends up with > an exec_file_attach call in clone_program_space. That one > should probably be setting the is_user_supplied flag too, > I'd think. Or at least, copying it from the original. > > At this point, I'm wondering about adding a parameter to > exec_file_attach to force considering (now and in future) > the right value to put in the flag in each case. I tried this too (see patch below). As this requires touching the user-supplied paths anyway, it didn't really matter to tag files user-supplied or auto-discovered, so I reverted back to user-supplied. For symbols, we already have the add_flags, so I added SYMFILE_USER_SUPPLIED instead of a new boolean. > >> @@ -2490,11 +2490,14 @@ attach_command_post_wait (char *args, int from_tty, int async_exec) >> inferior = current_inferior (); >> inferior->control.stop_soon = NO_STOP_QUIETLY; >> >> - /* If no exec file is yet known, try to determine it from the >> - process itself. */ >> - if (get_exec_file (0) == NULL) >> - exec_file_locate_attach (ptid_get_pid (inferior_ptid), from_tty); >> - else >> + /* Attempt to open the file that was executed to create this >> + inferior. If the user has explicitly specified executable >> + and/or symbol files then warn the user if their choices do >> + not match. Otherwise, set exec_file and symfile_objfile to >> + the new file. */ >> + exec_file_locate_attach (ptid_get_pid (inferior_ptid), from_tty); >> + >> + if (exec_file_is_user_supplied) >> { >> reopen_exec_file (); >> reread_symbols (); > > It seems to me that we should be able to move these reopen/reread > calls inside exec_file_locate_attach. I did this too. What do you think of the version below? I also tweaked the warnings a bit, to explicitly say "mismatch". This would still need docs/NEWS changes, and a test would be good too. commit 3751bb587bb5e1646a1fcba1ebffa27f6106dccd Author: Jan Kratochvil Date: Thu Aug 13 16:17:19 2015 +0200 hexallocate commit 5f63a388e55f85724b5d43612cfd50fe61c1d129 Author: Jan Kratochvil Date: Thu Aug 13 16:17:19 2015 +0200 locatetest commit 5947a0c9cceb88d4a9ce62c67f3f61e363de7ddc Author: Jan Kratochvil Date: Thu Aug 13 16:17:19 2015 +0200 Tests for validate symbol file using build-id New testcase. gdb/testsuite/ChangeLog 2015-07-15 Aleksandar Ristovski Date: Thu Aug 13 16:17:18 2015 +0200 buildidwarn commit fbf2026ee8b96565184917aaa92bba3c9e1f14d5 Author: Jan Kratochvil Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibbfdopen commit 11dadb4d264555fd91ab0ae46a136dc61af990f5 Author: Jan Kratochvil Date: Thu Aug 13 16:17:18 2015 +0200 buildidverify commit a5f5b8ea74ee76db95178b3d2ce7623ba614007a Author: Jan Kratochvil Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibsearch commit 41492ad8abdaf4cc33c9f70550f45251a080eb23 Author: Jan Kratochvil Date: Thu Aug 13 16:17:18 2015 +0200 buildidtofile commit 06333a2a928fc3336ab1bdcc881d6d7437d14086 Author: Jan Kratochvil Date: Thu Aug 13 16:17:17 2015 +0200 buildidproto commit f3deab52baf3eb5e375a7f336c9de79a9eb90a85 Author: Jan Kratochvil Date: Thu Aug 13 16:17:17 2015 +0200 buildidtobfd commit fc02788f47d59ce13086aa0877d62ee422d56c10 Author: Jan Kratochvil Date: Thu Aug 13 16:17:17 2015 +0200 buildidforcemove commit 28f27b3907e177dd11ee4c9bcc0c802a40ffb44d Author: Jan Kratochvil Date: Thu Aug 13 16:17:17 2015 +0200 buildidfreefix commit b13b54a2c120999e08bfca8e4d8ab2148a7745fe Author: Jan Kratochvil Date: Thu Aug 13 16:17:16 2015 +0200 openpsymfile commit 3cb111fb4dedceda32b0daaf5c05d9b68751a048 Author: Jan Kratochvil Date: Thu Aug 13 16:17:16 2015 +0200 openpsolib commit 8b26582be65a0db52f849eebfdf60c7678e69779 Author: Jan Kratochvil Date: Thu Aug 13 16:17:16 2015 +0200 Refactor openp() to return file_location Hi, openp() remains as a backward compatibility wrapper around renamed openp->openp_file(). Jan gdb/ChangeLog 2015-08-19 Jan Kratochvil * defs.h (enum openp_flags): Remove OPF_OPEN_RW_TMP, add OPF_BFD_CANONICAL. (openp_bfd, openp_file): Add prototypes. * exec.c (exec_file_attach): Replace openp by openp_bfd calls. * source.c (file_location_from_filename): Support OPF_BFD_CANONICAL. (openp, openp_bfd): New functions. (openp): Rename to ... (openp_file): ... here, return file_location, remove filename_opened parameter. commit 1042077e6bef94e03fe6371aa5ff02b6c7ecaa0a Author: Jan Kratochvil Date: Thu Aug 13 16:17:16 2015 +0200 Add file_location utility functions Hi, build id verification faces a problem current codebase calls openp() and similar functions which search many directories and after they find the file they return its filename. Caller then typically opens that file as BFD. But to search the directories openp() needs to open each file it iterates to verify their build-id. Then it would close the file and caller would reopen it again. This is inefficient (+racy), so a new intermediate representation of the found files is created (file_location). Another possibility would be to depends on bfd cache as being done in exec_file_attach. But then a similar problem is needed for callers which want only fd (and not bfd). Besides that I find depending on pending make_cleanup_bfd_unref() from openp() calls would be tricky. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * defs.h (enum openp_flags): Add OPF_IS_BFD. * gdb_bfd.c (fileio_errno_to_host): Make it public. * gdb_bfd.h (fileio_errno_to_host): Add prototype. * source.c: Include inferior.h and gdb/fileio.h. (file_location_enoent, file_location_free, file_location_cleanup) (file_location_is_valid, file_location_from_filename) (file_location_to_bfd, filename_to_bfd): New functions. * source.h (struct file_location): New definition. (file_location_enoent, file_location_free, file_location_is_valid) (file_location file_location_from_filename, file_location_to_bfd) (filename_to_bfd): New prototypes. commit 26b420e6255539de37024a6af1927b886b1b510a Author: Jan Kratochvil Date: Thu Aug 13 16:17:15 2015 +0200 gdb_bfd_open_from_target: Optionally do not close fd Hi, gdb_bfd_open_from_target currently always embedded passed fd into returned BFD and closed that fd after closing that BFD. As one cannot do dup() for target fileio FDs one could not use FD after BFD using it has been closed. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * gdb_bfd.c (gdb_bfd_iovec_fileio_close_nop): New function. (gdb_bfd_open_from_target): Add parameter do_close. Optionally pass gdb_bfd_iovec_fileio_close_nop. (gdb_bfd_open): Update caller. * gdb_bfd.h (gdb_bfd_open_from_target): Update prototype. commit 2179cd5a95f40a8bcafa2bfc55504c68631254d2 Author: Jan Kratochvil Date: Thu Aug 13 16:17:15 2015 +0200 gdb_bfd_open_from_target: Support real fd Hi, gdb_bfd_open_from_target is extended so that it can be now passed also some non-(-1) fd. non-(-1) fd was not supported for remote files in mainline. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * gdb_bfd.c (gdb_bfd_iovec_fileio_open_fd): New function. (gdb_bfd_open_from_target): Conditionally use it. commit 21b5225718b928c4f47bfeb660f3d1af6dd281ed Author: Jan Kratochvil Date: Thu Aug 13 16:17:15 2015 +0200 Provide new gdb_bfd_open_from_target Hi, later code needs to call the gdb_bfd_openr_iovec part of gdb_bfd_open with more special parameters. So it is refactored out first (and extended later in the next patches). Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * gdb_bfd.c (gdb_bfd_open_from_target): New function from ... (gdb_bfd_open): ... here. Call it. * gdb_bfd.h (gdb_bfd_open_from_target): New prototype. commit 1837127dfa8a55db25a410a5f6b705fc7c66499f Author: Jan Kratochvil Date: Thu Aug 13 16:17:14 2015 +0200 Code cleanup: openp parameter filename_opened is never NULL Hi, this parameter is never passed as NULL in the codebase so the check can be removed. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * source.c (openp): Update function comment for filename_opened. Remove NULL check for filename_opened. commit 530b609f9e975ec38b2e234dfdbd6260f76ecaf6 Author: Jan Kratochvil Date: Thu Aug 13 16:17:14 2015 +0200 Code cleanup: Remove openp parameter mode Hi, simplify the code, make it also suitable for more code refactorings. The new flag OPF_OPEN_RW_TMP is removed later in this patch series. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * cli/cli-cmds.c (find_and_open_script): Update openp caller. * defs.h (enum openp_flags): Add OPF_OPEN_RW_TMP. (openp): Remove parameter mode. * dwarf2read.c (try_open_dwop_file): Update openp caller. * exec.c (exec_file_attach): Likewise. * nto-tdep.c (nto_find_and_open_solib): Remove parameter o_flags, update openp caller. * nto-tdep.h (nto_find_and_open_solib): Remove parameter o_flags. * solib.c (solib_find_2): Update openp and find_and_open_solib caller. * solist.h (struct target_so_ops): Remove parameter o_flags from find_and_open_solib method. * source.c (openp): Change parameter mode to a new variable. (source_full_path_of, find_and_open_source): Update openp caller. * symfile.c (symfile_bfd_open): Likewise. commit fa098ccdf9a6eb22c98ec202d4b6ff605c0f785d Author: Jan Kratochvil Date: Thu Aug 13 16:17:14 2015 +0200 Code cleanup: Remove OPF_RETURN_REALPATH Hi, OPF_RETURN_REALPATH is used only at the end of openp() to convert the returned values. That is not useful, code can be simplified if callers that passed OPF_RETURN_REALPATH adjust the returned values on their own. Or at least it helps further refactorizations. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * cli/cli-cmds.c (find_and_open_script): Remove OPF_RETURN_REALPATH. Call gdb_realpath_and_xfree. * defs.h (enum openp_flags): Add OPF_NONE, remove OPF_RETURN_REALPATH. * dwarf2read.c (try_open_dwop_file): Remove OPF_RETURN_REALPATH. Call gdb_realpath_and_xfree. * nto-tdep.c (nto_find_and_open_solib): Remove OPF_RETURN_REALPATH. Call gdb_realpath_and_xfree and xstrdup. * solib.c (solib_find_2): New variable temp_pathname_is_realpath. Remove OPF_RETURN_REALPATH. Conditionally call gdb_realpath_and_xfree. * source.c (openp): Remove OPF_RETURN_REALPATH processing. (source_full_path_of, find_and_open_source): Remove OPF_RETURN_REALPATH. Call gdb_realpath_and_xfree. * symfile.c (symfile_bfd_open): Likewise. * utils.c (gdb_realpath_and_xfree): New function. * utils.h (gdb_realpath_and_xfree): New prototype. commit 6e49cd7f3be2d9090b1afbea9ed8475d27a2afba Author: Jan Kratochvil Date: Thu Aug 13 16:17:13 2015 +0200 Code cleanup: Add enum for openp_flags Hi, it is for many reasons better, in C++ it could be even type safe. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * cli/cli-cmds.c (find_and_open_script): Use enum openp_flags for search_flags. * defs.h (OPF_TRY_CWD_FIRST, OPF_SEARCH_IN_PATH, OPF_RETURN_REALPATH): Wrap them to a new ... (enum openp_flags): ... enum. (openp): Update prototype. * dwarf2read.c (try_open_dwop_file): Use enum openp_flags for flags. * source.c (openp): Update opts parameter type. Move out OPF_* comments. commit 4df97c6d0d18295c788d8bf3f1dd62ccfdaa4810 Author: Jan Kratochvil Date: Thu Aug 13 16:17:13 2015 +0200 Change sysroot to ":target:" Hi, that is try "" first and "target:" second. Various performance problems should be fixed by trying to look up the remote file first on local filesystem. Thanks to build-ids it is quick and safe to verify both files are the same build. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * NEWS (Changes since GDB 7.10): Mention sysroot. * main.c (captured_main): Initialize new gdb_sysroot. gdb/testsuite/ChangeLog * gdb.base/attach.exp (do_attach_tests): Update sysroot parsing. * gdb.base/break-probes.exp: Likewise. commit 5f17ab81872a7e316cb83dcb814bd2444783978e Author: Jan Kratochvil Date: Thu Aug 13 16:17:13 2015 +0200 Permit multiple sysroot directories Hi, the goal is to have both "" and "target:" as the default gdb_sysroot, in this order. Therefore permit multiple directory components of gdb_sysroot. Jan gdb/ChangeLog 2015-08-18 Jan Kratochvil * NEWS (Changes since GDB 7.10): Mention set sysroot and show sysroot. * solib.c: Include source.h. (solib_find_1): Rename to ... (solib_find_2): ... here and change the sysroot variable to parameter. (solib_find_1): Call it using dirnames_to_char_ptr_vec_target_exc. * source.c (dirnames_to_char_ptr_vec_target_exc): New function. * source.h (dirnames_to_char_ptr_vec_target_exc): New declaration. gdb/doc/ChangeLog 2015-08-18 Jan Kratochvil * gdb.texinfo (Files): Permit set sysroot and show sysroot to have multiple components. commit e0b27412689ea95cc05d207f6091c70972077fc5 Author: Jan Kratochvil Date: Tue Aug 18 19:44:27 2015 +0200 Code cleanup: Make solib_find_1 variable const Hi, it gets used in the next patch. Jan 2015-08-18 Jan Kratochvil * solib.c (solib_find_1): Make sysroot variable const. commit f6cd4980f1bb94b524dca174dcdd381ad2be32da Author: Jan Kratochvil Date: Tue Aug 18 19:44:27 2015 +0200 Validate symbol file using build-id Consumer part of the "build-id" attribute. gdb/ChangeLog 2015-07-15 Aleksandar Ristovski 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 * gdb.texinfo (Files): Add 'set validate-build-id' and 'show validate-build-id'. commit ace8843332eb835e1010275d6ba2d4f2cddbdb5d Author: Jan Kratochvil Date: Tue Aug 18 19:44:26 2015 +0200 gdbserver build-id attribute generator Producer part of the new "build-id" XML attribute. gdb/ChangeLog 2015-07-15 Aleksandar Ristovski 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 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 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 ec0053bd4301d249eef54d95908e5849ab100724 Author: Jan Kratochvil Date: Tue Aug 18 19:44:26 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 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 * 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. ----------------------------------------------------------------------- Summary of changes: gdb/common/linux-maps.c | 3 +- gdb/defs.h | 18 +++++++++++++- gdb/exec.c | 6 +++- gdb/gdb_bfd.c | 12 ++++++--- gdb/solib.c | 25 +++++++++++++++------ gdb/source.c | 55 ++++++++++++++++++++++++---------------------- gdb/source.h | 10 ++++++- 7 files changed, 85 insertions(+), 44 deletions(-) First 500 lines of diff: diff --git a/gdb/common/linux-maps.c b/gdb/common/linux-maps.c index ef3da6a..b9f3990 100644 --- a/gdb/common/linux-maps.c +++ b/gdb/common/linux-maps.c @@ -42,7 +42,8 @@ struct smaps_vmflags unsigned int uses_huge_tlb : 1; - /* Do not include this memory region on the coredump (VM_DONTDUMP, "dd"). */ + /* Do not include this memory region on the coredump + (VM_DONTDUMP, "dd"). */ unsigned int exclude_coredump : 1; diff --git a/gdb/defs.h b/gdb/defs.h index 3369e01..c2c54ad 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -323,8 +323,19 @@ extern const char *pc_prefix (CORE_ADDR); /* See openp function definition for their description. */ enum openp_flags { + /* No options specified, type-compatibile with the enum. */ OPF_NONE = 0, + + /* Try to open ./STRING before searching PATH (ie pretend the first + element of PATH is "."). This also indicates that, unless + OPF_SEARCH_IN_PATH is also specified, a slash in STRING disables + searching of the path (this is so that "exec-file ./foo" or + "symbol-file ./foo" insures that you get that particular version of + foo or an error message). */ OPF_TRY_CWD_FIRST = (1 << 0), + + /* Absolute names will also be searched in path (we usually want this + for source files but not for executables). */ OPF_SEARCH_IN_PATH = (1 << 1), /* Ask for bfd * to be returned in file_location. */ @@ -338,9 +349,12 @@ enum openp_flags extern int openp (const char *, enum openp_flags, const char *, size_t build_idsz, const gdb_byte *build_id, char **); -extern bfd *openp_bfd (const char *path, enum openp_flags opts, const char *string); +extern bfd *openp_bfd (const char *path, enum openp_flags opts, + const char *string); -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 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 source_full_path_of (const char *, size_t build_idsz, const gdb_byte *build_id, char **); diff --git a/gdb/exec.c b/gdb/exec.c index f28d3fb..cb3003f 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -258,14 +258,16 @@ exec_file_attach (int user_supplied, const char *filename, int from_tty) struct target_section *sections = NULL, *sections_end = NULL; char **matching; - exec_bfd = openp_bfd (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_BFD_CANONICAL, filename); + exec_bfd = openp_bfd (getenv ("PATH"), + OPF_TRY_CWD_FIRST | OPF_BFD_CANONICAL, filename); #if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__) if (exec_bfd == NULL) { char *exename = alloca (strlen (filename) + 5); strcat (strcpy (exename, filename), ".exe"); - exec_bfd = openp_bfd (getenv ("PATH"), OPF_TRY_CWD_FIRST | OPF_BFD_CANONICAL, exename); + exec_bfd = openp_bfd (getenv ("PATH"), + OPF_TRY_CWD_FIRST | OPF_BFD_CANONICAL, exename); } #endif if (exec_bfd == NULL) diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 5164886..802f28c 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -380,16 +380,20 @@ gdb_bfd_iovec_fileio_fstat (struct bfd *abfd, void *stream, gdb_bfd_openr_iovec. */ struct bfd * -gdb_bfd_open_from_target (const char *name, const char *target, int fd, int do_close) +gdb_bfd_open_from_target (const char *name, const char *target, int fd, + int do_close) { gdb_assert (is_target_filename (name)); gdb_assert (!target_filesystem_is_local ()); return gdb_bfd_openr_iovec (name, target, - (fd == -1 ? gdb_bfd_iovec_fileio_open : gdb_bfd_iovec_fileio_open_fd), - (fd == -1 ? (void *) current_inferior () : (void *) &fd), + (fd == -1 ? gdb_bfd_iovec_fileio_open + : gdb_bfd_iovec_fileio_open_fd), + (fd == -1 ? (void *) current_inferior () + : (void *) &fd), gdb_bfd_iovec_fileio_pread, - do_close ? gdb_bfd_iovec_fileio_close : gdb_bfd_iovec_fileio_close_nop, + (do_close ? gdb_bfd_iovec_fileio_close + : gdb_bfd_iovec_fileio_close_nop), gdb_bfd_iovec_fileio_fstat); } diff --git a/gdb/solib.c b/gdb/solib.c index 2bcebe8..866ea41 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -152,7 +152,8 @@ show_solib_search_path (struct ui_file *file, int from_tty, */ static struct file_location -solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char *sysroot, size_t build_idsz, const gdb_byte *build_id) +solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, + const char *sysroot, size_t build_idsz, const gdb_byte *build_id) { const struct target_so_ops *ops = solib_ops (target_gdbarch ()); char *temp_pathname; @@ -344,7 +345,8 @@ solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char solib_search_path (if any). */ if (is_solib && solib_search_path != NULL) { - file = openp_file (solib_search_path, OPF_TRY_CWD_FIRST | opts, in_pathname, build_idsz, build_id); + file = openp_file (solib_search_path, OPF_TRY_CWD_FIRST | opts, + in_pathname, build_idsz, build_id); if (file_location_is_valid (&file)) { file.filename = gdb_realpath_and_xfree (file.filename); @@ -359,7 +361,9 @@ solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char from the opened path. */ if (is_solib && solib_search_path != NULL) { - file = openp_file (solib_search_path, OPF_TRY_CWD_FIRST | opts, target_lbasename (fskind, in_pathname), build_idsz, build_id); + file = openp_file (solib_search_path, OPF_TRY_CWD_FIRST | opts, + target_lbasename (fskind, in_pathname), build_idsz, + build_id); if (file_location_is_valid (&file)) { file.filename = gdb_realpath_and_xfree (file.filename); @@ -381,7 +385,10 @@ solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char /* If not found, next search the inferior's $PATH environment variable. */ if (sysroot == NULL) { - file = openp_file (get_in_environ (current_inferior ()->environment, "PATH"), OPF_TRY_CWD_FIRST | opts, in_pathname, build_idsz, build_id); + file = openp_file (get_in_environ (current_inferior ()->environment, + "PATH"), + OPF_TRY_CWD_FIRST | opts, in_pathname, build_idsz, + build_id); if (file_location_is_valid (&file)) { file.filename = gdb_realpath_and_xfree (file.filename); @@ -394,7 +401,10 @@ solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char inferior's $LD_LIBRARY_PATH environment variable. */ if (is_solib && sysroot == NULL) { - file = openp_file (get_in_environ (current_inferior ()->environment, "LD_LIBRARY_PATH"), OPF_TRY_CWD_FIRST | opts, in_pathname, build_idsz, build_id); + file = openp_file (get_in_environ (current_inferior ()->environment, + "LD_LIBRARY_PATH"), + OPF_TRY_CWD_FIRST | opts, in_pathname, build_idsz, + build_id); if (file_location_is_valid (&file)) { file.filename = gdb_realpath_and_xfree (file.filename); @@ -407,11 +417,12 @@ solib_find_3 (char *in_pathname, enum openp_flags opts, int is_solib, const char return file; } -/* It is an solib_find_2 wrapper handling multiple directory components +/* It is an solib_find_3 wrapper handling multiple directory components of GDB_SYSROOT. */ static struct file_location -solib_find_1 (char *in_pathname, enum openp_flags opts, int is_solib, size_t build_idsz, const gdb_byte *build_id) +solib_find_2 (char *in_pathname, enum openp_flags opts, int is_solib, + size_t build_idsz, const gdb_byte *build_id) { VEC (char_ptr) *sysroot_vec; struct cleanup *back_to; diff --git a/gdb/source.c b/gdb/source.c index 61b5893..5cff343 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -858,8 +858,10 @@ file_location_from_filename (const char *filename, enum openp_flags opts, size_t { const int do_close = (opts & OPF_IS_BFD) != 0; - gdb_assert (strcmp (filename, file.filename + strlen (TARGET_SYSROOT_PREFIX)) == 0); - file.abfd = gdb_bfd_open_from_target (file.filename, gnutarget, file.fd, do_close); + gdb_assert (strcmp (filename, + file.filename + strlen (TARGET_SYSROOT_PREFIX)) == 0); + file.abfd = gdb_bfd_open_from_target (file.filename, gnutarget, file.fd, + do_close); if (do_close && file.abfd != NULL) file.fd = -1; } @@ -973,11 +975,23 @@ file_location_to_bfd (struct file_location file) bfd * filename_to_bfd (const char *filename) { - return file_location_to_bfd (file_location_from_filename (filename, OPF_IS_BFD, 0 /* build_idsz */, NULL /* build_id */)); + return file_location_to_bfd (file_location_from_filename (filename, + OPF_IS_BFD, + 0 /* build_idsz */, + NULL /* build_id */)); } +/* Wrapper of openp_file returning filename string. + + FILENAME_OPENED must be non-null. It is set to + file_location.filename returned from openp_file. + + If a file is found, return the descriptor. + Otherwise, return -1, with errno set for the last name we tried to open. */ + int -openp (const char *path, enum openp_flags opts, const char *string, size_t build_idsz, const gdb_byte *build_id, char **filename_opened) +openp (const char *path, enum openp_flags opts, const char *string, + size_t build_idsz, const gdb_byte *build_id, char **filename_opened) { struct file_location file; int retval; @@ -988,9 +1002,12 @@ openp (const char *path, enum openp_flags opts, const char *string, size_t build gdb_assert (file.abfd == NULL); if (file.fd == -1) { + int save_errno = file.file_errno; + gdb_assert (file.filename == NULL); file_location_free (&file); *filename_opened = NULL; + errno = save_errno; return -1; } gdb_assert (file.filename != NULL); @@ -1001,6 +1018,9 @@ openp (const char *path, enum openp_flags opts, const char *string, size_t build return retval; } +/* Wrapper of openp_file returning bfd *. See file_location_to_bfd how + the function behaves in the case of failure. */ + bfd * openp_bfd (const char *path, enum openp_flags opts, const char *string) { @@ -1009,31 +1029,13 @@ openp_bfd (const char *path, enum openp_flags opts, const char *string) return file_location_to_bfd (openp_file (path, opts | OPF_IS_BFD, string, 0, NULL)); } -/* Open a file named STRING, searching path PATH (dir names sep by some char) - using mode MODE in the calls to open. You cannot use this function to - create files (O_CREAT). +/* Open a file named STRING, searching path PATH (dir names sep by some char). + You cannot use this function to create files. OPTS specifies the function behaviour in specific cases. - If OPF_TRY_CWD_FIRST, try to open ./STRING before searching PATH. - (ie pretend the first element of PATH is "."). This also indicates - that, unless OPF_SEARCH_IN_PATH is also specified, a slash in STRING - disables searching of the path (this is so that "exec-file ./foo" or - "symbol-file ./foo" insures that you get that particular version of - foo or an error message). - - If OPTS has OPF_SEARCH_IN_PATH set, absolute names will also be - searched in path (we usually want this for source files but not for - executables). - - FILENAME_OPENED must be non-null. Set it to a newly allocated string naming - the actual file opened (this string will always start with a "/"). We - have to take special pains to avoid doubling the "/" between the directory - and the file, sigh! Emacs gets confuzzed by this when we print the - source file name!!! - - If a file is found, return the descriptor. - Otherwise, return -1, with errno set for the last name we tried to open. */ + Call file_location_is_valid on returned file_location to check + whether this function has succeeded. */ /* >>>> This should only allow files of certain types, >>>> eg executable, non-directory. */ @@ -1190,6 +1192,7 @@ openp_file (const char *path, enum openp_flags opts, const char *string, size_t return file; } + /* This is essentially a convenience, for clients that want the behaviour of openp, using source_path, but that really don't want the file to be opened but want instead just to know what the full pathname is (as diff --git a/gdb/source.h b/gdb/source.h index c1ff46e..e2e2044 100644 --- a/gdb/source.h +++ b/gdb/source.h @@ -108,7 +108,11 @@ struct file_location /* This pointer can be NULL. Use OPF_IS_BFD to get it filled in. */ bfd *abfd; - /* This pointer is never NULL. */ + /* This pointer is never NULL. It names the actual file opened (this + string will always start with a "/"). We have to take special + pains to avoid doubling the "/" between the directory and the file, + sigh! Emacs gets confuzzed by this when we print the source file + name!!! */ char *filename; /* A flag whether FD represents remote target fileio descriptor or @@ -136,7 +140,9 @@ extern void file_location_free (struct file_location *file); extern int file_location_is_valid (const struct file_location *file); -extern struct file_location file_location_from_filename (const char *filename, enum openp_flags opts, size_t build_idsz, const gdb_byte *build_id); +extern struct file_location + file_location_from_filename (const char *filename, enum openp_flags opts, + size_t build_idsz, const gdb_byte *build_id); extern bfd *file_location_to_bfd (struct file_location file); hooks/post-receive -- Repository for Project Archer.