Skip to content

Commit

Permalink
Merge pull request #24 from janvrany/pr/use-libgdbs
Browse files Browse the repository at this point in the history
Use LibGDBs also on Pharo
  • Loading branch information
janvrany authored Nov 28, 2023
2 parents e38138a + 91e7e03 commit 7b8ec78
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 26 deletions.
27 changes: 25 additions & 2 deletions pharo/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ all: build
-include GNUmakefile.local
include ../makefiles/pharo.gmk
include ../makefiles/git.gmk
include ../makefiles/mercurial.gmk

ifndef MACHINEARITHMETIC_DIR
MACHINEARITHMETIC_DIR := ../3rdparty/MachineArithmetic
Expand Down Expand Up @@ -44,29 +45,51 @@ PHARO_HACKS_BRANCH ?= master
$(eval $(call git-clone-local,PHARO_HACKS_DIR,$(PHARO_HACKS_URL),$(PHARO_HACKS_BRANCH)))
endif

ifndef PTERM_DIR
PTERM_DIR := ../3rdparty/PTerm
PTERM_URL ?= https://github.com/janvrany/PTerm
PTERM_BRANCH ?= master
$(eval $(call git-clone-local,PTERM_DIR,$(PTERM_URL),$(PTERM_BRANCH)))
endif

ifndef LIBGDBS_DIR
LIBGDBS_DIR := ../3rdparty/jv/libgdbs
LIBGDBS_URL ?= https://jan.vrany.io/hg/jv-libgdbs
LIBGDBS_BRANCH ?= default
$(eval $(call mercurial-clone-local,LIBGDBS_DIR,$(LIBGDBS_URL),$(LIBGDBS_BRANCH)))
endif

build: prereq $(PROJECT).image shells
@echo ""
@echo "To open Pharo $(PROJECT) image run:"
@echo ""
@echo " make run"
@echo ""

prereq::
$(MAKE) -C $(LIBGDBS_DIR)/ports/pharo source

$(PROJECT).image: ../src/*/*.st
$(call pharo-copy-image, $(PHARO_IMAGE), $@)
$(call pharo-load-local, $@, MachineArithmetic,$(MACHINEARITHMETIC_DIR))
$(call pharo-load-local, $@, ArchC, $(ARCHC_DIR)/src)
$(call pharo-load-local, $@, SmallRSP, $(SMALLRSP_DIR)/src)
$(call pharo-load-local, $@, LibUnix, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, LibCompat, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, LibUnix, $(PHARO_HACKS_DIR)/src)
$(call pharo-load-local, $@, PTerm, $(PTERM_DIR))
$(call pharo-load-local, $@, LibGDBs, $(LIBGDBS_DIR)/ports/pharo/src-generated)
$(call pharo-load-local, $@, Tinyrossa, ../src)

run: build
ARCHC_PDL_DIR=$(ARCHC_PDL_DIR)/ $(PHARO_VM) $(PROJECT).image

test: build
ARCHC_PDL_DIR=$(ARCHC_PDL_DIR)/ $(PHARO_VM_HEADLESS) $(PROJECT).image test --fail-on-failure \
"$(PROJECT)" \
"$(PROJECT)-Tests"
$(PROJECT) \
$(PROJECT)-Tests \
$(PROJECT)-Tests-RISCV \
$(PROJECT)-Tests-POWER

shells:
make -C ../shell
Expand Down
2 changes: 1 addition & 1 deletion src/Tinyrossa-Tests-RISCV/TRRV64GCompilationTests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TRRV64GCompilationTests >> test03_lconst_n [
VDBDebuggerApplication openFor: debugger
"
debugger c.
self assert: (debugger getRegister: 'a0') hex equals: '-7AFEAFFECAFEAFFE'.
self assert: (debugger getRegister: 'a0') equals: -16r7AFEAFFECAFEAFFE.
]

{ #category : #tests }
Expand Down
40 changes: 18 additions & 22 deletions src/Tinyrossa-Tests/TRCompilationTestShell.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -110,27 +110,21 @@ TRCompilationTestShell >> setUp [

{ #category : #'running-private' }
TRCompilationTestShell >> setUpDebuggerOnHost: host port: port [
Smalltalk isSmalltalkX ifTrue:[
"On Smalltalk/X we use jv:libgdbs to poke at shell."
(Smalltalk includesKey: #GDBDebugger) ifTrue:[
"Use LibGDBs if available..."

self assert: (Smalltalk includesKey: #GDBDebugger).

debugger := (Smalltalk at: #GDBDebugger) new.
debugger executable: binary.
debugger send: 'target remote ', host , ':' , port printString.
^self
].

Smalltalk isPharo ifTrue:[
"On Pharo, we se ULD (SmallRSP) to poke at shell."
] ifFalse:[
"...else use SmallRSP."

self assert: (Smalltalk includesKey: #RemoteGDB).

debugger := (Smalltalk at: #RemoteGDB) host: host port: port.
^self.
].

self error:'Unsupported dialect'
]

{ #category : #running }
Expand All @@ -140,23 +134,25 @@ TRCompilationTestShell >> tearDown [

{ #category : #'running-private' }
TRCompilationTestShell >> tearDownDebugger [
Smalltalk isSmalltalkX ifTrue:[
"On Smalltalk/X we use jv:libgdbs to poke at shell."
(debugger class name = #GDBDebugger) ifTrue:[
"debugger is LibGDBs' GDBDebugger..."

(debugger notNil and: [ debugger isConnected ]) ifTrue: [
| shouldQuitDebugger |

debugger send: 'kill'.
(Smalltalk includesKey: #VDBDebuggerApplication) ifTrue: [
((Smalltalk at: #VDBDebuggerApplication) allInstances allSatisfy:[:vdbApp | vdbApp debugger ~~ target]) ifTrue: [
debugger send: 'quit' andWait: false.
].

shouldQuitDebugger := (Smalltalk includesKey: #VDBDebuggerApplication) not
or:[(Smalltalk at: #VDBDebuggerApplication) allInstances allSatisfy:[:vdbApp | vdbApp debugger ~~ target]].
shouldQuitDebugger ifTrue: [
debugger send: 'quit' andWait: false.
].
].
] ifFalse:[
"debugger is either nil or SmallRSP's RemoteGDB"
debugger notNil ifTrue:[
debugger disconnect.
].

].
Smalltalk isPharo ifTrue:[
"On Pharo, we se ULD (SmallRSP) to poke at shell."

debugger disconnect.
].
debugger := nil.
]
2 changes: 1 addition & 1 deletion stx/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif

ifndef LIBGDBS_DIR
LIBGDBS_DIR := ../3rdparty/jv/libgdbs
LIBGDBS_URL ?= https://swing.fit.cvut.cz/hg/jv-libgdbs
LIBGDBS_URL ?= https://jan.vrany.io/hg/jv-libgdbs
LIBGDBS_BRANCH ?= default
$(eval $(call mercurial-clone-local,LIBGDBS_DIR,$(LIBGDBS_URL),$(LIBGDBS_BRANCH)))
endif
Expand Down

0 comments on commit 7b8ec78

Please sign in to comment.