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
C_SOURCES := main.c
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,174 @@
"""Test that anonymous structs/unions are transparent to member access"""
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 AnonymousTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipIf(
compiler="icc",
bugnumber="llvm.org/pr15036: LLDB generates an incorrect AST layout for an anonymous struct when DWARF is generated by ICC")
def test_expr_nest(self):
self.build()
self.common_setup(self.line0)
# These should display correctly.
self.expect("expression n->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 4"])
self.expect("expression n->b", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 2"])
def test_expr_child(self):
self.build()
self.common_setup(self.line1)
# These should display correctly.
self.expect("expression c->foo.d", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 4"])
self.expect(
"expression c->grandchild.b",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 2"])
@skipIf(
compiler="icc",
bugnumber="llvm.org/pr15036: This particular regression was introduced by r181498")
def test_expr_grandchild(self):
self.build()
self.common_setup(self.line2)
# These should display correctly.
self.expect("expression g.child.foo.d", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 4"])
self.expect("expression g.child.b", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 2"])
def test_expr_parent(self):
self.build()
if "clang" in self.getCompiler() and "3.4" in self.getCompilerVersion():
self.skipTest(
"llvm.org/pr16214 -- clang emits partial DWARF for structures referenced via typedef")
self.common_setup(self.line2)
# These should display correctly.
self.expect("expression pz", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["(type_z *) $", " = 0x0000"])
self.expect("expression z.y", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["(type_y) $", "dummy = 2"])
@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr21550")
def test_expr_null(self):
self.build()
self.common_setup(self.line2)
# This should fail because pz is 0, but it succeeds on OS/X.
# This fails on Linux with an upstream error "Couldn't dematerialize struct", as does "p *n" with "int *n = 0".
# Note that this can also trigger llvm.org/pr15036 when run
# interactively at the lldb command prompt.
self.expect("expression *(type_z *)pz", error=True)
def test_child_by_name(self):
self.build()
# Set debugger into synchronous mode
self.dbg.SetAsync(False)
# Create a target
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
break_in_main = target.BreakpointCreateBySourceRegex(
'// Set breakpoint 2 here.', lldb.SBFileSpec(self.source))
self.assertTrue(break_in_main, VALID_BREAKPOINT)
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
threads = lldbutil.get_threads_stopped_at_breakpoint(
process, break_in_main)
if len(threads) != 1:
self.fail("Failed to stop at breakpoint in main.")
thread = threads[0]
frame = thread.frames[0]
if not frame.IsValid():
self.fail("Failed to get frame 0.")
var_n = frame.FindVariable("n")
if not var_n.IsValid():
self.fail("Failed to get the variable 'n'")
elem_a = var_n.GetChildMemberWithName("a")
if not elem_a.IsValid():
self.fail("Failed to get the element a in n")
error = lldb.SBError()
value = elem_a.GetValueAsSigned(error, 1000)
if not error.Success() or value != 0:
self.fail("failed to get the correct value for element a in n")
def test_nest_flat(self):
self.build()
self.common_setup(self.line2)
# These should display correctly.
self.expect('frame variable n --flat',
substrs=['n.a = 0',
'n.b = 2',
'n.foo.c = 0',
'n.foo.d = 4'])
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line numbers to break in main.c.
self.source = 'main.c'
self.line0 = line_number(self.source, '// Set breakpoint 0 here.')
self.line1 = line_number(self.source, '// Set breakpoint 1 here.')
self.line2 = line_number(self.source, '// Set breakpoint 2 here.')
def common_setup(self, line):
# Set debugger into synchronous mode
self.dbg.SetAsync(False)
# Create a target
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
# Set breakpoints inside and outside methods that take pointers to the
# containing struct.
lldbutil.run_break_set_by_file_and_line(
self, self.source, line, num_expected_locations=1, loc_exact=True)
# 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)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'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'])

View File

@ -0,0 +1,82 @@
#include <stdio.h>
struct anonymous_nest {
struct {
struct {
int a;
int b;
}; // anonymous
struct {
int c;
int d;
} foo;
}; // anonymous
};
struct anonymous_child {
struct {
struct {
int a;
int b;
} grandchild;
struct {
int c;
int d;
} foo;
}; // anonymous
};
struct anonymous_grandchild {
struct {
struct {
int a;
int b;
}; // anonymous
struct {
int c;
int d;
} foo;
} child;
};
int processor_nest (struct anonymous_nest *n)
{
return n->foo.d + n->b; // Set breakpoint 0 here.
}
int processor_child (struct anonymous_child *c)
{
return c->foo.d + c->grandchild.b; // Set breakpoint 1 here.
}
int processor_grandchild (struct anonymous_grandchild *g)
{
return g->child.foo.d + g->child.b;
}
typedef struct {
int dummy;
} type_y;
typedef struct {
type_y y;
} type_z;
int main()
{
struct anonymous_nest n = { 0, 2, 0, 4 };
struct anonymous_child c = { 0, 2, 0, 4 };
struct anonymous_grandchild g = { 0, 2, 0, 4 };
type_z *pz = 0;
type_z z = {{2}};
printf("%d\n", processor_nest(&n));
printf("%d\n", processor_child(&c));
printf("%d\n", processor_grandchild(&g)); // Set breakpoint 2 here.
return 0;
}

View File

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

View File

@ -0,0 +1,228 @@
"""Test breakpoint by file/line number; and list variables with array types."""
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 ArrayTypesTestCase(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.c', '// Set break point at this line.')
def test_and_run_command(self):
"""Test 'frame variable var_name' on some variables with array types."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self, "main.c", self.line, num_expected_locations=1, loc_exact=False)
self.runCmd("run", RUN_SUCCEEDED)
# The test suite sometimes shows that the process has exited without stopping.
#
# CC=clang ./dotest.py -v -t array_types
# ...
# Process 76604 exited with status = 0 (0x00000000)
self.runCmd("process status")
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'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'])
# Issue 'variable list' command on several array-type variables.
self.expect(
"frame variable --show-types strings",
VARIABLES_DISPLAYED_CORRECTLY,
startstr='(char *[4])',
substrs=[
'(char *) [0]',
'(char *) [1]',
'(char *) [2]',
'(char *) [3]',
'Hello',
'Hola',
'Bonjour',
'Guten Tag'])
self.expect(
"frame variable --show-types --raw -- char_16",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=[
'(char) [0]',
'(char) [15]'])
self.expect(
"frame variable --show-types ushort_matrix",
VARIABLES_DISPLAYED_CORRECTLY,
startstr='(unsigned short [2][3])')
self.expect(
"frame variable --show-types long_6",
VARIABLES_DISPLAYED_CORRECTLY,
startstr='(long [6])')
@add_test_categories(['pyapi'])
def test_and_python_api(self):
"""Use Python APIs to inspect variables with array types."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Sanity check the print representation of breakpoint.
bp = str(breakpoint)
self.expect(bp, msg="Breakpoint looks good", exe=False,
substrs=["file = 'main.c'",
"line = %d" % self.line,
"locations = 1"])
self.expect(
bp,
msg="Breakpoint is not resolved as yet",
exe=False,
matching=False,
substrs=["resolved = 1"])
# 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)
# Sanity check the print representation of process.
proc = str(process)
self.expect(proc, msg="Process looks good", exe=False,
substrs=["state = stopped",
"executable = a.out"])
# The stop reason of the thread should be breakpoint.
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertIsNotNone(thread)
# Sanity check the print representation of thread.
thr = str(thread)
# TODO(zturner): Whether the TID is printed in hex or decimal should be controlled by a setting,
# and this test should read the value of the setting. This check is currently hardcoded to
# match the check in Core/FormatEntity.cpp in the function FormatEntity::Format() for
# the Entry::Type::ThreadID case of the switch statement.
if self.getPlatform() == "linux" or self.getPlatform() == "freebsd":
tidstr = "tid = %u" % thread.GetThreadID()
else:
tidstr = "tid = 0x%4.4x" % thread.GetThreadID()
self.expect(
thr,
"Thread looks good with stop reason = breakpoint",
exe=False,
substrs=[tidstr])
# The breakpoint should have a hit count of 1.
self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
# The breakpoint should be resolved by now.
bp = str(breakpoint)
self.expect(bp, "Breakpoint looks good and is resolved", exe=False,
substrs=["file = 'main.c'",
"line = %d" % self.line,
"locations = 1"])
# Sanity check the print representation of frame.
frame = thread.GetFrameAtIndex(0)
frm = str(frame)
self.expect(
frm,
"Frame looks good with correct index %d" %
frame.GetFrameID(),
exe=False,
substrs=[
"#%d" %
frame.GetFrameID()])
# Lookup the "strings" string array variable and sanity check its print
# representation.
variable = frame.FindVariable("strings")
var = str(variable)
self.expect(
var,
"Variable for 'strings' looks good with correct name",
exe=False,
substrs=[
"%s" %
variable.GetName()])
self.DebugSBValue(variable)
self.assertTrue(variable.GetNumChildren() == 4,
"Variable 'strings' should have 4 children")
child3 = variable.GetChildAtIndex(3)
self.DebugSBValue(child3)
self.assertTrue(child3.GetSummary() == '"Guten Tag"',
'strings[3] == "Guten Tag"')
# Lookup the "char_16" char array variable.
variable = frame.FindVariable("char_16")
self.DebugSBValue(variable)
self.assertTrue(variable.GetNumChildren() == 16,
"Variable 'char_16' should have 16 children")
# Lookup the "ushort_matrix" ushort[] array variable.
# Notice the pattern of int(child0_2.GetValue(), 0). We pass a
# base of 0 so that the proper radix is determined based on the contents
# of the string. Same applies to long().
variable = frame.FindVariable("ushort_matrix")
self.DebugSBValue(variable)
self.assertTrue(variable.GetNumChildren() == 2,
"Variable 'ushort_matrix' should have 2 children")
child0 = variable.GetChildAtIndex(0)
self.DebugSBValue(child0)
self.assertTrue(child0.GetNumChildren() == 3,
"Variable 'ushort_matrix[0]' should have 3 children")
child0_2 = child0.GetChildAtIndex(2)
self.DebugSBValue(child0_2)
self.assertTrue(int(child0_2.GetValue(), 0) == 3,
"ushort_matrix[0][2] == 3")
# Lookup the "long_6" char array variable.
variable = frame.FindVariable("long_6")
self.DebugSBValue(variable)
self.assertTrue(variable.GetNumChildren() == 6,
"Variable 'long_6' should have 6 children")
child5 = variable.GetChildAtIndex(5)
self.DebugSBValue(child5)
self.assertTrue(int(child5.GetValue(), 0) == 6,
"long_6[5] == 6")
# Last, check that "long_6" has a value type of eValueTypeVariableLocal
# and "argc" has eValueTypeVariableArgument.
from lldbsuite.test.lldbutil import value_type_to_str
self.assertTrue(
variable.GetValueType() == lldb.eValueTypeVariableLocal,
"Variable 'long_6' should have '%s' value type." %
value_type_to_str(
lldb.eValueTypeVariableLocal))
argc = frame.FindVariable("argc")
self.DebugSBValue(argc)
self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument,
"Variable 'argc' should have '%s' value type." %
value_type_to_str(lldb.eValueTypeVariableArgument))

View File

@ -0,0 +1,3 @@
break main.c:42
continue
var

View File

@ -0,0 +1,51 @@
//===-- main.c --------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main (int argc, char const *argv[])
{
struct point_tag {
int x;
int y;
};
struct rect_tag {
struct point_tag bottom_left;
struct point_tag top_right;
};
char char_16[16] = "Hello World\n";
char *strings[] = { "Hello", "Hola", "Bonjour", "Guten Tag" };
char char_matrix[3][3] = {{'a', 'b', 'c' }, {'d', 'e', 'f' }, {'g', 'h', 'i' }};
char char_matrix_matrix[3][2][3] =
{ {{'a', 'b', 'c' }, {'d', 'e', 'f' }},
{{'A', 'B', 'C' }, {'D', 'E', 'F' }},
{{'1', '2', '3' }, {'4', '5', '6' }}};
short short_4[4] = { 1,2,3,4 };
short short_matrix[1][2] = { {1,2} };
unsigned short ushort_4[4] = { 1,2,3,4 };
unsigned short ushort_matrix[2][3] = {
{ 1, 2, 3},
{11,22,33}
};
int int_2[2] = { 1, 2 };
unsigned int uint_2[2] = { 1, 2 };
long long_6[6] = { 1, 2, 3, 4, 5, 6 };
unsigned long ulong_6[6] = { 1, 2, 3, 4, 5, 6 };
struct point_tag points_2[2] = {
{1,2},
{3,4}
};
struct point_tag points_2_4_matrix[2][4] = { // Set break point at this line.
{{ 1, 2}, { 3, 4}, { 5, 6}, { 7, 8}},
{{11,22}, {33,44}, {55,66}, {77,88}}
};
struct rect_tag rects_2[2] = {
{{1,2}, {3,4}},
{{5,6}, {7,8}}
};
return 0;
}

View File

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

View File

@ -0,0 +1,188 @@
"""Show bitfields and check that they display 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 BitfieldsTestCase(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.c', '// Set break point at this line.')
# BitFields exhibit crashes in record layout on Windows
# (http://llvm.org/pr21800)
@skipIfWindows
def test_and_run_command(self):
"""Test 'frame variable ...' on a variable with bitfields."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break inside the main.
lldbutil.run_break_set_by_file_and_line(
self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
self.runCmd("run", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'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'])
# This should display correctly.
self.expect(
"frame variable --show-types bits",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=[
'(uint32_t:1) b1 = 1',
'(uint32_t:2) b2 = 3',
'(uint32_t:3) b3 = 7',
'(uint32_t) b4 = 15',
'(uint32_t:5) b5 = 31',
'(uint32_t:6) b6 = 63',
'(uint32_t:7) b7 = 127',
'(uint32_t:4) four = 15'])
# And so should this.
# rdar://problem/8348251
self.expect(
"frame variable --show-types",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=[
'(uint32_t:1) b1 = 1',
'(uint32_t:2) b2 = 3',
'(uint32_t:3) b3 = 7',
'(uint32_t) b4 = 15',
'(uint32_t:5) b5 = 31',
'(uint32_t:6) b6 = 63',
'(uint32_t:7) b7 = 127',
'(uint32_t:4) four = 15'])
self.expect("expr (bits.b1)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '1'])
self.expect("expr (bits.b2)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '3'])
self.expect("expr (bits.b3)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '7'])
self.expect("expr (bits.b4)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '15'])
self.expect("expr (bits.b5)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '31'])
self.expect("expr (bits.b6)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '63'])
self.expect("expr (bits.b7)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '127'])
self.expect("expr (bits.four)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '15'])
self.expect(
"frame variable --show-types more_bits",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=[
'(uint32_t:3) a = 3',
'(uint8_t:1) b = \'\\0\'',
'(uint8_t:1) c = \'\\x01\'',
'(uint8_t:1) d = \'\\0\''])
self.expect("expr (more_bits.a)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', '3'])
self.expect("expr (more_bits.b)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint8_t', '\\0'])
self.expect("expr (more_bits.c)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint8_t', '\\x01'])
self.expect("expr (more_bits.d)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint8_t', '\\0'])
self.expect("expr (packed.a)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['char', "'a'"])
self.expect("expr (packed.b)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', "10"])
self.expect("expr/x (packed.c)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint32_t', "7112233"])
@add_test_categories(['pyapi'])
# BitFields exhibit crashes in record layout on Windows
# (http://llvm.org/pr21800)
@skipIfWindows
def test_and_python_api(self):
"""Use Python APIs to inspect a bitfields variable."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
breakpoint = target.BreakpointCreateByLocation("main.c", self.line)
self.assertTrue(breakpoint, VALID_BREAKPOINT)
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
thread = lldbutil.get_stopped_thread(
process, lldb.eStopReasonBreakpoint)
self.assertIsNotNone(thread)
# The breakpoint should have a hit count of 1.
self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
# Lookup the "bits" variable which contains 8 bitfields.
frame = thread.GetFrameAtIndex(0)
bits = frame.FindVariable("bits")
self.DebugSBValue(bits)
self.assertTrue(
bits.GetTypeName() == 'Bits',
"bits.GetTypeName() == 'Bits'")
self.assertTrue(
bits.GetNumChildren() == 10,
"bits.GetNumChildren() == 10")
test_compiler = self.getCompiler()
self.assertTrue(bits.GetByteSize() == 32, "bits.GetByteSize() == 32")
# Notice the pattern of int(b1.GetValue(), 0). We pass a base of 0
# so that the proper radix is determined based on the contents of the
# string.
b1 = bits.GetChildMemberWithName("b1")
self.DebugSBValue(b1)
self.assertTrue(b1.GetName() == "b1" and
b1.GetTypeName() == "uint32_t:1" and
b1.IsInScope() and
int(b1.GetValue(), 0) == 1,
'bits.b1 has type uint32_t:1, is in scope, and == 1')
b7 = bits.GetChildMemberWithName("b7")
self.DebugSBValue(b7)
self.assertTrue(b7.GetName() == "b7" and
b7.GetTypeName() == "uint32_t:7" and
b7.IsInScope() and
int(b7.GetValue(), 0) == 127,
'bits.b7 has type uint32_t:7, is in scope, and == 127')
four = bits.GetChildMemberWithName("four")
self.DebugSBValue(four)
self.assertTrue(four.GetName() == "four" and
four.GetTypeName() == "uint32_t:4" and
four.IsInScope() and
int(four.GetValue(), 0) == 15,
'bits.four has type uint32_t:4, is in scope, and == 15')
# Now kill the process, and we are done.
rc = target.GetProcess().Kill()
self.assertTrue(rc.Success())

View File

@ -0,0 +1,81 @@
//===-- 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 <stdint.h>
#include <stdio.h>
int main (int argc, char const *argv[])
{
struct Bits
{
uint32_t : 1, // Unnamed bitfield
b1 : 1,
b2 : 2,
: 2, // Unnamed bitfield
b3 : 3,
: 2, // Unnamed bitfield (this will get removed)
b4 __attribute__ ((aligned(16))),
b5 : 5,
b6 : 6,
b7 : 7,
four : 4;
};
printf("%lu", sizeof(struct Bits));
struct Bits bits;
int i;
for (i=0; i<(1<<1); i++)
bits.b1 = i; //// break $source:$line
for (i=0; i<(1<<2); i++)
bits.b2 = i; //// break $source:$line
for (i=0; i<(1<<3); i++)
bits.b3 = i; //// break $source:$line
for (i=0; i<(1<<4); i++)
bits.b4 = i; //// break $source:$line
for (i=0; i<(1<<5); i++)
bits.b5 = i; //// break $source:$line
for (i=0; i<(1<<6); i++)
bits.b6 = i; //// break $source:$line
for (i=0; i<(1<<7); i++)
bits.b7 = i; //// break $source:$line
for (i=0; i<(1<<4); i++)
bits.four = i; //// break $source:$line
struct MoreBits
{
uint32_t a : 3;
uint8_t : 1;
uint8_t b : 1;
uint8_t c : 1;
uint8_t d : 1;
};
struct MoreBits more_bits;
more_bits.a = 3;
more_bits.b = 0;
more_bits.c = 1;
more_bits.d = 0;
#pragma pack(1)
struct PackedBits
{
char a;
uint32_t b : 5,
c : 27;
};
#pragma pack()
struct PackedBits packed;
packed.a = 'a';
packed.b = 10;
packed.c = 0x7112233;
return 0; //// Set break point at this line.
}

View File

@ -0,0 +1,6 @@
LEVEL = ../../../make
C_SOURCES := main.c
CFLAGS_EXTRAS += -fblocks
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,84 @@
"""Test that lldb can invoke blocks and access variables inside them"""
from __future__ import print_function
import unittest2
import os
import time
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
class BlocksTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
lines = []
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line numbers to break at.
self.lines.append(line_number('main.c', '// Set breakpoint 0 here.'))
self.lines.append(line_number('main.c', '// Set breakpoint 1 here.'))
def launch_common(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
self.is_started = False
# Break inside the foo function which takes a bar_ptr argument.
for line in self.lines:
lldbutil.run_break_set_by_file_and_line(
self, "main.c", line, num_expected_locations=1, loc_exact=True)
self.wait_for_breakpoint()
@skipUnlessDarwin
def test_expr(self):
self.launch_common()
self.expect("expression a + b", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 7"])
self.expect("expression c", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 1"])
self.wait_for_breakpoint()
# This should display correctly.
self.expect("expression (int)neg (-12)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=["= 12"])
@skipUnlessDarwin
def test_define(self):
self.launch_common()
self.runCmd(
"expression int (^$add)(int, int) = ^int(int a, int b) { return a + b; };")
self.expect(
"expression $add(2,3)",
VARIABLES_DISPLAYED_CORRECTLY,
substrs=[" = 5"])
self.runCmd("expression int $a = 3")
self.expect(
"expression int (^$addA)(int) = ^int(int b) { return $a + b; };",
"Proper error is reported on capture",
error=True)
def wait_for_breakpoint(self):
if not self.is_started:
self.is_started = True
self.runCmd("process launch", RUN_SUCCEEDED)
else:
self.runCmd("process continue", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'stop reason = breakpoint'])

View File

@ -0,0 +1,21 @@
#include <stdio.h>
int main()
{
int c = 1;
int (^add)(int, int) = ^int(int a, int b)
{
return a + b + c; // Set breakpoint 0 here.
};
int (^neg)(int) = ^int(int a)
{
return -a;
};
printf("%d\n", add(3, 4));
printf("%d\n", neg(-5)); // Set breakpoint 1 here.
return 0;
}

View File

@ -0,0 +1,18 @@
LEVEL := ../../../make
LD_EXTRAS := -L. -l$(LIB_PREFIX)One -l$(LIB_PREFIX)Two
C_SOURCES := main.c
main.o : CFLAGS_EXTRAS += -g -O0
include $(LEVEL)/Makefile.rules
.PHONY:
a.out: lib_One lib_Two
lib_%:
$(MAKE) -f $*.mk
clean::
$(MAKE) -f One.mk clean
$(MAKE) -f Two.mk clean

View File

@ -0,0 +1,12 @@
LEVEL := ../../../make
DYLIB_NAME := One
DYLIB_C_SOURCES := One/One.c One/OneConstant.c
DYLIB_ONLY := YES
include $(LEVEL)/Makefile.rules
CFLAGS_EXTRAS += -fPIC
One/OneConstant.o: One/OneConstant.c
$(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@

View File

@ -0,0 +1,6 @@
#include "One.h"
#include <stdio.h>
void one() {
printf("One\n"); // break here
}

View File

@ -0,0 +1,4 @@
#ifndef ONE_H
#define ONE_H
void one();
#endif

View File

@ -0,0 +1 @@
int __attribute__ ((visibility("hidden"))) conflicting_symbol = 11111;

View File

@ -0,0 +1,123 @@
"""Test that conflicting symbols in different shared libraries work 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 TestConflictingSymbols(TestBase):
mydir = TestBase.compute_mydir(__file__)
NO_DEBUG_INFO_TESTCASE = True
def setUp(self):
TestBase.setUp(self)
self.One_line = line_number('One/One.c', '// break here')
self.Two_line = line_number('Two/Two.c', '// break here')
self.main_line = line_number('main.c', '// break here')
def test_conflicting_symbols(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget("a.out")
self.assertTrue(target, VALID_TARGET)
# Register our shared libraries for remote targets so they get
# automatically uploaded
environment = self.registerSharedLibrariesWithTarget(
target, ['One', 'Two'])
lldbutil.run_break_set_command(
self, 'breakpoint set -f One.c -l %s' % (self.One_line))
lldbutil.run_break_set_command(
self, 'breakpoint set -f Two.c -l %s' % (self.Two_line))
lldbutil.run_break_set_by_file_and_line(
self, 'main.c', self.main_line, num_expected_locations=1, loc_exact=True)
process = target.LaunchSimple(
None, environment, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'stop reason = breakpoint'])
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs=[' resolved, hit count = 1'])
# This should display correctly.
self.expect(
"expr (unsigned long long)conflicting_symbol",
"Symbol from One should be found",
substrs=[
"11111"])
self.runCmd("continue", 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("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs=[' resolved, hit count = 1'])
self.expect(
"expr (unsigned long long)conflicting_symbol",
"Symbol from Two should be found",
substrs=[
"22222"])
self.runCmd("continue", 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("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs=[' resolved, hit count = 1'])
self.expect(
"expr (unsigned long long)conflicting_symbol",
"An error should be printed when symbols can't be ordered",
error=True,
substrs=[
"Multiple internal symbols"])
@expectedFailureAll(bugnumber="llvm.org/pr35043")
def test_shadowed(self):
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget("a.out")
self.assertTrue(target, VALID_TARGET)
# Register our shared libraries for remote targets so they get
# automatically uploaded
environment = self.registerSharedLibrariesWithTarget(
target, ['One', 'Two'])
lldbutil.run_break_set_by_file_and_line(self, 'main.c', self.main_line)
process = target.LaunchSimple(
None, environment, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
substrs=['stopped',
'stop reason = breakpoint'])
# As we are shadowing the conflicting symbol, there should be no
# ambiguity in this expression.
self.expect(
"expr int conflicting_symbol = 474747; conflicting_symbol",
substrs=[ "474747"])

View File

@ -0,0 +1,12 @@
LEVEL := ../../../make
DYLIB_NAME := Two
DYLIB_C_SOURCES := Two/Two.c Two/TwoConstant.c
DYLIB_ONLY := YES
include $(LEVEL)/Makefile.rules
CFLAGS_EXTRAS += -fPIC
Two/TwoConstant.o: Two/TwoConstant.c
$(CC) $(CFLAGS_NO_DEBUG) -c $< -o $@

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