From 31166f990e5c703b3ab3e59a49e3e9665665ad88 Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Wed, 8 Oct 2014 12:06:05 +0200 Subject: [PATCH] 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 --- tools/import-trace/ElfImporter.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/import-trace/ElfImporter.cc b/tools/import-trace/ElfImporter.cc index 84c89435..9027a016 100644 --- a/tools/import-trace/ElfImporter.cc +++ b/tools/import-trace/ElfImporter.cc @@ -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;