import-trace: fix source line mapping to file IDs

Up to now, source code lines and mappings from static instruction
addresses to lines could be linked to the wrong file if
dbg_filename.path contained duplicates.  This is unfortunately the
normal case when importing multiple variants of the same program into
the database.

Change-Id: I57e71379584d7b01177606192b3aa644846225db
This commit is contained in:
Horst Schirmeier
2014-10-08 12:06:05 +02:00
parent c8bbbb43b4
commit 31166f990e

View File

@ -291,7 +291,9 @@ bool ElfImporter::import_source_code(std::string fileName) {
currentLine = db->escape_string(currentLine);
std::stringstream ss;
ss << "SELECT file_id FROM dbg_filename WHERE path = " << "\"" << fileName.c_str() << "\"";
ss << "SELECT file_id FROM dbg_filename "
<< "WHERE path = '" << fileName.c_str() << "' "
<< "AND variant_id = " << m_variant_id;
MYSQL_RES *res = db->query(ss.str().c_str(), true);
MYSQL_ROW row;
@ -348,7 +350,9 @@ bool ElfImporter::import_mapping(std::string fileName) {
temp_addrToLine = mapping.front();
std::stringstream ss;
ss << "SELECT file_id FROM dbg_filename WHERE path = " << "\"" << temp_addrToLine.lineSource << "\"";
ss << "SELECT file_id FROM dbg_filename "
<< "WHERE path = '" << temp_addrToLine.lineSource << "' "
<< "AND variant_id = " << m_variant_id;
MYSQL_RES *res = db->query(ss.str().c_str(), true);
MYSQL_ROW row;