Introduced new exception class: `GDBCommandFailedError`
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 13 Sep 2017 22:11:51 +0100
changeset 88 90c50fd6374c
parent 87 50e80d25ea6f
child 89 ba62d486014f
Introduced new exception class: `GDBCommandFailedError` ...that is raised from `GDBDebugger >> #send:andWait:` when used synchronously (that is, when waiting for command result). This allows senders to catch the command failures specifically.
GDBCommandFailedError.st
GDBDebugger.st
Make.proto
Make.spec
abbrev.stc
bc.mak
jv_libgdbs.st
libInit.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GDBCommandFailedError.st	Wed Sep 13 22:11:51 2017 +0100
@@ -0,0 +1,48 @@
+"{ Package: 'jv:libgdbs' }"
+
+"{ NameSpace: Smalltalk }"
+
+GDBError subclass:#GDBCommandFailedError
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'GDB-Core-Exeptions'
+!
+
+!GDBCommandFailedError class methodsFor:'raising'!
+
+raiseForResult: result
+    <resource: #skipInDebuggersWalkBack>
+
+    self newException
+        result: result;
+        raise.
+
+    "Created: / 13-09-2017 / 14:47:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!GDBCommandFailedError methodsFor:'accessing'!
+
+command
+    "Returns the command (as `GDBCommand`) that failed."
+
+    ^ self result command
+
+    "Created: / 13-09-2017 / 14:40:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+result
+    "Returns the command result (as `GDBCommandResult`) for the failure"
+
+    ^ self parameter
+
+    "Created: / 13-09-2017 / 14:41:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+result: aGDBCommandResult
+    parameter := aGDBCommandResult.
+    messageText := 'Command failed: ', (aGDBCommandResult propertyAt: 'msg').
+
+    "Created: / 13-09-2017 / 14:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/GDBDebugger.st	Fri Jul 07 11:28:44 2017 +0200
+++ b/GDBDebugger.st	Wed Sep 13 22:11:51 2017 +0100
@@ -184,13 +184,9 @@
         connection pushEvent:(GDBCommandEvent new command:cmd).
         blocker wait.
         result isError ifTrue:[
-            GDBError newException
-                parameter: result;
-                messageText: 'Command failed: ', (result propertyAt: 'msg');
-                raise.
+            GDBCommandFailedError raiseForResult: result.
         ].
         result.
-
     ]
     ifFalse:[
         connection pushEvent:(GDBCommandEvent new command:cmd).
@@ -198,7 +194,7 @@
     ]
 
     "Created: / 02-06-2014 / 23:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 11-07-2017 / 21:14:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-09-2017 / 14:46:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 send:command andWaitFor:eventHandlers
--- a/Make.proto	Fri Jul 07 11:28:44 2017 +0200
+++ b/Make.proto	Wed Sep 13 22:11:51 2017 +0100
@@ -34,7 +34,7 @@
 # add the path(es) here:,
 # ********** OPTIONAL: MODIFY the next lines ***
 # LOCALINCLUDES=-Ifoo -Ibar
-LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/announcements -I$(INCLUDE_TOP)/stx/goodies/magritte -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg
+LOCALINCLUDES= -I$(INCLUDE_TOP)/stx/goodies/announcements -I$(INCLUDE_TOP)/stx/goodies/magritte -I$(INCLUDE_TOP)/stx/goodies/sunit -I$(INCLUDE_TOP)/stx/libbasic -I$(INCLUDE_TOP)/stx/libbasic2 -I$(INCLUDE_TOP)/stx/libtool -I$(INCLUDE_TOP)/stx/libview2 -I$(INCLUDE_TOP)/stx/libwidg
 
 
 # if you need any additional defines for embedded C code,
