Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make exegesis annotator work with mappings that aren't page aligned #33

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gematria/datasets/find_accessed_addrs_exegesis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ Expected<AccessedAddrs> ExegesisAnnotator::findAccessedAddrs(
handleAllErrors(std::move(std::get<0>(BenchmarkResultOrErr)),
[&](SnippetSegmentationFault &CrashInfo) {
MemoryMapping MemMap;
MemMap.Address = CrashInfo.getAddress();
// Zero out the last twelve bits of the address to align
// the address to a page boundary.
uintptr_t MapAddress = (CrashInfo.getAddress() & ~0xfff);
MemMap.Address = MapAddress;
MemMap.MemoryValueName = "memdef1";
BenchCode.Key.MemoryMappings.push_back(MemMap);
});
Expand Down
11 changes: 11 additions & 0 deletions gematria/datasets/find_accessed_addrs_exegesis_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,16 @@ TEST_F(FindAccessedAddrsExegesisTest, ExegesisOneAccess) {
EXPECT_EQ(Result.accessed_blocks[0], 0x10000);
}

TEST_F(FindAccessedAddrsExegesisTest, ExegesisNotPageAligned) {
auto AddrsOrErr = FindAccessedAddrsExegesis(R"asm(
movq $0x10001, %rax
movq (%rax), %rax
)asm");
ASSERT_TRUE(static_cast<bool>(AddrsOrErr));
AccessedAddrs Result = *AddrsOrErr;
EXPECT_EQ(Result.accessed_blocks.size(), 1);
EXPECT_EQ(Result.accessed_blocks[0], 0x10000);
}

} // namespace
} // namespace gematria
Loading