Ignore functions that have invalid addresses or sizes, instead of aborting the

symbol file load (#137).   r=mmentovai.


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@130 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
bryner 2007-03-22 23:20:17 +00:00
parent 6bc866cc82
commit 809f0cb858
4 changed files with 24 additions and 10 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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 ^ =

View file

@ -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