[Vm-dev] VM Maker: Cog-eem.308.mcz
commits at source.squeak.org
commits at source.squeak.org
Sat Dec 12 01:51:10 UTC 2015
Eliot Miranda uploaded a new version of Cog to project VM Maker:
http://source.squeak.org/VMMaker/Cog-eem.308.mcz
==================== Summary ====================
Name: Cog-eem.308
Author: eem
Time: 11 December 2015, 5:50:57.59 pm
UUID: 4ac7d67f-cfe6-45d6-abc3-0b63c4771a7d
Ancestors: Cog-eem.307
Clean up disassembly and use the decorateDisassembly:for:fromAddress: form on x64 to use relativeBaseForDisassemblyInto: for method-relative pc numbering.
=============== Diff against Cog-eem.307 ===============
Item was removed:
- ----- Method: BochsIA32Alien>>decorateDisassembly:for: (in category 'disassembly') -----
- decorateDisassembly: anInstructionString for: aSymbolManager "<Cogit>"
- | string i1 i2 v |
- string := anInstructionString.
- (i1 := string indexOfSubCollection: '%ds:0x') > 0 ifTrue:
- [i2 := i1 + 6.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- string := string
- copyReplaceFrom: i1 + 4
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 4 to: i2 - 1))].
- (i1 := string indexOfSubCollection: '%ss:0x') > 0 ifTrue:
- [i2 := i1 + 6.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- ((string at: i2) = $(
- and: [(string at: i2 + 1) = $%]) ifTrue:
- [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
- string := string
- copyReplaceFrom: i1
- to: i2 - 1
- with: ((v bitAnd: (1 bitShift: 31) - 1) - (v bitAnd: (1 bitShift: 31))) printString]].
- (i1 := string indexOfSubCollection: '$0x') > 0 ifTrue:
- [i2 := i1 + 3.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- string := string
- copyReplaceFrom: i1 + 1
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
- ((i1 := string indexOf: $() > 1
- and: [(string at: i1 + 1) isDigit
- and: [i1 < (i2 := string indexOf: $))]]) ifTrue:
- [string := string
- copyReplaceFrom: i1 + 1
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
- ^string!
Item was added:
+ ----- Method: BochsIA32Alien>>decorateDisassembly:for:fromAddress: (in category 'disassembly') -----
+ decorateDisassembly: anInstructionString for: aSymbolManager "<Cogit>" fromAddress: address
+ | string i1 i2 v |
+ string := anInstructionString.
+ aSymbolManager relativeBaseForDisassemblyInto:
+ [:baseAddress :baseName|
+ string := baseName, '+', (address - baseAddress printStringBase: 16 length: 4 padded: true), (string copyFrom: (string indexOf: $:) + 1 to: string size)].
+ aSymbolManager relativeBaseForDisassemblyInto:
+ [:baseAddress :baseName| | stream delta |
+ stream := ReadStream on: string from: 1 to: string size.
+ delta := (Integer readFrom: stream base: 16) - baseAddress.
+ string := baseName, '+', (delta printStringBase: 16 length: 4 padded: true), (string copyFrom: stream position to: stream size)].
+ (i1 := string indexOfSubCollection: '%ds:0x') > 0 ifTrue:
+ [i2 := i1 + 6.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ string := string
+ copyReplaceFrom: i1 + 4
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 4 to: i2 - 1))].
+ (i1 := string indexOfSubCollection: '%ss:0x') > 0 ifTrue:
+ [i2 := i1 + 6.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ ((string at: i2) = $(
+ and: [(string at: i2 + 1) = $%]) ifTrue:
+ [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
+ string := string
+ copyReplaceFrom: i1
+ to: i2 - 1
+ with: ((v bitAnd: (1 bitShift: 31) - 1) - (v bitAnd: (1 bitShift: 31))) printString]].
+ (i1 := string indexOfSubCollection: '$0x') > 0 ifTrue:
+ [i2 := i1 + 3.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ string := string
+ copyReplaceFrom: i1 + 1
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
+ ((i1 := string indexOf: $() > 1
+ and: [(string at: i1 + 1) isDigit
+ and: [i1 < (i2 := string indexOf: $))]]) ifTrue:
+ [string := string
+ copyReplaceFrom: i1 + 1
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
+ ^string!
Item was removed:
- ----- Method: BochsX64Alien>>decorateDisassembly:for: (in category 'disassembly') -----
- decorateDisassembly: anInstructionString for: aSymbolManager "<Cogit>"
- | string i1 i2 v extra |
- string := anInstructionString.
- ((i1 := string indexOfSubCollection: '%ds:(') > 0
- or: [(i1 := string indexOfSubCollection: '%ss:(') > 0]) ifTrue:
- [string := string copyReplaceFrom: i1 to: i1 + 3 with: ''].
- (i1 := string indexOfSubCollection: '%ds:0x') > 0 ifTrue:
- [i2 := i1 + 6.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- (v := string copyFrom: i2 to: (i2 + 5 min: string size)) = '(%rbx)' ifTrue:
- [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
- (aSymbolManager lookupAddress: aSymbolManager varBaseAddress + v) ifNotNil:
- [:varName| extra := ' = ', varName]].
- v = '(%rip)' ifTrue:
- [v := string size - (string indexOf: $: startingAt: i2 + 5) - 1 / 3. "Count number of instruction bytes to find size of instruction"
- v := v + (Integer readFrom: (ReadStream on: string from: 1 to: 8) base: 16). "Add address of instruction"
- v := v + (Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16) signedIntFromLong64. "Add offset to yield pc-relative address"
- (aSymbolManager lookupAddress: v) ifNotNil:
- [:methodName| extra := ' = ', methodName]].
- string := string
- copyReplaceFrom: i1
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 4 to: i2 - 1))].
- (i1 := string indexOfSubCollection: '%ss:0x') > 0 ifTrue:
- [i2 := i1 + 6.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- ((string at: i2) = $(
- and: [(string at: i2 + 1) = $%]) ifTrue:
- [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
- string := string
- copyReplaceFrom: i1
- to: i2 - 1
- with: ((v bitAnd: (1 bitShift: 31) - 1) - (v bitAnd: (1 bitShift: 31))) printString]].
- (i1 := string indexOfSubCollection: '$0x') > 0 ifTrue:
- [i2 := i1 + 3.
- ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
- string := string
- copyReplaceFrom: i1 + 1
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
- ((i1 := string indexOf: $() > 1
- and: [(string at: i1 + 1) isDigit
- and: [i1 < (i2 := string indexOf: $))]]) ifTrue:
- [string := string
- copyReplaceFrom: i1 + 1
- to: i2 - 1
- with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1)).
- i1 := string indexOfSubCollection: '+0x'. "calls & jumps"
- i1 > 0 ifTrue:
- [v := Integer readFrom: (i2 := ReadStream on: string from: i1 + 3 to: string size) base: 16.
- v := ((v bitAnd: (1 bitShift: 63) - 1) - (v bitAnd: (1 bitShift: 63))) printStringRadix: 16.
- v := v first = $1
- ifTrue: [v copyReplaceFrom: 1 to: 3 with: '+0x']
- ifFalse: [v copyReplaceFrom: 2 to: 4 with: '0x'].
- string := string copyReplaceFrom: i1 to: i2 position with: v]].
- ^extra
- ifNil: [string]
- ifNotNil: [i1 := string lastIndexOf: $:. string copyReplaceFrom: i1 - 1 to: i1 - 2 with: extra]!
Item was added:
+ ----- Method: BochsX64Alien>>decorateDisassembly:for:fromAddress: (in category 'disassembly') -----
+ decorateDisassembly: anInstructionString for: aSymbolManager "<Cogit>" fromAddress: address
+ | string i1 i2 v extra |
+ string := anInstructionString.
+ aSymbolManager relativeBaseForDisassemblyInto:
+ [:baseAddress :baseName|
+ string := baseName, '+', (address - baseAddress printStringBase: 16 length: 4 padded: true), (string copyFrom: (string indexOf: $:) + 1 to: string size)].
+ ((i1 := string indexOfSubCollection: '%ds:(') > 0
+ or: [(i1 := string indexOfSubCollection: '%ss:(') > 0]) ifTrue:
+ [string := string copyReplaceFrom: i1 to: i1 + 3 with: ''].
+ (i1 := string indexOfSubCollection: '%ds:0x') > 0 ifTrue:
+ [i2 := i1 + 6.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ (v := string copyFrom: i2 to: (i2 + 5 min: string size)) = '(%rbx)' ifTrue:
+ [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
+ (aSymbolManager lookupAddress: aSymbolManager varBaseAddress + v) ifNotNil:
+ [:varName| extra := ' = ', varName]].
+ v = '(%rip)' ifTrue:
+ [v := string size - (string indexOf: $: startingAt: i2 + 5) - 1 / 3. "Count number of instruction bytes to find size of instruction"
+ v := v + address. "Add address of instruction"
+ v := v + (Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16) signedIntFromLong64. "Add offset to yield pc-relative address"
+ (aSymbolManager lookupAddress: v) ifNotNil:
+ [:methodName| extra := ' = ', methodName]].
+ string := string
+ copyReplaceFrom: i1
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 4 to: i2 - 1))].
+ (i1 := string indexOfSubCollection: '%ss:0x') > 0 ifTrue:
+ [i2 := i1 + 6.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ ((string at: i2) = $(
+ and: [(string at: i2 + 1) = $%]) ifTrue:
+ [v := Integer readFrom: (ReadStream on: string from: i1 + 6 to: i2 - 1) base: 16.
+ string := string
+ copyReplaceFrom: i1
+ to: i2 - 1
+ with: ((v bitAnd: (1 bitShift: 31) - 1) - (v bitAnd: (1 bitShift: 31))) printString]].
+ (i1 := string indexOfSubCollection: '$0x') > 0 ifTrue:
+ [i2 := i1 + 3.
+ ['0123456789abcdef' includes: (string at: i2)] whileTrue: [i2 := i2 + 1].
+ string := string
+ copyReplaceFrom: i1 + 1
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1))].
+ ((i1 := string indexOf: $() > 1
+ and: [(string at: i1 + 1) isDigit
+ and: [i1 < (i2 := string indexOf: $))]]) ifTrue:
+ [string := string
+ copyReplaceFrom: i1 + 1
+ to: i2 - 1
+ with: (aSymbolManager lookupCHexString: (string copyFrom: i1 + 1 to: i2 - 1)).
+ i1 := string indexOfSubCollection: '+0x'. "calls & jumps"
+ i1 > 0 ifTrue:
+ [v := Integer readFrom: (i2 := ReadStream on: string from: i1 + 3 to: string size) base: 16.
+ v := ((v bitAnd: (1 bitShift: 63) - 1) - (v bitAnd: (1 bitShift: 63))) printStringRadix: 16.
+ v := v first = $1
+ ifTrue: [v copyReplaceFrom: 1 to: 3 with: '+0x']
+ ifFalse: [v copyReplaceFrom: 2 to: 4 with: '0x'].
+ string := string copyReplaceFrom: i1 to: i2 position with: v]].
+ ^extra
+ ifNil: [string]
+ ifNotNil: [i1 := string lastIndexOf: $:. string copyReplaceFrom: i1 - 1 to: i1 - 2 with: extra]!
Item was removed:
- ----- Method: GdbARMAlien>>decorateDisassembly:for: (in category 'disassembly') -----
- decorateDisassembly: anInstructionString for: aSymbolManager
- | parts strm hexNum string |
-
- "break up the string"
- parts:= anInstructionString subStrings: ' ,:'.
- "part 1 is the address, part 2 is the instruction. Last part is sometimes a hex number"
-
- "is this a mov of a literal number?"
- ((parts at: 2) includesSubString: 'mov')
- ifTrue:[
- "clear the flags & running total"
- LongConstReg := nil.
- LongConstValue := 0.
- LongConstStep := 0.
- (parts at:4) first = $#
- ifTrue:["looks a good candidate"
- LongConstReg :=(parts at: 3). "the target register"
- (parts last beginsWith: '0x') ifTrue:[
- LongConstValue :=(NumberParser on: (parts last allButFirst:2)) nextUnsignedIntegerBase: 16].
- LongConstStep := 1].
- "not a likely candidate, just return the string"
- ^anInstructionString].
-
- "is this a build of a literal number?"
- (((parts at: 2) includesSubString: 'orr') and:[LongConstStep >0])
- ifTrue:["add to running total if the register matches"
- LongConstReg = (parts at: 3)
- ifTrue:[
- (parts at:5) first = $#
- ifTrue:["looks a good candidate with the # indicating a const - due to disassembler idiocy we have to check for both hex
- and dec values. "
- (parts last beginsWith: '0x')
- ifTrue:[ LongConstValue := LongConstValue +((NumberParser on: (parts last allButFirst:2)) nextUnsignedIntegerBase: 16)]
- ifFalse:[ LongConstValue := LongConstValue + ((NumberParser on: (parts at:5) allButFirst) nextUnsignedIntegerBase: 10) ].
- LongConstStep:= LongConstStep +1].
- LongConstStep = 4
- ifTrue:["we've completed a pattern of mov/orr/orr/orr, so print the value it built"
- ^anInstructionString, ' (', LongConstReg , ' = ', LongConstValue hex8, ((aSymbolManager lookupAddress: LongConstValue) ifNil: [''] ifNotNil:[:val| ' = ', val]), ')']]
- ifFalse:[ LongConstStep := 0.
- LongConstReg := nil.
- LongConstValue := 0].
- "either not a likely candidate orpartway through the pattern, so just return the string"
- ^anInstructionString].
-
-
- strm :=anInstructionString readStream.
- strm skip: 9. "the instruction address"
-
- strm upToAll: '0x'. "see if there is a hex number"
- strm atEnd ifTrue:[^anInstructionString]. "if not, leave it be"
-
- "extract the number"
- hexNum := (NumberParser on: strm) nextUnsignedIntegerBase: 16.
- "is there an intersting address with this?"
- (string := aSymbolManager lookupAddress: hexNum) ifNil: [^anInstructionString].
- ^ anInstructionString, ' = ', string!
More information about the Vm-dev
mailing list