Exemplo n.º 1
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchSpecific)) {
    // Test that when calling ResolveSymbolContext with a specific line number,
    // only line entries
    // which match the requested line are returned.
    FileSpec fspec(m_pdb_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFile *symfile = plugin->GetSymbolFile();

    FileSpec source_file("test-pdb.cpp", false);
    FileSpec header1("test-pdb.h", false);
    FileSpec header2("test-pdb-nested.h", false);
    uint32_t cus = symfile->GetNumCompileUnits();
    EXPECT_EQ(2u, cus);

    SymbolContextList sc_list;
    uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;

    // First test with line 7, and verify that only line 7 entries are added.
    uint32_t count =
        symfile->ResolveSymbolContext(source_file, 7, true, scope, sc_list);
    EXPECT_EQ(1u, count);
    SymbolContext sc;
    EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));

    LineTable *lt = sc.comp_unit->GetLineTable();
    EXPECT_NE(nullptr, lt);
    count = lt->GetSize();
    // We expect one extra entry for termination
    EXPECT_EQ(3u, count);

    VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
    VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);

    sc_list.Clear();
    // Then test with line 9, and verify that only line 9 entries are added.
    count = symfile->ResolveSymbolContext(source_file, 9, true, scope, sc_list);
    EXPECT_EQ(1u, count);
    EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));

    lt = sc.comp_unit->GetLineTable();
    EXPECT_NE(nullptr, lt);
    count = lt->GetSize();
    // We expect one extra entry for termination
    EXPECT_EQ(3u, count);

    VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);
    VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
}
Exemplo n.º 2
0
TEST_F(SymbolFilePDBTests, REQUIRES_DIA_SDK(TestLineTablesMatchAll)) {
    // Test that when calling ResolveSymbolContext with a line number of 0, all
    // line entries from
    // the specified files are returned.
    FileSpec fspec(m_pdb_test_exe.c_str(), false);
    ArchSpec aspec("i686-pc-windows");
    lldb::ModuleSP module = std::make_shared<Module>(fspec, aspec);

    SymbolVendor *plugin = module->GetSymbolVendor();
    SymbolFile *symfile = plugin->GetSymbolFile();

    FileSpec source_file("test-pdb.cpp", false);
    FileSpec header1("test-pdb.h", false);
    FileSpec header2("test-pdb-nested.h", false);
    uint32_t cus = symfile->GetNumCompileUnits();
    EXPECT_EQ(2u, cus);

    SymbolContextList sc_list;
    uint32_t scope = lldb::eSymbolContextCompUnit | lldb::eSymbolContextLineEntry;

    uint32_t count =
        symfile->ResolveSymbolContext(source_file, 0, true, scope, sc_list);
    EXPECT_EQ(1u, count);
    SymbolContext sc;
    EXPECT_TRUE(sc_list.GetContextAtIndex(0, sc));

    LineTable *lt = sc.comp_unit->GetLineTable();
    EXPECT_NE(nullptr, lt);
    count = lt->GetSize();
    // We expect one extra entry for termination (per function)
    EXPECT_EQ(16u, count);

    VerifyLineEntry(module, sc, source_file, *lt, 7, 0x401040);
    VerifyLineEntry(module, sc, source_file, *lt, 8, 0x401043);
    VerifyLineEntry(module, sc, source_file, *lt, 9, 0x401045);

    VerifyLineEntry(module, sc, source_file, *lt, 13, 0x401050);
    VerifyLineEntry(module, sc, source_file, *lt, 14, 0x401054);
    VerifyLineEntry(module, sc, source_file, *lt, 15, 0x401070);

    VerifyLineEntry(module, sc, header1, *lt, 9, 0x401090);
    VerifyLineEntry(module, sc, header1, *lt, 10, 0x401093);
    VerifyLineEntry(module, sc, header1, *lt, 11, 0x4010a2);

    VerifyLineEntry(module, sc, header2, *lt, 5, 0x401080);
    VerifyLineEntry(module, sc, header2, *lt, 6, 0x401083);
    VerifyLineEntry(module, sc, header2, *lt, 7, 0x401089);
}