From: "Abid, Hafiz" <Hafiz_Abid@mentor.com>
To: "Qi, Yao" <Yao_Qi@mentor.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: RE: [PATCH/python] notify memory changed.
Date: Thu, 21 Jun 2012 08:52:00 -0000 [thread overview]
Message-ID: <EB3B29AD43CA924DA27099BC8519237629A526@EU-MBX-03.mgc.mentorg.com> (raw)
In-Reply-To: <1375760.Ghu1pfDITS@qiyao.dyndns.org>
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Qi, Yao
> Sent: Thursday, June 21, 2012 2:54 AM
> To: gdb-patches@sourceware.org
> Cc: Joel Brobecker
> Subject: Re: [PATCH/python] notify memory changed.
>
> 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.
>
> --
> Yao (齐尧)
>
>
> 2012-06-21 Yao Qi <yao@codesourcery.com>
>
> * 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
> *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);
>
> val = 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"
>
> /* Local function declarations. */
>
> @@ -361,6 +362,16 @@ write_memory (CORE_ADDR memaddr,
> memory_error (status, memaddr);
> }
>
> +/* 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);
> +}
> +
Do you think it will be useful to have parameters of observer_notify_memory_changed in same order as write_memory. When I looked at this code, I had to look at the function to make sure it was not a typo.
> /* 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,
> struct
> type *type);
> extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr,
> ssize_t len);
>
> +/* 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,
> PyObject *kw)
> error = 1;
> break;
> }
> - write_memory (addr, buffer, length);
> + write_memory_with_notification (addr, buffer, length);
> }
> GDB_PY_HANDLE_EXCEPTION (except);
>
> 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
> *fromval)
> dest_buffer = value_contents (fromval);
> }
>
> - 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;
>
> --
> 1.7.7.6
>
next prev parent reply other threads:[~2012-06-21 8:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 3:16 Yao Qi
2012-06-19 15:14 ` Joel Brobecker
2012-06-20 3:46 ` Yao Qi
2012-06-20 14:52 ` Joel Brobecker
2012-06-21 1:54 ` Yao Qi
2012-06-21 8:52 ` Abid, Hafiz [this message]
[not found] ` <2883062.LPF6KAsNoT@qiyao.dyndns.org>
2012-06-22 14:36 ` Tom Tromey
2012-06-22 14:35 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=EB3B29AD43CA924DA27099BC8519237629A526@EU-MBX-03.mgc.mentorg.com \
--to=hafiz_abid@mentor.com \
--cc=Yao_Qi@mentor.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox