// Get reference to FileOutputStream constructor - two versions may apply // Older (pre JDK1.4) version accepts (String name) parameters only // Later version also accepts (String name, boolean append) parameter pattern // If append mode function is found, set flag to indicate call parameter to be added static jmethodID getStreamConstructor(JNIEnv *env, jclass& fileOutputStreamClass, bool overwriteModeOnly, bool& useAppendParam) { jmethodID fileOutputStreamConstructor = NULL; useAppendParam = false; if (!overwriteModeOnly) { fileOutputStreamConstructor = env->GetMethodID(fileOutputStreamClass, "<init>", "(Ljava/lang/String;Z)V"); // if this form of constructor not found (pre 1.4 JVM) then use simpler (String name) form instead if (exceptionRaised(env) || (fileOutputStreamConstructor == NULL)) { useAppendParam = false; // wanted later version, but not available in this JVM } else // found later constructor to use for appending to output file { useAppendParam = true; } } // if not using later form of constructor, look for simpler (String name) form instead, no append if (overwriteModeOnly || !useAppendParam) { fileOutputStreamConstructor = env->GetMethodID(fileOutputStreamClass, "<init>", "(Ljava/lang/String;)V"); } return fileOutputStreamConstructor; }
/** * Processes a stop-reply message. * * @param msg The message to process. * * @return A NaviError code that describes whether the operation was successful * or not. */ NaviError GdbSystem::processMessage(const std::string& msg) { if (cpu->isBreakpointMessage(msg)) { bool isRegular = cpu->hasRegularBreakpointMessage(); unsigned int signal = isRegular ? zylib::zycon::parseHexString<unsigned int>(msg.substr(2, 2)) : 0; msglog->log(LOG_VERBOSE, "Received stop message %s", msg.c_str()); if (!isRegular || signal == 5) { return processBreakpointMessage(msg); } else if (signal == SIGSEGV) { // SEGFAULT msglog->log(LOG_ALWAYS, "Target process segfaulted"); cpu->sendAck(); CPUADDRESS address = 0; NaviError eipResult = getInstructionPointer( threadFromBreakpointMessage(msg), address); if (eipResult) { msglog->log(LOG_VERBOSE, "Error: Couldn't read the value of the " "instruction pointer (Code %d)", eipResult); return eipResult; } exceptionRaised(threadFromBreakpointMessage(msg), address, signal); return NaviErrors::SUCCESS; } else { msglog->log(LOG_ALWAYS, "Received unknown stop message %s", msg.c_str()); cpu->sendAck(); resume(threadFromBreakpointMessage(msg)); return NaviErrors::SUCCESS; } } else if (cpu->isProcessExitMessage(msg) || cpu->isProcessTerminateMessage(msg)) { cpu->sendAck(); // Tell the base system that the process exited processExit(); } else { msglog->log(LOG_ALWAYS, "Error: Received unknown message %s", msg.c_str()); } return NaviErrors::SUCCESS; }