mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 22:26:06 +00:00
Fix mac after https://codereview.chromium.org/1419623003/
L"" and wstring are a bit of a mess cross-platform, so just store the type name as UTF8 instead. R=mark@chromium.org BUG=crashpad:21, crashpad:52 Review URL: https://codereview.chromium.org/1421473005 .
This commit is contained in:
parent
3261edd997
commit
fe49473b3d
@ -50,7 +50,7 @@ void MinidumpHandleDataWriter::InitializeFromSnapshot(
|
|||||||
// TODO(scottmg): There is often a number of repeated type names here, the
|
// TODO(scottmg): There is often a number of repeated type names here, the
|
||||||
// strings ought to be pooled.
|
// strings ought to be pooled.
|
||||||
strings_.push_back(new internal::MinidumpUTF16StringWriter());
|
strings_.push_back(new internal::MinidumpUTF16StringWriter());
|
||||||
strings_.back()->SetUTF16(handle_snapshot.type_name);
|
strings_.back()->SetUTF8(handle_snapshot.type_name);
|
||||||
strings_.back()->RegisterRVA(&descriptor.TypeNameRva);
|
strings_.back()->RegisterRVA(&descriptor.TypeNameRva);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "minidump/minidump_file_writer.h"
|
#include "minidump/minidump_file_writer.h"
|
||||||
#include "minidump/test/minidump_file_writer_test_util.h"
|
#include "minidump/test/minidump_file_writer_test_util.h"
|
||||||
@ -78,7 +79,7 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
|||||||
|
|
||||||
HandleSnapshot handle_snapshot;
|
HandleSnapshot handle_snapshot;
|
||||||
handle_snapshot.handle = 0x1234;
|
handle_snapshot.handle = 0x1234;
|
||||||
handle_snapshot.type_name = L"Something";
|
handle_snapshot.type_name = "Something";
|
||||||
handle_snapshot.attributes = 0x12345678;
|
handle_snapshot.attributes = 0x12345678;
|
||||||
handle_snapshot.granted_access = 0x9abcdef0;
|
handle_snapshot.granted_access = 0x9abcdef0;
|
||||||
handle_snapshot.pointer_count = 4567;
|
handle_snapshot.pointer_count = 4567;
|
||||||
@ -95,8 +96,7 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
|||||||
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
||||||
|
|
||||||
const size_t kTypeNameStringDataLength =
|
const size_t kTypeNameStringDataLength =
|
||||||
(handle_snapshot.type_name.size() + 1) *
|
(handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
|
||||||
sizeof(handle_snapshot.type_name[0]);
|
|
||||||
ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
||||||
sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
|
sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
|
||||||
sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) +
|
sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) +
|
||||||
@ -113,8 +113,8 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
|||||||
&handle_data_stream[1]);
|
&handle_data_stream[1]);
|
||||||
EXPECT_EQ(handle_snapshot.handle, handle_descriptor->Handle);
|
EXPECT_EQ(handle_snapshot.handle, handle_descriptor->Handle);
|
||||||
EXPECT_EQ(handle_snapshot.type_name,
|
EXPECT_EQ(handle_snapshot.type_name,
|
||||||
MinidumpStringAtRVAAsString(string_file.string(),
|
base::UTF16ToUTF8(MinidumpStringAtRVAAsString(
|
||||||
handle_descriptor->TypeNameRva));
|
string_file.string(), handle_descriptor->TypeNameRva)));
|
||||||
EXPECT_EQ(0u, handle_descriptor->ObjectNameRva);
|
EXPECT_EQ(0u, handle_descriptor->ObjectNameRva);
|
||||||
EXPECT_EQ(handle_snapshot.attributes, handle_descriptor->Attributes);
|
EXPECT_EQ(handle_snapshot.attributes, handle_descriptor->Attributes);
|
||||||
EXPECT_EQ(handle_snapshot.granted_access, handle_descriptor->GrantedAccess);
|
EXPECT_EQ(handle_snapshot.granted_access, handle_descriptor->GrantedAccess);
|
||||||
|
@ -99,13 +99,6 @@ class MinidumpUTF16StringWriter final
|
|||||||
//! \note Valid in #kStateMutable.
|
//! \note Valid in #kStateMutable.
|
||||||
void SetUTF8(const std::string& string_utf8);
|
void SetUTF8(const std::string& string_utf8);
|
||||||
|
|
||||||
//! \brief Sets the given UTF-16 string as the string to be written.
|
|
||||||
//!
|
|
||||||
//! \note Valid in #kStateMutable.
|
|
||||||
void SetUTF16(const base::string16& string_utf16) {
|
|
||||||
set_string(string_utf16);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(MinidumpUTF16StringWriter);
|
DISALLOW_COPY_AND_ASSIGN(MinidumpUTF16StringWriter);
|
||||||
};
|
};
|
||||||
|
@ -53,23 +53,6 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
|||||||
MinidumpStringAtRVAAsString(string_file.string(), 0));
|
MinidumpStringAtRVAAsString(string_file.string(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
SCOPED_TRACE("no conversion");
|
|
||||||
string_file.Reset();
|
|
||||||
crashpad::internal::MinidumpUTF16StringWriter string_writer;
|
|
||||||
const base::string16 kString(L"oóöőo");
|
|
||||||
string_writer.SetUTF16(kString);
|
|
||||||
EXPECT_TRUE(string_writer.WriteEverything(&string_file));
|
|
||||||
ASSERT_EQ(
|
|
||||||
sizeof(MINIDUMP_STRING) + (kString.size() + 1) * sizeof(kString[0]),
|
|
||||||
string_file.string().size());
|
|
||||||
|
|
||||||
const MINIDUMP_STRING* minidump_string =
|
|
||||||
MinidumpStringAtRVA(string_file.string(), 0);
|
|
||||||
EXPECT_TRUE(minidump_string);
|
|
||||||
EXPECT_EQ(kString, MinidumpStringAtRVAAsString(string_file.string(), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct {
|
const struct {
|
||||||
size_t input_length;
|
size_t input_length;
|
||||||
const char* input_string;
|
const char* input_string;
|
||||||
|
@ -25,8 +25,8 @@ struct HandleSnapshot {
|
|||||||
HandleSnapshot();
|
HandleSnapshot();
|
||||||
~HandleSnapshot();
|
~HandleSnapshot();
|
||||||
|
|
||||||
//! \brief A string representation of the handle's type.
|
//! \brief A UTF-8 string representation of the handle's type.
|
||||||
std::wstring type_name;
|
std::string type_name;
|
||||||
|
|
||||||
//! \brief The handle's value.
|
//! \brief The handle's value.
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "snapshot/win/memory_snapshot_win.h"
|
#include "snapshot/win/memory_snapshot_win.h"
|
||||||
#include "snapshot/win/module_snapshot_win.h"
|
#include "snapshot/win/module_snapshot_win.h"
|
||||||
#include "util/win/registration_protocol_win.h"
|
#include "util/win/registration_protocol_win.h"
|
||||||
@ -211,7 +212,10 @@ std::vector<HandleSnapshot> ProcessSnapshotWin::Handles() const {
|
|||||||
std::vector<HandleSnapshot> result;
|
std::vector<HandleSnapshot> result;
|
||||||
for (const auto& handle : process_reader_.GetProcessInfo().Handles()) {
|
for (const auto& handle : process_reader_.GetProcessInfo().Handles()) {
|
||||||
HandleSnapshot snapshot;
|
HandleSnapshot snapshot;
|
||||||
snapshot.type_name = handle.type_name;
|
// This is probably not strictly correct, but these are not localized so we
|
||||||
|
// expect them all to be in ASCII range anyway. This will need to be more
|
||||||
|
// carefully done if the object name is added.
|
||||||
|
snapshot.type_name = base::UTF16ToUTF8(handle.type_name);
|
||||||
snapshot.handle = handle.handle;
|
snapshot.handle = handle.handle;
|
||||||
snapshot.attributes = handle.attributes;
|
snapshot.attributes = handle.attributes;
|
||||||
snapshot.granted_access = handle.granted_access;
|
snapshot.granted_access = handle.granted_access;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user