@@ -149,6 +149,7 @@
 $(OUTDIR)GDBAsyncEvent.$(O) GDBAsyncEvent.$(C) GDBAsyncEvent.$(H): GDBAsyncEvent.st $(INCLUDE_TOP)/jv/libgdbs/GDBEvent.$(H) $(INCLUDE_TOP)/stx/goodies/announcements/Announcement.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCLICommand.$(O) GDBCLICommand.$(C) GDBCLICommand.$(H): GDBCLICommand.st $(INCLUDE_TOP)/jv/libgdbs/GDBCommand.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandEvent.$(O) GDBCommandEvent.$(C) GDBCommandEvent.$(H): GDBCommandEvent.st $(INCLUDE_TOP)/jv/libgdbs/GDBEvent.$(H) $(INCLUDE_TOP)/stx/goodies/announcements/Announcement.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)GDBCommandFailedError.$(O) GDBCommandFailedError.$(C) GDBCommandFailedError.$(H): GDBCommandFailedError.st $(INCLUDE_TOP)/jv/libgdbs/GDBError.$(H) $(INCLUDE_TOP)/stx/libbasic/Error.$(H) $(INCLUDE_TOP)/stx/libbasic/Exception.$(H) $(INCLUDE_TOP)/stx/libbasic/GenericException.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandResult.$(O) GDBCommandResult.$(C) GDBCommandResult.$(H): GDBCommandResult.st $(INCLUDE_TOP)/jv/libgdbs/GDBCommandStatus.$(H) $(INCLUDE_TOP)/jv/libgdbs/GDBObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandResultEvent.$(O) GDBCommandResultEvent.$(C) GDBCommandResultEvent.$(H): GDBCommandResultEvent.st $(INCLUDE_TOP)/jv/libgdbs/GDBEvent.$(H) $(INCLUDE_TOP)/stx/goodies/announcements/Announcement.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBConnection.$(O) GDBConnection.$(C) GDBConnection.$(H): GDBConnection.st $(INCLUDE_TOP)/jv/libgdbs/GDBDebugFlags.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/Make.spec	Fri Jul 07 11:28:44 2017 +0200
+++ b/Make.spec	Wed Sep 13 22:11:51 2017 +0100
@@ -73,6 +73,7 @@
 	GDBAsyncEvent \
 	GDBCLICommand \
 	GDBCommandEvent \
+	GDBCommandFailedError \
 	GDBCommandResult \
 	GDBCommandResultEvent \
 	GDBConnection \
@@ -263,6 +264,7 @@
     $(OUTDIR)GDBAsyncEvent.$(O) \
     $(OUTDIR)GDBCLICommand.$(O) \
     $(OUTDIR)GDBCommandEvent.$(O) \
+    $(OUTDIR)GDBCommandFailedError.$(O) \
     $(OUTDIR)GDBCommandResult.$(O) \
     $(OUTDIR)GDBCommandResultEvent.$(O) \
     $(OUTDIR)GDBConnection.$(O) \
--- a/abbrev.stc	Fri Jul 07 11:28:44 2017 +0200
+++ b/abbrev.stc	Wed Sep 13 22:11:51 2017 +0100
@@ -23,6 +23,7 @@
 GDBAsyncEvent GDBAsyncEvent jv:libgdbs 'GDB-Core-Events' 0
 GDBCLICommand GDBCLICommand jv:libgdbs 'GDB-Core-Commands' 0
 GDBCommandEvent GDBCommandEvent jv:libgdbs 'GDB-Core-Events' 0
+GDBCommandFailedError GDBCommandFailedError jv:libgdbs 'GDB-Core-Exeptions' 1
 GDBCommandResult GDBCommandResult jv:libgdbs 'GDB-Core-Commands' 0
 GDBCommandResultEvent GDBCommandResultEvent jv:libgdbs 'GDB-Core-Events' 0
 GDBConnection GDBConnection jv:libgdbs 'GDB-Private' 0
--- a/bc.mak	Fri Jul 07 11:28:44 2017 +0200
+++ b/bc.mak	Wed Sep 13 22:11:51 2017 +0100
@@ -35,7 +35,7 @@
 
 
 
-LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\announcements -I$(INCLUDE_TOP)\stx\goodies\magritte -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg
+LOCALINCLUDES= -I$(INCLUDE_TOP)\stx\goodies\announcements -I$(INCLUDE_TOP)\stx\goodies\magritte -I$(INCLUDE_TOP)\stx\goodies\sunit -I$(INCLUDE_TOP)\stx\libbasic -I$(INCLUDE_TOP)\stx\libbasic2 -I$(INCLUDE_TOP)\stx\libtool -I$(INCLUDE_TOP)\stx\libview2 -I$(INCLUDE_TOP)\stx\libwidg
 LOCALDEFINES=
 
 STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) -headerDir=. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES)  -varPrefix=$(LIBNAME)
