Tools__ObjectModuleInformation.st
changeset 2253 a282d11e1ec4
parent 2184 1ffb97ee0a55
child 2254 06ada9ab1a8a
equal deleted inserted replaced
2252:e2804df19f8c 2253:a282d11e1ec4
     3 "{ NameSpace: Tools }"
     3 "{ NameSpace: Tools }"
     4 
     4 
     5 ToolApplicationModel subclass:#ObjectModuleInformation
     5 ToolApplicationModel subclass:#ObjectModuleInformation
     6 	instanceVariableNames:'readOnly listOfModuleNames selectedModuleIndexHolder allModules
     6 	instanceVariableNames:'readOnly listOfModuleNames selectedModuleIndexHolder allModules
     7 		objectHandles showOthers showCObjects showBuiltIn showMethods
     7 		objectHandles showOthers showCObjects showBuiltIn showMethods
     8 		showClassLibs table1VisibleHolder table2VisibleHolder'
     8 		showClassLibs table1VisibleHolder table2VisibleHolder
       
     9 		selectedInfoIndexHolder canBrowseSelectedModule
       
    10 		canUnloadSelectedModule classNamesShown classInfoShown
       
    11 		vmInfoShown'
     9 	classVariableNames:''
    12 	classVariableNames:''
    10 	poolDictionaries:''
    13 	poolDictionaries:''
    11 	category:'Monitors-ST/X'
    14 	category:'Monitors-ST/X'
    12 !
    15 !
    13 
    16 
    24 "
    27 "
    25     Shows the modules (dll's) of ST/X.
    28     Shows the modules (dll's) of ST/X.
    26     Both builtIn modules, and dynamically loaded modules are listed.
    29     Both builtIn modules, and dynamically loaded modules are listed.
    27 
    30 
    28     [author:]
    31     [author:]
    29         cg
    32         Claus Gittinger
    30 "
    33 "
    31 !
    34 !
    32 
    35 
    33 examples
    36 examples
    34 "
    37 "
    92              (SpecCollection
    95              (SpecCollection
    93                 collection: (
    96                 collection: (
    94                  (SequenceViewSpec
    97                  (SequenceViewSpec
    95                     name: 'List1'
    98                     name: 'List1'
    96                     model: selectedModuleIndexHolder
    99                     model: selectedModuleIndexHolder
       
   100                     menu: moduleMenu
    97                     hasHorizontalScrollBar: true
   101                     hasHorizontalScrollBar: true
    98                     hasVerticalScrollBar: true
   102                     hasVerticalScrollBar: true
    99                     useIndex: true
   103                     useIndex: true
   100                     sequenceList: listOfModuleNames
   104                     sequenceList: listOfModuleNames
   101                   )
   105                   )
   114                        (DataSetSpec
   118                        (DataSetSpec
   115                           name: 'Table1'
   119                           name: 'Table1'
   116                           layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   120                           layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   117                           visibilityChannel: table1VisibleHolder
   121                           visibilityChannel: table1VisibleHolder
   118                           model: selectedInfoIndexHolder
   122                           model: selectedInfoIndexHolder
       
   123                           menu: moduleItemMenu
   119                           hasHorizontalScrollBar: true
   124                           hasHorizontalScrollBar: true
   120                           hasVerticalScrollBar: true
   125                           hasVerticalScrollBar: true
   121                           dataList: infoTable1ListHolder
   126                           dataList: infoTable1ListHolder
   122                           columnHolder: tableColumns
   127                           columnHolder: tableColumns
   123                           separatorOneDColor: (Color 66.999313344015 66.999313344015 66.999313344015)
   128                           separatorOneDColor: (Color 66.999313344015 66.999313344015 66.999313344015)
   229             label: 'Module'
   234             label: 'Module'
   230             translateLabel: true
   235             translateLabel: true
   231             submenu: 
   236             submenu: 
   232            (Menu
   237            (Menu
   233               (
   238               (
       
   239               (MenuItem
       
   240                  enabled: canBrowseSelectedModule
       
   241                  label: 'Browse'
       
   242                  itemValue: browseModule
       
   243                  translateLabel: true
       
   244                )
       
   245                (MenuItem   
       
   246                   enabled: canCopyClassNameList
       
   247                   label: 'Copy Version Info to Clipboard'
       
   248                   itemValue: copyClassOrVMNameList
       
   249                   translateLabel: true
       
   250                 )
   234                (MenuItem
   251                (MenuItem
   235                   enabled: notReadOnly
   252                   label: '-'
       
   253                 )
       
   254                (MenuItem
       
   255                   enabled: canUnloadSelectedModule
   236                   label: 'Unload'
   256                   label: 'Unload'
   237                   translateLabel: true
   257                   translateLabel: true
       
   258                  itemValue: unloadSelectedModule
   238                 )
   259                 )
       
   260                 (MenuItem
       
   261                    enabled: canUnloadSelectedModule
       
   262                    label: 'Remove Classes && Unload'
       
   263                    itemValue: unloadSelectedModuleAndRemoveClasses
       
   264                    translateLabel: true
       
   265                  )
   239                )
   266                )
   240               nil
   267               nil
   241               nil
   268               nil
   242             )
   269             )
   243           )
   270           )
   268           )
   295           )
   269          )
   296          )
   270         nil
   297         nil
   271         nil
   298         nil
   272       )
   299       )
       
   300 !
       
   301 
       
   302 moduleItemMenu
       
   303     "This resource specification was automatically generated
       
   304      by the MenuEditor of ST/X."
       
   305 
       
   306     "Do not manually edit this!! If it is corrupted,
       
   307      the MenuEditor may not be able to read the specification."
       
   308 
       
   309     "
       
   310      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#moduleItemMenu
       
   311      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation moduleItemMenu)) startUp
       
   312     "
       
   313 
       
   314     <resource: #menu>
       
   315 
       
   316     ^ 
       
   317      #(Menu
       
   318         (
       
   319          (MenuItem   
       
   320             enabled: canBrowseSelectedClass
       
   321             label: 'Browse'
       
   322             itemValue: browseClass
       
   323             translateLabel: true
       
   324           )
       
   325          (MenuItem   
       
   326             label: '-'
       
   327           )
       
   328          (MenuItem   
       
   329             enabled: canCopyClassNameList
       
   330             label: 'Copy Version Info to Clipboard'
       
   331             itemValue: copyClassOrVMNameList
       
   332             translateLabel: true
       
   333           )
       
   334          )
       
   335         nil
       
   336         nil
       
   337       )
       
   338 !
       
   339 
       
   340 moduleMenu
       
   341     "This resource specification was automatically generated
       
   342      by the MenuEditor of ST/X."
       
   343 
       
   344     "Do not manually edit this!! If it is corrupted,
       
   345      the MenuEditor may not be able to read the specification."
       
   346 
       
   347     "
       
   348      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#moduleMenu
       
   349      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation moduleMenu)) startUp
       
   350     "
       
   351 
       
   352     <resource: #menu>
       
   353 
       
   354     ^ 
       
   355      #(Menu
       
   356         (
       
   357          (MenuItem
       
   358             enabled: canBrowseSelectedModule
       
   359             label: 'Browse'
       
   360             itemValue: browseModule
       
   361             translateLabel: true
       
   362           )
       
   363          (MenuItem   
       
   364             enabled: canCopyClassNameList
       
   365             label: 'Copy Version Info to Clipboard'
       
   366             itemValue: copyClassOrVMNameList
       
   367             translateLabel: true
       
   368           )
       
   369          (MenuItem
       
   370             label: '-'
       
   371           )
       
   372          (MenuItem
       
   373             enabled: canUnloadSelectedModule
       
   374             label: 'Remove Classes && Unload'
       
   375             itemValue: unloadSelectedModuleAndRemoveClasses
       
   376             translateLabel: true
       
   377           )
       
   378          (MenuItem
       
   379             enabled: canUnloadSelectedModule
       
   380             label: 'Unload'
       
   381             itemValue: unloadSelectedModule
       
   382             translateLabel: true
       
   383           )
       
   384          )
       
   385         nil
       
   386         nil
       
   387       )
   273 ! !
   388 ! !
   274 
   389 
   275 !ObjectModuleInformation class methodsFor:'tableColumns specs'!
   390 !ObjectModuleInformation class methodsFor:'tableColumns specs'!
   276 
   391 
   277 tableColumns
   392 tableColumns
   347     
   462     
   348 ! !
   463 ! !
   349 
   464 
   350 !ObjectModuleInformation methodsFor:'aspects'!
   465 !ObjectModuleInformation methodsFor:'aspects'!
   351 
   466 
       
   467 canBrowseSelectedClass
       
   468     ^ [classNamesShown notEmptyOrNil
       
   469        and:[ self selectedInfoIndex notNil
       
   470        and:[ self selectedInfoIndex ~~ 0 ]]]
       
   471 
       
   472     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   473 !
       
   474 
       
   475 canBrowseSelectedModule
       
   476     canBrowseSelectedModule isNil ifTrue:[
       
   477         canBrowseSelectedModule := false asValue
       
   478     ].
       
   479     ^ canBrowseSelectedModule.
       
   480 
       
   481     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   482 !
       
   483 
       
   484 canCopyClassNameList
       
   485     ^ [table1VisibleHolder value 
       
   486     and:[classInfoShown notEmptyOrNil or:[vmInfoShown notEmptyOrNil] ]]
       
   487 
       
   488     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   489 !
       
   490 
       
   491 canUnloadSelectedModule
       
   492     canUnloadSelectedModule isNil ifTrue:[
       
   493         canUnloadSelectedModule := false asValue
       
   494     ].
       
   495     ^ canUnloadSelectedModule.
       
   496 
       
   497     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   498 !
       
   499 
   352 infoTable1ListHolder
   500 infoTable1ListHolder
   353     ^ builder valueAspectFor:#'infoTable1ListHolder' initialValue:#()
   501     ^ builder valueAspectFor:#'infoTable1ListHolder' initialValue:#()
   354 
   502 
   355     "Created: / 05-10-2007 / 12:48:06 / cg"
   503     "Created: / 05-10-2007 / 12:48:06 / cg"
   356 !
   504 !
   384 
   532 
   385 readOnly
   533 readOnly
   386     ^ readOnly ? false
   534     ^ readOnly ? false
   387 
   535 
   388     "Created: / 05-10-2007 / 13:05:51 / cg"
   536     "Created: / 05-10-2007 / 13:05:51 / cg"
       
   537 !
       
   538 
       
   539 readOnly:aBoolean
       
   540     readOnly := aBoolean
       
   541 
       
   542     "Created: / 05-10-2007 / 13:05:51 / cg"
       
   543 !
       
   544 
       
   545 selectedInfoIndex
       
   546     |sel|
       
   547 
       
   548     sel := self selectedInfoIndexHolder value.
       
   549     ^ sel
       
   550 !
       
   551 
       
   552 selectedInfoIndexHolder
       
   553     selectedInfoIndexHolder isNil ifTrue:[
       
   554         selectedInfoIndexHolder := ValueHolder new.
       
   555         selectedInfoIndexHolder onChangeSend:#selectedInfoIndexChanged to:self.
       
   556     ].
       
   557     ^ selectedInfoIndexHolder.
       
   558 
       
   559     "Modified: / 05-10-2007 / 10:51:39 / cg"
       
   560 !
       
   561 
       
   562 selectedModuleIndex
       
   563     |sel|
       
   564 
       
   565     sel := self selectedModuleIndexHolder value.
       
   566     ^ sel
   389 !
   567 !
   390 
   568 
   391 selectedModuleIndexHolder
   569 selectedModuleIndexHolder
   392     selectedModuleIndexHolder isNil ifTrue:[
   570     selectedModuleIndexHolder isNil ifTrue:[
   393         selectedModuleIndexHolder := ValueHolder new.
   571         selectedModuleIndexHolder := ValueHolder new.
   466     "Modified: / 05-10-2007 / 12:53:14 / cg"
   644     "Modified: / 05-10-2007 / 12:53:14 / cg"
   467 ! !
   645 ! !
   468 
   646 
   469 !ObjectModuleInformation methodsFor:'change & update'!
   647 !ObjectModuleInformation methodsFor:'change & update'!
   470 
   648 
       
   649 selectedInfoIndexChanged
       
   650 !
       
   651 
       
   652 selectedModule
       
   653     |sel|
       
   654 
       
   655     sel := self selectedModuleIndex.
       
   656     sel isNil ifTrue:[^ nil].
       
   657     ^ objectHandles at:sel.
       
   658 !
       
   659 
   471 selectedModuleIndexChanged
   660 selectedModuleIndexChanged
       
   661     |module info|
       
   662 
       
   663     info := self selectedModuleInfo.
       
   664     module := self selectedModule.
       
   665 
       
   666     self canBrowseSelectedModule value:(info notNil and:[info ~~ #VM and:[module notNil]]).
       
   667     self canUnloadSelectedModule value:(self readOnly not and:[info ~~ #VM and:[module notNil and:[module dynamic]]]).
       
   668 
       
   669     classNamesShown := nil.
       
   670     classInfoShown := nil.
       
   671     vmInfoShown := nil.
       
   672 
       
   673     info isNil ifTrue:[
       
   674         "/ selected a method, cObject or unknown
       
   675         self showInfoForNonClassLib:(self selectedModuleIndex).
       
   676         ^ self.
       
   677     ].
       
   678     info == #VM ifTrue:[
       
   679         "/ selected the pseudo entry for the VM itself
       
   680         self showInfoForVM.
       
   681         ^ self.
       
   682     ].
       
   683     "/ selected a class-library package
       
   684     self showInfoForClassLib:info.
       
   685 
       
   686     "Modified: / 05-10-2007 / 12:56:13 / cg"
       
   687 !
       
   688 
       
   689 selectedModuleInfo
   472     |sel info|
   690     |sel info|
   473 
   691 
   474     sel := self selectedModuleIndexHolder value.
   692     sel := self selectedModuleIndex.
   475     sel notNil ifTrue:[
   693     sel notNil ifTrue:[
   476         (self showClassLibs value or:[self showBuiltIn value]) ifTrue:[
   694         (self showClassLibs value or:[self showBuiltIn value]) ifTrue:[
   477             info := allModules at:sel ifAbsent:nil.
   695             info := allModules at:sel ifAbsent:nil.
   478         ].
   696         ].
   479     ].
   697     ].
   480 
   698     ^ info
   481     info isNil ifTrue:[
       
   482         "/ selected a method, cObject or unknown
       
   483         self showInfoForNonClassLib:sel.
       
   484         ^ self.
       
   485     ].
       
   486     info == #VM ifTrue:[
       
   487         "/ selected the pseudo entry for the VM itself
       
   488         self showInfoForVM.
       
   489         ^ self.
       
   490     ].
       
   491     "/ selected a class-library package
       
   492     self showInfoForClassLib:info.
       
   493 
       
   494     "Modified: / 05-10-2007 / 12:56:13 / cg"
       
   495 !
   699 !
   496 
   700 
   497 showInfoForClassLib:info
   701 showInfoForClassLib:info
   498     "/ selected a package; fill bottom list with class-info
   702     "/ selected a package; fill bottom list with class-info
   499 
   703 
   510                         true "a removed class"
   714                         true "a removed class"
   511                     ] ifFalse:[
   715                     ] ifFalse:[
   512                         cls isPrivate not
   716                         cls isPrivate not
   513                     ].
   717                     ].
   514                   ].
   718                   ].
       
   719 
       
   720     classNamesShown := classNames.
   515 
   721 
   516     rows := classNames collect:[:cName |
   722     rows := classNames collect:[:cName |
   517                     |cls entry rev listEntry revisionInfo|
   723                     |cls entry rev listEntry revisionInfo|
   518 
   724 
   519                     listEntry := InfoRow new.
   725                     listEntry := InfoRow new.
   548                         ].
   754                         ].
   549                     ].
   755                     ].
   550                     listEntry
   756                     listEntry
   551                   ].
   757                   ].
   552 
   758 
       
   759     classInfoShown := rows.
       
   760 
   553     self infoTable1ListHolder value:rows.
   761     self infoTable1ListHolder value:rows.
   554     self table1VisibleHolder value:true.
   762     self table1VisibleHolder value:true.
   555     self table2VisibleHolder value:false.
   763     self table2VisibleHolder value:false.
   556 
   764 
   557     "Modified: / 05-10-2007 / 13:03:56 / cg"
   765     "Modified: / 05-10-2007 / 13:03:56 / cg"
   559 
   767 
   560 showInfoForNonClassLib:sel
   768 showInfoForNonClassLib:sel
   561     "/ selected a method, cObject or unknown
   769     "/ selected a method, cObject or unknown
   562 
   770 
   563     |module fileName list entry|
   771     |module fileName list entry|
       
   772 
       
   773     sel isNil ifTrue:[
       
   774         self table1VisibleHolder value:false.
       
   775         self table2VisibleHolder value:false.
       
   776         ^ self.
       
   777     ].
   564 
   778 
   565     module := objectHandles at:sel.
   779     module := objectHandles at:sel.
   566     fileName := module pathName.
   780     fileName := module pathName.
   567 
   781 
   568     module isMethodHandle ifTrue:[
   782     module isMethodHandle ifTrue:[
   667                 listEntry date:date.
   881                 listEntry date:date.
   668             ].
   882             ].
   669         ].
   883         ].
   670         listEntry.
   884         listEntry.
   671     ].
   885     ].
       
   886 
       
   887     vmInfoShown := l.
   672     self infoTable1ListHolder value:l.
   888     self infoTable1ListHolder value:l.
   673     self table1VisibleHolder value:true.
   889     self table1VisibleHolder value:true.
   674     self table2VisibleHolder value:false.
   890     self table2VisibleHolder value:false.
   675 
   891 
   676 "/    readOnly ifFalse:[
   892 "/    readOnly ifFalse:[
   700     "Created: / 05-10-2007 / 10:50:27 / cg"
   916     "Created: / 05-10-2007 / 10:50:27 / cg"
   701 ! !
   917 ! !
   702 
   918 
   703 !ObjectModuleInformation methodsFor:'menu actions'!
   919 !ObjectModuleInformation methodsFor:'menu actions'!
   704 
   920 
       
   921 browseClass
       
   922     |module info classNames selectedClassName selectedClass|
       
   923 
       
   924     module := self selectedModule.
       
   925     info := self selectedModuleInfo.
       
   926     classNames := info classNames asSortedCollection.
       
   927     selectedClassName := classNames at:(self selectedInfoIndex).
       
   928     selectedClass := Smalltalk classNamed:selectedClassName.
       
   929 
       
   930     UserPreferences systemBrowserClass 
       
   931         openInClass:selectedClass
       
   932 !
       
   933 
       
   934 browseModule
       
   935     |module classes|
       
   936 
       
   937     module := self selectedModule.
       
   938     classes := module classNames collect:[:nm | Smalltalk classNamed:nm].
       
   939     UserPreferences systemBrowserClass 
       
   940         browseClasses:classes
       
   941         label:(resources string:'Classes in %1' with:module libraryName)
       
   942 !
       
   943 
       
   944 copyClassOrVMNameList
       
   945     |text|
       
   946 
       
   947     text := ((classInfoShown ? vmInfoShown)collect:[:eachRow | eachRow infoString]) asStringCollection asString.
       
   948     self window setClipboardText:text.
       
   949 !
       
   950 
   705 openDocumentation
   951 openDocumentation
   706     self openHTMLDocument: 'tools/misc/TOP.html#MODULEINFO'
   952     self openHTMLDocument: 'tools/misc/TOP.html#MODULEINFO'
   707 
   953 
   708     "Modified: / 05-10-2007 / 13:11:45 / cg"
   954     "Modified: / 05-10-2007 / 13:11:45 / cg"
       
   955 !
       
   956 
       
   957 unloadModule
       
   958     self unloadModuleRemoveClasses:false
       
   959 !
       
   960 
       
   961 unloadModuleAndRemoveClasses
       
   962     self unloadModuleRemoveClasses:true
       
   963 !
       
   964 
       
   965 unloadModuleRemoveClasses:doRemoveClasses
       
   966     self withWaitCursorDo:[
       
   967         |info idx handle pathName|
       
   968 
       
   969         info := self selectedModuleInfo.
       
   970         self selectedModuleIndexHolder value:nil.
       
   971         handle := objectHandles at:(self selectedModuleIndex).
       
   972 
       
   973         info isNil ifTrue:[
       
   974             "/ selected a method
       
   975             "/ idx := idx - allModules size.
       
   976             pathName := handle pathName.
       
   977         ] ifFalse:[
       
   978             "/ selected a package
       
   979             pathName := info pathName.
       
   980         ].
       
   981         pathName notNil ifTrue:[
       
   982             doRemoveClasses ifTrue:[
       
   983                 ObjectFileLoader unloadObjectFileAndRemoveClasses:pathName.
       
   984             ] ifFalse:[
       
   985                 ObjectFileLoader unloadObjectFile:pathName.
       
   986             ]
       
   987         ].
       
   988         self updateModuleList.
       
   989     ]
   709 ! !
   990 ! !
   710 
   991 
   711 !ObjectModuleInformation methodsFor:'private'!
   992 !ObjectModuleInformation methodsFor:'private'!
   712 
   993 
   713 filterChanged
   994 filterChanged
   839 
  1120 
   840 version:something
  1121 version:something
   841     version := something.
  1122     version := something.
   842 ! !
  1123 ! !
   843 
  1124 
       
  1125 !ObjectModuleInformation::InfoRow methodsFor:'info'!
       
  1126 
       
  1127 infoString
       
  1128     ^ name , ' ', (version ? '-') , ' ', (date ? '-') printString
       
  1129 ! !
       
  1130 
   844 !ObjectModuleInformation class methodsFor:'documentation'!
  1131 !ObjectModuleInformation class methodsFor:'documentation'!
   845 
  1132 
   846 version
  1133 version
   847     ^ '$Header$'
  1134     ^ '$Header$'
   848 ! !
  1135 ! !