[binutils-gdb] Also compare frame_id_is_next in frapy_richcompare

Hannes Domani ssbssa@sourceware.org
Sun Feb 7 18:16:34 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=83962f8340726373e0d174dcf688818eb7faea6b

commit 83962f8340726373e0d174dcf688818eb7faea6b
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Fri Dec 18 18:23:41 2020 +0100

    Also compare frame_id_is_next in frapy_richcompare
    
    The last frame in a corrupt stack stores the frame_id of the next frame,
    so these two frames currently compare as equal.
    
    So if you have a backtrace where the oldest frame is corrupt, this happens:
    
    (gdb) py
     >f = gdb.selected_frame()
     >while f.older():
     >  f = f.older()
     >print(f == f.newer())
     >end
    True
    
    With this change, that same example returns False.
    
    gdb/ChangeLog:
    
    2021-02-07  Hannes Domani  <ssbssa@yahoo.de>
    
            * python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.

Diff:
---
 gdb/ChangeLog         | 4 ++++
 gdb/python/py-frame.c | 7 +++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 78cd0590e51..9e66fad0802 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2021-02-07  Hannes Domani  <ssbssa@yahoo.de>
+
+	* python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.
+
 2021-02-05  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* symmisc.c (std_in, std_out, std_err): Remove.
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 5c027547825..8e32ba55de4 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -658,8 +658,11 @@ frapy_richcompare (PyObject *self, PyObject *other, int op)
       return Py_NotImplemented;
     }
 
-  if (frame_id_eq (((frame_object *) self)->frame_id,
-		   ((frame_object *) other)->frame_id))
+  frame_object *self_frame = (frame_object *) self;
+  frame_object *other_frame = (frame_object *) other;
+
+  if (self_frame->frame_id_is_next == other_frame->frame_id_is_next
+      && frame_id_eq (self_frame->frame_id, other_frame->frame_id))
     result = Py_EQ;
   else
     result = Py_NE;


More information about the Gdb-cvs mailing list