From 6b66d136ca36c23a2457cad43e2a65f725e3bba6 Mon Sep 17 00:00:00 2001 From: Zequan Wu Date: Thu, 14 Oct 2021 10:39:55 -0700 Subject: [PATCH] Fix building unittests failure caused by the introduction of StringView at https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3189410 Change-Id: I258863e5de6201bc24b53dbe50b4d2515d29e338 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3221513 Reviewed-by: Mike Frysinger --- src/common/module_unittest.cc | 3 ++- src/common/stabs_to_module_unittest.cc | 6 +++--- src/common/string_view.h | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/module_unittest.cc b/src/common/module_unittest.cc index ddccc320..26964a56 100644 --- a/src/common/module_unittest.cc +++ b/src/common/module_unittest.cc @@ -193,7 +193,8 @@ TEST(Write, OmitUnusedFiles) { function->lines.push_back(line2); m.AddFunction(function); - m.AssignSourceIds(); + std::set inline_origins; + m.AssignSourceIds(inline_origins); vector vec; m.GetFiles(&vec); diff --git a/src/common/stabs_to_module_unittest.cc b/src/common/stabs_to_module_unittest.cc index 9c134e73..d265f4dc 100644 --- a/src/common/stabs_to_module_unittest.cc +++ b/src/common/stabs_to_module_unittest.cc @@ -62,7 +62,7 @@ TEST(StabsToModule, SimpleCU) { m.GetFunctions(&functions, functions.end()); ASSERT_EQ((size_t) 1, functions.size()); Module::Function *function = functions[0]; - EXPECT_STREQ("function", function->name.c_str()); + EXPECT_STREQ("function", function->name.str().c_str()); EXPECT_EQ(0xfde4abbed390c394LL, function->address); EXPECT_EQ(0x10U, function->ranges[0].size); EXPECT_EQ(0U, function->parameter_size); @@ -164,7 +164,7 @@ TEST(InferSizes, LineSize) { ASSERT_EQ((size_t) 1, functions.size()); Module::Function *function = functions[0]; - EXPECT_STREQ("function", function->name.c_str()); + EXPECT_STREQ("function", function->name.str().c_str()); EXPECT_EQ(0xb4513962eff94e92LL, function->address); EXPECT_EQ(0x1000100000000ULL, function->ranges[0].size); // inferred from CU end EXPECT_EQ(0U, function->parameter_size); @@ -214,7 +214,7 @@ TEST(FunctionNames, Mangled) { EXPECT_STREQ("std::vector >::" "push_back(unsigned long long const&)", - function->name.c_str()); + function->name.str().c_str()); EXPECT_EQ(0xf2cfda63cef7f46dLL, function->address); EXPECT_LT(0U, function->ranges[0].size); // should have used dummy size EXPECT_EQ(0U, function->parameter_size); diff --git a/src/common/string_view.h b/src/common/string_view.h index 3d59ec4e..aa01db8b 100644 --- a/src/common/string_view.h +++ b/src/common/string_view.h @@ -38,7 +38,8 @@ namespace google_breakpad { // A StringView is a string reference to a string object, but not own the -// string object. +// string object. It's a compatibile layer until we can use std::string_view in +// C++17. class StringView { private: // The start of the string, in an external buffer. It doesn't have to be