import-trace: ElfImporter cleanups

-  added several insert_multiple() flushes (which completely broke
    the import before)
 -  import_source_code() refactored
 -  parameter naming improved
 -  better error handling
 -  whitespace/coding-style cleanups
 -  documentation added + cleanups

Change-Id: I70ac95391b9678e0dcce8adfa7df69a4f91ca30d
This commit is contained in:
Horst Schirmeier
2014-10-08 13:06:12 +02:00
parent 31166f990e
commit 8fcbc7eeae
2 changed files with 125 additions and 113 deletions

View File

@ -14,21 +14,18 @@
/**
The ElfImporter is not a real trace importer, but we locate it
into the import-trace utility, since here the infrastructure is
already in place to import things related to an elf binary into
already in place to import things related to an ELF binary into
the database.
The ElfImporter calls objdump and dissassembles an elf binary
The ElfImporter calls objdump and dissassembles an ELF binary
and imports the results into the database
In addition, debugging information can be imported:
If the --sources option is set, the source files will be imported
into the database. Only the files that were actually used in the
elf binary will be imported.
If the --debug option is set, the line number table of the elf binary will
be imported into the database. The information will be stored in the
"mapping" table.
ELF binary will be imported. Additionally, the line number table of the
ELF binary will be imported into the database.
*/
class ElfImporter : public Importer {
llvm::OwningPtr<llvm::object::Binary> binary;
@ -44,24 +41,24 @@ class ElfImporter : public Importer {
/* Imports a single instruction into the objdump table */
bool import_instruction(fail::address_t addr, char opcode[16], int opcode_length,
const std::string &instruction, const std::string &comment);
const std::string &instruction, const std::string &comment);
bool import_source_files(const std::string& fileName,std::list<std::string>& lines);
bool import_source_files(const std::string& elf_filename, std::list<std::string>& filenames);
bool import_source_code(std::string fileName);
bool import_mapping(std::string fileName);
protected:
virtual bool handle_ip_event(fail::simtime_t curtime, instruction_count_t instr,
Trace_Event &ev) { return true; }
Trace_Event &ev) { return true; }
virtual bool handle_mem_event(fail::simtime_t curtime, instruction_count_t instr,
Trace_Event &ev) { return true; }
Trace_Event &ev) { return true; }
virtual void open_unused_ec_intervals() {
/* empty, Memory Map has a no meaning in this importer */
}
public:
ElfImporter() : Importer() {};
ElfImporter() : Importer() {}
/**
* Callback function that can be used to add command line options