GDBDebugger.st
changeset 169 a3d1f59e3bfd
parent 166 5cb191425081
child 170 6cf990ac2cad
--- a/GDBDebugger.st	Wed Jan 16 23:42:24 2019 +0000
+++ b/GDBDebugger.st	Sat Jan 19 23:25:55 2019 +0000
@@ -354,7 +354,7 @@
 
     self assert: self isConnected.
     command isString ifTrue:[
-        commandObject := (GDBMIParser on:command) parseCommand.
+        commandObject := GDBCommand parse: command.
         commandObject token:self nextCommandSequnceNumber.
     ] ifFalse:[
         commandObject := command.
@@ -368,7 +368,7 @@
         withTimeoutMs: timeout
 
     "Created: / 07-03-2015 / 11:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified (format): / 04-02-2018 / 00:20:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 19-01-2019 / 23:05:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 send:command andWithResultDo: block
@@ -397,7 +397,7 @@
     self assert: self isConnected.
     cmd := command.
     cmd isString ifTrue:[
-        cmd := GDBCLICommand new value:cmd.
+        cmd := GDBCommand parse:cmd.
     ].
     token := self nextCommandSequnceNumber.
     cmd token:token.
@@ -419,7 +419,7 @@
 
     "Created: / 26-01-2018 / 21:47:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 26-03-2018 / 21:48:02 / jv"
-    "Modified (comment): / 01-01-2019 / 11:31:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 19-01-2019 / 23:06:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBDebugger methodsFor:'commands - API'!
@@ -594,6 +594,22 @@
     "Modified: / 09-02-2018 / 09:44:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+getParameter:name 
+    "Teturn the current value of a GDB parameter. 
+     See `show` GDB command.
+
+     Subscribe to `GDBCmdParamChangedEvent` to get notified
+     when parameter value changes.
+    "
+    
+    | result |
+
+    result := self send:(GDBMI_gdb_show arguments:(Array with:name)).
+    ^ result propertyAt:#value.
+
+    "Created: / 19-01-2019 / 21:55:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 selectFrame: aGDBFrame
     "
     Set the context frame to given frame. This frame is then
@@ -616,6 +632,20 @@
     "Created: / 01-02-2018 / 22:25:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+setParameter:name to:value 
+    "Set an internal GDB parameter named `name` to `value`.
+     See `set` GDB command.
+
+     Subscribe to `GDBCmdParamChangedEvent` to get notified
+     when parameter value changes.
+    "
+    
+    self assert:value isString.
+    self send:(GDBMI_gdb_set arguments:(Array with:name with:value)).
+
+    "Created: / 19-01-2019 / 21:56:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 targetConnect: type parameters: parameters
     "Connect to the remote target. `type` is the type of target, 
      for instance ‘extended-remote=’. `parameters` are device names, 
@@ -795,6 +825,29 @@
     "Modified: / 20-06-2014 / 22:09:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+onCommandResultEvent:aGDBCommandResultEvent
+    | result |
+
+    result := aGDBCommandResultEvent result.
+
+    "/ For some reason, -gdb-set MI command does not cause
+    "/ =cmd-param-changed notification. To make this transparent
+    "/ for users, catch successful -gdb-set here and send
+    "/ GDBCmdParamChangedEvent manually. Sigh, what a hack!!
+    (result isDone
+        and:[ result command notNil
+        and:[ result command isMICommand 
+        and:[ result command operation = 'gdb-set' ]]]) ifTrue:[ 
+        | event |
+
+        event := GDBCmdParamChangedEvent name: result command arguments first value: result command arguments second.
+        connection pushEvent: event.  
+    ].
+
+    "Created: / 19-01-2019 / 22:35:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-01-2019 / 17:53:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 onExitEvent:aGDBExitEvent 
     self release.
 
@@ -988,6 +1041,7 @@
 subscribe
     connection eventAnnouncerInternal
         when: GDBCommandEvent               send: #onCommandEvent:           to: self;
+        when: GDBCommandResultEvent         send: #onCommandResultEvent:     to: self;
         when: GDBExitEvent                  send: #onExitEvent:              to: self;
 
         when: GDBThreadGroupAddedEvent      send: #onThreadGroupAddedEvent:  to: self;
@@ -1009,7 +1063,7 @@
         when: GDBCmdParamChangedEvent       send: #onCmdParamChangedEvent:    to: self.
 
     "Created: / 20-06-2014 / 22:07:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 29-07-2018 / 22:18:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 19-01-2019 / 22:20:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 unsubscribe