Commit 58cb7e29 authored by Robert Sesek's avatar Robert Sesek Committed by Commit Bot

Update Crashpad to a7453394d6ed712a56c000dafa465857f9eee970

6dd2be7c44a9 Stop providing unimplemented stubs for
             util/mach/exc_server_variants.cc
f09257b17c36 Remove more unneeded MIG server stubs
a7453394d6ed Provide a StringPiece getter and setter for
             StringAnnotation

Bug: 598854
Change-Id: I402e191195c90891c0f44e73334cfceed2f61568
Reviewed-on: https://chromium-review.googlesource.com/774912Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517204}
parent ac7d91f7
...@@ -2,7 +2,7 @@ Name: Crashpad ...@@ -2,7 +2,7 @@ Name: Crashpad
Short Name: crashpad Short Name: crashpad
URL: https://crashpad.chromium.org/ URL: https://crashpad.chromium.org/
Version: unknown Version: unknown
Revision: d7798a4e284456702ce154e00e8adc2846f3a4f3 Revision: a7453394d6ed712a56c000dafa465857f9eee970
License: Apache 2.0 License: Apache 2.0
License File: crashpad/LICENSE License File: crashpad/LICENSE
Security Critical: yes Security Critical: yes
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
#include "base/strings/string_piece.h"
#include "build/build_config.h" #include "build/build_config.h"
namespace crashpad { namespace crashpad {
...@@ -210,6 +211,22 @@ class StringAnnotation : public Annotation { ...@@ -210,6 +211,22 @@ class StringAnnotation : public Annotation {
std::min(MaxSize, base::saturated_cast<ValueSizeType>(strlen(value)))); std::min(MaxSize, base::saturated_cast<ValueSizeType>(strlen(value))));
} }
//! \brief Sets the Annotation's string value.
//!
//! \param[in] value The string value.
void Set(base::StringPiece string) {
Annotation::ValueSizeType size =
std::min(MaxSize, base::saturated_cast<ValueSizeType>(string.size()));
memcpy(value_, string.data(), size);
// Check for no embedded `NUL` characters.
DCHECK(!memchr(value_, '\0', size));
SetSize(size);
}
const base::StringPiece value() const {
return base::StringPiece(value_, size());
}
private: private:
// This value is not `NUL`-terminated, since the size is stored by the base // This value is not `NUL`-terminated, since the size is stored by the base
// annotation. // annotation.
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "client/annotation_list.h" #include "client/annotation_list.h"
#include "client/crashpad_info.h" #include "client/crashpad_info.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "test/gtest_death_check.h"
namespace crashpad { namespace crashpad {
namespace test { namespace test {
...@@ -81,14 +82,13 @@ TEST_F(Annotation, Basics) { ...@@ -81,14 +82,13 @@ TEST_F(Annotation, Basics) {
TEST_F(Annotation, StringType) { TEST_F(Annotation, StringType) {
crashpad::StringAnnotation<5> annotation("name"); crashpad::StringAnnotation<5> annotation("name");
const char* value_ptr = static_cast<const char*>(annotation.value());
EXPECT_FALSE(annotation.is_set()); EXPECT_FALSE(annotation.is_set());
EXPECT_EQ(crashpad::Annotation::Type::kString, annotation.type()); EXPECT_EQ(crashpad::Annotation::Type::kString, annotation.type());
EXPECT_EQ(0u, annotation.size()); EXPECT_EQ(0u, annotation.size());
EXPECT_EQ(std::string("name"), annotation.name()); EXPECT_EQ(std::string("name"), annotation.name());
EXPECT_EQ(0u, strlen(value_ptr)); EXPECT_EQ(0u, annotation.value().size());
annotation.Set("test"); annotation.Set("test");
...@@ -96,15 +96,19 @@ TEST_F(Annotation, StringType) { ...@@ -96,15 +96,19 @@ TEST_F(Annotation, StringType) {
EXPECT_EQ(1u, AnnotationsCount()); EXPECT_EQ(1u, AnnotationsCount());
EXPECT_EQ(4u, annotation.size()); EXPECT_EQ(4u, annotation.size());
EXPECT_EQ(std::string("test"), value_ptr); EXPECT_EQ("test", annotation.value());
annotation.Set("loooooooooooong"); annotation.Set(std::string("loooooooooooong"));
EXPECT_TRUE(annotation.is_set()); EXPECT_TRUE(annotation.is_set());
EXPECT_EQ(1u, AnnotationsCount()); EXPECT_EQ(1u, AnnotationsCount());
EXPECT_EQ(5u, annotation.size()); EXPECT_EQ(5u, annotation.size());
EXPECT_EQ(std::string("loooo"), std::string(value_ptr, annotation.size())); EXPECT_EQ("loooo", annotation.value());
#if DCHECK_IS_ON()
EXPECT_DEATH_CHECK(annotation.Set(std::string("te\0st", 5)), "");
#endif
} }
} // namespace } // namespace
......
...@@ -18,25 +18,6 @@ ...@@ -18,25 +18,6 @@
#include "util/mach/child_portServer.h" #include "util/mach/child_portServer.h"
#include "util/mach/mach_message.h" #include "util/mach/mach_message.h"
extern "C" {
// This function is not used, and is in fact obsoleted by the other
// functionality implemented in this file. The standard MIG-generated
// child_port_server() (in child_portServer.c) server dispatch routine usable
// with the standard mach_msg_server() function calls out to this function.
// child_port_server() is unused and is replaced by the more flexible
// ChildPortServer, but the linker still needs to see this function definition.
kern_return_t handle_child_port_check_in(child_port_server_t server,
child_port_token_t token,
mach_port_t port,
mach_msg_type_name_t right_type) {
NOTREACHED();
return KERN_FAILURE;
}
} // extern "C"
namespace { namespace {
// There is no predefined constant for this. // There is no predefined constant for this.
......
...@@ -30,98 +30,6 @@ ...@@ -30,98 +30,6 @@
#include "util/mach/mach_excServer.h" #include "util/mach/mach_excServer.h"
#include "util/mach/mach_message.h" #include "util/mach/mach_message.h"
extern "C" {
// These six functions are not used, and are in fact obsoleted by the other
// functionality implemented in this file. The standard MIG-generated exc_server
// (in excServer.c) and mach_exc_server (in mach_excServer.c) server dispatch
// routines usable with the standard mach_msg_server() function call out to
// these functions. exc_server() and mach_exc_server() are unused and are
// replaced by the more flexible ExcServer and MachExcServer, but the linker
// still needs to see these six function definitions.
kern_return_t catch_exception_raise(exception_handler_t exception_port,
thread_t thread,
task_t task,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t code_count) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t catch_exception_raise_state(
exception_handler_t exception_port,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t code_count,
thread_state_flavor_t* flavor,
thread_state_t old_state,
mach_msg_type_number_t old_state_count,
thread_state_t new_state,
mach_msg_type_number_t* new_state_count) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t catch_exception_raise_state_identity(
exception_handler_t exception_port,
thread_t thread,
task_t task,
exception_type_t exception,
exception_data_t code,
mach_msg_type_number_t code_count,
thread_state_flavor_t* flavor,
thread_state_t old_state,
mach_msg_type_number_t old_state_count,
thread_state_t new_state,
mach_msg_type_number_t* new_state_count) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t catch_mach_exception_raise(exception_handler_t exception_port,
thread_t thread,
task_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t code_count) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t catch_mach_exception_raise_state(
exception_handler_t exception_port,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t code_count,
thread_state_flavor_t* flavor,
thread_state_t old_state,
mach_msg_type_number_t old_state_count,
thread_state_t new_state,
mach_msg_type_number_t* new_state_count) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t catch_mach_exception_raise_state_identity(
exception_handler_t exception_port,
thread_t thread,
task_t task,
exception_type_t exception,
mach_exception_data_t code,
mach_msg_type_number_t code_count,
thread_state_flavor_t* flavor,
thread_state_t old_state,
mach_msg_type_number_t old_state_count,
thread_state_t new_state,
mach_msg_type_number_t* new_state_count) {
NOTREACHED();
return KERN_FAILURE;
}
} // extern "C"
namespace crashpad { namespace crashpad {
namespace { namespace {
......
...@@ -73,6 +73,18 @@ def FixServerImplementation(implementation): ...@@ -73,6 +73,18 @@ def FixServerImplementation(implementation):
# Rewrite the declarations in this file as “mig_external”. # Rewrite the declarations in this file as “mig_external”.
contents = declaration_pattern.sub(r'mig_external \1', contents); contents = declaration_pattern.sub(r'mig_external \1', contents);
# Crashpad never implements the mach_msg_server() MIG callouts. To avoid
# needing to provide stub implementations, set KERN_FAILURE as the RetCode
# and abort().
routine_callout_pattern = re.compile(
r'OutP->RetCode = (([a-zA-Z0-9_]+)\(.+\));')
routine_callouts = routine_callout_pattern.findall(contents)
for routine in routine_callouts:
contents = contents.replace(routine[0], 'KERN_FAILURE; abort()')
# Include the header for abort().
contents = '#include <stdlib.h>\n' + contents
file.seek(0) file.seek(0)
file.truncate() file.truncate()
file.write(contents) file.write(contents)
......
...@@ -18,46 +18,6 @@ ...@@ -18,46 +18,6 @@
#include "util/mach/mach_message.h" #include "util/mach/mach_message.h"
#include "util/mach/notifyServer.h" #include "util/mach/notifyServer.h"
extern "C" {
// These five functions are not used, and are in fact obsoleted by the other
// functionality implemented in this file. The standard MIG-generated
// notify_server() (in notifyServer.c) server dispatch routine usable with the
// standard mach_msg_server() function calls out to this function.
// notify_server() is unused and is replaced by the more flexible NotifyServer,
// but the linker still needs to see these five function definitions.
kern_return_t do_mach_notify_port_deleted(notify_port_t notify,
mach_port_name_t name) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t do_mach_notify_port_destroyed(notify_port_t notify,
mach_port_t rights) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t do_mach_notify_no_senders(notify_port_t notify,
mach_port_mscount_t mscount) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t do_mach_notify_send_once(notify_port_t notify) {
NOTREACHED();
return KERN_FAILURE;
}
kern_return_t do_mach_notify_dead_name(notify_port_t notify,
mach_port_name_t name) {
NOTREACHED();
return KERN_FAILURE;
}
} // extern "C"
namespace { namespace {
// The MIG-generated __MIG_check__Request__*() functions are not declared as // The MIG-generated __MIG_check__Request__*() functions are not declared as
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment