This commit is contained in:
Vladimir Krivosheev
2015-09-28 17:51:47 +02:00
parent 2f6f792c25
commit 2608521462
2 changed files with 20 additions and 21 deletions
@@ -35,7 +35,6 @@ import org.jetbrains.debugger.connection.VmConnection
import org.jetbrains.debugger.frame.SuspendContextImpl
import java.util.concurrent.ConcurrentMap
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.properties.Delegates
public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSession,
public val connection: C,
@@ -52,7 +51,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
public var processBreakpointConditionsAtIdeSide: Boolean = false
private val _breakpointHandlers: Array<XBreakpointHandler<*>> by Delegates.lazy { createBreakpointHandlers() }
private val _breakpointHandlers: Array<XBreakpointHandler<*>> by lazy(LazyThreadSafetyMode.NONE) { createBreakpointHandlers() }
init {
connection.addListener(object : SocketConnectionListener {
@@ -62,13 +61,13 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
if (status == ConnectionStatus.DETACHED) {
if (realProcessHandler != null) {
// here must we must use effective process handler
getProcessHandler().detachProcess()
processHandler.detachProcess()
}
}
getSession().stop()
}
ConnectionStatus.CONNECTION_FAILED -> {
getSession().reportError(status.getStatusText())
getSession().reportError(status.statusText)
getSession().stop()
}
else -> {
@@ -80,7 +79,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
}
protected final val realProcessHandler: ProcessHandler?
get() = executionResult?.getProcessHandler()
get() = executionResult?.processHandler
override final fun getSmartStepIntoHandler() = smartStepIntoHandler
@@ -94,7 +93,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
protected abstract fun createBreakpointHandlers(): Array<XBreakpointHandler<*>>
private fun updateLastCallFrame() {
lastCallFrame = vm?.getSuspendContextManager()?.getContext()?.getTopFrame()
lastCallFrame = vm?.getSuspendContextManager()?.context?.topFrame
}
override final fun checkCanPerformCommands() = vm != null
@@ -136,7 +135,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
protected final fun continueVm(stepAction: StepAction) {
val suspendContextManager = vm!!.getSuspendContextManager()
if (stepAction === StepAction.CONTINUE) {
if (suspendContextManager.getContext() == null) {
if (suspendContextManager.context == null) {
// on resumed we ask session to resume, and session then call our "resume", but we have already resumed, so, we don't need to send "continue" message
return
}
@@ -157,7 +156,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
}
protected final fun processBreakpoint(suspendContext: SuspendContext, breakpoint: XBreakpoint<*>, xSuspendContext: SuspendContextImpl) {
val condition = breakpoint.getConditionExpression()?.getExpression()
val condition = breakpoint.conditionExpression?.expression
if (!processBreakpointConditionsAtIdeSide || condition == null) {
processBreakpointLogExpressionAndSuspend(breakpoint, xSuspendContext, suspendContext)
}
@@ -182,7 +181,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
}
private fun processBreakpointLogExpressionAndSuspend(breakpoint: XBreakpoint<*>, xSuspendContext: SuspendContextImpl, suspendContext: SuspendContext) {
val logExpression = breakpoint.getLogExpressionObject()?.getExpression()
val logExpression = breakpoint.logExpressionObject?.expression
if (logExpression == null) {
breakpointReached(breakpoint, null, xSuspendContext)
}
@@ -202,7 +201,7 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
}
private fun breakpointReached(breakpoint: XBreakpoint<*>, evaluatedLogExpression: String?, suspendContext: XSuspendContext) {
if (getSession().breakpointReached(breakpoint, evaluatedLogExpression, suspendContext)) {
if (session.breakpointReached(breakpoint, evaluatedLogExpression, suspendContext)) {
setOverlay()
}
else {
@@ -211,14 +210,14 @@ public abstract class DebugProcessImpl<C : VmConnection<*>>(session: XDebugSessi
}
override final fun startPausing() {
connection.vm.getSuspendContextManager().suspend().rejected(RejectErrorReporter(getSession(), "Cannot pause"))
connection.vm.getSuspendContextManager().suspend().rejected(RejectErrorReporter(session, "Cannot pause"))
}
override final fun getCurrentStateMessage() = connection.getState().getMessage()
override final fun getCurrentStateMessage() = connection.state.message
override final fun getCurrentStateHyperlinkListener() = connection.getState().getMessageLinkListener()
override final fun getCurrentStateHyperlinkListener() = connection.state.messageLinkListener
override fun doGetProcessHandler() = executionResult?.getProcessHandler() ?: object : DefaultDebugProcessHandler() { override fun isSilentlyDestroyOnClose() = true }
override fun doGetProcessHandler() = executionResult?.processHandler ?: object : DefaultDebugProcessHandler() { override fun isSilentlyDestroyOnClose() = true }
public fun saveResolvedFile(url: Url, file: VirtualFile) {
urlToFileCache.putIfAbsent(url, file)
@@ -37,7 +37,7 @@ public abstract class LineBreakpointManager(private val vm: Vm, private val debu
override fun resolved(breakpoint: Breakpoint) {
var breakpoints = synchronized (lock) { vmToIdeBreakpoint.get(breakpoint) }
for (ideBreakpoint in breakpoints) {
debugProcess.getSession().updateBreakpointPresentation(ideBreakpoint, AllIcons.Debugger.Db_verified_breakpoint, null)
debugProcess.session.updateBreakpointPresentation(ideBreakpoint, AllIcons.Debugger.Db_verified_breakpoint, null)
}
}
@@ -47,13 +47,13 @@ public abstract class LineBreakpointManager(private val vm: Vm, private val debu
}
if (synchronized (lock) { runToLocationBreakpoints.remove(breakpoint) }) {
debugProcess.getSession().reportError("Cannot run to cursor: ${errorMessage!!}")
debugProcess.session.reportError("Cannot run to cursor: ${errorMessage!!}")
return
}
var breakpoints = synchronized (lock) { vmToIdeBreakpoint.get(breakpoint) }
for (ideBreakpoint in breakpoints) {
debugProcess.getSession().updateBreakpointPresentation(ideBreakpoint, AllIcons.Debugger.Db_invalid_breakpoint, errorMessage)
debugProcess.session.updateBreakpointPresentation(ideBreakpoint, AllIcons.Debugger.Db_invalid_breakpoint, errorMessage)
}
}
})
@@ -71,7 +71,7 @@ public abstract class LineBreakpointManager(private val vm: Vm, private val debu
for (vmBreakpoint in target) {
if (!vmBreakpoint.enabled) {
vmBreakpoint.enabled = true
breakpointManager.flush(vmBreakpoint).rejected { debugProcess.getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.getMessage()) }
breakpointManager.flush(vmBreakpoint).rejected { debugProcess.session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, it.getMessage()) }
}
}
}
@@ -155,8 +155,8 @@ public abstract class LineBreakpointManager(private val vm: Vm, private val debu
protected fun doSetBreakpoint(breakpoint: XLineBreakpoint<*>?, location: Location, isTemporary: Boolean): Breakpoint {
val breakpointManager = vm.getBreakpointManager()
val target = createTarget(breakpoint, breakpointManager, location, isTemporary)
val condition = breakpoint?.getConditionExpression()
return breakpointManager.setBreakpoint(target, location.getLine(), location.getColumn(), condition?.getExpression(), Breakpoint.EMPTY_VALUE, true)
val condition = breakpoint?.conditionExpression
return breakpointManager.setBreakpoint(target, location.line, location.column, condition?.expression, Breakpoint.EMPTY_VALUE, true)
}
protected abstract fun createTarget(breakpoint: XLineBreakpoint<*>?, breakpointManager: BreakpointManager, location: Location, isTemporary: Boolean): BreakpointTarget
@@ -200,7 +200,7 @@ public abstract class LineBreakpointManager(private val vm: Vm, private val debu
public fun clearRunToLocationBreakpoints() {
var breakpoints = synchronized (lock) {
if (runToLocationBreakpoints.isEmpty()) {
if (runToLocationBreakpoints.isEmpty) {
return@clearRunToLocationBreakpoints
}
var breakpoints = runToLocationBreakpoints.toArray<Breakpoint>(arrayOfNulls<Breakpoint>(runToLocationBreakpoints.size()))