The branch, jankratochvil/gdbserverbuildid has been updated discards ea8ad7ecbd272bdfaaa28fbef8dbd24cd14caa8a (commit) discards ad89a2f824135c905c231a78d9627e6589bb4a95 (commit) discards 4874f3b58bb2c74b62ec7227fbe41386fb5d8007 (commit) discards 5353e034a77740ff0ef0ee48eb9d0f7af01e8307 (commit) discards 82e9f636c521d9ecdf804a9072170177e8e793b3 (commit) discards cd79c4492a000a36649464257cea46def250391c (commit) discards 08ad08f1e4305221a4513ec87e1d5d085c3d4fab (commit) discards 177660d6a8d4f4ba1660fc61b49da42cdf96eb9e (commit) discards 8db972fd3127ea419267b3b235cd7b00b9fe875d (commit) discards a3b70f44851d42fc06a9f94b01ab687440ea19c2 (commit) discards c4c90a0f7bc8317cb962c499ede1208790a9253a (commit) discards c4ef17e38205ff1559a58e3bdd5f6ef92ecda89b (commit) discards 0d00d3a8d93e6ac23d29c7c8e53f1dfc1666a822 (commit) discards 4600db9a5cc528a655a1ebe92d477209d7146800 (commit) discards c1d8b72d24a6123eb8648bdbc1b2e3a56e282bc6 (commit) discards 87d3c70eb6acd1584f17ff27dbfa7853fe0ea9ed (commit) discards 2fce2213eba7e5446979a0ce2d032b1acb621aaf (commit) discards 12f3de0ea0fb4c5d60f5fad73c6f054bd1e0fea1 (commit) discards 8db0b61178445252d6c43384784728b71b7f3f05 (commit) discards e600bf60a682090eb325052245a7c79aba73ff77 (commit) discards 99c41f79be7c1437c8499d632fd13e8ae7d36c32 (commit) discards 06214010ff8650436a4021a8536af52a19e4c748 (commit) discards 418b022857bb6be73630d795ff6ccb818145a566 (commit) discards 79df217f6235b3fc200668fd39dfe38df1dafc44 (commit) discards 47c49eb97dcc9ff751e977d5a57f48e27333c59d (commit) discards 4ab6b65563fb705f0dc5a45396e429995f6dd25c (commit) via aa180b0c7f35cb8f20ffec5d74e9c63a88b422a0 (commit) via 37b4f6ecd060252c96287ecc5e6c17476065b37d (commit) via 37b7a7dc41042cd194d42e4b51ec62a76b67909f (commit) via e70bc7d408e34e531db1a3374fc4d8ba3966727f (commit) via b10b37757831c1d24112dae16c956a5aced002c8 (commit) via 4db67c2978ebc2bab19838a0a4dc938595541856 (commit) via 1fbb639307854a32484a4c24440214cd095b1dd3 (commit) via c5420b36ebe6cee180207253abb8c5807828f51c (commit) via f2291abd5dd1bf7eb65d304cd59da2ef00c4820f (commit) via 0e45553a30b2b8b8adeb0a00a0eed1ab0f37eabf (commit) via 3a8a0b30b2dccbed430eb6c38da165a9fde1feef (commit) via cfe1119c0322114641aee215f9e5f5293b723e82 (commit) via ab4afa2535c0182dc528a1e867c3f57b5d8292c4 (commit) via ff4f9d48102ed472ca527b52640fabc5f750c2cc (commit) via 3754f48adfbdb91c9005e8945f910772c76e1c26 (commit) via 15ee2159ec7f57bd4daa3e404baa41cee9f76637 (commit) via 14cc6806a7ea29ab4b66d7353952d4a05d86ed89 (commit) via 4ad6a791530bc04da99b523d6e7510b195d2543f (commit) via 0f7e18c01c27f2b1ad53c6f8882db8752405ebb9 (commit) via 46a81d5758e65c73e7e4eaf5257c6ff341c068a3 (commit) via 51a6ed4c87273fe52e81b7947dd4ee3c878d3870 (commit) via 116a250b31b5665873c7c58da676528520565f40 (commit) via 6ae7a094e89cdcb07d56586f8c3b9986f0bce700 (commit) via 5ca7075e738daca657d39426377c29632e832b07 (commit) via 7038751dcc9c65cf412ff977869d614d233d7aa0 (commit) via af7cb14bcbbcaabbc8e0edb9dbe99e2ca4d56af3 (commit) from ea8ad7ecbd272bdfaaa28fbef8dbd24cd14caa8a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit aa180b0c7f35cb8f20ffec5d74e9c63a88b422a0 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 mainbuildid commit 37b4f6ecd060252c96287ecc5e6c17476065b37d Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 37b7a7dc41042cd194d42e4b51ec62a76b67909f Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 hexallocate commit e70bc7d408e34e531db1a3374fc4d8ba3966727f Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 locatetest commit b10b37757831c1d24112dae16c956a5aced002c8 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 4db67c2978ebc2bab19838a0a4dc938595541856 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidwarn commit 1fbb639307854a32484a4c24440214cd095b1dd3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibbfdopen commit c5420b36ebe6cee180207253abb8c5807828f51c Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidverify commit f2291abd5dd1bf7eb65d304cd59da2ef00c4820f Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibsearch commit 0e45553a30b2b8b8adeb0a00a0eed1ab0f37eabf Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidtofile commit 3a8a0b30b2dccbed430eb6c38da165a9fde1feef Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidproto commit cfe1119c0322114641aee215f9e5f5293b723e82 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidtobfd commit ab4afa2535c0182dc528a1e867c3f57b5d8292c4 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidforcemove commit ff4f9d48102ed472ca527b52640fabc5f750c2cc Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidfreefix commit 3754f48adfbdb91c9005e8945f910772c76e1c26 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsymfile commit 15ee2159ec7f57bd4daa3e404baa41cee9f76637 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsolib commit 14cc6806a7ea29ab4b66d7353952d4a05d86ed89 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openp commit 4ad6a791530bc04da99b523d6e7510b195d2543f Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 filelib commit 0f7e18c01c27f2b1ad53c6f8882db8752405ebb9 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtargetdoclose commit 46a81d5758e65c73e7e4eaf5257c6ff341c068a3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtargetfd commit 51a6ed4c87273fe52e81b7947dd4ee3c878d3870 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtarget commit 116a250b31b5665873c7c58da676528520565f40 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openpnullpathname commit 6ae7a094e89cdcb07d56586f8c3b9986f0bce700 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openpmode commit 5ca7075e738daca657d39426377c29632e832b07 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openppath commit 7038751dcc9c65cf412ff977869d614d233d7aa0 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:13 2015 +0200 openpenum commit af7cb14bcbbcaabbc8e0edb9dbe99e2ca4d56af3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:13 2015 +0200 sysrootdefault ----------------------------------------------------------------------- Summary of changes: gdb/cli/cli-cmds.c | 2 +- gdb/defs.h | 4 +- gdb/dwarf2read.c | 2 +- gdb/exec.c | 10 ++- gdb/infrun.c | 2 +- gdb/solib-svr4.c | 18 +++ gdb/solib.c | 16 +++- gdb/solist.h | 12 ++- gdb/source.c | 10 +- gdb/testsuite/gdb.base/attach.exp | 7 +- gdb/testsuite/gdb.base/main-mismatch-mod.c | 39 ++++++ gdb/testsuite/gdb.base/main-mismatch.c | 39 ++++++ gdb/testsuite/gdb.base/main-mismatch.exp | 178 ++++++++++++++++++++++++++++ 13 files changed, 323 insertions(+), 16 deletions(-) create mode 100644 gdb/testsuite/gdb.base/main-mismatch-mod.c create mode 100644 gdb/testsuite/gdb.base/main-mismatch.c create mode 100644 gdb/testsuite/gdb.base/main-mismatch.exp First 500 lines of diff: diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 5be758d..2af76a2 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -510,7 +510,7 @@ 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, 0 /* build_idsz */, NULL /* build_id */, full_pathp); if (fd == -1) { diff --git a/gdb/defs.h b/gdb/defs.h index 0011635..f4bdbe1 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -329,13 +329,13 @@ enum openp_flags OPF_BFD_CANONICAL = (1 << 3), }; -extern int openp (const char *, enum openp_flags, const char *, char **); +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 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 *, char **); +extern int source_full_path_of (const char *, size_t build_idsz, const gdb_byte *build_id, char **); extern void mod_path (char *, char **); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 332f102..b2463da 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -10500,7 +10500,7 @@ try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd) flags = 0; if (is_dwp) flags |= OPF_SEARCH_IN_PATH; - desc = openp (search_path, flags, file_name, &absolute_name); + desc = openp (search_path, flags, file_name, 0 /* build_idsz */, NULL /* build_id */, &absolute_name); xfree (search_path); if (desc < 0) return NULL; diff --git a/gdb/exec.c b/gdb/exec.c index 4ec321b..aeec5c2 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -152,10 +152,16 @@ exec_file_and_symbols_resync (struct inferior *inf, int from_tty) exec_file = target_pid_to_exec_file (inf->pid); if (exec_file != NULL) { + size_t build_idsz; + gdb_byte *build_id; + + solib_main_build_id (&build_idsz, &build_id); + make_cleanup (xfree, build_id); + /* If gdb_sysroot is not empty and the discovered filename is absolute then prefix the filename with gdb_sysroot. */ if (*gdb_sysroot != '\0' && IS_ABSOLUTE_PATH (exec_file)) - full_exec_path = exec_file_find (exec_file, NULL); + full_exec_path = exec_file_find (exec_file, build_idsz, build_id, NULL); if (full_exec_path == NULL) { @@ -166,7 +172,7 @@ exec_file_and_symbols_resync (struct inferior *inf, int from_tty) Attempt to qualify the filename against the source path. (If that fails, we'll just fall back on the original filename. Not much more we can do...) */ - if (!source_full_path_of (exec_file, &full_exec_path)) + if (!source_full_path_of (exec_file, build_idsz, build_id, &full_exec_path)) full_exec_path = xstrdup (exec_file); } } diff --git a/gdb/infrun.c b/gdb/infrun.c index 44d2e06..46d14db 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1165,7 +1165,7 @@ follow_exec (ptid_t ptid, char *execd_pathname) if (*gdb_sysroot != '\0') { - char *name = exec_file_find (execd_pathname, NULL); + char *name = exec_file_find (execd_pathname, 0 /* build_idsz */, NULL /* build_id */, NULL); execd_pathname = alloca (strlen (name) + 1); strcpy (execd_pathname, name); diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index f15ea02..196c96a 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1592,6 +1592,23 @@ svr4_current_sos_1 (void) return svr4_current_sos_direct (info); } +static void +svr4_main_build_id (size_t *build_idszp, gdb_byte **build_idp) +{ + struct svr4_info *info = get_svr4_info (); + + /* If the solib list has been read and stored by the probes + interface then even main_build_id should be valid there. */ + if (info->solib_list == NULL) + svr4_current_sos_direct (info); + + *build_idszp = info->main_build_idsz; + if (*build_idszp == 0) + *build_idp = NULL; + else + *build_idp = xmemdup (info->main_build_id, *build_idszp, *build_idszp); +} + /* Implement the "current_sos" target_so_ops method. */ static struct so_list * @@ -3355,6 +3372,7 @@ _initialize_svr4_solib (void) svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling; svr4_so_ops.current_sos = svr4_current_sos; svr4_so_ops.open_symbol_file_object = open_symbol_file_object; + svr4_so_ops.main_build_id = svr4_main_build_id; svr4_so_ops.in_dynsym_resolve_code = svr4_in_dynsym_resolve_code; svr4_so_ops.bfd_open = solib_bfd_open; svr4_so_ops.lookup_lib_global_symbol = elf_lookup_lib_symbol; diff --git a/gdb/solib.c b/gdb/solib.c index b343df0..6b5e61d 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -470,7 +470,7 @@ solib_find_1 (char *in_pathname, size_t build_idsz, const gdb_byte *build_id, above. */ char * -exec_file_find (char *in_pathname, int *fd) +exec_file_find (char *in_pathname, size_t build_idsz, const gdb_byte *build_id, int *fd) { char *result = solib_find_1 (in_pathname, 0 /* build_idsz */, NULL /* build_id */, fd, 0 /* is_solib */); @@ -1642,6 +1642,20 @@ solib_global_lookup (struct objfile *objfile, return (struct block_symbol) {NULL, NULL}; } +/* See solist.h. */ + +void +solib_main_build_id (size_t *build_idszp, gdb_byte **build_idp) +{ + const struct target_so_ops *ops = ops = solib_ops (target_gdbarch ()); + + if (ops->main_build_id != NULL) + return ops->main_build_id (build_idszp, build_idp); + + *build_idszp = 0; + *build_idp = NULL; +} + /* Lookup the value for a specific symbol from dynamic symbol table. Look up symbol from ABFD. MATCH_SYM is a callback function to determine whether to pick up a symbol. DATA is the input of this callback diff --git a/gdb/solist.h b/gdb/solist.h index e189183..c13aed1 100644 --- a/gdb/solist.h +++ b/gdb/solist.h @@ -135,6 +135,13 @@ struct target_so_ops catch_errors requires a pointer argument. */ int (*open_symbol_file_object) (void *from_ttyp); + /* Report build-id of the main executable. Both BUILD_IDSZP and + BUILD_IDP must not be NULL. If returned *BUILD_IDSZP is zero + build-id is not known. Returned *BUILD_IDP must be xfree-d by + the caller. This pointer can be NULL, in which case this + functionality is not supported for this target. */ + void (*main_build_id) (size_t *build_idszp, gdb_byte **build_idp); + /* Determine if PC lies in the dynamic symbol resolution code of the run time loader. */ int (*in_dynsym_resolve_code) (CORE_ADDR pc); @@ -188,7 +195,7 @@ void free_so (struct so_list *so); struct so_list *master_so_list (void); /* Find main executable binary file. */ -extern char *exec_file_find (char *in_pathname, int *fd); +extern char *exec_file_find (char *in_pathname, size_t build_idsz, const gdb_byte *build_id, int *fd); /* Find shared library binary file. */ extern char *solib_find (char *in_pathname, size_t build_idsz, @@ -209,4 +216,7 @@ struct block_symbol solib_global_lookup (struct objfile *objfile, const char *name, const domain_enum domain); +/* See target_so_ops's main_build_id. */ +void solib_main_build_id (size_t *build_idszp, gdb_byte **build_idp); + #endif diff --git a/gdb/source.c b/gdb/source.c index 2b3650d..a7e2561 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -955,7 +955,7 @@ filename_to_bfd (const char *filename) } int -openp (const char *path, enum openp_flags opts, const char *string, 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; @@ -1180,12 +1180,12 @@ openp_file (const char *path, enum openp_flags opts, const char *string, size_t Else, this functions returns 0, and FULL_PATHNAME is set to NULL. */ int -source_full_path_of (const char *filename, char **full_pathname) +source_full_path_of (const char *filename, size_t build_idsz, const gdb_byte *build_id, char **full_pathname) { int fd; fd = openp (source_path, OPF_TRY_CWD_FIRST | OPF_SEARCH_IN_PATH, - filename, full_pathname); + filename, build_idsz, build_id, full_pathname); if (fd < 0) { *full_pathname = NULL; @@ -1360,7 +1360,7 @@ find_and_open_source (const char *filename, } gdb_assert (OPEN_MODE == (O_RDONLY | O_BINARY)); - result = openp (path, OPF_SEARCH_IN_PATH, filename, fullname); + result = openp (path, OPF_SEARCH_IN_PATH, filename, 0 /* build_idsz */, NULL /* build_id */, fullname); if (result < 0) { /* Didn't work. Try using just the basename. */ @@ -1368,7 +1368,7 @@ find_and_open_source (const char *filename, if (p != filename) { gdb_assert (OPEN_MODE == (O_RDONLY | O_BINARY)); - result = openp (path, OPF_SEARCH_IN_PATH, p, fullname); + result = openp (path, OPF_SEARCH_IN_PATH, p, 0 /* build_idsz */, NULL /* build_id */, fullname); } } diff --git a/gdb/testsuite/gdb.base/attach.exp b/gdb/testsuite/gdb.base/attach.exp index bf0d84e..a879e33 100644 --- a/gdb/testsuite/gdb.base/attach.exp +++ b/gdb/testsuite/gdb.base/attach.exp @@ -67,7 +67,7 @@ proc do_attach_tests {} { global timeout # Figure out a regular expression that will match the sysroot, - # noting that the default sysroot is "target:", and also noting + # noting that the default sysroot is ":target:", and also noting # that GDB will strip "target:" from the start of filenames when # operating on the local filesystem set sysroot "" @@ -77,7 +77,10 @@ proc do_attach_tests {} { set sysroot $expect_out(1,string) } } - regsub "^target:" "$sysroot" "(target:)?" sysroot + # Use only the first element of $sysroot which will hopefully + # successfully match the filename. + regsub "^target:(\[^:\]*):.*$" "$sysroot" "" sysroot + regsub "^(?!target:)(\[^:\]*):.*$" "$sysroot" "" sysroot # Start the program running and then wait for a bit, to be sure # that it can be attached to. diff --git a/gdb/testsuite/gdb.base/main-mismatch-mod.c b/gdb/testsuite/gdb.base/main-mismatch-mod.c new file mode 100644 index 0000000..83d0710 --- /dev/null +++ b/gdb/testsuite/gdb.base/main-mismatch-mod.c @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <unistd.h> + +int _bar = 21; + +int +bar (void) +{ + return 42 - _bar; +} + +int +foo (void) +{ + return 24 + bar(); +} + +int +main (void) +{ + sleep (60); + return 0; +} diff --git a/gdb/testsuite/gdb.base/main-mismatch.c b/gdb/testsuite/gdb.base/main-mismatch.c new file mode 100644 index 0000000..8ea17dc --- /dev/null +++ b/gdb/testsuite/gdb.base/main-mismatch.c @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2015 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <unistd.h> + +int _bar = 42; + +int +bar (void) +{ + return _bar + 21; +} + +int +foo (void) +{ + return _bar; +} + +int +main (void) +{ + sleep (60); + return 0; +} diff --git a/gdb/testsuite/gdb.base/main-mismatch.exp b/gdb/testsuite/gdb.base/main-mismatch.exp new file mode 100644 index 0000000..3a5e18d --- /dev/null +++ b/gdb/testsuite/gdb.base/main-mismatch.exp @@ -0,0 +1,178 @@ +# Copyright 2015 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +standard_testfile + +if ![is_remote target] { + untested "only gdbserver supports build-id reporting" +#FIXME: +### return -1 +} +if [is_remote host] { + untested "only local host is currently supported" + return -1 +} + +# Test overview: +# generate two executable. One that will be used by the process +# and another, modified, that will be found by gdb. Gdb should +# detect the mismatch and refuse to use mismatched executable. + +if { [get_compiler_info] } { + untested "get_compiler_info failed." + return -1 +} + +# First version of the object, to be loaded by ld. +set srcmainfilerun ${testfile}.c + +# Modified version of the object to be loaded by gdb +# Code in -libmod.c is tuned so it gives a mismatch but +# leaves .dynamic at the same point. +set srcmainfilegdb ${testfile}-mod.c + +# So file name: +set binmainfilebase {testfile} + +# Setup run directory (where program is run from) +# It contains the right executable. +set binmainfiledirrun [standard_output_file ${testfile}_wd] +set binmainfilerun ${binmainfiledirrun}/${binmainfilebase} + +# Second executable version is in current directory, '-mod' version. +set binmainfiledirgdb [standard_output_file ""] +set binmainfilegdb ${binmainfiledirgdb}/${binmainfilebase} + +file delete -force -- "${binmainfiledirrun}" +file mkdir "${binmainfiledirrun}" + +set exec_opts {} +lappend exec_opts "additional_flags=-DDIRNAME\=\"${binmainfiledirrun}\"" +lappend exec_opts "debug" +lappend exec_opts "ldflags=-Wl,--build-id" + +if { [build_executable $testfile.exp $binmainfilerun $srcmainfilerun $exec_opts] != 0 } { + return -1 +} +if { [build_executable $testfile.exp $binmainfilegdb $srcmainfilegdb $exec_opts] != 0 } { + return -1 +} + +proc main_matching_test { symsloaded } { + global gdb_prompt + global binmainfilerun + + clean_restart + + set test_spawn_id [spawn_wait_for_attach $binmainfilerun] + set testpid [spawn_id_get_pid $test_spawn_id] + + set test "attach" + gdb_test_multiple "attach $testpid" "$test" { + -re "Attaching to program.*\r\n$gdb_prompt $" { + pass "$test" + } + } + + if { $symsloaded } { + gdb_test "bt" " in main \[^\r\n\]*" + } else { + set test "bt" + gdb_test_multiple $test $test { + -re " in main \[^\r\n\]*\r\n$gdb_prompt $" { + fail $test + } + -re "\r\n$gdb_prompt $" { + pass $test + } + } + } + + kill_wait_spawned_process $test_spawn_id + + return 0 +} + +proc main_locate_test { solibfile symsloaded } { + global binmainfiledirrun + global binmainfilerun + global nocrlf + global expected_header + + gdb_test_no_output "set debug-file-directory ${binmainfiledirrun}" "" + gdb_test_no_output "nosharedlibrary" "" + gdb_test "sharedlibrary" "" "" + + set expected_line "${symsloaded}${nocrlf}${solibfile}" + + gdb_test "info sharedlibrary ${solibfile}" \ + "${expected_header}\r\n.*${expected_line}.*" \ + "Symbols for ${solibfile} loaded: expected '${symsloaded}'" +} + +# Copy binary to working dir so it pulls in the library from that dir +# (by the virtue of $ORIGIN). +file copy -force "${binmainfiledirgdb}/${binmainfilebase}" \ + "${binmainfiledirrun}/${binmainfilebase}" + +# Test unstripped, .dynamic matching +with_test_prefix "test unstripped, .dynamic matching" { + main_matching_test 0 +} + +# Keep original so for debugging purposes +file copy -force "${binmainfilegdb}" "${binmainfilegdb}-orig" +set objcopy_program [transform objcopy] +set result [catch "exec $objcopy_program --only-keep-debug ${binmainfilegdb}"] hooks/post-receive -- Repository for Project Archer.
The branch, jankratochvil/gdbserverbuildid has been updated discards aa180b0c7f35cb8f20ffec5d74e9c63a88b422a0 (commit) discards 37b4f6ecd060252c96287ecc5e6c17476065b37d (commit) discards 37b7a7dc41042cd194d42e4b51ec62a76b67909f (commit) discards e70bc7d408e34e531db1a3374fc4d8ba3966727f (commit) discards b10b37757831c1d24112dae16c956a5aced002c8 (commit) discards 4db67c2978ebc2bab19838a0a4dc938595541856 (commit) discards 1fbb639307854a32484a4c24440214cd095b1dd3 (commit) discards c5420b36ebe6cee180207253abb8c5807828f51c (commit) discards f2291abd5dd1bf7eb65d304cd59da2ef00c4820f (commit) discards 0e45553a30b2b8b8adeb0a00a0eed1ab0f37eabf (commit) discards 3a8a0b30b2dccbed430eb6c38da165a9fde1feef (commit) discards cfe1119c0322114641aee215f9e5f5293b723e82 (commit) discards ab4afa2535c0182dc528a1e867c3f57b5d8292c4 (commit) discards ff4f9d48102ed472ca527b52640fabc5f750c2cc (commit) discards 3754f48adfbdb91c9005e8945f910772c76e1c26 (commit) discards 15ee2159ec7f57bd4daa3e404baa41cee9f76637 (commit) discards 14cc6806a7ea29ab4b66d7353952d4a05d86ed89 (commit) discards 4ad6a791530bc04da99b523d6e7510b195d2543f (commit) discards 0f7e18c01c27f2b1ad53c6f8882db8752405ebb9 (commit) discards 46a81d5758e65c73e7e4eaf5257c6ff341c068a3 (commit) discards 51a6ed4c87273fe52e81b7947dd4ee3c878d3870 (commit) discards 116a250b31b5665873c7c58da676528520565f40 (commit) discards 6ae7a094e89cdcb07d56586f8c3b9986f0bce700 (commit) discards 5ca7075e738daca657d39426377c29632e832b07 (commit) discards 7038751dcc9c65cf412ff977869d614d233d7aa0 (commit) discards af7cb14bcbbcaabbc8e0edb9dbe99e2ca4d56af3 (commit) discards e67b73dbb7068902c37ef2e08caf3e0f70421832 (commit) discards 73ed2df5ca2a88300086c72adf5cf88961c3e0dd (commit) discards e9100478ca7b48f167372bc4c0578df868cc5302 (commit) discards d68335080a1989970d4a5dfcd16d32954f7b520d (commit) via a4faa57625e8354219ccc5c0c22ed64d30990a9c (commit) via e409aea34676677025d83d1b0ca5153b1ddc1b00 (commit) via ef91dfde292089e454f63342bf4cc6b5fc51b048 (commit) via b65862108ecb81b2f5bdd4b7325ca7cea8fba2da (commit) via c042c3a5c6209625cad0a2671d4a146b6f942e32 (commit) via 3d1add591c515f8f5bdbc0e9cf0d60d0ca4e0810 (commit) via e7b2efaeddb23cb53b3fb0e60a58f14d5bd547da (commit) via 463b80107127bbceee4b146197d576a315594869 (commit) via 3ec45cbb78911212f77a261f7e62d49144b1d7ac (commit) via 249f0191c52a135cbfc7721d0cdc8f783a965603 (commit) via 944f86c952083e8f022921226a18ff34d7f08f1a (commit) via 233fa00f011d0b2dedaa6680431f454f15d74741 (commit) via d0bd1ea6bc0dd7b4b0cd6c8a140066b08b019141 (commit) via d8d61243c6a097dddf7b7224c4fe488dbe0b41a5 (commit) via f1661fce9fefd5e3190a75520fbb7f22a0b104dc (commit) via d2b3d4db62cb5466a997ad9a278e5e8884c64838 (commit) via 2020b631c3e55c8bff0162e6403748af93021451 (commit) via 8b8251d655e27031fe477776f346a3f4ab2ba4ab (commit) via 740940f25b9788f8e96881cc53dde8566c9861bf (commit) via 689d3b1eab59efe92fc7fef265df74cdec16ea41 (commit) via cee275608439f3e18a6b35132dca4a520b86b635 (commit) via 174fa76532b7de4ab71abb8265caacc3f494fb1d (commit) via 765f034443db1384d1896ae154817187a281bec9 (commit) via f445c8ebbca61b6be9a9c39d7c6b83803bc788c6 (commit) via aada6c38c98e1d611550d3ea09f79c271336c8f1 (commit) via 6ef1a4beb8acba2f1b796cb76878a02830b01dba (commit) via 95d808aa74c22213702c684daec079a23c50431a (commit) via 148c1b780165bb005eb0589b759d94c3298b489a (commit) via 199878b64f2627b21199d5f934405e7fb3c70d57 (commit) via 0901913cf7b0dad6ddf01241b20af881eb7a43f2 (commit) from aa180b0c7f35cb8f20ffec5d74e9c63a88b422a0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit a4faa57625e8354219ccc5c0c22ed64d30990a9c Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 mainbuildid commit e409aea34676677025d83d1b0ca5153b1ddc1b00 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 ef91dfde292089e454f63342bf4cc6b5fc51b048 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 hexallocate commit b65862108ecb81b2f5bdd4b7325ca7cea8fba2da Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 locatetest commit c042c3a5c6209625cad0a2671d4a146b6f942e32 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 3d1add591c515f8f5bdbc0e9cf0d60d0ca4e0810 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidwarn commit e7b2efaeddb23cb53b3fb0e60a58f14d5bd547da Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibbfdopen commit 463b80107127bbceee4b146197d576a315594869 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidverify commit 3ec45cbb78911212f77a261f7e62d49144b1d7ac Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibsearch commit 249f0191c52a135cbfc7721d0cdc8f783a965603 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidtofile commit 944f86c952083e8f022921226a18ff34d7f08f1a Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidproto commit 233fa00f011d0b2dedaa6680431f454f15d74741 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidtobfd commit d0bd1ea6bc0dd7b4b0cd6c8a140066b08b019141 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidforcemove commit d8d61243c6a097dddf7b7224c4fe488dbe0b41a5 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidfreefix commit f1661fce9fefd5e3190a75520fbb7f22a0b104dc Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsymfile commit d2b3d4db62cb5466a997ad9a278e5e8884c64838 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsolib commit 2020b631c3e55c8bff0162e6403748af93021451 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openp commit 8b8251d655e27031fe477776f346a3f4ab2ba4ab Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 filelib commit 740940f25b9788f8e96881cc53dde8566c9861bf Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtargetdoclose commit 689d3b1eab59efe92fc7fef265df74cdec16ea41 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtargetfd commit cee275608439f3e18a6b35132dca4a520b86b635 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:15 2015 +0200 openfromtarget commit 174fa76532b7de4ab71abb8265caacc3f494fb1d Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openpnullpathname commit 765f034443db1384d1896ae154817187a281bec9 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openpmode commit f445c8ebbca61b6be9a9c39d7c6b83803bc788c6 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:14 2015 +0200 openppath commit aada6c38c98e1d611550d3ea09f79c271336c8f1 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:13 2015 +0200 openpenum commit 6ef1a4beb8acba2f1b796cb76878a02830b01dba Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:13 2015 +0200 sysrootdefault commit 95d808aa74c22213702c684daec079a23c50431a Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:13 2015 +0200 sysrootdelim commit 148c1b780165bb005eb0589b759d94c3298b489a Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:12 2015 +0200 sysrootconst commit 199878b64f2627b21199d5f934405e7fb3c70d57 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Sat Aug 15 11:38:53 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 0901913cf7b0dad6ddf01241b20af881eb7a43f2 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Sat Aug 15 11:38:52 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. ----------------------------------------------------------------------- Summary of changes: gdb/build-id.c | 8 ++++- gdb/build-id.h | 4 +- gdb/dwarf2read.c | 2 +- gdb/exec.c | 18 ++++++--- gdb/gdbserver/linux-low.c | 7 +++- gdb/solib-svr4.c | 11 +++--- gdb/source.c | 2 +- gdb/testsuite/gdb.base/main-mismatch.exp | 55 ++++++++++++++---------------- 8 files changed, 60 insertions(+), 47 deletions(-) First 500 lines of diff: diff --git a/gdb/build-id.c b/gdb/build-id.c index 1db4099..59c0265 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -62,7 +62,7 @@ build_id_bfd_get (bfd *abfd) /* See build-id.h. */ int -build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) +build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check, int advice) { const struct bfd_build_id *found = build_id_bfd_get (abfd); char *message, *check_hex = alloca (check_len * 2 + 1); @@ -88,6 +88,12 @@ build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check) return 1; back_to = make_cleanup (xfree, message); + if (!advice) + { + warning ("%s", message); + do_cleanups (back_to); + return !validate_build_id; + } if (validate_build_id) { warning (_("Symbol file \"%s\" could not be validated (%s) and " diff --git a/gdb/build-id.h b/gdb/build-id.h index 0924f72..1280824 100644 --- a/gdb/build-id.h +++ b/gdb/build-id.h @@ -27,8 +27,8 @@ extern const struct bfd_build_id *build_id_bfd_get (bfd *abfd); /* Return true if ABFD has NT_GNU_BUILD_ID matching the CHECK value. Otherwise, issue a warning and return false. */ -extern int build_id_verify (bfd *abfd, - size_t check_len, const bfd_byte *check); +extern int build_id_verify (bfd *abfd, size_t check_len, const bfd_byte *check, + int advice); extern struct file_location build_id_to_file (size_t build_id_len, const bfd_byte *build_id, const char *suffix, enum openp_flags opts); diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b2463da..bf1b51c 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2495,7 +2495,7 @@ dwarf2_get_dwz_file (void) dwz_bfd = gdb_bfd_open (filename, gnutarget, -1); if (dwz_bfd != NULL) { - if (!build_id_verify (dwz_bfd, buildid_len, buildid)) + if (!build_id_verify (dwz_bfd, buildid_len, buildid, 1 /* advice */)) { gdb_bfd_unref (dwz_bfd); dwz_bfd = NULL; diff --git a/gdb/exec.c b/gdb/exec.c index aeec5c2..e735be5 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -35,6 +35,7 @@ #include "progspace.h" #include "gdb_bfd.h" #include "gcore.h" +#include "build-id.h" #include <fcntl.h> #include "readline/readline.h" @@ -143,21 +144,21 @@ exec_file_and_symbols_resync (struct inferior *inf, int from_tty) { char *exec_file, *full_exec_path = NULL; struct cleanup *old_chain = save_current_program_space (); + size_t build_idsz; + gdb_byte *build_id; + /* Switch over temporarily, while reading executable and symbols. */ set_current_program_space (inf->pspace); + solib_main_build_id (&build_idsz, &build_id); + make_cleanup (xfree, build_id); + /* Try to determine a filename from the process itself. */ exec_file = target_pid_to_exec_file (inf->pid); if (exec_file != NULL) { - size_t build_idsz; - gdb_byte *build_id; - - solib_main_build_id (&build_idsz, &build_id); - make_cleanup (xfree, build_id); - /* If gdb_sysroot is not empty and the discovered filename is absolute then prefix the filename with gdb_sysroot. */ if (*gdb_sysroot != '\0' && IS_ABSOLUTE_PATH (exec_file)) @@ -183,6 +184,8 @@ exec_file_and_symbols_resync (struct inferior *inf, int from_tty) warning (_("Detected exec-file mismatch on %s. Running %s; Loaded %s"), target_pid_to_str (pid_to_ptid (inf->pid)), full_exec_path, exec_filename); + if (build_idsz != 0) + build_id_verify (exec_bfd, build_idsz, build_id, 0 /* advice */); reopen_exec_file (); } else if (full_exec_path != NULL) @@ -197,6 +200,9 @@ exec_file_and_symbols_resync (struct inferior *inf, int from_tty) warning (_("Detected symbol-file mismatch on %s. Running %s; Loaded %s"), target_pid_to_str (pid_to_ptid (inf->pid)), full_exec_path, symbol_filename); + + if (build_idsz != 0) + build_id_verify (symfile_objfile->obfd, build_idsz, build_id, 0 /* advice */); } else if (full_exec_path != NULL) symbol_file_add_main (0, full_exec_path, from_tty); diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 2bd7b02..76a1430 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6773,8 +6773,11 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, struct find_memory_region_callback_data data; /* COREFILTER_ANON_PRIVATE and COREFILTER_ANON_SHARED do not have an - associated file so it is not expected it could have an ELF header. */ - const enum filterflags filterflags = (COREFILTER_MAPPED_PRIVATE + associated file but they may represent a " (deleted)" file with + valid ELF header. */ + const enum filterflags filterflags = (COREFILTER_ANON_PRIVATE + | COREFILTER_ANON_SHARED + | COREFILTER_MAPPED_PRIVATE | COREFILTER_MAPPED_SHARED | COREFILTER_ELF_HEADERS | COREFILTER_HUGETLB_PRIVATE diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 196c96a..c6e9f04 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1246,9 +1246,10 @@ 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; + const struct gdb_xml_value *const att_main_build_id + = xml_find_attribute (attributes, "main-build-id"); + const char *const main_hex_build_id = (att_main_build_id + ? att_main_build_id->value : NULL); if (strcmp (version, "1.0") != 0) gdb_xml_error (parser, @@ -1257,8 +1258,8 @@ 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, - _("main executable")); + hex2bin_allocate (main_hex_build_id, &list->main_build_id, + &list->main_build_idsz, _("main executable")); } /* The allowed elements and attributes for an XML library list. diff --git a/gdb/source.c b/gdb/source.c index a7e2561..8490d8b 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -899,7 +899,7 @@ file_location_from_filename (const char *filename, enum openp_flags opts, size_t return file; } - if (!build_id_verify (file.abfd, build_idsz, build_id)) + if (!build_id_verify (file.abfd, build_idsz, build_id, 1 /* advice */)) { do_cleanups (back_to); file_location_enoent (&file); diff --git a/gdb/testsuite/gdb.base/main-mismatch.exp b/gdb/testsuite/gdb.base/main-mismatch.exp index 3a5e18d..84129e2 100644 --- a/gdb/testsuite/gdb.base/main-mismatch.exp +++ b/gdb/testsuite/gdb.base/main-mismatch.exp @@ -70,40 +70,37 @@ if { [build_executable $testfile.exp $binmainfilegdb $srcmainfilegdb $exec_opts] return -1 } -proc main_matching_test { symsloaded } { - global gdb_prompt - global binmainfilerun +set test_spawn_id [spawn_wait_for_attach $binmainfilerun] +set testpid [spawn_id_get_pid $test_spawn_id] - clean_restart +file copy -force $binmainfilegdb $binmainfilerun - set test_spawn_id [spawn_wait_for_attach $binmainfilerun] - set testpid [spawn_id_get_pid $test_spawn_id] +clean_restart $binmainfilerun - set test "attach" - gdb_test_multiple "attach $testpid" "$test" { - -re "Attaching to program.*\r\n$gdb_prompt $" { - pass "$test" - } +#gdb_test "set debug remote 1" + +set test "attach" +gdb_test_multiple "attach $testpid" "$test" { + -re "Attaching to process $testpid\r\n.*\r\n$gdb_prompt $" { + pass "$test" } +} - if { $symsloaded } { - gdb_test "bt" " in main \[^\r\n\]*" - } else { - set test "bt" - gdb_test_multiple $test $test { - -re " in main \[^\r\n\]*\r\n$gdb_prompt $" { - fail $test - } - -re "\r\n$gdb_prompt $" { - pass $test - } - } +set test "bt" +gdb_test_multiple $test $test { + -re " in main \[^\r\n\]*\r\n$gdb_prompt $" { + fail $test + } + -re "\r\n$gdb_prompt $" { + pass $test } +} - kill_wait_spawned_process $test_spawn_id +kill_wait_spawned_process $test_spawn_id - return 0 -} +return + +# gdb_test "bt" " in main \[^\r\n\]*" proc main_locate_test { solibfile symsloaded } { global binmainfiledirrun @@ -129,7 +126,7 @@ file copy -force "${binmainfiledirgdb}/${binmainfilebase}" \ # Test unstripped, .dynamic matching with_test_prefix "test unstripped, .dynamic matching" { - main_matching_test 0 +# main_matching_test 0 } # Keep original so for debugging purposes @@ -142,7 +139,7 @@ if {$result != 0} { # Test --only-keep-debug, .dynamic matching so with_test_prefix "test --only-keep-debug" { - main_matching_test 0 +# main_matching_test 0 } # Test locating file by its build-id - if the regular filename does not match. @@ -174,5 +171,5 @@ file copy -force "${binmainfilerun}" "${binmainfilegdb}" # Now test it does not mis-invalidate matching libraries with_test_prefix "test matching libraries" { - main_matching_test 1 +# main_matching_test 1 } hooks/post-receive -- Repository for Project Archer.
The branch, jankratochvil/gdbserverbuildid has been updated discards a4faa57625e8354219ccc5c0c22ed64d30990a9c (commit) discards e409aea34676677025d83d1b0ca5153b1ddc1b00 (commit) discards ef91dfde292089e454f63342bf4cc6b5fc51b048 (commit) discards b65862108ecb81b2f5bdd4b7325ca7cea8fba2da (commit) discards c042c3a5c6209625cad0a2671d4a146b6f942e32 (commit) discards 3d1add591c515f8f5bdbc0e9cf0d60d0ca4e0810 (commit) discards e7b2efaeddb23cb53b3fb0e60a58f14d5bd547da (commit) discards 463b80107127bbceee4b146197d576a315594869 (commit) discards 3ec45cbb78911212f77a261f7e62d49144b1d7ac (commit) discards 249f0191c52a135cbfc7721d0cdc8f783a965603 (commit) discards 944f86c952083e8f022921226a18ff34d7f08f1a (commit) discards 233fa00f011d0b2dedaa6680431f454f15d74741 (commit) discards d0bd1ea6bc0dd7b4b0cd6c8a140066b08b019141 (commit) discards d8d61243c6a097dddf7b7224c4fe488dbe0b41a5 (commit) discards f1661fce9fefd5e3190a75520fbb7f22a0b104dc (commit) discards d2b3d4db62cb5466a997ad9a278e5e8884c64838 (commit) discards 2020b631c3e55c8bff0162e6403748af93021451 (commit) discards 8b8251d655e27031fe477776f346a3f4ab2ba4ab (commit) discards 740940f25b9788f8e96881cc53dde8566c9861bf (commit) discards 689d3b1eab59efe92fc7fef265df74cdec16ea41 (commit) discards cee275608439f3e18a6b35132dca4a520b86b635 (commit) discards 174fa76532b7de4ab71abb8265caacc3f494fb1d (commit) discards 765f034443db1384d1896ae154817187a281bec9 (commit) discards f445c8ebbca61b6be9a9c39d7c6b83803bc788c6 (commit) discards aada6c38c98e1d611550d3ea09f79c271336c8f1 (commit) discards 6ef1a4beb8acba2f1b796cb76878a02830b01dba (commit) discards 95d808aa74c22213702c684daec079a23c50431a (commit) discards 148c1b780165bb005eb0589b759d94c3298b489a (commit) discards 199878b64f2627b21199d5f934405e7fb3c70d57 (commit) discards 0901913cf7b0dad6ddf01241b20af881eb7a43f2 (commit) discards 47498547bc0aa3debec59ad458a18a5612bc9604 (commit) discards 89fa75c615cbd3ebb1e3c804ba7f51d2682d5ca6 (commit) discards 6d7d4da8f7097b4dd84029ed20ca9272622a64f2 (commit) discards cfeca82d7f630591c93f1a47b84742294aa84a57 (commit) via 295a8e9aac03bc1d9e4171d390547dfe36f091b1 (commit) via 62ef4dab59b9919fa01adc1f47b31a87b24d9679 (commit) via 0135e550ce15ed1b3796c16b1a77b09410395681 (commit) via fef4666f6b3f3ffbd9c2e85f2990514772a84895 (commit) via 985601646481aefd6304f398be8b03545c877559 (commit) via 1eb21b54e9572702cb377dd2c401242d03c541f3 (commit) via 749f69903be8e96e0d0362408eb9f5dbb4c681fb (commit) via 170204351e1aff6160e08ca6e3d420cd901ef9c3 (commit) via b74795165b852e4427d14968b77a668262b2b61b (commit) via 3865249c28d15498ad90589719c5ce0e0582de25 (commit) via 40d06717b5315f7770f4e3dd763cf55897578ecf (commit) via ea0ea3b46c08a5922a8cfdbf784d3669a42ad4c9 (commit) via 902f3ad6b7b42c21d891a220be74c783366907de (commit) via c976bc3030cad2ff2b9135c3e63982a9446c04a3 (commit) via de12313d1abfe8467a42df3ea4cea698f2c566b8 (commit) via a4e19f0c9c7087922910fb56d8a709a4a99bc86b (commit) via 4b60037e3600142aa6e3d0dbceccc6432b51694b (commit) via 015dc972aa3cd7c7d71bcb368bf8af110e0efe7b (commit) via 6c4892292153b82202d598a5c75f4d7f333737ac (commit) via 69d58245ab0758763c4c14da6fb09d4ea93754e3 (commit) via 0cb6c2225a22f28f09c821934dc32911ce868034 (commit) via d9cbc96668c5af6ba19f937e80635e7d80d2dccc (commit) via 548608ab3b42c9376055224ccd5ecd6fc7bdc52c (commit) via 7cd5067be92346752ad6dde93a938d596582484a (commit) via fee553fc5696a90209ffc0f1b2a4e3fe0cf7b162 (commit) via 758d882951dd2084b80a7ab0ab249eebd447c87c (commit) via 675af07c3197652f1d6cfe1ae16c299f8e12c44a (commit) via 28bea9dcc9f5d5c3aae0a83a11a7f75d7abc31b3 (commit) via 0b1ba7f7810a813a5ecd883b4d31c87a09a7ecdd (commit) via fdbe940d41ab5212b13c0e2c9de2210290bd0f39 (commit) via 07980d2eb445547f2c40bddbba0593c631f4b4cc (commit) via d24163121891e5c67c2837c266831c5ca99328ee (commit) via fa5a5a47b32c04b28dc134c9443c3d0d13b93f7b (commit) via 6ebf8fd4c922433ab739998eb8696f3b705d3689 (commit) via 4e1626f5a8d73573d6cf593fabe5bc80f7b3e04e (commit) via 26d56a939e9e54e09d46ea6e9678463ac344fa33 (commit) via cae1fbbb7e3d770702a0d7a5027b46835e6adc13 (commit) via 2b4bf6afd4506165007c0e76bc7c4381031cfaf6 (commit) via 44b4145b723b43b175d4378c77bd79faaaa80312 (commit) via 566f5e3b385a99c09b5babc9f90dae93e052d52c (commit) via 18989b3c5642e2ba533e02737797dcf06134229b (commit) via c04fe68f6b94815d3f49c9aed64b2c388d45f4aa (commit) via 0e1862bb401f47716446aef143b2bf7a4563f541 (commit) via b2a33439909493f5bf93ada871bd588f365d61f4 (commit) via fe875424a05df7c4055cd9382ab76f65e952c4dd (commit) via 43417696fe32416607940258ded622c121872515 (commit) via f6721e4955d86bf879b5225f2d128a5a8ddfcae8 (commit) via 71b57e37fe94bbc17f57f8f9ca5e9c5400cedd6b (commit) via 7f3706ebfeb44e6b1f39f95fe44b7099a91c32c9 (commit) via ad89c2aa677c28c76ffd5a35e2b36eece4d82597 (commit) via 2309f875707215e9b6dfbd9af866f6ead3ccaff5 (commit) via 919b75f7e28942fe320dc533759f88131f160bf3 (commit) via 26a4b92c9131ab952f3db9bcafa82fb2360d19b6 (commit) via db2ed2e0b910376fd2bf4c2bc5d626315c4269c6 (commit) via 1762568fd6bd84f1b1a488375cf320a1efa06b22 (commit) via a40f728f5cb20a41cfff68ef523a0025bbc6f402 (commit) via 8763cedeec7f0a1daea41c2231bda165652e273b (commit) via 51cdc99310171d6c53d2d00103a0ce34374d0b9b (commit) via 95cf586902b681310e63ee06d89ba2498d1d5dcf (commit) via e3ae3c4345fa14f2f3b0b2c5d4d23760af9f74f5 (commit) from a4faa57625e8354219ccc5c0c22ed64d30990a9c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 295a8e9aac03bc1d9e4171d390547dfe36f091b1 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 mainbuildid commit 62ef4dab59b9919fa01adc1f47b31a87b24d9679 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 0135e550ce15ed1b3796c16b1a77b09410395681 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 hexallocate commit fef4666f6b3f3ffbd9c2e85f2990514772a84895 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 locatetest commit 985601646481aefd6304f398be8b03545c877559 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 1eb21b54e9572702cb377dd2c401242d03c541f3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidwarn commit 749f69903be8e96e0d0362408eb9f5dbb4c681fb Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibbfdopen commit 170204351e1aff6160e08ca6e3d420cd901ef9c3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidverify commit b74795165b852e4427d14968b77a668262b2b61b Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibsearch commit 3865249c28d15498ad90589719c5ce0e0582de25 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidtofile commit 40d06717b5315f7770f4e3dd763cf55897578ecf Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidproto commit ea0ea3b46c08a5922a8cfdbf784d3669a42ad4c9 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidtobfd commit 902f3ad6b7b42c21d891a220be74c783366907de Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidforcemove commit c976bc3030cad2ff2b9135c3e63982a9446c04a3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidfreefix commit de12313d1abfe8467a42df3ea4cea698f2c566b8 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsymfile commit a4e19f0c9c7087922910fb56d8a709a4a99bc86b Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsolib commit 4b60037e3600142aa6e3d0dbceccc6432b51694b Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 Make openp() to use file_location Hi, openp() remains as a backward compatibility wrapper. Jan commit 015dc972aa3cd7c7d71bcb368bf8af110e0efe7b Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 6c4892292153b82202d598a5c75f4d7f333737ac Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 69d58245ab0758763c4c14da6fb09d4ea93754e3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * gdb_bfd.c (gdb_bfd_iovec_fileio_open_fd): New function. (gdb_bfd_open_from_target): Conditionally use it. commit 0cb6c2225a22f28f09c821934dc32911ce868034 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 d9cbc96668c5af6ba19f937e80635e7d80d2dccc Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * source.c (openp): Update function comment for filename_opened. Remove NULL check for filename_opened. commit 548608ab3b42c9376055224ccd5ecd6fc7bdc52c Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 7cd5067be92346752ad6dde93a938d596582484a Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 fee553fc5696a90209ffc0f1b2a4e3fe0cf7b162 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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. commit 758d882951dd2084b80a7ab0ab249eebd447c87c Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 675af07c3197652f1d6cfe1ae16c299f8e12c44a Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> * gdb.texinfo (Files): Permit set sysroot and show sysroot to have multiple components. commit 28bea9dcc9f5d5c3aae0a83a11a7f75d7abc31b3 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * solib.c (solib_find_1): Make sysroot variable const. commit 0b1ba7f7810a813a5ecd883b4d31c87a09a7ecdd Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 fdbe940d41ab5212b13c0e2c9de2210290bd0f39 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 07980d2eb445547f2c40bddbba0593c631f4b4cc Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 d24163121891e5c67c2837c266831c5ca99328ee Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Tue Aug 18 19:44:26 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 fa5a5a47b32c04b28dc134c9443c3d0d13b93f7b Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Tue Aug 18 19:44:26 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 6ebf8fd4c922433ab739998eb8696f3b705d3689 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Tue Aug 18 19:44:25 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. commit 4e1626f5a8d73573d6cf593fabe5bc80f7b3e04e Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Aug 18 10:43:19 2015 -0700 Add another test for PR ld/18841 PR ld/18841 * ld-ifunc/ifunc.exp: Add another test for PR ld/18841. * ld-ifunc/pr18841c.c: New file. commit 26d56a939e9e54e09d46ea6e9678463ac344fa33 Author: Sandra Loosemore <sandra@codesourcery.com> Date: Tue Aug 18 10:29:54 2015 -0700 Fix mis-parsing of hex register numbers in 'T' stop replies. 2015-08-18 Sandra Loosemore <sandra@codesourcery.com> gdb/ * remote.c (strprefix): New. (remote_parse_stop_reply): Use strprefix instead of strncmp to ensure exact match of keyword. commit cae1fbbb7e3d770702a0d7a5027b46835e6adc13 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Aug 18 09:47:59 2015 -0700 Return reloc_class_ifunc for reloc against IFUNC elf_XXX_reloc_type_class should return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. bfd/ PR ld/18841 * elf-bfd.h (elf_link_hash_table): Add dynsym. * elf32-i386.c (elf_i386_reloc_type_class): Return reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. * elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise. * elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym. (bfd_elf_size_dynsym_hash_dynstr): Use dynsym. (elf_final_link_info): Remove dynsym_sec. (elf_link_output_extsym): Replace dynsym_sec with dynsym. (bfd_elf_final_link): Remove reference to dynsym_sec. Replace dynsym_sec with dynsym. ld/testsuite/ PR ld/18841 * ld-ifunc/ifunc.exp: Add a test for PR ld/18841. * ld-ifunc/pr18841.out: New file. * ld-ifunc/pr18841a.c: Likewise. * ld-ifunc/pr18841b.c: Likewise. commit 2b4bf6afd4506165007c0e76bc7c4381031cfaf6 Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Tue Aug 18 17:09:41 2015 +0100 gdb/doc: Fix build of 'info' manual. In commit 18989b3c5642e2ba533e02737797dcf06134229b I broke the creation of gdb's info manual; I added a new section without adding a suitable menu entry. This commit adds the missing menu entry and fixes the build of gdb's info manual. gdb/doc/ChangeLog: * gdb.texinfo (GDB Files): Add 'File Caching' menu entry. commit 44b4145b723b43b175d4378c77bd79faaaa80312 Author: Jiong Wang <jiong.wang@arm.com> Date: Tue Aug 18 16:50:56 2015 +0100 [AArch64] Cleanup TLS relocation types which don't go through GOT table This patch done two types of cleanup: * in aarch64_reloc_got_type and elfNN_aarch64_relocate_section We don't need those redundant "case" check, as they can be merged with the "default" which just "break". * in elfNN_aarch64_gc_sweep_hook and elfNN_aarch64_check_relocs All TLS local executable relocations and some local dynamic relocations (those calculate module offset) actually don't need GOT entry, so remove them from GOT entry counting. 2015-08-18 Jiong Wang <jiong.wang@arm.com> bfd/ * elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check. (elfNN_aarch64_relocate_section): Likewise. (elfNN_aarch64_gc_sweep_hook): Likewise. (elfNN_aarch64_check_relocs): Likewise. commit 566f5e3b385a99c09b5babc9f90dae93e052d52c Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Mon Apr 13 16:56:23 2015 +0100 gdb: Add debug tracing for bfd cache activity. This patch adds a new debug flag bfd-cache, which when set to non-zero produces debugging log messages relating to gdb's bfd cache. gdb/ChangeLog: * gdb_bfd.c (debug_bfd_cache): New variable. (show_bfd_cache_debug): New function. (gdb_bfd_open): Add debug logging. (gdb_bfd_ref): Likewise. (gdb_bfd_unref): Likewise. (_initialize_gdb_bfd): Add new set/show command. * NEWS: Mention new command. gdb/doc/ChangeLog: * gdb.texinfo (File Caching): Document "set/show debug bfd-cache". commit 18989b3c5642e2ba533e02737797dcf06134229b Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Mon Apr 13 16:31:21 2015 +0100 gdb: New maintenance command to disable bfd sharing. In some rare maintainer cases it is desirable to be able to disable bfd sharing. This patch adds new commands maintenance set/show commands for bfd-sharing, allowing gdb's bfd cache to be turned off. gdb/ChangeLog: * gdb_bfd.c (bfd_sharing): New variable. (show_bfd_sharing): New function. (gdb_bfd_open): Check bfd_sharing variable. (_initialize_gdb_bfd): Add new set/show command. * NEWS: Mention new command. gdb/doc/ChangeLog: * gdb.texinfo (Maintenance Commands): Move documentation of "main info bfds" to... (File Caching): A New section. Outline bfd caching, and add new description for "main set/show bfd-sharing". commit c04fe68f6b94815d3f49c9aed64b2c388d45f4aa Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Mon Apr 13 14:53:48 2015 +0100 gdb: Improve cache matching criteria for the bfd cache. Within gdb open bfd objects are reused where possible if an attempt is made to reopen a file that is already being debugged. To spot if the on disc file has changed gdb currently examines the mtime of the file and compares it to the mtime of the open bfd in the cache. A problem exists when the on disc file is being rapidly regenerated, as happens, for example, with automated testing. In some cases the file is generated so quickly that the mtime appears not to change, while the on disc file has changed. This patch extends the bfd cache to also hold the file size of the file, the inode of the file, and the device id of the file; gdb can then compare filename, file size, mtime, inode, and device id to determine if an existing bfd object can be reused. gdb/ChangeLog: * gdb_bfd.c (struct gdb_bfd_data): Add size, inode, and device id field. (struct gdb_bfd_cache_search): Likewise. (eq_bfd): Compare the size, inode, and device id fields. (gdb_bfd_open): Initialise the size, inode, and device id fields. (gdb_bfd_ref): Likewise. (gdb_bfd_unref): Likewise. commit 0e1862bb401f47716446aef143b2bf7a4563f541 Author: H.J. Lu <hjl.tools@gmail.com> Date: Tue Aug 18 05:51:03 2015 -0700 Add output_type to bfd_link_info The "shared" field in bfd_link_info is set for both DSO and and PIE. There are separate fields for executable and relocatable outputs. This patch adds an "output_type" field: enum output_type { type_unknown = 0, type_executable, type_dll, type_relocatable }; and a "pic" field to bfd_link_info to replace shared, executable and relocatable fields so that we can use the "output_type" field to check for output type and the "pic" field check if output is PIC. Macros, bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie, are provided to check for output features. bfd/ * bfd/aoutx.h: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * bfd/bout.c: Likewise. * bfd/coff-alpha.c: Likewise. * bfd/coff-arm.c: Likewise. * bfd/coff-i386.c: Likewise. * bfd/coff-i960.c: Likewise. * bfd/coff-m68k.c: Likewise. * bfd/coff-mcore.c: Likewise. * bfd/coff-mips.c: Likewise. * bfd/coff-ppc.c: Likewise. * bfd/coff-rs6000.c: Likewise. * bfd/coff-sh.c: Likewise. * bfd/coff-tic80.c: Likewise. * bfd/coff-x86_64.c: Likewise. * bfd/coff64-rs6000.c: Likewise. * bfd/coffgen.c: Likewise. * bfd/cofflink.c: Likewise. * bfd/ecoff.c: Likewise. * bfd/ecofflink.c: Likewise. * bfd/elf-bfd.h: Likewise. * bfd/elf-eh-frame.c: Likewise. * bfd/elf-ifunc.c: Likewise. * bfd/elf-m10200.c: Likewise. * bfd/elf-m10300.c: Likewise. * bfd/elf-s390-common.c: Likewise. * bfd/elf-vxworks.c: Likewise. * bfd/elf.c: Likewise. * bfd/elf32-arm.c: Likewise. * bfd/elf32-avr.c: Likewise. * bfd/elf32-bfin.c: Likewise. * bfd/elf32-cr16.c: Likewise. * bfd/elf32-cr16c.c: Likewise. * bfd/elf32-cris.c: Likewise. * bfd/elf32-crx.c: Likewise. * bfd/elf32-d10v.c: Likewise. * bfd/elf32-dlx.c: Likewise. * bfd/elf32-epiphany.c: Likewise. * bfd/elf32-fr30.c: Likewise. * bfd/elf32-frv.c: Likewise. * bfd/elf32-ft32.c: Likewise. * bfd/elf32-h8300.c: Likewise. * bfd/elf32-hppa.c: Likewise. * bfd/elf32-i370.c: Likewise. * bfd/elf32-i386.c: Likewise. * bfd/elf32-i860.c: Likewise. * bfd/elf32-ip2k.c: Likewise. * bfd/elf32-iq2000.c: Likewise. * bfd/elf32-lm32.c: Likewise. * bfd/elf32-m32c.c: Likewise. * bfd/elf32-m32r.c: Likewise. * bfd/elf32-m68hc11.c: Likewise. * bfd/elf32-m68hc1x.c: Likewise. * bfd/elf32-m68k.c: Likewise. * bfd/elf32-mcore.c: Likewise. * bfd/elf32-mep.c: Likewise. * bfd/elf32-metag.c: Likewise. * bfd/elf32-microblaze.c: Likewise. * bfd/elf32-moxie.c: Likewise. * bfd/elf32-msp430.c: Likewise. * bfd/elf32-mt.c: Likewise. * bfd/elf32-nds32.c: Likewise. * bfd/elf32-nios2.c: Likewise. * bfd/elf32-or1k.c: Likewise. * bfd/elf32-ppc.c: Likewise. * bfd/elf32-rl78.c: Likewise. * bfd/elf32-rx.c: Likewise. * bfd/elf32-s390.c: Likewise. * bfd/elf32-score.c: Likewise. * bfd/elf32-score7.c: Likewise. * bfd/elf32-sh-symbian.c: Likewise. * bfd/elf32-sh.c: Likewise. * bfd/elf32-sh64.c: Likewise. * bfd/elf32-spu.c: Likewise. * bfd/elf32-tic6x.c: Likewise. * bfd/elf32-tilepro.c: Likewise. * bfd/elf32-v850.c: Likewise. * bfd/elf32-vax.c: Likewise. * bfd/elf32-visium.c: Likewise. * bfd/elf32-xc16x.c: Likewise. * bfd/elf32-xstormy16.c: Likewise. * bfd/elf32-xtensa.c: Likewise. * bfd/elf64-alpha.c: Likewise. * bfd/elf64-hppa.c: Likewise. * bfd/elf64-ia64-vms.c: Likewise. * bfd/elf64-mmix.c: Likewise. * bfd/elf64-ppc.c: Likewise. * bfd/elf64-s390.c: Likewise. * bfd/elf64-sh64.c: Likewise. * bfd/elf64-x86-64.c: Likewise. * bfd/elflink.c: Likewise. * bfd/elfnn-aarch64.c: Likewise. * bfd/elfnn-ia64.c: Likewise. * bfd/elfxx-mips.c: Likewise. * bfd/elfxx-sparc.c: Likewise. * bfd/elfxx-tilegx.c: Likewise. * bfd/i386linux.c: Likewise. * bfd/linker.c: Likewise. * bfd/m68klinux.c: Likewise. * bfd/pdp11.c: Likewise. * bfd/pe-mips.c: Likewise. * bfd/peXXigen.c: Likewise. * bfd/reloc.c: Likewise. * bfd/reloc16.c: Likewise. * bfd/sparclinux.c: Likewise. * bfd/sunos.c: Likewise. * bfd/vms-alpha.c: Likewise. * bfd/xcofflink.c: Likewise. include/ * include/bfdlink.h (output_type): New enum. (bfd_link_executable): New macro. (bfd_link_dll): Likewise. (bfd_link_relocatable): Likewise. (bfd_link_pic): Likewise. (bfd_link_pie): Likewise. (bfd_link_info): Remove shared, executable, pie and relocatable. Add output_type and pic. ld/ * ld/ldctor.c: Replace shared, executable, relocatable and pie fields with bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic and bfd_link_pie. * ld/ldemul.c: Likewise. * ld/ldfile.c: Likewise. * ld/ldlang.c: Likewise. * ld/ldmain.c: Likewise. * ld/ldwrite.c: Likewise. * ld/lexsup.c: Likewise. * ld/pe-dll.c: Likewise. * ld/plugin.c: Likewise. * ld/emultempl/aarch64elf.em: Likewise. * ld/emultempl/aix.em: Likewise. * ld/emultempl/alphaelf.em: Likewise. * ld/emultempl/armcoff.em: Likewise. * ld/emultempl/armelf.em: Likewise. * ld/emultempl/avrelf.em: Likewise. * ld/emultempl/beos.em: Likewise. * ld/emultempl/cr16elf.em: Likewise. * ld/emultempl/elf-generic.em: Likewise. * ld/emultempl/elf32.em: Likewise. * ld/emultempl/genelf.em: Likewise. * ld/emultempl/generic.em: Likewise. * ld/emultempl/gld960.em: Likewise. * ld/emultempl/gld960c.em: Likewise. * ld/emultempl/hppaelf.em: Likewise. * ld/emultempl/irix.em: Likewise. * ld/emultempl/linux.em: Likewise. * ld/emultempl/lnk960.em: Likewise. * ld/emultempl/m68hc1xelf.em: Likewise. * ld/emultempl/m68kcoff.em: Likewise. * ld/emultempl/m68kelf.em: Likewise. * ld/emultempl/metagelf.em: Likewise. * ld/emultempl/mipself.em: Likewise. * ld/emultempl/mmo.em: Likewise. * ld/emultempl/msp430.em: Likewise. * ld/emultempl/nds32elf.em: Likewise. * ld/emultempl/needrelax.em: Likewise. * ld/emultempl/nios2elf.em: Likewise. * ld/emultempl/pe.em: Likewise. * ld/emultempl/pep.em: Likewise. * ld/emultempl/ppc32elf.em: Likewise. * ld/emultempl/ppc64elf.em: Likewise. * ld/emultempl/sh64elf.em: Likewise. * ld/emultempl/solaris2.em: Likewise. * ld/emultempl/spuelf.em: Likewise. * ld/emultempl/sunos.em: Likewise. * ld/emultempl/tic6xdsbt.em: Likewise. * ld/emultempl/ticoff.em: Likewise. * ld/emultempl/v850elf.em: Likewise. * ld/emultempl/vms.em: Likewise. * ld/emultempl/vxworks.em: Likewise. commit b2a33439909493f5bf93ada871bd588f365d61f4 Author: Pedro Alves <palves@redhat.com> Date: Tue Aug 18 11:04:30 2015 +0100 x86/Linux: disable all-stop on top of non-stop Markus reported that ASNS breaks target record-btrace. In particular, the gdb.btrace/multi-thread-step.exp test fails (both with BTS and PT tracing) with a crash in py-inferior.c: Program received signal SIGSEGV, Segmentation fault. 0x00000000006aa40d in add_thread_object (tp=0x27d32d0) at /users/mmetzger/team/gdb/git/gdb/python/py-inferior.c:337 337 entry->next = inf_obj->threads; My machine doesn't support BTS nor PT, so I missed this... Disabling ASNS temporarily on x86 until this is addressed. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-08-18 Pedro Alves <palves@redhat.com> * linux-nat.c (linux_nat_always_non_stop_p): If the linux_ops target implements to_always_non_stop_p, call it. * x86-linux-nat.c (x86_linux_always_non_stop_p): New function. (x86_linux_create_target): Install it as to_always_non_stop_p method. commit fe875424a05df7c4055cd9382ab76f65e952c4dd Author: Alan Modra <amodra@gmail.com> Date: Tue Aug 18 16:44:48 2015 +0930 Use $SED in bfd Makefile PR 18667 * Makefile.am: Use $(SED) in place of sed throughout. * Makefile.in: Regenerate. commit 43417696fe32416607940258ded622c121872515 Author: Alan Modra <amodra@gmail.com> Date: Tue Aug 18 16:43:18 2015 +0930 PPC64: Allow .TOC. in linker script to override backend calculated value bfd/ * elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC. if already defined, and set linker_def. (ppc64_elf_set_toc): Use .TOC. value if defined other than by the backend. ld/ * ldexp.c (exp_fold_tree_1): Clear linker_def on symbol assignment. commit f6721e4955d86bf879b5225f2d128a5a8ddfcae8 Author: GDB Administrator <gdbadmin@sourceware.org> Date: Tue Aug 18 00:00:08 2015 +0000 Automatic date update in version.in commit 71b57e37fe94bbc17f57f8f9ca5e9c5400cedd6b Author: Doug Evans <dje@google.com> Date: Mon Aug 17 13:07:11 2015 -0700 ui-out.c (default_ui_out_impl): Add comment. gdb/ChangeLog: * ui-out.c (default_ui_out_impl): Add comment. commit 7f3706ebfeb44e6b1f39f95fe44b7099a91c32c9 Author: Iain Buclaw <ibuclaw@gdcproject.org> Date: Mon Aug 17 21:45:42 2015 +0200 [D] Implement looking up members of D enums. In D, all named enums are explicitly scoped (the C++ equivalent of enum class) so they should be handled as such in the language-specific symbol lookup routines. However so as to support D compilers that don't emit enums as DW_AT_enum_class, need to make sure that appropriate checks for TYPE_DECLARED_CLASS are done. gdb/ChangeLog * d-exp.y (type_aggregate_p): New function. (PrimaryExpression : TypeExp '.' IdentifierExp): Use it. (classify_inner_name): Likewise. * d-namespace.c (d_lookup_nested_symbol): Handle TYPE_CODE_ENUM. commit ad89c2aa677c28c76ffd5a35e2b36eece4d82597 Author: Keith Seitz <keiths@redhat.com> Date: Thu Aug 13 11:56:50 2015 -0700 Move strace -m/explicit location test to strace.exp One of the build slaves shows this error running explicit.exp: (gdb) strace -m gdbfoobarbaz Remote failure reply: E.In-process agent library not loaded in process. Fast and static tracepoints unavailable. (gdb) FAIL: gdb.linespec/explicit.exp: strace -m gdbfoobarbaz There are two big problems with this test: 1) The expected output is actually not what the test is meant to test for. 2) This test should really only run where it is supported. This is most easily fixed by moving the test to gdb.trace/strace.exp. gdb/testsuite/ChangeLog * gdb.linespec/explicit.exp: Move strace test from here ... * gdb.trace/strace.exp: ... to here. commit 2309f875707215e9b6dfbd9af866f6ead3ccaff5 Author: Alan Modra <amodra@gmail.com> Date: Mon Aug 17 12:01:58 2015 +0930 Regen binutils/configure Looks like previous regen wasn't using current sources. * configure: Regenerate. commit 919b75f7e28942fe320dc533759f88131f160bf3 Author: Alan Modra <amodra@gmail.com> Date: Mon Aug 17 11:51:44 2015 +0930 Trailing space in opcodes/ generated files HJ recently removed trailing space in binutils files, but unfortunately they return when regenerating files in opcodes. This fixes the regen process. * cgen.sh: Trim trailing space from cgen output. * ia64-gen.c (print_dependency_table): Don't generate trailing space. (print_dis_table): Likewise. * opc2c.c (dump_lines): Likewise. (orig_filename): Warning fix. * ia64-asmtab.c: Regenerate. commit 26a4b92c9131ab952f3db9bcafa82fb2360d19b6 Author: GDB Administrator <gdbadmin@sourceware.org> Date: Mon Aug 17 00:00:08 2015 +0000 Automatic date update in version.in commit db2ed2e0b910376fd2bf4c2bc5d626315c4269c6 Author: Alan Modra <amodra@gmail.com> Date: Mon Aug 17 09:05:42 2015 +0930 Rationalize ARM .align * gas/config/tc-arm.c (s_align): Delete. (md_pseudo_table): Use s_align_ptwo for "align". * gas/config/tc-arm.h (TC_ALIGN_ZERO_IS_DEFAULT): Define. * read.c (s_align): Modify for TC_ALIGN_ZERO_IS_DEFAULT. commit 1762568fd6bd84f1b1a488375cf320a1efa06b22 Author: Doug Evans <xdje42@gmail.com> Date: Sat Aug 15 22:08:47 2015 -0700 psymtab.c (add_psymbol_to_bcache): Remove "val" arg. gdb/ChangeLog: * psymtab.c (add_psymbol_to_bcache): Remove "val" arg. All callers updated. (add_psymbol_to_list): Ditto. commit a40f728f5cb20a41cfff68ef523a0025bbc6f402 Author: GDB Administrator <gdbadmin@sourceware.org> Date: Sun Aug 16 00:00:08 2015 +0000 Automatic date update in version.in commit 8763cedeec7f0a1daea41c2231bda165652e273b Author: Doug Evans <xdje42@gmail.com> Date: Sat Aug 15 16:46:20 2015 -0700 Add end_psymtab_common, have all debug info readers call it. gdb/ChangeLog: * dbxread.c (dbx_end_psymtab): Renamed from end_psymtab. All callers updated. Call end_psymtab_common. * dwarf2read.c (process_psymtab_comp_unit_reader): Call end_psymtab_common. (build_type_psymtabs_reader): Ditto. * psympriv.h (sort_pst_symbols): Delete. (end_psymtab_common): Declare. * psymtab.c (sort_pst_symbols): Make static. (end_psymtab_common): New function. * xcoffread.c (xcoff_end_psymtab): Call end_psymtab_common. commit 51cdc99310171d6c53d2d00103a0ce34374d0b9b Author: Doug Evans <xdje42@gmail.com> Date: Sat Aug 15 16:25:53 2015 -0700 Use macros for some enum bit field sizes. gdb/ChangeLog: * defs.h (LANGUAGE_BITS): Define. * psympriv.h (partial_symbol) <domain>: Use SYMBOL_DOMAIN_BITS. (partial_symbol) <aclass>: Use SYMBOL_ACLASS_BITS. * symtab.h (general_symbol_info> <language>: Usage LANGUAGE_BITS. (minimal_symbol_type): Add nr_minsym_types. (MINSYM_TYPE_BITS): Define. (minimal_symbol) <type>: Use MINSYM_TYPE_BITS. (domain_enum_tag): Add NR_DOMAINS. (SYMBOL_DOMAIN_BITS): Change from 4 to 3. (SYMBOL_ACLASS_BITS): Define from 6 to 5. commit 95cf586902b681310e63ee06d89ba2498d1d5dcf Author: Doug Evans <xdje42@gmail.com> Date: Sat Aug 15 15:51:00 2015 -0700 objfiles.h,psympriv.h,psymtab.c: Whitespace. gdb/ChangeLog: * objfiles.h: Whitespace cleanup. * psympriv.h: Whitespace cleanup. * psymtab.c: Whitespace/coding convention cleanup. commit e3ae3c4345fa14f2f3b0b2c5d4d23760af9f74f5 Author: Patrick Palka <patrick@parcs.ath.cx> Date: Tue Jul 28 15:00:58 2015 -0400 Fix invoking "[kill|detach] inferiors" on inferiors that are not running Invoking either of the above commands on an inferior that's not running triggers the following assert failure: .../binutils-gdb/gdb/thread.c:514: internal-error: any_thread_of_process: Assertion `pid != 0' failed. The fix is straightforward. This patch also adds a test to check the basic functionality of these commands, along with testing this fix in particular. Tested on x86_64 Linux. gdb/ChangeLog: * inferior.c (detach_inferior_command): Don't call any_thread_of_process when pid is 0. (kill_inferior_command): Likewise. gdb/testsuite/ChangeLog: * gdb.base/kill-detach-inferiors-cmd.exp: New test file. * gdb.base/kill-detach-inferiors-cmd.c: New test file. ----------------------------------------------------------------------- Summary of changes: bfd/ChangeLog | 146 ++ bfd/Makefile.am | 28 +- bfd/Makefile.in | 28 +- bfd/aoutx.h | 16 +- bfd/bout.c | 2 +- bfd/coff-alpha.c | 16 +- bfd/coff-arm.c | 20 +- bfd/coff-i386.c | 2 +- bfd/coff-i960.c | 6 +- bfd/coff-m68k.c | 2 +- bfd/coff-mcore.c | 2 +- bfd/coff-mips.c | 4 +- bfd/coff-ppc.c | 16 +- bfd/coff-rs6000.c | 2 +- bfd/coff-sh.c | 4 +- bfd/coff-tic80.c | 2 +- bfd/coff-x86_64.c | 2 +- bfd/coff64-rs6000.c | 2 +- bfd/coffgen.c | 2 +- bfd/cofflink.c | 44 +- bfd/ecoff.c | 8 +- bfd/ecofflink.c | 12 +- bfd/elf-bfd.h | 5 +- bfd/elf-eh-frame.c | 14 +- bfd/elf-ifunc.c | 16 +- bfd/elf-m10200.c | 4 +- bfd/elf-m10300.c | 52 +- bfd/elf-s390-common.c | 17 +- bfd/elf-vxworks.c | 4 +- bfd/elf.c | 14 +- bfd/elf32-arm.c | 125 +- bfd/elf32-avr.c | 8 +- bfd/elf32-bfin.c | 72 +- bfd/elf32-cr16.c | 24 +- bfd/elf32-cr16c.c | 2 +- bfd/elf32-cris.c | 86 +- bfd/elf32-crx.c | 4 +- bfd/elf32-d10v.c | 8 +- bfd/elf32-dlx.c | 2 +- bfd/elf32-epiphany.c | 4 +- bfd/elf32-fr30.c | 4 +- bfd/elf32-frv.c | 71 +- bfd/elf32-ft32.c | 2 +- bfd/elf32-h8300.c | 4 +- bfd/elf32-hppa.c | 76 +- bfd/elf32-i370.c | 26 +- bfd/elf32-i386.c | 126 +- bfd/elf32-i860.c | 2 +- bfd/elf32-ip2k.c | 4 +- bfd/elf32-iq2000.c | 4 +- bfd/elf32-lm32.c | 42 +- bfd/elf32-m32c.c | 12 +- bfd/elf32-m32r.c | 67 +- bfd/elf32-m68hc11.c | 2 +- bfd/elf32-m68hc1x.c | 4 +- bfd/elf32-m68k.c | 48 +- bfd/elf32-mcore.c | 6 +- bfd/elf32-mep.c | 2 +- bfd/elf32-metag.c | 71 +- bfd/elf32-microblaze.c | 55 +- bfd/elf32-moxie.c | 4 +- bfd/elf32-msp430.c | 6 +- bfd/elf32-mt.c | 4 +- bfd/elf32-nds32.c | 77 +- bfd/elf32-nios2.c | 80 +- bfd/elf32-or1k.c | 52 +- bfd/elf32-ppc.c | 168 +- bfd/elf32-rl78.c | 10 +- bfd/elf32-rx.c | 4 +- bfd/elf32-s390.c | 100 +- bfd/elf32-score.c | 35 +- bfd/elf32-score7.c | 36 +- bfd/elf32-sh-symbian.c | 2 +- bfd/elf32-sh.c | 143 +- bfd/elf32-sh64.c | 8 +- bfd/elf32-spu.c | 10 +- bfd/elf32-tic6x.c | 57 +- bfd/elf32-tilepro.c | 86 +- bfd/elf32-v850.c | 6 +- bfd/elf32-vax.c | 30 +- bfd/elf32-visium.c | 4 +- bfd/elf32-xc16x.c | 2 +- bfd/elf32-xstormy16.c | 8 +- bfd/elf32-xtensa.c | 56 +- bfd/elf64-alpha.c | 69 +- bfd/elf64-hppa.c | 68 +- bfd/elf64-ia64-vms.c | 54 +- bfd/elf64-mmix.c | 10 +- bfd/elf64-ppc.c | 145 ++- bfd/elf64-s390.c | 90 +- bfd/elf64-sh64.c | 66 +- bfd/elf64-x86-64.c | 118 +- bfd/elflink.c | 143 +- bfd/elfnn-aarch64.c | 112 +- bfd/elfnn-ia64.c | 92 +- bfd/elfxx-mips.c | 135 +- bfd/elfxx-sparc.c | 122 +- bfd/elfxx-tilegx.c | 88 +- bfd/i386linux.c | 2 +- bfd/linker.c | 10 +- bfd/m68klinux.c | 2 +- bfd/pdp11.c | 12 +- bfd/pe-mips.c | 6 +- bfd/peXXigen.c | 4 +- bfd/reloc.c | 2 +- bfd/reloc16.c | 2 +- bfd/sparclinux.c | 2 +- bfd/sunos.c | 42 +- bfd/version.h | 2 +- bfd/vms-alpha.c | 2 +- bfd/xcofflink.c | 8 +- binutils/ChangeLog | 4 + binutils/configure | 93 +- gas/ChangeLog | 7 + gas/config/tc-arm.c | 49 +- gas/config/tc-arm.h | 1 + gas/read.c | 5 + gdb/ChangeLog | 97 ++ gdb/NEWS | 14 + gdb/cli/cli-cmds.c | 2 +- gdb/common/filestuff.c | 2 - gdb/d-exp.y | 19 +- gdb/d-namespace.c | 1 + gdb/dbxread.c | 93 +- gdb/defs.h | 7 + gdb/doc/ChangeLog | 15 + gdb/doc/gdb.texinfo | 56 +- gdb/dwarf2read.c | 40 +- gdb/exec.c | 1 - gdb/gdb_bfd.c | 139 ++- gdb/gdb_bfd.h | 3 +- gdb/inferior.c | 10 + gdb/linux-nat.c | 2 + gdb/main.c | 3 +- gdb/mdebugread.c | 54 +- gdb/objfiles.h | 288 ++-- gdb/psympriv.h | 17 +- gdb/psymtab.c | 194 ++-- gdb/remote.c | 36 +- gdb/solib.c | 13 +- gdb/source.c | 42 +- gdb/source.h | 19 + gdb/stabsread.h | 16 +- gdb/symtab.h | 38 +- gdb/testsuite/ChangeLog | 10 + gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c | 25 + .../gdb.base/kill-detach-inferiors-cmd.exp | 62 + gdb/testsuite/gdb.base/main-mismatch.exp | 159 +-- gdb/testsuite/gdb.linespec/explicit.exp | 4 - gdb/testsuite/gdb.trace/strace.exp | 5 + gdb/ui-out.c | 2 +- gdb/utils.c | 2 + gdb/x86-linux-nat.c | 11 + gdb/xcoffread.c | 29 +- include/ChangeLog | 11 + include/bfdlink.h | 30 +- ld/ChangeLog | 59 + ld/emultempl/aarch64elf.em | 4 +- ld/emultempl/aix.em | 21 +- ld/emultempl/alphaelf.em | 8 +- ld/emultempl/armcoff.em | 8 +- ld/emultempl/armelf.em | 6 +- ld/emultempl/avrelf.em | 4 +- ld/emultempl/beos.em | 10 +- ld/emultempl/cr16elf.em | 4 +- ld/emultempl/elf-generic.em | 2 +- ld/emultempl/elf32.em | 50 +- ld/emultempl/genelf.em | 4 +- ld/emultempl/generic.em | 10 +- ld/emultempl/gld960.em | 8 +- ld/emultempl/gld960c.em | 8 +- ld/emultempl/hppaelf.em | 6 +- ld/emultempl/irix.em | 2 +- ld/emultempl/linux.em | 10 +- ld/emultempl/lnk960.em | 10 +- ld/emultempl/m68hc1xelf.em | 2 +- ld/emultempl/m68kcoff.em | 12 +- ld/emultempl/m68kelf.em | 4 +- ld/emultempl/metagelf.em | 4 +- ld/emultempl/mipself.em | 2 +- ld/emultempl/mmo.em | 2 +- ld/emultempl/msp430.em | 12 +- ld/emultempl/nds32elf.em | 8 +- ld/emultempl/needrelax.em | 2 +- ld/emultempl/nios2elf.em | 8 +- ld/emultempl/pe.em | 32 +- ld/emultempl/pep.em | 32 +- ld/emultempl/ppc32elf.em | 3 +- ld/emultempl/ppc64elf.em | 12 +- ld/emultempl/sh64elf.em | 3 +- ld/emultempl/solaris2.em | 6 +- ld/emultempl/spuelf.em | 8 +- ld/emultempl/sunos.em | 23 +- ld/emultempl/tic6xdsbt.em | 2 +- ld/emultempl/ticoff.em | 8 +- ld/emultempl/v850elf.em | 2 +- ld/emultempl/vms.em | 2 +- ld/emultempl/vxworks.em | 2 +- ld/ldctor.c | 4 +- ld/ldemul.c | 6 +- ld/ldexp.c | 1 + ld/ldfile.c | 2 +- ld/ldlang.c | 43 +- ld/ldmain.c | 7 +- ld/ldwrite.c | 4 +- ld/lexsup.c | 46 +- ld/pe-dll.c | 6 +- ld/plugin.c | 10 +- ld/testsuite/ChangeLog | 14 + ld/testsuite/ld-ifunc/ifunc.exp | 32 + ld/testsuite/ld-ifunc/pr18841.out | 1 + ld/testsuite/ld-ifunc/pr18841a.c | 12 + ld/testsuite/ld-ifunc/pr18841b.c | 21 + ld/testsuite/ld-ifunc/pr18841c.c | 17 + opcodes/ChangeLog | 9 + opcodes/cgen.sh | 23 +- opcodes/ia64-asmtab.c | 1621 ++++++++++---------- opcodes/ia64-gen.c | 20 +- opcodes/opc2c.c | 7 +- 219 files changed, 4406 insertions(+), 3506 deletions(-) create mode 100644 gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.c create mode 100644 gdb/testsuite/gdb.base/kill-detach-inferiors-cmd.exp create mode 100644 ld/testsuite/ld-ifunc/pr18841.out create mode 100644 ld/testsuite/ld-ifunc/pr18841a.c create mode 100644 ld/testsuite/ld-ifunc/pr18841b.c create mode 100644 ld/testsuite/ld-ifunc/pr18841c.c First 500 lines of diff: diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 09f7650..c0fbbe9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,149 @@ +2015-08-18 Jiong Wang <jiong.wang@arm.com> + + * elfnn-aarch64.c (aarch64_reloc_got_type): Delete useless check. + (elfNN_aarch64_relocate_section): Likewise. + (elfNN_aarch64_gc_sweep_hook): Likewise. + (elfNN_aarch64_check_relocs): Likewise. + +2015-08-18 H.J. Lu <hongjiu.lu@intel.com> + + PR ld/18841 + * elf-bfd.h (elf_link_hash_table): Add dynsym. + * elf32-i386.c (elf_i386_reloc_type_class): Return + reloc_class_ifunc for relocation against STT_GNU_IFUNC symbol. + * elf64-x86-64.c (elf_x86_64_reloc_type_class): Likewise. + * elflink.c (_bfd_elf_link_create_dynamic_sections): Set dynsym. + (bfd_elf_size_dynsym_hash_dynstr): Use dynsym. + (elf_final_link_info): Remove dynsym_sec. + (elf_link_output_extsym): Replace dynsym_sec with dynsym. + (bfd_elf_final_link): Remove reference to dynsym_sec. Replace + dynsym_sec with dynsym. + +2015-08-18 H.J. Lu <hongjiu.lu@intel.com> + + * bfd/aoutx.h: Replace shared, executable, relocatable and pie + fields with bfd_link_executable, bfd_link_dll, + bfd_link_relocatable, bfd_link_pic and bfd_link_pie. + * bfd/bout.c: Likewise. + * bfd/coff-alpha.c: Likewise. + * bfd/coff-arm.c: Likewise. + * bfd/coff-i386.c: Likewise. + * bfd/coff-i960.c: Likewise. + * bfd/coff-m68k.c: Likewise. + * bfd/coff-mcore.c: Likewise. + * bfd/coff-mips.c: Likewise. + * bfd/coff-ppc.c: Likewise. + * bfd/coff-rs6000.c: Likewise. + * bfd/coff-sh.c: Likewise. + * bfd/coff-tic80.c: Likewise. + * bfd/coff-x86_64.c: Likewise. + * bfd/coff64-rs6000.c: Likewise. + * bfd/coffgen.c: Likewise. + * bfd/cofflink.c: Likewise. + * bfd/ecoff.c: Likewise. + * bfd/ecofflink.c: Likewise. + * bfd/elf-bfd.h: Likewise. + * bfd/elf-eh-frame.c: Likewise. + * bfd/elf-ifunc.c: Likewise. + * bfd/elf-m10200.c: Likewise. + * bfd/elf-m10300.c: Likewise. + * bfd/elf-s390-common.c: Likewise. + * bfd/elf-vxworks.c: Likewise. + * bfd/elf.c: Likewise. + * bfd/elf32-arm.c: Likewise. + * bfd/elf32-avr.c: Likewise. + * bfd/elf32-bfin.c: Likewise. + * bfd/elf32-cr16.c: Likewise. + * bfd/elf32-cr16c.c: Likewise. + * bfd/elf32-cris.c: Likewise. + * bfd/elf32-crx.c: Likewise. + * bfd/elf32-d10v.c: Likewise. + * bfd/elf32-dlx.c: Likewise. + * bfd/elf32-epiphany.c: Likewise. + * bfd/elf32-fr30.c: Likewise. + * bfd/elf32-frv.c: Likewise. + * bfd/elf32-ft32.c: Likewise. + * bfd/elf32-h8300.c: Likewise. + * bfd/elf32-hppa.c: Likewise. + * bfd/elf32-i370.c: Likewise. + * bfd/elf32-i386.c: Likewise. + * bfd/elf32-i860.c: Likewise. + * bfd/elf32-ip2k.c: Likewise. + * bfd/elf32-iq2000.c: Likewise. + * bfd/elf32-lm32.c: Likewise. + * bfd/elf32-m32c.c: Likewise. + * bfd/elf32-m32r.c: Likewise. + * bfd/elf32-m68hc11.c: Likewise. + * bfd/elf32-m68hc1x.c: Likewise. + * bfd/elf32-m68k.c: Likewise. + * bfd/elf32-mcore.c: Likewise. + * bfd/elf32-mep.c: Likewise. + * bfd/elf32-metag.c: Likewise. + * bfd/elf32-microblaze.c: Likewise. + * bfd/elf32-moxie.c: Likewise. + * bfd/elf32-msp430.c: Likewise. + * bfd/elf32-mt.c: Likewise. + * bfd/elf32-nds32.c: Likewise. + * bfd/elf32-nios2.c: Likewise. + * bfd/elf32-or1k.c: Likewise. + * bfd/elf32-ppc.c: Likewise. + * bfd/elf32-rl78.c: Likewise. + * bfd/elf32-rx.c: Likewise. + * bfd/elf32-s390.c: Likewise. + * bfd/elf32-score.c: Likewise. + * bfd/elf32-score7.c: Likewise. + * bfd/elf32-sh-symbian.c: Likewise. + * bfd/elf32-sh.c: Likewise. + * bfd/elf32-sh64.c: Likewise. + * bfd/elf32-spu.c: Likewise. + * bfd/elf32-tic6x.c: Likewise. + * bfd/elf32-tilepro.c: Likewise. + * bfd/elf32-v850.c: Likewise. + * bfd/elf32-vax.c: Likewise. + * bfd/elf32-visium.c: Likewise. + * bfd/elf32-xc16x.c: Likewise. + * bfd/elf32-xstormy16.c: Likewise. + * bfd/elf32-xtensa.c: Likewise. + * bfd/elf64-alpha.c: Likewise. + * bfd/elf64-hppa.c: Likewise. + * bfd/elf64-ia64-vms.c: Likewise. + * bfd/elf64-mmix.c: Likewise. + * bfd/elf64-ppc.c: Likewise. + * bfd/elf64-s390.c: Likewise. + * bfd/elf64-sh64.c: Likewise. + * bfd/elf64-x86-64.c: Likewise. + * bfd/elflink.c: Likewise. + * bfd/elfnn-aarch64.c: Likewise. + * bfd/elfnn-ia64.c: Likewise. + * bfd/elfxx-mips.c: Likewise. + * bfd/elfxx-sparc.c: Likewise. + * bfd/elfxx-tilegx.c: Likewise. + * bfd/i386linux.c: Likewise. + * bfd/linker.c: Likewise. + * bfd/m68klinux.c: Likewise. + * bfd/pdp11.c: Likewise. + * bfd/pe-mips.c: Likewise. + * bfd/peXXigen.c: Likewise. + * bfd/reloc.c: Likewise. + * bfd/reloc16.c: Likewise. + * bfd/sparclinux.c: Likewise. + * bfd/sunos.c: Likewise. + * bfd/vms-alpha.c: Likewise. + * bfd/xcofflink.c: Likewise. + +2015-08-18 Alan Modra <amodra@gmail.com> + + PR 18667 + * Makefile.am: Use $(SED) in place of sed throughout. + * Makefile.in: Regenerate. + +2015-08-18 Alan Modra <amodra@gmail.com> + + * elf64-ppc.c (ppc64_elf_func_desc_adjust): Don't redefine .TOC. + if already defined, and set linker_def. + (ppc64_elf_set_toc): Use .TOC. value if defined other than by + the backend. + 2015-08-14 Alan Modra <amodra@gmail.com> PR ld/18759 diff --git a/bfd/Makefile.am b/bfd/Makefile.am index e28904a..bf73057 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -860,7 +860,7 @@ noinst_LIBRARIES = libbfd.a libbfd_a_SOURCES = stamp-lib: libbfd.la - libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \ + libtooldir=`$(LIBTOOL) --config | $(SED) -n -e 's/^objdir=//p'`; \ if [ -f $$libtooldir/libbfd.a ]; then \ cp $$libtooldir/libbfd.a libbfd.tmp; \ $(RANLIB) libbfd.tmp; \ @@ -875,7 +875,7 @@ libbfd.a: stamp-lib ; @true # itself, but is included by targets.c. targmatch.h: config.bfd targmatch.sed rm -f targmatch.h - sed -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new + $(SED) -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new mv -f targmatch.new targmatch.h # When compiling archures.c and targets.c, supply the default target @@ -919,49 +919,49 @@ endif elf32-target.h : elfxx-target.h rm -f elf32-target.h - sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new + $(SED) -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new mv -f elf32-target.new elf32-target.h elf64-target.h : elfxx-target.h rm -f elf64-target.h - sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new + $(SED) -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new mv -f elf64-target.new elf64-target.h elf32-aarch64.c : elfnn-aarch64.c rm -f elf32-aarch64.c echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new - sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new + $(SED) -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new mv -f elf32-aarch64.new elf32-aarch64.c elf64-aarch64.c : elfnn-aarch64.c rm -f elf64-aarch64.c echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new - sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new + $(SED) -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new mv -f elf64-aarch64.new elf64-aarch64.c elf32-ia64.c : elfnn-ia64.c rm -f elf32-ia64.c - sed -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new + $(SED) -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new mv -f elf32-ia64.new elf32-ia64.c elf64-ia64.c : elfnn-ia64.c rm -f elf64-ia64.c - sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new + $(SED) -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new mv -f elf64-ia64.new elf64-ia64.c peigen.c : peXXigen.c rm -f peigen.c - sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new + $(SED) -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new mv -f peigen.new peigen.c pepigen.c : peXXigen.c rm -f pepigen.c - sed -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new + $(SED) -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new mv -f pepigen.new pepigen.c pex64igen.c: peXXigen.c rm -f pex64igen.c - sed -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new + $(SED) -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new mv -f pex64igen.new pex64igen.c BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h @@ -1042,18 +1042,18 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD_HFILES) libtool-soversion bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in @echo "creating $@" - @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ + @bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ bfd_version_string="\"$(VERSION)\"" ;\ bfd_soversion="$(VERSION)" ;\ bfd_version_package="\"$(PKGVERSION)\"" ;\ report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ . $(srcdir)/development.sh ;\ if test "$$development" = true ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ + bfd_version_date=`$(SED) -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ -e "s,@bfd_version_string@,$$bfd_version_string," \ -e "s,@bfd_version_package@,$$bfd_version_package," \ -e "s,@report_bugs_to@,$$report_bugs_to," \ diff --git a/bfd/Makefile.in b/bfd/Makefile.in index aa885e3..9fd0d68 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -1961,7 +1961,7 @@ stamp-ofiles: Makefile ofiles: stamp-ofiles ; @true stamp-lib: libbfd.la - libtooldir=`$(LIBTOOL) --config | sed -n -e 's/^objdir=//p'`; \ + libtooldir=`$(LIBTOOL) --config | $(SED) -n -e 's/^objdir=//p'`; \ if [ -f $$libtooldir/libbfd.a ]; then \ cp $$libtooldir/libbfd.a libbfd.tmp; \ $(RANLIB) libbfd.tmp; \ @@ -1976,7 +1976,7 @@ libbfd.a: stamp-lib ; @true # itself, but is included by targets.c. targmatch.h: config.bfd targmatch.sed rm -f targmatch.h - sed -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new + $(SED) -f $(srcdir)/targmatch.sed < $(srcdir)/config.bfd > targmatch.new mv -f targmatch.new targmatch.h # When compiling archures.c and targets.c, supply the default target @@ -2005,49 +2005,49 @@ dwarf2.lo: dwarf2.c Makefile elf32-target.h : elfxx-target.h rm -f elf32-target.h - sed -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new + $(SED) -e s/NN/32/g < $(srcdir)/elfxx-target.h > elf32-target.new mv -f elf32-target.new elf32-target.h elf64-target.h : elfxx-target.h rm -f elf64-target.h - sed -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new + $(SED) -e s/NN/64/g < $(srcdir)/elfxx-target.h > elf64-target.new mv -f elf64-target.new elf64-target.h elf32-aarch64.c : elfnn-aarch64.c rm -f elf32-aarch64.c echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new - sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new + $(SED) -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new mv -f elf32-aarch64.new elf32-aarch64.c elf64-aarch64.c : elfnn-aarch64.c rm -f elf64-aarch64.c echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new - sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new + $(SED) -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new mv -f elf64-aarch64.new elf64-aarch64.c elf32-ia64.c : elfnn-ia64.c rm -f elf32-ia64.c - sed -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new + $(SED) -e s/NN/32/g < $(srcdir)/elfnn-ia64.c > elf32-ia64.new mv -f elf32-ia64.new elf32-ia64.c elf64-ia64.c : elfnn-ia64.c rm -f elf64-ia64.c - sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new + $(SED) -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new mv -f elf64-ia64.new elf64-ia64.c peigen.c : peXXigen.c rm -f peigen.c - sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new + $(SED) -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new mv -f peigen.new peigen.c pepigen.c : peXXigen.c rm -f pepigen.c - sed -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new + $(SED) -e s/XX/pep/g < $(srcdir)/peXXigen.c > pepigen.new mv -f pepigen.new pepigen.c pex64igen.c: peXXigen.c rm -f pex64igen.c - sed -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new + $(SED) -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new mv -f pex64igen.new pex64igen.c $(BFD32_LIBS) \ $(BFD64_LIBS) \ @@ -2110,18 +2110,18 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES) bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in @echo "creating $@" - @bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ + @bfd_version=`echo "$(VERSION)" | $(SED) -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\ bfd_version_string="\"$(VERSION)\"" ;\ bfd_soversion="$(VERSION)" ;\ bfd_version_package="\"$(PKGVERSION)\"" ;\ report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\ . $(srcdir)/development.sh ;\ if test "$$development" = true ; then \ - bfd_version_date=`sed -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ + bfd_version_date=`$(SED) -n -e 's/.*DATE //p' < $(srcdir)/version.h` ;\ bfd_version_string="\"$(VERSION).$${bfd_version_date}\"" ;\ bfd_soversion="$(VERSION).$${bfd_version_date}" ;\ fi ;\ - sed -e "s,@bfd_version@,$$bfd_version," \ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ -e "s,@bfd_version_string@,$$bfd_version_string," \ -e "s,@bfd_version_package@,$$bfd_version_package," \ -e "s,@report_bugs_to@,$$report_bugs_to," \ diff --git a/bfd/aoutx.h b/bfd/aoutx.h index e3bd2dd..f78b910 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -3946,7 +3946,7 @@ aout_link_input_section_std (struct aout_final_link_info *flaginfo, BFD_ASSERT (input_bfd->xvec->header_byteorder == output_bfd->xvec->header_byteorder); - relocatable = flaginfo->info->relocatable; + relocatable = bfd_link_relocatable (flaginfo->info); syms = obj_aout_external_syms (input_bfd); strings = obj_aout_external_strings (input_bfd); sym_hashes = obj_aout_sym_hashes (input_bfd); @@ -4212,7 +4212,7 @@ aout_link_input_section_std (struct aout_final_link_info *flaginfo, /* Now warn if a global symbol is undefined. We could not do this earlier, because check_dynamic_reloc might want to skip this reloc. */ - if (hundef && ! flaginfo->info->shared && ! r_baserel) + if (hundef && ! bfd_link_pic (flaginfo->info) && ! r_baserel) { const char *name; @@ -4300,7 +4300,7 @@ aout_link_input_section_ext (struct aout_final_link_info *flaginfo, BFD_ASSERT (input_bfd->xvec->header_byteorder == output_bfd->xvec->header_byteorder); - relocatable = flaginfo->info->relocatable; + relocatable = bfd_link_relocatable (flaginfo->info); syms = obj_aout_external_syms (input_bfd); strings = obj_aout_external_strings (input_bfd); sym_hashes = obj_aout_sym_hashes (input_bfd); @@ -4616,7 +4616,7 @@ aout_link_input_section_ext (struct aout_final_link_info *flaginfo, do this earlier, because check_dynamic_reloc might want to skip this reloc. */ if (hundef - && ! flaginfo->info->shared + && ! bfd_link_pic (flaginfo->info) && r_type != (unsigned int) RELOC_BASE10 && r_type != (unsigned int) RELOC_BASE13 && r_type != (unsigned int) RELOC_BASE22) @@ -4749,7 +4749,7 @@ aout_link_input_section (struct aout_final_link_info *flaginfo, /* If we are producing relocatable output, the relocs were modified, and we now write them out. */ - if (flaginfo->info->relocatable && rel_size > 0) + if (bfd_link_relocatable (flaginfo->info) && rel_size > 0) { if (bfd_seek (flaginfo->output_bfd, *reloff_ptr, SEEK_SET) != 0) return FALSE; @@ -5335,7 +5335,7 @@ NAME (aout, final_link) (bfd *abfd, asection *o; bfd_boolean have_link_order_relocs; - if (info->shared) + if (bfd_link_pic (info)) abfd->flags |= DYNAMIC; aout_info.info = info; @@ -5363,7 +5363,7 @@ NAME (aout, final_link) (bfd *abfd, { bfd_size_type sz; - if (info->relocatable) + if (bfd_link_relocatable (info)) { if (bfd_get_flavour (sub) == bfd_target_aout_flavour) { @@ -5407,7 +5407,7 @@ NAME (aout, final_link) (bfd *abfd, } } - if (info->relocatable) + if (bfd_link_relocatable (info)) { if (obj_textsec (abfd) != NULL) trsize += (_bfd_count_link_order_relocs (obj_textsec (abfd) diff --git a/bfd/bout.c b/bfd/bout.c index 8ca3c78..f356b96 100644 --- a/bfd/bout.c +++ b/bfd/bout.c @@ -1139,7 +1139,7 @@ b_out_bfd_relax_section (bfd *abfd, arelent **reloc_vector = NULL; long reloc_size = bfd_get_reloc_upper_bound (input_bfd, input_section); - if (link_info->relocatable) + if (bfd_link_relocatable (link_info)) (*link_info->callbacks->einfo) (_("%P%F: --relax and -r may not be used together\n")); diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 0fdbded..58d4e1d 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -1226,7 +1226,7 @@ alpha_convert_external_reloc (bfd *output_bfd ATTRIBUTE_UNUSED, unsigned long r_symndx; bfd_vma relocation; - BFD_ASSERT (info->relocatable); + BFD_ASSERT (bfd_link_relocatable (info)); if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) @@ -1405,7 +1405,7 @@ alpha_relocate_section (bfd *output_bfd, lita_sec = symndx_to_section[RELOC_SECTION_LITA]; gp = _bfd_get_gp_value (output_bfd); - if (! info->relocatable && lita_sec != NULL) + if (! bfd_link_relocatable (info) && lita_sec != NULL) { struct ecoff_section_tdata *lita_sec_data; @@ -1530,7 +1530,7 @@ alpha_relocate_section (bfd *output_bfd, not otherwise used for anything. For some reason, the address of the relocation does not appear to include the section VMA, unlike the other relocation types. */ - if (info->relocatable) + if (bfd_link_relocatable (info)) H_PUT_64 (input_bfd, input_section->output_offset + r_vaddr, ext_rel->r_vaddr); adjust_addrp = FALSE; @@ -1683,7 +1683,7 @@ alpha_relocate_section (bfd *output_bfd, if (h == (struct ecoff_link_hash_entry *) NULL) abort (); - if (! info->relocatable) + if (! bfd_link_relocatable (info)) { if (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak) @@ -1726,7 +1726,7 @@ alpha_relocate_section (bfd *output_bfd, addend += r_vaddr; - if (info->relocatable) + if (bfd_link_relocatable (info)) { /* Adjust r_vaddr by the addend. */ H_PUT_64 (input_bfd, addend, ext_rel->r_vaddr); @@ -1762,7 +1762,7 @@ alpha_relocate_section (bfd *output_bfd, /* Store a value from the reloc stack into a bitfield. If hooks/post-receive -- Repository for Project Archer.
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 <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 mainbuildid commit 5ff4e589f6fe2bc2a8650f787f9a19b1c5ab2dd2 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 hexallocate commit 5f63a388e55f85724b5d43612cfd50fe61c1d129 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:19 2015 +0200 locatetest commit 5947a0c9cceb88d4a9ce62c67f3f61e363de7ddc Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 4e1494a43a52b384d696e02f2906d80e306a95f6 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidwarn commit fbf2026ee8b96565184917aaa92bba3c9e1f14d5 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibbfdopen commit 11dadb4d264555fd91ab0ae46a136dc61af990f5 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidverify commit a5f5b8ea74ee76db95178b3d2ce7623ba614007a Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidsolibsearch commit 41492ad8abdaf4cc33c9f70550f45251a080eb23 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:18 2015 +0200 buildidtofile commit 06333a2a928fc3336ab1bdcc881d6d7437d14086 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidproto commit f3deab52baf3eb5e375a7f336c9de79a9eb90a85 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidtobfd commit fc02788f47d59ce13086aa0877d62ee422d56c10 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidforcemove commit 28f27b3907e177dd11ee4c9bcc0c802a40ffb44d Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:17 2015 +0200 buildidfreefix commit b13b54a2c120999e08bfca8e4d8ab2148a7745fe Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsymfile commit 3cb111fb4dedceda32b0daaf5c05d9b68751a048 Author: Jan Kratochvil <jan.kratochvil@redhat.com> Date: Thu Aug 13 16:17:16 2015 +0200 openpsolib commit 8b26582be65a0db52f849eebfdf60c7678e69779 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * gdb_bfd.c (gdb_bfd_iovec_fileio_open_fd): New function. (gdb_bfd_open_from_target): Conditionally use it. commit 21b5225718b928c4f47bfeb660f3d1af6dd281ed Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * source.c (openp): Update function comment for filename_opened. Remove NULL check for filename_opened. commit 530b609f9e975ec38b2e234dfdbd6260f76ecaf6 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * 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 <jan.kratochvil@redhat.com> * gdb.texinfo (Files): Permit set sysroot and show sysroot to have multiple components. commit e0b27412689ea95cc05d207f6091c70972077fc5 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <jan.kratochvil@redhat.com> * solib.c (solib_find_1): Make sysroot variable const. commit f6cd4980f1bb94b524dca174dcdd381ad2be32da Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 ace8843332eb835e1010275d6ba2d4f2cddbdb5d Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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 ec0053bd4301d249eef54d95908e5849ab100724 Author: Jan Kratochvil <jan.kratochvil@redhat.com> 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 <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. ----------------------------------------------------------------------- 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.