@@ -96,6 +96,7 @@
 $(OUTDIR)GDBAsyncEvent.$(O) GDBAsyncEvent.$(C) GDBAsyncEvent.$(H): GDBAsyncEvent.st $(INCLUDE_TOP)\jv\libgdbs\GDBEvent.$(H) $(INCLUDE_TOP)\stx\goodies\announcements\Announcement.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCLICommand.$(O) GDBCLICommand.$(C) GDBCLICommand.$(H): GDBCLICommand.st $(INCLUDE_TOP)\jv\libgdbs\GDBCommand.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandEvent.$(O) GDBCommandEvent.$(C) GDBCommandEvent.$(H): GDBCommandEvent.st $(INCLUDE_TOP)\jv\libgdbs\GDBEvent.$(H) $(INCLUDE_TOP)\stx\goodies\announcements\Announcement.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)GDBCommandFailedError.$(O) GDBCommandFailedError.$(C) GDBCommandFailedError.$(H): GDBCommandFailedError.st $(INCLUDE_TOP)\jv\libgdbs\GDBError.$(H) $(INCLUDE_TOP)\stx\libbasic\Error.$(H) $(INCLUDE_TOP)\stx\libbasic\Exception.$(H) $(INCLUDE_TOP)\stx\libbasic\GenericException.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandResult.$(O) GDBCommandResult.$(C) GDBCommandResult.$(H): GDBCommandResult.st $(INCLUDE_TOP)\jv\libgdbs\GDBCommandStatus.$(H) $(INCLUDE_TOP)\jv\libgdbs\GDBObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBCommandResultEvent.$(O) GDBCommandResultEvent.$(C) GDBCommandResultEvent.$(H): GDBCommandResultEvent.st $(INCLUDE_TOP)\jv\libgdbs\GDBEvent.$(H) $(INCLUDE_TOP)\stx\goodies\announcements\Announcement.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBConnection.$(O) GDBConnection.$(C) GDBConnection.$(H): GDBConnection.st $(INCLUDE_TOP)\jv\libgdbs\GDBDebugFlags.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/jv_libgdbs.st	Fri Jul 07 11:28:44 2017 +0200
+++ b/jv_libgdbs.st	Wed Sep 13 22:11:51 2017 +0100
@@ -49,6 +49,7 @@
      Please also take a look at the #mandatoryPreRequisites method"
 
     ^ #(
+        #'stx:goodies/sunit'    "TestAsserter - superclass of GDBSimulatorResource"
         #'stx:libbasic2'    "List - referenced by GDBDebugger>>breakpoints"
         #'stx:libtool'    "Tools::Inspector2Tab - referenced by GDBBreakpoint>>inspector2TabCondition"
         #'stx:libview2'    "ApplicationModel - referenced by GDBEventSubscription class>>blockFor:withSelector:"
@@ -98,6 +99,7 @@
         GDBAsyncEvent
         GDBCLICommand
         GDBCommandEvent
+        GDBCommandFailedError
         GDBCommandResult
         GDBCommandResultEvent
         GDBConnection
--- a/libInit.cc	Fri Jul 07 11:28:44 2017 +0200
+++ b/libInit.cc	Wed Sep 13 22:11:51 2017 +0100
@@ -38,6 +38,7 @@
 extern void _GDBAsyncEvent_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBCLICommand_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBCommandEvent_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
+extern void _GDBCommandFailedError_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBCommandResult_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBCommandResultEvent_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBConnection_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
@@ -237,6 +238,7 @@
     _GDBAsyncEvent_Init(pass,__pRT__,snd);
     _GDBCLICommand_Init(pass,__pRT__,snd);
     _GDBCommandEvent_Init(pass,__pRT__,snd);
+    _GDBCommandFailedError_Init(pass,__pRT__,snd);
     _GDBCommandResult_Init(pass,__pRT__,snd);
     _GDBCommandResultEvent_Init(pass,__pRT__,snd);
     _GDBConnection_Init(pass,__pRT__,snd);