aboutsummaryrefslogtreecommitdiff
path: root/src/common/stabs_reader_unittest.cc
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:13:42 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-05-05 17:13:42 +0000
commitdeb500f6c85e4eb65218d171dbdbc528df8ebcfe (patch)
tree0ea47cd891eabf867536fae5a866ca3d5e4a4837 /src/common/stabs_reader_unittest.cc
parentBreakpad Linux dumper: Rename DumpStabsHandler to StabsToModule. (diff)
downloadbreakpad-deb500f6c85e4eb65218d171dbdbc528df8ebcfe.tar.xz
Breakpad STABS reader: Properly compute function end addresses.
An N_FUN stabs with no name is an explicit end-of-function marker, whose value is the size of the function. This patch changes the stabs reader to recognize these and use them to compute the function's ending address, instead of treating them as functions with no names and mysterious addresses. It also adds appropriate unit tests. a=jimblandy, r=thestig git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@585 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/stabs_reader_unittest.cc')
-rw-r--r--src/common/stabs_reader_unittest.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/common/stabs_reader_unittest.cc b/src/common/stabs_reader_unittest.cc
index 74897c46..df37995c 100644
--- a/src/common/stabs_reader_unittest.cc
+++ b/src/common/stabs_reader_unittest.cc
@@ -455,6 +455,49 @@ TEST(StabsReader, MultipleCUs) {
ASSERT_TRUE(ApplyHandlerToMockStabsData(&stabs, &strings, &mock_handler));
}
+TEST_F(Stabs, FunctionEnd) {
+ stabs.set_endianness(kLittleEndian);
+ stabs.set_value_size(8);
+ stabs
+ .Stab(N_SO, 102, 62362, 0x52a830d644cd6942ULL, "compilation unit")
+ // This function is terminated by the start of the next function.
+ .Stab(N_FUN, 216, 38405, 0xbb5ab70ecdd23bfeULL, "function 1")
+ // This function is terminated by an explicit end-of-function stab,
+ // whose value is a size in bytes.
+ .Stab(N_FUN, 240, 10973, 0xc954de9b8fb3e5e2ULL, "function 2")
+ .Stab(N_FUN, 14, 36749, 0xc1ab, "")
+ // This function is terminated by the end of the compilation unit.
+ .Stab(N_FUN, 143, 64514, 0xdff98c9a35386e1fULL, "function 3")
+ .Stab(N_SO, 164, 60142, 0xfdacb856e78bbf57ULL, "");
+
+ {
+ InSequence s;
+ EXPECT_CALL(mock_handler,
+ StartCompilationUnit(StrEq("compilation unit"),
+ 0x52a830d644cd6942ULL, NULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler,
+ StartFunction(Eq("function 1"), 0xbb5ab70ecdd23bfeULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler, EndFunction(0xc954de9b8fb3e5e2ULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler,
+ StartFunction(Eq("function 2"), 0xc954de9b8fb3e5e2ULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler, EndFunction(0xc954de9b8fb3e5e2ULL + 0xc1ab))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler,
+ StartFunction(Eq("function 3"), 0xdff98c9a35386e1fULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler, EndFunction(0xfdacb856e78bbf57ULL))
+ .WillOnce(Return(true));
+ EXPECT_CALL(mock_handler, EndCompilationUnit(0xfdacb856e78bbf57ULL))
+ .WillOnce(Return(true));
+ }
+
+ ASSERT_TRUE(ApplyHandlerToMockStabsData());
+}
+
// name duplication
} // anonymous namespace