Skip to content

Commit

Permalink
Merge pull request #91 from getsentry/meta/update
Browse files Browse the repository at this point in the history
Meta: update 2023-11-24
  • Loading branch information
supervacuus authored Nov 27, 2023
2 parents abdc106 + fec839d commit e63d0c2
Show file tree
Hide file tree
Showing 111 changed files with 555 additions and 288 deletions.
16 changes: 8 additions & 8 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ deps = {
'9719c1e1e676814c456b55f5f070eabad6709d31',
'crashpad/third_party/mini_chromium/mini_chromium':
Var('chromium_git') + '/chromium/mini_chromium@' +
'10f39a97650a0fe0b305415c15434443c0690a20',
'9e21183c1ea369398d6f6ddd302c8db580bd19c4',
'crashpad/third_party/libfuzzer/src':
Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' +
'fda403cf93ecb8792cb1d061564d89a6553ca020',
'crashpad/third_party/zlib/zlib':
Var('chromium_git') + '/chromium/src/third_party/zlib@' +
'13dc246a58e4b72104d35f9b1809af95221ebda7',
'fef58692c1d7bec94c4ed3d030a45a1832a9615d',

# CIPD packages.
'buildtools/linux64': {
Expand Down Expand Up @@ -89,8 +89,8 @@ deps = {
'crashpad/third_party/linux/clang/linux-amd64': {
'packages': [
{
'package': 'fuchsia/clang/linux-amd64',
'version': 'goma',
'package': 'fuchsia/third_party/clang/linux-amd64',
'version': 'Tpc85d1ZwSlZ6UKl2d96GRUBGNA5JKholOKe24sRDr0C',
},
],
'condition': 'checkout_linux and pull_linux_clang',
Expand All @@ -99,8 +99,8 @@ deps = {
'crashpad/third_party/fuchsia/clang/mac-amd64': {
'packages': [
{
'package': 'fuchsia/clang/mac-amd64',
'version': 'goma',
'package': 'fuchsia/third_party/clang/mac-amd64',
'version': 'MAOjNhwTu5JU3P_0C9dITiyCTtQ1n7lRJnMfB9hhvOkC',
},
],
'condition': 'checkout_fuchsia and host_os == "mac"',
Expand All @@ -109,8 +109,8 @@ deps = {
'crashpad/third_party/fuchsia/clang/linux-amd64': {
'packages': [
{
'package': 'fuchsia/clang/linux-amd64',
'version': 'goma',
'package': 'fuchsia/third_party/clang/linux-amd64',
'version': 'Tpc85d1ZwSlZ6UKl2d96GRUBGNA5JKholOKe24sRDr0C',
},
],
'condition': 'checkout_fuchsia and host_os == "linux"',
Expand Down
2 changes: 1 addition & 1 deletion build/ios/Unittest-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>${IOS_BUNDLE_ID_PREFIX}.googletest.${GTEST_BUNDLE_ID_SUFFIX:rfc1034identifier}</string>
<string>${IOS_BUNDLE_ID_PREFIX}.${GTEST_BUNDLE_ID_SUFFIX:rfc1034identifier}</string>
<key>UIApplicationDelegate</key>
<string>CrashpadUnitTestDelegate</string>
</dict>
Expand Down
14 changes: 12 additions & 2 deletions client/annotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ class Annotation {

std::atomic<Annotation*>& link_node() { return link_node_; }

Annotation* GetLinkNode(std::memory_order order = std::memory_order_seq_cst) {
return link_node_.load(order);
}
const Annotation* GetLinkNode(
std::memory_order order = std::memory_order_seq_cst) const {
return link_node_.load(order);
}

private:
//! \brief Linked list next-node pointer. Accessed only by \sa AnnotationList.
//!
Expand Down Expand Up @@ -323,9 +331,11 @@ class StringAnnotation : public Annotation {
void Set(base::StringPiece string) {
Annotation::ValueSizeType size =
std::min(MaxSize, base::saturated_cast<ValueSizeType>(string.size()));
memcpy(value_, string.data(), size);
string = string.substr(0, size);
std::copy(string.begin(), string.end(), value_);
// Check for no embedded `NUL` characters.
DCHECK(!memchr(value_, '\0', size)) << "embedded NUL";
DCHECK(string.find('\0', /*pos=*/0) == base::StringPiece::npos)
<< "embedded NUL";
SetSize(size);
}

Expand Down
34 changes: 32 additions & 2 deletions client/annotation_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Annotation* AnnotationList::Iterator::operator*() const {

AnnotationList::Iterator& AnnotationList::Iterator::operator++() {
CHECK_NE(curr_, tail_);
curr_ = curr_->link_node();
curr_ = curr_->GetLinkNode();
return *this;
}

Expand All @@ -86,12 +86,42 @@ bool AnnotationList::Iterator::operator==(
return curr_ == other.curr_;
}

AnnotationList::ConstIterator::ConstIterator(const Annotation* head,
const Annotation* tail)
: curr_(head), tail_(tail) {}

AnnotationList::ConstIterator::~ConstIterator() = default;

const Annotation* AnnotationList::ConstIterator::operator*() const {
CHECK_NE(curr_, tail_);
return curr_;
}

AnnotationList::ConstIterator& AnnotationList::ConstIterator::operator++() {
CHECK_NE(curr_, tail_);
curr_ = curr_->GetLinkNode();
return *this;
}

bool AnnotationList::ConstIterator::operator==(
const AnnotationList::ConstIterator& other) const {
return curr_ == other.curr_;
}

AnnotationList::Iterator AnnotationList::begin() {
return Iterator(head_.link_node(), tail_pointer_);
return Iterator(head_.GetLinkNode(), tail_pointer_);
}

AnnotationList::ConstIterator AnnotationList::cbegin() const {
return ConstIterator(head_.GetLinkNode(), tail_pointer_);
}

AnnotationList::Iterator AnnotationList::end() {
return Iterator(&tail_, tail_pointer_);
}

AnnotationList::ConstIterator AnnotationList::cend() const {
return ConstIterator(&tail_, tail_pointer_);
}

} // namespace crashpad
26 changes: 26 additions & 0 deletions client/annotation_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,37 @@ class AnnotationList {
// Copy and assign are required.
};

//! \brief An InputIterator for iterating a const AnnotationList.
class ConstIterator {
public:
~ConstIterator();

const Annotation* operator*() const;
ConstIterator& operator++();
bool operator==(const ConstIterator& other) const;
bool operator!=(const ConstIterator& other) const {
return !(*this == other);
}

private:
friend class AnnotationList;
ConstIterator(const Annotation* head, const Annotation* tail);

const Annotation* curr_;
const Annotation* const tail_;

// Copy and assign are required.
};

//! \brief Returns an iterator to the first element of the annotation list.
Iterator begin();
ConstIterator begin() const { return cbegin(); }
ConstIterator cbegin() const;

//! \brief Returns an iterator past the last element of the annotation list.
Iterator end();
ConstIterator end() const { return cend(); }
ConstIterator cend() const;

protected:
#if BUILDFLAG(IS_IOS)
Expand Down
94 changes: 94 additions & 0 deletions client/annotation_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,100 @@ TEST_F(AnnotationList, DuplicateKeys) {
EXPECT_EQ(1u, annotations.size());
}

TEST_F(AnnotationList, IteratorSingleAnnotation) {
ASSERT_EQ(annotations_.begin(), annotations_.end());
ASSERT_EQ(annotations_.cbegin(), annotations_.cend());

one_.Set("1");

auto iterator = annotations_.begin();
auto const_iterator = annotations_.cbegin();

ASSERT_NE(iterator, annotations_.end());
ASSERT_NE(const_iterator, annotations_.cend());

EXPECT_EQ(*iterator, &one_);
EXPECT_EQ(*const_iterator, &one_);

++iterator;
++const_iterator;

EXPECT_EQ(iterator, annotations_.end());
EXPECT_EQ(const_iterator, annotations_.cend());
}

TEST_F(AnnotationList, IteratorMultipleAnnotationsInserted) {
ASSERT_EQ(annotations_.begin(), annotations_.end());
ASSERT_EQ(annotations_.cbegin(), annotations_.cend());

one_.Set("1");
two_.Set("2");

// New annotations are inserted to the beginning of the list. Hence, |two_|
// must be the first annotation, followed by |one_|.
{
auto iterator = annotations_.begin();
auto const_iterator = annotations_.cbegin();

ASSERT_NE(iterator, annotations_.end());
ASSERT_NE(const_iterator, annotations_.cend());

EXPECT_EQ(*iterator, &two_);
EXPECT_EQ(*const_iterator, &two_);

++iterator;
++const_iterator;

ASSERT_NE(iterator, annotations_.end());
ASSERT_NE(const_iterator, annotations_.cend());

EXPECT_EQ(*iterator, &one_);
EXPECT_EQ(*const_iterator, &one_);

++iterator;
++const_iterator;

EXPECT_EQ(iterator, annotations_.end());
EXPECT_EQ(const_iterator, annotations_.cend());
}
}

TEST_F(AnnotationList, IteratorMultipleAnnotationsInsertedAndRemoved) {
ASSERT_EQ(annotations_.begin(), annotations_.end());
ASSERT_EQ(annotations_.cbegin(), annotations_.cend());

one_.Set("1");
two_.Set("2");
one_.Clear();
two_.Clear();

// Even after clearing, Annotations are still inserted in the list and
// reachable via the iterators.
auto iterator = annotations_.begin();
auto const_iterator = annotations_.cbegin();

ASSERT_NE(iterator, annotations_.end());
ASSERT_NE(const_iterator, annotations_.cend());

EXPECT_EQ(*iterator, &two_);
EXPECT_EQ(*const_iterator, &two_);

++iterator;
++const_iterator;

ASSERT_NE(iterator, annotations_.end());
ASSERT_NE(const_iterator, annotations_.cend());

EXPECT_EQ(*iterator, &one_);
EXPECT_EQ(*const_iterator, &one_);

++iterator;
++const_iterator;

EXPECT_EQ(iterator, annotations_.end());
EXPECT_EQ(const_iterator, annotations_.cend());
}

class RaceThread : public Thread {
public:
explicit RaceThread(test::AnnotationList* test) : Thread(), test_(test) {}
Expand Down
1 change: 1 addition & 0 deletions client/crash_report_database_generic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <tuple>
#include <utility>

#include "base/check_op.h"
#include "base/logging.h"
#include "build/build_config.h"
#include "client/settings.h"
Expand Down
8 changes: 4 additions & 4 deletions client/crash_report_database_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "base/scoped_generic.h"
#include "base/strings/strcat.h"
#include "base/strings/string_piece.h"
#include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h"
#include "client/settings.h"
#include "util/file/directory_reader.h"
Expand Down Expand Up @@ -116,9 +116,9 @@ bool CreateOrEnsureDirectoryExists(const base::FilePath& path) {
// have changed, and new_name determines whether the returned xattr name will be
// the old name or its new equivalent.
std::string XattrNameInternal(const base::StringPiece& name, bool new_name) {
return base::StringPrintf(new_name ? "org.chromium.crashpad.database.%s"
: "com.googlecode.crashpad.%s",
name.data());
return base::StrCat({new_name ? "org.chromium.crashpad.database."
: "com.googlecode.crashpad.",
name});
}

} // namespace
Expand Down
14 changes: 6 additions & 8 deletions client/crash_report_database_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <tuple>
#include <utility>

#include "base/check_op.h"
#include "base/logging.h"
#include "base/numerics/safe_math.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -545,8 +546,7 @@ void Metadata::Write() {
for (const auto& report : reports_) {
const base::FilePath& path = report.file_path;
if (path.DirName() != report_dir_) {
LOG(ERROR) << path.value().c_str() << " expected to start with "
<< base::WideToUTF8(report_dir_.value());
LOG(ERROR) << path << " expected to start with " << report_dir_;
return;
}
records.push_back(MetadataFileReportRecord(report, &string_table));
Expand Down Expand Up @@ -590,12 +590,11 @@ OperationStatus Metadata::VerifyReport(const ReportDisk& report_disk,
bool EnsureDirectory(const base::FilePath& path) {
DWORD fileattr = GetFileAttributes(path.value().c_str());
if (fileattr == INVALID_FILE_ATTRIBUTES) {
PLOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value());
PLOG(ERROR) << "GetFileAttributes " << path;
return false;
}
if ((fileattr & FILE_ATTRIBUTE_DIRECTORY) == 0) {
LOG(ERROR) << "GetFileAttributes " << base::WideToUTF8(path.value())
<< ": not a directory";
LOG(ERROR) << "GetFileAttributes " << path << ": not a directory";
return false;
}
return true;
Expand Down Expand Up @@ -877,7 +876,7 @@ OperationStatus CrashReportDatabaseWin::DeleteReport(const UUID& uuid) {
return os;

if (!DeleteFile(report_path.value().c_str())) {
PLOG(ERROR) << "DeleteFile " << base::WideToUTF8(report_path.value());
PLOG(ERROR) << "DeleteFile " << report_path;
return kFileSystemError;
}

Expand Down Expand Up @@ -1021,8 +1020,7 @@ void CrashReportDatabaseWin::CleanOrphanedAttachments() {
if (IsDirectory(path, false)) {
UUID uuid;
if (!uuid.InitializeFromString(filename.value())) {
LOG(ERROR) << "unexpected attachment dir name "
<< filename.value().c_str();
LOG(ERROR) << "unexpected attachment dir name " << filename;
continue;
}

Expand Down
6 changes: 6 additions & 0 deletions client/crashpad_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,11 +835,17 @@ class CrashpadClient {
#endif

private:
#if BUILDFLAG(IS_WIN)
//! \brief Registers process handlers for the client.
void RegisterHandlers();
#endif

#if BUILDFLAG(IS_APPLE)
base::apple::ScopedMachSendRight exception_port_;
#elif BUILDFLAG(IS_WIN)
std::wstring ipc_pipe_;
ScopedKernelHANDLE handler_start_thread_;
ScopedVectoredExceptionRegistration vectored_handler_;
#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
std::set<int> unhandled_signals_;
#endif // BUILDFLAG(IS_APPLE)
Expand Down
1 change: 1 addition & 0 deletions client/crashpad_client_fuchsia.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <lib/zx/process.h>
#include <zircon/processargs.h>

#include "base/check_op.h"
#include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h"
#include "client/client_argv_handling.h"
Expand Down
1 change: 1 addition & 0 deletions client/crashpad_client_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <atomic>

#include "base/check_op.h"
#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
Expand Down
Loading

0 comments on commit e63d0c2

Please sign in to comment.