Post by Brian FoxA question came up on Reddit /Forth by a person with an Apple M1.
They tried to use SEE but code words would not dis-assemble.
Is there anyone thinking about making one in Forth?
Could gFoRTH be made to interface to gbd in a workable way?
Gforth has had a gdb-based disassembler since 0.7. Some OSs
(e.g. Ubuntu) by default maim the ptrace system call and disasm-gdb
does not work there. On Ubuntu you can fix this with
sudo echo 0 >/proc/sys/kernel/yama/ptrace_scope
or (after the next reboot) by changing /etc/sysctl.d/10-ptrace.conf
The development version of Gforth also has Forth disassemblers for the
Here's on a A64 Ubuntu system with the fix above, using gforth-fast in
Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
see +
Code +
0x0000aaaae8bfa884 <gforth_engine+3220>: ldr x0, [x23, #8]!
0x0000aaaae8bfa888 <gforth_engine+3224>: add x25, x25, #0x8
0x0000aaaae8bfa88c <gforth_engine+3228>: add x24, x24, x0
0x0000aaaae8bfa890 <gforth_engine+3232>: ldur x2, [x25, #-8]
0x0000aaaae8bfa894 <gforth_engine+3236>: br x2
0x0000aaaae8bfa898 <gforth_engine+3240>: ldur x2, [x25, #-8]
0x0000aaaae8bfa89c <gforth_engine+3244>: br x2
0x0000aaaae8bfa8a0 <gforth_engine+3248>: br x2
0x0000aaaae8bfa8a4 <gforth_engine+3252>: mov x4, x25
0x0000aaaae8bfa8a8 <gforth_engine+3256>: ldr x0, [x4], #8
0x0000aaaae8bfa8ac <gforth_engine+3260>: add x24, x0, x24
0x0000aaaae8bfa8b0 <gforth_engine+3264>: add x25, x4, #0x8
0x0000aaaae8bfa8b4 <gforth_engine+3268>: ldur x2, [x25, #-8]
0x0000aaaae8bfa8b8 <gforth_engine+3272>: br x2
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.
end-code
Gforth 0.7.9_20230114
...
see +
Code +
AAAAADB6DF70: ldr x0, [x25,#0x8]!
AAAAADB6DF74: add x26, x26, #0x8
AAAAADB6DF78: add x27, x0, x27
AAAAADB6DF7C: ldur x1, [x26,#-0x8]
AAAAADB6DF80: br x1
end-code
ok
' disasm-gdb is discode ok
see +
Code +
0x0000aaaaadb6df70 <gforth_engine+2640>: ldr x0, [x25, #8]!
0x0000aaaaadb6df74 <gforth_engine+2644>: add x26, x26, #0x8
0x0000aaaaadb6df78 <gforth_engine+2648>: add x27, x0, x27
0x0000aaaaadb6df7c <gforth_engine+2652>: ldur x1, [x26, #-8]
0x0000aaaaadb6df80 <gforth_engine+2656>: br x1
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.
end-code
Development Gforth did not work on MacOS on Apple Silicon last time I
tried it.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2022: https://euro.theforth.net