Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for artificial tail call frames
This patch teaches lldb to detect when there are missing frames in a backtrace due to a sequence of tail calls, and to fill in the backtrace with artificial tail call frames when this happens. This is only done when the execution history can be determined from the call graph and from the return PC addresses of calls on the stack. Ambiguous sequences of tail calls (e.g anything involving tail calls and recursion) are detected and ignored. Depends on D49887. Differential Revision: https://reviews.llvm.org/D50478 llvm-svn: 343900
- Loading branch information
Showing
52 changed files
with
1,166 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
.../Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LEVEL = ../../../make | ||
CXX_SOURCES := main.cpp | ||
include $(LEVEL)/Makefile.rules | ||
CXXFLAGS += -g -O1 -glldb |
5 changes: 5 additions & 0 deletions
5
...st/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from lldbsuite.test import lldbinline | ||
from lldbsuite.test import decorators | ||
|
||
lldbinline.MakeInlineTest(__file__, globals(), | ||
[decorators.skipUnlessHasCallSiteInfo]) |
33 changes: 33 additions & 0 deletions
33
.../Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/main.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===-- main.cpp ------------------------------------------------*- C++ -*-===// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
volatile int x; | ||
|
||
void __attribute__((noinline)) sink() { | ||
x++; //% self.filecheck("bt", "main.cpp") | ||
// CHECK-NOT: func{{[23]}}_amb | ||
} | ||
|
||
void __attribute__((noinline)) func3_amb() { sink(); /* tail */ } | ||
|
||
void __attribute__((noinline)) func2_amb() { sink(); /* tail */ } | ||
|
||
void __attribute__((noinline)) func1() { | ||
if (x > 0) | ||
func2_amb(); /* tail */ | ||
else | ||
func3_amb(); /* tail */ | ||
} | ||
|
||
int __attribute__((disable_tail_calls)) main(int argc, char **) { | ||
// The sequences `main -> func1 -> f{2,3}_amb -> sink` are both plausible. Test | ||
// that lldb doesn't attempt to guess which one occurred. | ||
func1(); | ||
return 0; | ||
} |
4 changes: 4 additions & 0 deletions
4
.../Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LEVEL = ../../../make | ||
CXX_SOURCES := main.cpp | ||
include $(LEVEL)/Makefile.rules | ||
CXXFLAGS += -g -O1 -glldb |
5 changes: 5 additions & 0 deletions
5
...st/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from lldbsuite.test import lldbinline | ||
from lldbsuite.test import decorators | ||
|
||
lldbinline.MakeInlineTest(__file__, globals(), | ||
[decorators.skipUnlessHasCallSiteInfo]) |
Oops, something went wrong.