summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/python_api/symbol-context
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:57 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:57 +0000
commit88c643b6fec27eec436c8d138fee6346e92337d6 (patch)
tree82cd13b2f3cde1c9e5f79689ba4e6ba67694843f /packages/Python/lldbsuite/test/python_api/symbol-context
parent94994d372d014ce4c8758b9605d63fae651bd8aa (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api/symbol-context')
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py104
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/main.c51
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py81
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h11
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp21
-rw-r--r--packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp7
8 files changed, 0 insertions, 285 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/Makefile b/packages/Python/lldbsuite/test/python_api/symbol-context/Makefile
deleted file mode 100644
index 0d70f2595019..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-LEVEL = ../../make
-
-C_SOURCES := main.c
-
-include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
deleted file mode 100644
index 2b783fb90e56..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py
+++ /dev/null
@@ -1,104 +0,0 @@
-"""
-Test SBSymbolContext APIs.
-"""
-
-from __future__ import print_function
-
-
-import os
-import re
-import time
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class SymbolContextAPITestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- # Find the line number to of function 'c'.
- self.line = line_number(
- 'main.c', '// Find the line number of function "c" here.')
-
- @add_test_categories(['pyapi'])
- @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
- def test(self):
- """Exercise SBSymbolContext API extensively."""
- self.build()
- exe = self.getBuildArtifact("a.out")
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- # Now create a breakpoint on main.c by name 'c'.
- breakpoint = target.BreakpointCreateByName('c', 'a.out')
- #print("breakpoint:", breakpoint)
- self.assertTrue(breakpoint and
- breakpoint.GetNumLocations() == 1,
- VALID_BREAKPOINT)
-
- # Now launch the process, and do not stop at entry point.
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID)
-
- # Frame #0 should be on self.line.
- from lldbsuite.test.lldbutil import get_stopped_thread
- thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
- self.assertTrue(
- thread.IsValid(),
- "There should be a thread stopped due to breakpoint")
- frame0 = thread.GetFrameAtIndex(0)
- self.assertTrue(frame0.GetLineEntry().GetLine() == self.line)
-
- # Now get the SBSymbolContext from this frame. We want everything. :-)
- context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
- self.assertTrue(context)
-
- # Get the description of this module.
- module = context.GetModule()
- desc = lldbutil.get_description(module)
- self.expect(desc, "The module should match", exe=False,
- substrs=[self.getBuildArtifact("a.out")])
-
- compileUnit = context.GetCompileUnit()
- self.expect(
- str(compileUnit),
- "The compile unit should match",
- exe=False,
- substrs=[self.getSourcePath('main.c')])
-
- function = context.GetFunction()
- self.assertTrue(function)
- #print("function:", function)
-
- block = context.GetBlock()
- self.assertTrue(block)
- #print("block:", block)
-
- lineEntry = context.GetLineEntry()
- #print("line entry:", lineEntry)
- self.expect(
- lineEntry.GetFileSpec().GetDirectory(),
- "The line entry should have the correct directory",
- exe=False,
- substrs=[self.mydir])
- self.expect(
- lineEntry.GetFileSpec().GetFilename(),
- "The line entry should have the correct filename",
- exe=False,
- substrs=['main.c'])
- self.assertTrue(lineEntry.GetLine() == self.line,
- "The line entry's line number should match ")
-
- symbol = context.GetSymbol()
- self.assertTrue(
- function.GetName() == symbol.GetName() and symbol.GetName() == 'c',
- "The symbol name should be 'c'")
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/main.c b/packages/Python/lldbsuite/test/python_api/symbol-context/main.c
deleted file mode 100644
index 3ac1825d8d21..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/main.c
+++ /dev/null
@@ -1,51 +0,0 @@
-//===-- 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 <stdio.h>
-
-// This simple program is to test the lldb Python API SBSymbolContext.
-// When stopped on a frame, we can get the symbol context using the SBFrame API
-// SBFrame.GetSymbolContext().
-
-int a(int);
-int b(int);
-int c(int);
-
-int a(int val)
-{
- if (val <= 1)
- return b(val);
- else if (val >= 3)
- return c(val);
-
- return val;
-}
-
-int b(int val)
-{
- return c(val);
-}
-
-int c(int val)
-{
- return val + 3; // Find the line number of function "c" here.
-}
-
-int main (int argc, char const *argv[])
-{
- int A1 = a(1); // a(1) -> b(1) -> c(1)
- printf("a(1) returns %d\n", A1);
-
- int B2 = b(2); // b(2) -> c(2)
- printf("b(2) returns %d\n", B2);
-
- int A3 = a(3); // a(3) -> c(3)
- printf("a(3) returns %d\n", A3);
-
- return 0;
-}
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile
deleted file mode 100644
index 650a8b261bea..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-LEVEL = ../../../make
-
-CXX_SOURCES := file1.cpp file2.cpp
-
-include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
deleted file mode 100644
index 8640abe5625b..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py
+++ /dev/null
@@ -1,81 +0,0 @@
-"""
-Test SBSymbolContext APIs.
-"""
-
-from __future__ import print_function
-
-import os
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class SymbolContextTwoFilesTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- @add_test_categories(['pyapi'])
- @expectedFailureAll(oslist=["windows"])
- def test_lookup_by_address(self):
- """Test lookup by address in a module with multiple compilation units"""
- self.build()
- exe = self.getBuildArtifact("a.out")
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- module = target.GetModuleAtIndex(0)
- self.assertTrue(module.IsValid())
- for symbol_name in ["struct1::f()", "struct2::f()"]:
- sc_list = module.FindFunctions(symbol_name, lldb.eSymbolTypeCode)
- self.assertTrue(1, sc_list.GetSize())
- symbol_address = sc_list.GetContextAtIndex(
- 0).GetSymbol().GetStartAddress()
- self.assertTrue(symbol_address.IsValid())
- sc_by_address = module.ResolveSymbolContextForAddress(
- symbol_address, lldb.eSymbolContextFunction)
- self.assertEqual(symbol_name,
- sc_by_address.GetFunction().GetName())
-
- @add_test_categories(['pyapi'])
- def test_ranges_in_multiple_compile_unit(self):
- """This test verifies that we correctly handle the case when multiple
- compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes."""
- self.build()
- exe = self.getBuildArtifact("a.out")
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- source1 = "file1.cpp"
- line1 = line_number(source1, '// Break1')
- breakpoint1 = target.BreakpointCreateByLocation(source1, line1)
- self.assertIsNotNone(breakpoint1)
- self.assertTrue(breakpoint1.IsValid())
-
- source2 = "file2.cpp"
- line2 = line_number(source2, '// Break2')
- breakpoint2 = target.BreakpointCreateByLocation(source2, line2)
- self.assertIsNotNone(breakpoint2)
- self.assertTrue(breakpoint2.IsValid())
-
- process = target.LaunchSimple(None, None, self.get_process_working_directory())
- self.assertIsNotNone(process, PROCESS_IS_VALID)
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint2)
- self.assertEqual(len(threads), 1)
- frame = threads[0].GetFrameAtIndex(0)
- value = frame.FindVariable("x")
- self.assertTrue(value.IsValid())
-
- process.Continue()
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint1)
- self.assertEqual(len(threads), 1)
- frame = threads[0].GetFrameAtIndex(0)
- value = frame.FindVariable("x")
- self.assertTrue(value.IsValid())
-
- process.Continue()
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h
deleted file mode 100644
index 7c8045842062..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/decls.h
+++ /dev/null
@@ -1,11 +0,0 @@
-struct struct1 {
- ~struct1();
- static void f();
-};
-
-struct struct2 {
- ~struct2();
- static void f();
-};
-
-int g();
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp
deleted file mode 100644
index 327d0fb7718f..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file1.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "decls.h"
-
-int g() {
- return 1;
-}
-
-struct1::~struct1() {
- int x = g(); // Break1
-}
-
-void struct1::f() {}
-
-int main() {
- struct1::f();
- struct2::f();
-
- struct1 s1;
- struct2 s2;
-
- return 0;
-}
diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp
deleted file mode 100644
index 109e01572ed2..000000000000
--- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/file2.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "decls.h"
-
-struct2::~struct2() {
- int x = g(); // Break2
-}
-
-void struct2::f() {}