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,131 @@
"""
Test some lldb command abbreviations.
"""
from __future__ import print_function
import lldb
import os
import time
from lldbsuite.support import seven
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
def execute_command(command):
#print('%% %s' % (command))
(exit_status, output) = seven.get_command_status_output(command)
# if output:
# print(output)
#print('status = %u' % (exit_status))
return exit_status
class ExecTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
mydir = TestBase.compute_mydir(__file__)
@skipUnlessDarwin
@expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails.
@expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
@expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
def test_hitting_exec (self):
self.do_test(False)
@skipUnlessDarwin
@expectedFailureAll(oslist=['macosx'], bugnumber="rdar://36134350") # when building with cmake on green gragon or on ci.swift.org, this test fails.
@expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
@expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
def test_skipping_exec (self):
self.do_test(False)
def do_test(self, skip_exec):
if self.getArchitecture() == 'x86_64':
source = os.path.join(os.getcwd(), "main.cpp")
o_file = os.path.join(os.getcwd(), "main.o")
execute_command(
"'%s' -g -O0 -arch i386 -arch x86_64 '%s' -c -o '%s'" %
(os.environ["CC"], source, o_file))
execute_command(
"'%s' -g -O0 -arch i386 -arch x86_64 '%s'" %
(os.environ["CC"], o_file))
if self.debug_info != "dsym":
dsym_path = os.path.join(os.getcwd(), "a.out.dSYM")
execute_command("rm -rf '%s'" % (dsym_path))
else:
self.build()
exe = os.path.join(os.getcwd(), "a.out")
# Create the target
target = self.dbg.CreateTarget(exe)
# Create any breakpoints we need
breakpoint = target.BreakpointCreateBySourceRegex(
'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False))
self.assertTrue(breakpoint, VALID_BREAKPOINT)
# Launch the process
process = target.LaunchSimple(
None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
if skip_exec:
self.debugger.HandleCommand("settings set target.process.stop-on-exec false")
def cleanup():
self.runCmd("settings set target.process.stop-on-exec false",
check=False)
# Execute the cleanup function during test case tear down.
self.addTearDownHook(cleanup)
for i in range(6):
# The stop reason of the thread should be breakpoint.
self.assertTrue(process.GetState() == lldb.eStateStopped,
STOPPED_DUE_TO_BREAKPOINT)
threads = lldbutil.get_threads_stopped_at_breakpoint(
process, breakpoint)
self.assertTrue(len(threads) == 1)
# We had a deadlock tearing down the TypeSystemMap on exec, but only if some
# expression had been evaluated. So make sure we do that here so the teardown
# is not trivial.
thread = threads[0]
value = thread.frames[0].EvaluateExpression("1 + 2")
self.assertTrue(
value.IsValid(),
"Expression evaluated successfully")
int_value = value.GetValueAsSigned()
self.assertTrue(int_value == 3, "Expression got the right result.")
# Run and we should stop due to exec
process.Continue()
if not skip_exec:
self.assertTrue(process.GetState() == lldb.eStateStopped,
"Process should be stopped at __dyld_start")
threads = lldbutil.get_stopped_threads(
process, lldb.eStopReasonExec)
self.assertTrue(
len(threads) == 1,
"We got a thread stopped for exec.")
# Run and we should stop at breakpoint in main after exec
process.Continue()
threads = lldbutil.get_threads_stopped_at_breakpoint(
process, breakpoint)
if self.TraceOn():
for t in process.threads:
print(t)
if t.GetStopReason() != lldb.eStopReasonBreakpoint:
self.runCmd("bt")
self.assertTrue(len(threads) == 1,
"Stopped at breakpoint in exec'ed process.")

View File

@ -0,0 +1,94 @@
#include <errno.h>
#include <mach/mach.h>
#include <signal.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <spawn.h>
#include <unistd.h>
static void
exit_with_errno (int err, const char *prefix)
{
if (err)
{
fprintf (stderr,
"%s%s",
prefix ? prefix : "",
strerror(err));
exit (err);
}
}
static pid_t
spawn_process (const char **argv,
const char **envp,
cpu_type_t cpu_type,
int &err)
{
pid_t pid = 0;
const posix_spawn_file_actions_t *file_actions = NULL;
posix_spawnattr_t attr;
err = posix_spawnattr_init (&attr);
if (err)
return pid;
short flags = POSIX_SPAWN_SETEXEC | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
err = posix_spawnattr_setflags (&attr, flags);
if (err == 0)
{
// Use the default signal masks
sigset_t no_signals;
sigset_t all_signals;
sigemptyset (&no_signals);
sigfillset (&all_signals);
posix_spawnattr_setsigmask(&attr, &no_signals);
posix_spawnattr_setsigdefault(&attr, &all_signals);
if (cpu_type != 0)
{
size_t ocount = 0;
err = posix_spawnattr_setbinpref_np (&attr, 1, &cpu_type, &ocount);
}
if (err == 0)
{
err = posix_spawn (&pid,
argv[0],
file_actions,
&attr,
(char * const *)argv,
(char * const *)envp);
}
posix_spawnattr_destroy(&attr);
}
return pid;
}
int
main (int argc, char const **argv)
{
printf ("pid %i: Pointer size is %zu.\n", getpid(), sizeof(void *));
int err = 0; // Set breakpoint 1 here
#if defined (__x86_64__)
if (sizeof(void *) == 8)
{
spawn_process (argv, NULL, CPU_TYPE_I386, err);
if (err)
exit_with_errno (err, "posix_spawn i386 error");
}
else
{
spawn_process (argv, NULL, CPU_TYPE_X86_64, err);
if (err)
exit_with_errno (err, "posix_spawn x86_64 error");
}
#else
spawn_process (argv, NULL, 0, err);
if (err)
exit_with_errno (err, "posix_spawn x86_64 error");
#endif
return 0;
}