diff options
author | Nathan Lanza <nathan@lanza.io> | 2018-11-15 20:58:09 +0000 |
---|---|---|
committer | Nathan Lanza <nathan@lanza.io> | 2018-11-15 20:58:09 +0000 |
commit | 04f9d0a0c31398651ecf52a853362aa328756011 (patch) | |
tree | 0794fc602e6d4d2a050c384aa3dd2ed1ac72210a /lldb/packages/Python/lldbsuite/test/functionalities | |
parent | 5cc7de09ef983cc2741a3ba011170278b8994cbe (diff) | |
download | bcm5719-llvm-04f9d0a0c31398651ecf52a853362aa328756011.tar.gz bcm5719-llvm-04f9d0a0c31398651ecf52a853362aa328756011.zip |
Implement basic DidAttach and DidLaunch for DynamicLoaderWindowsDYLD
Summary:
This commit implements basic DidAttach and DidLaunch for the windows
DynamicLoader plugin which allow us to load shared libraries from the
inferior.
Reviewers: sas, zturner
Reviewed By: zturner
Differential Revision: https://reviews.llvm.org/D54544
llvm-svn: 346994
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities')
5 files changed, 101 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile new file mode 100644 index 00000000000..8289e159fc7 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/Makefile @@ -0,0 +1,14 @@ +LEVEL := ../../make + +LD_EXTRAS := -ldllfunc +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules + +a.out: dllfunc + +dllfunc: + $(MAKE) VERBOSE=1 VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dllfunc.mk + +clean:: + $(MAKE) -f $(SRCDIR)/dllfunc.mk clean diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py new file mode 100644 index 00000000000..77d4e710908 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/TestWindowsDYLD.py @@ -0,0 +1,42 @@ +""" +Test that breakpoints work in a DLL +""" + +from __future__ import print_function + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +@skipUnlessWindows +class WindowsDLLTestCase(TestBase): + def setUP(self): + TestBase.setUp(self) + self.build() + + def test_dll_linking(self): + """test that the debugger works with DLLs""" + + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + self.assertTrue(target and target.IsValid(), "Target is valid") + + self.runCmd("breakpoint set --file main.c --line 16") + self.runCmd("breakpoint set --file dllfunc.c --line 18") + + process = target.LaunchSimple(None, None, self.get_process_working_directory()) + + self.expect("p x", "16") + self.runCmd("thread step-out") + self.expect("p x", "16") + self.expect("thread step-in") + self.expect("thread step-in") + self.expect("p n", "8") + self.runCmd("c") + self.expect("p x", "64") + self.runCmd("breakpoint delete 2") + self.runCmd("c") + + self.assertEqual(process.GetExitStatus(), 336, PROCESS_EXITED) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c new file mode 100644 index 00000000000..aadf4e34a86 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.c @@ -0,0 +1,19 @@ +//===-- a.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <windows.h> + +BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, void* reserved) { + return TRUE; +} + +int __declspec(dllexport) DllFunc(int n) { + int x = n * n; + return x; // set breakpoint here +} diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk new file mode 100644 index 00000000000..f282344d36a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/dllfunc.mk @@ -0,0 +1,7 @@ +LEVEL := ../../make + +DYLIB_NAME := dllfunc +DYLIB_C_SOURCES := dllfunc.c +DYLIB_ONLY := YES + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c new file mode 100644 index 00000000000..4b62744fbd0 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/windows_dyld/main.c @@ -0,0 +1,19 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <windows.h> + +int __declspec(dllimport) DllFunc(int n); + +int main(int argc, char ** argv) { + int x = DllFunc(4); + int y = DllFunc(8); // set breakpoint here + int z = DllFunc(16); + return x + y + z; +} |