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,24 @@
CC ?= clang
ifeq "$(ARCH)" ""
ARCH = x86_64
endif
ifeq "$(OS)" ""
OS = $(shell uname -s)
endif
CFLAGS ?= -g -O0
ifeq "$(OS)" "Darwin"
CFLAGS += -arch $(ARCH)
endif
all: clean
mkdir hide.app
mkdir hide.app/Contents
$(CC) $(CFLAGS) -g main.c
mv a.out.dSYM hide.app/Contents
strip -x a.out
clean:
rm -rf a.out a.out.dSYM hide.app

View File

@ -0,0 +1,49 @@
"""Test that the 'add-dsym', aka 'target symbols add', succeeds in the middle of debug session."""
from __future__ import print_function
import os
import time
import lldb
import sys
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
@skipUnlessDarwin
class AddDsymMidExecutionCommandCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
self.source = 'main.c'
@no_debug_info_test # Prevent the genaration of the dwarf version of this test
def test_add_dsym_mid_execution(self):
"""Test that add-dsym mid-execution loads the symbols at the right place for a slid binary."""
self.buildDsym(clean=True)
exe = os.path.join(os.getcwd(), "a.out")
self.target = self.dbg.CreateTarget(exe)
self.assertTrue(self.target, VALID_TARGET)
main_bp = self.target.BreakpointCreateByName("main", "a.out")
self.assertTrue(main_bp, VALID_BREAKPOINT)
self.runCmd("settings set target.disable-aslr false")
self.process = self.target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(self.process, PROCESS_IS_VALID)
# The stop reason of the thread should be breakpoint.
self.assertTrue(self.process.GetState() == lldb.eStateStopped,
STOPPED_DUE_TO_BREAKPOINT)
self.runCmd("add-dsym hide.app/Contents/a.out.dSYM")
self.expect("frame select",
substrs=['a.out`main at main.c'])

View File

@ -0,0 +1,7 @@
#include <stdio.h>
static int var = 5;
int main ()
{
printf ("%p is %d\n", &var, var); // break on this line
return ++var;
}

View File

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

View File

