Merge branch 'master' of ssh://i4gerrit.informatik.uni-erlangen.de:29418/fail

This commit is contained in:
Bjoern Doebel
2014-04-23 14:55:40 +02:00
32 changed files with 1038 additions and 127 deletions

View File

@ -8,7 +8,7 @@ find_package(MySQL REQUIRED)
include_directories(${MYSQL_INCLUDE_DIR})
add_library(fail-cpn ${SRCS})
target_link_libraries(fail-cpn fail-comm ${MYSQL_LIBRARIES})
target_link_libraries(fail-cpn fail-comm fail-util ${MYSQL_LIBRARIES})
# make sure protobufs are generated before we include them
add_dependencies(fail-cpn fail-comm)

View File

@ -9,6 +9,7 @@ set(SRCS
add_library(fail-efw ${SRCS})
add_dependencies(fail-efw fail-comm)
target_link_libraries(fail-efw fail-comm)
target_link_libraries(fail-efw fail-util) # WallclockTimer
find_package(LibPCL REQUIRED)
include_directories(${LIBPCL_INCLUDE_DIRS})

View File

@ -43,17 +43,19 @@ include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
# libiberty required by Demangler.cc:
find_library(LIB_IBERTY iberty)
mark_as_advanced(LIB_IBERTY)
if(${LIB_IBERTY} STREQUAL LIB_IBERTY-NOTFOUND)
message(FATAL_ERROR "libiberty not found. Try installing binutils-dev: [ sudo aptitude install binutils-dev ]")
endif()
find_package(LibIberty REQUIRED)
include_directories(${LibIberty_INCLUDE_DIRS})
# libz required by gzstream
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIRS})
# libelf and libdwarf required by ElfReader/DwarfReader
find_package(LibElf REQUIRED)
find_package(LibDwarf REQUIRED)
include_directories(${LIBELF_INCLUDE_DIRS})
include_directories(${LIBDWARF_INCLUDE_DIRS})
# objdump required by Diassembler.cc
set(THE_OBJDUMP "${ARCH_TOOL_PREFIX}objdump")
@ -67,8 +69,7 @@ mark_as_advanced(FAIL_OBJDUMP)
add_library(fail-util ${SRCS})
add_dependencies(fail-util fail-comm)
target_link_libraries(fail-util fail-comm)
target_link_libraries(fail-util ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LIB_IBERTY} ${ZLIB_LIBRARIES} dwarf elf)
target_link_libraries(fail-util fail-comm ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${LibIberty_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBDWARF_LIBRARIES} ${LIBELF_LIBRARIES})
option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.3 preferred, for 3.1 and 3.2 read doc/how-to-build.txt)" OFF)
if (BUILD_LLVM_DISASSEMBLER)

View File

@ -12,14 +12,21 @@ using namespace fail;
boost::mutex Database::m_global_lock;
#endif
static CommandLine::option_handle DATABASE, HOSTNAME, USERNAME, DBDEFAULTS;
Database::Database(const std::string &username, const std::string &host, const std::string &database) {
#ifndef __puma
boost::lock_guard<boost::mutex> guard(m_global_lock);
#endif
CommandLine &cmd = CommandLine::Inst();
std::string db_conf_file = "~/.my.cnf";
if (cmd[DBDEFAULTS].count()) {
db_conf_file = cmd[DBDEFAULTS].first()->arg;
}
handle = mysql_init(0);
last_result = 0;
mysql_options(handle, MYSQL_READ_DEFAULT_FILE, "~/.my.cnf");
mysql_options(handle, MYSQL_READ_DEFAULT_FILE, db_conf_file.c_str());
if (!mysql_real_connect(handle, host.c_str(),
username.c_str(),
0, database.c_str(), 0, 0, 0)) {
@ -231,8 +238,6 @@ std::string Database::escape_string(const std::string unescaped_string) {
return result;
}
static CommandLine::option_handle DATABASE, HOSTNAME, USERNAME;
void Database::cmdline_setup() {
CommandLine &cmd = CommandLine::Inst();
@ -241,7 +246,9 @@ void Database::cmdline_setup() {
HOSTNAME = cmd.addOption("H", "hostname", Arg::Required,
"-h/--hostname \tMYSQL Hostname (default: taken from ~/.my.cnf)");
USERNAME = cmd.addOption("u", "username", Arg::Required,
"-u/--username \tMYSQL Username (default: taken from ~/.my.cnf, or your current user)\n");
"-u/--username \tMYSQL Username (default: taken from ~/.my.cnf, or your current user)");
DBDEFAULTS = cmd.addOption("", "database-option--file", Arg::Required,
"--database-option-file \toverride MySQL ~/.my.cnf option file (prepend with './' for files in the CWD)\n");
// should be called before any threads are spawned
mysql_library_init(0, NULL, NULL);

View File

@ -85,7 +85,10 @@ void LLVMDisassembler::disassemble()
uint64_t End;
// The end is either the size of the section or the beginning of the next
// symbol.
if (si == se - 1)
if (Start >= SectSize)
// we are beyond the end of the section
break;
else if (si == se - 1)
End = SectSize;
// Make sure this symbol takes up space.
else if (Symbols[si + 1].first != Start)
@ -98,7 +101,7 @@ void LLVMDisassembler::disassemble()
MCInst Inst;
if (disas->getInstruction(Inst, Size, memoryObject, Index,
nulls(), nulls())) {
nulls(), nulls()) == MCDisassembler::Success) {
const MCInstrDesc &desc = this->instr_info->get(Inst.getOpcode());
// Inst.dump();
Instr instr_info;
@ -107,6 +110,8 @@ void LLVMDisassembler::disassemble()
instr_info.address = SectionAddr + Index;
instr_info.conditional_branch = desc.isConditionalBranch();
assert( Size > 0 && "zero size instruction disassembled" );
unsigned int pos = 0;
for (MCInst::iterator it = Inst.begin(); it != Inst.end(); ++it) {