From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28882 invoked by alias); 12 Aug 2015 14:18:58 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 28857 invoked by uid 9674); 12 Aug 2015 14:18:57 -0000 Date: Wed, 12 Aug 2015 14:18:00 -0000 Message-ID: <20150812141856.28791.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] jankratochvil/gdbserverbuildid-locate: sticky X-Git-Refname: refs/heads/jankratochvil/gdbserverbuildid-locate X-Git-Reftype: branch X-Git-Oldrev: fdfff5459f87e263811f0fe597946b6ec8ef2ca5 X-Git-Newrev: 418401189cb3400e44e5fa27114025e8b539f4b3 X-SW-Source: 2015-q3/txt/msg00022.txt.bz2 List-Id: The branch, jankratochvil/gdbserverbuildid-locate has been updated discards fdfff5459f87e263811f0fe597946b6ec8ef2ca5 (commit) discards ae03cee1305381dac0621f97d77645c90e9fd907 (commit) discards fd861b8aae745799a44483808388cde6c4f20aaf (commit) discards 868abc8257c7e24b2ae4a68c57e5854bb58ecf48 (commit) discards e620804cc6184ac2766423ccbdd8aabaff6b70fa (commit) discards 9efcc0216f1fe90dbea76bb8e2738145205c6933 (commit) discards a823fdc321b6fb4cd2c5a46f21f67e961d737590 (commit) discards 847a1b1366e3ed0358ea7c8f57142865b52bd863 (commit) discards feb785d4098bf5bba00e940a7ebe6a96ac0edf72 (commit) discards 65bf749134458fe10426b700160b670d5643c3eb (commit) discards 86cc52cb9b768555c6a8551cdd02064846fd7791 (commit) discards 80394b0cb9ca0114f2444f6644b0bf9402966c94 (commit) discards 18b680351b49456ba30460c7c5f68abf570706e4 (commit) discards cf9c2659e990164f6c207c34aa0235d78164d7f4 (commit) discards ee862c4e7d47bd38fe07504d5cc71eca33a01281 (commit) discards 61aa8f63537242fb9fdc89b948f88b7787b27599 (commit) discards fea5a2a69d6351ecfdce8ec701017a99a41af745 (commit) discards efd2bb0409acad9f0a23fffdd8af9cfd5ac442c9 (commit) discards 8b70dce00e539378daf8ba171d7a0890e280c992 (commit) via 418401189cb3400e44e5fa27114025e8b539f4b3 (commit) via a46a3ea64e0b226c2f2a0986f38fb3e65afc15d3 (commit) via 4f85073201219d8880dea8105878f575f0c8b7f7 (commit) via c5a04e918fb12ecb68fc079b2da0f80a7b20d357 (commit) via 704b12ae8f7921594895f498f29f5bf8d1faefa0 (commit) via da855d42ea6c150b4426b672059469b9915d7d56 (commit) via f6be67c72ec0498c8b10437199fcb24fe096e221 (commit) via f10ba24c667f2dda4942506ed6a8ce942e3a2bdf (commit) via 18529c35ec3250d12add69aead900ab897e5de7c (commit) via 6a5f225738c49b519698a031cc6a0088a676dff7 (commit) via 9f3660b58fc677aa7b4606039141b79908da82c5 (commit) via bc9aa10512124621568dcfa4e56c66a51b19a801 (commit) via 58dd6320f5d05abd4ce07f2ed839ffad6ff41bd7 (commit) via 9f867d31d9988ec8b274db7bb63d6f15b26235c4 (commit) via ae9f88f532f7cbd8299d5fd157cac541805169a4 (commit) via 3a6629519fd3498a38c64f47def890c8dc3c9b6b (commit) via 27c7d53fe4853c56d28e0b600d347c0538d6d83e (commit) via 53c579199e0aa3d6a84fee360298bfb6dc24f3ac (commit) via 09f34f7dbb9fa265dac8aa9702b5cfc1b2816771 (commit) via 700c754e0f87acd321053cd441c4f97c552d4760 (commit) via 4ae2bce3eb769e4a173bfa150d1263b18513b022 (commit) from fdfff5459f87e263811f0fe597946b6ec8ef2ca5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 418401189cb3400e44e5fa27114025e8b539f4b3 Author: Jan Kratochvil Date: Wed Aug 5 21:41:00 2015 +0200 sticky Message-Id: <1433754079-10395-1-git-send-email-gbenson@redhat.com> Philippe Waroquiers wrote: > On Fri, 2015-06-05 at 12:22 +0100, Gary Benson wrote: > > Built and regtested on RHEL6.6 x86_64. > I tested with the last SVN version of the Valgrind gdbserver (that > supports qXfer:exec-file:read+). > > The patch introduces a regression: > with the patch, GDB does not anymore automatically load the > exec-file. > > I bypassed this problem by ignoring fake_pid_p in remote.c: > --- a/gdb/remote.c > +++ b/gdb/remote.c > @@ -1624,9 +1624,13 @@ remote_add_inferior (int fake_pid_p, int pid, int > attached, > inf->attach_flag = attached; > inf->fake_pid_p = fake_pid_p; > > - /* If no main executable is currently open then attempt to > - open the file that was executed to create this inferior. */ > - if (try_open_exec && get_exec_file (0) == NULL) > + /* 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. */ > + printf("fake_pid_p %d\n", fake_pid_p); > + if (try_open_exec)// && !fake_pid_p) > exec_file_locate_attach (pid, 1); > > Effectively, the printf shows that with Valgrind gdbsrv, > fake_pid_p value is 1. > > When ignoring fake_pid_p, GDB can properly attach > to different Valgrind gdbsrv, and changes of executable > as expected. Ah, it seems I mailed a bad patch, my apologies! I was working on two fixes that touched the same line, and it looks like I rebased them in the wrong order. This updated patch has been created against the latest gdb/master (80fb91378c91a8239817a5ab2b1c3e346109db25). Could you please try your tests again? Thanks, Gary --- On attach, GDB will only attempt to determine the main executable's filename if one is not already set. This causes problems if you attach to one process and then attach to another: GDB will not attempt to discover the main executable on the second attach. If the two processes have different main executable files then the symbols will now be wrong. This is PR gdb/17626. In GDB some filenames are supplied by the user (e.g. using the "file" or "symbol-file" commands) and some are determined by GDB (e.g. while processing an "attach" command). This commit updates GDB to track which filenames were supplied by the user. When GDB might attempt to determine an executable filename and one is already set, filenames determined by GDB may be overridden but user-supplied filenames will not. gdb/ChangeLog: PR gdb/17626 * progspace.h (struct program_space) : New field. : Likewise. (symfile_objfile_is_user_supplied): New macro. * exec.h (exec_file_is_user_supplied): Likewise. * exec.c (exec_close): Clear exec_file_is_user_supplied. (exec_file_locate_attach): Remove get_exec_file check. Do not replace user-supplied executable or symbol files. Warn if user-supplied executable or symbol files do not match discovered file. (exec_file_command): Set exec_file_is_user_supplied. * symfile.c (symbol_file_clear): Clear symfile_objfile_is_user_supplied. (symbol_file_command): Set symfile_objfile_is_user_supplied. * inferior.c (add_inferior_command): Set exec_file_is_user_supplied and symfile_objfile_is_user_supplied. * main.c (captured_main): Likewise. * infcmd.c (attach_command_post_wait): Always call exec_file_locate_attach. Only call reopen_exec_file and reread_symbols if exec_file_is_user_supplied. * remote.c (remote_add_inferior): Remove get_exec_file check around exec_file_locate_attach. commit a46a3ea64e0b226c2f2a0986f38fb3e65afc15d3 Author: Jan Kratochvil Date: Wed Aug 5 21:28:34 2015 +0200 mainbuildid commit 4f85073201219d8880dea8105878f575f0c8b7f7 Author: Jan Kratochvil Date: Wed Aug 5 21:28:33 2015 +0200 hexallocate commit c5a04e918fb12ecb68fc079b2da0f80a7b20d357 Author: Jan Kratochvil Date: Wed Aug 5 21:28:33 2015 +0200 locatetest commit 704b12ae8f7921594895f498f29f5bf8d1faefa0 Author: Jan Kratochvil Date: Wed Aug 5 21:28:33 2015 +0200 buildidwarn commit da855d42ea6c150b4426b672059469b9915d7d56 Author: Jan Kratochvil Date: Wed Aug 5 21:28:33 2015 +0200 buildidsolibbfdopen commit f6be67c72ec0498c8b10437199fcb24fe096e221 Author: Jan Kratochvil Date: Wed Aug 5 21:28:32 2015 +0200 buildidverify commit f10ba24c667f2dda4942506ed6a8ce942e3a2bdf Author: Jan Kratochvil Date: Wed Aug 5 21:28:32 2015 +0200 buildidsolibsearch commit 18529c35ec3250d12add69aead900ab897e5de7c Author: Jan Kratochvil Date: Wed Aug 5 21:28:32 2015 +0200 buildidtofile commit 6a5f225738c49b519698a031cc6a0088a676dff7 Author: Jan Kratochvil Date: Wed Aug 5 21:28:32 2015 +0200 buildidproto commit 9f3660b58fc677aa7b4606039141b79908da82c5 Author: Jan Kratochvil Date: Wed Aug 5 21:28:31 2015 +0200 buildidtobfd commit bc9aa10512124621568dcfa4e56c66a51b19a801 Author: Jan Kratochvil Date: Wed Aug 5 21:28:31 2015 +0200 buildidforcemove commit 58dd6320f5d05abd4ce07f2ed839ffad6ff41bd7 Author: Jan Kratochvil Date: Wed Aug 5 21:28:31 2015 +0200 buildidfreefix commit 9f867d31d9988ec8b274db7bb63d6f15b26235c4 Author: Jan Kratochvil Date: Wed Aug 5 21:28:30 2015 +0200 unvalidate commit ae9f88f532f7cbd8299d5fd157cac541805169a4 Author: Jan Kratochvil Date: Wed Aug 5 21:28:30 2015 +0200 openpsymfile commit 3a6629519fd3498a38c64f47def890c8dc3c9b6b Author: Jan Kratochvil Date: Tue Aug 11 22:34:28 2015 +0200 openpsolib commit 27c7d53fe4853c56d28e0b600d347c0538d6d83e Author: Jan Kratochvil Date: Tue Aug 11 22:34:28 2015 +0200 openp commit 53c579199e0aa3d6a84fee360298bfb6dc24f3ac Author: Jan Kratochvil Date: Tue Aug 11 22:34:28 2015 +0200 filelib commit 09f34f7dbb9fa265dac8aa9702b5cfc1b2816771 Author: Jan Kratochvil Date: Wed Aug 12 16:04:36 2015 +0200 openfromtargetdoclose commit 700c754e0f87acd321053cd441c4f97c552d4760 Author: Jan Kratochvil Date: Wed Aug 12 15:23:00 2015 +0200 openfromtargetfd commit 4ae2bce3eb769e4a173bfa150d1263b18513b022 Author: Jan Kratochvil Date: Wed Aug 12 15:12:12 2015 +0200 openfromtarget ----------------------------------------------------------------------- Summary of changes: gdb/gdb_bfd.c | 32 ++++++++++++++++++++++++-------- gdb/gdb_bfd.h | 2 ++ gdb/source.c | 50 ++++++++++++++++++++------------------------------ 3 files changed, 46 insertions(+), 38 deletions(-) First 500 lines of diff: diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index e7a0a32..cc1341d 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -300,6 +300,15 @@ gdb_bfd_iovec_fileio_close (struct bfd *abfd, void *stream) return 0; } +static int +gdb_bfd_iovec_fileio_close_nop (struct bfd *abfd, void *stream) +{ + xfree (stream); + + /* Zero means success. */ + return 0; +} + /* Wrapper for target_fileio_fstat suitable for passing as the STAT_FUNC argument to gdb_bfd_openr_iovec. */ @@ -321,6 +330,20 @@ gdb_bfd_iovec_fileio_fstat (struct bfd *abfd, void *stream, return result; } +struct bfd * +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), + gdb_bfd_iovec_fileio_pread, + do_close ? gdb_bfd_iovec_fileio_close : gdb_bfd_iovec_fileio_close_nop, + gdb_bfd_iovec_fileio_fstat); +} + /* See gdb_bfd.h. */ struct bfd * @@ -335,14 +358,7 @@ gdb_bfd_open (const char *name, const char *target, int fd) if (is_target_filename (name)) { if (!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), - gdb_bfd_iovec_fileio_pread, - gdb_bfd_iovec_fileio_close, - gdb_bfd_iovec_fileio_fstat); - } + return gdb_bfd_open_from_target (name, target, fd, 1 /* do_close */); name += strlen (TARGET_SYSROOT_PREFIX); } diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index 2ec8285..e42ee9c 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -53,6 +53,8 @@ int gdb_bfd_has_target_filename (struct bfd *abfd); struct bfd *gdb_bfd_open (const char *name, const char *target, int fd); +struct bfd *gdb_bfd_open_from_target (const char *name, const char *target, int fd, int do_close); + /* Increment the reference count of ABFD. It is fine for ABFD to be NULL; in this case the function does nothing. */ diff --git a/gdb/source.c b/gdb/source.c index 41b859e..3c35075 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -786,8 +786,7 @@ file_location_from_filename (const char *filename, int is_bfd, size_t build_idsz { struct file_location file; int load_via_target = 0; - int fd_dup = -1; - struct cleanup *back_to, *fd_dup_cleanup; + struct cleanup *back_to; memset (&file, 0, sizeof (file)); file.fd = -1; @@ -814,8 +813,8 @@ file_location_from_filename (const char *filename, int is_bfd, size_t build_idsz int target_errno; file.fd = target_fileio_open (current_inferior (), - filename, FILEIO_O_RDONLY, 0, - &target_errno); + filename, FILEIO_O_RDONLY, 0, + &target_errno); if (file.fd == -1) { file.file_errno = fileio_errno_to_host (target_errno); @@ -842,43 +841,38 @@ file_location_from_filename (const char *filename, int is_bfd, size_t build_idsz return file; } - fd_dup_cleanup = make_cleanup (null_cleanup, NULL); - if (!is_bfd) + if (load_via_target) { - fd_dup = dup (file.fd); - if (fd_dup == -1) - { - file.file_errno = errno; - close (file.fd); - file.fd = -1; - discard_cleanups (back_to); - return file; - } - make_cleanup_close (fd_dup); - } + const int do_close = is_bfd; - if (write_files && !load_via_target) - file.abfd = gdb_bfd_fopen (filename, gnutarget, FOPEN_RUB, file.fd); + 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; + } + else if (write_files) + { + file.abfd = gdb_bfd_fopen (filename, gnutarget, FOPEN_RUB, file.fd); + file.fd = -1; + } else { char *canonical; - struct cleanup *canonical_cleanup; /* gdb_bfd_open (and its variants) prefers canonicalized pathname for better BFD caching. */ - if (load_via_target) - canonical = xstrdup (filename); - else - canonical = gdb_realpath (filename); + struct cleanup *canonical_cleanup; + + canonical = gdb_realpath (filename); canonical_cleanup = make_cleanup (xfree, canonical); file.abfd = gdb_bfd_open (canonical, gnutarget, file.fd); + file.fd = -1; do_cleanups (canonical_cleanup); } - file.fd = -1; + if (file.abfd == NULL) { file.bfderr = bfd_get_error (); - do_cleanups (fd_dup_cleanup); discard_cleanups (back_to); return file; } @@ -886,7 +880,6 @@ file_location_from_filename (const char *filename, int is_bfd, size_t build_idsz if (build_idsz == 0) { gdb_assert (is_bfd); - gdb_assert (fd_dup == -1); discard_cleanups (back_to); return file; } @@ -898,13 +891,10 @@ file_location_from_filename (const char *filename, int is_bfd, size_t build_idsz return file; } - gdb_assert ((!is_bfd) == (fd_dup != -1)); if (!is_bfd) { gdb_bfd_unref (file.abfd); file.abfd = NULL; - gdb_assert (file.fd == -1); - file.fd = fd_dup; gdb_assert (file.fd != -1); } hooks/post-receive -- Repository for Project Archer.