Tools__ObjectModuleInformation.st
changeset 2619 09ab6a49e5ce
parent 2618 441ede629ea8
child 2620 fccbd77a9409
equal deleted inserted replaced
2618:441ede629ea8 2619:09ab6a49e5ce
     7 		objectHandles showOthers showCObjects showBuiltIn showMethods
     7 		objectHandles showOthers showCObjects showBuiltIn showMethods
     8 		showClassLibs table1VisibleHolder table2VisibleHolder
     8 		showClassLibs table1VisibleHolder table2VisibleHolder
     9 		selectedInfoIndexHolder canBrowseSelectedModule
     9 		selectedInfoIndexHolder canBrowseSelectedModule
    10 		canUnloadSelectedModule classNamesShown classInfoShown
    10 		canUnloadSelectedModule classNamesShown classInfoShown
    11 		vmInfoShown canUnloadSelectedModulesPackage
    11 		vmInfoShown canUnloadSelectedModulesPackage
    12 		canBrowseSelectedModulesExtensions'
    12 		canBrowseSelectedModulesExtensions canUnloadSelectedDLL'
    13 	classVariableNames:''
    13 	classVariableNames:''
    14 	poolDictionaries:''
    14 	poolDictionaries:''
    15 	category:'Monitors-ST/X'
    15 	category:'Monitors-ST/X'
    16 !
    16 !
    17 
    17 
   195             translateLabel: true
   195             translateLabel: true
   196             submenu: 
   196             submenu: 
   197            (Menu
   197            (Menu
   198               (
   198               (
   199                (MenuItem
   199                (MenuItem
       
   200                   label: 'Dynamically Loaded ClassLibraries Only'
       
   201                   translateLabel: true
       
   202                   hideMenuOnActivated: false
       
   203                   itemValue: showOnlyDynamicallyLoadedClassLibraries
       
   204                 )
       
   205                (MenuItem
       
   206                   label: '-'
       
   207                 )
       
   208                (MenuItem
   200                   label: 'Builtin'
   209                   label: 'Builtin'
   201                   translateLabel: true
   210                   translateLabel: true
   202                   hideMenuOnActivated: false
   211                   hideMenuOnActivated: false
   203                   indication: showBuiltIn
   212                   indication: showBuiltIn
   204                 )
   213                 )
   250                   label: 'Browse'
   259                   label: 'Browse'
   251                   itemValue: browseModule
   260                   itemValue: browseModule
   252                   translateLabel: true
   261                   translateLabel: true
   253                 )
   262                 )
   254                (MenuItem
   263                (MenuItem
       
   264                   enabled: canBrowseSelectedModulesExtensions
       
   265                   label: 'Browse Extensions'
       
   266                   itemValue: browseModuleExtensions
       
   267                   translateLabel: true
       
   268                 )
       
   269                (MenuItem
       
   270                   label: '-'
       
   271                 )
       
   272                (MenuItem
   255                   enabled: canCopyClassNameList
   273                   enabled: canCopyClassNameList
   256                   label: 'Copy Version Info to Clipboard'
   274                   label: 'Copy Version Info to Clipboard'
   257                   itemValue: copyClassOrVMNameList
   275                   itemValue: copyClassOrVMNameList
   258                   translateLabel: true
   276                   translateLabel: true
   259                 )
   277                 )
   260                (MenuItem
   278                (MenuItem
   261                   label: '-'
   279                   label: '-'
   262                 )
   280                 )
   263                (MenuItem
   281                (MenuItem
       
   282                   label: 'Load Package...'
       
   283                   itemValue: loadPackage
       
   284                   translateLabel: true
       
   285                 )
       
   286                (MenuItem
       
   287                   label: '-'
       
   288                 )
       
   289                (MenuItem
   264                   enabled: canUnloadSelectedModulesPackage
   290                   enabled: canUnloadSelectedModulesPackage
   265                   label: 'Unload Package'
   291                   label: 'Unload Package...'
   266                   itemValue: unloadSelectedModulesPackage
   292                   itemValue: unloadSelectedModulesPackage
   267                   translateLabel: true
   293                   translateLabel: true
   268                 )
   294                 )
   269                (MenuItem
   295                (MenuItem
       
   296                   enabled: canUnloadSelectedDLL
       
   297                   label: 'Remove Classes && Unload DLL...'
       
   298                   itemValue: unloadSelectedModuleAndRemoveClasses
       
   299                   translateLabel: true
       
   300                 )
       
   301                (MenuItem
   270                   enabled: canUnloadSelectedModule
   302                   enabled: canUnloadSelectedModule
   271                   label: 'Remove Classes && Unload DLL'
   303                   label: 'Unload DLL...'
   272                   itemValue: unloadSelectedModuleAndRemoveClasses
       
   273                   translateLabel: true
       
   274                 )
       
   275                (MenuItem
       
   276                   enabled: canUnloadSelectedModule
       
   277                   label: 'Unload DLL'
       
   278                   itemValue: unloadSelectedModule
   304                   itemValue: unloadSelectedModule
   279                   translateLabel: true
   305                   translateLabel: true
   280                 )
   306                 )
   281                )
   307                )
   282               nil
   308               nil
   379             enabled: canBrowseSelectedModulesExtensions
   405             enabled: canBrowseSelectedModulesExtensions
   380             label: 'Browse Extensions'
   406             label: 'Browse Extensions'
   381             itemValue: browseModuleExtensions
   407             itemValue: browseModuleExtensions
   382             translateLabel: true
   408             translateLabel: true
   383           )
   409           )
   384          (MenuItem   
   410          (MenuItem
       
   411             label: '-'
       
   412           )
       
   413          (MenuItem
   385             enabled: canCopyClassNameList
   414             enabled: canCopyClassNameList
   386             label: 'Copy Version Info to Clipboard'
   415             label: 'Copy Version Info to Clipboard'
   387             itemValue: copyClassOrVMNameList
   416             itemValue: copyClassOrVMNameList
   388             translateLabel: true
   417             translateLabel: true
   389           )
   418           )
   390          (MenuItem
   419          (MenuItem
   391             label: '-'
   420             label: '-'
   392           )
   421           )
   393          (MenuItem
   422          (MenuItem
   394             enabled: canUnloadSelectedModulesPackage
   423             enabled: canUnloadSelectedModulesPackage
   395             label: 'Unload Package'
   424             label: 'Unload Package...'
   396             itemValue: unloadSelectedModulesPackage
   425             itemValue: unloadSelectedModulesPackage
   397             translateLabel: true
   426             translateLabel: true
   398           )
   427           )
   399          (MenuItem
   428          (MenuItem
   400             enabled: canUnloadSelectedModule
   429             enabled: canUnloadSelectedModule
   401             label: 'Remove Classes && Unload DLL'
   430             label: 'Remove Classes && Unload DLL...'
   402             itemValue: unloadSelectedModuleAndRemoveClasses
   431             itemValue: unloadSelectedModuleAndRemoveClasses
   403             translateLabel: true
   432             translateLabel: true
   404           )
   433           )
   405          (MenuItem
   434          (MenuItem
   406             enabled: canUnloadSelectedModule
   435             enabled: canUnloadSelectedDLL
   407             label: 'Unload DLL'
   436             label: 'Unload DLL...'
   408             itemValue: unloadSelectedModule
   437             itemValue: unloadSelectedModule
       
   438             translateLabel: true
       
   439           )
       
   440          (MenuItem
       
   441             label: '-'
       
   442           )
       
   443          (MenuItem
       
   444             label: 'Update'
       
   445             itemValue: menuUpdateModuleList
   409             translateLabel: true
   446             translateLabel: true
   410           )
   447           )
   411          )
   448          )
   412         nil
   449         nil
   413         nil
   450         nil
   561     and:[classInfoShown notEmptyOrNil or:[vmInfoShown notEmptyOrNil] ]]
   598     and:[classInfoShown notEmptyOrNil or:[vmInfoShown notEmptyOrNil] ]]
   562 
   599 
   563     "Modified: / 05-10-2007 / 10:51:39 / cg"
   600     "Modified: / 05-10-2007 / 10:51:39 / cg"
   564 !
   601 !
   565 
   602 
       
   603 canUnloadSelectedDLL
       
   604     canUnloadSelectedDLL isNil ifTrue:[
       
   605         canUnloadSelectedDLL := false asValue
       
   606     ].
       
   607     ^ canUnloadSelectedDLL.
       
   608 
       
   609     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   610 !
       
   611 
   566 canUnloadSelectedModule
   612 canUnloadSelectedModule
   567     canUnloadSelectedModule isNil ifTrue:[
   613     canUnloadSelectedModule isNil ifTrue:[
   568         canUnloadSelectedModule := false asValue
   614         canUnloadSelectedModule := false asValue
   569     ].
   615     ].
   570     ^ canUnloadSelectedModule.
   616     ^ canUnloadSelectedModule.
   696     ^ showMethods
   742     ^ showMethods
   697 
   743 
   698     "Modified: / 05-10-2007 / 12:43:02 / cg"
   744     "Modified: / 05-10-2007 / 12:43:02 / cg"
   699 !
   745 !
   700 
   746 
       
   747 showOnlyDynamicallyLoadedClassLibraries
       
   748     self showBuiltIn value:false withoutNotifying:self.
       
   749     self showCObjects value:false withoutNotifying:self.
       
   750     self showMethods value:false withoutNotifying:self.
       
   751     self showOthers value:false withoutNotifying:self.
       
   752     self showClassLibs value:true withoutNotifying:self.
       
   753     self filterChanged.
       
   754 !
       
   755 
   701 showOthers
   756 showOthers
   702     showOthers isNil ifTrue:[
   757     showOthers isNil ifTrue:[
   703         showOthers := true asValue.
   758         showOthers := true asValue.
   704         showOthers onChangeSend:#filterChanged to:self.
   759         showOthers onChangeSend:#filterChanged to:self.
   705     ].
   760     ].
   742     sel isNil ifTrue:[^ nil].
   797     sel isNil ifTrue:[^ nil].
   743     ^ objectHandles at:sel.
   798     ^ objectHandles at:sel.
   744 !
   799 !
   745 
   800 
   746 selectedModuleIndexChanged
   801 selectedModuleIndexChanged
   747     |module info canBrowse canUnload canBrowseExtensions|
   802     |module info |
   748 
   803 
   749     info := self selectedModuleInfo.
   804     info := self selectedModuleInfo.
   750     module := self selectedModule.
   805     module := self selectedModule.
   751 
   806 
   752     canBrowse := info notNil and:[info ~~ #VM and:[module notNil]].
   807     self canBrowseSelectedModule value:false.
   753     canUnload := info notNil and:[info ~~ #VM and:[info dynamic and:[self readOnly not]]].
   808     self canBrowseSelectedModulesExtensions value:false.
   754     canBrowseExtensions := canBrowse 
   809     self canUnloadSelectedDLL value:false.
   755                            and:[ info classNames contains:[:nm | self isExtensionName:nm] ].
   810     self canUnloadSelectedModule value:false.
   756 
   811     self canUnloadSelectedModulesPackage value:false.
   757     self canBrowseSelectedModule value:canBrowse.
       
   758     self canBrowseSelectedModulesExtensions value:canBrowseExtensions.
       
   759     self canUnloadSelectedModule value:canUnload.
       
   760 
   812 
   761     classNamesShown := nil.
   813     classNamesShown := nil.
   762     classInfoShown := nil.
   814     classInfoShown := nil.
   763     vmInfoShown := nil.
   815     vmInfoShown := nil.
   764 
   816 
   792 !
   844 !
   793 
   845 
   794 showInfoForClassLib:info
   846 showInfoForClassLib:info
   795     " selected a lib-package; fill bottom list with class-info "
   847     " selected a lib-package; fill bottom list with class-info "
   796 
   848 
   797     |rows libraryName defClassName libraryDefinition mgr defClassNames|
   849     |rows libraryName defClassName libraryDefinition mgr defClassNames 
       
   850      canUnload canUnloadPackage|
       
   851 
       
   852     self canBrowseSelectedModule value:true.
       
   853 
       
   854     self canBrowseSelectedModulesExtensions 
       
   855         value:(info classNames contains:[:nm | self isExtensionName:nm]).
       
   856 
       
   857     canUnload := info dynamic and:[self readOnly not].
       
   858     self canUnloadSelectedModule value:canUnload.
       
   859     canUnloadPackage := canUnload and:[ self selectedModulesProjectDefinitionClass notNil ].
       
   860     self canUnloadSelectedModulesPackage value:canUnloadPackage.
   798 
   861 
   799     self middleLabelHolder value:'Contains Components:'.
   862     self middleLabelHolder value:'Contains Components:'.
   800 
   863 
   801     "/ try to figure out, what the definitionClass is inside that module.
   864     "/ try to figure out, what the definitionClass is inside that module.
   802     "/ in the future, we should always find one there, however, old libs or
   865     "/ in the future, we should always find one there, however, old libs or
   894     fileName := module pathName.
   957     fileName := module pathName.
   895 
   958 
   896     module isMethodHandle ifTrue:[
   959     module isMethodHandle ifTrue:[
   897         |method nm entry1 entry2 entry3|
   960         |method nm entry1 entry2 entry3|
   898 
   961 
       
   962         self canUnloadSelectedDLL value:true.
       
   963 
   899         self middleLabelHolder value:'Compiled Method:'.
   964         self middleLabelHolder value:'Compiled Method:'.
   900 
   965 
   901         (method := module method) isNil ifTrue:[
   966         (method := module method) isNil ifTrue:[
   902             nm := '** removed **'.
   967             nm := '** removed **'.
   903         ] ifFalse:[
   968         ] ifFalse:[
       
   969             self canBrowseSelectedModule value:true.
   904 "/            menu := PopUpMenu
   970 "/            menu := PopUpMenu
   905 "/                        labels:#('Inspect' 'Browse')
   971 "/                        labels:#('Inspect' 'Browse')
   906 "/                        selectors:#(inspect browse).
   972 "/                        selectors:#(inspect browse).
   907 "/            menu actionAt:#inspect put:[ method inspect ].
   973 "/            menu actionAt:#inspect put:[ method inspect ].
   908 "/            menu actionAt:#browse put:[ |who|
   974 "/            menu actionAt:#browse put:[ |who|
   965 showInfoForVM
  1031 showInfoForVM
   966     " show file versions of vm info in lower view. "
  1032     " show file versions of vm info in lower view. "
   967 
  1033 
   968     |l|
  1034     |l|
   969 
  1035 
       
  1036     self canBrowseSelectedModule value:false.
       
  1037 
   970     self middleLabelHolder value:'Contains Components:'.
  1038     self middleLabelHolder value:'Contains Components:'.
   971 
  1039 
   972     l := (ObjectMemory getVMIdentificationStrings).
  1040     l := (ObjectMemory getVMIdentificationStrings).
   973     l := l select:[:entry | entry includesString:'$Header'].
  1041     l := l select:[:entry | entry includesString:'$Header'].
   974     l := l select:[:entry | entry includesString:',v'].
  1042     l := l select:[:entry | entry includesString:',v'].
  1073 
  1141 
  1074     self breakPoint:#cg.
  1142     self breakPoint:#cg.
  1075 !
  1143 !
  1076 
  1144 
  1077 browseModule
  1145 browseModule
  1078     |module classes|
  1146     |module classes method|
  1079 
  1147 
  1080     module := self selectedModule.
  1148     module := self selectedModule.
  1081     classes := module classNames collect:[:nm | Smalltalk classNamed:nm].
  1149     module isMethodHandle ifTrue:[
  1082     UserPreferences systemBrowserClass 
  1150         method := module method.
  1083         browseClasses:classes
  1151         (method notNil and:[method mclass notNil]) ifFalse:[
  1084         label:(resources string:'Classes in %1' with:module libraryName)
  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 
       
  1160             browseClasses:classes
       
  1161             label:(resources string:'Classes in %1' with:module libraryName)
       
  1162     ]
  1085 !
  1163 !
  1086 
  1164 
  1087 browseModuleExtensions
  1165 browseModuleExtensions
  1088     |module name packageID methods|
  1166     |module name packageID methods|
  1089 
  1167 
  1100 
  1178 
  1101     text := ((classInfoShown ? vmInfoShown)collect:[:eachRow | eachRow infoString]) asStringCollection asString.
  1179     text := ((classInfoShown ? vmInfoShown)collect:[:eachRow | eachRow infoString]) asStringCollection asString.
  1102     self window setClipboardText:text.
  1180     self window setClipboardText:text.
  1103 !
  1181 !
  1104 
  1182 
       
  1183 loadPackage
       
  1184     |package ok|
       
  1185 
       
  1186     package := Dialog request:'Name of Package (module:directory)'.
       
  1187     package isEmptyOrNil ifTrue:[^ self].
       
  1188     self withWaitCursorDo:[
       
  1189         ok := Smalltalk loadPackage:package.
       
  1190     ].
       
  1191     ok ifFalse:[
       
  1192         Dialog information:'Package not loaded'
       
  1193     ].
       
  1194     self updateModuleList
       
  1195 !
       
  1196 
  1105 menuUpdateModuleList
  1197 menuUpdateModuleList
  1106     self updateModuleList
  1198     self updateModuleList
  1107 
  1199 
  1108     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1200     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1109 !
  1201 !
  1110 
  1202 
  1111 openDocumentation
  1203 openDocumentation
  1112     self openHTMLDocument: 'tools/misc/TOP.html#MODULEINFO'
  1204     self openHTMLDocument: 'tools/misc/TOP.html#MODULEINFO'
  1113 
  1205 
  1114     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1206     "Modified: / 05-10-2007 / 13:11:45 / cg"
       
  1207 !
       
  1208 
       
  1209 selectedModulesProjectDefinitionClass
       
  1210     |module info classNames classes definitionClasses|
       
  1211 
       
  1212     module := self selectedModule.
       
  1213     info := self selectedModuleInfo.
       
  1214     classNames := (self shownClassNamesFor:info) asSortedCollection.
       
  1215     classes := classNames collect:[:nm | Smalltalk classNamed:nm].
       
  1216     definitionClasses := classes select:[:cls | cls isProjectDefinition].
       
  1217     definitionClasses size == 1 ifTrue:[
       
  1218         ^ definitionClasses first
       
  1219     ].
       
  1220     ^ nil
  1115 !
  1221 !
  1116 
  1222 
  1117 unloadSelectedModule
  1223 unloadSelectedModule
  1118     self unloadSelectedModuleRemoveClasses:false
  1224     self unloadSelectedModuleRemoveClasses:false
  1119 !
  1225 !
  1123 !
  1229 !
  1124 
  1230 
  1125 unloadSelectedModuleRemoveClasses:doRemoveClasses
  1231 unloadSelectedModuleRemoveClasses:doRemoveClasses
  1126     (Dialog 
  1232     (Dialog 
  1127         confirm:'This is a possibly dangerous operation, as the DLL is unloaded without caring for 
  1233         confirm:'This is a possibly dangerous operation, as the DLL is unloaded without caring for 
  1128 proper package-deinstallation procedures. Please only use this in repair situations and when the 
  1234 proper package-deinstallation procedures. Please use this only in repair situations and when the 
  1129 regular unloadPackage operation fails.
  1235 regular unloadPackage operation fails.
  1130 
  1236 
  1131 Continue ?')
  1237 Continue ?')
  1132     ifFalse:[
  1238     ifFalse:[
  1133         ^ self  
  1239         ^ self  
  1155                 ObjectFileLoader unloadObjectFile:pathName.
  1261                 ObjectFileLoader unloadObjectFile:pathName.
  1156             ]
  1262             ]
  1157         ].
  1263         ].
  1158         self updateModuleList.
  1264         self updateModuleList.
  1159     ]
  1265     ]
       
  1266 !
       
  1267 
       
  1268 unloadSelectedModulesPackage
       
  1269     |definitionClass|
       
  1270 
       
  1271     definitionClass := self selectedModulesProjectDefinitionClass.
       
  1272     definitionClass isNil ifTrue:[^ self].
       
  1273 
       
  1274     (Dialog 
       
  1275         confirm:(resources stringWithCRs:'About to unload the package\\    %1\\Continue' with:definitionClass package allBold))
       
  1276     ifFalse:[
       
  1277         ^ self
       
  1278     ].
       
  1279     Smalltalk unloadPackage:definitionClass package.
  1160 ! !
  1280 ! !
  1161 
  1281 
  1162 !ObjectModuleInformation methodsFor:'private'!
  1282 !ObjectModuleInformation methodsFor:'private'!
  1163 
  1283 
  1164 filterChanged
  1284 filterChanged
  1246         allModules addFirst:#VM.
  1366         allModules addFirst:#VM.
  1247     ].
  1367     ].
  1248 
  1368 
  1249     self listOfModuleNames contents:listOfModuleNames.
  1369     self listOfModuleNames contents:listOfModuleNames.
  1250     objectHandles := handles.
  1370     objectHandles := handles.
       
  1371     self selectedModuleIndexChanged.
  1251 
  1372 
  1252     "Modified: / 05-10-2007 / 12:45:37 / cg"
  1373     "Modified: / 05-10-2007 / 12:45:37 / cg"
  1253 ! !
  1374 ! !
  1254 
  1375 
  1255 !ObjectModuleInformation::InfoRow methodsFor:'accessing'!
  1376 !ObjectModuleInformation::InfoRow methodsFor:'accessing'!