From c85fb043ed69145a38b3680571924f376b660bcd Mon Sep 17 00:00:00 2001 From: nealsid Date: Mon, 3 Nov 2008 23:23:50 +0000 Subject: Fix for dump_syms to ignore line number information for addresses that don't have an enclosing function git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@293 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/mac/dump_syms.mm | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/common/mac/dump_syms.mm b/src/common/mac/dump_syms.mm index 34d811de..5d96a741 100644 --- a/src/common/mac/dump_syms.mm +++ b/src/common/mac/dump_syms.mm @@ -963,7 +963,9 @@ static BOOL WriteFormat(int fd, const char *fmt, ...) { NSNumber *nextAddress; uint64_t nextAddressVal; unsigned int addressCount = [sortedAddresses count]; - + + bool insideFunction = false; + for (unsigned int i = 0; i < addressCount; ++i) { NSNumber *address = [sortedAddresses objectAtIndex:i]; // skip sources that have a starting address of 0 @@ -1048,8 +1050,10 @@ static BOOL WriteFormat(int fd, const char *fmt, ...) { if (line) { if (symbol && functionLength) { + uint64_t functionLengthVal = [functionLength unsignedLongLongValue]; - + + insideFunction = true; // sanity check to make sure the length we were told does not exceed // the space between this function and the next if (nextFunctionAddress != 0) { @@ -1066,25 +1070,30 @@ static BOOL WriteFormat(int fd, const char *fmt, ...) { return NO; } - // Source line - uint64_t length = nextAddressVal - addressVal; - - // if fileNameToFileIndex/dict has an entry for the - // file/kFunctionFileKey, we're processing DWARF and have stored - // files for each program counter. If there is no entry, we're - // processing STABS and can use the old method of mapping - // addresses to files(which was basically iterating over a set - // of addresses until we reached one that was greater than the - // high PC of the current file, then moving on to the next file) - NSNumber *fileIndex = [fileNameToFileIndex objectForKey:[dict objectForKey:kFunctionFileKey]]; - if (!WriteFormat(fd, "%llx %llx %d %d\n", addressVal, length, - [line unsignedIntValue], fileIndex ? [fileIndex unsignedIntValue] : fileIdx)) - return NO; + // Throw out line number information that doesn't correspond to + // any function + if (insideFunction) { + // Source line + uint64_t length = nextAddressVal - addressVal; + + // if fileNameToFileIndex/dict has an entry for the + // file/kFunctionFileKey, we're processing DWARF and have stored + // files for each program counter. If there is no entry, we're + // processing STABS and can use the old method of mapping + // addresses to files(which was basically iterating over a set + // of addresses until we reached one that was greater than the + // high PC of the current file, then moving on to the next file) + NSNumber *fileIndex = [fileNameToFileIndex objectForKey:[dict objectForKey:kFunctionFileKey]]; + if (!WriteFormat(fd, "%llx %llx %d %d\n", addressVal, length, + [line unsignedIntValue], fileIndex ? [fileIndex unsignedIntValue] : fileIdx)) + return NO; + } } else { // PUBLIC
if (!WriteFormat(fd, "PUBLIC %llx 0 %s\n", addressVal, [symbol UTF8String])) return NO; + insideFunction = false; } } -- cgit v1.2.1