From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KpnzP-0001iv-0r for qemu-devel@nongnu.org; Tue, 14 Oct 2008 13:47:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KpnzN-0001hM-FX for qemu-devel@nongnu.org; Tue, 14 Oct 2008 13:47:22 -0400 Received: from [199.232.76.173] (port=42497 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KpnzN-0001gq-9d for qemu-devel@nongnu.org; Tue, 14 Oct 2008 13:47:21 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:47424) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KpnzM-0007dC-3X for qemu-devel@nongnu.org; Tue, 14 Oct 2008 13:47:20 -0400 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id EB356F61D7A9 for ; Tue, 14 Oct 2008 19:45:27 +0200 (CEST) Received: from [88.64.28.10] (helo=[192.168.1.198]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1KpnxX-0006eh-00 for qemu-devel@nongnu.org; Tue, 14 Oct 2008 19:45:27 +0200 Message-ID: <48F4DAB1.4020308@web.de> Date: Tue, 14 Oct 2008 19:45:21 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20081014091223.932366369@mchn012c.ww002.siemens.net> <20081014091224.774875732@mchn012c.ww002.siemens.net> <5d6222a80810141024x1077066ek851f96a815c0cbe4@mail.gmail.com> In-Reply-To: <5d6222a80810141024x1077066ek851f96a815c0cbe4@mail.gmail.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC8972392F2AF58CE687116B0" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH 02/13] Refactor and enhance break/watchpoint API Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC8972392F2AF58CE687116B0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Glauber Costa wrote: >> Index: b/exec.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 >> --- a/exec.c >> +++ b/exec.c >> @@ -537,7 +537,6 @@ void cpu_exec_init(CPUState *env) >> cpu_index++; >> } >> env->cpu_index =3D cpu_index; >> - env->nb_watchpoints =3D 0; >> *penv =3D env; >> #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) >> register_savevm("cpu_common", cpu_index, CPU_COMMON_SAVE_VERSION, >> @@ -1311,107 +1310,150 @@ static void breakpoint_invalidate(CPUSta >> #endif >> >> /* Add a watchpoint. */ >> -int cpu_watchpoint_insert(CPUState *env, target_ulong addr, int type)= >> +int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ul= ong len, >> + int flags, CPUWatchpoint **watchpoint) >> { >> - int i; >> + CPUWatchpoint *wp; >> >> - for (i =3D 0; i < env->nb_watchpoints; i++) { >> - if (addr =3D=3D env->watchpoint[i].vaddr) >> - return 0; >> - } >> - if (env->nb_watchpoints >=3D MAX_WATCHPOINTS) >> - return -1; >> + wp =3D qemu_malloc(sizeof(*wp)); >> + if (!wp) >> + return -ENOBUFS; >> + >> + wp->vaddr =3D addr; >> + wp->len =3D len; >> + wp->flags =3D flags; >> + >> + wp->next =3D env->watchpoints; >> + wp->prev =3D NULL; >> + if (wp->next) >> + wp->next->prev =3D wp; >> + env->watchpoints =3D wp; >> >> - i =3D env->nb_watchpoints++; >> - env->watchpoint[i].vaddr =3D addr; >> - env->watchpoint[i].type =3D type; >> tlb_flush_page(env, addr); >> /* FIXME: This flush is needed because of the hack to make memory = ops >> terminate the TB. It can be removed once the proper IO trap an= d >> re-execute bits are in. */ >> tb_flush(env); >=20 >> Index: b/cpu-defs.h >> +typedef struct CPUBreakpoint { >> + target_ulong pc; >> + int flags; /* BP_* */ >> + struct CPUBreakpoint *prev, *next; >> +} CPUBreakpoint; >> + >> +typedef struct CPUWatchpoint { >> + target_ulong vaddr; >> + target_ulong len; >> + int flags; /* BP_* */ >> + struct CPUWatchpoint *prev, *next; >> +} CPUWatchpoint; >> + >=20 > Most of the time, you are transversing the list in a single direction. > So any particular reason to use a double linked list? When looking as this patch only, one may get along with a singly-linked list. But patch 13 adds a use case where the back-reference pays off. > By the way, /me thinks it is about time for us to have a generic > linked list implementation Probably - but $SOMEONE will have to do the time-consuming conversion work to make QEMU really benefit from this... Jan --------------enigC8972392F2AF58CE687116B0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkj02rUACgkQniDOoMHTA+n3cwCdGNNkou8mNl2lDzwNaYSVbfOx zqgAn07aFu/8QOcysn07YI04fgDdKo+B =vtUw -----END PGP SIGNATURE----- --------------enigC8972392F2AF58CE687116B0--