Quantcast

VM Maker: CogTools-sk.16.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

VM Maker: CogTools-sk.16.mcz

commits-2
 
Sophie Kaleba uploaded a new version of CogTools to project VM Maker:
http://source.squeak.org/VMMaker/CogTools-sk.16.mcz

==================== Summary ====================

Name: CogTools-sk.16
Author: sk
Time: 17 May 2017, 5:06:26.856039 pm
UUID: 21327485-6185-425c-a6e6-3a7c1494251f
Ancestors: CogTools-sk.15

fix a fileSystem issue

=============== Diff against CogTools-sk.14 ===============

Item was added:
+ ----- Method: SqueakVMProfiler class>>initialize (in category 'as yet unclassified') -----
+ initialize
+
+ super initialize.
+ (TheWorldMenu respondsTo: #registerOpenCommand:) ifTrue:
+ [TheWorldMenu registerOpenCommand: {'VM Profiler'. {self. #open}. 'A VM profiler'}].
+ Preferences
+ addBooleanPreference: #vmProfilerFillInIntegral
+ category: #vmProfiler
+ default: false
+ balloonHelp: 'If enabled, the profiler will fill in the area under the integral.'.
+ self fixTabs!

Item was changed:
  ----- Method: VMProfiler class>>initialize (in category 'class initialization') -----
  initialize
 
  CannedBenchmarkStrings := OrderedCollection new.
+ !
- "(TheWorldMenu respondsTo: #registerOpenCommand:) ifTrue:
- [TheWorldMenu registerOpenCommand: {'VM Profiler'. {self. #open}. 'A VM profiler'}].
- Preferences
- addBooleanPreference: #vmProfilerFillInIntegral
- category: #vmProfiler
- default: false
- balloonHelp: 'If enabled, the profiler will fill in the area under the integral.'.
- self fixTabs"!

Item was changed:
  ----- Method: VMProfilerLinuxSymbolsManager class>>tempDirectory (in category 'as yet unclassified') -----
  tempDirectory
 
+ ^ VMFileSystem nameFordirPath:'/tmp/vmsyms'  plus:OSProcess thisOSProcess pid printString
- ^ fileSystem nameFordirPath:'/tmp/vmsyms'  plus:OSProcess thisOSProcess pid printString
  !

Item was changed:
  ----- Method: VMProfilerLinuxSymbolsManager>>initializeMost (in category 'initialize-release') -----
  initializeMost
  | shortNames |
  initialized := false.
  maxAddressMask := (2 raisedToInteger: 32) - 1.
  modulesByName := Dictionary new.
  symbolsByModule := Dictionary new.
  shortNames := Set new.
  tempDir := self class tempDirectory.
  self fileSystem ensureExistenceOfDirectory:  tempDir.
  modules := self primitiveExecutableModules.
  modules := (1 to: modules size by: 2) collect:
  [:i| | fileName shortName counter longName |
  fileName := modules at: i.
  (fileName beginsWith: '/dgagent') ifTrue:
  [fileName := fileName allButFirst: 8].
+ shortName := VMFileSystem nameOfFile: fileName in: tempDir.  
- shortName := fileSystem nameOfFile: fileName in: tempDir.  
  counter := 0.
  [shortNames includes: shortName] whileTrue:
  [counter := counter + 1.
+ shortName := (VMFileSystem nameOfFile: fileName  in: tempDir), counter printString].
- shortName := (fileSystem nameOfFile: fileName  in: tempDir), counter printString].
  shortNames add: shortName.
  longName := (modules at: i + 1)
  ifNil: [fileName]
  ifNotNil:
  [:symlink|
  symlink first = $/
  ifTrue: [symlink]
+ ifFalse: [( VMFileSystem parentPathOfFile: fileName ), '/', symlink]].
- ifFalse: [( fileSystem parentPathOfFile: fileName ), '/', symlink]].
  "some files are off limits (e.g. /dgagent/lib/preload.so)"
+ (VMFileSystem exists: longName) ifTrue:
- (fileSystem exists: longName) ifTrue:
  [(modulesByName
  at: longName
  put: VMPExecutableModuleSymbol new)
  name: longName;
  shortName: shortName]].
  "The primitive always answers the VM info in the first entry."
  vmModule := modules first.
  "now filter out the files we can't read..."
  modules := modules select: [:m| modulesByName includesKey: m name]!

Item was changed:
  ----- Method: VMProfilerLinuxSymbolsManager>>parseSymbolsFor: (in category 'parsing') -----
  parseSymbolsFor: module
  | proc symtab symStream |
+ (VMFileSystem exists: tempDir fullName, '/', module shortName)  ifFalse:
- (fileSystem exists: tempDir fullName, '/', module shortName)  ifFalse:
  [proc := OSProcess thisOSProcess command:
  'objdump -j .text -tT "', module name, '" | fgrep .text | sort >"', tempDir fullName, '/', module shortName, '"'].
  symStream := (Array new: 1000) writeStream.
  symStream nextPut: module.
  proc ifNotNil:
  [[proc isComplete] whileFalse: [(Delay forMilliseconds: 25) wait]].
  symtab := [StandardFileStream readOnlyFileNamed: (tempDir fullName,'/',module shortName) ]
  on: Error
  do: [:ex| "Handle flaky OSProcess stuff by reporting error and failing to parse"
  Transcript print: ex; flush.
  ^nil].
  [| prev |
  prev := self parseSymbolsFrom: symtab to: symStream.
  symbolsByModule
  at: module
  put: (self relocateSymbols: symStream contents allButFirst inModule: module).
  (prev notNil
   and: [prev limit isNil]) ifTrue: [prev limit: module limit]]
  ensure: [symtab close]!

Item was changed:
  ----- Method: VMProfilerMacSymbolsManager class>>shutDown: (in category 'shut down') -----
  shutDown: quitting
+ "(quitting
- (quitting
  and: [Smalltalk platformName= 'Mac OS']) ifTrue:
  [| tempDir |
  (tempDir := self tempDirectory) exists ifTrue:
+ [tempDir recursiveDelete]]"!
- [tempDir recursiveDelete]]!

Item was changed:
  ----- Method: VMProfilerMacSymbolsManager class>>tempDirectory (in category 'as yet unclassified') -----
  tempDirectory
 
+ ^ VMFileSystem nameFordirPath:'private/tmp/vmsyms'  plus:OSProcess thisOSProcess pid printString
- ^ fileSystem nameFordirPath:'private/tmp/vmsyms'  plus:OSProcess thisOSProcess pid printString
  !

Item was changed:
  ----- Method: VMProfilerMacSymbolsManager>>computeLimitFor:initialShift: (in category 'parsing') -----
  computeLimitFor: module initialShift: initialShift
  "If we can't find a non-text symbol following the last text symbol, compute the ernd of text using the size command."
  | sizeFileName proc text size |
  sizeFileName := module shortName, '.size'.
+ (VMFileSystem exists: tempDir fullName, '/', sizeFileName) ifFalse:
- (fileSystem exists: tempDir, '/', sizeFileName) ifFalse:
  ["N.B. Don't use the -f option (which meant flat symbols) as in El Capitan it is misinterpreted to mean -format."
  proc := OSProcess thisOSProcess command:
  'cd ', tempDir fullName,
  ';size -arch ', self archName, " -f" ' "', module name, '" >"', sizeFileName, '"'.
  [proc isComplete] whileFalse: [(Delay forMilliseconds: 25) wait]].
+ text := (StandardFileStream readOnlyFileNamed: (tempDir fullName, '/', sizeFileName)) contentsOfEntireFile.
- text := (StandardFileStream readOnlyFileNamed: (tempDir fullNameFor: sizeFileName)) contentsOfEntireFile.
  size := Integer readFrom: (text copyAfter: Character lf) readStream.
  ^size + initialShift!

Item was changed:
  ----- Method: VMProfilerMacSymbolsManager>>initializeMost (in category 'initialize-release') -----
  initializeMost
  | shortNames |
  initialized := false.
  maxAddressMask := (2 raisedToInteger: Smalltalk wordSize * 8) - 1.
  modulesByName := Dictionary new.
  symbolsByModule := Dictionary new.
  shortNames := Set new.
  modules := self primitiveExecutableModulesAndOffsets.
  tempDir := self class tempDirectory.
  self fileSystem ensureExistenceOfDirectory:  tempDir.
  modules := (1 to: modules size by: 4) collect:
  [:i| | shortName counter |
+ shortName := VMFileSystem nameOfFile: (modules at: i) in: tempDir.
- shortName := fileSystem nameOfFile: (modules at: i) in: tempDir.
  counter := 0.
  [shortNames includes: shortName] whileTrue:
  [counter := counter + 1.
+ shortName := (VMFileSystem nameOfFile: (modules at: i) in: tempDir), counter printString].  
- shortName := (fileSystem nameOfFile: (modules at: i) in: tempDir), counter printString].  
  shortNames add: shortName.
  (modulesByName
  at: (modules at: i)
  put: VMPExecutableModuleSymbol new)
  name: (modules at: i);
  shortName: shortName;
  vmshift: (modules at: i + 1);
  address: (maxAddressMask bitAnd: (modules at: i + 2) + (modules at: i + 1));
  size: (modules at: i + 3)].
  modules := self filter: modules.
  "The primitive always answers the VM info in the first entry."
  vmModule := modules first.
  modules := modules asSortedCollection: [:m1 :m2| m1 address <= m2 address]!

Item was changed:
  ----- Method: VMProfilerMacSymbolsManager>>parseSymbolsFor: (in category 'parsing') -----
  parseSymbolsFor: module
  | proc symtab symStream |
+ (VMFileSystem exists: tempDir fullName, '/', module shortName) ifFalse:
- (fileSystem exists: tempDir fullName, '/', module shortName) ifFalse:
  "(tempDir fileExists: module shortName) ifFalse:"
  ["N.B. Don't use the -f option (which meant flat symbols) as in El Capitan it is misinterpreted to mean -format."
  proc := OSProcess thisOSProcess command:
  'cd ', tempDir fullName,
  ';nm -n -arch ', self archName, " -f" ' "', module name, '" | grep -v " [aAU] " >"', module shortName, '"'].
  symStream := (Array new: 1000) writeStream.
  symStream nextPut: module.
+ proc ifNotNil:[(Delay forMilliseconds: 25) wait].
+ "[[proc isComplete] whileFalse: [(Delay forMilliseconds: 25) wait]]." "infinite loop"
- proc ifNotNil:
- [[proc isComplete] whileFalse: [(Delay forMilliseconds: 25) wait]].
  symtab := [StandardFileStream readOnlyFileNamed: (tempDir fullName, '/', module shortName)]
  on: Error
  do: [:ex| "Handle flaky OSProcess stuff by reporting error and failing to parse"
  Transcript print: ex; flush.
  ^nil].
  "Have caller eliminate modules with no text."
  symtab size = 0 ifTrue:
  [^nil].
  module shortName = 'HIToolbox' ifTrue: [self halt].
  [| prev |
  prev := self parseSymbolsFrom: symtab to: symStream.
  "CoreAUC has a huge chunk of data at the end of its text segment that causes the profiler to spend ages
  counting zeros.  Hack fix by setting the end of the last symbol in the text segment to a little less than 1Mb."
  "00000000000f1922    retq" "Mavericks 13.4"
  "00000000000f3b21    retq" "Yosemite 14.5"
  module shortName = 'CoreAUC' ifTrue: [prev limit: 16rf8000].
  symbolsByModule
  at: module
  put: (self relocateSymbols: symStream contents allButFirst inModule: module).
  (prev notNil
   and: [prev limit isNil]) ifTrue: [prev limit: module limit]]
  ensure: [symtab close]!

Item was changed:
  Object subclass: #VMProfilerSymbolsManager
  instanceVariableNames: 'modules symbolsByModule modulesByName vmModule cogModule'
+ classVariableNames: 'VMFileSystem'
- classVariableNames: 'fileSystem'
  poolDictionaries: ''
  category: 'CogTools-VMProfiler'!

Item was changed:
  ----- Method: VMProfilerSymbolsManager class>>using: (in category 'as yet unclassified') -----
  using: aFileSystem
 
+ VMFileSystem := aFileSystem.
- fileSystem := aFileSystem.
  ^ self new
  !

Item was changed:
  ----- Method: VMProfilerSymbolsManager>>fileSystem (in category 'accessing') -----
  fileSystem
 
+ ^VMFileSystem !
- ^fileSystem !

Item was changed:
  ----- Method: VMProfilerSymbolsManager>>fileSystem: (in category 'accessing') -----
  fileSystem: aVMFileSystem
 
+ VMFileSystem := aVMFileSystem. !
- fileSystem := aVMFileSystem. !

Loading...