@ -0,0 +1,71 @@
"""
Test that clang produces the __apple accelerator tables, for example, __apple_types, 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
from lldbsuite.test.lldbutil import symbol_type_to_str
class AppleTypesTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
# rdar://problem/11166975
@skipUnlessDarwin
def test_debug_info_for_apple_types(self):
"""Test that __apple_types section does get produced by clang."""
if not self.getCompiler().endswith('clang'):
self.skipTest("clang compiler only test")
self.build()
if self.debug_info == "dsym":
exe = os.path.join(os.getcwd(),
"a.out.dSYM/Contents/Resources/DWARF/a.out")
else:
exe = os.path.join(os.getcwd(), "main.o")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
self.assertTrue(target.GetNumModules() > 0)
# Hide stdout if not running with '-t' option.
if not self.TraceOn():
self.HideStdout()
print("Number of modules for the target: %d" % target.GetNumModules())
for module in target.module_iter():
print(module)
# Get the executable module at index 0.
exe_module = target.GetModuleAtIndex(0)
dwarf_section = exe_module.FindSection("__DWARF")
self.assertTrue(dwarf_section)
print("__DWARF section:", dwarf_section)
print("Number of sub-sections: %d" % dwarf_section.GetNumSubSections())
INDENT = ' ' * 4
for subsec in dwarf_section:
print(INDENT + str(subsec))
debug_str_sub_section = dwarf_section.FindSubSection("__debug_str")
self.assertTrue(debug_str_sub_section)
print("__debug_str sub-section:", debug_str_sub_section)
# Find our __apple_types section by name.
apple_types_sub_section = dwarf_section.FindSubSection("__apple_types")
self.assertTrue(apple_types_sub_section)
print("__apple_types sub-section:", apple_types_sub_section)
# These other three all important subsections should also be present.
self.assertTrue(dwarf_section.FindSubSection("__apple_names") and
dwarf_section.FindSubSection("__apple_namespac") and
dwarf_section.FindSubSection("__apple_objc"))

View File

@ -0,0 +1,27 @@
//===-- 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;
}; // Set break point at this line.
struct rect_tag {
struct point_tag bottom_left;
struct point_tag top_right;
};
struct point_tag pt = { 2, 3 }; // This is the first executable statement.
struct rect_tag rect = {{1,2}, {3,4}};
pt.x = argc;
pt.y = argc * argc;
rect.top_right.x = rect.top_right.x + argc;
rect.top_right.y = rect.top_right.y + argc;
return 0;
}

View File

@ -0,0 +1,21 @@
CC ?= clang
ifeq "$(ARCH)" ""
ARCH = x86_64
endif
CFLAGS ?= -g -O0 -arch $(ARCH)
all: clean
$(CC) $(CFLAGS) -dynamiclib -o com.apple.sbd bundle.c
mkdir com.apple.sbd.xpc
mv com.apple.sbd com.apple.sbd.xpc/
mkdir -p com.apple.sbd.xpc.dSYM/Contents/Resources/DWARF
mv com.apple.sbd.dSYM/Contents/Resources/DWARF/com.apple.sbd com.apple.sbd.xpc.dSYM/Contents/Resources/DWARF/
rm -rf com.apple.sbd.dSYM
mkdir hide.app
tar cf - com.apple.sbd.xpc com.apple.sbd.xpc.dSYM | ( cd hide.app;tar xBpf -)
$(CC) $(CFLAGS) -o find-bundle-with-dots-in-fn main.c
clean:
rm -rf a.out a.out.dSYM hide.app com.apple.sbd com.apple.sbd.dSYM com.apple.sbd.xpc com.apple.sbd.xpc.dSYM find-bundle-with-dots-in-fn find-bundle-with-dots-in-fn.dSYM

View File

@ -0,0 +1,71 @@
"""Test that a dSYM can be found when a binary is in a bundle hnd has dots in the filename."""
from __future__ import print_function
#import unittest2
import os.path
from time import sleep
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
exe_name = 'find-bundle-with-dots-in-fn' # must match Makefile
class BundleWithDotInFilenameTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipIfRemote
@skipUnlessDarwin
# This test is explicitly a dSYM test, it doesn't need to run for any other config, but
# the following doesn't work, fixme.
# @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM")
def setUp(self):
TestBase.setUp(self)
self.source = 'main.c'
def tearDown(self):
# Destroy process before TestBase.tearDown()
self.dbg.GetSelectedTarget().GetProcess().Destroy()
# Call super's tearDown().
TestBase.tearDown(self)
def test_attach_and_check_dsyms(self):
"""Test attach to binary, see if the bundle dSYM is found"""
exe = os.path.join(os.getcwd(), exe_name)
self.build()
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
# Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in
sleep(5)
# Since the library that was dlopen()'ed is now removed, lldb will need to find the
# binary & dSYM via target.exec-search-paths
settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app"
self.runCmd(settings_str)
self.runCmd("process attach -p " + str(popen.pid))
target = self.dbg.GetSelectedTarget()
self.assertTrue(target.IsValid(), 'Should have a valid Target after attaching to process')
setup_complete = target.FindFirstGlobalVariable("setup_is_complete")
self.assertTrue(setup_complete.GetValueAsUnsigned() == 1, 'Check that inferior process has completed setup')
# Find the bundle module, see if we found the dSYM too (they're both in "hide.app")
i = 0
while i < target.GetNumModules():
mod = target.GetModuleAtIndex(i)
if mod.GetFileSpec().GetFilename() == 'com.apple.sbd':
dsym_name = mod.GetSymbolFileSpec().GetFilename()
self.assertTrue (dsym_name == 'com.apple.sbd', "Check that we found the dSYM for the bundle that was loaded")
i=i+1
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,4 @@
int foo ()
{
return 5;
}

View File

@ -0,0 +1,28 @@
#include <dlfcn.h>
#include <unistd.h>
#include <stdlib.h>
int setup_is_complete = 0;
int main()
{
void *handle = dlopen ("com.apple.sbd.xpc/com.apple.sbd", RTLD_NOW);
if (handle)
{
if (dlsym(handle, "foo"))
{
system ("/bin/rm -rf com.apple.sbd.xpc com.apple.sbd.xpc.dSYM");
setup_is_complete = 1;
// At this point we want lldb to attach to the process. If lldb attaches
// before we've removed the dlopen'ed bundle, lldb will find the bundle
// at its actual filepath and not have to do any tricky work, invalidating
// the test.
for (int loop_limiter = 0; loop_limiter < 100; loop_limiter++)
sleep (1);
}
}
return 0;
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>16B2657</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>MyFramework</string>
<key>CFBundleIdentifier</key>
<string>com.apple.test.framework</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>MyFramework</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>113</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>113</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>9L120i</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>17A261x</string>
<key>DTSDKName</key>
<string>macosx10.13</string>
<key>DTXcode</key>
<string>0900</string>
<key>DTXcodeBuild</key>
<string>9L120i</string>
</dict>
</plist>

View File

@ -0,0 +1,28 @@
CC ?= clang
ifeq "$(ARCH)" ""
ARCH = x86_64
endif
CFLAGS ?= -g -O0 -arch $(ARCH)
all: clean
$(CC) $(CFLAGS) -install_name $(PWD)/MyFramework.framework/Versions/A/MyFramework -dynamiclib -o MyFramework myframework.c
mkdir -p MyFramework.framework/Versions/A/Headers
mkdir -p MyFramework.framework/Versions/A/Resources
cp MyFramework MyFramework.framework/Versions/A
cp MyFramework.h MyFramework.framework/Versions/A/Headers
cp Info.plist MyFramework.framework/Versions/A/Resources
( cd MyFramework.framework/Versions ; ln -s A Current )
( cd MyFramework.framework/ ; ln -s Versions/Current/Headers . )
( cd MyFramework.framework/ ; ln -s Versions/Current/MyFramework . )
( cd MyFramework.framework/ ; ln -s Versions/Current/Resources . )
mv MyFramework.dSYM MyFramework.framework.dSYM
mkdir hide.app
rm -f MyFramework
tar cf - MyFramework.framework MyFramework.framework.dSYM | ( cd hide.app;tar xBpf -)
$(CC) $(CFLAGS) -o deep-bundle main.c -F. -framework MyFramework
clean:
rm -rf a.out a.out.dSYM deep-bundle deep-bundle.dSYM MyFramework.framework MyFramework.framework.dSYM MyFramework MyFramework.dSYM hide.app

View File

@ -0,0 +1,75 @@
"""Test that a dSYM can be found when a binary is in a deep bundle with multiple pathname components."""
from __future__ import print_function
#import unittest2
import os.path
from time import sleep
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
exe_name = 'deep-bundle' # must match Makefile
class DeepBundleTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipIfRemote
@skipUnlessDarwin
# This test is explicitly a dSYM test, it doesn't need to run for any other config, but
# the following doesn't work, fixme.
# @skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking explicitly for a dSYM")
def setUp(self):
TestBase.setUp(self)
self.source = 'main.c'
def tearDown(self):
# Destroy process before TestBase.tearDown()
self.dbg.GetSelectedTarget().GetProcess().Destroy()
# Call super's tearDown().
TestBase.tearDown(self)
def test_attach_and_check_dsyms(self):
"""Test attach to binary, see if the framework dSYM is found"""
exe = os.path.join(os.getcwd(), exe_name)
self.build()
popen = self.spawnSubprocess(exe)
self.addTearDownHook(self.cleanupSubprocesses)
# Give the inferior time to start up, dlopen a bundle, remove the bundle it linked in
sleep(5)
# Since the library that was dlopen()'ed is now removed, lldb will need to find the
# binary & dSYM via target.exec-search-paths
settings_str = "settings set target.exec-search-paths " + self.get_process_working_directory() + "/hide.app"
self.runCmd(settings_str)
self.runCmd("process attach -p " + str(popen.pid))
target = self.dbg.GetSelectedTarget()
self.assertTrue(target.IsValid(), 'Should have a valid Target after attaching to process')
setup_complete = target.FindFirstGlobalVariable("setup_is_complete")
self.assertTrue(setup_complete.GetValueAsUnsigned() == 1, 'Check that inferior process has completed setup')
# Find the bundle module, see if we found the dSYM too (they're both in "hide.app")
i = 0
found_module = False
while i < target.GetNumModules():
mod = target.GetModuleAtIndex(i)
if mod.GetFileSpec().GetFilename() == 'MyFramework':
found_module = True
dsym_name = mod.GetSymbolFileSpec().GetFilename()
self.assertTrue (dsym_name == 'MyFramework', "Check that we found the dSYM for the bundle that was loaded")
i=i+1
self.assertTrue(found_module, "Check that we found the framework loaded in lldb's image list")
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,22 @@
#include <MyFramework/MyFramework.h>
#include <unistd.h>
#include <stdlib.h>
int setup_is_complete = 0;
int main()
{
system ("/bin/rm -rf MyFramework MyFramework.framework MyFramework.framework.dSYM");
setup_is_complete = 1;
// At this point we want lldb to attach to the process. If lldb attaches
// before we've removed the framework we're running against, it will be
// easy for lldb to find the binary & dSYM without using target.exec-search-paths,
// which is the point of this test.
for (int loop_limiter = 0; loop_limiter < 100; loop_limiter++)
sleep (1);
return foo();
}

View File

@ -0,0 +1,4 @@
int foo ()
{
return 5;
}

View File

@ -0,0 +1,48 @@
CC ?= clang
ifeq "$(ARCH)" ""
ARCH = x86_64
endif
ifeq "$(OS)" ""
OS = $(shell uname -s)
endif
CFLAGS ?= -g -O0
CWD := $(shell pwd)
LIB_PREFIX := lib
ifeq "$(OS)" "Darwin"
CFLAGS += -arch $(ARCH)
DS := dsymutil
LD_FLAGS := -dynamiclib
LIB_INDIRECT := $(LIB_PREFIX)indirect.dylib
LIB_REEXPORT := $(LIB_PREFIX)reexport.dylib
EXEC_PATH := "@executable_path"
EXEC_PATH_INDIRECT := -install_name $(EXEC_PATH)/$(LIB_INDIRECT)
EXEC_PATH_REEXPORT := -install_name $(EXEC_PATH)/$(LIB_REEXPORT)
endif
all: a.out $(LIB_INDIRECT) $(LIB_REEXPORT)
a.out: main.o $(LIB_INDIRECT) $(LIB_REEXPORT)
$(CC) $(CFLAGS) -o a.out main.o -L. $(LIB_INDIRECT) $(LIB_REEXPORT)
main.o: main.c
$(CC) $(CFLAGS) -c main.c
$(LIB_INDIRECT): indirect.o
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_INDIRECT) -o $(LIB_INDIRECT) indirect.o
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_INDIRECT); fi
indirect.o: indirect.c
$(CC) $(CFLAGS) -c indirect.c
$(LIB_REEXPORT): reexport.o $(LIB_INDIRECT)
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_REEXPORT) -o $(LIB_REEXPORT) reexport.o -L. -lindirect -Wl,-alias_list,$(CWD)/alias.list
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_REEXPORT); fi
reexport.o: reexport.c
$(CC) $(CFLAGS) -c reexport.c
clean:
rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM)

View File

@ -0,0 +1,118 @@
"""Test stepping and setting breakpoints in indirect and re-exported symbols."""
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 TestIndirectFunctions(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Find the line numbers that we will step to in main:
self.main_source = "main.c"
@skipUnlessDarwin
@add_test_categories(['pyapi'])
def test_with_python_api(self):
"""Test stepping and setting breakpoints in indirect and re-exported symbols."""
self.build()
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
if self.platformIsDarwin():
lib1 = os.path.join(os.getcwd(), 'libindirect.dylib')
lib2 = os.path.join(os.getcwd(), 'libreexport.dylib')
self.registerSharedLibrariesWithTarget(target, [lib1, lib2])
self.main_source_spec = lldb.SBFileSpec(self.main_source)
break1 = target.BreakpointCreateBySourceRegex(
"Set breakpoint here to step in indirect.", self.main_source_spec)
self.assertTrue(break1, VALID_BREAKPOINT)
break2 = target.BreakpointCreateBySourceRegex(
"Set breakpoint here to step in reexported.", self.main_source_spec)
self.assertTrue(break2, 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)
# The stop reason of the thread should be breakpoint.
threads = lldbutil.get_threads_stopped_at_breakpoint(process, break1)
if len(threads) != 1:
self.fail("Failed to stop at breakpoint 1.")
thread = threads[0]
# Now do a step-into, and we should end up in the hidden target of this
# indirect function.
thread.StepInto()
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue(
curr_function == "call_through_indirect_hidden",
"Stepped into indirect symbols.")
# Now set a breakpoint using the indirect symbol name, and make sure we
# get to that:
break_indirect = target.BreakpointCreateByName("call_through_indirect")
self.assertTrue(break_indirect, VALID_BREAKPOINT)
# Now continue should take us to the second call through the indirect
# symbol:
threads = lldbutil.continue_to_breakpoint(process, break_indirect)
self.assertTrue(
len(threads) == 1,
"Stopped at breakpoint in indirect function.")
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue(
curr_function == "call_through_indirect_hidden",
"Stepped into indirect symbols.")
# Delete this breakpoint so it won't get in the way:
target.BreakpointDelete(break_indirect.GetID())
# Now continue to the site of the first re-exported function call in
# main:
threads = lldbutil.continue_to_breakpoint(process, break2)
# This is stepping Into through a re-exported symbol to an indirect
# symbol:
thread.StepInto()
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue(
curr_function == "call_through_indirect_hidden",
"Stepped into indirect symbols.")
# And the last bit is to set a breakpoint on the re-exported symbol and
# make sure we are again in out target function.
break_reexported = target.BreakpointCreateByName(
"reexport_to_indirect")
self.assertTrue(break_reexported, VALID_BREAKPOINT)
# Now continue should take us to the second call through the indirect
# symbol:
threads = lldbutil.continue_to_breakpoint(process, break_reexported)
self.assertTrue(
len(threads) == 1,
"Stopped at breakpoint in reexported function target.")
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
self.assertTrue(
curr_function == "call_through_indirect_hidden",
"Stepped into indirect symbols.")

View File

@ -0,0 +1 @@
_call_through_indirect _reexport_to_indirect

View File

@ -0,0 +1,14 @@
#define MakeResolver(name) \
void * name ## Resolver(void) __asm__("_" #name); \
void * name ## Resolver(void) { \
__asm__(".symbol_resolver _" #name); \
return name ## _hidden; \
}
int
call_through_indirect_hidden(int arg)
{
return arg + 5;
}
MakeResolver(call_through_indirect)

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