mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +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
|
||||
// strings ought to be pooled.
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "minidump/minidump_file_writer.h"
|
||||
#include "minidump/test/minidump_file_writer_test_util.h"
|
||||
@ -78,7 +79,7 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
||||
|
||||
HandleSnapshot handle_snapshot;
|
||||
handle_snapshot.handle = 0x1234;
|
||||
handle_snapshot.type_name = L"Something";
|
||||
handle_snapshot.type_name = "Something";
|
||||
handle_snapshot.attributes = 0x12345678;
|
||||
handle_snapshot.granted_access = 0x9abcdef0;
|
||||
handle_snapshot.pointer_count = 4567;
|
||||
@ -95,8 +96,7 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
||||
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
||||
|
||||
const size_t kTypeNameStringDataLength =
|
||||
(handle_snapshot.type_name.size() + 1) *
|
||||
sizeof(handle_snapshot.type_name[0]);
|
||||
(handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
|
||||
ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
||||
sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
|
||||
sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) +
|
||||
@ -113,8 +113,8 @@ TEST(MinidumpHandleDataWriter, OneHandle) {
|
||||
&handle_data_stream[1]);
|
||||
EXPECT_EQ(handle_snapshot.handle, handle_descriptor->Handle);
|
||||
EXPECT_EQ(handle_snapshot.type_name,
|
||||
MinidumpStringAtRVAAsString(string_file.string(),
|
||||
handle_descriptor->TypeNameRva));
|
||||
base::UTF16ToUTF8(MinidumpStringAtRVAAsString(
|
||||
string_file.string(), handle_descriptor->TypeNameRva)));
|
||||
EXPECT_EQ(0u, handle_descriptor->ObjectNameRva);
|
||||
EXPECT_EQ(handle_snapshot.attributes, handle_descriptor->Attributes);
|
||||
EXPECT_EQ(handle_snapshot.granted_access, handle_descriptor->GrantedAccess);
|
||||
|
@ -99,13 +99,6 @@ class MinidumpUTF16StringWriter final
|
||||
//! \note Valid in #kStateMutable.
|
||||
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:
|
||||
DISALLOW_COPY_AND_ASSIGN(MinidumpUTF16StringWriter);
|
||||
};
|
||||
|
@ -53,23 +53,6 @@ TEST(MinidumpStringWriter, MinidumpUTF16StringWriter) {
|
||||
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 {
|
||||
size_t input_length;
|
||||
const char* input_string;
|
||||
|
@ -25,8 +25,8 @@ struct HandleSnapshot {
|
||||
HandleSnapshot();
|
||||
~HandleSnapshot();
|
||||
|
||||
//! \brief A string representation of the handle's type.
|
||||
std::wstring type_name;
|
||||
//! \brief A UTF-8 string representation of the handle's type.
|
||||
std::string type_name;
|
||||
|
||||
//! \brief The handle's value.
|
||||
uint32_t handle;
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "snapshot/win/memory_snapshot_win.h"
|
||||
#include "snapshot/win/module_snapshot_win.h"
|
||||
#include "util/win/registration_protocol_win.h"
|
||||
@ -211,7 +212,10 @@ std::vector<HandleSnapshot> ProcessSnapshotWin::Handles() const {
|
||||
std::vector<HandleSnapshot> result;
|
||||
for (const auto& handle : process_reader_.GetProcessInfo().Handles()) {
|
||||
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.attributes = handle.attributes;
|
||||
snapshot.granted_access = handle.granted_access;
|
||||
|
Loading…
x
Reference in New Issue
Block a user