From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4097 invoked by alias); 11 Oct 2008 17:29:35 -0000 Received: (qmail 4089 invoked by uid 22791); 11 Oct 2008 17:29:34 -0000 X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 11 Oct 2008 17:28:44 +0000 Received: from tschwinge by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1KoiEF-0006u5-F3; Sat, 11 Oct 2008 13:26:11 -0400 Date: Sat, 11 Oct 2008 17:29:00 -0000 From: Thomas Schwinge To: Pedro Alves , uweigand@de.ibm.com Cc: gdb@sourceware.org, "Alfred M. Szmidt" , bug-hurd@gnu.org Subject: Re: GDB HEAD (partly) broken for GNU/Hurd Message-ID: <20081011172611.GH21737@fencepost.gnu.org> References: <20081009093424.GN7127@fencepost.gnu.org> <200810091255.17394.pedro@codesourcery.com> <20081010232706.GG21737@fencepost.gnu.org> <200810110047.39807.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lrvsYIebpInmECXG" Content-Disposition: inline In-Reply-To: <200810110047.39807.pedro@codesourcery.com> X-Homepage: http://www.thomas.schwinge.homeip.net/ User-Agent: Mutt/1.5.11 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00045.txt.bz2 --lrvsYIebpInmECXG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 11207 Hello! On Sat, Oct 11, 2008 at 12:47:39AM +0100, Pedro Alves wrote: > On Saturday 11 October 2008 00:27:06, Thomas Schwinge wrote: > > On HEAD, when undoing this change (and additionally commenting out the > > two ``stop_soon =3D X'' lines in that file), things are fine again. At the end of this email I'll append the patch I use to get it going again. Obviously this can't be installed as-is. :-) > Eh, I did point out at the time of that change that gnu-nat.c does > things a bit different. :-) Yes, I can see that: > Off-hand advice: >=20 > One thing that the hurd has a bit different, is that we have > multi-threading when going through the shell. >=20 > Could it be that target_wait is returning a specific ptid here: >=20 > fork_child.c:startup_inferior: >=20 > while (1) > { > int resume_signal =3D TARGET_SIGNAL_0; > ptid_t resume_ptid; >=20 > struct target_waitstatus ws; > memset (&ws, 0, sizeof (ws)); > resume_ptid =3D target_wait (pid_to_ptid (-1), &ws); > ^^^^^^^^^^^ >=20 >=20 > Hence this a bit below: >=20 > if (--pending_execs =3D=3D 0) > break; >=20 > /* Just make it go on. */ > target_resume (resume_ptid, 0, TARGET_SIGNAL_0); > ^^^^^^^^^^^ > } > } >=20 > Doesn't resume the whole shell? But as I see things we always have ``non_stop =3D=3D 0'' and thus ``resume_ptid =3D pid_to_ptid (-1)'', so that should be fine, isn't it? > If you make this change: > - target_resume (resume_ptid, 0, TARGET_SIGNAL_0); > + target_resume (minus_one_ptid, 0, TARGET_SIGNAL_0); This didn't help. > The other thing I suggest to look at, is to make sure the > local `pending_execs' and the `gnu-nat.c:struct inf'::pending_execs > aren't in conflict, but it doesn't look like it. Doesn't look like it, no. For another issue, see the comment in the patch below. > Hope this helps. Unfortunately no luck so far. wait_for_inferior / handle_inferior_event (which was used in the old code) is too complex as to be quickly understandable for me. And I guess I'm estimating correctly that it's ``simply'' some side-effect of these that the old code works, while the new doesn't? Perhaps having a look at the logs I appended below some of you GDB gurus is able to spot the obvious? Index: fork-child.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/fork-child.c,v retrieving revision 1.45 diff -u -p -r1.45 fork-child.c --- fork-child.c 22 Sep 2008 15:16:51 -0000 1.45 +++ fork-child.c 11 Oct 2008 16:59:47 -0000 @@ -128,7 +128,7 @@ fork_inferior (char *exec_file_arg, char static char default_shell_file[] =3D SHELL_FILE; int len; /* Set debug_fork then attach to the child while it sleeps, to debug. */ - static int debug_fork =3D 0; + static int debug_fork =3D 1; /* Not functionally needed, but helpful fo= r readable logging messages. */ /* This is set to the result of setpgrp, which if vforked, will be visib= le to you in the parent process. It's only used by humans for debugging= . */ static int debug_setpgrp =3D 657473; @@ -427,14 +427,23 @@ startup_inferior (int ntraps) have stopped one instruction after execing the shell. Here we must get it up to actual execution of the real program. */ =20 + /* TODO. How to keep this synchronized with gnu-nat.c's own counting? = */ if (exec_wrapper) pending_execs++; =20 +#define NEW_CODE 0 + +#if NEW_CODE +#else + init_wait_for_inferior (); +#endif + while (1) { int resume_signal =3D TARGET_SIGNAL_0; ptid_t resume_ptid; =20 +#if NEW_CODE struct target_waitstatus ws; memset (&ws, 0, sizeof (ws)); resume_ptid =3D target_wait (pid_to_ptid (-1), &ws); @@ -486,6 +495,17 @@ startup_inferior (int ntraps) resume_signal =3D ws.value.sig; break; } +#else + struct thread_info *tp; + + /* Make wait_for_inferior be quiet. */ + current_inferior ()->stop_soon =3D STOP_QUIETLY; + wait_for_inferior (1); + tp =3D inferior_thread (); + +resume_signal =3D tp->stop_signal; +resume_ptid =3D pid_to_ptid (-1); +#endif =20 if (resume_signal !=3D TARGET_SIGNAL_TRAP) { @@ -519,6 +539,10 @@ startup_inferior (int ntraps) target_resume (resume_ptid, 0, TARGET_SIGNAL_0); } } +#if NEW_CODE +#else + current_inferior ()->stop_soon =3D NO_STOP_QUIETLY; +#endif } =20 /* Implement the "unset exec-wrapper" command. */ Here is a debugging-enabled run of a thusly patched GDB HEAD: GNU gdb (GDB) 6.8.50.20081011-cvs [...] (gdb) set debug infrun 1 (gdb) set debug target 1 (gdb) r Starting program: /media/data/home/tschwinge/tmp/n1/hurd/ext2fs.static infrun: wait_for_inferior (treat_exec_as_sigtrap=3D1) target_wait (-1, status) =3D 25830, status->kind =3D stopped, signal = =3D SIGTRAP target_fetch_registers (eip) =3D 701e0000 0x1e70 7792 infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x1e70 STOPPED_BY_WATCHPOINT () =3D 0 infrun: context switch infrun: Switching context from bogus thread id 1 to Thread 25830.3 target_fetch_registers (eip) =3D 701e0000 0x1e70 7792 STOPPED_BY_WATCHPOINT () =3D 0 infrun: quietly stopped infrun: stop_stepping target_terminal_init () target_terminal_inferior () target_resume (-1, continue, 0) infrun: wait_for_inferior (treat_exec_as_sigtrap=3D1) target_wait (-1, status) =3D 25830, status->kind =3D stopped, signal = =3D SIGTRAP target_fetch_registers (eip) =3D 30810408 0x8048130 134512944 infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED infrun: stop_pc =3D 0x8048130 STOPPED_BY_WATCHPOINT () =3D 0 infrun: context switch infrun: Switching context from bogus thread id 3 to Thread 25830.4 target_fetch_registers (eip) =3D 30810408 0x8048130 134512944 STOPPED_BY_WATCHPOINT () =3D 0 target_terminal_ours_for_output () infrun: quietly stopped infrun: stop_stepping target_terminal_ours () GNU:target_xfer_partial (9, target.xml, 0x843d140, 0x0, 0x0, 4095) = =3D -1 GNU:target_xfer_partial (5, (null), 0x843d140, 0x0, 0x0, 4096) =3D -1 GNU:target_xfer_partial (5, (null), 0x843d140, 0x0, 0x0, 4096) =3D -1 target_memory_map () GNU:target_xfer_partial (2, (null), 0x15ff570, 0x0, 0x816ff14, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (5, (null), 0x843d140, 0x0, 0x0, 4096) =3D -1 GNU:target_xfer_partial (5, (null), 0x843d140, 0x0, 0x0, 4096) =3D -1 GNU:target_xfer_partial (2, (null), 0x15ff510, 0x0, 0x816ff14, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (2, (null), 0x15ff5d0, 0x0, 0x816ff14, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (5, (null), 0x843d140, 0x0, 0x0, 4096) =3D -1 infrun: proceed (addr=3D0xffffffff, signal=3D0, step=3D0) GNU:target_xfer_partial (2, (null), 0x836af1c, 0x0, 0x80deef0, 1) =3D = 1, bytes =3D 55 GNU:target_xfer_partial (2, (null), 0x0, 0x82d612b, 0x80deef0, 1) =3D= 1, bytes =3D cc target_insert_breakpoint (0x80deef0, xxx) =3D 0 infrun: resume (step=3D0, signal=3D0), trap_expected=3D0 target_terminal_inferior () target_resume (-1, continue, 0) infrun: wait_for_inferior (treat_exec_as_sigtrap=3D0) [New Thread 25830.5] target_wait (-1, status) =3D 25830, status->kind =3D stopped, signal = =3D SIGSEGV infrun: infwait_normal_state infrun: TARGET_WAITKIND_STOPPED target_fetch_registers (eip) =3D 79440b08 0x80b4479 134956153 infrun: stop_pc =3D 0x80b4479 STOPPED_BY_WATCHPOINT () =3D 0 STOPPED_BY_WATCHPOINT () =3D 0 target_terminal_ours_for_output () infrun: random signal 11 target_terminal_ours_for_output () =20=20=20=20 Program received signal SIGSEGV, Segmentation fault. infrun: stop_stepping GNU:target_xfer_partial (2, (null), 0x0, 0x836af1c, 0x80deef0, 1) =3D= 1, bytes =3D 55 target_remove_breakpoint (0x80deef0, xxx) =3D 0 target_terminal_ours () target_fetch_registers (ebp) =3D 18f90101 0x101f918 16906520 GNU:target_xfer_partial (2, (null), 0x83a567c, 0x0, 0x101f8ec, 4) =3D = 4, bytes =3D bc f0 13 08 GNU:target_xfer_partial (2, (null), 0x837b994, 0x0, 0x101f8e8, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (2, (null), 0x836e19c, 0x0, 0x101f8e4, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (2, (null), 0x836e25c, 0x0, 0x101f920, 4) =3D = 4, bytes =3D e8 12 17 08 GNU:target_xfer_partial (2, (null), 0x837b814, 0x0, 0x101f924, 4) =3D = 4, bytes =3D d0 fa 01 01 convert_options (argp=3D0x813f0bc, parent=3D0x0, parent_index=3D0, grou= p=3D0x81712e8, cvt=3D0x101fad0) at argp.h:579 579 argp.h: No such file or directory. in argp.h (gdb) info threads target_thread_alive (25830) =3D 1 target_thread_alive (25830) =3D 1 target_thread_alive (25830) =3D 0 target_thread_alive (25830) =3D 0 target_thread_alive (25830) =3D 0 target_find_new_threads () target_fetch_registers (eip) =3D 8c5a0b08 0x80b5a8c 134961804 5 Thread 25830.5 0x080b5a8c in mach_msg_trap () target_fetch_registers (eip) =3D 79440b08 0x80b4479 134956153 target_fetch_registers (ebp) =3D 18f90101 0x101f918 16906520 GNU:target_xfer_partial (2, (null), 0x838142c, 0x0, 0x101f8ec, 4) =3D = 4, bytes =3D bc f0 13 08 GNU:target_xfer_partial (2, (null), 0x837db74, 0x0, 0x101f8e8, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (2, (null), 0x83815fc, 0x0, 0x101f8e4, 4) =3D = 4, bytes =3D 00 00 00 00 GNU:target_xfer_partial (2, (null), 0x83816bc, 0x0, 0x101f920, 4) =3D = 4, bytes =3D e8 12 17 08 GNU:target_xfer_partial (2, (null), 0x83a2074, 0x0, 0x101f924, 4) =3D = 4, bytes =3D d0 fa 01 01 * 4 Thread 25830.4 convert_options (argp=3D0x813f0bc, parent=3D0x0, pa= rent_index=3D0, group=3D0x81712e8, cvt=3D0x101fad0) at argp.h:579 ... as compared to plain GDB HEAD: (gdb) set debug infrun 1 (gdb) set debug target 1 (gdb) r Starting program: /media/data/home/tschwinge/tmp/n1/hurd/ext2fs.static= =20 target_wait (-1, status) =3D 25945, status->kind =3D stopped, signal = =3D SIGTRAP target_terminal_init () target_terminal_inferior () target_resume (-1, continue, 0) target_wait (-1, status) =3D 25945, status->kind =3D stopped, signal = =3D SIGTRAP target_terminal_ours () GNU:target_xfer_partial (9, target.xml, 0x843b360, 0x0, 0x0, 4095) = =3D -1 GNU:target_xfer_partial (5, (null), 0x843b360, 0x0, 0x0, 4096) =3D -1 GNU:target_xfer_partial (5, (null), 0x843b360, 0x0, 0x0, 4096) =3D -1 target_memory_map () GNU:target_xfer_partial (2, (null), 0x15ff570, 0x0, 0x816ff14, 4) =3D= 4, bytes =3D 00 00 00 00 target_terminal_ours () Can't fetch registers from thread bogus thread id 1: No such thread Thanks for your help! Regards, Thomas --lrvsYIebpInmECXG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline Content-length: 191 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFI8OGzgfzh735dTTURAkvtAKDJjQwBXZCQ3F2FJySnFeZM50owowCfTQlZ +NqmWsePl/p7cZP2DnJRMqo= =UnIU -----END PGP SIGNATURE----- --lrvsYIebpInmECXG--