From 277958b31bbeb55197aad1e342e20290f561a16e Mon Sep 17 00:00:00 2001 From: Horst Schirmeier Date: Sun, 9 Feb 2014 18:54:21 +0100 Subject: [PATCH] cleanups Change-Id: I8022d937477668253c613e97c3a579ae65084b1e --- .gitignore | 1 - cmake/FindFTDI.cmake | 4 +- cmake/panda.cmake | 47 +++-- debuggers/openocd/openocd_wrapper.cc | 168 +++++++++--------- debuggers/openocd/openocd_wrapper.hpp.in | 46 ++--- doc/how-to-use.txt | 2 +- src/core/comm/CMakeLists.txt | 2 +- src/core/comm/InjectionPointHopsMessage.proto | 14 +- src/core/cpn/CMakeLists.txt | 8 +- src/core/cpn/DatabaseCampaign.cc | 13 +- src/core/cpn/InjectionPoint.hpp | 6 +- src/core/cpn/InjectionPointHops.cc | 14 +- src/core/sal/Architecture.hpp | 2 +- src/core/sal/CMakeLists.txt | 26 +-- src/core/sal/panda/PandaArmCPU.cc | 2 +- src/core/sal/panda/PandaArmCPU.hpp | 4 +- src/core/sal/panda/PandaBreakpoints.ah | 64 +++---- src/core/sal/panda/PandaConfig.hpp | 11 +- src/core/sal/panda/PandaController.cc | 19 +- src/core/sal/panda/PandaController.hpp | 2 +- src/core/sal/panda/PandaListener.hpp | 2 +- src/core/sal/panda/PandaMemory.hpp | 4 +- src/core/sal/panda/PandaTimer.ah | 70 ++++---- src/core/sal/panda/PandaWatchpoints.ah | 85 +++++---- src/core/util/CMakeLists.txt | 5 +- src/core/util/smarthops/SmartHops.cc | 4 +- src/core/util/smarthops/SmartHops.hpp | 20 +-- src/core/util/smarthops/TraceReader.cc | 10 +- src/core/util/smarthops/TraceReader.hpp | 55 +++--- .../lra-simple-panda/CMakeLists.txt | 2 +- src/experiments/lra-simple-panda/campaign.cc | 4 +- src/experiments/lra-simple-panda/campaign.hpp | 2 +- .../lra-simple-panda/experiment.cc | 30 ++-- .../lra-simple-panda/experiment.hpp | 4 +- .../lra-simple-panda/lra_simple.proto | 19 +- src/experiments/lra-simple-panda/main.cc | 3 +- tools/CMakeLists.txt | 4 +- tools/compute-hops/BasicAlgorithm.hpp | 21 ++- tools/compute-hops/CMakeLists.txt | 2 +- tools/compute-hops/ResultCollector.cc | 6 +- tools/compute-hops/ResultCollector.hpp | 4 +- tools/compute-hops/SimpleAlgorithm.hpp | 12 +- tools/compute-hops/SmartAlgorithm.cc | 2 +- tools/compute-hops/SmartAlgorithm.hpp | 10 +- tools/compute-hops/main.cc | 39 ++-- 45 files changed, 430 insertions(+), 444 deletions(-) diff --git a/.gitignore b/.gitignore index 63fe4245..3172459b 100644 --- a/.gitignore +++ b/.gitignore @@ -53,4 +53,3 @@ debuggers/openocd/src/startup.tcl debuggers/openocd/src/startup_tcl.c debuggers/openocd/src/target/xscale_debug.h debuggers/openocd/stamp-h1 - diff --git a/cmake/FindFTDI.cmake b/cmake/FindFTDI.cmake index 8b831a0f..532b403a 100644 --- a/cmake/FindFTDI.cmake +++ b/cmake/FindFTDI.cmake @@ -1,7 +1,7 @@ # Find FTDI library # Defines: # FTDI_FOUND -# FTDI_INCLUDE_DIR +# FTDI_INCLUDE_DIR # FTDI_LIBRARY # @@ -13,7 +13,7 @@ FIND_LIBRARY(FTDI_LIBRARY NAMES ftdi ENV LD_LIBRARY_PATH ) -# handle the QUIETLY and REQUIRED arguments and set FTDI_FOUND to TRUE if +# handle the QUIETLY and REQUIRED arguments and set FTDI_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(FTDI DEFAULT_MSG FTDI_LIBRARY FTDI_INCLUDE_DIR) diff --git a/cmake/panda.cmake b/cmake/panda.cmake index 5aebc7e8..b4af74cb 100644 --- a/cmake/panda.cmake +++ b/cmake/panda.cmake @@ -1,11 +1,11 @@ if(BUILD_PANDA) - + message(STATUS "[${PROJECT_NAME}] Building Pandaboard variant ...") SET(VARIANT panda) - + find_package(FTDI REQUIRED) set(openocd_library_dependencies ${openocd_library_dependencies} ${FTDI_LIBRARY}) - + # FIXME: some libraries still need to be located the "cmake way" set(openocd_library_dependencies ${openocd_library_dependencies} -ldl) @@ -27,37 +27,36 @@ if(BUILD_PANDA) # make sure aspects don't fail to match in entry.cc #include_directories(${PROJECT_SOURCE_DIR}/src/core ${CMAKE_BINARY_DIR}/src/core) # an executable needs at least one source file, so we hand over an empty .cc file to make cmake happy. - + set(srces ${openocd_src_dir}/openocd_wrapper.cc) - - set (srces ${srces} - ${openocd_src_dir}/opcode_parser/arm-addressmode.c - ${openocd_src_dir}/opcode_parser/arm-condition.c - ${openocd_src_dir}/opcode_parser/arm-opcode-coprocessor.c - ${openocd_src_dir}/opcode_parser/arm-opcode-data.c - ${openocd_src_dir}/opcode_parser/arm-opcode-ldmstm-branch.c - ${openocd_src_dir}/opcode_parser/arm-opcode-ldrstr.c - ${openocd_src_dir}/opcode_parser/arm-opcode.c) - - add_executable(fail-client ${srces}) + + set (srces ${srces} + ${openocd_src_dir}/opcode_parser/arm-addressmode.c + ${openocd_src_dir}/opcode_parser/arm-condition.c + ${openocd_src_dir}/opcode_parser/arm-opcode-coprocessor.c + ${openocd_src_dir}/opcode_parser/arm-opcode-data.c + ${openocd_src_dir}/opcode_parser/arm-opcode-ldmstm-branch.c + ${openocd_src_dir}/opcode_parser/arm-opcode-ldrstr.c + ${openocd_src_dir}/opcode_parser/arm-opcode.c) + + add_executable(fail-client ${srces}) target_link_libraries(fail-client ${openocd_src_dir}/src/.libs/libopenocd.a ${openocd_src_dir}/jimtcl/libjim.a fail ${openocd_library_dependencies}) add_dependencies(fail-client libfailopenocd_external) - + # ensure, elf path is set for enabling openocd to read elf symbols if(EXISTS $ENV{FAIL_ELF_PATH}) - SET(PANDA_ELF_PATH $ENV{FAIL_ELF_PATH}) - message(STATUS "[Fail*] PandaBoard ELF under test: ${PANDA_ELF_PATH}") + message(STATUS "[Fail*] PandaBoard ELF under test: $ENV{FAIL_ELF_PATH}") else() - message(FATAL_ERROR "Please set the FAIL_ELF_PATH enviroment variable to the binary under test.") + message(FATAL_ERROR "Please set the FAIL_ELF_PATH environment variable to the binary under test.") endif() - - - # copy the conf-files to build directory - # TODO: copy to install path on install!? + + + # copy the conf-files to build directory + # TODO: copy to install path on install!? file(COPY ${openocd_src_dir}/tcl/ DESTINATION oocd_conf/ PATTERN openocd EXCLUDE) get_filename_component(OOCD_CONF_FILES_PATH ${CMAKE_BINARY_DIR}/oocd_conf/ REALPATH) - configure_file(${openocd_src_dir}/openocd.cfg openocd.cfg COPYONLY) + configure_file(${openocd_src_dir}/openocd.cfg openocd.cfg COPYONLY) get_filename_component(OOCD_CONF_FILE_PATH ${CMAKE_BINARY_DIR}/openocd.cfg REALPATH) configure_file(${openocd_src_dir}/openocd_wrapper.hpp.in diff --git a/debuggers/openocd/openocd_wrapper.cc b/debuggers/openocd/openocd_wrapper.cc index 4278e591..8e9f8300 100644 --- a/debuggers/openocd/openocd_wrapper.cc +++ b/debuggers/openocd/openocd_wrapper.cc @@ -150,21 +150,21 @@ static std::vector mmu_watch_del_waiting_list; static std::vector mmu_watch; /* - * Timer related structures + * Timer related structures */ #define P_MAX_TIMERS 32 struct timer{ - bool inUse; // Timer slot is in-use (currently registered). - uint64_t timeToFire; // Time to fire next in microseconds - struct timeval time_begin; // Timer value at activation of timer - bool active; // 0=inactive, 1=active. - p_timer_handler_t funct; // A callback function for when the + bool inUse; // Timer slot is in-use (currently registered). + uint64_t timeToFire; // Time to fire next in microseconds + struct timeval time_begin; // Timer value at activation of timer + bool active; // 0=inactive, 1=active. + p_timer_handler_t funct; // A callback function for when the // timer fires. - void *this_ptr; // The this-> pointer for C++ callbacks - // has to be stored as well. - bool freezed; + void *this_ptr; // The this-> pointer for C++ callbacks + // has to be stored as well. + bool freezed; #define PMaxTimerIDLen 32 - char id[PMaxTimerIDLen]; // String ID of timer. + char id[PMaxTimerIDLen]; // String ID of timer. }; static struct timer timers[P_MAX_TIMERS]; @@ -678,7 +678,7 @@ int main(int argc, char *argv[]) exit(-1); } #else - if(!getHaltingWatchpoint(&halt)) { + if (!getHaltingWatchpoint(&halt)) { LOG << "FATAL ERROR: Can't determine memory-access address of halt cause" << endl; exit(-1); } @@ -687,26 +687,26 @@ int main(int argc, char *argv[]) // Get meta information and fire MemoryAccess event int iswrite; switch (halt.type) { - case HALT_TYPE_WP_READ: - iswrite = 0; - break; - case HALT_TYPE_WP_WRITE: - iswrite = 1; - break; - case HALT_TYPE_WP_READWRITE: - LOG << "We should not get a READWRITE as trigger of" - "a watchpoint!" << endl; - iswrite = 1; - break; - default: - LOG << "FATAL ERROR: Can't determine memory-access type of halt cause" << endl; - exit(-1); - break; + case HALT_TYPE_WP_READ: + iswrite = 0; + break; + case HALT_TYPE_WP_WRITE: + iswrite = 1; + break; + case HALT_TYPE_WP_READWRITE: + LOG << "We should not get a READWRITE as trigger of" + "a watchpoint!" << endl; + iswrite = 1; + break; + default: + LOG << "FATAL ERROR: Can't determine memory-access type of halt cause" << endl; + exit(-1); + break; } freeze_timers(); LOG << "WATCHPOINT EVENT ADDR: " << hex << halt.address << dec - << " LENGTH: " << halt.addr_len << " TYPE: " + << " LENGTH: " << halt.addr_len << " TYPE: " << (iswrite?'W':'R') << endl; fail::simulator.onMemoryAccess(NULL, halt.address, halt.addr_len, iswrite, pc); unfreeze_timers(); @@ -721,7 +721,7 @@ int main(int argc, char *argv[]) break; default: LOG << "FATAL ERROR: Target halted in unexpected cpu state " - << current_dr << endl; + << current_dr << endl; exit (-1); break; } @@ -731,19 +731,19 @@ int main(int argc, char *argv[]) update_timers(); } - /* === FINISHING UP === */ - unregister_all_commands(cmd_ctx, NULL); + /* === FINISHING UP === */ + unregister_all_commands(cmd_ctx, NULL); - /* free commandline interface */ - command_done(cmd_ctx); + /* free commandline interface */ + command_done(cmd_ctx); - adapter_quit(); + adapter_quit(); - fclose(file); + fclose(file); - LOG << "finished" << endl; + LOG << "finished" << endl; - exit(oocdw_exCode); + exit(oocdw_exCode); } void oocdw_finish(int exCode) @@ -758,7 +758,7 @@ void oocdw_set_halt_condition(struct halt_condition *hc) assert((hc != NULL) && "No halt condition defined"); - if (hc->type == HALT_TYPE_BP) { /* BREAKPOINT */ + if (hc->type == HALT_TYPE_BP) { /* BREAKPOINT */ LOG << "Adding BP " << hex << hc->address << dec << ":" << hc->addr_len << endl; if (!free_breakpoints) { LOG << "FATAL ERROR: No free breakpoints left" << endl; @@ -771,13 +771,13 @@ void oocdw_set_halt_condition(struct halt_condition *hc) } free_breakpoints--; - } else if (hc->type == HALT_TYPE_SINGLESTEP) { /* SINGLE STEP */ + } else if (hc->type == HALT_TYPE_SINGLESTEP) { /* SINGLE STEP */ // Just set flag, so single step will be executed in according // main loop stage single_step_requested = true; } else if ((hc->type == HALT_TYPE_WP_READ) || (hc->type == HALT_TYPE_WP_WRITE) || - (hc->type == HALT_TYPE_WP_READWRITE)) { /* WATCHPOINT */ + (hc->type == HALT_TYPE_WP_READWRITE)) { /* WATCHPOINT */ // Use MMU for watching ? if ((hc->addr_len > 4) || !free_watchpoints) { @@ -834,17 +834,17 @@ void oocdw_delete_halt_condition(struct halt_condition *hc) assert((hc != NULL) && "No halt condition defined"); // Remove halt condition from pandaboard - if (hc->type == HALT_TYPE_BP) { /* BREAKPOINT */ + if (hc->type == HALT_TYPE_BP) { /* BREAKPOINT */ LOG << "Removing BP " << hex << hc->address << dec << ":" << hc->addr_len << endl; breakpoint_remove(target_a9, hc->address); free_breakpoints++; - } else if (hc->type == HALT_TYPE_SINGLESTEP) { /* SINGLE STEP */ + } else if (hc->type == HALT_TYPE_SINGLESTEP) { /* SINGLE STEP */ // Do nothing. Single-stepping event hits one time and // extinguishes itself automatically } else if ((hc->type == HALT_TYPE_WP_READWRITE) || (hc->type == HALT_TYPE_WP_READ) || - (hc->type == HALT_TYPE_WP_WRITE)) { /* WATCHPOINT */ + (hc->type == HALT_TYPE_WP_WRITE)) { /* WATCHPOINT */ struct mem_range mr; mr.address = hc->address; @@ -876,7 +876,7 @@ void oocdw_delete_halt_condition(struct halt_condition *hc) // Remove hardware watchpoint watchpoint_remove(target_a9, hc->address); free_watchpoints++; - LOG << hex << "Removing WP " << hc->address << ":" << hc->addr_len + LOG << hex << "Removing WP " << hc->address << ":" << hc->addr_len << ":" << ((hc->type == HALT_TYPE_WP_READ) ? "R" : (hc->type == HALT_TYPE_WP_WRITE) ? "W" : "R/W") << dec << endl; } @@ -956,44 +956,44 @@ void oocdw_reboot() LOG << "Rebooting device" << endl; reboot_success = true; - // If target is not halted, reset will result in freeze - if (target_a9->state != TARGET_HALTED) { - if (!oocdw_halt_target(target_a9)) { - reboot_success = false; - if (fail_counter++ > 4) { + // If target is not halted, reset will result in freeze + if (target_a9->state != TARGET_HALTED) { + if (!oocdw_halt_target(target_a9)) { + reboot_success = false; + if (fail_counter++ > 4) { LOG << "FATAL ERROR: Rebooting not possible" << endl; exit(-1); } - usleep(100*1000); - continue; - } - } + usleep(100*1000); + continue; + } + } - /* - * Clear all halt conditions - */ - breakpoint_clear_target(target_a9); - watchpoint_clear_target(target_a9); + /* + * Clear all halt conditions + */ + breakpoint_clear_target(target_a9); + watchpoint_clear_target(target_a9); - /* - * Reset state structures - */ - free_watchpoints = 4; - free_breakpoints = 6; - mmu_recovery_needed = false; - mmu_watch.clear(); - mmu_watch_add_waiting_list.clear(); - mmu_watch_del_waiting_list.clear(); + /* + * Reset state structures + */ + free_watchpoints = 4; + free_breakpoints = 6; + mmu_recovery_needed = false; + mmu_watch.clear(); + mmu_watch_add_waiting_list.clear(); + mmu_watch_del_waiting_list.clear(); - // Standard configuration: Sections only, all mapped - for (int i = 0; i < 4096; i++) { - if (mmu_conf[i].type == DESCRIPTOR_PAGE) { - delete[] mmu_conf[i].second_lvl_mapped; - mmu_conf[i].type = DESCRIPTOR_SECTION; - } - mmu_conf[i].mapped = true; - } + // Standard configuration: Sections only, all mapped + for (int i = 0; i < 4096; i++) { + if (mmu_conf[i].type == DESCRIPTOR_PAGE) { + delete[] mmu_conf[i].second_lvl_mapped; + mmu_conf[i].type = DESCRIPTOR_SECTION; + } + mmu_conf[i].mapped = true; + } /* * The actual reset command executed by OpenOCD jimtcl-engine @@ -1351,7 +1351,7 @@ void oocdw_read_from_memory(uint32_t address, uint32_t chunk_size, uint32_t chunk_num, uint8_t *data) { if (target_read_memory(target_a9, address, chunk_size, chunk_num, data)) { - LOG << "FATAL ERROR: Reading from memory failed. Addr: " << hex + LOG << "FATAL ERROR: Reading from memory failed. Addr: " << hex << address << dec << " chunk-size: " << chunk_size << " chunk_num: " << chunk_num << endl; exit(-1); @@ -1757,7 +1757,7 @@ static void force_page_alignment_mem_range (std::vector &in, static bool compareByAddress(const struct mem_range &a, const struct mem_range &b) { - return a.address < b.address; + return a.address < b.address; } static void merge_mem_ranges (std::vector &in_out) @@ -1768,7 +1768,7 @@ static void merge_mem_ranges (std::vector &in_out) std::vector::iterator it, next_it; it = in_out.begin(); next_it = it; next_it++; - while(it != in_out.end() && next_it != in_out.end()) { + while (it != in_out.end() && next_it != in_out.end()) { if ((it->address + it->width) >= next_it->address) { uint32_t additive_width = (next_it->address - it->address) + next_it->width; if (additive_width > it->width) { @@ -1872,7 +1872,7 @@ static bool update_mmu_watch_add() first_lvl->second_lvl_mapped[i] = true; descr_content = (((cand_it->index - (cand_it->index % 256)) + i) << 12) | 0x32; buffer_for_chunked_write.push_back(std::pair( - pageTableAddress + (i * 4), + pageTableAddress + (i * 4), descr_content)); } first_lvl->type = DESCRIPTOR_PAGE; @@ -1885,7 +1885,7 @@ static bool update_mmu_watch_add() if (first_lvl->second_lvl_mapped[cand_it->index % 256]) { uint32_t descr_content = (cand_it->index << 12) | 0x30; buffer_for_chunked_write.push_back(std::pair( - sym_addr_PageTableSecondLevel + (cand_it->index * 4), + sym_addr_PageTableSecondLevel + (cand_it->index * 4), descr_content)); first_lvl->second_lvl_mapped[cand_it->index % 256] = false; invalidate = true; @@ -1908,7 +1908,7 @@ static bool update_mmu_watch_add() if (first_lvl->type == DESCRIPTOR_SECTION) { if (first_lvl->mapped) { uint32_t descr_content = (cand_it->index << 20) | 0xc00; - uint32_t descr_addr = sym_addr_PageTableFirstLevel + (cand_it->index * 4); + uint32_t descr_addr = sym_addr_PageTableFirstLevel + (cand_it->index * 4); buffer_for_chunked_write.push_back( std::pair(descr_addr,descr_content)); @@ -2035,7 +2035,7 @@ static bool update_mmu_watch_remove() uint32_t pageTableAddress = sym_addr_PageTableSecondLevel + ((cand_it->index - (cand_it->index % 256)) * 4); uint32_t descr_content = pageTableAddress | 0x1e9; uint32_t target_address = sym_addr_PageTableFirstLevel + ((cand_it->index / 256) * 4); - LOG << "Writing to " << hex << target_address << dec << endl; + LOG << "Writing to " << hex << target_address << dec << endl; oocdw_write_to_memory(target_address, 4, 1, (unsigned char*)(&descr_content), true); invalidate = true; @@ -2046,7 +2046,7 @@ static bool update_mmu_watch_remove() first_lvl->second_lvl_mapped[i] = false; descr_content = (((cand_it->index - (cand_it->index % 256)) + i) << 12) | 0x30; buffer_for_chunked_write.push_back(std::pair( - pageTableAddress + (i * 4), + pageTableAddress + (i * 4), descr_content)); } first_lvl->type = DESCRIPTOR_PAGE; @@ -2056,7 +2056,7 @@ static bool update_mmu_watch_remove() if (!first_lvl->second_lvl_mapped[cand_it->index % 256]) { uint32_t descr_content = (cand_it->index << 12) | 0x32; buffer_for_chunked_write.push_back(std::pair( - sym_addr_PageTableSecondLevel + (cand_it->index * 4), + sym_addr_PageTableSecondLevel + (cand_it->index * 4), descr_content)); first_lvl->second_lvl_mapped[cand_it->index % 256] = true; } @@ -2078,7 +2078,7 @@ static bool update_mmu_watch_remove() if (first_lvl->type == DESCRIPTOR_SECTION) { if (!first_lvl->mapped) { uint32_t descr_content = (cand_it->index << 20) | 0xc02; - uint32_t descr_addr = sym_addr_PageTableFirstLevel + (cand_it->index * 4); + uint32_t descr_addr = sym_addr_PageTableFirstLevel + (cand_it->index * 4); LOG << "Write to " << hex << descr_addr << dec << endl; oocdw_write_to_memory(descr_addr, 4, 1, (unsigned char*)(&descr_content), true); LOG << "Writing entry at " << hex << descr_addr << " content: " << descr_content << dec << endl; diff --git a/debuggers/openocd/openocd_wrapper.hpp.in b/debuggers/openocd/openocd_wrapper.hpp.in index 48b3c753..0eae7b74 100644 --- a/debuggers/openocd/openocd_wrapper.hpp.in +++ b/debuggers/openocd/openocd_wrapper.hpp.in @@ -8,17 +8,17 @@ #define OOCD_CONF_FILES_PATH "@OOCD_CONF_FILES_PATH@" enum halt_type { - HALT_TYPE_BP, - HALT_TYPE_WP_READWRITE, - HALT_TYPE_WP_READ, - HALT_TYPE_WP_WRITE, - HALT_TYPE_SINGLESTEP, + HALT_TYPE_BP, + HALT_TYPE_WP_READWRITE, + HALT_TYPE_WP_READ, + HALT_TYPE_WP_WRITE, + HALT_TYPE_SINGLESTEP, }; struct halt_condition { - enum halt_type type; - uint32_t address; - uint32_t addr_len; + enum halt_type type; + uint32_t address; + uint32_t addr_len; }; /* @@ -48,7 +48,7 @@ void oocdw_write_reg(uint32_t reg_num, uint32_t data); /* * Set a halt condition - * + * * Halt conditions can be Break- and Watchpoints as well as single-steps * @param hc Pointer to struct defining new halt condition */ @@ -56,7 +56,7 @@ void oocdw_set_halt_condition(struct halt_condition *hc); /* * Remove a halt condition - * + * * Halt conditions can be Break- and Watchpoints as well as single-steps * @param hc Pointer to struct defining to be deleted halt condition */ @@ -69,7 +69,7 @@ bool oocdw_halt_target(struct target *target); /* * Target reboot - * + * * The target gets reset and will be navigated to a dynamic instruction * right before main entry. Afterwards a new experiment can be executed. */ @@ -77,18 +77,18 @@ void oocdw_reboot(); /* * Finish OpenOCD execution - * + * * Function will be called by simulator.terminate() and will simply * set a finish-flag. Afterwards a coroutine-switch must be called, so * the actual finishing will be done in the OpenOCD-Wrapper coroutine. - * Before returning, another coroutine-switch is called, so the + * Before returning, another coroutine-switch is called, so the * experiment is able to exit in desired state. */ void oocdw_finish(int exCode = EXIT_SUCCESS); /* * Read data from pandaboard memory - * + * * @param address Start address of memory region to be read * @param chunk_size Size of chunks, which will be read * @param chunk_num Number of chunks to be read @@ -99,7 +99,7 @@ void oocdw_read_from_memory(uint32_t address, uint32_t chunk_size, /* * Write data to pandaboard memory - * + * * @param address Start address of memory region to be written * @param chunk_size Size of chunks, which will be written * @param chunk_num Number of chunks to be written @@ -114,29 +114,29 @@ void oocdw_write_to_memory(uint32_t address, uint32_t chunk_size, typedef void (*p_timer_handler_t)(void *); /* * Register new timer - * + * * @param this_ptr This pointer for calling object method * @param funct Callback to call if timer expired (object method) - * @param useconds Number of microseconds until timer expires + * @param useconds Number of microseconds until timer expires * @param active Sets if timer is initially active * @param id String representation of timer * @returns Timer index (ID) or -1 if no timer slot left */ -int oocdw_register_timer(void *this_ptr, p_timer_handler_t funct, +int oocdw_register_timer(void *this_ptr, p_timer_handler_t funct, uint64_t useconds, bool active, const char *id); - + /* * Unregister timer - * - * @param timerID Timer index (ID), which defines the timer to be + * + * @param timerID Timer index (ID), which defines the timer to be * unregistered */ bool oocdw_unregisterTimer(unsigned timerID); /* * Deactivate timer - * - * @param timerID Timer index (ID), which defines the timer to be + * + * @param timerID Timer index (ID), which defines the timer to be * deactivated. */ void oocdw_deactivate_timer(unsigned timer_index); diff --git a/doc/how-to-use.txt b/doc/how-to-use.txt index 5d0d9e45..25029122 100644 --- a/doc/how-to-use.txt +++ b/doc/how-to-use.txt @@ -274,4 +274,4 @@ A campaign experiment to use with the lra-panda-dijkstra experiment-target. - It will create a result table for the possible experiment outcomes 'OK','ERR_WRONG_RESULT','ERR_TRAP','ERR_TIMEOUT' and 'ERR_OUTSIDE_TEXT'. 'ERR_OUTSIDE_TEXT' describes any memory accesses which went outside the - application memory. \ No newline at end of file + application memory. diff --git a/src/core/comm/CMakeLists.txt b/src/core/comm/CMakeLists.txt index 154190d2..850bfc57 100644 --- a/src/core/comm/CMakeLists.txt +++ b/src/core/comm/CMakeLists.txt @@ -12,7 +12,7 @@ set(PROTOS ) ## Set concrete implementation of InjectionPointMessage -# ToDo: Define seperate symbol, so it can also be used in other build types +# TODO: Define separate symbol, so it can also be used in other build types if(CONFIG_INJECTIONPOINT_HOPS) set(PROTOS ${PROTOS} InjectionPointHopsMessage.proto) set(CONCRETE_INJECTION_POINT InjectionPointHopsMessage.proto) diff --git a/src/core/comm/InjectionPointHopsMessage.proto b/src/core/comm/InjectionPointHopsMessage.proto index a97e9968..238c4649 100644 --- a/src/core/comm/InjectionPointHopsMessage.proto +++ b/src/core/comm/InjectionPointHopsMessage.proto @@ -2,18 +2,18 @@ message InjectionPointMessage { // Costs of the hop chain on the PandaBoard // ToDo: Could be eliminated, but it is nice for evaluation optional uint32 costs = 3; - + // If checkpoint must be used for this hop chain, id is set properly optional uint32 checkpoint_id = 1; - // If we need to knwo the target dynamic instruction offset, - // here it is - optional uint32 target_trace_position = 4; + // If we need to know the target dynamic instruction offset, + // here it is + optional uint32 target_trace_position = 4; - // Repeated groups can't be defined as notempty, so a manual - // non-empty check is required at usage - + // Repeated groups can't be defined as non-empty, so a manual + // non-empty check is required at usage + // As we assume hops to always watch addresses of length 1, we // don't encode the length in here repeated group Hops = 2 { diff --git a/src/core/cpn/CMakeLists.txt b/src/core/cpn/CMakeLists.txt index eaeee8a8..d3b50cee 100644 --- a/src/core/cpn/CMakeLists.txt +++ b/src/core/cpn/CMakeLists.txt @@ -6,17 +6,17 @@ set(SRCS # only compile concrete implementation of InjectionPoint if(CONFIG_INJECTIONPOINT_HOPS) - set (SRCS ${SRCS} InjectionPointHops.cc) + set (SRCS ${SRCS} InjectionPointHops.cc) else(CONFIG_INJECTIONPOINT_HOPS) - set (SRCS ${SRCS} InjectionPointSteps.cc) + set (SRCS ${SRCS} InjectionPointSteps.cc) endif(CONFIG_INJECTIONPOINT_HOPS) add_library(fail-cpn ${SRCS}) -# if hop-chains need to be calculated by the server, we +# if hop-chains need to be calculated by the server, we # the smarthopping module if(CONFIG_INJECTIONPOINT_HOPS) - add_dependencies(fail-cpn fail-smarthops) + add_dependencies(fail-cpn fail-smarthops) endif(CONFIG_INJECTIONPOINT_HOPS) add_dependencies(fail-cpn fail-comm) diff --git a/src/core/cpn/DatabaseCampaign.cc b/src/core/cpn/DatabaseCampaign.cc index 82e0f741..4734ca46 100644 --- a/src/core/cpn/DatabaseCampaign.cc +++ b/src/core/cpn/DatabaseCampaign.cc @@ -35,7 +35,7 @@ bool DatabaseCampaign::run() { CommandLine::option_handle PRUNER = cmd.addOption("p", "prune-method", Arg::Required, "-p/--prune-method \tWhich import method to use (default: basic)"); - if(!cmd.parse()) { + if (!cmd.parse()) { log_send << "Error parsing arguments." << std::endl; exit(-1); } @@ -82,7 +82,7 @@ bool DatabaseCampaign::run() { std::vector variants = db->get_variants(variant, benchmark); for (std::vector::const_iterator it = variants.begin(); it != variants.end(); ++it) { - if(!run_variant(*it)) { + if (!run_variant(*it)) { log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <query_stream ((sql_select + sql_body).c_str()); - log_send << "Found " << experiment_count << " unfinished experiments in database. (" + log_send << "Found " << experiment_count << " unfinished experiments in database. (" << variant.variant << "/" << variant.benchmark << ")" << std::endl; - // abstraction of injection point - // must not be initialized in loop, because hop chain calculator would loose state after loop pass - // and so for every hop chain it would have to begin calculating at trace instruction zero + // abstraction of injection point: + // must not be initialized in loop, because hop chain calculator would lose + // state after loop pass and so for every hop chain it would have to begin + // calculating at trace instruction zero ConcreteInjectionPoint ip; sent_pilots = 0; diff --git a/src/core/cpn/InjectionPoint.hpp b/src/core/cpn/InjectionPoint.hpp index 7cd6544c..26739605 100644 --- a/src/core/cpn/InjectionPoint.hpp +++ b/src/core/cpn/InjectionPoint.hpp @@ -58,7 +58,7 @@ class SmartHops; /** * \class InjectionPointHops * - * Concrete injection point which contains a hop chain to the target + * Concrete injection point which contains a hop chain to the target * trace instruction. */ class InjectionPointHops : public InjectionPointBase { @@ -79,7 +79,7 @@ public: m_curr_instr2(-1), m_initialized(false) {} virtual ~InjectionPointHops(); - + /** * Parses a hop chain from a injection instruction (trace offset). * @param instr1 trace instruction offset of beginning of equivalence class @@ -101,7 +101,7 @@ typedef InjectionPointHops ConcreteInjectionPoint; class InjectionPointSteps : public InjectionPointBase { public: virtual ~InjectionPointSteps() {} - + /** * Parses a trace offset from a injection instruction (trace offset), * so it effectively just stores the value in the protobuf message. diff --git a/src/core/cpn/InjectionPointHops.cc b/src/core/cpn/InjectionPointHops.cc index 96a0eee6..70ae2a70 100644 --- a/src/core/cpn/InjectionPointHops.cc +++ b/src/core/cpn/InjectionPointHops.cc @@ -6,10 +6,10 @@ namespace fail { - InjectionPointHops::~InjectionPointHops() { - if (m_initialized) + if (m_initialized) { delete m_sa; + } } void InjectionPointHops::init() @@ -17,11 +17,11 @@ void InjectionPointHops::init() m_sa = new SmartHops(); char * elfpath = getenv("FAIL_TRACE_PATH"); - if(elfpath == NULL){ + if (elfpath == NULL) { m_log << "FAIL_TRACE_PATH not set :(" << std::endl; exit(-1); - }else{ - m_sa->init((const char*)elfpath); + } else { + m_sa->init((const char*) elfpath); } m_initialized = true; @@ -74,7 +74,7 @@ void InjectionPointHops::parseFromInjectionInstr(unsigned instr1, unsigned instr if (!m_sa->calculateFollowingHop(m, new_curr_instr2)) { m_log << "FATAL ERROR: Trace does not contain enough instructions (no instruction with offset " << new_curr_instr2 << ")" << std::endl; - exit(-1); + exit(-1); } m_results.push_back(m); @@ -93,7 +93,7 @@ void InjectionPointHops::parseFromInjectionInstr(unsigned instr1, unsigned instr if (search == search_end) { m_ip = *search; } else { - for(;search != search_end; search++) { + for (;search != search_end; search++) { if (!search->has_costs()) { m_log << "FATAL ERROR: Costs must be delivered in order to calculate minimum costs" << std::endl; exit(-1); diff --git a/src/core/sal/Architecture.hpp b/src/core/sal/Architecture.hpp index 2ccee29e..9afc701a 100644 --- a/src/core/sal/Architecture.hpp +++ b/src/core/sal/Architecture.hpp @@ -1,6 +1,6 @@ // Architecture.hpp: wraps architecture definition headers #ifndef __ARCHITECTURE_HPP__ - #define __ARCHITECTURE_HPP__ +#define __ARCHITECTURE_HPP__ #include "config/FailConfig.hpp" diff --git a/src/core/sal/CMakeLists.txt b/src/core/sal/CMakeLists.txt index 66f6a794..102bced4 100644 --- a/src/core/sal/CMakeLists.txt +++ b/src/core/sal/CMakeLists.txt @@ -58,7 +58,7 @@ elseif(BUILD_T32) ) endif(BUILD_ARM) elseif(BUILD_PANDA) - include_directories(${PROJECT_SOURCE_DIR}/debuggers/openocd) + include_directories(${PROJECT_SOURCE_DIR}/debuggers/openocd) set(SRCS CPU.cc CPUState.cc @@ -82,28 +82,28 @@ if(BUILD_X86) set(SRCS ${SRCS} x86/X86Architecture.cc ) - set(ARCH_TOOL_PREFIX "" CACHE PATH "Setup prefix for binutils, e.g., arm-none-eabi- or tricore-, ..") + set(ARCH_TOOL_PREFIX "" CACHE PATH "Setup prefix for binutils, e.g., arm-none-eabi- or tricore-, ..") elseif(BUILD_ARM) set(SRCS ${SRCS} arm/ArmArchitecture.cc ) - set(ARCH_TOOL_PREFIX "arm-none-eabi-" CACHE PATH "Setup prefix for binutils, e.g., arm-none-eabi- or tricore-, ..") + set(ARCH_TOOL_PREFIX "arm-none-eabi-" CACHE PATH "Setup prefix for binutils, e.g., arm-none-eabi- or tricore-, ..") endif(BUILD_X86) if(BUILD_GEM5) - message(STATUS "[${PROJECT_NAME}] Generating SConscript in ${CMAKE_CURRENT_BINARY_DIR}/gem5") - set(additional_libs "") + message(STATUS "[${PROJECT_NAME}] Generating SConscript in ${CMAKE_CURRENT_BINARY_DIR}/gem5") + set(additional_libs "") - foreach(exp ${EXPERIMENTS_ACTIVATED}) - set(additional_libs "${additional_libs} '-lfail-${exp}',") - endforeach(exp) + foreach(exp ${EXPERIMENTS_ACTIVATED}) + set(additional_libs "${additional_libs} '-lfail-${exp}',") + endforeach(exp) - foreach(plug ${PLUGINS_ACTIVATED}) - set(additional_libs "${additional_libs} '-lfail-${plug}',") - endforeach(plug) + foreach(plug ${PLUGINS_ACTIVATED}) + set(additional_libs "${additional_libs} '-lfail-${plug}',") + endforeach(plug) - set(GEM5_SAL_SRCS "'${CMAKE_CURRENT_SOURCE_DIR}/gem5/Gem5Wrapper.cc'") - configure_file(gem5/SConscript.in ${CMAKE_CURRENT_BINARY_DIR}/gem5/SConscript) + set(GEM5_SAL_SRCS "'${CMAKE_CURRENT_SOURCE_DIR}/gem5/Gem5Wrapper.cc'") + configure_file(gem5/SConscript.in ${CMAKE_CURRENT_BINARY_DIR}/gem5/SConscript) endif(BUILD_GEM5) # Don't include these sources if perf-stuff is disabled # (reduces compiler overhead): diff --git a/src/core/sal/panda/PandaArmCPU.cc b/src/core/sal/panda/PandaArmCPU.cc index 9c5563a1..fa24e9ce 100644 --- a/src/core/sal/panda/PandaArmCPU.cc +++ b/src/core/sal/panda/PandaArmCPU.cc @@ -9,7 +9,7 @@ regdata_t PandaArmCPU::getRegisterContent(const Register* reg) const regdata_t data; oocdw_read_reg(reg->getId(), &data); - + return data; } diff --git a/src/core/sal/panda/PandaArmCPU.hpp b/src/core/sal/panda/PandaArmCPU.hpp index e3a88ebb..5f048acd 100644 --- a/src/core/sal/panda/PandaArmCPU.hpp +++ b/src/core/sal/panda/PandaArmCPU.hpp @@ -1,5 +1,5 @@ #ifndef __PANDA_ARM_CPU_HPP__ - #define __PANDA_ARM_CPU_HPP__ +#define __PANDA_ARM_CPU_HPP__ #include "../arm/ArmArchitecture.hpp" #include "../arm/ArmCPUState.hpp" @@ -33,7 +33,7 @@ public: */ regdata_t getRegisterContent(const Register* reg) const; /** - * Sets the register content for the \a current Pandaboard CPU. + * Sets the register content for the \a current Pandaboard CPU. * @param reg the (initialized) register object whose content should be set * @param value the new content of the register \c reg */ diff --git a/src/core/sal/panda/PandaBreakpoints.ah b/src/core/sal/panda/PandaBreakpoints.ah index 961a8a37..95df3afb 100644 --- a/src/core/sal/panda/PandaBreakpoints.ah +++ b/src/core/sal/panda/PandaBreakpoints.ah @@ -1,5 +1,5 @@ #ifndef __PANDA_BREAKPOINTS_AH__ - #define __PANDA_BREAKPOINTS_AH__ +#define __PANDA_BREAKPOINTS_AH__ #include "config/FailConfig.hpp" #include "config/VariantConfig.hpp" @@ -11,38 +11,40 @@ aspect PandaBreakpoints { - advice "fail::BPSingleListener" : slice class - { - public: - bool onAddition() - { - // Setup Breakpoint on Pandaboard - struct halt_condition hc; - if (m_WatchInstrPtr == ANY_ADDR) { - hc.type = HALT_TYPE_SINGLESTEP; - } else { - hc.type = HALT_TYPE_BP; - } - hc.address = m_WatchInstrPtr; - hc.addr_len= 4; // Thumb? => 2 - oocdw_set_halt_condition(&hc); - return true; - } - void onDeletion() - { - // Delete Breakpoint on Pandaboard - struct halt_condition hc; - if (m_WatchInstrPtr == ANY_ADDR) { - hc.type = HALT_TYPE_SINGLESTEP; - } else { - hc.type = HALT_TYPE_BP; - } - hc.address = m_WatchInstrPtr; - hc.addr_len= 4; // Thumb? => 2 - oocdw_delete_halt_condition(&hc); +advice "fail::BPSingleListener" : slice class +{ +public: + bool onAddition() + { + // Setup Breakpoint on Pandaboard + struct halt_condition hc; + if (m_WatchInstrPtr == ANY_ADDR) { + hc.type = HALT_TYPE_SINGLESTEP; + } else { + hc.type = HALT_TYPE_BP; } - }; + hc.address = m_WatchInstrPtr; + hc.addr_len = 4; // Thumb? => 2 + oocdw_set_halt_condition(&hc); + return true; + } + + void onDeletion() + { + // Delete Breakpoint on Pandaboard + struct halt_condition hc; + if (m_WatchInstrPtr == ANY_ADDR) { + hc.type = HALT_TYPE_SINGLESTEP; + } else { + hc.type = HALT_TYPE_BP; + } + hc.address = m_WatchInstrPtr; + hc.addr_len = 4; // Thumb? => 2 + oocdw_delete_halt_condition(&hc); + } +}; + }; #endif // BUILD_PANDA && CONFIG_EVENT_BREAKPOINTS diff --git a/src/core/sal/panda/PandaConfig.hpp b/src/core/sal/panda/PandaConfig.hpp index 1d9b299d..b0d30304 100644 --- a/src/core/sal/panda/PandaConfig.hpp +++ b/src/core/sal/panda/PandaConfig.hpp @@ -5,13 +5,14 @@ */ #ifndef __PANDA_CONFIG_HPP__ - #define __PANDA_CONFIG_HPP__ +#define __PANDA_CONFIG_HPP__ namespace fail { - typedef uint32_t host_address_t; //!< the host memory address type - typedef uint32_t guest_address_t; //!< the guest memory address type - typedef uint32_t register_data_t; //!< register data type (32 bit) - typedef int timer_t; //!< type of timer IDs + +typedef uint32_t host_address_t; //!< the host memory address type +typedef uint32_t guest_address_t; //!< the guest memory address type +typedef uint32_t register_data_t; //!< register data type (32 bit) +typedef int timer_t; //!< type of timer IDs } // end-of-namespace: fail diff --git a/src/core/sal/panda/PandaController.cc b/src/core/sal/panda/PandaController.cc index 715e8133..88100e65 100644 --- a/src/core/sal/panda/PandaController.cc +++ b/src/core/sal/panda/PandaController.cc @@ -9,7 +9,7 @@ #include "openocd_wrapper.hpp" #if defined(CONFIG_FIRE_INTERRUPTS) - #error Firing intterupts not implemented for Pandaboard + #error Firing interrupts not implemented for Pandaboard #endif #if defined(CONFIG_SR_REBOOT) || defined(CONFIG_SR_RESTORE) || defined(CONFIG_SR_SAVE) @@ -56,16 +56,7 @@ void PandaController::onTimerTrigger(void* thisPtr) bool PandaController::save(const std::string& path) { - // ToDo (PORT): Save - - /*int stat; - - stat = mkdir(path.c_str(), 0777); - if (!(stat == 0 || errno == EEXIST)) { - return false; - // std::cout << "[FAIL] Can not create target-directory to save!" << std::endl; - // TODO: (Non-)Verbose-Mode? Log-level? Maybe better: use return value to indicate failure? - }*/ + // TODO return true; } @@ -73,11 +64,7 @@ bool PandaController::save(const std::string& path) void PandaController::restore(const std::string& path) { clearListeners(); - /*restore_bochs_request = true; - BX_CPU(0)->async_event |= 1; - sr_path = path;*/ - - // ToDo (PORT): Restore + // TODO } void PandaController::reboot() diff --git a/src/core/sal/panda/PandaController.hpp b/src/core/sal/panda/PandaController.hpp index b4e3d05c..8b3e9b58 100644 --- a/src/core/sal/panda/PandaController.hpp +++ b/src/core/sal/panda/PandaController.hpp @@ -1,5 +1,5 @@ #ifndef __PANDA_CONTROLLER_HPP__ - #define __PANDA_CONTROLLER_HPP__ +#define __PANDA_CONTROLLER_HPP__ #include #include diff --git a/src/core/sal/panda/PandaListener.hpp b/src/core/sal/panda/PandaListener.hpp index 9ca38599..5ad918ec 100644 --- a/src/core/sal/panda/PandaListener.hpp +++ b/src/core/sal/panda/PandaListener.hpp @@ -1,5 +1,5 @@ #ifndef __PANDA_LISTENER_HPP__ - #define __PANDA_LISTENER_HPP__ +#define __PANDA_LISTENER_HPP__ namespace fail { diff --git a/src/core/sal/panda/PandaMemory.hpp b/src/core/sal/panda/PandaMemory.hpp index 173bd849..177ac609 100644 --- a/src/core/sal/panda/PandaMemory.hpp +++ b/src/core/sal/panda/PandaMemory.hpp @@ -1,5 +1,5 @@ #ifndef __PANDA_MEMORY_HPP__ - #define __PANDA_MEMORY_HPP__ +#define __PANDA_MEMORY_HPP__ #include "../Memory.hpp" @@ -19,7 +19,7 @@ public: * Constructs a new MemoryManager object and initializes * it's attributes appropriately. */ - PandaMemoryManager() : MemoryManager() { } + PandaMemoryManager() : MemoryManager() { } /** * Retrieves the size of the available simulated memory. * @return the size of the memory pool in bytes diff --git a/src/core/sal/panda/PandaTimer.ah b/src/core/sal/panda/PandaTimer.ah index ff54278f..28ac7e07 100644 --- a/src/core/sal/panda/PandaTimer.ah +++ b/src/core/sal/panda/PandaTimer.ah @@ -1,5 +1,5 @@ #ifndef __PANDA_TIMER_AH__ - #define __PANDA_TIMER_AH__ +#define __PANDA_TIMER_AH__ #include "config/VariantConfig.hpp" #include "config/FailConfig.hpp" @@ -10,40 +10,42 @@ #include "PandaListener.hpp" aspect PandaTimer { - advice "fail::TimerListener" : slice class { - public: - bool onAddition() - { - // Register the timer listener in the Bochs simulator: - timer_id_t id = m_registerTimer(this); - if (id == -1) { - setId(INVALID_TIMER); - return false; // unable to register the timer (error in Bochs' function call) - } - setId(id); - return true; + +advice "fail::TimerListener" : slice class { +public: + bool onAddition() + { + // Register the timer listener in the Bochs simulator: + timer_id_t id = m_registerTimer(this); + if (id == -1) { + setId(INVALID_TIMER); + return false; // unable to register the timer (error in Bochs' function call) } - void onDeletion() - { - // Unregister the time listener: - m_unregisterTimer(this); - } - private: - timer_id_t m_registerTimer(TimerListener* pev) - { - assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); - return static_cast( - oocdw_register_timer(pev, fail::onTimerTrigger, - pev->getTimeout() /*timeout in microseconds*/, - true /*start immediately*/, "Fail*: PandaController"/*name*/)); - } - bool m_unregisterTimer(TimerListener* pev) - { - assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); - oocdw_deactivate_timer(static_cast(pev->getId())); - return oocdw_unregisterTimer(static_cast(pev->getId())); - } - }; + setId(id); + return true; + } + void onDeletion() + { + // Unregister the time listener: + m_unregisterTimer(this); + } +private: + timer_id_t m_registerTimer(TimerListener* pev) + { + assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); + return static_cast( + oocdw_register_timer(pev, fail::onTimerTrigger, + pev->getTimeout() /*timeout in microseconds*/, + true /*start immediately*/, "Fail*: PandaController"/*name*/)); + } + bool m_unregisterTimer(TimerListener* pev) + { + assert(pev != NULL && "FATAL ERROR: TimerListener object ptr cannot be NULL!"); + oocdw_deactivate_timer(static_cast(pev->getId())); + return oocdw_unregisterTimer(static_cast(pev->getId())); + } +}; + }; #endif // BUILD_PANDA && CONFIG_EVENT_BREAKPOINTS diff --git a/src/core/sal/panda/PandaWatchpoints.ah b/src/core/sal/panda/PandaWatchpoints.ah index 9a5be2c8..309e3a8b 100644 --- a/src/core/sal/panda/PandaWatchpoints.ah +++ b/src/core/sal/panda/PandaWatchpoints.ah @@ -1,5 +1,5 @@ #ifndef __PANDA_WATCHPOINTS_AH__ - #define __PANDA_WATCHPOINTS_AH__ +#define __PANDA_WATCHPOINTS_AH__ #include "config/FailConfig.hpp" #include "config/VariantConfig.hpp" @@ -11,49 +11,56 @@ aspect PandaWatchpoints { - advice "fail::MemAccessListener" : slice class + +advice "fail::MemAccessListener" : slice class +{ + int m_t32access; +public: + bool onAddition() { - int m_t32access; - public: - bool onAddition() - { - // Setup Watchpoint on Pandaboard (if it cant be realized as WP, mmu will be utilzed) - struct halt_condition hc; - - switch(m_WatchType) { - case MemAccessEvent::MEM_READ: hc.type = HALT_TYPE_WP_READ; break; - case MemAccessEvent::MEM_WRITE: hc.type = HALT_TYPE_WP_WRITE; break; - case MemAccessEvent::MEM_READWRITE: hc.type = HALT_TYPE_WP_READWRITE; break; - default: return false; - } - - hc.address = m_WatchAddr; - hc.addr_len = m_WatchWidth; + // Setup Watchpoint on Pandaboard (if it can't be realized as WP, MMU will be utilized) + struct halt_condition hc; - oocdw_set_halt_condition(&hc); - - return true; + switch (m_WatchType) { + case MemAccessEvent::MEM_READ: + hc.type = HALT_TYPE_WP_READ; break; + case MemAccessEvent::MEM_WRITE: + hc.type = HALT_TYPE_WP_WRITE; break; + case MemAccessEvent::MEM_READWRITE: + hc.type = HALT_TYPE_WP_READWRITE; break; + default: return false; } - void onDeletion() - { - // Remove Watchpoint from Pandaboard (if it was realized by mmu, it will be reprogrammed) - struct halt_condition hc; - - switch(m_WatchType) { - case MemAccessEvent::MEM_READ: hc.type = HALT_TYPE_WP_READ; break; - case MemAccessEvent::MEM_WRITE: hc.type = HALT_TYPE_WP_WRITE; break; - case MemAccessEvent::MEM_READWRITE: hc.type = HALT_TYPE_WP_READWRITE; break; - default: return; // ToDo: Error handling - } - - hc.address = m_WatchAddr; - hc.addr_len = m_WatchWidth; - - // ToDo: Error handling - oocdw_delete_halt_condition(&hc); + hc.address = m_WatchAddr; + hc.addr_len = m_WatchWidth; + + oocdw_set_halt_condition(&hc); + + return true; + } + + void onDeletion() + { + // Remove Watchpoint from Pandaboard (if it was realized by MMU, it will be reprogrammed) + struct halt_condition hc; + + switch (m_WatchType) { + case MemAccessEvent::MEM_READ: + hc.type = HALT_TYPE_WP_READ; break; + case MemAccessEvent::MEM_WRITE: + hc.type = HALT_TYPE_WP_WRITE; break; + case MemAccessEvent::MEM_READWRITE: + hc.type = HALT_TYPE_WP_READWRITE; break; + default: return; // ToDo: Error handling } - }; + + hc.address = m_WatchAddr; + hc.addr_len = m_WatchWidth; + + // ToDo: Error handling + oocdw_delete_halt_condition(&hc); + } +}; }; diff --git a/src/core/util/CMakeLists.txt b/src/core/util/CMakeLists.txt index 5b78bf2d..f44acab6 100644 --- a/src/core/util/CMakeLists.txt +++ b/src/core/util/CMakeLists.txt @@ -66,8 +66,8 @@ mark_as_advanced(FAIL_OBJDUMP) # compile smarthops calculator if needed if(CONFIG_INJECTIONPOINT_HOPS) - add_subdirectory(smarthops) - set(ADDITIONAL_LIBS fail-smarthops) + add_subdirectory(smarthops) + set(ADDITIONAL_LIBS fail-smarthops) endif(CONFIG_INJECTIONPOINT_HOPS) add_library(fail-util ${SRCS}) @@ -78,4 +78,3 @@ option(BUILD_LLVM_DISASSEMBLER "Build the LLVM-based disassembler (LLVM 3.3 pref if (BUILD_LLVM_DISASSEMBLER) add_subdirectory(llvmdisassembler) endif (BUILD_LLVM_DISASSEMBLER) - diff --git a/src/core/util/smarthops/SmartHops.cc b/src/core/util/smarthops/SmartHops.cc index c251957c..eb0aa82c 100644 --- a/src/core/util/smarthops/SmartHops.cc +++ b/src/core/util/smarthops/SmartHops.cc @@ -31,7 +31,7 @@ void SmartHops::convertToIPM(std::vector &result, unsigned costs, } ipm.set_costs(costs); - for(;it_hop != result.end(); + for (; it_hop != result.end(); it_hop++) { InjectionPointMessage_Hops *hop = ipm.add_hops(); hop->set_address(it_hop->first.first); @@ -116,7 +116,7 @@ bool SmartHops::calculateFollowingHop(InjectionPointMessage &ip, unsigned instru continue; } - // Deltion of unnecessary hops + // Deletion of unnecessary hops /* * |----------------| diff --git a/src/core/util/smarthops/SmartHops.hpp b/src/core/util/smarthops/SmartHops.hpp index 72485337..b837af55 100644 --- a/src/core/util/smarthops/SmartHops.hpp +++ b/src/core/util/smarthops/SmartHops.hpp @@ -30,8 +30,8 @@ public: // ToDo: If you want to use checkoints as additional hop-chain-element, you may switch // m_use_checkpoints to true, but there will be additional changes needed for this to fully work. // The sal must, for example, generate CPs at the given positions - SmartHops() : m_trace_pos(0), m_costs(0), m_next_cp_id(0), m_log("SmartHops", false), m_use_watchpoints(true), - m_use_weights(true), m_use_checkpoints(false), m_cp_thresh(0), m_cost_cp(0), m_rollback_thresh(0){} + SmartHops() : m_trace_pos(0), m_costs(0), m_next_cp_id(0), m_log("SmartHops", false), m_use_watchpoints(true), + m_use_weights(true), m_use_checkpoints(false), m_cp_thresh(0), m_cost_cp(0), m_rollback_thresh(0) {} /** * Initializes the used TraceReader with given trace file path @@ -44,24 +44,24 @@ public: * @param filename Path to the trace file * @returns \c true if calculation succeeded and \c false if it did not */ - bool calculateFollowingHop(InjectionPointMessage &ip, unsigned instruction_offset); + bool calculateFollowingHop(InjectionPointMessage &ip, unsigned instruction_offset); private: /** - * Converts internal representation of a hop chain to a + * Converts internal representation of a hop chain to a * InjectionPointMessage. The delivered InjectionPointMessage is * cleared before parsing. * @param result Internal representation of a hop chain * @param costs Costs of the hop chain (extracted from cost model) * @param ipm InjectionPointMessage to which the hop chain is parsed */ - void convertToIPM(std::vector &result, unsigned costs, InjectionPointMessage &ipm); + void convertToIPM(std::vector &result, unsigned costs, InjectionPointMessage &ipm); unsigned int m_trace_pos; unsigned int m_costs; - TraceReader m_trace_reader; - unsigned int m_next_cp_id; + TraceReader m_trace_reader; + unsigned int m_next_cp_id; Logger m_log; bool m_use_watchpoints; @@ -77,10 +77,10 @@ private: unsigned int m_rollback_thresh; - std::map m_last_positions; - std::vector m_checkpoints; + std::map m_last_positions; + std::vector m_checkpoints; - std::vector m_trace_events; + std::vector m_trace_events; std::vector m_result; }; diff --git a/src/core/util/smarthops/TraceReader.cc b/src/core/util/smarthops/TraceReader.cc index 96eec1c8..cc91ebe6 100644 --- a/src/core/util/smarthops/TraceReader.cc +++ b/src/core/util/smarthops/TraceReader.cc @@ -53,7 +53,7 @@ bool TraceReader::openTraceFile(const char *filename, unsigned int num_inst) } bool TraceReader::getNextTraceEvents(trace_pos_t& trace_pos, - std::vector& trace_events) + std::vector& trace_events) { // Stop after fixed number of instructions, if given as command line argument if ((m_max_num_inst > 0) && (m_current_position > m_max_num_inst)) { @@ -86,15 +86,15 @@ bool TraceReader::getNextTraceEvents(trace_pos_t& trace_pos, ev_avail = true; break; } - + // Add a trace_event for every byte in memory access. - // This breaks down the calculations to multiple - // memory accesses of length 1. No more complexity + // This breaks down the calculations to multiple + // memory accesses of length 1. No more complexity // is needed in hop calculations. if (ev.has_width()) { for (unsigned int i = 0; i < ev.width(); i++) { trace_events.push_back( - trace_event_tuple_t(ev.memaddr() + i, + trace_event_tuple_t(ev.memaddr() + i, ev.accesstype() == ev.READ ? ACCESS_READ : ACCESS_WRITE)); } } diff --git a/src/core/util/smarthops/TraceReader.hpp b/src/core/util/smarthops/TraceReader.hpp index 4cb30d39..fcf11eb7 100644 --- a/src/core/util/smarthops/TraceReader.hpp +++ b/src/core/util/smarthops/TraceReader.hpp @@ -14,11 +14,11 @@ namespace fail { typedef enum { - ACCESS_NONE , - ACCESS_READ , - ACCESS_WRITE , - ACCESS_READORWRITE , // some architectures can't distinguish read and write WPs in general (e.g. x86) - ACCESS_CHECKPOINT , + ACCESS_NONE, + ACCESS_READ, + ACCESS_WRITE, + ACCESS_READORWRITE, // some architectures can't distinguish read and write WPs in general (e.g. x86) + ACCESS_CHECKPOINT, } mem_access_type_e; typedef uint32_t address_t; @@ -26,33 +26,32 @@ typedef uint32_t trace_pos_t; typedef std::pair trace_event_tuple_t; class TraceReader { - public: +public: + TraceReader() : m_current_position(1), + ps(0), + normal_stream(0), + gz_stream(0), + m_max_num_inst(0), + ev_avail(false), + m_log("TraceReader", false) {} - TraceReader() : m_current_position(1), - ps(0), - normal_stream(0), - gz_stream(0), - m_max_num_inst(0), - ev_avail(false), - m_log("TraceReader", false) {} + ~TraceReader(); - ~TraceReader(); + // Returns ACCESS_NONE in mem_access if current instruction does not access memory + bool getNextTraceEvents(trace_pos_t& trace_pos, + std::vector& trace_events); - // Returns ACCESS_NONE in mem_access if current instruction does not access memory - bool getNextTraceEvents(trace_pos_t& trace_pos, - std::vector& trace_events); + bool openTraceFile(const char *filename, unsigned int num_inst = 0); +private: + unsigned int m_current_position; + ProtoIStream* ps; + std::ifstream *normal_stream; + igzstream *gz_stream; + unsigned int m_max_num_inst; + Trace_Event ev; + bool ev_avail; - bool openTraceFile(const char *filename, unsigned int num_inst = 0); - private: - unsigned int m_current_position; - ProtoIStream* ps; - std::ifstream *normal_stream; - igzstream *gz_stream; - unsigned int m_max_num_inst; - Trace_Event ev; - bool ev_avail; - - Logger m_log; + Logger m_log; }; } // end of namespace diff --git a/src/experiments/lra-simple-panda/CMakeLists.txt b/src/experiments/lra-simple-panda/CMakeLists.txt index d7912abc..586dc950 100644 --- a/src/experiments/lra-simple-panda/CMakeLists.txt +++ b/src/experiments/lra-simple-panda/CMakeLists.txt @@ -5,7 +5,7 @@ configure_file(../instantiate-experiment.ah.in ) ## Setup desired protobuf descriptions HERE ## -set(MY_PROTOS +set(MY_PROTOS lra_simple.proto ) diff --git a/src/experiments/lra-simple-panda/campaign.cc b/src/experiments/lra-simple-panda/campaign.cc index e2969758..011d190a 100644 --- a/src/experiments/lra-simple-panda/campaign.cc +++ b/src/experiments/lra-simple-panda/campaign.cc @@ -11,9 +11,9 @@ using namespace std; using namespace fail; using namespace google::protobuf; -void LraSimpleCampaign::cb_send_pilot(DatabaseCampaignMessage pilot) { +void LraSimpleCampaign::cb_send_pilot(DatabaseCampaignMessage pilot) +{ LraSimpleExperimentData *data = new LraSimpleExperimentData; data->msg.mutable_fsppilot()->CopyFrom(pilot); campaignmanager.addParam(data); } - diff --git a/src/experiments/lra-simple-panda/campaign.hpp b/src/experiments/lra-simple-panda/campaign.hpp index 9364fca8..1fed0145 100644 --- a/src/experiments/lra-simple-panda/campaign.hpp +++ b/src/experiments/lra-simple-panda/campaign.hpp @@ -14,7 +14,7 @@ public: }; class LraSimpleCampaign : public fail::DatabaseCampaign { - virtual const google::protobuf::Descriptor * cb_result_message() + virtual const google::protobuf::Descriptor * cb_result_message() { return google::protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName("LraSimpleProtoMsg"); } virtual void cb_send_pilot(DatabaseCampaignMessage pilot); diff --git a/src/experiments/lra-simple-panda/experiment.cc b/src/experiments/lra-simple-panda/experiment.cc index 199ab6b7..b65759d7 100644 --- a/src/experiments/lra-simple-panda/experiment.cc +++ b/src/experiments/lra-simple-panda/experiment.cc @@ -54,7 +54,6 @@ int32_t correct_result[100] = { 0, 0, 0, 0 }; - // ToDo: Move this functionality to SimulatorController bool LRASimplePandaExperiment::navigateToInjectionPoint(ConcreteInjectionPoint &ip) { Logger log_nav("navigator", false); @@ -66,11 +65,10 @@ bool LRASimplePandaExperiment::navigateToInjectionPoint(ConcreteInjectionPoint & if (ipm.has_checkpoint_id()) { // ToDo: Load CP state! - log_nav << "FATAL ERROR: CPs not yet implemented!" << endl; + log_nav << "FATAL ERROR: CPs not yet implemented!" << endl; simulator.terminate(1); } - log_nav << "Navigating to next instruction at navigational costs of " << ipm.costs() << endl; log_nav << "Length of hop-chain: " << ipm.hops_size() << endl; @@ -110,7 +108,6 @@ bool LRASimplePandaExperiment::navigateToInjectionPoint(ConcreteInjectionPoint & log_nav << "FATAL ERROR: Unexpected event while navigating!" << endl; simulator.terminate(1); } - } #else // Step nav @@ -195,7 +192,7 @@ bool LRASimplePandaExperiment::run() while (true) { logger << "asking jobserver for parameters. Undone: "<getNumberOfUndoneJobs() << endl; LraSimpleExperimentData param; - if(!jobClient->getParam(param)){ + if (!jobClient->getParam(param)) { logger << "Dying." << endl; // We were told to die. simulator.terminate(1); } @@ -203,17 +200,17 @@ bool LRASimplePandaExperiment::run() logger << "New param" << param.msg.DebugString() << endl; // Get input data from Jobserver - unsigned injection_instr = param.msg.fsppilot().injection_instr(); + unsigned injection_instr = param.msg.fsppilot().injection_instr(); address_t data_address = param.msg.fsppilot().data_address(); // unsigned data_width = param.msg.fsppilot().data_width(); ConcreteInjectionPoint ip; ip.parseFromCampaignMessage(param.msg.fsppilot()); - for (unsigned experiment_id = 0; experiment_id < LRASP_NUM_EXP_PER_PILOT; ++experiment_id) { - LraSimpleProtoMsg_Result *result = param.msg.add_result(); + for (unsigned experiment_id = 0; experiment_id < LRASP_NUM_EXP_PER_PILOT; ++experiment_id) { + LraSimpleProtoMsg_Result *result = param.msg.add_result(); executed_jobs ++; - WallclockTimer timer; + WallclockTimer timer; timer.startTimer(); /******************** @@ -255,7 +252,6 @@ bool LRASimplePandaExperiment::run() // Alternatively for single-bit-flips: // data ^= 1 << experiment_id; - logger << "Injection bitflips at address " << hex << data_address << dec << endl; timer.startTimer(); @@ -321,7 +317,7 @@ bool LRASimplePandaExperiment::run() BaseListener* ev = simulator.resume(); if (ev == &ev_timeout) { - logger << "Timeout!" << endl; + logger << "Timeout!" << endl; result->set_resulttype(result->ERR_TIMEOUT); } else if (ev == &ev_trap) { logger << "Trap!" << endl; @@ -332,7 +328,7 @@ bool LRASimplePandaExperiment::run() ev == &ev_unauth_mem_acc_4) { result->set_resulttype(result->ERR_OUTSIDE_TEXT); - logger << hex << "Unauthorized memory access (" << ((((MemAccessListener*)ev)->getTriggerAccessType() == fail::MemAccessEvent::MEM_READ) ? "R" : "W") << + logger << hex << "Unauthorized memory access (" << ((((MemAccessListener*)ev)->getTriggerAccessType() == fail::MemAccessEvent::MEM_READ) ? "R" : "W") << ") at instruction " << ((MemAccessListener*)ev)->getTriggerInstructionPointer() << " access address: " << ((MemAccessListener*)ev)->getTriggerAddress() << dec << endl; } else if (ev == &ev_func_end) { @@ -357,12 +353,12 @@ bool LRASimplePandaExperiment::run() result->set_experiment_number(executed_jobs); - simulator.clearListeners(); - } + simulator.clearListeners(); + } - jobClient->sendResult(param); - logger << param.debugString(); - } + jobClient->sendResult(param); + logger << param.debugString(); + } logger << "jobClient.getNumberOfUndoneJobs() = " << jobClient->getNumberOfUndoneJobs() << "executed_jobs = " << executed_jobs << endl; diff --git a/src/experiments/lra-simple-panda/experiment.hpp b/src/experiments/lra-simple-panda/experiment.hpp index 463e7470..ec889ee0 100644 --- a/src/experiments/lra-simple-panda/experiment.hpp +++ b/src/experiments/lra-simple-panda/experiment.hpp @@ -1,6 +1,6 @@ #ifndef __LRA_SIMPLE_PANDA_EXPERIMENT_HPP__ - #define __LRA_SIMPLE_PANDA_EXPERIMENT_HPP__ - +#define __LRA_SIMPLE_PANDA_EXPERIMENT_HPP__ + #include "efw/ExperimentFlow.hpp" #include "cpn/InjectionPoint.hpp" #include "util/ElfReader.hpp" diff --git a/src/experiments/lra-simple-panda/lra_simple.proto b/src/experiments/lra-simple-panda/lra_simple.proto index 6e23cd1c..beda33cb 100644 --- a/src/experiments/lra-simple-panda/lra_simple.proto +++ b/src/experiments/lra-simple-panda/lra_simple.proto @@ -6,25 +6,24 @@ message LraSimpleProtoMsg { repeated group Result = 2 { enum ResultType { OK = 1; - - ERR_WRONG_RESULT = 2; - + + ERR_WRONG_RESULT = 2; + ERR_TRAP = 3; ERR_TIMEOUT = 4; - + ERR_OUTSIDE_TEXT = 5; } - //required int32 bitoffset = 1 [(sql_primary_key) = true]; - - required uint32 experiment_number = 1 [(sql_primary_key) = true]; + //required int32 bitoffset = 1 [(sql_primary_key) = true]; + + required uint32 experiment_number = 1 [(sql_primary_key) = true]; required ResultType resulttype = 2; - - + // Times for evaluation required float time_init = 3; required float time_nav = 4; required float time_inject = 5; required float time_aftermath = 6; } -} \ No newline at end of file +} diff --git a/src/experiments/lra-simple-panda/main.cc b/src/experiments/lra-simple-panda/main.cc index ae6e5f3f..45566e59 100644 --- a/src/experiments/lra-simple-panda/main.cc +++ b/src/experiments/lra-simple-panda/main.cc @@ -8,8 +8,9 @@ int main(int argc, char **argv) { fail::CommandLine &cmd = fail::CommandLine::Inst(); - for (int i = 1; i < argc; ++i) + for (int i = 1; i < argc; ++i) { cmd.add_args(argv[i]); + } LraSimpleCampaign c; if (fail::campaignmanager.runCampaign(&c)) { diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 737f53de..269dc4b9 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -27,9 +27,9 @@ if(BUILD_CONVERT_TRACE) endif(BUILD_CONVERT_TRACE) if(BUILD_COMPUTE_HOPS) - add_subdirectory(compute-hops) + add_subdirectory(compute-hops) endif(BUILD_COMPUTE_HOPS) if(BUILD_DUMP_HOPS) - add_subdirectory(dump-hops) + add_subdirectory(dump-hops) endif(BUILD_DUMP_HOPS) diff --git a/tools/compute-hops/BasicAlgorithm.hpp b/tools/compute-hops/BasicAlgorithm.hpp index e1891771..30208593 100644 --- a/tools/compute-hops/BasicAlgorithm.hpp +++ b/tools/compute-hops/BasicAlgorithm.hpp @@ -5,19 +5,18 @@ class ResultCollector; class BasicAlgorithm { - public: - /** - * - * @returns boolean value for calculation success - */ - virtual bool calculateAllHops(fail::TraceReader& trace) = 0; +public: + /** + * + * @returns boolean value for calculation success + */ + virtual bool calculateAllHops(fail::TraceReader& trace) = 0; - BasicAlgorithm(ResultCollector *rc) {m_resultCollector = rc;} - virtual ~BasicAlgorithm() {} + BasicAlgorithm(ResultCollector *rc) { m_resultCollector = rc; } + virtual ~BasicAlgorithm() {} - protected: - ResultCollector *m_resultCollector; +protected: + ResultCollector *m_resultCollector; }; #endif // __BASIC_ALGORITHM__HPP - diff --git a/tools/compute-hops/CMakeLists.txt b/tools/compute-hops/CMakeLists.txt index 9d21d7ea..e81a680e 100644 --- a/tools/compute-hops/CMakeLists.txt +++ b/tools/compute-hops/CMakeLists.txt @@ -5,7 +5,7 @@ set(SRCS ) if(NOT CONFIG_INJECTIONPOINT_HOPS) - message (FATAL_ERROR "For building the compute-hops tool you need to enable CONFIG_INJECTIONPOINT_HOPS") + message (FATAL_ERROR "For building the compute-hops tool you need to enable CONFIG_INJECTIONPOINT_HOPS") endif() add_executable(compute-hops main.cc ${SRCS}) diff --git a/tools/compute-hops/ResultCollector.cc b/tools/compute-hops/ResultCollector.cc index e69d5bb9..792fea25 100644 --- a/tools/compute-hops/ResultCollector.cc +++ b/tools/compute-hops/ResultCollector.cc @@ -74,7 +74,7 @@ ResultCollector::addResult(std::vector& res, unsigned int costs) if (ps) { InjectionPointMessage hc; hc.set_costs(costs); - hc.set_target_trace_position(res.back().second); + hc.set_target_trace_position(res.back().second); // If checkpoint at beginning of hop-chain, add its id to InjectionPointMessage std::vector::iterator it_hop = res.begin(); if (it_hop != res.end() && it_hop->first.second == ACCESS_CHECKPOINT) { @@ -82,7 +82,7 @@ ResultCollector::addResult(std::vector& res, unsigned int costs) it_hop++; } - for(;it_hop != res.end(); + for (; it_hop != res.end(); it_hop++) { InjectionPointMessage_Hops *hop = hc.add_hops(); hop->set_address(it_hop->first.first); @@ -111,7 +111,7 @@ ResultCollector::addResult(std::vector& res, unsigned int costs) } ps->writeMessage(&hc); } else { - for(std::vector::iterator it_hop = res.begin(); + for (std::vector::iterator it_hop = res.begin(); it_hop != res.end(); it_hop++) { address_t add = it_hop->first.first; diff --git a/tools/compute-hops/ResultCollector.hpp b/tools/compute-hops/ResultCollector.hpp index 67205b35..a360d236 100644 --- a/tools/compute-hops/ResultCollector.hpp +++ b/tools/compute-hops/ResultCollector.hpp @@ -45,7 +45,7 @@ public: m_checkpoint_count(1), m_it_mean_costs(0), m_max_costs(0), - ps(0){} + ps(0) {} void addResult(std::vector& res, unsigned int costs); @@ -87,5 +87,3 @@ private: }; #endif /* STATISTICSCOLLECTOR_HPP_ */ - - diff --git a/tools/compute-hops/SimpleAlgorithm.hpp b/tools/compute-hops/SimpleAlgorithm.hpp index cfcb832d..24e06a3a 100644 --- a/tools/compute-hops/SimpleAlgorithm.hpp +++ b/tools/compute-hops/SimpleAlgorithm.hpp @@ -1,7 +1,6 @@ #ifndef SIMPLE_ALGORITHM__HPP #define SIMPLE_ALGORITHM__HPP -//#include #include #include "BasicAlgorithm.hpp" @@ -16,15 +15,14 @@ public: SimpleAlgorithm(ResultCollector *rc) : BasicAlgorithm(rc) {} virtual ~SimpleAlgorithm() {} - bool calculateAllHops(TraceReader& trace); + bool calculateAllHops(TraceReader& trace); private: - // Count occurences - //map > m_occurences; - std::map m_occurences; + // Count occurences + //map > m_occurences; + std::map m_occurences; - std::map m_occ_cp; + std::map m_occ_cp; }; #endif // SIMPLE_ALGORITHM__HPP - diff --git a/tools/compute-hops/SmartAlgorithm.cc b/tools/compute-hops/SmartAlgorithm.cc index 16f4f2b2..b1b9b2df 100644 --- a/tools/compute-hops/SmartAlgorithm.cc +++ b/tools/compute-hops/SmartAlgorithm.cc @@ -71,7 +71,7 @@ bool SmartAlgorithm::calculateAllHops(TraceReader& trace) continue; } - // Deltion of unnecessary hops + // Deletion of unnecessary hops /* * |----------------| diff --git a/tools/compute-hops/SmartAlgorithm.hpp b/tools/compute-hops/SmartAlgorithm.hpp index 7d1321e5..80d76c0d 100644 --- a/tools/compute-hops/SmartAlgorithm.hpp +++ b/tools/compute-hops/SmartAlgorithm.hpp @@ -21,19 +21,19 @@ public: SmartAlgorithm(ResultCollector *rc) : BasicAlgorithm(rc), m_next_cp_id(0) {} virtual ~SmartAlgorithm() {} - bool calculateAllHops(TraceReader& trace); + bool calculateAllHops(TraceReader& trace); private: - bool + bool occurenceInPosIntervall(unsigned int intervall_low, unsigned int intervall_high, address_t add, mem_access_type_e acc); - std::map m_last_positions; - std::vector m_checkpoints; - unsigned int m_next_cp_id; + std::map m_last_positions; + std::vector m_checkpoints; + unsigned int m_next_cp_id; }; #endif // SMART_ALGORITHM__HPP diff --git a/tools/compute-hops/main.cc b/tools/compute-hops/main.cc index aa2639c5..2f3979de 100644 --- a/tools/compute-hops/main.cc +++ b/tools/compute-hops/main.cc @@ -37,7 +37,6 @@ Logger LOG("hop-calculator", false); int main(int argc, char *argv[]) { - // Manually fill the command line option parser CommandLine &cmd = CommandLine::Inst(); @@ -239,7 +238,7 @@ int main(int argc, char *argv[]) if (cmd[CHECKPOINT_OUTPUT_FILE].count() > 0) { std::string filename(cmd[CHECKPOINT_OUTPUT_FILE].first()->arg); g_cp_ofstream.open(filename.c_str()); - if(!g_cp_ofstream.is_open()) { + if (!g_cp_ofstream.is_open()) { LOG << "Unable to open cp_out_file " << filename << std::endl; exit(-1); } @@ -282,32 +281,32 @@ int main(int argc, char *argv[]) BasicAlgorithm *algo; - switch (algorithm) { - case ALGO_SMART: - algo = new SmartAlgorithm(&rc); - break; - case ALGO_SIMPLE: - algo = new SimpleAlgorithm(&rc); - break; - default: - break; + switch (algorithm) { + case ALGO_SMART: + algo = new SmartAlgorithm(&rc); + break; + case ALGO_SIMPLE: + algo = new SimpleAlgorithm(&rc); + break; + default: + break; } - rc.startTimer(); - algo->calculateAllHops(trace); - rc.stopTimer(); + rc.startTimer(); + algo->calculateAllHops(trace); + rc.stopTimer(); - rc.finish(); + rc.finish(); - // ToDo: close output file if not stdout + // ToDo: close output file if not stdout if (outFile != &std::cout) { ((std::ofstream*)outFile)->close(); delete (std::ofstream*)outFile; } - if (g_use_checkpoints) { - g_cp_ofstream.close(); - } + if (g_use_checkpoints) { + g_cp_ofstream.close(); + } - return 0; + return 0; }