* [2/5] RFC: fix py-finishbreakpoint bug
@ 2013-02-07 21:00 Tom Tromey
2013-02-28 19:21 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2013-02-07 21:00 UTC (permalink / raw)
To: gdb-patches
The exception checker pointed out that we called
frame_object_to_frame_info in the Python code outside of a TRY_CATCH.
Also, the code seemed somewhat convoluted in that it called
gdbpy_newest_frame rather than directly calling get_current_frame.
This patch rearranges the code to be correct.
Tom
* py-finishbreakpoint.c (bpfinishpy_init): Reorganize to call
frame_object_to_frame_info inside TRY_CATCH.
---
gdb/python/py-finishbreakpoint.c | 70 +++++++++++++++++++-------------------
1 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 5685308..edf75d7 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -173,40 +173,45 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
&frame_obj, &internal))
return -1;
- /* Default frame to gdb.newest_frame if necessary. */
- if (!frame_obj)
- frame_obj = gdbpy_newest_frame (NULL, NULL);
- else
- Py_INCREF (frame_obj);
-
- frame = frame_object_to_frame_info (frame_obj);
- Py_DECREF (frame_obj);
-
- if (frame == NULL)
- goto invalid_frame;
-
TRY_CATCH (except, RETURN_MASK_ALL)
{
- prev_frame = get_prev_frame (frame);
- if (prev_frame == 0)
- {
- PyErr_SetString (PyExc_ValueError, _("\"FinishBreakpoint\" not " \
- "meaningful in the outermost "\
- "frame."));
- }
- else if (get_frame_type (prev_frame) == DUMMY_FRAME)
- {
- PyErr_SetString (PyExc_ValueError, _("\"FinishBreakpoint\" cannot "\
- "be set on a dummy frame."));
- }
+ /* Default frame to newest frame if necessary. */
+ if (frame_obj == NULL)
+ frame = get_current_frame ();
else
- {
- frame_id = get_frame_id (prev_frame);
- if (frame_id_eq (frame_id, null_frame_id))
- PyErr_SetString (PyExc_ValueError,
- _("Invalid ID for the `frame' object."));
- }
+ frame = frame_object_to_frame_info (frame_obj);
+
+ if (frame == NULL)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("Invalid ID for the `frame' object."));
+ }
+ else
+ {
+ prev_frame = get_prev_frame (frame);
+ if (prev_frame == 0)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("\"FinishBreakpoint\" not "
+ "meaningful in the outermost "
+ "frame."));
+ }
+ else if (get_frame_type (prev_frame) == DUMMY_FRAME)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("\"FinishBreakpoint\" cannot "
+ "be set on a dummy frame."));
+ }
+ else
+ {
+ frame_id = get_frame_id (prev_frame);
+ if (frame_id_eq (frame_id, null_frame_id))
+ PyErr_SetString (PyExc_ValueError,
+ _("Invalid ID for the `frame' object."));
+ }
+ }
}
+ Py_XDECREF (frame_obj);
if (except.reason < 0)
{
gdbpy_convert_exception (except);
@@ -305,11 +310,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
self_bpfinish->py_bp.bp->pspace = current_program_space;
return 0;
-
- invalid_frame:
- PyErr_SetString (PyExc_ValueError,
- _("Invalid ID for the `frame' object."));
- return -1;
}
/* Called when GDB notices that the finish breakpoint BP_OBJ is out of
--
1.7.7.6
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [2/5] RFC: fix py-finishbreakpoint bug
2013-02-07 21:00 [2/5] RFC: fix py-finishbreakpoint bug Tom Tromey
@ 2013-02-28 19:21 ` Tom Tromey
2013-02-28 19:24 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2013-02-28 19:21 UTC (permalink / raw)
To: gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> The exception checker pointed out that we called
Tom> frame_object_to_frame_info in the Python code outside of a TRY_CATCH.
Tom> Also, the code seemed somewhat convoluted in that it called
Tom> gdbpy_newest_frame rather than directly calling get_current_frame.
Tom> This patch rearranges the code to be correct.
Tom> * py-finishbreakpoint.c (bpfinishpy_init): Reorganize to call
Tom> frame_object_to_frame_info inside TRY_CATCH.
I'm checking this in now.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [2/5] RFC: fix py-finishbreakpoint bug
2013-02-28 19:21 ` Tom Tromey
@ 2013-02-28 19:24 ` Tom Tromey
0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2013-02-28 19:24 UTC (permalink / raw)
To: gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:
Tom> I'm checking this in now.
Pre-commit testing showed a bug.
I'm checking in this patch instead.
Tom
* py-finishbreakpoint.c (bpfinishpy_init): Reorganize to call
frame_object_to_frame_info inside TRY_CATCH.
---
gdb/python/py-finishbreakpoint.c | 69 ++++++++++++++++++-------------------
1 files changed, 34 insertions(+), 35 deletions(-)
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 5685308..d3d6bfd 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -173,39 +173,43 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
&frame_obj, &internal))
return -1;
- /* Default frame to gdb.newest_frame if necessary. */
- if (!frame_obj)
- frame_obj = gdbpy_newest_frame (NULL, NULL);
- else
- Py_INCREF (frame_obj);
-
- frame = frame_object_to_frame_info (frame_obj);
- Py_DECREF (frame_obj);
-
- if (frame == NULL)
- goto invalid_frame;
-
TRY_CATCH (except, RETURN_MASK_ALL)
{
- prev_frame = get_prev_frame (frame);
- if (prev_frame == 0)
- {
- PyErr_SetString (PyExc_ValueError, _("\"FinishBreakpoint\" not " \
- "meaningful in the outermost "\
- "frame."));
- }
- else if (get_frame_type (prev_frame) == DUMMY_FRAME)
- {
- PyErr_SetString (PyExc_ValueError, _("\"FinishBreakpoint\" cannot "\
- "be set on a dummy frame."));
- }
+ /* Default frame to newest frame if necessary. */
+ if (frame_obj == NULL)
+ frame = get_current_frame ();
else
- {
- frame_id = get_frame_id (prev_frame);
- if (frame_id_eq (frame_id, null_frame_id))
- PyErr_SetString (PyExc_ValueError,
- _("Invalid ID for the `frame' object."));
- }
+ frame = frame_object_to_frame_info (frame_obj);
+
+ if (frame == NULL)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("Invalid ID for the `frame' object."));
+ }
+ else
+ {
+ prev_frame = get_prev_frame (frame);
+ if (prev_frame == 0)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("\"FinishBreakpoint\" not "
+ "meaningful in the outermost "
+ "frame."));
+ }
+ else if (get_frame_type (prev_frame) == DUMMY_FRAME)
+ {
+ PyErr_SetString (PyExc_ValueError,
+ _("\"FinishBreakpoint\" cannot "
+ "be set on a dummy frame."));
+ }
+ else
+ {
+ frame_id = get_frame_id (prev_frame);
+ if (frame_id_eq (frame_id, null_frame_id))
+ PyErr_SetString (PyExc_ValueError,
+ _("Invalid ID for the `frame' object."));
+ }
+ }
}
if (except.reason < 0)
{
@@ -305,11 +309,6 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
self_bpfinish->py_bp.bp->pspace = current_program_space;
return 0;
-
- invalid_frame:
- PyErr_SetString (PyExc_ValueError,
- _("Invalid ID for the `frame' object."));
- return -1;
}
/* Called when GDB notices that the finish breakpoint BP_OBJ is out of
--
1.7.7.6
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-28 19:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-07 21:00 [2/5] RFC: fix py-finishbreakpoint bug Tom Tromey
2013-02-28 19:21 ` Tom Tromey
2013-02-28 19:24 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox