From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1377 invoked by alias); 21 Jun 2012 01:54:07 -0000 Received: (qmail 1360 invoked by uid 22791); 21 Jun 2012 01:54:05 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_CP X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 21 Jun 2012 01:53:52 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1ShWak-000392-F5 from Yao_Qi@mentor.com ; Wed, 20 Jun 2012 18:53:50 -0700 Received: from SVR-ORW-FEM-05.mgc.mentorg.com ([147.34.97.43]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 20 Jun 2012 18:53:09 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.1.289.1; Wed, 20 Jun 2012 18:53:49 -0700 From: Yao Qi To: CC: Joel Brobecker Subject: Re: [PATCH/python] notify memory changed. Date: Thu, 21 Jun 2012 01:54:00 -0000 Message-ID: <1375760.Ghu1pfDITS@qiyao.dyndns.org> User-Agent: KMail/4.8.3 (Linux/3.3.7-1.fc16.i686; KDE/4.8.3; i686; ; ) In-Reply-To: <20120620145222.GC2799@adacore.com> References: <1340075728-24870-1-git-send-email-yao@codesourcery.com> <12411572.tk6EVZMAgM@qiyao.dyndns.org> <20120620145222.GC2799@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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: 2012-06/txt/msg00649.txt.bz2 On Wednesday 20 June 2012 07:52:22 Joel Brobecker wrote: > Perhaps, for later, we might want to have a look at having two routines, > one "silent", and one that notifies the observers, a little bit like > the routine we have for adding new threads, for instance. Agreed. Here is a new one. --=20 Yao (=E9=BD=90=E5=B0=A7) 2012-06-21 Yao Qi * corefile.c (write_memory_with_notification): New. Include "observer.h". * gdbcore.h: Declare write_memory_with_notification. * ada-lang.c (ada_value_assign): Replace 'write_memory' and 'observer_notify_memory_changed' with 'write_memory_with_notification'. * valops.c (value_assign): Likewise. * python/py-inferior.c (infpy_write_memory): Call 'write_memory_with_notification'. --- gdb/ada-lang.c | 3 +-- gdb/corefile.c | 11 +++++++++++ gdb/gdbcore.h | 6 ++++++ gdb/python/py-inferior.c | 2 +- gdb/valops.c | 4 +--- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6f65472..7afcef8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2534,8 +2534,7 @@ ada_value_assign (struct value *toval, struct value=20 *fromval) else move_bits (buffer, value_bitpos (toval), value_contents (fromval), 0, bits, 0); - write_memory (to_addr, buffer, len); - observer_notify_memory_changed (to_addr, len, buffer); + write_memory_with_notification (to_addr, buffer, len); =20 val =3D value_copy (toval); memcpy (value_contents_raw (val), value_contents (fromval), diff --git a/gdb/corefile.c b/gdb/corefile.c index 611cd62..ac8eff5 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -34,6 +34,7 @@ #include "gdb_stat.h" #include "completer.h" #include "exceptions.h" +#include "observer.h" =20 /* Local function declarations. */ =20 @@ -361,6 +362,16 @@ write_memory (CORE_ADDR memaddr, memory_error (status, memaddr); } =20 +/* Same as write_memory, but notify 'memory_changed' observers. */ + +void +write_memory_with_notification (CORE_ADDR memaddr, const bfd_byte *myaddr, + ssize_t len) +{ + write_memory (memaddr, myaddr, len); + observer_notify_memory_changed (memaddr, len, myaddr); +} + /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */ void diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h index 1081f3f..d6c9de2 100644 --- a/gdb/gdbcore.h +++ b/gdb/gdbcore.h @@ -86,6 +86,12 @@ CORE_ADDR read_memory_typed_address (CORE_ADDR addr, str= uct=20 type *type); extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len); =20 +/* Same as write_memory, but notify 'memory_changed' observers. */ + +extern void write_memory_with_notification (CORE_ADDR memaddr, + const bfd_byte *myaddr, + ssize_t len); + /* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */ extern void write_memory_unsigned_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order, diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 0ea4f55..aa41073 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -493,7 +493,7 @@ infpy_write_memory (PyObject *self, PyObject *args,=20 PyObject *kw) error =3D 1; break; } - write_memory (addr, buffer, length); + write_memory_with_notification (addr, buffer, length); } GDB_PY_HANDLE_EXCEPTION (except); =20 diff --git a/gdb/valops.c b/gdb/valops.c index 5002272..97d889b 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1299,9 +1299,7 @@ value_assign (struct value *toval, struct value=20 *fromval) dest_buffer =3D value_contents (fromval); } =20 - write_memory (changed_addr, dest_buffer, changed_len); - observer_notify_memory_changed (changed_addr, changed_len, - dest_buffer); + write_memory_with_notification (changed_addr, dest_buffer, changed_len); } break; =20 --=20 1.7.7.6