GDBRegisterWithValue.st
changeset 144 342b6dfe3a6f
child 225 8bafbf291261
equal deleted inserted replaced
143:883c830472cb 144:342b6dfe3a6f
       
     1 "
       
     2 jv:libgdbs - GNU Debugger Interface Library
       
     3 Copyright (C) 2015-now Jan Vrany
       
     4 
       
     5 This library is free software; you can redistribute it and/or
       
     6 modify it under the terms of the GNU Lesser General Public
       
     7 License as published by the Free Software Foundation; either
       
     8 version 2.1 of the License. 
       
     9 
       
    10 This library is distributed in the hope that it will be useful,
       
    11 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13 Lesser General Public License for more details.
       
    14 
       
    15 You should have received a copy of the GNU Lesser General Public
       
    16 License along with this library; if not, write to the Free Software
       
    17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
       
    18 "
       
    19 "{ Package: 'jv:libgdbs' }"
       
    20 
       
    21 "{ NameSpace: Smalltalk }"
       
    22 
       
    23 GDBDebuggerObject subclass:#GDBRegisterWithValue
       
    24 	instanceVariableNames:'register frame value changed'
       
    25 	classVariableNames:''
       
    26 	poolDictionaries:''
       
    27 	category:'GDB-Core'
       
    28 !
       
    29 
       
    30 !GDBRegisterWithValue class methodsFor:'documentation'!
       
    31 
       
    32 copyright
       
    33 "
       
    34 jv:libgdbs - GNU Debugger Interface Library
       
    35 Copyright (C) 2015-now Jan Vrany
       
    36 
       
    37 This library is free software; you can redistribute it and/or
       
    38 modify it under the terms of the GNU Lesser General Public
       
    39 License as published by the Free Software Foundation; either
       
    40 version 2.1 of the License. 
       
    41 
       
    42 This library is distributed in the hope that it will be useful,
       
    43 but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    45 Lesser General Public License for more details.
       
    46 
       
    47 You should have received a copy of the GNU Lesser General Public
       
    48 License along with this library; if not, write to the Free Software
       
    49 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
       
    50 "
       
    51 ! !
       
    52 
       
    53 !GDBRegisterWithValue class methodsFor:'accessing-magritte'!
       
    54 
       
    55 descriptionContainer
       
    56     ^ super descriptionContainer
       
    57         define: #number as: Integer;
       
    58         define: #value as: String;
       
    59         yourself
       
    60 
       
    61     "Created: / 26-09-2018 / 10:38:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    62 ! !
       
    63 
       
    64 !GDBRegisterWithValue methodsFor:'accessing'!
       
    65 
       
    66 name
       
    67     ^  register name
       
    68 
       
    69     "Created: / 27-09-2018 / 10:06:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    70 !
       
    71 
       
    72 number
       
    73     ^ register isInteger ifTrue:[
       
    74         register
       
    75     ] ifFalse:[
       
    76         register number
       
    77     ]
       
    78 
       
    79     "Created: / 27-09-2018 / 09:56:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    80 !
       
    81 
       
    82 value
       
    83     changed value.
       
    84     ^ value
       
    85 
       
    86     "Modified: / 27-09-2018 / 15:26:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    87 ! !
       
    88 
       
    89 !GDBRegisterWithValue methodsFor:'initialization'!
       
    90 
       
    91 setDebugger: aGDBDebugger
       
    92     super setDebugger: aGDBDebugger.
       
    93     changed := GDBTransientDataHolder debugger: debugger factory: [
       
    94         (frame notNil and:[frame isValid]) ifTrue:[
       
    95             | changes change |
       
    96 
       
    97             changes := frame registersChanges.
       
    98             change := changes detect:[:each | each number = self number ] ifNone:[ nil ].
       
    99             (change notNil and:[change value ~= value]) ifTrue:[ 
       
   100                 value := change value.
       
   101                 true
       
   102             ] ifFalse:[ 
       
   103                 false
       
   104             ].
       
   105         ] ifFalse:[ 
       
   106             false
       
   107         ].
       
   108     ].
       
   109 
       
   110     "Created: / 27-09-2018 / 15:11:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   111 !
       
   112 
       
   113 setFrame: aGDBFrame
       
   114     self setDebugger: aGDBFrame debugger.
       
   115     frame := aGDBFrame.
       
   116 
       
   117     "Created: / 26-09-2018 / 22:25:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   118     "Modified: / 27-09-2018 / 15:31:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   119 !
       
   120 
       
   121 setRegisterFrom: aDictionary
       
   122     self assert: register isInteger.
       
   123     self assert: (aDictionary includesKey: register).
       
   124 
       
   125     register := aDictionary at: register.
       
   126 
       
   127     "Created: / 26-09-2018 / 10:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   128 ! !
       
   129 
       
   130 !GDBRegisterWithValue methodsFor:'printing & storing'!
       
   131 
       
   132 printOn:aStream
       
   133     "append a printed representation of the receiver to the argument, aStream"
       
   134 
       
   135     super printOn:aStream.
       
   136     aStream nextPut:$(.
       
   137     register isInteger ifTrue:[
       
   138         register printOn:aStream.
       
   139     ] ifFalse:[ 
       
   140         register name printOn:aStream.    
       
   141     ].
       
   142     aStream nextPutAll: ': '.
       
   143     value printOn: aStream.
       
   144     aStream nextPut:$).
       
   145 
       
   146     "Modified: / 26-09-2018 / 10:48:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   147 ! !
       
   148 
       
   149 !GDBRegisterWithValue methodsFor:'private'!
       
   150 
       
   151 _number: anInteger
       
   152     register := anInteger
       
   153 
       
   154     "Created: / 26-09-2018 / 10:39:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   155 ! !
       
   156 
       
   157 !GDBRegisterWithValue methodsFor:'queries'!
       
   158 
       
   159 hasChanged
       
   160     "Return true, if the value of this register has changed since last
       
   161      'stop', false otherwise (i.e., when unchanged)"
       
   162 
       
   163     ^ changed value
       
   164 
       
   165     "Created: / 27-09-2018 / 16:01:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
   166 ! !
       
   167 
       
   168 !GDBRegisterWithValue class methodsFor:'documentation'!
       
   169 
       
   170 version_HG
       
   171 
       
   172     ^ '$Changeset: <not expanded> $'
       
   173 ! !
       
   174