Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lldb] Add support for debugging via the dynamic linker.
This patch adds support for shared library load when the executable is called through ld.so. Differential Revision:https://reviews.llvm.org/D108061
- Loading branch information
1 parent
f3c2094
commit 03df971
Showing
8 changed files
with
169 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CXX_SOURCES := main.cpp | ||
DYLIB_NAME := signal_file | ||
DYLIB_CXX_SOURCES := signal_file.cpp | ||
include Makefile.rules |
58 changes: 58 additions & 0 deletions
58
lldb/test/API/functionalities/dyld-launch-linux/TestDyldLaunchLinux.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,58 @@ | ||
""" | ||
Test that LLDB can launch a linux executable through the dynamic loader and still hit a breakpoint. | ||
""" | ||
|
||
import lldb | ||
import os | ||
|
||
from lldbsuite.test.decorators import * | ||
from lldbsuite.test.lldbtest import * | ||
|
||
class TestLinux64LaunchingViaDynamicLoader(TestBase): | ||
mydir = TestBase.compute_mydir(__file__) | ||
|
||
@skipIf(oslist=no_match(['linux'])) | ||
@no_debug_info_test | ||
def test(self): | ||
self.build() | ||
|
||
# Extracts path of the interpreter. | ||
spec = lldb.SBModuleSpec() | ||
spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact("a.out"))) | ||
interp_section = lldb.SBModule(spec).FindSection(".interp") | ||
if not interp_section: | ||
return | ||
section_data = interp_section.GetSectionData() | ||
error = lldb.SBError() | ||
exe = section_data.GetString(error,0) | ||
if error.Fail(): | ||
return | ||
|
||
target = self.dbg.CreateTarget(exe) | ||
self.assertTrue(target, VALID_TARGET) | ||
|
||
# Set breakpoints both on shared library function as well as on | ||
# main. Both of them will be pending breakpoints. | ||
breakpoint_main = target.BreakpointCreateBySourceRegex("// Break here", lldb.SBFileSpec("main.cpp")) | ||
breakpoint_shared_library = target.BreakpointCreateBySourceRegex("get_signal_crash", lldb.SBFileSpec("signal_file.cpp")) | ||
launch_info = lldb.SBLaunchInfo([ "--library-path", self.get_process_working_directory(), self.getBuildArtifact("a.out")]) | ||
launch_info.SetWorkingDirectory(self.get_process_working_directory()) | ||
error = lldb.SBError() | ||
process = target.Launch(launch_info, error) | ||
self.assertTrue(error.Success()) | ||
|
||
# Stopped on main here. | ||
self.assertEqual(process.GetState(), lldb.eStateStopped) | ||
thread = process.GetSelectedThread() | ||
self.assertIn("main", thread.GetFrameAtIndex(0).GetDisplayFunctionName()) | ||
process.Continue() | ||
|
||
# Stopped on get_signal_crash function here. | ||
self.assertEqual(process.GetState(), lldb.eStateStopped) | ||
self.assertIn("get_signal_crash", thread.GetFrameAtIndex(0).GetDisplayFunctionName()) | ||
process.Continue() | ||
|
||
# Stopped because of generated signal. | ||
self.assertEqual(process.GetState(), lldb.eStateStopped) | ||
self.assertIn("raise", thread.GetFrameAtIndex(0).GetDisplayFunctionName()) | ||
self.assertIn("get_signal_crash", thread.GetFrameAtIndex(1).GetDisplayFunctionName()) |
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,6 @@ | ||
#include "signal_file.h" | ||
|
||
int main() { | ||
// Break here | ||
return get_signal_crash(); | ||
} |
7 changes: 7 additions & 0 deletions
7
lldb/test/API/functionalities/dyld-launch-linux/signal_file.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,7 @@ | ||
#include "signal_file.h" | ||
#include <signal.h> | ||
|
||
int get_signal_crash(void) { | ||
raise(SIGSEGV); | ||
return 0; | ||
} |
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 @@ | ||
int get_signal_crash(); |