From cc0c2f90df7e1abbd37efb86563a5458fcc305ea Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Mon, 8 Apr 2019 17:28:18 -0700 Subject: [PATCH] Add lss to third_party and use sys_getpid() More syscalls to come. Bug: crashpad:265 Change-Id: Ib139e638b0356426f922650249632132fd613f6f Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1540403 Commit-Queue: Joshua Peraza Reviewed-by: Mark Mentovai --- DEPS | 3 +++ client/BUILD.gn | 10 +++++++++- client/client.gyp | 1 + client/crashpad_client_linux.cc | 3 ++- third_party/lss/BUILD.gn | 31 +++++++++++++++++++++++++++++++ third_party/lss/README.crashpad | 16 ++++++++++++++++ third_party/lss/lss.gyp | 27 +++++++++++++++++++++++++++ third_party/lss/lss.h | 26 ++++++++++++++++++++++++++ 8 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 third_party/lss/BUILD.gn create mode 100644 third_party/lss/README.crashpad create mode 100644 third_party/lss/lss.gyp create mode 100644 third_party/lss/lss.h diff --git a/DEPS b/DEPS index 861d1ec0..7f08b885 100644 --- a/DEPS +++ b/DEPS @@ -28,6 +28,9 @@ deps = { 'crashpad/third_party/gyp/gyp': Var('chromium_git') + '/external/gyp@' + '8bee09f4a57807136593ddc906b0b213c21f9014', + 'crashpad/third_party/lss/lss': + Var('chromium_git') + '/linux-syscall-support.git@' + + '8048ece6c16c91acfe0d36d1d3cc0890ab6e945c', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + '471390dc9c5a4244364c0f9c5d463ebc78083e2b', diff --git a/client/BUILD.gn b/client/BUILD.gn index 56312af0..bfe03320 100644 --- a/client/BUILD.gn +++ b/client/BUILD.gn @@ -82,13 +82,21 @@ static_library("client") { "../util", ] + deps = [] + if (crashpad_is_win) { libs = [ "rpcrt4.lib" ] cflags = [ "/wd4201" ] # nonstandard extension used : nameless struct/union } + if (crashpad_is_linux || crashpad_is_android) { + deps += [ + "../third_party/lss", + ] + } + if (crashpad_is_fuchsia) { - deps = [ + deps += [ "../third_party/fuchsia", ] if (crashpad_is_in_fuchsia) { diff --git a/client/client.gyp b/client/client.gyp index a23d0c86..dcb2d0eb 100644 --- a/client/client.gyp +++ b/client/client.gyp @@ -23,6 +23,7 @@ 'dependencies': [ '../compat/compat.gyp:crashpad_compat', '../third_party/mini_chromium/mini_chromium.gyp:base', + '../third_party/lss/lss.gyp:lss', '../util/util.gyp:crashpad_util', ], 'include_dirs': [ diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc index 4b9c1752..b72980c1 100644 --- a/client/crashpad_client_linux.cc +++ b/client/crashpad_client_linux.cc @@ -25,6 +25,7 @@ #include "base/logging.h" #include "base/strings/stringprintf.h" #include "client/client_argv_handling.h" +#include "third_party/lss/lss.h" #include "util/file/file_io.h" #include "util/linux/exception_handler_client.h" #include "util/linux/exception_information.h" @@ -149,7 +150,7 @@ class LaunchAtCrashHandler { context); exception_information_.thread_id = syscall(SYS_gettid); - ScopedPrSetPtracer set_ptracer(getpid(), /* may_log= */ false); + ScopedPrSetPtracer set_ptracer(sys_getpid(), /* may_log= */ false); ScopedPrSetDumpable set_dumpable(/* may_log= */ false); pid_t pid = fork(); diff --git a/third_party/lss/BUILD.gn b/third_party/lss/BUILD.gn new file mode 100644 index 00000000..1e0bd2bf --- /dev/null +++ b/third_party/lss/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright 2019 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("../../build/crashpad_buildconfig.gni") + +config("lss_config") { + if (crashpad_is_in_chromium) { + defines = [ "CRASHPAD_LSS_SOURCE_EXTERNAL" ] + } else { + defines = [ "CRASHPAD_LSS_SOURCE_EMBEDDED" ] + } +} + +source_set("lss") { + public_configs = [ ":lss_config" ] + + sources = [ + "lss.h", + ] +} diff --git a/third_party/lss/README.crashpad b/third_party/lss/README.crashpad new file mode 100644 index 00000000..c036ae0f --- /dev/null +++ b/third_party/lss/README.crashpad @@ -0,0 +1,16 @@ +Name: linux-syscall-support +Short Name: lss +URL: https://chromium.googlesource.com/linux-syscall-support/ +Revision: See DEPS +License: BSD 3-clause +License File: lss/linux-syscall-support.h +Security Critical: yes + +Description: +Every so often, projects need to directly embed Linux system calls instead of +calling the implementations in the system runtime library. This project +provides a header file that can be included into your application whenever you +need to make direct system calls. + +Local Modifications: +None. diff --git a/third_party/lss/lss.gyp b/third_party/lss/lss.gyp new file mode 100644 index 00000000..63b9b3ae --- /dev/null +++ b/third_party/lss/lss.gyp @@ -0,0 +1,27 @@ +# Copyright 2019 The Crashpad Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +{ + 'targets': [ + { + 'target_name': 'lss', + 'type': 'none', + 'sources': [ 'lss.h' ], + 'direct_dependent_settings': { + # gyp is only used in circumstances when the embedded lss is used. + 'defines': [ 'CRASHPAD_LSS_SOURCE_EMBEDDED' ] + }, + } + ] +} diff --git a/third_party/lss/lss.h b/third_party/lss/lss.h new file mode 100644 index 00000000..11209ff8 --- /dev/null +++ b/third_party/lss/lss.h @@ -0,0 +1,26 @@ +// Copyright 2019 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_THIRD_PARTY_LSS_LSS_H_ +#define CRASHPAD_THIRD_PARTY_LSS_LSS_H_ + +#if defined(CRASHPAD_LSS_SOURCE_EXTERNAL) +#include "third_party/lss/linux_syscall_support.h" +#elif defined(CRASHPAD_LSS_SOURCE_EMBEDDED) +#include "third_party/lss/lss/linux_syscall_support.h" +#else +#error Unknown lss source +#endif + +#endif // CRASHPAD_THIRD_PARTY_LSS_LSS_H_