pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lldb-netbsd: Welcome to liblldbPluginProcessNetBSD.a!
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Mon Dec 19 04:08:48 2016 +0100
Changeset: c32936e71211b272ce761e9a460b73eeee39d35b
Modified Files:
lldb-netbsd/PLIST
lldb-netbsd/distinfo
Added Files:
lldb-netbsd/patches/patch-source_Host_CMakeLists.txt
lldb-netbsd/patches/patch-source_Host_netbsd_ProcessLauncherNetBSD.cpp
Log Message:
lldb-netbsd: Welcome to liblldbPluginProcessNetBSD.a!
Add ProcessLauncherNetBSD.cpp.
It's not functional thought (not even tested at this point).
Next step is to determine why bin/ files are trimmed on install.
Sponsored by <The NetBSD Foundation>
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=c32936e71211b272ce761e9a460b73eeee39d35b
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
lldb-netbsd/PLIST | 2 +
lldb-netbsd/distinfo | 2 +
.../patches/patch-source_Host_CMakeLists.txt | 12 ++
...ch-source_Host_netbsd_ProcessLauncherNetBSD.cpp | 175 +++++++++++++++++++++
4 files changed, 191 insertions(+)
diffs:
diff --git a/lldb-netbsd/PLIST b/lldb-netbsd/PLIST
index 35fcea3..f996af6 100644
--- a/lldb-netbsd/PLIST
+++ b/lldb-netbsd/PLIST
@@ -298,6 +298,7 @@ include/lldb/Host/msvc/Config.h
include/lldb/Host/netbsd/Config.h
include/lldb/Host/netbsd/HostInfoNetBSD.h
include/lldb/Host/netbsd/HostThreadNetBSD.h
+include/lldb/Host/netbsd/ProcessLauncherNetBSD.h
include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
include/lldb/Host/posix/DomainSocket.h
include/lldb/Host/posix/Fcntl.h
@@ -577,6 +578,7 @@ lib/liblldbPluginProcessElfCore.a
lib/liblldbPluginProcessGDBRemote.a
lib/liblldbPluginProcessMachCore.a
lib/liblldbPluginProcessMinidump.a
+lib/liblldbPluginProcessNetBSD.a
lib/liblldbPluginProcessPOSIX.a
lib/liblldbPluginProcessUtility.a
lib/liblldbPluginRenderScriptRuntime.a
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index 359a0cf..05d8216 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -16,8 +16,10 @@ SHA1 (patch-cmake_LLDBDependencies.cmake) = 81673d8624ca7a9ad60bcaf530587fbfbd69
SHA1 (patch-include_lldb_Host_netbsd_HostThreadNetBSD.h) = 79f207cdb9da2ef57d39eeb307ec6d10cf828925
SHA1 (patch-include_lldb_Host_netbsd_ProcessLauncherNetBSD.h) = 5422ae06ff064f0b522148a576a7e8d3b4ea1974
SHA1 (patch-source_CMakeLists.txt) = 5dacabc3f39c23bdfd432b5a4895866157b97aa0
+SHA1 (patch-source_Host_CMakeLists.txt) = b7b5fbf2354e05c33c63bf47ffa1ef58f58727ef
SHA1 (patch-source_Host_common_NativeProcessProtocol.cpp) = 2446b1727d87e9d5e6e7a12f66d7263798ad554d
SHA1 (patch-source_Host_netbsd_HostThreadNetBSD.cpp) = a1b0fbdad062309a845cfefe4469614fbbe9d20e
+SHA1 (patch-source_Host_netbsd_ProcessLauncherNetBSD.cpp) = ba4d233967961d59e18dc88a149622727755a6d3
SHA1 (patch-source_Host_netbsd_ThisThread.cpp) = f0d32c81bc1b8fe9aeb86519ea46ba2cb16571c2
SHA1 (patch-source_Plugins_Process_CMakeLists.txt) = c0168f81da56d9896eb414e6b8bb7262de04ac33
SHA1 (patch-source_Plugins_Process_NetBSD_CMakeLists.txt) = df17afdf71c29d945c887e318718904793cd48ad
diff --git a/lldb-netbsd/patches/patch-source_Host_CMakeLists.txt b/lldb-netbsd/patches/patch-source_Host_CMakeLists.txt
new file mode 100644
index 0000000..e299a1d
--- /dev/null
+++ b/lldb-netbsd/patches/patch-source_Host_CMakeLists.txt
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- source/Host/CMakeLists.txt.orig 2016-12-17 10:30:35.000000000 +0000
++++ source/Host/CMakeLists.txt
+@@ -141,6 +141,7 @@ else()
+ netbsd/HostInfoNetBSD.cpp
+ netbsd/HostThreadNetBSD.cpp
+ netbsd/ThisThread.cpp
++ netbsd/ProcessLauncherNetBSD.cpp
+ )
+ endif()
+ endif()
diff --git a/lldb-netbsd/patches/patch-source_Host_netbsd_ProcessLauncherNetBSD.cpp b/lldb-netbsd/patches/patch-source_Host_netbsd_ProcessLauncherNetBSD.cpp
new file mode 100644
index 0000000..09273dd
--- /dev/null
+++ b/lldb-netbsd/patches/patch-source_Host_netbsd_ProcessLauncherNetBSD.cpp
@@ -0,0 +1,175 @@
+$NetBSD$
+
+--- source/Host/netbsd/ProcessLauncherNetBSD.cpp.orig 2016-12-19 03:03:08.647656376 +0000
++++ source/Host/netbsd/ProcessLauncherNetBSD.cpp
+@@ -0,0 +1,170 @@
++//===-- ProcessLauncherNetBSD.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/Host/netbsd/ProcessLauncherNetBSD.h"
++#include "lldb/Core/Log.h"
++#include "lldb/Host/FileSpec.h"
++#include "lldb/Host/Host.h"
++#include "lldb/Host/HostProcess.h"
++#include "lldb/Host/Pipe.h"
++#include "lldb/Target/ProcessLaunchInfo.h"
++
++#include <limits.h>
++#include <sys/ptrace.h>
++#include <sys/wait.h>
++
++#include <sstream>
++
++using namespace lldb;
++using namespace lldb_private;
++
++static void LLVM_ATTRIBUTE_NORETURN ExitWithError(int error_fd,
++ const char *operation) {
++ std::ostringstream os;
++ os << operation << " failed: " << strerror(errno);
++ write(error_fd, os.str().data(), os.str().size());
++ close(error_fd);
++ _exit(1);
++}
++
++static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
++ int flags) {
++ int target_fd = ::open(file_spec.GetCString(), flags, 0666);
++
++ if (target_fd == -1)
++ ExitWithError(error_fd, "DupDescriptor-open");
++
++ if (target_fd == fd)
++ return;
++
++ if (::dup2(target_fd, fd) == -1)
++ ExitWithError(error_fd, "DupDescriptor-dup2");
++
++ ::close(target_fd);
++ return;
++}
++
++static void LLVM_ATTRIBUTE_NORETURN ChildFunc(int error_fd,
++ const ProcessLaunchInfo &info) {
++ // First, make sure we disable all logging. If we are logging to stdout, our
++ // logs can be
++ // mistaken for inferior output.
++ Log::DisableAllLogChannels(nullptr);
++
++ // Do not inherit setgid powers.
++ if (setgid(getgid()) != 0)
++ ExitWithError(error_fd, "setgid");
++
++ if (info.GetFlags().Test(eLaunchFlagLaunchInSeparateProcessGroup)) {
++ if (setpgid(0, 0) != 0)
++ ExitWithError(error_fd, "setpgid");
++ }
++
++ for (size_t i = 0; i < info.GetNumFileActions(); ++i) {
++ const FileAction &action = *info.GetFileActionAtIndex(i);
++ switch (action.GetAction()) {
++ case FileAction::eFileActionClose:
++ if (close(action.GetFD()) != 0)
++ ExitWithError(error_fd, "close");
++ break;
++ case FileAction::eFileActionDuplicate:
++ if (dup2(action.GetFD(), action.GetActionArgument()) == -1)
++ ExitWithError(error_fd, "dup2");
++ break;
++ case FileAction::eFileActionOpen:
++ DupDescriptor(error_fd, action.GetFileSpec(), action.GetFD(),
++ action.GetActionArgument());
++ break;
++ case FileAction::eFileActionNone:
++ break;
++ }
++ }
++
++ const char **argv = info.GetArguments().GetConstArgumentVector();
++
++ // Change working directory
++ if (info.GetWorkingDirectory() &&
++ 0 != ::chdir(info.GetWorkingDirectory().GetCString()))
++ ExitWithError(error_fd, "chdir");
++
++ Args env = info.GetEnvironmentEntries();
++ const char **envp = env.GetConstArgumentVector();
++
++ // Clear the signal mask to prevent the child from being affected by
++ // any masking done by the parent.
++ sigset_t set;
++ if (sigemptyset(&set) != 0 ||
++ sigprocmask(SIG_SETMASK, &set, nullptr) != 0)
++ ExitWithError(error_fd, "pthread_sigmask");
++
++ if (info.GetFlags().Test(eLaunchFlagDebug)) {
++ // HACK:
++ // Close everything besides stdin, stdout, and stderr that has no file
++ // action to avoid leaking. Only do this when debugging, as elsewhere we
++ // actually rely on
++ // passing open descriptors to child processes.
++ for (int fd = 3; fd < sysconf(_SC_OPEN_MAX); ++fd)
++ if (!info.GetFileActionForFD(fd) && fd != error_fd)
++ close(fd);
++
++ // Start tracing this child that is about to exec.
++ if (ptrace(PTRACE_TRACEME, 0, nullptr, nullptr) == -1)
++ ExitWithError(error_fd, "ptrace");
++ }
++
++ // Execute. We should never return...
++ execve(argv[0], const_cast<char *const *>(argv),
++ const_cast<char *const *>(envp));
++
++ // ...unless exec fails. In which case we definitely need to end the child
++ // here.
++ ExitWithError(error_fd, "execve");
++}
++
++HostProcess
++ProcessLauncherNetBSD::LaunchProcess(const ProcessLaunchInfo &launch_info,
++ Error &error) {
++ char exe_path[PATH_MAX];
++ launch_info.GetExecutableFile().GetPath(exe_path, sizeof(exe_path));
++
++ // A pipe used by the child process to report errors.
++ PipePosix pipe;
++ const bool child_processes_inherit = false;
++ error = pipe.CreateNew(child_processes_inherit);
++ if (error.Fail())
++ return HostProcess();
++
++ ::pid_t pid = ::fork();
++ if (pid == -1) {
++ // Fork failed
++ error.SetErrorStringWithFormat("Fork failed with error message: %s",
++ strerror(errno));
++ return HostProcess(LLDB_INVALID_PROCESS_ID);
++ }
++ if (pid == 0) {
++ // child process
++ pipe.CloseReadFileDescriptor();
++ ChildFunc(pipe.ReleaseWriteFileDescriptor(), launch_info);
++ }
++
++ // parent process
++
++ pipe.CloseWriteFileDescriptor();
++ char buf[1000];
++ int r = read(pipe.GetReadFileDescriptor(), buf, sizeof buf);
++
++ if (r == 0)
++ return HostProcess(pid); // No error. We're done.
++
++ error.SetErrorString(buf);
++
++ waitpid(pid, nullptr, 0);
++
++ return HostProcess();
++}
Home |
Main Index |
Thread Index |
Old Index