src/developer/debug/zxdb/console/input_location_parser_unittest.cc
// Tests that ParseLocalInputLocation() finds matches on the local object for symbolic names.
Tests that ParseLocalInputLocation() finds matches on the local object for symbolic names.
Tests that ParseLocalInputLocation () finds matches on the local object for symbolic names .
TEST_F(InputLocationParserTest, ParseLocalInputLocation) {
  auto& root = mock_module_symbols_->index().root();
  const char kFunctionName[] = "Foo";
  std::vector<InputLocation> results;
  Err err = ParseLocalInputLocation(nullptr, kFunctionName, &results);
  ASSERT_TRUE(err.ok());
  ASSERT_EQ(1u, results.size());
  EXPECT_EQ(InputLocation::Type::kName, results[0].type);
  EXPECT_EQ(R"("Foo")", results[0].name.GetDebugName());
  const char kClassName[] = "MyClass";
  auto my_class = fxl::MakeRefCounted<Collection>(DwarfTag::kClassType);
  my_class->set_assigned_name(kClassName);
  TestIndexedSymbol indexed_class(mock_module_symbols_, &root, kClassName, my_class);
  auto foo_func = fxl::MakeRefCounted<Function>(DwarfTag::kSubprogram);
  SymbolTestParentSetter foo_func_parent(foo_func, my_class);
  foo_func->set_assigned_name(kFunctionName);
  constexpr uint64_t kFunctionBegin = ProcessSymbolsTestSetup::kDefaultLoadAddress + 0x1000;
  foo_func->set_code_ranges(AddressRanges(AddressRange(kFunctionBegin, kFunctionBegin + 0x10)));
  TestIndexedSymbol indexed_func(mock_module_symbols_, indexed_class.index_node, kFunctionName,
                                 foo_func);
  auto my_class_ptr = fxl::MakeRefCounted<ModifiedType>(DwarfTag::kPointerType, my_class);
  auto this_var =
      fxl::MakeRefCounted<Variable>(DwarfTag::kVariable, "this", my_class_ptr, VariableLocation());
  foo_func->set_object_pointer(this_var);
  Session session;
  MockProcess process(&session);
  process.set_symbols(&symbols_.process());
  MockThread thread(&process);
  Location location(kFunctionBegin, FileLine(), 0, symbol_context_, foo_func);
  MockFrame frame(&session, &thread, location, 0x1000);
  err = ParseLocalInputLocation(&frame, kFunctionName, &results);
  ASSERT_TRUE(err.ok());
  ASSERT_EQ(2u, results.size());
  EXPECT_EQ(InputLocation::Type::kName, results[0].type);
  EXPECT_EQ(R"(::"MyClass"; ::"Foo")", results[0].name.GetDebugName());
  EXPECT_EQ(InputLocation::Type::kName, results[1].type);
  EXPECT_EQ(R"("Foo")", results[1].name.GetDebugName());
  results.clear();
  err = ParseLocalInputLocation(&frame, std::string("::") + kFunctionName, &results);
  ASSERT_TRUE(err.ok());
  ASSERT_EQ(1u, results.size());
  EXPECT_EQ(InputLocation::Type::kName, results[0].type);
  EXPECT_EQ(R"(::"Foo")", results[0].name.GetDebugName());
}
TEST_F ( InputLocationParserTest , ParseLocalInputLocation ) { auto & root = mock_module_symbols_ -> index ( ) . root ( ) ; const char kFunctionName [ ] = " " ; std :: vector < InputLocation > results ; Err err = ParseLocalInputLocation ( nullptr , kFunctionName , & results ) ; ASSERT_TRUE ( err . ok ( ) ) ; ASSERT_EQ ( 1u , results . size ( ) ) ; EXPECT_EQ ( InputLocation :: Type :: kName , results [ 0 ] . type ) ; EXPECT_EQ ( R" ( "Foo" ) " , results [ 0 ] . name . GetDebugName ( ) ) ; const char kClassName [ ] = " " ; auto my_class = fxl :: MakeRefCounted < Collection > ( DwarfTag :: kClassType ) ; my_class -> set_assigned_name ( kClassName ) ; TestIndexedSymbol indexed_class ( mock_module_symbols_ , & root , kClassName , my_class ) ; auto foo_func = fxl :: MakeRefCounted < Function > ( DwarfTag :: kSubprogram ) ; SymbolTestParentSetter foo_func_parent ( foo_func , my_class ) ; foo_func -> set_assigned_name ( kFunctionName ) ; constexpr uint64_t kFunctionBegin = ProcessSymbolsTestSetup :: kDefaultLoadAddress + 0x1000 ; foo_func -> set_code_ranges ( AddressRanges ( AddressRange ( kFunctionBegin , kFunctionBegin + 0x10 ) ) ) ; TestIndexedSymbol indexed_func ( mock_module_symbols_ , indexed_class . index_node , kFunctionName , foo_func ) ; auto my_class_ptr = fxl :: MakeRefCounted < ModifiedType > ( DwarfTag :: kPointerType , my_class ) ; auto this_var = fxl :: MakeRefCounted < Variable > ( DwarfTag :: kVariable , " " , my_class_ptr , VariableLocation ( ) ) ; foo_func -> set_object_pointer ( this_var ) ; Session session ; MockProcess process ( & session ) ; process . set_symbols ( & symbols_ . process ( ) ) ; MockThread thread ( & process ) ; Location location ( kFunctionBegin , FileLine ( ) , 0 , symbol_context_ , foo_func ) ; MockFrame frame ( & session , & thread , location , 0x1000 ) ; err = ParseLocalInputLocation ( & frame , kFunctionName , & results ) ; ASSERT_TRUE ( err . ok ( ) ) ; ASSERT_EQ ( 2u , results . size ( ) ) ; EXPECT_EQ ( InputLocation :: Type :: kName , results [ 0 ] . type ) ; EXPECT_EQ ( R" ( ::"MyClass"; ::"Foo" ) " , results [ 0 ] . name . GetDebugName ( ) ) ; EXPECT_EQ ( InputLocation :: Type :: kName , results [ 1 ] . type ) ; EXPECT_EQ ( R" ( "Foo" ) " , results [ 1 ] . name . GetDebugName ( ) ) ; results . clear ( ) ; err = ParseLocalInputLocation ( & frame , std :: string ( " " ) + kFunctionName , & results ) ; ASSERT_TRUE ( err . ok ( ) ) ; ASSERT_EQ ( 1u , results . size ( ) ) ; EXPECT_EQ ( InputLocation :: Type :: kName , results [ 0 ] . type ) ; EXPECT_EQ ( R" ( ::"Foo" ) " , results [ 0 ] . name . GetDebugName ( ) ) ; }
Tests that ParseLocalInputLocation() finds matches on the local object for symbolic names.
Tests that ParseLocalInputLocation () finds matches on the local object for symbolic names .
// The no-context case should just return the input symbol. // Make a class. // Function inside the class. // Make a "this" pointer for the function pointing back to the class. // Process/thread setup. // The location points to the first address of the function. // A new search should return the more specific version in the class, plus the global one. // A fully qualified function name ("::Foo") should not match the current class and only the // global version should be returned.