summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/cpp/stl
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/lang/cpp/stl
parent94994d372d014ce4c8758b9605d63fae651bd8aa (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/stl')
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/stl/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py125
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py118
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/stl/cmds.txt3
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp30
5 files changed, 0 insertions, 284 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/Makefile b/packages/Python/lldbsuite/test/lang/cpp/stl/Makefile
deleted file mode 100644
index fe27980afe9b..000000000000
--- a/packages/Python/lldbsuite/test/lang/cpp/stl/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-LEVEL = ../../../make
-
-CXX_SOURCES := main.cpp
-CFLAGS := -g -O0
-
-clean: OBJECTS+=$(wildcard main.d.*)
-
-include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py
deleted file mode 100644
index d11004e66d0a..000000000000
--- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestSTL.py
+++ /dev/null
@@ -1,125 +0,0 @@
-"""
-Test some expressions involving STL data types.
-"""
-
-from __future__ import print_function
-
-
-import unittest2
-import os
-import time
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class STLTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- # Find the line number to break inside main().
- self.source = 'main.cpp'
- self.line = line_number(
- self.source, '// Set break point at this line.')
-
- @skipIf
- @expectedFailureAll(bugnumber="llvm.org/PR36713")
- def test(self):
- """Test some expressions involving STL data types."""
- self.build()
- exe = self.getBuildArtifact("a.out")
-
- # The following two lines, if uncommented, will enable loggings.
- #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res)
- # self.assertTrue(res.Succeeded())
-
- self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
- lldbutil.run_break_set_by_file_and_line(
- self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
-
- self.runCmd("run", RUN_SUCCEEDED)
-
- # Stop at 'std::string hello_world ("Hello World!");'.
- self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
- substrs=['main.cpp:%d' % self.line,
- 'stop reason = breakpoint'])
-
- # The breakpoint should have a hit count of 1.
- self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
- substrs=[' resolved, hit count = 1'])
-
- # Now try some expressions....
-
- self.runCmd(
- 'expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }')
-
- self.expect('expr associative_array.size()',
- substrs=[' = 3'])
- self.expect('expr associative_array.count(hello_world)',
- substrs=[' = 1'])
- self.expect('expr associative_array[hello_world]',
- substrs=[' = 1'])
- self.expect('expr associative_array["hello"]',
- substrs=[' = 2'])
-
- @expectedFailureAll(
- compiler="icc",
- bugnumber="ICC (13.1, 14-beta) do not emit DW_TAG_template_type_parameter.")
- @add_test_categories(['pyapi'])
- def test_SBType_template_aspects(self):
- """Test APIs for getting template arguments from an SBType."""
- self.build()
- exe = self.getBuildArtifact("a.out")
-
- # Create a target by the debugger.
- target = self.dbg.CreateTarget(exe)
- self.assertTrue(target, VALID_TARGET)
-
- # Create the breakpoint inside function 'main'.
- breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
- self.assertTrue(breakpoint, 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)
-
- # Get Frame #0.
- self.assertTrue(process.GetState() == lldb.eStateStopped)
- thread = lldbutil.get_stopped_thread(
- process, lldb.eStopReasonBreakpoint)
- self.assertTrue(
- thread.IsValid(),
- "There should be a thread stopped due to breakpoint condition")
- frame0 = thread.GetFrameAtIndex(0)
-
- # Get the type for variable 'associative_array'.
- associative_array = frame0.FindVariable('associative_array')
- self.DebugSBValue(associative_array)
- self.assertTrue(associative_array, VALID_VARIABLE)
- map_type = associative_array.GetType()
- self.DebugSBType(map_type)
- self.assertTrue(map_type, VALID_TYPE)
- num_template_args = map_type.GetNumberOfTemplateArguments()
- self.assertTrue(num_template_args > 0)
-
- # We expect the template arguments to contain at least 'string' and
- # 'int'.
- expected_types = {'string': False, 'int': False}
- for i in range(num_template_args):
- t = map_type.GetTemplateArgumentType(i)
- self.DebugSBType(t)
- self.assertTrue(t, VALID_TYPE)
- name = t.GetName()
- if 'string' in name:
- expected_types['string'] = True
- elif 'int' == name:
- expected_types['int'] = True
-
- # Check that both entries of the dictionary have 'True' as the value.
- self.assertTrue(all(expected_types.values()))
diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py b/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py
deleted file mode 100644
index 23e94e9addc0..000000000000
--- a/packages/Python/lldbsuite/test/lang/cpp/stl/TestStdCXXDisassembly.py
+++ /dev/null
@@ -1,118 +0,0 @@
-"""
-Test the lldb disassemble command on lib stdc++.
-"""
-
-from __future__ import print_function
-
-
-import unittest2
-import os
-import time
-import lldb
-from lldbsuite.test.lldbtest import *
-import lldbsuite.test.lldbutil as lldbutil
-
-
-class StdCXXDisassembleTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- # Find the line number to break inside main().
- self.line = line_number('main.cpp', '// Set break point at this line.')
-
- # rdar://problem/8504895
- # Crash while doing 'disassemble -n "-[NSNumber descriptionWithLocale:]"
- @unittest2.skipIf(
- TestBase.skipLongRunningTest(),
- "Skip this long running test")
- def test_stdcxx_disasm(self):
- """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib."""
- self.build()
- exe = self.getBuildArtifact("a.out")
- self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
- # rdar://problem/8543077
- # test/stl: clang built binaries results in the breakpoint locations = 3,
- # is this a problem with clang generated debug info?
- #
- # Break on line 13 of main.cpp.
- lldbutil.run_break_set_by_file_and_line(
- self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
-
- self.runCmd("run", RUN_SUCCEEDED)
-
- # Now let's get the target as well as the process objects.
- target = self.dbg.GetSelectedTarget()
- process = target.GetProcess()
-
- # The process should be in a 'stopped' state.
- self.expect(str(process), STOPPED_DUE_TO_BREAKPOINT, exe=False,
- substrs=["a.out",
- "stopped"])
-
- # Disassemble the functions on the call stack.
- self.runCmd("thread backtrace")
- thread = lldbutil.get_stopped_thread(
- process, lldb.eStopReasonBreakpoint)
- self.assertIsNotNone(thread)
- depth = thread.GetNumFrames()
- for i in range(depth - 1):
- frame = thread.GetFrameAtIndex(i)
- function = frame.GetFunction()
- if function.GetName():
- self.runCmd("disassemble -n '%s'" % function.GetName())
-
- lib_stdcxx = "FAILHORRIBLYHERE"
- # Iterate through the available modules, looking for stdc++ library...
- for i in range(target.GetNumModules()):
- module = target.GetModuleAtIndex(i)
- fs = module.GetFileSpec()
- if (fs.GetFilename().startswith("libstdc++")
- or fs.GetFilename().startswith("libc++")):
- lib_stdcxx = str(fs)
- break
-
- # At this point, lib_stdcxx is the full path to the stdc++ library and
- # module is the corresponding SBModule.
-
- self.expect(lib_stdcxx, "Libraray StdC++ is located", exe=False,
- substrs=["lib"])
-
- self.runCmd("image dump symtab '%s'" % lib_stdcxx)
- raw_output = self.res.GetOutput()
- # Now, look for every 'Code' symbol and feed its load address into the
- # command: 'disassemble -s load_address -e end_address', where the
- # end_address is taken from the next consecutive 'Code' symbol entry's
- # load address.
- #
- # The load address column comes after the file address column, with both
- # looks like '0xhhhhhhhh', i.e., 8 hexadecimal digits.
- codeRE = re.compile(r"""
- \ Code\ {9} # ' Code' followed by 9 SPCs,
- 0x[0-9a-f]{16} # the file address column, and
- \ # a SPC, and
- (0x[0-9a-f]{16}) # the load address column, and
- .* # the rest.
- """, re.VERBOSE)
- # Maintain a start address variable; if we arrive at a consecutive Code
- # entry, then the load address of the that entry is fed as the end
- # address to the 'disassemble -s SA -e LA' command.
- SA = None
- for line in raw_output.split(os.linesep):
- match = codeRE.search(line)
- if match:
- LA = match.group(1)
- if self.TraceOn():
- print("line:", line)
- print("load address:", LA)
- print("SA:", SA)
- if SA and LA:
- if int(LA, 16) > int(SA, 16):
- self.runCmd("disassemble -s %s -e %s" % (SA, LA))
- SA = LA
- else:
- # This entry is not a Code entry. Reset SA = None.
- SA = None
diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/cmds.txt b/packages/Python/lldbsuite/test/lang/cpp/stl/cmds.txt
deleted file mode 100644
index 9c9c2e3db57b..000000000000
--- a/packages/Python/lldbsuite/test/lang/cpp/stl/cmds.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-b main.cpp:6
-continue
-var
diff --git a/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp
deleted file mode 100644
index cfdb7b2d3db5..000000000000
--- a/packages/Python/lldbsuite/test/lang/cpp/stl/main.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-//===-- main.cpp ------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#include <cstdio>
-#include <iostream>
-#include <string>
-#include <map>
-int main (int argc, char const *argv[])
-{
- std::string hello_world ("Hello World!");
- std::cout << hello_world << std::endl;
- std::cout << hello_world.length() << std::endl;
- std::cout << hello_world[11] << std::endl;
-
- std::map<std::string, int> associative_array;
- std::cout << "size of upon construction associative_array: " << associative_array.size() << std::endl;
- associative_array[hello_world] = 1;
- associative_array["hello"] = 2;
- associative_array["world"] = 3;
-
- std::cout << "size of associative_array: " << associative_array.size() << std::endl;
- printf("associative_array[\"hello\"]=%d\n", associative_array["hello"]);
-
- printf("before returning....\n"); // Set break point at this line.
-}