Skip to content

Commit

Permalink
Fix handling of instrumentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Jackson committed Jan 27, 2020
1 parent 11cf10b commit 91b3e2e
Showing 1 changed file with 39 additions and 15 deletions.
54 changes: 39 additions & 15 deletions lib/debugserver/server.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ proc ::server::output { category msg args } {
]
}

proc ::server::bgerror { msg } {
::server::output console $msg
}

proc ::server::handle { msg } {
set type [dict get $msg type]
switch -exact -- $type {
Expand Down Expand Up @@ -142,7 +138,7 @@ proc ::server::OnRequest_initialize { msg } {

# Register the error handler for errors during instrumentation.

set instrument::errorHandler debugger::instrumentErrorHandler
set instrument::errorHandler ::server::instrumentErrorHandler

# Initialize the debugger.

Expand Down Expand Up @@ -709,16 +705,6 @@ proc ::server::exitHandler { args } {
::connection::notify terminated [json::write object]
}

proc ::server::errorHandler { errMsg errStk errCode uncaught } {
variable handlingError
incr handlingError
::connection::notify stopped [json::write object \
reason [json::write string "exception"] \
description [json::write string "Error: $errMsg"] \
threadId 1
]
}

proc ::server::resultHandler { id code result errCode errInfo } {
variable eval_requests
variable evaluating
Expand Down Expand Up @@ -802,3 +788,41 @@ proc ::server::mapFileName { direction fileName } {
}
return $fileName
}

proc ::server::bgerror { msg } {
::server::output console $msg
}

proc ::server::errorHandler { errMsg errStk errCode uncaught } {
variable handlingError
incr handlingError
::connection::notify stopped [json::write object \
reason [json::write string "exception"] \
description [json::write string "Error: $errMsg"] \
threadId 1
]
::server::output console "Uncaught error: $errMsg"
::server::output console " - errCode: $errCode"
::server::output console " - errStk: $errStk"
::server::output console " - uncaught: $uncaught"
::server::output console " - Issue 'step out' to ignore"

}

proc ::server::instrumentErrorHandler {loc} {
# See lib/tclgebugger/gui.tcl : instrumentErrorHandler

set errorMsg [lindex $::errorCode end]

::dbg::Log error {Instrumentation errorCode: $::errorCode}

::server::output console "Instrument ERROR:\
\n$errorMsg\
\n\nInstrumentation may be incomplete."

# TODO: We could actually throw a breakpoint here, vwait and intercept the
# continue call, but let's not.

# Ignore the error
return 1
}

0 comments on commit 91b3e2e

Please sign in to comment.