import-trace: import debug info

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
"dbg_mapping" table.

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.

Change-Id: I0e9de6b456bc42b329c1700c25e5839d9552cdbb
This commit is contained in:
Richard Hellwig
2014-01-24 16:44:56 +01:00
parent d307dd2ecb
commit 13175c259b
7 changed files with 551 additions and 6 deletions

View File

@ -1,9 +1,15 @@
#ifndef __OBJDUMP_IMPORTER_H__
#define __OBJDUMP_IMPORTER_H__
#include <string>
#include <list>
#include "libdwarf.h"
#include "libelf.h"
#include "Importer.hpp"
#include "util/llvmdisassembler/LLVMDisassembler.hpp"
#include "util/CommandLine.hpp"
#include "util/DwarfReader.hpp"
/**
The ElfImporter is not a real trace importer, but we locate it
@ -13,12 +19,25 @@
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.
*/
class ElfImporter : public Importer {
llvm::OwningPtr<llvm::object::Binary> binary;
llvm::OwningPtr<fail::LLVMDisassembler> disas;
fail::CommandLine::option_handle OBJDUMP;
fail::CommandLine::option_handle SOURCECODE;
fail::CommandLine::option_handle DEBUGINFO;
fail::DwarfReader dwReader;
bool import_with_objdump(const std::string &objdump_binary);
bool evaluate_objdump_line(const std::string &line);
@ -27,6 +46,10 @@ class ElfImporter : public Importer {
bool import_instruction(fail::address_t addr, char opcode[16], int opcode_length,
const std::string &instruction, const std::string &comment);
bool import_source_files(const std::string& fileName,std::list<std::string>& lines);
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; }