From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30540 invoked by alias); 2 Mar 2010 00:25:57 -0000 Received: (qmail 30515 invoked by uid 22791); 2 Mar 2010 00:25:54 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Mar 2010 00:25:50 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o220PnjI032573 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 1 Mar 2010 19:25:49 -0500 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o220PmnY023887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Mon, 1 Mar 2010 19:25:48 -0500 Date: Tue, 02 Mar 2010 00:25:00 -0000 From: Kevin Buettner To: gdb-patches@sourceware.org Subject: [RFC] remote-mips.c: Fix bit rot associated with the inferior's state Message-ID: <20100301172548.1672f69e@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00037.txt.bz2 The patch below updates remote-mips.c so inferior_ptid is set after successfully connecting to a target board. A suitable inferior and thread are also created at that time. I was surprised to find that I also needed to fiddle with the inferior's aspace and pspace. Calls to target_mourn_inferior() have also been added. Using this patch in conjunction with some other soon-to-be-submitted patches allows me to connect to a board and debug a program on the board. Comments? * remote-mips.c (gdbthread.h): Include. (magic_null_ptid): Declare. (common_open): Set inferior_ptid, add it as an inferior, and as a thread too. Set up the inferior's address spaces. (mips_kill): Make sure that target_mourn_inferior is invoked. (mips_load): Don't null out inferior_ptid. (_initialize_remote_mips): Initialize magic_null_ptid. Index: remote-mips.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/remote-mips.c,v retrieving revision 1.108 diff -u -p -r1.108 remote-mips.c --- remote-mips.c 26 Feb 2010 23:11:24 -0000 1.108 +++ remote-mips.c 2 Mar 2010 00:17:56 -0000 @@ -35,6 +35,7 @@ #include "regcache.h" #include #include "mips-tdep.h" +#include "gdbthread.h" =0C =20 /* Breakpoint types. Values 0, 1, and 2 must agree with the watch @@ -1457,6 +1458,8 @@ mips_initialize (void) mips_request ('r', 0, 0, &err, mips_receive_wait, NULL); } =20 +static ptid_t magic_null_ptid; + /* Open a connection to the remote board. */ static void common_open (struct target_ops *ops, char *name, int from_tty, @@ -1468,6 +1471,7 @@ common_open (struct target_ops *ops, cha char *remote_name =3D 0; char *local_name =3D 0; char **argv; + struct inferior *inf; =20 if (name =3D=3D 0) error ( @@ -1563,6 +1567,12 @@ device is attached to the target board ( /* Switch to using remote target now. */ push_target (ops); =20 + inferior_ptid =3D magic_null_ptid; + inf =3D add_inferior_silent (ptid_get_pid (inferior_ptid)); + inf->aspace =3D current_program_space->aspace; + inf->pspace =3D current_program_space; + add_thread_silent (inferior_ptid); + /* FIXME: Should we call start_remote here? */ =20 /* Try to figure out the processor model if possible. */ @@ -2140,7 +2150,10 @@ static void mips_kill (struct target_ops *ops) { if (!mips_wait_flag) - return; + { + target_mourn_inferior (); + return; + } =20 interrupt_count++; =20 @@ -2173,6 +2186,8 @@ Give up (and stop debugging it)? "))) =20 serial_send_break (mips_desc); =20 + target_mourn_inferior (); + #if 0 if (mips_is_open) { @@ -3297,8 +3312,6 @@ mips_load (char *file, int from_tty) if (exec_bfd) regcache_write_pc (regcache, bfd_get_start_address (exec_bfd)); =20 - inferior_ptid =3D null_ptid; /* No process now */ - /* This is necessary because many things were based on the PC at the time = that we attached to the monitor, which is no longer valid now that we have l= oaded new code (and just changed the PC). Another way to do this might be to= call @@ -3458,4 +3471,5 @@ Use \"on\" to enable the masking and \"o NULL, NULL, /* FIXME: i18n: */ &setlist, &showlist); + magic_null_ptid =3D ptid_build (42000, 1, -1); }