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,12 @@
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_subdirectory(darwin-debug)
add_subdirectory(debugserver)
endif()
add_subdirectory(argdumper)
add_subdirectory(driver)
add_subdirectory(lldb-mi)
if (LLDB_CAN_USE_LLDB_SERVER)
add_subdirectory(lldb-server)
endif()
add_subdirectory(intel-features)
add_subdirectory(lldb-test)

View File

@@ -0,0 +1,6 @@
add_lldb_tool(lldb-argdumper INCLUDE_IN_FRAMEWORK
argdumper.cpp
LINK_LIBS
lldbUtility
)

View File

@@ -0,0 +1,33 @@
//===-- argdumper.cpp --------------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/StreamString.h"
#include <iostream>
using namespace lldb_private;
int main(int argc, char *argv[]) {
JSONArray::SP arguments(new JSONArray());
for (int i = 1; i < argc; i++) {
arguments->AppendObject(JSONString::SP(new JSONString(argv[i])));
}
JSONObject::SP object(new JSONObject());
object->SetObject("arguments", arguments);
StreamString ss;
object->Write(ss);
std::cout << ss.GetData() << std::endl;
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
add_lldb_tool(darwin-debug INCLUDE_IN_FRAMEWORK
darwin-debug.cpp
)

View File

@@ -0,0 +1,337 @@
//===-- Launcher.cpp --------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//----------------------------------------------------------------------
// Darwin launch helper
//
// This program was written to allow programs to be launched in a new
// Terminal.app window and have the application be stopped for debugging
// at the program entry point.
//
// Although it uses posix_spawn(), it uses Darwin specific posix spawn
// attribute flags to accomplish its task. It uses an "exec only" flag
// which avoids forking this process, and it uses a "stop at entry"
// flag to stop the program at the entry point.
//
// Since it uses darwin specific flags this code should not be compiled
// on other systems.
//----------------------------------------------------------------------
#if defined(__APPLE__)
#include <crt_externs.h> // for _NSGetEnviron()
#include <getopt.h>
#include <limits.h>
#include <mach/machine.h>
#include <signal.h>
#include <spawn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <string>
#ifndef _POSIX_SPAWN_DISABLE_ASLR
#define _POSIX_SPAWN_DISABLE_ASLR 0x0100
#endif
#define streq(a, b) strcmp(a, b) == 0
static struct option g_long_options[] = {
{"arch", required_argument, NULL, 'a'},
{"disable-aslr", no_argument, NULL, 'd'},
{"no-env", no_argument, NULL, 'e'},
{"help", no_argument, NULL, 'h'},
{"setsid", no_argument, NULL, 's'},
{"unix-socket", required_argument, NULL, 'u'},
{"working-dir", required_argument, NULL, 'w'},
{"env", required_argument, NULL, 'E'},
{NULL, 0, NULL, 0}};
static void usage() {
puts("NAME\n"
" darwin-debug -- posix spawn a process that is stopped at the entry "
"point\n"
" for debugging.\n"
"\n"
"SYNOPSIS\n"
" darwin-debug --unix-socket=<SOCKET> [--arch=<ARCH>] "
"[--working-dir=<PATH>] [--disable-aslr] [--no-env] [--setsid] [--help] "
"-- <PROGRAM> [<PROGRAM-ARG> <PROGRAM-ARG> ....]\n"
"\n"
"DESCRIPTION\n"
" darwin-debug will exec itself into a child process <PROGRAM> that "
"is\n"
" halted for debugging. It does this by using posix_spawn() along "
"with\n"
" darwin specific posix_spawn flags that allows exec only (no fork), "
"and\n"
" stop at the program entry point. Any program arguments "
"<PROGRAM-ARG> are\n"
" passed on to the exec as the arguments for the new process. The "
"current\n"
" environment will be passed to the new process unless the "
"\"--no-env\"\n"
" option is used. A unix socket must be supplied using the\n"
" --unix-socket=<SOCKET> option so the calling program can handshake "
"with\n"
" this process and get its process id.\n"
"\n"
"EXAMPLE\n"
" darwin-debug --arch=i386 -- /bin/ls -al /tmp\n");
exit(1);
}
static void exit_with_errno(int err, const char *prefix) {
if (err) {
fprintf(stderr, "%s%s", prefix ? prefix : "", strerror(err));
exit(err);
}
}
pid_t posix_spawn_for_debug(char *const *argv, char *const *envp,
const char *working_dir, cpu_type_t cpu_type,
int disable_aslr) {
pid_t pid = 0;
const char *path = argv[0];
posix_spawnattr_t attr;
exit_with_errno(::posix_spawnattr_init(&attr),
"::posix_spawnattr_init (&attr) error: ");
// Here we are using a darwin specific feature that allows us to exec only
// since we want this program to turn into the program we want to debug,
// and also have the new program start suspended (right at __dyld_start)
// so we can debug it
short flags = POSIX_SPAWN_START_SUSPENDED | POSIX_SPAWN_SETEXEC |
POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
// Disable ASLR if we were asked to
if (disable_aslr)
flags |= _POSIX_SPAWN_DISABLE_ASLR;
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);
// Set the flags we just made into our posix spawn attributes
exit_with_errno(::posix_spawnattr_setflags(&attr, flags),
"::posix_spawnattr_setflags (&attr, flags) error: ");
// Another darwin specific thing here where we can select the architecture
// of the binary we want to re-exec as.
if (cpu_type != 0) {
size_t ocount = 0;
exit_with_errno(
::posix_spawnattr_setbinpref_np(&attr, 1, &cpu_type, &ocount),
"posix_spawnattr_setbinpref_np () error: ");
}
// I wish there was a posix_spawn flag to change the working directory of
// the inferior process we will spawn, but there currently isn't. If there
// ever is a better way to do this, we should use it. I would rather not
// manually fork, chdir in the child process, and then posix_spawn with exec
// as the whole reason for doing posix_spawn is to not hose anything up
// after the fork and prior to the exec...
if (working_dir)
::chdir(working_dir);
exit_with_errno(::posix_spawnp(&pid, path, NULL, &attr, (char *const *)argv,
(char *const *)envp),
"posix_spawn() error: ");
// This code will only be reached if the posix_spawn exec failed...
::posix_spawnattr_destroy(&attr);
return pid;
}
int main(int argc, char *const *argv, char *const *envp, const char **apple) {
#if defined(DEBUG_LLDB_LAUNCHER)
const char *program_name = strrchr(apple[0], '/');
if (program_name)
program_name++; // Skip the last slash..
else
program_name = apple[0];
printf("%s called with:\n", program_name);
for (int i = 0; i < argc; ++i)
printf("argv[%u] = '%s'\n", i, argv[i]);
#endif
cpu_type_t cpu_type = 0;
bool show_usage = false;
int ch;
int disable_aslr = 0; // By default we disable ASLR
bool pass_env = true;
std::string unix_socket_name;
std::string working_dir;
#if __GLIBC__
optind = 0;
#else
optreset = 1;
optind = 1;
#endif
while ((ch = getopt_long_only(argc, argv, "a:deE:hsu:?", g_long_options,
NULL)) != -1) {
switch (ch) {
case 0:
break;
case 'a': // "-a i386" or "--arch=i386"
if (optarg) {
if (streq(optarg, "i386"))
cpu_type = CPU_TYPE_I386;
else if (streq(optarg, "x86_64"))
cpu_type = CPU_TYPE_X86_64;
else if (streq(optarg, "x86_64h"))
cpu_type = 0; // Don't set CPU type when we have x86_64h
else if (strstr(optarg, "arm") == optarg)
cpu_type = CPU_TYPE_ARM;
else {
::fprintf(stderr, "error: unsupported cpu type '%s'\n", optarg);
::exit(1);
}
}
break;
case 'd':
disable_aslr = 1;
break;
case 'e':
pass_env = false;
break;
case 'E': {
// Since we will exec this program into our new program, we can just set
// environment
// variables in this process and they will make it into the child process.
std::string name;
std::string value;
const char *equal_pos = strchr(optarg, '=');
if (equal_pos) {
name.assign(optarg, equal_pos - optarg);
value.assign(equal_pos + 1);
} else {
name = optarg;
}
::setenv(name.c_str(), value.c_str(), 1);
} break;
case 's':
// Create a new session to avoid having control-C presses kill our current
// terminal session when this program is launched from a .command file
::setsid();
break;
case 'u':
unix_socket_name.assign(optarg);
break;
case 'w': {
struct stat working_dir_stat;
if (stat(optarg, &working_dir_stat) == 0)
working_dir.assign(optarg);
else
::fprintf(stderr, "warning: working directory doesn't exist: '%s'\n",
optarg);
} break;
case 'h':
case '?':
default:
show_usage = true;
break;
}
}
argc -= optind;
argv += optind;
if (show_usage || argc <= 0 || unix_socket_name.empty())
usage();
#if defined(DEBUG_LLDB_LAUNCHER)
printf("\n%s post options:\n", program_name);
for (int i = 0; i < argc; ++i)
printf("argv[%u] = '%s'\n", i, argv[i]);
#endif
// Open the socket that was passed in as an option
struct sockaddr_un saddr_un;
int s = ::socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
perror("error: socket (AF_UNIX, SOCK_STREAM, 0)");
exit(1);
}
saddr_un.sun_family = AF_UNIX;
::strncpy(saddr_un.sun_path, unix_socket_name.c_str(),
sizeof(saddr_un.sun_path) - 1);
saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0';
saddr_un.sun_len = SUN_LEN(&saddr_un);
if (::connect(s, (struct sockaddr *)&saddr_un, SUN_LEN(&saddr_un)) < 0) {
perror("error: connect (socket, &saddr_un, saddr_un_len)");
exit(1);
}
// We were able to connect to the socket, now write our PID so whomever
// launched us will know this process's ID
char pid_str[64];
const int pid_str_len =
::snprintf(pid_str, sizeof(pid_str), "%i", ::getpid());
const int bytes_sent = ::send(s, pid_str, pid_str_len, 0);
if (pid_str_len != bytes_sent) {
perror("error: send (s, pid_str, pid_str_len, 0)");
exit(1);
}
// We are done with the socket
close(s);
system("clear");
printf("Launching: '%s'\n", argv[0]);
if (working_dir.empty()) {
char cwd[PATH_MAX];
const char *cwd_ptr = getcwd(cwd, sizeof(cwd));
printf("Working directory: '%s'\n", cwd_ptr);
} else {
printf("Working directory: '%s'\n", working_dir.c_str());
}
printf("%i arguments:\n", argc);
for (int i = 0; i < argc; ++i)
printf("argv[%u] = '%s'\n", i, argv[i]);
// Now we posix spawn to exec this process into the inferior that we want
// to debug.
posix_spawn_for_debug(
argv,
pass_env ? *_NSGetEnviron() : NULL, // Pass current environment as we may
// have modified it if "--env" options
// was used, do NOT pass "envp" here
working_dir.empty() ? NULL : working_dir.c_str(), cpu_type, disable_aslr);
return 0;
}
#endif // #if defined (__APPLE__)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.4.3)
project(Debugserver LANGUAGES C CXX ASM-ATT)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/../../cmake"
"${CMAKE_SOURCE_DIR}/../../cmake/modules"
)
include(LLDBStandalone)
include(AddLLDB)
set(LLDB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../../")
include_directories(${LLDB_SOURCE_DIR}/include)
endif()
add_subdirectory(source)

View File

@@ -0,0 +1,2 @@
_DNB*
__DNB*

View File

@@ -0,0 +1 @@
6a919cfef5de7eaf1fbf6a8e36dce87c0ece4907

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:debugserver.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
version = "1.8">
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26CE0593115C31C20022F371"
BuildableName = "debugserver"
BlueprintName = "debugserver"
ReferencedContainer = "container:debugserver.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26CE0593115C31C20022F371"
BuildableName = "debugserver"
BlueprintName = "debugserver"
ReferencedContainer = "container:debugserver.xcodeproj">
</BuildableReference>
</MacroExpansion>
<EnvironmentVariables>
<EnvironmentVariable
key = "UBBY"
value = ""
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
displayScaleIsEnabled = "NO"
displayScale = "1.00"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
queueDebuggingEnabled = "No">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26CE0593115C31C20022F371"
BuildableName = "debugserver"
BlueprintName = "debugserver"
ReferencedContainer = "container:debugserver.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
displayScaleIsEnabled = "NO"
displayScale = "1.00"
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "26CE0593115C31C20022F371"
BuildableName = "debugserver"
BlueprintName = "debugserver"
ReferencedContainer = "container:debugserver.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "UBBY"
value = ""
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,21 @@
<?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>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.debugserver</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>debugserver</string>
<key>CFBundleVersion</key>
<string>2</string>
<key>SecTaskAccess</key>
<array>
<string>allowed</string>
<string>debug</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,18 @@
fbt::exception_deliver:entry
{
printf("pid %d got an exception of type %d\n", pid, arg1);
stack();
ustack();
}
syscall::kill:entry
{
printf("pid %d called kill(%d, %d)\n", pid, arg0, arg1);
ustack();
}
syscall::__pthread_kill:entry
{
printf("pid %d called pthread_kill(%p, %d)\n", pid, arg0, arg1);
ustack();
}

View File

@@ -0,0 +1,206 @@
//===-- ARM_DWARF_Registers.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef ARM_DWARF_Registers_h_
#define ARM_DWARF_Registers_h_
enum {
dwarf_r0 = 0,
dwarf_r1,
dwarf_r2,
dwarf_r3,
dwarf_r4,
dwarf_r5,
dwarf_r6,
dwarf_r7,
dwarf_r8,
dwarf_r9,
dwarf_r10,
dwarf_r11,
dwarf_r12,
dwarf_sp,
dwarf_lr,
dwarf_pc,
dwarf_cpsr,
dwarf_s0 = 64,
dwarf_s1,
dwarf_s2,
dwarf_s3,
dwarf_s4,
dwarf_s5,
dwarf_s6,
dwarf_s7,
dwarf_s8,
dwarf_s9,
dwarf_s10,
dwarf_s11,
dwarf_s12,
dwarf_s13,
dwarf_s14,
dwarf_s15,
dwarf_s16,
dwarf_s17,
dwarf_s18,
dwarf_s19,
dwarf_s20,
dwarf_s21,
dwarf_s22,
dwarf_s23,
dwarf_s24,
dwarf_s25,
dwarf_s26,
dwarf_s27,
dwarf_s28,
dwarf_s29,
dwarf_s30,
dwarf_s31,
// FPA Registers 0-7
dwarf_f0 = 96,
dwarf_f1,
dwarf_f2,
dwarf_f3,
dwarf_f4,
dwarf_f5,
dwarf_f6,
dwarf_f7,
// Intel wireless MMX general purpose registers 0 - 7
dwarf_wCGR0 = 104,
dwarf_wCGR1,
dwarf_wCGR2,
dwarf_wCGR3,
dwarf_wCGR4,
dwarf_wCGR5,
dwarf_wCGR6,
dwarf_wCGR7,
// XScale accumulator register 07 (they do overlap with wCGR0 - wCGR7)
dwarf_ACC0 = 104,
dwarf_ACC1,
dwarf_ACC2,
dwarf_ACC3,
dwarf_ACC4,
dwarf_ACC5,
dwarf_ACC6,
dwarf_ACC7,
// Intel wireless MMX data registers 0 - 15
dwarf_wR0 = 112,
dwarf_wR1,
dwarf_wR2,
dwarf_wR3,
dwarf_wR4,
dwarf_wR5,
dwarf_wR6,
dwarf_wR7,
dwarf_wR8,
dwarf_wR9,
dwarf_wR10,
dwarf_wR11,
dwarf_wR12,
dwarf_wR13,
dwarf_wR14,
dwarf_wR15,
dwarf_spsr = 128,
dwarf_spsr_fiq,
dwarf_spsr_irq,
dwarf_spsr_abt,
dwarf_spsr_und,
dwarf_spsr_svc,
dwarf_r8_usr = 144,
dwarf_r9_usr,
dwarf_r10_usr,
dwarf_r11_usr,
dwarf_r12_usr,
dwarf_r13_usr,
dwarf_r14_usr,
dwarf_r8_fiq,
dwarf_r9_fiq,
dwarf_r10_fiq,
dwarf_r11_fiq,
dwarf_r12_fiq,
dwarf_r13_fiq,
dwarf_r14_fiq,
dwarf_r13_irq,
dwarf_r14_irq,
dwarf_r13_abt,
dwarf_r14_abt,
dwarf_r13_und,
dwarf_r14_und,
dwarf_r13_svc,
dwarf_r14_svc,
// Intel wireless MMX control register in co-processor 0 - 7
dwarf_wC0 = 192,
dwarf_wC1,
dwarf_wC2,
dwarf_wC3,
dwarf_wC4,
dwarf_wC5,
dwarf_wC6,
dwarf_wC7,
// VFP-v3/Neon
dwarf_d0 = 256,
dwarf_d1,
dwarf_d2,
dwarf_d3,
dwarf_d4,
dwarf_d5,
dwarf_d6,
dwarf_d7,
dwarf_d8,
dwarf_d9,
dwarf_d10,
dwarf_d11,
dwarf_d12,
dwarf_d13,
dwarf_d14,
dwarf_d15,
dwarf_d16,
dwarf_d17,
dwarf_d18,
dwarf_d19,
dwarf_d20,
dwarf_d21,
dwarf_d22,
dwarf_d23,
dwarf_d24,
dwarf_d25,
dwarf_d26,
dwarf_d27,
dwarf_d28,
dwarf_d29,
dwarf_d30,
dwarf_d31,
// Neon quadword registers
dwarf_q0 = 288,
dwarf_q1,
dwarf_q2,
dwarf_q3,
dwarf_q4,
dwarf_q5,
dwarf_q6,
dwarf_q7,
dwarf_q8,
dwarf_q9,
dwarf_q10,
dwarf_q11,
dwarf_q12,
dwarf_q13,
dwarf_q14,
dwarf_q15
};
#endif // ARM_DWARF_Registers_h_

View File

@@ -0,0 +1,34 @@
//===-- ARM_ehframe_Registers.h -------------------------------------*- C++
//-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef utility_ARM_ehframe_Registers_h_
#define utility_ARM_ehframe_Registers_h_
enum {
ehframe_r0 = 0,
ehframe_r1,
ehframe_r2,
ehframe_r3,
ehframe_r4,
ehframe_r5,
ehframe_r6,
ehframe_r7,
ehframe_r8,
ehframe_r9,
ehframe_r10,
ehframe_r11,
ehframe_r12,
ehframe_sp,
ehframe_lr,
ehframe_pc,
ehframe_cpsr
};
#endif // utility_ARM_ehframe_Registers_h_

View File

@@ -0,0 +1,229 @@
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/..)
include_directories(${LLDB_SOURCE_DIR}/source)
include_directories(MacOSX/DarwinLog)
include_directories(MacOSX)
#include_directories(${CMAKE_CURRENT_BINARY_DIR}/MacOSX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist")
check_cxx_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments"
CXX_SUPPORTS_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS)
if (CXX_SUPPORTS_NO_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
endif ()
check_cxx_compiler_flag("-Wno-zero-length-array"
CXX_SUPPORTS_NO_ZERO_LENGTH_ARRAY)
if (CXX_SUPPORTS_NO_ZERO_LENGTH_ARRAY)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-zero-length-array")
endif ()
check_cxx_compiler_flag("-Wno-extended-offsetof"
CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
if (CXX_SUPPORTS_NO_EXTENDED_OFFSETOF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-extended-offsetof")
endif ()
check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
add_subdirectory(MacOSX)
set(generated_mach_interfaces
${CMAKE_CURRENT_BINARY_DIR}/mach_exc.h
${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
)
add_custom_command(OUTPUT ${generated_mach_interfaces}
COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
)
set(DEBUGSERVER_VERS_GENERATED_FILE ${CMAKE_CURRENT_BINARY_DIR}/debugserver_vers.c)
set_source_files_properties(${DEBUGSERVER_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
add_custom_command(OUTPUT ${DEBUGSERVER_VERS_GENERATED_FILE}
COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj debugserver
> ${DEBUGSERVER_VERS_GENERATED_FILE}
DEPENDS ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
)
set(lldbDebugserverCommonSources
DNBArch.cpp
DNBBreakpoint.cpp
DNB.cpp
DNBDataRef.cpp
DNBError.cpp
DNBLog.cpp
DNBRegisterInfo.cpp
DNBThreadResumeActions.cpp
JSON.cpp
StdStringExtractor.cpp
# JSON reader depends on the following LLDB-common files
${LLDB_SOURCE_DIR}/source/Host/common/StringConvert.cpp
${LLDB_SOURCE_DIR}/source/Host/common/SocketAddress.cpp
# end JSON reader dependencies
libdebugserver.cpp
PseudoTerminal.cpp
PThreadEvent.cpp
PThreadMutex.cpp
RNBContext.cpp
RNBRemote.cpp
RNBServices.cpp
RNBSocket.cpp
SysSignal.cpp
TTYState.cpp
MacOSX/CFBundle.cpp
MacOSX/CFString.cpp
MacOSX/Genealogy.cpp
MacOSX/MachException.cpp
MacOSX/MachProcess.mm
MacOSX/MachTask.mm
MacOSX/MachThread.cpp
MacOSX/MachThreadList.cpp
MacOSX/MachVMMemory.cpp
MacOSX/MachVMRegion.cpp
MacOSX/OsLogger.cpp
${generated_mach_interfaces}
${DEBUGSERVER_VERS_GENERATED_FILE})
add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
if (APPLE)
if(IOS)
find_library(BACKBOARD_LIBRARY BackBoardServices
PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
find_library(FRONTBOARD_LIBRARY FrontBoardServices
PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
find_library(SPRINGBOARD_LIBRARY SpringBoardServices
PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
find_library(MOBILESERVICES_LIBRARY MobileCoreServices
PATHS ${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks)
find_library(LOCKDOWN_LIBRARY lockdown)
if(NOT BACKBOARD_LIBRARY)
set(SKIP_DEBUGSERVER True)
endif()
else()
find_library(COCOA_LIBRARY Cocoa)
endif()
endif()
if(HAVE_LIBCOMPRESSION)
set(LIBCOMPRESSION compression)
endif()
if(NOT SKIP_DEBUGSERVER)
target_link_libraries(lldbDebugserverCommon
INTERFACE ${COCOA_LIBRARY}
${CORE_FOUNDATION_LIBRARY}
${FOUNDATION_LIBRARY}
${BACKBOARD_LIBRARY}
${FRONTBOARD_LIBRARY}
${SPRINGBOARD_LIBRARY}
${MOBILESERVICES_LIBRARY}
${LOCKDOWN_LIBRARY}
lldbDebugserverArchSupport
lldbDebugserverDarwin_DarwinLog
${LIBCOMPRESSION})
if(HAVE_LIBCOMPRESSION)
set_property(TARGET lldbDebugserverCommon APPEND PROPERTY
COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
endif()
set(LLVM_OPTIONAL_SOURCES ${lldbDebugserverCommonSources})
add_lldb_tool(debugserver INCLUDE_IN_FRAMEWORK
debugserver.cpp
LINK_LIBS
lldbDebugserverCommon
)
if(IOS)
set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_DEFINITIONS
WITH_LOCKDOWN
WITH_FBS
WITH_BKS
)
set_property(TARGET debugserver APPEND PROPERTY COMPILE_DEFINITIONS
WITH_LOCKDOWN
WITH_FBS
WITH_BKS
)
set_property(TARGET lldbDebugserverCommon APPEND PROPERTY COMPILE_FLAGS
-F${CMAKE_OSX_SYSROOT}/System/Library/PrivateFrameworks
)
endif()
endif()
if(IOS)
add_library(lldbDebugserverCommon_NonUI ${lldbDebugserverCommonSources})
target_link_libraries(lldbDebugserverCommon_NonUI
INTERFACE ${COCOA_LIBRARY}
${CORE_FOUNDATION_LIBRARY}
${FOUNDATION_LIBRARY}
lldbDebugserverArchSupport
lldbDebugserverDarwin_DarwinLog
${LIBCOMPRESSION})
if(HAVE_LIBCOMPRESSION)
set_property(TARGET lldbDebugserverCommon_NonUI APPEND PROPERTY
COMPILE_DEFINITIONS HAVE_LIBCOMPRESSION)
endif()
add_lldb_tool(debugserver-nonui
debugserver.cpp
LINK_LIBS
lldbDebugserverCommon_NonUI
)
endif()
set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-macosx-entitlements.plist)
if(IOS)
set(entitlements_xml ${CMAKE_CURRENT_SOURCE_DIR}/debugserver-entitlements.plist)
endif()
set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
set(LLDB_USE_ENTITLEMENTS_Default On)
if("${LLDB_CODESIGN_IDENTITY}" STREQUAL "lldb_codesign")
set(LLDB_USE_ENTITLEMENTS_Default Off)
endif()
option(LLDB_USE_ENTITLEMENTS "Use entitlements when codesigning (Defaults Off when using lldb_codesign identity, otherwise On)" ${LLDB_USE_ENTITLEMENTS_Default})
if (NOT ("${LLDB_CODESIGN_IDENTITY}" STREQUAL ""))
if(LLDB_USE_ENTITLEMENTS)
set(entitlements_flags --entitlements ${entitlements_xml})
endif()
execute_process(
COMMAND xcrun -f codesign_allocate
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE CODESIGN_ALLOCATE
)
add_custom_command(TARGET debugserver
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
${entitlements_flags}
$<TARGET_FILE:debugserver>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
if(IOS)
add_custom_command(TARGET debugserver-nonui
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E env CODESIGN_ALLOCATE=${CODESIGN_ALLOCATE}
codesign --force --sign ${LLDB_CODESIGN_IDENTITY}
${entitlements_flags}
$<TARGET_FILE:debugserver>
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endif()
endif()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

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