GDBThread.st
changeset 130 3aa56be1d6f7
parent 111 7ce18f6f18ac
child 136 213e436320fe
--- a/GDBThread.st	Mon Jul 30 07:24:57 2018 +0100
+++ b/GDBThread.st	Tue Aug 07 09:28:55 2018 +0100
@@ -114,7 +114,6 @@
                 "/ just replace the 'new' frame with the 'old'.
                 newFrame addr = oldFrame addr ifTrue:[ 
                     "/ OK, the two frames are really the same thing
-                    oldFrame setLevel: newFrame level.
                     oldFrame setLevel: newFrame level. "/ Update level
                     new at: newFrameIndex put: (old at: oldFrameIndex).
                     newFrameIndex := newFrameIndex - 1.
@@ -122,22 +121,34 @@
                 ] ifFalse:[ 
                     "/ No, frame pc differs. This is the first time they differ so
                     "/ it could be the same frame just on different PC (since PC of
-                    "/ caller did not change). Check, if function names matches,
-                    "/ if so, update the frame and exit the loop. If not, just exit
-                    "/ the loop.
-                    oldFrame func = newFrame func ifTrue:[ 
-                        "/ Update the frame...
-                        oldFrame setAddr: newFrame addr.
-                        oldFrame setLine: newFrame line.
-                        oldFrame setLevel: newFrame level.
-                        new at: newFrameIndex put: (old at: oldFrameIndex).
-
-                        "/ Note, that we need to presetve the newFrameIndex value, it's
-                        "/ used below!!
-                        newFrameIndex := newFrameIndex - 1.
-                    ].
-                    "/ Terminate the loop, see the condition above.
-                    oldFrameIndex := 0. 
+                    "/ caller did not change). Subsequent frames could also be "same"
+                    "/ if they're inlined into caller - in this case, the PC (#addr) of
+                    "/ the caller frame and inlined callee are the same.
+                    "/ 
+                    "/ So, we update subsequent frames as long as 
+                    "/  a) function names are the same AND
+                    "/  b) PC is the same as PC of its caller
+                    "/
+                    "/ Complicated, isn't it?
+                    | oldAddr newAddr |
+                    oldAddr := oldFrame addr.
+                    newAddr := newFrame addr.
+                    [ newFrameIndex > 0 and:[ oldFrameIndex > 0 ] ] whileTrue:[
+                        newFrame := new at: newFrameIndex.
+                        oldFrame := old at: oldFrameIndex.    
+                        ("a)"oldFrame func = newFrame func and: ["b)"oldFrame addr = oldAddr and:[newFrame addr = newAddr]]) ifTrue:[ 
+                            "/ Update the frame...
+                            oldFrame setAddr: newFrame addr.
+                            oldFrame setLine: newFrame line.
+                            oldFrame setLevel: newFrame level.
+                            new at: newFrameIndex put: (old at: oldFrameIndex).
+                            newFrameIndex := newFrameIndex - 1.
+                            oldFrameIndex := oldFrameIndex - 1.    
+                        ] ifFalse:[
+                            "/ Terminate the loop, see the condition above.
+                            oldFrameIndex := 0. 
+                        ].
+                    ]
                 ].
             ].
             "/ For the remaining really new frames, set the debugger
@@ -154,8 +165,8 @@
     ^ stack value
 
     "Created: / 09-09-2014 / 00:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 15-02-2018 / 08:41:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-02-2018 / 23:19:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 06-08-2018 / 15:57:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 07-08-2018 / 08:44:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 status