Skip to content

Commit 86f792b

Browse files
committed
Fine tuning of when to do error and error vs return -code 1 (same as error) vs exit 1 (does not work in sims)
1 parent 9cfdf1b commit 86f792b

2 files changed

Lines changed: 65 additions & 28 deletions

File tree

CallbackDefaults.tcl

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace eval ::osvvm {
5959
# CallbackBefore_Xxx, CallbackAfter_Xxx
6060
#
6161
proc CallbackBefore_Build {Path_Or_File args} {
62-
# puts "Build Before ${Path_Or_File}"
62+
# puts "Build Before ${Path_Or_File}"
6363
}
6464
proc CallbackAfter_Build {Path_Or_File args} {
6565
# puts "Build After ${Path_Or_File}"
@@ -105,13 +105,15 @@ namespace eval ::osvvm {
105105

106106
proc CallbackOnError_Build {Path_Or_File BuildErrorMessage LocalBuildErrorInfo} {
107107
set ::osvvm::BuildErrorInfo $LocalBuildErrorInfo
108-
if {$::osvvm::FailOnBuildErrors} {
109-
# error "For tcl errorInfo, puts \$::osvvm::BuildErrorInfo"
110-
puts "Error: For tcl errorInfo, puts \$::osvvm::BuildErrorInfo. Signaling TCL Error"
111-
error "$BuildErrorMessage "
108+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
109+
puts "Build Error: Info from \$::osvvm::BuildErrorInfo "
110+
puts "$::osvvm::BuildErrorInfo"
112111
} else {
113-
puts "Error: For tcl errorInfo, puts \$::osvvm::BuildErrorInfo"
112+
puts "Build Error: For tcl errorInfo, puts \$::osvvm::BuildErrorInfo."
114113
}
114+
if {$::osvvm::FailOnBuildErrors} {
115+
error $BuildErrorMessage
116+
}
115117
}
116118

117119
proc CallbackOnError_FindIncludeFile {Path_Or_File CommandName} {
@@ -123,21 +125,36 @@ namespace eval ::osvvm {
123125
set ::osvvm::LibraryErrorInfo $::errorInfo
124126
puts "LibraryError: $ErrMsg"
125127
puts "LibraryError: library $LibraryName $PathToLib failed in $ErrInProc See messages above"
126-
puts "For tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
128+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
129+
puts "LibraryError: Info from \$::osvvm::LibraryErrorInfo"
130+
puts "$::osvvm::LibraryErrorInfo"
131+
} else {
132+
puts "LibraryError: For Tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
133+
}
127134
error "LibraryError: $ErrMsg"
128135
}
129136

130137
proc CallbackOnError_LinkLibrary {Message} {
131138
set ::osvvm::LibraryErrorInfo $::errorInfo
132-
puts "LibraryError: $Message See messages above"
133-
puts "For tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
139+
puts "LibraryError: LinkLibrary $Message See messages above"
140+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
141+
puts "LibraryError: Info from \$::osvvm::LibraryErrorInfo"
142+
puts "$::osvvm::LibraryErrorInfo"
143+
} else {
144+
puts "LibraryError: For Tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
145+
}
134146
error "$Message"
135147
}
136148

137149
proc CallbackOnError_RemoveLibraryDirectory {Message} {
138150
set ::osvvm::LibraryErrorInfo $::errorInfo
139-
puts "LibraryError: $Message See messages above"
140-
puts "For tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
151+
puts "LibraryError: RemoveLibraryDirectory $Message See messages above"
152+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
153+
puts "LibraryError: Info from \$::osvvm::LibraryErrorInfo"
154+
puts "$::osvvm::LibraryErrorInfo"
155+
} else {
156+
puts "LibraryError: For Tcl errorInfo, puts \$::osvvm::LibraryErrorInfo"
157+
}
141158
error "$Message"
142159
}
143160

@@ -151,8 +168,14 @@ namespace eval ::osvvm {
151168

152169
set AnalyzeErrorCount [expr $AnalyzeErrorCount+1]
153170
# set ConsecutiveAnalyzeErrors [expr $ConsecutiveAnalyzeErrors+1]
171+
154172
puts "AnalyzeError: See messages above in \"analyze $args\""
155-
puts "For tcl errorInfo, puts \$::osvvm::AnalyzeErrorInfo"
173+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
174+
puts "AnalyzeError: Info from \$::osvvm::AnalyzeErrorInfo"
175+
puts "$::osvvm::AnalyzeErrorInfo"
176+
} else {
177+
puts "AnalyzeError: For Tcl errorInfo, puts \$::osvvm::AnalyzeErrorInfo"
178+
}
156179

157180
# These settings are in OsvvmDefaultSettings. Override them in LocalScriptDefaults.tcl
158181
if {$AnalyzeErrorStopCount != 0 && $AnalyzeErrorCount >= $AnalyzeErrorStopCount } {
@@ -169,7 +192,12 @@ namespace eval ::osvvm {
169192
set SimulateErrorCount [expr $SimulateErrorCount+1]
170193
# set ConsecutiveSimulateErrors [expr $ConsecutiveSimulateErrors+1]
171194
puts "SimulateError: See messages above in \"simulate $args\""
172-
puts "For tcl errorInfo, puts \$::osvvm::SimulateErrorInfo"
195+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
196+
puts "SimulateError: Info from \$::osvvm::SimulateErrorInfo"
197+
puts "$::osvvm::SimulateErrorInfo"
198+
} else {
199+
puts "SimulateError: For Tcl errorInfo, puts \$::osvvm::SimulateErrorInfo"
200+
}
173201

174202
# These settings are in OsvvmDefaultSettings. Override them in LocalScriptDefaults.tcl
175203
if {$SimulateErrorStopCount != 0 && $SimulateErrorCount >= $SimulateErrorStopCount } {
@@ -184,7 +212,12 @@ namespace eval ::osvvm {
184212
set ::osvvm::WaveErrorInfo $LocalErrorInfo
185213

186214
puts "WaveError: Error while doing source $Directory/wave.do during simulate $LibraryUnit: $ErrMsg"
187-
puts "For tcl errorInfo, puts \$::osvvm::WaveErrorInfo"
215+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
216+
puts "WaveError: Info from \$::osvvm::WaveErrorInfo"
217+
puts "$::osvvm::WaveErrorInfo"
218+
} else {
219+
puts "WaveError: For Tcl errorInfo, puts \$::osvvm::WaveErrorInfo"
220+
}
188221

189222
# No errors are signaled here
190223
}
@@ -201,7 +234,12 @@ namespace eval ::osvvm {
201234
puts "ScriptError: during build. See previous messages for details."
202235
puts "Please include your simulator version in any issue reports"
203236
puts "For tcl errorInfo, puts \$::osvvm::BuildReportErrorInfo"
204-
237+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
238+
puts "ScriptError: Info from \$::osvvm::BuildReportErrorInfo"
239+
puts "$::osvvm::BuildReportErrorInfo"
240+
} else {
241+
puts "ScriptError: For Tcl errorInfo, puts \$::osvvm::BuildReportErrorInfo"
242+
}
205243
# Errors are signaled later in the build
206244
}
207245

@@ -253,7 +291,7 @@ namespace eval ::osvvm {
253291
set ::osvvm::SimulateReportErrorInfo $LocalReportErrorInfo
254292
# Continue current build
255293
puts "ReportError: Simulate2Html failed. See previous messages for details"
256-
if {$::osvvm::Debug} {
294+
if {$::osvvm::TclDebug || $::osvvm::Debug} {
257295
puts "errorInfo: $::osvvm::SimulateReportErrorInfo"
258296
}
259297

OsvvmScriptsCore.tcl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,23 +399,18 @@ proc build {{Path_Or_File "."} args} {
399399
set LocalBuildErrorInfo $::errorInfo
400400
if {$BuildErrorCode != 0} {
401401
CheckSimulationDirs ; ##?? Creates ReportsDirectory for builds that fail. Refactor later.
402-
if {$::osvvm::TclDebug} {
403-
puts "LocalBuild errorInfo: $::errorInfo"
404-
}
405402
}
406403

407404
set ReportYamlErrorCode [catch {FinishBuildYaml $BuildName} BuildYamlErrMsg]
408405
set LocalBuildYamlErrorInfo $::errorInfo
409-
if {$::osvvm::TclDebug} {
410-
puts "FinishBuildYaml errorInfo: $::errorInfo"
406+
if {($ReportYamlErrorCode != 0) && ($::osvvm::TclDebug || $::osvvm::Debug)} {
407+
# No prior call back, only depends on opening file that has already been opened
408+
puts "FinishBuildYaml \$LocalBuildYamlErrorInfo: $::errorInfo"
411409
}
412410

413411
# Try to create reports, even if the build failed
414412
set ReportErrorCode [catch {AfterBuildReports $BuildName} ReportsErrMsg]
415413
set LocalReportErrorInfo $::errorInfo
416-
if {$::osvvm::TclDebug} {
417-
puts "AfterBuildReports errorInfo: $::errorInfo"
418-
}
419414

420415
StopTranscript ${BuildName}
421416

@@ -441,12 +436,13 @@ proc build {{Path_Or_File "."} args} {
441436
if {$AnalyzeErrorCount > 0 || $SimulateErrorCount > 0} {
442437
CallbackOnError_Build $Path_Or_File "Failed with Analyze Errors: $AnalyzeErrorCount and/or Simulate Errors: $SimulateErrorCount" $LocalBuildErrorInfo
443438
}
444-
if {($ReportErrorCode != 0) || ($ScriptErrorCount != 0)} {
439+
if {($ReportErrorCode != 0) || ($ScriptErrorCount != 0)} {
445440
CallbackOnError_AfterBuildReports $LocalReportErrorInfo
446441
}
447442
# Fail on Test Case Errors
448443
if {($::osvvm::BuildStatus ne "PASSED") && ($::osvvm::FailOnTestCaseErrors)} {
449-
error "Test finished with Test Case Errors"
444+
puts "Test finished with Test Case Errors. Return -code 1"
445+
return -code 1
450446
}
451447
# Fail on Report / Script Errors?
452448
if {($ReportYamlErrorCode != 0) || ($ReportErrorCode != 0) || ($Log2ErrorCode != 0) || ($ScriptErrorCount != 0)} {
@@ -1188,6 +1184,7 @@ proc simulate {LibraryUnit args} {
11881184
set SavedInteractive [GetInteractiveMode]
11891185
if {!($::osvvm::BuildStarted)} {
11901186
SetInteractiveMode "true"
1187+
BuildName $LibraryUnit
11911188
}
11921189

11931190
set SimulateErrorCode [catch {LocalSimulate $LibraryUnit {*}$args} SimErrMsg]
@@ -1201,8 +1198,6 @@ proc simulate {LibraryUnit args} {
12011198
unset vendor_simulate_started
12021199
}
12031200

1204-
SetInteractiveMode $SavedInteractive ; # Restore original value
1205-
12061201
set ReportErrorCode [catch {AfterSimulateReports} ReportErrMsg]
12071202
set LocalReportErrorInfo $::errorInfo
12081203

@@ -1224,6 +1219,10 @@ proc simulate {LibraryUnit args} {
12241219
if {$ReportErrorCode != 0} {
12251220
CallbackOnError_AfterSimulateReports $ReportErrMsg $LocalReportErrorInfo
12261221
}
1222+
if {!($::osvvm::BuildStarted)} {
1223+
SetInteractiveMode $SavedInteractive ; # Restore original value
1224+
Set BuildName ""
1225+
}
12271226
}
12281227

12291228
proc LocalSimulate {LibraryUnit args} {

0 commit comments

Comments
 (0)