Tools__ObjectModuleInformation.st
author Claus Gittinger <cg@exept.de>
Mon, 12 Oct 2009 19:27:33 +0200
changeset 2616 01e597429c47
parent 2403 11c5c82a852c
child 2617 060a35c37056
permissions -rw-r--r--
preps for package unloading
     1 "{ Package: 'stx:libtool2' }"
     2 
     3 "{ NameSpace: Tools }"
     4 
     5 ToolApplicationModel subclass:#ObjectModuleInformation
     6 	instanceVariableNames:'readOnly listOfModuleNames selectedModuleIndexHolder allModules
     7 		objectHandles showOthers showCObjects showBuiltIn showMethods
     8 		showClassLibs table1VisibleHolder table2VisibleHolder
     9 		selectedInfoIndexHolder canBrowseSelectedModule
    10 		canUnloadSelectedModule classNamesShown classInfoShown
    11 		vmInfoShown canUnloadSelectedModulesPackage'
    12 	classVariableNames:''
    13 	poolDictionaries:''
    14 	category:'Monitors-ST/X'
    15 !
    16 
    17 Object subclass:#InfoRow
    18 	instanceVariableNames:'name version date value'
    19 	classVariableNames:''
    20 	poolDictionaries:''
    21 	privateIn:ObjectModuleInformation
    22 !
    23 
    24 !ObjectModuleInformation class methodsFor:'documentation'!
    25 
    26 documentation
    27 "
    28     Shows the modules (dll's) of ST/X.
    29     Both builtIn modules, and dynamically loaded modules are listed.
    30 
    31     [author:]
    32         Claus Gittinger
    33 "
    34 !
    35 
    36 examples
    37 "
    38   Starting the application:
    39                                                                 [exBegin]
    40     ObjectModuleInformation open
    41 
    42                                                                 [exEnd]
    43 "
    44 ! !
    45 
    46 !ObjectModuleInformation class methodsFor:'info'!
    47 
    48 defaultLabel
    49     ^ 'Object Module Info'
    50 
    51     "Created: / 05-10-2007 / 11:56:59 / cg"
    52 ! !
    53 
    54 !ObjectModuleInformation class methodsFor:'interface specs'!
    55 
    56 windowSpec
    57     "This resource specification was automatically generated
    58      by the UIPainter of ST/X."
    59 
    60     "Do not manually edit this!! If it is corrupted,
    61      the UIPainter may not be able to read the specification."
    62 
    63     "
    64      UIPainter new openOnClass:Tools::ObjectModuleInformation andSelector:#windowSpec
    65      Tools::ObjectModuleInformation new openInterface:#windowSpec
    66      Tools::ObjectModuleInformation open
    67     "
    68 
    69     <resource: #canvas>
    70 
    71     ^ 
    72      #(FullSpec
    73         name: windowSpec
    74         window: 
    75        (WindowSpec
    76           label: 'ST/X Module & Version Information'
    77           name: 'ST/X Module & Version Information'
    78           min: (Point 0 0)
    79           bounds: (Rectangle 0 0 505 567)
    80           menu: mainMenu
    81         )
    82         component: 
    83        (SpecCollection
    84           collection: (
    85            (MenuPanelSpec
    86               name: 'ToolBar1'
    87               layout: (LayoutFrame 0 0 0 0 0 1 40 0)
    88               menu: toolbarMenu
    89               textDefault: true
    90             )
    91            (VariableVerticalPanelSpec
    92               name: 'VariableVerticalPanel1'
    93               layout: (LayoutFrame 0 0 40 0 0 1 0 1)
    94               component: 
    95              (SpecCollection
    96                 collection: (
    97                  (SequenceViewSpec
    98                     name: 'List1'
    99                     model: selectedModuleIndexHolder
   100                     menu: moduleMenu
   101                     hasHorizontalScrollBar: true
   102                     hasVerticalScrollBar: true
   103                     useIndex: true
   104                     sequenceList: listOfModuleNames
   105                   )
   106                  (ViewSpec
   107                     name: 'Box1'
   108                     component: 
   109                    (SpecCollection
   110                       collection: (
   111                        (LabelSpec
   112                           name: 'Label1'
   113                           layout: (LayoutFrame 0 0 0 0 0 1 30 0)
   114                           translateLabel: true
   115                           labelChannel: middleLabelHolder
   116                           adjust: left
   117                         )
   118                        (DataSetSpec
   119                           name: 'Table1'
   120                           layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   121                           visibilityChannel: table1VisibleHolder
   122                           model: selectedInfoIndexHolder
   123                           menu: moduleItemMenu
   124                           hasHorizontalScrollBar: true
   125                           hasVerticalScrollBar: true
   126                           dataList: infoTable1ListHolder
   127                           columnHolder: tableColumns
   128                           separatorOneDColor: (Color 66.999313344015 66.999313344015 66.999313344015)
   129                         )
   130                        (DataSetSpec
   131                           name: 'Table2'
   132                           layout: (LayoutFrame 0 0 30 0 0 1 0 1)
   133                           initiallyInvisible: true
   134                           visibilityChannel: table2VisibleHolder
   135                           model: selectedInfoIndexHolder
   136                           hasHorizontalScrollBar: true
   137                           hasVerticalScrollBar: true
   138                           dataList: infoTable2ListHolder
   139                           columnHolder: tableColumnsForSingleInfo
   140                           separatorOneDColor: (Color 66.999313344015 66.999313344015 66.999313344015)
   141                         )
   142                        )
   143                      
   144                     )
   145                   )
   146                  )
   147                
   148               )
   149               handles: (Any 0.35195530726257 1.0)
   150             )
   151            )
   152          
   153         )
   154       )
   155 ! !
   156 
   157 !ObjectModuleInformation class methodsFor:'menu specs'!
   158 
   159 mainMenu
   160     "This resource specification was automatically generated
   161      by the MenuEditor of ST/X."
   162 
   163     "Do not manually edit this!! If it is corrupted,
   164      the MenuEditor may not be able to read the specification."
   165 
   166     "
   167      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#mainMenu
   168      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation mainMenu)) startUp
   169     "
   170 
   171     <resource: #menu>
   172 
   173     ^ 
   174      #(Menu
   175         (
   176          (MenuItem
   177             label: 'File'
   178             translateLabel: true
   179             submenu: 
   180            (Menu
   181               (
   182                (MenuItem
   183                   label: 'Exit'
   184                   itemValue: closeRequest
   185                   translateLabel: true
   186                 )
   187                )
   188               nil
   189               nil
   190             )
   191           )
   192          (MenuItem
   193             label: 'View'
   194             translateLabel: true
   195             submenu: 
   196            (Menu
   197               (
   198                (MenuItem
   199                   label: 'Builtin'
   200                   translateLabel: true
   201                   hideMenuOnActivated: false
   202                   indication: showBuiltIn
   203                 )
   204                (MenuItem
   205                   label: 'Class Libraries'
   206                   translateLabel: true
   207                   hideMenuOnActivated: false
   208                   indication: showClassLibs
   209                 )
   210                (MenuItem
   211                   label: 'Methods'
   212                   translateLabel: true
   213                   hideMenuOnActivated: false
   214                   indication: showMethods
   215                 )
   216                (MenuItem
   217                   label: 'C-Objects'
   218                   translateLabel: true
   219                   hideMenuOnActivated: false
   220                   indication: showCObjects
   221                 )
   222                (MenuItem
   223                   label: 'Others'
   224                   translateLabel: true
   225                   hideMenuOnActivated: false
   226                   indication: showOthers
   227                 )
   228                (MenuItem
   229                   label: '-'
   230                 )
   231                (MenuItem
   232                   label: 'Update'
   233                   itemValue: menuUpdateModuleList
   234                   translateLabel: true
   235                 )
   236                )
   237               nil
   238               nil
   239             )
   240           )
   241          (MenuItem
   242             label: 'Module'
   243             translateLabel: true
   244             submenu: 
   245            (Menu
   246               (
   247                (MenuItem
   248                   enabled: canBrowseSelectedModule
   249                   label: 'Browse'
   250                   itemValue: browseModule
   251                   translateLabel: true
   252                 )
   253                (MenuItem
   254                   enabled: canCopyClassNameList
   255                   label: 'Copy Version Info to Clipboard'
   256                   itemValue: copyClassOrVMNameList
   257                   translateLabel: true
   258                 )
   259                (MenuItem
   260                   label: '-'
   261                 )
   262                (MenuItem
   263                   enabled: canUnloadSelectedModulesPackage
   264                   label: 'Unload Package'
   265                   itemValue: unloadSelectedModulesPackage
   266                   translateLabel: true
   267                 )
   268                (MenuItem
   269                   enabled: canUnloadSelectedModule
   270                   label: 'Remove Classes && Unload DLL'
   271                   itemValue: unloadSelectedModuleAndRemoveClasses
   272                   translateLabel: true
   273                 )
   274                (MenuItem
   275                   enabled: canUnloadSelectedModule
   276                   label: 'Unload DLL'
   277                   itemValue: unloadSelectedModule
   278                   translateLabel: true
   279                 )
   280                )
   281               nil
   282               nil
   283             )
   284           )
   285          (MenuItem
   286             label: 'Help'
   287             translateLabel: true
   288             startGroup: conditionalRight
   289             submenu: 
   290            (Menu
   291               (
   292                (MenuItem
   293                   label: 'Documentation'
   294                   itemValue: openDocumentation
   295                   translateLabel: true
   296                 )
   297                (MenuItem
   298                   label: '-'
   299                 )
   300                (MenuItem
   301                   label: 'About this Application...'
   302                   itemValue: openAboutThisApplication
   303                   translateLabel: true
   304                 )
   305                )
   306               nil
   307               nil
   308             )
   309           )
   310          )
   311         nil
   312         nil
   313       )
   314 !
   315 
   316 moduleItemMenu
   317     "This resource specification was automatically generated
   318      by the MenuEditor of ST/X."
   319 
   320     "Do not manually edit this!! If it is corrupted,
   321      the MenuEditor may not be able to read the specification."
   322 
   323     "
   324      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#moduleItemMenu
   325      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation moduleItemMenu)) startUp
   326     "
   327 
   328     <resource: #menu>
   329 
   330     ^ 
   331      #(Menu
   332         (
   333          (MenuItem   
   334             enabled: canBrowseSelectedClass
   335             label: 'Browse'
   336             itemValue: browseClass
   337             translateLabel: true
   338           )
   339          (MenuItem   
   340             label: '-'
   341           )
   342          (MenuItem   
   343             enabled: canCopyClassNameList
   344             label: 'Copy Version Info to Clipboard'
   345             itemValue: copyClassOrVMNameList
   346             translateLabel: true
   347           )
   348          )
   349         nil
   350         nil
   351       )
   352 !
   353 
   354 moduleMenu
   355     "This resource specification was automatically generated
   356      by the MenuEditor of ST/X."
   357 
   358     "Do not manually edit this!! If it is corrupted,
   359      the MenuEditor may not be able to read the specification."
   360 
   361     "
   362      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#moduleMenu
   363      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation moduleMenu)) startUp
   364     "
   365 
   366     <resource: #menu>
   367 
   368     ^ 
   369      #(Menu
   370         (
   371          (MenuItem
   372             enabled: canBrowseSelectedModule
   373             label: 'Browse'
   374             itemValue: browseModule
   375             translateLabel: true
   376           )
   377          (MenuItem   
   378             enabled: canCopyClassNameList
   379             label: 'Copy Version Info to Clipboard'
   380             itemValue: copyClassOrVMNameList
   381             translateLabel: true
   382           )
   383          (MenuItem
   384             label: '-'
   385           )
   386          (MenuItem
   387             enabled: canUnloadSelectedModulesPackage
   388             label: 'Unload Package'
   389             itemValue: unloadSelectedModulesPackage
   390             translateLabel: true
   391           )
   392          (MenuItem
   393             enabled: canUnloadSelectedModule
   394             label: 'Remove Classes && Unload DLL'
   395             itemValue: unloadSelectedModuleAndRemoveClasses
   396             translateLabel: true
   397           )
   398          (MenuItem
   399             enabled: canUnloadSelectedModule
   400             label: 'Unload DLL'
   401             itemValue: unloadSelectedModule
   402             translateLabel: true
   403           )
   404          )
   405         nil
   406         nil
   407       )
   408 !
   409 
   410 toolbarMenu
   411     "This resource specification was automatically generated
   412      by the MenuEditor of ST/X."
   413 
   414     "Do not manually edit this!! If it is corrupted,
   415      the MenuEditor may not be able to read the specification."
   416 
   417     "
   418      MenuEditor new openOnClass:Tools::ObjectModuleInformation andSelector:#toolbarMenu
   419      (Menu new fromLiteralArrayEncoding:(Tools::ObjectModuleInformation toolbarMenu)) startUp
   420     "
   421 
   422     <resource: #menu>
   423 
   424     ^ 
   425      #(Menu
   426         (
   427          (MenuItem
   428             enabled: canBrowseSelectedModule
   429             label: 'Action'
   430             itemValue: browseModule
   431             translateLabel: true
   432             isButton: true
   433             labelImage: (ResourceRetriever ToolbarIconLibrary systemBrowser24x24Icon2)
   434           )
   435          )
   436         nil
   437         nil
   438       )
   439 ! !
   440 
   441 !ObjectModuleInformation class methodsFor:'tableColumns specs'!
   442 
   443 tableColumns
   444     "This resource specification was automatically generated
   445      by the DataSetBuilder of ST/X."
   446 
   447     "Do not manually edit this!! If it is corrupted,
   448      the DataSetBuilder may not be able to read the specification."
   449 
   450     "
   451      DataSetBuilder new openOnClass:ObjectModuleInformation andSelector:#tableColumns
   452     "
   453 
   454     <resource: #tableColumns>
   455 
   456     ^#(
   457       (DataSetColumnSpec
   458          label: 'Name'
   459          activeHelpKey: ''
   460          labelButtonType: Button
   461          width: 0.5
   462          model: name
   463          canSelect: false
   464        )
   465       (DataSetColumnSpec
   466          label: 'Version'
   467          activeHelpKey: ''
   468          labelButtonType: Button
   469          model: version
   470          canSelect: false
   471        )
   472       (DataSetColumnSpec
   473          label: 'Date'
   474          activeHelpKey: ''
   475          labelButtonType: Button
   476          model: date
   477          canSelect: false
   478        )
   479       )
   480     
   481 !
   482 
   483 tableColumnsForSingleInfo
   484     "This resource specification was automatically generated
   485      by the DataSetBuilder of ST/X."
   486 
   487     "Do not manually edit this!! If it is corrupted,
   488      the DataSetBuilder may not be able to read the specification."
   489 
   490     "
   491      DataSetBuilder new openOnClass:Tools::ObjectModuleInformation andSelector:#tableColumnsForSingleInfo
   492     "
   493 
   494     <resource: #tableColumns>
   495 
   496     ^#(
   497       (DataSetColumnSpec
   498          label: ''
   499          activeHelpKey: ''
   500          labelButtonType: None
   501          width: 0.3
   502          model: name
   503          canSelect: false
   504        )
   505       (DataSetColumnSpec
   506          label: ''
   507          activeHelpKey: ''
   508          labelButtonType: None
   509          model: value
   510          canSelect: false
   511        )
   512       )
   513     
   514 ! !
   515 
   516 !ObjectModuleInformation methodsFor:'aspects'!
   517 
   518 canBrowseSelectedClass
   519     ^ [classNamesShown notEmptyOrNil
   520        and:[ self selectedInfoIndex notNil
   521        and:[ self selectedInfoIndex ~~ 0 ]]]
   522 
   523     "Modified: / 05-10-2007 / 10:51:39 / cg"
   524 !
   525 
   526 canBrowseSelectedModule
   527     canBrowseSelectedModule isNil ifTrue:[
   528         canBrowseSelectedModule := false asValue
   529     ].
   530     ^ canBrowseSelectedModule.
   531 
   532     "Modified: / 05-10-2007 / 10:51:39 / cg"
   533 !
   534 
   535 canCopyClassNameList
   536     ^ [table1VisibleHolder value 
   537     and:[classInfoShown notEmptyOrNil or:[vmInfoShown notEmptyOrNil] ]]
   538 
   539     "Modified: / 05-10-2007 / 10:51:39 / cg"
   540 !
   541 
   542 canUnloadSelectedModule
   543     canUnloadSelectedModule isNil ifTrue:[
   544         canUnloadSelectedModule := false asValue
   545     ].
   546     ^ canUnloadSelectedModule.
   547 
   548     "Modified: / 05-10-2007 / 10:51:39 / cg"
   549 !
   550 
   551 canUnloadSelectedModulesPackage
   552     canUnloadSelectedModulesPackage isNil ifTrue:[
   553         canUnloadSelectedModulesPackage := false asValue
   554     ].
   555     ^ canUnloadSelectedModulesPackage.
   556 !
   557 
   558 infoTable1ListHolder
   559     ^ builder valueAspectFor:#'infoTable1ListHolder' initialValue:#()
   560 
   561     "Created: / 05-10-2007 / 12:48:06 / cg"
   562 !
   563 
   564 infoTable2ListHolder
   565     ^ builder valueAspectFor:#'infoTable2ListHolder' initialValue:#()
   566 
   567     "Created: / 05-10-2007 / 12:48:10 / cg"
   568 !
   569 
   570 listOfModuleNames
   571     listOfModuleNames isNil ifTrue:[
   572         listOfModuleNames := List new.
   573     ].
   574     ^ listOfModuleNames.
   575 
   576     "Modified: / 05-10-2007 / 10:49:19 / cg"
   577 !
   578 
   579 middleLabelHolder
   580     ^ builder valueAspectFor:#'middleLabelHolder' initialValue:''
   581 
   582     "Created: / 05-10-2007 / 11:05:08 / cg"
   583 !
   584 
   585 notReadOnly
   586     ^ self readOnly not
   587 
   588     "Created: / 05-10-2007 / 13:06:00 / cg"
   589 !
   590 
   591 readOnly
   592     ^ readOnly ? false
   593 
   594     "Created: / 05-10-2007 / 13:05:51 / cg"
   595 !
   596 
   597 readOnly:aBoolean
   598     readOnly := aBoolean
   599 
   600     "Created: / 05-10-2007 / 13:05:51 / cg"
   601 !
   602 
   603 selectedInfoIndex
   604     |sel|
   605 
   606     sel := self selectedInfoIndexHolder value.
   607     ^ sel
   608 !
   609 
   610 selectedInfoIndexHolder
   611     selectedInfoIndexHolder isNil ifTrue:[
   612         selectedInfoIndexHolder := ValueHolder new.
   613         selectedInfoIndexHolder onChangeSend:#selectedInfoIndexChanged to:self.
   614     ].
   615     ^ selectedInfoIndexHolder.
   616 
   617     "Modified: / 05-10-2007 / 10:51:39 / cg"
   618 !
   619 
   620 selectedModuleIndex
   621     |sel|
   622 
   623     sel := self selectedModuleIndexHolder value.
   624     ^ sel
   625 !
   626 
   627 selectedModuleIndexHolder
   628     selectedModuleIndexHolder isNil ifTrue:[
   629         selectedModuleIndexHolder := ValueHolder new.
   630         selectedModuleIndexHolder onChangeSend:#selectedModuleIndexChanged to:self.
   631     ].
   632     ^ selectedModuleIndexHolder.
   633 
   634     "Modified: / 05-10-2007 / 10:51:39 / cg"
   635 !
   636 
   637 showBuiltIn
   638     showBuiltIn isNil ifTrue:[
   639         showBuiltIn := true asValue.
   640         showBuiltIn onChangeSend:#filterChanged to:self.
   641     ].
   642     ^ showBuiltIn
   643 
   644     "Modified: / 05-10-2007 / 12:43:23 / cg"
   645 !
   646 
   647 showCObjects
   648     showCObjects isNil ifTrue:[
   649         showCObjects := true asValue.
   650         showCObjects onChangeSend:#filterChanged to:self.
   651     ].
   652     ^ showCObjects
   653 
   654     "Modified: / 05-10-2007 / 12:43:16 / cg"
   655 !
   656 
   657 showClassLibs
   658     showClassLibs isNil ifTrue:[
   659         showClassLibs := true asValue.
   660         showClassLibs onChangeSend:#filterChanged to:self.
   661     ].
   662     ^ showClassLibs
   663 
   664     "Modified: / 05-10-2007 / 12:43:10 / cg"
   665 !
   666 
   667 showMethods
   668     showMethods isNil ifTrue:[
   669         showMethods := true asValue.
   670         showMethods onChangeSend:#filterChanged to:self.
   671     ].
   672     ^ showMethods
   673 
   674     "Modified: / 05-10-2007 / 12:43:02 / cg"
   675 !
   676 
   677 showOthers
   678     showOthers isNil ifTrue:[
   679         showOthers := true asValue.
   680         showOthers onChangeSend:#filterChanged to:self.
   681     ].
   682     ^ showOthers
   683 
   684     "Modified: / 05-10-2007 / 12:42:54 / cg"
   685 !
   686 
   687 table1VisibleHolder
   688     table1VisibleHolder isNil ifTrue:[
   689         table1VisibleHolder := true asValue.
   690     ].
   691     ^ table1VisibleHolder.
   692 
   693     "Modified: / 05-10-2007 / 12:53:05 / cg"
   694 !
   695 
   696 table2VisibleHolder
   697     table2VisibleHolder isNil ifTrue:[
   698         table2VisibleHolder := false asValue.
   699     ].
   700     ^ table2VisibleHolder.
   701 
   702     "Modified: / 05-10-2007 / 12:53:14 / cg"
   703 ! !
   704 
   705 !ObjectModuleInformation methodsFor:'change & update'!
   706 
   707 selectedInfoIndexChanged
   708 !
   709 
   710 selectedModule
   711     |sel|
   712 
   713     sel := self selectedModuleIndex.
   714     sel isNil ifTrue:[^ nil].
   715     ^ objectHandles at:sel.
   716 !
   717 
   718 selectedModuleIndexChanged
   719     |module info|
   720 
   721     info := self selectedModuleInfo.
   722     module := self selectedModule.
   723 
   724     self canBrowseSelectedModule value:(info notNil and:[info ~~ #VM and:[module notNil]]).
   725     self canUnloadSelectedModule value:(self readOnly not and:[info ~~ #VM and:[info notNil and:[info dynamic]]]).
   726 
   727     classNamesShown := nil.
   728     classInfoShown := nil.
   729     vmInfoShown := nil.
   730 
   731     info isNil ifTrue:[
   732         "/ selected a method, cObject or unknown
   733         self showInfoForNonClassLib:(self selectedModuleIndex).
   734         ^ self.
   735     ].
   736     info == #VM ifTrue:[
   737         "/ selected the pseudo entry for the VM itself
   738         self showInfoForVM.
   739         ^ self.
   740     ].
   741     "/ selected a class-library package
   742     self showInfoForClassLib:info.
   743 
   744     "Modified: / 05-10-2007 / 12:56:13 / cg"
   745 !
   746 
   747 selectedModuleInfo
   748     |sel info|
   749 
   750     sel := self selectedModuleIndex.
   751     sel notNil ifTrue:[
   752         (self showClassLibs value or:[self showBuiltIn value]) ifTrue:[
   753             info := allModules at:sel ifAbsent:nil.
   754         ].
   755     ].
   756     ^ info
   757 !
   758 
   759 showInfoForClassLib:info
   760     " selected a lib-package; fill bottom list with class-info "
   761 
   762     |rows libraryName defClassName libraryDefinition mgr defClassNames|
   763 
   764     self middleLabelHolder value:'Contains Components:'.
   765 
   766     "/ try to figure out, what the definitionClass is inside that module.
   767     "/ in the future, we should always find one there, however, old libs or
   768     "/ special libraries (hand built) might be without a projectDefinition.
   769     defClassNames := (info classNames ? #()) 
   770                         select:[:nm |                
   771                             |cls| 
   772                             cls := Smalltalk classNamed:nm.
   773                             cls isBehavior and:[ cls isProjectDefinition ]].
   774 
   775     defClassNames size == 1 ifTrue:[
   776         libraryName := defClassNames first
   777     ] ifFalse:[
   778         "/ fallback - some heuristics...
   779         libraryName := info libraryName.
   780         (libraryName notNil and:[ libraryName startsWith:'lib' ]) ifTrue:[
   781             defClassName := libraryName copyFrom:4
   782         ] ifFalse:[
   783             self halt.
   784         ].
   785     ].
   786     defClassName notNil ifTrue:[
   787         libraryDefinition := Smalltalk classNamed:defClassName.
   788     ].
   789 
   790     classNamesShown := self shownClassNamesFor:info.
   791 
   792     rows := classNamesShown collect:[:cName |
   793                     |cls entry rev listEntry revisionInfo versionString dateString|
   794 
   795                     listEntry := InfoRow new.
   796                     listEntry name:cName.
   797 
   798                     cls := Smalltalk classNamed:cName.
   799                     cls isNil ifTrue:[
   800                         (cName endsWith:'_extensions') ifFalse:[
   801                             versionString := '(class removed)'.
   802                         ] ifTrue:[
   803                             libraryDefinition notNil ifTrue:[
   804                                 mgr := libraryDefinition sourceCodeManager.
   805                                 versionString := libraryDefinition perform:(mgr nameOfVersionMethodForExtensions) ifNotUnderstood:nil.
   806                                 versionString notNil ifTrue:[
   807                                     versionString := '(bin: ',(mgr revisionInfoFromString:versionString) revision,')'.
   808                                 ]
   809                             ].
   810                         ].
   811                     ] ifFalse:[
   812                         rev := cls binaryRevision.
   813                         rev notNil ifTrue:[
   814                             cls isLoaded ifFalse:[
   815                                 entry := '(stub for: ' , rev.
   816                             ] ifTrue:[
   817                                 entry :='(bin: ' , rev.
   818                             ].    
   819                             cls revision ~= rev ifTrue:[
   820                                 entry := entry , ' / src: ' , (cls revision printString)
   821                             ].
   822                             entry := entry , ')'.
   823                             versionString := entry
   824                         ] ifFalse:[
   825                             cls revision notNil ifTrue:[
   826                                 versionString := '(overloaded by: ' , cls revision , ')' 
   827                             ]
   828                         ].
   829                         revisionInfo := cls revisionInfo.
   830                         revisionInfo notNil ifTrue:[
   831                             dateString := (revisionInfo at:#date)
   832                         ].
   833                     ].
   834                     listEntry version:versionString.
   835                     listEntry date:dateString
   836                   ].
   837 
   838     classInfoShown := rows.
   839 
   840     self infoTable1ListHolder value:rows.
   841     self table1VisibleHolder value:true.
   842     self table2VisibleHolder value:false.
   843 
   844     "Modified: / 05-10-2007 / 13:03:56 / cg"
   845 !
   846 
   847 showInfoForNonClassLib:sel
   848     " selected a method, cObject or unknown "
   849 
   850     |module fileName list entry|
   851 
   852     sel isNil ifTrue:[
   853         self table1VisibleHolder value:false.
   854         self table2VisibleHolder value:false.
   855         ^ self.
   856     ].
   857 
   858     module := objectHandles at:sel.
   859     fileName := module pathName.
   860 
   861     module isMethodHandle ifTrue:[
   862         |method nm entry1 entry2 entry3|
   863 
   864         self middleLabelHolder value:'Compiled Method:'.
   865 
   866         (method := module method) isNil ifTrue:[
   867             nm := '** removed **'.
   868         ] ifFalse:[
   869 "/            menu := PopUpMenu
   870 "/                        labels:#('Inspect' 'Browse')
   871 "/                        selectors:#(inspect browse).
   872 "/            menu actionAt:#inspect put:[ method inspect ].
   873 "/            menu actionAt:#browse put:[ |who|
   874 "/                                        who := method who.
   875 "/                                        UserPreferences systemBrowserClass
   876 "/                                            openInClass:(who methodClass) 
   877 "/                                            selector:(who methodSelector) 
   878 "/                                      ].
   879 "/            listView1 middleButtonMenu:menu.
   880 
   881             nm := (method whoString) asText emphasizeAllWith:(#color->Color blue).
   882         ].
   883         entry1 := InfoRow new.
   884         entry1 name:'Compiled method'; value:nm.
   885 
   886         entry2 := InfoRow new.
   887         entry2 name:'Path'; value:fileName.
   888 
   889         entry3 := InfoRow new.
   890         entry3 name:'Address'; value:('(16r) ' , (method code address hexPrintString leftPaddedTo:8 with:$0)).
   891 
   892         self infoTable2ListHolder value:(Array with:entry1 with:entry2 with:entry3).
   893         self table1VisibleHolder value:false.
   894         self table2VisibleHolder value:true.
   895         ^ self.
   896     ].
   897 
   898     (module isFunctionObjectHandle 
   899     and:[module functions notEmpty]) ifTrue:[
   900         self middleLabelHolder value:'Functions:'.
   901 
   902 "/        menu := PopUpMenu
   903 "/                    labels:#('Inspect')
   904 "/                    selectors:#(inspect).
   905 "/        menu actionAt:#inspect put:[ module functions inspect  ].
   906 "/        listView1 middleButtonMenu:menu.
   907 "/
   908         list := (module functions select:[:f | f notNil])
   909                         collect:[:f | |entry|
   910                                         entry := InfoRow new.
   911                                         entry name:(f name asText emphasizeAllWith:(#color->Color blue)).
   912                                         entry value:('address: (16r) ' , (f code address hexPrintString leftPaddedTo:8 with:$0)).
   913                                         entry
   914                                 ].
   915         self infoTable2ListHolder value:list.
   916         self table1VisibleHolder value:false.
   917         self table2VisibleHolder value:true.
   918         ^ self.
   919     ].
   920 
   921     entry := InfoRow new.
   922     entry name:'Unknown'.
   923     self infoTable2ListHolder value:(Array with:entry).
   924     self table1VisibleHolder value:false.
   925     self table2VisibleHolder value:true.
   926 
   927     "Modified: / 05-10-2007 / 13:01:33 / cg"
   928 !
   929 
   930 showInfoForVM
   931     " show file versions of vm info in lower view. "
   932 
   933     |l|
   934 
   935     self middleLabelHolder value:'Contains Components:'.
   936 
   937     l := (ObjectMemory getVMIdentificationStrings).
   938     l := l select:[:entry | entry includesString:'$Header'].
   939     l := l select:[:entry | entry includesString:',v'].
   940     l := l collect:[:entry |
   941         |i1 i2 file revision date listEntry|
   942 
   943         listEntry := InfoRow new.
   944 
   945         i1 := entry indexOfSubCollection:'librun'.
   946         i1 ~~ 0 ifTrue:[
   947             i2 := entry indexOfSubCollection:',v' startingAt:i1.
   948             i2 ~~ 0 ifTrue:[
   949                 file := entry copyFrom:i1+7 to:(i2-1).
   950                 listEntry name:file.
   951 
   952                 i1 := i2+3.
   953                 i2 := entry indexOfSeparatorStartingAt:i1.
   954                 revision := entry copyFrom:i1 to:(i2-1).
   955                 listEntry version:revision.
   956 
   957                 i1 := i2+1.
   958                 i2 := entry indexOfSeparatorStartingAt:i1.
   959                 date := entry copyFrom:i1 to:(i2-1).
   960                 listEntry date:date.
   961             ].
   962         ].
   963         listEntry.
   964     ].
   965 
   966     vmInfoShown := l.
   967     self infoTable1ListHolder value:l.
   968     self table1VisibleHolder value:true.
   969     self table2VisibleHolder value:false.
   970 
   971 "/    readOnly ifFalse:[
   972 "/        unloadButton disable.
   973 "/        unloadAndRemoveButton disable.
   974 "/    ]
   975 
   976     "Modified: / 05-10-2007 / 12:53:44 / cg"
   977 !
   978 
   979 shownClassNamesFor:info
   980     "/ selected a package; fill bottom list with class-info
   981 
   982     |classNames|
   983 
   984     classNames := info classNames asSortedCollection.
   985     ^ classNames 
   986         select:[:cName |
   987             |cls|
   988 
   989             cls := Smalltalk classNamed:cName.
   990             cls isNil ifTrue:[
   991                 true "a removed class"
   992             ] ifFalse:[
   993                 cls isPrivate not
   994             ].
   995         ].
   996 ! !
   997 
   998 !ObjectModuleInformation methodsFor:'initialization'!
   999 
  1000 postBuildWith:aBuilder
  1001     |canDoIt|
  1002 
  1003     super postBuildWith:aBuilder.
  1004 
  1005     canDoIt := ObjectFileLoader notNil and:[ObjectFileLoader canLoadObjectFiles].
  1006     self showBuiltIn value:canDoIt.
  1007     self showCObjects value:canDoIt.
  1008     self showClassLibs value:canDoIt.
  1009     self showMethods value:canDoIt.
  1010     self showOthers value:canDoIt.
  1011 
  1012     self updateModuleList
  1013 
  1014     "Created: / 05-10-2007 / 10:50:27 / cg"
  1015 ! !
  1016 
  1017 !ObjectModuleInformation methodsFor:'menu actions'!
  1018 
  1019 browseClass
  1020     |module info classNames selectedClassName selectedClass packageID methods|
  1021 
  1022     module := self selectedModule.
  1023     info := self selectedModuleInfo.
  1024     classNames := (self shownClassNamesFor:info) asSortedCollection.
  1025     selectedClassName := classNames at:(self selectedInfoIndex).
  1026     selectedClass := Smalltalk classNamed:selectedClassName.
  1027 
  1028     selectedClass notNil ifTrue:[
  1029         Smalltalk browseInClass:selectedClass.
  1030         ^ self.
  1031     ].
  1032 
  1033     "/ clicked on an extensions-module ?
  1034     (selectedClassName endsWith:'_extensions') ifTrue:[
  1035         packageID := (selectedClassName copyWithoutLast:('_extensions' size)) asSymbol.
  1036         methods := Smalltalk allExtensionsForPackage:packageID.
  1037         (UserPreferences browserClass) browseMethods:methods title:('Extensions for ',packageID).
  1038         ^ self.
  1039     ].
  1040 self halt.
  1041 !
  1042 
  1043 browseModule
  1044     |module classes|
  1045 
  1046     module := self selectedModule.
  1047     classes := module classNames collect:[:nm | Smalltalk classNamed:nm].
  1048     UserPreferences systemBrowserClass 
  1049         browseClasses:classes
  1050         label:(resources string:'Classes in %1' with:module libraryName)
  1051 !
  1052 
  1053 copyClassOrVMNameList
  1054     |text|
  1055 
  1056     text := ((classInfoShown ? vmInfoShown)collect:[:eachRow | eachRow infoString]) asStringCollection asString.
  1057     self window setClipboardText:text.
  1058 !
  1059 
  1060 menuUpdateModuleList
  1061     self updateModuleList
  1062 
  1063     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1064 !
  1065 
  1066 openDocumentation
  1067     self openHTMLDocument: 'tools/misc/TOP.html#MODULEINFO'
  1068 
  1069     "Modified: / 05-10-2007 / 13:11:45 / cg"
  1070 !
  1071 
  1072 unloadSelectedModule
  1073     self unloadSelectedModuleRemoveClasses:false
  1074 !
  1075 
  1076 unloadSelectedModuleAndRemoveClasses
  1077     self unloadSelectedModuleRemoveClasses:true
  1078 !
  1079 
  1080 unloadSelectedModuleRemoveClasses:doRemoveClasses
  1081     (Dialog 
  1082         confirm:'This is a possibly dangerous operation, as the DLL is unloaded without caring for 
  1083 proper package-deinstallation procedures. Please only use this in repair situations and when the 
  1084 regular unloadPackage operation fails.
  1085 
  1086 Continue ?')
  1087     ifFalse:[
  1088         ^ self  
  1089     ].
  1090 
  1091     self withWaitCursorDo:[
  1092         |info idx handle pathName|
  1093 
  1094         info := self selectedModuleInfo.
  1095         handle := objectHandles at:(self selectedModuleIndex).
  1096         self selectedModuleIndexHolder value:nil.
  1097 
  1098         info isNil ifTrue:[
  1099             "/ selected a method
  1100             "/ idx := idx - allModules size.
  1101             pathName := handle pathName.
  1102         ] ifFalse:[
  1103             "/ selected a package
  1104             pathName := info pathName.
  1105         ].
  1106         pathName notNil ifTrue:[
  1107             doRemoveClasses ifTrue:[
  1108                 ObjectFileLoader unloadObjectFileAndRemoveClasses:pathName.
  1109             ] ifFalse:[
  1110                 ObjectFileLoader unloadObjectFile:pathName.
  1111             ]
  1112         ].
  1113         self updateModuleList.
  1114     ]
  1115 ! !
  1116 
  1117 !ObjectModuleInformation methodsFor:'private'!
  1118 
  1119 filterChanged
  1120     self updateModuleList
  1121 
  1122     "Created: / 05-10-2007 / 12:43:36 / cg"
  1123 !
  1124 
  1125 updateModuleList
  1126     |showClassLibs showBuiltIn showMethods showCObjects showOthers
  1127      listOfModuleNames allObjects handles|
  1128 
  1129     showClassLibs := self showClassLibs value.
  1130     showBuiltIn := self showBuiltIn value.
  1131     showMethods := self showMethods value.
  1132     showCObjects := self showCObjects value.
  1133     showOthers := self showOthers value.
  1134 
  1135     listOfModuleNames := OrderedCollection new.
  1136     handles := OrderedCollection new.
  1137 
  1138     allObjects := ObjectFileLoader loadedObjectHandles.
  1139 
  1140     (showClassLibs or:[showBuiltIn]) ifTrue:[
  1141         |moduleNames|
  1142 
  1143         allModules := ObjectMemory binaryModuleInfo asOrderedCollection.
  1144         (showBuiltIn and:[showClassLibs]) ifFalse:[
  1145             allModules := allModules select:
  1146                                         [:i |
  1147                                             |wantToSee|
  1148 
  1149                                             wantToSee := i dynamic.
  1150                                             showBuiltIn ifTrue:[
  1151                                                 wantToSee := wantToSee not
  1152                                             ].
  1153                                             wantToSee
  1154                                         ]
  1155         ].
  1156 
  1157         "/ sorting by reverse id brings newest ones to the top (a side effect)
  1158         allModules sort:[:a :b | (a id) > (b id)].
  1159         moduleNames := allModules collect:[:entry | entry name].
  1160         listOfModuleNames addAll:moduleNames.
  1161         handles addAll:allModules.
  1162     ].
  1163 
  1164     showMethods ifTrue:[
  1165         |methodObjects methodNames|
  1166 
  1167         methodObjects := (allObjects select:[:h | h isMethodHandle]) asArray.
  1168         methodNames := methodObjects collect:[:mH | mH method isNil ifTrue:[
  1169                                                         'compiled method - removed' " , ' (in ' , mH pathName , ')' "
  1170                                                     ] ifFalse:[
  1171                                                         'compiled method ' , mH method whoString  " , ' (in ' , mH pathName , ')' "
  1172                                                     ].
  1173                                              ].
  1174         listOfModuleNames addAll:methodNames.
  1175         handles addAll:methodObjects.
  1176     ].
  1177 
  1178     showCObjects ifTrue:[
  1179         |cObjects cObjectNames|
  1180 
  1181         cObjects := (allObjects select:[:h | h isFunctionObjectHandle]) asArray.
  1182         cObjectNames := cObjects collect:[:entry | entry pathName].
  1183         listOfModuleNames addAll:cObjectNames.
  1184         handles addAll:cObjects.
  1185     ].
  1186 
  1187     showOthers ifTrue:[
  1188         |otherObjects otherObjectNames|
  1189 
  1190         otherObjects := (allObjects select:[:h | (h isFunctionObjectHandle
  1191                                                  or:[h isMethodHandle
  1192                                                  or:[h isClassLibHandle]]) not]) asArray.
  1193         otherObjectNames := otherObjects collect:[:entry | entry pathName].
  1194         listOfModuleNames addAll:otherObjectNames.
  1195         handles addAll:otherObjects.
  1196     ].
  1197 
  1198     showBuiltIn ifTrue:[
  1199         listOfModuleNames addFirst:'VM'.
  1200         handles addFirst:#VM.
  1201         allModules addFirst:#VM.
  1202     ].
  1203 
  1204     self listOfModuleNames contents:listOfModuleNames.
  1205     objectHandles := handles.
  1206 
  1207     "Modified: / 05-10-2007 / 12:45:37 / cg"
  1208 ! !
  1209 
  1210 !ObjectModuleInformation::InfoRow methodsFor:'accessing'!
  1211 
  1212 date
  1213     ^ date
  1214 !
  1215 
  1216 date:something
  1217     date := something.
  1218 !
  1219 
  1220 name
  1221     ^ name
  1222 !
  1223 
  1224 name:something
  1225     name := something.
  1226 !
  1227 
  1228 name:nameArg version:versionArg date:dateArg 
  1229     name := nameArg.
  1230     version := versionArg.
  1231     date := dateArg.
  1232 !
  1233 
  1234 value
  1235     ^ value
  1236 !
  1237 
  1238 value:something
  1239     value := something.
  1240 !
  1241 
  1242 version
  1243     ^ version
  1244 !
  1245 
  1246 version:something
  1247     version := something.
  1248 ! !
  1249 
  1250 !ObjectModuleInformation::InfoRow methodsFor:'info'!
  1251 
  1252 infoString
  1253     ^ name , ' ', (version ? '-') , ' ', (date ? '-') printString
  1254 ! !
  1255 
  1256 !ObjectModuleInformation class methodsFor:'documentation'!
  1257 
  1258 version
  1259     ^ '$Header$'
  1260 !
  1261 
  1262 version_CVS
  1263     ^ '$Header$'
  1264 ! !