int main(int argc, char **argv) { QCoreApplication app(argc, argv); DLogger::registerCallback({DLogger::Type::Error, DLogger::Type::Warning, DLogger::Type::Message}, [](QString msg)-> void { printf("%s\n", msg.toStdString().c_str()); fflush(0); }); LOG_MSG("Start!"); ELFTester tester("elf_test_outputs"); QList<QString> file_names_x86 = { "bin/my32", "bin/myaslr32", "bin/derby32" }; QList<QString> file_names_x64 = { "bin/my64", "bin/myaslr64", "bin/derby64", "bin/edb", "bin/dDeflect", "bin/telnet" }; // QList<QString> file_names_x86 = { "bin/my32" }; // QList<QString> file_names_x64 = { "bin/edb"/*, "bin/telnet"*/ }; /* foreach (QString fname, file_names_x86) tester.test_everything_x86(fname, true); foreach (QString fname, file_names_x64) tester.test_everything_x64(fname, false); */ SourceCodeDescription scd; DJsonParser json_parser("descriptions/src/"); if (!json_parser.loadSourceCodeDescription("src_is_debugger_present.json", scd)) return -1; /* tester.test_one("bin/derby32", "derby32_ud2_x86", ELFTester::Method::Thread, "lin_x86_ptrace", "lin_x86_ud2", false, false, false); tester.test_one("bin/derby32", "derby32_fpe_x86", ELFTester::Method::Thread, "lin_x86_ptrace", "lin_x86_fpe", false, false, false); tester.test_one("bin/derby32", "derby32_mov_x86", ELFTester::Method::Thread, "lin_x86_ptrace", "lin_x86_mov", false, false, false); tester.test_one("bin/derby32", "derby32_jmp_x86", ELFTester::Method::Thread, "lin_x86_ptrace", "lin_x86_jmp", false, false, false); tester.test_one("bin/edb", "__edb_ud2_x64", ELFTester::Method::OEP, "lin_x64_ptrace", "lin_x64_ud2", false, true, false); tester.test_one("bin/edb", "__edb_fpe_x64", ELFTester::Method::OEP, "lin_x64_ptrace", "lin_x64_fpe", false, true, false); tester.test_one("bin/edb", "__edb_mov_x64", ELFTester::Method::OEP, "lin_x64_ptrace", "lin_x64_mov", false, true, false); tester.test_one("bin/edb", "__edb_jmp_x64", ELFTester::Method::OEP, "lin_x64_ptrace", "lin_x64_jmp", false, true, false); */ return 0; }
static void sync_tuple_changed_callback(const uint32_t key, const Tuple* new_tuple, const Tuple* old_tuple, void* context) { APP_LOG(APP_LOG_LEVEL_DEBUG, "App Message Sync received: %lu", key); // Set the timer to normal rate if (update_interval != OPENWEATHER_REFRESH_INTERVAL) set_timer(OPENWEATHER_REFRESH_INTERVAL); // Interpret the forecast if (key == OPENWEATHER_KEY) { if (new_tuple->value->cstring) APP_LOG(APP_LOG_LEVEL_DEBUG, "Data: size %u ***%s***", (unsigned int)strlen(new_tuple->value->cstring), new_tuple->value->cstring); else APP_LOG(APP_LOG_LEVEL_DEBUG, "Data: NULL"); forecast_data.cnt = 0; JSP_ErrorType result = json_parser(new_tuple->value->cstring); if (result == JSP_OK) openweather_issue_callbacks(); else LOG_DEBUG("Json parser error 0x%x", result); } else LOG_ERROR("Unknown key received %lu", key); }
namespace oos { json_parser json_type::parser = json_parser(); json_type::json_type(const std::string &name) : type_(name) {} json_type::~json_type() {} json_value& json_type::operator[](const std::string &) { throw std::logic_error(type_ + " has no key access operator"); } json_value& json_type::operator[](size_t ) { throw std::logic_error(type_ + " has no index access operator"); } const json_value& json_type::operator[](size_t ) const { throw std::logic_error(type_ + " has no index access operator"); } void json_type::push_back(const json_value &) { throw std::logic_error(type_ + " has no push_back method"); } std::string json_type::type() const { return type_; } void json_type::type(const std::string &type) { type_ = type; } size_t json_type::size() const { throw std::logic_error(type_ + " has no size method"); } /* std::istream& operator>>(std::istream &str, json_type &value) { value.parse(str); return str; } */ std::ostream& operator<<(std::ostream &str, const json_type &value) { value.print(str); return str; } }
stat_t _command_dispatch() { #ifdef __AVR stat_t status; // read input line or return if not a completed line // xio_gets() is a non-blocking workalike of fgets() while (true) { if ((status = xio_gets(cs.primary_src, cs.in_buf, sizeof(cs.in_buf))) == STAT_OK) { cs.bufp = cs.in_buf; break; } // handle end-of-file from file devices if (status == STAT_EOF) { // EOF can come from file devices only if (cfg.comm_mode == TEXT_MODE) { fprintf_P(stderr, PSTR("End of command file\n")); } else { rpt_exception(STAT_EOF); // not really an exception } tg_reset_source(); // reset to default source } return (status); // Note: STAT_EAGAIN, errors, etc. will drop through } #endif // __AVR #ifdef __ARM // detect USB connection and transition to disconnected state if it disconnected if (SerialUSB.isConnected() == false) cs.state = CONTROLLER_NOT_CONNECTED; // read input line and return if not a completed line if (cs.state == CONTROLLER_READY) { if (read_line(cs.in_buf, &cs.read_index, sizeof(cs.in_buf)) != STAT_OK) { cs.bufp = cs.in_buf; return (STAT_OK); // This is an exception: returns OK for anything NOT OK, so the idler always runs } } else if (cs.state == CONTROLLER_NOT_CONNECTED) { if (SerialUSB.isConnected() == false) return (STAT_OK); cm_request_queue_flush(); rpt_print_system_ready_message(); cs.state = CONTROLLER_STARTUP; } else if (cs.state == CONTROLLER_STARTUP) { // run startup code cs.state = CONTROLLER_READY; } else { return (STAT_OK); } cs.read_index = 0; #endif // __ARM #ifdef __RX stat_t status; parse_gcode_func_selection(CODE_PARSER); // read input line or return if not a completed line // xio_gets() is a non-blocking workalike of fgets() while (true) { if ((status = xio_gets(cs.primary_src, cs.in_buf, sizeof(cs.in_buf))) == STAT_OK) { cs.bufp = cs.in_buf; break; } // handle end-of-file from file devices if (status == STAT_EOF) { // EOF can come from file devices only //gfilerunning = false; xio_close(cs.primary_src); // macro_func_ptr = command_idle; if (cfg.comm_mode == TEXT_MODE) { fprintf_P(stderr, PSTR("End of command file\n")); } else { rpt_exception(STAT_EOF); // not really an exception } tg_reset_source(); // reset to default source } return (status); // Note: STAT_EAGAIN, errors, etc. will drop through } #endif // __AVR // set up the buffers cs.linelen = strlen(cs.in_buf)+1; // linelen only tracks primary input strncpy(cs.saved_buf, cs.bufp, SAVED_BUFFER_LEN-1); // save input buffer for reporting // dispatch the new text line switch (toupper(*cs.bufp)) { // first char case '!': { cm_request_feedhold(); break; } // include for AVR diagnostics and ARM serial case '%': { cm_request_queue_flush(); break; } case '~': { cm_request_cycle_start(); break; } case NUL: { // blank line (just a CR) if (cfg.comm_mode != JSON_MODE) { text_response(STAT_OK, cs.saved_buf); } break; } case '$': case '?': case 'H': { // text mode input cfg.comm_mode = TEXT_MODE; text_response(text_parser(cs.bufp), cs.saved_buf); break; } case '{': { // JSON input cfg.comm_mode = JSON_MODE; json_parser(cs.bufp); break; } default: { // anything else must be Gcode if (cfg.comm_mode == JSON_MODE) { // run it as JSON... strncpy(cs.out_buf, cs.bufp, INPUT_BUFFER_LEN -8); // use out_buf as temp sprintf((char *)cs.bufp,"{\"gc\":\"%s\"}\n", (char *)cs.out_buf); // '-8' is used for JSON chars json_parser(cs.bufp); } else { //...or run it as text text_response(gc_gcode_parser(cs.bufp), cs.saved_buf); } } } return (STAT_OK); }