* [python] Fix infpy_read_memory cleanups handling
@ 2009-08-02 2:34 Jan Kratochvil
2009-08-03 17:31 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2009-08-02 2:34 UTC (permalink / raw)
To: archer
[ Not checked-in for archer-tromey-python. ]
commit 1d39c91be21ffe7295fb63aceb18b11bc2f341c7
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
Date: Sun Aug 2 04:28:50 2009 +0200
Fix infpy_read_memory cleanups handling.
It was crashing gdb.python/python-value.exp during a Fedora merge.
* python/python-inferior.c (infpy_read_memory): No longer initialize
cleanups to NULL, initialize it by null_cleanup later. Do not
reinitialize null_cleanup by xfree make_cleanup. Call do_cleanups on
any error exit path.
diff --git a/gdb/python/python-inferior.c b/gdb/python/python-inferior.c
index fc36550..5e90cc2 100644
--- a/gdb/python/python-inferior.c
+++ b/gdb/python/python-inferior.c
@@ -378,12 +378,14 @@ infpy_read_memory (PyObject *self, PyObject *args)
void *buffer = NULL;
membuf_object *membuf_obj;
PyObject *addr_obj, *length_obj;
- struct cleanup *cleanups = NULL;
+ struct cleanup *cleanups;
volatile struct gdb_exception except;
if (! PyArg_ParseTuple (args, "OO", &addr_obj, &length_obj))
return NULL;
+ cleanups = make_cleanup (null_cleanup, NULL);
+
TRY_CATCH (except, RETURN_MASK_ALL)
{
if (!get_addr_from_python (addr_obj, &addr)
@@ -394,26 +396,29 @@ infpy_read_memory (PyObject *self, PyObject *args)
}
buffer = xmalloc (length);
- cleanups = make_cleanup (xfree, buffer);
+ make_cleanup (xfree, buffer);
read_memory (addr, buffer, length);
}
GDB_PY_HANDLE_EXCEPTION (except);
if (error)
- return NULL;
-
- discard_cleanups (cleanups);
+ {
+ do_cleanups (cleanups);
+ return NULL;
+ }
membuf_obj = PyObject_New (membuf_object, &membuf_object_type);
if (membuf_obj == NULL)
{
- xfree (buffer);
PyErr_SetString (PyExc_MemoryError,
"Could not allocate memory buffer object.");
+ do_cleanups (cleanups);
return NULL;
}
+ discard_cleanups (cleanups);
+
membuf_obj->buffer = buffer;
membuf_obj->addr = addr;
membuf_obj->length = length;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [python] Fix infpy_read_memory cleanups handling
2009-08-02 2:34 [python] Fix infpy_read_memory cleanups handling Jan Kratochvil
@ 2009-08-03 17:31 ` Tom Tromey
2009-08-03 17:34 ` Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2009-08-03 17:31 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: archer
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> [ Not checked-in for archer-tromey-python. ]
Jan> It was crashing gdb.python/python-value.exp during a Fedora merge.
Jan> * python/python-inferior.c (infpy_read_memory): No longer initialize
Jan> cleanups to NULL, initialize it by null_cleanup later. Do not
Jan> reinitialize null_cleanup by xfree make_cleanup. Call do_cleanups on
Jan> any error exit path.
Looks good, please push it to archer-tromey-python.
Thanks.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [python] Fix infpy_read_memory cleanups handling
2009-08-03 17:31 ` Tom Tromey
@ 2009-08-03 17:34 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2009-08-03 17:34 UTC (permalink / raw)
To: Tom Tromey; +Cc: archer
On Mon, 03 Aug 2009 19:31:01 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> It was crashing gdb.python/python-value.exp during a Fedora merge.
>
> Jan> * python/python-inferior.c (infpy_read_memory): No longer initialize
> Jan> cleanups to NULL, initialize it by null_cleanup later. Do not
> Jan> reinitialize null_cleanup by xfree make_cleanup. Call do_cleanups on
> Jan> any error exit path.
>
> Looks good, please push it to archer-tromey-python.
> Thanks.
Cherry-picked-in as: 74200760800432ef70cb3a703f764ac628247a2d
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-03 17:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-02 2:34 [python] Fix infpy_read_memory cleanups handling Jan Kratochvil
2009-08-03 17:31 ` Tom Tromey
2009-08-03 17:34 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).