Skip to content

Conversation

@Jlalond
Copy link
Contributor

@Jlalond Jlalond commented Nov 18, 2025

I've been working on some scripts that evaluate the parent and child frame. It's been very annoying that the parent frame has a property but not the child. So I've added this to the extensions, I would've preferred to return None, but because the existing impl returns an invalid SBFrame, so I'm conforming to that API.

(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> lldb.frame
frame #0: 0x0000555555555200 fib.out`main
>>> lldb.frame.parent
frame #1: 0x00007ffff782a610 libc.so.6`__libc_start_call_main + 128
>>> lldb.frame.parent.child
frame #0: 0x0000555555555200 fib.out`main

@Jlalond Jlalond requested a review from ashgti November 18, 2025 22:35
@llvmbot llvmbot added the lldb label Nov 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2025

@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)

Changes

I've been working on some scripts that evaluate the parent and child frame. It's been very annoying that the parent frame has a property but not the child. So I've added this to the extensions, I would've preferred to return None, but because the existing impl returns an invalid SBFrame, so I'm conforming to that API.

(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> lldb.frame
frame #<!-- -->0: 0x0000555555555200 fib.out`main
&gt;&gt;&gt; lldb.frame.parent
frame #<!-- -->1: 0x00007ffff782a610 libc.so.6`__libc_start_call_main + 128
&gt;&gt;&gt; lldb.frame.parent.child
frame #<!-- -->0: 0x0000555555555200 fib.out`main

Full diff: https://github.com/llvm/llvm-project/pull/168619.diff

1 Files Affected:

  • (modified) lldb/bindings/interface/SBFrameExtensions.i (+8)
diff --git a/lldb/bindings/interface/SBFrameExtensions.i b/lldb/bindings/interface/SBFrameExtensions.i
index 38d03abaee8f0..0c79b98b290f2 100644
--- a/lldb/bindings/interface/SBFrameExtensions.i
+++ b/lldb/bindings/interface/SBFrameExtensions.i
@@ -24,6 +24,13 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
             else:
                 return SBFrame()
 
+        def get_child_frame(self):
+            child_idx = self.idx - 1
+            if child_idx >= 0:
+                return self.thread.frame[child_idx]
+            else:
+                return SBFrame()
+
         def get_arguments(self):
             return self.GetVariables(True,False,False,False)
 
@@ -92,6 +99,7 @@ STRING_EXTENSION_OUTSIDE(SBFrame)
         register = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame.''')
         reg = property(get_registers_access, None, doc='''A read only property that returns an helper object providing a flattened indexable view of the CPU registers for this stack frame''')
         parent = property(get_parent_frame, None, doc='''A read only property that returns the parent (caller) frame of the current frame.''')
+        child = property(get_child_frame, None, doc='''A read only property that returns the child (callee) frame of the current frame.''')
     %}
 #endif
 }

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

🐧 Linux x64 Test Results

  • 33162 tests passed
  • 495 tests skipped

Copy link
Collaborator

@jimingham jimingham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Apparently we don't test that these property affordances at all, so far as I can see. We really should do that, but given nobody else has it seems unfair to require it for this patch...

@Jlalond
Copy link
Contributor Author

Jlalond commented Nov 20, 2025

LGTM. Apparently we don't test that these property affordances at all, so far as I can see. We really should do that, but given nobody else has it seems unfair to require it for this patch...

Opened an issue #168920, end of the year will be very busy for me personally but I will also look into adding more tests in the future!

@Jlalond Jlalond enabled auto-merge (squash) November 20, 2025 17:59
@Jlalond Jlalond merged commit 62deee4 into llvm:main Nov 20, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants