diff options
-rw-r--r-- | src/processor/basic_source_line_resolver.cc | 18 | ||||
-rw-r--r-- | src/processor/basic_source_line_resolver_unittest.cc | 9 | ||||
-rw-r--r-- | src/processor/testdata/module1.out | 2 | ||||
-rw-r--r-- | src/processor/testdata/module4_bad.out | 5 |
4 files changed, 24 insertions, 10 deletions
diff --git a/src/processor/basic_source_line_resolver.cc b/src/processor/basic_source_line_resolver.cc index 8db41b4b..a66a4700 100644 --- a/src/processor/basic_source_line_resolver.cc +++ b/src/processor/basic_source_line_resolver.cc @@ -226,7 +226,7 @@ bool BasicSourceLineResolver::Module::LoadMap(const string &map_file) { // lines, which might be present for FUNC lines of highly-templatized // code. char buffer[8192]; - Function *cur_func = NULL; + linked_ptr<Function> cur_func; while (fgets(buffer, sizeof(buffer), f)) { if (strncmp(buffer, "FILE ", 5) == 0) { @@ -236,17 +236,17 @@ bool BasicSourceLineResolver::Module::LoadMap(const string &map_file) { return false; } } else if (strncmp(buffer, "FUNC ", 5) == 0) { - cur_func = ParseFunction(buffer); - if (!cur_func) { - return false; - } - if (!functions_.StoreRange(cur_func->address, cur_func->size, - linked_ptr<Function>(cur_func))) { + cur_func.reset(ParseFunction(buffer)); + if (!cur_func.get()) { return false; } + // StoreRange will fail if the function has an invalid address or size. + // We'll silently ignore this, the function and any corresponding lines + // will be destroyed when cur_func is released. + functions_.StoreRange(cur_func->address, cur_func->size, cur_func); } else if (strncmp(buffer, "PUBLIC ", 7) == 0) { // Clear cur_func: public symbols don't contain line number information. - cur_func = NULL; + cur_func.reset(); if (!ParsePublicSymbol(buffer)) { return false; @@ -259,7 +259,7 @@ bool BasicSourceLineResolver::Module::LoadMap(const string &map_file) { // // MODULE <guid> <age> <filename> } else { - if (!cur_func) { + if (!cur_func.get()) { return false; } Line *line = ParseLine(buffer); diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc index 96ce5ebe..63b38456 100644 --- a/src/processor/basic_source_line_resolver_unittest.cc +++ b/src/processor/basic_source_line_resolver_unittest.cc @@ -152,6 +152,10 @@ static bool RunTests() { ASSERT_FALSE(frame_info->allocates_base_pointer); ASSERT_FALSE(frame_info->program_string.empty()); + frame.instruction = 0x2000; + frame_info.reset(resolver.FillSourceLineInfo(&frame)); + ASSERT_FALSE(frame_info.get()); + TestCodeModule module2("module2"); frame.instruction = 0x2181; @@ -186,8 +190,11 @@ static bool RunTests() { testdata_dir + "/module3_bad.out")); ASSERT_FALSE(resolver.HasModule("module3")); ASSERT_FALSE(resolver.LoadModule("module4", - testdata_dir + "/invalid-filename")); + testdata_dir + "/module4_bad.out")); ASSERT_FALSE(resolver.HasModule("module4")); + ASSERT_FALSE(resolver.LoadModule("module5", + testdata_dir + "/invalid-filename")); + ASSERT_FALSE(resolver.HasModule("module5")); ASSERT_FALSE(resolver.HasModule("invalid-module")); return true; } diff --git a/src/processor/testdata/module1.out b/src/processor/testdata/module1.out index 63de4cfa..85687828 100644 --- a/src/processor/testdata/module1.out +++ b/src/processor/testdata/module1.out @@ -11,6 +11,8 @@ FUNC 1100 8 4 Function1_2 1104 4 66 2 FUNC 1200 100 8 Function1_3 FUNC 1300 100 c Function1_4 +FUNC 2000 0 0 Test_Zero_Size_Function_Is_Ignored +2000 4 88 2 STACK WIN 4 1000 c 1 0 0 0 0 0 1 $eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ = STACK WIN 4 1100 8 1 0 0 0 0 0 1 $eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ = STACK WIN 4 1100 100 1 0 0 0 0 0 1 $eip 4 + ^ = $esp $ebp 8 + = $ebp $ebp ^ = diff --git a/src/processor/testdata/module4_bad.out b/src/processor/testdata/module4_bad.out new file mode 100644 index 00000000..d01fb2cc --- /dev/null +++ b/src/processor/testdata/module4_bad.out @@ -0,0 +1,5 @@ +MODULE windows x86 444444444444444444444444444444444 module4.pdb +FILE 1 file4_1.cc +FILE 2 file4_2.cc +1000 4 44 1 +1004 4 45 1 |