Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,5 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,40 @@
"""
Tests that auto types work
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class CPPAutoTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@expectedFailureAll(
compiler="gcc",
bugnumber="GCC generates incomplete debug info")
@expectedFailureAll(oslist=['windows'], bugnumber="llvm.org/pr26339")
def test_with_run_command(self):
"""Test that auto types work in the expression parser"""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
line = line_number('main.cpp', '// break here')
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
self.runCmd("process launch", RUN_SUCCEEDED)
self.expect('expr auto f = 123456; f', substrs=['int', '123456'])
self.expect(
'expr struct Test { int x; int y; Test() : x(123), y(456) {} }; auto t = Test(); t',
substrs=[
'Test',
'123',
'456'])
self.expect(
'expr auto s = helloworld; s',
substrs=[
'string',
'hello world'])

View File

@ -0,0 +1,16 @@
//===-- 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 <string>
int main()
{
std::string helloworld("hello world");
return 0; // break here
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,28 @@
"""
Tests that bool types work
"""
import lldb
from lldbsuite.test.lldbtest import *
import lldbsuite.test.lldbutil as lldbutil
class CPPBoolTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def test_with_run_command(self):
"""Test that bool types work in the expression parser"""
self.build()
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
line = line_number('main.cpp', '// breakpoint 1')
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
self.runCmd("process launch", RUN_SUCCEEDED)
self.expect("expression -- bool second_bool = my_bool; second_bool",
startstr="(bool) $0 = false")
self.expect("expression -- my_bool = true",
startstr="(bool) $1 = true")

View File

@ -0,0 +1,17 @@
//===-- 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 <stdio.h>
int main()
{
bool my_bool = false;
printf("%s\n", my_bool ? "true" : "false"); // breakpoint 1
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../../make
CXX_SOURCES := nested.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,86 @@
"""
Test lldb breakpoint command for CPP methods & functions in a namespace.
"""
from __future__ import print_function
import os
import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class CPPBreakpointCommandsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def make_breakpoint(self, name, type, expected_num_locations):
bkpt = self.target.BreakpointCreateByName(name,
type,
self.a_out_module,
self.nested_comp_unit)
num_locations = bkpt.GetNumLocations()
self.assertTrue(
num_locations == expected_num_locations,
"Wrong number of locations for '%s', expected: %d got: %d" %
(name,
expected_num_locations,
num_locations))
return bkpt
def test_cpp_breakpoint_cmds(self):
"""Test a sequence of breakpoint command add, list, and delete."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
# Create a target from the debugger.
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
self.a_out_module = lldb.SBFileSpecList()
self.a_out_module.Append(lldb.SBFileSpec(exe))
self.nested_comp_unit = lldb.SBFileSpecList()
self.nested_comp_unit.Append(lldb.SBFileSpec("nested.cpp"))
# First provide ONLY the method name. This should get everybody...
self.make_breakpoint("Function",
lldb.eFunctionNameTypeAuto,
5)
# Now add the Baz class specifier. This should get the version contained in Bar,
# AND the one contained in ::
self.make_breakpoint("Baz::Function",
lldb.eFunctionNameTypeAuto,
2)
# Then add the Bar::Baz specifier. This should get the version
# contained in Bar only
self.make_breakpoint("Bar::Baz::Function",
lldb.eFunctionNameTypeAuto,
1)
self.make_breakpoint("Function",
lldb.eFunctionNameTypeMethod,
3)
self.make_breakpoint("Baz::Function",
lldb.eFunctionNameTypeMethod,
2)
self.make_breakpoint("Bar::Baz::Function",
lldb.eFunctionNameTypeMethod,
1)
self.make_breakpoint("Function",
lldb.eFunctionNameTypeBase,
2)
self.make_breakpoint("Bar::Function",
lldb.eFunctionNameTypeBase,
1)

View File

