[Vm-dev] VM Maker: VMMaker.oscog-eem.298.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Jun 11 01:14:42 UTC 2013


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.298.mcz

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

Name: VMMaker.oscog-eem.298
Author: eem
Time: 10 June 2013, 6:12:31.011 pm
UUID: da5c90a8-14fa-4f7a-a58f-40f16337392c
Ancestors: VMMaker.oscog-eem.297

Change the VMProfileLinuxSupportPlugin to follow symlinks,
answering pairs of module name, dereferenced symlink or nil.

=============== Diff against VMMaker.oscog-eem.297 ===============

Item was changed:
  ----- Method: VMProfileLinuxSupportPlugin class>>declareHeaderFilesIn: (in category 'translation') -----
  declareHeaderFilesIn: cg
  
+ 	cg
+ 		addHeaderFile: '<limits.h>';
+ 		addHeaderFile: '#ifndef _GNU_SOURCE\# define _GNU_SOURCE\#endif\#include <link.h>' withCRs!
- 	cg  addHeaderFile: '#ifndef _GNU_SOURCE\# define _GNU_SOURCE\#endif\#include <link.h>' withCRs!

Item was changed:
  ----- Method: VMProfileLinuxSupportPlugin>>primitiveExecutableModules (in category 'primitives') -----
  primitiveExecutableModules
+ 	"Answer an Array of pairs of strings for executable modules (the VM executable and loaded libraries).
+ 	 The first element in each pair is the filename of the module.  The second element is either nil or
+ 	 the symlink's target, if the filename is a symlink."
- 	"Answer an Array of strings for executable modules (the VM executable and loaded libraries)."
  	<export: true>
  	<var: #name type: 'const char *'>
  	<var: #nameObjData type: #'char *'>
  	| resultObj |
  	numModules := 0.
  	self cCode: 'dl_iterate_phdr(countnummodules,0)' inSmalltalk: [0].
  	resultObj := interpreterProxy
  					instantiateClass: interpreterProxy classArray
+ 					indexableSize: numModules - 1 * 2. "skip the fake linux-gate.so.1"
- 					indexableSize: numModules - 1. "skip the fake linux-gate.so.1"
  	resultObj = 0 ifTrue:
  		[^interpreterProxy primitiveFailFor: PrimErrNoMemory].
  	interpreterProxy pushRemappableOop: resultObj.
  	primErr := numModules := 0.
+ 	self cCode: 'dl_iterate_phdr(reapmodulesymlinks,0)' inSmalltalk: [0].
- 	self cCode: 'dl_iterate_phdr(reapmodulenames,0)' inSmalltalk: [0].
  	resultObj := interpreterProxy popRemappableOop.
  	primErr ~= 0 ifTrue:
  		[^interpreterProxy primitiveFailFor: primErr].
  	^interpreterProxy methodReturnValue: resultObj!

Item was added:
+ ----- Method: VMProfileLinuxSupportPlugin>>reap:module:symlinks: (in category 'iteration callbacks') -----
+ reap: info module: size symlinks: ignored
+ 	"like reap:module:names:, but follows symlinks"
+ 	| elfModuleName len moduleNameObj GetAttributeString symLinkBuf |
+ 	<var: #info type: #'struct dl_phdr_info *'>
+ 	<var: 'elfModuleName' type: #'const char *'>
+ 	<var: #GetAttributeString declareC: 'extern char *GetAttributeString(sqInt)'>
+ 	<var: #symLinkBuf declareC: 'char symLinkBuf[PATH_MAX]'>
+ 	<var: #size type: #'size_t'>
+ 	<var: #ignored type: #'void *'>
+ 	self touch: GetAttributeString.
+ 	elfModuleName := self cCode: 'numModules ? info->dlpi_name : GetAttributeString(0)'.
+ 	(elfModuleName isNil
+ 	 or: [(len := self strlen: elfModuleName) = 0]) ifTrue:
+ 		[^0]. "skip the fake linux-gate.so.1"
+ 	moduleNameObj := interpreterProxy
+ 							instantiateClass: interpreterProxy classString
+ 							indexableSize: len.
+ 	moduleNameObj = 0 ifTrue:
+ 		[primErr := PrimErrNoMemory.
+ 		 ^1]. "stop iteration"
+ 	self st: (interpreterProxy arrayValueOf: moduleNameObj)
+ 		rn: elfModuleName
+ 		cpy: len. "(char *)strncpy()"
+ 	interpreterProxy
+ 		storePointer: numModules
+ 		ofObject: interpreterProxy topRemappableOop
+ 		withValue: moduleNameObj.
+ 	"now dereference the symlink, if it exists"
+ 	self str: symLinkBuf cpy: elfModuleName.
+ 	(len := self read: elfModuleName li: symLinkBuf nk: #'PATH_MAX') > 0
+ 		ifTrue:
+ 			[moduleNameObj := interpreterProxy
+ 									instantiateClass: interpreterProxy classString
+ 									indexableSize: len.
+ 			 moduleNameObj = 0 ifTrue:
+ 				[primErr := PrimErrNoMemory.
+ 				 ^1]. "stop iteration"
+ 			 self st: (interpreterProxy arrayValueOf: moduleNameObj)
+ 				rn: symLinkBuf
+ 				cpy: len. "(char *)strncpy()"
+ 			 interpreterProxy
+ 				storePointer: numModules + 1
+ 				ofObject: interpreterProxy topRemappableOop
+ 				withValue: moduleNameObj]
+ 		ifFalse:
+ 			[interpreterProxy
+ 				storePointer: numModules + 1
+ 				ofObject: interpreterProxy topRemappableOop
+ 				withValue: interpreterProxy nilObject].
+ 	numModules := numModules + 2.
+ 	^0!



More information about the Vm-dev mailing list