Skip to content

Commit

Permalink
Use TRCodeCache in test shell
Browse files Browse the repository at this point in the history
This commit makes use of `TRCodeCache` introduced in previous commit.
This is a necessary step for writing tests that compile multiple functions
and/or refer to external (relocatable) symbols.
  • Loading branch information
janvrany committed Jun 24, 2024
1 parent 14f50a3 commit d008da5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Tinyrossa-Tests/TRCompilationTestShell.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Class {
#instVars : [
'target',
'binary',
'debugger'
'debugger',
'nzone'
],
#classVars : [
'DefaultImpl'
Expand Down Expand Up @@ -92,7 +93,7 @@ TRCompilationTestShell >> initializeWithTarget: aTRCompilationTarget [
TRCompilationTestShell >> inject: compilation [
"Utility: inject compiled code into the shell"

debugger memoryAt: self nzone put: compilation codeBuffer bytes
self nzone add: compilation codeBuffer symbol: compilation functionSymbol
]

{ #category : #utilities }
Expand Down Expand Up @@ -132,7 +133,7 @@ TRCompilationTestShell >> invoke: symbol with: arguments types: argumentTypes [
self error: 'Parameter type not supported yet: ' , typ name
].
].
self debugger setRegister: 'pc' to: self nzone.
self debugger setRegister: 'pc' to: symbol address.

"Call injected function"
"
Expand All @@ -153,7 +154,18 @@ TRCompilationTestShell >> invoke: symbol with: arguments types: argumentTypes [

{ #category : #accessing }
TRCompilationTestShell >> nzone [
"Return the address of nzone. See shell.link linker script."
nzone isNil ifTrue: [
| runtime |

runtime := TRRuntime forTarget: target.
nzone := TRCodeCache runtime: runtime base: self nzoneBase size: 512 memory: debugger selectedInferior memory.
].
^ nzone
]

{ #category : #accessing }
TRCompilationTestShell >> nzoneBase [
"Return the base address of nzone. See shell.link linker script."

^ 16r00080000
]
Expand Down

0 comments on commit d008da5

Please sign in to comment.