@ -0,0 +1,76 @@
#include <stdio.h>
namespace Foo
{
namespace Bar
{
class Baz
{
public:
Baz (int value):m_value(value) {}
int Function ()
{
printf ("%s returning: %d.\n", __FUNCTION__, m_value);
return m_value + 1;
}
private:
int m_value;
};
class Baz2
{
public:
Baz2 (int value):m_value(value) {}
int Function ()
{
printf ("%s returning: %d.\n", __FUNCTION__, m_value);
return m_value + 2;
}
private:
int m_value;
};
static int bar_value = 20;
int Function ()
{
printf ("%s returning: %d.\n", __FUNCTION__, bar_value);
return bar_value + 3;
}
}
}
class Baz
{
public:
Baz (int value):m_value(value) {}
int Function ()
{
printf ("%s returning: %d.\n", __FUNCTION__, m_value);
return m_value + 4;
}
private:
int m_value;
};
int
Function ()
{
printf ("I am a global function, I return 333.\n");
return 333;
}
int main ()
{
Foo::Bar::Baz mine(200);
Foo::Bar::Baz2 mine2(300);
::Baz bare_baz (500);
printf ("Yup, got %d from Baz.\n", mine.Function());
printf ("Yup, got %d from Baz.\n", mine2.Function());
printf ("Yup, got %d from Baz.\n", bare_baz.Function());
printf ("And got %d from Bar.\n", Foo::Bar::Function());
printf ("And got %d from ::.\n", ::Function());
return 0;
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,38 @@
"""
Tests calling a function by basename
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class CallCPPFunctionTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
TestBase.setUp(self)
self.line = line_number('main.cpp', '// breakpoint')
@expectedFailureAll(
oslist=["windows"],
bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
def test_with_run_command(self):
"""Test calling a function by basename"""
self.build()
self.runCmd("file a.out", 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("process launch", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list",
STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped', 'stop reason = breakpoint'])
self.expect("expression -- a_function_to_call()",
startstr="(int) $0 = 0")

View File

@ -0,0 +1,11 @@
#include <stdio.h>
int a_function_to_call()
{
return 0;
}
int main()
{
printf("%d\n", a_function_to_call()); // breakpoint
}

View File

@ -0,0 +1,5 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,102 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestCppChainedCalls(TestBase):
mydir = TestBase.compute_mydir(__file__)
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21765")
def test_with_run_command(self):
self.build()
# Get main source file
src_file = "main.cpp"
src_file_spec = lldb.SBFileSpec(src_file)
self.assertTrue(src_file_spec.IsValid(), "Main source file")
# Get the path of the executable
cwd = os.getcwd()
exe_file = "a.out"
exe_path = os.path.join(cwd, exe_file)
# Load the executable
target = self.dbg.CreateTarget(exe_path)
self.assertTrue(target.IsValid(), VALID_TARGET)
# Break on main function
main_breakpoint = target.BreakpointCreateBySourceRegex(
"break here", src_file_spec)
self.assertTrue(
main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1,
VALID_BREAKPOINT)
# Launch the process
args = None
env = None
process = target.LaunchSimple(
args, env, self.get_process_working_directory())
self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
# Get the thread of the process
self.assertTrue(
process.GetState() == lldb.eStateStopped,
PROCESS_STOPPED)
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
# Get frame for current thread
frame = thread.GetSelectedFrame()
# Test chained calls
test_result = frame.EvaluateExpression("get(set(true))")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "true",
"get(set(true)) = true")
test_result = frame.EvaluateExpression("get(set(false))")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(set(false)) = false")
test_result = frame.EvaluateExpression("get(t & f)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(t & f) = false")
test_result = frame.EvaluateExpression("get(f & t)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(f & t) = false")
test_result = frame.EvaluateExpression("get(t & t)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "true",
"get(t & t) = true")
test_result = frame.EvaluateExpression("get(f & f)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(f & f) = false")
test_result = frame.EvaluateExpression("get(t & f)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(t & f) = false")
test_result = frame.EvaluateExpression("get(f) && get(t)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(f) && get(t) = false")
test_result = frame.EvaluateExpression("get(f) && get(f)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "false",
"get(f) && get(t) = false")
test_result = frame.EvaluateExpression("get(t) && get(t)")
self.assertTrue(
test_result.IsValid() and test_result.GetValue() == "true",
"get(t) && get(t) = true")

View File

@ -0,0 +1,33 @@
class Bool {
public:
Bool operator&(const Bool other)
{
Bool result;
result.value = value && other.value;
return result;
}
bool value;
};
bool get(Bool object)
{
return object.value;
}
Bool set(bool value)
{
Bool result;
result.value = value;
return result;
}
int main()
{
Bool t = set(true);
Bool f = set(false);
get(t);
get(f);
get(t & f);
return 0; // break here
}

View File

@ -0,0 +1 @@
dataformatters

View File

@ -0,0 +1,8 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
CFLAGS :=-g -O0 -std=c++11
clean: OBJECTS+=$(wildcard main.d.*)
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,122 @@
# coding=utf8
"""
Test that the C++11 support for char16_t and char32_t works correctly.
"""
from __future__ import print_function
import os
import time
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class Char1632TestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line number to break for main.cpp.
self.source = 'main.cpp'
self.lines = [line_number(self.source, '// breakpoint1'),
line_number(self.source, '// breakpoint2')]
@expectedFailureAll(
compiler="icc",
bugnumber="ICC (13.1) does not emit the DW_TAG_base_type for char16_t and char32_t.")
def test(self):
"""Test that the C++11 support for char16_t and char32_t works correctly."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
# Create a target by the debugger.
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# Set breakpoints
for line in self.lines:
lldbutil.run_break_set_by_file_and_line(self, "main.cpp", line)
# Now launch the process, and do not stop at entry point and stop at
# breakpoint1
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
if not process:
self.fail("SBTarget.Launch() failed")
if self.TraceOn():
self.runCmd("frame variable")
# Check that we correctly report the const types
self.expect(
"frame variable cs16 cs32",
substrs=[
'(const char16_t *) cs16 = ',
'(const char32_t *) cs32 = ',
'u"hello world ྒྙྐ"',
'U"hello world ྒྙྐ"'])
# Check that we correctly report the non-const types
self.expect(
"frame variable s16 s32",
substrs=[
'(char16_t *) s16 = ',
'(char32_t *) s32 = ',
'u"ﺸﺵۻ"',
'U"ЕЙРГЖО"'])
# Check that we correctly report the array types
self.expect(
"frame variable as16 as32",
patterns=[
'\(char16_t \[[0-9]+\]\) as16 = ',
'\(char32_t \[[0-9]+\]\) as32 = '],
substrs=[
'u"ﺸﺵۻ"',
'U"ЕЙРГЖО"'])
self.runCmd("next") # step to after the string is nullified
# check that we don't crash on NULL
self.expect("frame variable s32",
substrs=['(char32_t *) s32 = 0x00000000'])
# continue and hit breakpoint2
self.runCmd("continue")
# check that the new strings show
self.expect(
"frame variable s16 s32",
substrs=[
'(char16_t *) s16 = 0x',
'(char32_t *) s32 = ',
'"色ハ匂ヘト散リヌルヲ"',
'""'])
# check the same as above for arrays
self.expect(
"frame variable as16 as32",
patterns=[
'\(char16_t \[[0-9]+\]\) as16 = ',
'\(char32_t \[[0-9]+\]\) as32 = '],
substrs=[
'"色ハ匂ヘト散リヌルヲ"',
'""'])
# check that zero values are properly handles
self.expect('frame variable cs16_zero', substrs=["U+0000 u'\\0'"])
self.expect(
'frame variable cs32_zero',
substrs=["U+0x00000000 U'\\0'"])
self.expect('expression cs16_zero', substrs=["U+0000 u'\\0'"])
self.expect('expression cs32_zero', substrs=["U+0x00000000 U'\\0'"])
# Check that we can run expressions that return charN_t
self.expect("expression u'a'", substrs=['(char16_t) $', "61 u'a'"])
self.expect("expression U'a'", substrs=['(char32_t) $', "61 U'a'"])

View File

@ -0,0 +1,44 @@
//===-- 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 <assert.h>
#include <string>
#define UASZ 64
template<class T, int N>
void copy_char_seq (T (&arr)[N], const T* src)
{
size_t src_len = std::char_traits<T>::length(src);
assert(src_len < N);
std::char_traits<T>::copy(arr, src, src_len);
arr[src_len] = 0;
}
int main (int argc, char const *argv[])
{
char16_t as16[UASZ];
char32_t as32[UASZ];
auto cs16_zero = (char16_t)0;
auto cs32_zero = (char32_t)0;
auto cs16 = u"hello world ྒྙྐ";
auto cs32 = U"hello world ྒྙྐ";
char16_t *s16 = (char16_t *)u"ﺸﺵۻ";
char32_t *s32 = (char32_t *)U"ЕЙРГЖО";
copy_char_seq(as16, s16);
copy_char_seq(as32, s32);
s32 = nullptr; // breakpoint1
s32 = (char32_t *)U"";
s16 = (char16_t *)u"色ハ匂ヘト散リヌルヲ";
copy_char_seq(as16, s16);
copy_char_seq(as32, s32);
s32 = nullptr; // breakpoint2
return 0;
}

View File

@ -0,0 +1,3 @@
LEVEL = ../../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

Some files were not shown because too many files have changed in this diff Show More