[Lldb-commits] [PATCH] D50478: WIP: Basic tail call frame support
Vedant Kumar via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 8 14:14:27 PDT 2018
vsk created this revision.
Herald added a subscriber: JDevlieghere.
This is a prototype of tail call frame support for lldb based on
compiler support from https://reviews.llvm.org/D49887. It isn't ready for review. I'm sharing the
proof-of-concept to give a heads-up about this coming down the pipeline,
and/or to answer any early questions.
Demo (see the included tail5.cc test case):
+ /Users/vsk/src/builds/llvm-project-tailcall-RA/bin//clang++ tail5.cc -o tail5.cc.out -g -mllvm -callsite-debuginfo-experimental=true -O2
+ xcrun lldb -o 'b sink' -o r -o bt -o quit tail5.cc.out
(lldb) target create "tail5.cc.out"
Current executable set to 'tail5.cc.out' (x86_64).
(lldb) b sink
Breakpoint 1: where = tail5.cc.out`sink() + 4 at tail5.cc:2, address = 0x0000000100000f64
(lldb) r
tail5.cc.out was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 21540 stopped
- thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000f64 tail5.cc.out`sink() at tail5.cc:2 [opt] 1 volatile int x;
-> 2 void __attribute__((noinline)) sink() { x++; }
3 void __attribute__((noinline)) D() { sink(); /* tail */ }
4 void __attribute__((disable_tail_calls, noinline)) C() { D(); /* regular */ }
5 void __attribute__((noinline)) B() { C(); /* tail */ }
6 int __attribute__((disable_tail_calls)) main() { B(); /* regular */ }
Target 0: (tail5.cc.out) stopped.
Process 21540 launched: '/Users/vsk/src/llvm-project-tailcall/lldb/test/testcases/functionalities/tail_call_frames/tail5.cc.out' (x86_64)
(lldb) bt
- thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
- frame #0: 0x0000000100000f64 tail5.cc.out`sink() at tail5.cc:2 [opt] frame #1: 0x0000000100000f89 tail5.cc.out`C() at tail5.cc:4 [opt] frame #2: 0x0000000100000fa9 tail5.cc.out`main at tail5.cc:6 [opt] frame #3: 0x00007fff57147015 libdyld.dylib`start + 1 frame #4: 0x00007fff57147015 libdyld.dylib`start + 1
(lldb) quit
+ /Users/vsk/src/builds/llvm-project-tailcall-RA/bin//lldb -o 'b sink' -o r -o 'log enable -f tail5.cc.log lldb step' -o bt -o quit tail5.cc.out
(lldb) target create "tail5.cc.out"
Current executable set to 'tail5.cc.out' (x86_64).
(lldb) b sink
Breakpoint 1: where = tail5.cc.out`sink() + 4 at tail5.cc:2, address = 0x0000000100000f64
(lldb) r
tail5.cc.out was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 21544 stopped
- thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000f64 tail5.cc.out`sink() at tail5.cc:2 [opt] 1 volatile int x;
-> 2 void __attribute__((noinline)) sink() { x++; }
3 void __attribute__((noinline)) D() { sink(); /* tail */ }
4 void __attribute__((disable_tail_calls, noinline)) C() { D(); /* regular */ }
5 void __attribute__((noinline)) B() { C(); /* tail */ }
6 int __attribute__((disable_tail_calls)) main() { B(); /* regular */ }
Process 21544 launched: '/Users/vsk/src/llvm-project-tailcall/lldb/test/testcases/functionalities/tail_call_frames/tail5.cc.out' (x86_64)
(lldb) log enable -f tail5.cc.log lldb step
(lldb) bt
- thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
- frame #0: 0x0000000100000f64 tail5.cc.out`sink() at tail5.cc:2 [opt] frame #1: 0x0000000000000010 tail5.cc.out`D() - 4294971232 [opt] frame #2: 0x0000000100000f89 tail5.cc.out`C() at tail5.cc:4 [opt] frame #3: 0x0000000000000030 tail5.cc.out`B() - 4294971232 [opt] frame #4: 0x0000000100000fa9 tail5.cc.out`main at tail5.cc:6 [opt] frame #5: 0x00007fff57147015 libdyld.dylib`start + 1 frame #6: 0x00007fff57147015 libdyld.dylib`start + 1
https://reviews.llvm.org/D50478
Files:
lldb/include/lldb/Symbol/Block.h
lldb/include/lldb/Symbol/Function.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Target/StackFrame.h
lldb/include/lldb/Target/StackFrameList.h
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/tail.cc
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/tail2.cc
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/tail3.cc
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/tail4.cc
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/tail5.cc
lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/test.sh
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Symbol/Block.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Target/StackFrameList.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50478.159790.patch
Type: text/x-patch
Size: 21698 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180808/18a0c38a/attachment-0001.bin>
More information about the lldb-commits
mailing list