From 0dd6c95b3fcf0bef0a473901e47eb4c23fb30f5b Mon Sep 17 00:00:00 2001 From: "thestig@chromium.org" Date: Tue, 13 Jul 2010 18:14:27 +0000 Subject: Remove duplicate FUNC entries from dump_syms output. Review URL: http://breakpad.appspot.com/128001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@623 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/module.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/common/module.cc') diff --git a/src/common/module.cc b/src/common/module.cc index f7f5788e..01f4985f 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -49,7 +49,7 @@ Module::Module(const string &name, const string &os, Module::~Module() { for (FileByNameMap::iterator it = files_.begin(); it != files_.end(); it++) delete it->second; - for (vector::iterator it = functions_.begin(); + for (set::iterator it = functions_.begin(); it != functions_.end(); it++) delete *it; for (vector::iterator it = stack_frame_entries_.begin(); @@ -62,12 +62,17 @@ void Module::SetLoadAddress(Address address) { } void Module::AddFunction(Function *function) { - functions_.push_back(function); + std::pair::iterator,bool> ret = functions_.insert(function); + if (!ret.second) { + // Free the duplicate we failed to insert because we own it. + delete function; + } } void Module::AddFunctions(vector::iterator begin, vector::iterator end) { - functions_.insert(functions_.end(), begin, end); + for (vector::iterator it = begin; it != end; it++) + AddFunction(*it); } void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) { @@ -130,7 +135,7 @@ void Module::AssignSourceIds() { // Next, mark all files actually cited by our functions' line number // info, by setting each one's source id to zero. - for (vector::const_iterator func_it = functions_.begin(); + for (set::const_iterator func_it = functions_.begin(); func_it != functions_.end(); func_it++) { Function *func = *func_it; for (vector::iterator line_it = func->lines.begin(); @@ -145,13 +150,13 @@ void Module::AssignSourceIds() { int next_source_id = 0; for (FileByNameMap::iterator file_it = files_.begin(); file_it != files_.end(); file_it++) - if (! file_it->second->source_id) + if (!file_it->second->source_id) file_it->second->source_id = next_source_id++; } bool Module::ReportError() { fprintf(stderr, "error writing symbol file: %s\n", - strerror (errno)); + strerror(errno)); return false; } @@ -187,7 +192,7 @@ bool Module::Write(FILE *stream) { } // Write out functions and their lines. - for (vector::const_iterator func_it = functions_.begin(); + for (set::const_iterator func_it = functions_.begin(); func_it != functions_.end(); func_it++) { Function *func = *func_it; if (0 > fprintf(stream, "FUNC %llx %llx %llx %s\n", @@ -217,7 +222,7 @@ bool Module::Write(FILE *stream) { || !WriteRuleMap(entry->initial_rules, stream) || 0 > putc('\n', stream)) return ReportError(); - + // Write out this entry's delta rules as 'STACK CFI' records. for (RuleChangeMap::const_iterator delta_it = entry->rule_changes.begin(); delta_it != entry->rule_changes.end(); delta_it++) { -- cgit v1.2.1