Tools__ObjectModuleInformation.st
changeset 2620 fccbd77a9409
parent 2619 09ab6a49e5ce
child 2623 6e7e1b2b961f
equal deleted inserted replaced
2619:09ab6a49e5ce 2620:fccbd77a9409
   467 
   467 
   468     ^ 
   468     ^ 
   469      #(Menu
   469      #(Menu
   470         (
   470         (
   471          (MenuItem
   471          (MenuItem
       
   472             label: 'Update'
       
   473             itemValue: menuUpdateModuleList
       
   474             translateLabel: true
       
   475             isButton: true
       
   476             labelImage: (ResourceRetriever ToolbarIconLibrary reloadIcon)
       
   477           )
       
   478          (MenuItem
       
   479             label: '-'
       
   480           )
       
   481          (MenuItem
   472             enabled: canBrowseSelectedModule
   482             enabled: canBrowseSelectedModule
   473             label: 'Browse the Selected Module''s Classes'
   483             label: 'Browse the Selected Module''s Classes'
   474             itemValue: browseModule
   484             itemValue: browseModule
   475             translateLabel: true
   485             translateLabel: true
   476             isButton: true
   486             isButton: true
   797     sel isNil ifTrue:[^ nil].
   807     sel isNil ifTrue:[^ nil].
   798     ^ objectHandles at:sel.
   808     ^ objectHandles at:sel.
   799 !
   809 !
   800 
   810 
   801 selectedModuleIndexChanged
   811 selectedModuleIndexChanged
   802     |module info |
   812     | info |
   803 
   813 
   804     info := self selectedModuleInfo.
   814     info := self selectedModuleInfo.
   805     module := self selectedModule.
       
   806 
   815 
   807     self canBrowseSelectedModule value:false.
   816     self canBrowseSelectedModule value:false.
   808     self canBrowseSelectedModulesExtensions value:false.
   817     self canBrowseSelectedModulesExtensions value:false.
   809     self canUnloadSelectedDLL value:false.
   818     self canUnloadSelectedDLL value:false.
   810     self canUnloadSelectedModule value:false.
   819     self canUnloadSelectedModule value:false.
   813     classNamesShown := nil.
   822     classNamesShown := nil.
   814     classInfoShown := nil.
   823     classInfoShown := nil.
   815     vmInfoShown := nil.
   824     vmInfoShown := nil.
   816 
   825 
   817     info isNil ifTrue:[
   826     info isNil ifTrue:[
   818         "/ selected a method, cObject or unknown
   827         "/ selected a cObject or unknown
   819         self showInfoForNonClassLib:(self selectedModuleIndex).
   828         self showInfoForNonClassLib:(self selectedModuleIndex).
   820         ^ self.
   829         ^ self.
   821     ].
   830     ].
   822     info == #VM ifTrue:[
   831     info == #VM ifTrue:[
   823         "/ selected the pseudo entry for the VM itself
   832         "/ selected the pseudo entry for the VM itself
   830 
   839 
   831     "Modified: / 05-10-2007 / 12:56:13 / cg"
   840     "Modified: / 05-10-2007 / 12:56:13 / cg"
   832 !
   841 !
   833 
   842 
   834 selectedModuleInfo
   843 selectedModuleInfo
   835     |sel info|
   844     |sel|
   836 
   845 
   837     sel := self selectedModuleIndex.
   846     sel := self selectedModuleIndex.
   838     sel notNil ifTrue:[
   847     sel notNil ifTrue:[
   839         (self showClassLibs value or:[self showBuiltIn value]) ifTrue:[
   848         (self showClassLibs value or:[self showBuiltIn value]) ifTrue:[
   840             info := allModules at:sel ifAbsent:nil.
   849             ^ allModules at:sel ifAbsent:nil.
   841         ].
   850         ].
   842     ].
   851     ].
   843     ^ info
   852     ^ nil
       
   853 !
       
   854 
       
   855 selectedObjectHandle
       
   856     |sel|
       
   857 
       
   858     sel := self selectedModuleIndex.
       
   859     sel isNil ifTrue:[^ nil].
       
   860     ^ objectHandles at:sel.
   844 !
   861 !
   845 
   862 
   846 showInfoForClassLib:info
   863 showInfoForClassLib:info
   847     " selected a lib-package; fill bottom list with class-info "
   864     " selected a lib-package; fill bottom list with class-info "
   848 
   865 
   876         "/ fallback - some heuristics...
   893         "/ fallback - some heuristics...
   877         libraryName := info libraryName.
   894         libraryName := info libraryName.
   878         (libraryName notNil and:[ libraryName startsWith:'lib' ]) ifTrue:[
   895         (libraryName notNil and:[ libraryName startsWith:'lib' ]) ifTrue:[
   879             defClassName := libraryName copyFrom:4
   896             defClassName := libraryName copyFrom:4
   880         ] ifFalse:[
   897         ] ifFalse:[
   881             self halt.
   898             "/ self halt.
   882         ].
   899         ].
   883     ].
   900     ].
   884     defClassName notNil ifTrue:[
   901     defClassName notNil ifTrue:[
   885         libraryDefinition := Smalltalk classNamed:defClassName.
   902         libraryDefinition := Smalltalk classNamed:defClassName.
   886     ].
   903     ].
  1118 ! !
  1135 ! !
  1119 
  1136 
  1120 !ObjectModuleInformation methodsFor:'menu actions'!
  1137 !ObjectModuleInformation methodsFor:'menu actions'!
  1121 
  1138 
  1122 browseClass
  1139 browseClass
  1123     |module info classNames selectedClassName selectedClass|
  1140     |info classNames selectedClassName selectedClass|
  1124 
  1141 
  1125     module := self selectedModule.
       
  1126     info := self selectedModuleInfo.
  1142     info := self selectedModuleInfo.
  1127     classNames := (self shownClassNamesFor:info) asSortedCollection.
  1143     classNames := (self shownClassNamesFor:info) asSortedCollection.
  1128     selectedClassName := classNames at:(self selectedInfoIndex).
  1144     selectedClassName := classNames at:(self selectedInfoIndex).
  1129     selectedClass := Smalltalk classNamed:selectedClassName.
  1145     selectedClass := Smalltalk classNamed:selectedClassName.
  1130 
  1146 
  1141 
  1157 
  1142     self breakPoint:#cg.
  1158     self breakPoint:#cg.
  1143 !
  1159 !
  1144 
  1160 
  1145 browseModule
  1161 browseModule
  1146     |module classes method|
  1162     |moduleInfoOrHandle classes method|
  1147 
  1163 
  1148     module := self selectedModule.
  1164     moduleInfoOrHandle := self selectedObjectHandle.
  1149     module isMethodHandle ifTrue:[
  1165     "/ what a hack
  1150         method := module method.
  1166     (moduleInfoOrHandle isKindOf: ObjectMemory::BinaryModuleDescriptor) ifTrue:[
  1151         (method notNil and:[method mclass notNil]) ifFalse:[
  1167         classes := moduleInfoOrHandle classNames collect:[:nm | Smalltalk classNamed:nm].
  1152             Dialog information:'The method has been redefined/removed'.
       
  1153             ^ self.
       
  1154         ].
       
  1155         UserPreferences systemBrowserClass 
       
  1156             openInMethod:method
       
  1157     ] ifFalse:[
       
  1158         classes := module classNames collect:[:nm | Smalltalk classNamed:nm].
       
  1159         UserPreferences systemBrowserClass 
  1168         UserPreferences systemBrowserClass 
  1160             browseClasses:classes
  1169             browseClasses:classes
  1161             label:(resources string:'Classes in %1' with:module libraryName)
  1170             label:(resources string:'Classes in %1' with:moduleInfoOrHandle libraryName)
  1162     ]
  1171     ] ifFalse:[
       
  1172         moduleInfoOrHandle isMethodHandle ifTrue:[
       
  1173             method := moduleInfoOrHandle method.
       
  1174             (method notNil and:[method mclass notNil]) ifFalse:[
       
  1175                 Dialog information:'The method has been redefined/removed'.
       
  1176                 ^ self.
       
  1177             ].
       
  1178             UserPreferences systemBrowserClass 
       
  1179                 openInMethod:method
       
  1180         ]
       
  1181     ].
  1163 !
  1182 !
  1164 
  1183 
  1165 browseModuleExtensions
  1184 browseModuleExtensions
  1166     |module name packageID methods|
  1185     |info name packageID methods|
  1167 
  1186 
  1168     module := self selectedModule.
  1187     info := self selectedModuleInfo.
  1169 
  1188 
  1170     name := module classNames detect:[:nm | self isExtensionName:nm].
  1189     name := info classNames detect:[:nm | self isExtensionName:nm].
  1171     packageID := (name copyWithoutLast:('_extensions' size)) asSymbol.
  1190     packageID := (name copyWithoutLast:('_extensions' size)) asSymbol.
  1172     methods := Smalltalk allExtensionsForPackage:packageID.
  1191     methods := Smalltalk allExtensionsForPackage:packageID.
  1173     (UserPreferences browserClass) browseMethods:methods title:('Extensions for ',packageID).
  1192     (UserPreferences browserClass) browseMethods:methods title:('Extensions for ',packageID).
  1174 !
  1193 !
  1175 
  1194 
  1205 
  1224 
  1206     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1225     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1207 !
  1226 !
  1208 
  1227 
  1209 selectedModulesProjectDefinitionClass
  1228 selectedModulesProjectDefinitionClass
  1210     |module info classNames classes definitionClasses|
  1229     | info classNames classes definitionClasses|
  1211 
  1230 
  1212     module := self selectedModule.
       
  1213     info := self selectedModuleInfo.
  1231     info := self selectedModuleInfo.
  1214     classNames := (self shownClassNamesFor:info) asSortedCollection.
  1232     classNames := (self shownClassNamesFor:info) asSortedCollection.
  1215     classes := classNames collect:[:nm | Smalltalk classNamed:nm].
  1233     classes := classNames collect:[:nm | Smalltalk classNamed:nm].
  1216     definitionClasses := classes select:[:cls | cls isProjectDefinition].
  1234     definitionClasses := classes select:[:cls | cls isProjectDefinition].
  1217     definitionClasses size == 1 ifTrue:[
  1235     definitionClasses size == 1 ifTrue:[
  1287     "Created: / 05-10-2007 / 12:43:36 / cg"
  1305     "Created: / 05-10-2007 / 12:43:36 / cg"
  1288 !
  1306 !
  1289 
  1307 
  1290 updateModuleList
  1308 updateModuleList
  1291     |showClassLibs showBuiltIn showMethods showCObjects showOthers
  1309     |showClassLibs showBuiltIn showMethods showCObjects showOthers
  1292      listOfModuleNames allObjects handles|
  1310      listOfModuleNames allObjects handles methodObjects |
  1293 
  1311 
  1294     showClassLibs := self showClassLibs value.
  1312     showClassLibs := self showClassLibs value.
  1295     showBuiltIn := self showBuiltIn value.
  1313     showBuiltIn := self showBuiltIn value.
  1296     showMethods := self showMethods value.
  1314     showMethods := self showMethods value.
  1297     showCObjects := self showCObjects value.
  1315     showCObjects := self showCObjects value.
  1299 
  1317 
  1300     listOfModuleNames := OrderedCollection new.
  1318     listOfModuleNames := OrderedCollection new.
  1301     handles := OrderedCollection new.
  1319     handles := OrderedCollection new.
  1302 
  1320 
  1303     allObjects := ObjectFileLoader loadedObjectHandles.
  1321     allObjects := ObjectFileLoader loadedObjectHandles.
       
  1322     methodObjects := (allObjects select:[:h | h isMethodHandle]) asArray.
  1304 
  1323 
  1305     (showClassLibs or:[showBuiltIn]) ifTrue:[
  1324     (showClassLibs or:[showBuiltIn]) ifTrue:[
  1306         |moduleNames|
  1325         |moduleNames|
  1307 
  1326 
  1308         allModules := ObjectMemory binaryModuleInfo asOrderedCollection.
  1327         allModules := ObjectMemory binaryModuleInfo asOrderedCollection.
  1309         (showBuiltIn and:[showClassLibs]) ifFalse:[
  1328         allModules := allModules select:
  1310             allModules := allModules select:
  1329                                     [:i |
  1311                                         [:i |
  1330                                         |wantToSee|
  1312                                             |wantToSee|
  1331 
  1313 
  1332                                         wantToSee := false.
  1314                                             wantToSee := i dynamic.
  1333                                         i dynamic ifTrue:[
       
  1334                                             showClassLibs ifTrue:[
       
  1335                                                 i isSingleMethod ifFalse:[
       
  1336                                                     wantToSee := true
       
  1337                                                 ].
       
  1338                                             ].
       
  1339                                         ] ifFalse:[
  1315                                             showBuiltIn ifTrue:[
  1340                                             showBuiltIn ifTrue:[
  1316                                                 wantToSee := wantToSee not
  1341                                                 wantToSee := true
  1317                                             ].
  1342                                             ].
  1318                                             wantToSee
  1343                                         ].
  1319                                         ]
  1344                                         wantToSee
  1320         ].
  1345                                     ].
  1321 
  1346 
  1322         "/ sorting by reverse id brings newest ones to the top (a side effect)
  1347         "/ sorting by reverse id brings newest ones to the top (a side effect)
  1323         allModules sort:[:a :b | (a id) > (b id)].
  1348         allModules sort:[:a :b | (a id) > (b id)].
  1324         moduleNames := allModules collect:[:entry | entry name].
  1349         moduleNames := allModules collect:[:entry | entry name].
  1325         listOfModuleNames addAll:moduleNames.
  1350         listOfModuleNames addAll:moduleNames.
  1326         handles addAll:allModules.
  1351         handles addAll:allModules.
  1327     ].
  1352     ].
  1328 
  1353 
  1329     showMethods ifTrue:[
  1354     showMethods ifTrue:[
  1330         |methodObjects methodNames|
  1355         |methodNames|
  1331 
  1356 
  1332         methodObjects := (allObjects select:[:h | h isMethodHandle]) asArray.
       
  1333         methodNames := methodObjects collect:[:mH | mH method isNil ifTrue:[
  1357         methodNames := methodObjects collect:[:mH | mH method isNil ifTrue:[
  1334                                                         'compiled method - removed' " , ' (in ' , mH pathName , ')' "
  1358                                                         'compiled method - removed' " , ' (in ' , mH pathName , ')' "
  1335                                                     ] ifFalse:[
  1359                                                     ] ifFalse:[
  1336                                                         'compiled method ' , mH method whoString  " , ' (in ' , mH pathName , ')' "
  1360                                                         'compiled method ' , mH method whoString  " , ' (in ' , mH pathName , ')' "
  1337                                                     ].
  1361                                                     ].