You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2007/04/18 17:28:25 UTC
svn commit: r530059 - in
/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core:
EventDispatcher.cpp PacketDispatcher.cpp
Author: gshimansky
Date: Wed Apr 18 08:28:24 2007
New Revision: 530059
URL: http://svn.apache.org/viewvc?view=rev&rev=530059
Log:
Applied HARMONY-3047 [jdktools][JDWP] EUT jdtdebug suit passes with JVMTI_ERROR_unknown error
Modified:
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/EventDispatcher.cpp
harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.cpp
Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/EventDispatcher.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/EventDispatcher.cpp?view=diff&rev=530059&r1=530058&r2=530059
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/EventDispatcher.cpp (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/EventDispatcher.cpp Wed Apr 18 08:28:24 2007
@@ -24,6 +24,7 @@
#include "EventDispatcher.h"
#include "ThreadManager.h"
#include "OptionParser.h"
+#include "PacketDispatcher.h"
#include "Log.h"
using namespace jdwp;
@@ -44,27 +45,46 @@
void EventDispatcher::Run(JNIEnv* jni) {
JDWP_TRACE_ENTRY("Run(" << jni << ')');
- MonitorAutoLock malCM(m_completeMonitor JDWP_FILE_LINE);
-
- while (!m_stopFlag) {
- EventComposer *ec;
-
- // get next event from queue
- {
- MonitorAutoLock lock(m_queueMonitor JDWP_FILE_LINE);
- while (m_holdFlag || m_eventQueue.empty()) {
- m_queueMonitor->Wait();
- if (m_stopFlag) {
- return;
+ try {
+ MonitorAutoLock malCM(m_completeMonitor JDWP_FILE_LINE);
+
+ try {
+ while (!m_stopFlag) {
+ EventComposer *ec;
+
+ // get next event from queue
+ {
+ MonitorAutoLock lock(m_queueMonitor JDWP_FILE_LINE);
+ while (m_holdFlag || m_eventQueue.empty()) {
+ m_queueMonitor->Wait();
+ if (m_stopFlag) {
+ return;
+ }
+ }
+ ec = m_eventQueue.front();
+ m_eventQueue.pop();
+ m_queueMonitor->NotifyAll();
}
+
+ // send event and suspend thread according to suspend policy
+ SuspendOnEvent(jni, ec);
}
- ec = m_eventQueue.front();
- m_eventQueue.pop();
- m_queueMonitor->NotifyAll();
}
-
- // send event and suspend thread according to suspend policy
- SuspendOnEvent(jni, ec);
+ catch (const AgentException& e)
+ {
+ JDWP_ERROR("Exception in EventDispatcher thread: "
+ << e.what() << " [" << e.ErrCode() << "]");
+
+ // reset current session
+ JDWP_TRACE_PROG("Run: reset session after exception");
+ GetPacketDispatcher().ResetAll(jni);
+ }
+ }
+ catch (const AgentException& e)
+ {
+ // just report an error, cannot do anything else
+ JDWP_ERROR("Exception in EventDispatcher synchronization: "
+ << e.what() << " [" << e.ErrCode() << "]");
}
}
Modified: harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.cpp?view=diff&rev=530059&r1=530058&r2=530059
==============================================================================
--- harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.cpp (original)
+++ harmony/enhanced/jdktools/trunk/modules/jpda/src/main/native/jdwp/common/agent/core/PacketDispatcher.cpp Wed Apr 18 08:28:24 2007
@@ -82,132 +82,140 @@
{
JDWP_TRACE_ENTRY("Run(" << jni << ")");
- m_isRunning = true;
-
- MonitorAutoLock lock(m_completionMonitor JDWP_FILE_LINE);
- TransportManager &transport = GetTransportManager();
-
- try
- {
- // run multiplle sessions in a loop
- for (; ;)
+ try {
+ m_isRunning = true;
+
+ MonitorAutoLock lock(m_completionMonitor JDWP_FILE_LINE);
+ TransportManager &transport = GetTransportManager();
+
+ try
{
- // connect for new session
- JDWP_TRACE_PROG("Run: start new session");
- try
- {
- transport.Connect();
- }
- catch (const TransportException& e)
+ // run multiplle sessions in a loop
+ for (; ;)
{
- JDWP_TRACE_PROG("Run: Exception in connection: "
- << e.what() << " [" << e.ErrCode()
- << "/" << e.TransportErrorCode() << "]");
- if (!IsDead()) {
- JDWP_DIE(e.what() << " [" << e.ErrCode() << "/"
- << e.TransportErrorCode() << "]: "
- << GetTransportManager().GetLastTransportError());
+ // connect for new session
+ JDWP_TRACE_PROG("Run: start new session");
+ try
+ {
+ transport.Connect();
}
- break;
- }
-
- // start session and execute commands
- try
- {
- // add internal request for automatic VMDeath event with no modifiers
- GetRequestManager().AddInternalRequest(jni,
- new AgentEventRequest(JDWP_EVENT_VM_DEATH, JDWP_SUSPEND_NONE));
-
- // release events
- GetEventDispatcher().ReleaseEvents();
-
- // read and execute commands
- m_isProcessed = true;
- while (m_isProcessed)
+ catch (const TransportException& e)
{
- // read command
- try {
- JDWP_TRACE_PROG("Run: handle next command");
- m_cmdParser.ReadCommand();
- if (m_cmdParser.command.GetLength() == 0)
- break;
+ JDWP_TRACE_PROG("Run: Exception in connection: "
+ << e.what() << " [" << e.ErrCode()
+ << "/" << e.TransportErrorCode() << "]");
+ if (!IsDead()) {
+ JDWP_DIE(e.what() << " [" << e.ErrCode() << "/"
+ << e.TransportErrorCode() << "]: "
+ << GetTransportManager().GetLastTransportError());
}
- catch (const TransportException& e)
+ break;
+ }
+
+ // start session and execute commands
+ try
+ {
+ // add internal request for automatic VMDeath event with no modifiers
+ GetRequestManager().AddInternalRequest(jni,
+ new AgentEventRequest(JDWP_EVENT_VM_DEATH, JDWP_SUSPEND_NONE));
+
+ // release events
+ GetEventDispatcher().ReleaseEvents();
+
+ // read and execute commands
+ m_isProcessed = true;
+ while (m_isProcessed)
{
- JDWP_TRACE_PROG("Run: Exception in reading command: "
- << e.what() << " [" << e.ErrCode()
- << "/" << e.TransportErrorCode() << "]");
- if (m_isProcessed && !IsDead())
+ // read command
+ try {
+ JDWP_TRACE_PROG("Run: handle next command");
+ m_cmdParser.ReadCommand();
+ if (m_cmdParser.command.GetLength() == 0)
+ break;
+ }
+ catch (const TransportException& e)
{
- char* msg = GetTransportManager().GetLastTransportError();
- AgentAutoFree af(msg JDWP_FILE_LINE);
-
- if (e.TransportErrorCode() == JDWPTRANSPORT_ERROR_OUT_OF_MEMORY) {
- JDWP_DIE(e.what() << " [" << e.ErrCode() << "/"
- << e.TransportErrorCode() << "]: " << msg);
- } else {
- JDWP_ERROR(e.what() << " [" << e.ErrCode() << "/"
- << e.TransportErrorCode() << "]: " << msg);
+ JDWP_TRACE_PROG("Run: Exception in reading command: "
+ << e.what() << " [" << e.ErrCode()
+ << "/" << e.TransportErrorCode() << "]");
+ if (m_isProcessed && !IsDead())
+ {
+ char* msg = GetTransportManager().GetLastTransportError();
+ AgentAutoFree af(msg JDWP_FILE_LINE);
+
+ if (e.TransportErrorCode() == JDWPTRANSPORT_ERROR_OUT_OF_MEMORY) {
+ JDWP_DIE(e.what() << " [" << e.ErrCode() << "/"
+ << e.TransportErrorCode() << "]: " << msg);
+ } else {
+ JDWP_ERROR(e.what() << " [" << e.ErrCode() << "/"
+ << e.TransportErrorCode() << "]: " << msg);
+ }
}
+ break;
+ }
+
+ // execute command and prevent from reset while execution
+ {
+ MonitorAutoLock lock(m_executionMonitor JDWP_FILE_LINE);
+ m_cmdDispatcher.ExecCommand(jni, &m_cmdParser);
}
- break;
}
-
- // execute command and prevent from reset while execution
- {
- MonitorAutoLock lock(m_executionMonitor JDWP_FILE_LINE);
- m_cmdDispatcher.ExecCommand(jni, &m_cmdParser);
+ }
+ catch (const AgentException& e)
+ {
+ JDWP_TRACE_PROG("Run: Exception in executing command: "
+ << e.what() << " [" << e.ErrCode() << "]");
+ if (!IsDead()) {
+ JDWP_ERROR(e.what() << " [" << e.ErrCode() << "]");
}
}
- }
- catch (const AgentException& e)
- {
- JDWP_TRACE_PROG("Run: Exception in executing command: "
- << e.what() << " [" << e.ErrCode() << "]");
- if (!IsDead()) {
- JDWP_ERROR(e.what() << " [" << e.ErrCode() << "]");
+
+ // reset all modules after session finished
+ JDWP_TRACE_PROG("Run: reset session");
+ ResetAll(jni);
+
+ // no more sessions if VMDeath event occured
+ if (IsDead()) {
+ JDWP_TRACE_PROG("Run: VM is dead -> shutdown");
+ break;
+ }
+
+ // no more sessions in attach mode
+ if (!GetOptionParser().GetServer()) {
+ JDWP_TRACE_PROG("Run: attach mode -> shutdown");
+ break;
}
}
-
- // reset all modules after session finished
- JDWP_TRACE_PROG("Run: reset session");
- ResetAll(jni);
-
- // no more sessions if VMDeath event occured
- if (IsDead()) {
- JDWP_TRACE_PROG("Run: VM is dead -> shutdown");
- break;
- }
-
- // no more sessions in attach mode
- if (!GetOptionParser().GetServer()) {
- JDWP_TRACE_PROG("Run: attach mode -> shutdown");
- break;
+ }
+ catch (const AgentException& e)
+ {
+ JDWP_TRACE_PROG("Run: Exception in PacketDispatcher: "
+ << e.what() << " [" << e.ErrCode() << "]");
+ if (!IsDead()) {
+ JDWP_DIE(e.what() << " [" << e.ErrCode() << "]");
}
}
- }
- catch (const AgentException& e)
- {
- JDWP_TRACE_PROG("Run: Exception in PacketDispatcher: "
- << e.what() << " [" << e.ErrCode() << "]");
- if (!IsDead()) {
- JDWP_DIE(e.what() << " [" << e.ErrCode() << "]");
+
+ // stop also EventDispatcher thread
+ try
+ {
+ JDWP_TRACE_PROG("Run: stop EventDispatcher");
+ GetEventDispatcher().Stop(jni);
+ }
+ catch (const AgentException& e)
+ {
+ JDWP_TRACE_PROG("Run: Exception in stopping EventDispatcher: "
+ << e.what() << " [" << e.ErrCode() << "]");
}
- }
- // stop also EventDispatcher thread
- try
- {
- JDWP_TRACE_PROG("Run: stop EventDispatcher");
- GetEventDispatcher().Stop(jni);
+ m_isRunning = false;
}
catch (const AgentException& e)
{
- JDWP_TRACE_PROG("Run: Exception in stopping EventDispatcher: "
+ // just report an error, cannot do anything else
+ JDWP_ERROR("Exception in PacketDispatcher synchronization: "
<< e.what() << " [" << e.ErrCode() << "]");
}
-
- m_isRunning = false;
}
//-----------------------------------------------------------------------------